Răsfoiți Sursa

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mall-service/pom.xml
#	mall-service/src/main/java/com/txz/mall/MallApplication.java
Mr.qian 2 săptămâni în urmă
părinte
comite
b77d221063

+ 6 - 0
mall-service/pom.xml

@@ -173,6 +173,12 @@
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson</artifactId>
+            <version>3.16.6</version>
+        </dependency>
+
         <dependency>
             <groupId>io.github.engagelab-mt</groupId>
             <artifactId>engagelab-sdk-java</artifactId>

+ 2 - 0
mall-service/src/main/java/com/txz/mall/MallApplication.java

@@ -10,9 +10,11 @@ import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFa
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
 import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.web.client.RestTemplate;
 
+@EnableScheduling
 @EnableDiscoveryClient
 @SpringBootApplication
 @EnableAsync

+ 74 - 40
mall-service/src/main/java/com/txz/mall/business/impl/OrderServiceBusinessImpl.java

@@ -17,6 +17,7 @@ import com.txz.mall.model.*;
 import com.txz.mall.service.*;
 import com.txz.mall.util.I18nUtil;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.time.DateUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -38,6 +39,7 @@ import java.util.stream.Collectors;
 @Service
 @Transactional
 @AllArgsConstructor
+@Slf4j
 public class OrderServiceBusinessImpl implements OrderServiceBusiness {
 
     private final StoreOrderService storeOrderService;
@@ -50,7 +52,7 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
     private final RedisUtil redisUtil;
     private final CifRedEnvelopeDubboServiceClient cifRedEnvelopeDubboServiceClient;
     private final StoreOrderMapper storeOrderMapper;
-
+    private final StoreProductService storeProductService;
     @Override
     public StoreOrderVO orderDetail(Long id, String orderNo) {
         StoreOrderVO vo = new StoreOrderVO();
@@ -179,48 +181,80 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
 //            return list;
 //        }
 
-        Date date = new Date();
-        Date date1 = DateUtils.addDays(date, -7);
-       // List<Map<String, Object>> rank = storeOrderMapper.getRank(date1);
-        List<Map<String, Object>> rank = storePinkMapper.getRank(date1);
-
-
-        if (!CollectionUtils.isEmpty(rank)) {
-            Map<Long, Map<String, Object>> saleMap = rank.stream().collect(Collectors.toMap(a -> Long.valueOf(a.get("pid")+"") , a -> a, (b, c) -> c));
-            List<Long> pidList = rank.stream().map(a -> Long.valueOf(a.get("pid")+"")).collect(Collectors.toList());
-
-            Condition storeCombinationCondition = new Condition(StoreCombination.class);
-            Example.Criteria storeCombinationCriteria = storeCombinationCondition.createCriteria();
-            storeCombinationCriteria.andIn("productId", pidList);
-            List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
-            Map<Long, StoreCombination> storeCombinationMap = new HashMap<>();
-            if(!CollectionUtils.isEmpty(combinationList)){
-                 storeCombinationMap = combinationList.stream().collect(Collectors.toMap(StoreCombination::getProductId, a -> a, (b, c) -> c));
-            }
-            for (Map<String, Object> stringObjectMap : rank) {
-
-
-                Object pid = stringObjectMap.get("pid");
-                Object num = stringObjectMap.get("num");
-
-                StoreCombination storeCombination = storeCombinationMap.get(Long.parseLong(pid + ""));
-                StoreCombinationRankVO rankVO = new StoreCombinationRankVO();
-                rankVO.setProductId(storeCombination.getProductId());
-                rankVO.setProductName(storeCombination.getProductName());
-                rankVO.setSales(Integer.valueOf(num+""));
-                rankVO.setFicti(Integer.valueOf(num+""));
-                rankVO.setImage(storeCombination.getImage());
-                rankVO.setPrice(storeCombination.getPrice());
-                list.add(rankVO);
-            }
-
-            if(!CollectionUtils.isEmpty(list)){
-                list =list.stream().sorted(Comparator.comparing(StoreCombinationRankVO::getSales).reversed()).collect(Collectors.toList());
-            }
-
+        Set<Long> isvalidProductIdList = new HashSet<>();
+        //提取有效的参与活动的商品id
+        Condition storeCombinationCondition = new Condition(StoreCombination.class);
+        Example.Criteria StoreCombinationCriteria = storeCombinationCondition.createCriteria();
+        StoreCombinationCriteria.andEqualTo("isDelete", 0);
+        StoreCombinationCriteria.andEqualTo("isShow", 1);
+        List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
+
+        if(!CollectionUtils.isEmpty(combinationList)){
+            log.info("getRank.storeCombinationService.findByCondition"+JSONObject.toJSONString(combinationList));
+            List<Long> productIdList1 = combinationList.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
+            isvalidProductIdList.addAll(productIdList1);
         }
 
 
+//        Condition storeProductondition = new Condition(StoreProduct.class);
+//        Example.Criteria storeProductCriteria = storeProductondition.createCriteria();
+//        storeProductCriteria.andEqualTo("isDelete", 0);
+//        storeProductCriteria.andEqualTo("isShow", 1);
+//        List<StoreProduct> storeProductList = storeProductService.findByCondition(storeProductondition);
+//        if(!CollectionUtils.isEmpty(storeProductList)){
+//            List<Long> productIdList2 = storeProductList.stream().map(StoreProduct::getId).collect(Collectors.toList());
+//            isvalidProductIdList.addAll(productIdList2);
+//        }
+
+
+       if(!CollectionUtils.isEmpty(isvalidProductIdList)) {
+           log.info("getRank.isvalidProductIdList"+JSONObject.toJSONString(isvalidProductIdList));
+           Date date = new Date();
+           Date date1 = DateUtils.addDays(date, -7);
+           // List<Map<String, Object>> rank = storeOrderMapper.getRank(date1);
+           List<Map<String, Object>> rank = storePinkMapper.getRank(date1,isvalidProductIdList);
+
+
+           if (!CollectionUtils.isEmpty(rank)) {
+               log.info("rank"+JSONObject.toJSONString(rank));
+               Map<Long, Map<String, Object>> saleMap = rank.stream().collect(Collectors.toMap(a -> Long.valueOf(a.get("pid") + ""), a -> a, (b, c) -> c));
+               List<Long> pidList = rank.stream().map(a -> Long.valueOf(a.get("pid") + "")).collect(Collectors.toList());
+
+//               Condition storeCombinationCondition = new Condition(StoreCombination.class);
+//               Example.Criteria storeCombinationCriteria = storeCombinationCondition.createCriteria();
+//               storeCombinationCriteria.andIn("productId", pidList);
+//               List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
+               Map<Long, StoreCombination> storeCombinationMap = new HashMap<>();
+               if (!CollectionUtils.isEmpty(combinationList)) {
+                   log.info("getRank.combinationList"+JSONObject.toJSONString(combinationList));
+                   storeCombinationMap = combinationList.stream().collect(Collectors.toMap(StoreCombination::getProductId, a -> a, (b, c) -> c));
+               }
+               for (Map<String, Object> stringObjectMap : rank) {
+
+
+                   Object pid = stringObjectMap.get("pid");
+                   Object num = stringObjectMap.get("num");
+                   log.info("getRank.pid"+JSONObject.toJSONString(pid));
+                   StoreCombination storeCombination = storeCombinationMap.get(Long.parseLong(pid + ""));
+                   log.info("getRank.storeCombination"+JSONObject.toJSONString(storeCombination));
+                   StoreCombinationRankVO rankVO = new StoreCombinationRankVO();
+                   rankVO.setProductId(storeCombination.getProductId());
+                   rankVO.setProductName(storeCombination.getProductName());
+                   rankVO.setSales(Integer.valueOf(num + ""));
+                   rankVO.setFicti(Integer.valueOf(num + ""));
+                   rankVO.setImage(storeCombination.getImage());
+                   rankVO.setPrice(storeCombination.getPrice());
+                   list.add(rankVO);
+               }
+
+               if (!CollectionUtils.isEmpty(list)) {
+                   log.info("getRank.list"+JSONObject.toJSONString(list));
+                   list = list.stream().sorted(Comparator.comparing(StoreCombinationRankVO::getSales).reversed()).collect(Collectors.toList());
+               }
+
+           }
+
+       }
 
         // redisUtil.set(key, list);
         return list;

+ 84 - 0
mall-service/src/main/java/com/txz/mall/configurer/RedissonConfig.java

@@ -0,0 +1,84 @@
+package com.txz.mall.configurer;
+
+import org.redisson.Redisson;
+import org.redisson.api.RedissonClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+import org.redisson.config.Config;
+import org.springframework.beans.factory.annotation.Value;
+
+
+@Configuration
+public class RedissonConfig {
+
+    @Value("${redisson.singleServerConfig.address}")
+    private String address;
+
+
+    @Value("${redisson.singleServerConfig.password}")
+    private String password;
+
+
+    @Value("${redisson.singleServerConfig.database}")
+    private Integer database;
+
+    @Value("${redisson.singleServerConfig.connectionMinimumIdleSize}")
+    private Integer connectionMinimumIdleSize;
+
+    @Value("${redisson.singleServerConfig.idleConnectionTimeout}")
+    private Integer idleConnectionTimeout;
+
+    @Value("${redisson.singleServerConfig.connectTimeout}")
+    private Integer connectTimeout;
+
+    @Value("${redisson.singleServerConfig.timeout}")
+    private Integer timeout;
+
+    @Value("${redisson.singleServerConfig.retryAttempts}")
+    private Integer retryAttempts;
+
+    @Value("${redisson.singleServerConfig.retryInterval}")
+    private Integer retryInterval;
+
+
+    @Value("${redisson.singleServerConfig.connectionPoolSize}")
+    private Integer connectionPoolSize;
+
+//    @Value("${redisson.singleServerConfig.reconnectionTimeout}")
+//    private Integer reconnectionTimeout;
+//
+//    @Value("${redisson.singleServerConfig.failedAttempts}")
+//    private Integer failedAttempts;
+
+//    redisson.singleServerConfig.database=0 # 默认数据库为0
+//    redisson.singleServerConfig.connectionMinimumIdleSize=10  # 连接池中的最小空闲连接数
+//    redisson.singleServerConfig.idleConnectionTimeout=10000  # 连接空闲超时,单位:毫秒
+//    redisson.singleServerConfig.connectTimeout=10000  # 超时时间,单位:毫秒
+//    redisson.singleServerConfig.timeout=3000  # 命令等待超时,单位:毫秒
+//    redisson.singleServerConfig.retryAttempts=3  # 命令失败重试次数
+//    redisson.singleServerConfig.retryInterval=1500  # 命令重试发送时间间隔,单位:毫秒
+//    redisson.singleServerConfig.reconnectionTimeout=3000  # 重新连接时间间隔,单位:毫秒
+//    redisson.singleServerConfig.failedAttempts=3 # 在这个时间内失败几次则认为连接失败,单位:次
+    @Bean(destroyMethod = "shutdown")
+    public RedissonClient redisson() {
+        Config config = new Config();
+        config.useSingleServer()
+                .setAddress(address)
+                .setDatabase(database)
+                .setPassword(password)
+                .setConnectionMinimumIdleSize(connectionMinimumIdleSize)
+                .setIdleConnectionTimeout(idleConnectionTimeout)
+                .setConnectTimeout(connectTimeout)
+                .setConnectionPoolSize(connectionPoolSize)
+                .setTimeout(timeout)
+                .setRetryAttempts(retryAttempts)
+                .setRetryInterval(retryInterval)
+
+
+
+        ;
+        return Redisson.create(config);
+    }
+}

+ 36 - 37
mall-service/src/main/java/com/txz/mall/controller/appcontroller/AppCombinationController.java

@@ -9,6 +9,7 @@ import com.txz.mall.business.OrderServiceBusiness;
 import com.txz.mall.core.Result;
 import com.txz.mall.core.ResultCode;
 import com.txz.mall.core.ServiceException;
+import com.txz.mall.enums.SpuSortEnum;
 import com.txz.mall.model.StoreCombination;
 import com.txz.mall.model.StoreProduct;
 import com.txz.mall.service.StoreCombinationService;
@@ -202,46 +203,44 @@ public class AppCombinationController {
     public Result<PageInfo<List<StoreCombinationVO>>> spuList(@Validated SpuListRO ro, Integer page, Integer size) {
         PageHelper.startPage(page, size);
 
-        List<StoreCombinationVO> storeCombinationVOS1 = storeCombinationService.spuList(ro);
+       // List<StoreCombinationVO> storeCombinationVOS1 = storeCombinationService.spuList(ro);
 
-//        Condition condition = new Condition(StoreCombination.class);
-//        Example.Criteria criteria = condition.createCriteria();
-//        criteria.andEqualTo("isDelete", 0);
-//        criteria.andEqualTo("isShow", 1);
-//
-//        if (StrUtil.isNotBlank(ro.getStoreName())) {
-//            criteria.andLike("productName", "%" + ro.getStoreName() + "%");
-//        }
-//        if (StrUtil.isNotBlank(ro.getCateId())) {
-//            criteria.andEqualTo("cateId", ro.getCateId());
-//        }
-//        if (ObjectUtil.isNotNull(ro.getPrice())) {
-//            criteria.andEqualTo("price", ro.getPrice());
-//        }
-//        condition.setOrderByClause(ro.getSort().getSort());
-//        List<StoreCombination> byCondition = storeCombinationService.findByCondition(condition);
-//        List<StoreCombinationVO> storeCombinationVOS = new ArrayList<>();
-//
-//        if(!CollectionUtils.isEmpty(byCondition)){
-//            List<Long> productIdList = byCondition.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
-//
-//            Condition conditionStoreProduct = new Condition(StoreProduct.class);
-//            Example.Criteria criteriaStoreProduct = conditionStoreProduct.createCriteria();
-//            criteriaStoreProduct.andEqualTo("isDelete", 0);
-//            criteriaStoreProduct.andIn("id",productIdList);
-//            List<StoreProduct> storeProductList = storeProductService.findByCondition(conditionStoreProduct);
-//            Map<Long, StoreProduct> storeProductMap = storeProductList.stream().collect(Collectors.toMap(StoreProduct::getId, a -> a, (b, c) -> c));
-//            for (StoreCombination storeCombination : byCondition) {
-//                StoreCombinationVO storeCombinationVO = new StoreCombinationVO();
-//                BeanUtils.copyProperties(storeCombination,storeCombinationVO);
-//                StoreProduct storeProduct = storeProductMap.get(storeCombination.getProductId());
-//                storeCombinationVO.setFicti(storeProduct.getFicti());
-//                storeCombinationVOS.add(storeCombinationVO);
-//            }
-//        }
+        Condition condition = new Condition(StoreCombination.class);
+        Example.Criteria criteria = condition.createCriteria();
+        criteria.andEqualTo("isDelete", 0);
+        criteria.andEqualTo("isShow", 1);
+        if(SpuSortEnum.SALES_ASC.equals(ro.getSort())){
+            condition.setOrderByClause("ficti asc");
+        }else if(SpuSortEnum.SALES_DESC.equals(ro.getSort())){
+            condition.setOrderByClause("ficti desc");
+        }else{
+            condition.setOrderByClause("ficti desc");
+        }
+
+        if (StrUtil.isNotBlank(ro.getStoreName())) {
+            criteria.andLike("productName", "%" + ro.getStoreName() + "%");
+        }
+        if (StrUtil.isNotBlank(ro.getCateId())) {
+            criteria.andEqualTo("cateId", ro.getCateId());
+        }
+        if (ObjectUtil.isNotNull(ro.getPrice())) {
+            criteria.andEqualTo("price", ro.getPrice());
+        }
+
+        List<StoreCombination> byCondition = storeCombinationService.findByCondition(condition);
+        List<StoreCombinationVO> storeCombinationVOS = new ArrayList<>();
 
+        if(!CollectionUtils.isEmpty(byCondition)){
+
+            for (StoreCombination storeCombination : byCondition) {
+                StoreCombinationVO storeCombinationVO = new StoreCombinationVO();
+                BeanUtils.copyProperties(storeCombination,storeCombinationVO);
+
+                storeCombinationVOS.add(storeCombinationVO);
+            }
+        }
 
-        return Result.success(new PageInfo(storeCombinationVOS1));
+        return Result.success(new PageInfo(storeCombinationVOS));
     }
     
     

+ 29 - 0
mall-service/src/main/java/com/txz/mall/controller/i18nTestController.java

@@ -9,6 +9,8 @@ import com.txz.mall.model.StoreCombination;
 import com.txz.mall.util.I18nUtil;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.MessageSource;
 import org.springframework.context.i18n.LocaleContextHolder;
@@ -40,6 +42,33 @@ public class i18nTestController {
         return I18nUtil.get("product.export.template")+"3";
     }
 
+    @Autowired
+    private RedissonClient redissonClient;
 
+    @ApiOperation(value = "redisson")
+    @GetMapping(value = "/redisson")
+    public String redisson1() {
+
+        RLock lock = redissonClient.getLock("lala");
+        lock.lock();
+        try {
+            Thread.sleep(8000);
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+        lock.unlock();
+
+        return "success1";
+    }
+
+    @ApiOperation(value = "redisson2")
+    @GetMapping(value = "/redisson2")
+    public String redisson2() {
+        RLock lock = redissonClient.getLock("lala");
+        lock.lock();
+
+        lock.unlock();
+        return "success2";
+    }
 
 }

+ 7 - 2
mall-service/src/main/java/com/txz/mall/dao/StorePinkMapper.java

@@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.SelectProvider;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 public interface StorePinkMapper extends Mapper<StorePink> {
     
@@ -18,7 +19,11 @@ public interface StorePinkMapper extends Mapper<StorePink> {
     List<ProductCarouselDTO> pinkByProductId(Long productId);
 
 
-    @Select("select pid as pid ,count(*) as num from m_store_pink where (order_status in (3,4,5,6,7,8) or l_id in(1) )and create_time > #{date} group by pid ORDER BY num desc limit 20")
-    List<Map<String,Object>> getRank(@Param("date") Date date);
+//    @Select("select pid as pid ,count(*) as num from m_store_pink where order_status in (3,4,5,6,7,8) and " +
+//            "<foreach collection='productSet' item='item' open='(' separator=',' close=')'>" +
+//               "#{item}" +
+//            "</foreach> " +
+//            "pid in (productSet) and create_time > #{date} group by pid ORDER BY num desc limit 20")
+    List<Map<String,Object>> getRank(@Param("date") Date date,@Param("productSet") Set<Long> productSet);
     
 }

+ 4 - 0
mall-service/src/main/java/com/txz/mall/model/StoreCombination.java

@@ -286,5 +286,9 @@ public class StoreCombination {
      */
     @Column(name = "version")
     private Integer version;
+
+
+    @ApiModelProperty(value = "虚拟销量")
+    private Integer ficti;
     
 }

+ 1 - 0
mall-service/src/main/java/com/txz/mall/service/impl/StoreCombinationServiceImpl.java

@@ -126,6 +126,7 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
             }
             storeCombination.setTitle(flashActivity.getName());
             storeCombination.setActivityId(activityId);
+            storeCombination.setFicti(storeProduct.getFicti());
         }
         //  直接进行覆盖
         Condition condition = new Condition(StoreCombination.class);

+ 11 - 7
mall-service/src/main/java/com/txz/mall/service/impl/StorePinkServiceImpl.java

@@ -14,6 +14,7 @@ import com.txz.cif.param.OrderParam;
 import com.txz.mall.constants.Constants;
 import com.txz.mall.core.AbstractService;
 import com.txz.mall.core.ServiceException;
+import com.txz.mall.dao.StoreCombinationMapper;
 import com.txz.mall.dao.StorePinkMapper;
 import com.txz.mall.dao.StoreProductMapper;
 import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
@@ -22,10 +23,7 @@ import com.txz.mall.enums.OrderEventsEnum;
 import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
 import com.txz.mall.enums.PinkOrderStatusEnum;
 import com.txz.mall.enums.StorePinkStatusEnum;
-import com.txz.mall.model.StoreOrder;
-import com.txz.mall.model.StorePink;
-import com.txz.mall.model.StorePinkSummary;
-import com.txz.mall.model.StoreProduct;
+import com.txz.mall.model.*;
 import com.txz.mall.service.*;
 import com.txz.mall.util.I18nUtil;
 import com.txz.mall.util.OrderStateMachine;
@@ -69,6 +67,8 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
     @Resource
     private StoreProductMapper storeProductMapper;
 
+    @Resource
+    private StoreCombinationMapper storeCombinationMapper;
     @Override
     public List<StorePink> getListByCidAndKid(Long cid, Long kid) {
         Condition condition = new Condition(StorePink.class);
@@ -111,12 +111,9 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
         Long pid = teamPink.getPid();
 
         StoreProduct storeProduct = storeProductService.findById(pid);
-
         StoreProduct storeProductForUpdate = new StoreProduct();
         storeProductForUpdate.setFicti(storeProduct.getFicti()+teamPink.getTotalNum());
         storeProductForUpdate.setVersion(storeProduct.getVersion()+1);
-
-
         Example exampleStoreProduct = new Example(StoreProduct.class);
         exampleStoreProduct.createCriteria().andEqualTo("id", pid).andEqualTo(storeProduct.getVersion());
         int i = storeProductMapper.updateByConditionSelective(storeProductForUpdate, exampleStoreProduct);
@@ -124,6 +121,13 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
             throw new ServiceException(I18nUtil.get("failed.to.increase.virtual.sales.during.payment")+pid);
         }
 
+        //将虚拟销量维护到拼团商品表上防止连表查询
+        StoreCombination storeCombinationUpdate = new StoreCombination();
+        storeCombinationUpdate.setFicti(storeProduct.getFicti()+teamPink.getTotalNum());
+        Example exampleStoreCombination = new Example(StoreCombination.class);
+        exampleStoreCombination.createCriteria().andEqualTo("productId", pid).andEqualTo("isDelete",0);
+        storeCombinationMapper.updateByConditionSelective(storeCombinationUpdate,exampleStoreCombination);
+
         memberList.add(teamPink);
 //        memberList.forEach(i -> {
 //            i.setStatus(2);

+ 66 - 4
mall-service/src/main/java/com/txz/mall/task/GeneralJob.java

@@ -1,8 +1,11 @@
 package com.txz.mall.task;
 
 import cn.hutool.core.collection.CollUtil;
+import com.txz.mall.service.StoreFlashActivityService;
+import com.txz.mall.service.StoreOrderService;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
@@ -22,17 +25,76 @@ import java.util.List;
  * @author xuxueli 2019-12-11 21:52:51
  */
 @Component
+@Slf4j
 public class GeneralJob {
-    private static Logger logger = LoggerFactory.getLogger(GeneralJob.class);
 
+//    private static Logger logger = LoggerFactory.getLogger(GeneralJob.class);
+
+    @Resource
+    private StoreOrderService storeOrderService;
+
+
+    @Resource
+    private StoreFlashActivityService storeFlashActivityService;
 
     /**
      * 1、简单任务示例(Bean模式)
      */
-    @XxlJob("generalReportJob")
-    public ReturnT<String> generalReportJob(String param) throws Exception {
-        //do things
+
+    @XxlJob("newScheduledTaskStorePinkSummaryClose")
+    public ReturnT<String> newsScheduledTaskStorePinkSummaryClose(String param) throws Exception {
+        try {
+            log.info("newScheduledTaskStorePinkSummaryClose start");
+            storeOrderService.scheduledTaskStorePinkSummaryClose();
+            log.info("newsScheduledTaskStorePinkSummaryClose end");
+        } catch (Exception e) {
+            log.error("newScheduledTaskStorePinkSummaryCloseError:e{}", e);
+            return ReturnT.FAIL;
+        }
         return ReturnT.SUCCESS;
     }
 
+    @XxlJob("newScheduledTaskBatchSigning")
+    public ReturnT<String> newScheduledTaskBatchSigning(String param) throws Exception {
+        try {
+            log.info("newScheduledTaskBatchSigning start");
+            storeOrderService.batchSigning();
+            log.info("newScheduledTaskBatchSigning end");
+        } catch (Exception e) {
+            log.error("newScheduledTaskBatchSigningError:e{}", e);
+            return ReturnT.FAIL;
+        }
+        return ReturnT.SUCCESS;
+    }
+
+
+    @XxlJob("newOrderTimeoutAutomaticCancel")
+    public ReturnT<String> newOrderTimeoutAutomaticCancel(String param) throws Exception {
+        try {
+            log.info("newOrderTimeoutAutomaticCancel start");
+            storeOrderService.orderTimeoutAutomaticCancel();
+            log.info("newOrderTimeoutAutomaticCancel end");
+        } catch (Exception e) {
+            log.error("newOrderTimeoutAutomaticCancelError:e{}", e);
+            return ReturnT.FAIL;
+        }
+        return ReturnT.SUCCESS;
+    }
+
+
+
+    @XxlJob("newActivityStatusJudgmentTimedTask")
+    public ReturnT<String> newActivityStatusJudgmentTimedTask(String param) throws Exception {
+        try {
+            log.info("newActivityStatusJudgmentTimedTask start");
+            storeFlashActivityService.activityStatusJudgmentTimedTask();
+            log.info("newActivityStatusJudgmentTimedTask end");
+        } catch (Exception e) {
+            log.error("newActivityStatusJudgmentTimedTaskError:e{}", e);
+            return ReturnT.FAIL;
+        }
+        return ReturnT.SUCCESS;
+    }
+
+
 }

+ 32 - 2
mall-service/src/main/resources/bootstrap.properties

@@ -42,12 +42,13 @@ spring.cloud.nacos.config.extension-configs[0]=mq-${spring.profiles.active}.prop
 spring.cloud.nacos.config.extension-configs[1]=redis-${spring.profiles.active}.properties
 spring.cloud.nacos.config.extension-configs[2]=${spring.application.name}-${spring.profiles.active}.properties
 
-spring.cloud.nacos.config.extension-configs[3]=xxljob-${spring.profiles.active}.properties
+#spring.cloud.nacos.config.extension-configs[3]=xxljob-${spring.profiles.active}.properties
 dubbo.protocol.serialization=kryo
 #dubbo.protocol.serialization=
 dubbo.protocol.optimizer=
 dubbo.protocol.name=dubbo
 dubbo.protocol.port=-1
+
 dubbo.registry.address=nacos://${${spring.profiles.active}.nacos}
 dubbo.scan.base-packages=com.txz.${spring.application.name}.dubbo.impl
 #dubbo.cloud.subscribed-services=cif
@@ -77,8 +78,37 @@ logging.level.com.txz.mall.dao=DEBUG
 logging.level.org.apache.ibatis=DEBUG
 logging.level.java.sql=DEBUG
 
+redisson.singleServerConfig.address=redis://124.220.229.80:6379
+redisson.singleServerConfig.password=mypassword
+# \u9ED8\u8BA4\u6570\u636E\u5E93\u4E3A0
+redisson.singleServerConfig.database=0
+
+redisson.singleServerConfig.connectionPoolSize=15
+# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5\u6570
+redisson.singleServerConfig.connectionMinimumIdleSize=5
+# \u8FDE\u63A5\u7A7A\u95F2\u8D85\u65F6\uFF0C\u5355\u4F4D\uFF1A\u6BEB\u79D2
+redisson.singleServerConfig.idleConnectionTimeout=10000
+# \u8D85\u65F6\u65F6\u95F4\uFF0C\u5355\u4F4D\uFF1A\u6BEB\u79D2
+redisson.singleServerConfig.connectTimeout=30000
+# \u547D\u4EE4\u7B49\u5F85\u8D85\u65F6\uFF0C\u5355\u4F4D\uFF1A\u6BEB\u79D2
+redisson.singleServerConfig.timeout=30000
+# \u547D\u4EE4\u5931\u8D25\u91CD\u8BD5\u6B21\u6570
+redisson.singleServerConfig.retryAttempts=2
+# \u547D\u4EE4\u91CD\u8BD5\u53D1\u9001\u65F6\u95F4\u95F4\u9694\uFF0C\u5355\u4F4D\uFF1A\u6BEB\u79D2
+redisson.singleServerConfig.retryInterval=1500
+
+
+
 local.job=http://8.219.117.74/xxl-job-admin
 dev.job=http://124.220.229.80:9096/xxl-job-admin
 test.job=http://172.10.100.40:8080/xxl-job-admin
 pro.job=http://172.10.100.40:8080/xxl-job-admin
-dev.accessToken=
+dev.accessToken=
+
+xxl.job.admin.addresses=${${spring.profiles.active}.job}
+xxl.job.executor.appname=${spring.application.name}executor
+xxl.job.accessToken=${${spring.profiles.active}.accessToken}
+xxl.job.executor.ip=
+xxl.job.executor.port=4444
+xxl.job.executor.logpath=/var/logs/xxljob/${spring.application.name}/jobhandler
+xxl.job.executor.logretentiondays=4

+ 8 - 0
mall-service/src/main/resources/logback.xml

@@ -58,6 +58,11 @@
     <logger name="java.sql.PreparedStatement" level="DEBUG"/>
 	<logger name="com.txz.mall" />
 
+    <logger name="io.lettuce" level="DEBUG"/>
+    <logger name="redis.clients.jedis" level="DEBUG"/>
+    <logger name="org.redisson" level="DEBUG"/>
+
+
     <!-- 日志输出级别 -->
     <root level="INFO">
         <appender-ref ref="STDOUT" />
@@ -65,6 +70,9 @@
         <appender-ref ref="ERROR_FILE" />
     </root>
 
+
+
+
     <!--日志异步到数据库 -->
     <!--<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">-->
         <!--&lt;!&ndash;日志异步到数据库 &ndash;&gt;-->

+ 17 - 0
mall-service/src/main/resources/mapper/StorePinkMapper.xml

@@ -30,4 +30,21 @@
         <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
         <result column="is_delete" jdbcType="INTEGER" property="isDelete"/>
     </resultMap>
+
+    <select id="getRank" resultType="map">
+
+        select pid as pid ,count(*) as num
+        from m_store_pink
+        where order_status in (3,4,5,6,7,8)
+        and pid in
+        <foreach collection='productSet' item='item' open='(' separator=',' close=')'>
+            #{item}
+        </foreach>
+        and create_time > #{date}
+        group by pid
+        ORDER BY num desc limit 20
+
+    </select>
+
+
 </mapper>