重新计算价格
This commit is contained in:
		
							parent
							
								
									ed4931b5b0
								
							
						
					
					
						commit
						52a0362ced
					
				| 
						 | 
				
			
			@ -14,7 +14,6 @@ import java.math.BigDecimal;
 | 
			
		|||
 * @date 2024-05-13
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
//@Builder
 | 
			
		||||
public class RlModel extends BaseEntity
 | 
			
		||||
{
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
| 
						 | 
				
			
			@ -54,4 +53,7 @@ public class RlModel extends BaseEntity
 | 
			
		|||
    @Excel(name = "图片")
 | 
			
		||||
    private String picture;
 | 
			
		||||
 | 
			
		||||
    /** 描述 */
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -68,7 +68,7 @@ public class RlOrder extends BaseEntity
 | 
			
		|||
    private String type;
 | 
			
		||||
 | 
			
		||||
    /** 订单总金额(元) */
 | 
			
		||||
    @Excel(name = "订单总金额", readConverterExp = "元=")
 | 
			
		||||
    @Excel(name = "订单总金额", readConverterExp = "元")
 | 
			
		||||
    private BigDecimal totalFee;
 | 
			
		||||
 | 
			
		||||
    /** 实际支付金额 */
 | 
			
		||||
| 
						 | 
				
			
			@ -83,6 +83,10 @@ public class RlOrder extends BaseEntity
 | 
			
		|||
    @Excel(name = "调度费")
 | 
			
		||||
    private BigDecimal dispatchFee;
 | 
			
		||||
 | 
			
		||||
    /** 配送费 */
 | 
			
		||||
    @Excel(name = "配送费")
 | 
			
		||||
    private BigDecimal deliveryFee;
 | 
			
		||||
 | 
			
		||||
    /** 租赁费 */
 | 
			
		||||
    @Excel(name = "租赁费")
 | 
			
		||||
    private BigDecimal leaseFee;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 | 
			
		|||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -27,5 +28,8 @@ public class StoreVo extends Store {
 | 
			
		|||
    @ApiModelProperty("车型列表")
 | 
			
		||||
    private List<RlModelVO> models;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty("最低价")
 | 
			
		||||
    private BigDecimal bottomPrice;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -192,6 +192,10 @@ public class RlOrderServiceImpl implements IRlOrderService
 | 
			
		|||
        order.setOrderNo(orderNo);
 | 
			
		||||
        order.setPaid(ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT);
 | 
			
		||||
        order.setType(type);
 | 
			
		||||
 | 
			
		||||
        /** 计算价格 */
 | 
			
		||||
        onceMoreCalculatePrice(order);
 | 
			
		||||
 | 
			
		||||
        Integer deliveryMethod = order.getDeliveryMethod();
 | 
			
		||||
        if(ServiceConstants.DELIVERY_METHOD_SELF_PICKUP == deliveryMethod){
 | 
			
		||||
            order.setStatus(ServiceConstants.ORDER_STATUS_TO_BE_TAKEN);
 | 
			
		||||
| 
						 | 
				
			
			@ -210,6 +214,15 @@ public class RlOrderServiceImpl implements IRlOrderService
 | 
			
		|||
        return responseVO;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void onceMoreCalculatePrice(RlOrderQuery order) {
 | 
			
		||||
        PriceVO priceVO = calculatePrice(order);
 | 
			
		||||
        order.setDeposit(priceVO.getDeposit());
 | 
			
		||||
        order.setLeaseFee(priceVO.getRent());
 | 
			
		||||
        order.setDispatchFee(priceVO.getDeliveryFee());
 | 
			
		||||
        order.setTotalFee(priceVO.getTotalFee());
 | 
			
		||||
        order.setPayFee(priceVO.getTotalFee());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** 解析地址 */
 | 
			
		||||
    private void analyzeAddress(RlOrderQuery order) {
 | 
			
		||||
        String address = cityService.getAddressByLocation(order.getPickupLon(),order.getPickupLat());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -450,6 +450,14 @@ public class StoreServiceImpl implements RlStoreService
 | 
			
		|||
                .map(store -> {
 | 
			
		||||
                    List<RlModelVO> list = modelService.selectEModelListByStoreId(store.getStoreId());
 | 
			
		||||
                    store.setModels(list);
 | 
			
		||||
                    /** 日均  */
 | 
			
		||||
                    // 计算最低价格
 | 
			
		||||
                    BigDecimal minPrice = list.stream()
 | 
			
		||||
                            .map(RlModelVO::getPrice) // 获取每个模型的价格
 | 
			
		||||
                            .filter(Objects::nonNull) // 过滤掉可能为 null 的价格
 | 
			
		||||
                            .min(BigDecimal::compareTo) // 找到最小值
 | 
			
		||||
                            .orElse(BigDecimal.ZERO); // 如果列表为空,返回 BigDecimal.ZERO
 | 
			
		||||
                    store.setBottomPrice(minPrice);
 | 
			
		||||
                    /** 多少辆可租 */
 | 
			
		||||
                    Integer integer = deviceService.selectRentalDeviceCountByStoreId(store.getStoreId(),null);
 | 
			
		||||
                    store.setRentalCar(integer);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,13 +7,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
    <resultMap type="RlModelVO" id="EModelResult" autoMapping="true" />
 | 
			
		||||
 | 
			
		||||
    <sql id="selectEModelVo">
 | 
			
		||||
        select model_id, model, full_voltage, low_voltage, full_endurance, create_by, create_time, update_by, update_time, remark, intro, agent_id, deposit, picture from rl_model
 | 
			
		||||
        select model_id, model, full_voltage, low_voltage, full_endurance, create_by, create_time, update_by, update_time, remark, intro, agent_id, deposit, picture, description from rl_model
 | 
			
		||||
    </sql>
 | 
			
		||||
 | 
			
		||||
    <select id="selectEModelList" parameterType="RlModel" resultMap="EModelResult">
 | 
			
		||||
        select m.model_id, m.model, m.full_voltage, m.low_voltage,
 | 
			
		||||
        m.full_endurance, m.create_by, m.create_time,
 | 
			
		||||
        m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture from rl_model m
 | 
			
		||||
        m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture,m.description from rl_model m
 | 
			
		||||
        where 1 = 1
 | 
			
		||||
        <if test="model != null  and model != ''"> and m.model = #{model}</if>
 | 
			
		||||
        <!-- 数据范围过滤  <if test="operator != null  and operator != ''"> and m.operator = #{operator}</if> -->
 | 
			
		||||
| 
						 | 
				
			
			@ -23,14 +23,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
    <select id="selectEModelListByAgentId" parameterType="RlModel" resultMap="EModelResult">
 | 
			
		||||
        select m.model_id, m.model, m.full_voltage, m.low_voltage,
 | 
			
		||||
               m.full_endurance, m.create_by, m.create_time,
 | 
			
		||||
               m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture from rl_model m
 | 
			
		||||
               m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture, m.description from rl_model m
 | 
			
		||||
        where m.agent_id = #{agentId}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectEModelByModelId" parameterType="Long" resultMap="EModelResult">
 | 
			
		||||
        select m.model_id, m.model,  m.full_voltage, m.low_voltage,
 | 
			
		||||
               m.full_endurance, m.create_by, m.create_time,
 | 
			
		||||
               m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture from rl_model m
 | 
			
		||||
               m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture, m.description from rl_model m
 | 
			
		||||
        where m.model_id = #{modelId}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -54,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            m.agent_id,
 | 
			
		||||
            m.deposit,
 | 
			
		||||
            m.picture,
 | 
			
		||||
            m.description,
 | 
			
		||||
            fr.price,
 | 
			
		||||
            fr.rental_unit
 | 
			
		||||
        FROM
 | 
			
		||||
| 
						 | 
				
			
			@ -84,6 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="agentId != null">agent_id,</if>
 | 
			
		||||
            <if test="deposit != null">deposit,</if>
 | 
			
		||||
            <if test="picture != null">picture,</if>
 | 
			
		||||
            <if test="description != null">description,</if>
 | 
			
		||||
         </trim>
 | 
			
		||||
        <trim prefix="values (" suffix=")" suffixOverrides=",">
 | 
			
		||||
            <if test="modelId != null">#{modelId},</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -100,6 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="agentId != null">#{agentId},</if>
 | 
			
		||||
            <if test="deposit != null">#{deposit},</if>
 | 
			
		||||
            <if test="picture != null">#{picture},</if>
 | 
			
		||||
            <if test="description != null">#{description},</if>
 | 
			
		||||
         </trim>
 | 
			
		||||
    </insert>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -119,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="agentId != null">agent_id = #{agentId},</if>
 | 
			
		||||
            <if test="deposit != null">deposit = #{deposit},</if>
 | 
			
		||||
            <if test="picture != null">picture = #{picture},</if>
 | 
			
		||||
            <if test="description != null">description = #{description},</if>
 | 
			
		||||
        </trim>
 | 
			
		||||
        where model_id = #{modelId}
 | 
			
		||||
    </update>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
    <resultMap type="RlOrderVO" id="RlOrderResult" autoMapping="true"/>
 | 
			
		||||
 | 
			
		||||
    <sql id="selectRlOrderVo">
 | 
			
		||||
        select order_id, order_no, out_trade_no, user_id, rule_id, device_mac, sn, pay_time, pay_type, paid, type, total_fee, pay_fee, deposit, overdue_fee, dispatch_fee,
 | 
			
		||||
        select order_id, order_no, out_trade_no, user_id, rule_id, device_mac, sn, pay_time, pay_type, paid, type, total_fee, pay_fee, deposit, overdue_fee, dispatch_fee,delivery_fee,
 | 
			
		||||
               lease_fee, mark, duration, status, create_time, return_time, deposit_deduction, deposit_order_no, deduction_amount, used_sn, change_reason,
 | 
			
		||||
               auto_refund_deposit, rental_unit, handling_charge, platform_service_fee, operator_dividend, pay_channel, delivery_method, pickup_time,
 | 
			
		||||
               agent_id, store_id, pickup_city, pickup_loc, pickup_lon, pickup_lat, model_id, expiry_time, original_order_no, num, price, explain,
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            o.deposit,
 | 
			
		||||
            o.overdue_fee,
 | 
			
		||||
            o.dispatch_fee,
 | 
			
		||||
            o.delivery_fee,
 | 
			
		||||
            o.lease_fee,
 | 
			
		||||
            o.mark,
 | 
			
		||||
            o.duration,
 | 
			
		||||
| 
						 | 
				
			
			@ -119,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="payFee != null"> and o.pay_fee = #{payFee}</if>
 | 
			
		||||
            <if test="deposit != null"> and o.deposit = #{deposit}</if>
 | 
			
		||||
            <if test="dispatchFee != null"> and o.dispatch_fee = #{dispatchFee}</if>
 | 
			
		||||
            <if test="deliveryFee != null"> and o.delivery_fee = #{deliveryFee}</if>
 | 
			
		||||
            <if test="leaseFee != null"> and o.lease_fee = #{leaseFee}</if>
 | 
			
		||||
            <if test="mark != null and mark != ''"> and o.mark = #{mark}</if>
 | 
			
		||||
            <if test="duration != null"> and o.duration = #{duration}</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -180,6 +182,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="deposit != null">deposit,</if>
 | 
			
		||||
            <if test="overdueFee != null">overdue_fee,</if>
 | 
			
		||||
            <if test="dispatchFee != null">dispatch_fee,</if>
 | 
			
		||||
            <if test="deliveryFee != null">delivery_fee,</if>
 | 
			
		||||
            <if test="leaseFee != null">lease_fee,</if>
 | 
			
		||||
            <if test="mark != null">mark,</if>
 | 
			
		||||
            <if test="duration != null">duration,</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -230,6 +233,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="deposit != null">#{deposit},</if>
 | 
			
		||||
            <if test="overdueFee != null">#{overdueFee},</if>
 | 
			
		||||
            <if test="dispatchFee != null">#{dispatchFee},</if>
 | 
			
		||||
            <if test="deliveryFee != null">#{deliveryFee},</if>
 | 
			
		||||
            <if test="leaseFee != null">#{leaseFee},</if>
 | 
			
		||||
            <if test="mark != null">#{mark},</if>
 | 
			
		||||
            <if test="duration != null">#{duration},</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -284,6 +288,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="deposit != null">deposit = #{deposit},</if>
 | 
			
		||||
            <if test="overdueFee != null">overdue_fee = #{overdueFee},</if>
 | 
			
		||||
            <if test="dispatchFee != null">dispatch_fee = #{dispatchFee},</if>
 | 
			
		||||
            <if test="deliveryFee != null">delivery_fee = #{deliveryFee},</if>
 | 
			
		||||
            <if test="leaseFee != null">lease_fee = #{leaseFee},</if>
 | 
			
		||||
            <if test="mark != null">mark = #{mark},</if>
 | 
			
		||||
            <if test="duration != null">duration = #{duration},</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -339,6 +344,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="deposit != null">deposit = #{deposit},</if>
 | 
			
		||||
            <if test="overdueFee != null">overdue_fee = #{overdueFee},</if>
 | 
			
		||||
            <if test="dispatchFee != null">dispatch_fee = #{dispatchFee},</if>
 | 
			
		||||
            <if test="deliveryFee != null">delivery_fee = #{deliveryFee},</if>
 | 
			
		||||
            <if test="leaseFee != null">lease_fee = #{leaseFee},</if>
 | 
			
		||||
            <if test="mark != null">mark = #{mark},</if>
 | 
			
		||||
            <if test="duration != null">duration = #{duration},</if>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user