|
|
@@ -46,28 +46,11 @@ class CgRefundService extends BaseService
|
|
|
{
|
|
|
$respond = self::addRefund($cgData, $cg);
|
|
|
$saleId = $cg->saleId ?? 0;
|
|
|
- $cgProductList = $cgData['product'] ?? [];
|
|
|
- if (empty($cgProductList)) {
|
|
|
- util::fail('没有花材');
|
|
|
- }
|
|
|
- $cgIds = array_column($cgProductList, 'productId');
|
|
|
- $cgProductInfo = ProductClass::getAllByCondition(['id' => ['in', $cgIds]], null, 'id,itemId');
|
|
|
- if (empty($cgProductInfo)) {
|
|
|
- util::fail('花材数据有问题');
|
|
|
- }
|
|
|
- $cgMap = [];
|
|
|
- foreach ($cgProductInfo as $cc) {
|
|
|
- $ccId = $cc['id'] ?? 0;
|
|
|
- $ccPtItemId = $cc['itemId'] ?? 0;
|
|
|
- $cgMap[$ccId] = $ccPtItemId;
|
|
|
- }
|
|
|
- $ptItemList = array_column($cgProductInfo, 'itemId');
|
|
|
-
|
|
|
$order = OrderClass::getById($saleId, true);
|
|
|
if (empty($order)) {
|
|
|
util::fail('没有订单信息');
|
|
|
}
|
|
|
- $remark = $cgData['remark']??'';
|
|
|
+ $remark = $cgData['remark'] ?? '';
|
|
|
$price = $cgData['price'] ?? 0;
|
|
|
$refundType = $cgData['refundType'] ?? 1;
|
|
|
$imgList = $cgData['imgList'] ?? '';
|
|
|
@@ -75,33 +58,48 @@ class CgRefundService extends BaseService
|
|
|
$shopId = $order->shopId ?? 0;
|
|
|
$mainId = $order->mainId ?? 0;
|
|
|
|
|
|
- $saleProductInfo = ProductClass::getAllByCondition(['mainId' => $mainId, 'itemId' => ['in', $ptItemList]], null, 'id,itemId');
|
|
|
- if (empty($saleProductInfo)) {
|
|
|
- util::fail('花材信息有问题');
|
|
|
- }
|
|
|
- $saleMap = [];
|
|
|
- foreach ($saleProductInfo as $ss) {
|
|
|
- $ssId = $ss['id'] ?? 0;
|
|
|
- $ssPtItemId = $ss['itemId'] ?? 0;
|
|
|
- $saleMap[$ssPtItemId] = $ssId;
|
|
|
- }
|
|
|
-
|
|
|
+ $cgProductList = $cgData['product'] ?? [];
|
|
|
$newProductList = [];
|
|
|
- foreach ($cgProductList as $cg) {
|
|
|
- if (isset($cg['productId']) == false) {
|
|
|
- util::fail('花材有问题呢');
|
|
|
+ if (!empty($cgProductList)) {
|
|
|
+ $cgIds = array_column($cgProductList, 'productId');
|
|
|
+ $cgProductInfo = ProductClass::getAllByCondition(['id' => ['in', $cgIds]], null, 'id,itemId');
|
|
|
+ if (empty($cgProductInfo)) {
|
|
|
+ util::fail('花材数据有问题');
|
|
|
+ }
|
|
|
+ $cgMap = [];
|
|
|
+ foreach ($cgProductInfo as $cc) {
|
|
|
+ $ccId = $cc['id'] ?? 0;
|
|
|
+ $ccPtItemId = $cc['itemId'] ?? 0;
|
|
|
+ $cgMap[$ccId] = $ccPtItemId;
|
|
|
+ }
|
|
|
+ $ptItemList = array_column($cgProductInfo, 'itemId');
|
|
|
+
|
|
|
+ $saleProductInfo = ProductClass::getAllByCondition(['mainId' => $mainId, 'itemId' => ['in', $ptItemList]], null, 'id,itemId');
|
|
|
+ if (empty($saleProductInfo)) {
|
|
|
+ util::fail('花材信息有问题');
|
|
|
}
|
|
|
- $productId = $cg['productId'];
|
|
|
- if (isset($cgMap[$productId]) == false) {
|
|
|
- util::fail('花材有问题哈');
|
|
|
+ $saleMap = [];
|
|
|
+ foreach ($saleProductInfo as $ss) {
|
|
|
+ $ssId = $ss['id'] ?? 0;
|
|
|
+ $ssPtItemId = $ss['itemId'] ?? 0;
|
|
|
+ $saleMap[$ssPtItemId] = $ssId;
|
|
|
}
|
|
|
- $ptItemId = $cgMap[$productId];
|
|
|
- if (isset($saleMap[$ptItemId]) == false) {
|
|
|
- util::fail('花材有问题哦');
|
|
|
+ foreach ($cgProductList as $cg) {
|
|
|
+ if (isset($cg['productId']) == false) {
|
|
|
+ util::fail('花材有问题呢');
|
|
|
+ }
|
|
|
+ $productId = $cg['productId'];
|
|
|
+ if (isset($cgMap[$productId]) == false) {
|
|
|
+ util::fail('花材有问题哈');
|
|
|
+ }
|
|
|
+ $ptItemId = $cgMap[$productId];
|
|
|
+ if (isset($saleMap[$ptItemId]) == false) {
|
|
|
+ util::fail('花材有问题哦');
|
|
|
+ }
|
|
|
+ $newProductId = $saleMap[$ptItemId];
|
|
|
+ $cg['productId'] = $newProductId;
|
|
|
+ $newProductList[] = $cg;
|
|
|
}
|
|
|
- $newProductId = $saleMap[$ptItemId];
|
|
|
- $cg['productId'] = $newProductId;
|
|
|
- $newProductList[] = $cg;
|
|
|
}
|
|
|
|
|
|
$orderData = [
|