| | |
| | | } |
| | | |
| | | /** |
| | | * @description 抢购商品 |
| | | * @author jqs |
| | | * @date 2023/7/6 11:45 |
| | | * @param appPanicBuyDto |
| | | * @return AppSureOrderVo |
| | | * @return AppSureOrderVo |
| | | * @description 抢购商品 |
| | | * @author jqs |
| | | * @date 2023/7/6 11:45 |
| | | */ |
| | | @Override |
| | | public AppPanicBuyVo panicBuyGoods(AppPanicBuyDto appPanicBuyDto){ |
| | | public AppPanicBuyVo panicBuyGoods(AppPanicBuyDto appPanicBuyDto) { |
| | | Long userId = appPanicBuyDto.getUserId(); |
| | | AppPanicBuyVo appPanicBuyVo = new AppPanicBuyVo(); |
| | | String activityId = appPanicBuyDto.getActivityId(); |
| | |
| | | activityGoodsGetDto.setGoodsId(goodsId); |
| | | activityGoodsGetDto.setUserId(userId); |
| | | ActivityGoodsGetVo activityGoodsGetVo = remoteActivityService.getUserActivityGoods(activityGoodsGetDto).getData(); |
| | | if(activityGoodsGetVo.getActivityStatus()==0){ |
| | | if (activityGoodsGetVo.getActivityStatus() == 0) { |
| | | throw new ServiceException(AppErrorConstant.ACTIVITY_NO_START); |
| | | } |
| | | if(activityGoodsGetVo.getActivityStatus()==2){ |
| | | if (activityGoodsGetVo.getActivityStatus() == 2) { |
| | | throw new ServiceException(AppErrorConstant.ACTIVITY_END); |
| | | } |
| | | if(activityGoodsGetVo.getAvailableBuyNum()<1){ |
| | | if (activityGoodsGetVo.getAvailableBuyNum() < 1) { |
| | | throw new ServiceException(AppErrorConstant.ACTIVITY_GOODS_NULL); |
| | | } |
| | | Goods goods = remoteGoodsService.getGoods(goodsId).getData(); |
| | |
| | | */ |
| | | @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; |
| | |
| | | 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; |
| | |
| | | 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) { |
| | |
| | | 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); |
| | |
| | | orderGoods.setCouponId(memberCouponId.toString()); |
| | | } |
| | | orderGoods.setGoodsPrice(goodsPrice); |
| | | orderGoods.setGoodsDeposit(goodsDeposit); |
| | | orderGoods.setGoodsTotalMoney(orderGoodsMoney); |
| | | orderGoods.setGoodsReceivableMoney(goodsRealPrice); |
| | | orderGoods.setCycleNumFlag(goods.getCycleNumFlag()); |
| | |
| | | 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("单品"); |
| | | } |
| | | } |
| | | // 创建订单 |
| | | Order order = new Order(); |
| | | order.setOrderId(orderId); |
| | | order.setDelFlag(0); |
| | | //为对接支付 直接付款成功 |
| | | order.setOrderStatus(1); |
| | | order.setOrderNo(orderNo); |
| | | order.setOrderFrom(1); |
| | |
| | | order.setReceivableDeposit(orderPayDeposit); |
| | | order.setChangeReceivableMoney(orderPayMoney); |
| | | order.setPayType(appPlaceOrderDto.getPayType()); |
| | | // 根据支付类型计算支付金额 |
| | | if (order.getPayType() == 1) { |
| | | order.setPayMoney(orderPayMoney); |
| | | order.setOnlinePayMoney(orderPayMoney); |
| | |
| | | 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); |
| | |
| | | } |
| | | appPlaceOrderVo.setOrderId(orderId); |
| | | appPlaceOrderVo.setOrderNo(orderNo); |
| | | |
| | | //调用支付 |
| | | |
| | | |
| | | // 调用支付 |
| | | return appPlaceOrderVo; |
| | | } |
| | | |
| | | /** |
| | | * @description 创建活动订单 |
| | | * @author jqs |
| | | * @date 2023/7/6 17:59 |
| | | * @param appPlaceActivityDto |
| | | * @return AppPlaceOrderVo |
| | | * @return AppPlaceOrderVo |
| | | * @description 创建活动订单 |
| | | * @author jqs |
| | | * @date 2023/7/6 17:59 |
| | | */ |
| | | @Override |
| | | public AppPlaceOrderVo placeActivityOrder( AppPlaceActivityDto appPlaceActivityDto){ |
| | | 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 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){ |
| | | // 检查活动状态 |
| | | if (activityGoodsGetVo.getActivityStatus() == 0) { |
| | | throw new ServiceException(AppErrorConstant.ACTIVITY_NO_START); |
| | | } |
| | | if(activityGoodsGetVo.getActivityStatus()==2){ |
| | | if (activityGoodsGetVo.getActivityStatus() == 2) { |
| | | throw new ServiceException(AppErrorConstant.ACTIVITY_END); |
| | | } |
| | | if(activityGoodsGetVo.getAvailableBuyNum()<1){ |
| | | 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(); |
| | |
| | | appSureOrderGoodsVo.setGoodsName(goods.getGoodsName()); |
| | | appSureOrderGoodsVo.setGoodsIntroduction(goods.getGoodsIntroduction()); |
| | | appSureOrderGoodsVo.setGoodsType(goods.getGoodsType()); |
| | | //商品图片 |
| | | // 获取商品图片 |
| | | goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData(); |
| | | appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl()); |
| | | buyNum = appPlaceActivityDto.getBuyNum(); |
| | | // 设置购买数量,商品价格,服务数量 |
| | | 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 = goods.getSubscription(); |
| | | // 获取商品押金 |
| | | 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); |
| | | //创建OrderGoods |
| | | // 创建订单商品,并设置订单商品ID,删除标志,订单ID,商品ID,购买数量,商品价格,商品押金,商品总金额,商品应收金额,周期数量标志,服务数量,商品类型,商品名称,商品图片 |
| | | orderGoods = new OrderGoods(); |
| | | orderGoodsId = IdUtils.simpleUUID(); |
| | | orderGoods.setOrderGoodsId(orderGoodsId); |
| | |
| | | orderGoods.setGoodsId(goodsId); |
| | | orderGoods.setBuyNum(buyNum); |
| | | orderGoods.setGoodsPrice(goodsPrice); |
| | | orderGoods.setGoodsDeposit(goodsDeposit); |
| | | orderGoods.setGoodsTotalMoney(orderGoodsMoney); |
| | | orderGoods.setGoodsReceivableMoney(goodsRealPrice); |
| | | orderGoods.setCycleNumFlag(goods.getCycleNumFlag()); |
| | |
| | | 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) { |
| | |
| | | } 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.setReceivableDeposit(orderPayDeposit); |
| | | order.setChangeReceivableMoney(orderPayMoney); |
| | | order.setPayType(appPlaceActivityDto.getPayType()); |
| | | // 根据支付类型设置订单支付金额,在线支付金额,订单支付金额,未支付金额,关闭标志 |
| | | if (order.getPayType() == 1) { |
| | | order.setPayMoney(orderPayMoney); |
| | | order.setOnlinePayMoney(orderPayMoney); |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | * @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获取订单商品列表 |
| | |
| | | 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); |
| | |
| | | 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()); |
| | |
| | | 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); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | 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()); |
| | |
| | | consumerGoods.setGoodsPicture(goodsFile.getFileUrl()); |
| | | consumerGoods.setGoodsNurses(goods.getGoodsNurses()); |
| | | consumerGoods.setSourceFrom(1); |
| | | consumerGoodsService.save(consumerGoods); |
| | | consumerGoodsList.add(consumerGoods); |
| | | } |
| | | consumerGoodsService.saveBatchConsumerGoods(consumerGoodsList); |
| | | return merVerifyCouponVo; |
| | | } |
| | | |
| | |
| | | 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; |
| | |
| | | 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); |
| | |
| | | //处理商品信息 |
| | | 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()) |
| | |
| | | * @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对象 |
| | |
| | | } 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(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @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); |
| | |
| | | |
| | | |
| | | /** |
| | | * @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); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @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); |
| | |
| | | |
| | | |
| | | /** |
| | | * @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); |
| | |
| | | |
| | | |
| | | /** |
| | | * @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); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @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"); |
| | |
| | | if (userMap.get(mgtShopOrderPageVo.getUserId()) != null) { |
| | | userInfo = userMap.get(mgtShopOrderPageVo.getUserId()).getNickName(); |
| | | mobile = userMap.get(mgtShopOrderPageVo.getUserId()).getUserMobile(); |
| | | if(StringUtils.isNotBlank(mobile)){ |
| | | 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()) |