|
|
@@ -3,11 +3,8 @@
|
|
|
namespace bizHd\cg\services;
|
|
|
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
-use biz\pt\classes\PtAssetClass;
|
|
|
-use biz\pt\classes\PtYeChangeClass;
|
|
|
use biz\shop\classes\ShopCapitalClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
-use biz\shop\classes\ShopYeChangeClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizGhs\stock\classes\StockRecordClass;
|
|
|
use bizHd\base\services\BaseService;
|
|
|
@@ -78,15 +75,15 @@ class CgRefundService extends BaseService
|
|
|
|
|
|
//写入订单表
|
|
|
$cgRefund = CgRefundClass::add($data, true);
|
|
|
- if($ghsItemInfo){
|
|
|
+ if ($ghsItemInfo) {
|
|
|
//写入cgRefundItem, 转hdProductId
|
|
|
$ghsItemInfo = self::toggleProductList($ghsItemInfo, $cg->shopId, $cg->sjId);
|
|
|
//将hdProductId =》productId
|
|
|
- foreach ($ghsItemInfo as $k=>$v){
|
|
|
- $ghsItemInfo[$k]['productId'] =$v['hdProductId'];
|
|
|
+ foreach ($ghsItemInfo as $k => $v) {
|
|
|
+ $ghsItemInfo[$k]['productId'] = $v['hdProductId'];
|
|
|
}
|
|
|
//退货,减库存
|
|
|
- foreach ($ghsItemInfo as $k=>$v){
|
|
|
+ foreach ($ghsItemInfo as $k => $v) {
|
|
|
$stockInfo = ProductClass::decreaseStock($v['hdProductId'], $v['bigNum'], $v['smallNum']);
|
|
|
$ghsItemInfo[$k]['oldStock'] = $stockInfo['oldStock'];
|
|
|
$ghsItemInfo[$k]['newStock'] = $stockInfo['newStock'];
|
|
|
@@ -102,6 +99,7 @@ class CgRefundService extends BaseService
|
|
|
|
|
|
}
|
|
|
//--------end-----花材处理逻辑 linqh 2021.6.28------
|
|
|
+
|
|
|
//门店总收入增加
|
|
|
$currentTotalIncome = bcadd($shop->totalIncome, $refundPrice, 2);
|
|
|
$shop->totalIncome = $currentTotalIncome;
|
|
|
@@ -216,13 +214,13 @@ class CgRefundService extends BaseService
|
|
|
|
|
|
|
|
|
//供货商productId 转 hdProductId [{productId:1,...}]
|
|
|
- public static function toggleProductList($ghsItemInfo,$hdShopId,$hdSjId)
|
|
|
+ public static function toggleProductList($ghsItemInfo, $hdShopId, $hdSjId)
|
|
|
{
|
|
|
$productIds = array_column($ghsItemInfo, "productId");
|
|
|
$productData = ProductClass::getProductByIds($productIds);
|
|
|
$itemIds = [];
|
|
|
$productMap = [];
|
|
|
- foreach ($productData as $v){
|
|
|
+ foreach ($productData as $v) {
|
|
|
$itemIds[] = $v['itemId'];
|
|
|
$productMap[$v['id']] = $v['itemId'];
|
|
|
}
|
|
|
@@ -231,7 +229,7 @@ class CgRefundService extends BaseService
|
|
|
$hdProductData = array_column($hdProductData, null, "itemId");
|
|
|
|
|
|
foreach ($ghsItemInfo as $k => $v) {
|
|
|
- $itemId =$productMap[$v['productId']];
|
|
|
+ $itemId = $productMap[$v['productId']];
|
|
|
$hdProductId = $hdProductData[$itemId]['id'];
|
|
|
$ghsItemInfo[$k]['hdProductId'] = $hdProductId;
|
|
|
}
|