xiaoyong931011
2023-04-03 c56372c3c3320a92af9b8fcd7e31ac29139f98ba
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -114,12 +114,22 @@
                DataDictionaryEnum.BUY_TIMES.getType(), DataDictionaryEnum.BUY_TIMES.getCode());
        Integer buyTimes = Integer.parseInt(buyTimesDic.getValue());
        DateTime date = DateUtil.date();
        DateTime date = DateUtil.offsetHour(DateUtil.date(), -1);
//        DateTime date = DateUtil.date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        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 +142,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());
@@ -454,18 +465,18 @@
        OrderDetailVo orderDetailVo = MallOrderInfoConversion.INSTANCE.entityToDetailVo(orderInfo);
        Integer deliverType = (ObjectUtil.isEmpty(orderInfo.getDeliverType()) ? new Integer(0):orderInfo.getDeliverType());
        if (orderInfo.getStatus() == OrderStatusEnum.WAIT_FINISH.getValue() && 2 != deliverType) {
            MallExpressInfo expressInfo = expressInfoMapper.selectByOrderId(orderInfo.getId());
            orderDetailVo.setExpressNo(expressInfo.getExpressNo());
            orderDetailVo.setExpressCom(expressInfo.getExpressCom());
        }
//        Integer deliverType = (ObjectUtil.isEmpty(orderInfo.getDeliverType()) ? new Integer(0):orderInfo.getDeliverType());
//        if (orderInfo.getStatus() == OrderStatusEnum.WAIT_FINISH.getValue() && 2 != deliverType) {
//            MallExpressInfo expressInfo = expressInfoMapper.selectByOrderId(orderInfo.getId());
//            orderDetailVo.setExpressNo(expressInfo.getExpressNo());
//            orderDetailVo.setExpressCom(expressInfo.getExpressCom());
//        }
        if (orderInfo.getStatus() == OrderStatusEnum.REFUNDING.getValue() || orderInfo.getStatus() == OrderStatusEnum.REFUNDED.getValue()) {
            MallOrderRefund orderRefund = mallOrderRefundMapper.selectOrderRefundByOrderId(orderInfo.getId());
            OrderRefundVo orderRefundVo = MallOrderRefundConversion.INSTANCE.entityToVo(orderRefund);
            orderDetailVo.setOrderRefund(orderRefundVo);
        }
//        if (orderInfo.getStatus() == OrderStatusEnum.REFUNDING.getValue() || orderInfo.getStatus() == OrderStatusEnum.REFUNDED.getValue()) {
//            MallOrderRefund orderRefund = mallOrderRefundMapper.selectOrderRefundByOrderId(orderInfo.getId());
//            OrderRefundVo orderRefundVo = MallOrderRefundConversion.INSTANCE.entityToVo(orderRefund);
//            orderDetailVo.setOrderRefund(orderRefundVo);
//        }
        if (OrderStatusEnum.WAIT_PAY.getValue() == orderInfo.getStatus()) {
            Date endTime = DateUtil.offsetMinute(orderInfo.getOrderTime(), 15);
@@ -473,20 +484,20 @@
            long remainTime = DateUtil.between(new Date(), endTime, DateUnit.SECOND, false);
            orderDetailVo.setRemainTime(remainTime);
        }
        if(2 == deliverType){
            MallShopApply mallShopApply = mallShopApplyMapper.selectById(orderInfo.getShopId());
            if(ObjectUtil.isNotEmpty(mallShopApply)){
                ApiShopApplyVo apiShopApplyVo = new ApiShopApplyVo();
                apiShopApplyVo.setName(mallShopApply.getName());
                apiShopApplyVo.setPhone(mallShopApply.getPhone());
                apiShopApplyVo.setSaleArea(mallShopApply.getSaleArea());
                apiShopApplyVo.setLatitude(mallShopApply.getLatitude());
                apiShopApplyVo.setLongitude(mallShopApply.getLongitude());
                apiShopApplyVo.setShopName(mallShopApply.getShopName());
                apiShopApplyVo.setAddress(mallShopApply.getAddress());
                orderDetailVo.setApiShopApplyVo(apiShopApplyVo);
            }
        }
//        if(2 == deliverType){
//            MallShopApply mallShopApply = mallShopApplyMapper.selectById(orderInfo.getShopId());
//            if(ObjectUtil.isNotEmpty(mallShopApply)){
//                ApiShopApplyVo apiShopApplyVo = new ApiShopApplyVo();
//                apiShopApplyVo.setName(mallShopApply.getName());
//                apiShopApplyVo.setPhone(mallShopApply.getPhone());
//                apiShopApplyVo.setSaleArea(mallShopApply.getSaleArea());
//                apiShopApplyVo.setLatitude(mallShopApply.getLatitude());
//                apiShopApplyVo.setLongitude(mallShopApply.getLongitude());
//                apiShopApplyVo.setShopName(mallShopApply.getShopName());
//                apiShopApplyVo.setAddress(mallShopApply.getAddress());
//                orderDetailVo.setApiShopApplyVo(apiShopApplyVo);
//            }
//        }
        return orderDetailVo;
    }
@@ -506,22 +517,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 +666,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());