wugg 3 years ago
parent
commit
5053bbc852

+ 250 - 9
app/admin/controller/After.php

@@ -18,27 +18,268 @@ class After extends \app\BaseController
     }
 
     public function create(){
-         $ordeCode = isset($this->post['orderCode']) &&$this->post['orderCode']!=''?trim($this->post['orderCode']) :"";
-         if($ordeCode==''){
-             return error_show(1004,"参数orderCode 不能为空");
+         $outCode = isset($this->post['outCode']) &&$this->post['outCode']!=''?trim($this->post['outCode']) :"";
+         if($outCode==''){
+             return error_show(1004,"参数outCode 不能为空");
          }
-         $order= Db::name("sale")->where(["orderCode"=>$ordeCode,"is_del"=>0])->find();
+         $order= Db::name("order_out")->where(["outCode"=>$outCode])->find();
          if(empty($order)){
              return error_show(1005,"未找到订单数据");
          }
+        $order= Db::name("sale")->where(["orderCode"=>$order['orderCode'],"is_del"=>0])->find();
+        if(empty($order)){
+            return error_show(1005,"未找到订单数据");
+        }
         $errorCode = isset($this->post['errorCode']) &&$this->post['errorCode']!=''?trim($this->post['errorCode']) :"";
-        if($ordeCode==''){
-            return error_show(1004,"参数orderCode 不能为空");
+        if($outCode==''){
+            return error_show(1004,"参数errorCode 不能为空");
         }
         $error =Db::name('result_info')->where(["result_code"=>$errorCode,"is_del"=>0])->find();
         if(empty($error)){
             return error_show(1005,"未找到退货原因数据");
         }
+        $num =isset($this->post['num']) &&$this->post['num']!=''?intval($this->post['num']) :"";
+        if($num==""){
+            return error_show(1004,"参数 num 不能为空或零");
+        }
         $remark =isset($this->post['remark']) &&$this->post['remark']!=''?trim($this->post['remark']) :"";
-        $data = isset($this->post['list'])&&$this->post['list']!='' ? $this->post['list'] :'';
-        if($data=='' || empty($data)){
-            return error_show(1005,"参数list不能为空");
+        $except_code =isset($this->post['except_code']) &&$this->post['except_code']!=''?trim($this->post['except_code']) :"";
+        $img = isset($this->post['img']) &&$this->post['img']!=''?trim($this->post['img']) :"";
+        $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
+        if($token==''){
+            return error_show(1005,"参数token不能为空");
+        }
+        $user =GetUserInfo($token);
+        if(empty($user)||$user['code']!=0){
+            return error_show(1002,"申请人数据不存在");
+        }
+        $rm= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
+        $ri= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
+        $returnCode=makeNo("RXS");
+        Db::startTrans();
+        try{
+            $in = [
+                "returnCode"=>$returnCode,
+                "outCode"=>$outCode,
+                "orderCode"=> $order['orderCode'],
+                "good_code"=>$order['good_code'],
+                "good_name"=>$order['good_name'],
+                "customer_code"=>$order['customer_code'],
+                "apply_id"=>$rm,
+                "apply_name"=>$ri,
+                'total_num'=>$order['send_num'],
+                "error_code"=>$errorCode,
+                "error_num"=>$num,
+                "error_img"=>$img,
+                "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"),
+                "updatetime"=>date("Y-m-d H:i:s")
+            ];
+            $create = Db::name("order_return")->insert($in);
+            if($create){
+                    Db::commit();
+                    return app_show(0,"售后申请单新建成功");
+            }
+            Db::rollback();
+            return error_show(1005,"售后申请单新建失败");
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1005,$e->getMessage());
+        }
+    }
+
+    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]];
+        $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
+        if($bkcode!=""){
+            $where[]=['returnCode',"like", "%{$bkcode}%"];
+        }
+        $out = isset($this->post['outCode']) && $this->post['outCode']!="" ? trim($this->post['outCode']):"";
+        if($out!=""){
+            $where[]=['outCode',"like", "%{$out}%"];
+        }
+        $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
+        if($status!==""){
+            $where[]=['status',"=", $status];
+        }
+        $orderCode = isset($this->post['orderCode']) && $this->post['orderCode']!="" ? trim($this->post['orderCode'])
+            :"";
+        if($orderCode!=""){
+            $where[]=['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}%"];
         }
+        $except_code = isset($this->post['except_code']) && $this->post['except_code']!="" ? trim($this->post['except_code']):"";
+        if($except_code!=""){
+            $where[]=['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}%"];
+        }
+        $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_return")->where($where)->count();
+        $total = ceil($count/$size);
+        $page = $total>=$page ? $page :$total;
+        $list = Db::name("order_return")->where($where)->page($page,$size)->select();
+        $data=[];
+        foreach ($list as $value){
+            $customer = Db::name("customer_info")->where(["companyNo"=>$value['customer_code']])->find();
+            $value['customer_name'] = isset($customer['companyName']) ?trim($customer['companyName']):'';
+            $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(){
+        $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,"未找到售后数据");
+        }
+        $out =Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
+        $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);
+    }
 
+    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 不能为空");
+        }
+      $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):"";
+        if($remark!=''){
+            $info['remark'] =$remark;
+        }
+        $info['status']=$status;
+        $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,"更新失败");
+        }
+    }
+
+    /**
+     * @return \think\response\Json|void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function postfeed(){
+        $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,"未找到售后数据");
+        }
+        $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']):"";
+        if($wsm_code==""){
+            return error_show(1005,"参数 wsm_code不能为空");
+        }
+        $wsm = Db::name("warehouse_info")->where(["wsm_code"=>$wsm_code])->find();
+        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,"更新失败");
+        }
+    }
+
+    /**
+     * @return \think\response\Json|void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function addpost(){
+        $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,"未找到售后数据");
+        }
+          $post_own = isset($this->post['own']) &&$this->post['own']!='' ? trim($this->post['own']):"";
+        if($post_own==''){
+            return error_show(1005,"参数own不能为空");
+        }
+        $info['post_own'] = $post_own;
+        $post_company = isset($this->post['company'])&&$this->post['company']!='' ? trim($this->post['company']):"";
+        if($post_company==''){
+            return error_show(1005,"参数company不能为空");
+        }
+        $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;
+        $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 error_show(1004,"更新失败");
+        }
     }
 }

+ 0 - 1
app/admin/controller/Process.php

@@ -72,7 +72,6 @@ class Process extends BaseController
     $data=[];
     foreach ($list as $value){
         $node = Db::name("process_order")->where(["order_type"=>$value['order_type'],"action_process"=>$value['order_process'],"order_code"=>$orderCode])->find();
-       // $value['node']=!empty($node) ?$node:[];
         $value['action_uid']= isset($node['action_uid']) ? $node['action_uid']:'';
         $value['action_name']= isset($node['action_name']) ? $node['action_name']:'';
         $data[]=$value;

+ 138 - 0
app/admin/controller/Reorder.php

@@ -0,0 +1,138 @@
+<?php
+
+
+namespace app\admin\controller;
+
+use think\facade\Db;
+use think\App;
+class Reorder extends \app\BaseController
+{
+    public $post=[];
+    public function __construct(App $app)
+    {
+        parent::__construct($app);
+        $this->post =$this->request->post();
+    }
+
+    public function create(){
+        $ordeCode = isset($this->post['orderCode']) &&$this->post['orderCode']!=''?trim($this->post['orderCode']) :"";
+        if($ordeCode==''){
+            return error_show(1004,"参数orderCode 不能为空");
+        }
+        $order= Db::name("sale")->where(["orderCode"=>$ordeCode,"is_del"=>0])->find();
+        if(empty($order)){
+            return error_show(1005,"未找到订单数据");
+        }
+        $errorCode = isset($this->post['errorCode']) &&$this->post['errorCode']!=''?trim($this->post['errorCode']) :"";
+        if($ordeCode==''){
+            return error_show(1004,"参数orderCode 不能为空");
+        }
+        $error =Db::name('result_info')->where(["result_code"=>$errorCode,"is_del"=>0])->find();
+        if(empty($error)){
+            return error_show(1005,"未找到退货原因数据");
+        }
+        $remark =isset($this->post['remark']) &&$this->post['remark']!=''?trim($this->post['remark']) :"";
+        $data = isset($this->post['list'])&&$this->post['list']!='' ? $this->post['list'] :'';
+        if($data=='' || empty($data)){
+            return error_show(1005,"参数list不能为空");
+        }
+        $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
+        if($token==''){
+            return error_show(1005,"参数token不能为空");
+        }
+        $user =GetUserInfo($token);
+        if(empty($user)||$user['code']!=0){
+            return error_show(1002,"申请人数据不存在");
+        }
+        $rm= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
+        $ri= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
+        $total = array_sum(array_column($data,"return_num"));
+        $returnCode=makeNo("RXS");
+        Db::startTrans();
+        try{
+            $in = [
+                "returnCode"=>$returnCode,
+                "orderCode"=>$ordeCode,
+                "good_code"=>$order['good_code'],
+                "good_name"=>$order['good_name'],
+                "apply_id"=>$rm,
+                "apply_name"=>$ri,
+                "error_code"=>$errorCode,
+                "num"=>$total,
+                "remark"=>$remark,
+                "order_type"=>1,
+                "status"=>0,
+                "is_del"=>0,
+                "addtime"=>date("Y-m-d H:i:s"),
+                "updatetime"=>date("Y-m-d H:i:s")
+            ];
+            $create = Db::name("sale_return")->insert($in);
+            if($create){
+                $info=[];
+                foreach ($data as $value){
+                    $wsmorder= Db::name("sale_info")->where(['orderCode'=>$ordeCode,"wsm_code"=>$value['wsm_code']])
+                        ->find();
+                    if(empty($wsmorder)){
+                        Db::rollback();
+                        return error_show(1002,"订单仓库数据不存在");
+                    }
+                    $temp=[];
+                    $temp['returnCode']=$returnCode;
+                    $temp['wsm_code']=$value['wsm_code'];
+                    $temp['return_num']=$value['return_num'];
+                    $temp['total_num']= $wsmorder['num'];
+                    $temp['addtime']= date("Y-m-d H:i:s");
+                    $temp['updatetime']= date("Y-m-d H:i:s");
+                    $info[]=$temp;
+                }
+                $return = Db::name("sale_returninfo")->insertAll($info);
+                if($return){
+                    Db::commit();
+                    return app_show(0,"退货单新建成功");
+                }
+            }
+            Db::rollback();
+            return error_show(1005,"退货单新建失败");
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1005,$e->getMessage());
+        }
+    }
+
+    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]];
+        $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
+        if($bkcode!=""){
+            $where[]=['returnCode',"like", "%{$bkcode}%"];
+        }
+        $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
+        if($status!==""){
+            $where[]=['status',"=", $status];
+        }
+        $orderCode = isset($this->post['orderCode']) && $this->post['orderCode']!="" ? trim($this->post['orderCode'])
+            :"";
+        if($orderCode!=""){
+            $where[]=['orderCode',"like", "%{$orderCode}%"];
+        }
+        $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}%"];
+        }
+        $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("sale_return")->where($where)->count();
+        $total = ceil($count/$size);
+        $page = $total>=$page ? $page :$total;
+        $list = Db::name("sale_return")->where($where)->page($page,$size)->select();
+        return app_show(0,"获取成功",['list'=>$list,"count"=>$count]);
+    }
+}

+ 7 - 0
app/admin/route/app.php

@@ -208,3 +208,10 @@ Route::rule('catcreate','admin/Cat/create');
 Route::rule('catedit','admin/Cat/edit');
 Route::rule('catinfo','admin/Cat/info');
 Route::rule('catstatus','admin/Cat/status');
+
+Route::rule('aftercreate','admin/After/create');
+Route::rule('afterinfo','admin/After/info');
+Route::rule('afterlist','admin/After/list');
+Route::rule('afterstatus','admin/After/status');
+Route::rule('afterfeed','admin/After/postfeed');
+Route::rule('afterpost','admin/After/addpost');