|
@@ -611,19 +611,9 @@ class Purch extends Base
|
|
|
$data['updatetime'] =date("Y-m-d H:i:s");
|
|
|
$upd=Db::name("purchease_order")->save($data);
|
|
|
if($upd){
|
|
|
-// ActionLog::logAdd($this->post['token'],$order,'cgd',$data['status'],$this->post);
|
|
|
-
|
|
|
//修改状态,添加待办
|
|
|
ActionLog::logAdd($this->post['token'], $order, "CGD", $data['status'], $this->post);
|
|
|
|
|
|
-// ProcessOrder::AddProcess($this->post['token'], [
|
|
|
-// "order_type" => 'CGD',
|
|
|
-// "order_code" => $cgdNo,//销售单code
|
|
|
-// "order_id" => $data['id'],
|
|
|
-// "order_status" => $data['status'],"before_status"=>1
|
|
|
-// ]);
|
|
|
-
|
|
|
-
|
|
|
return app_show(0,"更新成功");
|
|
|
}else{
|
|
|
return error_show(1004,'更新失败');
|
|
@@ -681,10 +671,6 @@ class Purch extends Base
|
|
|
}
|
|
|
|
|
|
//供应商信息
|
|
|
-// $supplier_rs = Db::name('supplier')
|
|
|
-// ->field('id,name supplierName,code supplierNo,person,personid')
|
|
|
-// ->where(['is_del' => 0, 'code' => $param['supplierNo']])
|
|
|
-// ->find();
|
|
|
$userCommon= \app\admin\common\User::getIns();
|
|
|
$supplier_temp =$userCommon->handle("sInfo",["code"=>$param['supplierNo']]);
|
|
|
|
|
@@ -738,17 +724,8 @@ class Purch extends Base
|
|
|
'creater_id' => $creater_id,
|
|
|
'creater' => $creater,
|
|
|
]);
|
|
|
-
|
|
|
//记录日志
|
|
|
ActionLog::logAdd(['id' => $creater_id, 'nickname' => $creater], $rs, "CGD", $rs['status'], $param);
|
|
|
-
|
|
|
-// ProcessOrder::AddProcess($this->post['token'], [
|
|
|
-// "order_type" => 'CGD',
|
|
|
-// "order_code" => $param['cgdNo'],//销售单code
|
|
|
-// "order_id" => $rs['id'],
|
|
|
-// "order_status" => $rs['status']
|
|
|
-// ]);
|
|
|
-
|
|
|
//维护台账
|
|
|
Db::name('standing_book')
|
|
|
->where('cgdNo', $param['cgdNo'])
|
|
@@ -790,15 +767,7 @@ class Purch extends Base
|
|
|
if (!empty($data)) throw new Exception($data['cgdNo'] . "采购单发货中无法取消");
|
|
|
|
|
|
}
|
|
|
-// if($data['send_status']>1 && $status==0){
|
|
|
-// return error_show(1004,"采购单发货中无法取消");
|
|
|
-// }
|
|
|
-// $order = ["order_code"=>$cgdNo,"status"=> $data['status'] ,"action_remark"=>$remark,"action_type"=>"status"];
|
|
|
-// $data['status'] = $status;
|
|
|
-// $data['remark'] = $remark;
|
|
|
-// $data['updatetime'] =date("Y-m-d H:i:s");
|
|
|
-
|
|
|
- //原始数据
|
|
|
+ //原始数据
|
|
|
$info = Db::name("purchease_order")
|
|
|
->whereIn('cgdNo', $cgdNo)
|
|
|
->column('id,cgdNo,status,supplierNo,spuCode,order_type', 'cgdNo');
|
|
@@ -815,16 +784,7 @@ class Purch extends Base
|
|
|
//获取供应商的负责人
|
|
|
$userCommon = \app\admin\common\User::getIns();
|
|
|
$supplier = $userCommon->handle('sGetList',['more_code'=>array_column($info, 'supplierNo')]);
|
|
|
-
|
|
|
$supplier_cgderid = array_column($supplier['data']['list'],'personid','code');
|
|
|
-// $supplier_cgderid = Db::name('supplier')
|
|
|
-// ->where('is_del', 0)
|
|
|
-// ->whereIn('code', array_column($info, 'supplierNo'))
|
|
|
-// ->column('personid', 'code');
|
|
|
-// ->leftJoin('supplier sip', 'sip.code=po.supplierNo')
|
|
|
-// ->field('po.*,on.orderCode,u.itemid,sip.personid as supplier_cgderid,sip.person as supplier_cgder')
|
|
|
-
|
|
|
-// $user=GetUserInfo($this->post['token']);
|
|
|
$uid = $this->uid;
|
|
|
$uname = $this->uname;
|
|
|
|
|
@@ -839,48 +799,17 @@ class Purch extends Base
|
|
|
if($status == 1){
|
|
|
//如果开通了供应商账号,则只允许level3账号操作,level2账号不允许操作
|
|
|
if (isset($all_has_supplier_account[$info[$vlue]['supplierNo']]) && $this->level == 2) throw new Exception('已开通供应商账号,当前账号不能操作');
|
|
|
-// if($this->level == 2 && $uid != $supplier_cgderid[$info[$vlue]['supplierNo']]) throw new Exception('只能由供应商负责人来操作');//与供应商确认的这个操作,只能由供应商负责人来操作
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
if ($status == 1 || $status == 2) {
|
|
|
-// $orderinfo = Db::name('sale')
|
|
|
-// ->alias('a')
|
|
|
-// ->field('a.id,a.orderCode,a.is_stock,a.order_type,a.cgderid')
|
|
|
-// ->leftJoin('order_num b','b.orderCode=a.orderCode')
|
|
|
-// ->where([
|
|
|
-// 'a.is_del'=>0,
|
|
|
-// 'b.cgdNo'=>$vlue,
|
|
|
-// ])->findOrEmpty();
|
|
|
-// $is_stock = Db::name('good_basic')
|
|
|
-// ->where(['is_del' => 0, 'spuCode' => $info[$vlue]['spuCode']])
|
|
|
-// ->value('is_stock');
|
|
|
-
|
|
|
-// if ($is_stock == 1) {
|
|
|
-// //库存品,推给31库管人员、41库管-张凯旋
|
|
|
-// $uids = Db::name('user_role')
|
|
|
-// ->where([
|
|
|
-// ['is_del', '=', 0],
|
|
|
-// ['roleid', 'in', [31, 41]],
|
|
|
-// ['status', '=', 1]
|
|
|
-// ])->column('uid');
|
|
|
-//// if (!in_array($this->uid, $uids)) throw new Exception('库存品订单只能由库管人员操作');
|
|
|
-// $process = ["order_code" => $vlue, "order_id" => isset($info[$vlue]['id']) ? $info[$vlue]['id'] : 0, "order_status" => $status, "order_type" => 'CGD', "before_status" => isset($info[$vlue]['status']) ? $info[$vlue]['status'] : 0, 'holder_id' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0, 'handle_user_list' => implode(',', $uids)];
|
|
|
-// } elseif ($is_stock == 0 || $info[$vlue]['order_type'] == 3) {
|
|
|
- //非库存品和采返商品,推给供应商负责人
|
|
|
-// if ($this->uid != $supplier_cgderid[$info[$vlue]['supplierNo']]) throw new Exception('非库存品和采返商品只能由供应商负责人操作');
|
|
|
-
|
|
|
- $process = ["order_code" => $vlue, "order_id" => isset($info[$vlue]['id']) ? $info[$vlue]['id'] : 0, "order_status" => $status, "order_type" => 'CGD', "before_status" => isset($info[$vlue]['status']) ? $info[$vlue]['status'] : 0, 'holder_id' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0, 'handle_user_list' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0];
|
|
|
-// }
|
|
|
+ $process = ["order_code" => $vlue, "order_id" => isset($info[$vlue]['id']) ? $info[$vlue]['id'] : 0, "order_status" => $status, "order_type" => 'CGD', "before_status" => isset($info[$vlue]['status']) ? $info[$vlue]['status'] : 0, 'holder_id' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0, 'handle_user_list' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0];
|
|
|
} else $process = ["order_code" => $vlue, "order_id" => isset($info[$vlue]['id']) ? $info[$vlue]['id'] : 0, "order_status" => $status, "order_type" => 'CGD', "before_status" => isset($info[$vlue]['status']) ? $info[$vlue]['status'] : 0, 'holder_id' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0];
|
|
|
|
|
|
ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $uname], $process);
|
|
|
$order = ["order_code" => $vlue, "status" => '', "action_remark" => $remark, "action_type" => "status"];
|
|
|
ActionLog::logAdd(['id' => $uid, 'nickname' => $uname], $order, 'CGD', $status, $this->post);
|
|
|
}
|
|
|
-// return app_show(0, "更新成功");
|
|
|
} else throw new Exception('更新失败');
|
|
|
-// return error_show(1004, '更新失败');
|
|
|
-
|
|
|
Db::commit();
|
|
|
return app_show(0, "更新成功");
|
|
|
} catch (Exception $exception) {
|
|
@@ -892,7 +821,6 @@ class Purch extends Base
|
|
|
//创建采购工差单
|
|
|
public function diffcreat(){
|
|
|
$token = isset($this->post['token']) && $this->post['token'] !=="" ?trim($this->post['token']):"";
|
|
|
- //$cgdNo=makeNo("CG");
|
|
|
$cgdNo = $this->post['cgdNo'] && $this->post['cgdNo'] !=="" ? trim($this->post['cgdNo']) :"";
|
|
|
if($cgdNo==""){
|
|
|
return error_show(1002,"参数good_code不能为空");
|