wufeng 2 lat temu
rodzic
commit
c64b83a928
1 zmienionych plików z 39 dodań i 6 usunięć
  1. 39 6
      app/admin/controller/After.php

+ 39 - 6
app/admin/controller/After.php

@@ -1259,7 +1259,7 @@ class After extends Base
         $actcode = $old_sale['activity_code'];
         $good_num = $info['error_num'];//数量,取售后申请单中的异常数量
         $supplierNo = $old_sale['supplierNo'];
-        $sale_price = $old_sale['sale_price'];
+        $sale_price = 0;
         $origin_price = $old_sale['origin_price'];
         $goodtype = $old_sale['good_type'];
         $is_stock = $goodinfo['is_stock'];
@@ -1329,8 +1329,8 @@ class After extends Base
             "spuCode" => $spuCode,
             "skuCode" => $skuCode,
 //            "good_name" => $ct['good_name'],
-            "sale_price" => $sale_price,
-            "total_fee" => $sale_price * $good_num,
+            "sale_price" => $old_cgd['sale_price'],
+            "total_fee" => $old_cgd['sale_price'] * $good_num,
 //            "pakge_fee" => isset($origin['package_fee']) ? $origin['package_fee'] : 0,
 //            "cert_fee" => isset($origin['cert_fee']) ? $origin['cert_fee'] : 0,
 //            "open_fee" => $ct['open_fee'],
@@ -1411,6 +1411,7 @@ class After extends Base
 //                'diff_weight' => 0,
 //                'diff_fee' => 0,
 //                "workNo" => '',
+                'status' => 0,
                 "addtime" => date("Y-m-d H:i:s"),
                 "updatetime" => date("Y-m-d H:i:s"),
 //                'total_price' => round($sale_price * $good_num, 2),
@@ -1511,6 +1512,25 @@ class After extends Base
                 Db::name("order_out")->insert($out);
                 $standing_book_da['outCode'] = $outCode;
 
+
+                $order = Db::name("order_num")->where(["orderCode" => $orderCode, "status" => 1])->where([["wsend_num", ">=", 0]])->find();
+                if (empty($order)) throw new Exception('采购单关联数据未找到');
+                $order['send_num'] += $good_num;
+                $order['wsend_num'] -= $good_num;
+                if ($order['wsend_num'] < 0) throw new Exception('发货数量已超出总数');
+                $ups = Db::name("order_num")->save($order);
+                if ($ups) {
+                    $sen = Db::name("order_send")->save([
+                        "cgdNo" => $order['cgdNo'],
+                        "outCode" => $outCode,
+                        "send_num" => $good_num,
+                        "status" => 1,
+                        "addtime" => date("Y-m-d H:i:s"),
+                        "updatetime" => date("Y-m-d H:i:s")
+                    ]);
+                    if ($sen == false) throw new Exception('发货地址添加创建失败');
+                }
+
                 if (!isset($standing_book_da['returnCode'])) $standing_book_da['returnCode'] = '';
                 if (!isset($standing_book_da['thNo'])) $standing_book_da['thNo'] = '';
                 if (!isset($standing_book_da['returnGoodCode'])) $standing_book_da['returnGoodCode'] = '';
@@ -1522,7 +1542,13 @@ class After extends Base
 
 
                 //维护售后申请单
-                Db::name('order_return')->where(['id' => $orid, 'is_reissue' => 0])->update(['is_reissue' => 1, 'updatetime' => date('Y-m-d H:i:s')]);
+                Db::name('order_return')
+                    ->where(['id' => $orid, 'is_reissue' => 0])
+                    ->update([
+                        'is_reissue' => 1,
+                        'newOrderCode' => $orderCode,
+                        'updatetime' => date('Y-m-d H:i:s')
+                    ]);
 
                 Db::commit();
                 return error_show(0, "操作成功");
@@ -1691,9 +1717,10 @@ class After extends Base
                 "apply_id" => $rm,
                 "apply_name" => $ri,
 //                "origin_price"=>$zxinfo['total_fee'],
-                "sale_price" => $sale_price,//销售单价支持修改
+                "sale_price" => $sale_price,
 //                "post_fee"=>0,
                 "status" => 0,
+                "send_status" => 0,
                 "send_num" => 0,
                 "wsend_num" => $good_num,
 //                "send_status"=>1,
@@ -1914,7 +1941,13 @@ class After extends Base
                 Db::name('standing_book')->where('infoNo', $standing_book_data['infoNo'])->update($standing_book_data);
 
 
-                Db::name('order_return')->where(['id' => $orid, 'is_reissue' => 0])->update(['is_reissue' => 1, 'updatetime' => date('Y-m-d H:i:s')]);
+                Db::name('order_return')
+                    ->where(['id' => $orid, 'is_reissue' => 0])
+                    ->update([
+                        'is_reissue' => 1,
+                        'newOrderCode' => $orderCode,
+                        'updatetime' => date('Y-m-d H:i:s')
+                    ]);
 
                 Db::commit();
                 return app_show(0, "咨询订单创建成功", ["order_code" => $orderCode]);