|
@@ -562,9 +562,10 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
}
|
|
|
|
|
|
// 更新数据库中的库存数据
|
|
|
+ log.info("更新学校场地数据库中的库存数据:{}", stock - ids.size());
|
|
|
int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
|
|
|
.eq(AppSitePriceRules::getId, productId)
|
|
|
- .set(AppSitePriceRules::getTicketNum, stock - ids.size()));
|
|
|
+ .set(AppSitePriceRules::getTicketNum, (stock - ids.size())));
|
|
|
if (row > 0) {
|
|
|
// 更新Redis中缓存的商品库存数据
|
|
|
redisTemplate.opsForValue().decrement(stockKey, ids.size());
|
|
@@ -738,63 +739,117 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
//赛事
|
|
|
case 1:
|
|
|
//个人赛
|
|
|
- AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
- AppGame appGame = appGameMapper.selectById(appGamePriceRules.getGameId());
|
|
|
- AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
|
|
|
+ if (Objects.equals(createOrderForm.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_3)) {
|
|
|
+ AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
+ AppGame appGame = appGameMapper.selectById(appGamePriceRules.getGameId());
|
|
|
+ AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
|
|
|
|
|
|
+ appOrder.setOrgCode(appGamePriceRules.getOrgCode());
|
|
|
+ appOrder.setTenantId(appGamePriceRules.getTenantId());
|
|
|
|
|
|
- appOrder.setOrgCode(appGamePriceRules.getOrgCode());
|
|
|
- appOrder.setTenantId(appGamePriceRules.getTenantId());
|
|
|
+ String startTime = DateUtil.format(appGame.getStartTime(), "HH:mm");
|
|
|
+ String endTime = DateUtil.format(appGame.getEndTime(), "HH:mm");
|
|
|
|
|
|
- //订单总价(商品的售价总和)
|
|
|
- BigDecimal sumPrice = new BigDecimal(0);
|
|
|
+ //订单总价(商品的售价总和)
|
|
|
+ BigDecimal sumPrice = new BigDecimal(0);
|
|
|
|
|
|
for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
|
|
|
- String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
|
|
|
- FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
|
|
|
- AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
- appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
|
- appOrderProInfo.setProductName(appGame.getName());
|
|
|
- appOrderProInfo.setAddress(appGame.getAddress());
|
|
|
- if (createOrderForm.getOrderType() == 3) {
|
|
|
+ String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
|
|
|
+ FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
|
|
|
+ AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
+ appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
|
+ appOrderProInfo.setProductName(appGame.getName());
|
|
|
+ appOrderProInfo.setAddress(appGame.getAddress());
|
|
|
appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_3);
|
|
|
- }
|
|
|
- if (createOrderForm.getOrderType() == 4) {
|
|
|
- appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_4);
|
|
|
- }
|
|
|
- appOrderProInfo.setFrameTimeStr(appGame.getStartTime() + "-" + appGame.getEndTime());
|
|
|
- appOrderProInfo.setExpireTime(DateUtil.format(appGameSchedule.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
- appOrderProInfo.setOriginalPrice(appGamePriceRules.getSellingPrice());
|
|
|
- appOrderProInfo.setPrice(appGamePriceRules.getSellingPrice());
|
|
|
- appOrderProInfo.setProductImage(appGame.getCover());
|
|
|
- appOrderProInfo.setOrderStatus(0);
|
|
|
- appOrderProInfo.setQuantity(1);
|
|
|
- appOrderProInfo.setFamilyUserId(familyUserId);
|
|
|
- appOrderProInfo.setUserName(familyMembers.getFullName());
|
|
|
- appOrderProInfo.setUserPhone(familyMembers.getPhone());
|
|
|
- appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
|
- appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ appOrderProInfo.setFrameTimeStr(startTime + "-" + endTime);
|
|
|
+ appOrderProInfo.setExpireTime(DateUtil.format(appGameSchedule.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ appOrderProInfo.setOriginalPrice(appGamePriceRules.getSellingPrice());
|
|
|
+ appOrderProInfo.setPrice(appGamePriceRules.getSellingPrice());
|
|
|
+ appOrderProInfo.setProductImage(appGame.getCover());
|
|
|
+ appOrderProInfo.setOrderStatus(0);
|
|
|
+ appOrderProInfo.setQuantity(1);
|
|
|
+ appOrderProInfo.setFamilyUserId(familyUserId);
|
|
|
+ appOrderProInfo.setUserName(familyMembers.getFullName());
|
|
|
+ appOrderProInfo.setUserPhone(familyMembers.getPhone());
|
|
|
+ appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
|
+ appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
|
|
|
proInfoList.add(appOrderProInfo);
|
|
|
|
|
|
- sumPrice = sumPrice.add(appGamePriceRules.getSellingPrice());
|
|
|
+ sumPrice = sumPrice.add(appGamePriceRules.getSellingPrice());
|
|
|
+ }
|
|
|
+ //计算订单总价
|
|
|
+ totalPrice = totalPrice.add(sumPrice);
|
|
|
+
|
|
|
+ appOrder
|
|
|
+ .setType(CommonConstant.ORDER_TYPE_1)
|
|
|
+ .setAddressSiteId(appGame.getSiteId())
|
|
|
+ .setOriginalPrice(sumPrice)
|
|
|
+ .setCreateTime(new Date())
|
|
|
+ .setUpdateTime(new Date())
|
|
|
+ .setCreateBy(user.getId())
|
|
|
+ .setUpdateBy(user.getId())
|
|
|
+ .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
+ .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ if (StrUtil.isNotBlank(createOrderForm.getGameCertificationForm())) {
|
|
|
+ appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
|
|
|
+ }
|
|
|
}
|
|
|
- //计算订单总价
|
|
|
- totalPrice = totalPrice.add(sumPrice);
|
|
|
+ if (Objects.equals(createOrderForm.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_4)){
|
|
|
+ AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
+ AppGame appGame = appGameMapper.selectById(appGamePriceRules.getGameId());
|
|
|
+ AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
|
|
|
|
|
|
- appOrder
|
|
|
- .setType(CommonConstant.ORDER_TYPE_1)
|
|
|
- .setAddressSiteId(appGame.getSiteId())
|
|
|
- .setOriginalPrice(sumPrice)
|
|
|
- .setCreateTime(new Date())
|
|
|
- .setUpdateTime(new Date())
|
|
|
- .setCreateBy(user.getId())
|
|
|
- .setUpdateBy(user.getId())
|
|
|
- .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
- .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
- if (StrUtil.isNotBlank(createOrderForm.getGameCertificationForm())) {
|
|
|
- appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
|
|
|
+ String startTime = DateUtil.format(appGame.getStartTime(), "HH:mm:ss");
|
|
|
+ String endTime = DateUtil.format(appGame.getEndTime(), "HH:mm:ss");
|
|
|
+
|
|
|
+ appOrder.setOrgCode(appGamePriceRules.getOrgCode());
|
|
|
+ appOrder.setTenantId(appGamePriceRules.getTenantId());
|
|
|
+
|
|
|
+ //订单总价(商品的售价总和)
|
|
|
+ BigDecimal sumPrice = appGamePriceRules.getSellingPrice();
|
|
|
+
|
|
|
+ List<String> familyIds = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (String familyId : familyIds) {
|
|
|
+ FamilyMembers familyMembers = familyMembersMapper.selectById(familyId);
|
|
|
+ AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
+ appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
|
+ appOrderProInfo.setProductName(appGame.getName());
|
|
|
+ appOrderProInfo.setAddress(appGame.getAddress());
|
|
|
+ appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_4);
|
|
|
+ appOrderProInfo.setFrameTimeStr(startTime + "-" + endTime);
|
|
|
+ appOrderProInfo.setExpireTime(DateUtil.format(appGameSchedule.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ appOrderProInfo.setOriginalPrice(appGamePriceRules.getSellingPrice());
|
|
|
+ appOrderProInfo.setPrice(BigDecimal.ZERO);
|
|
|
+ appOrderProInfo.setProductImage(appGame.getCover());
|
|
|
+ appOrderProInfo.setOrderStatus(0);
|
|
|
+ appOrderProInfo.setQuantity(1);
|
|
|
+ appOrderProInfo.setFamilyUserId(familyId);
|
|
|
+ appOrderProInfo.setUserName(familyMembers.getFullName());
|
|
|
+ appOrderProInfo.setUserPhone(familyMembers.getPhone());
|
|
|
+ appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
|
+ appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+
|
|
|
+ proInfoList.add(appOrderProInfo);
|
|
|
+ }
|
|
|
+ //计算订单总价
|
|
|
+ totalPrice = totalPrice.add(sumPrice);
|
|
|
+
|
|
|
+ appOrder
|
|
|
+ .setType(CommonConstant.ORDER_TYPE_1)
|
|
|
+ .setAddressSiteId(appGame.getSiteId())
|
|
|
+ .setOriginalPrice(sumPrice)
|
|
|
+ .setCreateTime(new Date())
|
|
|
+ .setUpdateTime(new Date())
|
|
|
+ .setCreateBy(user.getId())
|
|
|
+ .setUpdateBy(user.getId())
|
|
|
+ .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
+ .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ if (StrUtil.isNotBlank(createOrderForm.getGameCertificationForm())) {
|
|
|
+ appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
//课程
|
|
@@ -822,7 +877,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
BigDecimal sDiscounts = new BigDecimal(0);
|
|
|
BigDecimal tDiscounts = new BigDecimal(0);
|
|
|
|
|
|
- for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
+ for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
|
|
|
String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
|
|
|
FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
|
|
@@ -888,7 +943,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- proInfoList.add(appOrderProInfo);
|
|
|
+ proInfoList.add(appOrderProInfo);
|
|
|
|
|
|
tDiscounts = tDiscounts.add(appCourse.getOriginalPrice().subtract(appCourse.getSellingPrice()));
|
|
|
sumCoursePrice = sumCoursePrice.add(appCourse.getSellingPrice().subtract(sDiscounts));
|