| | |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.mall.conversion.MallGoodsCommentConversion; |
| | | import cc.mrbird.febs.mall.conversion.MallOrderInfoConversion; |
| | | import cc.mrbird.febs.mall.conversion.MallOrderRefundConversion; |
| | | import cc.mrbird.febs.mall.dto.*; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | private final MallAddressInfoMapper mallAddressInfoMapper; |
| | | private final MallOrderItemMapper mallOrderItemMapper; |
| | | private final MallMemberMapper memberMapper; |
| | | private final MallGoodsCommentMapper mallGoodsCommentMapper; |
| | | private final IApiMallMemberWalletService memberWalletService; |
| | | private final MallExpressInfoMapper expressInfoMapper; |
| | | private final MallOrderRefundMapper mallOrderRefundMapper; |
| | |
| | | |
| | | private final AgentProducer agentProducer; |
| | | private final IPayService payService; |
| | | private final IMallAchieveService mallAchieveService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | if (CollUtil.isNotEmpty(orderItems)) { |
| | | for (MallOrderItem orderItem : orderItems) { |
| | | MallGoods mallGoods = mallGoodsMapper.selectById(orderItem.getGoodsId()); |
| | | BigDecimal score; |
| | | BigDecimal score = BigDecimal.ZERO; |
| | | MallGoodsSku sku = mallGoodsSkuMapper.selectById(orderItem.getSkuId()); |
| | | if (mallGoods.getIsNormal() == 2) { |
| | | hasTc = true; |
| | | score = sku.getPresentPrice().multiply(mallGoods.getStaticMulti()); |
| | | |
| | | // 普通商品1:1 返还积分 |
| | | } else { |
| | | score = sku.getPresentPrice(); |
| | | // BigDecimal staticMulti = mallGoods.getStaticMulti() == null ? BigDecimal.ZERO : mallGoods.getStaticMulti(); |
| | | // score = sku.getPresentPrice().multiply(staticMulti); |
| | | } |
| | | |
| | | memberWalletService.add(score, member.getId(), "score"); |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), score, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | if (score.compareTo(BigDecimal.ZERO) > 0) { |
| | | memberWalletService.add(score, member.getId(), "score"); |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), score, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | |
| | | // 添加业绩 |
| | | mallAchieveService.add(orderItem.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue()); |
| | | // agentProducer.sendAutoLevelUpMsg(member.getId()); |
| | | agentProducer.sendAutoLevelUpMsg(member.getId()); |
| | | agentProducer.sendOrderReturn(orderInfo.getId()); |
| | | break; |
| | | case "4": |
| | |
| | | orderRefund.setRefundTime(new Date()); |
| | | orderRefund.setBeforeStatus(beforeStatus); |
| | | orderRefund.setStatus(OrderRefundStatusEnum.REFUND_APPLY.getValue()); |
| | | |
| | | // 未发货则退运费,发货了则不退 |
| | | if (beforeStatus == 2) { |
| | | orderRefund.setAmount(orderInfo.getAmount().add(orderInfo.getCarriage())); |
| | | } else { |
| | | orderRefund.setAmount(orderInfo.getAmount()); |
| | | } |
| | | mallOrderRefundMapper.insert(orderRefund); |
| | | } else { |
| | | orderRefund.setDesp(addRefundDto.getDesp()); |
| | |
| | | orderRefund.setRefundTime(new Date()); |
| | | orderRefund.setBeforeStatus(beforeStatus); |
| | | orderRefund.setStatus(OrderRefundStatusEnum.REFUND_APPLY.getValue()); |
| | | // 未发货则退运费,发货了则不退 |
| | | if (beforeStatus == 2) { |
| | | orderRefund.setAmount(orderInfo.getAmount().add(orderInfo.getCarriage())); |
| | | } else { |
| | | orderRefund.setAmount(orderInfo.getAmount()); |
| | | } |
| | | mallOrderRefundMapper.updateById(orderRefund); |
| | | } |
| | | |
| | |
| | | this.baseMapper.updateById(orderInfo); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void goodsComment(ApiAddCommentDtos addCommentDtos) { |
| | | Long orderId = addCommentDtos.getOrderId(); |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | MallOrderInfo orderInfo = this.baseMapper.selectOrderDetailsById(orderId); |
| | | if (orderInfo == null || AppContants.DEL_FLAG_Y == orderInfo.getDelFlag()) { |
| | | throw new FebsException("订单不存在"); |
| | | } |
| | | if (OrderStatusEnum.FINISH.getValue() != orderInfo.getStatus()) { |
| | | throw new FebsException("该状态不能评价"); |
| | | } |
| | | if (MallOrderInfo.COMMENT_STATE_YES == orderInfo.getCommentState()) { |
| | | throw new FebsException("该状态不能评价"); |
| | | } |
| | | |
| | | orderInfo.setCommentState(MallOrderInfo.COMMENT_STATE_YES); |
| | | this.baseMapper.updateById(orderInfo); |
| | | |
| | | List<ApiAddCommentDto> apiAddCommentDtos = addCommentDtos.getApiAddCommentDtos(); |
| | | if(CollUtil.isNotEmpty(apiAddCommentDtos)){ |
| | | for(ApiAddCommentDto apiAddCommentDto : apiAddCommentDtos){ |
| | | Long skuId = apiAddCommentDto.getSkuId(); |
| | | MallGoodsSku mallGoodsSku = mallGoodsSkuMapper.selectById(skuId); |
| | | Long goodsId = apiAddCommentDto.getGoodsId(); |
| | | MallGoods mallGoods = mallGoodsMapper.selectById(goodsId); |
| | | MallGoodsComment mallGoodsComment = MallGoodsCommentConversion.INSTANCE.dtoToEntity(apiAddCommentDto); |
| | | mallGoodsComment.setMemberId(member.getId()); |
| | | mallGoodsComment.setOrderId(orderId); |
| | | mallGoodsComment.setGoodsName(mallGoods.getGoodsName()); |
| | | mallGoodsComment.setSkuName(mallGoodsSku.getSkuName()); |
| | | mallGoodsComment.setStyleId(mallGoodsSku.getStyleId()); |
| | | mallGoodsComment.setStyleName(mallGoodsSku.getStyleName()); |
| | | mallGoodsComment.setShowState(MallGoodsComment.SHOW_STATE_ENABLE); |
| | | mallGoodsCommentMapper.insert(mallGoodsComment); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |