提交代码

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默认的消息推送主题,实际可在调用接口是指定
# 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

@ -150,19 +150,21 @@ public class WeiXinController {
order.setPayTime(new Date());
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)) {
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());

@ -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

@ -57,12 +57,14 @@ public class TradeOrderSchedule {
param.put("tradeOrderProfitSharingId", tradeOrderProfitSharing.getId());
List<BsTradeOrderProfitSharingReceiver> 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())) {

@ -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

@ -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<String, Map<String, SecDictionary>> dicCache = new HashMap<String,Map<String, SecDictionary>>();
private List<SecRegion> citiesCache = new ArrayList<>();
private Map<Long,List<SecRegion>> regionsCache = new HashMap<>();
private Map<Long,List<SecRegion>> streetCache = new HashMap<>();
private Map<Long,List<SecRegion>> communityCache = new HashMap<>();
private Map<Long, SecRegion> singleRegionCache = new HashMap<>();
@CreateCache(name = "cities:", cacheType = CacheType.REMOTE)
private Cache<Long, SecRegion> citiesCache;
@CreateCache(name = "region:", cacheType = CacheType.REMOTE)
private Cache<Long,List<SecRegion>> regionsCache;
@CreateCache(name = "regionStreet:", cacheType = CacheType.REMOTE)
private Cache<Long,List<SecRegion>> streetCache;
@CreateCache(name = "regionCommunity:", cacheType = CacheType.REMOTE)
private Cache<Long,List<SecRegion>> communityCache;
@CreateCache(name = "regionSingle:", cacheType = CacheType.REMOTE)
private Cache<Long, SecRegion> singleRegionCache;
@Override
public Map<String, List<SecDictionary>> getDictionaries() {
@ -276,17 +278,20 @@ public class CommonServiceImpl implements CommonService {
@Override
public List<SecRegion> 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<SecRegion> citiesList = regionMapper.selectByExample(example);
for(SecRegion city : citiesList){ // 省
citiesCache.put(city.getRegionId(), city);
singleRegionCache.put(city.getRegionId(), city);
List<SecRegion> regions = getRegions(city.getRegionId());
regionsCache.put(city.getRegionId(),regions);

Loading…
Cancel
Save