Commit cb013d9a authored by 张永's avatar 张永
parents 0eb7a707 b8e48df3
......@@ -46,14 +46,13 @@
<version>1.1.20</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.38</version>
<version>1.2.70</version>
</dependency>
<dependency>
<groupId>com.egolm</groupId>
......@@ -90,10 +89,6 @@
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
......@@ -191,7 +186,7 @@
<repository>
<id>my</id>
<name>my</name>
<url>http://git.egolm.com:9003/nexus/content/groups/public/</url>
<url>https://gitlab.linkfern.com/content/groups/public/</url>
</repository>
<repository>
<id>repo1</id>
......
......@@ -4,11 +4,13 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableAsync(proxyTargetClass=true)
@EnableScheduling
@EnableCaching
@EnableSwagger2
......
package com.egolm.shop.api;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -107,7 +108,7 @@ public class CommonController {
public Object getConfig(String appId) {
Map<String, Object> map = null;
try {
map = jdbcTemplate.queryForMap("select sOrgNO, sOrgDesc from tOrg where sAppID = ? and nTag&1 = 0", appId);
map = jdbcTemplate.queryForMap("select sOrgNO, sOrgDesc, sOrgPicUrl from tOrg where sAppID = ? and nTag&1 = 0", appId);
} catch (EmptyResultDataAccessException e) {
throw new XException("配置不存在", e);
}
......@@ -121,9 +122,36 @@ public class CommonController {
" where sCode = @ChoiceOssKEY";
Map<String, Object> omap = jdbcTemplate.queryForMap(ossSql.replaceAll("\\s+", " "));
Map<String, Object> cmap = jdbcTemplate.queryForMap("select sDesc,sValue1 from tSystemCtrl where sCode = 'ExemptCheck'");
List<Map<String, Object>> payTypes = jdbcTemplate.queryForList("select sSalesOrderPayTypeID, sSalesOrderPayType from tOrgPayType where sOrgNO = ? and nTag&1=0", sOrgNO);
List<Map<String, Object>> payTypes = jdbcTemplate.queryForList("select sSalesOrderPayTypeID, sSalesOrderPayType from tOrgPayType where sOrgNO = ? and nTag&1=0 order by nSort desc", sOrgNO);
List<Map<String, Object>> goodsTags = jdbcTemplate.queryForList("select sGoodsTagID, sGoodsTag from tOrgGoodsTag where sOrgNO = ? and nTag&1 = 0", sOrgNO);
return Rjx.jsonOk().set("OrgInfo", map).set("PicInfo", omap).set("ExemptCheck", cmap).set("payTypes", payTypes).set("goodsTags", goodsTags).toJson();
Map<String, Object> shareInfo = new HashMap<String, Object>();
try {
String sql = ""
+ "SELECT "
+ "SharePicUrl = sPicUrl, "
+ "ShareTitle = sShareTitle "
+ "FROM "
+ "tOrg "
+ "WHERE "
+ "sOrgNO = ? "
+ "AND sAppID = ?";
shareInfo = jdbcTemplate.queryForMap(sql, sOrgNO, appId);
} catch (EmptyResultDataAccessException e) {}
Map<String, Object> AppSystemInfo = new HashMap<String, Object>();
try {
String sql = ""
+ "SELECT "
+ "IsAppCustService = convert(BIT, CASE WHEN nIsAppCustService = 1 THEN 1 ELSE 0 END), "
+ "IsExemptCheck = convert(BIT, CASE WHEN nIsExemptCheck = 1 THEN 1 ELSE 0 END) "
+ "FROM "
+ "tOrg "
+ "WHERE "
+ "sOrgNO = ? "
+ "AND sAppID = ?";
AppSystemInfo = jdbcTemplate.queryForMap(sql, sOrgNO, appId);
} catch (EmptyResultDataAccessException e) {}
return Rjx.jsonOk().set("OrgInfo", map).set("PicInfo", omap).set("ExemptCheck", cmap).set("payTypes", payTypes).set("goodsTags", goodsTags).set("AppSystemInfo", AppSystemInfo).set("shareInfo", shareInfo).toJson();
}
}
package com.egolm.shop.api.service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.jdbc.Page;
public interface OrderService {
public String orderCheck(Map<String,Object> params);
public String submit(JSONObject submitObj);
public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page);
public String queryOrderDetailList(String salesOrderId);
public String getOrderDetail(String salesOrderId);
public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime);
public String getSubOrderDetail(String subOrderID);
public void cancelOrder(String sSalesOrderID);
public String submitByGroup(String orgNo, String shopNo, String prompPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public void confirmReceipt(String custNo, String subOrderID);
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID);
}
package com.egolm.shop.api.service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.jdbc.Page;
public interface OrderService {
public String orderCheck(Map<String,Object> params);
public String submit(JSONObject submitObj);
public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page);
public String queryOrderDetailList(String salesOrderId);
public String getOrderDetail(String salesOrderId);
public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime);
public String getSubOrderDetail(String subOrderID);
public void cancelOrder(String sSalesOrderID);
public String submitByGroup(String orgNo, String shopNo, String prompPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public void confirmReceipt(String custNo, String subOrderID);
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID);
}
package com.egolm.shop.api.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -9,6 +11,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
......@@ -51,7 +54,7 @@ public class AddressServiceImpl implements AddressService {
+ " lastUpdateTime = t.dLastUpdateTime "
+ " from tCustAddress t where t.sShopNO=? and t.sCustNO = ? and t.nTag&1=0 ";
jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.limit(sql, page, shopNO,userNO);
return jdbcTemplate.queryForList(sql, shopNO,userNO);
} catch (Exception e) {
e.printStackTrace();
return null;
......@@ -152,9 +155,7 @@ public class AddressServiceImpl implements AddressService {
return null;
}
}
public static void main(String[] args) {
System.out.println(0|1|2|1);
}
public String delete(String addId,String userNO,String shopNO,String langID) {
try {
boolean isShopExists = userService.checkShopExists(userNO, shopNO);
......@@ -229,7 +230,7 @@ public class AddressServiceImpl implements AddressService {
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Operate_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_Paramtype_error")).toJson();
}
}
@Override
public Map<String, Object> getDefaultAddress(String custNo, String shopNo) {
......@@ -254,25 +255,37 @@ public class AddressServiceImpl implements AddressService {
+ " from tCustAddress where nTag&1 = 0 and sCustNO = ? and (sShopNO = ? or sShopNO is null or sShopNO = '') order by nTag desc, dLastUpdateTime desc";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, custNo, shopNo);
Map<String, Object> defMap = null;
Integer nTag_Cur = 0;
List<Map<String, Object>> listTag6 = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> listTag4 = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> listTag2 = new ArrayList<Map<String, Object>>();
for(Map<String, Object> map : list) {
Integer nTag = (Integer)map.get("nTag");
Integer nTag = (Integer)map.get("tag");
if(nTag != null) {
if((nTag&6) == 6) {
defMap = map;
break;
} else if((nTag&4) == 4 && nTag_Cur < 4) {
defMap = map;
} else if((nTag&4) == 2 && nTag_Cur < 2) {
defMap = map;
listTag6.add(map);
}
if((nTag&4) == 4) {
listTag4.add(map);
}
if((nTag&2) == 2) {
listTag2.add(map);
}
nTag_Cur = nTag;
}
}
if(defMap == null && list.size() > 0) {
if(listTag6.size() > 0) {
defMap = listTag6.get(0);
} else if(listTag2.size() > 0) {
defMap = listTag2.get(0);
} else if(listTag4.size() > 0) {
defMap = listTag4.get(0);
} else if(list.size() > 0) {
defMap = list.get(0);
}
return defMap;
}
}
......@@ -86,7 +86,8 @@ public class BrandServiceImpl implements BrandService {
+ "WHERE "
+ "acg.sBrandID = b.sBrandID "
+ "and acg.sOrgNO = ? "
+ "and b.nTag&1 = 0 "
+ "and b.nTag&1=0 "
+ "and acg.nTag&19=18 "
+ "and b.sBrandID not in (select ip.sBrandID from tIPBrand ip)"
+ "group by "
+ "b.sPinyinCode, "
......@@ -112,7 +113,10 @@ public class BrandServiceImpl implements BrandService {
+ "tBrand b "
+ "WHERE "
+ "acg.sBrandID = b.sBrandID "
+ "and acg.sOrgNO = ? "
+ "and acg.sOrgNO = '1006' "
+ "and b.nTag&1=0 "
+ "and acg.nTag&3=2 "
+ "and b.sBrandID not in (select ip.sBrandID from tIPBrand ip)"
+ "group by "
+ "b.sPinyinCode, "
+ "acg.sBrandID, "
......
This source diff could not be displayed because it is too large. You can view the blob instead.
package com.egolm.shop.api.service.impl;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.shop.api.service.QiyeWxService;
import com.egolm.shop.common.utils.HttpUtil;
import com.egolm.shop.common.utils.HttpUtil.HttpReqObject;
import com.egolm.shop.common.utils.HttpUtil.HttpRespObject;
import com.egolm.shop.common.utils.HttpUtil.JsonReqObject;
import com.egolm.shop.common.utils.HttpUtil.SSLVersion;
@Service
public class QiyeWxServiceImpl implements QiyeWxService {
@Value("${qiyewx.corpid}")
private String corpid;
@Value("${qiyewx.corpsecret}")
private String corpsecret;
@Value("${qiyewx.baseUrl}")
private String baseUrl;
@Value("${qiyewx.msg.redirect.appid}")
private String redirectAppid;
@Autowired
private RedisTemplate<String, String> redis;
@Override
public String getTokenString() {
String redisCacheKey = PrefixRedisTokenKey + corpid;
Long systemTime = System.currentTimeMillis();
String tokenObjectString = redis.opsForValue().get(redisCacheKey);
if(StringUtil.isNotBlank(tokenObjectString)) {
JSONObject tokenObject = JSON.parseObject(tokenObjectString);
Integer errcode = tokenObject.getInteger("errcode");
if(errcode == 0) {
Long expires_in = tokenObject.getLong("expires_in");
String loadTimeString = tokenObject.getString("loadTime");
if(expires_in != null && StringUtil.isNotBlank(loadTimeString)) {
Date loadTime = DateUtil.parse(loadTimeString, "yyyy-MM-dd HH:mm:ss");
Long expireTime = loadTime.getTime() + (expires_in*1000L);
if((expireTime - DevTime) > systemTime) {
String access_token = tokenObject.getString("access_token");
if(StringUtil.isNotBlank(access_token)) {
return access_token;
}
}
}
}
}
String requestUrl = baseUrl + MessageFormat.format(UrlGetToken, corpid, corpsecret);
HttpRespObject resp = HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).get(new HttpReqObject(requestUrl, null, null));
if(resp.getHttpCode() == 200) {
String text = resp.getResponseBody();
JSONObject tokenObject = JSON.parseObject(text);
Integer code = tokenObject.getInteger("errcode");
if(code == 0) {
tokenObject.put("loadTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
redis.opsForValue().set(redisCacheKey, tokenObject.toJSONString());
return tokenObject.getString("access_token");
}
}
return null;
}
@Override
public void refreshToken() {
String redisCacheKey = PrefixRedisTokenKey + corpid;
redis.delete(redisCacheKey);
}
@Override
public void sendMessage(WxMessage wxMessage) {
String tokenString = this.getTokenString();
String requestUrl = baseUrl + MessageFormat.format(UrlSendMsg, tokenString);
Map<String, String> headers = new HashMap<String, String>();
headers.put("content-type", "application/x-www-form-urlencoded");
wxMessage.getMiniprogram_notice().setAppid(redirectAppid);
HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).postJson(new JsonReqObject(requestUrl, wxMessage, headers));
}
}
package com.egolm.shop.api.service.impl;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.shop.api.service.QiyeWxService;
import com.egolm.shop.common.utils.HttpUtil;
import com.egolm.shop.common.utils.HttpUtil.HttpReqObject;
import com.egolm.shop.common.utils.HttpUtil.HttpRespObject;
import com.egolm.shop.common.utils.HttpUtil.JsonReqObject;
import com.egolm.shop.common.utils.HttpUtil.SSLVersion;
@Service
public class QiyeWxServiceImpl implements QiyeWxService {
@Value("${qiyewx.corpid}")
private String corpid;
@Value("${qiyewx.corpsecret}")
private String corpsecret;
@Value("${qiyewx.baseUrl}")
private String baseUrl;
@Value("${qiyewx.msg.redirect.appid}")
private String redirectAppid;
@Autowired
private RedisTemplate<String, String> redis;
@Override
public String getTokenString() {
String redisCacheKey = PrefixRedisTokenKey + corpid;
Long systemTime = System.currentTimeMillis();
String tokenObjectString = redis.opsForValue().get(redisCacheKey);
if(StringUtil.isNotBlank(tokenObjectString)) {
JSONObject tokenObject = JSON.parseObject(tokenObjectString);
Integer errcode = tokenObject.getInteger("errcode");
if(errcode == 0) {
Long expires_in = tokenObject.getLong("expires_in");
String loadTimeString = tokenObject.getString("loadTime");
if(expires_in != null && StringUtil.isNotBlank(loadTimeString)) {
Date loadTime = DateUtil.parse(loadTimeString, "yyyy-MM-dd HH:mm:ss");
Long expireTime = loadTime.getTime() + (expires_in*1000L);
if((expireTime - DevTime) > systemTime) {
String access_token = tokenObject.getString("access_token");
if(StringUtil.isNotBlank(access_token)) {
return access_token;
}
}
}
}
}
String requestUrl = baseUrl + MessageFormat.format(UrlGetToken, corpid, corpsecret);
HttpRespObject resp = HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).get(new HttpReqObject(requestUrl, null, null));
if(resp.getHttpCode() == 200) {
String text = resp.getResponseBody();
JSONObject tokenObject = JSON.parseObject(text);
Integer code = tokenObject.getInteger("errcode");
if(code == 0) {
tokenObject.put("loadTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
redis.opsForValue().set(redisCacheKey, tokenObject.toJSONString());
return tokenObject.getString("access_token");
}
}
return null;
}
@Override
public void refreshToken() {
String redisCacheKey = PrefixRedisTokenKey + corpid;
redis.delete(redisCacheKey);
}
@Override
public void sendMessage(WxMessage wxMessage) {
String tokenString = this.getTokenString();
String requestUrl = baseUrl + MessageFormat.format(UrlSendMsg, tokenString);
Map<String, String> headers = new HashMap<String, String>();
headers.put("content-type", "application/x-www-form-urlencoded");
wxMessage.getMiniprogram_notice().setAppid(redirectAppid);
HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).postJson(new JsonReqObject(requestUrl, wxMessage, headers));
}
}
......@@ -875,8 +875,10 @@ public class UserServiceImpl implements UserService {
if(shopList.size() == 0) {
throw new XException("该账号暂未绑定门店");
}
Map<String, Object> custMap = datas.get(1).get(0);
custMap.put("sOpenID", openId);
map.put("userinfo", uMap);
map.put("customer", datas.get(1).get(0));
map.put("customer", custMap);
map.put("bankList", datas.get(2));
map.put("shopList", shopList);
return map;
......
package com.egolm.shop.common.interceptor;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.alibaba.fastjson.JSON;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.web.ServletUtil;
@Component
public class LogInterceptor extends HandlerInterceptorAdapter {
@Value("${log.isOpen}")
private Boolean isOpen;
@Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
this.exec(req);
return super.preHandle(req, resp, handler);
}
@Autowired
@Qualifier("log")
private JdbcTemplate jdbcTemplate;
private void exec(HttpServletRequest req) {
if(isOpen) {
try {
String contextPath = req.getContextPath();
String uri = req.getRequestURI().substring(contextPath.length());
String remoteIp = ServletUtil.remoteIp(req);
String params = JSON.toJSONString(req.getParameterMap());
Map<String, Object> map = new HashMap<String,Object>();
map.put("sProjectID", "SHOP");
map.put("sURI", uri);
map.put("sClientIP", remoteIp);
map.put("sParams", params);
map.put("dCreateTime", new Date());
jdbcTemplate.save("tLog", map);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
}
package com.egolm.shop.common.interceptor;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.alibaba.fastjson.JSON;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.web.ServletUtil;
@Component
public class LogInterceptor extends HandlerInterceptorAdapter {
@Value("${log.isOpen}")
private Boolean isOpen;
@Value("${log.sProjectID:SHOP}")
private String sProjectID;
@Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
this.exec(req);
return super.preHandle(req, resp, handler);
}
@Autowired
@Qualifier("log")
private JdbcTemplate jdbcTemplate;
private void exec(HttpServletRequest req) {
if(isOpen) {
try {
String contextPath = req.getContextPath();
String uri = req.getRequestURI().substring(contextPath.length());
String remoteIp = ServletUtil.remoteIp(req);
String params = JSON.toJSONString(req.getParameterMap());
Map<String, Object> map = new HashMap<String,Object>();
map.put("sProjectID", sProjectID);
map.put("sURI", uri);
map.put("sClientIP", remoteIp);
map.put("sParams", params);
map.put("dCreateTime", new Date());
this.save(map);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
@Async
public void save(Map<String, Object> map) {
jdbcTemplate.save("tLog", map);
}
}
package com.egolm.shop.common.interceptor;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.common.GsonUtil;
import com.egolm.common.MD5Util;
import com.egolm.common.StringUtil;
import com.egolm.shop.common.XException;
import com.egolm.shop.common.utils.I18NUtils;
import com.egolm.shop.common.utils.ShopContstrant;
@Component
public class OpenInterceptor extends HandlerInterceptorAdapter {
Log logger = LogFactory.getLog(OpenInterceptor.class);
String encoding = "UTF-8";
@Autowired
private RedisTemplate<String, Object> redisTemplate;
/*签名规则:1.按照参数字段名ASCII码排序;2.参数进行url拼接;3.加上签名字符串secret;4.得到字符串后进行SHA1签名;5.将签名得到的字符串加入参数列表中,字段名为sig*/
@Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
String uri = req.getRequestURI();
if((uri.indexOf("swagger") == -1 && uri.indexOf("/v2/api-docs") == -1) ) {
Map<String, String[]> paramMap = req.getParameterMap();
logger.info(GsonUtil.toJson(paramMap));
String sign = req.getParameter("sign");
String timestamp = req.getParameter("timestamp");
String langID = req.getParameter("langID");
String terminal = req.getParameter("terminal");
if(!StringUtil.isNotBlank(sign,timestamp,langID,terminal)) {
throw new XException(I18NUtils.getMessage(langID, "Msg_Paramter_Empty","[sign,timestamp,langID,terminal]")) ;
}
SortedMap<Object,Object> parameters = new TreeMap<Object,Object>();
Set<String> keys = paramMap.keySet() ;
for (String key : keys) {
String value = req.getParameter(key);
parameters.put(key,value);
}
redisTemplate.opsForHash().put("SystemCtl1111", "test","111");
System.out.println(redisTemplate.opsForHash().get("SystemCtl1111", "test"));
Map<?, ?> map = (Map<?, ?>)redisTemplate.opsForHash().get(ShopContstrant.SystemCtl_Redis_Base_Key, ShopContstrant.CLIENT_MD5KEY);
System.out.println(map);
if(map != null) {
parameters.put("md5Key", map.get("sValue1")+"");
}else {
logger.info("从redis中获取 计算签名用的md5key 获取失败");
throw new XException(I18NUtils.getMessage(langID, "Msg_Sign_failure"));
}
logger.info("request sign >>>>>>"+sign);
String createSign = MD5Util.createSign(encoding, parameters);
logger.info("create sign >>>>>>>"+createSign);
if(createSign.toUpperCase().equals(sign.toUpperCase())) {
return super.preHandle(req, resp, handler);
} else {
throw new XException(I18NUtils.getMessage(langID, "Msg_Sign_failure"));
}
}else {
return super.preHandle(req, resp, handler); //swagger-ui.html 界面不进行验证
}
}
public static void main(String[] args) {
String a= "/A0001/20181023/2018_10_23_17_27_00_58303479.png";
System.out.println(a.length());
}
}
package com.egolm.shop.common.interceptor;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.common.GsonUtil;
import com.egolm.common.MD5Util;
import com.egolm.common.StringUtil;
import com.egolm.common.Util;
import com.egolm.shop.common.XException;
import com.egolm.shop.common.utils.I18NUtils;
import com.egolm.shop.common.utils.ShopContstrant;
@Component
public class OpenInterceptor extends HandlerInterceptorAdapter {
Log logger = LogFactory.getLog(OpenInterceptor.class);
String encoding = "UTF-8";
@Value("${ignoreTimestamp:false}")
private Boolean ignoreTimestamp;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
/*签名规则:1.按照参数字段名ASCII码排序;2.参数进行url拼接;3.加上签名字符串secret;4.得到字符串后进行SHA1签名;5.将签名得到的字符串加入参数列表中,字段名为sig*/
@Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
String uri = req.getRequestURI();
if((uri.indexOf("swagger") == -1 && uri.indexOf("/v2/api-docs") == -1) ) {
Map<String, String[]> paramMap = req.getParameterMap();
logger.info(GsonUtil.toJson(paramMap));
String sign = req.getParameter("sign");
String timestamp = req.getParameter("timestamp");
String langID = req.getParameter("langID");
String terminal = req.getParameter("terminal");
if(!StringUtil.isNotBlank(sign,timestamp,langID,terminal)) {
throw new XException(I18NUtils.getMessage(langID, "Msg_Paramter_Empty","[sign,timestamp,langID,terminal]")) ;
}
Long timeLong = Util.objTo(timestamp, Long.class, 0L);
if(!ignoreTimestamp && Math.abs(timeLong - System.currentTimeMillis()) > (60L*5L)) {
throw new XException("时间戳无效");
}
SortedMap<Object,Object> parameters = new TreeMap<Object,Object>();
Set<String> keys = paramMap.keySet() ;
for (String key : keys) {
String value = req.getParameter(key);
parameters.put(key,value);
}
redisTemplate.opsForHash().put("SystemCtl1111", "test","111");
System.out.println(redisTemplate.opsForHash().get("SystemCtl1111", "test"));
Map<?, ?> map = (Map<?, ?>)redisTemplate.opsForHash().get(ShopContstrant.SystemCtl_Redis_Base_Key, ShopContstrant.CLIENT_MD5KEY);
System.out.println(map);
if(map != null) {
parameters.put("md5Key", map.get("sValue1")+"");
}else {
logger.info("从redis中获取 计算签名用的md5key 获取失败");
throw new XException(I18NUtils.getMessage(langID, "Msg_Sign_failure"));
}
logger.info("request sign >>>>>>"+sign);
String createSign = MD5Util.createSign(encoding, parameters);
logger.info("create sign >>>>>>>"+createSign);
if(createSign.toUpperCase().equals(sign.toUpperCase())) {
return super.preHandle(req, resp, handler);
} else {
throw new XException(I18NUtils.getMessage(langID, "Msg_Sign_failure"));
}
}else {
return super.preHandle(req, resp, handler); //swagger-ui.html 界面不进行验证
}
}
public static void main(String[] args) {
String a= "/A0001/20181023/2018_10_23_17_27_00_58303479.png";
System.out.println(a.length());
}
}
......@@ -73,7 +73,7 @@ public class QiyeWxMsgTask {
WxMessage wxMessage = new WxMessage(sCompanyAccountID);
MiniprogramNotice notice = new MiniprogramNotice();
wxMessage.setMiniprogram_notice(notice);
notice.setTitle("客户订单通知");
notice.setTitle("客户订单通知");
notice.setDescription(dateString);
notice.setPage("pages/ordermanage/detail/detail?SalesmanNO=" + salesmanNo + "&isShare=1&id=" + sSubOrderID + "&isActive=1");
Map<Object, Object> params = new LinkedHashMap<Object, Object>();
......
......@@ -6,4 +6,9 @@ spring.datasource.url=jdbc:sqlserver://172.16.0.8:55433;instanceName=SQLSERVER;D
log.datasource.username=root
log.datasource.password=asters#2019
log.datasource.url=jdbc:mysql://127.0.0.1:3306/shopLog?useSSL=false&useUnicode=true&characterEncoding=utf8
\ No newline at end of file
log.datasource.url=jdbc:mysql://127.0.0.1:3306/shopLog?useSSL=false&useUnicode=true&characterEncoding=utf8
qiyewx.corpid=ww92480eb625f6cf0f
qiyewx.corpsecret=sRDiUjmmr2yD4q-2A8d2_Y-1b_XPkbGmdD0goIYAGwU
qiyewx.msg.redirect.appid=wx79ba889cb1d94c27
......@@ -25,7 +25,7 @@ solr.goods.offset-minute-for-day: 1500
solr.goods.offset-minute-for-minute: 10
solr.goods.cron-for-day: 0 0 3 * * ?
solr.goods.cron-for-minute: 0 * * * * ?
solr.baseURL=http://127.0.0.1:8983/solr/goods
solr.baseURL=http://127.0.0.1:18004/solr/goods
logProducer.logName=AST_SHOP_ERROR_LOG
logProducer.isOpen=false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment