|
@@ -0,0 +1,261 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+namespace app\Admin\controller;
|
|
|
+
|
|
|
+use think\App;
|
|
|
+use think\facade\Db;
|
|
|
+
|
|
|
+class Orderback extends \app\BaseController
|
|
|
+{
|
|
|
+ public $post=[];
|
|
|
+ public function __construct(App $app)
|
|
|
+ {
|
|
|
+ parent::__construct($app);
|
|
|
+ $this->post =$this->request->post();
|
|
|
+ }
|
|
|
+
|
|
|
+ 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]];
|
|
|
+ $thNo = isset($this->post['thNo']) && $this->post['thNo']!="" ? trim($this->post['thNo']):"";
|
|
|
+ if($thNo!=""){
|
|
|
+ $where[]=['thNo',"like", "%{$thNo}%"];
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
|
|
|
+ if($status!==""){
|
|
|
+ // $where['status'] = $status;
|
|
|
+ $where[]=['status',"=", $status];
|
|
|
+ }
|
|
|
+ $post_code= isset($this->post['post_code']) && $this->post['post_code']!="" ? trim($this->post['post_code']):"";
|
|
|
+ if($post_code!=""){
|
|
|
+ $where[]=['post_code',"like", "%{$post_code}%"];
|
|
|
+ }
|
|
|
+ $post_compay = isset($this->post['post_compay']) && $this->post['post_compay']!="" ? trim($this->post['post_compay']):"";
|
|
|
+ if($post_compay!=""){
|
|
|
+ $where[]=['post_company',"=", $post_compay];
|
|
|
+ }
|
|
|
+ $customer_code = isset($this->post['customer_code']) && $this->post['customer_code']!="" ? trim($this->post['customer_code']):"";
|
|
|
+ if($customer_code!=""){
|
|
|
+ $where[]=['customer_code',"like", "%{$customer_code}%"];
|
|
|
+ }
|
|
|
+ $order_code = isset($this->post['order_code']) && $this->post['order_code']!="" ? trim($this->post['order_code']):"";
|
|
|
+ if($order_code!=""){
|
|
|
+ $where[]=['orderCode',"like", "%{$order_code}%"];
|
|
|
+ }
|
|
|
+ $out_code = isset($this->post['out_code']) && $this->post['out_code']!="" ? trim($this->post['out_code']):"";
|
|
|
+ if($out_code!=""){
|
|
|
+ $where[]=['outCode',"like", "%{$out_code}%"];
|
|
|
+ }
|
|
|
+ $return_code = isset($this->post['return_code']) && $this->post['return_code']!="" ? trim($this->post['return_code']):"";
|
|
|
+ if($return_code!=""){
|
|
|
+ $where[]=['returnCode',"like", "%{$return_code}%"];
|
|
|
+ }
|
|
|
+ $start =isset($this->post['start'])&&$this->post['start']!='' ? $this->post['start']:"";
|
|
|
+ if($start!==""){
|
|
|
+ $where[]=['addtime',">=", $start];
|
|
|
+ }
|
|
|
+ $end =isset($this->post['end'])&&$this->post['end']!='' ? $this->post['end']:"";
|
|
|
+ if($end!==""){
|
|
|
+ $where[]=['addtime',"<=", $end];
|
|
|
+ }
|
|
|
+ $count=Db::name("order_back")->where($where)->count();
|
|
|
+ $total = ceil($count/$size);
|
|
|
+ $page = $page >= $total ? $total : $page;
|
|
|
+ $list = Db::name("order_back")->where($where)->page($page,$size)->order("addtime desc")->select();
|
|
|
+ $data=[];
|
|
|
+ foreach ($list as $value){
|
|
|
+ $value['wsm_name']="";
|
|
|
+ $value['wsm_supplier']='';
|
|
|
+ $value['wsm_supplierNo']='';
|
|
|
+ if($value['return_wsm']!=""){
|
|
|
+ $wsmcode = Db::name("warehouse_info")->alias("a")->leftJoin("supplier b","a.supplierNo=b.code")
|
|
|
+ ->where(["a.wsm_code"=>$value['return_wsm']])->field("a.name as wsm_name,b.name,b.code")->find();
|
|
|
+ $value['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
|
|
|
+ $value['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
|
|
|
+ $value['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
|
|
|
+ }
|
|
|
+ $inorder= Db::name("order_backinfo")->where(['thNo'=>$value['thNo'],"is_del"=>0])->select();
|
|
|
+ $value['child']=empty($inorder)? [] : $inorder;
|
|
|
+ $data[]=$value;
|
|
|
+ }
|
|
|
+ return app_show(0,"获取成功",["list"=>$data ,"count"=>$count]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function info(){
|
|
|
+ $thNo = isset($this->post['thNo']) && $this->post['thNo']!="" ? trim($this->post['thNo']):"";
|
|
|
+ if($thNo==""){
|
|
|
+ return error_show(1004,"参数thNo不能为空");
|
|
|
+ }
|
|
|
+ $info =Db::name("order_back")->where(['thNo'=>$thNo])->find();
|
|
|
+ if(empty($info)){
|
|
|
+ return error_show(1004,"未找到数据");
|
|
|
+ }
|
|
|
+ $info['wsm_name']="";
|
|
|
+ $info['wsm_supplier']='';
|
|
|
+ $info['wsm_supplierNo']='';
|
|
|
+ if($info['return_wsm']!=""){
|
|
|
+ $wsmcode = Db::name("warehouse_info")->alias("a")->leftJoin("supplier b","a.supplierNo=b.code")
|
|
|
+ ->where(["a.wsm_code"=>$info['return_wsm']])->field("a.name as wsm_name,b.name,b.code")->find();
|
|
|
+ $info['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
|
|
|
+ $info['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
|
|
|
+ $info['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
|
|
|
+ }
|
|
|
+ $inorder= Db::name("order_backinfo")->where(['thNo'=>$info['thNo'],"is_del"=>0])->select();
|
|
|
+ $info['child']=empty($inorder)? [] : $inorder;
|
|
|
+ return app_show(0,"获取成功",$info);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function check(){
|
|
|
+ $thNo = isset($this->post['thNo']) && $this->post['thNo']!="" ? trim($this->post['thNo']):"";
|
|
|
+ if($thNo==""){
|
|
|
+ return error_show(1004,"参数thNo不能为空");
|
|
|
+ }
|
|
|
+ $info =Db::name("order_back")->where(['thNo'=>$thNo])->find();
|
|
|
+ if(empty($info)){
|
|
|
+ return error_show(1004,"未找到数据");
|
|
|
+ }
|
|
|
+ $receive = isset($this->post['receive']) && $this->post['receive']!="" ? intval($this->post['receive']):"";
|
|
|
+ if($receive==""){
|
|
|
+ return error_show(1004,"参数receive不能为空");
|
|
|
+ }
|
|
|
+ $normal = isset($this->post['normal']) && $this->post['normal']!=="" ? intval($this->post['normal']):"";
|
|
|
+ if($receive===""){
|
|
|
+ return error_show(1004,"参数receive不能为空");
|
|
|
+ }
|
|
|
+ $errorlist = isset($this->post['errorlist']) && $this->post['errorlist']!=="" ? $this->post['errorlist']:[];
|
|
|
+
|
|
|
+ $remark = isset($this->post['remark']) && $this->post['remark']!=="" ? trim($this->post['remark']):"";
|
|
|
+ $info['received_num'] = $receive;
|
|
|
+ $info['normal_num'] = $normal;
|
|
|
+ $info['remark'] = $remark;
|
|
|
+ $info['status'] = 2;
|
|
|
+ $info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $up=Db::name("order_back")->save($info);
|
|
|
+ if($up){
|
|
|
+ if(empty($errorlist)){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,'更新成功');
|
|
|
+ }
|
|
|
+ $temp =[];
|
|
|
+ foreach($errorlist as $value){
|
|
|
+ $data=[];
|
|
|
+ $data['thNo']=$thNo;
|
|
|
+ $data['error_num']=$value['error_num'];
|
|
|
+ $data['error_code']=$value['error_code'];
|
|
|
+ $data['error_remark']=$value['error_remark'];
|
|
|
+ $data['addtime']=date("Y-m-d H:i:s");
|
|
|
+ $data['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $temp[]=$data;
|
|
|
+ }
|
|
|
+ $in = Db::name("order_backinfo")->insertAll($temp);
|
|
|
+ if($in){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,'更新成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005,'更新失败');
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function CheckExam(){
|
|
|
+ $thNo = isset($this->post['thNo']) && $this->post['thNo']!="" ? trim($this->post['thNo']):"";
|
|
|
+ if($thNo==""){
|
|
|
+ return error_show(1004,"参数thNo不能为空");
|
|
|
+ }
|
|
|
+ $info =Db::name("order_back")->where(['thNo'=>$thNo])->find();
|
|
|
+ if(empty($info)){
|
|
|
+ return error_show(1004,"未找到数据");
|
|
|
+ }
|
|
|
+ $errorlist = isset($this->post['errorlist']) && $this->post['errorlist']!=="" ? $this->post['errorlist']:[];
|
|
|
+ $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
|
|
|
+ if($status===""){
|
|
|
+ return error_show(1004,"参数status不能为空");
|
|
|
+ }
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $info['status'] =$status;
|
|
|
+ $info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $up=Db::name("order_back")->save($info);
|
|
|
+ if($up){
|
|
|
+ if(empty($errorlist)){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,'更新成功');
|
|
|
+ }
|
|
|
+ // $temp =[];
|
|
|
+ foreach($errorlist as $value){
|
|
|
+ $temp=Db::name("order_backinfo")->where(['id'=>$value["id"],"is_del"=>0,"thNo"=>$thNo])->find();
|
|
|
+ if(empty($temp)){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005,'异常记录数据未找到');
|
|
|
+ }
|
|
|
+ $temp['status']=$value['status'];
|
|
|
+ $temp['exam_remark']=$value['remark'];
|
|
|
+ $temp['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $com = Db::name("order_backinfo")->save($temp);
|
|
|
+ if($com==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005,'异常记录数据更新失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,'更新成功');
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005,'更新失败');
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function Exam(){
|
|
|
+ $thNo = isset($this->post['thNo']) && $this->post['thNo']!="" ? trim($this->post['thNo']):"";
|
|
|
+ if($thNo==""){
|
|
|
+ return error_show(1004,"参数thNo不能为空");
|
|
|
+ }
|
|
|
+ $info =Db::name("order_back")->where(['thNo'=>$thNo])->find();
|
|
|
+ if(empty($info)){
|
|
|
+ return error_show(1004,"未找到数据");
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
|
|
|
+ if($status===""){
|
|
|
+ return error_show(1004,"参数status不能为空");
|
|
|
+ }
|
|
|
+ $remark= isset($this->post['remark']) && $this->post['remark']!="" ? trim($this->post['remark']):"";
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $info['status'] =$status;
|
|
|
+ $info['remark'] =$remark;
|
|
|
+ $info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $up=Db::name("order_back")->save($info);
|
|
|
+ if($up){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,'更新成功');
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005,'更新失败');
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|