Commit fd125fae by 吕明尚

修改可用优惠券顺序

parent d2ba1ef1
...@@ -193,12 +193,19 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe ...@@ -193,12 +193,19 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
@Override @Override
public List<SConsumerCouponVo> availableCouponList(CouponRequest couponRequest) { public List<SConsumerCouponVo> availableCouponList(CouponRequest couponRequest) {
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
SConsumer user = FrontTokenComponent.getWxSConsumerEntry(); SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sConsumerCoupon.setUseStatus(ConsumerCouponUseStatusEnum.WAIT_USE.getCode()); LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
sConsumerCoupon.setConsumerId(user.getId()); queryWrapper.eq(SConsumerCoupon::getConsumerId, user.getId());
queryWrapper.eq(SConsumerCoupon::getUseStatus, ConsumerCouponUseStatusEnum.WAIT_USE.getCode());
queryWrapper.eq(SConsumerCoupon::getIsDelete, YesNoEnum.no.getIndex());
queryWrapper.ge(SConsumerCoupon::getEndDate, new Date());
if (couponRequest.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
queryWrapper.orderByDesc(SConsumerCoupon::getOrderType);
}
queryWrapper.orderByAsc(SConsumerCoupon::getEndDate, SConsumerCoupon::getCouponType);
queryWrapper.orderByDesc(SConsumerCoupon::getSubPrice);
//查询用户未使用的优惠券 //查询用户未使用的优惠券
List<SConsumerCoupon> sConsumerCoupons = baseMapper.querySConsumerCouponList(sConsumerCoupon); List<SConsumerCoupon> sConsumerCoupons = baseMapper.selectList(queryWrapper);
//计算时长 //计算时长
BigDecimal timeLong = DateUtils.differentHour(couponRequest.getPreStartDate(), couponRequest.getPreEndDate()); BigDecimal timeLong = DateUtils.differentHour(couponRequest.getPreStartDate(), couponRequest.getPreEndDate());
if (CollectionUtils.isEmpty(sConsumerCoupons)) { if (CollectionUtils.isEmpty(sConsumerCoupons)) {
......
...@@ -1820,8 +1820,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1820,8 +1820,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId()); RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId());
//(促销价-优惠券促销价)+((时长-促销时长)*单价) //(促销价-优惠券促销价)+((时长-促销时长)*单价)
SRoom room = roomService.getById(request.getRoomId()); SRoom room = roomService.getById(request.getRoomId());
BigDecimal subtract = roomLabel.getPromotionAmount().subtract(consumerCoupon.getPromotionPrice()). BigDecimal subtract = (roomLabel.getPromotionAmount().subtract(consumerCoupon.getPromotionPrice())).
add((DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate()).subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice())); add(((DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate()).subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice())));
//判断是否为负数 //判断是否为负数
if (subtract.compareTo(BigDecimal.ZERO) < 0) { if (subtract.compareTo(BigDecimal.ZERO) < 0) {
priceResponse.setPayFee(BigDecimal.ZERO); priceResponse.setPayFee(BigDecimal.ZERO);
......
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
<if test="labelId != ''">label_id = #{labelId},</if> <if test="labelId != ''">label_id = #{labelId},</if>
<if test="packId != ''">pack_id = #{packId},</if> <if test="packId != ''">pack_id = #{packId},</if>
<if test="promotionDuration != ''">promotion_duration = #{promotionDuration},</if> <if test="promotionDuration != ''">promotion_duration = #{promotionDuration},</if>
<if test="promotionAmount != ''">promotion_amount = #{promotionAmount},</if> <if test="promotionAmount != '' or promotionAmount==0">promotion_amount = #{promotionAmount},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment