|
|
@ -1,13 +1,15 @@ |
|
|
|
package com.hai.service.impl; |
|
|
|
package com.hai.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import com.google.gson.JsonArray; |
|
|
|
|
|
|
|
import com.google.gson.JsonObject; |
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
import com.hai.dao.SecDictionaryMapper; |
|
|
|
import com.hai.dao.*; |
|
|
|
import com.hai.dao.SecRegionMapper; |
|
|
|
|
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.model.IndexCountModel; |
|
|
|
import com.hai.model.IndexCountModel; |
|
|
|
import com.hai.model.LineCountModel; |
|
|
|
import com.hai.model.LineCountModel; |
|
|
@ -17,6 +19,8 @@ import com.hai.service.HighUserService; |
|
|
|
import com.hai.service.SecConfigService; |
|
|
|
import com.hai.service.SecConfigService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
@ -27,7 +31,7 @@ import java.util.concurrent.locks.ReentrantLock; |
|
|
|
@Service("iCommonService") |
|
|
|
@Service("iCommonService") |
|
|
|
public class CommonServiceImpl implements CommonService { |
|
|
|
public class CommonServiceImpl implements CommonService { |
|
|
|
|
|
|
|
|
|
|
|
private long READ_STEP = 30*60*1000; //半小时刷新一次缓存的字典数据
|
|
|
|
private long READ_STEP = 30 * 60 * 1000; //半小时刷新一次缓存的字典数据
|
|
|
|
|
|
|
|
|
|
|
|
private ReentrantLock lock = new ReentrantLock(); |
|
|
|
private ReentrantLock lock = new ReentrantLock(); |
|
|
|
|
|
|
|
|
|
|
@ -52,20 +56,29 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HighOrderService highOrderService; |
|
|
|
private HighOrderService highOrderService; |
|
|
|
|
|
|
|
|
|
|
|
private Map<String, Map<String, SecDictionary>> dicCache = new HashMap<String,Map<String, SecDictionary>>(); |
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsProductPlatformMapper bsProductPlatformMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsProductDiscountMapper bsProductDiscountMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsProductPayTypeMapper bsProductPayTypeMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, Map<String, SecDictionary>> dicCache = new HashMap<String, Map<String, SecDictionary>>(); |
|
|
|
|
|
|
|
|
|
|
|
private List<SecRegion> citiesCache = new ArrayList<>(); |
|
|
|
private List<SecRegion> citiesCache = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
private Map<Long,List<SecRegion>> regionsCache = new HashMap<>(); |
|
|
|
private Map<Long, List<SecRegion>> regionsCache = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
private Map<Long,List<SecRegion>> streetCache = new HashMap<>(); |
|
|
|
private Map<Long, List<SecRegion>> streetCache = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
private Map<Long,List<SecRegion>> communityCache = new HashMap<>(); |
|
|
|
private Map<Long, List<SecRegion>> communityCache = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
private Map<Long, SecRegion> singleRegionCache = new HashMap<>(); |
|
|
|
private Map<Long, SecRegion> singleRegionCache = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String,Map<String, SecDictionary>> getDictionaries() { |
|
|
|
public Map<String, Map<String, SecDictionary>> getDictionaries() { |
|
|
|
refreshDic(); |
|
|
|
refreshDic(); |
|
|
|
return dicCache; |
|
|
|
return dicCache; |
|
|
|
} |
|
|
|
} |
|
|
@ -86,7 +99,7 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getDictionaryCodeName(String codeType, String codeValue) { |
|
|
|
public String getDictionaryCodeName(String codeType, String codeValue) { |
|
|
|
refreshDic(); |
|
|
|
refreshDic(); |
|
|
|
if(StringUtils.isBlank(codeType)){ |
|
|
|
if (StringUtils.isBlank(codeType)) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, SecDictionary> m = dicCache.get(codeType); |
|
|
|
Map<String, SecDictionary> m = dicCache.get(codeType); |
|
|
@ -116,7 +129,7 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public SecDictionary mappingSysCode(String codeType, String codeValue) { |
|
|
|
public SecDictionary mappingSysCode(String codeType, String codeValue) { |
|
|
|
refreshDic(); |
|
|
|
refreshDic(); |
|
|
|
if(StringUtils.isBlank(codeType)){ |
|
|
|
if (StringUtils.isBlank(codeType)) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, SecDictionary> m = dicCache.get(codeType); |
|
|
|
Map<String, SecDictionary> m = dicCache.get(codeType); |
|
|
@ -130,14 +143,14 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public SecDictionary mappingSysName(String codeType, String codeName) { |
|
|
|
public SecDictionary mappingSysName(String codeType, String codeName) { |
|
|
|
refreshDic(); |
|
|
|
refreshDic(); |
|
|
|
if(StringUtils.isBlank(codeType)){ |
|
|
|
if (StringUtils.isBlank(codeType)) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, SecDictionary> m = dicCache.get(codeType); |
|
|
|
Map<String, SecDictionary> m = dicCache.get(codeType); |
|
|
|
if (null == m) { |
|
|
|
if (null == m) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
for(Map.Entry<String, SecDictionary> entry : m.entrySet()){ |
|
|
|
for (Map.Entry<String, SecDictionary> entry : m.entrySet()) { |
|
|
|
String mapKey = entry.getKey(); |
|
|
|
String mapKey = entry.getKey(); |
|
|
|
SecDictionary mapValue = entry.getValue(); |
|
|
|
SecDictionary mapValue = entry.getValue(); |
|
|
|
if (mapValue.getCodeName().equals(codeName)) { |
|
|
|
if (mapValue.getCodeName().equals(codeName)) { |
|
|
@ -179,7 +192,7 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
List<SecDictionary> rtn = new ArrayList<>(); |
|
|
|
List<SecDictionary> rtn = new ArrayList<>(); |
|
|
|
for(SecDictionary dictionary : maps.values()){ |
|
|
|
for (SecDictionary dictionary : maps.values()) { |
|
|
|
if (ext1.equals(dictionary.getExt1())) { |
|
|
|
if (ext1.equals(dictionary.getExt1())) { |
|
|
|
rtn.add(dictionary); |
|
|
|
rtn.add(dictionary); |
|
|
|
} |
|
|
|
} |
|
|
@ -198,25 +211,25 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
List<JSONObject> rtn = new ArrayList<>(); |
|
|
|
List<JSONObject> rtn = new ArrayList<>(); |
|
|
|
for(SecDictionary dictionary : maps.values()){ |
|
|
|
for (SecDictionary dictionary : maps.values()) { |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("codeValue",dictionary.getCodeValue()); |
|
|
|
jo.put("codeValue", dictionary.getCodeValue()); |
|
|
|
jo.put("codeName",dictionary.getCodeName()); |
|
|
|
jo.put("codeName", dictionary.getCodeName()); |
|
|
|
rtn.add(jo); |
|
|
|
rtn.add(jo); |
|
|
|
} |
|
|
|
} |
|
|
|
return rtn; |
|
|
|
return rtn; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void getDicFormDB(){ |
|
|
|
private void getDicFormDB() { |
|
|
|
SecDictionaryExample example = new SecDictionaryExample(); |
|
|
|
SecDictionaryExample example = new SecDictionaryExample(); |
|
|
|
example.createCriteria().andStatusEqualTo(1); |
|
|
|
example.createCriteria().andStatusEqualTo(1); |
|
|
|
example.setOrderByClause(" sort_id asc"); |
|
|
|
example.setOrderByClause(" sort_id asc"); |
|
|
|
List<SecDictionary> dicList = dicMapper.selectByExample(example); |
|
|
|
List<SecDictionary> dicList = dicMapper.selectByExample(example); |
|
|
|
for(SecDictionary dic : dicList){ |
|
|
|
for (SecDictionary dic : dicList) { |
|
|
|
if(dicCache.get(dic.getCodeType()) != null){ |
|
|
|
if (dicCache.get(dic.getCodeType()) != null) { |
|
|
|
Map<String, SecDictionary> typeList = dicCache.get(dic.getCodeType()); |
|
|
|
Map<String, SecDictionary> typeList = dicCache.get(dic.getCodeType()); |
|
|
|
typeList.put(dic.getCodeValue(), dic); |
|
|
|
typeList.put(dic.getCodeValue(), dic); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
Map<String, SecDictionary> temp = new HashMap<String, SecDictionary>(); |
|
|
|
Map<String, SecDictionary> temp = new HashMap<String, SecDictionary>(); |
|
|
|
temp.put(dic.getCodeValue(), dic); |
|
|
|
temp.put(dic.getCodeValue(), dic); |
|
|
|
dicCache.put(dic.getCodeType(), temp); |
|
|
|
dicCache.put(dic.getCodeType(), temp); |
|
|
@ -233,7 +246,7 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
if (null != dicCache && dicCache.size() > 0) { //如果有数据说明已经初始化过了,直接返回老数据
|
|
|
|
if (null != dicCache && dicCache.size() > 0) { //如果有数据说明已经初始化过了,直接返回老数据
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
while (null == dicCache || dicCache.size()<1) { //说明初始化刷数据 等待10毫秒
|
|
|
|
while (null == dicCache || dicCache.size() < 1) { //说明初始化刷数据 等待10毫秒
|
|
|
|
try { |
|
|
|
try { |
|
|
|
Thread.sleep(10); |
|
|
|
Thread.sleep(10); |
|
|
|
//此处是否需要添加一个超时机制?
|
|
|
|
//此处是否需要添加一个超时机制?
|
|
|
@ -261,7 +274,8 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
refreshRegion(); |
|
|
|
refreshRegion(); |
|
|
|
return citiesCache; |
|
|
|
return citiesCache; |
|
|
|
} |
|
|
|
} |
|
|
|
private void refreshRegion(){ |
|
|
|
|
|
|
|
|
|
|
|
private void refreshRegion() { |
|
|
|
if (System.currentTimeMillis() - regionLastReadTime < READ_STEP) { |
|
|
|
if (System.currentTimeMillis() - regionLastReadTime < READ_STEP) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -269,7 +283,7 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
if (null != dicCache && dicCache.size() > 0) { //如果有数据说明已经初始化过了,直接返回老数据
|
|
|
|
if (null != dicCache && dicCache.size() > 0) { //如果有数据说明已经初始化过了,直接返回老数据
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
while (null == dicCache || dicCache.size()<1) { //说明初始化刷数据 等待10毫秒
|
|
|
|
while (null == dicCache || dicCache.size() < 1) { //说明初始化刷数据 等待10毫秒
|
|
|
|
try { |
|
|
|
try { |
|
|
|
Thread.sleep(10); |
|
|
|
Thread.sleep(10); |
|
|
|
//此处是否需要添加一个超时机制?
|
|
|
|
//此处是否需要添加一个超时机制?
|
|
|
@ -291,24 +305,25 @@ 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); |
|
|
|
citiesCache = regionMapper.selectByExample(example); |
|
|
|
for(SecRegion city : citiesCache){//市
|
|
|
|
for (SecRegion city : citiesCache) {//市
|
|
|
|
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); |
|
|
|
for(SecRegion region : regions){//区
|
|
|
|
for (SecRegion region : regions) {//区
|
|
|
|
singleRegionCache.put(region.getRegionId(), region); |
|
|
|
singleRegionCache.put(region.getRegionId(), region); |
|
|
|
List<SecRegion> streets = getRegions(region.getRegionId()); |
|
|
|
List<SecRegion> streets = getRegions(region.getRegionId()); |
|
|
|
streetCache.put(region.getRegionId(), streets); |
|
|
|
streetCache.put(region.getRegionId(), streets); |
|
|
|
for(SecRegion street : streets){ |
|
|
|
for (SecRegion street : streets) { |
|
|
|
singleRegionCache.put(street.getRegionId(), street); |
|
|
|
singleRegionCache.put(street.getRegionId(), street); |
|
|
|
List<SecRegion> communities = getRegions(street.getRegionId()); |
|
|
|
List<SecRegion> communities = getRegions(street.getRegionId()); |
|
|
|
communityCache.put(street.getRegionId(),communities); |
|
|
|
communityCache.put(street.getRegionId(), communities); |
|
|
|
for (SecRegion community : communities){ |
|
|
|
for (SecRegion community : communities) { |
|
|
|
singleRegionCache.put(community.getRegionId(),community); |
|
|
|
singleRegionCache.put(community.getRegionId(), community); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -321,45 +336,46 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
example.createCriteria().andStatusEqualTo(1).andParentIdEqualTo(parentId); |
|
|
|
example.createCriteria().andStatusEqualTo(1).andParentIdEqualTo(parentId); |
|
|
|
return regionMapper.selectByExample(example); |
|
|
|
return regionMapper.selectByExample(example); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<SecRegion> getRegionsByParentId(Long parentId) { |
|
|
|
public List<SecRegion> getRegionsByParentId(Long parentId) { |
|
|
|
if(parentId == null){ |
|
|
|
if (parentId == null) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
refreshRegion(); |
|
|
|
refreshRegion(); |
|
|
|
if(null != regionsCache.get(parentId)){ |
|
|
|
if (null != regionsCache.get(parentId)) { |
|
|
|
return regionsCache.get(parentId); |
|
|
|
return regionsCache.get(parentId); |
|
|
|
}else if(null != streetCache.get(parentId)){ |
|
|
|
} else if (null != streetCache.get(parentId)) { |
|
|
|
return streetCache.get(parentId); |
|
|
|
return streetCache.get(parentId); |
|
|
|
}else if(null != communityCache.get(parentId)){ |
|
|
|
} else if (null != communityCache.get(parentId)) { |
|
|
|
return communityCache.get(parentId); |
|
|
|
return communityCache.get(parentId); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, SecRegion> getParentInfoByRegionId(Long regionId) { |
|
|
|
public Map<String, SecRegion> getParentInfoByRegionId(Long regionId) { |
|
|
|
if(regionId == null){ |
|
|
|
if (regionId == null) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
refreshRegion(); |
|
|
|
refreshRegion(); |
|
|
|
Map<String, SecRegion> map = new HashMap<String, SecRegion>(); |
|
|
|
Map<String, SecRegion> map = new HashMap<String, SecRegion>(); |
|
|
|
Stack<SecRegion> regionStack = getRegionStack(regionId,new Stack<>()); |
|
|
|
Stack<SecRegion> regionStack = getRegionStack(regionId, new Stack<>()); |
|
|
|
if (regionStack.size() == 4){ |
|
|
|
if (regionStack.size() == 4) { |
|
|
|
map.put("city",regionStack.pop()); |
|
|
|
map.put("city", regionStack.pop()); |
|
|
|
map.put("region",regionStack.pop()); |
|
|
|
map.put("region", regionStack.pop()); |
|
|
|
map.put("street",regionStack.pop()); |
|
|
|
map.put("street", regionStack.pop()); |
|
|
|
map.put("community",regionStack.pop()); |
|
|
|
map.put("community", regionStack.pop()); |
|
|
|
}else if (regionStack.size() == 3){ |
|
|
|
} else if (regionStack.size() == 3) { |
|
|
|
map.put("city",regionStack.pop()); |
|
|
|
map.put("city", regionStack.pop()); |
|
|
|
map.put("region",regionStack.pop()); |
|
|
|
map.put("region", regionStack.pop()); |
|
|
|
map.put("street",regionStack.pop()); |
|
|
|
map.put("street", regionStack.pop()); |
|
|
|
}else if (regionStack.size() == 2){ |
|
|
|
} else if (regionStack.size() == 2) { |
|
|
|
map.put("city",regionStack.pop()); |
|
|
|
map.put("city", regionStack.pop()); |
|
|
|
map.put("region",regionStack.pop()); |
|
|
|
map.put("region", regionStack.pop()); |
|
|
|
}else if (regionStack.size() == 1){ |
|
|
|
} else if (regionStack.size() == 1) { |
|
|
|
map.put("city",regionStack.pop()); |
|
|
|
map.put("city", regionStack.pop()); |
|
|
|
} |
|
|
|
} |
|
|
|
return map; |
|
|
|
return map; |
|
|
|
} |
|
|
|
} |
|
|
@ -383,11 +399,11 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
return regionName; |
|
|
|
return regionName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Stack<SecRegion> getRegionStack(Long regionId, Stack<SecRegion> regionStack){ |
|
|
|
private Stack<SecRegion> getRegionStack(Long regionId, Stack<SecRegion> regionStack) { |
|
|
|
SecRegion region = singleRegionCache.get(regionId); |
|
|
|
SecRegion region = singleRegionCache.get(regionId); |
|
|
|
if (region != null){ |
|
|
|
if (region != null) { |
|
|
|
regionStack.push(region); |
|
|
|
regionStack.push(region); |
|
|
|
getRegionStack(region.getParentId(),regionStack); |
|
|
|
getRegionStack(region.getParentId(), regionStack); |
|
|
|
} |
|
|
|
} |
|
|
|
return regionStack; |
|
|
|
return regionStack; |
|
|
|
} |
|
|
|
} |
|
|
@ -450,7 +466,7 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void addHLTBalance(String codeType , BigDecimal price) { |
|
|
|
public void addHLTBalance(String codeType, BigDecimal price) { |
|
|
|
SecConfig secConfig = secConfigService.findByCodeType(codeType); |
|
|
|
SecConfig secConfig = secConfigService.findByCodeType(codeType); |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal balance = new BigDecimal(secConfig.getCodeValue()); |
|
|
|
BigDecimal balance = new BigDecimal(secConfig.getCodeValue()); |
|
|
@ -463,10 +479,10 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IndexCountModel getIndexCount() { |
|
|
|
public IndexCountModel getIndexCount() { |
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
Map<String , Object> mapToDay = new HashMap<>(); |
|
|
|
Map<String, Object> mapToDay = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
mapToDay.put("today" , "1"); |
|
|
|
mapToDay.put("today", "1"); |
|
|
|
|
|
|
|
|
|
|
|
IndexCountModel countModel = new IndexCountModel(); |
|
|
|
IndexCountModel countModel = new IndexCountModel(); |
|
|
|
|
|
|
|
|
|
|
@ -499,16 +515,146 @@ public class CommonServiceImpl implements CommonService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public JSONObject findByLatAndLng(String lng, String lat) throws Exception { |
|
|
|
public JSONObject findByLatAndLng(String lng, String lat) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>();//参数
|
|
|
|
Map<String, Object> map = new HashMap<>();//参数
|
|
|
|
map.put("ak", "SfrwGH7INvjPq7BwCrYrioBQZm9XXxrR");//申请百度开放平台KEY(ak)
|
|
|
|
map.put("ak", "SfrwGH7INvjPq7BwCrYrioBQZm9XXxrR");//申请百度开放平台KEY(ak)
|
|
|
|
map.put("output", "json");// 输出Json数据
|
|
|
|
map.put("output", "json");// 输出Json数据
|
|
|
|
map.put("extensions_town", "true");// 行政区划返回乡镇级数据(town),仅国内召回乡镇数据
|
|
|
|
map.put("extensions_town", "true");// 行政区划返回乡镇级数据(town),仅国内召回乡镇数据
|
|
|
|
map.put("coordtype", "wgs84ll"); // GPS 经纬度类型
|
|
|
|
map.put("coordtype", "wgs84ll"); // GPS 经纬度类型
|
|
|
|
map.put("location", lat+","+lng+"");//百度经纬度
|
|
|
|
map.put("location", lat + "," + lng + "");//百度经纬度
|
|
|
|
|
|
|
|
|
|
|
|
String url = "http://api.map.baidu.com/reverse_geocoding/v3/"; |
|
|
|
String url = "http://api.map.baidu.com/reverse_geocoding/v3/"; |
|
|
|
|
|
|
|
|
|
|
|
return HttpsUtils.doGet(url , map); |
|
|
|
return HttpsUtils.doGet(url, map); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
|
|
|
public void configPayType(JSONObject object) { |
|
|
|
|
|
|
|
// 删除原支付方式
|
|
|
|
|
|
|
|
deletePayType(object.getLong("sourceId")); |
|
|
|
|
|
|
|
// 支付方式
|
|
|
|
|
|
|
|
BsProductPayType productPayType; |
|
|
|
|
|
|
|
// 配置支付方式
|
|
|
|
|
|
|
|
JSONArray payTypeArray = object.getJSONArray("payType"); |
|
|
|
|
|
|
|
for (Object payType : payTypeArray) { |
|
|
|
|
|
|
|
SecDictionary dictionary = mappingSysCode("PAY_TYPE", String.valueOf(payType)); |
|
|
|
|
|
|
|
productPayType = new BsProductPayType(); |
|
|
|
|
|
|
|
productPayType.setCreateTime(new Date()); |
|
|
|
|
|
|
|
productPayType.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
productPayType.setPayTypeId(Integer.valueOf(String.valueOf(payType))); |
|
|
|
|
|
|
|
productPayType.setPayTypeLogo(dictionary.getExt1()); |
|
|
|
|
|
|
|
productPayType.setPayTypeName(dictionary.getCodeName()); |
|
|
|
|
|
|
|
productPayType.setProductType(3); |
|
|
|
|
|
|
|
productPayType.setOperatorId(object.getLong("operatorId")); |
|
|
|
|
|
|
|
productPayType.setOperatorName(object.getString("operatorName")); |
|
|
|
|
|
|
|
productPayType.setSourceId(object.getLong("sourceId")); |
|
|
|
|
|
|
|
bsProductPayTypeMapper.insert(productPayType); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
|
|
|
public void configIntegralDiscount(JSONObject object) { |
|
|
|
|
|
|
|
// 清空原积分抵扣比例
|
|
|
|
|
|
|
|
deleteIntegralDiscount(object.getLong("sourceId")); |
|
|
|
|
|
|
|
// 折扣比例
|
|
|
|
|
|
|
|
BsProductDiscount productDiscount; |
|
|
|
|
|
|
|
// 配置积分折扣比例
|
|
|
|
|
|
|
|
productDiscount = new BsProductDiscount(); |
|
|
|
|
|
|
|
productDiscount.setDiscount(object.getBigDecimal("integralDiscount")); |
|
|
|
|
|
|
|
productDiscount.setProductType(3); |
|
|
|
|
|
|
|
productDiscount.setCreateTime(new Date()); |
|
|
|
|
|
|
|
productDiscount.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
productDiscount.setOperatorId(object.getLong("operatorId")); |
|
|
|
|
|
|
|
productDiscount.setOperatorName(object.getString("operatorName")); |
|
|
|
|
|
|
|
productDiscount.setSourceId(object.getLong("sourceId")); |
|
|
|
|
|
|
|
bsProductDiscountMapper.insert(productDiscount); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
|
|
|
public void configPlatform(JSONObject object) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deletePlatform(object.getLong("sourceId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BsProductPlatform productPlatform; |
|
|
|
|
|
|
|
// 配置展示平台
|
|
|
|
|
|
|
|
JSONArray productPlatformArray = object.getJSONArray("productPlatform"); |
|
|
|
|
|
|
|
for (Object platform : productPlatformArray) { |
|
|
|
|
|
|
|
productPlatform = new BsProductPlatform(); |
|
|
|
|
|
|
|
SecDictionary dictionary = mappingSysCode("SHOW_PLATFORM", String.valueOf(platform)); |
|
|
|
|
|
|
|
productPlatform.setProductType(3); |
|
|
|
|
|
|
|
productPlatform.setPlatformId(Integer.valueOf(String.valueOf(platform))); |
|
|
|
|
|
|
|
productPlatform.setPlatformName(dictionary.getCodeName()); |
|
|
|
|
|
|
|
productPlatform.setCreateTime(new Date()); |
|
|
|
|
|
|
|
productPlatform.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
productPlatform.setOperatorId(object.getLong("operatorId")); |
|
|
|
|
|
|
|
productPlatform.setOperatorName(object.getString("operatorName")); |
|
|
|
|
|
|
|
productPlatform.setSourceId(object.getLong("sourceId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bsProductPlatformMapper.insert(productPlatform); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 清空支付方式配置
|
|
|
|
|
|
|
|
private void deletePayType(Long sourceId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sourceId == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BsProductPayTypeExample example = new BsProductPayTypeExample(); |
|
|
|
|
|
|
|
example.createCriteria().andSourceIdEqualTo(sourceId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BsProductPayType> list = bsProductPayTypeMapper.selectByExample(example); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (list.size() > 0) { |
|
|
|
|
|
|
|
for (BsProductPayType productPayType : list) { |
|
|
|
|
|
|
|
bsProductPayTypeMapper.deleteByPrimaryKey(productPayType.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 清空配置积分抵扣比例
|
|
|
|
|
|
|
|
private void deleteIntegralDiscount(Long sourceId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sourceId == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BsProductDiscountExample example = new BsProductDiscountExample(); |
|
|
|
|
|
|
|
example.createCriteria().andSourceIdEqualTo(sourceId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BsProductDiscount> list = bsProductDiscountMapper.selectByExample(example); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (list.size() > 0) { |
|
|
|
|
|
|
|
for (BsProductDiscount bsProductDiscount : list) { |
|
|
|
|
|
|
|
bsProductDiscountMapper.deleteByPrimaryKey(bsProductDiscount.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 清空配置展示平台
|
|
|
|
|
|
|
|
private void deletePlatform(Long sourceId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sourceId == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BsProductPlatformExample example = new BsProductPlatformExample(); |
|
|
|
|
|
|
|
example.createCriteria().andSourceIdEqualTo(sourceId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BsProductPlatform> list = bsProductPlatformMapper.selectByExample(example); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (list.size() > 0) { |
|
|
|
|
|
|
|
for (BsProductPlatform productPlatform : list) { |
|
|
|
|
|
|
|
bsProductDiscountMapper.deleteByPrimaryKey(productPlatform.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|