|
@@ -74,11 +74,6 @@ class After extends \app\BaseController
|
|
|
"error_msg"=>$error['result'],
|
|
|
"error_remark"=>$remark,
|
|
|
"except_code"=>$except_code,
|
|
|
- "return_wsm"=>'',
|
|
|
- "contactor"=>'',
|
|
|
- "mobile"=>'',
|
|
|
- "addr"=>'',
|
|
|
- "addr_code"=>'',
|
|
|
"status"=>0,
|
|
|
"is_del"=>0,
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
@@ -100,50 +95,62 @@ class After extends \app\BaseController
|
|
|
public function list(){
|
|
|
$page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
|
|
|
$size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10";
|
|
|
- $where =[['is_del',"=",0]];
|
|
|
+ $where =[['a.is_del',"=",0]];
|
|
|
$bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
|
|
|
if($bkcode!=""){
|
|
|
- $where[]=['returnCode',"like", "%{$bkcode}%"];
|
|
|
+ $where[]=['a.returnCode',"like", "%{$bkcode}%"];
|
|
|
}
|
|
|
$out = isset($this->post['outCode']) && $this->post['outCode']!="" ? trim($this->post['outCode']):"";
|
|
|
if($out!=""){
|
|
|
- $where[]=['outCode',"like", "%{$out}%"];
|
|
|
+ $where[]=['a.outCode',"like", "%{$out}%"];
|
|
|
}
|
|
|
$status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
|
|
|
if($status!==""){
|
|
|
- $where[]=['status',"=", $status];
|
|
|
+ $where[]=['a.status',"=", $status];
|
|
|
}
|
|
|
$orderCode = isset($this->post['orderCode']) && $this->post['orderCode']!="" ? trim($this->post['orderCode'])
|
|
|
:"";
|
|
|
if($orderCode!=""){
|
|
|
- $where[]=['orderCode',"like", "%{$orderCode}%"];
|
|
|
+ $where[]=['a.orderCode',"like", "%{$orderCode}%"];
|
|
|
}
|
|
|
$good_code = isset($this->post['good_code']) && $this->post['good_code']!="" ? trim($this->post['good_code'])
|
|
|
:"";
|
|
|
if($good_code!=""){
|
|
|
- $where[]=['good_code',"like", "%{$good_code}%"];
|
|
|
+ $where[]=['a.good_code',"like", "%{$good_code}%"];
|
|
|
+ }
|
|
|
+ $good_name = isset($this->post['good_name']) && $this->post['good_name']!="" ? trim($this->post['good_name'])
|
|
|
+ :"";
|
|
|
+ if($good_name!=""){
|
|
|
+ $where[]=['a.good_name',"like", "%{$good_name}%"];
|
|
|
+ }
|
|
|
+ $customer_code = isset($this->post['customer_code']) && $this->post['customer_code']!="" ? trim($this->post['customer_code'])
|
|
|
+ :"";
|
|
|
+ if($customer_code!=""){
|
|
|
+ $where[]=['a.customer_code',"like", "%{$customer_code}%"];
|
|
|
}
|
|
|
$except_code = isset($this->post['except_code']) && $this->post['except_code']!="" ? trim($this->post['except_code']):"";
|
|
|
if($except_code!=""){
|
|
|
- $where[]=['except_code',"=", $except_code];
|
|
|
+ $where[]=['a.except_code',"=", $except_code];
|
|
|
}
|
|
|
$apply_name = isset($this->post['apply_name']) && $this->post['apply_name']!="" ? trim($this->post['apply_name'])
|
|
|
:"";
|
|
|
if($apply_name!=""){
|
|
|
- $where[]=['apply_name',"like", "%{$apply_name}%"];
|
|
|
+ $where[]=['a.apply_name',"like", "%{$apply_name}%"];
|
|
|
}
|
|
|
$start =isset($this->post['start'])&&$this->post['start']!='' ? $this->post['start']:"";
|
|
|
if($start!==""){
|
|
|
- $where[]=['addtime',">=", $start];
|
|
|
+ $where[]=['a.addtime',">=", $start];
|
|
|
}
|
|
|
$end =isset($this->post['end'])&&$this->post['end']!='' ? $this->post['end']:"";
|
|
|
if($end!==""){
|
|
|
- $where[]=['addtime',"<=", $end];
|
|
|
+ $where[]=['a.addtime',"<=", $end];
|
|
|
}
|
|
|
- $count=Db::name("order_return")->where($where)->count();
|
|
|
+ $count=Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.orderCode=b.orderCode")->where
|
|
|
+ ($where)->count();
|
|
|
$total = ceil($count/$size);
|
|
|
$page = $total>=$page ? $page :$total;
|
|
|
- $list = Db::name("order_return")->where($where)->page($page,$size)->select();
|
|
|
+ $list =Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.orderCode=b.orderCode")->where($where)
|
|
|
+ ->field("a.*,b.return_wsm,b.contactor,b.mobile,b.addr,b.addr_code,b.post_code,b.post_company,b.post_fee,b.gys_remark")->page($page,$size)->select();
|
|
|
$data=[];
|
|
|
foreach ($list as $value){
|
|
|
$customer = Db::name("customer_info")->where(["companyNo"=>$value['customer_code']])->find();
|
|
@@ -164,7 +171,9 @@ class After extends \app\BaseController
|
|
|
if($bkcode==""){
|
|
|
return error_show(1005,"参数returnCode 不能为空");
|
|
|
}
|
|
|
- $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
|
|
|
+ $info = Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.orderCode=b.orderCode")
|
|
|
+ ->field("a.*,b.return_wsm,b.contactor,b.mobile,b.addr,b.addr_code,b.post_code,b.post_company,b.post_fee,b.gys_remark")
|
|
|
+ ->where(['a.returnCode'=>$bkcode])->find();
|
|
|
if(empty($info)){
|
|
|
return error_show(1005,"未找到售后数据");
|
|
|
}
|
|
@@ -172,7 +181,6 @@ class After extends \app\BaseController
|
|
|
$info['out_num'] = isset($out['send_num'])?$out['send_num']:'';
|
|
|
$customer = Db::name("customer_info")->where(["companyNo"=>$info['customer_code']])->find();
|
|
|
$info['customer_name'] = isset($customer['companyName']) ?trim($customer['companyName']):'';
|
|
|
-
|
|
|
return app_show(0,"获取成功",$info);
|
|
|
}
|
|
|
|
|
@@ -227,15 +235,39 @@ class After extends \app\BaseController
|
|
|
if(empty($wsm)){
|
|
|
return error_show(1005,"未找到仓库数据");
|
|
|
}
|
|
|
- $info['return_wsm']=$wsm_code;
|
|
|
- $info['status']=3;
|
|
|
- $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
- $up =Db::name("order_return")->save($info);
|
|
|
- if($up){
|
|
|
- return app_show(0,"更新成功");
|
|
|
- }else{
|
|
|
- return error_show(1004,"更新失败");
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $info['status']=3;
|
|
|
+ $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $up =Db::name("order_return")->save($info);
|
|
|
+ if($up){
|
|
|
+ $returninfo = Db::name("order_returninfo")->where(["orderCode"=>$bkcode])->find();
|
|
|
+ if(empty($returninfo)){
|
|
|
+ $returninfo=[
|
|
|
+ "returnCode"=>$bkcode,
|
|
|
+ "return_wsm"=>$wsm_code,
|
|
|
+ "contactor"=>'',
|
|
|
+ "mobile"=>'',
|
|
|
+ "addr"=>'',
|
|
|
+ "addr_code"=>'',
|
|
|
+ "addtime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ $returninfo['return_wsm'] = $wsm_code;
|
|
|
+ }
|
|
|
+ $in=Db::name("order_returninfo")->save($returninfo);
|
|
|
+ if($in){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,"更新成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"更新失败");
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -252,6 +284,21 @@ class After extends \app\BaseController
|
|
|
$info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
|
|
|
if(empty($info)){
|
|
|
return error_show(1005,"未找到售后数据");
|
|
|
+ }
|
|
|
+ $return_info = Db::name("order_returninfo")->where(['returnCode'=>$bkcode])->find();
|
|
|
+ if(empty($return_info)){
|
|
|
+ $return_info=[
|
|
|
+ "returnCode"=>$bkcode,
|
|
|
+ "return_wsm"=>'',
|
|
|
+ "contactor"=>'',
|
|
|
+ "mobile"=>'',
|
|
|
+ "addr"=>'',
|
|
|
+ "addr_code"=>'',
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "post_company"=>'',
|
|
|
+ "post_code"=>'',
|
|
|
+ "post_fee"=>'',
|
|
|
+ ];
|
|
|
}
|
|
|
$post_own = isset($this->post['own']) &&$this->post['own']!='' ? trim($this->post['own']):"";
|
|
|
if($post_own==''){
|
|
@@ -262,24 +309,35 @@ class After extends \app\BaseController
|
|
|
if($post_company==''){
|
|
|
return error_show(1005,"参数company不能为空");
|
|
|
}
|
|
|
- $info['post_company'] = $post_company;
|
|
|
+ $return_info['post_company'] = $post_company;
|
|
|
$post_code = isset($this->post['post_code'])&&$this->post['post_code']!='' ? trim($this->post['post_code']):"";
|
|
|
if($post_code==''){
|
|
|
return error_show(1005,"参数post_code不能为空");
|
|
|
}
|
|
|
- $info['post_code'] = $post_code;
|
|
|
+ $return_info['post_code'] = $post_code;
|
|
|
$fee= isset($this->post['post_fee'])&&$this->post['post_fee']!=='' ? round($this->post['post_fee'],2):"";
|
|
|
if($fee===''){
|
|
|
return error_show(1005,"参数post_code不能为空");
|
|
|
}
|
|
|
- $info['post_fee'] = $fee;
|
|
|
- $info['status'] =4;
|
|
|
- $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
- $up =Db::name("order_return")->save($info);
|
|
|
- if($up){
|
|
|
- return app_show(0,"更新成功");
|
|
|
- }else{
|
|
|
+ $return_info['post_fee'] = $fee;
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $info['status']=4;
|
|
|
+ $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $up =Db::name("order_return")->save($info);
|
|
|
+ if($up){
|
|
|
+ $in=Db::name("order_returninfo")->save($return_info);
|
|
|
+ if($in){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,"更新成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
return error_show(1004,"更新失败");
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|