Commit 88ee2160 by 吕明尚

查询优惠卷可用接口增加下单模式

parent 787e98b0
......@@ -5,13 +5,11 @@ package share.common.enums;
* @Date 2023/10/19 17:06
*/
public enum CouponTypeEnum {
//1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额,6:套餐劵
//1:折扣券,2,团购券,3:满减券,4:套餐劵
DISCOUNT(1,"1","折扣券"),
CASH(2,"2","满减券(现金券)"),
DURATION(3, "3", "时长券"),
VERIFICATION(4, "4", "核销券"),
RECHARGE(5, "5", "充值送金额"),
PACKAGE(6, "6", "套餐劵"),
PACKAGE(4, "4", "套餐劵"),
;
private Integer code;
......
......@@ -30,7 +30,6 @@ public class PackController extends BaseController {
/**
* 查询套餐列表
*/
@PreAuthorize("@ss.hasPermi('system:pack:list')")
@GetMapping("/list")
public TableDataInfo list(SPack SPack) {
startPage();
......@@ -39,53 +38,11 @@ public class PackController extends BaseController {
}
/**
* 导出套餐列表
*/
@PreAuthorize("@ss.hasPermi('system:pack:export')")
@Log(title = "套餐", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SPack SPack) {
List<SPack> list = packService.selectPackList(SPack);
ExcelUtil<SPack> util = new ExcelUtil<SPack>(SPack.class);
util.exportExcel(response, list, "套餐数据");
}
/**
* 获取套餐详细信息
*/
@PreAuthorize("@ss.hasPermi('system:pack:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(packService.selectPackById(id));
}
/**
* 新增套餐
*/
@PreAuthorize("@ss.hasPermi('system:pack:add')")
@Log(title = "套餐", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SPack SPack) {
return toAjax(packService.insertPack(SPack));
}
/**
* 修改套餐
*/
@PreAuthorize("@ss.hasPermi('system:pack:edit')")
@Log(title = "套餐", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SPack SPack) {
return toAjax(packService.updatePack(SPack));
}
/**
* 删除套餐
*/
@PreAuthorize("@ss.hasPermi('system:pack:remove')")
@Log(title = "套餐", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(packService.deletePackByIds(ids));
}
}
......@@ -57,7 +57,7 @@ public class SConsumerCoupon extends BaseEntity
private String couponTimeEnd;
/** 优惠券类型(1:折扣券,2,满减券,3:时长券) */
@Excel(name = "优惠券类型(1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额,6:套餐劵)")
@Excel(name = "优惠券类型(1:折扣券,2,团购券,3:满减券,4:套餐劵)")
private Integer couponType;
/** 门槛时长 */
......
......@@ -54,7 +54,7 @@ public class SCoupon extends BaseEntity
private String roomType;
/** 优惠券类型(1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额) */
@Excel(name = "优惠券类型(1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额,6:套餐劵)")
@Excel(name = "优惠券类型(1:折扣券,2,团购券,3:满减券,4:套餐劵)")
private Integer couponType;
/** 门槛时长 */
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
......@@ -33,6 +34,9 @@ public class SRoomPack extends BaseEntity {
@Excel(name = "套餐id")
private Long packId;
@TableField(exist = false)
private String roomName;
@Override
public String toString() {
......
......@@ -25,6 +25,10 @@ public class CouponRequest {
@NotNull(message = "房间ID不能为空")
private Long roomId;
@ApiModelProperty(value = "下单模式(1:小时模式,2:套餐模式)", required = true)
@NotNull(message = "下单模式不能为空")
private Integer orderMode;
/**
* 预约开始时间
*/
......
......@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.mapper.RoomPackMapper;
import share.system.domain.SRoomPack;
import share.system.mapper.SRoomMapper;
import share.system.service.IRoomPackService;
/**
......@@ -21,6 +22,8 @@ import share.system.service.IRoomPackService;
public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack> implements IRoomPackService {
@Autowired
private RoomPackMapper roomPackMapper;
@Autowired
private SRoomMapper sRoomMapper;
/**
* 查询包房套餐关系
......@@ -104,9 +107,12 @@ public class RoomPackServiceImpl extends ServiceImpl<RoomPackMapper, SRoomPack>
@Override
public List<SRoomPack> selectRoomPackByPackId(Long id) {
LambdaQueryWrapper<SRoomPack> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SRoomPack::getPackId, id);
return roomPackMapper.selectList(queryWrapper);
List<SRoomPack> sRoomPackList = roomPackMapper.selectList(queryWrapper);
sRoomPackList.forEach(item -> {
item.setRoomName(sRoomMapper.selectById(item.getRoomId()).getName());
});
return sRoomPackList;
}
}
......@@ -145,7 +145,15 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
SStore sStore = sStoreService.getById(couponRequest.getStoreId());
SRoom byId = sRoomService.getById(couponRequest.getRoomId());
BigDecimal subtract = new BigDecimal(item.getMinDuration());
if (item.getCouponType().equals(CouponTypeEnum.DURATION.getCode())) {
if (item.getCouponType().equals(CouponTypeEnum.PACKAGE.getCode())) {
if (couponRequest.getOrderMode().equals(BuyTypeEnum.PACK.getCode())) {
//计算价格
extracted(item, bigDecimal, byId, subtract, sStore);
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("仅支持套餐模式下单使用");
}
} else if (item.getCouponType().equals(CouponTypeEnum.DURATION.getCode())) {
//判断门槛时长
if (bigDecimal.compareTo(subtract) >= 0) {
//判断门店类型
......@@ -155,22 +163,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
item.setReason("下单时长等于" + bigDecimal + "小时,不满足优惠券门槛时长");
}
} else {
//计算价格
BigDecimal multiply = bigDecimal.multiply(byId.getPrice());
//判断是否满足优惠券门槛
if (item.getMinPrice().compareTo(multiply) <= 0) {
//判断门槛时长
if (bigDecimal.compareTo(subtract) >= 0) {
//判断门店类型
isStoreType(item, sStore, byId);
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("下单时长低于" + item.getMinDuration() + "小时 ");
}
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("消费金额低于" + item.getMinPrice() + "元");
}
extracted(item, bigDecimal, byId, subtract, sStore);
}
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
......@@ -184,6 +177,25 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
return sConsumerCoupons;
}
private void extracted(SConsumerCoupon item, BigDecimal bigDecimal, SRoom byId, BigDecimal subtract, SStore sStore) {
//计算价格
BigDecimal multiply = bigDecimal.multiply(byId.getPrice());
//判断是否满足优惠券门槛
if (item.getMinPrice().compareTo(multiply) <= 0) {
//判断门槛时长
if (bigDecimal.compareTo(subtract) >= 0) {
//判断门店类型
isStoreType(item, sStore, byId);
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("下单时长低于" + item.getMinDuration() + "小时 ");
}
} else {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
item.setReason("消费金额低于" + item.getMinPrice() + "元");
}
}
private void isStoreType(SConsumerCoupon item, SStore sStore, SRoom byId) {
if (item.getStoreType().contains(sStore.getStoreType())) {
//判断房间类型
......
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