root преди 2 години
родител
ревизия
b6e1b0777b
променени са 5 файла, в които са добавени 97 реда и са изтрити 32 реда
  1. 4 0
      app/Exports/CommonExport.php
  2. 13 10
      app/Service/Box/BoxHookService.php
  3. 27 21
      app/Service/Box/BoxService.php
  4. 52 0
      app/Service/Oa/OaService.php
  5. 1 1
      routes/api.php

+ 4 - 0
app/Exports/CommonExport.php

@@ -27,6 +27,10 @@ class CommonExport implements FromCollection, WithEvents, WithStrictNullComparis
         $this->data = $data;
     }
 
+    /**
+     * 导出数据的处理
+     * @return array
+     */
     public function registerEvents(): array
     {
         //这边处理数据格式

+ 13 - 10
app/Service/Box/BoxHookService.php

@@ -46,8 +46,8 @@ class BoxHookService extends Service
         $box = new Box();
         $data['order_no'] = $this->setOrderNo();
         if(!isset($data['out_order_no'])) return [false,'out_order_no is not exist'];
-        if(!isset($data['top_id'])) return [false,'top_id is not exist'];
-        if(!isset($data['num'])) return [false,'num is not exist'];
+//        if(!isset($data['top_id'])) return [false,'top_id is not exist'];
+//        if(!isset($data['num'])) return [false,'num is not exist'];
         list($status,$box) = $this->dealBox($box,$data);
         if(!$status) return [false,$box];
         $box->save();
@@ -68,8 +68,8 @@ class BoxHookService extends Service
 
         $box->order_no = $data['order_no'];
         $box->out_order_no = $data['out_order_no'];
-        $box->top_id = $data['top_id'];
-        $box->num = $data['num'];
+//        $box->top_id = $data['top_id'];
+//        $box->num = $data['num'];
         $box->ext_1 = isset($data['ext_1']) ? $data['ext_1'] : '';
         $box->ext_2 = isset($data['ext_2']) ? $data['ext_2'] : '';
         $box->ext_3 = isset($data['ext_3']) ? $data['ext_3'] : '';
@@ -112,16 +112,18 @@ class BoxHookService extends Service
         $time = time();
         foreach ($data as $v){
             if(!isset($v['top_id'])) return [false,'top_id is not exist'];
-            if(!isset($v['code'])) return [false,'code is not exist'];
-            if(!isset($v['title'])) return [false,'title is not exist'];
-            if(!isset($v['type'])) return [false,'type is not exist'];
+//            if(!isset($v['code'])) return [false,'code is not exist'];
+//            if(!isset($v['title'])) return [false,'title is not exist'];
+//            if(!isset($v['type'])) return [false,'type is not exist'];
+            if(!isset($v['num'])) return [false,'type is not exist'];
 
             $insert[] = [
                 'order_no' => $order_no,
                 'out_order_no' => $out_order_no,
                 'top_id' => $v['top_id'],
-                'code' => $v['code'],
-                'title' => $v['title'],
+                'code' => '',
+                'title' => '',
+                'num' => $v['num'],
                 'type' => isset($v['type'])?$v['type'] : 1,
                 'crt_time' => $time,
                 'upd_time' => $time,
@@ -152,7 +154,8 @@ class BoxHookService extends Service
      * @return array
      */
     public function boxDetail($data){
-        $box = new Box();
+        $order_no = $data['order_no'];
+        $box = new BoxDetail(['channel'=>$order_no]);
         if(!isset($data['id'])) return [false,'id not found'];
         $list = $box->where('top_id',$data['id'])->get()->toArray();
 

+ 27 - 21
app/Service/Box/BoxService.php

@@ -42,8 +42,8 @@ class BoxService extends Service
     public function boxIn($data)
     {
 
-        if(!isset($data['param'])) return [false,'not found param'];
-        $param = $data['param'];
+//        if(!isset($data['params'])) return [false,'not found params'];
+//        $param = $data['params'];
 //        $param = [
 //            [
 //                'id' => 716,
@@ -62,26 +62,28 @@ class BoxService extends Service
 
         $ids = [];
         $key_list = [];
-        foreach ($param as $v) {
+        foreach ($data as $v) {
             $ids[] = $v['id'];
             $total = 0;
 
-            foreach ($v['param'] as $vv) {
+            foreach ($v['params'] as $vv) {
                 $total += $vv;
             }
             $key_list[$v['id']] = [
-                'detail' => $v['param'],
+                'detail' => $v['params'],
                 'total' => $total,
             ];
         }
-
+        $insert = [];
         try{
             DB::beginTransaction();
-            $product_list = SaleOrdersProduct::wherein('id', $ids)->get()->toArray();
+            $key = $this->lock_key.'_'.$v['id'];
+            $lock_status = $this->isLock($key);
+            if(!$lock_status) return [false,'操作过于频繁'];
+            $product_list = OrdersProduct::wherein('id', $ids)->get()->toArray();
+            $box_insert = [];
             foreach ($product_list as $v) {
-                $key = $this->lock_key.'_'.$v['id'];
-                $lock_status = $this->isLock($key);
-                if(!$lock_status) return [false,'操作过于频繁'];
+
                 $num_list = $key_list[$v['id']];
                 $total = $num_list['total'];
                 $detail = $num_list['detail'];
@@ -93,10 +95,10 @@ class BoxService extends Service
                 $ext_3 = $v['product_no'];
                 $ext_4 = $v['product_title'];
                 $ext_5 = $v['product_size'];
-                $out_order_no = $v['out_order_no'];
-                $top_id = $v['id'];
+                $out_order_no = $insert['out_order_no'] = $v['out_order_no'];
+                $top_id = $v['sale_orders_product_id'];
                 foreach ($detail as $vv){
-                    $box_insert = [
+                    $box_insert[] = [
                         'out_order_no' => $out_order_no,
                         'top_id' => $top_id,
                         'ext_1' => $ext_1,
@@ -107,22 +109,26 @@ class BoxService extends Service
                         'num' => $vv,
 
                     ];
-                    list($status,$msg) = self::$box_hook->boxInsert($box_insert);
 
-                    if(!$status) {
-                        $this->delLock($key);
-                        DB::rollBack();
-                        return [false,$msg];
-                    }
 
                 }
-                $this->delLock($key);
-                SaleOrdersProduct::where('id',$top_id)->update([
+                SaleOrdersProduct::where('id',$v['sale_orders_product_id'])->update([
                     'box_num' => DB::raw('box_num + '.$total),
                 ]);
 
 
+
+
+            }
+            $insert['detail'] = $box_insert;
+            list($status,$msg) = self::$box_hook->boxInsert($insert);
+
+            if(!$status) {
+                $this->delLock($key);
+                DB::rollBack();
+                return [false,$msg];
             }
+            $this->delLock($key);
 
             DB::commit();
             return [true,''];

+ 52 - 0
app/Service/Oa/OaService.php

@@ -19,6 +19,11 @@ use App\Service\Service;
 class OaService extends Service
 {
 
+    /**
+     * 审核列表
+     * @param $data
+     * @return array
+     */
     public function oaList($data)
     {
 
@@ -35,6 +40,11 @@ class OaService extends Service
     }
 
 
+    /**
+     * 审核详情
+     * @param $data
+     * @return array
+     */
     public function oaDetail($data)
     {
 
@@ -58,6 +68,11 @@ class OaService extends Service
 
     }
 
+    /**
+     * 审核新增
+     * @param $data
+     * @return array
+     */
     public function oaAdd($data)
     {
 
@@ -102,6 +117,11 @@ class OaService extends Service
     }
 
 
+    /**
+     * 审核流
+     * @param $data
+     * @return array
+     */
     public function oaEdit($data)
     {
         $first = Oa::where('del_time', 0)->where('id', '<>', $data['id'])->where('menu_id', $data['menu_id']);
@@ -145,6 +165,11 @@ class OaService extends Service
         return [true, '更新成功'];
     }
 
+    /**
+     * 删除审核
+     * @param $data
+     * @return array
+     */
     public function oaDel($data)
     {
         $id = $data['id'];
@@ -175,6 +200,11 @@ class OaService extends Service
     }
 
 
+    /**
+     * 进入审批流
+     * @param $data
+     * @return array
+     */
     public function createOaOrder($data)
     {
         $menu_id = $data['menu_id'];
@@ -245,6 +275,11 @@ class OaService extends Service
 
     }
 
+    /**
+     * 审核列表
+     * @param $data
+     * @return array
+     */
     public function oaOrderList($data){
         $list = OaOrder::from('oa_order as o')
             ->leftJoin('sys_menu as s','s.id','o.menu_id')
@@ -255,6 +290,11 @@ class OaService extends Service
         return [true,$list];
     }
 
+    /**
+     * 审核详情
+     * @param $data
+     * @return array
+     */
     public function oaOrderDetail($data,$user){
 
         $id = $data['id'];
@@ -277,6 +317,12 @@ class OaService extends Service
         return [true,$first];
     }
 
+
+    /**
+     * 审核
+     * @param $data
+     * @return array
+     */
     public function oaCheck($data,$user){
 
 
@@ -394,6 +440,12 @@ class OaService extends Service
         return [true,'审核成功!'];
     }
 
+    /**
+     * 处理审核中的每个流程
+     * @param $list
+     * @param $sub_list
+     * @return array
+     */
     public function dealBeforeOaUser($list,$sub_list){
 
         $sub_key_list = [];

+ 1 - 1
routes/api.php

@@ -191,5 +191,5 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     //包装相关
     $route->any('boxDetail', 'Api\BoxController@boxDetail');
     $route->any('boxProductList', 'Api\BoxController@boxProductList');
-    $route->any('boxIn', 'Api\BoxController@boxIn');
+    $route->any('box_in', 'Api\BoxController@boxIn');
 });