瀏覽代碼

Merge remote-tracking branch 'origin/fyy' into fyy

# Conflicts:
#	app/Service/Box/BoxService.php
root 2 年之前
父節點
當前提交
0ad9159f6e
共有 3 個文件被更改,包括 31 次插入64 次删除
  1. 1 1
      app/Jobs/ProcessDataJob.php
  2. 17 29
      app/Service/FyyOrderService.php
  3. 13 34
      app/Service/FyySqlServerService.php

+ 1 - 1
app/Jobs/ProcessDataJob.php

@@ -138,7 +138,7 @@ class ProcessDataJob implements ShouldQueue
         $data = $this->data['data'];
 
         //进入队列的数据
-        Box::where('order_no',$data['order_no'])->update([
+        Box::whereIn('order_no',$data['order_no'])->update([
             'state' => 0,
         ]);
     }

+ 17 - 29
app/Service/FyyOrderService.php

@@ -223,7 +223,7 @@ class FyyOrderService extends Service
         Redis::hSet('order_failures', md5(json_encode($redis)), 0);
 
         //标记进入队列的数据
-        Box::where('order_no',$data['order_no'])->update([
+        Box::whereIn('order_no',$data['order_no'])->update([
             'state' => 1,
         ]);
 
@@ -235,57 +235,45 @@ class FyyOrderService extends Service
             $sqlServerModel = new FyySqlServerService();
             if($sqlServerModel->error) return [false,$sqlServerModel->error];
 
-            list($status,$msg) = $sqlServerModel->U8Rdrecord32Save($result);
+            list($status,$msg) = $sqlServerModel->U8Rdrecord32Save($data['post']);
             if(! $status) return [false,$msg];
 
             //更新
-            Box::where('order_no',$data['order_no'])->update([
+            DB::beginTransaction();
+            Box::whereIn('order_no',$data['order_no'])->update([
                 'state' => 2,
             ]);
+            foreach ($data['box_data'] as $value){
+                SaleOrdersProduct::where('out_order_no',$data['order_number'])->update([
+                    'top_id' => $value['top_id'],
+                    'shipment_num' => $value['num'],
+                ]);
+            }
+            DB::commit();
         }catch (\Exception $e){
+            DB::rollBack();
             return [false,$e->getFile() . $e->getLine(). $e->getMessage()];
         }
 
         return [true,''];
     }
 
-    public function orderOutRule($data){//todo
+    public function orderOutRule($data){
+        if(empty($data['order_number'])) return [false,'销售订单号不能为空!'];
         if(empty($data['order_no'])) return [false,'包装单号不能为空!'];
+        if(empty($data['post'])) return [false,'发货单数据不能为空!'];
+        if(empty($data['box_data'])) return [false,'包装单数据不能为空!'];
 
         $boxList = Box::whereIn('order_no',$data['order_no'])->get()->toArray();
         if(empty($boxList)) return [false,'包装单不存在!'];
 
-        $box_detail_list = [];
         foreach ($boxList as $value){
             if($value['del_time'] > 0) return [false,'包装单:' . $value['order_no'] . '已删除'];
             if($value['state'] == 1) return [false,'包装单:' . $value['order_no'] . '已操作出库!'];
             if($value['state'] > 1) return [false,'包装单:' . $value['order_no'] . '已出库!'];
-
-            $box_detail = new BoxDetail(['channel' => $value['order_no']]);
-            $box_detail_list = $box_detail->where('del_time',0)
-                ->where('order_no',$data['order_no'])
-                ->select('order_no','out_order_no','top_id as sale_orders_product_id','ext_1 as customer_no','ext_2 as customer_name','ext_3 as product_no','num')
-                ->get()->toArray();
-        }
-
-
-        $box_detail = new BoxDetail(['channel'=>$box['order_no']]);
-        $box_detail_list = $box_detail->where('order_no',$data['order_no'])
-            ->where('del_time',0)
-            ->select('order_no','out_order_no','top_id as sale_orders_product_id','ext_1 as customer_no','ext_2 as customer_name','ext_3 as product_no','num')
-            ->get()->toArray();
-        if(! empty($box_detail_list)){
-            $saleOrder = SaleOrdersProduct::whereIn('id',array_column($box_detail_list,'sale_orders_product_id'))
-                ->select('id','technology_name','wood_name')
-                ->get()->toArray();
-            $saleOrderMap = array_column($saleOrder,null,'id');
-            foreach ($box_detail_list as $key => $value){
-                $box_detail_list[$key]['technology_name'] = $saleOrderMap[$value['sale_orders_product_id']]['technology_name'];
-                $box_detail_list[$key]['wood_name'] = $saleOrderMap[$value['sale_orders_product_id']]['wood_name'];
-            }
         }
 
-        return [true, $box_detail_list];
+        return [true, ''];
     }
 
     public function orderMobileList($data){

+ 13 - 34
app/Service/FyySqlServerService.php

@@ -359,34 +359,13 @@ class FyySqlServerService extends Service
     //销售出库单保存接口给以及审核
     public function U8Rdrecord32Save($data,$bredvouch = 0){
         if(! empty($this->error)) return [false,$this->error];
-        date_default_timezone_set("PRC");
-
-        //通过销售订单号 获取发货单的数据
-        $out_order_no = array_unique(array_column($data,'out_order_no'));
-        $return = $this->getDataFromDispatchList($out_order_no);
-        if(empty($return)) return [false,'没有找到发货单!'];
-
-        //组织发货单的数据
-        $map = [];
-        foreach ($return as $value){
-            $map[$value['cSOCode']][] = $value;
-        }
 
-        $detail = [];
+        $new = [];
         foreach ($data as $value){
-            if(! isset($map[$value['out_order_no']])) return [false,'包装单的销售订单号:' . $value['out_order_no'] .'没有找到发货单!'];
-            $is_flag = 0;
-            foreach ($map[$value['out_order_no']] as $m){
-                if($value['product_no'] == $m['cinvcode'] && $value['technology_name'] == $m['cfree1'] && $value['wood_name'] == $m['cfree2']) {
-                    $is_flag = 1;
-                    $m['iquantity'] = $value['num'];
-                    $detail[$m['cSOCode']][] = $m;
-                }
-            }
-            if(! $is_flag) return [false,'包装单的产品:' . $value['product_no'] . $value['technology_name'] . $value['wood_name'] . '在发货单中不存在!'];
+            $new[$value['id']][] = $value;
         }
 
-        foreach ($detail as $value){
+        foreach ($new as $value){
             $main_tmp = $value[0];
             foreach ($value as $val){
                 $bodys_tmp[] = [
@@ -395,13 +374,13 @@ class FyySqlServerService extends Service
                     "dlrowno"=>"",
                     "cbdlcode"=>"",
                     "cinvcode"=>$val['cinvcode'],
-                    "cposition"=>$val['cposition'],
-                    "cbatch"=>$val['cbatch'],
+                    "cposition"=>$val['cposition'] ?? "",
+                    "cbatch"=>$val['cbatch'] ?? "",
                     "iquantity"=>$val['iquantity'],
-                    "inum"=>$val['iquantity'],
-                    "iinvexchrate"=>$value['iinvexchrate'],
-                    "iunitcost"=>"",
-                    "iprice"=>"",
+                    "inum"=>$val['inum'],
+                    "iinvexchrate"=> $val['iinvexchrate'] ?? 0,
+                    "iunitcost"=>$val['iunitcost'],
+                    "iprice"=>$val['imoney'],
                     "cbmemo"=>"",
                 ];
             }
@@ -423,9 +402,9 @@ class FyySqlServerService extends Service
                     "dnmaketime"=> date("Y-m-d"),
                     "IsExamine"=>true,
                     "bredvouch"=> $bredvouch,
-                    "cwhcode"=>"02",
-                    "cdepcode"=>"06",
-                    "crdcode"=>"102",
+                    "cwhcode"=>$main_tmp['cwhcode'],
+                    "cdepcode"=>$main_tmp['cdepcode'],
+                    "crdcode"=>'',
                     "cmemo"=> '',
                     "cdefine10" => $main_tmp['customer_name'], //客户名称
                     "bodys"=>$bodys_tmp
@@ -544,7 +523,7 @@ class FyySqlServerService extends Service
             ->leftJoin('DispatchLists as b','b.DLID','a.DLID')
             ->where('a.cSOcode',$order_number)
             ->whereColumn('b.iQuantity', '>', 'b.fOutQuantity')
-            ->select('a.cDefine10 as customer_name','a.cSOCode','a.cDepCode','b.iDLsID as idlsid','b.cWhCode as cwhcode','b.cInvCode as cinvcode','b.cInvName as product_title','b.cFree1 as cfree1','b.cFree2 as cfree2','b.cPosition as cposition','b.cBatch as cbatch','b.iQuantity as iquantity','b.iNum as inum','b.iInvExchRate as iinvexchrate','b.fOutQuantity as out_quantity')
+            ->select('a.DLID as id','a.cDefine10 as customer_name','a.cSOCode','a.cDepCode as cdepcode','b.iDLsID as idlsid','b.cWhCode as cwhcode','b.cInvCode as cinvcode','b.cInvName as product_title','b.cFree1 as cfree1','b.cFree2 as cfree2','b.cPosition as cposition','b.cBatch as cbatch','b.iQuantity as iquantity','b.iNum as inum','b.iInvExchRate as iinvexchrate','b.fOutQuantity as out_quantity','b.iUnitPrice as iunitcost','b.iMoney as imoney')
             ->get()->toArray();
         if(! empty($message)){
             foreach ($message as $key => $value){