|
@@ -2,7 +2,9 @@
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
-use app\admin\model\ActionLog;use think\facade\Db;
|
|
|
+use app\admin\model\ActionLog;
|
|
|
+use think\facade\Db;
|
|
|
+use app\admin\model\ProcessOrder;
|
|
|
use think\facade\Validate;
|
|
|
|
|
|
//报备单
|
|
@@ -196,9 +198,18 @@ class Filing extends Base
|
|
|
]);
|
|
|
$rs = Db::name('filing')
|
|
|
->strict(false)
|
|
|
- ->insert($data);
|
|
|
+ ->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, '创建报备单失败');
|
|
|
|
|
|
}
|
|
@@ -337,7 +348,16 @@ 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', 0, $data);
|
|
|
+ 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, '报备单更新失败');
|
|
|
|
|
|
}
|
|
@@ -403,6 +423,7 @@ class Filing extends Base
|
|
|
'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']]);
|
|
@@ -439,6 +460,15 @@ class Filing extends Base
|
|
|
->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, '操作失败');
|
|
|
|
|
|
|
|
@@ -460,7 +490,7 @@ class Filing extends Base
|
|
|
];
|
|
|
|
|
|
$rs = Db::name('filing')
|
|
|
- ->field('id,status,supplierNo')
|
|
|
+ ->field('id,status,supplierNo,filingCode')
|
|
|
->where($where)
|
|
|
->findOrEmpty();
|
|
|
if (empty($rs)) return json_show(1005, '该报备单不存在或不允许取消');
|
|
@@ -473,9 +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);
|
|
|
+ $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, '操作失败');
|
|
|
}
|
|
|
|
|
@@ -645,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')
|
|
@@ -653,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'],
|
|
@@ -677,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,
|
|
@@ -717,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' => $cg['status'],
|
|
|
+ 'before_status' => 0,
|
|
|
+ 'holder_id' => $this->uid,
|
|
|
+ 'wait_id'=>$this->uid,
|
|
|
+ 'wait_name'=>$this->uid,
|
|
|
+ ]);
|
|
|
//台账
|
|
|
$standing_bood_data = [
|
|
|
'standBookNo' => makeNo('IO'),
|
|
@@ -755,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'],
|
|
@@ -775,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,
|
|
@@ -806,6 +884,15 @@ class Filing extends Base
|
|
|
//待办已办先不处理
|
|
|
$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([
|