修改 app/common/repositories/store/order/StoreOrderRepository.php 文件:
1. 引入文件:
use app\common\repositories\user\MemberinterestsRepository;
2. 1325行添加如下代码:
//计算赠送积分
$data['give_integral'] = $_group['give_integral'] = $this->recalculateGiveIntegral($order, $_group['pay_price']);
3. 添加新方法:
public function recalculateGiveIntegral($order, $payPrice)
{
$order_total_give_integral = 0;
$svip_status = $order->svip_discount > 0 && systemConfig('svip_switch_status') == '1';
$svip_integral_rate = $svip_status ? app()->make(MemberinterestsRepository::class)->getSvipInterestVal(MemberinterestsRepository::HAS_TYPE_PAY) : 0;
//积分配置
$sysIntegralConfig = systemConfig(['integral_money', 'integral_status', 'integral_order_rate']);
$giveIntegralFlag = $sysIntegralConfig['integral_status'] && $sysIntegralConfig['integral_order_rate'] > 0;
$total_give_integral = 0;
//计算赠送积分, 只有普通商品赠送积分
if ($giveIntegralFlag && $payPrice > 0) {
$total_give_integral = floor(bcmul($payPrice, $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);
}
}
return bcadd($total_give_integral, $order_total_give_integral, 0);
}