1
0
Просмотр исходного кода

Merge remote-tracking branch 'upsteam/master'

dq 6 лет назад
Родитель
Сommit
865518520e
56 измененных файлов с 1970 добавлено и 358 удалено
  1. 0 3
      kmall-admin/src/main/java/com/kmall/admin/controller/AdController.java
  2. 0 2
      kmall-admin/src/main/java/com/kmall/admin/controller/AttributeController.java
  3. 0 2
      kmall-admin/src/main/java/com/kmall/admin/controller/BrandController.java
  4. 0 2
      kmall-admin/src/main/java/com/kmall/admin/controller/CategoryController.java
  5. 1 1
      kmall-admin/src/main/java/com/kmall/admin/controller/ExportExceptionDataController.java
  6. 1 1
      kmall-admin/src/main/java/com/kmall/admin/controller/FeedbackController.java
  7. 1 1
      kmall-admin/src/main/java/com/kmall/admin/controller/GoodsIssueController.java
  8. 1 1
      kmall-admin/src/main/java/com/kmall/admin/controller/HelpIssueController.java
  9. 98 50
      kmall-admin/src/main/java/com/kmall/admin/controller/OrderController.java
  10. 0 4
      kmall-admin/src/main/java/com/kmall/admin/controller/ProductStoreRelaController.java
  11. 97 0
      kmall-admin/src/main/java/com/kmall/admin/entity/OrderRefundEntity.java
  12. 9 4
      kmall-admin/src/main/java/com/kmall/admin/service/OrderService.java
  13. 1 1
      kmall-admin/src/main/java/com/kmall/admin/service/impl/CategoryServiceImpl.java
  14. 1 3
      kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java
  15. 0 2
      kmall-admin/src/main/java/com/kmall/admin/service/impl/OfflineCartServiceImpl.java
  16. 74 35
      kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java
  17. 12 1
      kmall-admin/src/main/java/com/kmall/admin/service/impl/ProductStoreRelaServiceImpl.java
  18. 1 1
      kmall-admin/src/main/java/com/kmall/admin/utils/ParamUtils.java
  19. 86 0
      kmall-admin/src/main/resources/conf/wx-global.properties
  20. 41 0
      kmall-admin/src/main/resources/mybatis/mapper/OrderRefundDao.xml
  21. 1 0
      kmall-admin/src/main/resources/spring/spring-context.xml
  22. 1 0
      kmall-admin/src/main/resources/spring/spring-main.xml
  23. 62 0
      kmall-admin/src/main/resources/spring/spring-wx-global-pay.xml
  24. 1 0
      kmall-admin/src/main/webapp/WEB-INF/web.xml
  25. 1 1
      kmall-api/src/main/java/com/kmall/api/api/ApiCartController.java
  26. 2 0
      kmall-api/src/main/java/com/kmall/api/api/ApiGoodsController.java
  27. 1 1
      kmall-api/src/main/java/com/kmall/api/api/ApiGoodsGroupController.java
  28. 7 7
      kmall-api/src/main/java/com/kmall/api/api/ApiOrderController.java
  29. 4 9
      kmall-api/src/main/java/com/kmall/api/api/ApiPayController.java
  30. 281 0
      kmall-api/src/main/java/com/kmall/api/api/wxGlobal/ApiWxGlobalPayController.java
  31. 62 1
      kmall-api/src/main/java/com/kmall/api/entity/OrderVo.java
  32. 1 1
      kmall-api/src/main/java/com/kmall/api/service/ApiCouponService.java
  33. 1 3
      kmall-api/src/main/java/com/kmall/api/service/ApiOrderService.java
  34. 8 5
      kmall-api/src/main/java/com/kmall/api/service/ApiPayService.java
  35. 1 1
      kmall-api/src/main/java/com/kmall/api/service/ApiUserCouponService.java
  36. 212 0
      kmall-api/src/main/java/com/kmall/api/service/wxGlobal/ApiWxGlobalPayService.java
  37. 6 0
      kmall-api/src/main/resources/mybatis/mapper/ApiGoodsMapper.xml
  38. 31 0
      kmall-api/src/main/resources/mybatis/mapper/ApiOrderMapper.xml
  39. 84 5
      kmall-common/src/main/java/com/kmall/common/constant/Dict.java
  40. 12 0
      kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayDevProperties.java
  41. 12 0
      kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayProdProperties.java
  42. 181 0
      kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayProperties.java
  43. 41 0
      kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayPropertiesBuilder.java
  44. 39 0
      kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayPropertiesConfiguration.java
  45. 9 0
      kmall-common/src/main/java/com/kmall/common/utils/wechat/WechatRefundApiResult.java
  46. 5 5
      kmall-common/src/main/java/com/kmall/common/utils/wechat/WechatUtil.java
  47. 79 89
      kmall-common/src/main/java/com/kmall/common/utils/wechat/wxglobal/WechatGlobalUtil.java
  48. 9 0
      kmall-common/src/main/java/com/kmall/common/utils/wechat/wxglobal/dto/WechatGlobalQueryApiResult.java
  49. 3 3
      kmall-common/src/main/java/com/kmall/common/utils/wechat/wxglobal/dto/WechatGlobalRefundApiResult.java
  50. 1 0
      kmall-framework/src/main/webapp/WEB-INF/web.xml
  51. 1 0
      kmall-framework/src/test/resources/applicationContext-test.xml
  52. 355 109
      kmall-schedule/src/main/java/com/kmall/schedule/service/QzOrderService.java
  53. 15 2
      kmall-schedule/src/main/resources/mybatis/mapper/QzOrderMapper.xml
  54. 1 1
      wx-mall/pages/goods/goods.wxml
  55. 15 0
      wx-mall/pages/shopping/address/address.js
  56. 1 1
      wx-mall/pages/ucenter/collect/collect.wxml

+ 0 - 3
kmall-admin/src/main/java/com/kmall/admin/controller/AdController.java

@@ -3,12 +3,9 @@ package com.kmall.admin.controller;
 import com.kmall.admin.entity.AdEntity;
 import com.kmall.admin.service.AdService;
 import com.kmall.admin.utils.ParamUtils;
-import com.kmall.api.contants.Dict;
-import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.PageUtils;
 import com.kmall.common.utils.Query;
 import com.kmall.common.utils.R;
-import com.kmall.common.utils.ShiroUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;

+ 0 - 2
kmall-admin/src/main/java/com/kmall/admin/controller/AttributeController.java

@@ -4,8 +4,6 @@ import com.google.common.collect.ImmutableBiMap;
 import com.kmall.admin.entity.AttributeEntity;
 import com.kmall.admin.service.AttributeService;
 import com.kmall.admin.utils.ParamUtils;
-import com.kmall.api.contants.Dict;
-import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.*;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;

+ 0 - 2
kmall-admin/src/main/java/com/kmall/admin/controller/BrandController.java

@@ -4,8 +4,6 @@ import com.google.common.collect.ImmutableBiMap;
 import com.kmall.admin.entity.BrandEntity;
 import com.kmall.admin.service.BrandService;
 import com.kmall.admin.utils.ParamUtils;
-import com.kmall.api.contants.Dict;
-import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.*;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;

+ 0 - 2
kmall-admin/src/main/java/com/kmall/admin/controller/CategoryController.java

@@ -3,8 +3,6 @@ package com.kmall.admin.controller;
 import com.kmall.admin.entity.CategoryEntity;
 import com.kmall.admin.service.CategoryService;
 import com.kmall.admin.utils.ParamUtils;
-import com.kmall.api.contants.Dict;
-import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.*;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/controller/ExportExceptionDataController.java

@@ -5,7 +5,7 @@ import java.util.Map;
 
 import com.kmall.admin.entity.ExportExceptionDataEntity;
 import com.kmall.admin.service.ExportExceptionDataService;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.PageUtils;
 import com.kmall.common.utils.Query;

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/controller/FeedbackController.java

@@ -2,7 +2,7 @@ package com.kmall.admin.controller;
 
 import com.kmall.admin.entity.FeedbackEntity;
 import com.kmall.admin.service.FeedbackService;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.PageUtils;
 import com.kmall.common.utils.Query;

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/controller/GoodsIssueController.java

@@ -3,7 +3,7 @@ package com.kmall.admin.controller;
 import com.google.common.collect.ImmutableBiMap;
 import com.kmall.admin.entity.GoodsIssueEntity;
 import com.kmall.admin.service.GoodsIssueService;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.*;
 import org.apache.shiro.authz.annotation.RequiresPermissions;

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/controller/HelpIssueController.java

@@ -3,7 +3,7 @@ package com.kmall.admin.controller;
 import com.google.common.collect.ImmutableBiMap;
 import com.kmall.admin.entity.HelpIssueEntity;
 import com.kmall.admin.service.HelpIssueService;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.*;
 import org.apache.shiro.authz.annotation.RequiresPermissions;

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

@@ -6,7 +6,7 @@ import com.kmall.admin.service.OrderExceptionRecordService;
 import com.kmall.admin.service.OrderProcessRecordService;
 import com.kmall.admin.service.OrderService;
 import com.kmall.admin.utils.ParamUtils;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.*;
 import com.kmall.common.utils.print.ticket.item.Ticket;
@@ -14,12 +14,14 @@ import com.kmall.common.utils.wechat.WechatMicropayApiResult;
 import com.kmall.common.utils.wechat.WechatRefundApiResult;
 import com.kmall.common.utils.wechat.WechatReverseApiResult;
 import com.kmall.common.utils.wechat.WechatUtil;
+import com.kmall.common.utils.wechat.wxglobal.WechatGlobalUtil;
+import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalRefundApiResult;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -300,45 +302,92 @@ public class OrderController {
         if (totalActualPrice == null) {
             totalActualPrice = 0d;
         }
-
-        if (orderInfo.getOrderStatus() != 0) {
-            // todo 退款
-            //          WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(),
-            //          orderInfo.getActualPrice().doubleValue(), refundMoney.doubleValue());
-            WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getMerchOrderSn().toString(), totalActualPrice,
-                                                               orderInfo.getActualPrice().doubleValue());
-            if (result.getResult_code().equals("SUCCESS")) {
-                orderService.refund(orderInfo, result);
-            } else {
-                OrderRefundEntity mallOrderRefund = orderRefundService.queryObjectByOrderId(orderInfo.getId());
-                OrderRefundEntity orderRefund = new OrderRefundEntity();
-                orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));
-                orderRefund.setRefundMoney(BigDecimal.valueOf(orderInfo.getActualPrice().doubleValue()));
-                orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_4.getItem()));
-                orderRefund.setModTime(new Date());
-                orderRefund.setOutRefundNo(result.getOut_refund_no());
-                if (mallOrderRefund != null) {
-                    orderRefund.setId(mallOrderRefund.getId());
-                    orderRefundService.update(orderRefund);//退款记录
+        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(StringUtils.isNotBlank(refundResult)){
+                    return R.error(refundResult);
+                }
+            }else{
+                refundResult = wxRefund(orderInfo,totalActualPrice);
+                if(StringUtils.isNotBlank(refundResult)){
+                    return R.error(refundResult);
                 }
-
-                OrderExceptionRecordEntity mallOrderExceptionRecord = new OrderExceptionRecordEntity();
-                mallOrderExceptionRecord.setUserId(Integer.parseInt(orderInfo.getUserId() + ""));
-                mallOrderExceptionRecord.setOrderSn(orderInfo.getOrderSn());
-                mallOrderExceptionRecord.setExceptionStatus(Dict.exceptionStatus.item_03.getItem());
-                mallOrderExceptionRecord.setExceptionContent("退款失败" + result.getErr_code_des());
-                mallOrderExceptionRecord.setCreateTime(new Date());
-                orderExceptionRecordService.save(mallOrderExceptionRecord);
-
-                return R.error(result.getErr_code_des());
             }
         }
-
         return R.ok("退款成功");
     }
-
+    /**
+     * 微信申请退款
+     * @param orderInfo
+     * @param totalActualPrice
+     * @return
+     */
+    private String wxRefund(OrderEntity orderInfo,Double totalActualPrice){
+        WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getMerchOrderSn().toString(), totalActualPrice,
+                orderInfo.getActualPrice().doubleValue());
+        if (result.getResult_code().equals(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+            orderService.refund(orderInfo, result);
+        } else {
+            OrderRefundEntity mallOrderRefund = orderRefundService.queryObjectByOrderId(orderInfo.getId());
+            OrderRefundEntity orderRefund = new OrderRefundEntity();
+            orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));
+            orderRefund.setRefundMoney(BigDecimal.valueOf(orderInfo.getActualPrice().doubleValue()));
+            orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_4.getItem()));
+            orderRefund.setModTime(new Date());
+            orderRefund.setOutRefundNo(result.getOut_refund_no());
+            if (mallOrderRefund != null) {
+                orderRefund.setId(mallOrderRefund.getId());
+                orderRefundService.update(orderRefund);//退款记录
+            }
+            OrderExceptionRecordEntity mallOrderExceptionRecord = new OrderExceptionRecordEntity();
+            mallOrderExceptionRecord.setUserId(Integer.parseInt(orderInfo.getUserId() + ""));
+            mallOrderExceptionRecord.setOrderSn(orderInfo.getOrderSn());
+            mallOrderExceptionRecord.setExceptionStatus(Dict.exceptionStatus.item_03.getItem());
+            mallOrderExceptionRecord.setExceptionContent("退款失败" + result.getErr_code_des());
+            mallOrderExceptionRecord.setCreateTime(new Date());
+            orderExceptionRecordService.save(mallOrderExceptionRecord);
+            return result.getErr_code_des();
+        }
+        return "";
+    }
 
     /**
+     * 微信国际申请退款
+     * @param orderInfo
+     * @param totalActualPrice
+     * @return
+     */
+    private String wxGlobalRefund(OrderEntity orderInfo,Double totalActualPrice){
+        WechatGlobalRefundApiResult result = WechatGlobalUtil.wxRefund(orderInfo.getMerchOrderSn().toString(), totalActualPrice,
+                orderInfo.getActualPrice().doubleValue());
+        if (result.getResult_code().equals(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+            orderService.globalRefund(orderInfo, result);
+        } else {
+            OrderRefundEntity mallOrderRefund = orderRefundService.queryObjectByOrderId(orderInfo.getId());
+            OrderRefundEntity orderRefund = new OrderRefundEntity();
+            orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));
+            orderRefund.setRefundMoney(BigDecimal.valueOf(orderInfo.getActualPrice().doubleValue()));
+            orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_4.getItem()));
+            orderRefund.setOutRefundNo(result.getOut_refund_no());
+            orderRefund.setModTime(new Date());
+            if (mallOrderRefund != null) {
+                orderRefund.setId(mallOrderRefund.getId());
+                orderRefundService.update(orderRefund);//退款记录
+            }
+            OrderExceptionRecordEntity mallOrderExceptionRecord = new OrderExceptionRecordEntity();
+            mallOrderExceptionRecord.setUserId(Integer.parseInt(orderInfo.getUserId() + ""));
+            mallOrderExceptionRecord.setOrderSn(orderInfo.getOrderSn());
+            mallOrderExceptionRecord.setExceptionStatus(Dict.exceptionStatus.item_03.getItem());
+            mallOrderExceptionRecord.setExceptionContent("退款失败" + result.getErr_code_des());
+            mallOrderExceptionRecord.setCreateTime(new Date());
+            orderExceptionRecordService.save(mallOrderExceptionRecord);
+            return result.getErr_code_des();
+        }
+        return "";
+    }
+    /**
      * 订单退款请求
      */
     @RequiresPermissions(value = {"order:offilineRefund"})
@@ -353,17 +402,16 @@ public class OrderController {
             return R.error("订单已退款");
         }
 
-        if (orderInfo.getOrderStatus() != 0) {
-            //现金支付
+        if (orderInfo.getOrderStatus() != Integer.parseInt(Dict.orderStatus.item_0.getItem())) {
             if (Dict.payFlag.item_cash.getItem().equals(orderInfo.getPayFlag())) {
+                //现金支付,直接修改订单状态
                 orderService.refund(orderInfo, null);
-                //微信支付
             } else if (Dict.payFlag.item_weixin.getItem().equals(orderInfo.getPayFlag())) {
-                // todo 退款
+                //微信线下扫码支付
                 WechatRefundApiResult result = WechatUtil
                         .wxRefund(orderInfo.getOrderSnWx(), orderInfo.getActualPrice().doubleValue(),
                                   orderInfo.getActualPrice().doubleValue());
-                if (result.getResult_code().equals("SUCCESS")) {
+                if (result.getResult_code().equals(WechatUtil.WXTradeState.SUCCESS.getCode())) {
                     orderService.refund(orderInfo, result);
                 } else {
                     OrderRefundEntity mallOrderRefund = orderRefundService.queryObjectByOrderId(orderInfo.getId());
@@ -371,8 +419,8 @@ public class OrderController {
                     orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));
                     orderRefund.setRefundMoney(BigDecimal.valueOf(orderInfo.getActualPrice().doubleValue()));
                     orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_4.getItem()));
-                    orderRefund.setModTime(new Date());
                     orderRefund.setOutRefundNo(result.getOut_refund_no());
+                    orderRefund.setModTime(new Date());
                     if (mallOrderRefund != null) {
                         orderRefund.setId(mallOrderRefund.getId());
                         orderRefundService.update(orderRefund);//退款记录
@@ -434,7 +482,7 @@ public class OrderController {
     @RequestMapping("/confirmPay")
     @RequiresPermissions("order:confirmPay")
     public R confirmPay(@RequestBody Long id) {
-        orderService.confirmPay(id, Dict.payFlag.item_cash, null);
+        orderService.confirmPay(id, Dict.payFlag.item_cash.getItem(), null);
 
         return R.ok();
     }
@@ -512,13 +560,13 @@ public class OrderController {
                     WechatReverseApiResult wechatReverseApiResult =
                             WechatUtil.wxReverse(orderWXPayRecordTemp.getOutTradeNoWX());
                     //撤销订单成功
-                    if ("SUCCESS".equals(wechatReverseApiResult.getReturn_code()) &&
-                        "SUCCESS".equals(wechatReverseApiResult.getResult_code())) {
+                    if (WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatReverseApiResult.getReturn_code()) &&
+                            WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatReverseApiResult.getResult_code())) {
                         //调用订单查询接口
                         WechatRefundApiResult wechatRefundApiResult =
                                 WechatUtil.wxOrderQuery(orderWXPayRecordTemp.getOutTradeNoWX());
-                        if ("SUCCESS".equals(wechatRefundApiResult.getReturn_code()) &&
-                            "SUCCESS".equals(wechatRefundApiResult.getResult_code())) {
+                        if (WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatRefundApiResult.getReturn_code()) &&
+                                WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatRefundApiResult.getResult_code())) {
                             // 修改订单支付记录
                             orderWXPayRecordService
                                     .updateWXPayRecordTradeState(orderWXPayRecordTemp.getId(), wechatRefundApiResult);
@@ -526,7 +574,7 @@ public class OrderController {
                     }
                 }
             }
-            orderService.confirmPay(id, Dict.payFlag.item_weixin, orderWXPayRecordCurrent.getOutTradeNoWX());
+            orderService.confirmPay(id, Dict.payFlag.item_weixin.getItem(), orderWXPayRecordCurrent.getOutTradeNoWX());
             r = R.ok();
             //用户支付中
         } else if (WechatUtil.WXTradeState.USERPAYING.getCode().equals(wechatMicropayApiResult.getTrade_state())) {
@@ -536,13 +584,13 @@ public class OrderController {
             WechatReverseApiResult wechatReverseApiResult =
                     WechatUtil.wxReverse(orderWXPayRecordCurrent.getOutTradeNoWX());
             //撤销订单成功
-            if ("SUCCESS".equals(wechatReverseApiResult.getReturn_code()) &&
-                "SUCCESS".equals(wechatReverseApiResult.getResult_code())) {
+            if (WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatReverseApiResult.getReturn_code()) &&
+                    WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatReverseApiResult.getResult_code())) {
                 //调用订单查询接口
                 WechatRefundApiResult wechatRefundApiResult =
                         WechatUtil.wxOrderQuery(orderWXPayRecordCurrent.getOutTradeNoWX());
-                if ("SUCCESS".equals(wechatRefundApiResult.getReturn_code()) &&
-                    "SUCCESS".equals(wechatRefundApiResult.getResult_code())) {
+                if (WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatRefundApiResult.getReturn_code()) &&
+                        WechatUtil.WXTradeState.SUCCESS.getCode().equals(wechatRefundApiResult.getResult_code())) {
                     // 修改订单支付记录
                     orderWXPayRecordService
                             .updateWXPayRecordTradeState(orderWXPayRecordCurrent.getId(), wechatRefundApiResult);

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

@@ -5,18 +5,14 @@ import com.kmall.admin.entity.StoreEntity;
 import com.kmall.admin.service.ProductStoreRelaService;
 import com.kmall.admin.service.StoreService;
 import com.kmall.admin.utils.ParamUtils;
-import com.kmall.api.contants.Dict;
-import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.PageUtils;
 import com.kmall.common.utils.Query;
 import com.kmall.common.utils.R;
-import com.kmall.common.utils.ShiroUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 

+ 97 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/OrderRefundEntity.java

@@ -115,6 +115,39 @@ public class OrderRefundEntity implements Serializable {
 
     private String userName;
 
+    /**
+     * 退款币种;微信国际退款返回数据
+     */
+    private String refundFeeType;
+    /**
+     * 标价金额;微信国际退款返回数据
+     */
+    private Integer totalFee;
+    /**
+     * 标价币种;微信国际退款返回数据
+     */
+    private String feeType;
+    /**
+     * 用户支付金额;微信国际退款返回数据
+     */
+    private Integer cashFee;
+    /**
+     * 用户支付币种;微信国际退款返回数据
+     */
+    private String cashFeeType;
+    /**
+     * 用户支付退款金额;微信国际退款返回数据
+     */
+    private Integer cashRefundFee;
+    /**
+     * 用户支付退款币种;微信国际退款返回数据
+     */
+    private String cashRefundFeeType;
+    /**
+     * 汇率
+     */
+    private String rate;
+
     public String getOrderSn() {
         return orderSn;
     }
@@ -410,4 +443,68 @@ public class OrderRefundEntity implements Serializable {
     public Date getTstm() {
         return tstm;
     }
+
+    public String getRefundFeeType() {
+        return refundFeeType;
+    }
+
+    public void setRefundFeeType(String refundFeeType) {
+        this.refundFeeType = refundFeeType;
+    }
+
+    public Integer getTotalFee() {
+        return totalFee;
+    }
+
+    public void setTotalFee(Integer totalFee) {
+        this.totalFee = totalFee;
+    }
+
+    public String getFeeType() {
+        return feeType;
+    }
+
+    public void setFeeType(String feeType) {
+        this.feeType = feeType;
+    }
+
+    public Integer getCashFee() {
+        return cashFee;
+    }
+
+    public void setCashFee(Integer cashFee) {
+        this.cashFee = cashFee;
+    }
+
+    public String getCashFeeType() {
+        return cashFeeType;
+    }
+
+    public void setCashFeeType(String cashFeeType) {
+        this.cashFeeType = cashFeeType;
+    }
+
+    public Integer getCashRefundFee() {
+        return cashRefundFee;
+    }
+
+    public void setCashRefundFee(Integer cashRefundFee) {
+        this.cashRefundFee = cashRefundFee;
+    }
+
+    public String getCashRefundFeeType() {
+        return cashRefundFeeType;
+    }
+
+    public void setCashRefundFeeType(String cashRefundFeeType) {
+        this.cashRefundFeeType = cashRefundFeeType;
+    }
+
+    public String getRate() {
+        return rate;
+    }
+
+    public void setRate(String rate) {
+        this.rate = rate;
+    }
 }

+ 9 - 4
kmall-admin/src/main/java/com/kmall/admin/service/OrderService.java

@@ -3,13 +3,11 @@ package com.kmall.admin.service;
 import com.kmall.admin.entity.OfflineCartEntity;
 import com.kmall.admin.entity.OrderEntity;
 import com.kmall.admin.entity.OrderRefundEntity;
-import com.kmall.api.contants.Dict;
 import com.kmall.common.entity.SysUserEntity;
-import com.kmall.common.utils.R;
 import com.kmall.common.utils.print.ticket.item.Ticket;
 import com.kmall.common.utils.wechat.WechatRefundApiResult;
+import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalRefundApiResult;
 
-import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -61,6 +59,13 @@ public interface OrderService {
      */
     void refund(OrderEntity orderInfo, WechatRefundApiResult result);
 
+    /**
+     * 微信国际退款逻辑处理
+     * @param order
+     * @param result
+     */
+    void globalRefund(OrderEntity order, WechatGlobalRefundApiResult result);
+
     List<OrderRefundEntity> queryRefundList(Map<String, Object> map);
 
     int queryRefundTotal(Map<String, Object> map);
@@ -87,5 +92,5 @@ public interface OrderService {
 
     Map orderSubmit(List<OfflineCartEntity> offlineCartEntityList,SysUserEntity user);
 
-    int confirmPay(Long id, Dict.payFlag payFlag,String orderSnWx);
+    int confirmPay(Long id, String payFlag,String orderSnWx);
 }

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/service/impl/CategoryServiceImpl.java

@@ -6,7 +6,7 @@ import com.kmall.admin.dao.GoodsDao;
 import com.kmall.admin.entity.CategoryEntity;
 import com.kmall.admin.entity.GoodsEntity;
 import com.kmall.admin.service.CategoryService;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.utils.MapBeanUtil;
 import com.kmall.common.utils.R;
 import com.kmall.common.utils.RRException;

+ 1 - 3
kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java

@@ -5,14 +5,12 @@ import com.kmall.admin.dao.*;
 import com.kmall.admin.dto.GoodsDto;
 import com.kmall.admin.entity.*;
 import com.kmall.admin.service.GoodsService;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.*;
-import com.kmall.common.utils.excel.ExcelImport;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.math.BigDecimal;
 import java.util.*;

+ 0 - 2
kmall-admin/src/main/java/com/kmall/admin/service/impl/OfflineCartServiceImpl.java

@@ -1,11 +1,9 @@
 package com.kmall.admin.service.impl;
 
 import com.kmall.admin.dao.OfflineCartDao;
-import com.kmall.admin.entity.CartEntity;
 import com.kmall.admin.entity.GoodsEntity;
 import com.kmall.admin.entity.OfflineCartEntity;
 import com.kmall.admin.service.OfflineCartService;
-import com.kmall.api.contants.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.ShiroUtils;
 import org.springframework.beans.factory.annotation.Autowired;

+ 74 - 35
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -1,17 +1,13 @@
 package com.kmall.admin.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.kmall.admin.dao.*;
 import com.kmall.admin.entity.*;
 import com.kmall.admin.entity.OrderProcessRecordEntity;
 import com.kmall.admin.service.OrderService;
-import com.kmall.api.contants.Dict;
-import com.kmall.api.dto.IdCardMsgVo;
-import com.kmall.api.entity.*;
+import com.kmall.common.constant.Dict;
 import com.kmall.api.service.merch.OmsMerchPropertiesBuilder;
 import com.kmall.api.util.CommonUtil;
-import com.kmall.api.util.IdCardUtil;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.service.print.ticket.PrintTicketPropertiesBuilder;
 import com.kmall.common.utils.Constant;
@@ -22,6 +18,7 @@ import com.kmall.common.utils.RRException;
 import com.kmall.common.utils.StringUtils;
 import com.kmall.common.utils.express.kdn.KdniaoUtil;
 import com.kmall.common.utils.wechat.WechatRefundApiResult;
+import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalRefundApiResult;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -114,27 +111,7 @@ public class OrderServiceImpl
             return;
         }
         // 更新库存
-        Map<String, Object> map = new HashMap<String, Object>();
-        map.put("orderId", order.getId());
-        List<OrderGoodsEntity> orderGoodsVoList = orderGoodsDao.queryList(map);
-        for (OrderGoodsEntity orderGoodsEntity : orderGoodsVoList) {
-            ProductStoreRelaEntity storeRelaEntity = productStoreRelaDao
-                    .queryByStoreIdProductId(Long.valueOf(order.getStoreId()),
-                                             Long.valueOf(orderGoodsEntity.getProductId()));
-            if (null == storeRelaEntity || null == storeRelaEntity.getSellVolume()) {
-                storeRelaEntity.setSellVolume(0);
-            }
-            BigDecimal sellVolume = new BigDecimal(storeRelaEntity.getSellVolume() - orderGoodsEntity.getNumber());//销售量
-            if (sellVolume.compareTo(Constant.ZERO) < 0) {
-                sellVolume = Constant.ZERO;
-            }
-            storeRelaEntity.setSellVolume(Integer.parseInt(sellVolume.toString()));
-            if (null == storeRelaEntity.getStockNum()) {
-                storeRelaEntity.setStockNum(0);
-            }
-            storeRelaEntity.setStockNum(storeRelaEntity.getStockNum() + orderGoodsEntity.getNumber());//库存数量
-            productStoreRelaDao.update(storeRelaEntity);
-        }
+        updateStock(order);
     }
 
     @Override
@@ -275,14 +252,11 @@ public class OrderServiceImpl
         if (order.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_201.getItem())) {
             order.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
         }
-
         if (Dict.payFlag.item_cash.getItem().equals(order.getPayFlag())) {
             order.setPayStatus(Integer.parseInt(Dict.payStatus.item_4.getItem()));
         }else{
             order.setPayStatus(Integer.parseInt(Dict.payStatus.item_3.getItem()));
-
             OrderRefundEntity mallOrderRefund = orderRefundDao.queryObjectByOrderId(order.getId());
-
             OrderRefundEntity orderRefund = new OrderRefundEntity();
             orderRefund.setRefundId(result.getRefund_id());
             orderRefund.setOutRefundNo(result.getOut_refund_no());
@@ -302,9 +276,65 @@ public class OrderServiceImpl
                 orderRefundDao.save(orderRefund);//退款记录
             }
         }
-
         orderDao.update(order);//修改为退款中
+        // 判断是否有优惠券
+        UserCouponEntity couponVo = userCouponDao.queryByOrderId(order.getId());
+        if (null != couponVo) {
+            userCouponDao.cancelOrder(couponVo);
+        }
 
+        if (!needUpdateStock) {
+            return;
+        }
+        // 更新库存
+        updateStock(order);
+    }
+
+
+    /**
+     * 微信国际退款逻辑处理
+     * @param order
+     * @param result
+     */
+    @Transactional
+    public void globalRefund(OrderEntity order, WechatGlobalRefundApiResult result) {
+        boolean needUpdateStock = true;
+        if (order.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_201.getItem())) {
+            order.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
+        }
+        order.setPayStatus(Integer.parseInt(Dict.payStatus.item_3.getItem()));
+        OrderRefundEntity orderRefund = new OrderRefundEntity();
+        orderRefund.setRefundId(result.getRefund_id());
+        orderRefund.setOutRefundNo(result.getOut_refund_no());
+        orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_5.getItem()));//退款处理中
+        orderRefund.setModTime(new Date());
+        orderRefund.setRefundMoney(BigDecimal.valueOf(Long.valueOf(result.getRefund_fee())).divide(Constant.ONE_HUNDRED));
+        orderRefund.setRefundFeeType(result.getRefund_fee_type());
+        if(org.apache.commons.lang3.StringUtils.isNotEmpty(result.getTotal_fee())) {
+            orderRefund.setTotalFee(Integer.parseInt(BigDecimal.valueOf(Long.valueOf(result.getTotal_fee())).divide(Constant.ONE_HUNDRED).toString()));
+        }
+        orderRefund.setFeeType(result.getFee_type());
+        if(org.apache.commons.lang3.StringUtils.isNotEmpty(result.getCash_fee())) {
+            orderRefund.setCashFee(Integer.parseInt(BigDecimal.valueOf(Long.valueOf(result.getCash_fee())).divide(Constant.ONE_HUNDRED).toString()));
+        }
+        orderRefund.setCashFeeType(result.getCash_fee_type());
+        if(org.apache.commons.lang3.StringUtils.isNotEmpty(result.getCash_refund_fee())) {
+            orderRefund.setCashRefundFee(Integer.parseInt(BigDecimal.valueOf(Long.valueOf(result.getCash_refund_fee())).divide(Constant.ONE_HUNDRED).toString()));
+        }
+        orderRefund.setCashRefundFeeType(result.getCash_refund_fee_type());
+
+        OrderRefundEntity mallOrderRefund = orderRefundDao.queryObjectByOrderId(order.getId());
+        if (mallOrderRefund != null) {
+            orderRefund.setRefundType(mallOrderRefund.getRefundType());
+            orderRefund.setId(mallOrderRefund.getId());
+            orderRefundDao.update(orderRefund);
+        } else {//退款记录不存在
+            orderRefund.setOrderId(Integer.parseInt(order.getId() + ""));
+            orderRefund.setUserId(Integer.parseInt(order.getUserId() + ""));
+            orderRefund.setCreateTime(new Date());
+            orderRefundDao.save(orderRefund);//退款记录
+        }
+        orderDao.update(order);//修改为退款中
         // 判断是否有优惠券
         UserCouponEntity couponVo = userCouponDao.queryByOrderId(order.getId());
         if (null != couponVo) {
@@ -315,13 +345,17 @@ public class OrderServiceImpl
             return;
         }
         // 更新库存
+        updateStock(order);
+    }
+
+    private void updateStock(OrderEntity order){
         Map<String, Object> map = new HashMap<String, Object>();
         map.put("orderId", order.getId());
         List<OrderGoodsEntity> orderGoodsVoList = orderGoodsDao.queryList(map);
         for (OrderGoodsEntity orderGoodsEntity : orderGoodsVoList) {
             ProductStoreRelaEntity storeRelaEntity = productStoreRelaDao
                     .queryByStoreIdProductId(Long.valueOf(order.getStoreId()),
-                                             Long.valueOf(orderGoodsEntity.getProductId()));
+                            Long.valueOf(orderGoodsEntity.getProductId()));
             if (null == storeRelaEntity || null == storeRelaEntity.getSellVolume()) {
                 storeRelaEntity.setSellVolume(0);
             }
@@ -337,7 +371,6 @@ public class OrderServiceImpl
             productStoreRelaDao.update(storeRelaEntity);
         }
     }
-
     /**
      * 处理用户退款申请
      *
@@ -515,6 +548,12 @@ public class OrderServiceImpl
         return orderEntity;
     }
 
+    /**
+     * 普货商品生成线下订单
+     * @param offlineCartList
+     * @param user
+     * @return
+     */
     @Transactional
     @Override
     public Map orderSubmit(List<OfflineCartEntity> offlineCartList, SysUserEntity user) {
@@ -670,7 +709,7 @@ public class OrderServiceImpl
         orderInfo.setIntegralMoney(Constant.ZERO);
         orderInfo.setCreateTime(new Date());
         orderInfo.setModTime(new Date());
-        orderInfo.setIsOnfflineOrder(Dict.isOnfflineOrder.item_1.getItem());
+        orderInfo.setIsOnfflineOrder(Dict.isOnfflineOrder.item_1.getItem());//线下购买
         /*//标记该订单已使用优惠券
         if(couponVo != null){
             couponVo.setUsed_time(new Date());
@@ -713,7 +752,7 @@ public class OrderServiceImpl
     }
 
     @Override
-    public int confirmPay(Long id, Dict.payFlag payFlag,String orderSnWx) {
+    public int confirmPay(Long id, String payFlag,String orderSnWx) {
         SysUserEntity user = ShiroUtils.getUserEntity();
         if (user == null) {
             throw new RRException("用户登录超时,请重新登录");
@@ -736,7 +775,7 @@ public class OrderServiceImpl
         }
         orderEntity.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
         orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
-        orderEntity.setPayFlag(payFlag.getItem());
+        orderEntity.setPayFlag(payFlag);
         orderEntity.setPayTime(new Date());
         if(orderSnWx != null){
             orderEntity.setOrderSnWx(orderSnWx);

+ 12 - 1
kmall-admin/src/main/java/com/kmall/admin/service/impl/ProductStoreRelaServiceImpl.java

@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableBiMap;
 import com.kmall.admin.dao.*;
 import com.kmall.admin.entity.*;
 import com.kmall.admin.service.ProductStoreRelaService;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.*;
 import org.apache.commons.lang.StringUtils;
@@ -103,6 +103,12 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
         SysUserEntity user = ShiroUtils.getUserEntity();
         ProductEntity product = productDao.queryObjectBySn(goodsEntity.getGoodsSn());
         if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
+            GoodsEntity goods = new GoodsEntity();
+            goods.setRetailPrice(productStoreRela.getRetailPrice());
+            goods.setMarketPrice(productStoreRela.getMarketPrice());
+            goods.setId(goodsEntity.getId());
+            goodsDao.update(goods);
+
             GoodsSpecificationEntity goodsSpecificationEntity = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
             if(goodsSpecificationEntity != null){
                 goodsSpecificationDao.delete(goodsSpecificationEntity.getId());
@@ -175,6 +181,11 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
 
         SysUserEntity user = ShiroUtils.getUserEntity();
         if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
+            GoodsEntity goods = new GoodsEntity();
+            goods.setRetailPrice(productStoreRela.getRetailPrice());
+            goods.setMarketPrice(productStoreRela.getMarketPrice());
+            goods.setId(goodsEntity.getId());
+            goodsDao.update(goods);
             // 添加商品规格
             GoodsSpecificationEntity goodsSpecification = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
             goodsSpecification.setValue(productStoreRela.getSpecification());

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/utils/ParamUtils.java

@@ -1,6 +1,6 @@
 package com.kmall.admin.utils;
 
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.RRException;
 import com.kmall.common.utils.ShiroUtils;

+ 86 - 0
kmall-admin/src/main/resources/conf/wx-global.properties

@@ -0,0 +1,86 @@
+########## 微信小程序配置 ##########
+
+# [dev, prod]
+pay.wx.global.env = dev
+
+
+#========== 开发环境 ==========
+#小程序ID
+wx.global.dev.appId=wxb6b30b1b14ee502a
+#小程序密钥
+wx.global.dev.secret=be0234dbbbde4ce68df43dd2b5e4c7b1
+#商户号
+wx.global.dev.mchId=
+#支付签名
+wx.global.dev.paySignKey=
+#交易类型
+wx.global.dev.tradeType=JSAPI
+#商户币种
+wx.global.dev.feeType=CNY
+#证书名称,对应不同的商户号
+wx.global.dev.certName=/cert/apiclient_cert.p12
+#支付回调地址
+wx.global.dev.notifyUrl=http://qhdswl.f3322.net:9001/platform-framework/api/global/pay/notify
+#获取code的请求地址
+wx.global.dev.getCode=https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=STAT#wechat_redirect
+#获取Web_access_tokenhttps的请求地址
+wx.global.dev.webAccessTokenhttps = https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code
+#拉取用户信息的请求地址
+wx.global.dev.userMessage=https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN
+#微信统一下单接口路径
+wx.global.dev.uniformorder=https://api.mch.weixin.qq.com/pay/unifiedorder
+#退款地址
+wx.global.dev.refundUrl=https://api.mch.weixin.qq.com/secapi/pay/refund
+#退款回调地址
+wx.global.dev.refundNotifyUrl=http://qhdswl.f3322.net:9001/platform-framework/api/global/pay/refundNotify
+#退款查询地址
+wx.global.dev.refundqueryUrl=https://api.mch.weixin.qq.com/pay/refundquery
+#微信查询订单状态
+wx.global.dev.orderquery=https://api.mch.weixin.qq.com/pay/orderquery
+#查询汇率
+wx.global.dev.ratequery=https://api.mch.weixin.qq.com/pay/queryexchagerate
+#服务器Ip
+wx.global.dev.spbillCreateIp=127.0.0.1
+
+
+
+#========== 生产环境 ==========
+
+#小程序ID
+wx.global.prod.appId=wxb6b30b1b14ee502a
+#小程序密钥
+wx.global.prod.secret=be0234dbbbde4ce68df43dd2b5e4c7b1
+#商户号
+wx.global.prod.mchId=
+#支付签名
+wx.global.prod.paySignKey=
+#交易类型
+wx.global.prod.tradeType=JSAPI
+#商户币种
+wx.global.prod.feeType=CNY
+#证书名称,对应不同的商户号
+wx.global.prod.certName=/cert/apiclient_cert.p12
+#支付回调地址
+wx.global.prod.notifyUrl=https://mp.k1net.cn/api/global/pay/notify
+#获取code的请求地址
+wx.global.prod.getCode=https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=STAT#wechat_redirect
+#获取Web_access_tokenhttps的请求地址
+wx.global.prod.webAccessTokenhttps = https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code
+#拉取用户信息的请求地址
+wx.global.prod.userMessage=https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN
+#微信统一下单接口路径
+wx.global.prod.uniformorder=https://api.mch.weixin.qq.com/pay/unifiedorder
+#退款地址
+wx.global.prod.refundUrl=https://api.mch.weixin.qq.com/secapi/pay/refund
+#退款回调地址
+wx.global.prod.refundNotifyUrl=https://mp.k1net.cn/api/global/pay/refundNotify
+#退款查询地址
+wx.global.prod.refundqueryUrl=https://api.mch.weixin.qq.com/pay/refundquery
+#微信查询订单状态
+wx.global.prod.orderquery=https://api.mch.weixin.qq.com/pay/orderquery
+#查询汇率
+wx.global.prod.ratequery=https://api.mch.weixin.qq.com/pay/queryexchagerate
+#服务器Ip
+wx.global.prod.spbillCreateIp=127.0.0.1
+
+

+ 41 - 0
kmall-admin/src/main/resources/mybatis/mapper/OrderRefundDao.xml

@@ -29,6 +29,15 @@
         <result property="orderStatus" column="order_status"/>
         <result property="actualPrice" column="actual_price"/>
         <result property="userName" column="username"/>
+
+        <result property="refundFeeType" column="refund_fee_type"/>
+        <result property="totalFee" column="total_fee"/>
+        <result property="feeType" column="fee_type"/>
+        <result property="cashFee" column="cash_fee"/>
+        <result property="cashFeeType" column="cash_fee_type"/>
+        <result property="cashRefundFee" column="cash_refund_fee"/>
+        <result property="cashRefundFeeType" column="cash_refund_fee_type"/>
+        <result property="rate" column="rate"/>
     </resultMap>
 
     <select id="queryObject" resultType="com.kmall.admin.entity.OrderRefundEntity">
@@ -42,6 +51,14 @@
         r.refund_time,
         r.creator,
         r.refund_money,
+		r.refund_fee_type,
+		r.total_fee,
+		r.fee_type,
+		r.cash_fee,
+		r.cash_fee_type,
+		r.cash_refund_fee,
+		r.cash_refund_fee_type,
+		r.rate,
         r.refund_status,
         r.refund_reason,
         r.wechat_refund_status_des,
@@ -173,6 +190,14 @@
 			`refund_time`,
 			`creator`,
 			`refund_money`,
+			`refund_fee_type`,
+			`total_fee`,
+			`fee_type`,
+			`cash_fee`,
+			`cash_fee_type`,
+			`cash_refund_fee`,
+			`cash_refund_fee_type`,
+			`rate`,
 			`refund_status`,
 			`wechat_refund_status_des`,
 			`approver`,
@@ -186,6 +211,14 @@
 			#{refundTime},
 			#{creator},
 			#{refundMoney},
+			#{refundFeeType},
+			#{totalFee},
+			#{feeType},
+			#{cashFee},
+			#{cashFeeType},
+			#{cashRefundFee},
+			#{cashRefundFeeType},
+			#{rate},
 			#{refundStatus},
 			#{wechatRefundStatusDes},
 			#{approver},
@@ -203,6 +236,14 @@
             <if test="refundTime != null">`refund_time` = #{refundTime},</if>
             <if test="creator != null">`creator` = #{creator},</if>
             <if test="refundMoney != null">`refund_money` = #{refundMoney},</if>
+            <if test="refundFeeType != null">`refund_fee_type` = #{refundFeeType}, </if>
+            <if test="totalFee != null">`total_fee` = #{totalFee}, </if>
+            <if test="feeType != null">`fee_type` = #{feeType}, </if>
+            <if test="cashFee != null">`cash_fee` = #{cashFee}, </if>
+            <if test="cashFeeType != null">`cash_fee_type` = #{cashFeeType}, </if>
+            <if test="cashRefundFee != null">`cash_refund_fee` = #{cashRefundFee}, </if>
+            <if test="cashRefundFeeType != null">`cash_refund_fee_type` = #{cashRefundFeeType}, </if>
+            <if test="rate != null">`rate` = #{rate}, </if>
             <if test="refundStatus != null">`refund_status` = #{refundStatus},</if>
             <if test="wechatRefundStatusDes != null">`wechat_refund_status_des` = #{wechatRefundStatusDes},</if>
             <if test="approver != null">`approver` = #{approver},</if>

+ 1 - 0
kmall-admin/src/main/resources/spring/spring-context.xml

@@ -27,6 +27,7 @@
                 <value>classpath:conf/redis.properties</value>
                 <value>classpath:conf/servlet.properties</value>
                 <value>classpath:conf/wx-mp.properties</value>
+                <value>classpath:conf/wx-global.properties</value>
                 <value>classpath:conf/pingan-pay.properties</value>
                 <value>classpath:conf/oms-merch.properties</value>
                 <value>classpath:conf/print-ticket.properties</value>

+ 1 - 0
kmall-admin/src/main/resources/spring/spring-main.xml

@@ -18,6 +18,7 @@
     <import resource="spring-redis.xml"/>
     <import resource="spring-express-kdn.xml"/>
     <import resource="spring-wx-pay.xml"/>
+    <import resource="spring-wx-global-pay.xml"/>
     <import resource="spring-pingan-pay.xml"/>
     <import resource="spring-jdbc.xml"/>
     <import resource="spring-oms-merch.xml"/>

+ 62 - 0
kmall-admin/src/main/resources/spring/spring-wx-global-pay.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xmlns:mvc="http://www.springframework.org/schema/mvc"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans 
+        http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
+        http://www.springframework.org/schema/context
+        http://www.springframework.org/schema/context/spring-context-4.2.xsd
+     	http://www.springframework.org/schema/aop
+     	http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
+		http://www.springframework.org/schema/mvc
+     	http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
+
+    <bean id="commonWxGlobalPayProdProperties" class="com.kmall.common.service.pay.global.CommonWxGlobalPayProdProperties">
+        <property name="appId" value="${wx.global.prod.appId}"/>
+        <property name="secret" value="${wx.global.prod.secret}"/>
+        <property name="mchId" value="${wx.global.prod.mchId}"/>
+        <property name="paySignKey" value="${wx.global.prod.paySignKey}"/>
+
+        <property name="tradeType" value="${wx.global.prod.tradeType}"/>
+        <property name="feeType" value="${wx.global.prod.feeType}"/>
+        <property name="certName" value="${wx.global.prod.certName}"/>
+        <property name="notifyUrl" value="${wx.global.prod.notifyUrl}"/>
+        <property name="getCode" value="${wx.global.prod.getCode}"/>
+
+        <property name="webAccessTokenhttps" value="${wx.global.prod.webAccessTokenhttps}"/>
+        <property name="userMessage" value="${wx.global.prod.userMessage}"/>
+        <property name="uniformorder" value="${wx.global.prod.uniformorder}"/>
+        <property name="refundUrl" value="${wx.global.prod.refundUrl}"/>
+        <property name="refundqueryUrl" value="${wx.global.prod.refundqueryUrl}"/>
+        <property name="orderquery" value="${wx.global.prod.orderquery}"/>
+        <property name="ratequery" value="${wx.global.prod.ratequery}"/>
+        <property name="spbillCreateIp" value="${wx.global.prod.spbillCreateIp}"/>
+        <property name="refundNotifyUrl" value="${wx.global.prod.refundNotifyUrl}"/>
+    </bean>
+
+    <bean id="commonWxGlobalPayDevProperties" class="com.kmall.common.service.pay.global.CommonWxGlobalPayDevProperties">
+        <property name="appId" value="${wx.global.dev.appId}"/>
+        <property name="secret" value="${wx.global.dev.secret}"/>
+        <property name="mchId" value="${wx.global.dev.mchId}"/>
+        <property name="paySignKey" value="${wx.global.dev.paySignKey}"/>
+
+        <property name="tradeType" value="${wx.global.dev.tradeType}"/>
+        <property name="feeType" value="${wx.global.dev.feeType}"/>
+        <property name="certName" value="${wx.global.dev.certName}"/>
+        <property name="notifyUrl" value="${wx.global.dev.notifyUrl}"/>
+        <property name="getCode" value="${wx.global.dev.getCode}"/>
+
+        <property name="webAccessTokenhttps" value="${wx.global.dev.webAccessTokenhttps}"/>
+        <property name="userMessage" value="${wx.global.dev.userMessage}"/>
+        <property name="uniformorder" value="${wx.global.dev.uniformorder}"/>
+        <property name="refundUrl" value="${wx.global.dev.refundUrl}"/>
+        <property name="refundqueryUrl" value="${wx.global.dev.refundqueryUrl}"/>
+        <property name="orderquery" value="${wx.global.dev.orderquery}"/>
+        <property name="ratequery" value="${wx.global.dev.ratequery}"/>
+        <property name="spbillCreateIp" value="${wx.global.dev.spbillCreateIp}"/>
+        <property name="refundNotifyUrl" value="${wx.global.dev.refundNotifyUrl}"/>
+    </bean>
+</beans>

+ 1 - 0
kmall-admin/src/main/webapp/WEB-INF/web.xml

@@ -12,6 +12,7 @@
             classpath:spring/spring-express-kdn.xml,
             classpath:spring/spring-redis.xml,
             classpath:spring/spring-wx-pay.xml,
+            classpath:spring/spring-wx-global-pay.xml,
             classpath:spring/spring-pingan-pay.xml,
             classpath:spring/spring-jdbc.xml,,
             classpath:spring/spring-oms-merch.xml,

+ 1 - 1
kmall-api/src/main/java/com/kmall/api/api/ApiCartController.java

@@ -2,7 +2,7 @@ package com.kmall.api.api;
 
 import com.alibaba.fastjson.JSONObject;
 import com.kmall.api.annotation.LoginUser;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.api.entity.*;
 import com.kmall.api.service.*;
 import com.kmall.api.util.ApiBaseAction;

+ 2 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiGoodsController.java

@@ -556,6 +556,8 @@ public class ApiGoodsController extends ApiBaseAction {
     public Object count(@LoginUser UserVo loginUser) {
         Map<String, Object> resultObj = new HashMap();
         Map param = new HashMap();
+        param.put("storeId", getStoreId());
+        param.put("searchGoodsCount", '1');
         param.put("is_delete", 0);
         param.put("is_on_sale", 1);
         Integer goodsCount = goodsService.queryTotal(param);

+ 1 - 1
kmall-api/src/main/java/com/kmall/api/api/ApiGoodsGroupController.java

@@ -2,7 +2,7 @@ package com.kmall.api.api;
 
 import com.kmall.api.annotation.IgnoreAuth;
 import com.kmall.api.annotation.LoginUser;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.api.entity.*;
 import com.kmall.api.service.*;
 import com.kmall.api.util.ApiBaseAction;

+ 7 - 7
kmall-api/src/main/java/com/kmall/api/api/ApiOrderController.java

@@ -2,11 +2,9 @@ package com.kmall.api.api;
 
 import com.alibaba.druid.util.StringUtils;
 import com.alibaba.fastjson.JSONObject;
-import com.google.common.collect.Maps;
 import com.kmall.api.annotation.IgnoreAuth;
 import com.kmall.api.annotation.LoginUser;
-import com.kmall.api.contants.Dict;
-import com.kmall.api.dao.ApiOrderRefundMapper;
+import com.kmall.common.constant.Dict;
 import com.kmall.api.entity.*;
 import com.kmall.api.service.*;
 import com.kmall.api.service.express.kdn.ApiKdniaoService;
@@ -14,11 +12,9 @@ import com.kmall.api.util.ApiBaseAction;
 import com.kmall.api.util.ApiPageUtils;
 import com.kmall.common.service.print.ticket.PrintTicketPropertiesBuilder;
 import com.kmall.common.utils.Constant;
-import com.kmall.common.utils.DateUtils;
 import com.kmall.common.utils.Query;
 import com.kmall.common.utils.wechat.WechatRefundApiResult;
 import com.kmall.common.utils.wechat.WechatUtil;
-import io.swagger.models.auth.In;
 import org.apache.commons.collections.MapUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -81,7 +77,11 @@ public class ApiOrderController extends ApiBaseAction {
         params.put("sidx", "add_time");
         params.put("order", "desc");
         params.put("size", "desc");
-
+        if(order_status != null) {
+            if (order_status == Integer.parseInt(Dict.orderStatus.item_401.getItem())) {
+                params.put("pay_status", Dict.payStatus.item_4.getItem());
+            }
+        }
         //查询列表数据
         Query query = new Query(params);
         List<OrderVo> orderEntityList = orderService.queryList(query);
@@ -269,7 +269,7 @@ public class ApiOrderController extends ApiBaseAction {
             if (orderVo.getPay_status() == 2) {
                 WechatRefundApiResult result = WechatUtil.wxRefund(orderVo.getMerchOrderSn().toString(),
                         orderVo.getActual_price().doubleValue(), orderVo.getActual_price().doubleValue());
-                if (result.getResult_code().equals("SUCCESS")) {
+                if (result.getResult_code().equals(WechatUtil.WXTradeState.SUCCESS.getCode())) {
                     if (orderVo.getOrder_status() == 201) {
                         orderVo.setOrder_status(401);
                     } else if (orderVo.getOrder_status() == 300) {

+ 4 - 9
kmall-api/src/main/java/com/kmall/api/api/ApiPayController.java

@@ -2,7 +2,7 @@ package com.kmall.api.api;
 
 import com.kmall.api.annotation.IgnoreAuth;
 import com.kmall.api.annotation.LoginUser;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.api.dao.ApiOrderRefundMapper;
 import com.kmall.api.entity.*;
 import com.kmall.api.service.*;
@@ -17,7 +17,6 @@ import com.kmall.common.utils.wechat.AESUtil;
 import com.kmall.common.utils.wechat.WechatRefundApiResult;
 import com.kmall.common.utils.wechat.WechatRefundNotifyResult;
 import com.kmall.common.utils.wechat.WechatUtil;
-import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -27,7 +26,6 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -53,8 +51,6 @@ public class ApiPayController extends ApiBaseAction {
     @Autowired
     private ApiOrderRefundMapper mallOrderRefundMapper;
 
-
-
     /**
      */
     @RequestMapping("index")
@@ -163,7 +159,7 @@ public class ApiPayController extends ApiBaseAction {
                 updateFailProcessBatch(processRecordEntityList, "支付失败," +return_msg);//更新订单流转信息
                 addOrderExceptionRecord(orderVoList, Dict.exceptionStatus.item_00.getItem(),"支付失败," +return_msg);//记录订单异常信息
                 return toResponsFail("支付失败," + return_msg);
-            } else if (return_code.equalsIgnoreCase("SUCCESS")) {
+            } else if (return_code.equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
                 // 返回数据
                 String result_code = MapUtils.getString("result_code", resultUn);
                 String err_code_des = MapUtils.getString("err_code_des", resultUn);
@@ -171,7 +167,7 @@ public class ApiPayController extends ApiBaseAction {
                     updateFailProcessBatch(processRecordEntityList, "支付失败," +err_code_des);//更新订单流转信息
                     addOrderExceptionRecord(orderVoList, Dict.exceptionStatus.item_00.getItem(),"支付失败," +err_code_des);//记录订单异常信息
                     return toResponsFail("支付失败," + err_code_des);
-                } else if (result_code.equalsIgnoreCase("SUCCESS")) {
+                } else if (result_code.equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
                     apiPayService.payPrepay(resultObj, resultUn, nonceStr, orderVoList);
                     orderProcessRecordService.updateBatch(processRecordEntityList);//更新订单流转信息
                     return toResponsObject(0, "微信统一订单下单成功", resultObj);
@@ -249,9 +245,8 @@ public class ApiPayController extends ApiBaseAction {
                 logger.error("订单" + out_trade_no + "支付失败");
                 response.getWriter().write(setXml("SUCCESS", "OK"));
                 response.getWriter().close();
-            } else if (result_code.equalsIgnoreCase("SUCCESS")) {
+            } else if (result_code.equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
                 //验签
-                String sign = result.getSign();
                 String time_end = result.getTime_end();
                 String out_trade_no = result.getOut_trade_no();//商户订单号
                 String transaction_id = result.getTransaction_id();//微信支付订单号

+ 281 - 0
kmall-api/src/main/java/com/kmall/api/api/wxGlobal/ApiWxGlobalPayController.java

@@ -0,0 +1,281 @@
+package com.kmall.api.api.wxGlobal;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.common.constant.Dict;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.service.wxGlobal.ApiWxGlobalPayService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.CommonUtil;
+import com.kmall.common.utils.CharUtil;
+import com.kmall.common.utils.Constant;
+import com.kmall.common.utils.XmlUtil;
+import com.kmall.common.utils.wechat.AESUtil;
+import com.kmall.common.utils.wechat.WechatRefundApiResult;
+import com.kmall.common.utils.wechat.WechatRefundNotifyResult;
+import com.kmall.common.utils.wechat.WechatUtil;
+import com.kmall.common.utils.wechat.wxglobal.WechatGlobalUtil;
+import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalNotifyResult;
+import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalQueryApiResult;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.*;
+
+
+/**
+ * 微信境外支付
+ *
+ * @author huangyq
+ * @email
+ * @date 2018-12-11 17:01
+ */
+@RestController
+@RequestMapping("/api/global/pay")
+public class ApiWxGlobalPayController extends ApiBaseAction {
+    private Logger logger = Logger.getLogger(ApiWxGlobalPayController.class);
+    @Autowired
+    private ApiOrderService orderService;
+    @Autowired
+    private ApiOrderGoodsService orderGoodsService;
+    @Autowired
+    private ApiWxGlobalPayService apiWxGlobalPayService;
+    @Autowired
+    private ApiOrderProcessRecordService orderProcessRecordService;
+    @Autowired
+    private ApiOrderExceptionRecordService apiOrderExceptionRecordService;
+
+    /**
+     * 发起支付
+     * @param loginUser
+     * @param orderIds
+     * @param isMergePay
+     * @return
+     */
+    @GetMapping("pay_prepay")
+    public Object payPrepay(@LoginUser UserVo loginUser, Long[] orderIds,String isMergePay) {
+        logger.info("微信支付接口>>>>>>payPrepay start");
+        List<Long> orderIdList=new ArrayList<>();
+        String merchOrderSn = "";
+        for(int i=0;i<orderIds.length;i++){
+            orderIdList.add(orderIds[i]);
+        }
+        BigDecimal actual_price = Constant.ZERO;
+        List<OrderVo> orderVoList = orderService.queryObjectByIdList(orderIdList);
+        List<OrderProcessRecordEntity> processRecordEntityList = new ArrayList<>();
+
+        for (OrderVo orderInfo:orderVoList) {
+            if (orderInfo.getOrder_status() == 101) {
+                return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单超时支付,已取消", "");
+            }
+            if (orderInfo.getPay_status() != 0 && orderInfo.getPay_status() != 1) {
+                return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单已支付,请不要重复操作", "");
+            }
+            OrderProcessRecordEntity processRecordEntity = orderProcessRecordService.queryObjectByOrderSn(orderInfo.getOrder_sn());
+            if(processRecordEntity != null){
+                OrderProcessRecordEntity entity = new OrderProcessRecordEntity();
+                entity.setOrderSn(orderInfo.getOrder_sn());
+                entity.setUserId(Integer.valueOf(loginUser.getId()+""));
+                entity.setId(processRecordEntity.getId());
+                entity.setPayStartTime(new Date());
+                processRecordEntityList.add(entity);
+            }
+            merchOrderSn = orderInfo.getMerchOrderSn();
+            //如此次是单笔支付,则判断下单时该商户订单是否是拆单订单,如果都满足,则更新商户订单号,生成新的预支付信息
+            if(Dict.isMergePay.item_0.getItem().equalsIgnoreCase(isMergePay)) {
+                if ("2".equalsIgnoreCase(orderInfo.getIsMergePay())) {//多笔订单单笔支付,则商户订单号,生成新的预支付信息
+                    merchOrderSn = "EMATO"+ CommonUtil.generateOrderNumber();
+                    orderInfo.setMerchOrderSn(merchOrderSn);
+                }
+            }
+            actual_price = actual_price.add(orderInfo.getActual_price());
+        }
+        String nonceStr = CharUtil.getRandomString(32);
+        Map<Object, Object> resultObj = new HashMap();
+
+        try {
+            //订单的商品
+            List<OrderGoodsVo> orderGoods = orderGoodsService.queryListByIds(orderIdList);
+            String body = "";
+            if (null != orderGoods) {
+                body = "商城-";
+                for (OrderGoodsVo goodsVo : orderGoods) {
+                    body = body + goodsVo.getGoods_name() + "、";
+                }
+                if (body.length() > 0) {
+                    body = body.substring(0, body.length() - 1);
+                }
+            }
+            //统一下单
+            WechatGlobalQueryApiResult queryApiResult = WechatGlobalUtil.unifiedOrder(merchOrderSn, body, actual_price, loginUser.getWeixin_openid());
+            // 响应报文
+            String return_code = queryApiResult.getReturn_code();
+            String return_msg = queryApiResult.getReturn_msg();
+            //
+            if (return_code.equalsIgnoreCase("FAIL")) {
+                updateFailProcessBatch(processRecordEntityList, "支付失败 ," +return_msg);//更新订单流转信息
+                addOrderExceptionRecord(orderVoList, Dict.exceptionStatus.item_00.getItem(),"支付失败 ," +return_msg);//记录订单异常信息
+                return toResponsFail("支付失败 ," + return_msg);
+            } else if (return_code.equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                // 返回数据
+                String result_code = queryApiResult.getResult_code();
+                String err_code_des = queryApiResult.getErr_code_des();
+                if (result_code.equalsIgnoreCase("FAIL")) {
+                    updateFailProcessBatch(processRecordEntityList, "支付失败 ," +err_code_des);//更新订单流转信息
+                    addOrderExceptionRecord(orderVoList, Dict.exceptionStatus.item_00.getItem(),"支付失败 ," +err_code_des);//记录订单异常信息
+                    return toResponsFail("支付失败 ," + err_code_des);
+                } else if (result_code.equalsIgnoreCase(WechatGlobalUtil.WXTradeState.SUCCESS.getCode())) {
+                    apiWxGlobalPayService.payPrepay(resultObj, queryApiResult, nonceStr, orderVoList);
+                    orderProcessRecordService.updateBatch(processRecordEntityList);//更新订单流转信息
+                    return toResponsObject(0, "微信统一订单下单成功", resultObj);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            updateFailProcessBatch(processRecordEntityList, "下单失败,error=" + e.getMessage());//更新订单流转信息
+            return toResponsFail("下单失败,error=" + e.getMessage());
+        }
+        return toResponsFail("下单失败");
+    }
+
+    /**
+     * 更新订单支付失败流转信息
+     * @param processRecordEntityList
+     * @param return_msg
+     */
+    public void updateFailProcessBatch(List<OrderProcessRecordEntity> processRecordEntityList,String return_msg){
+        for (OrderProcessRecordEntity orderProcessRecordEntity : processRecordEntityList) {
+            orderProcessRecordEntity.setIsPaymentSend(Dict.isSend.item_0.getItem());
+            orderProcessRecordEntity.setProcessContent(return_msg);
+        }
+        orderProcessRecordService.updateBatch(processRecordEntityList);
+    }
+
+    /**
+     * 记录订单异常信息
+     * @param orderVoList
+     * @param exceptionStatus
+     * @param expContent
+     */
+    public void addOrderExceptionRecord(List<OrderVo> orderVoList,String exceptionStatus,String expContent){
+        for (OrderVo orderInfo: orderVoList) {
+            MallOrderExceptionRecord mallOrderExceptionRecord = new MallOrderExceptionRecord();
+            mallOrderExceptionRecord.setUserId(Integer.parseInt(orderInfo.getUser_id()+""));
+            mallOrderExceptionRecord.setOrderSn(orderInfo.getOrder_sn());
+            mallOrderExceptionRecord.setExceptionContent(expContent);
+            mallOrderExceptionRecord.setExceptionStatus(exceptionStatus);
+            mallOrderExceptionRecord.setCreateTime(new Date());
+            apiOrderExceptionRecordService.save(mallOrderExceptionRecord);
+        }
+    }
+
+    /**
+     * 微信订单回调接口
+     *
+     * @return
+     */
+    @IgnoreAuth
+    @RequestMapping(value = "/notify", produces = "text/html;charset=UTF-8")
+    @ResponseBody
+    public void notify(HttpServletRequest request, HttpServletResponse response) {
+        logger.info("微信订单回调接口>>>>>>notify start");
+        try {
+            request.setCharacterEncoding("UTF-8");
+            response.setContentType("text/html;charset=UTF-8");
+            response.setCharacterEncoding("UTF-8");
+            response.setHeader("Access-Control-Allow-Origin", "*");
+            InputStream in = request.getInputStream();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buffer = new byte[1024];
+            int len = 0;
+            while ((len = in.read(buffer)) != -1) {
+                out.write(buffer, 0, len);
+            }
+            out.close();
+            in.close();
+            String reponseXml = new String(out.toByteArray(), "utf-8");//xml数据
+            logger.error("reponseXml:" + reponseXml);
+            WechatGlobalNotifyResult result = (WechatGlobalNotifyResult) XmlUtil.xmlStrToBean(reponseXml, WechatGlobalNotifyResult.class);
+            String result_code = result.getResult_code();
+            String out_trade_no = result.getOut_trade_no();//订单编号
+            if (result_code.equalsIgnoreCase("FAIL")) {
+                logger.error("订单 " + out_trade_no + " 支付失败");
+                response.getWriter().write(setXml(WechatGlobalUtil.WXTradeState.SUCCESS.getCode(), "OK"));
+                response.getWriter().close();
+            } else if (result_code.equalsIgnoreCase(WechatGlobalUtil.WXTradeState.SUCCESS.getCode())) {
+                logger.error("订单 " + out_trade_no + " 支付成功");
+                // 业务处理
+                apiWxGlobalPayService.notify(result);
+                response.getWriter().write(setXml(WechatGlobalUtil.WXTradeState.SUCCESS.getCode(), "OK"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return;
+        }
+    }
+
+    /**
+     * 微信订单退款回调接口
+     *
+     * @return
+     */
+    @IgnoreAuth
+    @RequestMapping(value = "/refundNotify", produces = "text/html;charset=UTF-8")
+    @ResponseBody
+    public void refundNotify(HttpServletRequest request, HttpServletResponse response) {
+        logger.info("微信订单退款回调接口》》》》refundNotify start");
+        try {
+            request.setCharacterEncoding("UTF-8");
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("text/html;charset=UTF-8");
+            response.setHeader("Access-Control-Allow-Origin", "*");
+            InputStream in = request.getInputStream();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buffer = new byte[1024];
+            int len = 0;
+            while ((len = in.read(buffer)) != -1) {
+                out.write(buffer, 0, len);
+            }
+            out.close();
+            in.close();
+            String reponseXml = new String(out.toByteArray(), "utf-8");//xml数据
+            logger.error("reponseXml :" + reponseXml);
+            WechatRefundNotifyResult result = (WechatRefundNotifyResult) XmlUtil.xmlStrToBean(reponseXml, WechatRefundNotifyResult.class);
+
+            if (result.getReturn_code().equalsIgnoreCase("FAIL")) {
+                logger.info("微信查询接口调用失败 : "+result.getReturn_msg());
+                response.getWriter().write(setXml(WechatGlobalUtil.WXTradeState.SUCCESS.getCode(), "OK"));
+                response.getWriter().close();
+            }else {
+                String req_info = result.getReq_info();//加密信息
+                String aesResult = AESUtil.decryptData(req_info);
+                System.out.println(aesResult);
+                WechatRefundApiResult refundApiResult = (WechatRefundApiResult) XmlUtil.xmlStrToBean(aesResult, WechatRefundApiResult.class);
+
+                logger.error("订单 " + refundApiResult.getOut_trade_no() + "退款成功");
+                // 业务处理
+                apiWxGlobalPayService.refundNotify(refundApiResult);
+                response.getWriter().write(setXml(WechatGlobalUtil.WXTradeState.SUCCESS.getCode(), "OK"));
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return;
+        }
+    }
+
+    //返回微信服务
+    public static String setXml(String return_code, String return_msg) {
+        return "<xml><return_code><![CDATA[" + return_code + "]]></return_code><return_msg><![CDATA[" + return_msg + "]]></return_msg></xml>";
+    }
+}

+ 62 - 1
kmall-api/src/main/java/com/kmall/api/entity/OrderVo.java

@@ -29,11 +29,12 @@ public class OrderVo implements Serializable {
     2xx 表示订单支付状态 201订单已付款,等待发货
     3xx 表示订单物流相关状态 300订单已发货, 301用户确认收货
     4xx 表示订单退换货相关的状态 401 没有发货,退款 402 已收货,退款退货
+    500订单已关闭;501 支付失败
     */
     private Integer order_status;
     //发货状态 商品配送情况;0未配送,1已配送,2已收货,4退货
     private Integer shipping_status;
-    //付款状态 支付状态;0未付款;1付款中;2已付款;4退款
+    //付款状态 支付状态;0未付款;1付款中;2已付款;4退款;5:退款关闭;6:退款异常;7:订单关闭;8:支付失败;
     private Integer pay_status;
     //评价状态 1已评价 0未评价
     private Integer comment_count = 0;
@@ -71,6 +72,26 @@ public class OrderVo implements Serializable {
     private String pay_name;
     //实际需要支付的金额
     private BigDecimal actual_price;
+    /**
+     * 用户支付金额;微信国际支付返回数据
+     */
+    private Integer cashFee;
+    /**
+     * 用户支付币种;微信国际支付返回数据
+     */
+    private String cashFeeType;
+    /**
+     * 标价金额;微信国际支付返回数据
+     */
+    private Integer totalFee;
+    /**
+     * 标价币种;微信国际支付返回数据
+     */
+    private String feeType;
+    /**
+     * 汇率;微信国际支付返回数据
+     */
+    private String rate;
     // 积分
     private Integer integral;
     // 积分抵扣金额
@@ -178,6 +199,46 @@ public class OrderVo implements Serializable {
     private String merchName;
     private Long storeId;
 
+    public Integer getCashFee() {
+        return cashFee;
+    }
+
+    public void setCashFee(Integer cashFee) {
+        this.cashFee = cashFee;
+    }
+
+    public String getCashFeeType() {
+        return cashFeeType;
+    }
+
+    public void setCashFeeType(String cashFeeType) {
+        this.cashFeeType = cashFeeType;
+    }
+
+    public Integer getTotalFee() {
+        return totalFee;
+    }
+
+    public void setTotalFee(Integer totalFee) {
+        this.totalFee = totalFee;
+    }
+
+    public String getFeeType() {
+        return feeType;
+    }
+
+    public void setFeeType(String feeType) {
+        this.feeType = feeType;
+    }
+
+    public String getRate() {
+        return rate;
+    }
+
+    public void setRate(String rate) {
+        this.rate = rate;
+    }
+
     public String getMerchName() {
         return merchName;
     }

+ 1 - 1
kmall-api/src/main/java/com/kmall/api/service/ApiCouponService.java

@@ -1,6 +1,6 @@
 package com.kmall.api.service;
 
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.api.dao.ApiCouponMapper;
 import com.kmall.api.dao.ApiUserCouponMapper;
 import com.kmall.api.entity.CouponVo;

+ 1 - 3
kmall-api/src/main/java/com/kmall/api/service/ApiOrderService.java

@@ -2,7 +2,7 @@ package com.kmall.api.service;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.api.dao.*;
 import com.kmall.api.dto.IdCardMsgVo;
 import com.kmall.api.entity.*;
@@ -20,14 +20,12 @@ import com.kmall.common.utils.RRException;
 import com.kmall.common.utils.StringUtils;
 import com.kmall.common.utils.print.ticket.TicketPrintUtil;
 import com.kmall.common.utils.print.ticket.item.*;
-import com.kmall.common.utils.printer.FeiGeUtils;
 import com.kmall.common.utils.wxtemplate.TemplateData;
 import com.kmall.common.utils.wxtemplate.WxTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.io.Serializable;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;

+ 8 - 5
kmall-api/src/main/java/com/kmall/api/service/ApiPayService.java

@@ -1,6 +1,6 @@
 package com.kmall.api.service;
 
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.api.dao.*;
 import com.kmall.api.entity.*;
 import com.kmall.api.service.pay.wxpay.WxPayPropertiesBuilder;
@@ -11,7 +11,6 @@ import com.kmall.common.utils.DateUtils;
 import com.kmall.common.utils.MapUtils;
 import com.kmall.common.utils.wechat.WechatRefundApiResult;
 import com.kmall.common.utils.wechat.WechatUtil;
-import io.swagger.models.auth.In;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -77,6 +76,7 @@ public class ApiPayService {
         for (OrderVo orderInfo: orderVoList) {
             // 业务处理
             orderInfo.setPay_id(prepay_id);
+            orderInfo.setPayFlag(Dict.payFlag.item_weixin.getItem());
             orderInfo.setPay_status(Integer.parseInt(Dict.payStatus.item_1.getItem())); // 付款中
             orderInfo.setOrder_status(Integer.parseInt(Dict.orderStatus.item_100.getItem()));
             orderService.update(orderInfo);
@@ -119,7 +119,7 @@ public class ApiPayService {
 
     @Transactional
     public void notify(String out_trade_no,String total_fee,String transaction_id,String time_end) {
-        // 业务处理
+        // 支付成功业务处理
         List<OrderVo> orderVoList = orderService.queryObjectByMerchOrderSn(out_trade_no);
         List<OrderProcessRecordEntity> processRecordEntityList = new ArrayList<>();
         Date timeEnd = DateUtils.convertStringToDate(time_end,DateUtils.DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS);
@@ -273,6 +273,7 @@ public class ApiPayService {
         Date successTime = DateUtils.strToDate(success_time);
         if(orderVoList != null && orderVoList.size()>0) {
             for(OrderVo orderInfo:orderVoList) {
+                OrderVo orderVo = new OrderVo();
                 if(orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_201.getItem())
                         || orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_401.getItem())){
                     MallOrderRefund mallOrderRefund = mallOrderRefundMapper.queryObjectByOrderId(orderInfo.getId()+"");
@@ -283,15 +284,19 @@ public class ApiPayService {
                         orderRefund.setRefundId(refundApiResult.getRefund_id());
                         orderRefund.setRefundMoney(BigDecimal.valueOf(Long.valueOf(refundApiResult.getRefund_fee())).divide(Constant.ONE_HUNDRED));
                         if (refundApiResult.getRefund_status().equalsIgnoreCase("SUCCESS")) {
+                            orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_4.getItem()));
                             orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_2.getItem()));
                             orderRefund.setWechatRefundStatusDes("退款成功");
                         } else if (refundApiResult.getRefund_status().equalsIgnoreCase("REFUNDCLOSE")) {
+                            orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_5.getItem()));
                             orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_4.getItem()));
                             orderRefund.setWechatRefundStatusDes("退款关闭");
                         } else if (refundApiResult.getRefund_status().equalsIgnoreCase("PROCESSING")) {
+                            orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_3.getItem()));
                             orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_5.getItem()));
                             orderRefund.setWechatRefundStatusDes("退款处理中");
                         } else if (refundApiResult.getRefund_status().equalsIgnoreCase("CHANGE")) {
+                            orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_6.getItem()));
                             orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_4.getItem()));
                             orderRefund.setWechatRefundStatusDes("退款异常");
                         }
@@ -299,8 +304,6 @@ public class ApiPayService {
                         orderRefund.setId(mallOrderRefund.getId());
                         mallOrderRefundMapper.update(orderRefund);//更新订单退款信息
 
-                        OrderVo orderVo = new OrderVo();
-                        orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_4.getItem()));
                         orderVo.setOrder_status(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
                         orderVo.setId(orderInfo.getId());
                         orderService.update(orderVo);

+ 1 - 1
kmall-api/src/main/java/com/kmall/api/service/ApiUserCouponService.java

@@ -1,6 +1,6 @@
 package com.kmall.api.service;
 
-import com.kmall.api.contants.Dict;
+import com.kmall.common.constant.Dict;
 import com.kmall.api.dao.ApiUserCouponMapper;
 import com.kmall.api.entity.UserCouponVo;
 import org.springframework.beans.factory.annotation.Autowired;

+ 212 - 0
kmall-api/src/main/java/com/kmall/api/service/wxGlobal/ApiWxGlobalPayService.java

@@ -0,0 +1,212 @@
+package com.kmall.api.service.wxGlobal;
+
+import com.kmall.common.constant.Dict;
+import com.kmall.api.dao.*;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.ApiOrderService;
+import com.kmall.api.service.PayerChildOrderRealService;
+import com.kmall.api.service.pay.wxpay.WxPayPropertiesBuilder;
+import com.kmall.common.entity.FormIdsEntity;
+import com.kmall.common.service.FormIdsService;
+import com.kmall.common.utils.Constant;
+import com.kmall.common.utils.DateUtils;
+import com.kmall.common.utils.wechat.WechatRefundApiResult;
+import com.kmall.common.utils.wechat.WechatUtil;
+import com.kmall.common.utils.wechat.wxglobal.WechatGlobalUtil;
+import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalNotifyResult;
+import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalQueryApiResult;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+/**
+ * 小程序form_id收集Service实现类
+ *
+ * @author Scott
+ * @email
+ * @date 2017-12-16 15:32:50
+ */
+@Service
+public class ApiWxGlobalPayService {
+    private static Logger logger = Logger.getLogger(ApiWxGlobalPayService.class);
+    @Autowired
+    private ApiOrderService orderService;
+    @Autowired
+    private FormIdsService formIdsService;
+    @Autowired
+    private PayerChildOrderRealService payerChildOrderRealService;
+    @Autowired
+    private ApiOrderExceptionRecordMapper mallOrderExceptionRecordMapper;
+    @Autowired
+    private ApiOrderProcessRecordMapper orderProcessRecordMapper;
+    @Autowired
+    private ApiOrderRefundMapper mallOrderRefundMapper;
+
+
+    @Transactional
+    public void payPrepay(Map<Object, Object> resultObj, WechatGlobalQueryApiResult queryApiResult, String nonceStr, List<OrderVo> orderVoList) {
+        logger.info("payPrepay》》》》更新订单状态");
+        String prepay_id = queryApiResult.getPrepay_id();
+        resultObj.put("appId", WxPayPropertiesBuilder.instance().getAppId());
+        resultObj.put("timeStamp", DateUtils.timeToStr(System.currentTimeMillis() / 1000, DateUtils.DATE_TIME_PATTERN));
+        resultObj.put("nonceStr", nonceStr);
+        resultObj.put("package", "prepay_id=" + prepay_id);
+        resultObj.put("signType", "MD5");
+        String paySign = WechatUtil.arraySign(resultObj, WxPayPropertiesBuilder.instance().getPaySignKey());
+        resultObj.put("paySign", paySign);
+        for (OrderVo orderInfo: orderVoList) {
+            // 业务处理
+            orderInfo.setPay_id(prepay_id);
+            orderInfo.setPayFlag(Dict.payFlag.item_wxglobalpay.getItem());
+            orderInfo.setOrder_status(Integer.parseInt(Dict.orderStatus.item_100.getItem()));
+            orderInfo.setPay_status(Integer.parseInt(Dict.payStatus.item_1.getItem())); // 付款中
+            orderService.update(orderInfo);
+
+            Map map = new HashMap();
+            map.put("orderSn", orderInfo.getOrder_sn());
+            List<PayerChildOrderRealEntity> list = payerChildOrderRealService.queryList(map);
+            PayerChildOrderRealEntity entity = new PayerChildOrderRealEntity();
+            entity.setGoodsBizType(orderInfo.getOrderBizType());
+            entity.setOrderSn(orderInfo.getOrder_sn());
+            entity.setMerchSn(orderInfo.getMerchSn());
+            entity.setMerchOrderSn(orderInfo.getMerchOrderSn());
+            entity.setPayNo(orderInfo.getPay_id());
+            entity.setPayPrice(orderInfo.getActual_price());
+            entity.setCreateTime(new Date());
+            entity.setModTime(new Date());
+            entity.setUserId(Integer.parseInt(orderInfo.getUser_id() + ""));
+            if(list.size() > 0) {
+                for (PayerChildOrderRealEntity payerChildOrderRealEntity:list) {
+                    entity.setId(payerChildOrderRealEntity.getId());
+                    payerChildOrderRealService.update(entity);
+                }
+            }else{
+                payerChildOrderRealService.save(entity);//记录微信返回的支付单与子订单信息
+            }
+            FormIdsEntity formIdsEntity = formIdsService.getFormIdsByMerchOrderSn(orderInfo.getMerchOrderSn());
+            if(formIdsEntity != null){
+                FormIdsEntity formIds = new FormIdsEntity();
+                formIds.setMerchOrderSn(orderInfo.getMerchOrderSn());
+                formIds.setFormId(prepay_id);
+                formIds.setValidNum(formIdsEntity.getValidNum()+1);
+                formIds.setId(formIdsEntity.getId());
+                formIdsService.releaseFormIds(formIds);
+            }else{
+                // 保存form_id
+                formIdsService.save(orderInfo.getUser_id(), prepay_id, 1, orderInfo.getMerchOrderSn());
+            }
+        }
+    }
+
+    @Transactional
+    public void notify(WechatGlobalNotifyResult result) {
+        String time_end = result.getTime_end();
+        String out_trade_no = result.getOut_trade_no();//商户订单号
+        String transaction_id = result.getTransaction_id();//微信支付订单号
+        String total_fee = result.getTotal_fee();//订单编号
+        // 支付成功业务处理
+        List<OrderVo> orderVoList = orderService.queryObjectByMerchOrderSn(out_trade_no);
+        List<OrderProcessRecordEntity> processRecordEntityList = new ArrayList<>();
+        Date timeEnd = DateUtils.convertStringToDate(time_end,DateUtils.DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS);
+        if(orderVoList != null && orderVoList.size()>0) {
+            for(OrderVo orderInfo:orderVoList) {
+                //校验返回的订单金额是否与商户侧的订单金额一致
+                String actualPrice = String.valueOf(orderInfo.getActual_price().multiply(Constant.ONE_HUNDRED));
+                if(!total_fee.equalsIgnoreCase(actualPrice)){//不一致
+                    MallOrderExceptionRecord mallOrderExceptionRecord = new MallOrderExceptionRecord();
+                    mallOrderExceptionRecord.setUserId(Integer.parseInt(orderInfo.getUser_id()+""));
+                    mallOrderExceptionRecord.setOrderSn(orderInfo.getOrder_sn());
+                    mallOrderExceptionRecord.setExceptionStatus(Dict.exceptionStatus.item_04.getItem());
+                    mallOrderExceptionRecord.setCreateTime(new Date());
+                    mallOrderExceptionRecord.setExceptionContent("微信支付回调返回的订单金额与商户订单金额不一致");
+                    mallOrderExceptionRecordMapper.save(mallOrderExceptionRecord);//支付订单异常记录
+                }
+                if(Dict.orderStatus.item_100.getItem().equalsIgnoreCase(orderInfo.getOrder_status()+"")
+                        && Dict.payStatus.item_1.getItem().equalsIgnoreCase(orderInfo.getPay_status()+"")){
+                    OrderProcessRecordEntity processRecordEntity = orderProcessRecordMapper.queryObjectByOrderSn(orderInfo.getOrder_sn());
+                    if(processRecordEntity != null){
+                        OrderProcessRecordEntity entity = new OrderProcessRecordEntity();
+                        entity.setOrderSn(orderInfo.getOrder_sn());
+                        entity.setUserId(Integer.valueOf(orderInfo.getUser_id()+""));
+                        entity.setId(processRecordEntity.getId());
+                        entity.setIsPaymentSend(Dict.isSend.item_1.getItem());
+                        entity.setPaySuccTime(timeEnd);//微信下单完成时间
+                        processRecordEntityList.add(entity);
+                    }
+
+                    orderInfo.setPayTransactionId(transaction_id);
+                    orderInfo.setPay_status(Integer.parseInt(Dict.payStatus.item_2.getItem()));
+                    orderInfo.setPay_time(timeEnd);//微信下单完成时间
+                    if (orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_100.getItem())) {
+                        orderInfo.setOrder_status(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
+                    }
+                    orderInfo.setTotalFee(Integer.parseInt(result.getTotal_fee()));//标价金额
+                    orderInfo.setFeeType(result.getFee_type());//标价币种
+                    orderInfo.setCashFee(Integer.parseInt(result.getCash_fee()));//用户支付金额
+                    orderInfo.setCashFeeType(result.getCash_fee_type());//用户支付金额币种
+                    orderInfo.setRate(result.getRate_value());//汇率
+                    orderService.update(orderInfo);
+                    orderProcessRecordMapper.updateBatch(processRecordEntityList);//更新订单流转信息
+
+                    // 微信支付成功通知
+                    orderService.notifyPaySuccess(orderInfo);
+                }
+            }
+        }
+    }
+
+
+    @Transactional
+    public void refundNotify(WechatRefundApiResult refundApiResult) {
+        String success_time = refundApiResult.getSuccess_time();
+        String out_trade_no = refundApiResult.getOut_trade_no();//商户订单号
+        // 业务处理
+        List<OrderVo> orderVoList = orderService.queryOrderByMerchOrderSnAndRefundStatus(out_trade_no);
+        Date successTime = DateUtils.strToDate(success_time);
+        if(orderVoList != null && orderVoList.size()>0) {
+            for(OrderVo orderInfo:orderVoList) {
+                if(orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_201.getItem())
+                        || orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_401.getItem())){
+                    MallOrderRefund mallOrderRefund = mallOrderRefundMapper.queryObjectByOrderId(orderInfo.getId()+"");
+                    MallOrderRefund orderRefund = new MallOrderRefund();
+                    OrderVo orderVo = new OrderVo();
+                    if(mallOrderRefund != null){
+                        orderRefund.setOutRefundNo(refundApiResult.getOut_refund_no());
+                        orderRefund.setRefundTime(successTime);//退款成功时间
+                        orderRefund.setRefundId(refundApiResult.getRefund_id());
+                        orderRefund.setRefundMoney(BigDecimal.valueOf(Long.valueOf(refundApiResult.getRefund_fee())).divide(Constant.ONE_HUNDRED));
+                        if (refundApiResult.getRefund_status().equalsIgnoreCase(WechatGlobalUtil.WXTradeState.SUCCESS.getCode())) {
+                            orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_2.getItem()));
+                            orderRefund.setWechatRefundStatusDes("退款成功");
+                            orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_4.getItem()));
+                        } else if (refundApiResult.getRefund_status().equalsIgnoreCase("PROCESSING")) {
+                            orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_5.getItem()));
+                            orderRefund.setWechatRefundStatusDes("退款处理中");
+                            orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_3.getItem()));
+                        } else if (refundApiResult.getRefund_status().equalsIgnoreCase("REFUNDCLOSE")) {
+                            orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_4.getItem()));
+                            orderRefund.setWechatRefundStatusDes("退款关闭");
+                            orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_5.getItem()));
+                        } else if (refundApiResult.getRefund_status().equalsIgnoreCase("CHANGE")) {
+                            orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_4.getItem()));
+                            orderRefund.setWechatRefundStatusDes("退款异常");
+                            orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_6.getItem()));
+                        }
+                        orderRefund.setRefundRecvAccout(refundApiResult.getRefund_recv_accout());
+                        orderRefund.setId(mallOrderRefund.getId());
+                        mallOrderRefundMapper.update(orderRefund);//更新订单退款信息
+
+                        orderVo.setOrder_status(Integer.parseInt(Dict.orderStatus.item_401.getItem()));
+                        orderVo.setId(orderInfo.getId());
+                        orderService.update(orderVo);
+                    }
+                }
+            }
+        }
+    }
+
+}

+ 6 - 0
kmall-api/src/main/resources/mybatis/mapper/ApiGoodsMapper.xml

@@ -313,6 +313,9 @@
         from mall_goods a
         left join mall_product_store_rela s on a.id = s.goods_id
         where 1 = 1 and a.is_on_sale = 1 AND s.stock_num > 0
+        <if test="storeId != null and storeId != ''">
+            and s.store_id = #{storeId}
+        </if>
         <if test="is_new != null and is_new != ''">
             and a.is_new = #{is_new}
         </if>
@@ -352,5 +355,8 @@
         <if test="goodsBizType != null and goodsBizType != ''">
             and a.goods_biz_type = #{goodsBizType}
         </if>
+        <if test="searchGoodsCount == '1'">
+            and a.goods_biz_type != '02' and a.goods_biz_type != '10'
+        </if>
     </select>
 </mapper>

+ 31 - 0
kmall-api/src/main/resources/mybatis/mapper/ApiOrderMapper.xml

@@ -71,6 +71,12 @@
         <result property="isMergePay" column="is_merge_pay"/>
         <result property="isOnfflineOrder" column="is_onffline_order"/>
         <result column="merch_name" property="merchName" jdbcType="VARCHAR" />
+
+        <result property="cashFee" column="cash_fee"/>
+        <result property="cashFeeType" column="cash_fee_type"/>
+        <result property="totalFee" column="total_fee"/>
+        <result property="feeType" column="fee_type"/>
+        <result property="rate" column="rate"/>
     </resultMap>
 
     <select id="queryObject" resultMap="orderMap">
@@ -200,6 +206,11 @@
 			`pay_name`,
 			`shipping_fee`,
 			`actual_price`,
+            `cash_fee`,
+            `cash_fee_type`,
+            `total_fee`,
+            `fee_type`,
+            `rate`,
 			`integral`,
 			`integral_money`,
 			`order_price`,
@@ -284,6 +295,11 @@
 			#{pay_name},
 			#{shipping_fee},
 			#{actual_price},
+            #{cashFee},
+            #{cashFeeType},
+            #{totalFee},
+            #{feeType},
+            #{rate},
 			#{integral},
 			#{integral_money},
 			#{order_price},
@@ -379,6 +395,11 @@
         `pay_name`,
         `shipping_fee`,
         `actual_price`,
+        `cash_fee`,
+        `cash_fee_type`,
+        `total_fee`,
+        `fee_type`,
+        `rate`,
         `integral`,
         `integral_money`,
         `order_price`,
@@ -431,6 +452,11 @@
             #{orderInfo.pay_name},
             #{orderInfo.shipping_fee},
             #{orderInfo.actual_price},
+            #{orderInfo.cashFee},
+            #{orderInfo.cashFeeType},
+            #{orderInfo.totalFee},
+            #{orderInfo.feeType},
+            #{orderInfo.rate},
             #{orderInfo.integral},
             #{orderInfo.integral_money},
             #{orderInfo.order_price},
@@ -489,6 +515,11 @@
             <if test="pay_name != null">`pay_name` = #{pay_name},</if>
             <if test="pay_time != null">`pay_time` = #{pay_time},</if>
             <if test="actual_price != null">`actual_price` = #{actual_price},</if>
+            <if test="cashFee != null">`cash_fee` = #{cashFee}, </if>
+            <if test="cashFeeType != null">`cash_fee_type` = #{cashFeeType}, </if>
+            <if test="totalFee != null">`total_fee` = #{totalFee}, </if>
+            <if test="feeType != null">`fee_type` = #{feeType}, </if>
+            <if test="rate != null">`rate` = #{rate}, </if>
             <if test="integral != null">`integral` = #{integral},</if>
             <if test="integral_money != null">`integral_money` = #{integral_money},</if>
             <if test="order_price != null">`order_price` = #{order_price},</if>

+ 84 - 5
kmall-api/src/main/java/com/kmall/api/contants/Dict.java → kmall-common/src/main/java/com/kmall/common/constant/Dict.java

@@ -1,4 +1,4 @@
-package com.kmall.api.contants;
+package com.kmall.common.constant;
 
 /**
  * @author huangyq
@@ -338,7 +338,7 @@ public class Dict {
 
     /**
      * 订单状态: 0 订单创建成功等待付款,100订单付款中, 101 订单已取消, 102 订单已删除,201 订单已付款,等待发货,300 订单已发货, 301 用户确认收货,400 维权申请中
-     * 401 没有发货,退款 402 已收货,退款退货
+     * 401 没有发货,退款 402 已收货,退款退货 500 订单已关闭 501 支付失败
      */
     public enum orderStatus {
         item_0("0", "订单创建成功等待付款"),
@@ -350,7 +350,9 @@ public class Dict {
         item_301("301", "用户确认收货"),
 //        item_400("400", "维权申请中"),
         item_401("401", "没有发货,退款"),
-        item_402("402", "已收货,退款退货");
+        item_402("402", "已收货,退款退货"),
+        item_500("500", "订单已关闭"),
+        item_501("501", "支付失败");
 
         private String item;
         private String itemName;
@@ -378,14 +380,18 @@ public class Dict {
     }
 
     /**
-     * 付款状态 支付状态;0 未付款;1 付款中;2 已付款;3 退款中;4 退款
+     * 付款状态 支付状态;0 未付款;1 付款中;2 已付款;3 退款中;4 退款; 5:退款关闭;6:退款异常 7:订单关闭 8 支付失败
      */
     public enum payStatus {
         item_0("0", "未付款"),
         item_1("1", "付款中"),
         item_2("2", "已付款"),
         item_3("3", "退款中"),
-        item_4("4", "退款");
+        item_4("4", "退款"),
+        item_5("5", "退款关闭"),
+        item_6("6", "退款异常"),
+        item_7("7", "订单关闭"),
+        item_8("8", "支付失败");
 
         private String item;
         private String itemName;
@@ -699,4 +705,77 @@ public class Dict {
         }
     }
 
+    /**
+     * SUCCESS—支付成功
+     REFUND—转入退款
+     NOTPAY—未支付
+     CLOSED—已关闭
+     REVOKED—已撤销(刷卡支付)
+     USERPAYING--用户支付中
+     PAYERROR--支付失败(其他原因,如银行返回失败)
+     */
+    public enum tradeState {
+        item_SUCCESS("SUCCESS", "支付成功"),
+        item_REFUND("REFUND", "转入退款"),
+        item_NOTPAY("NOTPAY", "未支付"),
+        item_CLOSED("CLOSED", "已关闭"),
+        item_REVOKED("REVOKED", "已撤销(刷卡支付)"),
+        item_USERPAYING("USERPAYING", "用户支付中"),
+        item_PAYERROR("PAYERROR", "支付失败(其他原因,如银行返回失败)");
+
+        private String item;
+        private String itemName;
+
+        tradeState(String item, String itemName) {
+            this.item = item;
+            this.itemName = itemName;
+        }
+
+        public String getItem() {
+            return item;
+        }
+
+        public void setItem(String item) {
+            this.item = item;
+        }
+
+        public String getItemName() {
+            return itemName;
+        }
+
+        public void setItemName(String itemName) {
+            this.itemName = itemName;
+        }
+    }
+    public enum pinganPayStatus {
+        item_1("1", "交易成功"),
+        item_2("2", "待支付"),
+        item_4("4", "已取消"),
+        item_9("9", "等待用户输入密码确认");
+
+        private String item;
+        private String itemName;
+
+        pinganPayStatus(String item, String itemName) {
+            this.item = item;
+            this.itemName = itemName;
+        }
+
+        public String getItem() {
+            return item;
+        }
+
+        public void setItem(String item) {
+            this.item = item;
+        }
+
+        public String getItemName() {
+            return itemName;
+        }
+
+        public void setItemName(String itemName) {
+            this.itemName = itemName;
+        }
+    }
+
 }

+ 12 - 0
kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayDevProperties.java

@@ -0,0 +1,12 @@
+package com.kmall.common.service.pay.global;
+
+import java.io.Serializable;
+
+/**
+ * @author Scott Chen
+ * @since 1.0
+ * 2018-09-27
+ */
+public class CommonWxGlobalPayDevProperties extends CommonWxGlobalPayProperties implements Serializable {
+    
+}

+ 12 - 0
kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayProdProperties.java

@@ -0,0 +1,12 @@
+package com.kmall.common.service.pay.global;
+
+import java.io.Serializable;
+
+/**
+ * @author Scott Chen
+ * @since 1.0
+ * 2018-09-27
+ */
+public class CommonWxGlobalPayProdProperties extends CommonWxGlobalPayProperties implements Serializable {
+    
+}

+ 181 - 0
kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayProperties.java

@@ -0,0 +1,181 @@
+package com.kmall.common.service.pay.global;
+
+import java.io.Serializable;
+
+/**
+ * @author Scott Chen
+ * @since 1.0
+ * 2018-09-27
+ */
+public class CommonWxGlobalPayProperties implements Serializable {
+
+    private static final long serialVersionUID = -5150960165047052585L;
+
+    private String appId;
+    private String secret;
+    private String mchId;
+    private String paySignKey;
+
+    private String tradeType;
+    private String certName;
+    private String notifyUrl;
+    private String getCode;
+
+    private String webAccessTokenhttps;
+    private String userMessage;
+    private String uniformorder;
+    private String refundUrl;
+
+    private String refundqueryUrl;
+    private String orderquery;
+    private String ratequery;
+    private String spbillCreateIp;
+    private String refundNotifyUrl;
+    private String feeType;
+
+    public String getFeeType() {
+        return feeType;
+    }
+
+    public void setFeeType(String feeType) {
+        this.feeType = feeType;
+    }
+
+    public String getRatequery() {
+        return ratequery;
+    }
+
+    public void setRatequery(String ratequery) {
+        this.ratequery = ratequery;
+    }
+
+    public String getRefundNotifyUrl() {
+        return refundNotifyUrl;
+    }
+
+    public void setRefundNotifyUrl(String refundNotifyUrl) {
+        this.refundNotifyUrl = refundNotifyUrl;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getSecret() {
+        return secret;
+    }
+
+    public void setSecret(String secret) {
+        this.secret = secret;
+    }
+
+    public String getMchId() {
+        return mchId;
+    }
+
+    public void setMchId(String mchId) {
+        this.mchId = mchId;
+    }
+
+    public String getPaySignKey() {
+        return paySignKey;
+    }
+
+    public void setPaySignKey(String paySignKey) {
+        this.paySignKey = paySignKey;
+    }
+
+    public String getTradeType() {
+        return tradeType;
+    }
+
+    public void setTradeType(String tradeType) {
+        this.tradeType = tradeType;
+    }
+
+    public String getCertName() {
+        return certName;
+    }
+
+    public void setCertName(String certName) {
+        this.certName = certName;
+    }
+
+    public String getNotifyUrl() {
+        return notifyUrl;
+    }
+
+    public void setNotifyUrl(String notifyUrl) {
+        this.notifyUrl = notifyUrl;
+    }
+
+    public String getGetCode() {
+        return getCode;
+    }
+
+    public void setGetCode(String getCode) {
+        this.getCode = getCode;
+    }
+
+    public String getWebAccessTokenhttps() {
+        return webAccessTokenhttps;
+    }
+
+    public void setWebAccessTokenhttps(String webAccessTokenhttps) {
+        this.webAccessTokenhttps = webAccessTokenhttps;
+    }
+
+    public String getUserMessage() {
+        return userMessage;
+    }
+
+    public void setUserMessage(String userMessage) {
+        this.userMessage = userMessage;
+    }
+
+    public String getUniformorder() {
+        return uniformorder;
+    }
+
+    public void setUniformorder(String uniformorder) {
+        this.uniformorder = uniformorder;
+    }
+
+    public String getRefundUrl() {
+        return refundUrl;
+    }
+
+    public void setRefundUrl(String refundUrl) {
+        this.refundUrl = refundUrl;
+    }
+
+    public String getRefundqueryUrl() {
+        return refundqueryUrl;
+    }
+
+    public void setRefundqueryUrl(String refundqueryUrl) {
+        this.refundqueryUrl = refundqueryUrl;
+    }
+
+    public String getOrderquery() {
+        return orderquery;
+    }
+
+    public void setOrderquery(String orderquery) {
+        this.orderquery = orderquery;
+    }
+
+    public String getSpbillCreateIp() {
+        return spbillCreateIp;
+    }
+
+    public void setSpbillCreateIp(String spbillCreateIp) {
+        this.spbillCreateIp = spbillCreateIp;
+    }
+
+
+}

+ 41 - 0
kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayPropertiesBuilder.java

@@ -0,0 +1,41 @@
+package com.kmall.common.service.pay.global;
+
+import com.kmall.common.service.pay.wxpay.CommonWxPayProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author Scott Chen
+ * @since 1.0
+ * 2018-09-27
+ */
+@Component
+public class CommonWxGlobalPayPropertiesBuilder {
+    private static final Logger logger = LoggerFactory.getLogger(CommonWxGlobalPayPropertiesBuilder.class);
+
+    @Autowired
+    @Qualifier("commonWxGlobalPayProperties")
+    private CommonWxGlobalPayProperties commonWxGlobalPayProperties;
+
+    private static CommonWxGlobalPayProperties wxPayProp;
+
+    /**
+     * Bean 向静态变量赋值
+     */
+    @PostConstruct
+    private void init(){
+        logger.info("CommonWxPayProperties初始化开始......");
+        wxPayProp = commonWxGlobalPayProperties;
+    }
+
+    public static CommonWxGlobalPayProperties instance(){
+        logger.info("CommonWxPayProperties实例返回");
+        return wxPayProp;
+    }
+
+}

+ 39 - 0
kmall-common/src/main/java/com/kmall/common/service/pay/global/CommonWxGlobalPayPropertiesConfiguration.java

@@ -0,0 +1,39 @@
+package com.kmall.common.service.pay.global;
+
+import com.kmall.common.service.pay.wxpay.CommonWxPayDevProperties;
+import com.kmall.common.service.pay.wxpay.CommonWxPayProdProperties;
+import com.kmall.common.service.pay.wxpay.CommonWxPayProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Scott Chen
+ * @since 1.0
+ * 2018-09-27
+ */
+@Component
+public class CommonWxGlobalPayPropertiesConfiguration {
+    private static final String PROD = "prod";
+    private static final String DEV = "dev";
+
+    @Value("${pay.wx.global.env}")
+    private String evn = PROD;
+
+    @Autowired
+    private CommonWxGlobalPayProdProperties commonWxGlobalPayProdProperties;
+
+    @Autowired
+    private CommonWxGlobalPayDevProperties commonWxGlobalPayDevProperties;
+
+    @Bean
+    public CommonWxGlobalPayProperties commonWxGlobalPayProperties(){
+        if (evn.equalsIgnoreCase(PROD)) {
+            return commonWxGlobalPayProdProperties;
+        }else {
+            return commonWxGlobalPayDevProperties;
+        }
+    }
+
+}

+ 9 - 0
kmall-common/src/main/java/com/kmall/common/utils/wechat/WechatRefundApiResult.java

@@ -46,6 +46,15 @@ public class WechatRefundApiResult {
 	 PAYERROR--支付失败(其他原因,如银行返回失败)
 	 */
 	private String trade_state;//交易状态
+	private String trade_state_desc;//交易状态描述
+
+	public String getTrade_state_desc() {
+		return trade_state_desc;
+	}
+
+	public void setTrade_state_desc(String trade_state_desc) {
+		this.trade_state_desc = trade_state_desc;
+	}
 
 	public String getOpenid() {
 		return openid;

+ 5 - 5
kmall-common/src/main/java/com/kmall/common/utils/wechat/WechatUtil.java

@@ -174,7 +174,7 @@ public class WechatUtil {
     /**
      * 请求微信https
      **/
-    private static String sendSSLPostToWx(String mapToXml, SSLConnectionSocketFactory sslcsf, String requestUrl) {
+    public static String sendSSLPostToWx(String mapToXml, SSLConnectionSocketFactory sslcsf, String requestUrl) {
         HttpPost httPost = new HttpPost(requestUrl);
         httPost.addHeader("Connection", "keep-alive");
         httPost.addHeader("Accept", "*/*");
@@ -474,9 +474,9 @@ public class WechatUtil {
         String reponseXml = sendMicropaySSLPostToWx(mapToXml);
         WechatMicropayApiResult result =
                 (WechatMicropayApiResult) XmlUtil.xmlStrToBean(reponseXml, WechatMicropayApiResult.class);
-        if ("SUCCESS".equals(result.getReturn_code()) && "OK".equals(result.getReturn_msg())) {
+        if (WXTradeState.SUCCESS.getCode().equals(result.getReturn_code()) && "OK".equals(result.getReturn_msg())) {
             //支付成功
-            if ("SUCCESS".equals(result.getResult_code())) {
+            if (WXTradeState.SUCCESS.getCode().equals(result.getResult_code())) {
                 result.setTrade_state(WXTradeState.SUCCESS.getCode());
             } else if ("FAIL".equals(result.getResult_code())) {
                 //支付中
@@ -527,7 +527,7 @@ public class WechatUtil {
     }
 
     /**
-     * 绑定提交付款码支付请求输入参数
+     * 绑定提交付款码支付请求参数
      *
      * @param shop_name    门店名称
      * @param orderBizType 订单业务类型
@@ -536,7 +536,7 @@ public class WechatUtil {
      * @param orderMoney   订单总金额,单位:元
      * @param ip           当前机器ip
      * @param auth_code    扫码得到支付授权码
-     * @return 提交付款码支付请求输入参数
+     * @return 提交付款码支付请求参数
      */
     private static Map<Object, Object> buildMicropayRequsetMapParam(String shop_name, String orderBizType,
                                                                     String attach, String out_trade_no,

+ 79 - 89
kmall-common/src/main/java/com/kmall/common/utils/wechat/wxglobal/WechatGlobalUtil.java

@@ -2,36 +2,26 @@ package com.kmall.common.utils.wechat.wxglobal;
 
 import com.alibaba.druid.support.logging.Log;
 import com.alibaba.druid.support.logging.LogFactory;
-import com.kmall.common.service.pay.wxpay.CommonWxPayPropertiesBuilder;
+import com.kmall.common.service.pay.global.CommonWxGlobalPayPropertiesBuilder;
 import com.kmall.common.utils.*;
 import com.kmall.common.utils.wechat.*;
 import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalQueryApiResult;
 import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalQueryRateResult;
 import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalRefundApiResult;
 import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalRefundQueryResult;
+import org.apache.commons.lang.StringUtils;
 import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
 import org.apache.http.util.EntityUtils;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.math.MathContext;
-import java.net.URLEncoder;
 import java.util.*;
 
 /**
@@ -105,6 +95,46 @@ public class WechatGlobalUtil {
         }
     }
 
+    /**
+     * 统一下单
+     * @param out_trade_no 商户订单号
+     * @param body 商品描述
+     * @param actual_price 实付金额
+     * @param openId 微信openId
+     * @return
+     */
+    public static WechatGlobalQueryApiResult unifiedOrder(String out_trade_no,String body,BigDecimal actual_price,String openId) {
+        Map<Object, Object> param = new TreeMap<>();
+        param.put("appid", CommonWxGlobalPayPropertiesBuilder.instance().getAppId());
+        param.put("mch_id", CommonWxGlobalPayPropertiesBuilder.instance().getMchId());// 商家账号
+        String randomStr = CharUtil.getRandomNum(18).toUpperCase();
+        param.put("nonce_str", randomStr);// 随机字符串
+        if(StringUtils.isNotEmpty(body)) {
+            param.put("body", body);// 商品描述
+        }else{
+            param.put("body", "商城-支付");// 商品描述
+        }
+        param.put("out_trade_no", out_trade_no);// 商户订单编号
+        //支付金额
+        param.put("total_fee", Math.round(actual_price.multiply(Constant.ONE_HUNDRED).doubleValue()));// 消费金额
+        param.put("fee_type",CommonWxGlobalPayPropertiesBuilder.instance().getFeeType());//标价币种
+        param.put("spbill_create_ip", CommonWxGlobalPayPropertiesBuilder.instance().getSpbillCreateIp());
+        param.put("notify_url", CommonWxGlobalPayPropertiesBuilder.instance().getNotifyUrl());// 回调地址
+        param.put("trade_type", CommonWxGlobalPayPropertiesBuilder.instance().getTradeType());// 交易类型APP
+        param.put("openid", openId);
+        String sign = WechatUtil.arraySign(param, CommonWxGlobalPayPropertiesBuilder.instance().getPaySignKey());
+        param.put("sign", sign);// 数字签证
+
+        String xml = MapUtils.convertMap2Xml(param);
+        logger.info("xml:" + xml);
+        logger.info("*******查询订单(WX Request:" + xml);
+        String reponseXml = WechatUtil.sendSSLPostToWx(xml, WechatConfig.getSslcsf(), CommonWxGlobalPayPropertiesBuilder.instance().getUniformorder());
+        logger.info("*******查询订单(WX Response:" + reponseXml);
+        WechatGlobalQueryApiResult result =
+                (WechatGlobalQueryApiResult) XmlUtil.xmlStrToBean(reponseXml, WechatGlobalQueryApiResult.class);
+
+        return result;
+    }
 
     /**
      * 微信境外查询订单
@@ -115,12 +145,12 @@ public class WechatGlobalUtil {
         //初始化请求微信服务器的配置信息包括appid密钥等
         //构建请求参数
         Map<Object, Object> params = new HashMap<Object, Object>();
-        params.put("appid", CommonWxPayPropertiesBuilder.instance().getAppId());//微信分配的公众账号ID(企业号corpid即为此appId)
-        params.put("mch_id", CommonWxPayPropertiesBuilder.instance().getMchId());//微信支付分配的商户号
+        params.put("appid", CommonWxGlobalPayPropertiesBuilder.instance().getAppId());//微信分配的公众账号ID(企业号corpid即为此appId)
+        params.put("mch_id", CommonWxGlobalPayPropertiesBuilder.instance().getMchId());//微信支付分配的商户号
         params.put("out_trade_no", out_trade_no);//商户传给微信的订单号
         params.put("nonce_str", CharUtil.getRandomString(16));//随机字符串,不长于32位。推荐随机数生成算法
         //签名前必须要参数全部写在前面
-        params.put("sign", WechatUtil.arraySign(params, CommonWxPayPropertiesBuilder.instance().getPaySignKey()));//签名
+        params.put("sign", WechatUtil.arraySign(params, CommonWxGlobalPayPropertiesBuilder.instance().getPaySignKey()));//签名
         String mapToXml = MapUtils.convertMap2Xml(params);
         //请求微信
         String reponseXml = sendQuerySSLPostToWx(mapToXml, WechatConfig.getSslcsf());
@@ -133,7 +163,7 @@ public class WechatGlobalUtil {
      **/
     private static String sendQuerySSLPostToWx(String mapToXml, SSLConnectionSocketFactory sslcsf) {
         logger.info("*******查询订单(WX Request:" + mapToXml);
-        String xmlStr = sendSSLPostToWx(mapToXml, sslcsf, CommonWxPayPropertiesBuilder.instance().getOrderquery());
+        String xmlStr = WechatUtil.sendSSLPostToWx(mapToXml, sslcsf, CommonWxGlobalPayPropertiesBuilder.instance().getOrderquery());
         logger.info("*******查询订单(WX Response:" + xmlStr);
         return xmlStr;
     }
@@ -147,15 +177,15 @@ public class WechatGlobalUtil {
         //初始化请求微信服务器的配置信息包括appid密钥等
         //构建请求参数
         Map<Object, Object> params = new HashMap<Object, Object>();
-        params.put("appid", CommonWxPayPropertiesBuilder.instance().getAppId());//微信分配的公众账号ID(企业号corpid即为此appId)
-        params.put("mch_id", CommonWxPayPropertiesBuilder.instance().getMchId());//微信支付分配的商户号
-        params.put("fee_type", "HKD");//外币币种
+        params.put("appid", CommonWxGlobalPayPropertiesBuilder.instance().getAppId());//微信分配的公众账号ID(企业号corpid即为此appId)
+        params.put("mch_id", CommonWxGlobalPayPropertiesBuilder.instance().getMchId());//微信支付分配的商户号
+        params.put("fee_type", CommonWxGlobalPayPropertiesBuilder.instance().getFeeType());//外币币种
         params.put("date", DateUtils.format(new Date(),DateUtils.DATE_TIME_PATTERN_YYYY_MM_DD));//格式为yyyyMMdd
         //签名前必须要参数全部写在前面
-        params.put("sign", WechatUtil.arraySign(params, CommonWxPayPropertiesBuilder.instance().getPaySignKey()));//签名
+        params.put("sign", WechatUtil.arraySign(params, CommonWxGlobalPayPropertiesBuilder.instance().getPaySignKey()));//签名
         String mapToXml = MapUtils.convertMap2Xml(params);
         //请求微信
-        String reponseXml = sendSSLPostToWx(mapToXml, WechatConfig.getSslcsf(), "https://api.mch.weixin.qq.com/pay/queryexchagerate");
+        String reponseXml = WechatUtil.sendSSLPostToWx(mapToXml, WechatConfig.getSslcsf(), CommonWxGlobalPayPropertiesBuilder.instance().getRatequery());
 
         WechatGlobalQueryRateResult result =
                 (WechatGlobalQueryRateResult) XmlUtil.xmlStrToBean(reponseXml, WechatGlobalQueryRateResult.class);
@@ -164,7 +194,9 @@ public class WechatGlobalUtil {
 
     /**
      * 微信境外申请退款
-     * @param
+     * @param out_trade_no 商户订单编号
+     * @param orderMoney 订单总金额
+     * @param refundMoney 申请退款金额
      * @return
      */
     public static WechatGlobalRefundApiResult wxRefund(String out_trade_no, Double orderMoney, Double refundMoney) {
@@ -174,17 +206,17 @@ public class WechatGlobalUtil {
         BigDecimal bdRefundMoney = new BigDecimal(refundMoney, MathContext.DECIMAL32);
         //构建请求参数
         Map<Object, Object> params = new HashMap<Object, Object>();
-        params.put("appid", CommonWxPayPropertiesBuilder.instance().getAppId());//微信分配的公众账号ID(企业号corpid即为此appId)
-        params.put("mch_id", CommonWxPayPropertiesBuilder.instance().getMchId());//微信支付分配的商户号
+        params.put("appid", CommonWxGlobalPayPropertiesBuilder.instance().getAppId());//微信分配的公众账号ID(企业号corpid即为此appId)
+        params.put("mch_id", CommonWxGlobalPayPropertiesBuilder.instance().getMchId());//微信支付分配的商户号
         params.put("nonce_str", CharUtil.getRandomString(16));//随机字符串,不长于32位。推荐随机数生成算法
         params.put("out_trade_no", out_trade_no);//商户传给微信的订单号
         params.put("out_refund_no", System.currentTimeMillis() + "");//商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔
-        params.put("total_fee", bdOrderMoney.multiply(Constant.ONE_HUNDRED).intValue());//订单总金额,单位为分,只能为整数
-        params.put("refund_fee", bdRefundMoney.multiply(Constant.ONE_HUNDRED).intValue());//退款总金额,订单总金额,单位为分,只能为整数
-        params.put("op_user_id", CommonWxPayPropertiesBuilder.instance().getMchId());//操作员帐号, 默认为商户号
-        params.put("notify_url", CommonWxPayPropertiesBuilder.instance().getRefundNotifyUrl());
+        params.put("total_fee", Math.round(bdOrderMoney.multiply(Constant.ONE_HUNDRED).doubleValue()));//订单总金额,单位为分,只能为整数
+        params.put("refund_fee", Math.round(bdRefundMoney.multiply(Constant.ONE_HUNDRED).doubleValue()));//退款总金额,订单总金额,单位为分,只能为整数
+        params.put("op_user_id", CommonWxGlobalPayPropertiesBuilder.instance().getMchId());//操作员帐号, 默认为商户号
+        params.put("notify_url", CommonWxGlobalPayPropertiesBuilder.instance().getRefundNotifyUrl());
         //签名前必须要参数全部写在前面
-        params.put("sign", WechatUtil.arraySign(params, CommonWxPayPropertiesBuilder.instance().getPaySignKey()));//签名
+        params.put("sign", WechatUtil.arraySign(params, CommonWxGlobalPayPropertiesBuilder.instance().getPaySignKey()));//签名
         String mapToXml = MapUtils.convertMap2Xml(params);
 
         //请求微信
@@ -200,12 +232,10 @@ public class WechatGlobalUtil {
      **/
     public static String sendRefundSSLPostToWx(String mapToXml, SSLConnectionSocketFactory sslcsf) {
         logger.info("*******退款(WX Request:" + mapToXml);
-        String xmlStr = sendSSLPostToWx(mapToXml, sslcsf, CommonWxPayPropertiesBuilder.instance().getRefundUrl());
+        String xmlStr = WechatUtil.sendSSLPostToWx(mapToXml, sslcsf, CommonWxGlobalPayPropertiesBuilder.instance().getRefundUrl());
         logger.info("*******退款(WX Response:" + xmlStr);
         return xmlStr;
     }
-
-
     /**
      * 微信境外查询退款
      * @param
@@ -213,12 +243,12 @@ public class WechatGlobalUtil {
      */
     public static WechatGlobalRefundQueryResult wxRefundquery(String out_trade_no) {
         Map<Object, Object> params = new HashMap<Object, Object>();
-        params.put("appid", CommonWxPayPropertiesBuilder.instance().getAppId());//微信分配的公众账号ID(企业号corpid即为此appId)
-        params.put("mch_id", CommonWxPayPropertiesBuilder.instance().getMchId());//微信支付分配的商户号
+        params.put("appid", CommonWxGlobalPayPropertiesBuilder.instance().getAppId());//微信分配的公众账号ID(企业号corpid即为此appId)
+        params.put("mch_id", CommonWxGlobalPayPropertiesBuilder.instance().getMchId());//微信支付分配的商户号
         params.put("nonce_str", CharUtil.getRandomString(16));//随机字符串,不长于32位。推荐随机数生成算法
         params.put("out_trade_no", out_trade_no);//商户侧传给微信的订单号
         //签名前必须要参数全部写在前面
-        params.put("sign", WechatUtil.arraySign(params, CommonWxPayPropertiesBuilder.instance().getPaySignKey()));//签名
+        params.put("sign", WechatUtil.arraySign(params, CommonWxGlobalPayPropertiesBuilder.instance().getPaySignKey()));//签名
         String mapToXml = MapUtils.convertMap2Xml(params);
         String reponseXml = sendRefundQerutySSLPostToWx(mapToXml, WechatConfig.getSslcsf());
         System.out.println(reponseXml);
@@ -229,64 +259,24 @@ public class WechatGlobalUtil {
     }
     public static String sendRefundQerutySSLPostToWx(String mapToXml, SSLConnectionSocketFactory sslcsf) {
         logger.info("*******退款查询(WX Request:" + mapToXml);
-        String xmlStr = sendSSLPostToWx(mapToXml, sslcsf, CommonWxPayPropertiesBuilder.instance().getRefundqueryUrl());
+        String xmlStr = WechatUtil.sendSSLPostToWx(mapToXml, sslcsf, CommonWxGlobalPayPropertiesBuilder.instance().getRefundqueryUrl());
         logger.info("*******退款查询(WX Response:" + xmlStr);
         return xmlStr;
     }
 
-    /**
-     * 请求微信https
-     **/
-    private static String sendSSLPostToWx(String mapToXml, SSLConnectionSocketFactory sslcsf, String requestUrl) {
-
-        HttpPost httPost = new HttpPost(requestUrl);
-        httPost.addHeader("Connection", "keep-alive");
-        httPost.addHeader("Accept", "*/*");
-        httPost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
-        httPost.addHeader("Host", "api.mch.weixin.qq.com");
-        httPost.addHeader("X-Requested-With", "XMLHttpRequest");
-        httPost.addHeader("Cache-Control", "max-age=0");
-        httPost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
-        httPost.setEntity(new StringEntity(mapToXml, "UTF-8"));
-        CloseableHttpClient httpClient = null;
-        if (sslcsf != null) {
-            httpClient = HttpClients.custom().setSSLSocketFactory(sslcsf).build();
-        } else {
-            httpClient = HttpClients.createDefault();
-        }
-
-        CloseableHttpResponse response = null;
-        try {
-            response = httpClient.execute(httPost);
-            HttpEntity entity = response.getEntity();
-            String xmlStr = EntityUtils.toString(entity, "UTF-8");
-            return xmlStr;
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        } finally {
-            try {
-                if (response != null) {
-                    response.close();
-                }
-            } catch (IOException e) {
-                logger.error(e.getMessage(), e);
-            }
-        }
-    }
-
     public static void main(String[] args) throws Exception {
-        Map<Object, Object> parame = new TreeMap<Object, Object>();
-        parame.put("mch_id", "");//
-        String randomStr = CharUtil.getRandomNum(18).toUpperCase();
-        parame.put("nonce_str", randomStr);//
-        String sign = WechatUtil.arraySign(parame, "");
-        parame.put("sign", sign);// 数字签证
-
-        String xml = MapUtils.convertMap2Xml(parame);
-        logger.info("xml:" + xml);
-        Map<String, Object> resultUn = XmlUtil.xmlStrToMap(
-                WechatUtil.requestOnce("https://apitest.mch.weixin.qq.com/sandboxnew/pay/getsignkey", xml));
-        System.out.print(resultUn);
+//        Map<Object, Object> parame = new TreeMap<Object, Object>();
+//        parame.put("mch_id", "");//
+//        String randomStr = CharUtil.getRandomNum(18).toUpperCase();
+//        parame.put("nonce_str", randomStr);//
+//        String sign = WechatUtil.arraySign(parame, "");
+//        parame.put("sign", sign);// 数字签证
+//
+//        String xml = MapUtils.convertMap2Xml(parame);
+//        logger.info("xml:" + xml);
+//        Map<String, Object> resultUn = XmlUtil.xmlStrToMap(
+//                WechatUtil.requestOnce("https://apitest.mch.weixin.qq.com/sandboxnew/pay/getsignkey", xml));
+//        System.out.print(resultUn);
+        System.out.println(Math.round(new BigDecimal("21.6366").multiply(Constant.ONE_HUNDRED).doubleValue()));
     }
 }

+ 9 - 0
kmall-common/src/main/java/com/kmall/common/utils/wechat/wxglobal/dto/WechatGlobalQueryApiResult.java

@@ -22,6 +22,7 @@ public class WechatGlobalQueryApiResult {
 	private String openId;//用户标识
 	private String is_subscribe;//是否关注公众账号
 	private String trade_type;//调用接口提交的交易类型,取值如下:JSAPI,NATIVE,APP,MICROPAY
+	private String prepay_id;//预支付编号
 	/**
 	 * SUCCESS—支付成功
 	 REFUND—转入退款
@@ -237,4 +238,12 @@ public class WechatGlobalQueryApiResult {
 	public void setRate(String rate) {
 		this.rate = rate;
 	}
+
+	public String getPrepay_id() {
+		return prepay_id;
+	}
+
+	public void setPrepay_id(String prepay_id) {
+		this.prepay_id = prepay_id;
+	}
 }

+ 3 - 3
kmall-common/src/main/java/com/kmall/common/utils/wechat/wxglobal/dto/WechatGlobalRefundApiResult.java

@@ -20,10 +20,10 @@ public class WechatGlobalRefundApiResult {
 	private String out_trade_no;
 	private String out_refund_no;
 	private String refund_id;
-	private String refund_fee;//申请退款金额
+	private String refund_fee;//申请退款金额,可支持部分退款
 	private String refund_fee_type;//退款币种
-	private String total_fee;//订单金额
-	private String fee_type;
+	private String total_fee;//订单金额
+	private String fee_type;//订单总金额币种
 	private String cash_fee;//用户支付金额
 	private String cash_fee_type;//用户支付金额币种
 	private String cash_refund_fee;//用户退款金额

+ 1 - 0
kmall-framework/src/main/webapp/WEB-INF/web.xml

@@ -12,6 +12,7 @@
             classpath:spring/spring-express-kdn.xml,
             classpath:spring/spring-redis.xml,
             classpath:spring/spring-wx-pay.xml,
+            classpath:spring/spring-wx-global-pay.xml,
             classpath:spring/spring-pingan-pay.xml,
             classpath:spring/spring-jdbc.xml,
             classpath:spring/spring-oms-merch.xml,

+ 1 - 0
kmall-framework/src/test/resources/applicationContext-test.xml

@@ -25,6 +25,7 @@
                 <value>classpath:conf/redis.properties</value>
                 <value>classpath:conf/servlet.properties</value>
                 <value>classpath:conf/wx-mp.properties</value>
+                <value>classpath:conf/wx-global.properties</value>
                 <value>classpath:conf/pingan-pay.properties</value>
                 <value>classpath:conf/oms-merch.properties</value>
                 <value>classpath:conf/print-ticket.properties</value>

+ 355 - 109
kmall-schedule/src/main/java/com/kmall/schedule/service/QzOrderService.java

@@ -1,7 +1,11 @@
 package com.kmall.schedule.service;
 
+import com.kmall.common.constant.Dict;
 import com.kmall.common.utils.*;
 import com.kmall.common.utils.wechat.*;
+import com.kmall.common.utils.wechat.wxglobal.WechatGlobalUtil;
+import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalQueryApiResult;
+import com.kmall.common.utils.wechat.wxglobal.dto.WechatGlobalRefundQueryResult;
 import com.kmall.schedule.dao.OrderWXPayRecordMapper;
 import com.kmall.schedule.dao.QzGroupMapper;
 import com.kmall.schedule.dao.QzOrderMapper;
@@ -213,7 +217,7 @@ public class QzOrderService {
     }
 
     /**
-     * 更新退款中或小程序更新退款信息异常订单
+     * 更新退款中的,或小程序更新退款信息异常订单
      */
     @Transactional
     public void refundUpdate() {
@@ -223,79 +227,176 @@ public class QzOrderService {
         List<Map> refundOrderList = qzOrderMapper.queryRefundOrderList();
         if (null != refundOrderList && refundOrderList.size() > 0) {
             for (Map map : refundOrderList) {
-                String out_trade_no = MapUtils.getString("merch_order_sn", map);
-                String order_id = MapUtils.getString("order_id", map);
-                Integer is_onffline_order = MapUtils.getInteger("is_onffline_order", map);
-                String order_sn_wx = MapUtils.getString("order_sn_wx", map);
+                String pay_flag = MapUtils.getString("pay_flag", map);
+                String orderId = MapUtils.getString("order_id", map);
+                if(org.apache.commons.lang.StringUtils.isNotEmpty(pay_flag)) {
+                    if (pay_flag.equalsIgnoreCase("wxglobalpay")) {//微信国际支付
+                        wxGlobalRefundQuery(map);
+                    } else {//微信支付、平安支付、线下扫码支付
+                        wxRefundquery(map);
+                    }
+                }else{
+                    logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate 订单编号【"+orderId+"】的支付方式不能为空! ");
+                }
+            }
+        } else {
+            logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate 未查到退款数据 ");
+        }
+        logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate is end ");
+    }
 
-                if (is_onffline_order == 1) {
-                    out_trade_no = order_sn_wx;
+    /**
+     * 微信支付、平安支付、线下扫码支付共用微信查询订单api
+     * @param map
+     */
+    private void  wxRefundquery(Map map){
+        logger.info(">>>>>>>>>>>>>>>>>>>>wxRefundquery 微信退款查询接口调用");
+        String out_trade_no = MapUtils.getString("merch_order_sn", map);
+        String order_id = MapUtils.getString("order_id", map);
+        String order_sn_wx = MapUtils.getString("order_sn_wx", map);
+        Integer is_onffline_order = MapUtils.getInteger("is_onffline_order", map);
+        if (is_onffline_order == 1) {
+            out_trade_no = order_sn_wx;
+        }
+        WechatRefundQueryResult result = WechatUtil.wxRefundquery(out_trade_no);
+        if (result.getReturn_code().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+            if (result.getResult_code().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                Map refundRaram = new HashMap();
+                int msgCount = Integer.parseInt(result.getRefund_count());
+                for (int i = 0; i < msgCount; i++) {
+                    WechatRefundQueryResult querySuccessResponseDto =
+                            ReaderXmlForDOM4J.parse(result.getXmlStr(), i);
+                    result.setRefund_success_time(querySuccessResponseDto.getRefund_success_time());
+                    result.setOut_refund_no(querySuccessResponseDto.getOut_refund_no());
+                    result.setRefund_account(querySuccessResponseDto.getRefund_account());
+                    result.setRefund_channel(querySuccessResponseDto.getRefund_channel());
+                    result.setRefund_fee(querySuccessResponseDto.getRefund_fee());
+                    result.setRefund_id(querySuccessResponseDto.getRefund_id());
+                    result.setRefund_recv_accout(querySuccessResponseDto.getRefund_recv_accout());
+                    result.setRefund_status(querySuccessResponseDto.getRefund_status());
                 }
+                Date successTime = DateUtils.strToDate(result.getRefund_success_time());
+                refundRaram.put("refundTime", successTime);
+                refundRaram.put("outRefundNo", result.getOut_refund_no());
+                refundRaram.put("refundId", result.getRefund_id());
+                refundRaram.put("refundMoney",
+                        BigDecimal.valueOf(Long.valueOf(result.getRefund_fee()))
+                                .divide(Constant.ONE_HUNDRED));
+                Map orderRaram = new HashMap();
+                if (result.getRefund_status().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                    refundRaram.put("refundStatus", Dict.RefundStatus.item_2.getItem());
+                    refundRaram.put("wechat_refund_status_des", "退款成功");
+                    orderRaram.put("payStatus", Dict.payStatus.item_4.getItem());
+                } else if (result.getRefund_status().equalsIgnoreCase("REFUNDCLOSE")) {
+                    refundRaram.put("refundStatus", Dict.RefundStatus.item_4.getItem());
+                    refundRaram.put("wechat_refund_status_des", "退款关闭");
+                    orderRaram.put("payStatus", Dict.payStatus.item_5.getItem());
+                } else if (result.getRefund_status().equalsIgnoreCase("CHANGE")) {
+                    refundRaram.put("refundStatus", Dict.RefundStatus.item_4.getItem());
+                    refundRaram.put("wechat_refund_status_des", "退款异常");
+                    orderRaram.put("payStatus", Dict.payStatus.item_6.getItem());
+                } else if (result.getRefund_status().equalsIgnoreCase("PROCESSING")) {
+                    refundRaram.put("refundStatus", Dict.RefundStatus.item_5.getItem());
+                    refundRaram.put("wechat_refund_status_des", "退款处理中");
+                    orderRaram.put("payStatus", Dict.payStatus.item_3.getItem());
+                }
+                refundRaram.put("refundRecvAccout", result.getRefund_recv_accout());
+                refundRaram.put("orderRefundId", result.getOut_refund_no());
+                qzOrderMapper.updateOrderRefund(refundRaram);//更新订单退款信息
+
+                orderRaram.put("orderStatus", Dict.orderStatus.item_401.getItem());
+                orderRaram.put("orderId", order_id);
+                orderRaram.put("payTransactionId", result.getTransaction_id());
+                qzOrderMapper.updateOrderInfo(orderRaram);
+            } else {
+                logger.info(">>>>>>>>>>>>>>>>>>>>wxRefundquery 微信退款查询接口返回失败信息:code 【" + result.getErr_code() +
+                        "】,des【" + result.getErr_code_des() + "】");
+            }
+        } else {
+            logger.info(">>>>>>>>>>>>>>>>>>>>wxRefundquery 微信退款查询接口调用失败: " + result.getReturn_msg());
+        }
+    }
 
-                WechatRefundQueryResult result = WechatUtil.wxRefundquery(out_trade_no);
-                if (result.getReturn_code().equalsIgnoreCase("SUCCESS")) {
-                    if (result.getResult_code().equalsIgnoreCase("SUCCESS")) {
-                        Map refundRaram = new HashMap();
-                        int msgCount = Integer.parseInt(result.getRefund_count());
-                        for (int i = 0; i < msgCount; i++) {
-                            WechatRefundQueryResult querySuccessResponseDto =
-                                    ReaderXmlForDOM4J.parse(result.getXmlStr(), i);
-                            if (result.getReturn_code().equalsIgnoreCase("SUCCESS")) {
-                                if (result.getResult_code().equalsIgnoreCase("SUCCESS")) {
-                                    result.setRefund_success_time(querySuccessResponseDto.getRefund_success_time());
-                                    result.setOut_refund_no(querySuccessResponseDto.getOut_refund_no());
-                                    result.setRefund_account(querySuccessResponseDto.getRefund_account());
-                                    result.setRefund_channel(querySuccessResponseDto.getRefund_channel());
-                                    result.setRefund_fee(querySuccessResponseDto.getRefund_fee());
-                                    result.setRefund_id(querySuccessResponseDto.getRefund_id());
-                                    result.setRefund_recv_accout(querySuccessResponseDto.getRefund_recv_accout());
-                                    result.setRefund_status(querySuccessResponseDto.getRefund_status());
-
-                                    Date successTime = DateUtils.strToDate(result.getRefund_success_time());
-                                    refundRaram.put("refundTime", successTime);
-                                    refundRaram.put("outRefundNo", result.getOut_refund_no());
-                                    refundRaram.put("refundId", result.getRefund_id());
-                                    refundRaram.put("refundMoney",
-                                                    BigDecimal.valueOf(Long.valueOf(result.getRefund_fee()))
-                                                              .divide(Constant.ONE_HUNDRED));
-                                    if (result.getRefund_status().equalsIgnoreCase("SUCCESS")) {
-                                        refundRaram.put("refundStatus", 2);
-                                        refundRaram.put("wechat_refund_status_des", "退款成功");
-                                    } else if (result.getRefund_status().equalsIgnoreCase("REFUNDCLOSE")) {
-                                        refundRaram.put("refundStatus", 4);
-                                        refundRaram.put("wechat_refund_status_des", "退款关闭");
-                                    } else if (result.getRefund_status().equalsIgnoreCase("PROCESSING")) {
-                                        refundRaram.put("refundStatus", 5);
-                                        refundRaram.put("wechat_refund_status_des", "退款处理中");
-                                    } else if (result.getRefund_status().equalsIgnoreCase("CHANGE")) {
-                                        refundRaram.put("refundStatus", 4);
-                                        refundRaram.put("wechat_refund_status_des", "退款异常");
-                                    }
-                                    refundRaram.put("refundRecvAccout", result.getRefund_recv_accout());
-                                    refundRaram.put("orderRefundId", result.getOut_refund_no());
-                                    qzOrderMapper.updateOrderRefund(refundRaram);//更新订单退款信息
-                                }
+    /**
+     * 微信国际支付微信查询订单api
+     * @param map
+     */
+    private void  wxGlobalRefundQuery(Map map){
+        logger.info(">>>>>>>>>>>>>>>>>>>>wxGlobalRefundQuery 微信国际退款查询接口调用");
+        String out_trade_no = MapUtils.getString("merch_order_sn", map);
+        String order_id = MapUtils.getString("order_id", map);
+        Map orderRaram = new HashMap();
+        WechatGlobalRefundQueryResult result = WechatGlobalUtil.wxRefundquery(out_trade_no);
+        if (result.getReturn_code().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+            if (result.getResult_code().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                Map refundRaram = new HashMap();
+                int msgCount = Integer.parseInt(result.getRefund_count());
+                for (int i = 0; i < msgCount; i++) {
+                    //微信部分退款时返回的多条退款信息数据解析
+                    WechatRefundQueryResult querySuccessResponseDto = ReaderXmlForDOM4J.parse(result.getXmlStr(), i);
+                    if (result.getReturn_code().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                        if (result.getResult_code().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                            //微信部分退款时返回的多条退款信息数据
+                            result.setRefund_fee(querySuccessResponseDto.getRefund_fee());
+                            result.setOut_refund_no(querySuccessResponseDto.getOut_refund_no());
+                            result.setRefund_id(querySuccessResponseDto.getRefund_id());
+                            result.setRefund_channel(querySuccessResponseDto.getRefund_channel());
+                            result.setRefund_status(querySuccessResponseDto.getRefund_status());
+                            result.setRefund_account(querySuccessResponseDto.getRefund_account());
+                            result.setRefund_recv_accout(querySuccessResponseDto.getRefund_recv_accout());
+                            result.setRefund_success_time(querySuccessResponseDto.getRefund_success_time());
+
+                            refundRaram.put("refundTime", DateUtils.strToDate(result.getRefund_success_time()));
+                            refundRaram.put("outRefundNo", result.getOut_refund_no());
+                            refundRaram.put("refundId", result.getRefund_id());
+                            refundRaram.put("refundMoney",
+                                    BigDecimal.valueOf(Long.valueOf(result.getRefund_fee()))
+                                            .divide(Constant.ONE_HUNDRED));//退款金额
+                            if(org.apache.commons.lang3.StringUtils.isNotEmpty(result.getTotal_fee())) {
+                                refundRaram.put("totalFee", BigDecimal.valueOf(Long.valueOf(result.getTotal_fee()))
+                                        .divide(Constant.ONE_HUNDRED));//标价金额
+                            }
+                            refundRaram.put("feeType", result.getFee_type());//标价币种
+                            if(org.apache.commons.lang3.StringUtils.isNotEmpty(result.getCash_fee())) {
+                                refundRaram.put("cashFee", BigDecimal.valueOf(Long.valueOf(result.getCash_fee()))
+                                        .divide(Constant.ONE_HUNDRED));//用户支付金额
+                            }
+                            refundRaram.put("cashFeeType", result.getCash_fee_type());//用户支付金额币种
+                            refundRaram.put("rate", result.getRate());//汇率
+                            if (result.getRefund_status().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                                refundRaram.put("refundStatus", Dict.RefundStatus.item_2.getItem());
+                                refundRaram.put("wechat_refund_status_des", "退款成功");
+                                orderRaram.put("payStatus", Dict.payStatus.item_4.getItem());
+                            } else if (result.getRefund_status().equalsIgnoreCase("PROCESSING")) {
+                                refundRaram.put("refundStatus", Dict.RefundStatus.item_5.getItem());
+                                refundRaram.put("wechat_refund_status_des", "退款处理中");
+                                orderRaram.put("payStatus", Dict.payStatus.item_3.getItem());
+                            } else if (result.getRefund_status().equalsIgnoreCase("REFUNDCLOSE")) {
+                                refundRaram.put("refundStatus", Dict.RefundStatus.item_4.getItem());
+                                refundRaram.put("wechat_refund_status_des", "退款关闭");
+                                orderRaram.put("payStatus", Dict.payStatus.item_5.getItem());
+                            } else if (result.getRefund_status().equalsIgnoreCase("CHANGE")) {
+                                refundRaram.put("refundStatus", Dict.RefundStatus.item_4.getItem());
+                                refundRaram.put("wechat_refund_status_des", "退款异常");
+                                orderRaram.put("payStatus", Dict.payStatus.item_6.getItem());
                             }
+                            refundRaram.put("refundRecvAccout", result.getRefund_recv_accout());
+                            refundRaram.put("orderRefundId", result.getOut_refund_no());
+                            qzOrderMapper.updateOrderRefund(refundRaram);//更新订单退款信息
                         }
-
-                        Map orderRaram = new HashMap();
-                        orderRaram.put("payStatus", 4);
-                        orderRaram.put("orderStatus", 401);
-                        orderRaram.put("orderId", order_id);
-                        orderRaram.put("payTransactionId", result.getTransaction_id());
-                        qzOrderMapper.updateOrderInfo(orderRaram);
-                    } else {
-                        logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate 微信退款查询接口返回失败信息:code 【" + result.getErr_code() +
-                                    "】,des【" + result.getErr_code_des() + "】");
                     }
-                } else {
-                    logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate 微信退款查询接口调用失败: " + result.getReturn_msg());
                 }
+                orderRaram.put("orderStatus", Dict.orderStatus.item_401.getItem());
+                orderRaram.put("orderId", order_id);
+                orderRaram.put("payTransactionId", result.getTransaction_id());
+                qzOrderMapper.updateOrderInfo(orderRaram);
+            } else {
+                logger.info(">>>>>>>>>>>>>>>>>>>>wxGlobalRefundQuery 微信国际退款查询接口返回失败信息:code 【" + result.getErr_code() +
+                        "】,des【" + result.getErr_code_des() + "】");
             }
         } else {
-            logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate 未查到退款数据 ");
+            logger.info(">>>>>>>>>>>>>>>>>>>>wxGlobalRefundQuery 微信国际退款查询接口调用失败: " + result.getReturn_msg());
         }
-        logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate is end ");
     }
 
 
@@ -310,50 +411,16 @@ public class QzOrderService {
         List<Map> orderList = qzOrderMapper.queryPayingOrderList();
         if (null != orderList && orderList.size() > 0) {
             for (Map map : orderList) {
-                String out_trade_no = MapUtils.getString("merch_order_sn", map);
+                String pay_flag = MapUtils.getString("pay_flag", map);
                 String orderId = MapUtils.getString("order_id", map);
-                String add_time = MapUtils.getString("add_time", map);
-                Integer number = MapUtils.getInteger("number", map);
-                Integer stock_num = MapUtils.getInteger("stock_num", map);
-                Long storeRelaId = MapUtils.getLong("storeRelaId", map);
-
-                Date addTime = DateUtils.strToDate(add_time);
-                Date nowDate = new Date();
-                WechatRefundApiResult result = WechatUtil.wxOrderQuery(out_trade_no);
-                if (result.getReturn_code().equalsIgnoreCase("SUCCESS")) {
-                    if (result.getResult_code().equalsIgnoreCase("SUCCESS") &&
-                        result.getTrade_state().equalsIgnoreCase("SUCCESS")) {
-                        Date successTime = DateUtils.convertStringToDate(result.getTime_end(),
-                                                                         DateUtils.DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS);
-                        Map orderRaram = new HashMap();
-                        orderRaram.put("payStatus", 2);//已支付
-                        orderRaram.put("orderStatus", 201);//已支付
-                        orderRaram.put("payTransactionId", result.getTransaction_id());
-                        orderRaram.put("payTime", successTime);
-                        orderRaram.put("orderId", orderId);
-                        qzOrderMapper.updateOrderInfo(orderRaram);
-                    } else if (result.getResult_code().equalsIgnoreCase("SUCCESS") &&
-                               result.getTrade_state().equalsIgnoreCase("NOTPAY")) {//订单未支付
-                        Map orderRaram = new HashMap();
-                        if (getDateBetween(addTime, nowDate) >= 15) {//订单下单时间超过15分钟直接取消订单
-                            orderRaram.put("payStatus", 0);//支付状态未支付
-                            orderRaram.put("orderStatus", 101);//订单状态已取消
-                            Map param = new HashMap();
-                            param.put("id", storeRelaId);
-                            param.put("stock_num", stock_num + number);
-                            qzOrderMapper.updateStockNum(param);
-                        } else {
-                            orderRaram.put("payStatus", 0);//支付状态未支付
-                            orderRaram.put("orderStatus", 0);//订单状态未支付
-                        }
-                        orderRaram.put("orderId", orderId);
-                        qzOrderMapper.updateOrderInfo(orderRaram);
-                    } else {
-                        logger.info(">>>>>>>>>>>>>>>>>>>>orderQueryUpdate 微信查询接口返回失败信息:code 【" + result.getErr_code() +
-                                    "】,des【" + result.getErr_code_des() + "】");
+                if(org.apache.commons.lang.StringUtils.isNotEmpty(pay_flag)) {
+                    if (pay_flag.equalsIgnoreCase("wxglobalpay")) {//微信国际支付
+                        wxGlobalOrderQuery(map);
+                    } else {//微信支付、平安支付、线下扫码支付
+                        wxOrderQuery(map);
                     }
-                } else {
-                    logger.info(">>>>>>>>>>>>>>>>>>>>orderQueryUpdate 微信查询接口调用失败: " + result.getReturn_msg());
+                }else{
+                    logger.info(">>>>>>>>>>>>>>>>>>>>refundUpdate 订单编号【"+orderId+"】的支付方式不能为空! ");
                 }
             }
         } else {
@@ -362,6 +429,179 @@ public class QzOrderService {
         logger.info(">>>>>>>>>>>>>>>>>>>>orderQueryUpdate is end ");
     }
 
+    /**
+     * 微信查询接口
+     * @param map
+     */
+    private void wxOrderQuery(Map map){
+        logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口调用");
+        String out_trade_no = MapUtils.getString("merch_order_sn", map);
+        String orderId = MapUtils.getString("order_id", map);
+        String add_time = MapUtils.getString("add_time", map);
+        Integer number = MapUtils.getInteger("number", map);
+        Integer stock_num = MapUtils.getInteger("stock_num", map);
+        Long storeRelaId = MapUtils.getLong("storeRelaId", map);
+        Date addTime = DateUtils.strToDate(add_time);
+        Date nowDate = new Date();
+
+        WechatRefundApiResult result = WechatUtil.wxOrderQuery(out_trade_no);
+        if (result.getReturn_code().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+            if (result.getResult_code().equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode()) ){
+                if(result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_SUCCESS.getItem())) {
+                    Date successTime = DateUtils.convertStringToDate(result.getTime_end(),
+                            DateUtils.DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS);
+                    Map orderRaram = new HashMap();
+                    orderRaram.put("payStatus", Dict.payStatus.item_2.getItem());//已支付
+                    orderRaram.put("orderStatus", Dict.orderStatus.item_201.getItem());//已支付
+                    orderRaram.put("payTransactionId", result.getTransaction_id());
+                    orderRaram.put("payTime", successTime);
+                    orderRaram.put("orderId", orderId);
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_NOTPAY.getItem())) {//订单未支付
+                    Map orderRaram = new HashMap();
+                    if (getDateBetween(addTime, nowDate) >= 15) {//订单下单时间超过15分钟直接取消订单
+                        Map param = new HashMap();
+                        param.put("id", storeRelaId);
+                        param.put("stock_num", stock_num + number);
+                        qzOrderMapper.updateStockNum(param);//库存还原
+                        orderRaram.put("payStatus", Dict.payStatus.item_0.getItem());//支付状态未支付
+                        orderRaram.put("orderStatus", Dict.orderStatus.item_101.getItem());//订单状态已取消
+                    } else {
+                        orderRaram.put("payStatus", Dict.payStatus.item_0.getItem());//支付状态未支付
+                        orderRaram.put("orderStatus", Dict.orderStatus.item_0.getItem());//订单状态未支付
+                    }
+                    orderRaram.put("orderId", orderId);
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_CLOSED.getItem())) {
+                    Map orderRaram = new HashMap();
+                    orderRaram.put("payStatus", Dict.payStatus.item_7.getItem());
+                    orderRaram.put("orderStatus", Dict.orderStatus.item_500.getItem());
+                    orderRaram.put("orderId", orderId);
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                    Map param = new HashMap();
+                    param.put("id", storeRelaId);
+                    param.put("stock_num", stock_num + number);
+                    qzOrderMapper.updateStockNum(param);//库存还原
+                    logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口返回信息:state 【" + result.getTrade_state() +
+                            "】,des【" + result.getTrade_state_desc() + "】");
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_PAYERROR.getItem())) {
+                    Map orderRaram = new HashMap();
+                    orderRaram.put("payStatus", Dict.payStatus.item_8.getItem());
+                    orderRaram.put("orderStatus", Dict.orderStatus.item_501.getItem());
+                    orderRaram.put("orderId", orderId);
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                    logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口返回信息:state 【" + result.getTrade_state() +
+                            "】,des【" + result.getTrade_state_desc() + "】");
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_USERPAYING.getItem())) {
+                    Map orderRaram = new HashMap();
+                    orderRaram.put("payStatus", Dict.payStatus.item_1.getItem());
+                    orderRaram.put("orderStatus", Dict.orderStatus.item_100.getItem());
+                    orderRaram.put("orderId", orderId);
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                    logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口返回信息:state 【" + result.getTrade_state() +
+                            "】,des【" + result.getTrade_state_desc() + "】");
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_REVOKED.getItem())) {
+                    logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口返回信息:state 【" + result.getTrade_state() +
+                            "】,des【" + result.getTrade_state_desc() + "】");
+                }
+            }else {
+                logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口返回失败信息:code 【" + result.getErr_code() +
+                        "】,des【" + result.getErr_code_des() + "】");
+            }
+        } else {
+            logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口调用失败: " + result.getReturn_msg());
+        }
+    }
+
+    /**
+     * 微信国际查询接口
+     * @param map
+     */
+    private void wxGlobalOrderQuery(Map map){
+        logger.info(">>>>>>>>>>>>>>>>>>>>wxGlobalOrderQuery 微信查询接口调用");
+        String out_trade_no = MapUtils.getString("merch_order_sn", map);
+        String orderId = MapUtils.getString("order_id", map);
+        String add_time = MapUtils.getString("add_time", map);
+        Integer number = MapUtils.getInteger("number", map);
+        Integer stock_num = MapUtils.getInteger("stock_num", map);
+        Long storeRelaId = MapUtils.getLong("storeRelaId", map);
+        Date addTime = DateUtils.strToDate(add_time);
+        Date nowDate = new Date();
+
+        WechatGlobalQueryApiResult result = WechatGlobalUtil.wxOrderQuery(out_trade_no);
+        if (result.getReturn_code().equalsIgnoreCase(WechatGlobalUtil.WXTradeState.SUCCESS.getCode())) {
+            if (result.getResult_code().equalsIgnoreCase(WechatGlobalUtil.WXTradeState.SUCCESS.getCode())) {
+                if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_SUCCESS.getItem())) {
+                    Date successTime = DateUtils.convertStringToDate(result.getTime_end(),
+                            DateUtils.DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS);
+                    Map orderRaram = new HashMap();
+                    orderRaram.put("payStatus", Dict.payStatus.item_2.getItem());//已支付
+                    orderRaram.put("orderStatus", Dict.orderStatus.item_201.getItem());//已支付
+                    orderRaram.put("payTransactionId", result.getTransaction_id());
+                    orderRaram.put("payTime", successTime);
+                    orderRaram.put("orderId", orderId);
+
+                    orderRaram.put("totalFee", result.getTotal_fee());//标价金额
+                    orderRaram.put("feeType", result.getFee_type());//标价币种
+                    orderRaram.put("cashFee", result.getCash_fee());//用户支付金额
+                    orderRaram.put("cashFeeType", result.getCash_fee_type());//用户支付金额币种
+                    orderRaram.put("rate", result.getRate());//汇率
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_NOTPAY.getItem())) {//订单未支付
+                    Map orderRaram = new HashMap();
+                    if (getDateBetween(addTime, nowDate) >= 15) {//订单下单时间超过15分钟直接取消订单
+                        orderRaram.put("payStatus", Dict.payStatus.item_0.getItem());//支付状态未支付
+                        orderRaram.put("orderStatus", Dict.orderStatus.item_101.getItem());//订单状态已取消
+                        Map param = new HashMap();
+                        param.put("id", storeRelaId);
+                        param.put("stock_num", stock_num + number);
+                        qzOrderMapper.updateStockNum(param);
+                    } else {
+                        orderRaram.put("payStatus", Dict.payStatus.item_0.getItem());//支付状态未支付
+                        orderRaram.put("orderStatus", Dict.orderStatus.item_0.getItem());//订单状态未支付
+                    }
+                    orderRaram.put("orderId", orderId);
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_PAYERROR.getItem())) {
+                    Map orderRaram = new HashMap();
+                    orderRaram.put("orderStatus", Dict.orderStatus.item_501.getItem());
+                    orderRaram.put("payStatus", Dict.payStatus.item_8.getItem());
+                    orderRaram.put("orderId", orderId);
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                    logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口返回信息:state 【" + result.getTrade_state() +
+                            "】,des【" + Dict.tradeState.item_PAYERROR.getItemName() + "】");
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_CLOSED.getItem())) {
+                    Map orderRaram = new HashMap();
+                    orderRaram.put("payStatus", Dict.payStatus.item_7.getItem());
+                    orderRaram.put("orderStatus", Dict.orderStatus.item_500.getItem());
+                    orderRaram.put("orderId", orderId);
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                    Map param = new HashMap();
+                    param.put("id", storeRelaId);
+                    param.put("stock_num", stock_num + number);
+                    qzOrderMapper.updateStockNum(param);//库存还原
+                    logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口返回信息:state 【" + result.getTrade_state() +
+                            "】,des【" + Dict.tradeState.item_CLOSED.getItemName() + "】");
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_USERPAYING.getItem())) {
+                    Map orderRaram = new HashMap();
+                    orderRaram.put("payStatus", Dict.payStatus.item_1.getItem());
+                    orderRaram.put("orderStatus", Dict.orderStatus.item_100.getItem());
+                    orderRaram.put("orderId", orderId);
+                    qzOrderMapper.updateOrderInfo(orderRaram);
+                    logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口返回信息:state 【" + result.getTrade_state() +
+                            "】,des【" + Dict.tradeState.item_USERPAYING.getItemName() + "】");
+                } else if (result.getTrade_state().equalsIgnoreCase(Dict.tradeState.item_REVOKED.getItem())) {
+                    logger.info(">>>>>>>>>>>>>>>>>>>>wxOrderQuery 微信查询接口返回信息:state 【" + result.getTrade_state() +
+                            "】,des【" + Dict.tradeState.item_REVOKED.getItemName() + "】");
+                }
+            }else {
+                logger.info(">>>>>>>>>>>>>>>>>>>>wxGlobalOrderQuery 微信查询接口返回失败信息:code 【" + result.getErr_code() +
+                        "】,des【" + result.getErr_code_des() + "】");
+            }
+        } else {
+            logger.info(">>>>>>>>>>>>>>>>>>>>wxGlobalOrderQuery 微信查询接口调用失败: " + result.getReturn_msg());
+        }
+    }
 
     /**
      * 查询付款码支付记录的支付状态
@@ -382,7 +622,7 @@ public class QzOrderService {
                 Integer id = MapUtils.getInteger("id", map);
 
                 WechatRefundApiResult result = WechatUtil.wxOrderQuery(out_trade_no_wx);
-                if ("SUCCESS".equals(result.getReturn_code()) && "SUCCESS".equals(result.getResult_code())) {
+                if (WechatUtil.WXTradeState.SUCCESS.getCode().equals(result.getReturn_code()) && WechatUtil.WXTradeState.SUCCESS.getCode().equals(result.getResult_code())) {
                     Map recordRaram = new HashMap();
                     recordRaram.put("id", id);
                     recordRaram.put("trade_state", result.getTrade_state());
@@ -468,11 +708,14 @@ public class QzOrderService {
         logger.info(">>>>>>>>>>>>>>>>>>>>查询付款码支付记录的支付状态 结束<<<<<<<<<<<<<<<<<<<<<<<");
     }
 
+    /**
+     * 商品发货后7天自动确认收货
+     */
     @Transactional
     public void shipmentOrderAutoTakeGoods() {
         logger.info(">>>>>>>>>>>>>>>>>>>>shipmentOrderAutoTakeGoods is start ");
         logger.info(">>>>>>>>>>>>>>>>>>>>商品发货后7天自动确认收货 ");
-        // 查询门店业务发货后7天的订单
+        // 查询门店业务发货后7天的订单,门店业务根据清关完成时间后7天
         List<Map> shipmentOrderList = qzOrderMapper.queryShipmentOrderList();
         if (null != shipmentOrderList && shipmentOrderList.size() > 0) {
             for (Map map : shipmentOrderList) {
@@ -481,7 +724,7 @@ public class QzOrderService {
                 qzOrderMapper.updateShipmentOrder(orderMap);
             }
         }
-        //查询保税备货发货后7天的订单
+        //查询保税备货发货后7天的订单,保税备货根据发货完成时间后7天
         List<Map> shipmentBondedOrderList = qzOrderMapper.queryShipmentBondedOrderList();
         if (null != shipmentBondedOrderList && shipmentBondedOrderList.size() > 0) {
             for (Map map : shipmentBondedOrderList) {
@@ -493,6 +736,9 @@ public class QzOrderService {
         logger.info(">>>>>>>>>>>>>>>>>>>>shipmentOrderAutoTakeGoods is end ");
     }
 
+    /**
+     * 确认收货后30天自动确认好评
+     */
     @Transactional
     public void receiptOrderAutoComment() {
         logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderAutoComment is start ");

+ 15 - 2
kmall-schedule/src/main/resources/mybatis/mapper/QzOrderMapper.xml

@@ -48,7 +48,8 @@
 
 
     <select id="queryRefundOrderList" resultType="map">
-        select a.pay_transaction_id,a.merch_order_sn,a.order_sn,a.order_status,a.pay_status,f.out_refund_no,f.refund_id,f.order_id,f.id 'orderRefundId',a.is_onffline_order,a.order_sn_wx
+        select a.pay_transaction_id,a.merch_order_sn,a.order_sn,a.order_status,a.pay_status,f.out_refund_no,f.refund_id,f.order_id,f.id 'orderRefundId',a.is_onffline_order,
+        a.order_sn_wx,a.pay_flag
         from mall_order a
         inner join mall_order_refund f on a.id = f.order_id	where (f.out_refund_no is null or f.refund_id is null
         or f.refund_time is null or f.wechat_refund_status_des is null) and a.order_status = '401' and f.refund_status
@@ -57,7 +58,7 @@
 
     <select id="queryPayingOrderList" resultType="map">
 		select a.pay_transaction_id,a.order_sn,a.order_status,a.pay_status,a.id 'order_id',a.merch_order_sn,date_format(a.add_time,'%Y-%m-%d %H:%i:%s') as add_time,
-        b.product_id,b.number,c.stock_num,c.id as storeRelaId
+        b.product_id,b.number,c.stock_num,c.id as storeRelaId,a.pay_flag
         from mall_order a
         LEFT JOIN mall_order_goods b ON a.id = b.order_id
         LEFT JOIN mall_product_store_rela c ON b.product_id = c.product_id
@@ -75,6 +76,12 @@
             <if test="orderSnWx != null">a.order_sn_wx = #{orderSnWx},</if>
             <if test="payTransactionId != null">a.pay_transaction_id = #{payTransactionId},</if>
             <if test="payTime != null">a.pay_time = #{payTime},</if>
+
+            <if test="totalFee != null">a.total_fee = #{totalFee},</if>
+            <if test="feeType != null">a.fee_type = #{feeType},</if>
+            <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
+            <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
+            <if test="rate != null">a.rate = #{rate},</if>
         </set>
         WHERE 1 = 1
         AND a.id = #{orderId}
@@ -89,6 +96,12 @@
             <if test="refundRecvAccout != null">a.refund_recv_accout = #{refundRecvAccout},</if>
             <if test="refundTime != null">a.refund_time = #{refundTime},</if>
             <if test="wechat_refund_status_des != null">a.wechat_refund_status_des = #{wechat_refund_status_des},</if>
+
+            <if test="totalFee != null">a.total_fee = #{totalFee},</if>
+            <if test="feeType != null">a.fee_type = #{feeType},</if>
+            <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
+            <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
+            <if test="rate != null">a.rate = #{rate},</if>
         </set>
         WHERE 1 = 1
         AND a.out_refund_no = #{orderRefundId}

+ 1 - 1
wx-mall/pages/goods/goods.wxml

@@ -29,7 +29,7 @@
       </view>
       <view class="nav-item">
         <text class="nav-text">购物车</text>
-        <view class="nav-cell" bindtap="switchNav" data-name="cart">
+        <view class="nav-cell" bindtap="openCartPage" data-name="cart">
           <image src="../../static/images/nav-4.png"></image>
         </view>
       </view>

+ 15 - 0
wx-mall/pages/shopping/address/address.js

@@ -78,6 +78,21 @@ Page({
       addressVo: selectAddressVo[0]
     })
 
+    util.request(api.AddressSave, {
+      id: selectAddressVo[0].id,
+      userName: selectAddressVo[0].userName,
+      telNumber: selectAddressVo[0].telNumber,
+      provinceName: selectAddressVo[0].provinceName,
+      cityName: selectAddressVo[0].cityName,
+      countyName: selectAddressVo[0].countyName,
+      detailInfo: selectAddressVo[0].detailInfo,
+      isDefault: true,
+      latitude: selectAddressVo[0].latitude,
+      longitude: selectAddressVo[0].longitude,
+    }, 'POST').then(function (res) {
+      
+    });
+
     wx.navigateBack();
   },
   getWtAddress() {

+ 1 - 1
wx-mall/pages/ucenter/collect/collect.wxml

@@ -4,7 +4,7 @@
       <image class="img" src="{{item.list_pic_url}}"></image>
       <view class="info">
         <view class="name">{{item.name}}</view>
-        <view class="subtitle">{{item.goods_brief}}</view>
+        <view class="subtitle" wx:if="{{item.goods_brief}}">{{item.goods_brief}}</view>
         <view class="price">¥{{item.retail_price}}</view>
       </view>
     </view>