From 69ec045718760a70335f391dab2c84fdbf57b798 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Mon, 21 Mar 2022 14:41:15 +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 --- .../controller/v1/setting/SystemStorage.php | 4 +++ .../app/model/system/config/SystemStorage.php | 20 +++++++++++ .../order/StoreOrderRefundServices.php | 36 ++++++++++--------- .../product/product/StoreCategoryServices.php | 4 +-- .../product/product/StoreProductServices.php | 2 +- 5 files changed, 47 insertions(+), 19 deletions(-) diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemStorage.php b/crmeb/app/adminapi/controller/v1/setting/SystemStorage.php index 6680b049b..40703a5b1 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemStorage.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemStorage.php @@ -248,6 +248,10 @@ class SystemStorage extends AuthController */ public function uploadType(SystemConfigServices $services, $type) { + $status = $this->services->count(['type' => $type, 'status' => 1]); + if (!$status && $type != 1) { + return app('json')->success('未有正在使用的存储空间'); + } $services->update('upload_type', ['value' => json_encode($type)], 'menu_name'); \crmeb\services\CacheService::clear(); if ($type != 1) { diff --git a/crmeb/app/model/system/config/SystemStorage.php b/crmeb/app/model/system/config/SystemStorage.php index 4867a6611..bdb9f1484 100644 --- a/crmeb/app/model/system/config/SystemStorage.php +++ b/crmeb/app/model/system/config/SystemStorage.php @@ -45,4 +45,24 @@ class SystemStorage extends BaseModel { $query->where('name', $value); } + + /** + * 类型搜索器 + * @param $query + * @param $value + */ + public function searchTypeAttr($query, $value) + { + if ($value) $query->where('type', $value); + } + + /** + * 状态搜索器 + * @param $query + * @param $value + */ + public function searchStatusAttr($query, $value) + { + if ($value !== '') $query->where('status', $value); + } } 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 */