From 3f7a3aefe2965459aed169383b285fba400cfe8c Mon Sep 17 00:00:00 2001
From: jiangqs <343695869@qq.com>
Date: 星期日, 04 六月 2023 13:13:54 +0800
Subject: [PATCH] Merge branch 'master' of http://sinata.cn:10101/gitblit/r/java/HongRuiTang

---
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java |   39 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java
index bf1103a..db79d33 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java
@@ -4,13 +4,17 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.exception.ServiceException;
+import com.ruoyi.common.core.utils.DateUtils;
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.order.domain.dto.*;
 import com.ruoyi.order.domain.pojo.order.ConsumerGoods;
+import com.ruoyi.order.domain.pojo.order.UserServiceRecord;
 import com.ruoyi.order.domain.vo.AppConsumerPageVo;
 import com.ruoyi.order.domain.vo.MerConsumerGoodsListVo;
 import com.ruoyi.order.domain.vo.MerConsumerGoodsVo;
 import com.ruoyi.order.mapper.order.ConsumerGoodsMapper;
 import com.ruoyi.order.service.order.ConsumerGoodsService;
+import com.ruoyi.order.service.order.UserServiceRecordService;
 import com.ruoyi.system.api.constant.AppErrorConstant;
 import org.springframework.stereotype.Service;
 
@@ -32,6 +36,8 @@
     @Resource
     private ConsumerGoodsMapper consumerGoodsMapper;
 
+    @Resource
+    private UserServiceRecordService userServiceRecordService;
     /**
      * 获取用户服务
      * @param page
@@ -91,6 +97,11 @@
             Integer usedNum;
             Integer useNum;
             Integer surpNum;
+            Long shopId = null;
+            Long userId = null;
+            String consumerGoodsNames = "";
+            String consumerGoodsIds = "";
+            Integer serviceType = 1;
             for(MerSureConsumerGoodsListDto merSureConsumerGoodsListDto : merSureConsumerGoodsListDtoList){
                 consumerGoods = this.getById(merSureConsumerGoodsListDto.getConsumerGoodsId());
                 serviceNum = consumerGoods.getServiceNum();
@@ -101,13 +112,35 @@
                     throw new ServiceException(AppErrorConstant.BEYOND_SURP_NUM);
                 }
                 consumerGoods.setUsedNum(usedNum+useNum);
-                consumerGoods.setUseTime(new Date());
-                if(consumerGoods.getUsedNum()==serviceNum){
+                consumerGoods.setUseTime(DateUtils.getNowDate());
+                if(consumerGoods.getUsedNum().equals(serviceNum)){
                     consumerGoods.setServiceStatus(2);
-                    consumerGoods.setCompleteTime(new Date());
+                    consumerGoods.setCompleteTime(DateUtils.getNowDate());
                 }
                 this.saveOrUpdate(consumerGoods);
+                shopId = consumerGoods.getShopId();
+                userId= consumerGoods.getUserId();
+                serviceType = consumerGoods.getGoodsType();
+                if(StringUtils.isBlank(consumerGoodsIds)){
+                    consumerGoodsIds = consumerGoods.getConsumerGoodsId();
+                }else{
+                    consumerGoodsIds = consumerGoodsIds + "," + consumerGoods.getConsumerGoodsId();
+                }
+                if(StringUtils.isBlank(consumerGoodsNames)){
+                    consumerGoodsNames = consumerGoods.getGoodsName();
+                }else{
+                    consumerGoodsNames = consumerGoodsNames + "、" + consumerGoods.getGoodsName();
+                }
             }
+            UserServiceRecord userServiceRecord = new UserServiceRecord();
+            userServiceRecord.setCreateTime(DateUtils.getNowDate());
+            userServiceRecord.setServiceType(serviceType);
+            userServiceRecord.setDelFlag(0);
+            userServiceRecord.setShopId(shopId);
+            userServiceRecord.setUserId(userId);
+            userServiceRecord.setConsumerGoodsIds(consumerGoodsIds);
+            userServiceRecord.setConsumerGoodsNames(consumerGoodsNames);
+            userServiceRecordService.saveOrUpdate(userServiceRecord);
         }
     }
 

--
Gitblit v1.7.1