| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace bizHd\refund\classes;
- use bizGhs\product\classes\ProductClass;
- use bizGhs\stock\classes\StockRecordClass;
- use Yii;
- use bizHd\base\classes\BaseClass;
- class HdRefundItemClass extends BaseClass
- {
- public static $baseFile = '\bizHd\refund\models\HdRefundItem';
- public static function getItemListBySn($orderSn)
- {
- $list = self::getAllByCondition(['refundSn' => $orderSn], null, '*');
- return $list;
- }
- //退款的花材 ssh 20220427
- public static function addData($data, $refundSn, $post)
- {
- $itemId = $data['itemId'] ?? 0;
- $num = $data['num'] ?? 0;
- $unitType = $data['unitType'] ?? 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 ($unitType == 1) {
- $bigNum = 0;
- $smallNum = $num;
- } else {
- $bigNum = $num;
- $smallNum = 0;
- }
- $refundType = $post['refundType'] ?? 0;
- if ($refundType == 1) {
- if ($bigNum > 0 || $smallNum > 0) {
- $stockInfo = ProductClass::addStock($itemId, $bigNum, $smallNum);
- ProductClass::tryRecoverLimitBuyWhenStockRollbackFromZero($itemId, $stockInfo['oldStock']);
- $recordData = [];
- $recordData['sjId'] = $sjId;
- $recordData['shopId'] = $shopId;
- $recordData['mainId'] = $mainId;
- $recordData['itemId'] = $ptItemId;
- $recordData['itemNum'] = ProductClass::mergeItemNum($bigNum, $smallNum, $ratio);
- $recordData['oldStock'] = $stockInfo['oldStock'];
- $recordData['newStock'] = $stockInfo['newStock'];
- $recordData['productId'] = $itemId;
- $recordData['orderSn'] = $refundSn;
- $recordData['relateName'] = $shopAdminName;
- StockRecordClass::hdRefundAddRecord($recordData);
- }
- }
- return self::add($data);
- }
- }
|