Просмотр исходного кода

Merge branch 'master-new-wgg' of wugg/phpstock into master-new

wugg 1 год назад
Родитель
Сommit
9fa6d7fe94
1 измененных файлов с 58 добавлено и 219 удалено
  1. 58 219
      app/admin/controller/Reorder.php

+ 58 - 219
app/admin/controller/Reorder.php

@@ -368,26 +368,26 @@ class Reorder extends Base
 //                    }
 
 
-//                    $data=[
-//                        "orderCode"=>$ordeCode,
-//                        "th_type"=>1,
-//                        "th_num"=>$thnum,
-//                        "th_fee"=>round($order['sale_price']*$thnum,2),
-//                        "thCode"=>$returnCode,
-//                        "spuCode"=>$order['good_code'],
-//                        "good_name"=>$order['good_name'],
-//                        "cat_id"=>$order['cat_id'],
-//                        "apply_id"=>$rm,
-//                        "apply_name"=>$ri,
-//                        "addtime"=>$date,
-//                        "status"=>1,
-//                        "is_del"=>0
-//                    ];
-//                    $inse=Db::name("th_data")->insert($data);
-//                    if($inse==false){
-//                        Db::rollback();
-//                        return json_show(1004,"退货单更新失败");
-//                    }
+                    $data=[
+                        "orderCode"=>$ordeCode,
+                        "th_type"=>1,
+                        "th_num"=>$thnum,
+                        "th_fee"=>round($order['sale_price']*$thnum,2),
+                        "thCode"=>$returnCode,
+                        "spuCode"=>$order['good_code'],
+                        "good_name"=>$order['good_name'],
+                        "cat_id"=>$order['cat_id'],
+                        "apply_id"=>$rm,
+                        "apply_name"=>$ri,
+                        "addtime"=>$date,
+                        "status"=>1,
+                        "is_del"=>0
+                    ];
+                    $inse=Db::name("th_data")->insert($data);
+                    if($inse==false){
+                        Db::rollback();
+                        return json_show(1004,"退货单更新失败");
+                    }
                 }
 
                 Db::commit();
@@ -963,7 +963,8 @@ class Reorder extends Base
                         if(empty($good))throw new Exception('未找到商品信息');
                         $stock=Db::name("good")->where($good)->update(["usable_stock"=>$good['usable_stock']+$info['num'],"updatetime"=>date("Y-m-d H:i:s")]);
                         if ($stock == false) throw new Exception('商品库存更新失败');
-                    } else {
+                    }
+                    else {
                         if ($info['is_th'] == 1) {
                             $orderinfo['th_num'] += $info['num'];
                             if ($orderinfo['th_num'] == $orderinfo['send_num'] && $orderinfo['wsend_num'] == 0) {
@@ -1088,14 +1089,14 @@ class Reorder extends Base
                         }
 
                     }
-                    ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
+                    ActionLog::logAdd(['id' => $info['apply_id'], 'nickname' => $info['apply_name']], [
                         "order_code" => $orderinfo["orderCode"],//出库单号
                         "status" => $lor,//这里的status是之前的值
                         "action_remark" => '',//备注
                         "action_type" => "status"//新建create,编辑edit,更改状态status
                     ], "XSQRD", $orderinfo['status'], $orderinfo);
 
-                    ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
+                    ProcessOrder::AddProcess(['id' => $info['apply_id'], 'nickname' => $info['apply_name']], [
                         "order_type" => 'XSQRD',
                         "order_code" => $orderinfo["orderCode"],//出库单号
                         "order_id" => $orderinfo["id"],
@@ -1141,185 +1142,23 @@ class Reorder extends Base
                         }
                     }
 
-//                    ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
-//                        "order_type" => 'CGD',
-//                        "order_code" => $cgd['cgdNo'],
-//                        "order_id" => $cgd["id"],
-//                        "order_status" => $cgd['status'],
-//                        "before_status" => $lor,
-//                        'holder_id' => $holder_id
-//                    ]);
-
-                    //以下判断是当供应商不同意要退回到业务公司的时候触发的,在3.0系统中不需要了2023-02-09@by武
-//                    if ($orderinfo['is_stock'] == 1 || $info['is_th'] == 0) {
-//
-//                        if ($orderinfo['order_type'] != 1) {
-//                            if ($orderinfo['order_type'] == 3) {
-//                                $goon = Db::name("good_zixun")
-//                                    ->where(["spuCode" => $orderinfo['good_code'], "is_del" => 0])
-//                                    ->findOrEmpty();
-//                                $isZx = 1;
-//                            } else {
-//                                $goon = Db::name('good_basic')
-//                                    ->where(['spuCode' => $orderinfo['good_code']])
-//                                    ->findOrEmpty();
-//                                $isZx = 2;
-//                            }
-//                            $spuCode = $this->CheckGoodZx($goon, $isZx, $code);
-//                            $wsmcode = $info['return_wsm'];
-//                            if ($wsmcode == "") throw new Exception('未找到退货仓库');
-//
-//                            $stock = Db::name("good_stock")
-//                                ->where(['is_del' => 0, "spuCode" => $spuCode, 'wsm_code' => $wsmcode])
-//                                ->findOrEmpty();
-//                            if (empty($stock)) {
-//                                $stock = [
-//                                    "spuCode" => $spuCode,
-//                                    "wsm_code" => $wsmcode,
-//                                    "usable_stock" => 0,
-//                                    "wait_out_stock" => 0,
-//                                    "wait_in_stock" => 0,
-//                                    "total_stock" => 0,
-//                                    "addtime" => $date,
-//                                    "updatetime" => $date,
-//                                ];
-//                            }
-//                            $stock['usable_stock'] += $info['num'];
-//                            $stock['updatetime'] = $date;
-//                            $st_up = Db::name("good_stock")->save($stock);
-//                            if ($st_up == false) throw new Exception('可售商品入库失败');
-//
-//                            $stockid = isset($stock['id']) ? $stock['id'] : Db::name("good_stock")->getLastInsID();
-//                            $sabebn = Db::name("sale_info")
-//                                ->where(["orderCode" => $orderinfo["orderCode"]])
-//                                ->select()
-//                                ->toArray();
-//                            if (!empty($sabebn)) {
-//                                $total_num = $info['num'];
-//                                foreach ($sabebn as $ve) {
-//                                    $tempnum = 0;
-//                                    if ($total_num == 0) break;
-//                                    if ($total_num >= $ve['num']) {
-//                                        $tempnum = $ve['num'];
-//                                        $total_num -= $ve['num'];
-//                                        $ve['th_num'] += $ve['num'];
-//                                        $ve['num'] = 0;
-//                                    } else {
-//                                        $tempnum = $total_num;
-//                                        $ve['num'] -= $total_num;
-//                                        $ve['th_num'] += $total_num;
-//                                        $total_num = 0;
-//                                    }
-//                                    $bnin = GoodStockInfo::AddBn($stockid, $ve['bnCode'], $tempnum, $ve['origin_price']);
-//                                    if ($bnin == false) throw new Exception('可售商品Bn库存数入库失败');
-//
-//                                    $ve['updatetime'] = $date;
-//                                    $up = Db::name("sale_info")->save($ve);
-//                                    if ($up == false) throw new Exception('可售商品Bn库存数入库失败');
-//
-//                                    $bnin = GoodStockInfo::ReturnBn($info['returnCode'], $ve['id'], $tempnum);
-//                                    if ($bnin == false) throw new Exception('可售商品Bn库存数入库失败');
-//
-//                                }
-//                            } else {
-//                                $bn = makeNo("BN");
-//                                $bnin = GoodStockInfo::AddBn($stockid, $bn, $info['num'], $cgd['good_price'] ?? 0);
-//                                if ($bnin == false) throw new Exception('可售商品Bn库存数入库失败');
-//
-//                            }
-//                            $good_data = ['good_log_code' => $info['returnCode'], "stock_id" => $stockid, "type" => 1, 'stock' => $info['num'], "stock_name" => "usable_stock"];
-//                            GoodLog::LogAdd(['id' => $this->uid, 'nickname' => $this->uname], $good_data, 'XSTHD');
-//                        } else {
-//                            $sabebn = Db::name("sale_info")
-//                                ->where(["orderCode" => $orderinfo["orderCode"]])
-//                                ->select()
-//                                ->toArray();
-//                            if (!empty($sabebn)) {
-//                                $total_num = $info['num'];
-//                                foreach ($sabebn as $ve) {
-//                                    $stock = Db::name("good_stock")
-//                                        ->where(['is_del' => 0, "spuCode" => $orderinfo['good_code'], 'id' => $ve['stockid']])
-//                                        ->findOrEmpty();
-//                                    if ($stock == false) throw new Exception('商品库存数据未找到');
-//
-//                                    $tempnum = 0;
-//                                    if ($total_num == 0) break;
-//                                    if ($total_num >= $ve['num']) {
-//                                        $tempnum = $ve['num'];
-//                                        $total_num -= $ve['num'];
-//                                        $ve['th_num'] += $ve['num'];
-//                                        $ve['num'] = 0;
-//                                    } else {
-//                                        $tempnum = $total_num;
-//                                        $ve['num'] -= $total_num;
-//                                        $ve['th_num'] += $total_num;
-//                                        $total_num = 0;
-//                                    }
-//                                    $stock['usable_stock'] += $tempnum;
-//                                    $stock['wait_out_stock'] -= $tempnum;
-//                                    $stock['updatetime'] = $date;
-//                                    $st_up = Db::name("good_stock")->save($stock);
-//                                    if ($st_up == false) throw new Exception('可售商品入库失败');
-//
-//
-//                                    $bnin = GoodStockInfo::AddBn($ve['stock_id'], $ve['bnCode'], $tempnum, $ve['origin_price']);
-//                                    if ($bnin == false) throw new Exception('可售商品Bn库存数入库失败');
-//
-//                                    $ve['updatetime'] = $date;
-//                                    $up = Db::name("sale_info")->save($ve);
-//                                    if ($up == false) throw new Exception('可售商品Bn库存数入库失败');
-//
-//                                    $bnin = GoodStockInfo::ReturnBn($info['returnCode'], $ve['id'], $tempnum);
-//                                    if ($bnin == false) throw new Exception('可售商品Bn库存数入库失败');
-//
-//                                }
-//                            } else {
-//
-//                                $ordernum = Db::name("order_num")->where(['orderCode' => $orderinfo["orderCode"]])->findOrEmpty();
-//                                if ($ordernum == false) throw new Exception('未找到关联采购单');
-//
-//                                $cgd = Db::name("purchease_order")
-//                                    ->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])
-//                                    ->findOrEmpty();
-//                                if ($cgd == false) throw new Exception('未找到采购单数据');
-//
-//                                $bn = makeNo("BN");
-//                                $stock = Db::name("good_stock")
-//                                    ->where(["spuCode" => $orderinfo['good_code'], 'wsm_code' => $cgd['wsm_code'], "is_del" => 0, "status" => 1])
-//                                    ->findOrEmpty();
-//                                if ($stock == false) throw new Exception('商品库存数据未找到');
-//
-//                                $stock['usable_stock'] += $info['num'];
-//                                $stock['wait_out_stock'] -= $info['num'];
-//                                $stock['updatetime'] = $date;
-//                                $st_up = Db::name("good_stock")->save($stock);
-//                                if ($st_up == false) throw new Exception('可售商品入库失败');
-//
-//                                $yp = GoodStockInfo::AddBn($stock['id'], $bn, $info['num'], $cgd['good_price']);
-//                                if ($yp == false) throw new Exception('商品批次退货入库失败');
-//
-//                            }
-//                        }
-//                    }
-
-
-//                    $data = [
-//                        "orderCode" => $info['orderCode'],
-//                        "th_type" => 1,
-//                        "th_num" => $info['num'],
-//                        "th_fee" => round($info['num'] * $orderinfo['sale_price'], 2),
-//                        "thCode" => $info['returnCode'],
-//                        "spuCode" => $orderinfo['good_code'],
-//                        "good_name" => $orderinfo['good_name'],
-//                        "cat_id" => $orderinfo['cat_id'],
-//                        "apply_id" => $info['apply_id'],
-//                        "apply_name" => $info['apply_name'],
-//                        "addtime" => $date,
-//                        "status" => 1,
-//                        "is_del" => 0
-//                    ];
-//                    $inse = Db::name("th_data")->insert($data);
-//                    if ($inse == false) throw new Exception('退货单更新失败');
+                    $data = [
+                        "orderCode" => $info['orderCode'],
+                        "th_type" => 1,
+                        "th_num" => $info['num'],
+                        "th_fee" => round($info['num'] * $orderinfo['sale_price'], 2),
+                        "thCode" => $info['returnCode'],
+                        "spuCode" => $orderinfo['good_code'],
+                        "good_name" => $orderinfo['good_name'],
+                        "cat_id" => $orderinfo['cat_id'],
+                        "apply_id" => $info['apply_id'],
+                        "apply_name" => $info['apply_name'],
+                        "addtime" => $date,
+                        "status" => 1,
+                        "is_del" => 0
+                    ];
+                    $inse = Db::name("th_data")->insert($data);
+                    if ($inse == false) throw new Exception('退货单更新失败');
 
                 }
             }
@@ -1724,23 +1563,23 @@ class Reorder extends Base
 //                        }
 //                    }
 
-//                    $data=[
-//                        "orderCode"=>$orderCode,
-//                        "th_type"=>1,
-//                        "th_num"=>$thnum,
-//                        "th_fee"=>round($order['sale_price']*$thnum,2),
-//                        "thCode"=>$returnCode,
-//                        "spuCode"=>$order['good_code'],
-//                        "good_name"=>$order['good_name'],
-//                        "cat_id"=>$order['cat_id'],
-//                        "apply_id"=>$this->uid,
-//                        "apply_name"=>$this->uname,
-//                        "addtime"=>date("Y-m-d H:i:s"),
-//                        "status"=>1,
-//                        "is_del"=>0
-//                    ];
-//                    $inse=Db::name("th_data")->insert($data);
-//                    if($inse==false) throw new Exception("退货单更新失败");
+                    $data=[
+                        "orderCode"=>$orderCode,
+                        "th_type"=>1,
+                        "th_num"=>$thnum,
+                        "th_fee"=>round($order['sale_price']*$thnum,2),
+                        "thCode"=>$returnCode,
+                        "spuCode"=>$order['good_code'],
+                        "good_name"=>$order['good_name'],
+                        "cat_id"=>$order['cat_id'],
+                        "apply_id"=>$this->uid,
+                        "apply_name"=>$this->uname,
+                        "addtime"=>date("Y-m-d H:i:s"),
+                        "status"=>1,
+                        "is_del"=>0
+                    ];
+                    $inse=Db::name("th_data")->insert($data);
+                    if($inse==false) throw new Exception("退货单更新失败");
 
                 }
                 Db::commit();