|
|
@@ -1462,925 +1462,6 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
|
|
|
return payForm;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 改价创建订单
|
|
|
- *
|
|
|
- * @return 支付订单对象
|
|
|
- */
|
|
|
-// @Transactional(rollbackFor = Exception.class)
|
|
|
-// public UserPayForm orderChangePrice(PriceChangeForm priceChangeForm){
|
|
|
-//
|
|
|
-// AppOrder order = appOrderMapper.selectById(priceChangeForm.getOrderId());
|
|
|
-// String userOpenId = order.getUserOpenId();
|
|
|
-// if (ObjectUtil.isEmpty(order)) {
|
|
|
-// throw new JeecgBootException("订单不存在!");
|
|
|
-// }
|
|
|
-// if (Objects.equals(order.getStatus(), CommonConstant.ORDER_STATUS_4)) {
|
|
|
-// throw new JeecgBootException("订单已超时取消!");
|
|
|
-// }
|
|
|
-//
|
|
|
-// //订单取消
|
|
|
-// if (Objects.equals(order.getOrderStatus(), CommonConstant.ORDER_STATUS_0)) {
|
|
|
-// order.setOrderStatus(CommonConstant.ORDER_STATUS_4);
|
|
|
-// appOrderMapper.updateById(order);
|
|
|
-// appOrderProInfoMapper.update(null,Wrappers.lambdaUpdate(AppOrderProInfo.class)
|
|
|
-// .eq(AppOrderProInfo::getOrderId, order.getId())
|
|
|
-// .set(AppOrderProInfo::getOrderStatus, CommonConstant.ORDER_PRO_INFO_TYPE_4));
|
|
|
-// }
|
|
|
-//
|
|
|
-// String userId = order.getUserId();
|
|
|
-// SysUser sysUser = sysUserMapper.selectById(userId);
|
|
|
-// //根据订单构建改价后的订单信息(总金额 = 子订单金额 + 保险)
|
|
|
-// CreateOrderForm createOrderForm = new CreateOrderForm();
|
|
|
-// createOrderForm.setType(order.getType());
|
|
|
-// createOrderForm.setOrderType(order.getOrderType());
|
|
|
-// createOrderForm.setOrFreeOrder(order.getOrderOrFree());
|
|
|
-// createOrderForm.setAmount(order.getAmount());
|
|
|
-// createOrderForm.setFamilyIds(order.getFamilyIds());
|
|
|
-// createOrderForm.setGameCertificationForm(order.getGameCertification());
|
|
|
-// //构建商品IDs
|
|
|
-// List<PriceChangeForm.OrderItemForm> orderItemList = priceChangeForm.getOrderItemList();
|
|
|
-// String productIds = orderItemList.get(0).getProductId();
|
|
|
-// createOrderForm.setProductIds(productIds);
|
|
|
-// if (order.getOrderType() == 1){
|
|
|
-// createOrderForm.setProductIds(order.getOrderExtraField());
|
|
|
-// }
|
|
|
-// //构建保险表单
|
|
|
-// List<InsureOrderInfo> insureOrderInfos =
|
|
|
-// insureOrderInfoMapper.selectList(Wrappers.<InsureOrderInfo>lambdaQuery().eq(InsureOrderInfo::getOrderId,
|
|
|
-// order.getId()));
|
|
|
-//
|
|
|
-// if (CollUtil.isNotEmpty(insureOrderInfos)){
|
|
|
-// String familyMembersIds = insureOrderInfos.stream().map(InsureOrderInfo::getFamilyMembersId).collect(Collectors.joining(","));
|
|
|
-//
|
|
|
-// InsurePrice insurePrices = insurePriceMapper.selectOne(Wrappers.lambdaQuery(InsurePrice.class).eq(InsurePrice::getInsureId,
|
|
|
-// insureOrderInfos.get(0).getInsureId()));
|
|
|
-// InsureOrderInfoForm insureOrderInfoForms = new InsureOrderInfoForm();
|
|
|
-// insureOrderInfoForms.setInsureId(insureOrderInfos.get(0).getInsureId());
|
|
|
-// insureOrderInfoForms.setAssertStartTime(insureOrderInfos.get(0).getAssertStartTime());
|
|
|
-// insureOrderInfoForms.setAssertEndTime(insureOrderInfos.get(0).getAssertEndTime());
|
|
|
-// insureOrderInfoForms.setInsurePriceId(insurePrices.getId());
|
|
|
-// insureOrderInfoForms.setFamilyMembersIds(familyMembersIds);
|
|
|
-//
|
|
|
-// createOrderForm.setInsureOrderInfoForm(insureOrderInfoForms);
|
|
|
-// }
|
|
|
-//
|
|
|
-// String orderCode = generateOrderNumber(0);
|
|
|
-//
|
|
|
-// //创建订单
|
|
|
-// AppOrder appOrder = new AppOrder();
|
|
|
-// appOrder
|
|
|
-// .setOrderType(createOrderForm.getOrderType())
|
|
|
-// .setOrderCode(orderCode)
|
|
|
-// .setUserId(sysUser.getId())
|
|
|
-// .setUserOpenId(sysUser.getOpenid())
|
|
|
-// .setUserPhone(sysUser.getPhone())
|
|
|
-// .setOrderStatus(0)
|
|
|
-// .setProductIds(createOrderForm.getProductIds())
|
|
|
-// .setAmount(createOrderForm.getAmount())
|
|
|
-// ;
|
|
|
-// BigDecimal totalPrice = BigDecimal.ZERO;
|
|
|
-//
|
|
|
-// List<AppOrderProInfo> proInfoList = new ArrayList<>();
|
|
|
-//
|
|
|
-// List<InsureOrderInfo> insureOrderInfoList = new ArrayList<>();
|
|
|
-//
|
|
|
-// List<AppCoursesVerificationRecord> appCoursesVerificationRecordList = new ArrayList<>();
|
|
|
-//
|
|
|
-// 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());
|
|
|
-//
|
|
|
-// String productId = createOrderForm.getProductIds();
|
|
|
-//
|
|
|
-// //改价
|
|
|
-// for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
|
|
|
-// if (orderItemForm.getProductId().equals(productId)){
|
|
|
-// priceRule.setSellingPrice(orderItemForm.getOriginalPrice());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// //判断是否已下单
|
|
|
-// List<String> familyIds = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
|
|
|
-// AppOrderProInfo proInfo = appOrderProInfoMapper.selectOne(Wrappers.<AppOrderProInfo>lambdaQuery()
|
|
|
-// .eq(AppOrderProInfo::getProductId, productId)
|
|
|
-// .in(AppOrderProInfo::getFamilyUserId, familyIds)
|
|
|
-// .last("limit 1")
|
|
|
-// );
|
|
|
-// if (ObjectUtil.isNotEmpty(proInfo)) {
|
|
|
-// String userName = proInfo.getUserName();
|
|
|
-// throw new JeecgBootException(userName + "已预约过该场地的同一日期和时段,无需重复预约,请直接进场。");
|
|
|
-// }
|
|
|
-//
|
|
|
-// 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);
|
|
|
-// //使用人
|
|
|
-// List<String> ids = Arrays.stream(createOrderForm.getFamilyIds().split(",")).collect(Collectors.toList());
|
|
|
-// log.info("学校场地预约商品库存数量:{}", stock);
|
|
|
-// // 缓存没有商品库存,查询数据库
|
|
|
-// if (stock == null || stock == 0 || stock < ids.size()) {
|
|
|
-// AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
|
|
|
-// if (Objects.isNull(product)) {
|
|
|
-// throw new JeecgBootException("订单提交失败,商品已下架");
|
|
|
-// }
|
|
|
-// redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product), 60 * 60 * 24, TimeUnit.SECONDS);
|
|
|
-// // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
|
|
|
-// if (product.getTicketNum() == null) {
|
|
|
-// throw new JeecgBootException("订单提交失败,当前商品库存为空");
|
|
|
-// }
|
|
|
-// stock = product.getTicketNum();
|
|
|
-// redisTemplate.opsForValue().set(stockKey, stock, 60 * 60 * 24, TimeUnit.SECONDS);
|
|
|
-// }
|
|
|
-// // 检查库存是否足够
|
|
|
-// if (stock < ids.size()) {
|
|
|
-// throw new JeecgBootException("订单提交失败,库存不足");
|
|
|
-// }
|
|
|
-// // 更新数据库中的库存数据
|
|
|
-// log.info("更新学校场地数据库中的库存数据:{}", stock - ids.size());
|
|
|
-// int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
|
|
|
-// .eq(AppSitePriceRules::getId, productId)
|
|
|
-// .set(AppSitePriceRules::getTicketNum, (stock - ids.size())));
|
|
|
-// if (row > 0) {
|
|
|
-// // 更新Redis中缓存的商品库存数据
|
|
|
-// redisTemplate.opsForValue().decrement(stockKey, ids.size());
|
|
|
-// }
|
|
|
-// // 库存扣减完,创建订单
|
|
|
-// 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())
|
|
|
-// .setOrProfitSharing(0)
|
|
|
-// .setCreateTime(new Date())
|
|
|
-// .setUpdateTime(new Date())
|
|
|
-// .setCreateBy(sysUser.getId())
|
|
|
-// .setUpdateBy(sysUser.getId())
|
|
|
-// .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
-// .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
-//
|
|
|
-// for (String id : ids) {
|
|
|
-// FamilyMembers familyMembers = familyMembersMapper.selectById(id);
|
|
|
-// if (Objects.isNull(familyMembers)) {
|
|
|
-// throw new JeecgBootException("订单提交失败,用户不存在");
|
|
|
-// }
|
|
|
-// 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;
|
|
|
-// if (priceRule.getEndTime() != null) {
|
|
|
-// expireTime = date + " " + endTime;
|
|
|
-// } else {
|
|
|
-// expireTime = date;
|
|
|
-// }
|
|
|
-// if (startTime == null) {
|
|
|
-// startTime = DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
|
-// }
|
|
|
-// AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
-// appOrderProInfo
|
|
|
-// .setProductId(priceRule.getId())
|
|
|
-// .setProductName("学校场地预约")
|
|
|
-// .setType(CommonConstant.ORDER_PRO_INFO_TYPE_0)
|
|
|
-// .setUseDateStr(date)
|
|
|
-// .setFrameTimeStr(startTime + "-" + endTime)
|
|
|
-// .setExpireTime(expireTime)
|
|
|
-// .setOriginalPrice(priceRule.getOriginalPrice())
|
|
|
-// .setProductImage(appSitePlace.getCover())
|
|
|
-// .setAddress(appSite.getAddress())
|
|
|
-// .setPrice(priceRule.getSellingPrice())
|
|
|
-// .setOrderStatus(1)
|
|
|
-// .setQuantity(1)
|
|
|
-// .setFamilyUserId(id)
|
|
|
-// .setSiteId(appOrder.getAddressSiteId())
|
|
|
-// .setUserName(familyMembers.getFullName())
|
|
|
-// .setUserPhone(familyMembers.getPhone())
|
|
|
-// .setStatus(CommonConstant.STATUS_0_INT)
|
|
|
-// .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
-//
|
|
|
-// proInfoList.add(appOrderProInfo);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// //包场
|
|
|
-// if (createOrderForm.getOrderType() == 1) {
|
|
|
-// //1976836179476189186|2025-10-23,1976836179522326529|2025-10-23
|
|
|
-// List<String> list = Arrays.stream(createOrderForm.getProductIds().split(",")).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// //订单总价(商品的售价总和)
|
|
|
-// BigDecimal sumPrice = BigDecimal.ZERO;
|
|
|
-//
|
|
|
-// 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 (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
|
|
|
-// if (orderItemForm.getProductId().equals(priceRule.getId())){
|
|
|
-// priceRule.setSellingPrice(orderItemForm.getOriginalPrice());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// appOrder.setOrgCode(appSite.getOrgCode());
|
|
|
-//
|
|
|
-// String date = list.get(i).split("\\|")[1];
|
|
|
-// String startTime = DateUtil.format(priceRule.getStartTime(), "HH:mm");
|
|
|
-// String endTime = DateUtil.format(priceRule.getEndTime(), "HH:mm");
|
|
|
-// String expireTime = date + " " + endTime;
|
|
|
-//
|
|
|
-// AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
-// appOrderProInfo.setProductId(list.get(i).split("\\|")[0]);
|
|
|
-// appOrderProInfo.setProductName(date.substring(5) + " " + startTime + "-" + endTime + "|" + appSitePlace.getName());
|
|
|
-// appOrderProInfo.setProductImage(appSitePlace.getCover());
|
|
|
-// appOrderProInfo.setExpireTime(expireTime);
|
|
|
-// appOrderProInfo.setUseDateStr(date.substring(5));
|
|
|
-// appOrderProInfo.setAddress(appSite.getName());
|
|
|
-// appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_1);
|
|
|
-// appOrderProInfo.setProductImage(appSite.getCover());
|
|
|
-// appOrderProInfo.setOriginalPrice(priceRule.getSellingPrice());
|
|
|
-// 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(appOrderProInfo.getPrice());
|
|
|
-// }
|
|
|
-//
|
|
|
-// //计算订单总价
|
|
|
-// totalPrice = totalPrice.add(sumPrice);
|
|
|
-//
|
|
|
-// List<String> collect = list.stream().map(e -> e.split("\\|")[0]).collect(Collectors.toList());
|
|
|
-// String ids = String.join(",", collect);
|
|
|
-// appOrder
|
|
|
-// .setProductIds(ids)
|
|
|
-// .setType(CommonConstant.ORDER_TYPE_0)
|
|
|
-// .setOriginalPrice(sumPrice)
|
|
|
-// .setCreateTime(new Date())
|
|
|
-// .setUpdateTime(new Date())
|
|
|
-// .setCreateBy(sysUser.getId())
|
|
|
-// .setUpdateBy(sysUser.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());
|
|
|
-//
|
|
|
-// //改价
|
|
|
-// for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
|
|
|
-// if (orderItemForm.getProductId().equals(priceRule.getId())){
|
|
|
-// priceRule.setSellingPrice(orderItemForm.getOriginalPrice());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// //订单总价(商品的售价总和)
|
|
|
-// BigDecimal sumPrice = BigDecimal.ZERO;
|
|
|
-// //团购优惠
|
|
|
-// BigDecimal tDiscounts = BigDecimal.ZERO;
|
|
|
-//
|
|
|
-// for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
-//
|
|
|
-// //门店的营业时间
|
|
|
-// Integer indate = appSitePlace.getIndate();
|
|
|
-// String date = DateUtil.format(Date.from(LocalDate.now().plusDays(indate).atStartOfDay(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd");
|
|
|
-// String startTime = DateUtil.format(appSite.getStartTime(), "HH:mm");
|
|
|
-// String endTime = DateUtil.format(appSite.getEndTime(), "HH:mm");
|
|
|
-// String expireTime = date + " " + endTime;
|
|
|
-// if (null == appSite.getStartTime()) {
|
|
|
-// startTime = "00:00";
|
|
|
-// }
|
|
|
-// if (null == appSite.getEndTime()) {
|
|
|
-// endTime = "23:59";
|
|
|
-// }
|
|
|
-// 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_2);
|
|
|
-// 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()));
|
|
|
-// sumPrice = sumPrice.add(priceRule.getSellingPrice());
|
|
|
-// }
|
|
|
-//
|
|
|
-// //计算订单总价
|
|
|
-// totalPrice = totalPrice.add(sumPrice);
|
|
|
-//
|
|
|
-// 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(sysUser.getId())
|
|
|
-// .setUpdateBy(sysUser.getId())
|
|
|
-// .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
-// .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// //赛事
|
|
|
-// case 1:
|
|
|
-// //个人赛
|
|
|
-// if (Objects.equals(createOrderForm.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_3)) {
|
|
|
-// AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
-// AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getId());
|
|
|
-// AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
|
|
|
-//
|
|
|
-// //改价
|
|
|
-// for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
|
|
|
-// if (orderItemForm.getProductId().equals(appGamePriceRules.getId())){
|
|
|
-// appGamePriceRules.setSellingPrice(orderItemForm.getOriginalPrice());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// 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 = BigDecimal.ZERO;
|
|
|
-//
|
|
|
-// 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());
|
|
|
-// if (appGame.getSiteType() == 1) {
|
|
|
-// appOrderProInfo.setAddress(appGameMapper.selectById(appGame.getId()).getAddress());
|
|
|
-// } else {
|
|
|
-// appOrderProInfo.setAddress(appSiteMapper.selectById(appGame.getSiteId()).getAddress());
|
|
|
-// }
|
|
|
-// appOrderProInfo.setType(CommonConstant.ORDER_PRO_INFO_TYPE_3);
|
|
|
-// 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());
|
|
|
-// }
|
|
|
-// //计算订单总价
|
|
|
-// totalPrice = totalPrice.add(sumPrice);
|
|
|
-//
|
|
|
-// appOrder
|
|
|
-// .setType(CommonConstant.ORDER_TYPE_1)
|
|
|
-// .setOriginalPrice(sumPrice)
|
|
|
-// .setCreateTime(new Date())
|
|
|
-// .setUpdateTime(new Date())
|
|
|
-// .setCreateBy(sysUser.getId())
|
|
|
-// .setUpdateBy(sysUser.getId())
|
|
|
-// .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
-// .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
-// if (ObjectUtil.isNotEmpty(appGame.getSiteId())) {
|
|
|
-// appOrder.setAddressSiteId(appGame.getSiteId());
|
|
|
-// }
|
|
|
-// if (StrUtil.isNotBlank(createOrderForm.getGameCertificationForm())) {
|
|
|
-// appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (Objects.equals(createOrderForm.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_4)) {
|
|
|
-// AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
-// AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getId());
|
|
|
-// AppGameSchedule appGameSchedule = appGameScheduleMapper.selectOne(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, appGame.getId()).last("limit 1"));
|
|
|
-//
|
|
|
-// //改价
|
|
|
-// for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
|
|
|
-// if (orderItemForm.getProductId().equals(appGamePriceRules.getId())){
|
|
|
-// appGamePriceRules.setSellingPrice(orderItemForm.getOriginalPrice());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// 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());
|
|
|
-// String ticketNo = RandomUtil.randomNumbers(10);
|
|
|
-// for (String familyId : familyIds) {
|
|
|
-// FamilyMembers familyMembers = familyMembersMapper.selectById(familyId);
|
|
|
-// AppOrderProInfo appOrderProInfo = new AppOrderProInfo();
|
|
|
-// appOrderProInfo.setProductId(createOrderForm.getProductIds());
|
|
|
-// appOrderProInfo.setProductName(appGame.getName());
|
|
|
-// if (appGame.getSiteType() == 1) {
|
|
|
-// appOrderProInfo.setAddress(appGameMapper.selectById(appGame.getId()).getAddress());
|
|
|
-// } else {
|
|
|
-// appOrderProInfo.setAddress(appSiteMapper.selectById(appGame.getSiteId()).getAddress());
|
|
|
-// }
|
|
|
-// appOrderProInfo.setTicketNo(ticketNo);
|
|
|
-// 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)
|
|
|
-// .setOriginalPrice(sumPrice)
|
|
|
-// .setCreateTime(new Date())
|
|
|
-// .setUpdateTime(new Date())
|
|
|
-// .setCreateBy(sysUser.getId())
|
|
|
-// .setUpdateBy(sysUser.getId())
|
|
|
-// .setStatus(CommonConstant.STATUS_NORMAL)
|
|
|
-// .setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
-// if (ObjectUtil.isNotEmpty(appGame.getSiteId())) {
|
|
|
-// appOrder.setAddressSiteId(appGame.getSiteId());
|
|
|
-// }
|
|
|
-// if (StrUtil.isNotBlank(createOrderForm.getGameCertificationForm())) {
|
|
|
-// appOrder.setGameCertification(createOrderForm.getGameCertificationForm());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// //课程
|
|
|
-// case 2:
|
|
|
-// //课程
|
|
|
-// AppCourses appCourse = appCoursesMapper.selectById(appOrder.getProductIds());
|
|
|
-// if (ObjectUtil.isEmpty(appCourse)) {
|
|
|
-// log.error("当前课程不存在!");
|
|
|
-// throw new JeecgBootException("当前课程已下架!");
|
|
|
-// }
|
|
|
-//
|
|
|
-// //改价
|
|
|
-// for (PriceChangeForm.OrderItemForm orderItemForm : orderItemList) {
|
|
|
-// if (orderItemForm.getProductId().equals(appCourse.getId())){
|
|
|
-// appCourse.setSellingPrice(orderItemForm.getOriginalPrice());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<AppCoursesPriceRules> priceRulesList = appCoursesPriceRulesMapper.selectList(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId, appCourse.getId()));
|
|
|
-// AppSite appSite = appSiteMapper.selectById(appCourse.getAddressSiteId());
|
|
|
-// appOrder.setOrderOrFree(createOrderForm.getOrFreeOrder());
|
|
|
-// 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());
|
|
|
-// }
|
|
|
-//
|
|
|
-// //订单总价(商品的售价总和)
|
|
|
-// BigDecimal sumCoursePrice = BigDecimal.ZERO;
|
|
|
-//
|
|
|
-// //优惠金额,如果当前课程商品类目是第一次购买,触发免费政策
|
|
|
-// BigDecimal sDiscounts = BigDecimal.ZERO;
|
|
|
-// BigDecimal tDiscounts = BigDecimal.ZERO;
|
|
|
-//
|
|
|
-// for (int i = 1; i <= createOrderForm.getAmount(); i++) {
|
|
|
-//
|
|
|
-// String familyUserId = createOrderForm.getFamilyIds().split(",")[i - 1];
|
|
|
-// FamilyMembers familyMembers = familyMembersMapper.selectById(familyUserId);
|
|
|
-//
|
|
|
-// //判断当前课程是否已下过单
|
|
|
-// List<AppOrderProInfo> infos = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery()
|
|
|
-// .eq(AppOrderProInfo::getProductId, appCourse.getId())
|
|
|
-// .eq(AppOrderProInfo::getFamilyUserId, familyUserId)
|
|
|
-// );
|
|
|
-// List<AppOrderProInfo> infoList = appOrderProInfoMapper.selectList(Wrappers.<AppOrderProInfo>lambdaQuery()
|
|
|
-// .eq(AppOrderProInfo::getProductId, appCourse.getId())
|
|
|
-// .eq(AppOrderProInfo::getFamilyUserId, familyUserId)
|
|
|
-// .eq(AppOrderProInfo::getOrFreePro, CommonConstant.STATUS_0_INT)
|
|
|
-// .notIn(AppOrderProInfo::getOrderStatus, CommonConstant.ORDER_STATUS_4, CommonConstant.ORDER_STATUS_5, CommonConstant.ORDER_STATUS_6)
|
|
|
-// );
|
|
|
-//
|
|
|
-// if (ObjectUtil.isNotEmpty(infoList)) {
|
|
|
-// throw new JeecgBootException("当前课程已下过单,请勿重复下单");
|
|
|
-// }
|
|
|
-// if (Objects.equals(createOrderForm.getOrFreeOrder(), CommonConstant.STATUS_1_INT)) {
|
|
|
-// List<AppOrderProInfo> freeProList = infos.stream()
|
|
|
-// .filter(info -> Objects.equals(info.getOrFreePro(), CommonConstant.STATUS_0_INT) && !Objects.equals(info.getOrderStatus(), CommonConstant.ORDER_PRO_INFO_TYPE_4))
|
|
|
-// .collect(Collectors.toList());
|
|
|
-// if (ObjectUtil.isNotEmpty(freeProList)) {
|
|
|
-// throw new JeecgBootException("当前试听课课程已下过单,请勿重复下单");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// 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_5);
|
|
|
-// 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.setUseDateStr(DateUtil.format(appCourse.getStartTime(), "yyyy-MM-dd"));
|
|
|
-// 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)) {
|
|
|
-//
|
|
|
-// if (Objects.equals(appOrder.getOrderOrFree(), CommonConstant.STATUS_0_INT)) {
|
|
|
-// //非试听课
|
|
|
-// 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 (Objects.equals(appOrder.getOrderOrFree(), CommonConstant.STATUS_1_INT)) {
|
|
|
-// priceRulesList.sort(Comparator.comparing(AppCoursesPriceRules::getSort));
|
|
|
-// AppCoursesPriceRules appCoursesPriceRules = priceRulesList.get(0);
|
|
|
-// 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(sysUser.getId(), appCourse.getCategoryId());
|
|
|
-// if (flag && i == 1) {
|
|
|
-// //订单中的多个商品中的第一个商品触发免费,将金额设置为优惠金额
|
|
|
-// sDiscounts = sDiscounts.add(appCourse.getOriginalPrice());
|
|
|
-// appOrderProInfo.setOrFreePro(CommonConstant.STATUS_1_INT);
|
|
|
-// appOrderProInfo.setOrderStatus(1);
|
|
|
-// appOrderProInfo.setOriginalPrice(appCourse.getOriginalPrice());
|
|
|
-// appOrderProInfo.setPrice(BigDecimal.ZERO);
|
|
|
-// appOrder.setContractNo(null);
|
|
|
-// //试听优惠
|
|
|
-// appOrder.setSDiscounts(sDiscounts);
|
|
|
-// appOrder.setOrderOrFree(CommonConstant.STATUS_1_INT);
|
|
|
-// appOrder.setOrProfitSharing(0);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// proInfoList.add(appOrderProInfo);
|
|
|
-//
|
|
|
-// tDiscounts = tDiscounts.add(appCourse.getOriginalPrice().subtract(appCourse.getSellingPrice()));
|
|
|
-// if (createOrderForm.getOrFreeOrder() == 1) {
|
|
|
-// tDiscounts = BigDecimal.ZERO;
|
|
|
-// }
|
|
|
-// sumCoursePrice = sumCoursePrice.add(appCourse.getSellingPrice());
|
|
|
-// if (createOrderForm.getOrFreeOrder() == 1) {
|
|
|
-// sumCoursePrice = BigDecimal.ZERO;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// //计算订单总价
|
|
|
-// totalPrice = totalPrice.add(sumCoursePrice);
|
|
|
-//
|
|
|
-// //团购优惠
|
|
|
-// appOrder.setTDiscounts(tDiscounts);
|
|
|
-// if (createOrderForm.getOrFreeOrder() == 1) {
|
|
|
-// //团购优惠
|
|
|
-// appOrder.setTDiscounts(BigDecimal.ZERO);
|
|
|
-// }
|
|
|
-// //使用人IDs
|
|
|
-// appOrder.setFamilyIds(createOrderForm.getFamilyIds());
|
|
|
-//
|
|
|
-// appOrder.setAddressSiteId(appCourse.getAddressSiteId());
|
|
|
-// 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());
|
|
|
-// }
|
|
|
-// //计算总价 = 订单金额 + 保单金额
|
|
|
-// totalPrice = totalPrice.add(sumPrice);
|
|
|
-// }
|
|
|
-// //原订单总价
|
|
|
-// appOrder.setOriginalPrice(totalPrice);
|
|
|
-// appOrder.setPrice(totalPrice);
|
|
|
-// appOrderMapper.insert(appOrder);
|
|
|
-// if (appOrder.getOrderType() == 5 && appOrder.getOrderOrFree() == 0) {
|
|
|
-// 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_6);
|
|
|
-//
|
|
|
-// appOrderProInfo.setPrice(insureOrderInfo.getMoney());
|
|
|
-// appOrderProInfo.setOriginalPrice(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
|
|
|
-// .setOrderId(appOrder.getId())
|
|
|
-// .setOrderCode(appOrder.getOrderCode());
|
|
|
-// if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_4)) {
|
|
|
-// appOrderProInfo.setTicketNo(RandomUtil.randomNumbers(10));
|
|
|
-// }
|
|
|
-// if (appOrderProInfoMapper.insert(appOrderProInfo) > 0) {
|
|
|
-// if (appOrderProInfo.getType() == 5) {
|
|
|
-// AppSite appSite = appSiteMapper.selectById(appCoursesMapper.selectById(appOrderProInfo.getProductId()).getAddressSiteId());
|
|
|
-// if (null != appSite &&
|
|
|
-// appSite.getType() == 0) {
|
|
|
-// FamilyMembers familyMembers = familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId());
|
|
|
-// for (AppDevice appDevice : appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getSiteId, appSite.getId()))) {
|
|
|
-// if (null != appDevice) {
|
|
|
-// JsonObject addUserJson = JsonParser.parseString(addUser(new Date(),
|
|
|
-// appDevice.getDeviceSerial(),
|
|
|
-// appOrderProInfo.getUserName(),
|
|
|
-// familyMembers.getId(), new DateTime(appOrderProInfo.getExpireTime()))).getAsJsonObject();
|
|
|
-// JsonObject addFaceJson = JsonParser.parseString(addFace(appDevice.getDeviceSerial(), familyMembers.getId(),
|
|
|
-// familyMembers.getRealNameImg())).getAsJsonObject();
|
|
|
-// if (addUserJson.get("code").getAsInt() != 0 && addFaceJson.get("code").getAsInt() != 0) {
|
|
|
-// throw new JeecgBootException("设备录入用户信息失败!请联系管理员");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (!Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_6)) {
|
|
|
-// //订单券号记录
|
|
|
-// 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())
|
|
|
-// //过期时间
|
|
|
-// .setExpireTime(appOrderProInfo.getExpireTime())
|
|
|
-// //生成10位随机券号
|
|
|
-// .setTicketNo(appOrderProInfo.getTicketNo())
|
|
|
-// .setIsinStatus(CommonConstant.ISIN_STATUS_0);
|
|
|
-// if (appOrder.getType() == 0) {
|
|
|
-// String s = createOrderForm.getProductIds().split(",")[0];
|
|
|
-// String priceRuleId = s.split("\\|")[0];
|
|
|
-// AppSitePriceRules priceRule = appSitePriceRulesMapper.selectById(priceRuleId);
|
|
|
-// AppSitePlace appSitePlace = appSitePlaceMapper.selectById(priceRule.getSitePlaceId());
|
|
|
-// AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
|
|
|
-// appIsin.setUseAddress(appSite.getName());
|
|
|
-// }
|
|
|
-// if (appOrder.getType() == 1) {
|
|
|
-// AppGamePriceRules appGamePriceRules = appGamePriceRulesMapper.selectById(createOrderForm.getProductIds());
|
|
|
-// AppGame appGame = appGameMapper.findByPriceRules(appGamePriceRules.getId());
|
|
|
-// appIsin.setUseAddress(sysDepartMapper.selectOne(Wrappers.<SysDepart>lambdaQuery().eq(SysDepart::getOrgCode, appGame.getOrgCode())).getDepartName());
|
|
|
-// }
|
|
|
-// if (appOrder.getType() == 2) {
|
|
|
-// AppSite appSite = appSiteMapper.selectById(appCoursesMapper.selectById(appOrderProInfo.getProductId()).getAddressSiteId());
|
|
|
-// appIsin.setUseAddress(appSite.getName());
|
|
|
-//
|
|
|
-// //判断当前课程是否是在学校上课
|
|
|
-// if (appSite.getType() == 0) {
|
|
|
-// //查询当前课程的课时
|
|
|
-// AppCourses appCourses = appCoursesMapper.selectById(appOrderProInfo.getProductId());
|
|
|
-// List<AppCoursesPriceRules> appCoursesPriceRules = appCoursesPriceRulesMapper.selectList(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId,
|
|
|
-// appCourses.getId()));
|
|
|
-// for (AppCoursesPriceRules appCoursesPriceRule : appCoursesPriceRules) {
|
|
|
-// AppIsin appIsinInfo = new AppIsin();
|
|
|
-// appIsinInfo
|
|
|
-// .setOrderId(appOrder.getId())
|
|
|
-// .setOrgCode(appOrder.getOrgCode())
|
|
|
-// .setOrderCode(appOrder.getOrderCode())
|
|
|
-// .setOrderProInfoId(appOrderProInfo.getId())
|
|
|
-// .setCoursePriceRuleId(appCoursesPriceRule.getId())
|
|
|
-// .setFamilyId(appOrderProInfo.getFamilyUserId())
|
|
|
-// .setFamilyUserName(appOrderProInfo.getUserName())
|
|
|
-// .setTicketNo(appOrderProInfo.getTicketNo())
|
|
|
-// .setIsinStatus(CommonConstant.ISIN_STATUS_0);
|
|
|
-// appIsinMapper.insert(appIsinInfo);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// appIsinMapper.insert(appIsin);
|
|
|
-// }
|
|
|
-// if (Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_0)) {
|
|
|
-// FamilyMembers familyMembers = familyMembersMapper.selectById(appOrderProInfo.getFamilyUserId());
|
|
|
-// for (AppDevice appDevice : appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getOrgCode, appOrder.getOrgCode()))) {
|
|
|
-// String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
|
|
|
-// appDevice.getDeviceSerial(),
|
|
|
-// appOrderProInfo.getUserName(),
|
|
|
-// familyMembers.getId(), null);
|
|
|
-// String addFace = addFace(appDevice.getDeviceSerial(), familyMembers.getId(),
|
|
|
-// familyMembers.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("设备录入用户信息失败!请联系管理员");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// //保存核销记录
|
|
|
-// if (CollUtil.isNotEmpty(appCoursesVerificationRecordList)) {
|
|
|
-// for (AppCoursesVerificationRecord appCoursesVerificationRecord : appCoursesVerificationRecordList) {
|
|
|
-// appCoursesVerificationRecord.setOrderId(appOrder.getId());
|
|
|
-// appCoursesVerificationRecord.setOrderCode(appOrder.getOrderCode());
|
|
|
-// appCoursesVerificationRecord.setOrgCode(appOrder.getOrgCode());
|
|
|
-// appCoursesVerificationRecordMapper.insert(appCoursesVerificationRecord);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// //构建支付表单返回给前端支撑JsApi支付调用
|
|
|
-// UserPayForm payForm = new UserPayForm();
|
|
|
-// payForm.setOrderId(appOrder.getId()).setOrderCode(orderCode);
|
|
|
-//
|
|
|
-// //判断是否试听课(试听课不走订单)
|
|
|
-// if ((ObjectUtil.isNotEmpty(appOrder.getOrderOrFree()) && appOrder.getOrderOrFree() == 1) || appOrder.getPrice().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
-// payForm.setOrPayOrder(0);
|
|
|
-// } else {
|
|
|
-// //分账能否成功,判断是否可以下单
|
|
|
-// List<AppOrderProInfo> orderProInfoList =
|
|
|
-// proInfoList.stream().filter(appOrderProInfo -> Objects.equals(appOrderProInfo.getType(), CommonConstant.ORDER_PRO_INFO_TYPE_6)).collect(Collectors.toList());
|
|
|
-// BigDecimal insurePrice = BigDecimal.ZERO;
|
|
|
-// if (CollUtil.isNotEmpty(orderProInfoList)) {
|
|
|
-// BigDecimal reduce = orderProInfoList.stream().map(AppOrderProInfo::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
-// insurePrice = insurePrice.add(reduce);
|
|
|
-// }
|
|
|
-// //创建预分账详情
|
|
|
-// String orgCode = appOrder.getOrgCode();
|
|
|
-// SysDepart depart = sysDepartMapper.selectOne(Wrappers.lambdaQuery(SysDepart.class).eq(SysDepart::getOrgCode, orgCode).last("limit 1"));
|
|
|
-// String deptId = depart.getId();
|
|
|
-// if (depart.getSystemType() == 2) {
|
|
|
-// deptId = depart.getParentId();
|
|
|
-// }
|
|
|
-// if (depart.getSystemType() != 0) {
|
|
|
-// SeparateAccounts separateAccounts = separateAccountsMapper.selectOne(Wrappers.lambdaQuery(SeparateAccounts.class).eq(SeparateAccounts::getDeptId, deptId));
|
|
|
-// if (ObjectUtil.isEmpty(separateAccounts)) {
|
|
|
-// throw new JeecgBootException("商户信息未配置!请联系管理员");
|
|
|
-// }
|
|
|
-// //获取分账比例
|
|
|
-// BigDecimal PT = separateAccounts.getPtSeparateAccounts();
|
|
|
-// BigDecimal SH = separateAccounts.getShSeparateAccounts();
|
|
|
-// BigDecimal MD = separateAccounts.getMdSeparateAccounts();
|
|
|
-// //分账金额(支付金额-保险金额)
|
|
|
-// BigDecimal price = appOrder.getPrice().subtract(insurePrice);
|
|
|
-// //微信手续费,不足1分按1分算(当计算值小于0.01时强制提升至0.01)
|
|
|
-//// BigDecimal FEE = calculate(price, new BigDecimal("0.006"));
|
|
|
-//
|
|
|
-//// price = price.subtract(FEE);
|
|
|
-//
|
|
|
-// //商户(分账给平台)
|
|
|
-// if (depart.getSystemType() == 1) {
|
|
|
-// BigDecimal[] allocate = RatiosUtil.allocate(price, new BigDecimal[]{SH, PT});
|
|
|
-// if (appOrder.getPrice().multiply(BigDecimal.valueOf(0.3)).compareTo(allocate[1].add(insurePrice)) < 0) {
|
|
|
-// throw new JeecgBootException("订单金额不支持分账,无法下单!");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// //门店(分账给平台及商户)
|
|
|
-// if (depart.getSystemType() == 2) {
|
|
|
-// BigDecimal[] allocate = RatiosUtil.allocate(price, MD, SH, PT);
|
|
|
-// if (appOrder.getPrice().multiply(BigDecimal.valueOf(0.3)).compareTo(allocate[1].add(allocate[2]).add(insurePrice)) < 0) {
|
|
|
-// throw new JeecgBootException("订单金额不支持分账,无法下单!");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// Map<String, String> result = payment(appOrder.getId(),userOpenId);
|
|
|
-// payForm.setParams(result);
|
|
|
-//
|
|
|
-// //发布任务到redission延迟队列(16分钟)
|
|
|
-//// String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
|
|
|
-//// redissonDelayQueue.offerTask(task, 60 * 16);
|
|
|
-//
|
|
|
-// //发送延迟消息
|
|
|
-// delayedMessageService.sendOrderMessage(appOrder.getId());
|
|
|
-// }
|
|
|
-// return payForm;
|
|
|
-// }
|
|
|
-
|
|
|
private static final BigDecimal MIN_THRESHOLD = new BigDecimal("0.01"); // 最小阈值
|
|
|
|
|
|
/**
|