瀏覽代碼

申请人 ---- 申购申请录入页面,导入文档录入之后,提交报错

zhanglinxin 1 年之前
父節點
當前提交
4a10065053
共有 2 個文件被更改,包括 14 次插入14 次删除
  1. 13 12
      application/common/service/ApproveInfoService.php
  2. 1 2
      application/common/service/GoodsCategoryService.php

+ 13 - 12
application/common/service/ApproveInfoService.php

@@ -34,7 +34,7 @@ class ApproveInfoService
      * @param mixed $user 用户信息
      * @param string $way 方式:create=申请,update=重新发起
      **/
-    public static function create($id, $module, $params, $user,$way)
+    public static function create($id, $module, $params, $user, $way)
     {
         $userid = $user['userid'];
         $apply_user_id = $userid;
@@ -145,14 +145,15 @@ class ApproveInfoService
             }
             Db::commit();
         } catch (Exception $e) {
-            except('出现错误:' . $e->getMessage());
+            Db::rollback();
+            except('出现错误:' . $e->getMessage() . '|' . $e->getFile() . '|' . $e->getLine());
         }
 
-        if($way == CommonConstant::create){
+        if ($way == CommonConstant::create) {
             if ($module == CommonConstant::MODULE_9) {
                 // 生成合同编号
                 $contract_no = CommonService::get_contract_no($params['type']);
-                $info->save(['reason'=>$contract_no]);
+                $info->save(['reason' => $contract_no]);
             }
         }
 
@@ -368,9 +369,8 @@ class ApproveInfoService
                 ->with([
                     'goodsStock',
                 ])
-                ->select()
-                ->toArray();
-            $goods_object = $goods_list ? array_column($goods_list, null, 'id') : [];
+                ->select();
+            $goods_object = $goods_list ? array_column($goods_list->toArray(), null, 'id') : [];
             $goods_name = '';
             $goods_stock_name = '';
             $apply_goods_data = [];
@@ -433,7 +433,7 @@ class ApproveInfoService
 
         // 批量导入
         if ($category_first_data) {
-            $category_first_list = GoodsCategoryService::get_list([['name', 'in', array_keys($category_first_data)]],1);
+            $category_first_list = GoodsCategoryService::get_list([['name', 'in', array_keys($category_first_data)]], 1);
             $category_first_object = $category_first_list ? array_column($category_first_list->toArray(), null, 'name') : [];
             foreach ($category_first_data as $key => $value) {
                 if (array_key_exists($key, $category_first_object)) {
@@ -493,10 +493,11 @@ class ApproveInfoService
             if ($value['flag'] == '2') {
                 // 批量导入
                 if (array_key_exists($value['goods_category_first'], $category_object)) {
-                    $category_info = $category_object[$value['goods_category_first']];
-                    $goods_category_first_id = $category_info['id'];
-                    $category_info_object = array_column($category_info['childlist'], null, 'name');
-                    $goods_category_id = $category_info_object[$value['goods_category_id']];
+                    $category_first_info = $category_object[$value['goods_category_first']];
+                    $goods_category_first_id = $category_first_info['id'];
+                    $category_second_object = array_column($category_first_info['childlist'], null, 'name');
+                    $category_second_info = $category_second_object[$value['goods_category_id']];
+                    $goods_category_id = $category_second_info['id'];
 
                     $goods_ids_new[$key] = $value;
                     $goods_ids_new[$key]['goods_category_first'] = $goods_category_first_id;

+ 1 - 2
application/common/service/GoodsCategoryService.php

@@ -15,11 +15,10 @@ class GoodsCategoryService
      * 商品分类列表
      *
      * @param array $where
-     * @param integer $child 0=一级,1=二级
+     * @param integer $child 是否有二级:0=一级,1=二级
      **/
     public static function get_list($where = [], $child = 0)
     {
-
         $list = GoodsCategory::field('is_deleted,create_at', true)
             ->where('is_deleted', CommonConstant::IS_DELETED_0)
             ->where('pid', 0)