|
@@ -53,10 +53,10 @@ class RefundOrderService extends BaseService
|
|
|
$data['shopAdminId'] = $post['shopAdminId'] ?? 0;
|
|
$data['shopAdminId'] = $post['shopAdminId'] ?? 0;
|
|
|
$data['shopAdminName'] = $post['shopAdminName'] ?? '';
|
|
$data['shopAdminName'] = $post['shopAdminName'] ?? '';
|
|
|
|
|
|
|
|
- //花材列表 [{productId:0,num:1,unitType:0}] productId 花材id num 退货数 unitType 大小单位0大1小
|
|
|
|
|
$postProduct = $post['product'] ?? '';
|
|
$postProduct = $post['product'] ?? '';
|
|
|
-
|
|
|
|
|
if ($data['refundType'] == RefundOrderClass::REFUND_TYPE_MONEY_GOOD) {
|
|
if ($data['refundType'] == RefundOrderClass::REFUND_TYPE_MONEY_GOOD) {
|
|
|
|
|
+ //花材列表结构
|
|
|
|
|
+ // [{productId:0,num:1,unitType:0,unitPrice:12,unitName:'扎'}] productId 花材id num 退货数 unitType 大小单位0大1小 unitPrice 售价 unitName单位名称
|
|
|
if (empty($postProduct)) {
|
|
if (empty($postProduct)) {
|
|
|
util::fail('没有退款花材');
|
|
util::fail('没有退款花材');
|
|
|
}
|
|
}
|
|
@@ -72,10 +72,16 @@ class RefundOrderService extends BaseService
|
|
|
foreach ($postProduct as $currentProduct) {
|
|
foreach ($postProduct as $currentProduct) {
|
|
|
$id = $currentProduct['productId'] ?? 0;
|
|
$id = $currentProduct['productId'] ?? 0;
|
|
|
$num = $currentProduct['num'] ?? 0;
|
|
$num = $currentProduct['num'] ?? 0;
|
|
|
|
|
+ $xhUnitName = $currentProduct['unitName'] ?? '';
|
|
|
|
|
+ $xhUnitPrice = $currentProduct['unitPrice'] ?? '';
|
|
|
$unitType = $currentProduct['unitType'] ?? 0;
|
|
$unitType = $currentProduct['unitType'] ?? 0;
|
|
|
|
|
+
|
|
|
|
|
+ $xhPrice = bcmul($num, $xhUnitPrice, 2);
|
|
|
|
|
+
|
|
|
$name = $productInfo[$id]['name'] ?? '';
|
|
$name = $productInfo[$id]['name'] ?? '';
|
|
|
$ptItemId = $productInfo[$id]['itemId'] ?? 0;
|
|
$ptItemId = $productInfo[$id]['itemId'] ?? 0;
|
|
|
$itemCost = $productInfo[$id]['cost'] ?? 0;
|
|
$itemCost = $productInfo[$id]['cost'] ?? 0;
|
|
|
|
|
+ $ratio = $productInfo[$id]['ratio'] ?? 0;
|
|
|
|
|
|
|
|
$xhNum = $orderItemData[$id]['xhNum'] ?? 0;
|
|
$xhNum = $orderItemData[$id]['xhNum'] ?? 0;
|
|
|
$refundNum = $orderItemData[$id]['refundNum'] ?? 0;
|
|
$refundNum = $orderItemData[$id]['refundNum'] ?? 0;
|
|
@@ -84,6 +90,11 @@ class RefundOrderService extends BaseService
|
|
|
util::fail("{$name}超过可退数量");
|
|
util::fail("{$name}超过可退数量");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $itemNum = $num;
|
|
|
|
|
+ if ($unitType == dict::getDict('unitType', 'small')) {
|
|
|
|
|
+ $itemNum = bcdiv($num, $ratio, 2);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$thisItemData = [
|
|
$thisItemData = [
|
|
|
'sjId' => $sjId,
|
|
'sjId' => $sjId,
|
|
|
'shopId' => $shopId,
|
|
'shopId' => $shopId,
|
|
@@ -91,31 +102,28 @@ class RefundOrderService extends BaseService
|
|
|
'productId' => $id,
|
|
'productId' => $id,
|
|
|
'name' => $name,
|
|
'name' => $name,
|
|
|
'itemId' => $ptItemId,
|
|
'itemId' => $ptItemId,
|
|
|
- 'itemStock' => 0,
|
|
|
|
|
'itemCost' => $itemCost,
|
|
'itemCost' => $itemCost,
|
|
|
- 'newStock' => 0,
|
|
|
|
|
|
|
+ 'itemNum' => $itemNum,
|
|
|
'xhNum' => $xhNum,
|
|
'xhNum' => $xhNum,
|
|
|
'xhUnitName' => $xhUnitName,
|
|
'xhUnitName' => $xhUnitName,
|
|
|
'xhUnitType' => $unitType,
|
|
'xhUnitType' => $unitType,
|
|
|
'xhUnitPrice' => $xhUnitPrice,
|
|
'xhUnitPrice' => $xhUnitPrice,
|
|
|
'xhPrice' => $xhPrice,
|
|
'xhPrice' => $xhPrice,
|
|
|
|
|
+ 'mainId' => $mainId,
|
|
|
];
|
|
];
|
|
|
RefundOrderItemClass::addData($thisItemData);
|
|
RefundOrderItemClass::addData($thisItemData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
$data['customId'] = $order->customId ?? 0;
|
|
$data['customId'] = $order->customId ?? 0;
|
|
|
$data['remark'] = $post['remark'] ?? '';
|
|
$data['remark'] = $post['remark'] ?? '';
|
|
|
$data['refundPrice'] = $refundPrice;
|
|
$data['refundPrice'] = $refundPrice;
|
|
|
$data['refundType'] = $post['refundType'] ?? 0;
|
|
$data['refundType'] = $post['refundType'] ?? 0;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//写入订单表
|
|
//写入订单表
|
|
|
$refund = RefundOrderClass::add($data, true);
|
|
$refund = RefundOrderClass::add($data, true);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
$payWay = $order->payWay;
|
|
$payWay = $order->payWay;
|
|
|
$shopId = $order->shopId;
|
|
$shopId = $order->shopId;
|
|
|
$shop = ShopClass::getLockById($shopId);
|
|
$shop = ShopClass::getLockById($shopId);
|
|
@@ -156,7 +164,6 @@ class RefundOrderService extends BaseService
|
|
|
$order->refund = OrderClass::REFUND_YES;
|
|
$order->refund = OrderClass::REFUND_YES;
|
|
|
$order->save();
|
|
$order->save();
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//退款流程
|
|
//退款流程
|
|
|
if ($payWay == dict::getDict('payWay', 'wxPay')) {
|
|
if ($payWay == dict::getDict('payWay', 'wxPay')) {
|
|
|
|
|
|