diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 8940d33..64e1825 100755 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -726,9 +726,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository if ($integralRate > 0) { $productIntegralPrice = min(bcmul(bcmul($this->cartByPrice($cart), $cart['cart_num'], 2), $integralRate, 2), $cart['true_price']); if ($productIntegralPrice > 0) { - $productIntegral = ceil(bcdiv($productIntegralPrice, $sysIntegralConfig['integral_money'], 3)); + $productIntegral = bcdiv($productIntegralPrice, $sysIntegralConfig['integral_money'], 3); if ($productIntegral <= $userIntegral) { - $userIntegral = bcsub($userIntegral, $productIntegral, 0); + $userIntegral = bcsub($userIntegral, $productIntegral, 2); //使用多少积分抵扣了多少金额 $cart['integral'] = [ 'use' => $productIntegral, @@ -748,7 +748,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository $merchantCart['order']['true_price'] = bcsub($merchantCart['order']['true_price'], $cart['integral']['price'], 2); $total_integral_price = bcadd($total_integral_price, $cart['integral']['price'], 2); - $total_integral = bcadd($total_integral, $cart['integral']['use'], 0); + $total_integral = bcadd($total_integral, $cart['integral']['use'], 2); continue; } } @@ -756,7 +756,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository $cart['integral'] = null; } unset($cart); - $order_total_integral = bcadd($order_total_integral, $total_integral, 0); + $order_total_integral = bcadd($order_total_integral, $total_integral, 2); $order_total_integral_price = bcadd($order_total_integral_price, $total_integral_price, 2); $_pay_price = $merchantCart['order']['true_price']; @@ -790,10 +790,10 @@ class StoreOrderCreateRepository extends StoreOrderRepository if ($giveIntegralFlag && !$order_type && $pay_price > 0) { $total_give_integral = floor(bcmul($pay_price, $sysIntegralConfig['integral_order_rate'], 0)); if ($total_give_integral > 0 && $svip_status && $svip_integral_rate > 0) { - $total_give_integral = bcmul($svip_integral_rate, $total_give_integral, 0); + $total_give_integral = bcmul($svip_integral_rate, $total_give_integral, 2); } } - $order_total_give_integral = bcadd($total_give_integral, $order_total_give_integral, 0); + $order_total_give_integral = bcadd($total_give_integral, $order_total_give_integral, 2); foreach ($fn as $callback) { $callback(); diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 8aa61dc..cd52cb2 100755 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -17,6 +17,7 @@ namespace app\controller\api\store\order; use app\common\repositories\delivery\DeliveryOrderRepository; use app\common\repositories\store\order\StoreOrderCreateRepository; use app\common\repositories\store\order\StoreOrderReceiptRepository; +use app\common\repositories\user\UserAssetsRepository; use app\validate\api\UserReceiptValidate; use crmeb\basic\BaseController; use app\common\repositories\store\order\StoreCartRepository; @@ -242,6 +243,9 @@ class StoreOrder extends BaseController $groupOrder = $groupOrderRepository->detail($this->request->uid(), (int)$id, false); if (!$groupOrder) return app('json')->fail('订单不存在或已支付'); + $assets = \app(UserAssetsRepository::class)->assets($this->request->uid()); + if($groupOrder['integral'] > $assets['integral_buy'] + $assets['integral_withdraw']) + return \app('json')->fail('积分不足'); $this->repository->changePayType($groupOrder, array_search($type, StoreOrderRepository::PAY_TYPE)); if ($groupOrder['pay_price'] == 0) { $this->repository->paySuccess($groupOrder); diff --git a/public/system.html b/public/system.html index 7adbaf6..44e545e 100755 --- a/public/system.html +++ b/public/system.html @@ -1,3 +1,3 @@ -