|
@@ -370,74 +370,96 @@ class After extends Base
|
|
|
|
|
|
return app_show(0,"获取成功",$info);
|
|
|
}
|
|
|
+
|
|
|
+ //售后申请单 审核
|
|
|
public function status(){
|
|
|
- $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
|
|
|
- if($bkcode==""){
|
|
|
- return error_show(1005,"参数returnCode 不能为空");
|
|
|
- }
|
|
|
- $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
|
|
|
- if(empty($info)){
|
|
|
- return error_show(1005,"未找到售后数据");
|
|
|
- }
|
|
|
- $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']) :"";
|
|
|
- if($status===""){
|
|
|
- return error_show(1005,"参数status 不能为空");
|
|
|
- }
|
|
|
- $orde= Db::name("order_out")->where(["outCode"=>$info['outCode'],"is_del"=>0])->find();
|
|
|
- if($orde==false){
|
|
|
- return error_show(1005,"未找到出库单数据");
|
|
|
- }
|
|
|
- $sale = Db::name("sale")->where(["orderCode"=> $info['orderCode']])->find();
|
|
|
- if($sale==false){
|
|
|
- return error_show(1005,"未找到销售单数据");
|
|
|
- }
|
|
|
- $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):"";
|
|
|
- if($remark!=''){
|
|
|
- $info['remark'] =$remark;
|
|
|
- }
|
|
|
- if($status==3 && $info['is_receive']==1){
|
|
|
- $post =isset($this->post['is_post'])&&$this->post['is_post']!==""? intval($this->post['is_post']):"";
|
|
|
- if($post===""){
|
|
|
- return error_show(1005,"参数is_post不能为空");
|
|
|
- }
|
|
|
- $info['is_post']=$post;
|
|
|
- $return_tag =isset($this->post['return_tag'])&&$this->post['return_tag']!==""? intval($this->post['return_tag']):"";
|
|
|
- if($return_tag===""){
|
|
|
- return error_show(1005,"参数return_tag不能为空");
|
|
|
- }
|
|
|
- $info['return_tag']=$return_tag;
|
|
|
- $is_th =isset($this->post['is_th'])&&$this->post['is_th']!==""? intval($this->post['is_th']):"0";
|
|
|
- $info['is_th']=$is_th;
|
|
|
- }
|
|
|
-// $status = $info['order_status']==1&&$info['order_type']==1 && $status==1?4:$status;
|
|
|
+
|
|
|
+ $param = $this->request->only(['returnCode','status','remark'=>''],'post','trim');
|
|
|
+
|
|
|
+ $val = Validate::rule([
|
|
|
+ 'returnCode'=>'require',
|
|
|
+ 'status'=>'require|number|in:1,2,4,5,6,9,10',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if($val->check($param) == false) return json_show(1004,$val->getError());
|
|
|
+
|
|
|
+// $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
|
|
|
+// if($bkcode==""){
|
|
|
+// return error_show(1005,"参数returnCode 不能为空");
|
|
|
+// }
|
|
|
+ $info = Db::name("order_return")
|
|
|
+ ->where(['is_del'=>0,'returnCode'=>$param['returnCode']])
|
|
|
+ ->findOrEmpty();
|
|
|
+ if(empty($info)) return json_show(1005,"未找到售后数据");
|
|
|
+ if($info['status'] == 5) return json_show(1005,'售后已完成,无法操作');
|
|
|
+ if($info['status'] == 8) return json_show(1005,'申请已取消,无法操作');
|
|
|
+
|
|
|
+
|
|
|
+// $param['status'] = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']) :"";
|
|
|
+// if($param['status']===""){
|
|
|
+// return error_show(1005,"参数status 不能为空");
|
|
|
+// }
|
|
|
+ $orde= Db::name("order_out")
|
|
|
+ ->field('id,outCode,status')
|
|
|
+ ->where(["outCode"=>$info['outCode'],"is_del"=>0])
|
|
|
+ ->findOrEmpty();
|
|
|
+ if(empty($orde)) return json_show(1005,"未找到出库单数据");
|
|
|
+
|
|
|
+ $sale = Db::name("sale")
|
|
|
+ ->field('id,th_num,th_fee,sale_price,good_code,good_name,cat_id')
|
|
|
+ ->where(['is_del'=>0,"orderCode"=> $info['orderCode']])
|
|
|
+ ->findOrEmpty();
|
|
|
+ if(empty($sale)) return json_show(1005,"未找到销售单数据");
|
|
|
+
|
|
|
+// $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):"";
|
|
|
+ if($param['remark']!='') $info['remark'] =$param['remark'];
|
|
|
+
|
|
|
+// if($param['status']==3 && $info['is_receive']==1){
|
|
|
+// $post =isset($this->post['is_post'])&&$this->post['is_post']!==""? intval($this->post['is_post']):"";
|
|
|
+// if($post===""){
|
|
|
+// return error_show(1005,"参数is_post不能为空");
|
|
|
+// }
|
|
|
+// $info['is_post']=$post;
|
|
|
+// $return_tag =isset($this->post['return_tag'])&&$this->post['return_tag']!==""? intval($this->post['return_tag']):"";
|
|
|
+// if($return_tag===""){
|
|
|
+// return error_show(1005,"参数return_tag不能为空");
|
|
|
+// }
|
|
|
+// $info['return_tag']=$return_tag;
|
|
|
+// $is_th =isset($this->post['is_th'])&&$this->post['is_th']!==""? intval($this->post['is_th']):"0";
|
|
|
+// $info['is_th']=$is_th;
|
|
|
+// }
|
|
|
+// $param['status'] = $info['order_status']==1&&$info['order_type']==1 && $param['status']==1?4:$param['status'];
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
+
|
|
|
+ $date = date('Y-m-d H:i:s');
|
|
|
+ $action_log_user = ['id'=>$this->uid,'nickname'=>$this->uname];
|
|
|
+
|
|
|
$var=$info['status'];
|
|
|
- $info['status']=$status;
|
|
|
- $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $info['status']=$param['status'];
|
|
|
+ $info['updatetime']=$date;
|
|
|
$up =Db::name("order_return")->save($info);
|
|
|
if($up){
|
|
|
- if($status==5 && $info['is_receive']==0){
|
|
|
+
|
|
|
+ //售后完成
|
|
|
+ if($param['status']==5 && $info['is_receive']==0){
|
|
|
$od_status = $orde['status'];
|
|
|
$orde['status']=4;
|
|
|
- $orde['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $orde['updatetime']=$date;
|
|
|
$out = Db::name("order_out")->save($orde);
|
|
|
- if($out==false){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1004,"发货单更新失败");
|
|
|
- }
|
|
|
+ if($out==false) throw new Exception("发货单更新失败");
|
|
|
+
|
|
|
$order = ["order_code"=>$orde['outCode'],"status"=>$od_status,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
- ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"CKD", $orde['status'],$this->post);
|
|
|
+ ActionLog::logAdd($action_log_user,$order,"CKD", $orde['status'],$this->post);
|
|
|
$process=["order_code"=>$orde['outCode'],"order_id"=>$orde['id'],"order_status"=>$orde['status'],"order_type"=>"CKD","before_status"=>$od_status];
|
|
|
- ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
|
|
|
+ ProcessOrder::AddProcess($action_log_user,$process);
|
|
|
+
|
|
|
$sale['th_num'] += $info['error_num'];
|
|
|
$sale['th_fee'] += round($info['error_num']*$sale['sale_price'],2);
|
|
|
- $sale['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $sale['updatetime']= $date;
|
|
|
$sup =Db::name("sale")->save($sale);
|
|
|
- if($sup==false){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1004,"销售单更新失败");
|
|
|
- }
|
|
|
+ if($sup==false) throw new Exception("销售单更新失败");
|
|
|
+
|
|
|
$data=[
|
|
|
"orderCode"=>$info['orderCode'],
|
|
|
"th_type"=>2,
|
|
@@ -449,51 +471,50 @@ class After extends Base
|
|
|
"cat_id"=>$sale['cat_id'],
|
|
|
"apply_id"=>$info['apply_id'],
|
|
|
"apply_name"=>$info['apply_name'],
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "addtime"=>$date,
|
|
|
"status"=>1,
|
|
|
"is_del"=>0
|
|
|
];
|
|
|
$inse=Db::name("th_data")->insert($data);
|
|
|
- if($inse==false){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1004,"退回单更新失败");
|
|
|
- }
|
|
|
+ if($inse==false) throw new Exception('退回单更新失败');
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
$order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
- ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$order,"SHD", $info['status'],$this->post);
|
|
|
+ ActionLog::logAdd($action_log_user,$order,"SHD", $info['status'],$this->post);
|
|
|
|
|
|
-// switch ($status) {
|
|
|
+// switch ($param['status']) {
|
|
|
// //待采购审核
|
|
|
// case 2:
|
|
|
-// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
|
|
|
+// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
|
|
|
// break;
|
|
|
//
|
|
|
// //待设置仓库
|
|
|
// case 3:
|
|
|
-// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'], 'holder_id' => $info['cgderid']];
|
|
|
+// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'], 'holder_id' => $info['cgderid']];
|
|
|
// break;
|
|
|
//
|
|
|
// //待客户退货
|
|
|
// case 4:
|
|
|
-// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'], 'holder_id' => $info['apply_id']];
|
|
|
+// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'], 'holder_id' => $info['apply_id']];
|
|
|
// break;
|
|
|
//
|
|
|
// default:
|
|
|
-// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'holder_id' => $info['apply_id']];
|
|
|
+// $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'holder_id' => $info['apply_id']];
|
|
|
// }
|
|
|
-// if (in_array($status, [2, 3])) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'],'holder_id'=>$info['cgderid']];
|
|
|
-// elseif ($status == 4) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'],'holder_id'=>$info['apply_id']];
|
|
|
-// else $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var,'holder_id'=>$info['apply_id']];
|
|
|
- $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
|
|
|
+// if (in_array($param['status'], [2, 3])) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'],'holder_id'=>$info['cgderid']];
|
|
|
+// elseif ($param['status'] == 4) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'],'holder_id'=>$info['apply_id']];
|
|
|
+// else $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var,'holder_id'=>$info['apply_id']];
|
|
|
+ $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
|
|
|
|
|
|
- ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
|
|
|
+ ProcessOrder::AddProcess($action_log_user,$process);
|
|
|
Db::commit();
|
|
|
return app_show(0,"更新成功");
|
|
|
}else{
|
|
|
Db::rollback();
|
|
|
return error_show(1004,"更新失败");
|
|
|
}
|
|
|
- }catch (\Exception $e){
|
|
|
+ }catch (Exception $e){
|
|
|
Db::rollback();
|
|
|
return error_show(1004,$e->getMessage());
|
|
|
}
|