|
@@ -218,7 +218,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
});
|
|
|
});
|
|
|
AppSitePlace appSitePlace = appSitePlaceMapper.selectById(placeId);
|
|
|
- previewOrderPlaceSchool.setName(appSitePlace.getName())
|
|
|
+ previewOrderPlaceSchool.setName(appSite.getName())
|
|
|
.setId(appSitePlace.getId())
|
|
|
.setTimeSlot(timeSlot);
|
|
|
if (StringUtils.isNotEmpty(appSitePlace.getInsureIds())) {
|
|
@@ -492,584 +492,582 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
String productKey = ""; // ORDER_TYPE_1_PRODUCT_N001
|
|
|
String stockKey = ""; // ORDER_TYPE_1_PRODUCT_STOCK_N001
|
|
|
|
|
|
- //订单内容
|
|
|
- switch (createOrderForm.getType()) {
|
|
|
- //场地(学校,包场,无固定场)
|
|
|
- case 0:
|
|
|
- //学校
|
|
|
- if (createOrderForm.getOrderType() == 0) {
|
|
|
- AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
- AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
|
|
|
- AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
|
|
|
+ //订单内容
|
|
|
+ switch (createOrderForm.getType()) {
|
|
|
+ //场地(学校,包场,无固定场)
|
|
|
+ case 0:
|
|
|
+ //学校
|
|
|
+ if (createOrderForm.getOrderType() == 0) {
|
|
|
+ AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
+ AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
|
|
|
+ AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
|
|
|
|
|
|
- String productId = createOrderForm.getProductIds();
|
|
|
+ String productId = createOrderForm.getProductIds();
|
|
|
|
|
|
- productKey = "ORDER_TYPE_1_PRODUCT_" + productId; // ORDER_TYPE_1_PRODUCT_N001
|
|
|
- stockKey = "ORDER_TYPE_1_PRODUCT_STOCK_" + productId; // ORDER_TYPE_1_PRODUCT_STOCK_N001
|
|
|
+ productKey = "ORDER_TYPE_1_PRODUCT_" + productId; // ORDER_TYPE_1_PRODUCT_N001
|
|
|
+ stockKey = "ORDER_TYPE_1_PRODUCT_STOCK_" + productId; // ORDER_TYPE_1_PRODUCT_STOCK_N001
|
|
|
|
|
|
- // 查询库存
|
|
|
- Integer stock = (Integer) redisTemplate.opsForValue().get(stockKey);
|
|
|
- // 缓存没有商品库存,查询数据库
|
|
|
- if (stock == null) {
|
|
|
- AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
|
|
|
- if (Objects.isNull(product)) {
|
|
|
- throw new JeecgBootException("订单提交失败,商品已下架");
|
|
|
- }
|
|
|
- redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product),60*60*24,TimeUnit.SECONDS);
|
|
|
- // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
|
|
|
- stock = product.getTicketNum();
|
|
|
- redisTemplate.opsForValue().set(stockKey, stock,60*60*24,TimeUnit.SECONDS);
|
|
|
+ // 查询库存
|
|
|
+ Integer stock = (Integer) redisTemplate.opsForValue().get(stockKey);
|
|
|
+ // 缓存没有商品库存,查询数据库
|
|
|
+ if (stock == null) {
|
|
|
+ AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
|
|
|
+ if (Objects.isNull(product)) {
|
|
|
+ throw new JeecgBootException("订单提交失败,商品已下架");
|
|
|
}
|
|
|
+ redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product), 60 * 60 * 24, TimeUnit.SECONDS);
|
|
|
+ // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
|
|
|
+ stock = product.getTicketNum();
|
|
|
+ redisTemplate.opsForValue().set(stockKey, stock, 60 * 60 * 24, TimeUnit.SECONDS);
|
|
|
+ }
|
|
|
|
|
|
- // 检查库存是否足够
|
|
|
- if (stock < count) {
|
|
|
- throw new JeecgBootException("订单提交失败,库存不足");
|
|
|
- }
|
|
|
+ // 检查库存是否足够
|
|
|
+ if (stock < count) {
|
|
|
+ throw new JeecgBootException("订单提交失败,库存不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新数据库中的库存数据
|
|
|
+ int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
|
|
|
+ .eq(AppSitePriceRules::getId, productId)
|
|
|
+ .set(AppSitePriceRules::getTicketNum, stock - count));
|
|
|
+ if (row > 0) {
|
|
|
+ // 更新Redis中缓存的商品库存数据
|
|
|
+ redisTemplate.opsForValue().decrement(stockKey, count);
|
|
|
+ }
|
|
|
+ // 库存扣减完,创建订单
|
|
|
+ appOrder
|
|
|
+ .setPayType(3)
|
|
|
+ .setOrderStatus(1)
|
|
|
+ .setOrgCode(appSite.getOrgCode())
|
|
|
+ .setTenantId(appSite.getTenantId())
|
|
|
+ .setType(CommonConstant.ORDER_TYPE_0)
|
|
|
+ //使用人IDs
|
|
|
+ .setFamilyIds(createOrderForm.getFamilyIds())
|
|
|
+ .setOriginalPrice(priceRule.getSellingPrice())
|
|
|
+ .setAddressSiteId(appSite.getId())
|
|
|
+ .setPrice(totalPrice)
|
|
|
+ .setCreateTime(new Date())
|
|
|
+ .setUpdateTime(new Date())
|
|
|
+ .setCreateBy(user.getId())
|
|
|
+ .setUpdateBy(user.getId())
|
|
|
+ .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
+ .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ //使用人
|
|
|
+ List<String> ids = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
|
|
|
+ for (String id : ids) {
|
|
|
+ FamilyMembers familyMembers = familyMembersMapper.selectById(id);
|
|
|
+ if (Objects.isNull(familyMembers)) {
|
|
|
|
|
|
- // 更新数据库中的库存数据
|
|
|
- int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
|
|
|
- .eq(AppSitePriceRules::getId, productId)
|
|
|
- .set(AppSitePriceRules::getTicketNum, stock - count));
|
|
|
- if (row > 0) {
|
|
|
- // 更新Redis中缓存的商品库存数据
|
|
|
- redisTemplate.opsForValue().decrement(stockKey, count);
|
|
|
}
|
|
|
- // 库存扣减完,创建订单
|
|
|
- appOrder
|
|
|
- .setPayType(3)
|
|
|
- .setOrderStatus(1)
|
|
|
- .setOrgCode(appSite.getOrgCode())
|
|
|
- .setTenantId(appSite.getTenantId())
|
|
|
- .setType(CommonConstant.ORDER_TYPE_0)
|
|
|
- //使用人IDs
|
|
|
- .setFamilyIds(createOrderForm.getFamilyIds())
|
|
|
- .setOriginalPrice(priceRule.getSellingPrice())
|
|
|
- .setAddressSiteId(appSite.getId())
|
|
|
- .setPrice(totalPrice)
|
|
|
- .setCreateTime(new Date())
|
|
|
- .setUpdateTime(new Date())
|
|
|
- .setCreateBy(user.getId())
|
|
|
- .setUpdateBy(user.getId())
|
|
|
- .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
+
|
|
|
+ String date = DateUtil.format(priceRule.getDateOfSale(), "yyyy-MM-dd");
|
|
|
+ String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm:ss");
|
|
|
+ String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm:ss");
|
|
|
+ String expireTime = date + " " + endTime;
|
|
|
+ AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
+ appOrderProInfo
|
|
|
+ .setProductId(priceRule.getId())
|
|
|
+ .setProductName("学校场地预约")
|
|
|
+ .setType(CommonConstant.ORDER_PRO_INFO_TYPE_1)
|
|
|
+ .setUseDateStr(date)
|
|
|
+ .setFrameTimeStr(startTime + "-" + endTime)
|
|
|
+ .setExpireTime(expireTime)
|
|
|
+ .setOriginalPrice(priceRule.getOriginalPrice())
|
|
|
+ .setProductImage(appSitePlace.getCover())
|
|
|
+ .setAddress(appSite.getAddress())
|
|
|
+ .setPrice(priceRule.getSellingPrice())
|
|
|
+ .setOrderStatus(0)
|
|
|
+ .setQuantity(1)
|
|
|
+ .setFamilyUserId(id)
|
|
|
+ .setUserName(familyMembers.getFullName())
|
|
|
+ .setUserPhone(familyMembers.getPhone())
|
|
|
+ .setStatus(CommonConstant.STATUS_0_INT)
|
|
|
.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
- //使用人
|
|
|
- List<String> ids = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
|
|
|
- for (String id : ids) {
|
|
|
- FamilyMembers familyMembers = familyMembersMapper.selectById(id);
|
|
|
-
|
|
|
- String date = DateUtil.format(priceRule.getDateOfSale(), "yyyy-MM-dd");
|
|
|
- String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm:ss");
|
|
|
- String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm:ss");
|
|
|
- String expireTime = date + " " + endTime;
|
|
|
- AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
- appOrderProInfo
|
|
|
- .setProductId(priceRule.getId())
|
|
|
- .setProductName("学校场地预约")
|
|
|
- .setType(CommonConstant.ORDER_PRO_INFO_TYPE_1)
|
|
|
- .setUseDateStr(date)
|
|
|
- .setFrameTimeStr(startTime + "-" + endTime)
|
|
|
- .setExpireTime(expireTime)
|
|
|
- .setOriginalPrice(priceRule.getOriginalPrice())
|
|
|
- .setProductImage(appSitePlace.getCover())
|
|
|
- .setAddress(appSite.getAddress())
|
|
|
- .setPrice(priceRule.getSellingPrice())
|
|
|
- .setOrderStatus(0)
|
|
|
- .setQuantity(1)
|
|
|
- .setFamilyUserId(id)
|
|
|
- .setUserName(familyMembers.getFullName())
|
|
|
- .setUserPhone(familyMembers.getPhone())
|
|
|
- .setStatus(CommonConstant.STATUS_0_INT)
|
|
|
- .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
-
|
|
|
- proInfoList.add(appOrderProInfo);
|
|
|
+
|
|
|
+ proInfoList.add(appOrderProInfo);
|
|
|
// appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getId,appSite.getId())).forEach(appDevice -> {
|
|
|
// addUser(priceRule.getDateOfSale(),appDevice.getDeviceSerial(),familyMembers.getFullName(),id);
|
|
|
// });
|
|
|
- }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //包场
|
|
|
- if (createOrderForm.getOrderType() == 1) {
|
|
|
+ //包场
|
|
|
+ if (createOrderForm.getOrderType() == 1) {
|
|
|
|
|
|
- List<String> list = Arrays.stream(createOrderForm.getProductIds().split(",")).collect(Collectors.toList());
|
|
|
+ List<String> list = Arrays.stream(createOrderForm.getProductIds().split(",")).collect(Collectors.toList());
|
|
|
|
|
|
- //订单总价(商品的售价总和)
|
|
|
- BigDecimal sumPrice = new BigDecimal(0);
|
|
|
+ //订单总价(商品的售价总和)
|
|
|
+ BigDecimal sumPrice = new BigDecimal(0);
|
|
|
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(list.get(i).split("\\|")[0]);
|
|
|
- AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
|
|
|
- AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(list.get(i).split("\\|")[0]);
|
|
|
+ AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
|
|
|
+ AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
|
|
|
|
|
|
appOrder.setOrgCode(appSite.getOrgCode());
|
|
|
|
|
|
- String date = list.get(i).split("\\|")[1];
|
|
|
- String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm:ss");
|
|
|
- String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm:ss");
|
|
|
- String expireTime = date + " " + endTime;
|
|
|
-
|
|
|
- AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
- appOrderProInfo.setProductId(list.get(i).split("\\|")[0]);
|
|
|
- appOrderProInfo.setProductName(date + " " + startTime + "-" + endTime + "|" + appSitePlace.getName());
|
|
|
- appOrderProInfo.setProductImage(appSitePlace.getCover());
|
|
|
- appOrderProInfo.setExpireTime(expireTime);
|
|
|
- appOrderProInfo.setAddress(appSite.getAddress());
|
|
|
- appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_2);
|
|
|
- appOrderProInfo.setOriginalPrice(priceRule.getOriginalPrice());
|
|
|
- appOrderProInfo.setPrice(priceRule.getSellingPrice());
|
|
|
- appOrderProInfo.setOrderStatus(0);
|
|
|
- appOrderProInfo.setQuantity(1);
|
|
|
- appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
|
- appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
-
|
|
|
- proInfoList.add(appOrderProInfo);
|
|
|
- appOrder.setOrgCode(appSitePlace.getOrgCode())
|
|
|
- .setTenantId(appSitePlace.getTenantId()).setAddressSiteId(appSite.getId());
|
|
|
-
|
|
|
- sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
+ String date = list.get(i).split("\\|")[1];
|
|
|
+ String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm:ss");
|
|
|
+ String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm:ss");
|
|
|
+ String expireTime = date + " " + endTime;
|
|
|
|
|
|
- //计算订单总价
|
|
|
- totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
-
|
|
|
- appOrder
|
|
|
- .setType(CommonConstant.ORDER_TYPE_0)
|
|
|
- .setOriginalPrice(sumPrice)
|
|
|
- .setCreateTime(new Date())
|
|
|
- .setUpdateTime(new Date())
|
|
|
- .setCreateBy(user.getId())
|
|
|
- .setUpdateBy(user.getId())
|
|
|
- .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
- .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
- }
|
|
|
-
|
|
|
- //无固定场
|
|
|
- if (createOrderForm.getOrderType() == 2) {
|
|
|
- AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
- AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
|
|
|
- AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
|
|
|
+ AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
+ appOrderProInfo.setProductId(list.get(i).split("\\|")[0]);
|
|
|
+ appOrderProInfo.setProductName(date + " " + startTime + "-" + endTime + "|" + appSitePlace.getName());
|
|
|
+ appOrderProInfo.setProductImage(appSitePlace.getCover());
|
|
|
+ appOrderProInfo.setExpireTime(expireTime);
|
|
|
+ appOrderProInfo.setAddress(appSite.getAddress());
|
|
|
+ appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_2);
|
|
|
+ appOrderProInfo.setOriginalPrice(priceRule.getOriginalPrice());
|
|
|
+ appOrderProInfo.setPrice(priceRule.getSellingPrice());
|
|
|
+ appOrderProInfo.setOrderStatus(0);
|
|
|
+ appOrderProInfo.setQuantity(1);
|
|
|
+ appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
|
+ appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
|
|
|
- //订单总价(商品的售价总和)
|
|
|
- BigDecimal sumPrice = new BigDecimal(0);
|
|
|
- //团购优惠
|
|
|
- BigDecimal tDiscounts = new BigDecimal(0);
|
|
|
-
|
|
|
- for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
-
|
|
|
- String date = DateUtil.format(priceRule.getDateOfSale(), "yyyy-MM-dd");
|
|
|
- String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm:ss");
|
|
|
- String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm:ss");
|
|
|
- String expireTime = date + " " + endTime;
|
|
|
-
|
|
|
- AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
- appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
|
- appOrderProInfo.setProductName(appSitePlace.getName());
|
|
|
- appOrderProInfo.setProductImage(appSitePlace.getCover());
|
|
|
- appOrderProInfo.setAddress(appSite.getAddress());
|
|
|
- appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_3);
|
|
|
- appOrderProInfo.setFrameTimeStr(startTime + "-" + endTime);
|
|
|
- appOrderProInfo.setExpireTime(expireTime);
|
|
|
- appOrderProInfo.setOriginalPrice(priceRule.getOriginalPrice());
|
|
|
- appOrderProInfo.setPrice(priceRule.getSellingPrice());
|
|
|
- appOrderProInfo.setOrderStatus(0);
|
|
|
- appOrderProInfo.setQuantity(1);
|
|
|
- appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
|
- appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
-
|
|
|
- proInfoList.add(appOrderProInfo);
|
|
|
- tDiscounts = tDiscounts.add(priceRule.getOriginalPrice().subtract(priceRule.getSellingPrice())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
+ proInfoList.add(appOrderProInfo);
|
|
|
+ appOrder.setOrgCode(appSitePlace.getOrgCode())
|
|
|
+ .setTenantId(appSitePlace.getTenantId()).setAddressSiteId(appSite.getId());
|
|
|
|
|
|
- //计算订单总价
|
|
|
- totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
-
|
|
|
- appOrder
|
|
|
- .setOrgCode(appSite.getOrgCode())
|
|
|
- .setTenantId(appSite.getTenantId())
|
|
|
- .setType(CommonConstant.ORDER_TYPE_0)
|
|
|
- .setTDiscounts(tDiscounts)
|
|
|
- .setOriginalPrice(sumPrice)
|
|
|
- .setAddressSiteId(appSite.getId())
|
|
|
- .setCreateTime(new Date())
|
|
|
- .setUpdateTime(new Date())
|
|
|
- .setCreateBy(user.getId())
|
|
|
- .setUpdateBy(user.getId())
|
|
|
- .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
- .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
- break;
|
|
|
- //赛事
|
|
|
- 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"));
|
|
|
|
|
|
+ //计算订单总价
|
|
|
+ totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ appOrder
|
|
|
+ .setType(CommonConstant.ORDER_TYPE_0)
|
|
|
+ .setOriginalPrice(sumPrice)
|
|
|
+ .setCreateTime(new Date())
|
|
|
+ .setUpdateTime(new Date())
|
|
|
+ .setCreateBy(user.getId())
|
|
|
+ .setUpdateBy(user.getId())
|
|
|
+ .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
+ .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+ }
|
|
|
|
|
|
- appOrder.setOrgCode(appGamePriceRules.getOrgCode());
|
|
|
- appOrder.setTenantId(appGamePriceRules.getTenantId());
|
|
|
+ //无固定场
|
|
|
+ if (createOrderForm.getOrderType() == 2) {
|
|
|
+ AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
+ AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
|
|
|
+ AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
|
|
|
|
|
|
//订单总价(商品的售价总和)
|
|
|
BigDecimal sumPrice = new BigDecimal(0);
|
|
|
+ //团购优惠
|
|
|
+ BigDecimal tDiscounts = new BigDecimal(0);
|
|
|
|
|
|
for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
|
|
|
- String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
|
|
|
- FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
|
|
|
+ String date = DateUtil.format(priceRule.getDateOfSale(), "yyyy-MM-dd");
|
|
|
+ String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm:ss");
|
|
|
+ String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm:ss");
|
|
|
+ String expireTime = date + " " + endTime;
|
|
|
+
|
|
|
AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
|
- appOrderProInfo.setProductName(appGame.getName());
|
|
|
- appOrderProInfo.setAddress(appGame.getAddress());
|
|
|
- if (createOrderForm.getOrderType() == 3) {
|
|
|
- appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_4);
|
|
|
- }
|
|
|
- if (createOrderForm.getOrderType() == 4) {
|
|
|
- appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_5);
|
|
|
- }
|
|
|
- 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.setProductName(appSitePlace.getName());
|
|
|
+ appOrderProInfo.setProductImage(appSitePlace.getCover());
|
|
|
+ appOrderProInfo.setAddress(appSite.getAddress());
|
|
|
+ appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_3);
|
|
|
+ appOrderProInfo.setFrameTimeStr(startTime + "-" + endTime);
|
|
|
+ appOrderProInfo.setExpireTime(expireTime);
|
|
|
+ appOrderProInfo.setOriginalPrice(priceRule.getOriginalPrice());
|
|
|
+ appOrderProInfo.setPrice(priceRule.getSellingPrice());
|
|
|
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()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ tDiscounts = tDiscounts.add(priceRule.getOriginalPrice().subtract(priceRule.getSellingPrice())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ sumPrice = sumPrice.add(priceRule.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
+
|
|
|
//计算订单总价
|
|
|
totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
appOrder
|
|
|
- .setType(CommonConstant.ORDER_TYPE_1)
|
|
|
- .setAddressSiteId(appGame.getSiteId())
|
|
|
+ .setOrgCode(appSite.getOrgCode())
|
|
|
+ .setTenantId(appSite.getTenantId())
|
|
|
+ .setType(CommonConstant.ORDER_TYPE_0)
|
|
|
+ .setTDiscounts(tDiscounts)
|
|
|
.setOriginalPrice(sumPrice)
|
|
|
+ .setAddressSiteId(appSite.getId())
|
|
|
.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;
|
|
|
- //课程
|
|
|
- case 2:
|
|
|
- //课程
|
|
|
- AppCourses appCourse = appCoursesMapper.selectById(appOrder.getProductIds());
|
|
|
- List<AppCoursesPriceRules> priceRulesList = appCoursesPriceRulesMapper.selectList(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId, appCourse.getId()));
|
|
|
- AppSite appSite = appSiteMapper.selectById(appCourse.getAddressSiteId());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //赛事
|
|
|
+ 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"));
|
|
|
|
|
|
- String productId = createOrderForm.getProductIds();
|
|
|
|
|
|
- productKey = "ORDER_TYPE_5_PRODUCT_" + productId; // ORDER_TYPE_1_PRODUCT_N001
|
|
|
- stockKey = "ORDER_TYPE_5_PRODUCT_STOCK_" + productId; // ORDER_TYPE_1_PRODUCT_STOCK_N001
|
|
|
+ appOrder.setOrgCode(appGamePriceRules.getOrgCode());
|
|
|
+ appOrder.setTenantId(appGamePriceRules.getTenantId());
|
|
|
|
|
|
- // 查询库存
|
|
|
- Integer stock = (Integer) redisTemplate.opsForValue().get(stockKey);
|
|
|
- // 缓存没有商品库存,查询数据库
|
|
|
- if (stock == null) {
|
|
|
- AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
|
|
|
- if (Objects.isNull(product)) {
|
|
|
- throw new JeecgBootException("订单提交失败,商品已下架");
|
|
|
- }
|
|
|
- redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product));
|
|
|
- // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
|
|
|
- stock = product.getTicketNum();
|
|
|
- redisTemplate.opsForValue().set(stockKey, stock);
|
|
|
- }
|
|
|
+ //订单总价(商品的售价总和)
|
|
|
+ BigDecimal sumPrice = new BigDecimal(0);
|
|
|
|
|
|
- // 检查库存是否足够
|
|
|
- if (stock < count) {
|
|
|
- throw new JeecgBootException("订单提交失败,库存不足");
|
|
|
- }
|
|
|
+ for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
|
|
|
- // 更新数据库中的库存数据
|
|
|
- int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
|
|
|
- .eq(AppSitePriceRules::getId, productId)
|
|
|
- .set(AppSitePriceRules::getTicketNum, stock - count));
|
|
|
- if (row > 0) {
|
|
|
- // 更新Redis中缓存的商品库存数据
|
|
|
- redisTemplate.opsForValue().decrement(stockKey, count);
|
|
|
+ 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) {
|
|
|
+ appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_4);
|
|
|
}
|
|
|
-
|
|
|
- appOrder.setType(CommonConstant.ORDER_TYPE_2);
|
|
|
- appOrder.setOrgCode(appCourse.getOrgCode());
|
|
|
- appOrder.setTenantId(appCourse.getTenantId());
|
|
|
-
|
|
|
- //合同编号
|
|
|
- AppContractInfo appContractInfo = appContractInfoMapper.selectOne(Wrappers.<AppContractInfo>lambdaQuery()
|
|
|
- .eq(AppContractInfo::getOrgCode, appOrder.getOrgCode()).eq(AppContractInfo::getDelFlag, 0));
|
|
|
- if (ObjectUtil.isNotEmpty(appContractInfo)) {
|
|
|
- appOrder.setContractNo(appContractInfo.getId());
|
|
|
+ if (createOrderForm.getOrderType() == 4) {
|
|
|
+ appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_5);
|
|
|
}
|
|
|
+ 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.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);
|
|
|
|
|
|
- //订单总价(商品的售价总和)
|
|
|
- BigDecimal sumCoursePrice = new BigDecimal(0);
|
|
|
-
|
|
|
- //优惠金额,如果当前课程商品类目是第一次购买,触发免费政策
|
|
|
- BigDecimal sDiscounts = new BigDecimal(0);
|
|
|
- BigDecimal tDiscounts = 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(appCourse.getName());
|
|
|
- appOrderProInfo.setAddress(appSite.getAddress());
|
|
|
- appOrderProInfo.setProductImage(appCourse.getCover());
|
|
|
- appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_6);
|
|
|
- appOrderProInfo.setFrameTimeStr(DateUtil.format(appCourse.getStartTime(), "yyyy-MM-dd") + "-" + DateUtil.format(appCourse.getEndTime(), "MM-dd"));
|
|
|
- appOrderProInfo.setExpireTime(DateUtil.format(appCourse.getEndTime(), "yyyy-MM-dd"));
|
|
|
- appOrderProInfo.setOriginalPrice(appCourse.getOriginalPrice());
|
|
|
- appOrderProInfo.setPrice(appCourse.getSellingPrice());
|
|
|
- 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);
|
|
|
-
|
|
|
- //创建核销记录
|
|
|
- if (CollUtil.isNotEmpty(priceRulesList)) {
|
|
|
- for (AppCoursesPriceRules appCoursesPriceRules : priceRulesList) {
|
|
|
- AppCoursesVerificationRecord appCoursesVerificationRecord = new AppCoursesVerificationRecord();
|
|
|
- appCoursesVerificationRecord.setCoursesId(appCourse.getId());
|
|
|
- appCoursesVerificationRecord.setCoursesPriceRuleId(appCoursesPriceRules.getId());
|
|
|
- appCoursesVerificationRecord.setCoursesName(appCoursesPriceRules.getName());
|
|
|
- appCoursesVerificationRecord.setCoursesStartTime(appCoursesPriceRules.getStartTime());
|
|
|
- appCoursesVerificationRecord.setCoursesEndTime(appCoursesPriceRules.getEndTime());
|
|
|
- appCoursesVerificationRecord.setUseUserId(familyUserId);
|
|
|
- appCoursesVerificationRecord.setUseUserName(familyMembers.getFullName());
|
|
|
- appCoursesVerificationRecord.setUseUserPhone(familyMembers.getPhone());
|
|
|
- appCoursesVerificationRecord.setUseUserImage(familyMembers.getRealNameImg());
|
|
|
- appCoursesVerificationRecord.setUseUserName(familyMembers.getFullName());
|
|
|
- appCoursesVerificationRecord.setVerifyStatus(0);
|
|
|
- appCoursesVerificationRecord.setOrPostpone(0);
|
|
|
- appCoursesVerificationRecord.setCoursesType(appCoursesPriceRules.getCoursesType());
|
|
|
- appCoursesVerificationRecordList.add(appCoursesVerificationRecord);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (createOrderForm.getOrFreeOrder() == 1) {
|
|
|
- Boolean flag = checkOrderOrFree(user.getId(), appCourse.getCategoryId());
|
|
|
- if (!flag && i == 1) {
|
|
|
- //订单中的多个商品中的第一个商品触发免费,将金额设置为优惠金额
|
|
|
- sDiscounts = sDiscounts.add(appCourse.getSellingPrice());
|
|
|
- appOrderProInfo.setOrFreePro(CommonConstant.STATUS_1_INT);
|
|
|
- appOrder.setContractNo(null);
|
|
|
- //试听优惠
|
|
|
- appOrder.setSDiscounts(sDiscounts);
|
|
|
- }
|
|
|
- }
|
|
|
+ proInfoList.add(appOrderProInfo);
|
|
|
|
|
|
- proInfoList.add(appOrderProInfo);
|
|
|
+ sumPrice = sumPrice.add(appGamePriceRules.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //计算订单总价
|
|
|
+ totalPrice = totalPrice.add(sumPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
- tDiscounts = tDiscounts.add(appCourse.getOriginalPrice().subtract(appCourse.getSellingPrice())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- sumCoursePrice = sumCoursePrice.add(appCourse.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ 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;
|
|
|
+ //课程
|
|
|
+ case 2:
|
|
|
+ //课程
|
|
|
+ AppCourses appCourse = appCoursesMapper.selectById(appOrder.getProductIds());
|
|
|
+ List<AppCoursesPriceRules> priceRulesList = appCoursesPriceRulesMapper.selectList(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId, appCourse.getId()));
|
|
|
+ AppSite appSite = appSiteMapper.selectById(appCourse.getAddressSiteId());
|
|
|
+
|
|
|
+ String productId = createOrderForm.getProductIds();
|
|
|
+
|
|
|
+ productKey = "ORDER_TYPE_5_PRODUCT_" + productId; // ORDER_TYPE_1_PRODUCT_N001
|
|
|
+ stockKey = "ORDER_TYPE_5_PRODUCT_STOCK_" + productId; // ORDER_TYPE_1_PRODUCT_STOCK_N001
|
|
|
+
|
|
|
+ // 查询库存
|
|
|
+ Integer stock = (Integer) redisTemplate.opsForValue().get(stockKey);
|
|
|
+ // 缓存没有商品库存,查询数据库
|
|
|
+ if (stock == null) {
|
|
|
+ AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
|
|
|
+ if (Objects.isNull(product)) {
|
|
|
+ throw new JeecgBootException("订单提交失败,商品已下架");
|
|
|
}
|
|
|
+ redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product));
|
|
|
+ // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
|
|
|
+ stock = product.getTicketNum();
|
|
|
+ redisTemplate.opsForValue().set(stockKey, stock);
|
|
|
+ }
|
|
|
|
|
|
- //计算订单总价
|
|
|
- totalPrice = totalPrice.add(sumCoursePrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 检查库存是否足够
|
|
|
+ if (stock < count) {
|
|
|
+ throw new JeecgBootException("订单提交失败,库存不足");
|
|
|
+ }
|
|
|
|
|
|
- //团购优惠
|
|
|
- appOrder.setTDiscounts(tDiscounts);
|
|
|
- //原订单总价
|
|
|
- appOrder.setOriginalPrice(sumCoursePrice);
|
|
|
- //使用人IDs
|
|
|
- appOrder.setFamilyIds(createOrderForm.getFamilyIds());
|
|
|
-
|
|
|
- appOrder.setAddressSiteId(appSite.getId());
|
|
|
- break;
|
|
|
- }
|
|
|
+ // 更新数据库中的库存数据
|
|
|
+ int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
|
|
|
+ .eq(AppSitePriceRules::getId, productId)
|
|
|
+ .set(AppSitePriceRules::getTicketNum, stock - count));
|
|
|
+ if (row > 0) {
|
|
|
+ // 更新Redis中缓存的商品库存数据
|
|
|
+ redisTemplate.opsForValue().decrement(stockKey, count);
|
|
|
+ }
|
|
|
|
|
|
+ appOrder.setType(CommonConstant.ORDER_TYPE_2);
|
|
|
+ appOrder.setOrgCode(appCourse.getOrgCode());
|
|
|
+ appOrder.setTenantId(appCourse.getTenantId());
|
|
|
|
|
|
- //构建保单内容
|
|
|
- InsureOrderInfoForm insureOrderInfoForm = createOrderForm.getInsureOrderInfoForm();
|
|
|
- if (ObjectUtils.isNotEmpty(insureOrderInfoForm)) {
|
|
|
- List<String> ids = Arrays.stream(insureOrderInfoForm.getFamilyMembersIds().split(",")).collect(Collectors.toList());
|
|
|
- AppInsure appInsure = appInsureMapper.selectById(insureOrderInfoForm.getInsureId());
|
|
|
- DictAnnotationUtil.translateDict(appInsure);
|
|
|
- //保单总价
|
|
|
- BigDecimal sumPrice = new BigDecimal(0);
|
|
|
- for (String id : ids) {
|
|
|
-
|
|
|
- //查询保单价格
|
|
|
- InsurePrice insurePrice = insurePriceMapper.selectById(insureOrderInfoForm.getInsurePriceId());
|
|
|
- FamilyMembers members = familyMembersMapper.selectById(id);
|
|
|
-
|
|
|
- //创建保单
|
|
|
- InsureOrderInfo insureOrderInfo = new InsureOrderInfo();
|
|
|
- insureOrderInfo
|
|
|
- .setOrderId(appOrder.getId())
|
|
|
- .setBdOrderNo(generateOrderNumber(2))
|
|
|
- .setInsureName(appInsure.getName())
|
|
|
- .setCoverImg(appInsure.getCoverImg())
|
|
|
- .setInsureCompany(appInsure.getInsuranceName_dictText())
|
|
|
- .setInsureId(appInsure.getId())
|
|
|
- .setMoney(insurePrice.getInsurePrice())
|
|
|
- .setFamilyMembersId(id)
|
|
|
- .setFamilyUserName(members.getFullName())
|
|
|
- .setAssertStartTime(insureOrderInfoForm.getAssertStartTime())
|
|
|
- .setAssertEndTime(insureOrderInfoForm.getAssertEndTime())
|
|
|
- .setIsEnterSystem(CommonConstant.STATUS_0_INT)
|
|
|
- ;
|
|
|
- insureOrderInfoList.add(insureOrderInfo);
|
|
|
-
|
|
|
- sumPrice = sumPrice.add(insurePrice.getInsurePrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //合同编号
|
|
|
+ AppContractInfo appContractInfo = appContractInfoMapper.selectOne(Wrappers.<AppContractInfo>lambdaQuery()
|
|
|
+ .eq(AppContractInfo::getOrgCode, appOrder.getOrgCode()).eq(AppContractInfo::getDelFlag, 0));
|
|
|
+ if (ObjectUtil.isNotEmpty(appContractInfo)) {
|
|
|
+ appOrder.setContractNo(appContractInfo.getId());
|
|
|
}
|
|
|
- //计算总价 = 订单金额 + 保单金额
|
|
|
- totalPrice = totalPrice.add(sumPrice);
|
|
|
- }
|
|
|
- appOrder.setPrice(totalPrice);
|
|
|
- appOrderMapper.insert(appOrder);
|
|
|
- if(appOrder.getType() == 2){
|
|
|
- saveSignFlowRecord(appOrder);
|
|
|
- }
|
|
|
|
|
|
- if (!insureOrderInfoList.isEmpty()) {
|
|
|
- //保存保险
|
|
|
- for (InsureOrderInfo insureOrderInfo : insureOrderInfoList) {
|
|
|
- insureOrderInfo.setOrderId(appOrder.getId());
|
|
|
- insureOrderInfoMapper.insert(insureOrderInfo);
|
|
|
+ //订单总价(商品的售价总和)
|
|
|
+ BigDecimal sumCoursePrice = new BigDecimal(0);
|
|
|
|
|
|
- AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
- appOrderProInfo.setProductId(insureOrderInfo.getId());
|
|
|
- appOrderProInfo.setProductName(insureOrderInfo.getInsureName());
|
|
|
- appOrderProInfo.setProductImage(insureOrderInfo.getCoverImg());
|
|
|
- appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_7);
|
|
|
+ //优惠金额,如果当前课程商品类目是第一次购买,触发免费政策
|
|
|
+ BigDecimal sDiscounts = new BigDecimal(0);
|
|
|
+ BigDecimal tDiscounts = new BigDecimal(0);
|
|
|
+
|
|
|
+ for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
|
|
|
- appOrderProInfo.setPrice(insureOrderInfo.getMoney());
|
|
|
+ String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
|
|
|
+ FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
|
|
|
+ AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
+ appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
|
+ appOrderProInfo.setProductName(appCourse.getName());
|
|
|
+ appOrderProInfo.setAddress(appSite.getAddress());
|
|
|
+ appOrderProInfo.setProductImage(appCourse.getCover());
|
|
|
+ appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_6);
|
|
|
+ appOrderProInfo.setFrameTimeStr(DateUtil.format(appCourse.getStartTime(), "yyyy-MM-dd") + "-" + DateUtil.format(appCourse.getEndTime(), "MM-dd"));
|
|
|
+ appOrderProInfo.setExpireTime(DateUtil.format(appCourse.getEndTime(), "yyyy-MM-dd"));
|
|
|
+ appOrderProInfo.setOriginalPrice(appCourse.getOriginalPrice());
|
|
|
+ appOrderProInfo.setPrice(appCourse.getSellingPrice());
|
|
|
+ appOrderProInfo.setOrderStatus(0);
|
|
|
appOrderProInfo.setQuantity(1);
|
|
|
- FamilyMembers familyMembers = familyMembersMapper.selectById(insureOrderInfo.getFamilyMembersId());
|
|
|
- appOrderProInfo.setFamilyUserId(familyMembers.getId());
|
|
|
+ appOrderProInfo.setFamilyUserId(familyUserId);
|
|
|
appOrderProInfo.setUserName(familyMembers.getFullName());
|
|
|
appOrderProInfo.setUserPhone(familyMembers.getPhone());
|
|
|
appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
|
appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
|
|
|
+ //创建核销记录
|
|
|
+ if (CollUtil.isNotEmpty(priceRulesList)) {
|
|
|
+ for (AppCoursesPriceRules appCoursesPriceRules : priceRulesList) {
|
|
|
+ AppCoursesVerificationRecord appCoursesVerificationRecord = new AppCoursesVerificationRecord();
|
|
|
+ appCoursesVerificationRecord.setCoursesId(appCourse.getId());
|
|
|
+ appCoursesVerificationRecord.setCoursesPriceRuleId(appCoursesPriceRules.getId());
|
|
|
+ appCoursesVerificationRecord.setCoursesName(appCoursesPriceRules.getName());
|
|
|
+ appCoursesVerificationRecord.setCoursesStartTime(appCoursesPriceRules.getStartTime());
|
|
|
+ appCoursesVerificationRecord.setCoursesEndTime(appCoursesPriceRules.getEndTime());
|
|
|
+ appCoursesVerificationRecord.setUseUserId(familyUserId);
|
|
|
+ appCoursesVerificationRecord.setUseUserName(familyMembers.getFullName());
|
|
|
+ appCoursesVerificationRecord.setUseUserPhone(familyMembers.getPhone());
|
|
|
+ appCoursesVerificationRecord.setUseUserImage(familyMembers.getRealNameImg());
|
|
|
+ appCoursesVerificationRecord.setUseUserName(familyMembers.getFullName());
|
|
|
+ appCoursesVerificationRecord.setVerifyStatus(0);
|
|
|
+ appCoursesVerificationRecord.setOrPostpone(0);
|
|
|
+ appCoursesVerificationRecord.setCoursesType(appCoursesPriceRules.getCoursesType());
|
|
|
+ appCoursesVerificationRecordList.add(appCoursesVerificationRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (createOrderForm.getOrFreeOrder() == 1) {
|
|
|
+ Boolean flag = checkOrderOrFree(user.getId(), appCourse.getCategoryId());
|
|
|
+ if (!flag && i == 1) {
|
|
|
+ //订单中的多个商品中的第一个商品触发免费,将金额设置为优惠金额
|
|
|
+ sDiscounts = sDiscounts.add(appCourse.getSellingPrice());
|
|
|
+ appOrderProInfo.setOrFreePro(CommonConstant.STATUS_1_INT);
|
|
|
+ appOrder.setContractNo(null);
|
|
|
+ //试听优惠
|
|
|
+ appOrder.setSDiscounts(sDiscounts);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
proInfoList.add(appOrderProInfo);
|
|
|
+
|
|
|
+ tDiscounts = tDiscounts.add(appCourse.getOriginalPrice().subtract(appCourse.getSellingPrice())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ sumCoursePrice = sumCoursePrice.add(appCourse.getSellingPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
+
|
|
|
+ //计算订单总价
|
|
|
+ totalPrice = totalPrice.add(sumCoursePrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ //团购优惠
|
|
|
+ appOrder.setTDiscounts(tDiscounts);
|
|
|
+ //原订单总价
|
|
|
+ appOrder.setOriginalPrice(sumCoursePrice);
|
|
|
+ //使用人IDs
|
|
|
+ appOrder.setFamilyIds(createOrderForm.getFamilyIds());
|
|
|
+
|
|
|
+ appOrder.setAddressSiteId(appSite.getId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //构建保单内容
|
|
|
+ InsureOrderInfoForm insureOrderInfoForm = createOrderForm.getInsureOrderInfoForm();
|
|
|
+ if (ObjectUtils.isNotEmpty(insureOrderInfoForm)) {
|
|
|
+ List<String> ids = Arrays.stream(insureOrderInfoForm.getFamilyMembersIds().split(",")).collect(Collectors.toList());
|
|
|
+ AppInsure appInsure = appInsureMapper.selectById(insureOrderInfoForm.getInsureId());
|
|
|
+ DictAnnotationUtil.translateDict(appInsure);
|
|
|
+ //保单总价
|
|
|
+ BigDecimal sumPrice = new BigDecimal(0);
|
|
|
+ for (String id : ids) {
|
|
|
+
|
|
|
+ //查询保单价格
|
|
|
+ InsurePrice insurePrice = insurePriceMapper.selectById(insureOrderInfoForm.getInsurePriceId());
|
|
|
+ FamilyMembers members = familyMembersMapper.selectById(id);
|
|
|
+
|
|
|
+ //创建保单
|
|
|
+ InsureOrderInfo insureOrderInfo = new InsureOrderInfo();
|
|
|
+ insureOrderInfo
|
|
|
+ .setOrderId(appOrder.getId())
|
|
|
+ .setBdOrderNo(generateOrderNumber(2))
|
|
|
+ .setInsureName(appInsure.getName())
|
|
|
+ .setCoverImg(appInsure.getCoverImg())
|
|
|
+ .setInsureCompany(appInsure.getInsuranceName_dictText())
|
|
|
+ .setInsureId(appInsure.getId())
|
|
|
+ .setMoney(insurePrice.getInsurePrice())
|
|
|
+ .setFamilyMembersId(id)
|
|
|
+ .setFamilyUserName(members.getFullName())
|
|
|
+ .setAssertStartTime(insureOrderInfoForm.getAssertStartTime())
|
|
|
+ .setAssertEndTime(insureOrderInfoForm.getAssertEndTime())
|
|
|
+ .setIsEnterSystem(CommonConstant.STATUS_0_INT)
|
|
|
+ ;
|
|
|
+ insureOrderInfoList.add(insureOrderInfo);
|
|
|
+
|
|
|
+ sumPrice = sumPrice.add(insurePrice.getInsurePrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //计算总价 = 订单金额 + 保单金额
|
|
|
+ totalPrice = totalPrice.add(sumPrice);
|
|
|
+ }
|
|
|
+ appOrder.setPrice(totalPrice);
|
|
|
+ appOrderMapper.insert(appOrder);
|
|
|
+ saveSignFlowRecord(appOrder);
|
|
|
+
|
|
|
+ if (!insureOrderInfoList.isEmpty()) {
|
|
|
+ //保存保险
|
|
|
+ for (InsureOrderInfo insureOrderInfo : insureOrderInfoList) {
|
|
|
+ insureOrderInfo.setOrderId(appOrder.getId());
|
|
|
+ insureOrderInfoMapper.insert(insureOrderInfo);
|
|
|
+
|
|
|
+ AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
+ appOrderProInfo.setProductId(insureOrderInfo.getId());
|
|
|
+ appOrderProInfo.setProductName(insureOrderInfo.getInsureName());
|
|
|
+ appOrderProInfo.setProductImage(insureOrderInfo.getCoverImg());
|
|
|
+ appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_7);
|
|
|
+
|
|
|
+ appOrderProInfo.setPrice(insureOrderInfo.getMoney());
|
|
|
+ appOrderProInfo.setQuantity(1);
|
|
|
+ FamilyMembers familyMembers = familyMembersMapper.selectById(insureOrderInfo.getFamilyMembersId());
|
|
|
+ appOrderProInfo.setFamilyUserId(familyMembers.getId());
|
|
|
+ appOrderProInfo.setUserName(familyMembers.getFullName());
|
|
|
+ appOrderProInfo.setUserPhone(familyMembers.getPhone());
|
|
|
+ appOrderProInfo.setStatus(CommonConstant.STATUS_0_INT);
|
|
|
+ appOrderProInfo.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
+
|
|
|
+ proInfoList.add(appOrderProInfo);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- for (AppOrderProInfo appOrderProInfo : proInfoList) {
|
|
|
- appOrderProInfo
|
|
|
+ for (AppOrderProInfo appOrderProInfo : proInfoList) {
|
|
|
+ appOrderProInfo
|
|
|
+ .setOrderId(appOrder.getId())
|
|
|
+ .setOrderCode(appOrder.getOrderCode())
|
|
|
+ //生成10位随机券号
|
|
|
+ .setTicketNo(RandomUtil.randomNumbers(10))
|
|
|
+ ;
|
|
|
+ appOrderProInfoMapper.insert(appOrderProInfo);
|
|
|
+ if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_7)) {
|
|
|
+ //订单券号记录
|
|
|
+ AppIsin appIsin = new AppIsin();
|
|
|
+ appIsin
|
|
|
.setOrderId(appOrder.getId())
|
|
|
+ .setOrgCode(appOrder.getOrgCode())
|
|
|
.setOrderCode(appOrder.getOrderCode())
|
|
|
+ .setOrderProInfoId(appOrderProInfo.getId())
|
|
|
+ .setFamilyId(appOrderProInfo.getFamilyUserId())
|
|
|
+ .setFamilyUserName(appOrderProInfo.getUserName())
|
|
|
+ .setUserPhone(appOrderProInfo.getUserPhone())
|
|
|
+ .setUseAddress(StrUtil.isBlank(appOrderProInfo.getAddress()) ? null : appOrderProInfo.getAddress())
|
|
|
+ //过期时间
|
|
|
+ .setExpireTime(appOrderProInfo.getExpireTime())
|
|
|
//生成10位随机券号
|
|
|
- .setTicketNo(RandomUtil.randomNumbers(10))
|
|
|
- ;
|
|
|
- appOrderProInfoMapper.insert(appOrderProInfo);
|
|
|
- if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_7)) {
|
|
|
- //订单券号记录
|
|
|
- AppIsin appIsin = new AppIsin();
|
|
|
- appIsin
|
|
|
- .setOrderId(appOrder.getId())
|
|
|
- .setOrgCode(appOrder.getOrgCode())
|
|
|
- .setOrderCode(appOrder.getOrderCode())
|
|
|
- .setOrderProInfoId(appOrderProInfo.getId())
|
|
|
- .setFamilyId(appOrderProInfo.getFamilyUserId())
|
|
|
- .setFamilyUserName(appOrderProInfo.getUserName())
|
|
|
- .setUserPhone(appOrderProInfo.getUserPhone())
|
|
|
- .setUseAddress(StrUtil.isBlank(appOrderProInfo.getAddress()) ? null : appOrderProInfo.getAddress())
|
|
|
- //过期时间
|
|
|
- .setExpireTime(appOrderProInfo.getExpireTime())
|
|
|
- //生成10位随机券号
|
|
|
- .setTicketNo(appOrderProInfo.getTicketNo())
|
|
|
- .setIsinStatus(CommonConstant.ISIN_STATUS_1);
|
|
|
- appIsinMapper.insert(appIsin);
|
|
|
- }
|
|
|
- if (Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_1)) {
|
|
|
- appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getOrgCode, appOrder.getOrgCode())).forEach(appDevice -> {
|
|
|
- try {
|
|
|
- String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
|
|
|
- appDevice.getDeviceSerial(),
|
|
|
- appOrderProInfo.getUserName(),
|
|
|
- appOrderProInfo.getId());
|
|
|
- String addFace = addFace(appDevice.getDeviceSerial(), appOrderProInfo.getId(),
|
|
|
- familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId()).getRealNameImg());
|
|
|
- JsonObject addUserJson = JsonParser.parseString(addUser).getAsJsonObject();
|
|
|
- JsonObject addFaceJson = JsonParser.parseString(addFace).getAsJsonObject();
|
|
|
- if (addUserJson.get("code").getAsInt() != 0 && addFaceJson.get("code").getAsInt() != 0)
|
|
|
- throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
|
|
|
- } catch (Exception e) {
|
|
|
+ .setTicketNo(appOrderProInfo.getTicketNo())
|
|
|
+ .setIsinStatus(CommonConstant.ISIN_STATUS_1);
|
|
|
+ appIsinMapper.insert(appIsin);
|
|
|
+ }
|
|
|
+ if (Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_1)) {
|
|
|
+ appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getOrgCode, appOrder.getOrgCode())).forEach(appDevice -> {
|
|
|
+ try {
|
|
|
+ String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
|
|
|
+ appDevice.getDeviceSerial(),
|
|
|
+ appOrderProInfo.getUserName(),
|
|
|
+ appOrderProInfo.getId());
|
|
|
+ String addFace = addFace(appDevice.getDeviceSerial(), appOrderProInfo.getId(),
|
|
|
+ familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId()).getRealNameImg());
|
|
|
+ JsonObject addUserJson = JsonParser.parseString(addUser).getAsJsonObject();
|
|
|
+ JsonObject addFaceJson = JsonParser.parseString(addFace).getAsJsonObject();
|
|
|
+ if (addUserJson.get("code").getAsInt() != 0 && addFaceJson.get("code").getAsInt() != 0)
|
|
|
throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //保存核销记录
|
|
|
- if (CollUtil.isNotEmpty(appCoursesVerificationRecordList)) {
|
|
|
- for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
|
|
|
- appCoursesVerificationRecord.setOrderId(appOrder.getId());
|
|
|
- appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
|
|
|
- appCoursesVerificationRecordMapper.insert(appCoursesVerificationRecord);
|
|
|
- }
|
|
|
+ //保存核销记录
|
|
|
+ if (CollUtil.isNotEmpty(appCoursesVerificationRecordList)) {
|
|
|
+ for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
|
|
|
+ appCoursesVerificationRecord.setOrderId(appOrder.getId());
|
|
|
+ appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
|
|
|
+ appCoursesVerificationRecordMapper.insert(appCoursesVerificationRecord);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //构建支付表单返回给前端支撑JsApi支付调用
|
|
|
- UserPayForm payForm = new UserPayForm();
|
|
|
- payForm
|
|
|
- .setOrderId(appOrder.getId())
|
|
|
- .setOrderCode(orderCode)
|
|
|
- ;
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
|
-
|
|
|
- //构建微信支付参数
|
|
|
- JSONObject params = new JSONObject();
|
|
|
- params.put("sub_appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
|
|
|
- params.put("mchid", WechatConstants.WECHAT_MCH_ID); //商户号
|
|
|
- params.put("description", "胶片订单业务"); //商品描述
|
|
|
- params.put("out_trade_no", appOrder.getOrderCode()); //商户订单号
|
|
|
- params.put("time_expire", sdf.format(calendar.getTime())); //交易结束时间 选填 时间到了之后将不能再支付 遵循rfc3339标准格式
|
|
|
- params.put("attach", appOrder.getOrderCode()); //附加数据 选填
|
|
|
- // 在查询API和支付通知中原样返回 可作为自定义参数使用
|
|
|
- params.put("notify_url", WechatUrlConstants.PAY_V3_NOTIFY); //支付结果异步通知接口
|
|
|
- params.put("trade_type", "JSAPI"); //支付类型
|
|
|
- //分账必传参数
|
|
|
- params.put("profit_sharing", "Y");
|
|
|
-
|
|
|
- //订单金额信息
|
|
|
- JSONObject amount_json = new JSONObject();
|
|
|
- //支付金额 单位:分
|
|
|
-// amount_json.put("total", Integer.parseInt(amount_fee(Double.valueOf("0.1"))));
|
|
|
- amount_json.put("total", Integer.parseInt(amount_fee(appOrder.getPrice())));
|
|
|
- params.put("amount", amount_json);
|
|
|
-
|
|
|
- //支付者信息
|
|
|
- JSONObject payer = new JSONObject();
|
|
|
- //用户在小程序侧的openid
|
|
|
- payer.put("openid", sysUser.getOpenid());
|
|
|
- params.put("payer", payer);
|
|
|
-
|
|
|
- //拉起支付
|
|
|
-// Map<String, String> result = weChatPayService.wechatPay(params);
|
|
|
-
|
|
|
-
|
|
|
- String sub_appid = "wx62ba790ae7983d34";
|
|
|
- String user_id = "oWL7G6MsNrimSKUgr2ezEXgEp4Po";
|
|
|
-
|
|
|
-
|
|
|
- //预支付订单,返回构建小程序支付拉起参数
|
|
|
-
|
|
|
- //发布任务到redission延迟队列
|
|
|
- String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
|
|
|
- redissonDelayQueue.offerTask(task, 60 * 15);
|
|
|
-
|
|
|
- return payForm;
|
|
|
+ //构建支付表单返回给前端支撑JsApi支付调用
|
|
|
+ UserPayForm payForm = new UserPayForm();
|
|
|
+ payForm
|
|
|
+ .setOrderId(appOrder.getId())
|
|
|
+ .setOrderCode(orderCode)
|
|
|
+ ;
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
|
+
|
|
|
+ //构建微信支付参数
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
|
|
|
+// params.put("sub_appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
|
|
|
+ params.put("mchid", WechatConstants.WECHAT_MCH_ID); //商户号
|
|
|
+ params.put("description", "全龄运动"); //商品描述
|
|
|
+ params.put("out_trade_no", appOrder.getOrderCode()); //商户订单号
|
|
|
+ params.put("time_expire", sdf.format(calendar.getTime())); //交易结束时间 选填 时间到了之后将不能再支付 遵循rfc3339标准格式
|
|
|
+ params.put("attach", appOrder.getOrderCode()); //附加数据 选填
|
|
|
+ // 在查询API和支付通知中原样返回 可作为自定义参数使用
|
|
|
+ params.put("notify_url", WechatUrlConstants.PAY_V3_NOTIFY); //支付结果异步通知接口
|
|
|
+
|
|
|
+ //分账必传参数
|
|
|
+ JSONObject settleInfo = new JSONObject();
|
|
|
+ settleInfo.put("profit_sharing", Boolean.TRUE);
|
|
|
+ params.put("settle_info", settleInfo);
|
|
|
+
|
|
|
+ //订单金额信息
|
|
|
+ JSONObject amount_json = new JSONObject();
|
|
|
+ //支付金额 单位:分
|
|
|
+ amount_json.put("total", Integer.parseInt(amount_fee(new BigDecimal("0.01"))));//测试0.01元
|
|
|
+// amount_json.put("total", Integer.parseInt(amount_fee(appOrder.getPrice())));
|
|
|
+ params.put("amount", amount_json);
|
|
|
+
|
|
|
+ //支付者信息
|
|
|
+ JSONObject payer = new JSONObject();
|
|
|
+ //用户在小程序侧的openid
|
|
|
+ payer.put("openid", sysUser.getOpenid());
|
|
|
+ params.put("payer", payer);
|
|
|
+
|
|
|
+ //拉起支付-返回JSAPI参数
|
|
|
+ Map<String, String> result = weChatPayService.wechatPay(params);
|
|
|
+ payForm.setParams(result);
|
|
|
+
|
|
|
+ //发布任务到redission延迟队列
|
|
|
+ String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
|
|
|
+ redissonDelayQueue.offerTask(task, 60 * 15);
|
|
|
+
|
|
|
+ return payForm;
|
|
|
|
|
|
}
|
|
|
|