From 885fe03cbbe831434d2099a95f71e6536c5fcdd6 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Fri, 18 Mar 2022 15:28:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/StoreOrderRefundServices.php | 36 ++++++++++--------- .../product/product/StoreCategoryServices.php | 4 +-- .../product/product/StoreProductServices.php | 2 +- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/crmeb/app/services/order/StoreOrderRefundServices.php b/crmeb/app/services/order/StoreOrderRefundServices.php index 724b80ab8..cd7c8d58c 100644 --- a/crmeb/app/services/order/StoreOrderRefundServices.php +++ b/crmeb/app/services/order/StoreOrderRefundServices.php @@ -894,22 +894,26 @@ class StoreOrderRefundServices extends BaseServices } $refund_num = bcadd((string)$refund_num, (string)$cart['cart_num'], 0); } - /** @var StoreOrderSplitServices $storeOrderSpliteServices */ - $storeOrderSpliteServices = app()->make(StoreOrderSplitServices::class); - $cartInfos = $storeOrderSpliteServices->getSplitOrderCartInfo($id, $cart_ids, $order); - $total_price = $pay_postage = 0; - foreach ($cartInfos as $cart) { - $_info = is_string($cart['cart_info']) ? json_decode($cart['cart_info'], true) : $cart['cart_info']; - $total_price = bcadd((string)$total_price, bcmul((string)($_info['truePrice'] ?? 0), (string)$cart['cart_num'], 4), 2); - $pay_postage = bcadd((string)$pay_postage, (string)($_info['postage_price'] ?? 0), 2); - } - $refund_pay_price = bcadd((string)$total_price, (string)$pay_postage, 2); - //订单实际支付金额 - $order_pay_price = bcsub((string)bcadd((string)$order['total_price'], (string)$order['pay_postage'], 2), (string)bcadd((string)$order['deduction_price'], (string)$order['coupon_price'], 2), 2); - if ($order_pay_price != $order['pay_price'] && $refund_pay_price != $order_pay_price) {//有改价 - $refund_price = bcmul((string)bcdiv((string)$order['pay_price'], (string)$order_pay_price, 4), (string)$refund_pay_price, 2); - } else { - $refund_price = $refund_pay_price; + //总共申请多少件 + $total_num = array_sum(array_column($cart_ids, 'cart_num')); + if ($total_num < $order['total_num']) { + /** @var StoreOrderSplitServices $storeOrderSpliteServices */ + $storeOrderSpliteServices = app()->make(StoreOrderSplitServices::class); + $cartInfos = $storeOrderSpliteServices->getSplitOrderCartInfo($id, $cart_ids, $order); + $total_price = $pay_postage = 0; + foreach ($cartInfos as $cart) { + $_info = is_string($cart['cart_info']) ? json_decode($cart['cart_info'], true) : $cart['cart_info']; + $total_price = bcadd((string)$total_price, bcmul((string)($_info['truePrice'] ?? 0), (string)$cart['cart_num'], 4), 2); + $pay_postage = bcadd((string)$pay_postage, (string)($_info['postage_price'] ?? 0), 2); + } + $refund_pay_price = bcadd((string)$total_price, (string)$pay_postage, 2); + //订单实际支付金额 + $order_pay_price = bcsub((string)bcadd((string)$order['total_price'], (string)$order['pay_postage'], 2), (string)bcadd((string)$order['deduction_price'], (string)$order['coupon_price'], 2), 2); + if ($order_pay_price != $order['pay_price'] && $refund_pay_price != $order_pay_price) {//有改价 + $refund_price = bcmul((string)bcdiv((string)$order['pay_price'], (string)$order_pay_price, 4), (string)$refund_pay_price, 2); + } else { + $refund_price = $refund_pay_price; + } } } else { foreach ($cartInfos as $cart) { diff --git a/crmeb/app/services/product/product/StoreCategoryServices.php b/crmeb/app/services/product/product/StoreCategoryServices.php index 96c51b767..47fc1ae69 100644 --- a/crmeb/app/services/product/product/StoreCategoryServices.php +++ b/crmeb/app/services/product/product/StoreCategoryServices.php @@ -187,7 +187,7 @@ class StoreCategoryServices extends BaseServices */ public function createData($data) { - if ($this->dao->getOne(['cate_name' => $data['cate_name']])) { + if ($this->dao->getOne(['cate_name' => $data['cate_name'], 'pid' => $data['pid']])) { throw new AdminException('该分类已经存在'); } $data['add_time'] = time(); @@ -203,7 +203,7 @@ class StoreCategoryServices extends BaseServices */ public function editData($id, $data) { - $cate = $this->dao->getOne(['cate_name' => $data['cate_name']]); + $cate = $this->dao->getOne(['cate_name' => $data['cate_name'], 'pid' => $data['pid']]); if ($cate && $cate['id'] != $id) { throw new AdminException('该分类已存在'); } diff --git a/crmeb/app/services/product/product/StoreProductServices.php b/crmeb/app/services/product/product/StoreProductServices.php index 8b9c4273e..d00645465 100644 --- a/crmeb/app/services/product/product/StoreProductServices.php +++ b/crmeb/app/services/product/product/StoreProductServices.php @@ -252,7 +252,7 @@ class StoreProductServices extends BaseServices $productInfo['give_integral'] = floatval($productInfo['give_integral']); $productInfo['presale'] = boolval($productInfo['presale'] ?? 0); $productInfo['vip_product'] = boolval($productInfo['vip_product'] ?? 0); - $productInfo['presale_time'] = $productInfo['presale_start_time'] == 0 ? [] : [date('Y-m-d M:i:s', $productInfo['presale_start_time']), date('Y-m-d M:i:s', $productInfo['presale_end_time'])]; + $productInfo['presale_time'] = $productInfo['presale_start_time'] == 0 ? [] : [date('Y-m-d H:i:s', $productInfo['presale_start_time']), date('Y-m-d H:i:s', $productInfo['presale_end_time'])]; $productInfo['description'] = $storeDescriptionServices->getDescription(['product_id' => $id, 'type' => 0]); $productInfo['custom_form'] = json_decode($productInfo['custom_form'], true); /** @var StoreProductAttrServices $storeProductAttrServices */