فهرست منبع

1.excel导出逻辑修改
2.订单对比kmall、oms逻辑编写
3.退款逻辑修改(存入退单表,并记录订单号跟退款时间)

zcb 4 سال پیش
والد
کامیت
b58f40d1a6
20فایلهای تغییر یافته به همراه888 افزوده شده و 173 حذف شده
  1. 6 0
      kmall-admin/pom.xml
  2. 4 4
      kmall-admin/src/main/java/com/kmall/admin/controller/OrderController.java
  3. 17 4
      kmall-admin/src/main/java/com/kmall/admin/entity/compared/OrderComparedErrorEntity.java
  4. 13 76
      kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java
  5. 181 51
      kmall-admin/src/main/java/com/kmall/admin/service/impl/compared/OrderComparedErrorServiceImpl.java
  6. 11 6
      kmall-admin/src/main/java/com/kmall/admin/service/impl/compared/PayOrderInfoServiceImpl.java
  7. 245 0
      kmall-admin/src/main/java/com/kmall/admin/utils/data/response/ResponseMessage.java
  8. 86 0
      kmall-admin/src/main/java/com/kmall/admin/utils/data/response/ResponseMessageData.java
  9. 29 0
      kmall-admin/src/main/java/com/kmall/admin/utils/data/response/ResponseStatus.java
  10. 40 0
      kmall-admin/src/main/java/com/kmall/admin/utils/oms/MD5Util.java
  11. 128 0
      kmall-admin/src/main/java/com/kmall/admin/utils/oms/OkHttpUtils.java
  12. 53 0
      kmall-admin/src/main/java/com/kmall/admin/utils/oms/OmsSign.java
  13. 18 6
      kmall-admin/src/main/resources/mybatis/mapper/compared/OrderComparedErrorDao.xml
  14. 1 1
      kmall-admin/src/main/resources/mybatis/mapper/compared/PayOrderInfoDao.xml
  15. 1 3
      kmall-admin/src/main/webapp/WEB-INF/page/compared/ordercomparederror.html
  16. 5 0
      kmall-admin/src/main/webapp/js/compared/ordercomparederror.js
  17. 13 10
      kmall-common/src/main/java/com/kmall/common/utils/excel/ExcelExport.java
  18. 20 0
      kmall-manager/src/main/java/com/kmall/manager/manager/merch/OmsMerchProperties.java
  19. 15 12
      kmall-manager/src/main/resources/conf/oms-merch.properties
  20. 2 0
      kmall-manager/src/main/resources/spring/spring-oms-merch.xml

+ 6 - 0
kmall-admin/pom.xml

@@ -136,6 +136,12 @@
             <version>5.5.1</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.2</version>
+        </dependency>
+
 
     </dependencies>
 

+ 4 - 4
kmall-admin/src/main/java/com/kmall/admin/controller/OrderController.java

@@ -1096,10 +1096,10 @@ public class OrderController {
             String url = OmsMerchPropertiesBuilder.instance().getWxOrderResendUrl() + "/"+orderSn;
             // 同步访问,返回结果字符串
             response = OkHttpUtils.post(map, url, "SSL");
-            ResponseData responseData = JacksonUtils.fromStringJson(response, ResponseData.class);
-            if(responseData.getCode().equalsIgnoreCase("0")){
-                List<WxOrderEntity> list = responseData.getData().getRows();
-            }
+//            ResponseData responseData = JacksonUtils.fromStringJson(response, ResponseData.class);
+//            if(responseData.getCode().equalsIgnoreCase("0")){
+//                List<WxOrderEntity> list = responseData.getData().getRows();
+//            }
         } catch (Exception e) {
             logger.error("查询失败。"+e.getMessage());
         }

+ 17 - 4
kmall-admin/src/main/java/com/kmall/admin/entity/compared/OrderComparedErrorEntity.java

@@ -16,19 +16,19 @@ public class OrderComparedErrorEntity implements Serializable {
     private static final long serialVersionUID = 1L;
 
     /**
-     *
+     * 主键
      */
     private Integer moceId;
     /**
-     *
+     * 商户订单编号
      */
     private String merchOrderSn;
     /**
-     *
+     * 订单金额
      */
     private BigDecimal orderAmount;
     /**
-     *
+     * 异常订单来源 (kmall/oms)
      */
     private String orderSource;
     /**
@@ -37,6 +37,11 @@ public class OrderComparedErrorEntity implements Serializable {
     private String createTime;
 
     /**
+     * 异常原因
+     */
+    private String reason;
+
+    /**
      * 设置:
      */
     public void setMoceId(Integer moceId) {
@@ -101,4 +106,12 @@ public class OrderComparedErrorEntity implements Serializable {
     public String getCreateTime() {
         return createTime;
     }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
 }

+ 13 - 76
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -520,9 +520,12 @@ public class OrderServiceImpl implements OrderService {
             OrderRefundEntity mallOrderRefund = orderRefundDao.queryObjectByOrderId(order.getId());
             OrderRefundEntity orderRefund = new OrderRefundEntity();
             orderRefund.setRefundId(result.getRefund_id());
-            orderRefund.setOutRefundNo(result.getOut_refund_no());
-            orderRefund
-                    .setRefundMoney(BigDecimal.valueOf(Long.valueOf(result.getRefund_fee())).divide(Constant.ONE_HUNDRED));
+            try {
+                orderRefund.setOutRefundNo(result.getOut_trade_no());
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            orderRefund.setRefundMoney(BigDecimal.valueOf(Long.valueOf(result.getRefund_fee())).divide(Constant.ONE_HUNDRED));
             orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_5.getItem()));//退款处理中
             orderRefund.setModTime(new Date());
 
@@ -565,7 +568,6 @@ public class OrderServiceImpl implements OrderService {
 
     @Transactional
     public void refund(OrderEntity order, AliPayMicropayApiResult result) {
-        boolean needUpdateStock = true;
         if (order.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_201.getItem())) {
             order.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
         }
@@ -600,21 +602,8 @@ public class OrderServiceImpl implements OrderService {
             }
         }
         orderDao.update(order);//修改为退款中
-        // TODO: 2019/6/13 定时任务查询退款成功后释放库存、优惠券
-        /*// 判断是否有优惠券
-        UserCouponEntity couponVo = userCouponDao.queryByOrderId(order.getId());
-        if (null != couponVo) {
-            userCouponDao.cancelOrder(couponVo);
-        }
-
-        if (!needUpdateStock) {
-            return;
-        }
-        // 更新库存
-        updateStock(order, "管理后台订单退款");*/
         updateStock(order, "收银端退款");
 
-//        queryStorePromRealUpdateIsScan(order);
     }
 
     /**
@@ -829,7 +818,7 @@ public class OrderServiceImpl implements OrderService {
      */
     private void resetStoreGoodsStock(Integer stockNum, ProductStoreRelaEntity storeRelaEntity,
                                  OrderGoodsEntity orderGoodsEntity, BigDecimal sellVolume, String changeReason, SysUserEntity user){
-        storeRelaEntity.setSellVolume(Integer.parseInt(sellVolume.toString()));
+        storeRelaEntity.setSellVolume(Integer.parseInt(sellVolume.toString())); // 减退库存
         storeRelaEntity.setStockNum(stockNum + orderGoodsEntity.getNumber());//库存数量
         productStoreRelaDao.update(storeRelaEntity);
 
@@ -1847,14 +1836,9 @@ public class OrderServiceImpl implements OrderService {
                             productInfo.setStockNum(productInfo.getStockNum() - num);
                             productInfo.setStoreId(Long.valueOf(storeId));
                             productInfo.setSellVolume(productInfo.getSellVolume() + num);
-//                            productInfo.addSellVolume();
                             productInfo.setLastSaleTime(new Date());
                             productStoreRelaDao.updateStockNum(productInfo);//修改普通商品库存
 
-
-
-
-
                             if(goodsEntity != null) {
                                 MngChangeEntity mngChangeEntity = new MngChangeEntity();
                                 mngChangeEntity.setThirdPartyMerchCode(goodsEntity.getThirdPartyMerchCode());
@@ -1872,8 +1856,6 @@ public class OrderServiceImpl implements OrderService {
                                 mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goodsEntity.getId())));
 
                                 mngChangeDao.save(mngChangeEntity);
-
-
                                 goodsEntity.setGoodsNumber(goodsEntity.getGoodsNumber() - num);
                                 goodsEntity.setLastSaleTime(new Date());
                                 goodsDao.update(goodsEntity);
@@ -1930,8 +1912,6 @@ public class OrderServiceImpl implements OrderService {
                         goodsEntity.setDiscountedPrice(disCountedPrice);
                         goodsEntity.setActualPaymentAmount(actualPaymentAmount);
 
-
-
                         // 借用这个字段来存储购买数
                         goodsEntity.setGoodsNumber(num);
                         goodsEntity.setActivity((String) goodsDto.get("activity"));
@@ -1954,9 +1934,6 @@ public class OrderServiceImpl implements OrderService {
                     tax = new BigDecimal((String) taxObject) ;
                 }
                 totalTax = totalTax.add(tax).setScale(2,BigDecimal.ROUND_HALF_DOWN); // 计算总的税额
-
-
-
             }
 
 
@@ -2000,7 +1977,6 @@ public class OrderServiceImpl implements OrderService {
             }
 
 
-
             // 判断该用户是否是生日
             Boolean isBirth = false;
             String birthday = "";
@@ -2065,8 +2041,6 @@ public class OrderServiceImpl implements OrderService {
 
             // 设置支付单开始时间
             processRecordEntity.setPaymentStartTime(new Date());
-
-
             // 判断是微信的支付码还是支付宝的支付码
             if (parCode.startsWith("28")) {
                 // 支付宝支付
@@ -2076,7 +2050,6 @@ public class OrderServiceImpl implements OrderService {
                     e.printStackTrace();
                     throw e;
                 }
-
             }else{
             // 微信支付
                 try {
@@ -2085,7 +2058,6 @@ public class OrderServiceImpl implements OrderService {
                     e.printStackTrace();
                     throw e;
                 }
-
             }
 
             OrderEntity orderEntity = queryObject(order.getId());
@@ -2405,28 +2377,6 @@ public class OrderServiceImpl implements OrderService {
             //查询当前订单所有的支付记录
             List<OrderWXPayRecordEntity> orderWXPayRecordEntitys =
                     orderWXPayRecordService.getRecordsByOutTradeNo(order.getOrder_sn());
-//            for (OrderWXPayRecordEntity orderWXPayRecordTemp : orderWXPayRecordEntitys) {
-//                //查询出来的记录排除当前已支付成功的记录,对其他记录交易状态为未撤销,未关闭的订单,调用撤销订单
-//                if (orderWXPayRecordTemp.getId() != orderWXPayRecordCurrent.getId() &&
-//                        (!WechatUtil.WXTradeState.REVOKED.getCode().equals(orderWXPayRecordTemp.getTradeState()) ||
-//                                !WechatUtil.WXTradeState.CLOSED.getCode().equals(orderWXPayRecordTemp.getTradeState()))) {
-//                    WechatReverseApiResult wechatReverseApiResult =
-//                            WechatUtil.wxReverse(orderWXPayRecordTemp.getOutTradeNoWX());
-//                    //撤销订单成功
-//                    if (WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatReverseApiResult.getReturn_code()) &&
-//                            WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatReverseApiResult.getResult_code())) {
-//                        //调用订单查询接口
-//                        WechatRefundApiResult wechatRefundApiResult =
-//                                WechatUtil.wxOrderQuery(orderWXPayRecordTemp.getOutTradeNoWX());
-//                        if (WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatRefundApiResult.getReturn_code()) &&
-//                                WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatRefundApiResult.getResult_code())) {
-//                            // 修改订单支付记录
-//                            orderWXPayRecordService
-//                                    .updateWXPayRecordTradeState(orderWXPayRecordTemp.getId(), wechatRefundApiResult);
-//                        }
-//                    }
-//                }
-//            }
             LOGGER.info("wechatMicropayApiResult.getTransaction_id()"+wechatMicropayApiResult.getTransaction_id());
 
             Map orderRaram = Maps.newHashMap();
@@ -2462,8 +2412,6 @@ public class OrderServiceImpl implements OrderService {
                 }
                 times++;
             }
-
-
             //用户支付失败
         } else if (WechatUtil.WXTradeState.PAYERROR.getCode().equals(wechatMicropayApiResult.getTrade_state())) {
             WechatReverseApiResult wechatReverseApiResult =
@@ -2600,24 +2548,14 @@ public class OrderServiceImpl implements OrderService {
             }
             String refundResult = "";
             if (orderInfo.getOrderStatus() != Integer.parseInt(Dict.orderStatus.item_0.getItem())) {
-//                if (orderInfo.getPayFlag().equalsIgnoreCase(Dict.payFlag.item_wxglobalpay.getItem())) {
-//                    refundResult = wxGlobalRefund(orderInfo, totalActualPrice);
-//                    if (org.apache.commons.lang3.StringUtils.isNotBlank(refundResult)) {
-//                        return R.error(refundResult);
-//                    }
-//                } else if (orderInfo.getPayFlag().equalsIgnoreCase(Dict.payFlag.item_pingan.getItem())) {
-//                    refundResult = pinganRefund(orderInfo, refundId);
-//                    if (org.apache.commons.lang3.StringUtils.isNotBlank(refundResult)) {
-//                        return R.error(refundResult);
-//                    }
-//                } else{
                 LOGGER.info("微信退款开始");
                     refundResult = wxRefund(orderInfo,totalActualPrice);
                     if(org.apache.commons.lang3.StringUtils.isNotBlank(refundResult)){
                         return R.error(refundResult);
                     }
+                order.setPayStatus(Integer.parseInt(Dict.payStatus.item_5.getItem()));
+                order.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
                 LOGGER.info("微信退款");
-//                }
             }
         // 支付宝的退款代码
         } else if(Dict.payFlag.item_alipay.getItem().equals(payFlag)) {
@@ -2635,10 +2573,10 @@ public class OrderServiceImpl implements OrderService {
                     .setRefundMoney(new BigDecimal(userRefund.getRefundFee()));
             orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_2.getItem()));//退款成功
             orderRefund.setModTime(new Date());
-
-                orderRefund.setOrderId(Integer.parseInt(order.getId() + ""));
-                orderRefund.setUserId(Integer.parseInt(order.getUserId() + ""));
-                orderRefund.setCreateTime(new Date());
+            orderRefund.setRefundTime(new Date());
+            orderRefund.setOrderId(Integer.parseInt(order.getId() + ""));
+            orderRefund.setUserId(Integer.parseInt(order.getUserId() + ""));
+            orderRefund.setCreateTime(new Date());
                 List<OrderEntity> list = orderDao.queryObjectByMerchOrderSn(order.getMerchOrderSn());
                 if(list.size()>1){//多条订单
                     orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_2.getItem()));//部分退款
@@ -2652,7 +2590,6 @@ public class OrderServiceImpl implements OrderService {
         PickUpCodeEntity pickUpCodeEntity = pickUpCodeService.queryObject(order.getOrderSn());
         pickUpCodeEntity.setPickUpCodeStatus("3");
         pickUpCodeService.update(pickUpCodeEntity);
-//        WebSocketServer.delete(sessionId,order.getStoreId(),pickUpCodeEntity);
         updateStock(order, "收银端退款");
         return R.ok("退款成功");
     }

+ 181 - 51
kmall-admin/src/main/java/com/kmall/admin/service/impl/compared/OrderComparedErrorServiceImpl.java

@@ -1,5 +1,10 @@
 package com.kmall.admin.service.impl.compared;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.google.gson.internal.LinkedTreeMap;
 import com.kmall.admin.dao.compared.OrderComparedErrorDao;
 import com.kmall.admin.entity.OrderEntity;
 import com.kmall.admin.entity.compared.OrderComparedErrorEntity;
@@ -7,9 +12,22 @@ import com.kmall.admin.entity.compared.PayOrderInfoEntity;
 import com.kmall.admin.service.OrderService;
 import com.kmall.admin.service.compared.OrderComparedErrorService;
 import com.kmall.admin.service.compared.PayOrderInfoService;
+import com.kmall.admin.utils.data.response.ResponseMessage;
+import com.kmall.admin.utils.data.response.ResponseMessageData;
+import com.kmall.admin.utils.oms.OkHttpUtils;
+import com.kmall.admin.utils.oms.OmsSign;
+import com.kmall.common.utils.R;
+import com.kmall.manager.manager.merch.OmsMerchProperties;
+import okhttp3.Request;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
 
+import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -24,6 +42,9 @@ import java.util.stream.Collectors;
  */
 @Service("orderComparedErrorService")
 public class OrderComparedErrorServiceImpl implements OrderComparedErrorService {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(OrderComparedErrorServiceImpl.class);
+
     @Autowired
     private OrderComparedErrorDao orderComparedErrorDao;
 
@@ -32,6 +53,10 @@ public class OrderComparedErrorServiceImpl implements OrderComparedErrorService
     @Autowired
     private OrderService orderService;
 
+    @Autowired
+    private OmsMerchProperties omsMerchProperties;
+
+
     @Override
     public OrderComparedErrorEntity queryObject(Integer moceId) {
         return orderComparedErrorDao.queryObject(moceId);
@@ -71,6 +96,7 @@ public class OrderComparedErrorServiceImpl implements OrderComparedErrorService
      * 对比订单
      */
     @Override
+    @Transactional
     public String comparedOrder() {
 
         try {
@@ -80,75 +106,179 @@ public class OrderComparedErrorServiceImpl implements OrderComparedErrorService
                 return "暂无需要对比的订单";
             }
 
-            // 查询前一天的订单
-            List<OrderEntity> orderEntities = orderService.queryLastDayOrder();
-            // 异常订单集合
-            Set<String> errorOrderSn = new HashSet<>();
-            // 删除订单号集合
-            Set<String> removeOrderSn = new HashSet<>();
-
-            // 判断两边数量是否相等
-            if(payOrderInfoEntities.size() != orderEntities.size()){
-                Set<String> payOrderSnSet = payOrderInfoEntities.stream().map(PayOrderInfoEntity::getMerchOrderSn).collect(Collectors.toSet());
-                Set<String> orderSnSet = orderEntities.stream().map(OrderEntity::getOrderSn).collect(Collectors.toSet());
-                orderSnSet.removeAll(payOrderSnSet);
-                errorOrderSn.addAll(orderSnSet);
-            }
+            // 对比中网的订单数据
+            comparedKmallOrder(payOrderInfoEntities);
+            // 对比oms的订单数据
+            comparedOmsOrder(payOrderInfoEntities);
+
+            // 批量修改支付单对比状态跟对比时间
+            payOrderInfoService.updateBatch(payOrderInfoEntities);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "对比失败,原因:"+e.getMessage();
+        }
 
+        return "对比成功";
+     }
 
-            for(PayOrderInfoEntity parOrderInfo : payOrderInfoEntities){
+    private void comparedOmsOrder(List<PayOrderInfoEntity> payOrderInfoEntities) throws IOException {
+        // 查询oms系统前一天的订单
+        List<OrderEntity> orderEntities = new ArrayList<>();
+        List<String> merchOrderSns = payOrderInfoEntities.stream().map(PayOrderInfoEntity::getMerchOrderSn).collect(Collectors.toList());
 
-                String merchOrderSn = parOrderInfo.getMerchOrderSn();
-                // 先将该订单装入集合中
-                boolean add = errorOrderSn.add(merchOrderSn);
-                for(OrderEntity order : orderEntities){
-                    String orderSn = order.getOrderSn();
-                    if(orderSn.equals(merchOrderSn)){
+        Map<String, String> sParaTemp = new TreeMap<String, String>();
+        sParaTemp.put("data",omsMerchProperties.getThirdSn());
+        sParaTemp.put("merchId",omsMerchProperties.getMerchSn());
+        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
+        sParaTemp.put("timestamp", timestamp);
+        //生成要请求给oms秘钥
+//        String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
+        LOGGER.info("md5混淆码参数:" + omsMerchProperties.getMd5Salt());
+        String sign = OmsSign.sign(sParaTemp,omsMerchProperties.getMd5Salt());
+        sParaTemp.put("sign", sign);
+        //构建Request
+        String  url = omsMerchProperties.getQueryOrderUrl();
+        url = "http://127.0.0.1:8680/al/shop/order/query";
+        Request request = OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
+        LOGGER.info("oms的请求报文:" + request);
+        // 同步访问,返回结果字符串
+        String responseString = null;
+        try {
 
-                        // 判断订单状态
-                        if(!order.getOrderStatus().equals(Integer.parseInt(parOrderInfo.getOrderStatus()))){
-                            continue;
-                        }
-                        // 判断支付状态
-                        if(!order.getPayStatus().equals(Integer.parseInt(parOrderInfo.getPayStatus()))){
-                            continue;
-                        }
+            responseString = OkHttpUtils.post(request);
 
-                        // 如果都一致,在集合中移除改订单
-                        errorOrderSn.remove(merchOrderSn);
-                        removeOrderSn.add(merchOrderSn);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+
+        LOGGER.info("oms的响应报文"+responseString);
+        //解析响应数据
+        Gson gson = new Gson();
+        ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
+        if(result == null){
+            String info = "解析响应数据Result失败";
+            LOGGER.error("--- {}", info);
+            throw new RuntimeException(info);
+        }
+        List rows = (List) result.getData().getRows().get(0);
+        // 要插入的异常订单集合
+        List<OrderComparedErrorEntity> insertList = new ArrayList<>();
+
+        // --------------------------- 开始对比支付单跟kmall中的订单 --------------------------
+
+        Map<String,OrderComparedErrorEntity> inconsistentMap = new HashMap<>();
+
+
+        for(PayOrderInfoEntity parOrderInfo : payOrderInfoEntities){
+
+            String merchOrderSn = parOrderInfo.getMerchOrderSn();
+            // 将订单号插入到表中
+            OrderComparedErrorEntity orderComparedErrorEntity = new OrderComparedErrorEntity();
+            orderComparedErrorEntity.setMerchOrderSn(merchOrderSn);
+            orderComparedErrorEntity.setOrderSource("OMS");
+            orderComparedErrorEntity.setReason("oms无订单");
+            inconsistentMap.put(merchOrderSn,orderComparedErrorEntity);
+
+            for(int i = 0 ; i < rows.size() ; i ++){
+                LinkedTreeMap<String,Object> treeMap = (LinkedTreeMap<String, Object>) rows.get(i);
+                String orderSn = (String) treeMap.get("merchOrderSn");
+                if(orderSn.equals(merchOrderSn)){
+                    String orderStatus = (String) treeMap.get("orderStatus");
+                    if("52".equals(orderStatus)){
+                        orderStatus = "300";
                     }
-                }
+                    // 判断订单状态 不等于支付单状态
+                    if(!orderStatus.equals(Integer.parseInt(parOrderInfo.getOrderStatus()))){
 
-                parOrderInfo.setCompared("1");
-                parOrderInfo.setComparedTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+                        orderComparedErrorEntity.setOrderSource("OMS");
+                        orderComparedErrorEntity.setReason("订单状态不一致");
+//                        inconsistentMap.put(orderSn,orderComparedErrorEntity);
+                        continue;
+                    }
+                    // 如果状态一直,然后map中有数据,则证明是当天退款的订单( 支付单:收费  退费 2条 订单 : 退 1条)
+                    if(orderComparedErrorEntity != null){
+                        inconsistentMap.remove(orderSn);
+                    }
 
+                }
             }
+            insertList = inconsistentMap.values().stream().collect(Collectors.toList());
+
+
+            parOrderInfo.setCompared("1");
+            parOrderInfo.setComparedTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+
+        }
+
+
+        if(insertList != null && insertList.size() > 0){
+            // 插入异常订单记录
+            orderComparedErrorDao.saveBatch(insertList);
+        }
+    }
+
+    private void comparedKmallOrder(List<PayOrderInfoEntity> payOrderInfoEntities) {
+        // 查询前一天的订单
+        List<OrderEntity> orderEntities = orderService.queryLastDayOrder();
+        // 要插入的异常订单集合
+        List<OrderComparedErrorEntity> insertList = new ArrayList<>();
 
-            // 防止出现下了单当天退,支付宝会有两条数据,所以需要在删除一次
-            errorOrderSn.removeAll(removeOrderSn);
+        // --------------------------- 开始对比支付单跟kmall中的订单 --------------------------
 
-            List<OrderComparedErrorEntity> insertList = new ArrayList<>();
+        Map<String,OrderComparedErrorEntity> inconsistentMap = new HashMap<>();
 
-            Iterator<String> iterator = errorOrderSn.iterator();
-            while(iterator.hasNext()){
-                String orderSn = iterator.next();
-                // 将订单号插入到表中
-                OrderComparedErrorEntity orderComparedErrorEntity = new OrderComparedErrorEntity();
-                orderComparedErrorEntity.setMerchOrderSn(orderSn);
 
-                insertList.add(orderComparedErrorEntity);
+        for(PayOrderInfoEntity parOrderInfo : payOrderInfoEntities){
+
+            String merchOrderSn = parOrderInfo.getMerchOrderSn();
+            // 将订单号插入到表中
+            OrderComparedErrorEntity orderComparedErrorEntity = new OrderComparedErrorEntity();
+            orderComparedErrorEntity.setMerchOrderSn(merchOrderSn);
+            orderComparedErrorEntity.setOrderSource("Kmall");
+            orderComparedErrorEntity.setReason("kmall无订单");
+            inconsistentMap.put(merchOrderSn,orderComparedErrorEntity);
+
+            for(OrderEntity order : orderEntities){
+                String orderSn = order.getOrderSn();
+                if(orderSn.equals(merchOrderSn)){
+
+                    // 判断订单状态 不等于支付单状态
+                    if(!order.getOrderStatus().equals(Integer.parseInt(parOrderInfo.getOrderStatus()))){
+
+                        orderComparedErrorEntity.setOrderSource("Kmall");
+                        orderComparedErrorEntity.setReason("订单状态不一致");
+//                        inconsistentMap.put(orderSn,orderComparedErrorEntity);
+                        continue;
+                    }
+                    // 如果状态一直,然后map中有数据,则证明是当天退款的订单( 支付单:收费  退费 2条 订单 : 退 1条)
+                    if(orderComparedErrorEntity != null){
+                        inconsistentMap.remove(orderSn);
+                    }
+
+                }
             }
+            insertList = inconsistentMap.values().stream().collect(Collectors.toList());
 
+
+            parOrderInfo.setCompared("1");
+            parOrderInfo.setComparedTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+
+        }
+
+
+        if(insertList != null && insertList.size() > 0){
             // 插入异常订单记录
             orderComparedErrorDao.saveBatch(insertList);
-            // 批量修改支付单对比状态跟对比时间
-            payOrderInfoService.updateBatch(payOrderInfoEntities);
-        } catch (NumberFormatException e) {
-            e.printStackTrace();
-            return "对比失败,原因:"+e.getMessage();
         }
 
-        return "对比成功";
     }
+
+    @RequestMapping("/orderReduce/{orderSn}")
+    public R orderReduce(@PathVariable("orderSn") String orderSn){
+
+
+        return R.ok();
+    }
+
 }

+ 11 - 6
kmall-admin/src/main/java/com/kmall/admin/service/impl/compared/PayOrderInfoServiceImpl.java

@@ -81,17 +81,22 @@ public class PayOrderInfoServiceImpl implements PayOrderInfoService {
                 ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
                 builder.put("merchOrderSn", "商户订单编号");
 
+                if(Dict.payFlag.item_alipay.getItem().equals(payFlag)){
+                    String style = payOrderDto.getPayFlag();
+                    if(style == null){
+                        continue;
+                    }
+                    if( !style.equals("在线支付") && !style.equals("退款(交易退款)")){
+                        continue;
+                    }
+                }
+
                 R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
                 if (Integer.valueOf(r.get("code").toString()) != 0) {
                     throw new RRException(r.get("msg").toString());
                 } else {
 
-                    if(Dict.payFlag.item_alipay.getItem().equals(payFlag)){
-                        String style = payOrderDto.getPayFlag();
-                        if( !style.equals("在线支付") && !style.equals("退款(交易退款)")){
-                            continue;
-                        }
-                    }
+
 
                     PayOrderInfoEntity payOrderInfoEntity = new PayOrderInfoEntity();
                     payOrderInfoEntity.setImporter(userEntity.getUserId()+""); // 导入者id

+ 245 - 0
kmall-admin/src/main/java/com/kmall/admin/utils/data/response/ResponseMessage.java

@@ -0,0 +1,245 @@
+package com.kmall.admin.utils.data.response;
+
+import com.google.common.base.Strings;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 回执消息结构
+ *
+ * @author Scott Chen
+ * @date 2017/4/20
+ */
+public class ResponseMessage {
+
+
+    /**
+     * 消息码
+     */
+    private String code;
+
+    /**
+     * 消息
+     */
+    private String msg;
+
+    /**
+     * 回执业务数据
+     */
+    private ResponseMessageData data;
+
+    private ResponseMessage() {
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public ResponseMessageData getData() {
+        return data;
+    }
+
+    public static boolean isSuccess(ResponseMessage message) {
+        return message.getCode() == null ? false : message.getCode().equals(ResponseStatus.SUCCESS.code) ? true : false;
+    }
+
+    public static Builder builder() {
+        return new Builder();
+    }
+    public static Builder builder(String code, String msg) {
+        return new Builder(code, msg);
+    }
+    public static Builder builder(String code, String msg, ResponseMessageData responseMessageData) {
+        return new Builder(code, msg, responseMessageData);
+    }
+    public static Builder builder(String code, String msg, List list) {
+        return new Builder(code, msg, list);
+    }
+    public static <T> Builder builder(T t,  Class<T> type) {
+        return new Builder(ResponseStatus.SUCCESS.code, ResponseStatus.SUCCESS.phrase, t, type);
+    }
+    public static <T> Builder builder(String msg, T t,  Class<T> type) {
+        return new Builder(ResponseStatus.SUCCESS.code, msg, t, type);
+    }
+    public static <T> Builder builder(String code, String msg, T t,  Class<T> type) {
+        return new Builder(code, msg, t, type);
+    }
+
+
+    //---------- 直接返回结果 ----------
+    //成功
+    public static ResponseMessage success() {
+        return new Builder().build();
+    }
+    public static ResponseMessage success(String code, String msg) {
+        return new Builder(code, msg).build();
+    }
+    public static ResponseMessage success(String msg) {
+        return new Builder(ResponseStatus.SUCCESS.code, msg).build();
+    }
+
+    public static ResponseMessage success(Map map) {
+        return new Builder(ResponseStatus.SUCCESS.code, ResponseStatus.SUCCESS.phrase, map).build();
+    }
+    public static ResponseMessage success(String msg, Map map) {
+        return new Builder(ResponseStatus.SUCCESS.code, msg, map).build();
+    }
+    public static ResponseMessage success(List rows) {
+        return new Builder(ResponseStatus.SUCCESS.code, ResponseStatus.SUCCESS.phrase, rows).build();
+    }
+    public static ResponseMessage success(String msg, List rows) {
+        return new Builder(ResponseStatus.SUCCESS.code, msg, rows).build();
+    }
+    public static ResponseMessage success(String code, String msg, List rows) {
+        return new Builder(code, msg, rows).build();
+    }
+    public static <T> ResponseMessage success(T t, Class<T> type) {
+        return new Builder(ResponseStatus.SUCCESS.code, ResponseStatus.SUCCESS.phrase, t, type).build();
+    }
+    public static <T> ResponseMessage success(String msg, T t, Class<T> type) {
+        return new Builder(ResponseStatus.SUCCESS.code, msg, t, type).build();
+    }
+    public static <T> ResponseMessage success(String code, String msg, T t, Class<T> type) {
+        return new Builder(code, msg, t, type).build();
+    }
+
+    //错误
+    public static ResponseMessage error() {
+        return new Builder(ResponseStatus.ERROR.code, ResponseStatus.ERROR.phrase).build();
+    }
+    public static ResponseMessage error(String code, String msg) {
+        return new Builder(code, msg).build();
+    }
+    public static ResponseMessage error(String msg) {
+        return new Builder(ResponseStatus.ERROR.code, msg).build();
+    }
+    public static ResponseMessage error(Map map) {
+        return new Builder(ResponseStatus.ERROR.code, ResponseStatus.ERROR.phrase, map).build();
+    }
+    public static ResponseMessage error(String msg, Map map) {
+        return new Builder(ResponseStatus.ERROR.code, msg, map).build();
+    }
+    public static ResponseMessage error(List rows) {
+        return new Builder(ResponseStatus.ERROR.code, ResponseStatus.ERROR.phrase, rows).build();
+    }
+    public static ResponseMessage error(String msg, List rows) {
+        return new Builder(ResponseStatus.ERROR.code, msg, rows).build();
+    }
+    public static ResponseMessage error(String code, String msg, List rows) {
+        return new Builder(code, msg, rows).build();
+    }
+
+    //失败
+    public static ResponseMessage failed() {
+        return new Builder(ResponseStatus.FAILURE.code, ResponseStatus.FAILURE.phrase).build();
+    }
+    public static ResponseMessage failed(String code, String msg) {
+        return new Builder(code, msg).build();
+    }
+    public static ResponseMessage failed(String msg) {
+        return new Builder(ResponseStatus.FAILURE.code, msg).build();
+    }
+
+    public static ResponseMessage failed(Map map) {
+        return new Builder(ResponseStatus.ERROR.code, ResponseStatus.ERROR.phrase, map).build();
+    }
+    public static ResponseMessage failed(String msg, Map map) {
+        return new Builder(ResponseStatus.ERROR.code, msg, map).build();
+    }
+    public static ResponseMessage failed(List rows) {
+        return new Builder(ResponseStatus.FAILURE.code, ResponseStatus.FAILURE.phrase, rows).build();
+    }
+    public static ResponseMessage failed(String msg, List rows) {
+        return new Builder(ResponseStatus.ERROR.code, msg, rows).build();
+    }
+    public static ResponseMessage failed(String code, String msg, List rows) {
+        return new Builder(code, msg, rows).build();
+    }
+
+    /**
+     * 消息构建器类
+     */
+    public static class Builder {
+        private String code;
+        private String msg;
+        private ResponseMessageData data;
+
+        public Builder() {
+            this.code = ResponseStatus.SUCCESS.code;
+            this.msg = ResponseStatus.SUCCESS.phrase;
+            this.data = ResponseMessageData.builder().build();
+        }
+
+        public Builder(String code, String msg) {
+            this.code = Strings.isNullOrEmpty(code) ? ResponseStatus.SUCCESS.code : code;
+            this.msg = Strings.isNullOrEmpty(msg) ? ResponseStatus.SUCCESS.phrase : msg;
+            this.data = ResponseMessageData.builder().build();
+        }
+
+        public Builder(String code, String msg, ResponseMessageData responseMessageData) {
+            this.code = Strings.isNullOrEmpty(code) ? ResponseStatus.SUCCESS.code : code;
+            this.msg = Strings.isNullOrEmpty(msg) ? ResponseStatus.SUCCESS.phrase : msg;
+            this.data = responseMessageData;
+        }
+
+        public Builder(String code, String msg, Map map) {
+            this.code = Strings.isNullOrEmpty(code) ? ResponseStatus.SUCCESS.code : code;
+            this.msg = Strings.isNullOrEmpty(msg) ? ResponseStatus.SUCCESS.phrase : msg;
+            this.data = ResponseMessageData.builder(map, Map.class).build();
+        }
+
+        public Builder(String code, String msg, List rows) {
+            this.code = Strings.isNullOrEmpty(code) ? ResponseStatus.SUCCESS.code : code;
+            this.msg = Strings.isNullOrEmpty(msg) ? ResponseStatus.SUCCESS.phrase : msg;
+            this.data = ResponseMessageData.builder(rows).build();
+        }
+
+        public <T> Builder(T t, Class<T> type) {
+            this.code = ResponseStatus.SUCCESS.code;
+            this.msg = ResponseStatus.SUCCESS.phrase;
+            this.data = ResponseMessageData.builder(t, type).build();
+        }
+
+        public <T> Builder(String msg, T t, Class<T> type) {
+            this.code = ResponseStatus.SUCCESS.code;
+            this.msg = Strings.isNullOrEmpty(msg) ? ResponseStatus.SUCCESS.phrase : msg;
+            this.data = ResponseMessageData.builder(t, type).build();
+        }
+
+        public <T> Builder(String code, String msg, T t, Class<T> type) {
+            this.code = Strings.isNullOrEmpty(code) ? ResponseStatus.SUCCESS.code : code;
+            this.msg = Strings.isNullOrEmpty(msg) ? ResponseStatus.SUCCESS.phrase : msg;
+            this.data = ResponseMessageData.builder(t, type).build();
+        }
+
+        public Builder setCode(String code) {
+            this.code = code;
+            return this;
+        }
+
+        public Builder setMsg(String msg) {
+            this.msg = msg;
+            return this;
+        }
+
+        public Builder setData(ResponseMessageData data) {
+            this.data = data;
+            return this;
+        }
+
+        public ResponseMessage build() {
+            ResponseMessage message = new ResponseMessage();
+            message.code = this.code;
+            message.msg = this.msg;
+            message.data = this.data;
+            return message;
+        }
+
+    }
+}
+

+ 86 - 0
kmall-admin/src/main/java/com/kmall/admin/utils/data/response/ResponseMessageData.java

@@ -0,0 +1,86 @@
+package com.kmall.admin.utils.data.response;
+
+import java.lang.reflect.ParameterizedType;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Scott Chen
+ * @date 2017/4/20
+ */
+public class ResponseMessageData {
+
+    private int total;
+    private List rows;
+
+    private ResponseMessageData() {
+    }
+
+    public int countUser() {
+        return total;
+    }
+
+    public List getRows() {
+        return rows;
+    }
+
+    public static Builder builder() {
+        return new Builder();
+    }
+    public static Builder builder(List rows) {
+        return new Builder(rows);
+    }
+    public static <T> Builder builder(T t, Class<T> type) {
+        return new Builder(t, type);
+    }
+
+
+    public static class Builder {
+        private int total = 0;
+        private List rows = new ArrayList<>();
+
+        public Builder() {
+        }
+
+        public Builder(List rows) {
+            this.total = rows ==null ? 0 : rows.size();
+            this.rows = rows ==null ? new ArrayList<>() : rows;
+        }
+
+        public <T> Builder(T t, Class<T> type) {
+            List rows = new ArrayList<>();
+            if (t == null) {
+                this.total = 0;
+            } else{
+                rows.add(t);
+                this.total = rows.size();
+            }
+            this.rows = rows;
+        }
+
+        private Class getActualTypeClass(Class entity) {
+            ParameterizedType type = (ParameterizedType) entity.getGenericSuperclass();
+            Class entityClass = (Class) type.getActualTypeArguments()[0];
+            return entityClass;
+        }
+
+        public Builder setTotal(int total) {
+            this.total = total;
+            return this;
+        }
+
+        public Builder setRows(List rows) {
+            this.rows = rows;
+            return this;
+        }
+
+        public ResponseMessageData build() {
+            ResponseMessageData data = new ResponseMessageData();
+            data.total = this.total;
+            data.rows = this.rows;
+            return data;
+        }
+
+    }
+
+}

+ 29 - 0
kmall-admin/src/main/java/com/kmall/admin/utils/data/response/ResponseStatus.java

@@ -0,0 +1,29 @@
+package com.kmall.admin.utils.data.response;
+
+/**
+ * 回执状态码
+ *
+ * @author Scott Chen
+ * @date 2017/3/9
+ */
+public enum ResponseStatus {
+
+    SUCCESS("0", "成功"),
+    ERROR("-1", "错误"),
+    FAILURE("-2", "失败"),
+
+    UNAUTHORIZED("401", "非法请求"),
+
+
+    SESSION_EXPIRE("600", "会话过期");
+
+
+    public final String code;
+    public final String phrase;
+
+    ResponseStatus(String code, String phrase) {
+        this.code = code;
+        this.phrase = phrase;
+    }
+
+}

+ 40 - 0
kmall-admin/src/main/java/com/kmall/admin/utils/oms/MD5Util.java

@@ -0,0 +1,40 @@
+package com.kmall.admin.utils.oms;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * @author zengjunlin
+ * @version 1.0
+ * 2017-09-26 15:18
+ */
+public class MD5Util {
+    //静态方法,便于作为工具类
+    public static String getMd5(String plainText) {
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            md.update(plainText.getBytes());
+            byte b[] = md.digest();
+
+            int i;
+
+            StringBuffer buf = new StringBuffer("");
+            for (int offset = 0; offset < b.length; offset++) {
+                i = b[offset];
+                if (i < 0)
+                    i += 256;
+                if (i < 16)
+                    buf.append("0");
+                buf.append(Integer.toHexString(i));
+            }
+            //32位加密
+            return buf.toString();
+            // 16位的加密
+            //return buf.toString().substring(8, 24);
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+            return null;
+        }
+
+    }
+}

+ 128 - 0
kmall-admin/src/main/java/com/kmall/admin/utils/oms/OkHttpUtils.java

@@ -0,0 +1,128 @@
+package com.kmall.admin.utils.oms;
+
+import okhttp3.*;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Scott Chen
+ * @date 2017/3/13
+ */
+public class OkHttpUtils {
+
+    public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
+    public static final int CONNEC_TIME = 20;
+    public static final int READ_TIME = 30;
+    public static final int WRITE_TIME = 30;
+
+    private static OkHttpClient okHttpClient = null;
+    static{
+        okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(CONNEC_TIME, TimeUnit.SECONDS)
+                .readTimeout(READ_TIME, TimeUnit.SECONDS)
+                .writeTimeout(WRITE_TIME, TimeUnit.SECONDS)
+                .build();
+    }
+
+    /**
+     * 构造RequestBody
+     *
+     * @param params
+     * @return
+     */
+    public static RequestBody buildRequestBody(Map<String, String> params) {
+        FormBody.Builder builder = new FormBody.Builder();
+        Iterator<Map.Entry<String, String>> iterator = params.entrySet().iterator();
+        while (iterator.hasNext()) {
+            Map.Entry<String, String> entry = iterator.next();
+            builder.add(entry.getKey(), entry.getValue());
+        }
+        return builder.build();
+    }
+
+    /**
+     * 以字符串数据构建Request(未使用)
+     * @param url
+     * @param json
+     * @return
+     */
+    public static Request buildRequest(String url, String json) {
+        RequestBody body = RequestBody.create(JSON, json);
+        return buildRequest(url, body);
+    }
+
+    /**
+     * 构建Request
+     * @param url
+     * @param body
+     * @return
+     */
+    public static Request buildRequest(String url, RequestBody body) {
+        return new Request.Builder()
+                .url(url)
+                .post(body)
+                .build();
+    }
+
+    /**
+     * 同步访问,返回结果字符串
+     * 可能超时
+     *
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    public static String post(Request request) throws IOException {
+        Response response = okHttpClient.newCall(request).execute();
+        String result = "";
+        if (response.isSuccessful()) {
+            result = response.body().string();
+        }else {
+            throw new IOException("okhttp3 post exception: " + response);
+        }
+        return result;
+    }
+
+    /**
+     * 同步访问,返回Response
+     * 可能超时
+     *
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    public static Response postReturnResponse(Request request)  throws IOException {
+        return okHttpClient.newCall(request).execute();
+    }
+
+    /**
+     * 异步访问,回调结果
+     * @param request
+     * @param responseCallback
+     */
+    public static void asyncPostCallback(Request request, Callback responseCallback) {
+        okHttpClient.newCall(request).enqueue(responseCallback);
+    }
+
+    /**
+     * 异步访问,无结果返回
+     * @param request
+     */
+    public static void asyncPost(Request request) {
+        okHttpClient.newCall(request).enqueue(new Callback() {
+            @Override
+            public void onFailure(Call call, IOException e) {
+
+            }
+
+            @Override
+            public void onResponse(Call call, Response response) throws IOException {
+
+            }
+        });
+    }
+
+}

+ 53 - 0
kmall-admin/src/main/java/com/kmall/admin/utils/oms/OmsSign.java

@@ -0,0 +1,53 @@
+package com.kmall.admin.utils.oms;
+
+
+import java.util.*;
+
+/**
+ * @author zengjunlin
+ * @version 1.0
+ * 2017-10-25 11:04
+ */
+public class OmsSign {
+
+
+    /**
+     * 加签
+     * @param params      请求参数
+     * @param secretKey  密钥
+     * @return 返回签名字串
+     */
+    public static final String sign(Map<String,String> params, String secretKey){
+        StringBuffer sign = new StringBuffer();
+        //按升序排列
+        List<Map.Entry<String, String>> infoIds = new ArrayList<Map.Entry<String, String>>(params.entrySet());
+        Collections.sort(infoIds, new Comparator<Map.Entry<String, String>>() {
+            public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
+                return (o1.getKey()).toString().compareTo(o2.getKey());
+            }
+        });
+        for(Map.Entry<String, String> m : infoIds){
+            sign.append(m.getKey()+ m.getValue());
+        }
+        sign.insert(0,secretKey);
+        return MD5Util.getMd5(sign.toString());
+    }
+
+
+    /**
+     * 验签
+     * @param signature  签名字串
+     * @param params      请求参数
+     * @param secretKey  密钥
+     * @return 签名通过返回true ,不通过返回false
+     */
+    public static final boolean verify(String signature, Map<String,String> params, String secretKey){
+       String sign = sign(params,secretKey);
+       if(signature.equals(sign)){
+            return true;
+       }
+        return false;
+    }
+
+
+}

+ 18 - 6
kmall-admin/src/main/resources/mybatis/mapper/compared/OrderComparedErrorDao.xml

@@ -9,6 +9,7 @@
         <result property="orderAmount" column="order_amount"/>
         <result property="orderSource" column="order_source"/>
         <result property="createTime" column="create_time"/>
+        <result property="reason" column="reason"/>
     </resultMap>
 
 	<select id="queryObject" resultType="com.kmall.admin.entity.compared.OrderComparedErrorEntity">
@@ -17,7 +18,8 @@
 			`merch_order_sn`,
 			`order_amount`,
 			`order_source`,
-			`create_time`
+			`create_time`,
+			`reason`
 		from mall_order_compared_error
 		where moce_id = #{id}
 	</select>
@@ -28,7 +30,8 @@
     		`merch_order_sn`,
     		`order_amount`,
     		`order_source`,
-    		`create_time`
+    		`create_time`,
+    		`reason`
 		from mall_order_compared_error
 		WHERE 1=1
 		<if test="name != null and name.trim() != ''">
@@ -60,12 +63,16 @@
 			`merch_order_sn`,
 			`order_amount`,
 			`order_source`,
-			`create_time`)
+			`create_time`,
+			`reason`
+			)
 		values(
 			#{merchOrderSn},
 			#{orderAmount},
 			#{orderSource},
-			#{createTime})
+			#{createTime},
+			#{reason}
+			)
 	</insert>
 
 	<update id="update" parameterType="com.kmall.admin.entity.compared.OrderComparedErrorEntity">
@@ -75,6 +82,7 @@
 			<if test="orderAmount != null">`order_amount` = #{orderAmount}, </if>
 			<if test="orderSource != null">`order_source` = #{orderSource}, </if>
 			<if test="createTime != null">`create_time` = #{createTime}</if>
+			<if test="reason != null">`reason` = #{reason}</if>
 		</set>
 		where moce_id = #{moceId}
 	</update>
@@ -95,14 +103,18 @@
 			`merch_order_sn`,
 			`order_amount`,
 			`order_source`,
-			`create_time`)
+			`create_time`,
+			`reason`
+			)
 		values
 		<foreach collection="list" index="index" item="item" separator=",">
 		(
 			#{item.merchOrderSn},
 			#{item.orderAmount},
 			#{item.orderSource},
-			#{item.createTime})
+			#{item.createTime},
+			#{item.reason}
+			)
 		</foreach>
 	</insert>
 

+ 1 - 1
kmall-admin/src/main/resources/mybatis/mapper/compared/PayOrderInfoDao.xml

@@ -182,7 +182,7 @@
 		from mall_pay_order_info
 		WHERE 1=1
 		AND compared = 0
-		order by mpoi_id desc
+		order by pay_time
 	</select>
 
 	<update id="updateBatch" parameterType="java.util.List">

+ 1 - 3
kmall-admin/src/main/webapp/WEB-INF/page/compared/ordercomparederror.html

@@ -16,9 +16,7 @@
                 <i-button @click="reloadSearch">重置</i-button>
             </div>
             <div class="buttons-group">
-                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
-                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
-                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
+                <i-button type="info" @click="reduce"><i class="fa fa-plus"></i>&nbsp;kmall调减</i-button>
             </div>
         </Row>
 	    <table id="jqGrid"></table>

+ 5 - 0
kmall-admin/src/main/webapp/js/compared/ordercomparederror.js

@@ -5,6 +5,8 @@ $(function () {
         colModel: [
 			{label: 'moceId', name: 'moceId', index: 'moce_id', key: true, hidden: true},
 			{label: '订单号', name: 'merchOrderSn', index: 'merch_order_sn', width: 80},
+			{label: '来源', name: 'orderSource', index: 'merch_order_sn', width: 80},
+			{label: '异常原因', name: 'reason', index: 'merch_order_sn', width: 80},
 			],
 		viewrecords: true,
         height: 550,
@@ -51,6 +53,9 @@ let vm = new Vue({
 		query: function () {
 			vm.reload();
 		},
+		reduce:function(){
+
+		},
 		add: function () {
 			vm.showList = false;
 			vm.title = "新增";

+ 13 - 10
kmall-common/src/main/java/com/kmall/common/utils/excel/ExcelExport.java

@@ -230,10 +230,11 @@ public class ExcelExport {
         int colNum = 0;
         // 从第二行开始
         int startRow = 1;
+        CellStyle cellStyle = workBook.createCellStyle();
         for (Object[] obj : list) {
 
             Row row = sheet.createRow(startRow++);
-            int cols = createRowData(row, Arrays.asList(obj));
+            int cols = createRowData(row, Arrays.asList(obj), cellStyle);
             row.setHeight((short) 400);
             colNum = colNum > cols ? colNum : cols;
         }
@@ -269,9 +270,11 @@ public class ExcelExport {
         // 转换数据
         // 从第二行开始
         int startRow = 1;
+
+        CellStyle cellStyle = workBook.createCellStyle();
         for (Map<String, Object> map : list) {
             Row row = sheet.createRow(startRow++);
-            int cols = createRowData(row, map.values());
+            int cols = createRowData(row, map.values(),cellStyle);
             row.setHeight((short) 400);
             colNum = colNum > cols ? colNum : cols;
         }
@@ -308,9 +311,10 @@ public class ExcelExport {
      *
      * @param row  要处理的行
      * @param coll 集合类型(List Map.values) 要处理的数据
+     * @param cellStyle
      * @return int  列数
      */
-    private int createRowData(Row row, Collection<Object> coll) {
+    private int createRowData(Row row, Collection<Object> coll, CellStyle cellStyle) {
 
         int cellNum = 0;
         for (Object obj : coll) {
@@ -333,7 +337,7 @@ public class ExcelExport {
                 // 处理宽度
 
                 // 设置单元格的值
-                setCellValue(cell, obj);
+                setCellValue(cell, obj,cellStyle);
 
             }
 
@@ -353,11 +357,11 @@ public class ExcelExport {
      * 对于CellType 和CellValue 的设置还需要详细参考文档,避免产生不必要的错误转换
      * 日期类型格式以通用格式。 待替换为全局变量
      * 数字保留小数和显示百分比格式暂时未设置
-     *
-     * @param cell 单元格
+     *  @param cell 单元格
      * @param obj  原始值( null已转换为"" 空字符串)
+     * @param cellStyle
      */
-    private void setCellValue(Cell cell, Object obj) {
+    private void setCellValue(Cell cell, Object obj, CellStyle cellStyle) {
 
         CreationHelper createHelper = workBook.getCreationHelper();
         String strValue = obj.toString();
@@ -367,7 +371,7 @@ public class ExcelExport {
             // 转换为Date后赋值
             Date dt = (Timestamp) obj;
             // String value = DateUtil.format(dt, "yyyy-MM-dd HH:mm:ss");
-            CellStyle cellStyle = workBook.createCellStyle();
+
             cellStyle.setDataFormat(createHelper.createDataFormat().getFormat(
                     "yyyy-MM-dd HH:mm:ss"));
 
@@ -381,7 +385,6 @@ public class ExcelExport {
             // String value = DateUtil.format((Date)obj, "yyyy-MM-dd");
             // cell.setCellValue(value);
 
-            CellStyle cellStyle = workBook.createCellStyle();
             cellStyle.setDataFormat(createHelper.createDataFormat().getFormat(
                     "yyyy-MM-dd"));
 
@@ -553,7 +556,7 @@ public class ExcelExport {
 
             }
         } catch (Exception e) {
-            // 不对异常做处理。仅打印到控制台以供调试 
+            // 不对异常做处理。仅打印到控制台以供调试
             // 占不打印
             // e.printStackTrace();
         }

+ 20 - 0
kmall-manager/src/main/java/com/kmall/manager/manager/merch/OmsMerchProperties.java

@@ -25,6 +25,10 @@ public class OmsMerchProperties implements Serializable {
 
     private String quotaInquiryUrl;
 
+    private String thirdSn ;
+
+    private String queryOrderUrl;
+
     public String getMerchSn() {
         return merchSn;
     }
@@ -80,4 +84,20 @@ public class OmsMerchProperties implements Serializable {
     public void setQuotaInquiryUrl(String quotaInquiryUrl) {
         this.quotaInquiryUrl = quotaInquiryUrl;
     }
+
+    public String getThirdSn() {
+        return thirdSn;
+    }
+
+    public void setThirdSn(String thirdSn) {
+        this.thirdSn = thirdSn;
+    }
+
+    public String getQueryOrderUrl() {
+        return queryOrderUrl;
+    }
+
+    public void setQueryOrderUrl(String queryOrderUrl) {
+        this.queryOrderUrl = queryOrderUrl;
+    }
 }

+ 15 - 12
kmall-manager/src/main/resources/conf/oms-merch.properties

@@ -6,24 +6,27 @@ merch.merchSn=mhbs990053989883052032
 merch.merchName=\u4E2D\u7F51\u79D1\u6280
 #oms\u5546\u6237\u7B80\u79F0
 merch.merchShortName=ZW
+#cw\u5546\u6237\u7F16\u53F7
+merch.thirdSn=CW001
+#\u67E5\u8BE2\u8BA2\u5355\u5730\u5740
+merch.queryOrderUrl=http://ws.ds-bay.com/al/shop/orderQuery
 
 #ccnet\u751F\u4EA7\u73AF\u5883\u67E5\u8BE2\u652F\u4ED8\u5355\u3001\u7535\u5B50\u8BA2\u5355\u3001\u8FD0\u5355\u5931\u8D25\u8BA2\u5355\u63A5\u53E3
-merch.wxOrderResendUrl=http://183.62.225.124:8680/wx/wxOrderResendQueryAll
-
+merch.wxOrderResendUrl=http://8.135.102.238:8680/wx/wxOrderResendQueryAll
 #oms\u6D4B\u8BD5\u73AF\u5883\u5BC6\u94A5
-merch.md5Salt=IxyIvP0sJqlUZinx
-#oms\u6D4B\u8BD5\u73AF\u5883\u6D3B\u4F53\u4EBA\u8138\u6838\u8EAB\u63A5\u53E3
-merch.livenessRecognitionUrl=http://127.0.0.1:8680/al/faceid/livenessRecognition
-#oms\u6D4B\u8BD5\u73AF\u5883\u8DE8\u5883\u989D\u5EA6\u67E5\u8BE2\u63A5\u53E3
-merch.quotaInquiryUrl=http://127.0.0.1:8680/al/cus/yearLimit
+#merch.md5Salt=IxyIvP0sJqlUZinx
+##oms\u6D4B\u8BD5\u73AF\u5883\u6D3B\u4F53\u4EBA\u8138\u6838\u8EAB\u63A5\u53E3
+#merch.livenessRecognitionUrl=http://127.0.0.1:8680/al/faceid/livenessRecognition
+##oms\u6D4B\u8BD5\u73AF\u5883\u8DE8\u5883\u989D\u5EA6\u67E5\u8BE2\u63A5\u53E3
+#merch.quotaInquiryUrl=http://127.0.0.1:8680/al/cus/yearLimit
 
 
 ####oms\u751F\u4EA7\u73AF\u5883\u5BC6\u94A5
-#merch.md5Salt=IxyIvP0sJqlUZinx
-###oms\u751F\u4EA7\u73AF\u5883\u6D3B\u4F53\u4EBA\u8138\u6838\u8EAB\u63A5\u53E3
-#merch.livenessRecognitionUrl=http://ws.ds-bay.com/al/faceid/livenessRecognition
-###oms\u6D4B\u8BD5\u73AF\u5883\u8DE8\u5883\u989D\u5EA6\u67E5\u8BE2\u63A5\u53E3
-#merch.quotaInquiryUrl=http://ws.ds-bay.com/al/cus/yearLimit
+merch.md5Salt=IxyIvP0sJqlUZinx
+##oms\u751F\u4EA7\u73AF\u5883\u6D3B\u4F53\u4EBA\u8138\u6838\u8EAB\u63A5\u53E3
+merch.livenessRecognitionUrl=http://ws.ds-bay.com/al/faceid/livenessRecognition
+##oms\u6D4B\u8BD5\u73AF\u5883\u8DE8\u5883\u989D\u5EA6\u67E5\u8BE2\u63A5\u53E3
+merch.quotaInquiryUrl=http://ws.ds-bay.com/al/cus/yearLimit
 
 
 ##oms\u5546\u6237\u6D4B\u8BD5\u73AF\u5883\u5BC6\u94A5

+ 2 - 0
kmall-manager/src/main/resources/spring/spring-oms-merch.xml

@@ -23,5 +23,7 @@
         <property name="md5Salt" value="${merch.md5Salt}"/>
         <property name="livenessRecognitionUrl" value="${merch.livenessRecognitionUrl}"/>
         <property name="quotaInquiryUrl" value="${merch.quotaInquiryUrl}"/>
+        <property name="thirdSn" value="${merch.thirdSn}"/>
+        <property name="queryOrderUrl" value="${merch.queryOrderUrl}"/>
     </bean>
 </beans>