diff --git a/bweb/src/main/resources/prod/application.yml b/bweb/src/main/resources/prod/application.yml index 3da2558..71a0b38 100644 --- a/bweb/src/main/resources/prod/application.yml +++ b/bweb/src/main/resources/prod/application.yml @@ -57,6 +57,28 @@ spring: #MQTT默认的消息推送主题,实际可在调用接口是指定 # default: # topic: topic +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 127.0.0.1 + port: 36379 + password: HF123456.Redis + database: 2 + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 mybatis: mapperLocations: - classpath*:sqlmap*/*.xml diff --git a/cweb/src/main/java/com/cweb/notify/WeiXinController.java b/cweb/src/main/java/com/cweb/notify/WeiXinController.java index b5910ac..30f9566 100644 --- a/cweb/src/main/java/com/cweb/notify/WeiXinController.java +++ b/cweb/src/main/java/com/cweb/notify/WeiXinController.java @@ -150,19 +150,21 @@ public class WeiXinController { order.setPayTime(new Date()); tradeOrderService.editOrder(order); + new Thread(() -> { + Map param = new HashMap<>(); + param.put("storeId", order.getStoreId()); + param.put("deviceType", DeviceTypeEnum.type1.getNumber()); + param.put("status", DeviceStatusEnum.status1.getNumber()); + List deviceList = deviceService.getDeviceList(param); + for (BsDevice device : deviceList) { + soundService.sendPayMsg(device.getDeviceNo(), order.getTradeAmount()); + } + }); + // 创建分账 if (order.getProfitSharingStatus().equals(true)) { tradeOrderProfitSharingService.createProfitSharing(order); } - - Map param = new HashMap<>(); - param.put("storeId", order.getStoreId()); - param.put("deviceType", DeviceTypeEnum.type1.getNumber()); - param.put("status", DeviceStatusEnum.status1.getNumber()); - List deviceList = deviceService.getDeviceList(param); - for (BsDevice device : deviceList) { - soundService.sendPayMsg(device.getDeviceNo(), order.getTradeAmount()); - } } } BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); diff --git a/cweb/src/main/resources/prod/application.yml b/cweb/src/main/resources/prod/application.yml index 4cc1060..62ffa56 100644 --- a/cweb/src/main/resources/prod/application.yml +++ b/cweb/src/main/resources/prod/application.yml @@ -58,6 +58,30 @@ spring: #MQTT默认的消息推送主题,实际可在调用接口是指定 # default: # topic: topic + +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 127.0.0.1 + port: 36379 + password: HF123456.Redis + database: 2 + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 + mybatis: mapperLocations: - classpath*:sqlmap*/*.xml diff --git a/schedule/src/main/java/com/hfkj/schedule/TradeOrderSchedule.java b/schedule/src/main/java/com/hfkj/schedule/TradeOrderSchedule.java index 79299b1..6d15ec4 100644 --- a/schedule/src/main/java/com/hfkj/schedule/TradeOrderSchedule.java +++ b/schedule/src/main/java/com/hfkj/schedule/TradeOrderSchedule.java @@ -57,12 +57,14 @@ public class TradeOrderSchedule { param.put("tradeOrderProfitSharingId", tradeOrderProfitSharing.getId()); List profitSharingReceivers = tradeOrderProfitSharingReceiverService.getProfitSharingList(param); for (BsTradeOrderProfitSharingReceiver receiver : profitSharingReceivers) { - receiversMap = new HashMap<>(); - receiversMap.put("type", "MERCHANT_ID"); - receiversMap.put("account", receiver.getReceiverAccount()); - receiversMap.put("amount", receiver.getReceiverAmount().multiply(new BigDecimal("100")).intValue()); - receiversMap.put("description", "分给商户:" + receiver.getReceiverName()); - receiversList.add(receiversMap); + if (!receiver.getReceiverAccount().equals(new BigDecimal("0"))) { + receiversMap = new HashMap<>(); + receiversMap.put("type", "MERCHANT_ID"); + receiversMap.put("account", receiver.getReceiverAccount()); + receiversMap.put("amount", receiver.getReceiverAmount().multiply(new BigDecimal("100")).intValue()); + receiversMap.put("description", "分给商户:" + receiver.getReceiverName()); + receiversList.add(receiversMap); + } } if (tradeOrderProfitSharing.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { diff --git a/schedule/src/main/resources/prod/application.yml b/schedule/src/main/resources/prod/application.yml index 9e0d102..82f0d50 100644 --- a/schedule/src/main/resources/prod/application.yml +++ b/schedule/src/main/resources/prod/application.yml @@ -59,7 +59,28 @@ spring: #MQTT默认的消息推送主题,实际可在调用接口是指定 # default: # topic: topic - +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 127.0.0.1 + port: 36379 + password: HF123456.Redis + database: 2 + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 mybatis: mapperLocations: - classpath*:sqlmap*/*.xml diff --git a/service/src/main/java/com/hfkj/service/impl/CommonServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/CommonServiceImpl.java index a708a11..3805939 100644 --- a/service/src/main/java/com/hfkj/service/impl/CommonServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/CommonServiceImpl.java @@ -3,9 +3,11 @@ package com.hfkj.service.impl; import com.alibaba.fastjson.JSONObject; import com.alicp.jetcache.Cache; +import com.alicp.jetcache.RefreshPolicy; import com.alicp.jetcache.anno.CacheType; import com.alicp.jetcache.anno.Cached; import com.alicp.jetcache.anno.CreateCache; +import com.alicp.jetcache.embedded.LinkedHashMapCacheBuilder; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; @@ -20,6 +22,7 @@ import com.hfkj.service.CommonService; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.*; import java.util.concurrent.TimeUnit; @@ -48,19 +51,18 @@ public class CommonServiceImpl implements CommonService { @Resource private SecDictionaryMapper dicMapper; - - private Map> dicCache = new HashMap>(); - - private List citiesCache = new ArrayList<>(); - - private Map> regionsCache = new HashMap<>(); - private Map> streetCache = new HashMap<>(); - - private Map> communityCache = new HashMap<>(); - - private Map singleRegionCache = new HashMap<>(); + @CreateCache(name = "cities:", cacheType = CacheType.REMOTE) + private Cache citiesCache; + @CreateCache(name = "region:", cacheType = CacheType.REMOTE) + private Cache> regionsCache; + @CreateCache(name = "regionStreet:", cacheType = CacheType.REMOTE) + private Cache> streetCache; + @CreateCache(name = "regionCommunity:", cacheType = CacheType.REMOTE) + private Cache> communityCache; + @CreateCache(name = "regionSingle:", cacheType = CacheType.REMOTE) + private Cache singleRegionCache; @Override public Map> getDictionaries() { @@ -276,17 +278,20 @@ public class CommonServiceImpl implements CommonService { @Override public List getCities() { refreshRegion(); - return citiesCache; + SecRegionExample example = new SecRegionExample(); + example.createCriteria().andStatusEqualTo(1).andParentIdIsNull(); + return regionMapper.selectByExample(example); } - private void refreshRegion(){ - if (System.currentTimeMillis() - regionLastReadTime < READ_STEP) { - return; - } - if (regionLock.isLocked()) { //说明有线程已经在刷数据了 - if (null != dicCache && dicCache.size() > 0) { //如果有数据说明已经初始化过了,直接返回老数据 + + private void refreshRegion() { + if (regionsCache.get(500000L) != null) { + return; + } + if (regionLock.isLocked()) { // 说明有线程已经在刷数据了 + if (null != regionsCache) { //如果有数据说明已经初始化过了,直接返回老数据 return; } - while (null == dicCache || dicCache.size()<1) { //说明初始化刷数据 等待10毫秒 + while (null == regionsCache) { //说明初始化刷数据 等待10毫秒 try { Thread.sleep(10); //此处是否需要添加一个超时机制? @@ -311,8 +316,9 @@ public class CommonServiceImpl implements CommonService { private void getRegionFromDB(){ SecRegionExample example = new SecRegionExample(); example.createCriteria().andStatusEqualTo(1).andParentIdIsNull(); - citiesCache = regionMapper.selectByExample(example); - for(SecRegion city : citiesCache){ // 省 + List citiesList = regionMapper.selectByExample(example); + for(SecRegion city : citiesList){ // 省 + citiesCache.put(city.getRegionId(), city); singleRegionCache.put(city.getRegionId(), city); List regions = getRegions(city.getRegionId()); regionsCache.put(city.getRegionId(),regions);