| | |
| | | import com.ruoyi.system.api.domain.poji.shop.Shop; |
| | | import com.ruoyi.system.api.domain.poji.sys.SysUser; |
| | | import com.ruoyi.system.api.domain.vo.AppOrderTotalVo; |
| | | import com.ruoyi.system.api.domain.vo.AppUserCouponVo; |
| | | import com.ruoyi.system.api.domain.vo.AppMemberCouponVo; |
| | | import com.ruoyi.order.mapper.order.OrderMapper; |
| | | import com.ruoyi.order.service.order.OrderService; |
| | | import com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo; |
| | |
| | | String goodsId; |
| | | Integer buyNum; |
| | | BigDecimal buyNumBig; |
| | | Long userCouponId; |
| | | Long memberCouponId; |
| | | Goods goods; |
| | | BigDecimal goodsPrice; |
| | | BigDecimal goodsTotalPrice; |
| | | BigDecimal goodsRealPrice; |
| | | List<AppUserCouponVo> appUserCouponVoList = remoteMemberService.listVoUserCouponByUserId(userId).getData(); |
| | | List<AppUserCouponVo> appGoodsUserCouponVoList; |
| | | Map<Long,AppUserCouponVo> appUserCouponVoMap = appUserCouponVoList.stream().collect(Collectors.toMap(AppUserCouponVo::getUserCouponId, Function.identity())); |
| | | AppUserCouponVo appUserCouponVo; |
| | | List<AppMemberCouponVo> appMemberCouponVoList = remoteMemberService.listVoMemberCouponByUserId(userId).getData(); |
| | | List<AppMemberCouponVo> appGoodsMemberCouponVoList; |
| | | Map<Long,AppMemberCouponVo> appMemberCouponVoMap = appMemberCouponVoList.stream().collect(Collectors.toMap(AppMemberCouponVo::getMemberCouponId, Function.identity())); |
| | | AppMemberCouponVo appMemberCouponVo; |
| | | Integer couponType; |
| | | BigDecimal moneyThreshold; |
| | | BigDecimal discountMoney = new BigDecimal("0.00"); |
| | |
| | | useCoupon = 0; |
| | | goodsId = appBuyGoodsDto.getGoodsId(); |
| | | buyNum = appBuyGoodsDto.getBuyNum(); |
| | | userCouponId = appBuyGoodsDto.getUserCouponId(); |
| | | memberCouponId = appBuyGoodsDto.getMemberCouponId(); |
| | | goods = remoteGoodsService.getGoods(goodsId).getData(); |
| | | appSureOrderGoodsVo.setGoodsId(goodsId); |
| | | appSureOrderGoodsVo.setGoodsName(goods.getGoodsName()); |
| | |
| | | buyNumBig = BigDecimal.valueOf(buyNum); |
| | | goodsTotalPrice = goodsPrice.multiply(buyNumBig); |
| | | goodsRealPrice = goodsTotalPrice; |
| | | if(userCouponId!=null){ |
| | | appUserCouponVo = appUserCouponVoMap.get(userCouponId); |
| | | if(StringUtils.isBlank(appUserCouponVo.getRelGoodsIds()) || appUserCouponVo.getRelGoodsIds().contains(goodsId)){ |
| | | couponType = appUserCouponVo.getCouponType(); |
| | | if(couponType == 1 && appUserCouponVo.getMoneyThreshold()!=null && appUserCouponVo.getDiscountMoney()!=null){ |
| | | moneyThreshold = appUserCouponVo.getMoneyThreshold(); |
| | | 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){ |
| | | discountMoney = appUserCouponVo.getDiscountMoney(); |
| | | discountMoney = appMemberCouponVo.getDiscountMoney(); |
| | | goodsRealPrice = goodsTotalPrice.subtract(discountMoney); |
| | | useCoupon = 1; |
| | | } |
| | | }else if(couponType == 2 && appUserCouponVo.getDiscountPercent()!=null){ |
| | | discountPercent = appUserCouponVo.getDiscountPercent(); |
| | | }else if(couponType == 2 && appMemberCouponVo.getDiscountPercent()!=null){ |
| | | discountPercent = appMemberCouponVo.getDiscountPercent(); |
| | | goodsRealPrice = goodsTotalPrice.multiply(discountPercent).divide(BigDecimal.TEN).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | discountMoney = goodsRealPrice.subtract(goodsTotalPrice); |
| | | useCoupon = 1; |
| | | }else if(couponType == 3 && appUserCouponVo.getDiscountMoney()!=null){ |
| | | discountMoney = appUserCouponVo.getDiscountMoney(); |
| | | }else if(couponType == 3 && appMemberCouponVo.getDiscountMoney()!=null){ |
| | | discountMoney = appMemberCouponVo.getDiscountMoney(); |
| | | goodsRealPrice = goodsTotalPrice.subtract(discountMoney); |
| | | useCoupon = 1; |
| | | } |
| | |
| | | orderPayDeposit = orderPayDeposit.add(goodsDeposit); |
| | | orderPayMoney = orderPayMoney.add(goodsRealPrice); |
| | | //商品关联优惠券 |
| | | appGoodsUserCouponVoList = new ArrayList<>(); |
| | | if(appUserCouponVoList!=null && !appUserCouponVoList.isEmpty()){ |
| | | for(AppUserCouponVo entity : appUserCouponVoList){ |
| | | appGoodsMemberCouponVoList = new ArrayList<>(); |
| | | if(appMemberCouponVoList!=null && !appMemberCouponVoList.isEmpty()){ |
| | | for(AppMemberCouponVo entity : appMemberCouponVoList){ |
| | | if(StringUtils.isBlank(entity.getRelGoodsIds())){ |
| | | appGoodsUserCouponVoList.add(entity); |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else if(entity.getRelGoodsIds().contains(goodsId)){ |
| | | appGoodsUserCouponVoList.add(entity); |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | | appSureOrderGoodsVo.setAppUserCouponVoList(appGoodsUserCouponVoList); |
| | | appSureOrderGoodsVo.setAppMemberCouponVoList(appGoodsMemberCouponVoList); |
| | | } |
| | | appSureOrderGoodsVoList.add(appSureOrderGoodsVo); |
| | | } |
| | |
| | | BigDecimal buyNumBig; |
| | | Integer serviceNum; |
| | | Integer goodsNum = 0; |
| | | Long userCouponId; |
| | | Long memberCouponId; |
| | | Goods goods; |
| | | BigDecimal goodsPrice; |
| | | BigDecimal goodsTotalPrice; |
| | | BigDecimal goodsRealPrice; |
| | | List<AppUserCouponVo> appUserCouponVoList = remoteMemberService.listVoUserCouponByUserId(userId).getData(); |
| | | Map<Long,AppUserCouponVo> appUserCouponVoMap = appUserCouponVoList.stream().collect(Collectors.toMap(AppUserCouponVo::getUserCouponId, Function.identity())); |
| | | AppUserCouponVo appUserCouponVo; |
| | | List<AppMemberCouponVo> appMemberCouponVoList = remoteMemberService.listVoMemberCouponByUserId(userId).getData(); |
| | | Map<Long,AppMemberCouponVo> appMemberCouponVoMap = appMemberCouponVoList.stream().collect(Collectors.toMap(AppMemberCouponVo::getMemberCouponId, Function.identity())); |
| | | AppMemberCouponVo appMemberCouponVo; |
| | | Integer couponType; |
| | | BigDecimal moneyThreshold; |
| | | BigDecimal discountMoney = new BigDecimal("0.00"); |
| | |
| | | appSureOrderGoodsVo = new AppSureOrderGoodsVo(); |
| | | useCoupon = 0; |
| | | goodsId = appBuyGoodsDto.getGoodsId(); |
| | | userCouponId = appBuyGoodsDto.getUserCouponId(); |
| | | memberCouponId = appBuyGoodsDto.getMemberCouponId(); |
| | | goods = remoteGoodsService.getGoods(goodsId).getData(); |
| | | appSureOrderGoodsVo.setGoodsId(goodsId); |
| | | appSureOrderGoodsVo.setGoodsName(goods.getGoodsName()); |
| | |
| | | buyNumBig = BigDecimal.valueOf(buyNum); |
| | | goodsTotalPrice = goodsPrice.multiply(buyNumBig); |
| | | goodsRealPrice = goodsTotalPrice; |
| | | if(userCouponId!=null){ |
| | | appUserCouponVo = appUserCouponVoMap.get(userCouponId); |
| | | if(StringUtils.isBlank(appUserCouponVo.getRelGoodsIds()) || appUserCouponVo.getRelGoodsIds().contains(goodsId)){ |
| | | couponType = appUserCouponVo.getCouponType(); |
| | | if(couponType == 1 && appUserCouponVo.getMoneyThreshold()!=null && appUserCouponVo.getDiscountMoney()!=null){ |
| | | moneyThreshold = appUserCouponVo.getMoneyThreshold(); |
| | | 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){ |
| | | discountMoney = appUserCouponVo.getDiscountMoney(); |
| | | discountMoney = appMemberCouponVo.getDiscountMoney(); |
| | | goodsRealPrice = goodsTotalPrice.subtract(discountMoney); |
| | | useCoupon = 1; |
| | | } |
| | | }else if(couponType == 2 && appUserCouponVo.getDiscountPercent()!=null){ |
| | | discountPercent = appUserCouponVo.getDiscountPercent(); |
| | | }else if(couponType == 2 && appMemberCouponVo.getDiscountPercent()!=null){ |
| | | discountPercent = appMemberCouponVo.getDiscountPercent(); |
| | | goodsRealPrice = goodsTotalPrice.multiply(discountPercent).divide(BigDecimal.TEN).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | discountMoney = goodsRealPrice.subtract(goodsTotalPrice); |
| | | useCoupon = 1; |
| | | }else if(couponType == 3 && appUserCouponVo.getDiscountMoney()!=null){ |
| | | discountMoney = appUserCouponVo.getDiscountMoney(); |
| | | }else if(couponType == 3 && appMemberCouponVo.getDiscountMoney()!=null){ |
| | | discountMoney = appMemberCouponVo.getDiscountMoney(); |
| | | goodsRealPrice = goodsTotalPrice.subtract(discountMoney); |
| | | useCoupon = 1; |
| | | } |
| | |
| | | orderGoods.setOrderId(orderId); |
| | | orderGoods.setGoodsId(goodsId); |
| | | orderGoods.setBuyNum(buyNum); |
| | | if(userCouponId!=null){ |
| | | orderGoods.setCouponId(userCouponId.toString()); |
| | | if(memberCouponId!=null){ |
| | | orderGoods.setCouponId(memberCouponId.toString()); |
| | | } |
| | | orderGoods.setGoodsPrice(goodsPrice); |
| | | orderGoods.setGoodsTotalMoney(orderGoodsMoney); |
| | |
| | | BigDecimal buyNumBig; |
| | | Integer serviceNum; |
| | | Integer goodsNum = 0; |
| | | Long userCouponId; |
| | | Long memberCouponId; |
| | | Goods goods; |
| | | BigDecimal goodsPrice; |
| | | BigDecimal goodsTotalPrice; |
| | | BigDecimal goodsRealPrice; |
| | | List<AppUserCouponVo> appUserCouponVoList = remoteMemberService.listVoUserCouponByUserId(userId).getData(); |
| | | Map<Long,AppUserCouponVo> appUserCouponVoMap = new HashMap<>(); |
| | | if(null != appUserCouponVoList){ |
| | | appUserCouponVoMap = appUserCouponVoList.stream().collect(Collectors.toMap(AppUserCouponVo::getUserCouponId, Function.identity())); |
| | | List<AppMemberCouponVo> appMemberCouponVoList = remoteMemberService.listVoMemberCouponByUserId(userId).getData(); |
| | | Map<Long,AppMemberCouponVo> appMemberCouponVoMap = new HashMap<>(); |
| | | if(null != appMemberCouponVoList){ |
| | | appMemberCouponVoMap = appMemberCouponVoList.stream().collect(Collectors.toMap(AppMemberCouponVo::getMemberCouponId, Function.identity())); |
| | | } |
| | | |
| | | AppUserCouponVo appUserCouponVo; |
| | | AppMemberCouponVo appMemberCouponVo; |
| | | Integer couponType; |
| | | BigDecimal moneyThreshold; |
| | | BigDecimal discountMoney = new BigDecimal("0.00"); |
| | |
| | | String orderGoodsId; |
| | | for(AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList){ |
| | | goodsId = appBuyGoodsDto.getGoodsId(); |
| | | userCouponId = appBuyGoodsDto.getUserCouponId(); |
| | | memberCouponId = appBuyGoodsDto.getMemberCouponId(); |
| | | goods = remoteGoodsService.getGoods(goodsId).getData(); |
| | | buyNum = appBuyGoodsDto.getBuyNum(); |
| | | goodsPrice = goods.getSalesPrice(); |
| | |
| | | buyNumBig = BigDecimal.valueOf(buyNum); |
| | | goodsTotalPrice = goodsPrice.multiply(buyNumBig); |
| | | goodsRealPrice = goodsTotalPrice; |
| | | if(userCouponId!=null){ |
| | | appUserCouponVo = appUserCouponVoMap.get(userCouponId); |
| | | if(null != appUserCouponVo && (StringUtils.isBlank(appUserCouponVo.getRelGoodsIds()) || appUserCouponVo.getRelGoodsIds().contains(goodsId))){ |
| | | couponType = appUserCouponVo.getCouponType(); |
| | | if(couponType == 1 && appUserCouponVo.getMoneyThreshold()!=null && appUserCouponVo.getDiscountMoney()!=null){ |
| | | moneyThreshold = appUserCouponVo.getMoneyThreshold(); |
| | | if(memberCouponId!=null){ |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId); |
| | | if(null != appMemberCouponVo && (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){ |
| | | discountMoney = appUserCouponVo.getDiscountMoney(); |
| | | discountMoney = appMemberCouponVo.getDiscountMoney(); |
| | | goodsRealPrice = goodsTotalPrice.subtract(discountMoney); |
| | | } |
| | | }else if(couponType == 2 && appUserCouponVo.getDiscountPercent()!=null){ |
| | | discountPercent = appUserCouponVo.getDiscountPercent(); |
| | | }else if(couponType == 2 && appMemberCouponVo.getDiscountPercent()!=null){ |
| | | discountPercent = appMemberCouponVo.getDiscountPercent(); |
| | | goodsRealPrice = goodsTotalPrice.multiply(discountPercent).divide(BigDecimal.TEN).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | discountMoney = goodsRealPrice.subtract(goodsTotalPrice); |
| | | }else if(couponType == 3 && appUserCouponVo.getDiscountMoney()!=null){ |
| | | discountMoney = appUserCouponVo.getDiscountMoney(); |
| | | }else if(couponType == 3 && appMemberCouponVo.getDiscountMoney()!=null){ |
| | | discountMoney = appMemberCouponVo.getDiscountMoney(); |
| | | goodsRealPrice = goodsTotalPrice.subtract(discountMoney); |
| | | } |
| | | } |
| | |
| | | orderGoods.setOrderId(orderId); |
| | | orderGoods.setGoodsId(goodsId); |
| | | orderGoods.setBuyNum(buyNum); |
| | | if(null != userCouponId){ |
| | | orderGoods.setCouponId(userCouponId.toString()); |
| | | if(null != memberCouponId){ |
| | | orderGoods.setCouponId(memberCouponId.toString()); |
| | | } |
| | | orderGoods.setGoodsPrice(goodsPrice); |
| | | orderGoods.setGoodsTotalMoney(orderGoodsMoney); |