Bläddra i källkod

Merge branch 'master-new-dev-wf' of wugg/phpstock into master-new

wufeng 2 år sedan
förälder
incheckning
df8328e0fa
2 ändrade filer med 19 tillägg och 6 borttagningar
  1. 5 5
      app/admin/controller/Purch.php
  2. 14 1
      app/command/TempHandleBusinessData.php

+ 5 - 5
app/admin/controller/Purch.php

@@ -312,12 +312,12 @@ class Purch extends Base
         $im = Db::name('purchease_back')->where(['cgdNo' => $data['cgdNo'], 'is_del' => 0])->select();
         $var = [];
         foreach ($im as $value) {
-            if ($data['order_type'] == 3) {
-                $goo = Db::name("good_zixun")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->find();
+            if (in_array($data['order_type'], [3, 4])) {
+                $goo = Db::name("good_zixun")->field('cat_id')->where(["spuCode" => $value['spuCode'], "is_del" => 0])->findOrEmpty();
             } else {
-                $goo = Db::name('good_basic')->where(['spuCode' => $value['spuCode']])->find();
+                $goo = Db::name('good_basic')->field('cat_id')->where(['spuCode' => $value['spuCode']])->findOrEmpty();
             }
-            if ($goo == false) {
+            if (empty($goo)) {
                 return error_show(1002, "未找到商品数据");
             }
             $cat = isset($goo['cat_id']) && $goo['cat_id'] != 0 ? made($goo['cat_id']) : [];
@@ -326,7 +326,7 @@ class Purch extends Base
         }
         //采购工差单
         $dom = Db::name("purchease_diff")->where(['cgdNo' => $data['cgdNo'], 'is_del' => 0])->find();
-        if ($data['order_type'] == 3) {
+        if (in_array($data['order_type'], [3, 4])) {
             $goon = Db::name("good_zixun")->where(["spuCode" => $data['spuCode'], "is_del" => 0])->find();
         } else {
             $goon = Db::name('good_basic')->where(['spuCode' => $data['spuCode']])->find();

+ 14 - 1
app/command/TempHandleBusinessData.php

@@ -141,7 +141,7 @@ class TempHandleBusinessData extends Command
                     ->whereIn('code', array_column($rs['data'], 'supplierNo'))
                     ->column('*', 'code');
 
-                $insert = $gys_insert = [];
+                $insert = $gys_insert = $customer_ins = [];
                 foreach ($rs['data'] as $item) {
                     if (!isset($exists[$item['companyNo']])) {
                         $insert[] = [
@@ -181,6 +181,14 @@ class TempHandleBusinessData extends Command
                                 'updatetime' => date('Y-m-d H:i:s'),
                             ]
                         );
+
+                        $customer_ins[]=[
+                            'companyNo'=>$item['companyNo'],
+                            'companyName'=>$item['company'],
+                            'parent'=>'业务公司',
+                            'addtime'=>date('Y-m-d H:i:s'),
+                            'updatetime'=>date('Y-m-d H:i:s'),
+                        ];
                     }else{
 	                    if($item["updatetime"]==$exists[$item['companyNo']]['updatetime']) continue;
                     	$upda=[
@@ -216,6 +224,11 @@ class TempHandleBusinessData extends Command
                         ->table('cfp_supplier_info')
                         ->insertAll($gys_insert);
                 }
+                if ($customer_ins) {
+                    Db::connect('mysql_cxinv')
+                        ->table('cfp_customer_info')
+                        ->insertAll($customer_ins);
+                }
 
             }