shish 1 год назад
Родитель
Сommit
e5be96dad3

+ 2 - 0
app-ghs/controllers/ItemController.php

@@ -262,6 +262,8 @@ class ItemController extends BaseController
     //增加和减少半扎 ssh 20250417
     public function actionChangeHalf()
     {
+        util::fail('此功能已停用');
+
         $post = Yii::$app->request->post();
         $productId = $post['productId'] ?? '';
         $add = $post['add'] ?? 0;

+ 2 - 5
app-ghs/controllers/PartController.php

@@ -86,10 +86,7 @@ class PartController extends BaseController
         foreach ($productList as $v) {
             $bigNum = $v['bigNum'] ?? 0;
             $smallNum = $v['smallNum'] ?? 0;
-            if ($smallNum > 0) {
-                util::fail('只能拆散整扎');
-            }
-            if ($bigNum <= 0) {
+            if ($bigNum <= 0 && $smallNum <= 0) {
                 util::fail('数量不能为0');
             }
             $property = $v['property'] ?? 1;
@@ -105,7 +102,7 @@ class PartController extends BaseController
             $post['ptStyle'] = dict::getDict('ptStyle', 'ghs');
             $return = PartClass::addOrder($post);
             $transaction->commit();
-            util::success($return,'拆散成功');
+            util::success($return, '拆散成功');
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::info("拆散失败原因:" . $e->getMessage());

+ 5 - 8
app-ghs/controllers/StockOutController.php

@@ -48,8 +48,8 @@ class StockOutController extends BaseController
                 foreach ($changeFormatData as $k => $v) {
                     $productId = $v['productId'];
                     $actPutNum = $v['actPutNum'] ?? 0;
-                    $itemName = $v['itemName']??'';
-                    $changeData[$productId] = ['actPutNum' => $actPutNum,'itemName' => $itemName];
+                    $itemName = $v['itemName'] ?? '';
+                    $changeData[$productId] = ['actPutNum' => $actPutNum, 'itemName' => $itemName];
                 }
             }
         }
@@ -67,8 +67,8 @@ class StockOutController extends BaseController
                     $changeResult = $changeData[$productId];
                     $itemNum = $changeResult['actPutNum'];
                     $itemName = $changeResult['itemName'];
-                    if(!is_numeric($itemNum)) {
-                        util::fail('请填写【'.$itemName.'】回调数值');
+                    if (!is_numeric($itemNum)) {
+                        util::fail('请填写【' . $itemName . '】回调数值');
                     }
                 }
             }
@@ -280,10 +280,7 @@ class StockOutController extends BaseController
                 $bigNum = $v['bigNum'] ?? 0;
                 $smallNum = $v['smallNum'] ?? 0;
                 $name = $v['name'] ?? '';
-                if ($smallNum > 0) {
-                    util::fail($name . '不能调拨小单位');
-                }
-                if ($bigNum <= 0) {
+                if ($bigNum <= 0 && $smallNum <= 0) {
                     util::fail('花材数量不能为0');
                 }
             }

+ 2 - 5
app-ghs/controllers/WastageController.php

@@ -59,12 +59,9 @@ class WastageController extends BaseController
         foreach ($productList as $v) {
             $bigNum = $v['bigNum'] ?? 0;
             $smallNum = $v['smallNum'] ?? 0;
-            if ($bigNum <= 0) {
+            if ($bigNum <= 0 && $smallNum <= 0) {
                 util::fail('花材数量不能为0');
             }
-            if($smallNum > 0){
-                util::fail('小单位不能报损');
-            }
         }
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
@@ -72,7 +69,7 @@ class WastageController extends BaseController
             //判断花材有效性
             ProductClass::valid($productList, $this->mainId);
             $post['product'] = $productList;
-            $return = StockWastageOrderClass::addOrder($post,$this->shop,true);
+            $return = StockWastageOrderClass::addOrder($post, $this->shop, true);
             $transaction->commit();
             util::success($return);
         } catch (\Exception $e) {

+ 2 - 0
app-hd/controllers/ItemController.php

@@ -18,6 +18,8 @@ class ItemController extends BaseController
     //增加和减少半扎 ssh 20250417
     public function actionChangeHalf()
     {
+        util::fail('此功能已停用');
+
         $post = Yii::$app->request->post();
         $productId = $post['productId'] ?? '';
         $add = $post['add'] ?? 0;

+ 2 - 1
app-hd/controllers/RefundController.php

@@ -176,7 +176,8 @@ class RefundController extends BaseController
             $orderItem = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
             if (!empty($orderItem)) {
                 foreach ($orderItem as $singe) {
-                    $productData[] = ['productId' => $singe->itemId, 'num' => $singe->num, 'unitPrice' => $singe->unitPrice, 'property' => 1,];
+                    $unitType = $singe->unitType;
+                    $productData[] = ['productId' => $singe->itemId, 'num' => $singe->num, 'unitPrice' => $singe->unitPrice, 'property' => 1, 'unitType' => $unitType];
                 }
             }
             $post['product'] = $productData;

+ 2 - 3
biz-ghs/order/classes/OrderItemClass.php

@@ -393,8 +393,7 @@ class OrderItemClass extends BaseClass
             }
 
             if ($stockMayChange == true) {
-                //小单位花材开单暂时不扣库存
-                if (intval($itemNum) > 0) {
+                if ($itemNum > 0) {
                     $checkStock = true;
                     //如果是虚拟客户,说明自己也是虚拟批发店,虚拟批发店不用考虑库存
                     if ($live == 0) {
@@ -406,7 +405,7 @@ class OrderItemClass extends BaseClass
                     $recordData['shopId'] = $post['shopId'] ?? 0;
                     $recordData['mainId'] = $post['mainId'] ?? 0;
                     $recordData['itemId'] = $val['itemId'] ?? 0;
-                    $recordData['itemNum'] = intval($itemNum);
+                    $recordData['itemNum'] = $itemNum;
                     $recordData['oldStock'] = $stockInfo['oldStock'];
                     $recordData['newStock'] = $stockInfo['newStock'];
                     $recordData['productId'] = $productId;

+ 11 - 4
biz-ghs/order/classes/RefundOrderClass.php

@@ -25,6 +25,7 @@ use bizGhs\base\classes\BaseClass;
 class RefundOrderClass extends BaseClass
 {
     use OrderTrait;
+
     public static $baseFile = '\bizGhs\order\models\RefundOrder';
 
     const STATUS_UN_COMPLETE = 0; //待审核
@@ -165,11 +166,17 @@ class RefundOrderClass extends BaseClass
                     $oneItem->refundNum = bcadd($refundNum, $num);
                     $oneItem->save();
 
-                    $smallNum = 0;
-                    $bigNum = $num;
+                    if ($refundSingle->xhUnitType == 1) {
+                        $smallNum = $num;
+                        $bigNum = 0;
+                    } else {
+                        $smallNum = 0;
+                        $bigNum = $num;
+                    }
+                    $itemNum = $refundSingle->itemNum;
 
                     //大单位退款才变库存,小单位不变化库存!!
-                    if ($bigNum > 0) {
+                    if ($bigNum > 0 || $smallNum > 0) {
                         //退货加库存
                         $stockInfo = ProductClass::addStock($productId, $bigNum, $smallNum);
                         $oldStock = $stockInfo['oldStock'] ?? 0;
@@ -177,7 +184,7 @@ class RefundOrderClass extends BaseClass
                         //库存变动记录
                         $recordData = [];
                         $recordData['relateName'] = $customName;
-                        $recordData['itemNum'] = $bigNum;
+                        $recordData['itemNum'] = $itemNum;
                         $recordData['sjId'] = $sjId;
                         $recordData['shopId'] = $shopId;
                         $recordData['mainId'] = $mainId;

+ 0 - 10
biz-ghs/order/services/RefundOrderService.php

@@ -96,16 +96,6 @@ class RefundOrderService extends BaseService
             }
         }
 
-        $orderSn = $refund->orderSn;
-        $refundItemList = RefundOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
-        if (!empty($refundItemList)) {
-            foreach ($refundItemList as $refundInfo) {
-                if ($refundInfo->xhUnitType == 1) {
-                    util::fail($refundInfo->name . ' 是小单位,只能使用【只退款】方式');
-                }
-            }
-        }
-
         $relateOrderSn = $refund->relateOrderSn ?? '';
         if (empty($relateOrderSn)) {
             util::fail('没有订单信息');

+ 2 - 3
biz-ghs/product/classes/ProductClass.php

@@ -850,7 +850,7 @@ class ProductClass extends BaseClass
     public static function addStock($productId, $itemNumBundle, $itemNumPiece)
     {
         //小单位库存不再考虑 ssh 20230303
-        $itemNumPiece = 0;
+        //$itemNumPiece = 0;
 
         $key = self::LOCK_STOCK . '_' . $productId;
         $lock = util::lock($key);
@@ -880,7 +880,6 @@ class ProductClass extends BaseClass
     //加路上库存
     public static function addOnStockByItemNum($productId, $itemNum)
     {
-        //小单位库存不再考虑 ssh 20230303
         $key = self::LOCK_ON_STOCK . '_' . $productId;
         $lock = util::lock($key);
         if (!$lock) {
@@ -933,7 +932,7 @@ class ProductClass extends BaseClass
     {
 
         //小单位库存不再考虑 ssh 20230303
-        $itemNumPiece = 0;
+        //$itemNumPiece = 0;
 
         $key = self::LOCK_STOCK . '_' . $productId;
         $lock = util::lock($key);

+ 12 - 5
biz-hd/cg/classes/CgRefundClass.php

@@ -115,16 +115,23 @@ class CgRefundClass extends BaseClass
                     }
                     $oneItem->refundNum = bcadd($refundNum, $num);
                     $oneItem->save();
-                    //大单位退款才变库存,小单位不变化库存!!
-                    $smallNum = 0;
-                    $bigNum = $num;
-                    if ($bigNum > 0) {
+
+                    if ($refundSingle->xhUnitType == 1) {
+                        $smallNum = $num;
+                        $bigNum = 0;
+                    } else {
+                        $smallNum = 0;
+                        $bigNum = $num;
+                    }
+                    $itemNum = $refundSingle->itemNum;
+
+                    if ($bigNum > 0 || $smallNum > 0) {
                         $stockInfo = ProductClass::decreaseStock($productId, $bigNum, $smallNum);
                         $oldStock = $stockInfo['oldStock'] ?? 0;
                         $newStock = $stockInfo['newStock'] ?? 0;
 
                         $recordData = [];
-                        $recordData['itemNum'] = $bigNum;
+                        $recordData['itemNum'] = $itemNum;
                         $recordData['sjId'] = $sjId;
                         $recordData['shopId'] = $shopId;
                         $recordData['mainId'] = $mainId;

+ 6 - 0
biz-hd/cg/services/CgRefundService.php

@@ -212,6 +212,11 @@ class CgRefundService extends BaseService
                 $currentPrice = bcmul($num,$unitPrice,2);
                 $originPrice = bcadd($originPrice,$currentPrice,2);
 
+                $itemNum = $num;
+                if ($unitType == dict::getDict('unitType', 'small')) {
+                    $itemNum = bcdiv($num, $ratio, 2);
+                }
+
                 $refundData = [];
                 $refundData['orderSn'] = $refundOrderSn;
                 $refundData['itemId'] = $ptItemId;
@@ -224,6 +229,7 @@ class CgRefundService extends BaseService
                 $refundData['shopId'] = $shopId;
                 $refundData['sjId'] = $sjId;
                 $refundData['xhNum'] = $num;
+                $refundData['itemNum'] = $itemNum;
                 $refundData['xhUnitName'] = $unitName;
                 $refundData['xhUnitType'] = $unitType;
                 $refundData['xhUnitPrice'] = $unitPrice;

+ 2 - 4
biz-hd/order/classes/OrderClass.php

@@ -442,18 +442,17 @@ class OrderClass extends BaseClass
         $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
         if (!empty($itemList)) {
             foreach ($itemList as $item) {
-
                 $ptItemId = $item->ptItemId ?? 0;
                 $sjId = $item->sjId ?? 0;
                 $shopId = $item->shopId ?? 0;
                 $mainId = $item->mainId ?? 0;
                 $ratio = $item->ratio ?? 20;
                 $unitType = $item->unitType ?? 0;
-                $bigNum = 0;
-                $smallNum = 0;
                 if ($unitType == 0) {
                     $bigNum = $item->num;
+                    $smallNum = 0;
                 } else {
+                    $bigNum = 0;
                     $smallNum = $item->num;
                 }
                 $itemId = $item->itemId ?? 0;
@@ -470,7 +469,6 @@ class OrderClass extends BaseClass
                 $recordData['orderSn'] = $orderSn;
                 $recordData['relateName'] = '系统';
                 StockRecordClass::addSellStockOrderCancelRecord($recordData);
-
             }
         }
         $shopId = $order->shopId ?? 0;

+ 1 - 2
biz-hd/order/classes/OrderItemClass.php

@@ -39,8 +39,7 @@ class OrderItemClass extends BaseClass
 
         //库存减少
         $itemNum = ProductClass::mergeItemNum($bigNum, $smallNum, $ratio);
-        //开单时如果是小单位暂时不扣库存
-        if (intval($itemNum) > 0) {
+        if ($itemNum > 0) {
             $stockInfo = ProductClass::decreaseStock($itemId, $bigNum, $smallNum, true);
             $recordData = [];
             $recordData['sjId'] = $sjId;

+ 1 - 1
biz-hd/purchase/classes/PurchaseClass.php

@@ -205,7 +205,7 @@ class PurchaseClass extends BaseClass
         $purchaseItem = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, "*");
         foreach ($purchaseItem as $v) {
             //小单位库存不考虑入库 ssh 202310
-            $itemNum = intval($v['itemNum']);
+            $itemNum = $v['itemNum'];
             if ($itemNum > 0) {
                 $productId = $v['productId'];
                 $stockInfo = ProductClass::addStockByItemNum($v['productId'], $itemNum);

+ 8 - 5
biz-hd/refund/classes/HdRefundItemClass.php

@@ -24,16 +24,20 @@ class HdRefundItemClass extends BaseClass
         $itemId = $data['itemId'] ?? 0;
         $num = $data['num'] ?? 0;
         $unitType = $data['unitType'] ?? 0;
-        $bigNum = $unitType == 0 ? $num : 0;
-        $smallNum = $unitType == 1 ? $num : 0;
         $ratio = $data['ratio'] ?? 0;
         $ptItemId = $data['ptItemId'] ?? 0;
         $mainId = $data['mainId'] ?? 0;
         $shopId = $data['shopId'] ?? 0;
         $sjId = $data['sjId'] ?? 0;
         $shopAdminName = $post['shopAdminName'] ?? '';
-
-        if ($bigNum > 0) {
+        if ($unitType == 1) {
+            $bigNum = 0;
+            $smallNum = $num;
+        } else {
+            $bigNum = $num;
+            $smallNum = 0;
+        }
+        if ($bigNum > 0 || $smallNum > 0) {
             $stockInfo = ProductClass::addStock($itemId, $bigNum, $smallNum);
             $recordData = [];
             $recordData['sjId'] = $sjId;
@@ -48,7 +52,6 @@ class HdRefundItemClass extends BaseClass
             $recordData['relateName'] = $shopAdminName;
             StockRecordClass::hdRefundAddRecord($recordData);
         }
-
         return self::add($data);
     }