|
@@ -1,11 +1,14 @@
|
|
|
<?php
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
+use app\abutment\model\SupplierRelationUser as SupplierRelationUserModel;
|
|
|
+use app\abutment\model\SupplierUser as SupplierUserModel;
|
|
|
use app\admin\model\ActionLog;
|
|
|
use app\admin\model\DataGroup as DataGroupModel;
|
|
|
use app\admin\model\GoodLog;
|
|
|
-use app\admin\model\ProcessOrder;
|
|
|
+use app\admin\model\GoodStockInfo;use app\admin\model\ProcessOrder;
|
|
|
use app\BaseController;
|
|
|
+use think\Exception;
|
|
|
use think\facade\Db;
|
|
|
use think\App;
|
|
|
|
|
@@ -94,6 +97,7 @@ class Purchin extends Base
|
|
|
$company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
|
|
|
if ($company_name !== "") $where[] = ["a.apply_id", 'in', get_company_item_user_by_name($company_name)];
|
|
|
|
|
|
+ //$count = Db::name('purchease_in')->alias('a')->join("purchease_order b","b.cgdNo=a.cgdNo","left")
|
|
|
$count = Db::name('purchease_in')
|
|
|
->alias('a')
|
|
|
->join("purchease_order b","b.cgdNo=a.cgdNo","left")
|
|
@@ -106,6 +110,7 @@ class Purchin extends Base
|
|
|
$list = Db::name('purchease_in')
|
|
|
->alias('a')
|
|
|
->join("purchease_order b","b.cgdNo=a.cgdNo","left")
|
|
|
+ ->leftJoin('supplier sip', 'sip.code=b.supplierNo')
|
|
|
->leftJoin("warehouse_info c","a.wsm_code=c.wsm_code")
|
|
|
->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
|
|
|
->where($where)
|
|
@@ -186,11 +191,8 @@ class Purchin extends Base
|
|
|
return error_show(1005,"采购单未发货");
|
|
|
}
|
|
|
|
|
|
- $wsm_in_code = makeNo("CF");
|
|
|
-// $wsm_code = isset($this->post['wsm_code'])&&$this->post['wsm_code']!="" ? trim($this->post['wsm_code']):"";
|
|
|
-// if($wsm_code==""){
|
|
|
-// return error_show(1004,"参数 wsm_code 不能为空");
|
|
|
-// }
|
|
|
+ $wsm_in_code = makeNo("CF");
|
|
|
+ $bn_code = makeNo("BN");
|
|
|
$wsminfo = Db::name("warehouse_info")->where(["wsm_code"=>$cgdinfo['wsm_code'],"is_del"=>0])->find();
|
|
|
if(empty($wsminfo)){
|
|
|
return error_show(1004,"未找到仓库信息");
|
|
@@ -202,11 +204,11 @@ class Purchin extends Base
|
|
|
return error_show(1004,"参数 sendtype 不能为空");
|
|
|
}
|
|
|
|
|
|
- $data = GetUserInfo($this->post['token']);
|
|
|
- if((!empty($data) && $data['code']!=0) ||empty($data) ){
|
|
|
- return error_show($data['code'],$data['message']);
|
|
|
- }
|
|
|
- $userinfo = $data['data'];
|
|
|
+// $data = GetUserInfo($this->post['token']);
|
|
|
+// if((!empty($data) && $data['code']!=0) ||empty($data) ){
|
|
|
+// return error_show($data['code'],$data['message']);
|
|
|
+// }
|
|
|
+// $userinfo = $data['data'];
|
|
|
$post_company = isset($this->post['post_company'])&&$this->post['post_company']!="" ? trim($this->post['post_company']):"";
|
|
|
$post_code = isset($this->post['post_code'])&&$this->post['post_code']!="" ? trim($this->post['post_code']):"";
|
|
|
$post_fee = isset($this->post['post_fee'])&&$this->post['post_fee']!="" ? $this->post['post_fee']:"0";
|
|
@@ -221,24 +223,13 @@ class Purchin extends Base
|
|
|
if($send_num>$cgdinfo['wsend_num']-$wsmin_num){
|
|
|
return error_show(1009,"采购单剩余未发货数量不足");
|
|
|
}
|
|
|
-// if($cgdinfo['order_type']==1||$cgdinfo['order_type']==2 ){
|
|
|
-// $goodinfo = Db::name("good_basic")->where(["spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
|
|
|
-// if($goodinfo==false){
|
|
|
-// return error_show(1004,"商品数据未找到");
|
|
|
-// }
|
|
|
-// if($goodinfo['is_stock']==0){
|
|
|
-// $status=4;
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// $send_way = Db::name("good_zixun")->where(["spuCode" => $cgdinfo['spuCode'], "is_del" => 0])->value('send_way');
|
|
|
-// if ($send_way) $status = 4;
|
|
|
-// }
|
|
|
if($sendtype==2 || $cgdinfo['order_type']!=1){
|
|
|
$status=4;
|
|
|
}
|
|
|
$orin = [
|
|
|
"wsm_in_code"=>$wsm_in_code,
|
|
|
"cgdNo"=>$cgdNo,
|
|
|
+ "bnCode"=>$bn_code,
|
|
|
"wsm_code"=>$cgdinfo['wsm_code'],
|
|
|
"wsm_reaper"=>isset($recep)&& $recep['wsm_name']!=''? $recep['wsm_name']:"",
|
|
|
"send_num"=>$send_num,
|
|
@@ -246,8 +237,8 @@ class Purchin extends Base
|
|
|
"post_code"=>$post_code,
|
|
|
"post_fee"=>$post_fee,
|
|
|
"sendtime"=>$post_time,
|
|
|
- "apply_id"=>$userinfo['id'],
|
|
|
- "apply_name"=>$userinfo['nickname'],
|
|
|
+ "apply_id"=>$this->uid,
|
|
|
+ "apply_name"=>$this->uname,
|
|
|
"wait_num"=>0,
|
|
|
"wsm_num"=>0,
|
|
|
"sendtype"=>$sendtype,
|
|
@@ -260,14 +251,38 @@ class Purchin extends Base
|
|
|
$win = Db::name("purchease_in")->insert($orin,true);
|
|
|
if($win){
|
|
|
$sto = ["order_code"=>$wsm_in_code,"status"=>$status,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
- ActionLog::logAdd($this->post['token'],$sto,"RKD",$status,$this->post);
|
|
|
- $process=["order_code"=>$wsm_in_code,"order_id"=>$win,"order_status"=>$status,"order_type"=>'RKD',"before_status"=>$status];
|
|
|
- ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$sto,"RKD",$status,$this->post);
|
|
|
+ $process=["order_code"=>$wsm_in_code,"order_id"=>$win,"order_status"=>$status,"order_type"=>'RKD',"before_status"=>$status,'holder_id' => $orin['apply_id']];
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
|
|
|
$order = ["order_code"=>$cgdNo,"status"=>$cgdinfo['status'],"action_remark"=>'',"action_type"=>"edit"];
|
|
|
|
|
|
//维护台账信息
|
|
|
Db::execute("UPDATE `wsm_standing_book` SET `wsm_in_code`=CONCAT(IFNULL(`wsm_in_code`,''),',{$wsm_in_code}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE `cgdNo`='{$cgdNo}'");
|
|
|
|
|
|
+
|
|
|
+ $is_stock = Db::name('good_basic')
|
|
|
+ ->where(['is_del'=>0,'spuCode'=>$cgdinfo['spuCode']])
|
|
|
+ ->value('is_stock');
|
|
|
+ if($is_stock == 1){
|
|
|
+ //库存品,只能由库管操作
|
|
|
+ $own_roleid = Db::name('user_role')->where(['is_del' => 0, 'status' => 1, 'uid' => $this->uid])->value('roleid');
|
|
|
+ if (!in_array($own_roleid, config('app.wsm_cgder_role'))) throw new Exception('只能由库管人员操作');
|
|
|
+ }else{
|
|
|
+ //非库存品,只能由供应商负责人操作(开通账号的不能操作)
|
|
|
+ //判断该供应商是否开通账号
|
|
|
+ //好像status==4里面的判断没用了,但是没时间修改
|
|
|
+ $res = SupplierRelationUserModel::field('id')
|
|
|
+ ->where(['is_del' => SupplierUserModel::$is_del_normal, 'supplierNo' => $cgdinfo['supplierNo'], 'status' => SupplierUserModel::$status_normal])
|
|
|
+ ->findOrEmpty()
|
|
|
+ ->isEmpty();
|
|
|
+ if(!$res) throw new Exception('供应商已开通账号,只能由供应商端操作');
|
|
|
+
|
|
|
+ $personid = Db::name('supplier')
|
|
|
+ ->where('code',$cgdinfo['supplierNo'])
|
|
|
+ ->value('personid');
|
|
|
+ if ($this->uid != $personid) throw new Exception('只能由供应商负责人操作');
|
|
|
+ }
|
|
|
+
|
|
|
if($status==1){
|
|
|
Db::commit();
|
|
|
return app_show(0,'新建成功',["wsm_in_code"=>$wsm_in_code]);
|
|
@@ -295,35 +310,25 @@ class Purchin extends Base
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
|
"updatetime"=>date("Y-m-d H:i:s"),
|
|
|
];
|
|
|
- // $order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'',
|
|
|
- // "action_type"=>"create"];
|
|
|
- }else{
|
|
|
- // $order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'',
|
|
|
- // "action_type"=>"edit"];
|
|
|
}
|
|
|
$good['wait_in_stock']-=$send_num;
|
|
|
-// if($good['presale_stock']>0){
|
|
|
-// if($good['presale_stock']>=$send_num){
|
|
|
-// $good['presale_stock']-=$send_num;
|
|
|
-// $good['wait_out_stock']+=$send_num;
|
|
|
-// }else{
|
|
|
-// $good['presale_stock']=0;
|
|
|
-// $good['usable_stock']+=$send_num-$good['presale_stock'];
|
|
|
-// $good['wait_out_stock']+=$good['presale_stock'];
|
|
|
-// }
|
|
|
-// }else{
|
|
|
- $good['usable_stock']+=$send_num;
|
|
|
- // }
|
|
|
-
|
|
|
+ $good['usable_stock']+=$send_num;
|
|
|
$good['total_stock']=$good['usable_stock']+$good['wait_out_stock'];
|
|
|
$good['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$upd= Db::name("good_stock")->save($good);
|
|
|
+ $stockid=$good['id']?? Db::name("good_stock")->getLastInsID();
|
|
|
//商品变动日志表,good_log_code字段存储采购单单号
|
|
|
- $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,'stock'=>$send_num,"stock_name"=>"usable_stock"];
|
|
|
- $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>2,'stock'=>$send_num,"stock_name"=>"wait_in_stock"];
|
|
|
+ $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>$stockid,"type"=>1,'stock'=>$send_num,"stock_name"=>"usable_stock"];
|
|
|
+ $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>$stockid,"type"=>2,'stock'=>$send_num,"stock_name"=>"wait_in_stock"];
|
|
|
if($upd){
|
|
|
- GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
|
|
|
+ GoodLog::LogAdd(['id'=>$this->uid,'nickname'=>$this->uname],$good_data,'RKD');
|
|
|
+ //todo:: 新增bn编号库存数据修改
|
|
|
if($cgdinfo['order_type']==1){
|
|
|
+ $bnin=GoodStockInfo::AddBn($stockid,$bn_code,$send_num,$cgdinfo['good_price']);
|
|
|
+ if($bnin==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"库存bn数据新增失败");
|
|
|
+ }
|
|
|
$bk =Db::name("order_bk")->where(['cgdNo'=>$cgdinfo['cgdNo']])->find();
|
|
|
if($bk==false){
|
|
|
$bk=[
|
|
@@ -355,8 +360,7 @@ class Purchin extends Base
|
|
|
if($cgdinfo['send_status']==3 && $cgdinfo['order_type']!=1){
|
|
|
$send=Db::name("order_send")->where(["cgdNo"=>$cgdNo,"status"=>1])->column("outCode");
|
|
|
if(!empty($send)){
|
|
|
- $out =Db::name("order_out")->where(["outCode"=>$send,"status"=>0])->select()
|
|
|
- ->toArray();
|
|
|
+ $out =Db::name("order_out")->where(["outCode"=>$send,"status"=>0])->select()->toArray();
|
|
|
if(!empty($out)){
|
|
|
$up =Db::name("order_out")->where(["outCode"=>$send,"status"=>0])->update
|
|
|
(["status"=>1,'wsm_code'=>$cgdinfo['wsm_code'],"updatetime"=>date('Y-m-d H:i:s')]);
|
|
@@ -364,21 +368,68 @@ class Purchin extends Base
|
|
|
Db::rollback();
|
|
|
return error_show(1004,"出库单出库失败");
|
|
|
}else{
|
|
|
+
|
|
|
+ //查询是否有非库存品订单
|
|
|
+ $is_stock = Db::name('sale')
|
|
|
+ ->where([
|
|
|
+ ['is_del','=',0],
|
|
|
+ ['orderCode','in',array_column($out,'orderCode')]
|
|
|
+ ])->column('is_stock','orderCode');
|
|
|
+
|
|
|
+ $supplier = Db::name('supplier')
|
|
|
+ ->field('person,personid')
|
|
|
+ ->where(['code'=>$cgdinfo['supplierNo'],'is_del'=>0])
|
|
|
+ ->findOrEmpty();
|
|
|
+
|
|
|
foreach ($out as $k => $v_outCode) {
|
|
|
- //修改状态,添加待办
|
|
|
- ActionLog::logAdd($this->post['token'], [
|
|
|
+ ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
"order_code" => $v_outCode['outCode'],//出库单号
|
|
|
"status" => 0,//这里的status是之前的值
|
|
|
"action_remark" => '',//备注
|
|
|
"action_type" => "status"//新建create,编辑edit,更改状态status
|
|
|
], "CKD", 1, $this->post);
|
|
|
|
|
|
- ProcessOrder::AddProcess($this->post['token'], [
|
|
|
- "order_type" => 'CKD',
|
|
|
- "order_code" => $v_outCode['outCode'],//出库单号
|
|
|
- "order_id" => $v_outCode['id'],
|
|
|
- "order_status" => 1,"before_status"=>0
|
|
|
- ]);
|
|
|
+ if ($is_stock[$v_outCode['orderCode']] == 1) {
|
|
|
+ //库存品,推给库管和库管-张凯旋
|
|
|
+ $roleid = config('app.wsm_cgder_role');
|
|
|
+ $uids = Db::name('user_role')
|
|
|
+ ->where('is_del', 0)
|
|
|
+ ->whereIn('roleid', $roleid)
|
|
|
+ ->column('uid');
|
|
|
+ ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_type" => 'CKD',
|
|
|
+ "order_code" => $v_outCode['outCode'],//出库单号
|
|
|
+ "order_id" => $v_outCode['id'],
|
|
|
+ "order_status" => 1,
|
|
|
+ "before_status" => 0,
|
|
|
+// 'wait_id' => $supplier['personid'],
|
|
|
+// 'wait_name' => $supplier['person'],
|
|
|
+// 'holder_id' => $supplier['personid'],
|
|
|
+ 'handle_user_list' => implode(',', $uids)
|
|
|
+ ]);
|
|
|
+ } elseif ($is_stock[$v_outCode['orderCode']] == 0 || $cgdinfo['order_type'] = 3) {
|
|
|
+ //非库存品和采返商品,推给供应商负责人
|
|
|
+ ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_type" => 'CKD',
|
|
|
+ "order_code" => $v_outCode['outCode'],//出库单号
|
|
|
+ "order_id" => $v_outCode['id'],
|
|
|
+ "order_status" => 1,
|
|
|
+ "before_status" => 0,
|
|
|
+ 'wait_id' => $supplier['personid'],
|
|
|
+ 'wait_name' => $supplier['person'],
|
|
|
+ 'holder_id' => $supplier['personid'],
|
|
|
+ ]);
|
|
|
+ } else {
|
|
|
+ ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_type" => 'CKD',
|
|
|
+ "order_code" => $v_outCode['outCode'],//出库单号
|
|
|
+ "order_id" => $v_outCode['id'],
|
|
|
+ "order_status" => 1,
|
|
|
+ "before_status" => 0,
|
|
|
+ 'holder_id' => $v_outCode['apply_id']
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
$good1 = Db::name("good_stock")->where(["wsm_code"=>$cgdinfo['wsm_code'], "spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
|
|
@@ -400,9 +451,11 @@ class Purchin extends Base
|
|
|
Db::rollback();
|
|
|
return error_show(1004,"库存数量更新失败");
|
|
|
}
|
|
|
- $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>isset($good['id'])?$good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,'stock'=>$send_num,"stock_name"=>"wait_out_stock"];
|
|
|
- $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>isset($good['id'])?$good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,'stock'=>$send_num,"stock_name"=>"usable_stock"];
|
|
|
- GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
|
|
|
+ $stockid= isset($good['id'])?$good['id']:Db::name("good_stock")->getLastInsID();
|
|
|
+
|
|
|
+ $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>$stockid,"type"=>1,'stock'=>$send_num,"stock_name"=>"wait_out_stock"];
|
|
|
+ $good_data[]=['good_log_code'=>$wsm_in_code,"stock_id"=>$stockid,"type"=>1,'stock'=>$send_num,"stock_name"=>"usable_stock"];
|
|
|
+ GoodLog::LogAdd(['id'=>$this->uid,'nickname'=>$this->uname],$good_data,'RKD');
|
|
|
$sendp=Db::name("order_send")->where(["cgdNo"=>$cgdNo,"outCode"=>$send,"status"=>1])->save (["status"=>2]);
|
|
|
if($sendp==false){
|
|
|
Db::rollback();
|
|
@@ -411,9 +464,38 @@ class Purchin extends Base
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- ActionLog::logAdd($this->post['token'],$order,"CGD", $cgdinfo['status'],$cgdinfo);
|
|
|
- $process=["order_code"=>$cgdNo,"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status']];
|
|
|
- ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
+
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"CGD", $cgdinfo['status'],$cgdinfo);
|
|
|
+
|
|
|
+
|
|
|
+ $personid = Db::name('supplier')
|
|
|
+ ->where('is_del',0)
|
|
|
+ ->where('code',$cgdinfo['supplierNo'])
|
|
|
+ ->value('personid');
|
|
|
+
|
|
|
+ if($cgdinfo['status']==1 || $cgdinfo['status']==2){
|
|
|
+
|
|
|
+ $is_stock = Db::name('good_basic')
|
|
|
+ ->where(['is_del'=>0,'spuCode'=>$cgdinfo['spuCode']])
|
|
|
+ ->value('is_stock');
|
|
|
+ if($is_stock==1){
|
|
|
+ //库存品,推给31库管人员、41库管-张凯旋
|
|
|
+ $uid = Db::name('user_role')
|
|
|
+ ->where([
|
|
|
+ ['is_del', '=', 0],
|
|
|
+ ['roleid', 'in', [31, 41]],
|
|
|
+ ['status', '=', 1]
|
|
|
+ ])->column('uid');
|
|
|
+ if(!in_array($this->uid,$uid)) throw new Exception('库存品订单只能由库管人员操作');
|
|
|
+ $process = ["order_code" => $cgdNo, "order_id" => $cgdinfo['id'], "order_status" => $cgdinfo['status'], "order_type" => 'CGD', "before_status" => $order['status'], 'holder_id' => $personid,'handle_user_list'=>implode(',', $uid)];
|
|
|
+
|
|
|
+ }elseif ($is_stock==0 || $cgdinfo['order_type']==3){
|
|
|
+ if($this->uid != $personid)throw new Exception('非库存品和采返商品只能由供应商负责人操作');
|
|
|
+ $process = ["order_code" => $cgdNo, "order_id" => $cgdinfo['id'], "order_status" => $cgdinfo['status'], "order_type" => 'CGD', "before_status" => $order['status'], 'holder_id' => $personid,'handle_user_list'=>$personid]; //非库存品和采返商品,推给供应商负责人
|
|
|
+ }
|
|
|
+ }else $process = ["order_code" => $cgdNo, "order_id" => $cgdinfo['id'], "order_status" => $cgdinfo['status'], "order_type" => 'CGD', "before_status" => $order['status'], 'holder_id' => $personid];
|
|
|
+
|
|
|
+ ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
|
|
|
Db::commit();
|
|
|
return app_show(0,'商品入库成功',["wsm_in_code"=>$wsm_in_code]);
|
|
|
}else{
|
|
@@ -428,7 +510,7 @@ class Purchin extends Base
|
|
|
return error_show(1004,"新建失败");
|
|
|
}catch (\Exception $e){
|
|
|
Db::rollback();
|
|
|
- return error_show(1004, $e->getMessage() . '|' . $e->getFile() . '|' . $e->getLine());
|
|
|
+ return error_show(1004, $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -538,7 +620,7 @@ class Purchin extends Base
|
|
|
$up =Db::name("purchease_in")->save($info);
|
|
|
if($up){
|
|
|
ActionLog::logAdd($this->post['token'],$order,"RKD",2,$this->post);
|
|
|
- $process=["order_code"=>$info['wsm_in_code'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>'RKD',"before_status"=>$order['status']];
|
|
|
+ $process=["order_code"=>$info['wsm_in_code'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>'RKD',"before_status"=>$order['status'],'holder_id' => $info['apply_id']];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
if(!empty($error_list)){
|
|
|
$data=[];
|
|
@@ -600,7 +682,7 @@ class Purchin extends Base
|
|
|
$update = Db::name("purchease_in")->save($info);
|
|
|
if($update){
|
|
|
ActionLog::logAdd($this->post['token'],$order,"RKD",$status,$this->post);
|
|
|
- $process=["order_code"=>$info['wsm_in_code'],"order_id"=>$info['id'],"order_status"=>$status,"order_type"=>'RKD',"before_status"=>$order['status']];
|
|
|
+ $process=["order_code"=>$info['wsm_in_code'],"order_id"=>$info['id'],"order_status"=>$status,"order_type"=>'RKD',"before_status"=>$order['status'],'holder_id' => $info['apply_id']];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
if($status==0){
|
|
|
$cgdinfo=Db::name("purchease_order")->where(['cgdNo'=>$info['cgdNo'],"is_del"=>0])->find();
|
|
@@ -617,8 +699,38 @@ class Purchin extends Base
|
|
|
$up=Db::name("purchease_order")->save($cgdinfo);
|
|
|
if($up){
|
|
|
ActionLog::logAdd($this->post['token'],$order,"CGD", $cgdinfo['status'],$cgdinfo);
|
|
|
- $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status']];
|
|
|
- ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
+
|
|
|
+ if($cgdinfo['status']==1 || $cgdinfo['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'=>$cgdinfo['cgdNo'],
|
|
|
+// ])->findOrEmpty();
|
|
|
+ $is_stock = Db::name('good_basic')
|
|
|
+ ->where(['is_del'=>0,'spuCode'=>$cgdinfo['spuCode']])
|
|
|
+ ->value('is_stock');
|
|
|
+
|
|
|
+ if($is_stock==1){
|
|
|
+ //库存品,推给31库管人员、41库管-张凯旋
|
|
|
+ $uid = Db::name('user_role')
|
|
|
+ ->where([
|
|
|
+ ['is_del', '=', 0],
|
|
|
+ ['roleid', 'in', [31, 41]],
|
|
|
+ ['status', '=', 1]
|
|
|
+ ])->column('uid');
|
|
|
+ if(!in_array($this->uid,$uid)) throw new Exception('库存品订单只能由库管人员操作');
|
|
|
+ $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0),'handle_user_list'=>implode(',', $uid)];
|
|
|
+ }elseif ($is_stock==0 || $cgdinfo['order_type']==3) {
|
|
|
+ $holder_id = Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0);
|
|
|
+ if($this->uid != $holder_id)throw new Exception('非库存品和采返商品只能由供应商负责人操作');
|
|
|
+ $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>$holder_id,'handle_user_list'=>$holder_id];
|
|
|
+ }//非库存品和采返商品,推给供应商负责人
|
|
|
+ }else $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0)];
|
|
|
+
|
|
|
+ ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
|
|
|
Db::commit();
|
|
|
return app_show(0,'取消成功');
|
|
|
}else{
|
|
@@ -641,7 +753,36 @@ class Purchin extends Base
|
|
|
$up=Db::name("purchease_order")->save($cgdinfo);
|
|
|
if($up){
|
|
|
ActionLog::logAdd($this->post['token'],$order,"CGD", $cgdinfo['status'],$cgdinfo);
|
|
|
- $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status']];
|
|
|
+
|
|
|
+
|
|
|
+ if($cgdinfo['status'] == 1 || $cgdinfo['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'=>$cgdinfo['cgdNo'],
|
|
|
+// ])->findOrEmpty();
|
|
|
+ $is_stock = Db::name('good_basic')
|
|
|
+ ->where(['is_del'=>0,'spuCode'=>$cgdinfo['spuCode']])
|
|
|
+ ->value('is_stock');
|
|
|
+ if($is_stock==1){
|
|
|
+ //库存品,推给31库管人员、41库管-张凯旋
|
|
|
+ $uid = Db::name('user_role')
|
|
|
+ ->where([
|
|
|
+ ['is_del', '=', 0],
|
|
|
+ ['roleid', 'in', [31, 41]],
|
|
|
+ ['status', '=', 1]
|
|
|
+ ])->column('uid');
|
|
|
+ if(!in_array($this->uid,$uid)) throw new Exception('库存品订单只能由库管人员操作');
|
|
|
+ $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0),'handle_user_list'=>implode(',', $uid)];
|
|
|
+ }elseif ($is_stock==0 || $cgdinfo['order_type']==3) {
|
|
|
+ $holder_id = Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0);
|
|
|
+ if($this->uid != $holder_id)throw new Exception('非库存品和采返商品只能由供应商负责人操作');
|
|
|
+ $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>$holder_id,'handle_user_list'=>$holder_id];
|
|
|
+ }//非库存品和采返商品,推给供应商负责人
|
|
|
+ }else $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0)];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
Db::commit();
|
|
|
return app_show(0,'发货成功');
|
|
@@ -668,7 +809,35 @@ class Purchin extends Base
|
|
|
return error_show(1002,"发货失败");
|
|
|
}
|
|
|
ActionLog::logAdd($this->post['token'],$order,"CGD", $cgdinfo['status'],$cgdinfo);
|
|
|
- $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status']];
|
|
|
+
|
|
|
+ if($cgdinfo['status']==1 || $cgdinfo['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'=>$cgdinfo['cgdNo'],
|
|
|
+// ])->findOrEmpty();
|
|
|
+ $is_stock = Db::name('good_basic')
|
|
|
+ ->where(['is_del'=>0,'spuCode'=>$cgdinfo['spuCode']])
|
|
|
+ ->value('is_stock');
|
|
|
+ if($is_stock==1){
|
|
|
+ //库存品,推给31库管人员、41库管-张凯旋
|
|
|
+ $uid = Db::name('user_role')
|
|
|
+ ->where([
|
|
|
+ ['is_del', '=', 0],
|
|
|
+ ['roleid', 'in', [31, 41]],
|
|
|
+ ['status', '=', 1]
|
|
|
+ ])->column('uid');
|
|
|
+ if(!in_array($this->uid,$uid)) throw new Exception('库存品订单只能由库管人员操作');
|
|
|
+ $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0),'handle_user_list'=>implode(',', $uid)];
|
|
|
+ }elseif ($is_stock==0 || $cgdinfo['order_type']==3) {
|
|
|
+ $holder_id = Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0);
|
|
|
+ if($this->uid != $holder_id)throw new Exception('非库存品和采返商品只能由供应商负责人操作');
|
|
|
+ $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>$holder_id,'handle_user_list'=>$holder_id];
|
|
|
+ }//非库存品和采返商品,推给供应商负责人
|
|
|
+ }else $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0)];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
|
|
|
$good = Db::name("good_stock")->where(["wsm_code"=>$info['wsm_code'], "spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
|
|
@@ -690,29 +859,22 @@ class Purchin extends Base
|
|
|
}else{
|
|
|
$order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
|
|
|
}
|
|
|
-// $good['usable_stock']+=$info['wsm_num'];
|
|
|
$good['wait_in_stock']-=$info['wsm_num'];
|
|
|
-// if($good['presale_stock']>0){
|
|
|
-// if($good['presale_stock']>=$info['wsm_num']){
|
|
|
-// $good['presale_stock']-=$info['wsm_num'];
|
|
|
-// $good['wait_out_stock']+$info['wsm_num'];
|
|
|
-// }else{
|
|
|
-// $good['presale_stock']=0;
|
|
|
-// $good['usable_stock']+=$info['wsm_num']-$good['presale_stock'];
|
|
|
-// $good['wait_out_stock']+=$good['presale_stock'];
|
|
|
-// }
|
|
|
-// }else{
|
|
|
- $good['usable_stock']+=$info['wsm_num'];
|
|
|
- // }
|
|
|
-
|
|
|
+ $good['usable_stock']+=$info['wsm_num'];
|
|
|
$good['total_stock']=$good['usable_stock']+$good['wait_out_stock'];
|
|
|
$good['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$upd= Db::name("good_stock")->save($good);
|
|
|
+ $stockid=$good['id']?? Db::name("good_stock")->getLastInsID();
|
|
|
//商品变动日志表,good_log_code字段存储入库单编号
|
|
|
$good_data[] = ['good_log_code' => $incode, "stock_id" => isset($good['id']) ? $good['id'] : Db::name("good_stock")->getLastInsID(), "type" => 1, 'stock' => $info['wsm_num'], "stock_name" => "usable_stock"];
|
|
|
$good_data[] = ['good_log_code' => $incode, "stock_id" => isset($good['id']) ? $good['id'] :
|
|
|
Db::name("good_stock")->getLastInsID(), "type" => 2, 'stock' => $info['wsm_num'], "stock_name" => "wait_in_stock"];
|
|
|
if($upd){
|
|
|
+ $bnin=GoodStockInfo::AddBn($stockid,$info['bnCode'],$info['wsm_num'],$cgdinfo['good_price']);
|
|
|
+ if($bnin==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"库存bn数据新增失败");
|
|
|
+ }
|
|
|
GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
|
|
|
Db::commit();
|
|
|
return app_show(0,'商品入库成功');
|
|
@@ -805,7 +967,35 @@ class Purchin extends Base
|
|
|
return error_show(1002,"发货失败");
|
|
|
}
|
|
|
ActionLog::logAdd($this->post['token'],$order,"CGD", $cgdinfo['status'],$cgdinfo);
|
|
|
- $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status']];
|
|
|
+
|
|
|
+ if($cgdinfo['status']==1 || $cgdinfo['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'=>$cgdinfo['cgdNo'],
|
|
|
+// ])->findOrEmpty();
|
|
|
+ $is_stock = Db::name('good_basic')
|
|
|
+ ->where(['is_del'=>0,'spuCode'=>$cgdinfo['spuCode']])
|
|
|
+ ->value('is_stock');
|
|
|
+ if($is_stock==1){
|
|
|
+ //库存品,推给31库管人员、41库管-张凯旋
|
|
|
+ $uid = Db::name('user_role')
|
|
|
+ ->where([
|
|
|
+ ['is_del', '=', 0],
|
|
|
+ ['roleid', 'in', [31, 41]],
|
|
|
+ ['status', '=', 1]
|
|
|
+ ])->column('uid');
|
|
|
+ if(!in_array($this->uid,$uid)) throw new Exception('库存品订单只能由库管人员操作');
|
|
|
+ $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0),'handle_user_list'=>implode(',', $uid)];
|
|
|
+ }elseif ($is_stock==0 || $cgdinfo==3) {
|
|
|
+ $holder_id = Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0);
|
|
|
+ if($this->uid != $holder_id)throw new Exception('非库存品和采返商品只能由供应商负责人操作');
|
|
|
+ $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>$holder_id,'handle_user_list'=>$holder_id];
|
|
|
+ }//非库存品和采返商品,推给供应商负责人
|
|
|
+ }else $process=["order_code"=>$info['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0)];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
$good = Db::name("good_stock")->where(["wsm_code"=>$info['wsm_code'], "spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
|
|
|
if(empty($good)) {
|
|
@@ -878,7 +1068,7 @@ class Purchin extends Base
|
|
|
|
|
|
}
|
|
|
ActionLog::logAdd($this->post['token'],$sto,"RKD", $info['status'],$this->post);
|
|
|
- $process=["order_code"=>$info['wsm_in_code'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>'RKD',"before_status"=>$sto['status']];
|
|
|
+ $process=["order_code"=>$info['wsm_in_code'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>'RKD',"before_status"=>$sto['status'],'holder_id' => $info['apply_id']];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
|
|
|
//需要在详情页把相关退货记录原样取出来,所以这里把if去掉,所有记录都入purchease_return表
|
|
@@ -981,7 +1171,7 @@ class Purchin extends Base
|
|
|
if($sa){
|
|
|
$stn = ["order_code"=>$info['wsm_in_code'],"status"=>$ark,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
ActionLog::logAdd($this->post['token'],$stn,"RKD",6,$info);
|
|
|
- $process=["order_code"=>$info['wsm_in_code'],"order_id"=>$info['id'],"order_status"=>6,"order_type"=>'RKD',"before_status"=>$stn['status']];
|
|
|
+ $process=["order_code"=>$info['wsm_in_code'],"order_id"=>$info['id'],"order_status"=>6,"order_type"=>'RKD',"before_status"=>$stn['status'],'holder_id' => $info['apply_id']];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
|
|
|
$good = Db::name("good_stock")->where(["wsm_code"=>$info['wsm_code'], "spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
|
|
@@ -996,27 +1186,12 @@ class Purchin extends Base
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
|
"updatetime"=>date("Y-m-d H:i:s"),
|
|
|
];
|
|
|
- $order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'',
|
|
|
- "action_type"=>"create"];
|
|
|
-
|
|
|
+ $order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
|
|
|
}else{
|
|
|
$order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
|
|
|
}
|
|
|
- $good['wait_in_stock']-=$return['wsm_num']+$return['return_num']-$return['reissue_num'];
|
|
|
-// if($good['presale_stock']>0){
|
|
|
-// if($good['presale_stock']>=$return['wsm_num']){
|
|
|
-// $good['presale_stock']-=$return['wsm_num'];
|
|
|
-// $good['wait_out_stock']+=$return['wsm_num'];
|
|
|
-// }else{
|
|
|
-// $good['presale_stock']=0;
|
|
|
-// $good['usable_stock']+=$return['wsm_num']-$good['presale_stock'];
|
|
|
-// $good['wait_out_stock']+=$good['presale_stock'];
|
|
|
-// }
|
|
|
-// }else{
|
|
|
- $good['usable_stock']+=$return['wsm_num'];
|
|
|
-// }
|
|
|
-// $good['usable_stock']+=$return['wsm_num'];
|
|
|
-// $good['wait_in_stock']-=$return['wsm_num']+$return['return_num']-$return['reissue_num'];
|
|
|
+ $good['wait_in_stock']-=$return['wsm_num']+$return['return_num']-$return['reissue_num'];
|
|
|
+ $good['usable_stock']+=$return['wsm_num'];
|
|
|
$good['total_stock']=$good['usable_stock']+$good['wait_out_stock'];
|
|
|
$good['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$upd= Db::name("good_stock")->save($good);
|
|
@@ -1024,8 +1199,14 @@ class Purchin extends Base
|
|
|
Db::rollback();
|
|
|
return error_show(1002,"库存更新失败");
|
|
|
}
|
|
|
- $good_data[]=['good_log_code' => $incode,"stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1, 'stock'=>$info['wsm_num'],"stock_name"=>"usable_stock"];
|
|
|
- $good_data[]=['good_log_code' => $incode,"stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>2, 'stock'=>$good['wait_in_stock'],"stock_name"=>"wait_in_stock"];
|
|
|
+ $stockid=$good['id']?? Db::name("good_stock")->getLastInsID();
|
|
|
+ $bnin=GoodStockInfo::AddBn($stockid,$info['bnCode'],$return['wsm_num'],$cgdinfo['good_price']);
|
|
|
+ if($bnin==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"库存bn数据新增失败");
|
|
|
+ }
|
|
|
+ $good_data[]=['good_log_code' => $incode,"stock_id"=>$stockid,"type"=>1, 'stock'=>$info['wsm_num'],"stock_name"=>"usable_stock"];
|
|
|
+ $good_data[]=['good_log_code' => $incode,"stock_id"=>$stockid,"type"=>2, 'stock'=>$good['wait_in_stock'],"stock_name"=>"wait_in_stock"];
|
|
|
GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
|
|
|
|
|
|
$order = ["order_code"=>$cgdinfo['cgdNo'],"status"=>$cgdinfo['status'],"action_remark"=>'',"action_type"=>"edit"];
|
|
@@ -1044,7 +1225,6 @@ class Purchin extends Base
|
|
|
Db::rollback();
|
|
|
return error_show(1004,"采购单数量更新失败");
|
|
|
}
|
|
|
-
|
|
|
$bk =Db::name("order_bk")->where(['cgdNo'=>$cgdinfo['cgdNo']])->lock(true)->find();
|
|
|
if($bk==false){
|
|
|
$bk=[
|
|
@@ -1069,8 +1249,39 @@ class Purchin extends Base
|
|
|
return error_show(1004,"采购单数量更新失败");
|
|
|
}
|
|
|
ActionLog::logAdd($this->post['token'],$order,"CGD", $cgdinfo['status'],$cgdinfo);
|
|
|
- $process=["order_code"=>$cgdinfo['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status']];
|
|
|
+
|
|
|
+ if($cgdinfo['status']==1 || $cgdinfo['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'=>$cgdinfo['cgdNo'],
|
|
|
+// ])->findOrEmpty();
|
|
|
+ $is_stock = Db::name('good_basic')
|
|
|
+ ->where(['is_del'=>0,'spuCode'=>$cgdinfo['spuCode']])
|
|
|
+ ->value('is_stock');
|
|
|
+
|
|
|
+ if($is_stock==1){
|
|
|
+ //库存品,推给31库管人员、41库管-张凯旋
|
|
|
+ $uid = Db::name('user_role')
|
|
|
+ ->where([
|
|
|
+ ['is_del', '=', 0],
|
|
|
+ ['roleid', 'in', [31, 41]],
|
|
|
+ ['status', '=', 1]
|
|
|
+ ])->column('uid');
|
|
|
+ if(!in_array($this->uid,$uid)) throw new Exception('库存品订单只能由库管人员操作');
|
|
|
+ $process=["order_code"=>$cgdinfo['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0),'handle_user_list'=>implode(',', $uid)];
|
|
|
+
|
|
|
+ }elseif ($is_stock==0 || $cgdinfo['order_type']==3) {
|
|
|
+ $holder_id = Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0);
|
|
|
+ if($this->uid != $holder_id)throw new Exception('非库存品和采返商品只能由供应商负责人操作');
|
|
|
+ $process=["order_code"=>$cgdinfo['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>$holder_id,'handle_user_list'=>$holder_id];//非库存品和采返商品,推给供应商负责人
|
|
|
+ }
|
|
|
+ }else $process=["order_code"=>$cgdinfo['cgdNo'],"order_id"=>$cgdinfo['id'],"order_status"=>$cgdinfo['status'],"order_type"=>'CGD',"before_status"=>$order['status'],'holder_id'=>Db::name('supplier')->where(['code' => $cgdinfo['supplierNo'], 'is_del' => 0])->value('personid', 0)];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
+
|
|
|
Db::commit();
|
|
|
return app_show(0,"退货发货成功");
|
|
|
}else{
|
|
@@ -1147,55 +1358,6 @@ class Purchin extends Base
|
|
|
$data[]=$value;
|
|
|
}
|
|
|
return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-// public function ReturnStatus(){
|
|
|
-// $incode = isset($this->post['wsm_in_code'])&&$this->post['wsm_in_code']!="" ? trim($this->post['wsm_in_code']) :"";
|
|
|
-// if($incode==""){
|
|
|
-// return error_show(1004,"参数wsm_in_code 不为空");
|
|
|
-// }
|
|
|
-// $info = Db::name("purchease_in")->where(['wsm_in_code'=>$incode,"is_del"=>0])->find();
|
|
|
-// if(empty($info)){
|
|
|
-// return error_show(1004,"未找到发货单数据");
|
|
|
-// }
|
|
|
-// $return = Db::name("purchease_return")->where(['wsm_in_code'=>$incode,"is_del"=>0])->find();
|
|
|
-// if(empty($return)){
|
|
|
-// return error_show(1004,"未找到数据");
|
|
|
-// }
|
|
|
-// if($info['status']<4){
|
|
|
-// return error_show(1004,"入库单未完成");
|
|
|
-// }
|
|
|
-// $status = isset($this->post['status'])&&$this->post['status']!="" ?$this->post['status']:"";
|
|
|
-// if($status==""){
|
|
|
-// return error_show(1004,"参数status 不为空");
|
|
|
-// }
|
|
|
-// Db::startTrans();
|
|
|
-// try{
|
|
|
-// $data=[
|
|
|
-// "status"=>$status,
|
|
|
-// "updatetime"=>date("Y-m-d H:i:s")
|
|
|
-// ];
|
|
|
-// $up =Db::name("purchease_return")->where($return)->save($data);
|
|
|
-// if($up){
|
|
|
-// $info['status']=$status==1?5:6;
|
|
|
-// $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
-// $sa=Db::name("purchease_in")->save($info);
|
|
|
-// if($sa){
|
|
|
-// Db::commit();
|
|
|
-// return app_show(0,"更新成功");
|
|
|
-// }else{
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1004,"更新失败");
|
|
|
-// }
|
|
|
-// }else{
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1004,"更新失败");
|
|
|
-// }
|
|
|
-// }catch (\Exception $e){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1004,$e->getMessage());
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
}
|