|
|
@@ -9,6 +9,7 @@ use biz\shop\classes\ShopClass;
|
|
|
use biz\wx\classes\WxMessageClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
use bizGhs\order\classes\RefundOrderClass;
|
|
|
+use bizGhs\order\services\NextDayRefundService;
|
|
|
use bizGhs\order\services\RefundOrderService;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizGhs\stock\classes\StockRecordClass;
|
|
|
@@ -42,14 +43,32 @@ class CgRefundService extends BaseService
|
|
|
RefundOrderClass::cancelRefund($saleRefund);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 花店申请售后:先判销售单是否须隔天(非当天/已结清),两端成对写 sameDay/fundType
|
|
|
+ */
|
|
|
public static function createOrder($cgData, $cg)
|
|
|
{
|
|
|
- $respond = self::addRefund($cgData, $cg);
|
|
|
$saleId = $cg->saleId ?? 0;
|
|
|
$order = OrderClass::getById($saleId, true);
|
|
|
if (empty($order)) {
|
|
|
util::fail('没有订单信息');
|
|
|
}
|
|
|
+
|
|
|
+ // 非当天 / 已结账 / 挂账结清 → 申请即写隔天售后;无资金弹窗时默认返余额
|
|
|
+ $sameDay = CgRefundClass::SAME_DAY_YES;
|
|
|
+ $fundType = NextDayRefundService::FUND_UNUSED;
|
|
|
+ if (NextDayRefundService::mustUseNextDay($order)) {
|
|
|
+ $sameDay = CgRefundClass::SAME_DAY_NO;
|
|
|
+ $fundType = NextDayRefundService::resolveFundType(
|
|
|
+ NextDayRefundService::FUND_BALANCE,
|
|
|
+ $order,
|
|
|
+ true
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $cgData['sameDay'] = $sameDay;
|
|
|
+ $cgData['fundType'] = $fundType;
|
|
|
+
|
|
|
+ $respond = self::addRefund($cgData, $cg);
|
|
|
$remark = $cgData['remark'] ?? '';
|
|
|
$price = $cgData['price'] ?? 0;
|
|
|
$refundType = $cgData['refundType'] ?? 1;
|
|
|
@@ -84,11 +103,11 @@ class CgRefundService extends BaseService
|
|
|
$ssPtItemId = $ss['itemId'] ?? 0;
|
|
|
$saleMap[$ssPtItemId] = $ssId;
|
|
|
}
|
|
|
- foreach ($cgProductList as $cg) {
|
|
|
- if (isset($cg['productId']) == false) {
|
|
|
+ foreach ($cgProductList as $cgItem) {
|
|
|
+ if (isset($cgItem['productId']) == false) {
|
|
|
util::fail('花材有问题呢');
|
|
|
}
|
|
|
- $productId = $cg['productId'];
|
|
|
+ $productId = $cgItem['productId'];
|
|
|
if (isset($cgMap[$productId]) == false) {
|
|
|
util::fail('花材有问题哈');
|
|
|
}
|
|
|
@@ -97,8 +116,8 @@ class CgRefundService extends BaseService
|
|
|
util::fail('花材有问题哦');
|
|
|
}
|
|
|
$newProductId = $saleMap[$ptItemId];
|
|
|
- $cg['productId'] = $newProductId;
|
|
|
- $newProductList[] = $cg;
|
|
|
+ $cgItem['productId'] = $newProductId;
|
|
|
+ $newProductList[] = $cgItem;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -111,13 +130,18 @@ class CgRefundService extends BaseService
|
|
|
'shopId' => $shopId,
|
|
|
'mainId' => $mainId,
|
|
|
'product' => $newProductList,
|
|
|
+ 'sameDay' => $sameDay,
|
|
|
+ 'fundType' => $fundType,
|
|
|
];
|
|
|
$cgRefundId = $respond->id ?? 0;
|
|
|
$saleRefund = RefundOrderService::addRefund($orderData, $order);
|
|
|
$saleRefund->cgRefundId = $cgRefundId;
|
|
|
$saleRefund->save();
|
|
|
$saleRefundId = $saleRefund->id ?? 0;
|
|
|
+ // 与销售侧最终 sameDay/fundType 对齐(addRefund 内可能再次强制隔天)
|
|
|
$respond->saleRefundId = $saleRefundId;
|
|
|
+ $respond->sameDay = intval($saleRefund->sameDay ?? $sameDay);
|
|
|
+ $respond->fundType = intval($saleRefund->fundType ?? $fundType);
|
|
|
$respond->save();
|
|
|
return $respond;
|
|
|
}
|