where($where1)->field('store_id')->find(); if ($store_res)//新版 { $getstoreid=$store_res['store_id']; $getpattern=tpCache('distribut.pattern', $getstoreid);//分销模式 $first_rate=tpCache('distribut.first_rate', $getstoreid);//分销模式 $second_rate=tpCache('distribut.second_rate', $getstoreid);//分销模式 $third_rate=tpCache('distribut.third_rate', $getstoreid);//分销模式 if ($getpattern=="") { $getpattern=0; } if ($first_rate=="") { $first_rate=0; } if ($second_rate=="") { $second_rate=0; } if ($third_rate=="") { $third_rate=0; } $where['store_id'] = $store_res['store_id']; if ($postjson['wareno']) { $where['a.goods_sn'] =array('like','%'.$postjson['wareno'].'%'); } if ($postjson['sku']) { $where['a.sku'] = $postjson['sku']; } $count = D('goods')->alias("a") ->where($where)->count(); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $fiedlist = "a.goods_id,a.erpwareid,a.goods_sn as WareNo,a.goods_name as WareName,a.sku as BarCode,b.name as ClassName,a.cat_id as ClassId,c.name as BrandName,a.brand_id as BrandId,d.name as NationName,a.nation_id as NationId,a.goods_spec as SpecName,a.goods_unitname as UnitName,a.goods_color as ColorName,a.weight as Weight,a.store_count as WebStoQty,a.market_price as PosPrice,a.shop_price as WebPrice,a.goods_content as WebContent"; if ($getpattern==1) { $fiedlist.=",1 as Pattern,a.fir_rate,a.sec_rate,a.thi_rate"; } else{ $fiedlist.=",0 as Pattern,$first_rate as fir_rate ,$second_rate as sec_rate, $third_rate as thi_rate"; } $res = M('goods')->alias("a") ->join('(select id,name from wxd_goods_category where store_id='.$getstoreid.') b','a.cat_id=b.id','left') ->join('(select id,name from wxd_brand where store_id='.$getstoreid.') c','a.brand_id=c.id','left') ->join('(select id,name from wxd_nation where store_id='.$getstoreid.') d','a.nation_id=d.id','left') ->where($where)->field($fiedlist)->limit($Page->firstRow . ',' . $Page->listRows) ->order('a.goods_sn asc')->select(); if ($res) { $jsonres["STATE"] = 1; $jsonres["version"] = 3.0; $jsonres["RECCOUNT"] = $count; $SUMPAGE=$Page->totalPages; $jsonres["SUMPAGE"] = $SUMPAGE; $jsonres["MSG"] = "SUCCESS"; foreach ($res as $k => $v) { $imglist = M('goods_images')->where('goods_id', $v['goods_id'])->field('image_url as ImgUrl')->order('ismain desc')->select(); if ($imglist) { foreach ($imglist as $k1 => $v1) { $imglist[$k1]["ImgUrl"]= QCLOUD_IMGURL.$v1['ImgUrl']; } } $res[$k]['imglist']=$imglist; } $jsonres["ITEMS"]=$res; } else { $jsonres["STATE"] = -1; $jsonres["MSG"] = "没有相关数据"; } } else { //old $oldres = httpRequest(IMPORT_URL . "/API/CustInfo.ashx?method=getgoodslist_ylp&pagesize=".$pagenum."&pagenumber=".I('p'),'POST',$postStr,array(),false,30); if ($oldres) { $oldres = json_decode($oldres, true); $jsonres["STATE"] = 1; $jsonres["version"] = 2.0; $jsonres["RECCOUNT"] = $oldres['total']; $jsonres["SUMPAGE"] = $oldres['page']; $jsonres["MSG"] = "SUCCESS"; $jsonres["ITEMS"] = $oldres['data']["ITEMS"]; } else { $jsonres["STATE"] = -1; $jsonres["msg"] = "获取失败001"; } //old end } } else { $jsonres["STATE"] = -1; $jsonres["MSG"] = "传递有误"; } } catch (Exception $ex) { $jsonres["STATE"] = -1; $jsonres["MSG"] = "异常出错"; } return json_encode($jsonres); } /*根据ACCDB获取商品类品牌*/ public function getbrandlist() { // try { $postStr = file_get_contents("php://input"); if (empty($postStr)) { $postStr = isset($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : ""; } // $postStr="{\"accdb\":\"ppt\",\"pagenum\":\"10\"}"; if ($postStr) { $postjson = json_decode($postStr, true); $pagenum = $postjson['pagenum']; $pagenum = 100; if ($postjson['pagenum']) { $pagenum = $postjson['pagenum']; } $ACCDB = $postjson['accdb']; if ($ACCDB) { $where1['ERPId'] = $ACCDB; $where1['is_audit'] = 1; } $store_res = M('store')->where($where1)->field('store_id')->find(); if ($store_res)//新版 { $getstoreid=$store_res['store_id']; $where['a.store_id'] = $store_res['store_id']; $count = D('brand')->alias("a") ->where($where)->count(); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $fiedlist = "a.id,a.name,a.logo,a.is_hot as isshow"; $res = M('brand')->alias("a")->where($where)->field($fiedlist) ->limit($Page->firstRow . ',' . $Page->listRows) ->order('a.sort asc') ->select(); if ($res) { foreach ($res as $k => $v) { $res[$k]['logo']= QCLOUD_IMGURL.$v['logo']; } $jsonres["STATE"] = 1; $jsonres["RECCOUNT"] = $count; $SUMPAGE=$Page->totalPages; $jsonres["version"] = 3.0; $jsonres["MSG"] = "SUCCESS"; $jsonres["ITEMS"]=$res; } else { $jsonres["STATE"] = -1; $jsonres["MSG"] = "没有相关数据"; } } else{ //old $oldres = httpRequest(IMPORT_URL . "/API/CustInfo.ashx?method=getbrandlist_ylp&type=2&pagesize=".$pagenum."&pagenumber=".I('p'),'POST',$postStr,array(),false,30); if ($oldres) { $oldres = json_decode($oldres, true); $jsonres["STATE"] = 1; $jsonres["version"] =2.0; $jsonres["RECCOUNT"] = $oldres['total']; $jsonres["SUMPAGE"] = $oldres['page']; $jsonres["MSG"] = "SUCCESS"; $jsonres["ITEMS"] = $oldres['data']["ITEMS"]; } else { $jsonres["STATE"] = -1; $jsonres["msg"] = "获取失败001"; } //old end } } return json_encode($jsonres); } /*根据ACCDB获取商品国家*/ public function getnationlist() { // try { $postStr = file_get_contents("php://input"); if (empty($postStr)) { $postStr = isset($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : ""; } // $postStr="{\"accdb\":\"mkm\",\"pagenum\":\"10\"}"; if ($postStr) { $postjson = json_decode($postStr, true); $pagenum = $postjson['pagenum']; $pagenum = 100; if ($postjson['pagenum']) { $pagenum = $postjson['pagenum']; } $ACCDB = $postjson['accdb']; if ($ACCDB) { $where1['ERPId'] = $ACCDB; $where1['is_audit'] = 1; } $store_res = M('store')->where($where1)->field('store_id')->find(); if ($store_res)//新版 { $getstoreid=$store_res['store_id']; $where['a.store_id'] = $store_res['store_id']; $count = D('nation')->alias("a") ->where($where)->count(); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $fiedlist = "a.id,a.name,a.logo,a.is_hot as isshow"; $res = M('nation')->alias("a")->where($where)->field($fiedlist) ->limit($Page->firstRow . ',' . $Page->listRows) ->order('a.sort asc') ->select(); if ($res) { foreach ($res as $k => $v) { $res[$k]['logo']= QCLOUD_IMGURL.$v['logo']; } $jsonres["STATE"] = 1; $jsonres["RECCOUNT"] = $count; $SUMPAGE=$Page->totalPages; $jsonres["version"] = 3.0; $jsonres["MSG"] = "SUCCESS"; $jsonres["ITEMS"]=$res; } else { $jsonres["STATE"] = -1; $jsonres["MSG"] = "没有相关数据"; } } else{ $oldres = httpRequest(IMPORT_URL . "/API/CustInfo.ashx?method=getbrandlist_ylp&type=3&pagesize=".$pagenum."&pagenumber=".I('p'),'POST',$postStr,array(),false,30); if ($oldres) { $oldres = json_decode($oldres, true); if ($oldres['code']==0) { $jsonres["STATE"] = 1; $jsonres["version"] = 2.0; $jsonres["RECCOUNT"] = $oldres['total']; $jsonres["SUMPAGE"] = $oldres['page']; $jsonres["MSG"] = "SUCCESS"; $jsonres["ITEMS"] = $oldres['data']["ITEMS"]; }else{ $jsonres["STATE"] = -1; $jsonres["msg"] = $oldres['msg']; } } else { $jsonres["STATE"] = -1; $jsonres["msg"] = "获取失败001"; } } } else { $jsonres["STATE"] = -1; $jsonres["msg"] = "POST为空"; } return json_encode($jsonres); } /*根据ACCDB获取商品类别*/ public function getcatlist() { // try { $postStr = file_get_contents("php://input"); if (empty($postStr)) { $postStr = isset($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : ""; } // $postStr="{\"accdb\":\"xym\",\"pagenum\":\"10\"}"; if ($postStr) { $postjson = json_decode($postStr, true); $pagenum = $postjson['pagenum']; $pagenum = 100; if ($postjson['pagenum']) { $pagenum = $postjson['pagenum']; } $ACCDB = $postjson['accdb']; if ($ACCDB) { $where1['ERPId'] = $ACCDB; $where1['is_audit'] = 1; } $store_res = M('store')->where($where1)->field('store_id')->find(); if ($store_res)//新版 { $getstoreid=$store_res['store_id']; $where['a.store_id'] = $store_res['store_id']; $count = D('goods_category')->alias("a") ->where($where)->count(); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $fiedlist = "a.id,a.name,a.parent_id,a.image as logo,a.is_show as isshow"; $res = M('goods_category')->alias("a")->where($where)->field($fiedlist) ->limit($Page->firstRow . ',' . $Page->listRows) ->order('parent_id asc,level asc,sort_order asc') ->select(); if ($res) { foreach ($res as $k => $v) { $res[$k]['logo']= QCLOUD_IMGURL.$v['logo']; } $jsonres["STATE"] = 1; $jsonres["RECCOUNT"] = $count; $SUMPAGE=$Page->totalPages; $jsonres["version"] = 3.0; $jsonres["MSG"] = "SUCCESS"; $jsonres["ITEMS"]=$res; } else { $jsonres["STATE"] = -1; $jsonres["MSG"] = "没有相关数据"; } } else{ $oldres = httpRequest(IMPORT_URL . "/API/CustInfo.ashx?method=getbrandlist_ylp&type=1&pagesize=".$pagenum."&pagenumber=".I('p'),'POST',$postStr,array(),false,30); if ($oldres) { $oldres = json_decode($oldres, true); if ($oldres['data']) { $jsonres["STATE"] = 1; $jsonres["version"] = 2.0; $jsonres["RECCOUNT"] = $oldres['total']; $jsonres["SUMPAGE"] = $oldres['page']; $jsonres["MSG"] = "SUCCESS"; $jsonres["ITEMS"] = $oldres['data']["ITEMS"]; } else { $jsonres["STATE"] = -1; $jsonres["msg"] = "获取失败001"; } } else{ $jsonres["STATE"] = -1; $jsonres["msg"] = "获取失败002"; } } } else { $jsonres["STATE"] = -1; $jsonres["msg"] = "未获取参数"; } return json_encode($jsonres); } //美妆图库 public function getskuinfo() { $postStr = file_get_contents("php://input"); if (empty($postStr)) { $postStr = isset($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : ""; } // $postStr="{\"sku\":\"6954776300762\"}"; if (empty($postStr)) { $jsonres["STATE"] = -1; $jsonres["msg"] = "未获取参数"; return json_encode($jsonres); } $postjson = json_decode($postStr, true); $sku=$postjson['sku']; if (empty($sku)) { $jsonres["STATE"] = -1; $jsonres["msg"] = "SKU不能为空"; return json_encode($jsonres); } //过滤掉ppt、tpty、cdzy $res = M('barcodegoods')->where("sku='" . $sku ."' and store_id not in(1,23,39) and goods_content is not null")->find(); if (empty($res)) { return json(['STATE' => -1, 'msg' => '美妆图库还没有记录']); } $img = M('barcodegoods_images')->where(['goods_id' => $res['goods_id'], 'ismain' => 0])->select(); return json(['STATE' => 1, 'msg' => '获取成功', 'des' => $res, 'img' => $img]); } //会员统计 public function getviplist() { // try { $postStr = file_get_contents("php://input"); if (empty($postStr)) { $postStr = isset($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : ""; } // $postStr="{\"accdb\":\"ppt\",\"pagenum\":\"10\"}"; if (empty($postStr)) { $jsonres["STATE"] = -1; $jsonres["msg"] = "未获取参数"; return json_encode($jsonres); } $postjson = json_decode($postStr, true); $pagenum = $postjson['pagenum']; $pagenum = 100; if ($postjson['pagenum']) { $pagenum = $postjson['pagenum']; } $ACCDB = $postjson['accdb']; if ($ACCDB) { $where1['ERPId'] = $ACCDB; $where1['is_audit'] = 1; } $store_res = M('store')->where($where1)->field('store_id')->find(); if ($store_res)//新版 { $getstoreid = $store_res['store_id']; $where['a.store_id'] = $store_res['store_id']; $where['a.mobile'] = array('neq', ''); $count = D('users')->alias("a") ->where($where)->count(); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $fiedlist = "a.vipname,a.mobile,ifnull(b.pickup_no,'') pickup_no,a.is_distribut,ifnull(c.mobile,'') as fromuser_mobile"; $res = M('users')->alias("a")->where($where)->field($fiedlist) ->join('pick_up b', 'a.pickup_id=b.pickup_id', 'left') ->join('(select mobile,user_id from wxd_users where store_id=' . $store_res['store_id'] . ' and mobile<>"" ) c', 'a.fromuser_id=c.user_id', 'left') ->limit($Page->firstRow . ',' . $Page->listRows) ->order('a.user_id asc') ->select(); if ($res) { $jsonres["STATE"] = 1; $jsonres["RECCOUNT"] = $count; $SUMPAGE = $Page->totalPages; $jsonres["version"] = 3.0; $jsonres["MSG"] = "SUCCESS"; $jsonres["ITEMS"] = $res; } else { $jsonres["STATE"] = -1; $jsonres["MSG"] = "没有相关数据"; } } else { $jsonres["STATE"] = -1; $jsonres["MSG"] = "找不到相关账套信息"; } return json_encode($jsonres); } }