Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/developerA' into developerC

chao 3 gadi atpakaļ
vecāks
revīzija
fa663c1158

+ 0 - 1
src/main/java/com/caimei365/user/UserApplication.java

@@ -14,7 +14,6 @@ import org.springframework.scheduling.annotation.EnableAsync;
  * @author : Charles
  * @author : Charles
  * @date : 2021/2/22
  * @date : 2021/2/22
  */
  */
-@EnableAsync
 @EnableDiscoveryClient
 @EnableDiscoveryClient
 @SpringBootApplication
 @SpringBootApplication
 @EnableFeignClients(basePackages = {"com.caimei365.user.feign"})
 @EnableFeignClients(basePackages = {"com.caimei365.user.feign"})

+ 33 - 0
src/main/java/com/caimei365/user/config/TaskPoolConfig.java

@@ -0,0 +1,33 @@
+package com.caimei365.user.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/11/12
+ */
+@Configuration
+@EnableAsync
+public class TaskPoolConfig {
+    @Bean("taskExecutor")
+    public Executor taskExecutor(){
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        executor.setCorePoolSize(10);
+        executor.setMaxPoolSize(20);
+        executor.setQueueCapacity(200);
+        executor.setKeepAliveSeconds(60);
+        executor.setThreadNamePrefix("asyncTask-");
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        executor.setWaitForTasksToCompleteOnShutdown(true);
+        executor.setAwaitTerminationSeconds(60);
+        return executor;
+    }
+}

+ 3 - 1
src/main/java/com/caimei365/user/mapper/HeHeMapper.java

@@ -6,6 +6,8 @@ import com.caimei365.user.model.po.UserPo;
 import com.caimei365.user.model.vo.HeHeUserVo;
 import com.caimei365.user.model.vo.HeHeUserVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 
 
+import java.util.List;
+
 /**
 /**
  * Description
  * Description
  *
  *
@@ -57,7 +59,7 @@ public interface HeHeMapper {
      * @param couponType    劵类型 1活动券 2专享券 3新人券 4好友分享券 5好友消费券
      * @param couponType    劵类型 1活动券 2专享券 3新人券 4好友分享券 5好友消费券
      * @return
      * @return
      */
      */
-    String getCurrentCouponIds(int couponType);
+    List<Integer> getCurrentCouponIds(int couponType);
 
 
     /**
     /**
      * 插入优惠券分享记录
      * 插入优惠券分享记录

+ 2 - 10
src/main/java/com/caimei365/user/model/po/CouponSharePo.java

@@ -22,15 +22,7 @@ public class CouponSharePo implements Serializable {
      */
      */
     private Integer receiveUserId;
     private Integer receiveUserId;
     /**
     /**
-     * 分享得到的好友分享券id,以,隔开
+     * 分享得到的好友分享/消费券id
      */
      */
-    private String shareCouponIds;
-    /**
-     * 被分享者是否已消费,0未消费,1已消费
-     */
-    private Integer consumeFlag;
-    /**
-     * 分享对象消费后得到的好友消费券id
-     */
-    private String consumeCouponIds;
+    private Integer shareCouponId;
 }
 }

+ 1 - 1
src/main/java/com/caimei365/user/service/impl/AsyncService.java

@@ -32,7 +32,7 @@ public class AsyncService {
     @Resource
     @Resource
     private BaseMapper baseMapper;
     private BaseMapper baseMapper;
 
 
-    @Async
+    @Async("taskExecutor")
     public void loginUpdateBeans(Integer userId, Integer identity) {
     public void loginUpdateBeans(Integer userId, Integer identity) {
         boolean isClub = null != identity && (2 == identity || 4 == identity);
         boolean isClub = null != identity && (2 == identity || 4 == identity);
         if (isClub){
         if (isClub){

+ 6 - 3
src/main/java/com/caimei365/user/service/impl/HeHeServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -108,9 +109,11 @@ public class HeHeServiceImpl implements HeHeService {
                         CouponSharePo couponSharePo = new CouponSharePo();
                         CouponSharePo couponSharePo = new CouponSharePo();
                         couponSharePo.setShareUserId(shareUserId);
                         couponSharePo.setShareUserId(shareUserId);
                         couponSharePo.setReceiveUserId(receiveUserId);
                         couponSharePo.setReceiveUserId(receiveUserId);
-                        String shareCouponIds = heHeMapper.getCurrentCouponIds(4);
-                        couponSharePo.setShareCouponIds(shareCouponIds);
-                        heHeMapper.insertCouponShare(couponSharePo);
+                        List<Integer> couponIds = heHeMapper.getCurrentCouponIds(4);
+                        couponIds.forEach(couponId->{
+                            couponSharePo.setShareCouponId(couponId);
+                            heHeMapper.insertCouponShare(couponSharePo);
+                        });
                     }
                     }
                 }
                 }
                 return ResponseJson.success(heHeUser);
                 return ResponseJson.success(heHeUser);

+ 4 - 5
src/main/resources/mapper/HeHeMapper.xml

@@ -33,12 +33,11 @@
         WHERE
         WHERE
           mobile = #{mobile}
           mobile = #{mobile}
     </select>
     </select>
-    <select id="getCurrentCouponIds" resultType="java.lang.String">
-        select group_concat(id)
+    <select id="getCurrentCouponIds" resultType="java.lang.Integer">
+        select id
         from cm_hehe_coupon
         from cm_hehe_coupon
         where couponType = #{couponType} and if(startNowFlag = 1,true, NOW() <![CDATA[  >=  ]]> startTime )
         where couponType = #{couponType} and if(startNowFlag = 1,true, NOW() <![CDATA[  >=  ]]> startTime )
           and if(permanentFlag = 1,true,NOW() <![CDATA[  <=  ]]> endTime) and delFlag = 0
           and if(permanentFlag = 1,true,NOW() <![CDATA[  <=  ]]> endTime) and delFlag = 0
-        group by couponType
     </select>
     </select>
 
 
     <update id="updateHeHeUser">
     <update id="updateHeHeUser">
@@ -75,8 +74,8 @@
 		  )
 		  )
     </insert>
     </insert>
     <insert id="insertCouponShare">
     <insert id="insertCouponShare">
-        insert into cm_hehe_coupon_share (shareUserId, receiveUserId, shareCouponIds,createTime)
-        values (#{shareUserId}, #{receiveUserId}, #{shareCouponIds},NOW())
+        insert into cm_hehe_coupon_share (shareUserId, receiveUserId, shareCouponId, type, createTime)
+        values (#{shareUserId}, #{receiveUserId}, #{shareCouponId}, 1, NOW())
     </insert>
     </insert>
 
 
 </mapper>
 </mapper>