mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 20:28:44 +08:00 
			
		
		
		
	Merge branch 'master' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/mall_product
Conflicts: yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql
This commit is contained in:
		@@ -345,7 +345,8 @@ public class PayOrderServiceImpl implements PayOrderService {
 | 
			
		||||
                        .channelId(channel.getId()).channelCode(channel.getCode())
 | 
			
		||||
                        .successTime(notify.getSuccessTime()).extensionId(orderExtension.getId()).no(orderExtension.getNo())
 | 
			
		||||
                        .channelOrderNo(notify.getChannelOrderNo()).channelUserId(notify.getChannelUserId())
 | 
			
		||||
                        .channelFeeRate(channel.getFeeRate()).channelFeePrice(MoneyUtils.calculateRatePrice(order.getPrice(), channel.getFeeRate()))
 | 
			
		||||
                        .channelFeeRate(channel.getFeeRate())
 | 
			
		||||
		                .channelFeePrice(MoneyUtils.calculateRatePrice(order.getPrice(), channel.getFeeRate()))
 | 
			
		||||
                        .build());
 | 
			
		||||
        if (updateCounts == 0) { // 校验状态,必须是待支付
 | 
			
		||||
            throw exception(ORDER_STATUS_IS_NOT_WAITING);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.util;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.util.NumberUtil;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.math.RoundingMode;
 | 
			
		||||
 | 
			
		||||
@@ -18,10 +20,20 @@ public class MoneyUtils {
 | 
			
		||||
     * @return 百分比金额
 | 
			
		||||
     */
 | 
			
		||||
    public static Integer calculateRatePrice(Integer price, Double rate) {
 | 
			
		||||
        return new BigDecimal(price)
 | 
			
		||||
                .multiply(BigDecimal.valueOf(rate)) // 乘以
 | 
			
		||||
                .setScale(0, RoundingMode.HALF_UP) // 四舍五入
 | 
			
		||||
                .intValue();
 | 
			
		||||
        return calculateRatePrice(price, rate, 0, RoundingMode.HALF_UP).intValue();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 计算百分比金额
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param price 金额
 | 
			
		||||
	 * @param rate 百分比,例如说 56.77% 则传入 56.77
 | 
			
		||||
	 * @param scale 保留小数位数
 | 
			
		||||
	 * @param roundingMode 舍入模式
 | 
			
		||||
	 */
 | 
			
		||||
	public static BigDecimal calculateRatePrice(Number price, Number rate, int scale, RoundingMode roundingMode) {
 | 
			
		||||
		return NumberUtil.toBigDecimal(price).multiply(NumberUtil.toBigDecimal(rate)) // 乘以
 | 
			
		||||
				.divide(BigDecimal.valueOf(100), scale, roundingMode); // 除以 100
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user