|
@@ -177,7 +177,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
public HttpResponseResult buy2Qqhe(MemberPayParamDto dto) throws Exception {
|
|
|
//获取学员信息
|
|
|
SysUser sysUser = getSysUser();
|
|
|
- if(!dto.getRepeatPay()){
|
|
|
+ if (!dto.getRepeatPay()) {
|
|
|
//查询是否有待支付订单
|
|
|
List<StudentPaymentOrder> studentPaymentOrders = studentPaymentOrderService.queryByCondition(GroupType.MEMBER,
|
|
|
null, sysUser.getId(), DealStatusEnum.ING, OrderTypeEnum.MEMBER);
|
|
@@ -199,7 +199,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
//从缓存取出上次传入参数
|
|
|
RBucket<Object> cache = redissonClient.getBucket(BUY_2_QQHE_LOCK + studentPaymentOrder.getOrderNo());
|
|
|
- if(!cache.isExists()){
|
|
|
+ if (!cache.isExists()) {
|
|
|
return BaseController.failed("订单超时,请重新购买!");
|
|
|
}
|
|
|
Map<String, Object> cacheMap = (Map<String, Object>) cache.get();
|
|
@@ -207,27 +207,22 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
}
|
|
|
|
|
|
int val = dto.getVal();
|
|
|
- if (val < 0) {
|
|
|
- throw new BizException("最少购买1个月!");
|
|
|
- }
|
|
|
- if (val > 12) {
|
|
|
- throw new BizException("最多购买12个月!");
|
|
|
- }
|
|
|
//获取赠送的月份
|
|
|
BigDecimal giveMonth = getGiveMonth(val);
|
|
|
//转换格式
|
|
|
BigDecimal valDecimal = new BigDecimal(val);
|
|
|
//获取单价
|
|
|
- String activityAmount = sysConfigDao.findConfigValue("qqhe_2022_buy_member_activity_amount");
|
|
|
- BigDecimal price = new BigDecimal(activityAmount);
|
|
|
+ BigDecimal price = Optional.of("qqhe_2022_buy_member_activity_amount")
|
|
|
+ .map(sysConfigDao::findConfigValue)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .map(BigDecimal::new)
|
|
|
+ .orElseThrow(() -> new BizException("未配置活动单价,请联系教务老师。"));
|
|
|
//计算出购买的价格 单价 X 购买的月份
|
|
|
BigDecimal amount = price.multiply(valDecimal);
|
|
|
//获取会员总激活时间
|
|
|
BigDecimal totalMonth = valDecimal.add(giveMonth);
|
|
|
- //优惠券使用范围
|
|
|
- String[] checkCoupon = CouponDetailTypeEnum.getAllowType(MEMBER);
|
|
|
- //使用优惠券
|
|
|
- StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(dto.getCouponIdList(), amount, true, checkCoupon);
|
|
|
+ //使用优惠券 设置优惠券使用范围
|
|
|
+ StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(dto.getCouponIdList(), amount, true, CouponDetailTypeEnum.getAllowType(MEMBER));
|
|
|
//写入redis证明是活动购买
|
|
|
String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
studentPaymentOrder.setOrderNo(orderNo);
|
|
@@ -294,6 +289,12 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
}
|
|
|
|
|
|
private BigDecimal getGiveMonth(int val) {
|
|
|
+ if (val < 0) {
|
|
|
+ throw new BizException("最少购买1个月!");
|
|
|
+ }
|
|
|
+ if (val > 12) {
|
|
|
+ throw new BizException("最多购买12个月!");
|
|
|
+ }
|
|
|
BigDecimal giveMonth;
|
|
|
//最小数o 最大数s
|
|
|
BiPredicate<Integer, Integer> predicate = (o, s) -> val >= o && val < s;
|