|
@@ -2,7 +2,9 @@
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
+use app\admin\model\ActionLog;
|
|
|
use think\facade\Db;
|
|
|
+use app\admin\model\ProcessOrder;
|
|
|
use think\facade\Validate;
|
|
|
|
|
|
//报备单
|
|
@@ -159,17 +161,14 @@ class Filing extends Base
|
|
|
$names = $userCommon->handle('getCodeAndName', ['code' => [$param['customerCode'], $param['supplierNo']]]);
|
|
|
if (!isset($names['data'][$param['customerCode']]) || $names['data'][$param['customerCode']] == '') return json_show(1004, '该业务公司不存在');
|
|
|
if (!isset($names['data'][$param['supplierNo']]) || $names['data'][$param['supplierNo']] == '') return json_show(1004, '该供应商不存在');
|
|
|
-
|
|
|
- $rs = Db::name('filing')
|
|
|
- ->strict(false)
|
|
|
- ->insert(array_merge($param, [
|
|
|
+ $data=array_merge($param, [
|
|
|
'customerName' => $names['data'][$param['customerCode']],
|
|
|
'supplierName' => $names['data'][$param['supplierNo']],
|
|
|
'filingCode' => makeNo('BM'),
|
|
|
'service_proportion' => $param['expect_service_proportion'],//服务费比例与期望服务费比例一致
|
|
|
'service_charge' => $param['expect_service'],//服务费与期望服务费一致
|
|
|
'specinfo' => json_encode($param['spec_list']),
|
|
|
- "wait_num"=>$param["num"],
|
|
|
+ 'wait_num'=>$param['num'],
|
|
|
'send_way' => 2,
|
|
|
'cert_fee' => 0,
|
|
|
'pakge_fee' => 0,
|
|
@@ -196,8 +195,21 @@ class Filing extends Base
|
|
|
'good_img' => implode(',', $param['good_img']),
|
|
|
'origin_place' => implode(',', $param['origin_place']),
|
|
|
'delivery_place' => implode(',', $param['delivery_place']),
|
|
|
- ]));
|
|
|
-
|
|
|
+ ]);
|
|
|
+ $rs = Db::name('filing')
|
|
|
+ ->strict(false)
|
|
|
+ ->insertGetId($data);
|
|
|
+ $stn = ['order_code' => $data['filingCode'], 'status' => 0, 'action_remark' => '', 'action_type' => 'add'];
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], $stn, 'BBD', 0, $data);
|
|
|
+ $process=[
|
|
|
+ 'order_type' => 'BBD',
|
|
|
+ 'order_code' => $data['filingCode'],//出库单号
|
|
|
+ 'order_id' => $rs ,
|
|
|
+ 'order_status' => 0,
|
|
|
+ 'before_status' => 0,
|
|
|
+ 'holder_id'=>0,
|
|
|
+ ];
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
|
|
|
return $rs ? json_show(0, '创建报备单成功') : json_show(1004, '创建报备单失败');
|
|
|
|
|
|
}
|
|
@@ -335,7 +347,17 @@ class Filing extends Base
|
|
|
]);
|
|
|
$rs = Db::name('filing')
|
|
|
->save(array_intersect_key($data,$row));
|
|
|
-
|
|
|
+ $stn = ['order_code' => $row['filingCode'], 'status' => 0, 'action_remark' => '', 'action_type' => 'edit'];
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], $stn, 'BBD', $row['status'], $data);
|
|
|
+ $process=[
|
|
|
+ 'order_type' => 'BBD',
|
|
|
+ 'order_code' => $row['filingCode'],//出库单号
|
|
|
+ 'order_id' => $row['id'],
|
|
|
+ 'order_status' => 0,
|
|
|
+ 'before_status' => $row['status'],
|
|
|
+ 'holder_id'=>0,
|
|
|
+ ];
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
|
|
|
return $rs ? json_show(0, '报备单更新成功') : json_show(1004, '报备单更新失败');
|
|
|
|
|
|
}
|
|
@@ -390,41 +412,63 @@ class Filing extends Base
|
|
|
|
|
|
if (!$val->check($param)) return json_show(1004, $val->getError());
|
|
|
$rs = Db::name('filing')
|
|
|
- ->field('id,status,is_determine_price,price,cgd_charge,platform_id,customerCode,customerName')
|
|
|
+ ->field('id,filingCode,status,is_determine_price,price,cgd_charge,platform_id,customerCode,customerName')
|
|
|
->where(['is_del' => 0, 'id' => $param['id'],"status"=>0])
|
|
|
->findOrEmpty();
|
|
|
if (empty($rs)) return json_show(1005, '该报备单不存在或不允许审核');
|
|
|
|
|
|
- $userCommon = \app\admin\common\User::getIns();
|
|
|
- $company = $userCommon->handle('cInfo', ['companyNo' => $param['companyCode']]);
|
|
|
- if (!isset($company['data'])) return json_show(1005, '该客户不存在');
|
|
|
- $tmp = Db::name('platform')
|
|
|
- ->where(['is_del' => 0, 'id' => $param['platform_id']])
|
|
|
- ->field('id,is_select_pay_rate,status')
|
|
|
- ->findOrEmpty();
|
|
|
- if (empty($tmp)) return json_show(1005, '该平台不存在');
|
|
|
- if ($tmp['status'] != 1) return error_show(1004, "平台信息已禁用");
|
|
|
- if($tmp['is_select_pay_rate']==1 && channel_is_company($param['platform_id'],$rs['customerCode']))return
|
|
|
- error_show(1004, "平台渠道包含当前业务公司 {$rs['customerName']}");
|
|
|
-
|
|
|
-
|
|
|
- //校验支付渠道中的业务公司是否与报备单业务公司重复
|
|
|
-
|
|
|
- $update = array_merge($param, [
|
|
|
- 'companyName' => $company['data']['companyName'],
|
|
|
- "status"=>$param["is_check"],
|
|
|
+ $update = array_merge($param, [
|
|
|
+ 'status'=>$param['is_check'],
|
|
|
'updaterid' => $this->uid,
|
|
|
'updater' => $this->uname,
|
|
|
'updatetime' => date('Y-m-d H:i:s'),
|
|
|
]);
|
|
|
+ //不合规则不处理原数据
|
|
|
+ if($param["is_check"]==2){
|
|
|
+ $userCommon = \app\admin\common\User::getIns();
|
|
|
+ $company = $userCommon->handle('cInfo', ['companyNo' => $param['companyCode']]);
|
|
|
+ if (!isset($company['data'])) return json_show(1005, '该客户不存在');
|
|
|
+ $update['companyName']=$company['data']['companyName']??"";
|
|
|
+ $tmp = Db::name('platform')
|
|
|
+ ->where(['is_del' => 0, 'id' => $param['platform_id']])
|
|
|
+ ->field('id,is_select_pay_rate,status')
|
|
|
+ ->findOrEmpty();
|
|
|
+ if (empty($tmp)) return json_show(1005, '该平台不存在');
|
|
|
+ if ($tmp['status'] != 1) return error_show(1004, '平台信息已禁用');
|
|
|
+ if($tmp['is_select_pay_rate']==1 && channel_is_company($param['platform_id'],$rs['customerCode']))return
|
|
|
+ error_show(1004, "平台渠道包含当前业务公司 {$rs['customerName']}");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //校验支付渠道中的业务公司是否与报备单业务公司重复
|
|
|
+//
|
|
|
+// $update = array_merge($param, [
|
|
|
+// 'companyName' => $companyName,
|
|
|
+// "status"=>$param["is_check"],
|
|
|
+// 'updaterid' => $this->uid,
|
|
|
+// 'updater' => $this->uname,
|
|
|
+// 'updatetime' => date('Y-m-d H:i:s'),
|
|
|
+// ]);
|
|
|
//
|
|
|
// if ($rs['is_determine_price'] == 1) $update['cgd_charge'] = round(bcsub($rs['price'], $param['service_charge'], 3), 2);//确定售价时,采购价=售价-服务费
|
|
|
// else $update['price'] = round(bcadd($rs['cgd_charge'], $param['service_charge'], 3), 2);//不确定售价时,售价=采购价+服务费
|
|
|
|
|
|
$res = Db::name('filing')
|
|
|
->where(['is_del' => 0, 'id' => $param['id']])
|
|
|
- ->whereIn('status', [0, 2])
|
|
|
+ ->whereIn('status', 0)
|
|
|
->update($update);
|
|
|
+ $stn = ['order_code' => $rs['filingCode'], 'status' =>$param['is_check'], 'action_remark' => '', 'action_type' => 'status'];
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], $stn, 'BBD', 0, $update);
|
|
|
+ $process=[
|
|
|
+ 'order_type' => 'BBD',
|
|
|
+ 'order_code' => $rs['filingCode'],//出库单号
|
|
|
+ 'order_id' => $rs['id'],
|
|
|
+ 'order_status' =>$param['is_check'],
|
|
|
+ 'before_status' =>$rs['status'],
|
|
|
+ 'holder_id'=>0,
|
|
|
+ ];
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
|
|
|
return $res ? json_show(0, '操作成功') : json_show(1004, '操作失败');
|
|
|
|
|
|
|
|
@@ -442,11 +486,11 @@ class Filing extends Base
|
|
|
$where = [
|
|
|
['is_del', '=', 0],
|
|
|
['id', '=', $param['id']],
|
|
|
- ['status', 'in', [0, 1, 2, 4]]
|
|
|
+ ['status', 'in', [0, 1, 2]]
|
|
|
];
|
|
|
|
|
|
$rs = Db::name('filing')
|
|
|
- ->field('id,status,supplierNo')
|
|
|
+ ->field('id,status,supplierNo,filingCode')
|
|
|
->where($where)
|
|
|
->findOrEmpty();
|
|
|
if (empty($rs)) return json_show(1005, '该报备单不存在或不允许取消');
|
|
@@ -459,6 +503,17 @@ class Filing extends Base
|
|
|
$res = Db::name('filing')
|
|
|
->where($where)
|
|
|
->update(['status' => 5, 'updatetime' => date('Y-m-d H:i:s'), 'updaterid' => $this->uid, 'updater' => $this->uname,]);
|
|
|
+ $stn = ['order_code' => $rs['filingCode'], 'status' =>5, 'action_remark' => '', 'action_type' =>'status'];
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], $stn, 'BBD', $rs['status'], $param);
|
|
|
+ $process=[
|
|
|
+ 'order_type' => 'BBD',
|
|
|
+ 'order_code' => $rs['filingCode'],//出库单号
|
|
|
+ 'order_id' => $rs['id'],
|
|
|
+ 'order_status' =>5,
|
|
|
+ 'before_status' =>$rs['status'],
|
|
|
+ 'holder_id'=>0,
|
|
|
+ ];
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
|
|
|
return $res ? json_show(0, '操作成功') : json_show(1004, '操作失败');
|
|
|
}
|
|
|
|
|
@@ -628,7 +683,21 @@ class Filing extends Base
|
|
|
'good_creater' => $filing['updater'],
|
|
|
]);
|
|
|
if($sale_id==false) throw new \Exception('订单生成失败');
|
|
|
-
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
|
|
|
+ 'order_code' => $orderCode,//销售单code
|
|
|
+ 'status' => 0,//这里的status是之前的值
|
|
|
+ 'action_remark' => '',//备注
|
|
|
+ 'action_type' => 'create'//新建create,编辑edit,更改状态status
|
|
|
+ ], 'XSQRD', 0, $this->post);
|
|
|
+
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
|
|
|
+ 'order_type' => 'XSQRD',
|
|
|
+ 'order_code' => $orderCode,//销售单code
|
|
|
+ 'order_id' => $sale_id,
|
|
|
+ 'order_status' => 0,
|
|
|
+ 'before_status' => 0,
|
|
|
+ 'holder_id' => $this->uid
|
|
|
+ ]);
|
|
|
//仓库
|
|
|
$wsm = Db::name('warehouse_info')
|
|
|
->field('id,wsm_code')
|
|
@@ -636,7 +705,6 @@ class Filing extends Base
|
|
|
->findOrEmpty();
|
|
|
if (empty($wsm)) {
|
|
|
$wsm_code = makeNo('WSM');
|
|
|
-
|
|
|
$ws= Db::name('warehouse_info')->insert([
|
|
|
'wsm_code' => $wsm_code,
|
|
|
'name' => $supplier['data']['name'],
|
|
@@ -660,7 +728,7 @@ class Filing extends Base
|
|
|
//采购单
|
|
|
$cgdCode = makeNo('CG');
|
|
|
|
|
|
- $cg= Db::name('purchease_order')->insert([
|
|
|
+ $cg= Db::name('purchease_order')->insertGetId([
|
|
|
'cgdNo' => $cgdCode,
|
|
|
'bkcode' => '',
|
|
|
'wsm_code' => $wsm_code,
|
|
@@ -700,6 +768,24 @@ class Filing extends Base
|
|
|
'good_creater' => $filing['updater'],
|
|
|
]);
|
|
|
if($cg==false)throw new \Exception('采购单生成失败');
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
|
|
|
+ 'order_code' =>$cgdCode,//销售单code
|
|
|
+ 'status' => 0,//这里的status是之前的值
|
|
|
+ 'action_remark' => '',//备注
|
|
|
+ 'action_type' => 'create'//新建create,编辑edit,更改状态status
|
|
|
+ ], 'CGD', 0, $param);
|
|
|
+
|
|
|
+ //当节点是0待与供应商确认,推给供应商负责人
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
|
|
|
+ 'order_type' => 'CGD',
|
|
|
+ 'order_code' => $cgdCode,//销售单code
|
|
|
+ 'order_id' => $cg,
|
|
|
+ 'order_status' => 0,
|
|
|
+ 'before_status' => 0,
|
|
|
+ 'holder_id' => $this->uid,
|
|
|
+ 'wait_id'=>$this->uid,
|
|
|
+ 'wait_name'=>$this->uname,
|
|
|
+ ]);
|
|
|
//台账
|
|
|
$standing_bood_data = [
|
|
|
'standBookNo' => makeNo('IO'),
|
|
@@ -738,7 +824,7 @@ class Filing extends Base
|
|
|
//改变编码规则,将原来的编码后两位换成序列号
|
|
|
//str_pad字符串填充
|
|
|
$outCode = substr($outCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
- $send= Db::name('order_out')->insert([
|
|
|
+ $send= Db::name('order_out')->insertGetId([
|
|
|
'orderCode' => $orderCode,
|
|
|
'outCode' => $outCode,
|
|
|
'apply_id' => $filing['updaterid'],
|
|
@@ -758,6 +844,15 @@ class Filing extends Base
|
|
|
'updatetime' => $date,
|
|
|
]);
|
|
|
if($send==false) throw new \Exception('发货单生成失败');
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname], [
|
|
|
+ 'order_type' => 'CKD',
|
|
|
+ 'order_code' => $outCode,//出库单号
|
|
|
+ 'order_id' => $send,
|
|
|
+ 'order_status' => 0,
|
|
|
+ 'before_status' => 0,
|
|
|
+ 'wait_id'=>0,
|
|
|
+ 'wait_name'=>0,
|
|
|
+ ]);
|
|
|
$standing_bood_data['outCode'][] = $outCode;
|
|
|
$order_send_insert[] = [
|
|
|
'cgdNo' => $cgdCode,
|
|
@@ -787,7 +882,17 @@ class Filing extends Base
|
|
|
|
|
|
if($fillup==false)throw new \Exception('报备单更新失败');
|
|
|
//待办已办先不处理
|
|
|
-
|
|
|
+ $stn = ['order_code' => $filing['filingCode'], 'status' =>$wait_num>0?3:4, 'action_remark' => '', 'action_type' => 'status'];
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], $stn, 'BBD', $filing['status'], $param);
|
|
|
+ $process=[
|
|
|
+ 'order_type' => 'BBD',
|
|
|
+ 'order_code' => $filing['filingCode'],//出库单号
|
|
|
+ 'order_id' => $filing['id'],
|
|
|
+ 'order_status' =>$wait_num>0?3:4,
|
|
|
+ 'before_status' =>$filing['status'],
|
|
|
+ 'holder_id'=>0,
|
|
|
+ ];
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
|
|
|
//关联表
|
|
|
$gu= Db::name('order_num')
|
|
|
->insert([
|