提交代码

yy_dev
胡锐 2 years ago
parent 8d156bc7bd
commit c75a2c4fa2
  1. 22
      bweb/src/main/resources/prod/application.yml
  2. 20
      cweb/src/main/java/com/cweb/notify/WeiXinController.java
  3. 24
      cweb/src/main/resources/prod/application.yml
  4. 14
      schedule/src/main/java/com/hfkj/schedule/TradeOrderSchedule.java
  5. 23
      schedule/src/main/resources/prod/application.yml
  6. 48
      service/src/main/java/com/hfkj/service/impl/CommonServiceImpl.java

@ -57,6 +57,28 @@ spring:
#MQTT默认的消息推送主题,实际可在调用接口是指定 #MQTT默认的消息推送主题,实际可在调用接口是指定
# default: # default:
# topic: topic # 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: mybatis:
mapperLocations: mapperLocations:
- classpath*:sqlmap*/*.xml - classpath*:sqlmap*/*.xml

@ -150,19 +150,21 @@ public class WeiXinController {
order.setPayTime(new Date()); order.setPayTime(new Date());
tradeOrderService.editOrder(order); tradeOrderService.editOrder(order);
new Thread(() -> {
Map<String,Object> param = new HashMap<>();
param.put("storeId", order.getStoreId());
param.put("deviceType", DeviceTypeEnum.type1.getNumber());
param.put("status", DeviceStatusEnum.status1.getNumber());
List<BsDevice> deviceList = deviceService.getDeviceList(param);
for (BsDevice device : deviceList) {
soundService.sendPayMsg(device.getDeviceNo(), order.getTradeAmount());
}
});
// 创建分账 // 创建分账
if (order.getProfitSharingStatus().equals(true)) { if (order.getProfitSharingStatus().equals(true)) {
tradeOrderProfitSharingService.createProfitSharing(order); tradeOrderProfitSharingService.createProfitSharing(order);
} }
Map<String,Object> param = new HashMap<>();
param.put("storeId", order.getStoreId());
param.put("deviceType", DeviceTypeEnum.type1.getNumber());
param.put("status", DeviceStatusEnum.status1.getNumber());
List<BsDevice> deviceList = deviceService.getDeviceList(param);
for (BsDevice device : deviceList) {
soundService.sendPayMsg(device.getDeviceNo(), order.getTradeAmount());
}
} }
} }
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());

@ -58,6 +58,30 @@ spring:
#MQTT默认的消息推送主题,实际可在调用接口是指定 #MQTT默认的消息推送主题,实际可在调用接口是指定
# default: # default:
# topic: topic # 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: mybatis:
mapperLocations: mapperLocations:
- classpath*:sqlmap*/*.xml - classpath*:sqlmap*/*.xml

@ -57,12 +57,14 @@ public class TradeOrderSchedule {
param.put("tradeOrderProfitSharingId", tradeOrderProfitSharing.getId()); param.put("tradeOrderProfitSharingId", tradeOrderProfitSharing.getId());
List<BsTradeOrderProfitSharingReceiver> profitSharingReceivers = tradeOrderProfitSharingReceiverService.getProfitSharingList(param); List<BsTradeOrderProfitSharingReceiver> profitSharingReceivers = tradeOrderProfitSharingReceiverService.getProfitSharingList(param);
for (BsTradeOrderProfitSharingReceiver receiver : profitSharingReceivers) { for (BsTradeOrderProfitSharingReceiver receiver : profitSharingReceivers) {
receiversMap = new HashMap<>(); if (!receiver.getReceiverAccount().equals(new BigDecimal("0"))) {
receiversMap.put("type", "MERCHANT_ID"); receiversMap = new HashMap<>();
receiversMap.put("account", receiver.getReceiverAccount()); receiversMap.put("type", "MERCHANT_ID");
receiversMap.put("amount", receiver.getReceiverAmount().multiply(new BigDecimal("100")).intValue()); receiversMap.put("account", receiver.getReceiverAccount());
receiversMap.put("description", "分给商户:" + receiver.getReceiverName()); receiversMap.put("amount", receiver.getReceiverAmount().multiply(new BigDecimal("100")).intValue());
receiversList.add(receiversMap); receiversMap.put("description", "分给商户:" + receiver.getReceiverName());
receiversList.add(receiversMap);
}
} }
if (tradeOrderProfitSharing.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { if (tradeOrderProfitSharing.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) {

@ -59,7 +59,28 @@ spring:
#MQTT默认的消息推送主题,实际可在调用接口是指定 #MQTT默认的消息推送主题,实际可在调用接口是指定
# default: # default:
# topic: topic # 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: mybatis:
mapperLocations: mapperLocations:
- classpath*:sqlmap*/*.xml - classpath*:sqlmap*/*.xml

@ -3,9 +3,11 @@ package com.hfkj.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alicp.jetcache.Cache; import com.alicp.jetcache.Cache;
import com.alicp.jetcache.RefreshPolicy;
import com.alicp.jetcache.anno.CacheType; import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached; import com.alicp.jetcache.anno.Cached;
import com.alicp.jetcache.anno.CreateCache; import com.alicp.jetcache.anno.CreateCache;
import com.alicp.jetcache.embedded.LinkedHashMapCacheBuilder;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
@ -20,6 +22,7 @@ import com.hfkj.service.CommonService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -48,19 +51,18 @@ public class CommonServiceImpl implements CommonService {
@Resource @Resource
private SecDictionaryMapper dicMapper; private SecDictionaryMapper dicMapper;
private Map<String, Map<String, SecDictionary>> dicCache = new HashMap<String,Map<String, SecDictionary>>(); private Map<String, Map<String, SecDictionary>> dicCache = new HashMap<String,Map<String, SecDictionary>>();
private List<SecRegion> citiesCache = new ArrayList<>(); @CreateCache(name = "cities:", cacheType = CacheType.REMOTE)
private Cache<Long, SecRegion> citiesCache;
private Map<Long,List<SecRegion>> regionsCache = new HashMap<>(); @CreateCache(name = "region:", cacheType = CacheType.REMOTE)
private Cache<Long,List<SecRegion>> regionsCache;
private Map<Long,List<SecRegion>> streetCache = new HashMap<>(); @CreateCache(name = "regionStreet:", cacheType = CacheType.REMOTE)
private Cache<Long,List<SecRegion>> streetCache;
private Map<Long,List<SecRegion>> communityCache = new HashMap<>(); @CreateCache(name = "regionCommunity:", cacheType = CacheType.REMOTE)
private Cache<Long,List<SecRegion>> communityCache;
private Map<Long, SecRegion> singleRegionCache = new HashMap<>(); @CreateCache(name = "regionSingle:", cacheType = CacheType.REMOTE)
private Cache<Long, SecRegion> singleRegionCache;
@Override @Override
public Map<String, List<SecDictionary>> getDictionaries() { public Map<String, List<SecDictionary>> getDictionaries() {
@ -276,17 +278,20 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public List<SecRegion> getCities() { public List<SecRegion> getCities() {
refreshRegion(); 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) { private void refreshRegion() {
return; if (regionsCache.get(500000L) != null) {
} return;
if (regionLock.isLocked()) { //说明有线程已经在刷数据了 }
if (null != dicCache && dicCache.size() > 0) { //如果有数据说明已经初始化过了,直接返回老数据 if (regionLock.isLocked()) { // 说明有线程已经在刷数据了
if (null != regionsCache) { //如果有数据说明已经初始化过了,直接返回老数据
return; return;
} }
while (null == dicCache || dicCache.size()<1) { //说明初始化刷数据 等待10毫秒 while (null == regionsCache) { //说明初始化刷数据 等待10毫秒
try { try {
Thread.sleep(10); Thread.sleep(10);
//此处是否需要添加一个超时机制? //此处是否需要添加一个超时机制?
@ -311,8 +316,9 @@ public class CommonServiceImpl implements CommonService {
private void getRegionFromDB(){ private void getRegionFromDB(){
SecRegionExample example = new SecRegionExample(); SecRegionExample example = new SecRegionExample();
example.createCriteria().andStatusEqualTo(1).andParentIdIsNull(); example.createCriteria().andStatusEqualTo(1).andParentIdIsNull();
citiesCache = regionMapper.selectByExample(example); List<SecRegion> citiesList = regionMapper.selectByExample(example);
for(SecRegion city : citiesCache){ // 省 for(SecRegion city : citiesList){ // 省
citiesCache.put(city.getRegionId(), city);
singleRegionCache.put(city.getRegionId(), city); singleRegionCache.put(city.getRegionId(), city);
List<SecRegion> regions = getRegions(city.getRegionId()); List<SecRegion> regions = getRegions(city.getRegionId());
regionsCache.put(city.getRegionId(),regions); regionsCache.put(city.getRegionId(),regions);

Loading…
Cancel
Save