123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- namespace app\abutment\controller;
- use think\facade\Db;
- use think\facade\Validate;
- use app\abutment\logic\Filing as FilingLogic;
- class Filing extends HomeBaseController
- {
- //列表
- public function getList()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'cat_id' => '', 'start_date' => '', 'end_date' => '', 'filingCode' => '', 'status' => '', 'good_name' => '', 'companyName' => '', 'companyCode' => '', 'orderCode' => ''], 'post');
- $param['supplierNo'] = $this->request->user['supplierNo'];
- return FilingLogic::list($param);
- }
- //添加
- public function add()
- {
- $param = $this->request->only(['customerCode','companyName', 'num', 'is_determine_price', 'price' => 0, 'expect_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([
- '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',
- 'expect_service_proportion|期望服务费比例' => 'require|float|between:0,100',
- 'expect_service|期望服务费' => 'require|float|max:99999999.99',
- 'cgd_charge|采购价' => 'requireIf:is_determine_price,0|float|max:99999999.99',
- 'brand_id|品牌' => 'require|number|gt:0',
- 'preservation_day|有效期' => 'require|number|max:999999999',
- 'delivery_day|物流时间' => 'require|number|max:999999999',
- 'make_day|生产工期' => 'require|number|max:999999999',
- 'tax|税点' => 'require|number|between:0,100',
- 'unit_id|单位' => 'require|number|gt:0',
- 'cat_id|分类' => 'require|number|gt:0',
- 'spec_list|规格类型' => 'array|max:100',
- 'good_name|商品名称' => 'require|max:255',
- 'origin_place|产地' => 'require|array|length:3',
- 'delivery_place|发货地' => 'require|array|length:3',
- 'weight|总重量' => 'require|float|max:99999999.99',
- 'supply_area|供货区域' => 'require|number|in:1,2',
- 'pay_way|付款方式' => 'require|number|in:0,1,2',
- 'remark|采购备注' => 'require|max:255',
- 'cost_desc|工艺说明' => 'max:255',
- 'good_img|商品图片' => 'require|array|max:10',
- ]);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- //如果是贵金属的话,额外判断
- $cat=made($param['cat_id']);
- if(isset($cat[0]['id']) && $cat[0]['id']==6){
- $val_gold = Validate::rule([
- 'gold_weight|贵金属重量' => 'require|float|max:99999999.99',
- 'noble_metal|贵金属类型' => 'require|number|in:1,2,3',
- 'config|配置要求' => 'require|max:255',
- 'other_config|其他配置要求' => 'require|max:255',
- ]);
- if(!$val_gold->check($param)) return json_show(1004,$val_gold->getError());
- }
- $val2 = Validate::rule([
- 'spec_id|规格id' => 'require|number|gt:0',
- 'spec_value_id|规格值id' => 'require|number|gt:0',
- ]);
- $all_spec = Db::name('specs')
- ->whereIn('id', array_column($param['spec_list'], 'spec_id'))
- ->column('spec_name', 'id');
- $all_spec_value = Db::name('spec_value')
- ->whereIn('id', array_column($param['spec_list'], 'spec_value_id'))
- ->column('spec_value', 'id');
- foreach ($param['spec_list'] as &$spec_list) {
- if (!$val2->check($spec_list)) return json_show(1004, $val2->getError());
- $spec_list['spec_name'] = $all_spec[$spec_list['spec_id']] ?? '';
- $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);
- }
- //详情
- public function detail()
- {
- $param = $this->request->only(['id'], 'post');
- $param['supplierNo'] = $this->request->user['supplierNo'];
- return FilingLogic::detail($param);
- }
- //取消转单
- public function cancel()
- {
- $param = $this->request->only(['id'], 'post');
- $param['supplierNo'] = $this->request->user['supplierNo'];
- return FilingLogic::cancel($param);
- }
- //转单
- public function transfer()
- {
- $param = $this->request->only(['id', 'addr_list'], 'post');
- $val = Validate::rule([
- 'id' => 'require|number|gt:0',
- 'addr_list|收货地址' => 'require|array|max:100',
- ]);
- if (!$val->check($param)) return json_show(1004, $val->getError());
- $val2 = Validate::rule([
- 'receipt_quantity|收货数量' => 'require|number|gt:0|max:999999999',
- 'contactor|联系人' => 'require|max:255',
- 'mobile|联系电话' => 'require|mobile',
- 'addr_code|收货省市区编码' => 'require|array|length:3',
- 'addr|详细地址' => 'require|max:255',
- ]);
- foreach ($param['addr_list'] as $addr_list) {
- if (!$val2->check($addr_list)) return json_show(1004, $val2->getError());
- }
- $param['supplierNo'] = $this->request->user['supplierNo'];
- return FilingLogic::transfer($param);
- }
- }
|