Bläddra i källkod

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

wugg 1 år sedan
förälder
incheckning
6a4019cc5f
3 ändrade filer med 46 tillägg och 31 borttagningar
  1. 2 2
      app/admin/controller/Activity.php
  2. 3 12
      app/admin/controller/Filing.php
  3. 41 17
      app/admin/controller/Goodup.php

+ 2 - 2
app/admin/controller/Activity.php

@@ -189,8 +189,8 @@ class Activity extends Base
 
         $relaComNo = isset($this->post['relaComNo']) && $this->post['relaComNo']!="" ? trim($this->post['relaComNo']):"";
         if($relaComNo!="") $where[]=['a.supplierNo|a.companyNo','=', $relaComNo];
-        $orderSource= isset($this->post['order_source']) && $this->post['order_source']!='' ? trim($this->post['order_source']):'';
-        if($orderSource!=""||!empty($orderSource)) $where[]=['a.order_source','in', $orderSource];
+		$orderSource= isset($this->post['order_source']) && $this->post['order_source']!='' ? $this->post['order_source']:[];
+        if(!empty($orderSource)) $where[]=['a.order_source','in', $orderSource];
 
         $count = Db::name('good_zixun')
             ->alias("a")

+ 3 - 12
app/admin/controller/Filing.php

@@ -576,21 +576,12 @@ class Filing extends Base
 
         $names = $userCommon->handle('getCodeAndName', ['code' => [ $param['customerCode']]]);
 		if (!isset($names['data'])) return json_show(1005, '该客户不存在');
-        //level3账号都可以操作
-        //level2账号的话,只有供应商负责人能操作
-//        if (($this->level == 2) && ($this->uid != $supplier['data']['personid'])) return json_show(1004, '只有供应商负责人才能操作');
-
-        $date = date('Y-m-d H:i:s');
-
-        Db::startTrans();
-
-        try {
-
+		$date = date('Y-m-d H:i:s');
+		Db::startTrans();
+		try {
             $order_type = 4;//报备商品
             $order_source = 7;//报备转单
-
             $spuCode = makeNo('SKU');
-
             //商品表
          $goodIn=   Db::name('good_zixun')
                 ->insert([

+ 41 - 17
app/admin/controller/Goodup.php

@@ -1078,6 +1078,7 @@ class Goodup extends Base
             $json = json_encode($timp,JSON_UNESCAPED_UNICODE);
             $jsp = json_encode($data,JSON_UNESCAPED_UNICODE);
             if($up){
+            	$this->BasicToGood($supcode,$temp);
                 ChangeLog::logAdd(3,$data['spuCode'],$jsp,$json,['id' => $this->uid, 'nickname' => $this->uname]);
                 if($speclist!=="" && !empty($speclist)){
                     foreach ($speclist as $value){
@@ -1208,6 +1209,7 @@ class Goodup extends Base
             $json = json_encode($temp,JSON_UNESCAPED_UNICODE);
             $jsp = json_encode($datas,JSON_UNESCAPED_UNICODE);
             if($up){
+            		$this->BasicToGood($supcode,$data);
                 ChangeLog::logAdd(3,$datas['spuCode'],$jsp,$json,['id' => $this->uid, 'nickname' => $this->uname]);
                 //修改状态,添加待办
                 ActionLog::logAdd($this->post['token'], [
@@ -2562,6 +2564,7 @@ class Goodup extends Base
             $json = json_encode($var,JSON_UNESCAPED_UNICODE);
             $dat = json_encode($data,JSON_UNESCAPED_UNICODE);
             if($up){
+            	$this->BasicToGood($supcode,$temp);
                 ChangeLog::logAdd(3,$data['spuCode'],$dat,$json,['id' => $this->uid, 'nickname' => $this->uname]);
 //                //修改状态,添加待办
 //                ActionLog::logAdd($this->post['token'], [
@@ -2835,8 +2838,12 @@ class Goodup extends Base
         if (!empty($all_good_basic)) return error_show(1004, '请从商品成本提交该商品上线');
 
         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']}商品使用实时金价,不可使用一口价!");
+//        	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']}商品使用实时金价,不可使用一口价!");
+//        	}
+			$bd=[];
+        	if($good_zixun_list[$value['spuCode']]['order_source']==2 ||$good_zixun_list[$value['spuCode']]['order_source']==3){
+        	$bd = Db::name('consult_bids')->where(['spuCode'=> $value['spuCode']])->findOrEmpty();
         	}
             //改变编码规则,将原来的skuCode后两位换成序列号
             //str_pad字符串填充
@@ -2893,9 +2900,9 @@ class Goodup extends Base
                     'packing_weight' => '',
                     'good_bar' => '',
                     'supply_area' => $good_zixun_list[$value['spuCode']]['supply_area'],
-                    'delivery_place' => '',
-                    'origin_place' => '',
-                    'delivery_day' => 0,
+                     'delivery_place' =>$bd['delivery_place']??"",
+                    'origin_place' =>$bd['origin_place']??'',
+                    'delivery_day' => $bd['delivery_day']??'',
                     'lead_time' => '',
                     'sample_day' => '',
                     'sample_fee' => '',
@@ -2961,9 +2968,9 @@ class Goodup extends Base
                     'packing_weight' => '',
                     'good_bar' => '',
                     'supply_area' => $good_zixun_list[$value['spuCode']]['supply_area'],
-                    'delivery_place' => '',
-                    'origin_place' => '',
-                    'delivery_day' => '',
+                    'delivery_place' =>$bd['delivery_place']??'',
+                    'origin_place' =>$bd['origin_place']??'',
+                    'delivery_day' => $bd['delivery_day']??'',
                     'lead_time' => '',
                     'sample_day' => '',
                     'sample_fee' => '',
@@ -2999,7 +3006,7 @@ class Goodup extends Base
             }
 
             //good_spec
-            if (!empty($good_zixun_list[$value['spuCode']]['specinfo'])) {
+            if ($good_zixun_list[$value['spuCode']]['specinfo']!=='') {
 
                 $spec_list = json_decode($good_zixun_list[$value['spuCode']]['specinfo'], true);
 
@@ -3008,8 +3015,8 @@ class Goodup extends Base
                     $temp = Db::name('good_spec')
                         ->field('id')
                         ->where(['spuCode' => $value['spuCode'], 'spec_id' => $specid, 'spec_value_id' => $spec['spec_value_id'], 'is_del' => 0])
-                        ->find();
-                    if (!empty($temp)) {
+                        ->findOrEmpty();
+                    if (empty($temp)) {
                         $good_spec_insert_data[] = [
                             'spuCode' => $value['spuCode'],
                             'spec_id' => $specid,
@@ -3494,9 +3501,14 @@ class Goodup extends Base
         $temp=[];
         $good_spec_insert_data=[];
         $GoodBasic = new GoodBasic();
+        
         foreach ($good_zixun_list as $item){
         	$isT =$GoodBasic->where(["spuCode"=>$item['spuCode'],"is_del"=>0])->findOrEmpty();
         	if($isT->isEmpty()==false)return error_show(1004, "{$item['good_name']}商品已存在成本库中!");
+        	$bd=[];
+        	if($item['order_source']==2 || $item['order_source']==3){
+        	$bd = Db::name("consult_bids")->where(["spuCode"=> $item['spuCode']])->findOrEmpty();
+        	}
         	  $temp[] = [
                     'spuCode' => $item['spuCode'],
                     'good_code' => $item['good_code'],
@@ -3525,9 +3537,9 @@ class Goodup extends Base
                     'packing_weight' => '',
                     'good_bar' => '',
                     'supply_area' => $item['supply_area'],
-                    'delivery_place' => '',
-                    'origin_place' => '',
-                    'delivery_day' => '',
+                    'delivery_place' =>$bd['delivery_place']??"",
+                    'origin_place' =>$bd['origin_place']??'',
+                    'delivery_day' => $bd['delivery_day']??'',
                     'lead_time' => '',
                     'sample_day' => '',
                     'sample_fee' => '',
@@ -3561,7 +3573,7 @@ class Goodup extends Base
                     'other_config' => $item['other_config'],
                 ];
         	  
-        	   if (!empty($item['specinfo'])) {
+        	   if ($item['specinfo']!='') {
 
                 $spec_list = json_decode($item['specinfo'], true);
 
@@ -3571,8 +3583,8 @@ class Goodup extends Base
                         ->field('id')
                         ->where(['spuCode' => $item['spuCode'], 'spec_id' => $specid, 'spec_value_id' => $spec['spec_value_id'],
                          'is_del' => 0])
-                        ->find();
-                    if (!empty($specinfo)) {
+                        ->findOrEmpty();
+                    if (empty($specinfo)) {
                         $good_spec_insert_data[] = [
                             'spuCode' => $item['spuCode'],
                             'spec_id' => $specid,
@@ -3629,4 +3641,16 @@ class Goodup extends Base
             return error_show(1005, $exception->getMessage());
         }
     }
+    
+    protected function BasicToGood($spuCode,$data=[]){
+	  $good =new \app\admin\model\Good();
+	  $info = $good->where(["spuCode"=>$spuCode,"is_del"=>0])->findOrEmpty();
+	  if($info->isEmpty()==false){
+	  	if(isset($data['usable_stock']))unset($data['usable_stock']);
+	  	if(isset($data['status']))unset($data['status']);
+	  	if(isset($data['charger']))unset($data['charger']);
+	  	if(isset($data['chargerid']))unset($data['chargerid']);
+	  	$good->where($info->toArray())->save($data);
+	  }
+	}
 }