Commit 768681f2 by 吕明尚

套餐增加是否开启字段

parent 1546f950
......@@ -72,4 +72,7 @@ public class SPack extends BaseEntity {
@Excel(name = "是否固定结束时间:0否,1是")
private Integer isFixedEndTime;
@Excel(name = "是否开启:0否,1是")
private Integer isOpen;
}
......@@ -11,6 +11,7 @@ public class RoomLabelVo extends RoomLabel {
private String roomName;
private String labelName;
private String packName;
private Integer openPack;
private Long labelType;
private String labelDuration;
private BigDecimal packPrice;
......
......@@ -8,7 +8,6 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
......@@ -77,5 +76,8 @@ public class CreateOrderRequest {
@NotNull(message = "实际支付金额不能为空")
private BigDecimal payFee;
@ApiModelProperty(value = "标签id")
private Long roomLabelId;
}
......@@ -145,6 +145,7 @@ public class RoomLabelServiceImpl extends ServiceImpl<RoomLabelMapper, RoomLabel
vo.setRoomName(roomMap.containsKey(item.getRoomId()) ? roomMap.get(item.getRoomId()).getName() : "");
vo.setPackName(packMap.containsKey(item.getPackId()) ? packMap.get(item.getPackId()).getName() : "");
vo.setPackPrice(packMap.containsKey(item.getPackId()) ? packMap.get(item.getPackId()).getPrice() : new BigDecimal("0.0"));
vo.setOpenPack(packMap.containsKey(item.getPackId()) ? packMap.get(item.getPackId()).getIsOpen() : null);
vo.setLabelName(labelMap.containsKey(item.getLabelId()) ? labelMap.get(item.getLabelId()).getName() : "");
vo.setLabelType(labelMap.containsKey(item.getLabelId()) ? labelMap.get(item.getLabelId()).getType() : null);
vo.setLabelDuration(labelMap.containsKey(item.getLabelId()) ? labelMap.get(item.getLabelId()).getDuration() : "");
......
......@@ -817,7 +817,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
//生成订单
SOrder sOrder = generatSOrder(request, user);
//校验订单金额
checkOrderPrice(sOrder, user);
checkOrderPrice(sOrder, user, request);
//校验订单预约时间
checkOrderDate(request);
//校验订单套餐
......@@ -1098,10 +1098,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
private void checkOrderPrice(SOrder order, SConsumer user) {
OrderComputedPriceRequest request = new OrderComputedPriceRequest();
BeanUtils.copyProperties(order, request);
ComputedOrderPriceResponse priceResponse = computedPrice(request, user);
private void checkOrderPrice(SOrder order, SConsumer user, CreateOrderRequest request) {
OrderComputedPriceRequest orderComputedPriceRequest = new OrderComputedPriceRequest();
BeanUtils.copyProperties(order, orderComputedPriceRequest);
orderComputedPriceRequest.setRoomLabelId(request.getRoomLabelId());
ComputedOrderPriceResponse priceResponse = computedPrice(orderComputedPriceRequest, user);
if (priceResponse.getPayFee().compareTo(order.getPayPrice()) != 0) {
throw new BaseException("订单金额异常!");
}
......@@ -1759,7 +1760,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
payPrice = totalPrice;
break;
case PACK://套餐模式
payPrice = computeTotalPrice(request.getPackId());
payPrice = computeTotalPrice(request.getPackId(), totalPrice);
break;
default:
throw new BaseException("购买方式类型异常!");
......@@ -1779,12 +1780,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return priceResponse;
}
private BigDecimal computeTotalPrice(Long packId) {
private BigDecimal computeTotalPrice(Long packId, BigDecimal totalPrice) {
SPack pack = packService.getById(packId);
if (Objects.isNull(pack)) {
throw new BaseException("计算订单金额套餐ID异常!");
}
return pack.getPrice();
if (pack.getIsOpen().equals(YesNoEnum.yes.getIndex())) {
return pack.getPrice();
} else {
return totalPrice;
}
}
/**
......
......@@ -14,6 +14,7 @@
<result property="packaEndPeriod" column="packa_end_period"/>
<result property="firstOrderAvailable" column="first_order_available"/>
<result property="isFixedEndTime" column="is_fixed_end_time"/>
<result property="isOpen" column="is_open"/>
<result property="type" column="type"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
......@@ -32,6 +33,7 @@
packa_end_period,
first_order_available,
is_fixed_end_time,
is_open,
type,
create_by,
create_time,
......@@ -60,6 +62,7 @@
#{isFixedEndTime}
</if>
<if test="type != null and type != '' or type==0">and type = #{type}</if>
<if test="isOpen != null and isOpen != '' or isOpen==0">and is_open = #{isOpen}</if>
</where>
</select>
......@@ -78,6 +81,7 @@
<if test="packaEndPeriod != null">packa_end_period,</if>
<if test="firstOrderAvailable != null">first_order_available,</if>
<if test="isFixedEndTime != null">is_fixed_end_time,</if>
<if test="isOpen != null">is_open,</if>
<if test="type != null">type,</if>
<if test="sort != null">sort,</if>
<if test="createBy != null">create_by,</if>
......@@ -94,6 +98,7 @@
<if test="packaEndPeriod != null">#{packaEndPeriod},</if>
<if test="firstOrderAvailable != null">#{firstOrderAvailable},</if>
<if test="isFixedEndTime != null">#{isFixedEndTime},</if>
<if test="isOpen != null">#{isOpen},</if>
<if test="type != null">#{type},</if>
<if test="sort != null">#{sort},</if>
<if test="createBy != null">#{createBy},</if>
......@@ -114,6 +119,7 @@
<if test="packaEndPeriod != null">packa_end_period = #{packaEndPeriod},</if>
<if test="firstOrderAvailable != null">first_order_available = #{firstOrderAvailable},</if>
<if test="isFixedEndTime != null">is_fixed_end_time = #{isFixedEndTime},</if>
<if test="isOpen != null">is_open = #{isOpen},</if>
<if test="type != null">type = #{type},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="createBy != null">create_by = #{createBy},</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