浏览代码

售后退货优化,其他细节优化

wufeng 2 年之前
父节点
当前提交
48347f70a1

+ 37 - 31
app/admin/controller/After.php

@@ -42,7 +42,7 @@ class After extends Base
 //             return error_show(1004,"参数outCode 不能为空");
 //         }
         $orderout = Db::name("order_out")
-            ->field('id,orderCode,wsm_code,send_num,order_type,status')
+            ->field('id,orderCode,wsm_code,send_num,order_type')
             ->where(["outCode" => $param['outCode'], 'is_del' => 0])
             ->findOrEmpty();
         if (empty($orderout)) return error_show(1005, "未找到发货单数据");
@@ -182,7 +182,6 @@ class After extends Base
                 "is_del" => 0,
                 "addtime" => date("Y-m-d H:i:s"),
                 "updatetime" => date("Y-m-d H:i:s"),
-                'order_out_status'=>$orderout['status'],
             ];
             $create = Db::name("order_return")->insert($in, true);
             $orde = ["order_code" => $returnCode, "status" => $in['status'], "action_remark" => '', "action_type" => "create"];
@@ -1265,7 +1264,7 @@ class After extends Base
             ->findOrEmpty();
         if (empty($info)) return error_show(1005, "未找到售后数据");
 
-        if (($info['is_receive'] != 0 || $info['status'] != 4)) return error_show(1005, "售后单流程状态有误");
+        if (($info['is_receive'] != 1 || $info['status'] != 4)) return error_show(1005, "售后单流程状态有误");
 
         $out = Db::name("order_out")
             ->where(["outCode" => $info["outCode"], "is_del" => 0])
@@ -1297,30 +1296,32 @@ class After extends Base
 
         Db::startTrans();
         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")
-                ->where(["returnCode" => $bkcode])
-                //->save($returninfo)
-                ->update($returninfo);
+            $returninfo = Db::name("order_returninfo")->where(["returnCode" => $bkcode])->findOrEmpty();
+            if (empty($returninfo)) {
+                $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")
+                ];
+                $up = Db::name("order_returninfo")->insert($returninfo);
+            } else {
+                $up = Db::name("order_returninfo")
+                    ->where(["returnCode" => $bkcode])
+                    ->update([
+                        'post_fee' => $post_fee,
+                        'post_company' => $company,
+                        'post_code' => $post_code,
+                        'updatetime' => date("Y-m-d H:i:s"),
+                    ]);
+            }
 
             if ($up) {
 
@@ -1354,6 +1355,11 @@ class After extends Base
                         "before_status" => $old_info_status,
                         'holder_id' => $info['apply_id']
                     ]);
+                    Db::commit();
+                    return json_show(0, '退货成功');
+                } else throw new Exception('修改售后申请单状态失败');
+
+            } else throw new Exception('退货失败');
 
                     //售后退货单数据
 //                    $thNo = makeNo("ST");
@@ -1624,10 +1630,10 @@ class After extends Base
 //                        Db::commit();
 //                        return app_show(0, "退货单新建成功", ["thNo" => $thNo]);
 //                    }
-                }
-            }
-            Db::commit();
-            return json_show(0, '退货成功');
+//                }
+//            }
+//            Db::commit();
+//            return json_show(0, '退货成功');
         } catch (Exception $e) {
             Db::rollback();
             return json_show(1004, $e->getMessage());

+ 12 - 7
app/admin/controller/AfterChild.php

@@ -31,7 +31,7 @@ class AfterChild extends Base
 
         $list = Db::name('order_return_child')
             ->alias('a')
-            ->field('a.id,a.returnCode,a.orderCode,a.outCode,a.order_out_status,a.outChildCode,b.supplierName send_supplierName,b.supplierNo send_supplierNo,b.name send_wsm_name,a.send_wsm_code,b.contactor_name send_contactor_name,a.send_num,a.return_num,c.supplierName return_supplierName,c.supplierNo return_supplierNo,c.name return_wsm_name,a.return_wsm_code,c.contactor_name return_contactor_name,a.status')
+            ->field('a.id,a.returnCode,a.orderCode,a.outCode,a.order_out_child_status,a.outChildCode,b.supplierName send_supplierName,b.supplierNo send_supplierNo,b.name send_wsm_name,a.send_wsm_code,b.contactor_name send_contactor_name,a.send_num,a.return_num,c.supplierName return_supplierName,c.supplierNo return_supplierNo,c.name return_wsm_name,a.return_wsm_code,c.contactor_name return_contactor_name,a.status')
             ->leftJoin('warehouse_info b', 'b.wsm_code=a.send_wsm_code')
             ->leftJoin('warehouse_info c', 'c.wsm_code=a.return_wsm_code')
             ->where($where)
@@ -146,16 +146,17 @@ class AfterChild extends Base
             'list|退货工单集合' => 'require|array|max:100',
         ]);
 
-        if ($val->check($param)) return json_show(1004, $val->getError());
+        if ($val->check($param) == false) return json_show(1004, $val->getError());
 
         $order_return = Db::name('order_return')
             ->alias('a')
-            ->field('a.id,a.good_code,a.outCode,b.orderCode,c.is_stock,c.order_type')
+            ->field('a.id,a.good_code,a.outCode,b.orderCode,c.is_stock,c.order_type,a.status')
             ->leftJoin('order_out b', 'b.outCode=a.outCode AND b.is_del=0')
             ->leftJoin('sale c', 'c.orderCode=b.orderCode AND c.is_del=0')
             ->where(['a.is_del' => 0, 'a.returnCode' => $param['returnCode']])
             ->findOrEmpty();
         if (empty($order_return)) return json_show(1004, '售后申请单不存在');
+        if ($order_return['status'] != 12) return json_show(1004, '售后申请单状态有误');
 
         $info = Db::name('order_return_child')
             ->alias('a')
@@ -188,7 +189,7 @@ class AfterChild extends Base
                         'can_sell_num' => $value['can_sell_num'],
                         'defective_num' => $value['defective_num'],
                         'loss_num' => $value['loss_num'],
-                        'remark' => $value['remark'],
+                        'remark' => $value['remark'] ?? '',
                         'updatetime' => $date,
                         'status' => 2
                     ]);
@@ -306,8 +307,7 @@ class AfterChild extends Base
                                     'updatetime' => $date,
                                 ]);
 
-                        }
-                        throw new Exception('未找到对应的商品数据');
+                        } else throw new Exception('未找到对应的商品数据');
 
                     }
 
@@ -335,7 +335,7 @@ class AfterChild extends Base
                                 ->insertGetId([
                                     'project_code' => '',
                                     'spuCode' => $spuCode,
-                                    'wsm_code' => $value['return_wsm_code'],
+                                    'wsm_code' => $info[$value['id']]['return_wsm_code'],
                                     'wait_in_stock' => 0,
                                     'wait_out_stock' => 0,
                                     'usable_stock' => $value['can_sell_num'],
@@ -468,6 +468,11 @@ class AfterChild extends Base
                 }
             }
 
+            //售后申请单状态维护
+            Db::name('order_return')
+                ->where(['is_del' => 0, 'returnCode' => $param['returnCode'], 'status' => 12])
+                ->update(['status' => 5, 'updatetime' => $date]);
+
             Db::commit();
             return json_show(0, '库管收货成功');
         } catch (Exception $exception) {

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

@@ -472,7 +472,7 @@ 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,"send_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,'wsm_code'=>$cgdinfo['wsm_code'],"updatetime"=>date('Y-m-d H:i:s')]);
                                     if($up==false){
                                         Db::rollback();
                                         return error_show(1004,"出库单出库失败");

+ 3 - 3
app/admin/controller/Reorder.php

@@ -61,7 +61,7 @@ class Reorder extends Base
 //        if($supplier==false){
 //            return error_show(1005,"未找到商品供应商数据");
 //        }
-        $names = $userCommon->handle('getCodeAndName',['code'=>[$order['supplierNo'],$order['customer_code']]]);
+//        $names = $userCommon->handle('getCodeAndName',['code'=>[$order['supplierNo'],$order['customer_code']]]);
 
         $errorCode = isset($this->post['errorCode']) &&$this->post['errorCode']!=''?trim($this->post['errorCode']) :"";
         if($errorCode==''){
@@ -118,9 +118,9 @@ class Reorder extends Base
                 'supplierNo' => $goon['supplierNo'],
                 'supplierName' => $supplier['name'],
                 'companyNo' => $order['supplierNo'],
-                'companyName' => $names['data'][$order['supplierNo']] ?? '',
+                'companyName' => $order['supplierName'],//$names['data'][$order['supplierNo']] ?? '',
                 'customer_code' => $order['customer_code'],
-                'customer_name' => $names['data'][$order['customer_code']] ?? '',
+                'customer_name' => $order['customerName'],//$names['data'][$order['customer_code']] ?? '',
             ];
             $create = Db::name("sale_return")->insert($in,true);
             if($create>0){