1
0
qng vor 3 Jahren
Ursprung
Commit
9626e175b9

+ 6 - 2
eccs-biz/src/main/java/com/emato/biz/controller/mall/SalesDetailController.java

@@ -6,12 +6,16 @@ import com.emato.biz.domain.mall.NewSystemFormatEntiy;
 import com.emato.biz.service.mall.ISalesDetaiServicel;
 import com.emato.common.annotation.AnonymousAccess;
 import com.emato.common.core.Result;
+import org.apache.http.Header;
+import org.apache.http.HttpRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
+
 @RestController
 @RequestMapping("/salesdetail")
 public class SalesDetailController {
@@ -40,9 +44,9 @@ public class SalesDetailController {
      */
     @AnonymousAccess
     @PostMapping("/getsalesdet")
-    public Result getSalesDetaiData(@RequestBody JSONObject msg)
+    public Result getSalesDetaiData(@RequestBody JSONObject msg, HttpServletRequest httpRequest)
     {
-        return salesDetaiServicel.getSalesDetaiData(msg);
+        return salesDetaiServicel.getSalesDetaiData(msg,httpRequest);
     }
 
 

+ 20 - 17
eccs-biz/src/main/java/com/emato/biz/service/impl/SalesDetaiServicelImpl.java

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

+ 2 - 1
eccs-biz/src/main/java/com/emato/biz/service/mall/ISalesDetaiServicel.java

@@ -4,10 +4,11 @@ import com.alibaba.fastjson.JSONObject;
 import com.emato.biz.domain.mall.NewSystemFormatEntiy;
 import com.emato.common.core.Result;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
 public interface ISalesDetaiServicel {
     int pushSalesDetaiServicel(NewSystemFormatEntiy newSystemFormatEntiy);
 
-    Result getSalesDetaiData(JSONObject msg);
+    Result getSalesDetaiData(JSONObject msg,HttpServletRequest httpServletRequest);
 }

+ 16 - 13
eccs-biz/src/main/resources/mapper/biz/mall/MallMngChangeMapper.xml

@@ -241,19 +241,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         remark
         FROM
         mall_sales_detail_data
-<!--        WHERE-->
-<!--        <if test="starTime != null and starTime != ''">-->
-<!--             time_stamp &gt; STR_TO_DATE(#{starTime}, '%Y-%m-%d %H:%i:%s')-->
-<!--        </if>-->
-<!--        <if test="endTime != null and endTime != ''">-->
-<!--            AND time_stamp &lt;= STR_TO_DATE(#{endTime}, '%Y-%m-%d %H:%i:%s')-->
-<!--        </if>-->
-<!--        <if test="orderStatus !=null and orderStatus !=''">-->
-<!--            AND order_status = #{orderStatus}-->
-<!--        </if>-->
-<!--        <if test="offset != null and limit != null">-->
-<!--            limit #{offset}, #{limit}-->
-<!--        </if>-->
+        WHERE
+        <if test="starTime != null and starTime != ''">
+             time_stamp &gt; STR_TO_DATE(#{starTime}, '%Y-%m-%d %H:%i:%s')
+        </if>
+        <if test="endTime != null and endTime != ''">
+            AND time_stamp &lt;= STR_TO_DATE(#{endTime}, '%Y-%m-%d %H:%i:%s')
+        </if>
+        <if test="orderStatus !=null and orderStatus !=''">
+            AND order_status = #{orderStatus}
+        </if>
+        <if test="orderNo !=null and orderNo !=''">
+            AND receipt_no = #{orderNo}
+        </if>
+        <if test="offset != null and limit != null">
+            limit #{offset}, #{limit}
+        </if>
     </select>
 
     <!--    记录外部调用接口入参-->

+ 1 - 0
eccs-common/src/main/java/com/emato/common/utils/oms/request/DesUtils.java

@@ -8,6 +8,7 @@ public class DesUtils {
 
     private static final String DES = "DES";
     private static final String KEY = "4YztMHI7PsT4rLZN";
+    public static final String SIGN = "C5B4054FD8D23tQB";
 
     private static byte[] encrypt(byte[] src, byte[] key) throws Exception {
         SecureRandom sr = new SecureRandom();