From 5627daeb1ac1a29947e902f9a7efb6730ed98611 Mon Sep 17 00:00:00 2001 From: jiangqs <jiangqs> Date: 星期五, 07 七月 2023 20:35:50 +0800 Subject: [PATCH] 管理台bug和用户端生日卡 --- ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java | 515 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 389 insertions(+), 126 deletions(-) diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java index c2de81f..6ac5722 100644 --- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java +++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java @@ -83,6 +83,8 @@ @Resource private RemoteCouponService remoteCouponService; + @Resource + private RemoteActivityService remoteActivityService; /** * @description: buyGoods @@ -135,7 +137,6 @@ //商品图片 goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData(); appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl()); - buyNum = appBuyGoodsDto.getBuyNum(); appSureOrderGoodsVo.setBuyNum(buyNum); goodsPrice = goods.getSalesPrice(); //商户定制价格 @@ -209,6 +210,84 @@ } /** + * @param appPanicBuyDto + * @return AppSureOrderVo + * @description 抢购商品 + * @author jqs + * @date 2023/7/6 11:45 + */ + @Override + public AppPanicBuyVo panicBuyGoods(AppPanicBuyDto appPanicBuyDto) { + Long userId = appPanicBuyDto.getUserId(); + AppPanicBuyVo appPanicBuyVo = new AppPanicBuyVo(); + String activityId = appPanicBuyDto.getActivityId(); + String goodsId = appPanicBuyDto.getGoodsId(); + Integer buyNum = appPanicBuyDto.getBuyNum(); + BigDecimal buyNumBig; + BigDecimal goodsPrice; + BigDecimal goodsTotalPrice; + BigDecimal goodsRealPrice; + BigDecimal goodsDeposit; + BigDecimal goodsActivityPrice; + GoodsFile goodsFile; + BigDecimal orderGoodsMoney = new BigDecimal("0.00"); + BigDecimal orderPayDeposit = new BigDecimal("0.00"); + BigDecimal orderPayMoney = new BigDecimal("0.00"); + ActivityGoodsGetDto activityGoodsGetDto = new ActivityGoodsGetDto(); + activityGoodsGetDto.setActivityId(activityId); + activityGoodsGetDto.setGoodsId(goodsId); + activityGoodsGetDto.setUserId(userId); + ActivityGoodsGetVo activityGoodsGetVo = remoteActivityService.getUserActivityGoods(activityGoodsGetDto).getData(); + if (activityGoodsGetVo.getActivityStatus() == 0) { + throw new ServiceException(AppErrorConstant.ACTIVITY_NO_START); + } + if (activityGoodsGetVo.getActivityStatus() == 2) { + throw new ServiceException(AppErrorConstant.ACTIVITY_END); + } + if (activityGoodsGetVo.getAvailableBuyNum() < 1) { + throw new ServiceException(AppErrorConstant.ACTIVITY_GOODS_NULL); + } + Goods goods = remoteGoodsService.getGoods(goodsId).getData(); + appPanicBuyVo.setGoodsId(goodsId); + appPanicBuyVo.setGoodsName(goods.getGoodsName()); + appPanicBuyVo.setGoodsIntroduction(goods.getGoodsIntroduction()); + appPanicBuyVo.setGoodsType(goods.getGoodsType()); + //商品图片 + goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData(); + appPanicBuyVo.setGoodsPicture(goodsFile.getFileUrl()); + appPanicBuyVo.setBuyNum(buyNum); + goodsPrice = goods.getSalesPrice(); + //商户定制价格 + AppShopGoodsGetDto appShopGoodsGetDto = new AppShopGoodsGetDto(); + appShopGoodsGetDto.setGoodsId(goods.getGoodsId()); + appShopGoodsGetDto.setShopId(appPanicBuyDto.getShopId()); + ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); + if (shopGoods != null) { + goodsPrice = shopGoods.getSalesPrice(); + } + appPanicBuyVo.setGoodsPrice(goodsPrice); + buyNumBig = BigDecimal.valueOf(buyNum); + goodsActivityPrice = activityGoodsGetVo.getActivityPrice(); + goodsTotalPrice = goodsActivityPrice.multiply(buyNumBig); + goodsRealPrice = goodsTotalPrice; + appPanicBuyVo.setActivityPrice(goodsActivityPrice); + appPanicBuyVo.setGoodsTotalPrice(goodsTotalPrice); + appPanicBuyVo.setGoodsRealPrice(goodsRealPrice); + goodsDeposit = activityGoodsGetVo.getActivitySubscription(); + if (goodsDeposit == null) { + goodsDeposit = new BigDecimal("0.00"); + } + appPanicBuyVo.setGoodsDeposit(goodsDeposit); + orderGoodsMoney = orderGoodsMoney.add(goodsTotalPrice); + orderPayDeposit = orderPayDeposit.add(goodsDeposit); + orderPayMoney = orderPayMoney.add(goodsRealPrice); + appPanicBuyVo.setOrderGoodsMoney(orderGoodsMoney); + appPanicBuyVo.setOrderPayDeposit(orderPayDeposit); + appPanicBuyVo.setOrderPayMoney(orderPayMoney); + return appPanicBuyVo; + } + + /** * 创建订单 * * @param appPlaceOrderDto @@ -216,11 +295,16 @@ */ @Override public AppPlaceOrderVo placeOrder(AppPlaceOrderDto appPlaceOrderDto) { + // 获取用户ID Long userId = appPlaceOrderDto.getUserId(); + // 创建下单视图对象 AppPlaceOrderVo appPlaceOrderVo = new AppPlaceOrderVo(); + // 创建商品列表 List<AppSureOrderGoodsVo> appSureOrderGoodsVoList = new ArrayList<>(); AppSureOrderGoodsVo appSureOrderGoodsVo; + // 获取购买的商品列表 List<AppBuyGoodsDto> appBuyGoodsDtoList = appPlaceOrderDto.getAppBuyGoodsDtoList(); + // 初始化变量 String goodsId; Integer buyNum; BigDecimal buyNumBig; @@ -228,10 +312,13 @@ Integer goodsNum = 0; String memberCouponId; Goods goods; + GoodsFile goodsFile; BigDecimal goodsPrice; BigDecimal goodsTotalPrice; BigDecimal goodsRealPrice; + // 获取用户优惠券列表 List<AppMemberCouponVo> appMemberCouponVoList = remoteCouponService.listVoMemberCouponByUserId(userId).getData(); + // 将用户优惠券列表转换为Map,方便后续查找 Map<String, AppMemberCouponVo> appMemberCouponVoMap = appMemberCouponVoList.stream().collect(Collectors.toMap(AppMemberCouponVo::getMemberCouponId, Function.identity())); AppMemberCouponVo appMemberCouponVo; Integer couponType; @@ -239,51 +326,63 @@ BigDecimal discountMoney = new BigDecimal("0.00"); BigDecimal discountPercent; BigDecimal goodsDeposit; - GoodsFile goodsFile; Integer useCoupon; BigDecimal orderGoodsMoney = new BigDecimal("0.00"); BigDecimal couponDiscount = new BigDecimal("0.00"); BigDecimal orderPayDeposit = new BigDecimal("0.00"); BigDecimal orderPayMoney = new BigDecimal("0.00"); + // 创建订单ID和订单号 String orderId = IdUtils.simpleUUID(); String orderNo = CodeFactoryUtil.getShopOrderNo(); OrderGoods orderGoods; String orderGoodsId; + // 创建商品类型集合,用于记录订单中所有商品的类型 HashSet<String> goodsTypeSet = new HashSet<>(); + // 遍历购买的商品列表 for (AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList) { appSureOrderGoodsVo = new AppSureOrderGoodsVo(); useCoupon = 0; + // 获取商品ID和优惠券ID goodsId = appBuyGoodsDto.getGoodsId(); memberCouponId = appBuyGoodsDto.getMemberCouponId(); + // 获取商品信息 goods = remoteGoodsService.getGoods(goodsId).getData(); + // 设置商品信息 appSureOrderGoodsVo.setGoodsId(goodsId); appSureOrderGoodsVo.setGoodsName(goods.getGoodsName()); appSureOrderGoodsVo.setGoodsIntroduction(goods.getGoodsIntroduction()); appSureOrderGoodsVo.setGoodsType(goods.getGoodsType()); - //商品图片 + // 获取商品图片 goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData(); appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl()); + // 获取购买数量 buyNum = appBuyGoodsDto.getBuyNum(); appSureOrderGoodsVo.setBuyNum(buyNum); + // 获取商品价格和服务数量 goodsPrice = goods.getSalesPrice(); serviceNum = goods.getServiceNum(); - //商户定制价格 + // 获取商户定制价格 AppShopGoodsGetDto appShopGoodsGetDto = new AppShopGoodsGetDto(); appShopGoodsGetDto.setGoodsId(goods.getGoodsId()); appShopGoodsGetDto.setShopId(appPlaceOrderDto.getShopId()); ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); + // 如果商户定制价格存在,则使用商户定制价格和服务数量 if (shopGoods != null) { goodsPrice = shopGoods.getSalesPrice(); serviceNum = shopGoods.getServiceNum(); } appSureOrderGoodsVo.setGoodsPrice(goodsPrice); + // 计算商品总价 buyNumBig = BigDecimal.valueOf(buyNum); goodsTotalPrice = goodsPrice.multiply(buyNumBig); goodsRealPrice = goodsTotalPrice; + // 如果使用了优惠券,计算优惠后的价格 if (memberCouponId != null) { appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId); + // 如果优惠券适用于该商品 if (StringUtils.isBlank(appMemberCouponVo.getRelGoodsIds()) || appMemberCouponVo.getRelGoodsIds().contains(goodsId)) { couponType = appMemberCouponVo.getCouponType(); + // 根据优惠券类型计算优惠后的价格 if (couponType == 1 && appMemberCouponVo.getMoneyThreshold() != null && appMemberCouponVo.getDiscountMoney() != null) { moneyThreshold = appMemberCouponVo.getMoneyThreshold(); if (goodsTotalPrice.compareTo(moneyThreshold) >= 0) { @@ -307,17 +406,19 @@ appSureOrderGoodsVo.setGoodsTotalPrice(goodsTotalPrice); appSureOrderGoodsVo.setCouponDiscount(discountMoney); appSureOrderGoodsVo.setGoodsRealPrice(goodsRealPrice); + // 获取商品押金 goodsDeposit = goods.getSubscription(); if (goodsDeposit == null) { goodsDeposit = new BigDecimal("0.00"); } appSureOrderGoodsVo.setGoodsDeposit(goodsDeposit); + // 计算商品总数量、商品总价、优惠总金额、支付押金、支付金额 goodsNum = goodsNum + buyNum; orderGoodsMoney = orderGoodsMoney.add(goodsTotalPrice); couponDiscount = couponDiscount.add(discountMoney); orderPayDeposit = orderPayDeposit.add(goodsDeposit); orderPayMoney = orderPayMoney.add(goodsRealPrice); - //创建OrderGoods + // 创建订单商品 orderGoods = new OrderGoods(); orderGoodsId = IdUtils.simpleUUID(); orderGoods.setOrderGoodsId(orderGoodsId); @@ -329,17 +430,22 @@ orderGoods.setCouponId(memberCouponId.toString()); } orderGoods.setGoodsPrice(goodsPrice); + orderGoods.setGoodsDeposit(goodsDeposit); orderGoods.setGoodsTotalMoney(orderGoodsMoney); orderGoods.setGoodsReceivableMoney(goodsRealPrice); orderGoods.setCycleNumFlag(goods.getCycleNumFlag()); orderGoods.setServiceNum(serviceNum); orderGoods.setGoodsType(goods.getGoodsType()); + orderGoods.setGoodsName(goods.getGoodsName()); + orderGoods.setGoodsPicture(goodsFile.getFileUrl()); + // 保存订单商品 orderGoodsService.save(orderGoods); - //清空购物车 + // 清空购物车 AppShoppingCartDelDto appShoppingCartDelDto = new AppShoppingCartDelDto(); appShoppingCartDelDto.setGoodsId(goodsId); appShoppingCartDelDto.setUserId(userId); remoteShoppingCartService.deleteShoppingCart(appShoppingCartDelDto); + // 记录商品类型 if (goods.getGoodsType() == 1) { goodsTypeSet.add("周期"); } else if (goods.getGoodsType() == 2) { @@ -350,10 +456,10 @@ goodsTypeSet.add("单品"); } } + // 创建订单 Order order = new Order(); order.setOrderId(orderId); order.setDelFlag(0); - //为对接支付 直接付款成功 order.setOrderStatus(1); order.setOrderNo(orderNo); order.setOrderFrom(1); @@ -366,6 +472,7 @@ order.setReceivableDeposit(orderPayDeposit); order.setChangeReceivableMoney(orderPayMoney); order.setPayType(appPlaceOrderDto.getPayType()); + // 根据支付类型计算支付金额 if (order.getPayType() == 1) { order.setPayMoney(orderPayMoney); order.setOnlinePayMoney(orderPayMoney); @@ -382,8 +489,9 @@ order.setOrderRemark(appPlaceOrderDto.getOrderRemark()); order.setGoodsNum(goodsNum); order.setCreateTime(new Date()); + // 保存订单 this.save(order); - //更新用户商品类型 + // 更新用户商品类型 if (goodsTypeSet != null && goodsTypeSet.size() > 0) { AppMemberGoodsTypeDto appMemberGoodsTypeDto = new AppMemberGoodsTypeDto(); appMemberGoodsTypeDto.setUserId(userId); @@ -392,12 +500,195 @@ } appPlaceOrderVo.setOrderId(orderId); appPlaceOrderVo.setOrderNo(orderNo); - - //调用支付 - - + // 调用支付 return appPlaceOrderVo; } + + /** + * @param appPlaceActivityDto + * @return AppPlaceOrderVo + * @description 创建活动订单 + * @author jqs + * @date 2023/7/6 17:59 + */ + @Override + public AppPlaceOrderVo placeActivityOrder(AppPlaceActivityDto appPlaceActivityDto) { + Long userId = appPlaceActivityDto.getUserId(); + // 创建订单对象 + AppPlaceOrderVo appPlaceOrderVo = new AppPlaceOrderVo(); + // 定义商品订单对象 + AppSureOrderGoodsVo appSureOrderGoodsVo; + // 获取活动ID,商品ID,购买数量 + String activityId = appPlaceActivityDto.getActivityId(); + String goodsId = appPlaceActivityDto.getGoodsId(); + Integer buyNum = appPlaceActivityDto.getBuyNum(); + // 定义购买数量,服务数量,商品数量 + BigDecimal buyNumBig; + Integer serviceNum; + Integer goodsNum = 0; + // 定义商品,商品文件,商品价格,商品总价,商品实际价格,折扣金额,折扣百分比,商品押金,使用优惠券,订单商品金额,优惠券折扣,订单支付押金,订单支付金额 + Goods goods; + GoodsFile goodsFile; + BigDecimal goodsPrice; + BigDecimal goodsTotalPrice; + BigDecimal goodsRealPrice; + BigDecimal discountMoney = new BigDecimal("0.00"); + BigDecimal discountPercent; + BigDecimal goodsDeposit; + Integer useCoupon; + BigDecimal orderGoodsMoney = new BigDecimal("0.00"); + BigDecimal couponDiscount = new BigDecimal("0.00"); + BigDecimal orderPayDeposit = new BigDecimal("0.00"); + BigDecimal orderPayMoney = new BigDecimal("0.00"); + // 创建活动商品对象,并设置活动ID,商品ID,用户ID + ActivityGoodsGetDto activityGoodsGetDto = new ActivityGoodsGetDto(); + activityGoodsGetDto.setActivityId(activityId); + activityGoodsGetDto.setGoodsId(goodsId); + activityGoodsGetDto.setUserId(userId); + // 获取用户活动商品 + ActivityGoodsGetVo activityGoodsGetVo = remoteActivityService.getUserActivityGoods(activityGoodsGetDto).getData(); + // 检查活动状态 + if (activityGoodsGetVo.getActivityStatus() == 0) { + throw new ServiceException(AppErrorConstant.ACTIVITY_NO_START); + } + if (activityGoodsGetVo.getActivityStatus() == 2) { + throw new ServiceException(AppErrorConstant.ACTIVITY_END); + } + if (activityGoodsGetVo.getAvailableBuyNum() < 1) { + throw new ServiceException(AppErrorConstant.ACTIVITY_GOODS_NULL); + } + // 创建订单ID和订单号 + String orderId = IdUtils.simpleUUID(); + String orderNo = CodeFactoryUtil.getShopOrderNo(); + // 创建订单商品对象和订单商品ID + OrderGoods orderGoods; + String orderGoodsId; + // 创建商品类型集合 + HashSet<String> goodsTypeSet = new HashSet<>(); + // 创建商品订单对象,并设置商品ID,商品名称,商品介绍,商品类型 + appSureOrderGoodsVo = new AppSureOrderGoodsVo(); + useCoupon = 0; + goodsId = appPlaceActivityDto.getGoodsId(); + goods = remoteGoodsService.getGoods(goodsId).getData(); + appSureOrderGoodsVo.setGoodsId(goodsId); + appSureOrderGoodsVo.setGoodsName(goods.getGoodsName()); + appSureOrderGoodsVo.setGoodsIntroduction(goods.getGoodsIntroduction()); + appSureOrderGoodsVo.setGoodsType(goods.getGoodsType()); + // 获取商品图片 + goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData(); + appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl()); + // 设置购买数量,商品价格,服务数量 + appSureOrderGoodsVo.setBuyNum(buyNum); + goodsPrice = goods.getSalesPrice(); + serviceNum = goods.getServiceNum(); + // 获取活动价格 + goodsPrice = activityGoodsGetVo.getActivityPrice(); + appSureOrderGoodsVo.setGoodsPrice(goodsPrice); + // 计算商品总价,商品实际价格 + buyNumBig = BigDecimal.valueOf(buyNum); + goodsTotalPrice = goodsPrice.multiply(buyNumBig); + goodsRealPrice = goodsTotalPrice; + // 设置使用优惠券,商品总价,优惠券折扣,商品实际价格 + appSureOrderGoodsVo.setUseCoupon(useCoupon); + appSureOrderGoodsVo.setGoodsTotalPrice(goodsTotalPrice); + appSureOrderGoodsVo.setCouponDiscount(discountMoney); + appSureOrderGoodsVo.setGoodsRealPrice(goodsRealPrice); + // 获取商品押金 + goodsDeposit = activityGoodsGetVo.getActivitySubscription(); + if (goodsDeposit == null) { + goodsDeposit = new BigDecimal("0.00"); + } + appSureOrderGoodsVo.setGoodsDeposit(goodsDeposit); + // 计算商品数量,订单商品金额,优惠券折扣,订单支付押金,订单支付金额 + goodsNum = goodsNum + buyNum; + orderGoodsMoney = orderGoodsMoney.add(goodsTotalPrice); + couponDiscount = couponDiscount.add(discountMoney); + orderPayDeposit = orderPayDeposit.add(goodsDeposit); + orderPayMoney = orderPayMoney.add(goodsRealPrice); + // 创建订单商品,并设置订单商品ID,删除标志,订单ID,商品ID,购买数量,商品价格,商品押金,商品总金额,商品应收金额,周期数量标志,服务数量,商品类型,商品名称,商品图片 + orderGoods = new OrderGoods(); + orderGoodsId = IdUtils.simpleUUID(); + orderGoods.setOrderGoodsId(orderGoodsId); + orderGoods.setDelFlag(0); + orderGoods.setOrderId(orderId); + orderGoods.setGoodsId(goodsId); + orderGoods.setBuyNum(buyNum); + orderGoods.setGoodsPrice(goodsPrice); + orderGoods.setGoodsDeposit(goodsDeposit); + orderGoods.setGoodsTotalMoney(orderGoodsMoney); + orderGoods.setGoodsReceivableMoney(goodsRealPrice); + orderGoods.setCycleNumFlag(goods.getCycleNumFlag()); + orderGoods.setServiceNum(serviceNum); + orderGoods.setGoodsType(goods.getGoodsType()); + orderGoods.setGoodsName(goods.getGoodsName()); + orderGoods.setGoodsPicture(goodsFile.getFileUrl()); + // 保存订单商品 + orderGoodsService.save(orderGoods); + // 清空购物车 + AppShoppingCartDelDto appShoppingCartDelDto = new AppShoppingCartDelDto(); + appShoppingCartDelDto.setGoodsId(goodsId); + appShoppingCartDelDto.setUserId(userId); + remoteShoppingCartService.deleteShoppingCart(appShoppingCartDelDto); + // 根据商品类型添加到商品类型集合中 + if (goods.getGoodsType() == 1) { + goodsTypeSet.add("周期"); + } else if (goods.getGoodsType() == 2) { + goodsTypeSet.add("服务"); + } else if (goods.getGoodsType() == 3) { + goodsTypeSet.add("体验"); + } else if (goods.getGoodsType() == 4) { + goodsTypeSet.add("单品"); + } + // 创建订单,并设置订单ID,删除标志,订单状态,订单号,订单来源,店铺ID,用户ID,订单金额,优惠券金额,折扣金额,应收金额,应收押金,变动应收金额,支付类型 + Order order = new Order(); + order.setOrderId(orderId); + order.setDelFlag(0); + order.setOrderStatus(1); + order.setOrderNo(orderNo); + order.setOrderFrom(1); + order.setShopId(appPlaceActivityDto.getShopId()); + order.setUserId(userId); + order.setOrderMoney(orderGoodsMoney); + order.setCouponMoney(couponDiscount); + order.setDiscountMoney(couponDiscount); + order.setReceivableMoney(orderPayMoney); + order.setReceivableDeposit(orderPayDeposit); + order.setChangeReceivableMoney(orderPayMoney); + order.setPayType(appPlaceActivityDto.getPayType()); + // 根据支付类型设置订单支付金额,在线支付金额,订单支付金额,未支付金额,关闭标志 + if (order.getPayType() == 1) { + order.setPayMoney(orderPayMoney); + order.setOnlinePayMoney(orderPayMoney); + appPlaceOrderVo.setPayMoney(orderPayMoney); + appPlaceOrderVo.setUnpaidMoney(order.getReceivableMoney().subtract(order.getPayMoney())); + order.setCloseFlag(1); + } else if (order.getPayType() == 2) { + order.setPayMoney(orderPayDeposit); + order.setOnlinePayMoney(orderPayDeposit); + appPlaceOrderVo.setPayMoney(orderPayDeposit); + appPlaceOrderVo.setUnpaidMoney(order.getReceivableMoney().subtract(order.getPayMoney())); + order.setCloseFlag(0); + } + // 设置订单备注,商品数量,创建时间 + order.setOrderRemark(appPlaceActivityDto.getOrderRemark()); + order.setGoodsNum(goodsNum); + order.setCreateTime(new Date()); + // 保存订单 + this.save(order); + // 更新用户商品类型 + if (goodsTypeSet != null && goodsTypeSet.size() > 0) { + AppMemberGoodsTypeDto appMemberGoodsTypeDto = new AppMemberGoodsTypeDto(); + appMemberGoodsTypeDto.setUserId(userId); + appMemberGoodsTypeDto.setGoodsTypeSet(goodsTypeSet); + remoteMemberService.updateMemberGoodsType(appMemberGoodsTypeDto); + } + // 设置订单ID和订单号 + appPlaceOrderVo.setOrderId(orderId); + appPlaceOrderVo.setOrderNo(orderNo); + // 调用支付 + return appPlaceOrderVo; + } + /** * 分页获取用户订单 @@ -529,15 +820,15 @@ * @return */ @Override - public MerVerifyOrderVo verifyOrder(String orderId,Long shopId) { + public MerVerifyOrderVo verifyOrder(String orderId, Long shopId) { // 创建返回对象 MerVerifyOrderVo merVerifyOrderVo = new MerVerifyOrderVo(); // 根据订单ID获取订单信息 Order order = this.getById(orderId); - if(order.getOrderStatus()!=2){ + if (order.getOrderStatus() != 2) { throw new ServiceException(AppErrorConstant.VERIFY_USED); } - if(!order.getShopId().equals(shopId)){ + if (!order.getShopId().equals(shopId)) { throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); } // 根据订单ID获取订单商品列表 @@ -580,7 +871,7 @@ Date nowTime = new Date(); //更新订单信息 Order order = this.getById(orderId); - if(order.getOrderStatus()!=2){ + if (order.getOrderStatus() != 2) { throw new ServiceException(AppErrorConstant.VERIFY_USED); } order.setOrderStatus(3); @@ -605,14 +896,7 @@ ConsumerGoods consumerGoods; String consumerGoodsId; Goods goods; - Integer serviceCount = 0; - Integer cycleService = 0; - Integer cyclePerson = 0; - Integer serviceService = 0; - Integer servicePerson = 0; - Integer experienceService = 0; - Integer experiencePerson = 0; - MerMemberConsumerGoodsTotalVo memberConsumerGoodsTotalVo = consumerGoodsService.getMemberConsumerGoodsTotalVo(order.getUserId(), order.getShopId()); + List<ConsumerGoods> consumerGoodsList = new ArrayList<>(); for (AppUserOrderGoodsPageVo appUserOrderGoodsPageVo : appUserOrderGoodsPageVoList) { consumerGoods = new ConsumerGoods(); goods = goodsMap.get(appUserOrderGoodsPageVo.getGoodsId()); @@ -635,35 +919,9 @@ consumerGoods.setGoodsPicture(appUserOrderGoodsPageVo.getGoodsPicture()); consumerGoods.setGoodsNurses(goods.getGoodsNurses()); consumerGoods.setSourceFrom(1); - consumerGoodsService.save(consumerGoods); - //处理商品服务次数 - if (consumerGoods.getCycleNumFlag() == 1) { - switch (goods.getGoodsType()) { - case 1: - cycleService = cycleService + appUserOrderGoodsPageVo.getServiceNum(); - break; - case 2: - serviceService = serviceService + appUserOrderGoodsPageVo.getServiceNum(); - break; - case 3: - experienceService = experienceService + appUserOrderGoodsPageVo.getServiceNum(); - break; - default: - break; - } - } + consumerGoodsList.add(consumerGoods); } - //判断是否加人 - if (cycleService > 0 && memberConsumerGoodsTotalVo.getCycleOrder() == 0) { - cyclePerson = 1; - } - if (serviceService > 0 && memberConsumerGoodsTotalVo.getServiceOrder() == 0) { - servicePerson = 1; - } - if (experienceService > 0 && memberConsumerGoodsTotalVo.getExperienceOrder() == 0) { - experiencePerson = 1; - } - serviceCount = cycleService + serviceService + experienceService; + consumerGoodsService.saveBatchConsumerGoods(consumerGoodsList); //生成返回 MerVerifyOrderVo merVerifyOrderVo = new MerVerifyOrderVo(); merVerifyOrderVo.setOrderId(orderId); @@ -683,24 +941,6 @@ SysUser sysUser = remoteUserService.getSysUser(order.getUserId()).getData(); merVerifyOrderVo.setUserName(sysUser.getNickName()); merVerifyOrderVo.setUserMobile(sysUser.getPhonenumber()); - //更新商户和会员服务统计 - MemberTotalChangeDto memberTotalChangeDto = new MemberTotalChangeDto(); - memberTotalChangeDto.setUserId(order.getUserId()); - memberTotalChangeDto.setTypeService(1); - memberTotalChangeDto.setServiceCount(serviceCount); - remoteMemberService.changeMemberTotal(memberTotalChangeDto); - ShopTotalChangeDto shopTotalChangeDto = new ShopTotalChangeDto(); - shopTotalChangeDto.setShopId(order.getShopId()); - shopTotalChangeDto.setTypeCycleService(1); - shopTotalChangeDto.setCycleService(cycleService); - shopTotalChangeDto.setCyclePerson(cyclePerson); - shopTotalChangeDto.setTypeServiceService(1); - shopTotalChangeDto.setServiceService(serviceService); - shopTotalChangeDto.setServicePerson(servicePerson); - shopTotalChangeDto.setTypeExperienceService(1); - shopTotalChangeDto.setExperienceService(experienceService); - shopTotalChangeDto.setExperiencePerson(experiencePerson); - remoteShopService.changeShopTotal(shopTotalChangeDto); return merVerifyOrderVo; } @@ -741,6 +981,9 @@ ConsumerGoods consumerGoods; String consumerGoodsId; GoodsFile goodsFile; + AppShopGoodsGetDto appShopGoodsGetDto; + ShopGoods shopGoods; + List<ConsumerGoods> consumerGoodsList = new ArrayList<>(); for (Goods goods : goodsList) { consumerGoods = new ConsumerGoods(); consumerGoodsId = IdUtils.simpleUUID(); @@ -755,6 +998,14 @@ consumerGoods.setGoodsName(goods.getGoodsName()); consumerGoods.setCycleNumFlag(goods.getCycleNumFlag()); consumerGoods.setServiceNum(goods.getServiceNum()); + appShopGoodsGetDto = new AppShopGoodsGetDto(); + appShopGoodsGetDto.setGoodsId(goods.getGoodsId()); + appShopGoodsGetDto.setShopId(memberCoupon.getShopId()); + //获取商户服务次数 + shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); + if(shopGoods!=null){ + consumerGoods.setServiceNum(shopGoods.getServiceNum()); + } consumerGoods.setUsedNum(0); consumerGoods.setGoodsType(goods.getGoodsType()); consumerGoods.setCreateTime(new Date()); @@ -763,8 +1014,9 @@ consumerGoods.setGoodsPicture(goodsFile.getFileUrl()); consumerGoods.setGoodsNurses(goods.getGoodsNurses()); consumerGoods.setSourceFrom(1); - consumerGoodsService.save(consumerGoods); + consumerGoodsList.add(consumerGoods); } + consumerGoodsService.saveBatchConsumerGoods(consumerGoodsList); return merVerifyCouponVo; } @@ -878,6 +1130,7 @@ String orderNo = CodeFactoryUtil.getShopOrderNo(); OrderGoods orderGoods; String orderGoodsId; + GoodsFile goodsFile; BigDecimal cycleMoney = new BigDecimal("0.00"); BigDecimal experienceMoney = new BigDecimal("0.00"); BigDecimal serviceMoney = new BigDecimal("0.00"); @@ -886,6 +1139,7 @@ goodsId = appBuyGoodsDto.getGoodsId(); memberCouponId = appBuyGoodsDto.getMemberCouponId(); goods = remoteGoodsService.getGoods(goodsId).getData(); + goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData(); buyNum = appBuyGoodsDto.getBuyNum(); goodsPrice = goods.getSalesPrice(); serviceNum = goods.getServiceNum(); @@ -949,8 +1203,10 @@ orderGoods.setCycleNumFlag(goods.getCycleNumFlag()); orderGoods.setServiceNum(serviceNum); orderGoods.setGoodsType(goods.getGoodsType()); + orderGoods.setGoodsName(goods.getGoodsName()); + orderGoods.setGoodsPicture(goodsFile.getFileUrl()); orderGoodsService.save(orderGoods); - switch(orderGoods.getGoodsType()){ + switch (orderGoods.getGoodsType()) { case 1: cycleMoney = cycleMoney.add(orderGoods.getGoodsReceivableMoney()); break; @@ -982,9 +1238,9 @@ order.setReceivableMoney(orderPayMoney); order.setReceivableDeposit(new BigDecimal("0.00")); order.setPayType(1); - if(merNewOrderDto.getChangeMoney()!=null){ + if (merNewOrderDto.getChangeMoney() != null) { order.setChangeReceivableMoney(merNewOrderDto.getChangeMoney()); - }else{ + } else { order.setChangeReceivableMoney(orderPayMoney); } order.setPayMoney(orderPayMoney); @@ -1361,7 +1617,7 @@ //处理商品信息 List<MgtOrderGoodsPageVo> mgtOrderGoodsVoList; String goodsString; - for(MgtShopOrderPageVo entity : shopOrderPageVoList){ + for (MgtShopOrderPageVo entity : shopOrderPageVoList) { mgtOrderGoodsVoList = entity.getMgtOrderGoodsPageVoList(); goodsString = mgtOrderGoodsVoList.stream() .map(goods -> goods.getGoodsName() + "*" + goods.getBuyNum()) @@ -2019,7 +2275,7 @@ * @date 2023/6/27 11:10 */ @Override - public MerVerifyCouponVo verifyCoupon(String verifyCode,Long shopId) { + public MerVerifyCouponVo verifyCoupon(String verifyCode, Long shopId) { // 创建MerVerifyCouponVo对象 MerVerifyCouponVo merVerifyCouponVo = new MerVerifyCouponVo(); // 调用remoteCouponService的getVerifyCoupon方法获取MerVerifyCouponGetVo对象 @@ -2034,7 +2290,7 @@ } else if (couponStatus != 0) { throw new ServiceException(AppErrorConstant.COUPON_NO_FIND); } - if(!memberCoupon.getShopId().equals(shopId)){ + if (!memberCoupon.getShopId().equals(shopId)) { throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); } List<Goods> goodsList = verifyCouponGetVo.getGoodsList(); @@ -2060,33 +2316,33 @@ } /** - * @description 获取用户未支付金额 - * @author jqs - * @date 2023/6/29 18:00 * @param merBaseDto - * @return BigDecimal + * @return BigDecimal + * @description 获取用户未支付金额 + * @author jqs + * @date 2023/6/29 18:00 */ @Override - public BigDecimal getMemberUnpaidOrder(MerBaseDto merBaseDto){ + public BigDecimal getMemberUnpaidOrder(MerBaseDto merBaseDto) { BigDecimal unpaidMoney = orderMapper.getMemberUnpaidOrder(merBaseDto); return unpaidMoney; } /** - * @description 商户获取订单统计 - * @author jqs - * @date 2023/7/3 19:29 * @param merTotalDto - * @return MerOrderTotalVo + * @return MerOrderTotalVo + * @description 商户获取订单统计 + * @author jqs + * @date 2023/7/3 19:29 */ @Override - public MerOrderTotalVo getMerOrderTotal(MerTotalDto merTotalDto){ - if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){ + public MerOrderTotalVo getMerOrderTotal(MerTotalDto merTotalDto) { + if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) { List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData(); merTotalDto.setShopIdList(shopIdList); merTotalDto.setShopId(null); } - if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){ + if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) { List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData(); merTotalDto.setShopIdList(shopIdList); merTotalDto.setShopId(null); @@ -2097,15 +2353,15 @@ /** - * @description - * @author jqs - * @date 2023/7/4 9:29 * @param merTotalDto - * @return MerOrderDistributionTotalVo + * @return MerOrderDistributionTotalVo + * @description + * @author jqs + * @date 2023/7/4 9:29 */ @Override - public MerOrderDistributionTotalVo MerOrderDistributionTotalVo(MerTotalDto merTotalDto){ - if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){ + public MerOrderDistributionTotalVo MerOrderDistributionTotalVo(MerTotalDto merTotalDto) { + if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) { List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData(); merTotalDto.setShopIdList(shopIdList); merTotalDto.setShopId(null); @@ -2166,15 +2422,15 @@ } /** - * @description 商户获取销售占比统计 - * @author jqs - * @date 2023/7/4 13:58 * @param merTotalDto - * @return MerOrderTypeTotalVo + * @return MerOrderTypeTotalVo + * @description 商户获取销售占比统计 + * @author jqs + * @date 2023/7/4 13:58 */ @Override - public MerOrderTypeTotalVo getMerOrderTypeTotal(MerTotalDto merTotalDto){ - if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){ + public MerOrderTypeTotalVo getMerOrderTypeTotal(MerTotalDto merTotalDto) { + if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) { List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData(); merTotalDto.setShopIdList(shopIdList); merTotalDto.setShopId(null); @@ -2217,15 +2473,15 @@ /** - * @description 商户端获取销售排行 - * @author jqs - * @date 2023/7/4 14:23 * @param merTotalDto - * @return MerOrderGoodsRankVo + * @return MerOrderGoodsRankVo + * @description 商户端获取销售排行 + * @author jqs + * @date 2023/7/4 14:23 */ @Override - public MerOrderGoodsRankVo getMerOrderGoodsRank(MerTotalDto merTotalDto){ - if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){ + public MerOrderGoodsRankVo getMerOrderGoodsRank(MerTotalDto merTotalDto) { + if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) { List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData(); merTotalDto.setShopIdList(shopIdList); merTotalDto.setShopId(null); @@ -2241,15 +2497,15 @@ /** - * @description 商户端获取渠道排行 - * @author jqs - * @date 2023/7/4 14:51 * @param merTotalDto - * @return MerOrderFromRankVo + * @return MerOrderFromRankVo + * @description 商户端获取渠道排行 + * @author jqs + * @date 2023/7/4 14:51 */ @Override - public MerOrderFromRankVo getMerOrderFromRank(MerTotalDto merTotalDto){ - if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){ + public MerOrderFromRankVo getMerOrderFromRank(MerTotalDto merTotalDto) { + if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) { List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData(); merTotalDto.setShopIdList(shopIdList); merTotalDto.setShopId(null); @@ -2265,29 +2521,29 @@ } /** - * @description 商户端订单管理统计 - * @author jqs - * @date 2023/7/4 16:27 * @param merBaseDto - * @return MerTotalOrderVo + * @return MerTotalOrderVo + * @description 商户端订单管理统计 + * @author jqs + * @date 2023/7/4 16:27 */ @Override - public MerTotalOrderVo totalMerOrder(MerBaseDto merBaseDto){ + public MerTotalOrderVo totalMerOrder(MerBaseDto merBaseDto) { return orderMapper.totalMerOrder(merBaseDto.getShopId()); } /** - * @description 平台获取商户订单记录 - * @author jqs - * @date 2023/7/5 20:17 * @param page * @param mgtShopAllOrderPageDto - * @return List<MgtShopAllOrderPageVo> + * @return List<MgtShopAllOrderPageVo> + * @description 平台获取商户订单记录 + * @author jqs + * @date 2023/7/5 20:17 */ @Override - public List<MgtShopAllOrderPageVo> pageMgtShopAllOrder(Page page, MgtShopAllOrderPageDto mgtShopAllOrderPageDto){ + public List<MgtShopAllOrderPageVo> pageMgtShopAllOrder(Page page, MgtShopAllOrderPageDto mgtShopAllOrderPageDto) { List<MgtShopAllOrderPageVo> shopAllOrderPageVoList = orderMapper.pageMgtShopAllOrder(page, mgtShopAllOrderPageDto); - if(!shopAllOrderPageVoList.isEmpty()){ + if (!shopAllOrderPageVoList.isEmpty()) { // 定义变量 HashSet<Long> userIdSet = new HashSet<>(); BigDecimal zeroBig = new BigDecimal("0.00"); @@ -2306,17 +2562,24 @@ .collect(Collectors.toMap(MgtSimpleMemberVo::getUserId, Function.identity())); } // 遍历列表,设置店铺名称、用户名称和未支付金额 + String userInfo; + String mobile; for (MgtShopAllOrderPageVo mgtShopOrderPageVo : shopAllOrderPageVoList) { if (userMap != null && !userMap.isEmpty()) { if (userMap.get(mgtShopOrderPageVo.getUserId()) != null) { - mgtShopOrderPageVo.setUserInfo(userMap.get(mgtShopOrderPageVo.getUserId()).getNickName()+"("+userMap.get(mgtShopOrderPageVo.getUserId()).getUserMobile()+")"); + userInfo = userMap.get(mgtShopOrderPageVo.getUserId()).getNickName(); + mobile = userMap.get(mgtShopOrderPageVo.getUserId()).getUserMobile(); + if (StringUtils.isNotBlank(mobile)) { + userInfo = userInfo + "(" + mobile + ")"; + } + mgtShopOrderPageVo.setUserInfo(userInfo); } } } //处理商品信息 List<MgtOrderGoodsPageVo> mgtOrderGoodsVoList; String goodsString; - for(MgtShopAllOrderPageVo entity : shopAllOrderPageVoList){ + for (MgtShopAllOrderPageVo entity : shopAllOrderPageVoList) { mgtOrderGoodsVoList = entity.getMgtOrderGoodsPageVoList(); goodsString = mgtOrderGoodsVoList.stream() .map(goods -> goods.getGoodsName() + "*" + goods.getBuyNum()) -- Gitblit v1.7.1