Browse Source

报备单优化

wufeng 2 years ago
parent
commit
5bc36af49d
2 changed files with 14 additions and 19 deletions
  1. 8 6
      app/abutment/controller/Filing.php
  2. 6 13
      app/abutment/logic/Filing.php

+ 8 - 6
app/abutment/controller/Filing.php

@@ -22,10 +22,11 @@ class Filing extends HomeBaseController
     //添加
     public function add()
     {
-        $param = $this->request->only(['companyName', 'num', 'is_determine_price', 'price' => 0, 'service_proportion', 'expect_service', 'cgd_charge' => 0, 'brand_id', 'preservation_day', 'delivery_day', 'make_day', 'tax', 'unit_id', 'cat_id', 'spec_list' => [], 'good_name', 'origin_place', 'delivery_place', 'weight', 'supply_area', 'pay_way', 'nake_fee', 'gold_weight', 'noble_metal', 'config', 'other_config', 'remark', 'cost_desc', 'good_img', 'supplierNo', 'supplierName'], 'post');
+        $param = $this->request->only(['customerCode','companyName', 'num', 'is_determine_price', 'price' => 0, 'service_proportion', 'expect_service', 'cgd_charge' => 0, 'brand_id', 'preservation_day', 'delivery_day', 'make_day', 'tax', 'unit_id', 'cat_id', 'spec_list' => [], 'good_name', 'origin_place', 'delivery_place', 'weight', 'supply_area', 'pay_way', 'gold_weight', 'noble_metal', 'config', 'other_config', 'remark', 'cost_desc', 'good_img'], 'post');
 
         $val = Validate::rule([
-            'companyName|业务公司' => 'require|max:255',
+            'customerCode|业务公司' => 'require|max:255',
+            'companyName|客户名称' => 'require|max:255',
             'num|销售数量' => 'require|number|gt:0|lt:999999999',
             'is_determine_price|是否确定售价' => 'require|number|in:1,0',
             'price|销售价' => 'requireIf:is_determine_price,1|float|max:99999999.99',
@@ -46,16 +47,14 @@ class Filing extends HomeBaseController
             'weight|总重量' => 'require|float|max:99999999.99',
             'supply_area|供货区域' => 'require|number|in:1,2',
             'pay_way|付款方式' => 'require|number|in:1,2,3',
-            'nake_fee|裸价' => 'require|float|max:99999999.99',
             'gold_weight|贵金属重量' => 'float|max:99999999.99',
-            'noble_metal|贵金属类型' => 'require|number|in:1,2,3',
+            'noble_metal|贵金属类型' => 'number|in:1,2,3',
             'config|配置要求' => 'require|max:255',
             'other_config|其他配置要求' => 'require|max:255',
             'remark|采购备注' => 'require|max:255',
             'cost_desc|工艺说明' => 'max:255',
             'good_img|商品图片' => 'require|max:255',
-            'supplierNo|供应商编码' => 'require|max:255',
-            'supplierName|供应商名称' => 'require|max:255',
+
         ]);
 
         if (!$val->check($param)) return json_show(1004, $val->getError());
@@ -79,6 +78,9 @@ class Filing extends HomeBaseController
             $spec_list['spec_value_name'] = $all_spec_value[$spec_list['spec_value_id']] ?? '';
         }
 
+        $param['supplierNo']= $this->request->user['supplierNo'];
+        $param['supplierName']= $this->request->user['supplierName'];
+
         return FilingLogic::add($param);
 
     }

+ 6 - 13
app/abutment/logic/Filing.php

@@ -53,9 +53,15 @@ class Filing
         if ($data['is_determine_price'] == 1) $data['cgd_charge'] = bcadd($data['price'], $data['expect_service'], 2);//确定售价时,采购价=售价+服务费
         else $data['price'] = bcsub($data['cgd_charge'], $data['expect_service'], 2);//不确定售价时,售价=采购价-服务费
 
+        $customerName = Db::name('business')
+            ->where(['companyNo' => $data['customerCode']])
+            ->value('company', '');
+        if ($customerName == '') return json_show(1004, '该业务公司不存在');
+
         $rs = Db::name('filing')
             ->strict(false)
             ->insert(array_merge($data, [
+                'customerName' => $customerName,
                 'filingCode' => makeNo('BM'),
                 'service_charge' => $data['expect_service'],//服务费与期望服务费一致
                 'specinfo' => json_encode($data['spec_list']),
@@ -97,19 +103,6 @@ class Filing
     //审核
     public static function status(array $data = [])
     {
-        //companyCode
-        /**
-         *
-         * $param = $this->request->only(['id', 'status', 'companyCode', 'plat_code' => '', 'service_charge', 'service_proportion', 'is_first_examine'], 'post');
-         *
-         * $val = Validate::rule([
-         * 'id' => 'require|number|gt:0',
-         * 'status|状态' => 'require|number|in:1,2',
-         * 'companyCode|客户' => 'require|length:18',
-         * 'service_charge|服务费' => 'require|float|max:99999999.99',
-         * 'service_proportion|服务费比例' => 'require|number|between:0,100',
-         * ]);
-         */
 
         $rs = Db::name('filing')
             ->field('id,status')