wugg před 2 roky
rodič
revize
aef3f80edb
1 změnil soubory, kde provedl 45 přidání a 32 odebrání
  1. 45 32
      app/txx/controller/Good.php

+ 45 - 32
app/txx/controller/Good.php

@@ -55,6 +55,8 @@ class Good extends BaseController
 		if($isActExit==false) return json_show(1005,"未找到活动有效数据");
 
 		$actGood=new ActGood();
+		$yzgood= new YzGood();
+		$yzadd = $yzgood->where(["item_no"=>array_column($snArr, 'skuCode'),"is_del"=>0])->column('detail_url,origin', 'item_no');
 		Db::startTrans();
 		try{
 			$data=[];
@@ -70,7 +72,9 @@ class Good extends BaseController
 					"apply_id"=>$this->uid,
 					"apply_name"=>$this->uname,
 					"roundId"=>$item['roundId']??"",
-					"status"=>0,
+					"good_url"=>$yzadd[$item['skuCode']]?$yzadd[$item['skuCode']]['detail_url']??"":"",
+					"origin_price"=>$yzadd[$item['skuCode']]?$yzadd[$item['skuCode']]['origin']??"":"",
+					"status"=>1,
 					"addtime"=>date("Y-m-d H:i:s"),
 					"updatetime"=>date("Y-m-d H:i:s")
 					];
@@ -147,11 +151,11 @@ class Good extends BaseController
        if($this->request->isCx==1){
        	$field="a.id,a.actCode,a.yz_good_code,a.apply_id,a.apply_name,a.stock_num,a.used_num,a.balance_num,a.status,
       a.addtime,a.updatetime,c.plat_code,b.act_name,b.company_name,b.contactor,b.mobile,b.startTime,b.endTime,
-     c.final_price,c.desc,d.good_name,d.good_unit,c.yz_cat_id,d.cat_id,a.roundId,d.brand_id";
+     c.final_price,c.desc,d.good_name,d.good_unit,c.yz_cat_id,d.cat_id,a.roundId,d.brand_id,a.origin_price,a.good_url";
        }else{
 		$field="a.id,a.actCode,a.yz_good_code,a.stock_num,a.used_num,a.balance_num,a.status,a.addtime,a.updatetime,
 		b.act_name,b.company_name,b.contactor,b.mobile,b.startTime,b.endTime,c.final_price,c.desc,d.good_name,
-		d.good_unit,d.cat_id,d.brand_id,a.roundId";
+		d.good_unit,d.cat_id,d.brand_id,a.roundId,a.origin_price,a.good_url";
        }
       $count =$actm->alias("a")
       ->leftJoin("act b","a.actCode=b.actCode")
@@ -172,13 +176,9 @@ class Good extends BaseController
             ->whereIn('id', array_column($list, 'brand_id'))
             ->column('brand_name', 'id');
          $unit = Db::name("unit")->where(["id" => array_column($list, 'good_unit')])->column('unit', 'id');
-            $value['unit'] = isset($unit['unit']) ? $unit['unit'] : "";
-	 $yzgood =new YzGood();
       foreach ($list as &$item){
 		$item['unit'] =$unit[$item['good_unit']] ?? "";
 		$item['brand_name'] = $all_brand[$item['brand_id']]?? "";
-		$item['web_url_num'] = Db::name("act_goodurl")->where(["act_good_id"=>$item['id'],"is_del"=>0])->count();
-	 $item['origin_price'] =$yzgood->where(["item_no"=>$item['yz_good_code'],"is_del"=>0])->value("origin",'');
 		if($this->request->isCx==1){
 			$item['cat_info'] = made($item['cat_id'], []);
 		}else{
@@ -209,6 +209,8 @@ class Good extends BaseController
 //	    $roundId= $post['roundId']!=''? trim($post['roundId']):"";
 //	    if($roundId=='') return json_show(1004,"参数错误 roundId 不能为空");
 		$actGood=new ActGood();
+		$yzgood= new YzGood();
+		$yzadd = $yzgood->where(["item_no"=>array_column($snArr, 'yz_good_code'),"is_del"=>0])->column('detail_url,origin', 'item_no');
 		Db::startTrans();
 		try{
 			$data=[];
@@ -221,6 +223,8 @@ class Good extends BaseController
 					"stock_num"=>$item['stock_num'],
 					"balance_num"=>$item['stock_num'],
 					"roundId"=>$item['roundId']??"",
+					"good_url"=>$yzadd[$item['yz_good_code']]?$yzadd[$item['yz_good_code']]['detail_url']??"":"",
+					"origin_price"=>$yzadd[$item['yz_good_code']]?$yzadd[$item['yz_good_code']]['origin']??"":"",
 					"is_del"=>$item['is_del']??0,
 					"updatetime"=>date("Y-m-d H:i:s")
 					];
@@ -253,11 +257,11 @@ class Good extends BaseController
     	 if($this->request->isCx==1){
        	    $field="a.id,a.actCode,a.yz_good_code,a.apply_id,a.apply_name,a.stock_num,a.used_num,a.balance_num,a.status,
             a.addtime,a.updatetime,c.plat_code,b.act_name,b.company_name,b.contactor,b.mobile,b.startTime,b.endTime,
-            c.final_price,c.desc,d.good_name,d.good_unit,c.yz_cat_id,d.cat_id,d.brand_id,a.roundId";
+            c.final_price,c.desc,d.good_name,d.good_unit,c.yz_cat_id,d.cat_id,d.brand_id,a.roundId,a.origin_price,a.good_url";
 	       }else{
 			$field="a.id,a.actCode,a.yz_good_code,a.stock_num,a.used_num,a.balance_num,a.status,a.addtime,a.updatetime,
 			b.act_name,b.company_name,b.contactor,b.mobile,b.startTime,b.endTime,c.final_price,c.desc,d.good_name,
-			d.good_unit,d.cat_id,d.brand_id,a.roundId";
+			d.good_unit,d.cat_id,d.brand_id,a.roundId,a.origin_price,a.good_url";
             }
     	$actm=new ActGood();
     	$info=$actm->alias("a")
@@ -444,9 +448,11 @@ class Good extends BaseController
      //获取跟有赞对接的平台所属的商品上线信息
     public function listByYz()
     {
+
     	 $this->noble=\think\facade\Config::get("noble");
         $order=\think\facade\Config::get("order");
         $this->acton=$order['order_type'];
+
         $param = $this->request->only([
             'page' => 1,
             'size' => 15,
@@ -494,20 +500,31 @@ class Good extends BaseController
             ->where($where)
             ->page(intval($param['page']),intval($param['size']))
             ->order("b.addtime desc")
-            ->select()
-            ->toArray();
-        $all_createrid = array_column($list,'purchase_id');
-        $item = get_company_name_by_uid($all_createrid);
+            ->select()->toArray();
         $data = [];
         $yzgood = new YzGood();
+
+         //6.补充数据,照搬list方法t
+		    $all_brand = Db::name('brand')
+		                   ->where('is_del', 0)
+		                   ->whereIn('id', array_column($list, 'brand_id'))
+		                   ->column('brand_name', 'id');
+		    $yzadd = $yzgood->where(["item_no"=>array_column($list, 'skuCode'),"is_del"=>0])->column('detail_url,origin', 'item_no');
+		    $unit = Db::name("unit")->where(["id" => array_column($list, 'good_unit')])->column('unit', 'id');
+		    if($this->request->isCx==1){
+			    $all_platform =Db::name("platform")->field('id,platform_name')->where(["id" =>array_column($list, 'platform_code')])->column('platform_name', 'id');
+			    $all_supplier = Db::name("supplier")->where(["code" =>array_column($list, 'supplierNo')])->column("name","code");
+			    $itemid_all =Db::name("depart_user")->where(["uid"=>array_column($list, 'purchase_id'),"is_del"=>0])->column("itemid",'uid');
+		    }
         foreach ($list as $value) {
-            $brand = Db::name("brand")->field('id,brand_name')->where(["id" => $value['brand_id']])->find();
-            $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
+//            $brand = Db::name("brand")->field('id,brand_name')->where(["id" => $value['brand_id']])->find();
+            $value["brand_name"] = $all_brand[$value['brand_id']]??"";
 
-            $unit = Db::name("unit")->field('id,unit')->where(["id" => $value['good_unit']])->find();
-            $value['unit'] = isset($unit['unit']) ? $unit['unit'] : "";
+//            $unit = Db::name("unit")->field('id,unit')->where(["id" => $value['good_unit']])->find();
+            $value['unit'] = $unit[$value['good_unit']]??"";
 		    $value['exam_status'] = $value['exam_status']==6?1:0;
-            $value['origin_price'] =$yzgood->where(["item_no"=>$value['skuCode'],"is_del"=>0])->value("origin",'');
+            $value['origin_price'] =$yzadd[$value['skuCode']]? $yzadd[$value['skuCode']]['origin']??"":"";
+            $value['good_url'] =$yzadd[$value['skuCode']]? $yzadd[$value['skuCode']]['detail_url']??"":"";
 
             $spec = Db::name("good_spec")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->select()->toArray();
             $speclist = [];
@@ -528,19 +545,18 @@ class Good extends BaseController
             $value['good_thumb_img']=str_replace($this->origin_img_host,$this->ssl_img_host,$value['good_img']);
             if($this->request->isCx==1){
         	$value['cat_info'] = made($value['cat_id'], []);
-            $platform = Db::name("platform")->field('id,platform_name')->where(["id" => $value['platform_code']])->find();
-            $value['platform_name'] = isset($platform['platform_name']) ? $platform['platform_name'] : "";
-            $value['platform_code_en'] = isset($platform['platform_code_en']) ? $platform['platform_code_en'] : "";
-            $supplier = Db::name("supplier")->field('id,name')->where(["code" => $value['supplierNo']])->find();
-            $value['supplier_name'] = isset($supplier['name']) ? $supplier['name'] : "";
-            $value['company'] = isset($company['company']) ? $company['company'] : "";
+//            $platform = Db::name("platform")->field('id,platform_name')->where(["id" => $value['platform_code']])->find();
+            $value['platform_name'] = $all_platform[$value['platform_code']]??"";
+//            $value['platform_code_en'] = isset($platform['platform_code_en']) ? $platform['platform_code_en'] : "";
+//            $supplier = Db::name("supplier")->field('id,name')->where(["code" => $value['supplierNo']])->find();
+            $value['supplier_name'] = $all_supplier[$value['supplierNo']]??"";
+//            $value['company'] = isset($company['company']) ? $company['company'] : "";
             $value['stock_total'] = Db::name("good_stock")->where(['spuCode' => $value['spuCode'], "is_del" => 0])->sum("usable_stock");
             $value['exclusive'] = makeExcluse($value['is_exclusive']);
             $value['noble_name'] = isset($value['noble_metal']) && $value['noble_metal'] != 0 ? $this->noble[$value['noble_metal']] : "";
-//            $itemid =Db::name("depart_user")->where(["uid"=>$value["purchase_id"],"is_del"=>0])->value("itemid",'');
-            $value['company_name'] = $item[$value['purchase_id']]??'';
+            $value['company_name'] = implode('/', array_column(GetPart($itemid_all[$value['purchase_id']]), 'name'));
         	}else{
-            	unset($value['brand_id']);
+            unset($value['brand_id']);
 			unset($value['good_unit']);
 			unset($value['spuCode']);
         	}
@@ -614,11 +630,8 @@ class Good extends BaseController
             $info['stock_total'] = Db::name("good_stock")->where(['spuCode' => $info['spuCode'], "is_del" => 0])->sum("usable_stock");
             $info['exclusive'] = makeExcluse($info['is_exclusive']);
             $info['noble_name'] = isset($info['noble_metal']) && $info['noble_metal'] != 0 ? $this->noble[$info['noble_metal']] : "";
-//            $itemid =Db::name("depart_user")->where(["uid"=>$info["purchase_id"],"is_del"=>0])->value("itemid",'');
-
-            $item = get_company_name_by_uid($info["purchase_id"]);
-            $info['company_name'] = $item??'';
-
+            $itemid =Db::name("depart_user")->where(["uid"=>$info["purchase_id"],"is_del"=>0])->value("itemid",'');
+            $info['company_name'] = implode('/', array_column(GetPart($itemid), 'name'));
         	}else{
 	    	unset($info['brand_id']);
 		    unset($info['good_unit']);