| | |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.*; |
| | | import cc.mrbird.febs.mall.vo.ApiLeaderListVo; |
| | | import cc.mrbird.febs.mall.vo.OrderDetailVo; |
| | | import cc.mrbird.febs.mall.vo.OrderListVo; |
| | | import cc.mrbird.febs.mall.vo.OrderRefundVo; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | | import cc.mrbird.febs.pay.model.BrandWCPayRequestData; |
| | | import cc.mrbird.febs.pay.model.OrderStateDto; |
| | | import cc.mrbird.febs.pay.service.IPayService; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.pay.util.WeixinServiceUtil; |
| | | import cc.mrbird.febs.rabbit.producter.AgentProducer; |
| | | import cc.mrbird.febs.vip.service.IMallVipConfigBenefitsService; |
| | | import cc.mrbird.febs.vip.service.IMallVipConfigService; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | @RequiredArgsConstructor |
| | | public class ApiMallOrderInfoServiceImpl extends ServiceImpl<MallOrderInfoMapper, MallOrderInfo> implements IApiMallOrderInfoService { |
| | | |
| | | private final MallMemberWalletMapper mallMemberWalletMapper; |
| | | private final MallGoodsMapper mallGoodsMapper; |
| | | private final MallGoodsSkuMapper mallGoodsSkuMapper; |
| | | private final MallAddressInfoMapper mallAddressInfoMapper; |
| | |
| | | private final IApiMallTeamLeaderService iApiMallTeamLeaderService; |
| | | private final IMallElectronicFenceService iMallElectronicFenceService; |
| | | private final MallElectronicFenceMapper mallElectronicFenceMapper; |
| | | private final MallMemberCouponMapper mallMemberCouponMapper; |
| | | private final MallGoodsCouponMapper mallGoodsCouponMapper; |
| | | private final CouponGoodsMapper couponGoodsMapper; |
| | | |
| | | private final IMallVipConfigService mallVipConfigService; |
| | | private final MallAchieveRecordMapper mallAchieveRecordMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | throw new FebsException("请重新选择收货地址信息"); |
| | | } |
| | | |
| | | String orderNo = MallUtils.getOrderNum(); |
| | | String orderNo = MallUtils.getOrderNum("O"); |
| | | MallOrderInfo orderInfo = new MallOrderInfo(); |
| | | orderInfo.setOrderNo(orderNo); |
| | | orderInfo.setOrderTime(new Date()); |
| | |
| | | this.baseMapper.insert(orderInfo); |
| | | |
| | | BigDecimal total = BigDecimal.ZERO; |
| | | BigDecimal totalScoreAmount = BigDecimal.ZERO; |
| | | /** |
| | | * 根据传入的优惠卷ID和商品明细集合计算出每个商品获取的实际支付金额 |
| | | */ |
| | | Map<Long, BigDecimal> couponAmountMap = new HashMap<>(); |
| | | MallMemberCoupon mallMemberCoupon = new MallMemberCoupon(); |
| | | if(ObjectUtil.isNotEmpty(addOrderDto.getMemberCouponId())){ |
| | | Long memberCouponId = addOrderDto.getMemberCouponId(); |
| | | mallMemberCoupon = mallMemberCouponMapper.selectById(memberCouponId); |
| | | if(ObjectUtil.isEmpty(mallMemberCoupon)){ |
| | | throw new FebsException(mallMemberCoupon.getCouponName()+"无法使用"); |
| | | } |
| | | Integer state = mallMemberCoupon.getState(); |
| | | if(1 != state){ |
| | | throw new FebsException(mallMemberCoupon.getCouponName()+"无法使用"); |
| | | } |
| | | List<AddOrderItemDto> items = addOrderDto.getItems(); |
| | | couponAmountMap = getCouponAmountMap(memberCouponId, items); |
| | | } |
| | | /** |
| | | * 判断用户的积分是否足够 |
| | | */ |
| | | Map<Long, BigDecimal> scoreAmountMap = getScoreAmountMap(addOrderDto.getItems()); |
| | | MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | //判断scoreAmountMap中的总积分数量是否大于用户的积分数量 |
| | | if(scoreAmountMap.values().stream().reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(mallMemberWallet.getPrizeScore()) > 0){ |
| | | throw new FebsException("您的积分不足"); |
| | | } |
| | | for (AddOrderItemDto item : addOrderDto.getItems()) { |
| | | MallOrderItem orderItem = new MallOrderItem(); |
| | | |
| | |
| | | orderItem.setSkuImage(mallGoods.getThumb()); |
| | | orderItem.setState(1); |
| | | |
| | | if (addOrderDto.getType() == 1) { |
| | | LambdaQueryWrapper<MallShoppingCart> delQuery = new LambdaQueryWrapper<>(); |
| | | delQuery.eq(MallShoppingCart::getGoodsId, item.getSkuId()) |
| | | .eq(MallShoppingCart::getMemberId, member.getId()); |
| | | mallShoppingCartMapper.delete(delQuery); |
| | | } |
| | | total = total.add(amount); |
| | | } else { |
| | | MallGoodsSku sku = mallGoodsSkuMapper.selectSkuInfoById(item.getSkuId()); |
| | |
| | | } |
| | | |
| | | MallGoods mallGoods = mallGoodsMapper.selectById(sku.getGoodsId()); |
| | | // 零撸专区购买 |
| | | // todo 纯积分商品一个账号限制购买一次 |
| | | if (new BigDecimal(mallGoods.getPresentPrice()).compareTo(BigDecimal.ZERO) == 0) { |
| | | Integer cnt = item.getCnt(); |
| | | if(1 < cnt){ |
| | | throw new FebsException("积分商品限购一件"); |
| | | } |
| | | List<MallOrderItem> items = mallOrderItemMapper.selectItemByGoodsIdUnCancel(mallGoods.getId(), member.getId()); |
| | | if (CollUtil.isNotEmpty(items)) { |
| | | throw new FebsException("无法重复领取同一个商品"); |
| | | throw new FebsException("积分商品一个账号限购一次"); |
| | | } |
| | | } |
| | | |
| | |
| | | if(1 != goodsResult){ |
| | | throw new FebsException(mallGoods.getGoodsName() + "库存不足"); |
| | | } |
| | | BigDecimal amount = BigDecimal.ZERO; |
| | | BigDecimal itemPrice = BigDecimal.ZERO; |
| | | if(AgentLevelEnum.ZERO_LEVEL.name().equals(member.getLevel())){ |
| | | //普通用户使用原价购买 |
| | | amount = sku.getOriginalPrice().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | itemPrice = sku.getOriginalPrice(); |
| | | }else if(AgentLevelEnum.LEVEL_ONE.name().equals(member.getLevel())){ |
| | | //普通用户使用原价购买 |
| | | amount = sku.getLevelOnePrice().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | itemPrice = sku.getLevelOnePrice(); |
| | | }else if(AgentLevelEnum.LEVEL_TWO.name().equals(member.getLevel())){ |
| | | //普通用户使用原价购买 |
| | | amount = sku.getLevelTwoPrice().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | itemPrice = sku.getLevelTwoPrice(); |
| | | }else if(AgentLevelEnum.LEVEL_THREE.name().equals(member.getLevel())){ |
| | | //普通用户使用原价购买 |
| | | amount = sku.getLevelThreePrice().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | itemPrice = sku.getLevelThreePrice(); |
| | | }else{ |
| | | //合伙人使用折扣价 |
| | | amount = sku.getPresentPrice().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | itemPrice = sku.getPresentPrice(); |
| | | |
| | | BigDecimal amount = sku.getPresentPrice().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | BigDecimal levelOnePrice = sku.getLevelOnePrice().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | //是否使用优惠卷 |
| | | if(ObjectUtil.isNotEmpty(addOrderDto.getMemberCouponId())){ |
| | | Long memberCouponId = addOrderDto.getMemberCouponId(); |
| | | if(ObjectUtil.isNotEmpty(couponAmountMap.get(item.getSkuId()))){ |
| | | BigDecimal skuCouponAmount = couponAmountMap.get(item.getSkuId());//使用折扣卷后的应该支付的钱 |
| | | if(skuCouponAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | amount = skuCouponAmount; |
| | | } |
| | | orderItem.setMemberCouponId(memberCouponId); |
| | | } |
| | | } |
| | | // BigDecimal amount = sku.getPresentPrice().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | orderItem.setAmount(amount); |
| | | orderItem.setLevelOnePrice(levelOnePrice); |
| | | orderItem.setScoreAmount(scoreAmountMap.get(item.getSkuId())); |
| | | orderItem.setCnt(item.getCnt()); |
| | | orderItem.setOrderId(orderInfo.getId()); |
| | | orderItem.setPrice(itemPrice); |
| | | orderItem.setPrice(sku.getPresentPrice()); |
| | | orderItem.setGoodsId(sku.getGoodsId()); |
| | | orderItem.setGoodsName(sku.getGoodsName()); |
| | | orderItem.setSkuId(sku.getId()); |
| | | orderItem.setState(1); |
| | | if(ObjectUtil.isNotEmpty(member.getReferrerId())){ |
| | | orderItem.setMemberInviteId(member.getReferrerId()); |
| | | } |
| | | if(ObjectUtil.isNotEmpty(addOrderDto.getMemberInviteId())){ |
| | | orderItem.setMemberInviteId(addOrderDto.getMemberInviteId()); |
| | | } |
| | | |
| | | orderItem.setStyleName(sku.getStyleName()); |
| | | orderItem.setSkuName(sku.getSkuName()); |
| | | orderItem.setSkuImage(sku.getSkuImage()); |
| | |
| | | orderItem.setCostPrice(sku.getCostPrice()); |
| | | |
| | | total = total.add(amount); |
| | | totalScoreAmount = totalScoreAmount.add(scoreAmountMap.get(item.getSkuId())); |
| | | //规格的库存销量 |
| | | Integer skuResult = mallGoodsSkuMapper.upDateStockAndVolumeBySkuId(sku.getId(),item.getCnt()); |
| | | if(1 != skuResult){ |
| | |
| | | } |
| | | mallOrderItemMapper.insert(orderItem); |
| | | } |
| | | //运费 |
| | | BigDecimal delivaryAmount = addOrderDto.getDeliveryAmount() == null ? BigDecimal.ZERO : addOrderDto.getDeliveryAmount(); |
| | | orderInfo.setCarriage(delivaryAmount); |
| | | |
| | | mallMemberCoupon.setState(2); |
| | | mallMemberCouponMapper.updateById(mallMemberCoupon); |
| | | |
| | | BigDecimal delivaryAmount = BigDecimal.ZERO; |
| | | if(StrUtil.isEmpty(addOrderDto.getTakeUniqueCode())){ |
| | | delivaryAmount = addOrderDto.getDeliveryAmount() == null ? BigDecimal.ZERO : addOrderDto.getDeliveryAmount(); |
| | | orderInfo.setCarriage(delivaryAmount); |
| | | }else{ |
| | | MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(orderInfo.getTakeUniqueCode()); |
| | | if(mallTeamLeader!=null){ |
| | | throw new FebsException("自提点信息异常"); |
| | | } |
| | | orderInfo.setCarriage(delivaryAmount); |
| | | orderInfo.setTakeCode(ShareCodeUtil.toSerialCode(orderInfo.getId()) + MallUtils.getRandomNum(10)); |
| | | orderInfo.setTakeUniqueCode(mallTeamLeader.getUniqueCode()); |
| | | orderInfo.setDeliveryType(1); |
| | | } |
| | | total = total.add(delivaryAmount); |
| | | orderInfo.setAmount(total); |
| | | orderInfo.setScoreAmount(totalScoreAmount); |
| | | orderInfo.setAddressId(address.getId()); |
| | | orderInfo.setName(address.getName()); |
| | | orderInfo.setPhone(address.getPhone()); |
| | |
| | | orderInfo.setLatitude(address.getLatitude()); |
| | | orderInfo.setLongitude(address.getLongitude()); |
| | | this.baseMapper.updateById(orderInfo); |
| | | |
| | | //过期时间修改成24小时 |
| | | agentProducer.sendOrderCancelDelayMsg(orderInfo.getId(), 24 * 60 * 60 * 1000L); |
| | | return orderInfo.getId(); |
| | | } |
| | | |
| | | private Map<Long, BigDecimal> getScoreAmountMap(List<AddOrderItemDto> items) { |
| | | |
| | | Map<Long, BigDecimal> scoreAmountMap = new HashMap<>(); |
| | | //全部skuIds |
| | | Set<Long> skuIds = items.stream().map(AddOrderItemDto::getSkuId).collect(Collectors.toSet()); |
| | | LambdaQueryWrapper<MallGoodsSku> mallGoodsSkuLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | mallGoodsSkuLambdaQueryWrapper.in(MallGoodsSku::getId, skuIds); |
| | | List<MallGoodsSku> skusAll = mallGoodsSkuMapper.selectList(mallGoodsSkuLambdaQueryWrapper); |
| | | //全部goodsId |
| | | Set<Long> goodsIdsAll = skusAll.stream().map(MallGoodsSku::getGoodsId).collect(Collectors.toSet()); |
| | | LambdaQueryWrapper<MallGoods> mallGoodsLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | mallGoodsLambdaQueryWrapper.in(MallGoods::getId, goodsIdsAll); |
| | | List<MallGoods> goodsAll = mallGoodsMapper.selectList(mallGoodsLambdaQueryWrapper); |
| | | //stream流操作goodsAll,返回一个Hashmap<id,MallGoods> |
| | | Map<Long, MallGoods> goodsMap = goodsAll.stream().collect(Collectors.toMap(MallGoods::getId, mallGoods -> mallGoods)); |
| | | |
| | | for (AddOrderItemDto item : items) { |
| | | Long skuId = item.getSkuId(); |
| | | Integer cnt = item.getCnt(); |
| | | MallGoodsSku sku = skusAll.stream().filter(s -> s.getId().equals(skuId)).findFirst().orElse(null); |
| | | if (ObjectUtil.isNotEmpty(sku)) { |
| | | Long goodsId = sku.getGoodsId(); |
| | | MallGoods mallGoods = goodsMap.get(goodsId); |
| | | if (ObjectUtil.isNotEmpty(mallGoods)) { |
| | | BigDecimal multi = mallGoods.getStaticProp().divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_DOWN); |
| | | //获取该商品该规格的积分 |
| | | BigDecimal scoreAmount = sku.getOriginalPrice().multiply(multi).multiply(new BigDecimal(cnt)).setScale(0, RoundingMode.HALF_DOWN); |
| | | scoreAmountMap.put(skuId, scoreAmount); |
| | | } |
| | | } |
| | | } |
| | | return scoreAmountMap; |
| | | } |
| | | |
| | | // /** |
| | | // * 根据传入的优惠卷ID和商品明细集合计算出每个商品获取的实际支付金额 |
| | | // * @param memberCouponId 优惠卷ID |
| | | // * @param items 商品明细 |
| | | // * @return Map<Long,BigDecimal> skuId,实际支付金额 |
| | | // */ |
| | | // @Override |
| | | // public Map<Long,BigDecimal> getCouponAmountMap(Long memberCouponId,List<AddOrderItemDto> items){ |
| | | // HashMap<Long,BigDecimal> couponAmountMap = new HashMap<>(); |
| | | // MallMemberCoupon mallMemberCoupon = mallMemberCouponMapper.selectById(memberCouponId); |
| | | // if(ObjectUtil.isEmpty(mallMemberCoupon)){ |
| | | // return couponAmountMap; |
| | | // } |
| | | // Integer state = mallMemberCoupon.getState(); |
| | | // if(1 != state){ |
| | | // return couponAmountMap; |
| | | // } |
| | | // Long couponId = mallMemberCoupon.getCouponId();//优惠卷ID |
| | | // List<Long> goodsIdsAll = couponGoodsMapper.selectByCouponId(couponId); |
| | | // List<MallGoodsSku> skusAll = mallGoodsSkuMapper.selectSkuIdsByGoodsId(goodsIdsAll);//获取该优惠卷绑定的全部商品sku |
| | | // List<Long> skuIdsAll = skusAll.stream().map(MallGoodsSku::getId).collect(Collectors.toList());//获取该优惠卷绑定的全部商品skuIDS |
| | | // List<Long> skuIds = items.stream().map(AddOrderItemDto::getSkuId).collect(Collectors.toList());//订单中的全部skuIds |
| | | // |
| | | // /** |
| | | // * 获取这张优惠卷生效的skuIds |
| | | // */ |
| | | // Set<Long> intersection = skuIdsAll.stream() |
| | | // .filter(item -> skuIds.contains(item)) |
| | | // .collect(Collectors.toSet());//获取两个集合的交集 |
| | | // if(CollUtil.isEmpty(intersection)){ |
| | | // return couponAmountMap; |
| | | // } |
| | | // HashMap<Long,BigDecimal> skuMap = new HashMap<>();//每个订单详情的ID和amount的map |
| | | // List<MallGoodsSku> skus = mallGoodsSkuMapper.selectByIds(new ArrayList<>(intersection)); |
| | | // BigDecimal totalAmount = BigDecimal.ZERO;//订单中的总金额 |
| | | // Map<Long, AddOrderItemDto> itemMap = new HashMap<>();// 预先将items转换为Map,以skuId作为键 |
| | | // for (AddOrderItemDto addOrderItemDto : items) { |
| | | // itemMap.put(addOrderItemDto.getSkuId(), addOrderItemDto); |
| | | // } |
| | | // for(MallGoodsSku mallGoodsSku : skus){ |
| | | // Long id = mallGoodsSku.getId(); |
| | | // BigDecimal presentPrice = mallGoodsSku.getPresentPrice(); |
| | | // // 检查itemMap中是否存在该商品 |
| | | // AddOrderItemDto addOrderItemDto = itemMap.get(id); |
| | | // if (addOrderItemDto != null) { |
| | | // BigDecimal skuAmount = presentPrice.multiply(BigDecimal.valueOf(addOrderItemDto.getCnt())); |
| | | // totalAmount = totalAmount.add(skuAmount); |
| | | // skuMap.put(id,skuAmount); |
| | | // } |
| | | // } |
| | | // |
| | | // /** |
| | | // * 计算每个商品利用优惠卷打折的具体金额 |
| | | // */ |
| | | // MallGoodsCoupon mallGoodsCoupon = mallGoodsCouponMapper.selectById(mallMemberCoupon.getCouponId()); |
| | | // BigDecimal costAmount = mallGoodsCoupon.getCostAmount(); |
| | | // BigDecimal realAmount = mallGoodsCoupon.getRealAmount(); |
| | | // if(totalAmount.compareTo(costAmount) < 0){ |
| | | // return couponAmountMap; |
| | | // } |
| | | // HashMap<Long,BigDecimal> skuMapPercent = new HashMap<>();//每个订单详情的ID和amount的map |
| | | // for (Map.Entry<Long,BigDecimal> entry : skuMap.entrySet()) { |
| | | // Long keySkuId = entry.getKey(); |
| | | // BigDecimal valueSkuAmount = entry.getValue(); |
| | | // BigDecimal divide = valueSkuAmount.divide(totalAmount, 4, BigDecimal.ROUND_DOWN);//每个商品占符合满减的总额的比例 |
| | | // skuMapPercent.put(keySkuId,divide); |
| | | // Integer type = mallGoodsCoupon.getType(); |
| | | // if(MallGoodsCoupon.TYPE_ONE == type){ |
| | | // BigDecimal bigDecimal = realAmount.multiply(divide).setScale(0, BigDecimal.ROUND_DOWN);//每个SKU的减免金额(比例*减免金额) |
| | | // BigDecimal skuRealAmount = valueSkuAmount.subtract(bigDecimal.compareTo(BigDecimal.ZERO) > 0 ? bigDecimal : BigDecimal.ZERO);//实际支付金额 |
| | | // couponAmountMap.put(keySkuId,skuRealAmount); |
| | | // } |
| | | // if(MallGoodsCoupon.TYPE_TWO == type){ |
| | | // BigDecimal divideTime = totalAmount.divide(costAmount, 0, BigDecimal.ROUND_DOWN);//累计减免次数 |
| | | // BigDecimal multiply = divideTime.multiply(realAmount);//实际减免金额 |
| | | // BigDecimal bigDecimal = multiply.multiply(divide).setScale(0, BigDecimal.ROUND_DOWN);//每个SKU的减免金额(比例*实际减免金额) |
| | | // BigDecimal skuRealAmount = valueSkuAmount.subtract(bigDecimal.compareTo(BigDecimal.ZERO) > 0 ? bigDecimal : BigDecimal.ZERO);//实际支付金额 |
| | | // couponAmountMap.put(keySkuId,skuRealAmount); |
| | | // } |
| | | // } |
| | | // return couponAmountMap; |
| | | // } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据传入的优惠卷ID和商品明细集合计算出每个商品获取的实际支付金额 |
| | | * @param memberCouponId 优惠卷ID |
| | | * @param items 商品明细 |
| | | * @return Map<Long,BigDecimal> skuId,实际支付金额 |
| | | */ |
| | | @Override |
| | | public Map<Long, BigDecimal> getCouponAmountMap(Long memberCouponId, List<AddOrderItemDto> items) { |
| | | HashMap<Long, BigDecimal> couponAmountMap = new HashMap<>(); |
| | | // 获取优惠券信息 |
| | | Optional<MallMemberCoupon> optionalMallMemberCoupon = Optional.ofNullable(mallMemberCouponMapper.selectById(memberCouponId)); |
| | | MallMemberCoupon mallMemberCoupon = optionalMallMemberCoupon.orElse(null); |
| | | |
| | | if (mallMemberCoupon == null || mallMemberCoupon.getState() != 1) { |
| | | return couponAmountMap; |
| | | } |
| | | |
| | | Set<Long> intersection = items.stream().map(AddOrderItemDto::getSkuId).collect(Collectors.toSet()); // 订单中的全部skuIds |
| | | |
| | | if (intersection.isEmpty()) { |
| | | return couponAmountMap; |
| | | } |
| | | |
| | | // 获取订单详情的ID和amount的map |
| | | Map<Long, AddOrderItemDto> itemMap = items.stream() |
| | | .collect(Collectors.toMap(AddOrderItemDto::getSkuId, item -> item)); |
| | | |
| | | List<MallGoodsSku> skus = mallGoodsSkuMapper.selectList( |
| | | new LambdaQueryWrapper<MallGoodsSku>() |
| | | .select(MallGoodsSku::getId, MallGoodsSku::getPresentPrice) |
| | | .in(MallGoodsSku::getId, intersection) |
| | | ); |
| | | BigDecimal totalAmount = BigDecimal.ZERO; |
| | | Map<Long, BigDecimal> skuMap = new HashMap<>(); |
| | | |
| | | for (MallGoodsSku mallGoodsSku : skus) { |
| | | Long id = mallGoodsSku.getId(); |
| | | BigDecimal presentPrice = mallGoodsSku.getPresentPrice(); |
| | | AddOrderItemDto addOrderItemDto = itemMap.get(id); |
| | | if (addOrderItemDto != null) { |
| | | BigDecimal skuAmount = presentPrice.multiply(BigDecimal.valueOf(addOrderItemDto.getCnt())); |
| | | totalAmount = totalAmount.add(skuAmount); |
| | | skuMap.put(id, skuAmount); |
| | | } |
| | | } |
| | | |
| | | // 计算每个商品利用优惠卷打折的具体金额 |
| | | Optional<MallGoodsCoupon> optionalMallGoodsCoupon = Optional.ofNullable(mallGoodsCouponMapper.selectById(mallMemberCoupon.getCouponId())); |
| | | MallGoodsCoupon mallGoodsCoupon = optionalMallGoodsCoupon.orElse(null); |
| | | if (mallGoodsCoupon == null) { |
| | | return couponAmountMap; |
| | | } |
| | | |
| | | BigDecimal costAmount = mallGoodsCoupon.getCostAmount(); |
| | | BigDecimal realAmount = mallGoodsCoupon.getRealAmount(); |
| | | Integer type = mallGoodsCoupon.getType(); |
| | | if (MallGoodsCoupon.TYPE_ONE == type) { |
| | | realAmount = mallGoodsCoupon.getRealAmount(); |
| | | } else if (MallGoodsCoupon.TYPE_TWO == type) { |
| | | BigDecimal divideTime = totalAmount.divide(costAmount, 0, RoundingMode.HALF_DOWN); // 累计减免次数 |
| | | realAmount = divideTime.multiply(realAmount); // 实际减免金额 |
| | | } |
| | | |
| | | if (totalAmount.compareTo(costAmount) < 0) { |
| | | return couponAmountMap; |
| | | } |
| | | |
| | | BigDecimal totalDiscount = BigDecimal.ZERO; |
| | | for (Map.Entry<Long, BigDecimal> entry : skuMap.entrySet()) { |
| | | Long keySkuId = entry.getKey(); |
| | | BigDecimal valueSkuAmount = entry.getValue(); |
| | | BigDecimal divide = valueSkuAmount.divide(totalAmount, 4, RoundingMode.HALF_DOWN); // 每个商品占符合满减的总额的比例 |
| | | BigDecimal skuRealAmount = BigDecimal.ZERO; |
| | | if (MallGoodsCoupon.TYPE_ONE == type) { |
| | | BigDecimal bigDecimalOne = realAmount.multiply(divide).setScale(2, RoundingMode.HALF_DOWN); // 每个SKU的减免金额(比例*减免金额) |
| | | skuRealAmount = valueSkuAmount.subtract(bigDecimalOne.max(BigDecimal.ZERO)).setScale(2, RoundingMode.HALF_DOWN); |
| | | totalDiscount = totalDiscount.add(bigDecimalOne); |
| | | } else if (MallGoodsCoupon.TYPE_TWO == type) { |
| | | BigDecimal divideTime = totalAmount.divide(costAmount, 0, RoundingMode.HALF_DOWN); // 累计减免次数 |
| | | BigDecimal multiply = divideTime.multiply(realAmount); // 实际减免金额 |
| | | BigDecimal bigDecimalTwo = multiply.multiply(divide).setScale(2, RoundingMode.HALF_DOWN); // 每个SKU的减免金额(比例*实际减免金额) |
| | | skuRealAmount = valueSkuAmount.subtract(bigDecimalTwo.max(BigDecimal.ZERO)).setScale(2, RoundingMode.HALF_DOWN); |
| | | totalDiscount = totalDiscount.add(bigDecimalTwo); |
| | | } |
| | | couponAmountMap.put(keySkuId, skuRealAmount); |
| | | } |
| | | |
| | | // 调整最后一个商品的减免金额以确保总减免金额达到预期 |
| | | if (totalDiscount.compareTo(realAmount) < 0) { |
| | | BigDecimal difference = realAmount.subtract(totalDiscount); |
| | | for (Map.Entry<Long, BigDecimal> entry : couponAmountMap.entrySet()) { |
| | | Long keySkuId = entry.getKey(); |
| | | BigDecimal skuRealAmount = entry.getValue(); |
| | | BigDecimal newSkuRealAmount = skuRealAmount.subtract(difference).setScale(2, RoundingMode.HALF_DOWN); |
| | | couponAmountMap.put(keySkuId, newSkuRealAmount); |
| | | break; // 调整最后一个商品的减免金额 |
| | | } |
| | | } |
| | | |
| | | return couponAmountMap; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | List<Integer> a = new ArrayList<>(); |
| | | a.add(1); |
| | | a.add(2); |
| | | a.add(3); |
| | | List<Integer> b = new ArrayList<>(); |
| | | b.add(3); |
| | | b.add(4); |
| | | b.add(5); |
| | | boolean b1 = a.retainAll(b); |
| | | System.out.println(b1); |
| | | System.out.println(a); |
| | | System.out.println(b); |
| | | List<Integer> intersection = a.stream() |
| | | .filter(item -> b.contains(item)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | System.out.println(intersection); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | orderInfo.setCancelType(MallOrderInfo.CANCEL_BY_SELF); |
| | | this.baseMapper.updateById(orderInfo); |
| | | |
| | | |
| | | if (orderInfo.getOrderType() == 2) { |
| | | // mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount(), MoneyFlowTypeEnum.REFUND.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.PRIZE_SCORE.getValue()); |
| | | // memberWalletService.add(orderInfo.getAmount(), member.getId(), "prizeScore"); |
| | | return; |
| | | } |
| | | |
| | | List<MallOrderItem> mallOrderItemList = mallOrderItemMapper.selectListByOrderId(orderInfo.getId()); |
| | | if(CollUtil.isNotEmpty(mallOrderItemList)){ |
| | |
| | | Integer skuResult = mallGoodsSkuMapper.updateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); |
| | | if(1 != skuResult){ |
| | | throw new FebsException(sku.getSkuName() + "库存不足"); |
| | | } |
| | | Long memberCouponId = mallOrderItem.getMemberCouponId(); |
| | | MallMemberCoupon mallMemberCoupon = mallMemberCouponMapper.selectById(memberCouponId); |
| | | if(ObjectUtil.isNotEmpty(mallMemberCoupon)){ |
| | | mallMemberCoupon.setState(1); |
| | | mallMemberCouponMapper.updateById(mallMemberCoupon); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | String payResultStr = ""; |
| | | String wxResultStr = ""; |
| | | switch (payOrderDto.getType()) { |
| | | case "1": |
| | | BrandWCPayRequestData brandWCPayRequestData = null; |
| | | try { |
| | | brandWCPayRequestData = iXcxPayService.startPayment(orderInfo); |
| | | } catch (Exception e) { |
| | | throw new FebsException("支付失败"); |
| | | } |
| | | wxResultStr = JSONUtil.toJsonStr(brandWCPayRequestData); |
| | | payResultStr = brandWCPayRequestData.getPrepay_id(); |
| | | orderInfo.setPayMethod("微信支付"); |
| | | break; |
| | | case "2": |
| | | if (StrUtil.isNotBlank(orderInfo.getPayOrderNo())) { |
| | | payResultStr = orderInfo.getPayOrderNo(); |
| | | } else { |
| | | payResultStr = payService.aliPay(orderInfo); |
| | | } |
| | | if(orderInfo.getAmount().compareTo(BigDecimal.ZERO) <= 0){ |
| | | //先支付积分部分 |
| | | if(orderInfo.getScoreAmount().compareTo(BigDecimal.ZERO) > 0){ |
| | | balanceScorePay(orderInfo, payOrderDto.getTradePwd(), "prizeScore"); |
| | | mallMoneyFlowService.addMoneyFlow( |
| | | member.getId(), |
| | | orderInfo.getScoreAmount().negate(), |
| | | ScoreFlowTypeEnum.PAY.getValue(), |
| | | orderInfo.getOrderNo(), |
| | | FlowTypeEnum.PRIZE_SCORE.getValue(), |
| | | StrUtil.format(ScoreFlowTypeEnum.PAY.getDesc(),orderInfo.getScoreAmount()), |
| | | 2 |
| | | ); |
| | | } |
| | | orderInfo.setPayOrderNo(orderInfo.getOrderNo()); |
| | | orderInfo.setPayMethod("积分支付"); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); |
| | | orderInfo.setPayTime(new Date()); |
| | | orderInfo.setPayResult("1"); |
| | | payResultStr = orderInfo.getOrderNo(); |
| | | }else{ |
| | | switch (payOrderDto.getType()) { |
| | | case "1": |
| | | BrandWCPayRequestData brandWCPayRequestData = null; |
| | | try { |
| | | brandWCPayRequestData = iXcxPayService.startPayment(orderInfo); |
| | | } catch (Exception e) { |
| | | throw new FebsException("支付失败"); |
| | | } |
| | | wxResultStr = JSONUtil.toJsonStr(brandWCPayRequestData); |
| | | payResultStr = brandWCPayRequestData.getPrepay_id(); |
| | | orderInfo.setPayMethod("微信支付"); |
| | | break; |
| | | case "2": |
| | | if (StrUtil.isNotBlank(orderInfo.getPayOrderNo())) { |
| | | payResultStr = orderInfo.getPayOrderNo(); |
| | | } else { |
| | | payResultStr = payService.aliPay(orderInfo); |
| | | } |
| | | |
| | | orderInfo.setPayOrderNo(payResultStr); |
| | | orderInfo.setPayMethod("支付宝支付"); |
| | | agentProducer.sendOrderReturn(orderInfo.getId()); |
| | | break; |
| | | case "3": |
| | | payResultStr = balancePay(orderInfo, payOrderDto.getTradePwd(), "balance"); |
| | | orderInfo.setPayOrderNo(payResultStr); |
| | | orderInfo.setPayMethod("支付宝支付"); |
| | | agentProducer.sendOrderReturn(orderInfo.getId()); |
| | | break; |
| | | case "3": |
| | | |
| | | orderInfo.setPayOrderNo(orderInfo.getOrderNo()); |
| | | orderInfo.setPayMethod("余额支付"); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); |
| | | orderInfo.setPayTime(new Date()); |
| | | orderInfo.setPayResult("1"); |
| | | orderInfo.setDeliveryState(OrderDeliveryStateEnum.DELIVERY_WAIT.getValue()); |
| | | payResultStr = balancePay(orderInfo, payOrderDto.getTradePwd(), "balance"); |
| | | |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue(),"余额支付",2); |
| | | break; |
| | | case "4": |
| | | if (orderInfo.getOrderType() != 2) { |
| | | throw new FebsException("非积分订单,无法使用积分支付"); |
| | | } |
| | | payResultStr = balancePay(orderInfo, payOrderDto.getTradePwd(), "prizeScore"); |
| | | //先支付积分部分 |
| | | if(orderInfo.getScoreAmount().compareTo(BigDecimal.ZERO) > 0){ |
| | | balanceScorePay(orderInfo, payOrderDto.getTradePwd(), "prizeScore"); |
| | | mallMoneyFlowService.addMoneyFlow( |
| | | member.getId(), |
| | | orderInfo.getScoreAmount().negate(), |
| | | ScoreFlowTypeEnum.PAY.getValue(), |
| | | orderInfo.getOrderNo(), |
| | | FlowTypeEnum.PRIZE_SCORE.getValue(), |
| | | StrUtil.format(ScoreFlowTypeEnum.PAY.getDesc(),orderInfo.getScoreAmount()), |
| | | 2 |
| | | ); |
| | | } |
| | | |
| | | orderInfo.setPayOrderNo(orderInfo.getOrderNo()); |
| | | orderInfo.setPayMethod("积分支付"); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); |
| | | orderInfo.setPayTime(new Date()); |
| | | orderInfo.setPayResult("1"); |
| | | orderInfo.setPayOrderNo(orderInfo.getOrderNo()); |
| | | orderInfo.setPayMethod("余额支付"); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); |
| | | orderInfo.setPayTime(new Date()); |
| | | orderInfo.setPayResult("1"); |
| | | orderInfo.setDeliveryState(OrderDeliveryStateEnum.DELIVERY_WAIT.getValue()); |
| | | |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.PRIZE_SCORE.getValue()); |
| | | break; |
| | | default: |
| | | mallMoneyFlowService.addMoneyFlow( |
| | | member.getId(), |
| | | orderInfo.getAmount().negate(), |
| | | ScoreFlowTypeEnum.PAY_BALANCE.getValue(), |
| | | orderInfo.getOrderNo(), |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | StrUtil.format(ScoreFlowTypeEnum.PAY_BALANCE.getDesc(),orderInfo.getAmount()), |
| | | 2 |
| | | ); |
| | | agentProducer.sendOrderCoupon(orderInfo.getId()); |
| | | break; |
| | | case "4": |
| | | if (orderInfo.getOrderType() != 2) { |
| | | throw new FebsException("非积分订单,无法使用积分支付"); |
| | | } |
| | | payResultStr = balancePay(orderInfo, payOrderDto.getTradePwd(), "prizeScore"); |
| | | |
| | | orderInfo.setPayOrderNo(orderInfo.getOrderNo()); |
| | | orderInfo.setPayMethod("积分支付"); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); |
| | | orderInfo.setPayTime(new Date()); |
| | | orderInfo.setPayResult("1"); |
| | | |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), ScoreFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.PRIZE_SCORE.getValue(), null, 2); |
| | | break; |
| | | default: |
| | | |
| | | } |
| | | } |
| | | //订单支付成功产生一个提货码 |
| | | String takeCode = ShareCodeUtil.toSerialCode(orderInfo.getId()); |
| | | orderInfo.setTakeCode(takeCode); |
| | | |
| | | this.baseMapper.updateById(orderInfo); |
| | | |
| | | |
| | | |
| | | // OrderStateDto orderStateDto = new OrderStateDto(); |
| | | // orderStateDto.setOrderNo(orderInfo.getOrderNo()); |
| | | // String productNames = getProductNames(orderInfo.getMemberId(), orderInfo.getId()); |
| | | // orderStateDto.setGoodsName(StrUtil.isEmpty(productNames)?"商品":productNames); |
| | | // orderStateDto.setOrderState("已送达自提点"); |
| | | // orderStateDto.setTakeCode(orderInfo.getTakeCode()); |
| | | // String takeUniqueCode = orderInfo.getTakeUniqueCode(); |
| | | // MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(takeUniqueCode); |
| | | // orderStateDto.setAddressArea(mallTeamLeader.getAddressArea()); |
| | | // orderStateDto.setOpenId(mallMemberMapper.selectById(orderInfo.getMemberId()).getOpenId()); |
| | | // DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WX_TEMPLATE_ID_ONE.getType(), DataDictionaryEnum.WX_TEMPLATE_ID_ONE.getCode()); |
| | | // orderStateDto.setTemplateId(dataDictionaryCustom.getValue()); |
| | | //// iXcxPayService.pushOrderToAddress(orderStateDto); |
| | | // iXcxPayService.uniformMessageSend(orderStateDto); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("orderInfo", payResultStr); |
| | | map.put("orderNo", orderInfo.getOrderNo()); |
| | | map.put("orderId", orderInfo.getId()); |
| | | map.put("wxResultStr", wxResultStr); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | private String balanceScorePay(MallOrderInfo orderInfo, String tradePwd, String field) { |
| | | if (StrUtil.isBlank(tradePwd)) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | MallMember mallMember = memberMapper.selectById(orderInfo.getMemberId()); |
| | | if (StrUtil.isBlank(mallMember.getTradePassword())) { |
| | | throw new FebsException("未设置支付密码"); |
| | | } |
| | | |
| | | if (!SecureUtil.md5(tradePwd).equals(mallMember.getTradePassword())) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | int reduce = memberWalletService.reduce(orderInfo.getScoreAmount(), mallMember.getId(), field); |
| | | if (reduce == 2) { |
| | | throw new FebsException("积分不足"); |
| | | } |
| | | return orderInfo.getOrderNo(); |
| | | } |
| | | |
| | | private String balancePay(MallOrderInfo orderInfo, String tradePwd, String field) { |
| | |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | int reduce = memberWalletService.reduce(orderInfo.getAmount().add(orderInfo.getCarriage()), mallMember.getId(), field); |
| | | int reduce = memberWalletService.reduce(orderInfo.getAmount(), mallMember.getId(), field); |
| | | if (reduce == 2) { |
| | | throw new FebsException("余额不足"); |
| | | } |
| | |
| | | orderListDto.setMemberId(member.getId()); |
| | | // IPage<MallOrderInfo> mallOrderInfos = this.baseMapper.selectApiOrderListInPage(page, orderListDto); |
| | | IPage<MallOrderInfo> mallOrderInfos = this.baseMapper.selectNewApiOrderListInPage(page, orderListDto); |
| | | if (CollUtil.isNotEmpty(mallOrderInfos.getRecords())) { |
| | | mallOrderInfos.getRecords().forEach(item -> { |
| | | item.setItems(mallOrderItemMapper.selectListByOrderId(item.getId())); |
| | | }); |
| | | } |
| | | // if (CollUtil.isNotEmpty(mallOrderInfos.getRecords())) { |
| | | // mallOrderInfos.getRecords().forEach(item -> { |
| | | // item.setItems(mallOrderItemMapper.selectListByOrderId(item.getId())); |
| | | // }); |
| | | // } |
| | | return MallOrderInfoConversion.INSTANCE.entitysToVos(mallOrderInfos.getRecords()); |
| | | } |
| | | |
| | |
| | | if (ObjectUtil.isNull(orderInfo)) { |
| | | throw new FebsException("订单不存在"); |
| | | } |
| | | // List<MallOrderItem> items = orderInfo.getItems(); |
| | | // if(CollUtil.isNotEmpty(items)){ |
| | | // for(MallOrderItem mallOrderItem : items){ |
| | | // mallOrderItem.setItemAmount(mallOrderItemMapper.selectById(mallOrderItem.getId()).getAmount()); |
| | | // mallOrderItem.setScoreAmount(mallOrderItemMapper.selectById(mallOrderItem.getId()).getScoreAmount()); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | OrderDetailVo orderDetailVo = MallOrderInfoConversion.INSTANCE.entityToDetailVo(orderInfo); |
| | | if(StrUtil.isNotEmpty(orderInfo.getTakeUniqueCode())){ |
| | | MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(orderInfo.getTakeUniqueCode()); |
| | | |
| | | if(ObjectUtil.isNotEmpty(mallTeamLeader)){ |
| | | orderDetailVo.setLeaderName(mallTeamLeader.getName()); |
| | | orderDetailVo.setLeaderPhone(mallTeamLeader.getPhone()); |
| | | orderDetailVo.setAddressPic(mallTeamLeader.getAddressPic()); |
| | | orderDetailVo.setAddressArea(mallTeamLeader.getAddressArea()); |
| | | orderDetailVo.setDetailAddress(mallTeamLeader.getDetailAddress()); |
| | | orderDetailVo.setLeaderLongitude(mallTeamLeader.getLongitude()); |
| | | orderDetailVo.setLeaderLatitude(mallTeamLeader.getLatitude()); |
| | | } |
| | | } |
| | | |
| | | MallExpressInfo expressInfo = expressInfoMapper.selectByOrderId(orderInfo.getId()); |
| | | if(ObjectUtil.isNotEmpty(expressInfo)){ |
| | |
| | | throw new FebsException("该状态不能确认收货"); |
| | | } |
| | | |
| | | // if (orderInfo.getDeliveryState() != OrderDeliveryStateEnum.DELIVERY_FINISH.getValue()) { |
| | | // throw new FebsException("还未送至自提点"); |
| | | // } |
| | | |
| | | List<MallRefundEntity> mallRefundEntities = mallRefundMapper.selectByItemIdAndOrderIdAndState(null, orderInfo.getId(), 3); |
| | | if(CollUtil.isNotEmpty(mallRefundEntities)){ |
| | | throw new FebsException("请先处理退款商品"); |
| | |
| | | orderInfo.setReceivingTime(new Date()); |
| | | this.baseMapper.updateById(orderInfo); |
| | | |
| | | //生成一条团长提成记录 |
| | | // Long orderInfoId = orderInfo.getId(); |
| | | // List<MallOrderItem> mallOrderItemList = mallOrderItemMapper.selectListByOrderId(orderInfoId); |
| | | // if(CollUtil.isNotEmpty(mallOrderItemList)){ |
| | | // |
| | | // MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(orderInfo.getTakeUniqueCode()); |
| | | // Integer profitSwitch = mallTeamLeader.getProfitSwitch()==null?2:mallTeamLeader.getProfitSwitch(); |
| | | // BigDecimal bonusPercent =new BigDecimal(mallTeamLeader.getBonusPercent()==null?"0":mallTeamLeader.getBonusPercent()); |
| | | // |
| | | // if(1 == profitSwitch){ |
| | | // for(MallOrderItem mallOrderItem : mallOrderItemList){ |
| | | // Integer state = mallOrderItem.getState() == null ? 1 : mallOrderItem.getState(); |
| | | // if(1 == state){ |
| | | // MallLeaderAchieve mallLeaderAchieve = new MallLeaderAchieve(); |
| | | // mallLeaderAchieve.setMemberId(orderInfo.getMemberId()); |
| | | // mallLeaderAchieve.setOrderNo(orderInfo.getOrderNo()); |
| | | // mallLeaderAchieve.setOrderItemId(mallOrderItem.getId()); |
| | | // BigDecimal itemAmount = mallOrderItem.getAmount(); |
| | | // mallLeaderAchieve.setAmount(itemAmount); |
| | | // BigDecimal bigDecimal = bonusPercent.multiply(itemAmount).setScale(2, BigDecimal.ROUND_DOWN); |
| | | // mallLeaderAchieve.setProfitAmount(bigDecimal); |
| | | // mallLeaderAchieve.setUniqueCode(orderInfo.getTakeUniqueCode()); |
| | | // mallLeaderAchieve.setState(MallLeaderAchieve.STATE_ONE); |
| | | // mallLeaderAchieveMapper.insert(mallLeaderAchieve); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | agentProducer.sendGetScoreMsg(orderInfo.getId()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | mallGoodsComment.setSkuName(mallGoodsSku.getSkuName()); |
| | | mallGoodsComment.setStyleId(mallGoodsSku.getStyleId()); |
| | | mallGoodsComment.setStyleName(mallGoodsSku.getStyleName()); |
| | | mallGoodsComment.setShowState(MallGoodsComment.SHOW_STATE_ENABLE); |
| | | mallGoodsComment.setShowState(MallGoodsComment.SHOW_STATE_DISABLED); |
| | | mallGoodsCommentMapper.insert(mallGoodsComment); |
| | | } |
| | | } |
| | |
| | | if(CollUtil.isEmpty(mallOrderItemList)){ |
| | | return new FebsResponse().fail().message("订单不存在"); |
| | | } |
| | | int i = 0; |
| | | for(MallOrderItem mallOrderItem : mallOrderItemList){ |
| | | QueryWrapper<MallRefundEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("member_id",member.getId()); |
| | |
| | | mallRefundEntity.setType(3); |
| | | } |
| | | mallRefundEntity.setState(3); |
| | | mallRefundEntity.setAmount(mallOrderItem.getAmount()); |
| | | if(i == 0){ |
| | | mallRefundEntity.setAmount(mallOrderItem.getAmount().add(mallOrderInfo.getCarriage())); |
| | | }else{ |
| | | mallRefundEntity.setAmount(mallOrderItem.getAmount()); |
| | | } |
| | | mallRefundMapper.insert(mallRefundEntity); |
| | | }else{ |
| | | if(mallRefund.getState() == 1){ |
| | |
| | | apiLeaderRefundOrderDto.setItemId(mallOrderItem.getId()); |
| | | apiLeaderRefundOrderDto.setAgreeState(1); |
| | | iApiMallTeamLeaderService.leaderRefundOrder(apiLeaderRefundOrderDto); |
| | | i++; |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | |
| | | if(CollUtil.isEmpty(items)){ |
| | | return new FebsResponse().fail().message("请先挑选商品"); |
| | | } |
| | | /** |
| | | * 判断用户的积分是否足够 |
| | | */ |
| | | Map<Long, BigDecimal> scoreAmountMap = getScoreAmountMap(apiCreateOrderVerifyDto.getItems()); |
| | | MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | //判断scoreAmountMap中的总积分数量是否大于用户的积分数量 |
| | | if(scoreAmountMap.values().stream().reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(mallMemberWallet.getPrizeScore()) > 0){ |
| | | throw new FebsException("您的积分不足"); |
| | | } |
| | | for (AddOrderItemDto item : apiCreateOrderVerifyDto.getItems()) { |
| | | MallGoodsSku sku = mallGoodsSkuMapper.selectSkuInfoById(item.getSkuId()); |
| | | if (sku == null) { |
| | |
| | | if (MallGoods.ISSALE_STATUS_DISABLED.equals(mallGoods.getIsSale())) { |
| | | return new FebsResponse().fail().message(mallGoods.getGoodsName() + "已下架"); |
| | | } |
| | | |
| | | //判断 |
| | | } |
| | | |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.print(AgentLevelEnum.ZERO_LEVEL.name()); |
| | | @Override |
| | | public FebsResponse chooseCoupon(ApiChooseCouponDto chooseCouponDto) { |
| | | Map<Long, BigDecimal> couponAmountMap = getCouponAmountMap(chooseCouponDto.getMemberCouponId(), chooseCouponDto.getItems()); |
| | | ArrayList<ApiCouponAmountMapVo> objects = new ArrayList<>(); |
| | | for (Map.Entry<Long,BigDecimal> entry : couponAmountMap.entrySet()) { |
| | | Long keySkuId = entry.getKey(); |
| | | BigDecimal valueSkuAmount = entry.getValue(); |
| | | ApiCouponAmountMapVo apiCouponAmountMapVo = new ApiCouponAmountMapVo(); |
| | | apiCouponAmountMapVo.setId(keySkuId); |
| | | apiCouponAmountMapVo.setAmount(valueSkuAmount); |
| | | objects.add(apiCouponAmountMapVo); |
| | | } |
| | | return new FebsResponse().success().data(objects); |
| | | } |
| | | |
| | | } |