xiaoyong931011
2023-03-24 491eb89ab53f47ff6c3e386c35cbc55729c47f46
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -119,7 +119,16 @@
        String yyyyMMdd = sdf.format(date);
        Integer times = this.baseMapper.selectCountByCreateTimeAndMemberId(yyyyMMdd,member.getId());
        if(buyTimes <= times){
            throw new FebsException("会员今日已无法购买");
            throw new FebsException("今日任务完成,明天再来");
        }
        DataDictionaryCustom allBuyTimesDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.ALL_BUY_TIMES.getType(), DataDictionaryEnum.ALL_BUY_TIMES.getCode());
        Integer allBuyTimes = Integer.parseInt(allBuyTimesDic.getValue());
        Integer allBuyTimesNow = this.baseMapper.selectCountByCreateTime(yyyyMMdd);
        if(allBuyTimes <= allBuyTimesNow){
            throw new FebsException("今日任务完成,明天再来");
        }
        String orderNo = MallUtils.getOrderNum();
@@ -132,6 +141,7 @@
        orderInfo.setOrderType(addOrderDto.getOrderType());
        //补贴金额
        orderInfo.setSubsidyAmount(goods.getSubsidyAmount());
        orderInfo.setCommentState(MallOrderInfo.COMMENT_STATE_NO);
        this.baseMapper.insert(orderInfo);
        List<MallGoodsSku> mallGoodsSkus = mallGoodsSkuMapper.selectSkuByGoodsId(goods.getId());
@@ -506,22 +516,22 @@
        orderInfo.setStatus(OrderStatusEnum.FINISH.getValue());
        orderInfo.setReceivingTime(new Date());
        this.baseMapper.updateById(orderInfo);
        /**
         * 通过支付流水记录,返回下单金额
         */
        MallMoneyFlow payFlow = mallMoneyFlowMapper.selectOneByMemberIdAndOrderNoAndTypeAndStatusAndIsReturn(
                member.getId(),
                orderInfo.getOrderNo(),
                MallMoneyFlowTypeEnum.PAY.getCode(),
                MallMoneyFlow.STATUS_SUCCESS,
                MallMoneyFlow.IS_RETURN_N);
        if(ObjectUtil.isNotEmpty(payFlow)){
            memberWalletService.addBalance(payFlow.getAmount().negate(),payFlow.getRtMemberId());
            payFlow.setIsReturn(MallMoneyFlow.IS_RETURN_Y);
            mallMoneyFlowMapper.updateById(payFlow);
        }
        //产生补贴流水记录
        agentProducer.sendDirectRewardMsg(orderInfo.getId());
//        /**
//         * 通过支付流水记录,返回下单金额
//         */
//        MallMoneyFlow payFlow = mallMoneyFlowMapper.selectOneByMemberIdAndOrderNoAndTypeAndStatusAndIsReturn(
//                member.getId(),
//                orderInfo.getOrderNo(),
//                MallMoneyFlowTypeEnum.PAY.getCode(),
//                MallMoneyFlow.STATUS_SUCCESS,
//                MallMoneyFlow.IS_RETURN_N);
//        if(ObjectUtil.isNotEmpty(payFlow)){
//            memberWalletService.addBalance(payFlow.getAmount().negate(),payFlow.getRtMemberId());
//            payFlow.setIsReturn(MallMoneyFlow.IS_RETURN_Y);
//            mallMoneyFlowMapper.updateById(payFlow);
//        }
//        //产生补贴流水记录
//        agentProducer.sendDirectRewardMsg(orderInfo.getId());
    }
@@ -655,13 +665,30 @@
        orderInfo.setCommentState(MallOrderInfo.COMMENT_STATE_YES);
        this.baseMapper.updateById(orderInfo);
        /**
         * 通过支付流水记录,返回下单金额
         */
        MallMoneyFlow payFlow = mallMoneyFlowMapper.selectOneByMemberIdAndOrderNoAndTypeAndStatusAndIsReturn(
                member.getId(),
                orderInfo.getOrderNo(),
                MallMoneyFlowTypeEnum.PAY.getCode(),
                MallMoneyFlow.STATUS_SUCCESS,
                MallMoneyFlow.IS_RETURN_N);
        if(ObjectUtil.isNotEmpty(payFlow)){
            memberWalletService.addBalance(payFlow.getAmount().negate(),payFlow.getRtMemberId());
            payFlow.setIsReturn(MallMoneyFlow.IS_RETURN_Y);
            mallMoneyFlowMapper.updateById(payFlow);
        }
        //产生补贴流水记录
        agentProducer.sendDirectRewardMsg(orderInfo.getId());
        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();
                List<MallGoodsSku> mallGoodsSkus = mallGoodsSkuMapper.selectSkuByGoodsId(goodsId);
                MallGoodsSku mallGoodsSku = mallGoodsSkus.get(0);
                MallGoods mallGoods = mallGoodsMapper.selectById(goodsId);
                MallGoodsComment mallGoodsComment = MallGoodsCommentConversion.INSTANCE.dtoToEntity(apiAddCommentDto);
                mallGoodsComment.setMemberId(member.getId());