Browse Source

细节优化,新增两个接口

wufeng 2 years ago
parent
commit
71093a768e

+ 4 - 2
app/admin/controller/Purchin.php

@@ -401,7 +401,8 @@ class Purchin extends Base
                                 $out =Db::name("order_out")->where(["outCode"=>$send,"status"=>0,"is_del"=>0])->select()
                                 ->toArray();
                                 if(!empty($out)){
-                                    $up =Db::name("order_out")->where(["outCode"=>$send,"status"=>0,"is_del"=>0])->update(["status"=>1,'wsm_code'=>$cgdinfo['wsm_code'],"updatetime"=>date('Y-m-d H:i:s')]);
+                                    $up =Db::name("order_out")->where(["outCode"=>$send,"status"=>0,"is_del"=>0])->update(["status"=>1,'send_status'=>1,'wsm_code'=>$cgdinfo['wsm_code'],"updatetime"=>date('Y-m-d H:i:s')]);
+                                    //2023-03-14 17:34修改,增加'send_status'=>1 by 武
                                     if($up==false){
                                         Db::rollback();
                                         return error_show(1004,"出库单出库失败");
@@ -718,7 +719,8 @@ class Purchin extends Base
                             if (!empty($send)) {
                                 $out = Db::name("order_out")->where(["outCode" => $send, "status" => 0,'is_del'=>0])->select()->toArray();
                                 if (!empty($out)) {
-                                    $up = Db::name("order_out")->where(["outCode" => $send, "status" => 0,'is_del'=>0])->update(["status" => 1, 'wsm_code' => $cgdinfo[$cgdNo]['wsm_code'], "updatetime" => date('Y-m-d H:i:s')]);
+                                    $up = Db::name("order_out")->where(["outCode" => $send, "status" => 0,'is_del'=>0])->update(["status" => 1,'send_status'=>1, 'wsm_code' => $cgdinfo[$cgdNo]['wsm_code'], "updatetime" => date('Y-m-d H:i:s')]);
+                                    //2023-03-14 17:34修改,增加'send_status'=>1 by 武
                                     if ($up == false) throw new Exception('出库单出库失败');
                                     else {
 

+ 88 - 10
app/admin/controller/Reorder.php

@@ -88,6 +88,15 @@ class Reorder extends Base
             $thnum = array_sum(array_column($returnadr, "return_num"));
             $is_addr = 1;
         }
+
+        //如果全退,且没有成功的售后申请单 提示使用'订单撤销功能'
+        if ($order['good_num'] == $thnum) {
+            $temp = Db::name("sale_return")
+                ->where(["orderCode" => $ordeCode, "is_del" => 0, "status" => 4])
+                ->count('id');
+            if ($temp == 0) return json_show(1004, '');
+        }
+
         $returnCode = makeNo("RN");
         Db::startTrans();
         try {
@@ -823,16 +832,16 @@ class Reorder extends Base
         $orderinfo = Db::name("sale")->where(["orderCode" => $info["orderCode"]])->findOrEmpty();
         if (empty($orderinfo)) return json_show(1004, "未找到订单数据");
 
-        if ($status == 4) {
-            if ($info['is_addr'] == 1) {
-                $addr = Db::name("sale_returnaddr")
-                    ->where(['returnCode' => $info['returnCode'], "is_del" => 0])
-                    ->select()
-                    ->toArray();
-                if (empty($addr)) return json_show(1004, "未找到发货单地址数据");
-
-            }
-        }
+//        if ($status == 4) {
+//            if ($info['is_addr'] == 1) {
+//                $addr = Db::name("sale_returnaddr")
+//                    ->where(['returnCode' => $info['returnCode'], "is_del" => 0])
+//                    ->select()
+//                    ->toArray();
+//                if (empty($addr)) return json_show(1004, "未找到发货单地址数据");
+//
+//            }
+//        }
 //        if($status==3){
 //            $is_th =isset($this->post['is_th'])&&$this->post['is_th']!=="" ? intval($this->post['is_th']):"";
 //            if($is_th===""){
@@ -1815,4 +1824,73 @@ class Reorder extends Base
 
     }
 
+    //获取退货单对应的发货单列表
+    public function getOrderOutList()
+    {
+        $param = $this->request->only(['returnCode', 'page' => 1, 'size' => 10], 'post', 'trim');
+
+        $val = Validate::rule([
+            'returnCode|售前退货单号' => 'require',
+            'page|页码' => 'require|number|gt:0',
+            'size|每页数量' => 'require|number|gt:0|max:200',
+        ]);
+
+        if ($val->check($param) == false) return json_show(1004, $val->getError());
+
+        $where = ['a.is_del' => 0, 'a.returnCode' => $param['returnCode']];
+        $count = Db::name('sale_returnaddr')
+            ->alias('a')
+            ->leftJoin('order_addr b', 'b.id=a.addrid and b.is_del=0')
+            ->where($where)
+            ->count('a.id');
+
+        $list = Db::name('sale_returnaddr')
+            ->alias('a')
+            ->field('a.id,a.outCode,a.send_num,a.return_num,b.contactor,b.mobile,b.addr_code,b.addr,"" addr_code_cn')
+            ->leftJoin('order_addr b', 'b.id=a.addrid and b.is_del=0')
+            ->where($where)
+            ->order(['a.addtime' => 'desc', 'a.id' => 'desc'])
+            ->page($param['page'], $param['size'])
+            ->select()
+            ->toArray();
+
+        foreach ($list as &$value) {
+            if ($value['addr_code'] != '') {
+                $temp = explode(',', $value['addr_code']);
+                $value['addr_code_cn'] = GetAddr(json_encode(['provice_code' => $temp[0], 'city_code' => $temp[1], 'area_code' => $temp[2]]));
+            }
+        }
+
+        return json_show(0, '获取列表成功', ['count' => $count, 'list' => $list]);
+
+    }
+
+    //取消
+    public function cancel()
+    {
+        $param = $this->request->only(['returnCode'], 'post', 'trim');
+
+        $val = Validate::rule([
+            'returnCode|售前退货申请单号' => 'require|array|max:100',
+        ]);
+
+        if ($val->check($param) == false) return json_show(1004, $val->getError());
+
+        $temp = Db::name('sale_return')
+            ->field('returnCode')
+            ->where(['is_del' => 0, 'returnCode' => $param['returnCode'], 'status' => [11, 12, 4, 5, 13]])
+            ->findOrEmpty();
+        if (!empty($temp)) return json_show(1004, $temp['returnCode'] . '状态有误,不允许取消');
+
+        $rs = Db::name('sale_return')
+            ->where(['is_del' => 0, 'returnCode' => $param['returnCode'], 'status' => [1, 8, 9, 10]])
+            ->update([
+                'status' => 13,
+                'updatetime' => date('Y-m-d H:i:s')
+            ]);
+
+        return $rs ? json_show(0, '售前退货申请单取消成功') : json_show(1004, '售前退货申请单取消失败');
+
+    }
+
 }

+ 1 - 1
app/admin/controller/ReorderChild.php

@@ -234,7 +234,7 @@ class ReorderChild extends Base
                     "order_type" => 'XSTHD',
                     "order_code" => $info['returnCode'],//单号
                     "order_id" => $info['sr_id'],
-                    "order_status" => 2,
+                    "order_status" => 4,
                     "before_status" => 12,
                     'holder_id' => $info['sr_apply_id']
                 ]);

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

@@ -369,6 +369,7 @@ class Sale extends Base
                                 "error_num" => 0,
                                 "wsm_code" => $is_stock == 1 ?'':$cgdinfo['wsm_code'],
                                 "order_type" => $is_stock == 1 ? 1 : 2,
+                                "send_status" => $outstatus,
                                 "status" => $outstatus,
                                 "addtime" => date("Y-m-d H:i:s"),
                                 "updatetime" => date("Y-m-d H:i:s")

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

@@ -323,6 +323,8 @@ Route::rule('reorderexam', 'admin/Reorder/exam');
 Route::rule('reorderzx', 'admin/Reorder/zxcreate');
 Route::rule('reorderall', 'admin/Reorder/allReturn');//全部退货
 Route::rule('reorderExport', 'admin/Reorder/export');//退货单导出
+Route::rule('reorderool', 'admin/Reorder/getOrderOutList');//获取退货单对应的发货单信息
+Route::rule('reorder_cancel', 'admin/Reorder/cancel');//售前退货申请单取消
 Route::rule('reorder_child_add', 'admin/ReorderChild/add');//退货工单创建
 Route::rule('reorder_child_list', 'admin/ReorderChild/getList');//退货工单列表
 Route::rule('reorder_child_receive', 'admin/ReorderChild/receive');//退货工单库管收货