Browse Source

Merge branch 'master-new-wgg' of wugg/phpstock into master-new

wugg 1 year ago
parent
commit
30cac40f98

+ 12 - 6
app/admin/controller/Activity.php

@@ -181,7 +181,7 @@ class Activity extends Base
         $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] !== "" ? trim($this->post['supplierNo']) : "";
         if ($supplierNo != "") $where[] = ['a.supplierNo', "like", "%$supplierNo%"];
         $name = isset($this->post['name']) && $this->post['name'] !== "" ? trim($this->post['name']) : "";
-        if ($name != "") $where[] = ['b.name', "like", "%$name%"];
+        if ($name != "") $where[] = ['a.supplierName', "like", "%$name%"];
         $start = isset($this->post['start']) && $this->post['start'] !== "" ? trim($this->post['start']) : "";
         if ($start != "") $where[] = ['a.addtime', ">=", $start];
         $end = isset($this->post['end']) && $this->post['end'] !== "" ? trim($this->post['end']) : "";
@@ -192,7 +192,6 @@ class Activity extends Base
 
         $count = Db::name('good_zixun')
             ->alias("a")
-            ->join("supplier b","b.code=a.supplierNo","left")
             ->where($where)
             ->count();
         $total = ceil($count / $size);
@@ -224,20 +223,27 @@ class Activity extends Base
         $all_code = array_merge(array_column($list,'supplierNo'),array_column($list,'companyNo'));
         $userCommon = \app\admin\common\User::getIns();
         $tmp = $userCommon->handle('getCodeAndName',['code'=>$all_code]);
+        $depart = get_company_name_by_uid( array_unique(array_column($list,'order_createrid')));
 
 //halt($list);
         $data=[];
         //分类/规格/品牌 等字段取出对应文字
+        $goodbasice = Db::name('good_basic')->where(['spuCode'=>array_column($list,"spuCode")])->column('status',"spuCode");
+        $good_online = Db::name('good_platform')->where(['spuCode'=>array_column($list,"spuCode")])->column('id',"spuCode");
         foreach ($list as $value){
             $value['cat_info']= made($value['cat_id'],[]);
-//            $platform = Db::name("platform")->where(["id"=>$value['platform_id']])->find();
+            $value['is_basic']=$goodbasice[$value['spuCode']]??null;
+            $value['order_creater_depart']=$depart[$value['order_createrid']]??'';
+            
+            $value['is_online']=isset($good_online[$value['spuCode']])?1:0;
+
             $value['platform_name'] = $all_platform[$value['platform_id']]??'';//isset($platform['platform_name']) ? $platform['platform_name']:"";
             $value['platform_code_en'] = '';//isset($platform['platform_code_en']) ? $platform['platform_code_en']:"";
-//            $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
+
             $value['supplier_name'] = $tmp[$value['supplierNo']] ?? '';//isset($supplier['name']) ? $supplier['name']:"";
-//            $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
+
             $value["brand_name"]=$all_brand[$value['brand_id']]??'';//isset($brand['brand_name'])?$brand['brand_name']:"";
-//            $unit = Db::name("unit")->where(["id"=>$value['good_unit']])->find();
+
             $value['unit'] =$all_unit[$value['good_unit']]??'';//isset($unit['unit'])?$unit['unit']:"";
 //            $company = Db::name("business")->where(["companyNo"=>$value['companyNo']])->find();
             $value['company'] = $tmp[$value['companyNo']]??'';//isset($company['company'])?$company['company']:"";

+ 1 - 7
app/admin/controller/Check.php

@@ -27,15 +27,9 @@ public function __construct(App $app)
         $condtion = [['b.is_del', "=", 0], ['c.is_del', "=", 0]];
         $wsmcode = isset($this->post['wsm_code']) && $this->post['wsm_code'] !== "" ? trim($this->post['wsm_code']) : "";
         if ($wsmcode !== "") {
-            //return error_show(1002,"仓库code不能为空");
             $condtion[] = ['c.wsm_code', "=", $wsmcode];
-            // $typecode= Db::name("good_stock")->where(["wsm_code"=>$wsmcode,'is_del'=>0])->column("good_type_code");
         }
-
-//    $good_code =isset($this->post['type_code']) &&$this->post['type_code'] !=="" ? trim($this->post['type_code']):"";
-//    if($good_code!=""){
-//        $condtion[]=['b.type_code',"=",$good_code];
-//    }
+        
         $goodcode = isset($this->post['good_code']) && $this->post['good_code'] !== "" ? trim($this->post['good_code']) : "";
         if ($goodcode != "") {
             // $condtion['a.good_code'] = Db::raw("like '%{$goodcode}%'");

+ 4 - 26
app/admin/controller/DataGroup.php

@@ -46,7 +46,7 @@ class DataGroup extends Base
             });
         }
         if ($param['type'] != '') $rs->where('a.type', $param['type']);
-        if ($param['supplierNo'] != '') $rs->where('a.supplierNo', '%' . $param['supplierNo'], '%');
+//        if ($param['supplierNo'] != '') $rs->where('a.supplierNo', '%' . $param['supplierNo'], '%');
 
         $count = $rs->count('a.id');
 
@@ -68,7 +68,7 @@ class DataGroup extends Base
         $param = $this->request->filter('trim')->only(['title', 'uids', 'type', 'remark' => '', 'supplierNo']);
 
         $val = Validate::rule([
-            'supplierNo|公司名称' => 'require|length:18',
+//            'supplierNo|公司名称' => 'require|length:18',
             'title|用户组名称' => 'require|max:100',
             'uids|组成员' => 'require|array|max:100',
             'type|共享类型' => 'require|number|in:' . DataGroupModel::$type_可编辑 . ',' . DataGroupModel::$type_只读 . ',' . DataGroupModel::$type_不共享,
@@ -82,7 +82,7 @@ class DataGroup extends Base
 
             //添加用户组
             $group_id = Db::name('data_group')->insertGetId([
-                'supplierNo' => $param['supplierNo'],
+//                'supplierNo' => $param['supplierNo'],
                 'title' => $param['title'],
                 'type' => $param['type'],
                 'remark' => $param['remark'],
@@ -279,34 +279,12 @@ class DataGroup extends Base
     //用户组列表(全部)
     public function getDataGroupListAll()
     {
-//        $param = $this->request->filter('trim')->only(['status' => '', 'title' => '', 'type' => '']);
 
-        $db = new DataGroupModel();
-
-//        $rs = $db
-//            ->alias('a')
-//            ->leftJoin('data_group_userid b', 'b.data_group_id=a.id AND b.is_del=' . DataGroupModel::$delete_正常)
-//            ->leftJoin('depart_user u', 'u.uid=b.uid AND u.is_del=0')
-//            ->group('a.id')
-//            ->where('a.is_del', DataGroupModel::$delete_正常);
-
-//        $val = Validate::rule([
-//            'status|状态' => 'number|in:' . DataGroupModel::$status_启用 . ',' . DataGroupModel::$status_禁用,
-//            'title|用户组名称' => 'max:100',
-////            'nickname|成员名称' => 'max:100',
-//            'type|共享类型' => 'number|in:' . DataGroupModel::$type_可编辑 . ',' . DataGroupModel::$type_只读 . ',' . DataGroupModel::$type_不共享,
-//        ]);
 
-//        if (!$val->check($param)) return error_show(1005, $val->getError());
-
-//        if ($param['status'] != '') $rs->where('a.status', $param['status']);
-//        if ($param['title'] != '') $rs->whereLike('a.title', '%' . $param['title'] . '%');
-//        if ($param['nickname'] != '') $rs->whereLike('u.nickname', '%' . $param['nickname'] . '%');
-//        if ($param['type'] != '') $rs->where('a.type', $param['type']);
+        $db = new DataGroupModel();
 
         $list = $db
             ->where('is_del', DataGroupModel::$delete_正常)
-//            ->field('a.*,GROUP_CONCAT(u.nickname) nickname')
             ->field('id,title,status')
             ->order('id', 'desc')
             ->select()

+ 11 - 2
app/admin/controller/Good.php

@@ -57,6 +57,10 @@ class Good extends Base
         if($is_stock!==""){
             $where[]=['a.is_stock',"=",$is_stock];
         }
+        $create_source = isset($this->post['create_source']) && $this->post['create_source'] !=='' ? intval($this->post['create_source']) :'';
+        if($create_source!==''){
+            $where[]=['a.create_source','=',$create_source];
+        }
         $good_type = isset($this->post['good_type']) && $this->post['good_type'] !=="" ? intval($this->post['good_type']) :"";
         if($good_type!==""){
             $where[]=['a.good_type',"=",$good_type];
@@ -131,7 +135,7 @@ class Good extends Base
         $list = Db::name('good')
             ->alias("a")
             ->field("b.skuCode,b.platform_code,b.plat_code,b.id as good_id,a.cat_id,a.good_name,a.good_img,b.is_fixed,
-            a.good_info_img,a.good_thumb_img,b.createrid,a.is_exclusive,a.brand_id,a.supplierNo,a.supplierName,
+            a.good_info_img,a.good_thumb_img,b.createrid,a.is_exclusive,a.brand_id,a.supplierNo,a.supplierName,a.create_source,
             a.good_unit,a.noble_metal,a.companyNo,a.companyName,a.spuCode,a.good_type,b.creater,b.addtime,b.updatetime,
             b.exam_status,a.createrid purchase_id,a.creater purchase,a.is_stock,p.platform_name,b.is_compliance,b.compliance_remark")
             //成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
@@ -377,6 +381,7 @@ class Good extends Base
         }
         $plat =Db::name("platform")->where(["id"=>$good_platform['platform_code']])->find();
         $data['skuCode']=$good_platform['skuCode'];
+        $data['market_url']=$good_platform['market_url'];
         $data['is_fixed']=$good_platform['is_fixed'];
         $data['platform_id']=$good_platform['platform_code'];
         $data['platform_code_en']=isset($plat['platform_code'])?$plat['platform_code']:"";
@@ -489,7 +494,11 @@ class Good extends Base
         $proof =Db::name("good_proof")->where(["spuCode"=>$good_platform['spuCode'],"is_del"=>0])->order("updatetime desc")->field("id,proof_type,proof_url")->find();
         $data['proof'] = isset($proof)&&$proof!=false? $proof:[];
         $data["nakelist"]=$nakearry;
-
+		$data['sale_price'] = 0;
+        if($data['create_source']==1){
+        	$data['sale_price'] = Db::name('sale')->where(['good_code'=>$good_platform['spuCode'],'order_type'=>3])
+        	->value('sale_price',0);
+        }
         //补充采购员字段
         //成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
         $temp_basic_info = Db::name('good_basic')

+ 99 - 84
app/admin/controller/Goodup.php

@@ -1471,6 +1471,11 @@ class Goodup extends Base
         if ($data['is_gold_price'] == 1) {
             $gold = Db::name("gold_price1")->where(["type" => $data['noble_metal'], "status" => 1, "is_del" => 0])->order("addtime desc")->find();
         }
+        $data['cgd_price'] = 0;
+        if($data['create_source']==1){
+        	$data['cgd_price'] = Db::name("purchease_order")->where(["spuCode"=>$supcode,"order_type"=>3])->value
+        	("good_price",0);
+        }
         $data['gold_price'] =isset($gold["price"])?$gold["price"]:0;
             $speclist=[];
         if(!empty($spec)){
@@ -1565,11 +1570,17 @@ class Goodup extends Base
         if($platform==""){
             return error_show(1004,"参数platform不能为空");
         }
-        $spuCode =isset($this->post['codes'])&&!empty($this->post['codes'])? $this->post['codes']:"";
-        if($spuCode===''){
-            return error_show(1004,"参数codes不能为空");
+//        $spuCode =isset($this->post['codes'])&&!empty($this->post['codes'])? $this->post['codes']:"";
+//        if($spuCode===''){
+//            return error_show(1004,"参数codes不能为空");
+//        }
+        
+        $goodinfo =isset($this->post['goodinfo'])&&!empty($this->post['goodinfo'])? $this->post['goodinfo']:[];
+        if(empty($goodinfo)){
+            return error_show(1004,'参数goodinfo不能为空');
         }
-        $datas = Db::name("good_basic")->where(["spuCode"=>$spuCode,"is_del"=>0])->select()->toArray();
+        $datas = Db::name("good_basic")->where(["spuCode"=>array_column($goodinfo,"spuCode"),"is_del"=>0])->select()
+        ->toArray();
         if(empty($datas)){
             return error_show(1004,"未找到商品数据");
         }
@@ -1581,10 +1592,11 @@ class Goodup extends Base
         if($online_remark===""){
             return error_show(1004,"参数online_remark不能为空");
         }
+     
         $fixed = isset($this->post['is_fixed'])&&$this->post['is_fixed']!==''? intval($this->post['is_fixed']):1;
         if($fixed==1){
         	//使用实时金价
-        	 $nake=Db::name('good_nake')->where(['spuCode'=> $spuCode,'is_del'=>0,"nake_fee"=>0])->findOrEmpty();
+        	 $nake=Db::name('good_nake')->where(['spuCode'=> array_column($goodinfo,'spuCode'),'is_del'=>0,"nake_fee"=>0])->findOrEmpty();
         	 if(!empty($nake)) return error_show(1004,'一口价商品请先完善商品成本单价');
           
         }
@@ -1612,11 +1624,12 @@ class Goodup extends Base
             'online_reason'=>$online_reason,
             'online_remark'=>$online_remark,
             'good_data'=>$datas,
+            'good_info'=>$goodinfo,
             'createrid'=>$createrid,
             'creater'=>$creater,
         ]);
         }
-
+		$market = array_column( $goodinfo,"market_url",'spuCode');
 
         $data=[];
         $isonline=[];
@@ -1672,6 +1685,7 @@ class Goodup extends Base
                     "exam_status"=>$count>0 ?2:1,
                     "is_online"=>0,
                     "is_fixed"=>$fixed,
+                    'market_url'=>$market[$value['spuCode']]??"",
                     "status"=>1,
                     "is_del"=>0,
                     "creater"=>$creater,
@@ -2727,14 +2741,14 @@ class Goodup extends Base
         $param = $this->request->only([
         'platform',
          "is_fixed",
-         'codes',
+         'goodinfo',
          'online_reason',
          'online_remark',
          'token'], 'post', 'trim');
 
         $val = Validate::rule([
             'platform|所选上线平台' => 'require|number|gt:0',
-            'codes|所选上线商品编号' => 'require',
+            'goodinfo|所选上线商品编号' => 'require|array',
             'is_fixed|是否一口价' => 'require|number|in:0,1',
             'online_reason|上线原因' => 'require',
             'online_remark|上线备注' => 'require',
@@ -2742,13 +2756,13 @@ class Goodup extends Base
         ]);
 
         if (!$val->check($param)) return error_show(1004, $val->getError());
-
+		$codes= array_column($param['goodinfo'],"spuCode");
         $good_zixun_list = Db::name("good_zixun")
             ->where(["is_del" => 0])
-            ->whereIn('spuCode', $param['codes'])
+            ->whereIn('spuCode',$codes)
             ->column('*', 'spuCode');
         if (empty($good_zixun_list)) return error_show(1004, "未找到相关咨询商品数据");
-        $a = array_diff($param['codes'], array_keys($good_zixun_list));
+        $a = array_diff($codes, array_keys($good_zixun_list));
 
         if (!empty($a)) return error_show(1005, '该咨询商品不存在' . implode(',', $a));
 
@@ -2756,7 +2770,7 @@ class Goodup extends Base
             ->alias('gp')
             ->field('gp.id,gp.spuCode,gb.good_name,gb.good_img,gp.exam_status')
             ->where(["gp.platform_code" => $param['platform'], "gp.is_del" => 0])
-            ->whereIn('gp.spuCode', $param['codes'])
+            ->whereIn('gp.spuCode', $codes)
             ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
             ->select()
             ->toArray();
@@ -2803,39 +2817,40 @@ class Goodup extends Base
 
         $all_nakes = Db::name("good_nake")
             ->where(["is_del" => 0])->fetchSql()
-            ->whereIn('spuCode', $param['codes'])
+            ->whereIn('spuCode',$codes)
             ->group('spuCode')
             ->column('count(`id`) total', 'spuCode');
 
         $all_good = Db::name('good')
             ->where('is_del', 0)
-            ->whereIn('spuCode', $param['codes'])
+            ->whereIn('spuCode', $codes)
             ->column('id', 'spuCode');
 
         if (!empty($all_good)) return error_show(1004, '请从商品成本提交该商品上线');
 
         $all_good_basic = Db::name('good_basic')
             ->where('is_del', 0)
-            ->whereIn('spuCode', $param['codes'])
+            ->whereIn('spuCode', $codes)
             ->column('id', 'spuCode');
         if (!empty($all_good_basic)) return error_show(1004, '请从商品成本提交该商品上线');
 
-        foreach ($param['codes'] as $value) {
-        	if($good_zixun_list[$value]['is_gold_price']==1&&$param['is_fixed']==1){
-        	return error_show(1004," {$good_zixun_list[$value]['good_name']}商品使用实时金价,不可使用一口价!");
+        foreach ($param['goodinfo'] as $value) {
+        	if($good_zixun_list[$value['spuCode']]['is_gold_price']==1&&$param['is_fixed']==1){
+        	return error_show(1004," {$good_zixun_list[$value['spuCode']]['good_name']}商品使用实时金价,不可使用一口价!");
         	}
             //改变编码规则,将原来的skuCode后两位换成序列号
             //str_pad字符串填充
             $skuCode = makeNo("SN");
             $skuCode = substr($skuCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
             $data[] = [
-                "spuCode" => $value,
+                "spuCode" => $value['spuCode'],
                 "skuCode" => $skuCode,
                 "platform_code" => $param['platform'],
                 "online_reason" => $param['online_reason'],
                 "online_remark" => $param['online_remark'],
                 "exam_status" => isset($all_nakes[$value]) ? ($all_nakes[$value] > 0 ? 2 : 1) : 1,
                 "is_online" => 0,
+                "market_url" =>$value['market_url'],
                 "is_fixed" =>$param['is_fixed'],
                 "status" => 0,
                 "is_del" => 0,
@@ -2847,55 +2862,55 @@ class Goodup extends Base
 
 
             //good表
-            if (!isset($all_good[$value])) {
+            if (!isset($all_good[$value['spuCode']])) {
                 $good_insert_data[] = [
-                    'spuCode' => $good_zixun_list[$value]['spuCode'],
-                    'good_code' => $good_zixun_list[$value]['good_code'],
-                    'good_name' => $good_zixun_list[$value]['good_name'],
-                    'cat_id' => $good_zixun_list[$value]['cat_id'],
-                    'brand_id' => $good_zixun_list[$value]['brand_id'],
-                    'good_unit' => $good_zixun_list[$value]['good_unit'],
-                    'good_type' => $good_zixun_list[$value]['good_type'],
-                    'companyNo' => $good_zixun_list[$value]['companyNo'],
-                    'companyName' => $good_zixun_list[$value]['companyName'],
-                    'moq' => $good_zixun_list[$value]['moq'],
-                    'customized' => $good_zixun_list[$value]['customized'],
-                    'tax' => $good_zixun_list[$value]['tax'],
-                    'supplierNo' => $good_zixun_list[$value]['supplierNo'],
-                    'supplierName' => $good_zixun_list[$value]['supplierName'],
-                    'is_auth' => $good_zixun_list[$value]['is_auth'],
+                    'spuCode' => $good_zixun_list[$value['spuCode']]['spuCode'],
+                    'good_code' => $good_zixun_list[$value['spuCode']]['good_code'],
+                    'good_name' => $good_zixun_list[$value['spuCode']]['good_name'],
+                    'cat_id' => $good_zixun_list[$value['spuCode']]['cat_id'],
+                    'brand_id' => $good_zixun_list[$value['spuCode']]['brand_id'],
+                    'good_unit' => $good_zixun_list[$value['spuCode']]['good_unit'],
+                    'good_type' => $good_zixun_list[$value['spuCode']]['good_type'],
+                    'companyNo' => $good_zixun_list[$value['spuCode']]['companyNo'],
+                    'companyName' => $good_zixun_list[$value['spuCode']]['companyName'],
+                    'moq' => $good_zixun_list[$value['spuCode']]['moq'],
+                    'customized' => $good_zixun_list[$value['spuCode']]['customized'],
+                    'tax' => $good_zixun_list[$value['spuCode']]['tax'],
+                    'supplierNo' => $good_zixun_list[$value['spuCode']]['supplierNo'],
+                    'supplierName' => $good_zixun_list[$value['spuCode']]['supplierName'],
+                    'is_auth' => $good_zixun_list[$value['spuCode']]['is_auth'],
                     'is_stock' => '',
-                    'auth_img' => $good_zixun_list[$value]['auth_img'],
+                    'auth_img' => $good_zixun_list[$value['spuCode']]['auth_img'],
                     'after_sales' => '',
-                    'craft_desc' => $good_zixun_list[$value]['craft_desc'],
-                    'good_remark' => $good_zixun_list[$value]['good_remark'],
+                    'craft_desc' => $good_zixun_list[$value['spuCode']]['craft_desc'],
+                    'good_remark' => $good_zixun_list[$value['spuCode']]['good_remark'],
                     'good_size' => '',
-                    'weight' => $good_zixun_list[$value]['weight'],
+                    'weight' => $good_zixun_list[$value['spuCode']]['weight'],
                     'packing_way' => '',
                     'packing_size' => '',
                     'packing_spec' => '',
                     'packing_list' => '',
                     'packing_weight' => '',
                     'good_bar' => '',
-                    'supply_area' => $good_zixun_list[$value]['supply_area'],
+                    'supply_area' => $good_zixun_list[$value['spuCode']]['supply_area'],
                     'delivery_place' => '',
                     'origin_place' => '',
                     'delivery_day' => 0,
                     'lead_time' => '',
                     'sample_day' => '',
                     'sample_fee' => '',
-                    'good_img' => $good_zixun_list[$value]['good_img'],
-                    'good_thumb_img' => $good_zixun_list[$value]['good_thumb_img'],
-                    'good_info_img' => $good_zixun_list[$value]['good_info_img'],
+                    'good_img' => $good_zixun_list[$value['spuCode']]['good_img'],
+                    'good_thumb_img' => $good_zixun_list[$value['spuCode']]['good_thumb_img'],
+                    'good_info_img' => $good_zixun_list[$value['spuCode']]['good_info_img'],
                     'cert_fee' => '',
                     'packing_fee' => '',
                     'cost_fee' => '',
                     'mark_fee' => '',
                     'demo_fee' => '',
                     'open_fee' => '',
-                    'noble_metal' => $good_zixun_list[$value]['noble_metal'],
-                    'noble_weight' => $good_zixun_list[$value]['good_weight'],
-                    'is_gold_price' => $good_zixun_list[$value]['is_gold_price'],
+                    'noble_metal' => $good_zixun_list[$value['spuCode']]['noble_metal'],
+                    'noble_weight' => $good_zixun_list[$value['spuCode']]['good_weight'],
+                    'is_gold_price' => $good_zixun_list[$value['spuCode']]['is_gold_price'],
                     'cgd_gold_price' => '',
                     'market_price' => '',
                     'nake_price' => '',
@@ -2910,60 +2925,60 @@ class Goodup extends Base
                     'addtime' => date('Y-m-d H:i:s'),
                     'updatetime' => date('Y-m-d H:i:s'),
                     'is_exclusive' => '',
-                    'is_diff' => $good_zixun_list[$value]['is_diff'],
-                    'config' => $good_zixun_list[$value]['config'],
-                    'other_config' => $good_zixun_list[$value]['other_config'],
+                    'is_diff' => $good_zixun_list[$value['spuCode']]['is_diff'],
+                    'config' => $good_zixun_list[$value['spuCode']]['config'],
+                    'other_config' => $good_zixun_list[$value['spuCode']]['other_config'],
                 ];
             }
 
             //good_basic表
-            if (!isset($all_good_basic[$value])) {
+            if (!isset($all_good_basic[$value['spuCode']])) {
                 $good_basic_insert_data[] = [
-                    'spuCode' => $good_zixun_list[$value]['spuCode'],
-                    'good_code' => $good_zixun_list[$value]['good_code'],
-                    'good_name' => $good_zixun_list[$value]['good_name'],
-                    'cat_id' => $good_zixun_list[$value]['cat_id'],
-                    'brand_id' => $good_zixun_list[$value]['brand_id'],
-                    'companyNo' => $good_zixun_list[$value]['companyNo'],
-                    'companyName' => $good_zixun_list[$value]['companyName'],
-                    'good_unit' => $good_zixun_list[$value]['good_unit'],
-                    'good_type' => $good_zixun_list[$value]['good_type'],
-                    'moq' => $good_zixun_list[$value]['moq'],
-                    'customized' => $good_zixun_list[$value]['customized'],
-                    'tax' => $good_zixun_list[$value]['tax'],
-                    'supplierNo' => $good_zixun_list[$value]['supplierNo'],
-                    'supplierName' => $good_zixun_list[$value]['supplierName'],
-                    'is_auth' => $good_zixun_list[$value]['is_auth'],
-                    'auth_img' => $good_zixun_list[$value]['auth_img'],
+                    'spuCode' => $value['spuCode'],
+                    'good_code' => $good_zixun_list[$value['spuCode']]['good_code'],
+                    'good_name' => $good_zixun_list[$value['spuCode']]['good_name'],
+                    'cat_id' => $good_zixun_list[$value['spuCode']]['cat_id'],
+                    'brand_id' => $good_zixun_list[$value['spuCode']]['brand_id'],
+                    'companyNo' => $good_zixun_list[$value['spuCode']]['companyNo'],
+                    'companyName' => $good_zixun_list[$value['spuCode']]['companyName'],
+                    'good_unit' => $good_zixun_list[$value['spuCode']]['good_unit'],
+                    'good_type' => $good_zixun_list[$value['spuCode']]['good_type'],
+                    'moq' => $good_zixun_list[$value['spuCode']]['moq'],
+                    'customized' => $good_zixun_list[$value['spuCode']]['customized'],
+                    'tax' => $good_zixun_list[$value['spuCode']]['tax'],
+                    'supplierNo' => $good_zixun_list[$value['spuCode']]['supplierNo'],
+                    'supplierName' => $good_zixun_list[$value['spuCode']]['supplierName'],
+                    'is_auth' => $good_zixun_list[$value['spuCode']]['is_auth'],
+                    'auth_img' => $good_zixun_list[$value['spuCode']]['auth_img'],
                     'after_sales' => '',
-                    'craft_desc' => $good_zixun_list[$value]['craft_desc'],
-                    'good_remark' => $good_zixun_list[$value]['good_remark'],
-                    'weight' => $good_zixun_list[$value]['weight'],
+                    'craft_desc' => $good_zixun_list[$value['spuCode']]['craft_desc'],
+                    'good_remark' => $good_zixun_list[$value['spuCode']]['good_remark'],
+                    'weight' => $good_zixun_list[$value['spuCode']]['weight'],
                     'packing_way' => '',
                     'packing_size' => '',
                     'packing_spec' => '',
                     'packing_list' => '',
                     'packing_weight' => '',
                     'good_bar' => '',
-                    'supply_area' => $good_zixun_list[$value]['supply_area'],
+                    'supply_area' => $good_zixun_list[$value['spuCode']]['supply_area'],
                     'delivery_place' => '',
                     'origin_place' => '',
                     'delivery_day' => '',
                     'lead_time' => '',
                     'sample_day' => '',
                     'sample_fee' => '',
-                    'good_img' => '',//$good_zixun_list[$value]['good_img'],
-                    'good_thumb_img' => $good_zixun_list[$value]['good_thumb_img'],
-                    'good_info_img' => $good_zixun_list[$value]['good_img'],//商品主图对应到商品详情
+                    'good_img' => '',//$good_zixun_list[$value['spuCode']]['good_img'],
+                    'good_thumb_img' => $good_zixun_list[$value['spuCode']]['good_thumb_img'],
+                    'good_info_img' => $good_zixun_list[$value['spuCode']]['good_img'],//商品主图对应到商品详情
                     'cert_fee' => '',
                     'packing_fee' => '',
                     'cost_fee' => '',
                     'mark_fee' => '',
                     'demo_fee' => '',
                     'open_fee' => '',
-                    'noble_metal' => $good_zixun_list[$value]['noble_metal'],
-                    'noble_weight' => $good_zixun_list[$value]['good_weight'],
-                    'is_gold_price' => $good_zixun_list[$value]['is_gold_price'],
+                    'noble_metal' => $good_zixun_list[$value['spuCode']]['noble_metal'],
+                    'noble_weight' => $good_zixun_list[$value['spuCode']]['good_weight'],
+                    'is_gold_price' => $good_zixun_list[$value['spuCode']]['is_gold_price'],
                     'cgd_gold_price' => '',
                     'market_price' => '',
                     'nake_price' => '',
@@ -2977,26 +2992,26 @@ class Goodup extends Base
                     'is_del' => 0,
                     'addtime' => date('Y-m-d H:i:s'),
                     'updatetime' => date('Y-m-d H:i:s'),
-                    'is_diff' => $good_zixun_list[$value]['is_diff'],
-                    'config' => $good_zixun_list[$value]['config'],
-                    'other_config' => $good_zixun_list[$value]['other_config'],
+                    'is_diff' => $good_zixun_list[$value['spuCode']]['is_diff'],
+                    'config' => $good_zixun_list[$value['spuCode']]['config'],
+                    'other_config' => $good_zixun_list[$value['spuCode']]['other_config'],
                 ];
             }
 
             //good_spec
-            if (!empty($good_zixun_list[$value]['specinfo'])) {
+            if (!empty($good_zixun_list[$value['spuCode']]['specinfo'])) {
 
-                $spec_list = json_decode($good_zixun_list[$value]['specinfo'], true);
+                $spec_list = json_decode($good_zixun_list[$value['spuCode']]['specinfo'], true);
 
                 foreach ($spec_list as $spec) {
                 	$specid =  $spec['specid']??($spec['spec_id']??"");
                     $temp = Db::name('good_spec')
                         ->field('id')
-                        ->where(['spuCode' => $value, 'spec_id' => $specid, 'spec_value_id' => $spec['spec_value_id'], 'is_del' => 0])
+                        ->where(['spuCode' => $value['spuCode'], 'spec_id' => $specid, 'spec_value_id' => $spec['spec_value_id'], 'is_del' => 0])
                         ->find();
                     if (!empty($temp)) {
                         $good_spec_insert_data[] = [
-                            'spuCode' => $value,
+                            'spuCode' => $value['spuCode'],
                             'spec_id' => $specid,
                             'spec_value_id' => $spec['spec_value_id'],
                             'is_del' => 0,
@@ -3020,7 +3035,7 @@ class Goodup extends Base
 
             Db::name("good_zixun")
                 ->where(["is_del" => 0, 'status' => 1])
-                ->whereIn('spuCode', $param['codes'])
+                ->whereIn('spuCode', $codes)
                 ->update(['status' => 2, 'updatetime' => date('Y-m-d H:i:s')]);
 
             if (!empty($good_insert_data)) Db::name('good')->insertAll($good_insert_data);

+ 70 - 68
app/admin/controller/Reorder.php

@@ -233,9 +233,9 @@ class Reorder extends Base
                     $uap = Db::name("sale")->save($order);
                     if ($uap == false) throw new Exception('销售单订单更新失败');
 					 $good =Db::name("good")->where(["spuCode"=>$order['good_code']])->findOrEmpty();
-                        if(empty($good))throw new Exception('未找到商品信息');
-                        $stock=Db::name("good")->where($good)->update(["usable_stock"=>$good['usable_stock']+$thnum,"updatetime"=>date("Y-m-d H:i:s")]);
-                        if ($stock == false) throw new Exception('商品库存更新失败');
+                    if(empty($good))throw new Exception('未找到商品信息');
+                     $stock=Db::name("good")->where($good)->update(["usable_stock"=>$good['usable_stock']+$thnum,"updatetime"=>date("Y-m-d H:i:s")]);
+                     if ($stock == false) throw new Exception('商品库存更新失败');
                     ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
                         "order_code" => $order["orderCode"],//出库单号
                         "status" => $lor,//这里的status是之前的值
@@ -299,74 +299,76 @@ class Reorder extends Base
 //                            return json_show(1005, '备库单库存数据释放失败');
 //                        }
 //                    }
+					if(strtotime($order['addtime'])< strtotime("2023-04-17 00:00:00")){
+						$saleinfo = Db::name('sale_info')
+                        ->where([['orderCode', '=', $ordeCode], ['num', '>', 0]])
+                        ->select()
+                        ->toArray();
+                    if (empty($saleinfo)) {
+                        $ordernum = Db::name('order_num')->where(['orderCode' => $ordeCode])->findOrEmpty();
+                        if (empty($ordernum)) throw new Exception('未找到关联采购单');
+
+                        $cgd = Db::name('purchease_order')->where(['cgdNo' => $ordernum['cgdNo'], 'is_del' => 0])->findOrEmpty();
+                        if (empty($cgd)) throw new Exception('未找到采购单数据');
+
+                        $bn = makeNo('BN');
+                        $stock = Db::name('good_stock')
+                            ->where(['spuCode' => $order['good_code'], 'wsm_code' => $cgd['wsm_code'], 'is_del' => 0, 'status' => 1])
+                            ->findOrEmpty();
+                        if ($stock == false) throw new Exception('商品库存数据未找到');
+
+                        $stock['usable_stock'] += $thnum;
+                        $stock['wait_out_stock'] -= $thnum;
+                        $stock['updatetime'] = $date;
+                        $st_up = Db::name('good_stock')->save($stock);
+                        if ($st_up == false) throw new Exception('可售商品入库失败');
+
+                        $yp = GoodStockInfo::AddBn($stock['id'], $bn, $thnum, $cgd['good_price']);
+                        if ($yp == false) throw new Exception('商品批次退货入库失败');
+
+                    } else {
+                        $tempnum = $thnum;
+                        foreach ($saleinfo as $va) {
+                            if ($tempnum == 0) break;
+                            $stock = Db::name('good_stock')->where(['spuCode' => $order['good_code'], 'id' => $va['stockid']])
+                                ->findOrEmpty();
+                            if ($stock == false) throw new Exception('商品库存数据未找到');
 
-//                    $saleinfo = Db::name("sale_info")
-//                        ->where([["orderCode", "=", $ordeCode], ["num", ">", 0]])
-//                        ->select()
-//                        ->toArray();
-//                    if (empty($saleinfo)) {
-//                        $ordernum = Db::name("order_num")->where(['orderCode' => $ordeCode])->findOrEmpty();
-//                        if (empty($ordernum)) throw new Exception('未找到关联采购单');
-//
-//                        $cgd = Db::name("purchease_order")->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])->findOrEmpty();
-//                        if (empty($cgd)) throw new Exception('未找到采购单数据');
-//
-//                        $bn = makeNo("BN");
-//                        $stock = Db::name("good_stock")
-//                            ->where(["spuCode" => $order['good_code'], 'wsm_code' => $cgd['wsm_code'], "is_del" => 0, "status" => 1])
-//                            ->findOrEmpty();
-//                        if ($stock == false) throw new Exception('商品库存数据未找到');
-//
-//                        $stock['usable_stock'] += $thnum;
-//                        $stock['wait_out_stock'] -= $thnum;
-//                        $stock['updatetime'] = $date;
-//                        $st_up = Db::name("good_stock")->save($stock);
-//                        if ($st_up == false) throw new Exception('可售商品入库失败');
-//
-//                        $yp = GoodStockInfo::AddBn($stock['id'], $bn, $thnum, $cgd['good_price']);
-//                        if ($yp == false) throw new Exception('商品批次退货入库失败');
-//
-//                    } else {
-//                        $tempnum = $thnum;
-//                        foreach ($saleinfo as $va) {
-//                            if ($tempnum == 0) break;
-//                            $stock = Db::name("good_stock")->where(["spuCode" => $order['good_code'], 'id' => $va['stockid']])
-//                                ->findOrEmpty();
-//                            if ($stock == false) throw new Exception('商品库存数据未找到');
-//
-//                            if ($va['num'] >= $tempnum) {
-//                                $tnm = $tempnum;
-//                                $va['num'] -= $tempnum;
-//                                $va['th_num'] += $tempnum;
-//                                $tempnum = 0;
-//                            } else {
-//                                $tnm = $va['num'];
-//                                $tempnum -= $va['num'];
-//                                $va['th_num'] += $va['num'];
-//                                $va['num'] = 0;
-//                            }
-//                            $stock['usable_stock'] += $tnm;
-//                            $stock['wait_out_stock'] -= $tnm;
-//                            $stock['updatetime'] = $date;
-//                            $st_up = Db::name("good_stock")->save($stock);
-//                            if ($st_up == false) throw new Exception('可售商品入库失败');
-//
-//                            $ps = GoodStockInfo::AddBn($va['stockid'], $va['bnCode'], $tnm);
-//                            if ($ps == false) throw new Exception('商品批次退货入库失败');
-//
-//                            $ret = GoodStockInfo::ReturnBn($returnCode, $va['id'], $tnm);
-//                            if ($ret == false) throw new Exception('商品批次退货入库失败');
-//
-//                            $va['updatetime'] = $date;
-//                            $sal = Db::name("sale_info")->save($va);
-//                            if ($sal == false) throw new Exception('商品批次退货入库失败');
-//
-//                            $good_data[] = ['good_log_code' => $returnCode, "stock_id" => $va['stockid'], "type" => 1, 'stock' => $thnum, "stock_name" => "usable_stock"];
-//                            $good_data[] = ['good_log_code' => $returnCode, "stock_id" => $va['stockid'], "type" => 2, 'stock' => $thnum, "stock_name" => "wait_out_stock"];
+                            if ($va['num'] >= $tempnum) {
+                                $tnm = $tempnum;
+                                $va['num'] -= $tempnum;
+                                $va['th_num'] += $tempnum;
+                                $tempnum = 0;
+                            } else {
+                                $tnm = $va['num'];
+                                $tempnum -= $va['num'];
+                                $va['th_num'] += $va['num'];
+                                $va['num'] = 0;
+                            }
+                            $stock['usable_stock'] += $tnm;
+                            $stock['wait_out_stock'] -= $tnm;
+                            $stock['updatetime'] = $date;
+                            $st_up = Db::name('good_stock')->save($stock);
+                            if ($st_up == false) throw new Exception('可售商品入库失败');
+
+                            $ps = GoodStockInfo::AddBn($va['stockid'], $va['bnCode'], $tnm);
+                            if ($ps == false) throw new Exception('商品批次退货入库失败');
+
+                            $ret = GoodStockInfo::ReturnBn($returnCode, $va['id'], $tnm);
+                            if ($ret == false) throw new Exception('商品批次退货入库失败');
+
+                            $va['updatetime'] = $date;
+                            $sal = Db::name('sale_info')->save($va);
+                            if ($sal == false) throw new Exception('商品批次退货入库失败');
+
+//                            $good_data[] = ['good_log_code' => $returnCode, 'stock_id' => $va['stockid'], 'type' => 1, 'stock' => $thnum, 'stock_name' => 'usable_stock'];
+//                            $good_data[] = ['good_log_code' => $returnCode, 'stock_id' => $va['stockid'], 'type' => 2, 'stock' => $thnum, 'stock_name' => 'wait_out_stock'];
 //                            GoodLog::LogAdd(['id' => $this->uid, 'nickname' => $this->uname], $good_data, 'XSTHD');
-//                        }
-//                    }
+                        }
+                    }
 
+					}
+                
 
                     $data=[
                         "orderCode"=>$ordeCode,

+ 7 - 1
app/admin/controller/Sale.php

@@ -1131,6 +1131,8 @@ class Sale extends Base
                     "is_del" => 0,
                     "createrid" => $zxinfo['createrid'],
                     "creater" => $zxinfo['creater'],
+                    "order_createrid" => $this->uid,
+                    "order_creater" =>  $this->uname,
                     "addtime" => date("Y-m-d H:i:s"),
                     "updatetime" => date("Y-m-d H:i:s"),
                     'proof_type' => $proof_type,//凭证类型
@@ -4577,13 +4579,17 @@ class Sale extends Base
             $price = Db::name("gold_price1")->where(["type" => $order['noble_metal'], "status" => 1, "is_del" => 0])->order("addtime desc")->find();
 
         }
-
+			$depart = get_company_name_by_uid($order['order_createrid']);
         $userCommon = \app\admin\common\User::getIns();
         $supplier = $userCommon->handle('sInfo',['code'=>$order['supplierNo']]);
 //        $supplier = Db::name("supplier")->where(["code" => $order['supplierNo']])->find();
         $order['supplier_name'] = isset($supplier['data']['name']) ? $supplier['data']['name'] : "";
         $order['cgder'] = isset($supplier['data']['person']) ? $supplier['data']['person'] : "";
         $order['cgderid'] = isset($supplier['data']['personid']) ? $supplier['data']['personid'] : "";
+        $order['order_creater_depart'] = $depart;
+        $is_online= Db::name('good_platform')->where(['spuCode'=>$order['spuCode']])->findOrEmpty();
+        $order['is_online'] = empty($is_online)?0:1;
+        $value['is_basic']= Db::name('good_basic')->where(['spuCode'=>$order['spuCode']])->value("status",null);
         $palt = Db::name("platform")->where(["id" => $order['platform_id']])->find();
         $order['platform_name'] = isset($palt['platform_name']) ? $palt['platform_name'] : "";
 

+ 0 - 2
app/admin/controller/Suppler.php

@@ -324,8 +324,6 @@ class Suppler extends Base
         if ($id == "") {
             return error_show(1002, "参数id不能为空");
         }
-//        $info = Db::name("supplier")->where(['id' => $id, 'is_del' => 0])->find();
-
         $code = $this->request->only(['code' => ''], 'post', 'trim');
         $userCommon = \app\admin\common\User::getIns();
         $info = $userCommon->handle('sInfo', $code);

+ 3 - 1
app/youzan/logic/Goodup.php

@@ -34,7 +34,7 @@ class Goodup
                 ->where(["min_num" => 1, "is_del" => 0])
                 ->whereIn('spuCode', array_column($data['good_data'], 'spuCode'))
                 ->column('id', 'spuCode');
-
+			$market = array_column( $data['good_info'],'market_url','spuCode');
             foreach ($data['good_data'] as $value) {
 //                $count = Db::name("good_nake")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->count();
 
@@ -53,6 +53,7 @@ class Goodup
 //                        $tp['exam_status'] = $ist['exam_status'];
                         $spec = Db::name("good_spec")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->select()->toArray();
                         $speclist = [];
+                        $speclist = [];
                         if (!empty($spec)) {
                             foreach ($spec as $val) {
                                 $temp = [];
@@ -134,6 +135,7 @@ class Goodup
                     "createrid" => $data['createrid'],
                     "creater" => $data['creater'],
                     "updaterid" => $data['createrid'],
+                    'market_url'=>$market[$value['spuCode']]??'',
                     "updater" => $data['creater'],
                     "addtime" => date("Y-m-d H:i:s"),
                     "updatetime" => date("Y-m-d H:i:s")