bug
jiangqs
2023-07-31 122bb1142631e31ce50716495dba420102f58f56
ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java
@@ -96,6 +96,10 @@
    @Override
    @Transactional
    public void sureMerConsumerGoods(MerSureConsumerGoodsDto merSureConsumerGoodsDto){
        ConsumerGoods oldConsumerGoods = this.getById(merSureConsumerGoodsDto.getConsumerGoodsId());
        if(oldConsumerGoods.getSureNum()==null||oldConsumerGoods.getSureNum()<1){
            throw new ServiceException(AppErrorConstant.GOODS_SURE_FAILED);
        }
        List<MerSureConsumerGoodsListDto> merSureConsumerGoodsListDtoList = merSureConsumerGoodsDto.getMerSureConsumerGoodsListDtoList();
        if(merSureConsumerGoodsListDtoList!=null && !merSureConsumerGoodsListDtoList.isEmpty()){
            ConsumerGoods consumerGoods;
@@ -106,12 +110,38 @@
            Integer servicePerson = 0;
            Integer experienceService = 0;
            Integer experiencePerson = 0;
            Goods goods;
            GoodsFile goodsFile;
            String consumerGoodsId;
            List<ConsumerGoods> consumerGoodsList = new ArrayList<>();
            MerMemberConsumerGoodsTotalVo memberConsumerGoodsTotalVo = this.getMemberConsumerGoodsTotalVo(merSureConsumerGoodsDto.getUserId(), merSureConsumerGoodsDto.getShopId());
            int sureNum = 0;
            for(MerSureConsumerGoodsListDto merSureConsumerGoodsListDto : merSureConsumerGoodsListDtoList){
                consumerGoods = this.getById(merSureConsumerGoodsListDto.getConsumerGoodsId());
                consumerGoods.setCycleNumFlag(1);
                consumerGoods.setServiceNum(merSureConsumerGoodsListDto.getServiceNum());
                this.saveOrUpdate(consumerGoods);
                goods = remoteGoodsService.getGoods(merSureConsumerGoodsListDto.getGoodsId()).getData();
                goodsFile = remoteGoodsService.getGoodsFile(goods.getGoodsId()).getData();
                if(goods!=null&&goods.getGoodsType()==1&&goods.getCycleNumFlag()==1){
                    for(int i=0;i<merSureConsumerGoodsListDto.getGoodsNum();i++){
                        consumerGoods = new ConsumerGoods();
                        consumerGoodsId = IdUtils.simpleUUID();
                        consumerGoods.setConsumerGoodsId(consumerGoodsId);
                        consumerGoods.setDelFlag(0);
                        consumerGoods.setServiceStatus(1);
                        consumerGoods.setShopId(merSureConsumerGoodsDto.getShopId());
                        consumerGoods.setUserId(merSureConsumerGoodsDto.getMemberUserId());
                        consumerGoods.setOrderId(oldConsumerGoods.getOrderId());
                        consumerGoods.setOrderGoodsId(oldConsumerGoods.getOrderGoodsId());
                        consumerGoods.setGoodsId(goods.getGoodsId());
                        consumerGoods.setGoodsName(goods.getGoodsName());
                        consumerGoods.setCycleNumFlag(goods.getCycleNumFlag());
                        consumerGoods.setServiceNum(goods.getServiceNum());
                        consumerGoods.setUsedNum(0);
                        consumerGoods.setCreateTime(new Date());
                        consumerGoods.setGoodsType(goods.getGoodsType());
                        consumerGoods.setGoodsIntroduction(goods.getGoodsIntroduction());
                        consumerGoods.setGoodsPicture(goodsFile.getFileUrl());
                        consumerGoods.setGoodsNurses(goods.getGoodsNurses());
                        consumerGoods.setSourceFrom(1);
                        consumerGoodsList.add(consumerGoods);
                //处理商品服务次数
                switch (consumerGoods.getGoodsType()) {
                    case 1:
@@ -126,7 +156,22 @@
                    default:
                        break;
                }
                        sureNum = sureNum + 1;
            }
                }
            }
            if(sureNum>oldConsumerGoods.getSureNum()){
                throw new ServiceException(AppErrorConstant.GOODS_SURE_FAILED);
            }else{
                int surpNum = oldConsumerGoods.getSureNum();
                surpNum = surpNum - sureNum;
                oldConsumerGoods.setSureNum(surpNum);
                if(surpNum==0){
                    oldConsumerGoods.setDelFlag(1);
                }
                this.saveOrUpdate(oldConsumerGoods);
            }
            this.saveBatch(consumerGoodsList);
            //判断是否加人
            if (cycleService > 0 && memberConsumerGoodsTotalVo.getCycleOrder() == 0) {
                cyclePerson = 1;