|
@@ -9,13 +9,12 @@ import com.emato.biz.service.mall.ISalesDetaiServicel;
|
|
|
import com.emato.common.core.Result;
|
|
|
import com.emato.common.utils.DateUtils;
|
|
|
import com.emato.common.utils.oms.request.DesUtils;
|
|
|
-import com.emato.common.utils.sign.Md5Utils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -48,28 +47,32 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Result getSalesDetaiData(JSONObject msg) {
|
|
|
+ public Result getSalesDetaiData(JSONObject msg, HttpServletRequest httpServletRequest) {
|
|
|
try {
|
|
|
-
|
|
|
+ String strMsg = httpServletRequest.getHeader("Sign");
|
|
|
+ String tranDtion = httpServletRequest.getHeader("tranDtion")==null?"":httpServletRequest.getHeader("tranDtion");
|
|
|
+ if(!strMsg.equals(DesUtils.SIGN)){
|
|
|
+ return Result.error("1003","签名错误");
|
|
|
+ }
|
|
|
+ if(tranDtion.equals("")){
|
|
|
+ return Result.error("1002","参数错误");
|
|
|
+ }
|
|
|
Map<String, Object> weChatMapMsg = JSONObject.toJavaObject(msg, Map.class);
|
|
|
logger.error("外部系统查询订单销售数据查询条件:"+JSON.toJSONString(weChatMapMsg));
|
|
|
weChatMapMsg.put("starTime", DateUtils.getStrDate((String) weChatMapMsg.get("starTime")));
|
|
|
weChatMapMsg.put("endTime",DateUtils.getStrDate((String)weChatMapMsg.get("endTime")));
|
|
|
weChatMapMsg.put("offset",Integer.parseInt(weChatMapMsg.get("pageIndex")+""));
|
|
|
weChatMapMsg.put("limit",Integer.parseInt(weChatMapMsg.get("pageSize")+""));
|
|
|
- //调用接口限制间隔时间
|
|
|
- Date msgDate = mallMngChangeMapper.getPullDataTime((String)weChatMapMsg.put("tranDirection",msg.get("tranDirection")));
|
|
|
- long diff=(new Date().getTime()-msgDate.getTime())/1000/60;
|
|
|
- if(diff>2){
|
|
|
- //if(true){
|
|
|
//记录调用参数接口日志
|
|
|
- pullQueryData(weChatMapMsg);
|
|
|
+ pullQueryData(weChatMapMsg,tranDtion);
|
|
|
List<NewSystemFormatEntiy> list = mallMngChangeMapper.getSalesDetaiData(weChatMapMsg);
|
|
|
- String desList = DesUtils.encode(JSON.toJSONString(list));
|
|
|
- return Result.success(desList);
|
|
|
- }else{
|
|
|
- return Result.error("1003","请求过于频繁,请稍后再试");
|
|
|
- }
|
|
|
+ String desList ="";
|
|
|
+ if(list.size()==0){
|
|
|
+ return Result.error("1004","该条件下无数据");
|
|
|
+ }else{
|
|
|
+ desList = DesUtils.encode(JSON.toJSONString(list));
|
|
|
+ return Result.success(desList);
|
|
|
+ }
|
|
|
}catch (Exception e){
|
|
|
logger.error("外部系统查询订单销售数据错误"+ JSON.toJSONString(msg),e);
|
|
|
return Result.error("1002","参数错误");
|
|
@@ -81,9 +84,9 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
|
|
|
* 记录外部调用接口参数,时间和调用方
|
|
|
* @param msg
|
|
|
*/
|
|
|
- private void pullQueryData(Map msg) {
|
|
|
+ private void pullQueryData(Map msg,String tranDtion) {
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("tranDirection",msg.get("tranDirection"));
|
|
|
+ map.put("tranDirection",tranDtion);
|
|
|
map.put("msg",msg.toString());
|
|
|
mallMngChangeMapper.pullQueryData(map);
|
|
|
|