|
@@ -248,7 +248,7 @@ class After extends \app\BaseController
|
|
|
if($remark!=''){
|
|
|
$info['remark'] =$remark;
|
|
|
}
|
|
|
- if($status==3){
|
|
|
+ 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不能为空");
|
|
@@ -755,4 +755,107 @@ class After extends \app\BaseController
|
|
|
}
|
|
|
return app_show(0,"获取成功",$list);
|
|
|
}
|
|
|
+
|
|
|
+ public function setdelivery(){
|
|
|
+ $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,"未找到售后数据");
|
|
|
+ }
|
|
|
+ if(($info['is_receive']==0&&$info['status']!=3)||($info['is_receive']==1&&$info['status']!=4) ){
|
|
|
+ return error_show(1005,"售后单流程状态有误");
|
|
|
+ }
|
|
|
+ $out=Db::name("order_out")->where(["outCode"=>$info["outCode"]])->find();
|
|
|
+ $is_th = isset($this->post['is_th'])&&$this->post['is_th']!=="" ? intval($this->post['is_th']):"";
|
|
|
+ if($is_th===""){
|
|
|
+ return error_show(1005,"参数is_th不能为空");
|
|
|
+ }
|
|
|
+ $company=isset($this->post['company'])&&$this->post['company']!=""?trim($this->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']!==""?floatval($this->post['post_fee']):"";
|
|
|
+ if($is_th==1){
|
|
|
+ if($company==""){
|
|
|
+ return error_show(1005,"参数company不能为空");
|
|
|
+ }
|
|
|
+ if($post_code==""){
|
|
|
+ return error_show(1005,"参数post_code不能为空");
|
|
|
+ }
|
|
|
+ if($post_fee==""){
|
|
|
+ return error_show(1005,"参数post_fee不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
|
|
|
+ if($returninfo==false){
|
|
|
+ $returninfo=[
|
|
|
+ "returnCode"=>$bkcode,
|
|
|
+ "return_wsm"=>"",
|
|
|
+ "contactor"=>"",
|
|
|
+ "mobile"=>"",
|
|
|
+ "addr"=>"",
|
|
|
+ "addr_code"=>"",
|
|
|
+ "post_code"=>$post_code,
|
|
|
+ "post_company"=>$company,
|
|
|
+ "post_fee"=>$post_fee,
|
|
|
+ "gys_remark"=>"",
|
|
|
+ "addtime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ $returninfo['post_fee']=$post_fee;
|
|
|
+ $returninfo['post_company']=$company;
|
|
|
+ $returninfo['post_code']=$post_code;
|
|
|
+ }
|
|
|
+ $up =Db::name("order_returninfo")->save($returninfo);
|
|
|
+ if($up){
|
|
|
+ $info['status']=5;
|
|
|
+ $info['updatetime']=date("y-m-d H:i:s");
|
|
|
+ $ro =Db::name("order_return")->save($info);
|
|
|
+ if($ro){
|
|
|
+ $thNo =makeNo("TH");
|
|
|
+ $thdata=[
|
|
|
+ "thNo"=>$thNo,
|
|
|
+ "orderCode"=>$out["orderCode"],
|
|
|
+ "outCode"=>$out["outCode"],
|
|
|
+ "order_type"=>$info["order_type"],
|
|
|
+ "returnCode"=>$info["returnCode"],
|
|
|
+ "good_code"=>$info["good_code"],
|
|
|
+ "good_name"=>$info["good_name"],
|
|
|
+ "return_wsm"=>$returninfo["return_wsm"],
|
|
|
+ "defective_wsm"=>'',
|
|
|
+ "return_msg"=>$out["error_msg"],
|
|
|
+ "return_num"=>$info["total_num"],
|
|
|
+ "normal_num"=>0,
|
|
|
+ "received_num"=>0,
|
|
|
+ "defective_num"=>0,
|
|
|
+ "loss_num"=>0,
|
|
|
+ "contactor"=>$returninfo["contactor"],
|
|
|
+ "mobile"=>$returninfo["mobile"],
|
|
|
+ "addr"=>$returninfo["addr"],
|
|
|
+ "addr_code"=>$returninfo["addr_code"],
|
|
|
+ "return_code"=>$info["error_code"],
|
|
|
+ "post_fee"=>$returninfo["post_fee"],
|
|
|
+ "post_code"=>$returninfo["post_code"],
|
|
|
+ "post_company"=>$returninfo["post_company"],
|
|
|
+ "customer_code"=>$returninfo["customer_code"],
|
|
|
+ "status"=>1,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $sav= Db::name("order_back")->insert($thdata);
|
|
|
+ if($sav){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,"退货单新建成功",["thNo"=>$thNo]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,'退货失败');
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|