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

支付方式列表接口开发

lilinhui 5 месяцев назад
Родитель
Сommit
a099c31dd3
100 измененных файлов с 13056 добавлено и 2126 удалено
  1. 6 5
      pom.xml
  2. 4 5
      poyi-app/src/main/java/com/tzy/config/ConnectionPoolWarmer.java
  3. 6 1
      poyi-app/src/main/java/com/tzy/controller/group/GroupLocalController.java
  4. 0 66
      poyi-app/src/main/java/com/tzy/listener/mq/AppUserBrowseRecordConsumer.java
  5. 0 39
      poyi-app/src/main/java/com/tzy/listener/mq/CommunityNotifyConsumer.java
  6. 0 46
      poyi-app/src/main/java/com/tzy/listener/mq/GiftCardConsumer.java
  7. 0 37
      poyi-app/src/main/java/com/tzy/listener/mq/GoodsSyncConsumer.java
  8. 0 53
      poyi-app/src/main/java/com/tzy/listener/mq/GoodsSyncEsConsumer.java
  9. 0 594
      poyi-app/src/main/java/com/tzy/listener/mq/GroupFullConsumer.java
  10. 0 61
      poyi-app/src/main/java/com/tzy/listener/mq/GroupOrderActConsumer.java
  11. 0 49
      poyi-app/src/main/java/com/tzy/listener/mq/GroupSortConsumer.java
  12. 0 34
      poyi-app/src/main/java/com/tzy/listener/mq/InitBrandMemberConsumer.java
  13. 0 76
      poyi-app/src/main/java/com/tzy/listener/mq/InitUserGiftCardConsumer.java
  14. 0 32
      poyi-app/src/main/java/com/tzy/listener/mq/InitUserMemberConsumer.java
  15. 0 37
      poyi-app/src/main/java/com/tzy/listener/mq/LuckyBagConsumer.java
  16. 0 104
      poyi-app/src/main/java/com/tzy/listener/mq/MerchantNotifyConsumer.java
  17. 0 64
      poyi-app/src/main/java/com/tzy/listener/mq/OrderAftAllocateConsumer.java
  18. 0 113
      poyi-app/src/main/java/com/tzy/listener/mq/OrderExpiredConsumer.java
  19. 0 96
      poyi-app/src/main/java/com/tzy/listener/mq/OrderOverConsumer.java
  20. 0 94
      poyi-app/src/main/java/com/tzy/listener/mq/OrderPayConsumer.java
  21. 0 99
      poyi-app/src/main/java/com/tzy/listener/mq/OrderSuccessConsumer.java
  22. 0 45
      poyi-app/src/main/java/com/tzy/listener/mq/PayPreCallBackConsumer.java
  23. 0 34
      poyi-app/src/main/java/com/tzy/listener/mq/SuperLuckyBagConsumer.java
  24. 0 50
      poyi-app/src/main/java/com/tzy/listener/mq/TestMqConsumer.java
  25. 0 83
      poyi-app/src/main/java/com/tzy/listener/mq/UserInviteCodeConsumer.java
  26. 0 49
      poyi-app/src/main/java/com/tzy/listener/mq/UserListActConsumer.java
  27. 0 49
      poyi-app/src/main/java/com/tzy/listener/mq/UserPointConsumer.java
  28. 0 51
      poyi-app/src/main/java/com/tzy/listener/mq/UserPointJsonConsumer.java
  29. 0 54
      poyi-app/src/main/java/com/tzy/listener/mq/UserWinCardConsumer.java
  30. 1 1
      poyi-app/src/main/resources/application-druid.yml
  31. 210 1
      poyi-app/src/main/resources/application.yml
  32. 3 3
      poyi-pojo/pom.xml
  33. 2 0
      tzy-common/pom.xml
  34. 58 1
      tzy-framework/pom.xml
  35. 30 0
      tzy-framework/src/main/java/com/tzy/framework/pay/Entity/MktInfoEntity.java
  36. 25 0
      tzy-framework/src/main/java/com/tzy/framework/pay/Entity/MktRefundInfoEntity.java
  37. 133 0
      tzy-framework/src/main/java/com/tzy/framework/pay/Entity/PostMasterEntity.java
  38. 29 0
      tzy-framework/src/main/java/com/tzy/framework/pay/Entity/ResultMasterEntity.java
  39. 31 0
      tzy-framework/src/main/java/com/tzy/framework/pay/Entity/RiskInfoEntity.java
  40. 29 0
      tzy-framework/src/main/java/com/tzy/framework/pay/Entity/SharingDetailsEntity.java
  41. 39 0
      tzy-framework/src/main/java/com/tzy/framework/pay/Entity/SharingInfoEntity.java
  42. 25 0
      tzy-framework/src/main/java/com/tzy/framework/pay/Entity/SharingRefundInfoEntity.java
  43. 246 0
      tzy-framework/src/main/java/com/tzy/framework/pay/Entity/TerminalInfoEntity.java
  44. 55 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/AliPayConfig.java
  45. 55 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/AliPaySpareConfig.java
  46. 51 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/BaoFooPayConfig.java
  47. 42 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/BaofooRechargePayConfig.java
  48. 89 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/BfPayConfig.java
  49. 39 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/HfPayConfig.java
  50. 54 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/HmPayConfig.java
  51. 170 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/PayConfig.java
  52. 77 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/QmH5PayConfig.java
  53. 76 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/QmPay1Config.java
  54. 76 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/QmPay2Config.java
  55. 94 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/QmPayConfig.java
  56. 35 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/QmPayZgConfig.java
  57. 82 0
      tzy-framework/src/main/java/com/tzy/framework/pay/config/WxPayAppConfig.java
  58. 24 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/AlipayData.java
  59. 110 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/BankInfo.java
  60. 40 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/CheckPaymentInfoDto.java
  61. 120 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/PayConstants.java
  62. 93 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/PaymentInfoResponseDto.java
  63. 96 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/PaymentRequestDto.java
  64. 35 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/PaymentUserInfo.java
  65. 41 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/PrePayRespDTO.java
  66. 25 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/QmZgOrderInfoDto.java
  67. 54 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/RechargeUserInfoDto.java
  68. 82 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/RefundRequestDto.java
  69. 80 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/ResourceData.java
  70. 56 0
      tzy-framework/src/main/java/com/tzy/framework/pay/dto/ResultMap.java
  71. 56 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/AlipayService.java
  72. 31 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/BankService.java
  73. 40 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/BaoFooBankPayService.java
  74. 39 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/BaoFooPayService.java
  75. 17 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/BaofooRechargePayService.java
  76. 31 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/BfPayService.java
  77. 64 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/BofooAgreementService.java
  78. 27 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/HfPayService.java
  79. 36 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/HmPayService.java
  80. 153 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/PaymentBaseService.java
  81. 76 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/PaymentService.java
  82. 31 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/QmH5PayService.java
  83. 12 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/QmPayAssetService.java
  84. 45 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/QmPayService.java
  85. 19 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/Qme1PayService.java
  86. 86 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/WxPayService.java
  87. 803 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/AlipayServiceImpl.java
  88. 53 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BankServiceImpl.java
  89. 492 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BaoFooBankPayServiceImpl.java
  90. 496 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BaoFooPayServiceImpl.java
  91. 1256 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BaofooRechargePayServiceImpl.java
  92. 779 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BfPayServiceImpl.java
  93. 829 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BofooAgreementServiceImpl.java
  94. 417 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/HfPayServiceImpl.java
  95. 967 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/HmPayServiceImpl.java
  96. 946 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/PaymentServiceImpl.java
  97. 657 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/QmH5PayServiceImpl.java
  98. 174 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/QmPayAssetServiceImpl.java
  99. 1342 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/QmPayServiceImpl.java
  100. 354 0
      tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/Qme1PayServiceImpl.java

+ 6 - 5
pom.xml

@@ -20,12 +20,12 @@
         <bitwalker.version>1.19</bitwalker.version>
         <kaptcha.version>2.3.2</kaptcha.version>
         <swagger.version>2.9.2</swagger.version>
-        <pagehelper.boot.version>1.3.0</pagehelper.boot.version>
+        <pagehelper.boot.version>1.3.1</pagehelper.boot.version>
         <fastjson.version>2.0.10</fastjson.version>
         <oshi.version>5.2.5</oshi.version>
         <jna.version>5.5.0</jna.version>
-        <commons.io.version>2.5</commons.io.version>
-        <commons.fileupload.version>1.3.3</commons.fileupload.version>
+        <commons.io.version>2.14.0</commons.io.version>
+        <commons.fileupload.version>1.6.0</commons.fileupload.version>
         <poi.version>3.17</poi.version>
         <velocity.version>1.7</velocity.version>
         <skipTests>true</skipTests>
@@ -38,14 +38,14 @@
             <dependency>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-dependencies</artifactId>
-                <version>2.2.5.RELEASE</version>
+                <version>2.2.13.RELEASE</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
             <dependency>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-starter-test</artifactId>
-                <version>2.1.17.RELEASE</version>
+                <version>2.2.13.RELEASE</version>
                 <scope>test</scope>
             </dependency>
             <!--阿里数据库连接池 -->
@@ -165,6 +165,7 @@
         <module>tzy-sportcard</module>
         <module>poyi-service</module>
         <module>poyi-app</module>
+        <module>poyee-order</module>
     </modules>
     <packaging>pom</packaging>
 

+ 4 - 5
poyi-app/src/main/java/com/tzy/config/ConnectionPoolWarmer.java

@@ -1,7 +1,7 @@
 package com.tzy.config;
 
 import com.tzy.elasticsearch.dto.CardGroupInfoGoodsDTO;
-import com.tzy.elasticsearch.service.CardGroupInfoGoodsService;
+
 import com.tzy.framework.util.RedisTools;
 import com.tzy.sportcard.api.dto.group.SimpleGroupDTO;
 import com.tzy.sportcard.api.service.GroupApiService;
@@ -22,14 +22,13 @@ import java.sql.Statement;
 import java.util.Arrays;
 import java.util.List;
 
-@Component
+//@Component
 @Slf4j
 public class ConnectionPoolWarmer implements ApplicationRunner {
 
     @Resource
     private DataSource dataSource;
-    @Resource
-    private CardGroupInfoGoodsService cardGroupInfoGoodsService;
+
     @Autowired
     @Qualifier("threadPoolTaskExecutor")
     private ThreadPoolTaskExecutor pools;
@@ -87,7 +86,7 @@ public class ConnectionPoolWarmer implements ApplicationRunner {
             CardGroupInfoGoodsDTO query = new CardGroupInfoGoodsDTO();
             query.setStatus("201");
             query.setRows(100);
-            cardGroupInfoGoodsService.page(query);
+//            cardGroupInfoGoodsService.page(query);
         } catch (Exception ignored) {
         }
     }

+ 6 - 1
poyi-app/src/main/java/com/tzy/controller/group/GroupLocalController.java

@@ -188,7 +188,12 @@ public class GroupLocalController {
         }
         return ResultDTO.buildSuccessResult(list);
     }
-
+    @ApiOperation("竞价下单")
+    @PostMapping("/order/submit")
+    public ResultDTO orderSubmit(@RequestBody AuctionOrderDTO auctionOrderDTO){
+        OrderSubmitDTO orderSubmitDTO = auctionOrderService.generateOrder(auctionOrderDTO);
+        return ResultDTO.buildSuccessResult(orderSubmitDTO);
+    }
     @ApiOperation("竞价订单回调")
     @PostMapping("/order/callback")
     public ResultDTO orderCallBack(@RequestBody AuctionOrderDTO auctionOrderDTO){

+ 0 - 66
poyi-app/src/main/java/com/tzy/listener/mq/AppUserBrowseRecordConsumer.java

@@ -1,66 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.browse.domain.AppUserBrowseRecord;
-import com.tzy.browse.mapper.AppUserBrowseRecordMapper;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.utils.bean.JSONTools;
-import com.tzy.framework.util.RedisUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-@Slf4j
-@Component
-public class AppUserBrowseRecordConsumer {
-    @Resource
-    private AppUserBrowseRecordMapper appUserBrowseRecordMapper;
-    @Resource
-    private RedisUtils redisUtils;
-    @Resource
-    private RedisTemplate<String, String> redisTemplate;
-
-    @RabbitHandler
-    //@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_USER_BROWSE_RECORD))
-    public void addUserBrowseRecord(String param, Channel channel, Message message) throws IOException {
-        log.debug("入库用户浏览记录:{}", param);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-        /*try{
-            List<AppUserBrowseRecord> records = JSONTools.parseObjectList(param, AppUserBrowseRecord.class);
-            records.forEach(record ->{
-                String key = "app_user_browse_" + record.getUserId();
-                Double timestamp = redisTemplate.opsForZSet().score(key, param);
-                record.setBrowseTime(new Date(timestamp.longValue()));
-                record.setBrowseDate(new Date(timestamp.longValue()));
-            });
-            appUserBrowseRecordMapper.batchSave(records);
-            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-            // 处理完要删除这些浏览记录
-            Set<Long> userIds = redisUtils.sGet("app_user_set").stream()
-                    .map(obj -> Long.parseLong(obj.toString()))
-                    .collect(Collectors.toSet());
-            userIds.forEach(userId ->{
-                // 用户浏览记录存储 Key
-                String historyKey = "app_user_browse_history_" + userId;
-                redisUtils.del(historyKey);
-            });
-            redisUtils.del("app_user_set");
-            redisUtils.set("browse_queue_count", 0); // 全局计数器归零
-        }catch (Exception e){
-            log.error("入库用户浏览记录异常:{}", param, e);
-            channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
-        }*/
-
-    }
-}

+ 0 - 39
poyi-app/src/main/java/com/tzy/listener/mq/CommunityNotifyConsumer.java

@@ -1,39 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson.JSON;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.system.domain.TzySysNoticeRecord;
-import com.tzy.system.service.ITzySysNoticeRecordService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.List;
-
-
-@Slf4j
-@Component
-public class CommunityNotifyConsumer {
-
-	@Resource
-	private ITzySysNoticeRecordService noticeRecordService;
-
-	@RabbitHandler
-	@RabbitListener(queues = {MqConstans.QUEUE_COMMUNITY_NOTIFY})
-	public void notifyConsumer(String param, Channel channel, Message message) throws IOException {
-		log.debug("社区通知消息:{}", param);
-		try {
-			List<TzySysNoticeRecord> noticeRecords = JSON.parseArray(param, TzySysNoticeRecord.class);
-			noticeRecords.forEach(noticeRecord -> noticeRecordService.insertTzySysNoticeRecord(noticeRecord));
-		} catch (Exception e) {
-			log.error("社区通知消息异常,参数:{}", param, e);
-		}
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-}

+ 0 - 46
poyi-app/src/main/java/com/tzy/listener/mq/GiftCardConsumer.java

@@ -1,46 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSON;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.dto.group.GroupActRecord;
-import com.tzy.sportcard.api.service.GroupApiService;
-import com.tzy.sportcard.api.service.MineApiService;
-import com.tzy.sportcard.point.domain.AppUserPointRecord;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.List;
-
-
-@Slf4j
-@Component
-public class GiftCardConsumer {
-
-
-	@Resource
-	private GroupApiService groupApiService;
-	@Autowired
-	private MineApiService mineApiService;
-
-	@RabbitHandler
-	@RabbitListener(queues = {MqConstans.QUEUE_GROUP_GIFT_CARD})
-	public void giftCardConsumer(String param, Channel channel, Message message) throws IOException {
-		log.info("精美卡片新增记录:{}", param);
-		try {
-			GroupActRecord actRecord = JSON.parseObject(param, GroupActRecord.class);
-			List<AppUserPointRecord> records = groupApiService.getUserGroupGiftCard(actRecord.getRefId());
-			records.forEach(r -> mineApiService.addUserPoint(r));
-		} catch (Exception e) {
-			log.error("精美卡片新增异常,参数:{}", param, e);
-		}
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-}

+ 0 - 37
poyi-app/src/main/java/com/tzy/listener/mq/GoodsSyncConsumer.java

@@ -1,37 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.sportcard.group.service.ICardGroupGoodsService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class GoodsSyncConsumer {
-
-	@Autowired
-	private ICardGroupGoodsService cardGroupGoodsService;
-
-	@RabbitHandler
-	@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_GROUP_GOODS_SYNC))
-	public void groupFullConsumer(Long groupInfoId, Channel channel, Message message) throws IOException {
-		log.info("同步组团中卡卡密,id:{}", groupInfoId);
-		try {
-			cardGroupGoodsService.syncGoods(groupInfoId);
-		} catch (Exception e) {
-			log.info("中卡记录同步异常,组团id:{}", groupInfoId, e);
-		}
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-
-}

+ 0 - 53
poyi-app/src/main/java/com/tzy/listener/mq/GoodsSyncEsConsumer.java

@@ -1,53 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSONObject;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.elasticsearch.dto.CardGroupInfoGoodsDTO;
-import com.tzy.elasticsearch.service.CardGroupInfoGoodsService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-
-/**
- * es 卡密数据同步
- */
-@Slf4j
-@Component
-public class GoodsSyncEsConsumer {
-	@Resource
-	private CardGroupInfoGoodsService cardGroupInfoGoodsService;
-
-	@RabbitHandler
-	@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_GROUP_GOODS_SYNC_ES))
-	public void groupEsConsumer(String param, Channel channel, Message message) throws IOException {
-		syncEsGoods(param);
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-	private void syncEsGoods(String param) {
-		log.info("同步组团卡密ES,参数:{}", param);
-		try {
-			CardGroupInfoGoodsDTO syncParam = JSONObject.parseObject(param, CardGroupInfoGoodsDTO.class);
-			if(CardGroupInfoGoodsDTO.SYNC_TYPE_ADD.equals(syncParam.getSyncType())){
-				cardGroupInfoGoodsService.save(syncParam.getGroupInfoId());
-			}else if(CardGroupInfoGoodsDTO.SYNC_TYPE_EDIT.equals(syncParam.getSyncType())){
-				cardGroupInfoGoodsService.update(syncParam);
-			}else if(CardGroupInfoGoodsDTO.SYNC_TYPE_DEL_ADD.equals(syncParam.getSyncType())){
-				cardGroupInfoGoodsService.syncInfo(syncParam.getGroupInfoId());
-			}
-		} catch (Exception e) {
-			log.error("同步组团卡密ES异常,参数:{}", param, e);
-		}
-
-	}
-
-
-}

+ 0 - 594
poyi-app/src/main/java/com/tzy/listener/mq/GroupFullConsumer.java

@@ -1,594 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson2.JSON;
-import com.google.common.collect.Lists;
-import com.rabbitmq.client.Channel;
-import com.tzy.app.domain.act.CodeRecordDTO;
-import com.tzy.app.dto.TypeCountDTO;
-import com.tzy.app.dto.group.GoodsActRecordDTO;
-import com.tzy.app.mapper.AppCarouselPictureMapper;
-import com.tzy.app.mapper.GoodsActRecordMapper;
-import com.tzy.brand.member.domain.MemberUserRelation;
-import com.tzy.brand.member.dto.BrandMemberInfoDTO;
-import com.tzy.brand.member.mapper.MemberUserRelationMapper;
-import com.tzy.common.constant.Constants;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.core.domain.entity.SysDictData;
-import com.tzy.common.dto.GoodsQuery;
-import com.tzy.common.dto.PayActDTO;
-import com.tzy.common.dto.act.ActExchangeConfig;
-import com.tzy.common.dto.act.GroupSaleCodeDTO;
-import com.tzy.common.dto.group.GroupActRecord;
-import com.tzy.common.exception.ServiceException;
-import com.tzy.common.utils.DateUtils;
-import com.tzy.common.utils.StringUtils;
-import com.tzy.common.utils.bean.JSONTools;
-import com.tzy.framework.util.RedisUtils;
-import com.tzy.sportcard.api.bean.act.AppActManage;
-import com.tzy.sportcard.api.bean.act.GoodsActRecord;
-import com.tzy.sportcard.api.bean.act.UserListActParam;
-import com.tzy.sportcard.api.domain.GoodsInfo;
-import com.tzy.sportcard.api.domain.GoodsSerialDto;
-import com.tzy.sportcard.api.mapper.AppActManageMapper;
-import com.tzy.sportcard.api.service.AsyncAppService;
-import com.tzy.sportcard.api.service.GroupApiService;
-import com.tzy.sportcard.api.service.MineApiService;
-import com.tzy.sportcard.base.service.CommonCacheService;
-import com.tzy.sportcard.group.domain.CardGroupGoods;
-import com.tzy.sportcard.group.domain.CardGroupInfo;
-import com.tzy.sportcard.group.domain.CardGroupOrderInfo;
-import com.tzy.sportcard.group.domain.TzyMerchantInfo;
-import com.tzy.sportcard.group.service.*;
-import com.tzy.sportcard.group.service.impl.AppActServiceImpl;
-import com.tzy.sportcard.group.service.impl.GroupActService;
-import com.tzy.sportcard.point.domain.AppUserPointRecord;
-import lombok.extern.slf4j.Slf4j;
-import org.elasticsearch.common.Strings;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-
-@Slf4j
-@Component
-public class GroupFullConsumer {
-
-	@Autowired
-	private MineApiService mineApiService;
-	@Autowired
-	private ICardGroupOrderInfoService cardGroupOrderInfoService;
-	@Autowired
-	private ICardGroupInfoService cardGroupInfoService;
-	@Autowired
-	private ITzyMerchantInfoService merchantInfoService;
-	@Resource
-	private AppCarouselPictureMapper appCarouselPictureMapper;
-	@Autowired
-	private AsyncAppService asyncAppService;
-	@Resource
-	private ICardGroupGoodsService cardGroupGoodsService;
-	@Resource
-	private AppActService appActService;
-	@Resource
-	private RedisUtils redisUtils;
-	@Resource
-	private CommonCacheService commonCacheService;
-	@Resource
-	private GroupApiService groupApiService;
-	@Resource
-	private RabbitTemplate rabbitTemplate;
-	@Resource
-	private GoodsActRecordMapper goodsActRecordMapper;
-	@Resource
-	private GroupActService groupActService;
-	@Resource
-	private MemberUserRelationMapper memberUserRelationMapper;
-
-	@RabbitHandler
-	@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_GROUP_FULL))
-	public void groupFullConsumer(Long groupInfoId, Channel channel, Message message) throws IOException {
-		log.info("拼团组齐消费开始,id:{}", groupInfoId);
-		try {
-			//groupFullById(groupInfoId);
-		} catch (Exception e) {
-			log.info("拼团组齐消费异常,参数:{}", groupInfoId, e);
-		}
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-	private void sendUserGiftCard(Long groupInfoId) {
-		GroupActRecord actRecord = new GroupActRecord().setType(Constants.GROUP_GIFT_CARD).setRefId(groupInfoId.intValue()).setActType(Constants.GROUP_GIFT_CARD);
-		rabbitTemplate.convertAndSend(MqConstans.QUEUE_GROUP_GIFT_CARD, JSON.toJSONString(actRecord));
-	}
-
-	private void buildListAct(CardGroupInfo cardGroupInfo) {
-		if(cardGroupInfo.getPaniniListId()==null){
-			return;
-		}
-		//panini list活动
-		List<GoodsActRecord> userListAct = groupApiService.getUserListAct(cardGroupInfo.getPaniniListId());
-		if (CollectionUtils.isEmpty(userListAct)) {
-			return;
-		}
-		GoodsActRecord act = userListAct.get(0);
-		String actType = act.getActType();
-		if (Constants.LIST_ACT_SELECT_NUM.equals(actType)) {
-			ActExchangeConfig actConfig = act.getActConfig();
-			if (actConfig != null && StringUtils.isNotEmpty(actConfig.getExchangeActType())) {
-				List<TypeCountDTO> countList = cardGroupGoodsService.getUserGoodsNum(cardGroupInfo.getId());
-				countList.forEach(c -> {
-					AppUserPointRecord pointRecord = new AppUserPointRecord();
-					pointRecord.setType(actConfig.getExchangeActType());
-					pointRecord.setChangePoint(c.getNum().longValue());
-					pointRecord.setUserId(Long.parseLong(c.getType()));
-					pointRecord.setOrderId(cardGroupInfo.getId());
-					pointRecord.setOrderNo(cardGroupInfo.getCode());
-					pointRecord.setCreateTime(new Date());
-					pointRecord.setPointRate(1d);
-					mineApiService.addUserPoint(pointRecord);
-				});
-			}
-		} else {
-			boolean isInAct = checkListActByInfoType(actType, cardGroupInfo.getType());
-			if (!isInAct) {
-				return;
-			}
-			UserListActParam listActParam = new UserListActParam(cardGroupInfo.getId(), cardGroupInfo.getGoodsType(), cardGroupInfo.getPaniniListId(), actType);
-			rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_USER_LIST_ACT, MqConstans.ROUTING_KEY_USER_LIST_ACT, JSON.toJSONString(listActParam));
-		}
-	}
-
-	private boolean checkListActByInfoType(String actType, String infoType) {
-		if (Constants.INFO_TYPE_BUY_TEAM.equals(infoType)) {
-			return false;
-		}
-		if (actType.endsWith(Constants.ACT_GOODS_TYPE_SET) && !Constants.INFO_TYPE_SETS.equals(infoType)) {
-			return false;
-		}
-		if (actType.endsWith(Constants.ACT_GOODS_TYPE_PLAYER) && Constants.INFO_TYPE_TEAM.equals(infoType)) {
-			return false;
-		}
-		if (actType.endsWith(Constants.ACT_GOODS_TYPE_TEAM) && Constants.INFO_TYPE_PLAYER.equals(infoType)) {
-			return false;
-		}
-		return true;
-	}
-
-	private void checkHasUnPayOrder(Long groupInfoId, CardGroupOrderInfo condition) {
-		int i = 0;
-		while (true) {
-			List<CardGroupOrderInfo> upPayOrders = cardGroupOrderInfoService.selectCardGroupOrderInfoList(condition);
-			if (upPayOrders.isEmpty() || i > 10) {
-				break;
-			}
-			i++;
-			log.info("存在未支付订单:{},次数:{}", groupInfoId, i);
-			try {
-				Thread.sleep(1000L);
-			} catch (InterruptedException e) {
-			}
-		}
-	}
-
-	private void addUserPointByGroupOrdersV2(CardGroupInfo cardGroupInfo, boolean isPreSale, List<CardGroupOrderInfo> orders) {
-		boolean isPointCat = StringUtils.isNotEmpty(cardGroupInfo.getPointType()) &&
-				cardGroupInfo.getPointType().startsWith(Constants.POINT_TYPE_MERCHANT_ACT_PRE);
-		int commonRate = isPointCat ? 1 : 100;
-		boolean isGroupRateAct = StringUtils.isNotEmpty(cardGroupInfo.getActType())
-				&& cardGroupInfo.getActType().startsWith(Constants.GROUP_ACT_RATE_PRE);
-		int actRate = isGroupRateAct ? cardGroupInfo.getPointRate() : commonRate;
-		List<AppUserPointRecord> pointRecords = orders.stream()
-				.flatMap(order -> Stream.of(
-						buildUserPointRecord(order, Constants.POINT_TYPE_COMMON, isPreSale, commonRate, isPointCat),
-						buildUserPointRecord(order, Constants.POINT_TYPE_USER_GROWTH, isPreSale, commonRate, isPointCat),
-						StringUtils.isNotEmpty(cardGroupInfo.getActPointType()) && groupApiService.checkOrderAct(cardGroupInfo.getActType(), order.getPaymentSuccessTime()) ?
-								buildUserPointRecord(order, cardGroupInfo.getActPointType(), isPreSale, actRate, isPointCat) : null
-				))
-				.filter(Objects::nonNull)
-				.collect(Collectors.toList());
-		int i = 0;
-		boolean isSuccess = false;
-		while (i < 3) {
-			i++;
-			try {
-				mineApiService.batchAddPointRecords(pointRecords);
-				isSuccess = true;
-				break;
-			} catch (Exception e) {
-				log.warn("拼团组齐积分记录异常,code:{},msg:", cardGroupInfo.getCode(), e);
-			}
-			try {
-				Thread.sleep(100L * i + 50);
-			} catch (InterruptedException ignored) {}
-		}
-		if (!isSuccess) {
-			throw new ServiceException("拼团组齐积分记录异常");
-		}
-	}
-
-	private void addUserPointByGroupOrdersV3(CardGroupInfo cardGroupInfo, boolean isPreSale, List<CardGroupOrderInfo> orders) {
-		boolean isPointCat = StringUtils.isNotEmpty(cardGroupInfo.getPointType()) &&
-				cardGroupInfo.getPointType().startsWith(Constants.POINT_TYPE_MERCHANT_ACT_PRE);
-		int commonRate = isPointCat ? 1 : 100;
-		boolean isGroupRateAct = StringUtils.isNotEmpty(cardGroupInfo.getActType())
-				&& cardGroupInfo.getActType().startsWith(Constants.GROUP_ACT_RATE_PRE);
-		int actRate = isGroupRateAct ? cardGroupInfo.getPointRate() : commonRate;
-		List<AppUserPointRecord> pointRecords = Lists.newArrayList();
-		// 送积分
-		boolean hashSaleCode = hasGroupSaleCode(cardGroupInfo);	//判断是否生态购
-		// 根据paniniListId 查询关联的活动(goods_act_record)
-		List<GoodsActRecord> goodsActRecordList = goodsActRecordMapper.selectListByGoodsId(cardGroupInfo.getPaniniListId());
-		Set<Long> filterUserId = new HashSet<>();
-		for(CardGroupOrderInfo order : orders){
-			// 平台通用积分
-			AppUserPointRecord commonRecord = buildUserPointRecord(order, Constants.POINT_TYPE_COMMON, isPreSale, commonRate, isPointCat);
-			pointRecords.add(commonRecord);
-			// 平台成长值
-			AppUserPointRecord userGrowthRecord = buildUserPointRecord(order, Constants.POINT_TYPE_USER_GROWTH, isPreSale, commonRate, isPointCat);
-			pointRecords.add(userGrowthRecord);
-			// 查询用户是否加入品牌会员
-			BrandMemberInfoDTO brandInfo = memberUserRelationMapper.getBrandInfo(order.getMerchantId());
-			if(brandInfo != null) {
-				MemberUserRelation memberUserRelation = memberUserRelationMapper.checkMemberUserRelation(order.getUserId().intValue(), brandInfo.getMerchantGroupId().intValue());
-				if (memberUserRelation != null) {
-					int status = memberUserRelation.getStatus();
-					// 必须是正常会员或者注销之前的订单
-					if (1 == status || (0 == status && order.getPaymentSuccessTime().before(memberUserRelation.getLogoutTime()))) {
-						com.alibaba.fastjson2.JSONObject commonConfig = JSONTools.parseObject(memberUserRelation.getCommonConfig()); // 品牌积分成长值配置
-						// 品牌会员积分
-						AppUserPointRecord brandMemberPointRecord = buildUserPointRecord3(order, Constants.BRAND_POINT_TYPE_PRE + memberUserRelation.getMerchantGroupId(),
-								isPreSale, commonRate, isPointCat, commonConfig.getInteger("pointRate"));
-						if (brandMemberPointRecord != null) {
-							brandMemberPointRecord.setMerchantGroupId(memberUserRelation.getMerchantGroupId());
-							brandMemberPointRecord.setMerchantId(order.getMerchantId());
-							brandMemberPointRecord.setPointRate(commonConfig.getDouble("pointRate"));
-							pointRecords.add(brandMemberPointRecord);
-						}
-						// 品牌会员成长值
-						AppUserPointRecord brandUserGrowthRecord = buildUserPointRecord3(order, Constants.BRAND_GROWTH_TYPE_PRE + memberUserRelation.getMerchantGroupId(),
-								isPreSale, 10, isPointCat, commonConfig.getInteger("growthRate"));
-						if (brandUserGrowthRecord != null) {
-							brandUserGrowthRecord.setMerchantGroupId(memberUserRelation.getMerchantGroupId());
-							brandUserGrowthRecord.setMerchantId(order.getMerchantId());
-							brandUserGrowthRecord.setPointRate(commonConfig.getDouble("growthRate"));
-							pointRecords.add(brandUserGrowthRecord);
-						}
-					}
-				}
-			}
-
-			AppUserPointRecord luckyPointRecord2025 = buildLuckyPoint2025(order, "", isPreSale, commonRate, isPointCat);
-			if(luckyPointRecord2025 != null) {
-				pointRecords.add(luckyPointRecord2025);
-			}
-			if(StringUtils.isNotEmpty(cardGroupInfo.getActPointType()) && groupApiService.checkOrderAct(cardGroupInfo.getActType(), order.getPaymentSuccessTime())){
-				AppUserPointRecord actPointRecord = buildUserPointRecord(order, cardGroupInfo.getActPointType(), isPreSale, actRate, isPointCat);
-				pointRecords.add(actPointRecord);
-			}
-			/*if(groupApiService.checkOrderActV2(cardGroupInfo.getActType(), order.getPaymentSuccessTime())){
-				AppUserPointRecord actPointRecord = buildUserPointRecord(order, cardGroupInfo.getActPointType(), isPreSale, actRate, isPointCat);
-				pointRecords.add(actPointRecord);
-			}*/
-			// 拼团成功奖励
-			List<AppUserPointRecord> groupFullRecords = buildUserPointRecord2(order, hashSaleCode, goodsActRecordList, filterUserId, isPointCat);
-			if(!CollectionUtils.isEmpty(groupFullRecords)) {
-				pointRecords.addAll(groupFullRecords);
-			}
-		}
-		pointRecords.removeIf(Objects::isNull); // 过滤null元素
-
-		int i = 0;
-		boolean isSuccess = false;
-		while (i < 3) {
-			i++;
-			try {
-				mineApiService.batchAddPointRecords(pointRecords);
-				isSuccess = true;
-				break;
-			} catch (Exception e) {
-				log.warn("拼团组齐积分记录异常,code:{},msg:", cardGroupInfo.getCode(), e);
-			}
-			try {
-				Thread.sleep(100L * i + 50);
-			} catch (InterruptedException ignored) {}
-		}
-		if (!isSuccess) {
-			throw new ServiceException("拼团组齐积分记录异常");
-		}
-	}
-
-	/**
-	 * 2025-618沙滩球活动
-	 */
-	private AppUserPointRecord buildLuckyPoint2025(CardGroupOrderInfo orderInfos, String type, boolean isPreSale, Integer commonRate, boolean isPointCat){
-		List<SysDictData> sysDictDatas = commonCacheService.getCommonDictData("app_hot_type_times_cache",
-				"hb_act_lucky_2025_618","1", null, -1);
-		if(!CollectionUtils.isEmpty(sysDictDatas)) {
-			com.alibaba.fastjson2.JSONObject jsonObject = JSONTools.parseObject(sysDictDatas.get(0).getDictValue());
-			Date startTime = jsonObject.getDate("startTime");
-			Date endTime = jsonObject.getDate("endTime");
-			if (orderInfos.getPaymentSuccessTime().after(startTime) && orderInfos.getPaymentSuccessTime().before(endTime)) {
-				BigDecimal refundFree = orderInfos.getRefundFee() != null ? orderInfos.getRefundFee() : BigDecimal.ZERO;
-				BigDecimal amount;
-				if (isPreSale) {
-					amount = orderInfos.getSettlementAmount();
-				} else {
-					amount = isPointCat ? new BigDecimal(String.valueOf(orderInfos.getPoint())) : orderInfos.getActualPayment().subtract(refundFree);
-				}
-				if (amount.doubleValue() <= 0) {
-					return null;
-				}
-				BigDecimal pointRate = new BigDecimal(commonRate.toString());
-				Long points = amount.multiply(pointRate).longValue();
-
-				AppUserPointRecord pointRecord = new AppUserPointRecord();
-				pointRecord.setType(jsonObject.getString("pointType"));
-				pointRecord.setChangePoint(points);
-				pointRecord.setUserId(orderInfos.getUserId());
-				pointRecord.setOrderId(orderInfos.getId());
-				pointRecord.setOrderNo(orderInfos.getOrderNo());
-				pointRecord.setCreateTime(new Date());
-				pointRecord.setPointRate(commonRate.doubleValue());
-				pointRecord.setTotalSale(amount);
-				return pointRecord;
-			}
-		}
-		return null;
-	}
-	private void buildOrderPayAct(Long groupInfoId, List<CardGroupOrderInfo> orders) {
-		List<SysDictData> payActs = asyncAppService.getPayActs(PayActDTO.TYPE_PAY_AMOUNT_TURNTABLE);
-		if (payActs != null && !payActs.isEmpty()) {
-			Map<Long, CardGroupOrderInfo> distinctUserOrders = orders.stream().collect(Collectors.toMap(CardGroupOrderInfo::getUserId, o -> o, (key1, key2) -> key1));
-			distinctUserOrders.values().forEach(order -> asyncAppService.aftPayAct(order, PayActDTO.TYPE_PAY_AMOUNT_TURNTABLE));
-			log.info("记录大转盘活动组团id:{}", groupInfoId);
-		}
-	}
-
-	private void editGroupInfo(CardGroupInfo cardGroupInfo) {
-		Long groupInfoId=cardGroupInfo.getId();
-		CardGroupInfo info = new CardGroupInfo();
-		info.setId(groupInfoId);
-		info.setAddPointFlag(Constants.ZERO);
-		info.setSortDefault(0);
-		cardGroupInfoService.updateCardGroupInfo(info);
-		TzyMerchantInfo merchantInfo = new TzyMerchantInfo();
-		merchantInfo.setId(cardGroupInfo.getMerchantId().longValue());
-		merchantInfo.setSaleNum(cardGroupInfoService.findMerchantSaleNum(cardGroupInfo.getMerchantId().longValue()));
-		merchantInfoService.updateTzyMerchantInfo(merchantInfo);
-		appCarouselPictureMapper.cancelBanner(Constants.REDIRECT_PATH + groupInfoId);
-		redisUtils.del("order_group_cache:"+groupInfoId);
-		redisUtils.hdel(Constants.INFO_TEAM_TO_RANDOM_CACHE, groupInfoId.toString());
-		redisUtils.set("group_full_flag"+groupInfoId,1,3600);
-	}
-
-	private void buildMerchantAct(CardGroupInfo cardGroupInfo) {
-		if (StringUtils.isEmpty(cardGroupInfo.getHotTypeConfig())) {
-			return;
-		}
-		List<GoodsActRecordDTO> actConfigs = JSON.parseArray(cardGroupInfo.getHotTypeConfig(), GoodsActRecordDTO.class);
-		if (CollectionUtils.isEmpty(actConfigs)) {
-			return;
-		}
-		GoodsActRecordDTO config = actConfigs.get(0);
-		if (Constants.GROUP_ACT_TYPE_RANDOM.equals(config.getSubType())) {
-			//随机卡密分配活动
-			String actType = config.getActType();
-			if (!Constants.MERCHANT_ACT_GROUP_FULL.equals(actType)) {
-				return;
-			}
-			List<CardGroupGoods> actGoods = groupApiService.getGroupActGoods(cardGroupInfo.getId());
-			if (CollectionUtils.isEmpty(actGoods)) {
-				return;
-			}
-			actGoods.forEach(goods -> appActService.sendPrize(goods.getUserId(), goods.getActId().longValue(), config.getActValueType()));
-			editGoodsActFlag(cardGroupInfo);
-			Map<Integer, List<CardGroupGoods>> userNotifyData = actGoods.stream().collect(Collectors.groupingBy(CardGroupGoods::getUserId));
-			String prizeName = AppActServiceImpl.getPrizeName(config.getActDesc());
-			userNotifyData.keySet().forEach(key -> {
-				List<CardGroupGoods> goodsList = userNotifyData.get(key);
-				CardGroupGoods goods = goodsList.get(0);
-				String userPrizeName = prizeName;
-				if (goodsList.size() > 1) {
-					userPrizeName = prizeName + "等活动奖品";
-				}
-				appActService.sendMerchantActNotify(cardGroupInfo.getName(), goods.getUserOrderId().longValue(), goods.getUserId(),
-						goods.getUserNickname(), userPrizeName, config.getActValueType(), config.getName());
-			});
-		} else if (Constants.GROUP_ACT_TYPE_SELECT.equals(config.getSubType())) {
-			//指定卡密
-			Long groupInfoId = cardGroupInfo.getId();
-			List<GoodsActRecord> allActGoods = cardGroupGoodsService.getActGoods(groupInfoId, Constants.MERCHANT_ACT_GROUP_FULL);
-			if (!allActGoods.isEmpty()) {
-				List<Long> goodsIdList = allActGoods.stream().filter(a -> a.getGoodsId() != null).map(GoodsActRecord::getGoodsId).collect(Collectors.toList());
-				GoodsQuery query = new GoodsQuery().setGroupInfoId(cardGroupInfo.getId()).setIds(goodsIdList).setActStatus(0);
-				List<GoodsSerialDto> actGoods = cardGroupGoodsService.selectGoods(cardGroupInfo.isNewGoodsType(), query);
-				actGoods.forEach(goods -> appActService.sendGoodsActPrize(goods, allActGoods, cardGroupInfo.getName()));
-				editGoodsActFlag(cardGroupInfo);
-				Map<Integer, List<GoodsSerialDto>> userNotifyData = actGoods.stream().collect(Collectors.groupingBy(GoodsSerialDto::getUserId));
-				userNotifyData.keySet().forEach(key -> {
-					List<GoodsSerialDto> goodsList = userNotifyData.get(key);
-					GoodsSerialDto goods = goodsList.get(0);
-					List<GoodsActRecord> actRecords = allActGoods.stream().filter(a -> a.getGoodsId() != null && a.getGoodsId().intValue() == goods.getId()).collect(Collectors.toList());
-					GoodsActRecord actRecord = actRecords.get(0);
-					String prizeName = AppActServiceImpl.getPrizeName(actRecord.getActDesc());
-					if (goodsList.size() > 1) {
-						prizeName = prizeName + ".等活动奖品";
-					}
-					appActService.sendMerchantActNotify(cardGroupInfo.getName(), goods.getUserOrderId().longValue(),
-							goods.getUserId(), goods.getNickname(), prizeName, config.getActValueType(), config.getName());
-				});
-			}
-		}
-	}
-
-	private void editGoodsActFlag(CardGroupInfo cardGroupInfo) {
-		GoodsQuery condition = new GoodsQuery().setGroupInfoId(cardGroupInfo.getId());
-		CardGroupGoods goods=new CardGroupGoods();
-		goods.setActStatus(1);
-		cardGroupGoodsService.updateGoodsByCond(goods,condition);
-	}
-
-
-	private void addPoint(CardGroupOrderInfo orderInfos, String type, boolean isPreSale, Integer actPointRate, boolean isPointCat) {
-		AppUserPointRecord pointRecord = buildUserPointRecord(orderInfos, type, isPreSale, actPointRate, isPointCat);
-		if (pointRecord == null) return;
-		//增加积分明细记录
-		mineApiService.addUserPoint(pointRecord);
-	}
-
-	private AppUserPointRecord buildUserPointRecord(CardGroupOrderInfo orderInfos, String type, boolean isPreSale, Integer actPointRate, boolean isPointCat) {
-		BigDecimal refundFree = orderInfos.getRefundFee() != null ? orderInfos.getRefundFee() : BigDecimal.ZERO;
-		BigDecimal amount;
-		if (isPreSale) {
-			amount = orderInfos.getSettlementAmount();
-		} else {
-			amount = isPointCat ? new BigDecimal(String.valueOf(orderInfos.getPoint())) : orderInfos.getActualPayment().subtract(refundFree);
-		}
-		if (amount.doubleValue() <= 0) {
-			return null;
-		}
-		BigDecimal pointRate = new BigDecimal(actPointRate.toString());
-		Long points = amount.multiply(pointRate).longValue();
-
-		AppUserPointRecord pointRecord = new AppUserPointRecord();
-		pointRecord.setType(type);
-		pointRecord.setChangePoint(points);
-		pointRecord.setUserId(orderInfos.getUserId());
-		pointRecord.setOrderId(orderInfos.getId());
-		pointRecord.setOrderNo(orderInfos.getOrderNo());
-		pointRecord.setCreateTime(new Date());
-		pointRecord.setPointRate(pointRate.doubleValue());
-		pointRecord.setTotalSale(amount);
-		return pointRecord;
-	}
-
-	private List<AppUserPointRecord> buildUserPointRecord2(CardGroupOrderInfo orderInfos, boolean hashSaleCode,
-														   List<GoodsActRecord> goodsActRecordList, Set<Long> filterUserId, boolean isPointCat){
-		List<AppUserPointRecord> results = Lists.newArrayList();
-		if(CollectionUtils.isEmpty(goodsActRecordList)) {
-			log.debug("拼团组齐次数无活动");
-			return results;
-		}
-		Map<String, List<GoodsActRecord>> groupMap = goodsActRecordList.stream().collect(Collectors.groupingBy(GoodsActRecord::getCategory));
-		BigDecimal refundFree = orderInfos.getRefundFee() != null ? orderInfos.getRefundFee() : BigDecimal.ZERO;
-		BigDecimal amount = isPointCat ? new BigDecimal(String.valueOf(orderInfos.getPoint())) : orderInfos.getActualPayment().subtract(refundFree);
-		groupMap.keySet().forEach(key -> {
-			GoodsActRecord actPoint = groupMap.get(key).get(0);
-			JSONObject prop1Obj = JSONObject.parseObject(actPoint.getProp1());
-			if(Strings.isEmpty(prop1Obj.getString("pointType"))){ // 如果不是送积分的活动 不走后面的逻辑
-				return;
-			}
-			if(Constants.GROUP_ACT_RATE.equals(key)){	// 	倍率积分活动
-				List<GoodsActRecord> actPointList = groupMap.get(key);
-				actPointList.stream()
-						.filter(record -> Objects.equals(JSONObject.parseObject(record.getProp1()).getBooleanValue("needSaleCode"), hashSaleCode))
-						.findFirst()
-						.ifPresent(filterRecord -> {
-							if(!checkActTime(filterRecord, orderInfos.getPaymentSuccessTime())){
-								return;
-							}
-							results.add(createPointRecord(JSONObject.parseObject(filterRecord.getProp1()), amount, orderInfos));
-						});
-			} else if(Constants.GROUP_FULL_COUNT.equals(key)){
-				log.debug("拼团组齐次数group_full_count--------");
-				if(!filterUserId.contains(orderInfos.getUserId())) {	//	拼团组齐只送一次
-					if(!checkActTime(actPoint, orderInfos.getPaymentSuccessTime())){
-						log.debug("拼团组齐次数用户支付时间不在范围内");
-						return;
-					}
-
-					// 拼团组齐次数
-					results.add(createPointRecord(prop1Obj, BigDecimal.ONE, orderInfos));
-					filterUserId.add(orderInfos.getUserId());
-				}
-			} else{
-				if(!checkActTime(actPoint, orderInfos.getPaymentSuccessTime())){
-					return;
-				}
-				results.add(createPointRecord(prop1Obj, amount, orderInfos));
-			}
-		});
-
-		return results;
-	}
-
-	private AppUserPointRecord buildUserPointRecord3(CardGroupOrderInfo orderInfos, String type, boolean isPreSale, Integer actPointRate, boolean isPointCat, Integer brandRate) {
-		BigDecimal refundFree = orderInfos.getRefundFee() != null ? orderInfos.getRefundFee() : BigDecimal.ZERO;
-		BigDecimal amount;
-		if (isPreSale) {
-			amount = orderInfos.getSettlementAmount();
-		} else {
-			amount = isPointCat ? new BigDecimal(String.valueOf(orderInfos.getPoint())) : orderInfos.getActualPayment().subtract(refundFree);
-		}
-		if (amount.doubleValue() <= 0) {
-			return null;
-		}
-		BigDecimal pointRate = new BigDecimal(actPointRate.toString());
-		Long points = amount.multiply(pointRate).divide(new BigDecimal(brandRate), 0, RoundingMode.HALF_UP).longValue();
-
-		AppUserPointRecord pointRecord = new AppUserPointRecord();
-		pointRecord.setType(type);
-		pointRecord.setChangePoint(points);
-		pointRecord.setUserId(orderInfos.getUserId());
-		pointRecord.setOrderId(orderInfos.getId());
-		pointRecord.setOrderNo(orderInfos.getOrderNo());
-		pointRecord.setCreateTime(new Date());
-		pointRecord.setPointRate(pointRate.doubleValue());
-		pointRecord.setTotalSale(amount);
-		return pointRecord;
-	}
-
-	// 判断订单是否在活动有效期
-	private boolean checkActTime(GoodsActRecord actRecord, Date orderPaymentSuccessTime){
-		Date startTime = actRecord.getStartTime();
-		Date endTime = actRecord.getEndTime();
-		if (startTime != null && orderPaymentSuccessTime.before(startTime)) {
-			return false;
-		}
-		if (endTime != null && orderPaymentSuccessTime.after(endTime)) {
-			return false;
-		}
-		return true;
-	}
-
-	// 提取通用的代码部分
-	private AppUserPointRecord createPointRecord(JSONObject prop1Obj, BigDecimal amount, CardGroupOrderInfo orderInfos) {
-		AppUserPointRecord pointRecord = new AppUserPointRecord();
-		double pointRate = prop1Obj.getDouble("pointRate");
-		Long points = amount.multiply(new BigDecimal(pointRate)).longValue();
-		pointRecord.setType(prop1Obj.getString("pointType"));
-		pointRecord.setChangePoint(points);
-		pointRecord.setUserId(orderInfos.getUserId());
-		pointRecord.setOrderId(orderInfos.getId());
-		pointRecord.setOrderNo(orderInfos.getOrderNo());
-		pointRecord.setCreateTime(new Date());
-		pointRecord.setPointRate(pointRate);
-		return pointRecord;
-	}
-
-	private boolean hasGroupSaleCode(CardGroupInfo cardGroupInfo){
-		List<CodeRecordDTO> codeRecords = groupApiService.getRefCodeRecord(cardGroupInfo.getId(), null);
-		boolean hasSaleCode = !CollectionUtils.isEmpty(codeRecords);
-		if(hasSaleCode){
-			return hasSaleCode;
-		}
-		//新版生态购
-		GroupSaleCodeDTO saleCodeConfig = groupActService.getGroupSaleCodeConfig(cardGroupInfo.getId(),cardGroupInfo.getStatus()>=201);
-		return saleCodeConfig.isHasBoxConfig();
-	}
-
-}

+ 0 - 61
poyi-app/src/main/java/com/tzy/listener/mq/GroupOrderActConsumer.java

@@ -1,61 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSON;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.dto.group.GroupActRecord;
-import com.tzy.common.utils.DateUtils;
-import com.tzy.sportcard.api.service.GroupApiService;
-import com.tzy.sportcard.group.service.AppActService;
-import com.tzy.sportcard.group.service.ICardGroupGoodsService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-import org.teasoft.bee.osql.SuidRich;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class GroupOrderActConsumer {
-
-	@Resource
-	private AppActService appActService;
-	@Resource
-	private SuidRich suidRich;
-	@Resource
-	private GroupApiService groupApiService;
-	@Resource
-	private ICardGroupGoodsService cardGroupGoodsService;
-
-	@RabbitHandler
-	@RabbitListener(queues = {MqConstans.QUEUE_GROUP_ORDER_ACT})
-	public void actConsumer(String param, Channel channel, Message message) throws IOException {
-		log.info("活动消费记录:{}", param);
-		try {
-			GroupActRecord actRecord = JSON.parseObject(param, GroupActRecord.class);
-			if(appActService.isActSend(actRecord.getType(),actRecord.getRefId(),actRecord.getActType())){
-				log.info("活动已存在记录:{}",param);
-				return;
-			}
-			sendActPrizeByType(actRecord);
-			actRecord.setCreateTime(DateUtils.getTimestampNow());
-			suidRich.insert(actRecord);
-		} catch (Exception e) {
-			log.error("活动消费异常,参数:{}", param, e);
-		}
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-	private void sendActPrizeByType(GroupActRecord actRecord) {
-		//String type = actRecord.getType();
-		//String actType = actRecord.getActType();
-		//Integer refId = actRecord.getRefId();
-	}
-
-
-}

+ 0 - 49
poyi-app/src/main/java/com/tzy/listener/mq/GroupSortConsumer.java

@@ -1,49 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.sportcard.api.service.AsyncAppService;
-import com.tzy.sportcard.group.domain.CardGroupInfo;
-import com.tzy.sportcard.group.service.ICardGroupInfoService;
-import com.tzy.system.service.ISysDictDataService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class GroupSortConsumer {
-    @Resource
-    private ICardGroupInfoService cardGroupInfoService;
-    @Resource
-    private AsyncAppService asyncAppService;
-    @Resource
-    private ISysDictDataService dictDataService;
-
-    @RabbitHandler
-    @RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_GROUP_SORT_UPDATE))
-    public void groupSortConsumer(Long groupInfoId, Channel channel, Message message) throws IOException {
-        try {
-            CardGroupInfo cardGroupInfo = cardGroupInfoService.selectCardGroupInfoById(groupInfoId);
-            if (cardGroupInfo != null && cardGroupInfo.getCopies() > cardGroupInfo.getSoldCopies()) {
-                asyncAppService.updateInfoSortQueryV3(cardGroupInfo);
-            }
-        } catch (Exception e) {
-            log.info("组团排序修改异常,参数:{}", groupInfoId, e);
-        }
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    }
-
-
-
-
-
-
-}

+ 0 - 34
poyi-app/src/main/java/com/tzy/listener/mq/InitBrandMemberConsumer.java

@@ -1,34 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.sportcard.api.service.BrandMemberManageService;
-import com.tzy.sportcard.api.service.IMemberManageService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class InitBrandMemberConsumer {
-
-	@Resource
-	private BrandMemberManageService brandMemberManageService;
-
-	@RabbitHandler
-	@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_INIT_BRAND_MEMBER))
-	public void initBrandMemberConsumer(String param, Channel channel, Message message) throws IOException {
-		log.info("InitBrandMemberConsumer param:{}", param);
-		brandMemberManageService.initMember();
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-
-}

+ 0 - 76
poyi-app/src/main/java/com/tzy/listener/mq/InitUserGiftCardConsumer.java

@@ -1,76 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.JSONObject;
-import com.rabbitmq.client.Channel;
-import com.tzy.app.dto.UserGiftCardDTO;
-import com.tzy.common.constant.Constants;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.utils.DateUtils;
-import com.tzy.framework.util.RedisUtils;
-import com.tzy.sportcard.api.service.MineApiService;
-import com.tzy.sportcard.point.domain.AppUserPointRecord;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.List;
-
-
-@Slf4j
-@Component
-public class InitUserGiftCardConsumer {
-	@Autowired
-	private MineApiService mineApiService;
-	@Autowired
-	private RedisUtils redisUtils;
-
-	private final static String START_TIME_DEFAULT="2023-11-01 00:00:00";
-	private final static String END_TIME_DEFAULT="2023-11-29 00:00:00";
-
-	@RabbitHandler
-	@RabbitListener(queues = {MqConstans.QUEUE_INIT_USER_GIFT_CARD})
-	public void initUserGiftCardConsumer(String param, Channel channel, Message message) throws IOException {
-		log.info("用户精美卡片初始化:{}", param);
-		try {
-			JSONObject paramJson = JSON.parseObject(param);
-			String userId = paramJson.getString("userId");
-			String startTime = paramJson.getString("startTime");
-			String endTime = paramJson.getString("endTime");
-			initUserGiftCard(Integer.valueOf(userId),startTime,endTime);
-		} catch (Exception e) {
-			log.error("用户精美卡片初始化异常,用户id:{}", param, e);
-		}
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-	private void initUserGiftCard(Integer userId,String startTime,String endTime) {
-		if (userId == null) {
-			return;
-		}
-		startTime = StringUtils.isEmpty(startTime) ? START_TIME_DEFAULT : startTime;
-		endTime = StringUtils.isEmpty(endTime) ? END_TIME_DEFAULT : endTime;
-		List<UserGiftCardDTO> userWaitCards = mineApiService.getUserInitWaitGiftCards(userId, DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, startTime),
-				DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, endTime));
-		userWaitCards.forEach(c -> {
-			AppUserPointRecord pointRecord = new AppUserPointRecord();
-			pointRecord.setType(Constants.POINT_TYPE_GIFT_CARD_PRE + c.getCardId());
-			pointRecord.setChangePoint(c.getWaitNum().longValue());
-			pointRecord.setCurrPoint(c.getCardId().longValue());
-			pointRecord.setUserId(userId.longValue());
-			pointRecord.setOrderId(c.getInfoId().longValue());
-			pointRecord.setMerchantId(c.getMerchantId().longValue());
-			pointRecord.setOrderNo(c.getInfoId().toString());
-			pointRecord.setCreateTime(new Date());
-			//增加积分明细记录
-			mineApiService.addUserPoint(pointRecord);
-		});
-		redisUtils.hset("init_user_gift_card", userId.toString(), 1);
-	}
-}

+ 0 - 32
poyi-app/src/main/java/com/tzy/listener/mq/InitUserMemberConsumer.java

@@ -1,32 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.sportcard.api.service.IMemberManageService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class InitUserMemberConsumer {
-
-	@Resource
-	private IMemberManageService memberManageService;
-
-	@RabbitHandler
-	@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_INIT_USER_USER_MEMBER))
-	public void initUserMemberConsumer(String param, Channel channel, Message message) throws IOException {
-		memberManageService.initMemberV2();
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-
-}

+ 0 - 37
poyi-app/src/main/java/com/tzy/listener/mq/LuckyBagConsumer.java

@@ -1,37 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.utils.bean.JSONTools;
-import com.tzy.luckybag.dto.LuckyBagMQDTO;
-import com.tzy.luckybag.service.IAppLiveLuckyBagService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-@Slf4j
-@Component
-public class LuckyBagConsumer {
-
-    @Resource
-    private IAppLiveLuckyBagService appLiveLuckyBagService;
-
-    @RabbitHandler
-    @RabbitListener(queues = {MqConstans.QUEUE_LUCKY_BAG_EXPIRED})
-    public void notifyConsumer(String dataStr, Channel channel, Message message) throws IOException {
-        log.info("福袋开奖 {}", dataStr);
-        LuckyBagMQDTO luckyBagMQDTO = JSONTools.jsonStr2obj(dataStr, LuckyBagMQDTO.class);
-        try {
-            appLiveLuckyBagService.startLottery(luckyBagMQDTO);
-//
-        } catch (Exception e) {
-            log.error("福袋开奖异常id:{}", luckyBagMQDTO.getBagId(), e);
-        }
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    }
-}

+ 0 - 104
poyi-app/src/main/java/com/tzy/listener/mq/MerchantNotifyConsumer.java

@@ -1,104 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.JSONObject;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.constant.NoticeMsgModel;
-import com.tzy.common.dto.notice.ToNoticeUserDTO;
-import com.tzy.common.utils.bean.BeanUtils;
-import com.tzy.sportcard.api.mapper.AppNotifyConfigMapper;
-import com.tzy.system.domain.TzySysNoticeRecord;
-import com.tzy.system.mapper.TzySysNoticeRecordMapper;
-import com.tzy.util.NoticeType;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-
-@Slf4j
-@Component
-public class MerchantNotifyConsumer {
-
-	@Resource
-	private AppNotifyConfigMapper appNotifyConfigMapper;
-	@Resource
-	private TzySysNoticeRecordMapper noticeRecordMapper;
-
-	@RabbitHandler
-	@RabbitListener(queues = {MqConstans.QUEUE_MERCHANT_NOTIFY})
-	public void notifyConsumer(String param, Channel channel, Message message) throws IOException {
-		log.debug("商家通知消息:{}", param);
-		try {
-			//notifyLikeMerchantUser(param);
-		} catch (Exception e) {
-			log.error("商家通知异常,组团id:{}", param, e);
-		}
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-	private void notifyLikeMerchantUser(String param) {
-		JSONObject notifyJson = JSON.parseObject(param);
-		String type = notifyJson.getString("type");
-		Integer merchantId = notifyJson.getIntValue("merchantId");
-		String merchantName = notifyJson.getString("merchantName");
-		Integer groupInfoId = notifyJson.getIntValue("groupInfoId");
-		String groupInfoName = notifyJson.getString("groupInfoName");
-
-		List<ToNoticeUserDTO> noticeUsers = appNotifyConfigMapper.selectNotifyUsersByMerchant(type, merchantId);
-		if(CollectionUtils.isEmpty(noticeUsers)){
-			return;
-		}
-		String refUrl = "live".equalsIgnoreCase(type) ? NoticeType.group_detail_url + groupInfoId : NoticeType.MERCHANT_SHOP_TOP + merchantId;
-		String msg = "live".equalsIgnoreCase(type) ? String.format(NoticeMsgModel.MERCHANT_LIVING_NOTIFY, groupInfoName)
-				: String.format(NoticeMsgModel.MERCHANT_SALE_NEW_NOTIFY, merchantName);
-
-		String title = "live".equalsIgnoreCase(type) ? "直播通知" : "开售通知";
-		List<TzySysNoticeRecord> records = noticeUsers.stream().filter(u -> checkUserIsNotify(type, u, merchantId))
-				.map(u -> buildNoticeRecord(u.getUserId(), type.toUpperCase(), refUrl, msg, title)).collect(Collectors.toList());
-		if (CollectionUtils.isEmpty(records)) {
-			return;
-		}
-		List<List<TzySysNoticeRecord>> batchList = BeanUtils.batchList(records, 500);
-		batchList.forEach(r -> noticeRecordMapper.batchInsertRecord(r));
-	}
-
-	private TzySysNoticeRecord buildNoticeRecord(Long userId, String type, String refUrl, String msg, String title) {
-		TzySysNoticeRecord noticeRecord = new TzySysNoticeRecord();
-		noticeRecord.setFromUser("HOBBY STOCKS");
-		noticeRecord.setTitle(title);
-		noticeRecord.setToUserid(userId);
-		noticeRecord.setContentUrl(refUrl);
-		noticeRecord.setMsg(msg);
-		noticeRecord.setType(type);
-		noticeRecord.setSubType(type);
-		return noticeRecord;
-	}
-
-	private boolean checkUserIsNotify(String type, ToNoticeUserDTO noticeUserDTO, Integer merchantId) {
-		if ("PRIVATE_MERCHANT".equals(noticeUserDTO.getNotifyType())) {
-			JSONObject configJson = JSON.parseObject(noticeUserDTO.getNotifyConfig());
-			String merchantIds = configJson.getString("merchantIds");
-			if (StringUtils.isNotEmpty(merchantIds)) {
-				List<String> merchantIdList = Arrays.asList(merchantIds.split(","));
-				return merchantIdList.contains(merchantId.toString());
-			}
-		}
-		if ("live".equals(type) && "BUY".equals(noticeUserDTO.getNotifyType())) {
-			return false;
-		}
-		return true;
-	}
-
-
-}

+ 0 - 64
poyi-app/src/main/java/com/tzy/listener/mq/OrderAftAllocateConsumer.java

@@ -1,64 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSONObject;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.utils.DateUtils;
-import com.tzy.dto.local.AllocateResult;
-import com.tzy.pojo.card.CardGroupOrderInfo;
-import com.tzy.sportcard.api.service.IAllocateGoodsService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.teasoft.bee.osql.SuidRich;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class OrderAftAllocateConsumer {
-
-	@Autowired
-	private SuidRich suidRich;
-	@Resource
-	private IAllocateGoodsService allocateGoodsService;
-
-
-	@RabbitHandler
-	@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_ORDER_AFT_ALLOCATE))
-	public void orderAftAllocateConsumer(String param, Channel channel, Message message) throws IOException {
-		orderAftAllocate(param);
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-	private void orderAftAllocate(String param) {
-		log.info("同步用户中卡,参数:{}", param);
-		try {
-			AllocateResult result = JSONObject.parseObject(param, AllocateResult.class);
-			if (result.getOrderId() == null) {
-				return;
-			}
-			CardGroupOrderInfo order = new CardGroupOrderInfo();
-			order.setId(result.getOrderId());
-			CardGroupOrderInfo existOrder = suidRich.selectOne(order);
-			if (existOrder == null) {
-				return;
-			}
-			order.setGoodsAllocate(1);
-			order.setProp2(result.getGuessCount() > 0 ? result.getGuessCount().toString() : "0");
-			order.setProp3(result.getMissCardCount() > 0 ? result.getMissCardCount().toString() : "0");
-			order.setUpdateTime(DateUtils.getTimestampNow());
-			suidRich.update(order);
-			allocateGoodsService.aftAllocateOrderGoods(existOrder.getGroupInfoId());
-		} catch (Exception e) {
-			log.error("同步用户中卡异常,参数:{}", param, e);
-		}
-	}
-
-}

+ 0 - 113
poyi-app/src/main/java/com/tzy/listener/mq/OrderExpiredConsumer.java

@@ -1,113 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSON;
-import com.rabbitmq.client.Channel;
-import com.tzy.app.domain.order.PayRecord;
-import com.tzy.common.constant.Constants;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.utils.DateUtils;
-import com.tzy.common.utils.StringUtils;
-import com.tzy.framework.util.RedisUtils;
-import com.tzy.member.benefits.mapper.MemberBenefitsRecordMapper;
-import com.tzy.service.MallOrderService;
-import com.tzy.sportcard.api.dto.ResourceData;
-import com.tzy.sportcard.api.service.GroupApiService;
-import com.tzy.sportcard.api.service.MineApiService;
-import com.tzy.sportcard.group.domain.CardGroupOrderInfo;
-import com.tzy.sportcard.group.service.ICardGroupOrderInfoService;
-import com.tzy.sportcard.point.domain.AppUserPointRecord;
-import com.tzy.system.service.ISysDictDataService;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.logging.log4j.util.Strings;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-
-@Slf4j
-@Component
-public class OrderExpiredConsumer {
-
-    @Autowired
-    private ICardGroupOrderInfoService cardGroupOrderInfoService;
-    @Autowired
-    private RedisUtils redisUtils;
-    @Autowired
-    private MallOrderService mallOrderService;
-    @Autowired
-    private GroupApiService groupApiService;
-    @Autowired
-    private MineApiService mineApiService;
-    @Resource
-    private MemberBenefitsRecordMapper memberBenefitsRecordMapper;
-    @Resource
-    private RabbitTemplate rabbitTemplate;
-    @Autowired
-    private ISysDictDataService dictDataService;
-
-    private static final List<String> no_search_pay_type = Arrays.asList("merchant_pay", "商家代收");
-
-    @RabbitHandler
-    @RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_ORDER_EXPIRED))
-    public void orderExpired(Long orderId, Channel channel, Message message) throws IOException {
-        //orderExpiredConsumer(orderId, channel, message);
-    }
-
-    private void pointCallBack(CardGroupOrderInfo orderInfo) {
-        ResourceData resourceData = new ResourceData();
-        ResourceData.PayAmount payAmount = new ResourceData.PayAmount();
-        payAmount.setTotal(0);
-        payAmount.setPayer_total(payAmount.getTotal());
-        //支付类型
-        resourceData.setTrade_type(dictDataService.getMerchantPointMsg(orderInfo.getPointType()));
-        resourceData.setSubPaymentType(orderInfo.getPointType());
-        resourceData.setOut_trade_no(orderInfo.getOrderNo());
-        resourceData.setTransaction_id(String.valueOf(System.currentTimeMillis()));
-        resourceData.setSuccess_time(DateUtils.dateTime(new Date()));
-        resourceData.setTrade_state("TRADE_SUCCESS");
-        resourceData.setTrade_state_desc("TRADE_SUCCESS");
-        resourceData.setBank_type(orderInfo.getPointType());
-        resourceData.setAmount(payAmount);
-        rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_PRE_PAY_CALLBACK, MqConstans.ROUTING_KEY_PRE_CALLBACK, JSON.toJSONString(resourceData));
-        log.info("订单支付成功,开始回调:{}", orderInfo.getOrderNo());
-    }
-
-    private void cancelOrderByType(CardGroupOrderInfo orderInfo) {
-        if (Constants.ORDER_TYPE_SHOP.equals(orderInfo.getOrderType())) {
-            mallOrderService.cancelOrder(orderInfo);
-            // 如果是权益兑换订单  删除权益兑换记录
-            String prop3 = orderInfo.getProp3();
-            if (Constants.MEMBER_BENEFITS.equals(orderInfo.getOrderSubType()) && Strings.isNotEmpty(prop3)) {
-                // 根据权益兑换记录id删除权益兑换记录
-                memberBenefitsRecordMapper.deleteMemberBenefitsRecordById(Long.parseLong(prop3));
-            }
-        } else if (Constants.ORDER_TYPE_GIFT_CARD.equals(orderInfo.getOrderType())) {
-            mallOrderService.cancelDrawOrder(orderInfo);
-        } else if (Constants.ORDER_TYPE_DRAW.equals(orderInfo.getOrderType())) {
-            mallOrderService.cancelDrawOrderNew(orderInfo.getId());
-        } else if (Constants.ORDER_TYPE_GROUP.equals(orderInfo.getOrderType())) {
-            cardGroupOrderInfoService.cancelOrder(orderInfo);
-        } else {
-            mallOrderService.cancelDrawOrder(orderInfo);
-        }
-        //返回所有关联优惠劵
-        cardGroupOrderInfoService.returnCouponByOrderId(orderInfo.getId());
-        boolean isPointOrder = StringUtils.isNotEmpty(orderInfo.getPointType()) && orderInfo.getPointType().startsWith(Constants.POINT_TYPE_MERCHANT_ACT_PRE);
-        if (!isPointOrder) {
-            String pointType = StringUtils.isNotEmpty(orderInfo.getPointType()) ? orderInfo.getPointType() : Constants.POINT_TYPE_COMMON_RETURN;
-            //回退订单消耗积分
-            mineApiService.addUserPoint(orderInfo, true, pointType);
-        }
-    }
-}

+ 0 - 96
poyi-app/src/main/java/com/tzy/listener/mq/OrderOverConsumer.java

@@ -1,96 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSON;
-import com.rabbitmq.client.Channel;
-import com.tzy.app.domain.order.OrderListDTO;
-import com.tzy.app.mapper.OrderListMapper;
-import com.tzy.common.constant.Constants;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.dto.act.OrderOverParam;
-import com.tzy.common.utils.bean.JSONTools;
-import com.tzy.sportcard.api.service.MineApiService;
-import com.tzy.sportcard.group.domain.CardGroupOrderInfo;
-import com.tzy.sportcard.group.mapper.CardGroupOrderInfoMapper;
-import com.tzy.sportcard.point.domain.AppUserPointRecord;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.List;
-
-
-/**
- * 订单完结消费
- * 消费者参数json格式:
- * type:类型,1:商城订单完结赠送积分 shop_point
- * orderId: 订单id
- */
-@Slf4j
-@Component
-public class OrderOverConsumer {
-
-	@Resource
-	private MineApiService mineApiService;
-	@Resource
-	private OrderListMapper orderListMapper;
-	@Resource
-	private CardGroupOrderInfoMapper cardGroupOrderInfoMapper;
-
-	@RabbitHandler
-	@RabbitListener(queues = {MqConstans.QUEUE_ORDER_OVER})
-	public void orderOverConsumer(String param, Channel channel, Message message) throws IOException {
-		log.info("订单完结记录:{}", param);
-		try {
-			OrderOverParam overParam = JSONTools.jsonStr2obj(param, OrderOverParam.class);
-			if(Constants.TYPE_SHOP_POINT.equals(overParam.getType())){
-				CardGroupOrderInfo order = cardGroupOrderInfoMapper.selectCardGroupOrderInfoById(overParam.getOrderId());
-				addOrderActPoint(order); // 加活动积分
-				addPointRecord(order, channel, message);// 商城积分、成长值
-			}
-		} catch (Exception e) {
-			log.error("订单完结异常,参数:{}", param, e);
-		}
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-	private void addOrderActPoint(CardGroupOrderInfo order) {
-		List<OrderListDTO> actOrderLists = orderListMapper.selectListByOrderId(order.getId(),true);
-		if (CollectionUtils.isEmpty(actOrderLists)) {
-			return;
-		}
-
-		String actType = actOrderLists.get(0).getActType();
-		if (!actType.startsWith(Constants.POINT_TYPE_HB_ACT_OVER_PRE)) {
-			return;
-		}
-		Integer totalActPoint = actOrderLists.stream().filter(ol -> ol.getActPoint() != null).mapToInt(OrderListDTO::getActPoint).sum();
-		AppUserPointRecord pointRecord = mineApiService.buildOrderActPointRecord(order, totalActPoint, actType);
-		mineApiService.addUserPoint(pointRecord);
-	}
-
-	private void addPointRecord(CardGroupOrderInfo order, Channel channel, Message message) throws IOException {
-		if(13 != order.getMerchantId() || order.getGiveOrderId() != null) {	// 不是YYDS商家 或者是精美卡片不赠送成长值
-			return;
-		}
-		BigDecimal refundFree = order.getRefundFee() == null ? BigDecimal.ZERO : order.getRefundFee();
-		BigDecimal amount=order.getActualPayment().subtract(refundFree);
-		if (amount.compareTo(BigDecimal.ZERO) != 1) {
-			return;
-		}
-		/*if(Constants.GROUP_SALE_MERCHANT_IDS.contains(orderInfos.getMerchantId())) { // 排除生态购商家
-			return;
-		}*/
-		Integer points = (amount.multiply(new BigDecimal(100))).intValue();
-		order.setPoint(points);
-		mineApiService.addUserPoint(order, true, Constants.POINT_TYPE_USER_GROWTH);
-		mineApiService.addUserPoint(order, true, Constants.POINT_TYPE_GOODS);
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-}

+ 0 - 94
poyi-app/src/main/java/com/tzy/listener/mq/OrderPayConsumer.java

@@ -1,94 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.app.dto.mq.OrderGoodsParam;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.framework.util.RedisUtils;
-import com.tzy.sportcard.api.service.GroupApiService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.DefaultTransactionDefinition;
-
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * 放弃执行
- * @author po'yi
- */
-@Slf4j
-//@Component
-public class OrderPayConsumer {
-    @Autowired
-    private GroupApiService groupApiService;
-    @Autowired
-    private DataSourceTransactionManager transactionManager;
-    @Autowired
-    private RedisUtils redisUtils;
-
-    private boolean assignCardGoods(OrderGoodsParam goodsParam){
-        String lockKey = "order_goods_lock_key" + goodsParam.getGroupInfoId();
-        boolean isLock=false;
-        //1.获取事务定义
-        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
-        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
-        def.setIsolationLevel(2);
-        TransactionStatus status=null;
-        try {
-            isLock = redisUtils.tryLock(lockKey, TimeUnit.SECONDS, 10L, 31L);
-            if (isLock) {
-                status = transactionManager.getTransaction(def);
-                //groupApiService.assignCardGoods(goodsParam);
-                //groupApiService.updateInfoData(goodsParam);
-                transactionManager.commit(status);
-                redisUtils.unlock(lockKey);
-                return true;
-            }
-        } catch (Exception e) {
-            log.error("卡密分配异常,参数:{}",goodsParam, e);
-            if(status!=null){
-                transactionManager.rollback(status);
-            }
-        } finally {
-            try {
-                if(isLock){
-                    redisUtils.unlock(lockKey);
-                }
-            } catch (Exception e) {
-                log.error("卡密分配锁释放异常:{}", goodsParam, e);
-            }
-        }
-        log.info("卡密分配提前结束,获取锁状态:{},参数:{}",isLock,goodsParam);
-        return false;
-    }
-
-    /**
-     * 支付回调消费
-     * @param data
-     * @param channel
-     * @param message
-     * @throws IOException
-     */
-    @RabbitHandler
-    @RabbitListener(queuesToDeclare=@Queue(MqConstans.QUEUE_ORDER_PAY_CALLBACK))
-    public void orderPayCallBack(OrderGoodsParam data, Channel channel, Message message) throws IOException {
-        try {
-            if(assignCardGoods(data)){
-                channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-                return;
-            }
-        } catch (Exception e) {
-            log.error("卡密分配消费失败,{}",data.toString(),e);
-        }
-        //失败后消息放回
-        channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
-    }
-}

+ 0 - 99
poyi-app/src/main/java/com/tzy/listener/mq/OrderSuccessConsumer.java

@@ -1,99 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.app.dto.mq.OrderSuccessParam;
-import com.tzy.common.constant.Constants;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.coupon.card.domain.AppUserCardRecord;
-import com.tzy.coupon.card.domain.TzyCardBaseInfo;
-import com.tzy.coupon.card.mapper.AppUserCardRecordMapper;
-import com.tzy.coupon.card.mapper.TzyCardBaseInfoMapper;
-import com.tzy.sportcard.api.service.AsyncAppService;
-import com.tzy.sportcard.group.domain.CardGroupOrderInfo;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.logging.log4j.util.Strings;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.DefaultTransactionDefinition;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.List;
-import java.util.stream.Collectors;
-
-
-@Slf4j
-@Component
-public class OrderSuccessConsumer {
-
-    @Autowired
-    private AsyncAppService asyncAppService;
-    @Autowired
-    private DataSourceTransactionManager transactionManager;
-    @Resource
-    private AppUserCardRecordMapper appUserCardRecordMapper;
-
-
-    private boolean orderPaySuccess(OrderSuccessParam param) {
-        //1.获取事务定义
-        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
-        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
-        def.setIsolationLevel(2);
-        TransactionStatus status = null;
-        try {
-            status = transactionManager.getTransaction(def);
-            //asyncAppService.orderPaySuccess(param.getOrderInfo(), param.getCardGroupInfo());
-            transactionManager.commit(status);
-            //expireUserFirstCoupon(param.getOrderInfo());
-            return true;
-        } catch (Exception e) {
-            log.error("订单异步执行错误,参数:{}", param, e);
-            if (status != null) {
-                transactionManager.rollback(status);
-            }
-        }
-        return false;
-    }
-
-    public void expireUserFirstCoupon(CardGroupOrderInfo cardGroupOrderInfo){
-        // 如果有首单券,未使用
-        Long userId = cardGroupOrderInfo.getUserId();
-        List<AppUserCardRecord> appUserCardRecordList = appUserCardRecordMapper.getUserFirstCoupons(userId);
-        if(CollectionUtils.isEmpty(appUserCardRecordList)) {
-            String orderType = cardGroupOrderInfo.getOrderType();
-            if (Constants.ORDER_TYPE_GROUP.equals(orderType)) {
-                // 拼团首单券未使用自动过期
-                List<Long> expireCardIds = appUserCardRecordList.stream()
-                        .filter(record -> Constants.COUPON_TYPE_CARD.equals(record.getUseScope()))
-                        .map(AppUserCardRecord::getId)
-                        .collect(Collectors.toList());
-                if (!CollectionUtils.isEmpty(expireCardIds)) {
-                    appUserCardRecordMapper.expireUserCardRecord(expireCardIds);
-                }
-            } else if (Constants.ORDER_TYPE_SHOP.equals(orderType)) {
-                // 商城首单券未使用自动过期
-                List<Long> expireGoodsIds = appUserCardRecordList.stream()
-                        .filter(record -> Constants.COUPON_TYPE_GOODS.equals(record.getSourceType()))
-                        .map(AppUserCardRecord::getId)
-                        .collect(Collectors.toList());
-                if (!CollectionUtils.isEmpty(expireGoodsIds)) {
-                    appUserCardRecordMapper.expireUserCardRecord(expireGoodsIds);
-                }
-            }
-        }
-    }
-    @RabbitHandler
-    @RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_ORDER_SUCCESS))
-    public void orderPaySuccessConsumer(OrderSuccessParam param, Channel channel, Message message) throws IOException {
-        orderPaySuccess(param);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    }
-}

+ 0 - 45
poyi-app/src/main/java/com/tzy/listener/mq/PayPreCallBackConsumer.java

@@ -1,45 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson2.JSON;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.sportcard.api.dto.ResourceData;
-import com.tzy.sportcard.api.service.AsyncAppService;
-import com.tzy.sportcard.api.service.GroupApiService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class PayPreCallBackConsumer {
-    @Autowired
-    private GroupApiService groupApiService;
-    @Resource
-    private AsyncAppService asyncAppService;
-
-
-    /**
-     * 回调前置消费
-     * @param data
-     * @param channel
-     * @param message
-     * @throws IOException
-     */
-    @RabbitHandler
-    @RabbitListener(queuesToDeclare=@Queue(MqConstans.QUEUE_PRE_PAY_CALLBACK))
-    public void payPreCallBack(String data, Channel channel, Message message) throws IOException {
-        //payCallBackConsumer(data, channel, message);
-    }
-
-}

+ 0 - 34
poyi-app/src/main/java/com/tzy/listener/mq/SuperLuckyBagConsumer.java

@@ -1,34 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.utils.bean.JSONTools;
-import com.tzy.luckybag.dto.LuckyBagMQDTO;
-import com.tzy.luckybag.service.IAppLiveLuckyBagService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-/**
- * 超级福袋开奖
- */
-@Slf4j
-@Component
-public class SuperLuckyBagConsumer {
-    @Resource
-    private IAppLiveLuckyBagService appLiveLuckyBagService;
-
-    @RabbitHandler
-    @RabbitListener(queues = MqConstans.QUEUE_SUPER_LUCK_BAG_EXPIRED)
-    public void superBagConsumer(String content, Channel channel, Message message)throws IOException {
-        log.info("超级福袋开奖 {}", content);
-        LuckyBagMQDTO luckyBagMQDTO = JSONTools.jsonStr2obj(content, LuckyBagMQDTO.class);
-        appLiveLuckyBagService.superBagLottery(luckyBagMQDTO);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    }
-}

+ 0 - 50
poyi-app/src/main/java/com/tzy/listener/mq/TestMqConsumer.java

@@ -1,50 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.app.dto.mq.TestParam;
-import com.tzy.common.constant.MqConstans;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class TestMqConsumer {
-
-
-    @RabbitHandler
-    @RabbitListener(queuesToDeclare=@Queue(MqConstans.TEST_QUEUE))
-    public void testMqConsumer(TestParam data, Channel channel, Message message) throws IOException {
-        log.info("test111收到消息:{}",data.toString());
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    }
-
-    //@RabbitHandler
-    //@RabbitListener(queuesToDeclare=@Queue(MqConstans.TEST_QUEUE+2))
-    //public void testMqConsumer2(TestParam data, Channel channel, Message message) throws IOException {
-    //    log.info("test2222收到消息:{}",data.toString());
-    //    channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    //}
-
-
-    // @RabbitHandler
-    // @RabbitListener(queuesToDeclare=@Queue("TestDirectQueueV2"))
-    // public void testMqConsumerV2(String data, Channel channel, Message message) throws IOException {
-    //     log.info("TestDirectQueueV2收到消息:{}",data);
-    //     channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    // }
-    //
-    // @RabbitHandler
-    // @RabbitListener(queuesToDeclare=@Queue("TestDirectQueueV3"))
-    // public void testMqConsumerV3(String data, Channel channel, Message message) throws IOException {
-    //     log.info("TestDirectQueueV3收到消息:{}",data);
-    //     channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    // }
-
-}

+ 0 - 83
poyi-app/src/main/java/com/tzy/listener/mq/UserInviteCodeConsumer.java

@@ -1,83 +0,0 @@
-//package com.tzy.listener.mq;
-//
-//import com.alibaba.fastjson.JSONObject;
-//import com.alibaba.fastjson2.JSON;
-//import com.rabbitmq.client.Channel;
-//import com.tzy.base.dto.DictBaseDto;
-//import com.tzy.base.service.SysBaseService;
-//import com.tzy.common.constant.Constants;
-//import com.tzy.common.constant.MqConstans;
-//import com.tzy.common.core.domain.entity.SysDictData;
-//import com.tzy.common.exception.ServiceException;
-//import com.tzy.coupon.card.service.IAppUserCardRecordService;
-//import com.tzy.sportcard.api.bean.act.UserListActParam;
-//import com.tzy.sportcard.api.service.GroupApiService;
-//import com.tzy.sportcard.base.service.CommonCacheService;
-//import com.tzy.sportcard.group.service.AppActService;
-//import lombok.extern.slf4j.Slf4j;
-//import org.springframework.amqp.core.Message;
-//import org.springframework.amqp.rabbit.annotation.Queue;
-//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-//import org.springframework.amqp.rabbit.annotation.RabbitListener;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.stereotype.Component;
-//
-//import javax.annotation.Resource;
-//import java.io.IOException;
-//import java.util.List;
-//
-//@Slf4j
-//@Component
-//public class UserInviteCodeConsumer {
-//        @Autowired
-//        private IAppUserCardRecordService appUserCardRecordService;
-//        @Resource
-//        private CommonCacheService commonCacheService;
-//        @Resource
-//        private GroupApiService groupApiService;
-//        @Resource
-//        private AppActService appActService;
-//        @Autowired
-//        private SysBaseService sysBaseService;
-//        @RabbitHandler
-//        @RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_USER_INVITE_CODE))
-//        public void userListActConsumer(String data, Channel channel, Message message) throws IOException {
-//            log.info("用户邀请码绑定消费:{}", data);
-//            try {
-//                //从data 的json结构解析出userId inviteCode parentUserId
-//                JSONObject sendData = JSONObject.parseObject(data);
-//                Long userId = sendData.getLong("userId");
-//                String inviteCode = sendData.getString("inviteCode");
-//                Long parentUserId = sendData.getLong("parentUserId");
-//                //查询数据字典 从中拿到商家邀请码配置的优惠券 并且发送给用户
-//
-//                List<SysDictData> sysDictDatas = commonCacheService.getCommonDictData(Constants.DICT_TYPE_INVITE_CODE,
-//                        null,"1", null, -1);
-//                //遍历优惠券列表  找到用户邀请的优惠券
-//                String couponDetail = null;
-//                String couponRemark = null;
-//                for (SysDictData sysDictData : sysDictDatas) {
-//                    if (sysDictData.getDictLabel().equals(inviteCode)) {
-//                        couponDetail = sysDictData.getDictValue();
-//                        couponRemark = sysDictData.getRemark();
-//                        JSONObject couponJson = JSONObject.parseObject(couponDetail);
-//                        Integer couponId = couponJson.getInteger("couponId");
-//                        Integer couponCount = couponJson.getInteger("couponCount");
-//                        int count = appUserCardRecordService.selectAppUserCardRecordCount(couponId.longValue());
-//                        if(count >= couponCount) {
-//                            log.error("用户{}绑定优惠券{}失败,优惠券不够", userId, inviteCode);
-//                            //throw new ServiceException("来晚了");
-//                        }else{
-//                            appUserCardRecordService.addUserCoupon(couponId, userId.intValue(), couponRemark, couponId.longValue(), Constants.DICT_TYPE_INVITE_CODE);
-//                            log.info("用户{}绑定邀请码{}成功", userId, inviteCode);
-//                        }
-//                    }
-//                }
-//
-//            } catch (Exception e) {
-//                log.error("用户邀请码绑定消费异常:{}", data, e);
-//            }
-//            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-//        }
-//
-//    }

+ 0 - 49
poyi-app/src/main/java/com/tzy/listener/mq/UserListActConsumer.java

@@ -1,49 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSON;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.Constants;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.sportcard.api.bean.act.UserListActParam;
-import com.tzy.sportcard.api.service.GroupApiService;
-import com.tzy.sportcard.group.service.AppActService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class UserListActConsumer {
-	@Resource
-	private GroupApiService groupApiService;
-	@Resource
-	private AppActService appActService;
-
-	@RabbitHandler
-	@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_USER_LIST_ACT))
-	public void userListActConsumer(String data, Channel channel, Message message) throws IOException {
-		log.info("panini_list收集活动开始:{}", data);
-		try {
-			UserListActParam listActParam = JSON.parseObject(data, UserListActParam.class);
-			if(appActService.isActSend(Constants.ORDER_TYPE_GROUP,listActParam.getGroupInfoId().intValue(), Constants.COLLECT_PANINI_ACT)){
-				log.info("活动已存在记录:{}",data);
-				return;
-			}
-			groupApiService.buildUserListActRecord(listActParam);
-			appActService.addActRecord(Constants.ORDER_TYPE_GROUP,listActParam.getGroupInfoId().intValue(), Constants.COLLECT_PANINI_ACT);
-		} catch (Exception e) {
-			log.error("panini list活动消费异常:{}", data, e);
-		}
-		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-	}
-
-
-
-}

+ 0 - 49
poyi-app/src/main/java/com/tzy/listener/mq/UserPointConsumer.java

@@ -1,49 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.Constants;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.sportcard.api.service.MineApiService;
-import com.tzy.sportcard.point.domain.AppUserPointRecord;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class UserPointConsumer {
-
-    @Autowired
-    private MineApiService mineApiService;
-
-    @RabbitHandler
-    @RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_USER_POINT))
-    public void addPointRecord(AppUserPointRecord pointRecord, Channel channel, Message message) throws IOException {
-        userPointConsumer(pointRecord, channel, message);
-    }
-
-    private void userPointConsumer(AppUserPointRecord pointRecord, Channel channel, Message message) throws IOException {
-        try {
-            mineApiService.addUserPoint(pointRecord);
-            /*if(Constants.POINT_TYPE_GOODS.equals(pointRecord.getType())){
-                pointRecord.setType(Constants.POINT_TYPE_USER_GROWTH);
-                mineApiService.addUserPoint(pointRecord);
-            }*/
-        } catch (Exception e) {
-            log.info("积分记录添加异常,参数:{}", pointRecord, e);
-        }
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    }
-
-
-
-
-
-}

+ 0 - 51
poyi-app/src/main/java/com/tzy/listener/mq/UserPointJsonConsumer.java

@@ -1,51 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSON;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.Constants;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.sportcard.api.service.MineApiService;
-import com.tzy.sportcard.point.domain.AppUserPointRecord;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-
-
-@Slf4j
-@Component
-public class UserPointJsonConsumer {
-
-    @Autowired
-    private MineApiService mineApiService;
-
-    @RabbitHandler
-    @RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_USER_POINT_JSON))
-    public void addPointRecord(String pointRecordStr, Channel channel, Message message) throws IOException {
-        userPointConsumer(pointRecordStr, channel, message);
-    }
-
-    private void userPointConsumer(String pointRecordStr, Channel channel, Message message) throws IOException {
-        try {
-            AppUserPointRecord pointRecord = JSON.parseObject(pointRecordStr, AppUserPointRecord.class);
-            mineApiService.addUserPoint(pointRecord);
-            if(Constants.POINT_TYPE_GOODS.equals(pointRecord.getType())){
-                pointRecord.setType(Constants.POINT_TYPE_USER_GROWTH);
-                mineApiService.addUserPoint(pointRecord);
-            }
-        } catch (Exception e) {
-            log.info("积分记录添加异常,参数:{},异常", pointRecordStr, e);
-        }
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    }
-
-
-
-
-
-}

+ 0 - 54
poyi-app/src/main/java/com/tzy/listener/mq/UserWinCardConsumer.java

@@ -1,54 +0,0 @@
-package com.tzy.listener.mq;
-
-import com.alibaba.fastjson2.JSONObject;
-import com.rabbitmq.client.Channel;
-import com.tzy.common.constant.Constants;
-import com.tzy.common.constant.MqConstans;
-import com.tzy.common.dto.group.SyncUserWinCardDTO;
-import com.tzy.framework.util.RedisUtils;
-import com.tzy.sportcard.api.service.IAppUserWinCardService;
-import com.tzy.sportcard.api.service.ICardReportService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-
-
-/**
- * es 卡密数据同步
- */
-@Slf4j
-@Component
-public class UserWinCardConsumer {
-	@Resource
-	private IAppUserWinCardService appUserWinCardService;
-	@Resource
-	private RedisUtils redisUtils;
-
-	@RabbitHandler
-	@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_SYNC_USER_WIN_CARD))
-	public void syncUserWinCardConsumer(String param, Channel channel, Message message) throws IOException {
-		log.info("同步用户中卡,参数:{}", param);
-		String key="win_card_count_" + param;
-		long count = redisUtils.incr(key, 1);
-		redisUtils.expire(key, 30);
-		try {
-			SyncUserWinCardDTO syncParam = JSONObject.parseObject(param, SyncUserWinCardDTO.class);
-			if (Constants.ORDER_TYPE_GROUP.equals(syncParam.getType())) {
-				appUserWinCardService.syncGroupWindCard(syncParam.getIds());
-			} else {
-				appUserWinCardService.syncShopOrderWindCard(syncParam.getIds());
-			}
-			channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-		} catch (Exception e) {
-			log.error("同步用户中卡异常,参数:{}", param, e);
-			channel.basicAck(message.getMessageProperties().getDeliveryTag(), count<3);
-		}
-	}
-
-}

+ 1 - 1
poyi-app/src/main/resources/application-druid.yml

@@ -8,7 +8,7 @@ spring:
             master:
                 username: postgres
                 password: 123456
-                url: jdbc:postgresql://192.168.50.10:5432/ahx_app
+                url: jdbc:postgresql://192.168.50.8:5432/ahx_app
             # 初始连接数
             initialSize: 5
             # 最小连接池数量

+ 210 - 1
poyi-app/src/main/resources/application.yml

@@ -135,7 +135,30 @@ spring:
         retry:
           enabled: true
           max-attempts: 1
-
+  flyway:
+    # 是否启用flyway
+    enabled: false
+    # 指定表
+    table: flyway_schema_history_app
+    # 禁止清理数据库表
+    clean-disabled: true
+    # 编码格式,默认UTF-8
+    encoding: UTF-8
+    # 迁移sql脚本文件存放路径,默认db/migration
+    locations: classpath:db/migration
+    # 迁移sql脚本文件名称的前缀,默认V
+    sql-migration-prefix: V
+    # 迁移sql脚本文件名称的分隔符,默认2个下划线__
+    sql-migration-separator: _
+    # 迁移sql脚本文件名称的后缀
+    sql-migration-suffixes: .sql
+    # 迁移时是否进行校验,默认true
+    validate-on-migrate: true
+    # 当迁移发现数据库非空且存在没有元数据的表时,自动执行基准迁移,新建schema_version表
+    baseline-on-migrate: true
+    url: ${DB_URL:jdbc:postgresql://192.168.50.8:5432/ahx_app}
+    user: ${DB_USERNAME:postgres}
+    password: ${DB_PASSWORD:123456}
   mail:
     host: smtp.exmail.qq.com
     port: 465
@@ -170,6 +193,192 @@ pagehelper:
 swagger:
   # 是否开启swagger
   enabled: true
+pay:
+  #微信支付
+  wxpay:
+    app:
+      appID: wx8ee47a255776f241
+      appletID: wx8ee47a255776f241
+      thirdAndriID: wx22a7349c29e688d4
+      mchID: 1612475613
+      key: 123456789123456789123456789abcdd
+      #微信商户平台下载的安全证书存放路径
+      certPath: /home/tzy/wxpay/cert/apiclient_cert.p12
+      #微信支付成功的回调地址
+      payNotifyUrl: https://m2-dev.hobbystock.cn/py-app/api/wx/paymentBack
+      refundNotifyUrl: https://m2-dev.hobbystock.cn/py-app/api/wx/refundBack
+  alipay:
+    app:
+      #      appId: 2021002181641642
+      #      privateKey:
+      #      alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyFERiu5uSV4UZTsA2OMp/rPVcIq2ggtLSWXMzOwwJDrZBTM1XCL+j6CbRjU9gaEbFFwPPb7Qt1AQMV6YaXh0uyDubI+53PHwDF6UgpDNAo9tQI8amMf+xyB7+w1hPZwIItc7nS5ABWvZ1nEOuj9xoAXo5MmibFYkcCu42tvmwCc0bVwDuBMHmh595QPZPf1r11qVLBTeUOOeWP6m0nZckLQJxuTDW55i76OGRyllM5VEJACv7X8gxlE3x90nwRQO6KQxRdG9UcTQKQTYEnQVDrDs8ePfJ8N1GktYBkgA6Cc1iQhA4Ttqe7y9bLpu58KrG7kZHaj4iVnZm64/TU3LkQIDAQAB
+      #      privateKeyPath: /home/tzy/alipay/privatekey.txt
+      # 生产
+      appId: 2021002181669560
+      privateKey:
+      alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgCIKpTwnnPm2D1IsMlTvuCq3WBAZKm8IaUqR/IxqQAzwEVuW0+lf6Ririm4PLNcU5eZXK7w+oHqi23b7rL5htqz1K0/q/oBHEeAliCNX+zMr+6sTBN33i5yX/buvVmBPGJJg791lFdnnnELGqZf+nQrJBlOAW/aCVTga7hcf8CH/ZRDboExzf9zK5N6qcxKexsgXZRZso+d47DcAj3sF1lAcYQvTAOG+aJRcwBFFOrb3QYZI1WLOZdjq3kdhXUuVrR8HhQ68BRIvfJGX7Hwy4Ffmb9hD/ljkT1S6+jzslMp3cMbU4IlJPF0o9xxCz4KWiW0pWhwQTolNVqW3GyHG2wIDAQAB
+      privateKeyPath: D:\java\poyi\privatekey.txt
+      #支付宝支付成功的回调地址
+      payNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/ali/paymentBack
+      refundNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/ali/refundBack
+    app1: #支付宝直连-备用1
+      # 生产
+      appId: 2021003126686832
+      privateKey:
+      alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl1uBO6TTbULTrIfNCErfTCSywYIJensWk7Rcsa4uMbvzQGYH/tL2rKwH+YaMeVkbZGFdVHGDn4NIzYTFjl+r0ePDreDzAntUOhH6vypHxh6MkIKszQPSAj1SR2y34WXkI2tCjmFHIhSIwpnz0le1DERa4MxgUPtfgGAPDOTEfPRW5tlNfIamPYdXOtaP7w6PBk7aq5+cW0zAsQJBIJrxOye9JCuXBUd78EyB8aBxXdgdjJ6cq0oW0jSqup5LHcZnl9xKAVzgEGnALHqmIBijArCE7+rxFtE40Vg6UqDE5bY5FqazkuZ7uoiJOg7oUcP4OqTz2MAQf8AMD/hQGw6llwIDAQAB
+      privateKeyPath: D:\java\poyi\hs\privatekey.txt
+      #支付宝支付成功的回调地址
+      payNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/ali/paymentBack
+      refundNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/ali/refundBack
+  hm:
+    app:
+      hmPublicKey: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkByRMw/sL8tg38lrGi4JFXFR/jrphyyj3LYHYYnTQj3dl+w4JUysgE7cE7FxEfxMkuM3efv6HeMP0vIsYBrS7EXvVB9vm/HH7QcpvqCfUOLhe4ugaDqfKz9/2BQinieiSRy8gRnm5eadEZn42EtxnZ+s6PBPKeijrxz+JyvCR8QIDAQAB
+      publicKey: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCJBww/AEqKfofkDGP+EkIKC5r4oHw93O6qFJ5QCnGgNMd5MC3q4Pyk6ImOjSj/OdRqTefRdWZUzcjlEPxMBLARa1wqKcdw4f2Wyxr+eT+VcJSQu5F8zWYjtNO+9BVwpKqJ4CXYPyZqY8fAx0urrd9opRkV0xpK3f/mlkgbgF+XvQIDAQAB
+      privateKeyPath: D:\java\poyi\pay\hm\privatekey.txt
+      wxMchID: 480528577
+      app_id: 663101000155258
+      format: JSON
+      version: 1.0
+      storeId: 100001
+      #支付宝支付成功的回调地址
+      host:
+      payNotifyUrl: https://m2-dev.hobbystock.cn/py-app/api/hm/paymentBack
+      refundNotifyUrl: https://m2-dev.hobbystock.cn/py-app/api/hm/refundBack
+      returnUrl: https://m.hobbystock.cn/py-app/api/hm/refundBack
+  qm:
+    app:
+      appid: 8a81c1bd7f93c875018045cd46d3075e
+      subAppId: wx22a7349c29e688d4
+      appKey: 40f65789bd064198a36430b4c0f12732
+      mid: 89831995399APPA #898340149000005 #商户号
+      tid: APPA0001 #'00000001' #终端号
+      msgSrcId: 13RZ #来源编号
+      #      msgUri: WWW.SHBRDZSW.COM #消息来源
+      privateKeyPath: D:\java\poyi\pay\qm\qmPrivatekeyProd.txt
+      instMid: APPDEFAULT #业务类型 (APP支付) 机构商户号
+      payFlag: P000001 #支付标记
+      refundFlag: R000002 #退款标记
+      #回调地址
+      payNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/qm/paymentBack
+      refundNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/qm/refundBack
+      showUrl:  #订单展示页面
+      sub_mid: 89831995399APPB #上海青藏电子商务有限公司,
+      sub_tid: APPB0001 #上海青藏电子商务有限公司,
+    # 全民资管
+    am:
+      ip: 180.169.95.129
+      userName: SHPYDZ_fan
+      pwd: aL1Jn$kg
+      merchantNo: SHPYDZ #商户集团编号 默认
+      businessUserNo: 89831995399APPA #企业用户号  默认
+      sub_businessUserNo: 89831995399APPB #企业用户号-划付入网商户号  默认
+      upPublicKeyPath: D:\java\poyi\pay\qm\am\pyPublicKey.cer #/home/tzy/qm/am/upPublicKey.cer #商户回盘验签公钥
+      upPrivateKeyPath: /home/tzy/qm/am/pyPrivateKey.pfx #/home/tzy/qm/am/upPrivateKey.pfx #商户加签私钥
+      upPrivateKeyPwd: 880615sandy #123456 #私钥密码
+      dwPublicKeyPath: D:\java\poyi\pay\qm\am\dwPublicKey-prod.cer #商户回盘验签公钥(生产)
+    #全民h5支付
+    h5:
+      appid: 8a81c1bd7f93c875018045cd46d3075e #10037e6f66f2d0f901672aa27d690006
+      subAppId: wx22a7349c29e688d4
+      appKey: 40f65789bd064198a36430b4c0f12732 #47ace12ae3b348fe93ab46cee97c6fde
+      mid_ali: 89831995399APPG #898201612345678 #用于支付宝和云闪付
+      mid_uac: #898310173992585 #用于银联在线无卡
+      mid_wxh5: #898340149000687 #用户h5微信小程序
+      tid: APPG0001 #88880001 #'00000001'
+      msgSrcId: 13RZ #1017 #来源编号
+      privateKeyPath: D:\java\poyi\pay\qm\qmPrivatekeyProd.txt
+      instMid: H5DEFAULT #业务类型 (H5支付)
+      payFlag: P000002 #支付标记
+      refundFlag: R000003 #退款标记
+      #回调地址
+      payNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/qm/paymentBack
+      refundNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/qm/refundBack
+      showUrl:  #订单展示页面
+  qm1:
+    app:
+      appid: 8a81c1bd7f93c875018045cd46d3075e
+      subAppId: wx22a7349c29e688d4
+      appKey: 40f65789bd064198a36430b4c0f12732
+      mid: 89831995399APPA #89831995399APPA
+      tid: APPA0001 #'00000001'
+      sub_mid: 89831995399APPB #89831995399APPA
+      sub_tid: APPB0001 #'00000001'
+      msgSrcId: 13RZ #来源编号
+      privateKeyPath: D:\java\poyi\pay\qm\qmPrivatekeyProd.txt
+      instMid: APPDEFAULT #业务类型 (APP支付)
+      payFlag: P000001 #支付标记
+      refundFlag: R000002 #退款标记
+      #回调地址
+      payNotifyUrl: https://m2-dev.hobbystocks.cn/api/qm/paymentBack
+      refundNotifyUrl: https://m2-dev.hobbystocks.cn/api/qm/refundBack
+      showUrl:  #订单展示页面
+  qm2:
+    app:
+      appid: 8a81c1bd7f93c875018045cd46d3075e
+      subAppId: wx22a7349c29e688d4
+      appKey: 40f65789bd064198a36430b4c0f12732
+      mid: 89831995399APPA #89831995399APPA
+      tid: APPA0001 #'00000001'
+      sub_mid: 89831995399APPC #89831995399APPA
+      sub_tid: APPC0001 #'00000001'
+      msgSrcId: 13RZ #来源编号
+      privateKeyPath: D:\java\poyi\pay\qm\qmPrivatekeyProd.txt
+      instMid: APPDEFAULT #业务类型 (APP支付)
+      payFlag: P000001 #支付标记
+      refundFlag: R000002 #退款标记
+      #回调地址
+      payNotifyUrl: https://m2-dev.hobbystocks.cn/api/qm/paymentBack
+      refundNotifyUrl: https://m2-dev.hobbystocks.cn/api/qm/refundBack
+      showUrl:  #订单展示页面
+
+  bf:
+    app:
+      format: JSON
+      appid: 818000802925 #814000473149 #商户在慧收钱的商户号,由慧收钱生成并下发
+      signType: RSA2
+      subMerchantNo: #门店编号
+      version: 1.0 #接口版本:1.0
+      privateKeyPath: D:\java\poyi\pay\bf\bfPrivateKey.pfx
+      privatePwd: 880615sandy
+      publicKeyPath: D:\java\poyi\pay\bf\bfPublicKey.cer
+      key: 7c16c26a6c5550289ab65e6a69e89ee1 #86a8eec5ae958e9948b7450439cc57e2
+      #回调页面
+      payNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/bf/paymentBack #后端通知地址
+      refundNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/bf/refundBack #后端通知地址
+      pageUrl: #前台通知地址
+  #汇付
+  hf:
+    app:
+      appid: app_db57e4cc-6324-430a-9ffc-dd836f412cb9
+      apiKey: api_live_62f4a9d5-905e-4d64-85f0-136a9c0620a5
+      apiMockKey: api_test_29708ffc-1d3f-4b24-8e7b-60073b138b9e
+      RSAPrivateKey: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIl2NugFoWa+HUk/xQyUx69u85pC7vbtZbtOWjD3Yqt6PnE7mT6B4GOf7lDYd4NrggzPaJ067yo8xv8GCNla+flP7KbRhbrp6h+U4L3NX32PQSvZJWjnGxUkOm+tDp3PfBPl48pf8/X7oocafn0ZGqZslNZh8/BTVJhwOi52G8i3AgMBAAECgYBPXbi/6BhTaOsh0rbj17cffHEcHQ859MFrDwcWBI+ssC0DVcTaCUTUYI/Jj+IZN+ZjnREqzs8t1N+UeRh83oE676Gl/+dQVgeQ7muugoCZ0FI7kEKsFQILSSXq0wAC7kfZJv3fVs3p9WEyjd9e90nWqO45vszAuCAijnIRV8vGeQJBALyvvgJGAGfMCqqFZdMdk9C+SEf8rjtuTezQzHOAw+kIYvyZZvmCeJRbYbZ7myoa6QaVquy52MSR2IDZyqPsQhUCQQC6gD++Gl/jhWsWejAl1VaMLq+sGQYtAp+rt5OQMAHebDnMgovoTjWXpLocDA0IPFNGuHjvsxN43J3OUOe1cC6bAkBN9D2IKuuX9pChiqNa6WlcYID0XMyO+S9wm4McZSKLcE+VFLuacfDnOinQfpjIeH21nrgTPWT1MVxFP7Wcq8tRAkEApIDhOL6s29RgK/hlJcnyyD2Z6LQ99U++JUoM1/7wdw+BP/najHMH5JWBL6IVkLEdR2EKE2wifdYjP8uvRiQIhwJABYPLM4gq099OjkyA9U0zm8bbKqFDQYdrRhmDUjUiojFw9QHlck7BcBc01PmUjg7TN5uBTWyTTJY7pOWtS7s6Ag==
+      RSAPublicKey: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB
+      deviceId:
+      merchantKey: '00003489'
+      debug: true
+      prodMode: true
+      #回调
+      notify_url: https://m2-dev.hobbystocks.cn/api/hf/paymentBack #支付通知地址
+      reverseNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/hf/reverseBack #撤销交易通知地址
+      refundNotifyUrl: https://m2-dev.hobbystocks.cn/py-app/api/hf/refundBack #退款通知地址
+    #钱包
+  recharge:
+    base: https://purchase-dev.hobbystocks.cn/pay/
+    wallet: https://purchase-dev.hobbystocks.cn/pay/api/v1/recharge/walletInfo #钱包余额
+    banks: https://purchase-dev.hobbystocks.cn/pay/api/v1/recharge/searchBindBanks #钱包银行卡列表
+    expend: https://bid-dev.auction.hobbystocks.cn/order/p1/api/order/rechargeExpendCallBack #钱包消费记录
+  server:
+    payType: https://bid-dev.auction.hobbystocks.cn/pay/p1/api/remotePayChannel/list #支付配置列表
+    unified: https://bid-dev.auction.hobbystocks.cn/pay/p1/v2/unified #下单
+    query: https://bid-dev.auction.hobbystocks.cn/pay/p1/query #查询
+    refund: https://bid-dev.auction.hobbystocks.cn/pay/p1/v2/refund #退款
+    readPay: https://bid-dev.auction.hobbystocks.cn/pay/p1/readPay #汇付创建支付对象
+    confirmPay: https://bid-dev.auction.hobbystocks.cn/pay/p1/confirmPay #汇付确认支付
+    bankList: https://bid-dev.auction.hobbystocks.cn/pay/p1/bankList #汇付确认支付
+#直播间webSocket地址
+liveWebSocketUrl: http://poyee-im/chat/handler
+
 
  #融云配置
 rongcloud:

+ 3 - 3
poyi-pojo/pom.xml

@@ -59,9 +59,9 @@
             <artifactId>jackson-databind</artifactId>
         </dependency>
         <dependency>
-            <groupId> org.springframework.boot </groupId>
-            <artifactId> spring-boot-configuration-processor </artifactId>
-            <optional> true </optional>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+            <optional>true</optional>
         </dependency>
 
     </dependencies>

+ 2 - 0
tzy-common/pom.xml

@@ -63,6 +63,7 @@
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
+            <version>3.18.0</version>
         </dependency>
 
 
@@ -94,6 +95,7 @@
         <dependency>
             <groupId>org.yaml</groupId>
             <artifactId>snakeyaml</artifactId>
+            <version>2.0</version>
         </dependency>
 
         <!-- servlet包 -->

+ 58 - 1
tzy-framework/pom.xml

@@ -30,7 +30,7 @@
         <dependency>
             <groupId>org.redisson</groupId>
             <artifactId>redisson</artifactId>
-            <version>3.5.0</version>
+            <version>3.22.0</version>
         </dependency>
         <!-- 验证码 -->
         <dependency>
@@ -54,6 +54,63 @@
             <artifactId>jjwt</artifactId>
             <version>0.9.0</version>
         </dependency>
+        <!--微信支付 -->
+        <dependency>
+            <groupId>com.github.wxpay</groupId>
+            <artifactId>wxpay-sdk</artifactId>
+            <version>0.0.3</version>
+        </dependency>
+        <!--支付宝支付-->
+        <dependency>
+            <groupId>com.alipay.sdk</groupId>
+            <artifactId>alipay-sdk-java</artifactId>
+            <version>4.16.50.ALL</version>
+        </dependency>
+        <!--河马付-->
+        <dependency>
+            <groupId>cn.com.sand</groupId>
+            <artifactId>hmpay-sdk</artifactId>
+            <version>1.1.4</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/src/main/resources/lib/hmpay-sdk-1.1.4.jar</systemPath>
+        </dependency>
+        <!--汇付-->
+        <dependency>
+            <groupId>com.huifu.adapay</groupId>
+            <artifactId>adapay-core-sdk</artifactId>
+            <version>1.2.10</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/src/main/resources/lib/adapay-core-sdk-1.2.10.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>com.huifu.adapay</groupId>
+            <artifactId>adapay-core-sdk-sources</artifactId>
+            <version>1.2.10</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/src/main/resources/lib/adapay-core-sdk-1.2.10-sources.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>com.huifu.adapay</groupId>
+            <artifactId>adapay-java-sdk</artifactId>
+            <version>1.2.10</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/src/main/resources/lib/adapay-java-sdk-1.2.10.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>com.huifu.adapay</groupId>
+            <artifactId>adapay-java-sdk-sources</artifactId>
+            <version>1.2.10</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/src/main/resources/lib/adapay-java-sdk-1.2.10-sources.jar</systemPath>
+        </dependency>
+        <!--  银联商务-沈阳sdk     -->
+        <dependency>
+            <groupId>com.jeequan.jeepay</groupId>
+            <artifactId>pay-sdk-java</artifactId>
+            <version>1.5.0</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/src/main/resources/lib/pay-sdk-java-1.5.0.jar</systemPath>
+        </dependency>
         <!--sftp-->
         <dependency>
             <groupId>org.lucee</groupId>

+ 30 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/Entity/MktInfoEntity.java

@@ -0,0 +1,30 @@
+/**
+ * 
+ */
+/**
+ * @author dasheng
+ * 分账明细
+ */
+package com.tzy.framework.pay.Entity;
+
+public class MktInfoEntity{	
+	String mktMerId;
+	String mktAmt;//营销金额,单位:分;
+	public String getMktMerId() {
+		return mktMerId;
+	}
+	public void setMktMerId(String mktMerId) {
+		this.mktMerId = mktMerId;
+	}
+	public String getMktAmt() {
+		return mktAmt;
+	}
+	public void setMktAmt(String mktAmt) {
+		this.mktAmt = mktAmt;
+	}
+	@Override
+	public String toString() {
+		return "MktInfoEntity [mktMerId=" + mktMerId + ", mktAmt=" + mktAmt + "]";
+	}
+	
+}

+ 25 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/Entity/MktRefundInfoEntity.java

@@ -0,0 +1,25 @@
+/**
+ * 
+ */
+/**
+ * @author dasheng
+ *
+ */
+package com.tzy.framework.pay.Entity;
+
+public class MktRefundInfoEntity{
+	String mktMerId;
+	String mktAmt;
+	public String getMktMerId() {
+		return mktMerId;
+	}
+	public void setMktMerId(String mktMerId) {
+		this.mktMerId = mktMerId;
+	}
+	public String getMktAmt() {
+		return mktAmt;
+	}
+	public void setMktAmt(String mktAmt) {
+		this.mktAmt = mktAmt;
+	}
+}

+ 133 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/Entity/PostMasterEntity.java

@@ -0,0 +1,133 @@
+/**
+ * 
+ */
+/**
+ * @author dasheng
+ *
+ */
+package com.tzy.framework.pay.Entity;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class PostMasterEntity{	
+	String merId;
+	String terId;
+	String method;
+	String charset;
+	String version;
+	String format;
+	String timestamp;
+	String signType;
+	String signSn;
+	String ncrptnSn;
+	String dgtlEnvlp;
+	String signStr;
+	String bizContent;
+	public PostMasterEntity(){
+		this.charset = "UTF-8";
+		this.version="1.0";
+		this.format="json";
+		String txnTime=new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());//报文发送日期时间
+		this.timestamp=txnTime;
+		this.signType = "RSA";
+		this.signSn="1";
+		this.ncrptnSn = "1";
+		this.dgtlEnvlp="";
+	}
+	public String getMerId() {
+		return merId;
+	}
+	public void setMerId(String merId) {
+		this.merId = merId;
+	}
+	public String getTerId() {
+		return terId;
+	}
+	public void setTerId(String terId) {
+		this.terId = terId;
+	}
+	public String getMethod() {
+		return method;
+	}
+	public void setMethod(String method) {
+		this.method = method;
+	}
+	public String getCharset() {
+		return charset;
+	}
+	public void setCharset(String charset) {
+		this.charset = charset;
+	}
+	public String getVersion() {
+		return version;
+	}
+	public void setVersion(String version) {
+		this.version = version;
+	}
+	public String getFormat() {
+		return format;
+	}
+	public void setFormat(String format) {
+		this.format = format;
+	}
+	public String getTimestamp() {
+		return timestamp;
+	}
+	public void setTimestamp(String timestamp) {
+		this.timestamp = timestamp;
+	}
+	public String getSignType() {
+		return signType;
+	}
+	public void setSignType(String signType) {
+		this.signType = signType;
+	}
+	public String getSignSn() {
+		return signSn;
+	}
+	public void setSignSn(String signSn) {
+		this.signSn = signSn;
+	}
+	public String getNcrptnSn() {
+		return ncrptnSn;
+	}
+	public void setNcrptnSn(String ncrptnSn) {
+		this.ncrptnSn = ncrptnSn;
+	}
+	public String getDgtlEnvlp() {
+		return dgtlEnvlp;
+	}
+	public void setDgtlEnvlp(String dgtlEnvlp) {
+		this.dgtlEnvlp = dgtlEnvlp;
+	}
+	public String getSignStr() {
+		return signStr;
+	}
+	public void setSignStr(String signStr) {
+		this.signStr = signStr;
+	}
+	public String getBizContent() {
+		return bizContent;
+	}
+	public void setBizContent(String bizContent) {
+		this.bizContent = bizContent;
+	}
+	
+	@Override
+	public String toString() {
+		return "PostMasterEntity [merId=" + merId + ", terId=" + terId + ", method=" + method + ", charset=" + charset
+				+ ", version=" + version + ", format=" + format + ", timestamp=" + timestamp + ", signType=" + signType
+				+ ", signSn=" + signSn + ", ncrptnSn=" + ncrptnSn + ", dgtlEnvlp=" + dgtlEnvlp + ", signStr=" + signStr
+				+ ", bizContent=" + bizContent + "]";
+	}
+	
+	public String getParmFormat(){
+		return "merId=" + merId + "&terId=" + terId + "&method=" + method + "&charset=" + charset
+				+ "&version=" + version + "&format=" + format + "&timestamp=" + timestamp + "&signType=" + signType
+				+ "&signSn=" + signSn + "&ncrptnSn=" + ncrptnSn + "&dgtlEnvlp=" + dgtlEnvlp + "&signStr=" + signStr
+				+ "&bizContent=" + bizContent;
+	}
+	
+
+}

+ 29 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/Entity/ResultMasterEntity.java

@@ -0,0 +1,29 @@
+/**
+ * 
+ */
+/**
+ * @author dasheng
+ *
+ */
+package com.tzy.framework.pay.Entity;
+
+import lombok.Data;
+
+@Data
+public class ResultMasterEntity{	
+	String merId;
+	String terId;
+	String charset;
+	String version;
+	String format;
+
+	String returnMsg;
+	String returnCode;
+
+	String signType;
+	String signSn;
+	String ncrptnSn;
+	String signStr;
+	String dataContent;
+
+}

+ 31 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/Entity/RiskInfoEntity.java

@@ -0,0 +1,31 @@
+/**
+ * 
+ */
+/**
+ * @author dasheng
+ * 分账明细
+ */
+package com.tzy.framework.pay.Entity;
+
+public class RiskInfoEntity{	
+	String clientIp;//付款用户ip地址
+	String locationPoint;//包含经度和纬度,英文逗号分隔;
+	public String getClientIp() {
+		return clientIp;
+	}
+	public void setClientIp(String clientIp) {
+		this.clientIp = clientIp;
+	}
+	public String getLocationPoint() {
+		return locationPoint;
+	}
+	public void setLocationPoint(String locationPoint) {
+		this.locationPoint = locationPoint;
+	}
+	@Override
+	public String toString() {
+		return "RiskInfoEntity [clientIp=" + clientIp + ", locationPoint=" + locationPoint + "]";
+	}
+	
+	
+}

+ 29 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/Entity/SharingDetailsEntity.java

@@ -0,0 +1,29 @@
+/**
+ * 
+ */
+/**
+ * @author dasheng
+ * 分账明细
+ */
+package com.tzy.framework.pay.Entity;
+
+public class SharingDetailsEntity{	
+	String sharingMerId;
+	String sharingAmt;//分账金额,单位:分;
+	public String getSharingMerId() {
+		return sharingMerId;
+	}
+	public void setSharingMerId(String sharingMerId) {
+		this.sharingMerId = sharingMerId;
+	}
+	public String getSharingAmt() {
+		return sharingAmt;
+	}
+	public void setSharingAmt(String sharingAmt) {
+		this.sharingAmt = sharingAmt;
+	}
+	@Override
+	public String toString() {
+		return "SharingDetailsEntity [sharingMerId=" + sharingMerId + ", sharingAmt=" + sharingAmt + "]";
+	}
+}

+ 39 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/Entity/SharingInfoEntity.java

@@ -0,0 +1,39 @@
+/**
+ * 
+ */
+/**
+ * @author dasheng
+ * terminal_info 终端信息参数     支付方式为:WECHAT_MICROPAY该字段必填
+ */
+package com.tzy.framework.pay.Entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SharingInfoEntity{	
+	String sharingNotifyUrl;
+	List<SharingDetailsEntity> sharingDetails;
+	
+	public SharingInfoEntity(){
+		this.sharingDetails = new ArrayList<SharingDetailsEntity>();
+	}
+	public String getSharingNotifyUrl() {
+		return sharingNotifyUrl;
+	}
+	public void setSharingNotifyUrl(String sharingNotifyUrl) {
+		this.sharingNotifyUrl = sharingNotifyUrl;
+	}
+	public List<SharingDetailsEntity> getSharingDetails() {
+		return sharingDetails;
+	}
+	public void setSharingDetails(SharingDetailsEntity sharingDetails) {
+		this.sharingDetails.add(sharingDetails);
+	}
+	@Override
+	public String toString() {
+		return "SharingInfoEntity [sharingNotifyUrl=" + sharingNotifyUrl + ", sharingDetails=" + sharingDetails + "]";
+	}
+	
+	
+
+}

+ 25 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/Entity/SharingRefundInfoEntity.java

@@ -0,0 +1,25 @@
+/**
+ * 
+ */
+/**
+ * @author dasheng
+ *
+ */
+package com.tzy.framework.pay.Entity;
+
+public class SharingRefundInfoEntity{
+	String sharingMerId;
+	String sharingAmt;
+	public String getSharingMerId() {
+		return sharingMerId;
+	}
+	public void setSharingMerId(String sharingMerId) {
+		this.sharingMerId = sharingMerId;
+	}
+	public String getSharingAmt() {
+		return sharingAmt;
+	}
+	public void setSharingAmt(String sharingAmt) {
+		this.sharingAmt = sharingAmt;
+	}
+}

+ 246 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/Entity/TerminalInfoEntity.java

@@ -0,0 +1,246 @@
+/**
+ * 
+ */
+/**
+ * @author dasheng
+ * terminal_info 终端信息参数     支付方式为:WECHAT_MICROPAY该字段必填
+ */
+package com.tzy.framework.pay.Entity;
+
+public class TerminalInfoEntity{	
+	String location;
+	String network_license;
+	String device_type;
+	String serial_num;
+	String terminal_id;////终端设备的硬件序列号---支付宝,
+	String device_id;///-终端设备号----微信,
+	String encrypt_rand_num;
+	String secret_text;
+	String app_version;
+	String device_ip;
+	String mobile_country_cd;
+	String mobile_net_num;
+	String icc_id;
+	String location_cd1;
+	String lbs_num1;
+	String lbs_signal1;
+	String location_cd2;
+	String lbs_num2;
+	String lbs_signal2;
+	String location_cd3;
+	String lbs_num3;
+	String lbs_signal3;
+	String telecom_sys_id;
+	String telecom_net_id;
+	String telecom_lbs;
+	String telecom_lbs_signal;
+	
+	public TerminalInfoEntity(String payCode,String Deviceid){
+		this.location="";
+		this.network_license="";
+		this.device_type="";
+		this.serial_num="";
+		this.device_id="";
+		this.terminal_id="";
+		if(payCode.startsWith("WECHAT")){
+			this.device_id= Deviceid;///-终端设备号
+		}else if(payCode.startsWith("ALIPAY")){
+			this.terminal_id=Deviceid;
+		}
+		
+		this.encrypt_rand_num="";
+		this.secret_text="";
+		this.app_version="";
+		this.device_ip="";
+		this.mobile_country_cd="";
+		this.mobile_net_num="";
+		this.icc_id="";
+		this.location_cd1="";
+		this.lbs_num1="";
+		this.lbs_signal1="";
+		this.location_cd2="";
+		this.lbs_num2="";
+		this.lbs_signal2="";
+		this.location_cd3="";
+		this.lbs_num3="";
+		this.lbs_signal3="";
+		this.telecom_sys_id="";
+		this.telecom_net_id="";
+		this.telecom_lbs="";
+		this.telecom_lbs_signal="";
+	}
+	
+	public String getLocation() {
+		return location;
+	}
+	public void setLocation(String location) {
+		this.location = location;
+	}
+	public String getNetwork_license() {
+		return network_license;
+	}
+	public void setNetwork_license(String network_license) {
+		this.network_license = network_license;
+	}
+	public String getDevice_type() {
+		return device_type;
+	}
+	public void setDevice_type(String device_type) {
+		this.device_type = device_type;
+	}
+	public String getSerial_num() {
+		return serial_num;
+	}
+	public void setSerial_num(String serial_num) {
+		this.serial_num = serial_num;
+	}
+	public String getDevice_id() {
+		return device_id;
+	}
+	public void setDevice_id(String device_id) {
+		this.device_id = device_id;
+	}
+	public String getEncrypt_rand_num() {
+		return encrypt_rand_num;
+	}
+	public void setEncrypt_rand_num(String encrypt_rand_num) {
+		this.encrypt_rand_num = encrypt_rand_num;
+	}
+	public String getSecret_text() {
+		return secret_text;
+	}
+	public void setSecret_text(String secret_text) {
+		this.secret_text = secret_text;
+	}
+	public String getApp_version() {
+		return app_version;
+	}
+	public void setApp_version(String app_version) {
+		this.app_version = app_version;
+	}
+	public String getDevice_ip() {
+		return device_ip;
+	}
+	public void setDevice_ip(String device_ip) {
+		this.device_ip = device_ip;
+	}
+	public String getMobile_country_cd() {
+		return mobile_country_cd;
+	}
+	public void setMobile_country_cd(String mobile_country_cd) {
+		this.mobile_country_cd = mobile_country_cd;
+	}
+	public String getMobile_net_num() {
+		return mobile_net_num;
+	}
+	public void setMobile_net_num(String mobile_net_num) {
+		this.mobile_net_num = mobile_net_num;
+	}
+	public String getIcc_id() {
+		return icc_id;
+	}
+	public void setIcc_id(String icc_id) {
+		this.icc_id = icc_id;
+	}
+	public String getLocation_cd1() {
+		return location_cd1;
+	}
+	public void setLocation_cd1(String location_cd1) {
+		this.location_cd1 = location_cd1;
+	}
+	public String getLbs_num1() {
+		return lbs_num1;
+	}
+	public void setLbs_num1(String lbs_num1) {
+		this.lbs_num1 = lbs_num1;
+	}
+	public String getLbs_signal1() {
+		return lbs_signal1;
+	}
+	public void setLbs_signal1(String lbs_signal1) {
+		this.lbs_signal1 = lbs_signal1;
+	}
+	public String getLocation_cd2() {
+		return location_cd2;
+	}
+	public void setLocation_cd2(String location_cd2) {
+		this.location_cd2 = location_cd2;
+	}
+	public String getLbs_num2() {
+		return lbs_num2;
+	}
+	public void setLbs_num2(String lbs_num2) {
+		this.lbs_num2 = lbs_num2;
+	}
+	public String getLbs_signal2() {
+		return lbs_signal2;
+	}
+	public void setLbs_signal2(String lbs_signal2) {
+		this.lbs_signal2 = lbs_signal2;
+	}
+	public String getLocation_cd3() {
+		return location_cd3;
+	}
+	public void setLocation_cd3(String location_cd3) {
+		this.location_cd3 = location_cd3;
+	}
+	public String getLbs_num3() {
+		return lbs_num3;
+	}
+	public void setLbs_num3(String lbs_num3) {
+		this.lbs_num3 = lbs_num3;
+	}
+	public String getLbs_signal3() {
+		return lbs_signal3;
+	}
+	public void setLbs_signal3(String lbs_signal3) {
+		this.lbs_signal3 = lbs_signal3;
+	}
+	public String getTelecom_sys_id() {
+		return telecom_sys_id;
+	}
+	public void setTelecom_sys_id(String telecom_sys_id) {
+		this.telecom_sys_id = telecom_sys_id;
+	}
+	public String getTelecom_net_id() {
+		return telecom_net_id;
+	}
+	public void setTelecom_net_id(String telecom_net_id) {
+		this.telecom_net_id = telecom_net_id;
+	}
+	public String getTelecom_lbs() {
+		return telecom_lbs;
+	}
+	public void setTelecom_lbs(String telecom_lbs) {
+		this.telecom_lbs = telecom_lbs;
+	}
+	public String getTelecom_lbs_signal() {
+		return telecom_lbs_signal;
+	}
+	public void setTelecom_lbs_signal(String telecom_lbs_signal) {
+		this.telecom_lbs_signal = telecom_lbs_signal;
+	}
+	public String getTerminal_id() {
+		return terminal_id;
+	}
+	public void setTerminal_id(String terminal_id) {
+		this.terminal_id = terminal_id;
+	}
+
+	@Override
+	public String toString() {
+		return "TerminalInfoEntity [location=" + location + ", network_license=" + network_license + ", device_type="
+				+ device_type + ", serial_num=" + serial_num + ", terminal_id=" + terminal_id + ", device_id="
+				+ device_id + ", encrypt_rand_num=" + encrypt_rand_num + ", secret_text=" + secret_text
+				+ ", app_version=" + app_version + ", device_ip=" + device_ip + ", mobile_country_cd="
+				+ mobile_country_cd + ", mobile_net_num=" + mobile_net_num + ", icc_id=" + icc_id + ", location_cd1="
+				+ location_cd1 + ", lbs_num1=" + lbs_num1 + ", lbs_signal1=" + lbs_signal1 + ", location_cd2="
+				+ location_cd2 + ", lbs_num2=" + lbs_num2 + ", lbs_signal2=" + lbs_signal2 + ", location_cd3="
+				+ location_cd3 + ", lbs_num3=" + lbs_num3 + ", lbs_signal3=" + lbs_signal3 + ", telecom_sys_id="
+				+ telecom_sys_id + ", telecom_net_id=" + telecom_net_id + ", telecom_lbs=" + telecom_lbs
+				+ ", telecom_lbs_signal=" + telecom_lbs_signal + "]";
+	}
+	
+	
+
+}

+ 55 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/AliPayConfig.java

@@ -0,0 +1,55 @@
+package com.tzy.framework.pay.config;
+
+import com.alipay.api.AlipayConfig;
+import com.tzy.common.utils.StringUtils;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+
+/**
+ *
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.alipay.app")
+public class AliPayConfig extends AlipayConfig {
+
+    private String name = "alipay";
+
+    private String appId;
+    //MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCXH4ho5I+CAOZROpsZVpSq3iz3tb/NVDz4msy0pGJyoMAN6FpfY0TO8f4nft6kLPshLaAzu/tTv14hm29BJ7fNoOULtTCf5iaOPGyHptsmHj7zzJJFpqEFkd3TE9Z+pxGmf9fsw6LWGRnZdpGKXCqzKV7YVuACfZVt9NXxidy4sKahvgr9A6OZBi1fuu2iL4xyPqY/87d6ixU+/BwM+oTDK6ChpNkg7o5NO2Te5syYF3LJtOqL5LXzbuzP6wLw+FOzphoAyHiLkgcnemw8eZoImcsdKJawFO/qjft432rnBnW1IWFuqsLq6JEJsgN2Wch38fkqRf0Y1/IdeEXNUvaHAgMBAAECggEBAJKlus1u3gOds+InKNLRvbqBlslZySILGI92SCcTTaVGcJgOXYQq5F6dXbAd4RcXvypXCBqr1BtUnJeoKbHkROx5sUpHLUQ9JjToVbjdJdQ7jYMvhNGp/J9XCRcHLSICJZKYhIPw5Fc2TGtGL70/6v+oqaztwLsp+pOU/vdAfLuK0kkaYJTNKQDRbdoGoSQ/vDir85PV+nliinyAEoUqBHvoDoN/Xs9jo9JGagZQKkpjJzv3DOoQZIzUyLF1imiEKKDuKa+WVRU3+YzE1Wd2CYq3iCJNvs8nf48VeHvx1q7JuU4wK82M75BDF0jyNIy7UrXs0lVUIv/mlgjumGxciqECgYEAzbS6doad0zGdk21H53NU4R9+z+eKSzacaU2J0p3t68ouNhb3uM6ijfsEjiSc0HhyiwfIVDfpAnXefsOKLahY3tuz7WkZu9xZeYAWCOKQlglVFOtN0VTmuuaVe32d8wZ7QDt+Jmtz217GgNtJJGuwS9rpnWZTRgrCwBpPmdj9nfMCgYEAvBJueNG8PYyLmHfI+mKRsde/i+RoySBHeQR8AAV8FCR2UEw+HLxdWIzpa77WQoq6+WBSqwfAtdYeKp8q/WJ0p1V6sIGXTnRVPD2w/a8rsD/dJotrogaKfaO+PvUUV0TOnCfZ99RfL7Gr4QT5YKHGxySUAcfiEIw7lwk15tvCJh0CgYEAhrDv5uv+K2sxYncLveEmksGspzVUuCrp/4ll1SLTxrB70a74RWoHxi+2q9wNUfOMDLzrzzlMuO+04AvpTjwM9N+m0K0gzIFblNLpmqe/RH6X1zq7mXWeHoMdHd8CrT5xNX2+/Ckfk2RbVcRAADkDFqggj4+QtywUmPShantKlUECgYB6WB8nV4D2JRyWda33O/H9WBVSIqcL14THM+Saevbpf4K73600MlEjDp+2KLHnHapeGYwNmICDiaOcJGjp5oduZ4vlkJfmQIVGJ/egP7jS8eiib2X4Q/sJmmBjQjkWQDuLl90SfEPjmdfvDLZRZ0wRNjlWIzpre140dZhr8p+M/QKBgFGaOb2croSy1rEJcx/kP+feyLpQadh3rD8+TsLs+kYrvF50V4JZFA3uFkB9WkzfkemuOVGVw6hL4yf2IrWRFufarzuSO2lChFBex3jXIvgiAh4YFqYqRXcbVm2FeHAufuztJA7MNPZbcQHuYhcUaaRjSvCrAd9awoH1CLSW+eXE
+    private String privateKey;
+    private String alipayPublicKey;
+    private String privateKeyPath;
+    private String payNotifyUrl;
+    private String refundNotifyUrl;
+
+    public String getPrivateKey(){
+        if(StringUtils.isEmpty(privateKey)) {
+            String privateKey = "";
+            InputStream inputStream = getClass().getClassLoader().getResourceAsStream(privateKeyPath);
+            if (null == inputStream) {
+                try {
+                    inputStream = new FileInputStream(new File(privateKeyPath));
+                    StringBuilder sb = new StringBuilder();
+                    String line;
+
+                    BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                    while ((line = br.readLine()) != null) {
+                        sb.append(line);
+                    }
+                    privateKey = sb.toString();
+                } catch (FileNotFoundException e) {
+                    e.printStackTrace();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            return privateKey;
+        }
+        return privateKey;
+    }
+
+}

+ 55 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/AliPaySpareConfig.java

@@ -0,0 +1,55 @@
+package com.tzy.framework.pay.config;
+
+import com.alipay.api.AlipayConfig;
+import com.tzy.common.utils.StringUtils;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+
+/**
+ *
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.alipay.app1")
+public class AliPaySpareConfig extends AlipayConfig {
+
+    private String name = "alipay-spare1";
+
+    private String appId;
+    //MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCXH4ho5I+CAOZROpsZVpSq3iz3tb/NVDz4msy0pGJyoMAN6FpfY0TO8f4nft6kLPshLaAzu/tTv14hm29BJ7fNoOULtTCf5iaOPGyHptsmHj7zzJJFpqEFkd3TE9Z+pxGmf9fsw6LWGRnZdpGKXCqzKV7YVuACfZVt9NXxidy4sKahvgr9A6OZBi1fuu2iL4xyPqY/87d6ixU+/BwM+oTDK6ChpNkg7o5NO2Te5syYF3LJtOqL5LXzbuzP6wLw+FOzphoAyHiLkgcnemw8eZoImcsdKJawFO/qjft432rnBnW1IWFuqsLq6JEJsgN2Wch38fkqRf0Y1/IdeEXNUvaHAgMBAAECggEBAJKlus1u3gOds+InKNLRvbqBlslZySILGI92SCcTTaVGcJgOXYQq5F6dXbAd4RcXvypXCBqr1BtUnJeoKbHkROx5sUpHLUQ9JjToVbjdJdQ7jYMvhNGp/J9XCRcHLSICJZKYhIPw5Fc2TGtGL70/6v+oqaztwLsp+pOU/vdAfLuK0kkaYJTNKQDRbdoGoSQ/vDir85PV+nliinyAEoUqBHvoDoN/Xs9jo9JGagZQKkpjJzv3DOoQZIzUyLF1imiEKKDuKa+WVRU3+YzE1Wd2CYq3iCJNvs8nf48VeHvx1q7JuU4wK82M75BDF0jyNIy7UrXs0lVUIv/mlgjumGxciqECgYEAzbS6doad0zGdk21H53NU4R9+z+eKSzacaU2J0p3t68ouNhb3uM6ijfsEjiSc0HhyiwfIVDfpAnXefsOKLahY3tuz7WkZu9xZeYAWCOKQlglVFOtN0VTmuuaVe32d8wZ7QDt+Jmtz217GgNtJJGuwS9rpnWZTRgrCwBpPmdj9nfMCgYEAvBJueNG8PYyLmHfI+mKRsde/i+RoySBHeQR8AAV8FCR2UEw+HLxdWIzpa77WQoq6+WBSqwfAtdYeKp8q/WJ0p1V6sIGXTnRVPD2w/a8rsD/dJotrogaKfaO+PvUUV0TOnCfZ99RfL7Gr4QT5YKHGxySUAcfiEIw7lwk15tvCJh0CgYEAhrDv5uv+K2sxYncLveEmksGspzVUuCrp/4ll1SLTxrB70a74RWoHxi+2q9wNUfOMDLzrzzlMuO+04AvpTjwM9N+m0K0gzIFblNLpmqe/RH6X1zq7mXWeHoMdHd8CrT5xNX2+/Ckfk2RbVcRAADkDFqggj4+QtywUmPShantKlUECgYB6WB8nV4D2JRyWda33O/H9WBVSIqcL14THM+Saevbpf4K73600MlEjDp+2KLHnHapeGYwNmICDiaOcJGjp5oduZ4vlkJfmQIVGJ/egP7jS8eiib2X4Q/sJmmBjQjkWQDuLl90SfEPjmdfvDLZRZ0wRNjlWIzpre140dZhr8p+M/QKBgFGaOb2croSy1rEJcx/kP+feyLpQadh3rD8+TsLs+kYrvF50V4JZFA3uFkB9WkzfkemuOVGVw6hL4yf2IrWRFufarzuSO2lChFBex3jXIvgiAh4YFqYqRXcbVm2FeHAufuztJA7MNPZbcQHuYhcUaaRjSvCrAd9awoH1CLSW+eXE
+    private String privateKey;
+    private String alipayPublicKey;
+    private String privateKeyPath;
+    private String payNotifyUrl;
+    private String refundNotifyUrl;
+
+    public String getPrivateKey(){
+        if(StringUtils.isEmpty(privateKey)) {
+            String privateKey = "";
+            InputStream inputStream = getClass().getClassLoader().getResourceAsStream(privateKeyPath);
+            if (null == inputStream) {
+                try {
+                    inputStream = new FileInputStream(new File(privateKeyPath));
+                    StringBuilder sb = new StringBuilder();
+                    String line;
+
+                    BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                    while ((line = br.readLine()) != null) {
+                        sb.append(line);
+                    }
+                    privateKey = sb.toString();
+                } catch (FileNotFoundException e) {
+                    e.printStackTrace();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            return privateKey;
+        }
+        return privateKey;
+    }
+
+}

+ 51 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/BaoFooPayConfig.java

@@ -0,0 +1,51 @@
+package com.tzy.framework.pay.config;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.bofoo.app")
+@NoArgsConstructor
+@AllArgsConstructor
+public class BaoFooPayConfig {
+    private String merchantName;
+    //商户号
+    private String mid = "1272618";
+    //终端号
+    private String tid = "80729";
+    //私钥
+//    private String privateKey = "C:\\poyi\\project\\poyee\\poyee-pay\\src\\main\\resources\\config\\prod\\bofooPrivate.pfx";
+//    //私钥密码
+//    private String privateKeyPwd = "880615sandy";
+////    private String privateKeyPwd = "123456";
+//    //公钥
+//    private String publicKey = "C:\\poyi\\project\\poyee\\poyee-pay\\src\\main\\resources\\config\\prod\\bfkey_1272618@@80729.cer";
+
+    private String privateKey = "/app/configs/bofooPrivate.pfx";
+    //私钥密码
+    private String privateKeyPwd = "880615sandy";
+    //    private String privateKeyPwd = "123456";
+    //公钥
+    private String publicKey = "/app/configs/bfkey_1272618_80729.cer";
+    //支付回调地址
+    private String payNotifyUrl = "https://m2-dev.hobbystocks.cn/py-app/api/bfoo/paymentBack";
+
+    private String agreementpayNotifyUrl = "https://m2-dev.hobbystocks.cn/py-app/api/agreement/paymentBack";
+    //退款回调地址
+    private String refundNotifyUrl;
+    //支付宝二级商户号
+    private String alipaySimid = "2088620820601391";
+    //微信商户号
+    private String wxSimid = "569520824";
+    //云闪付
+    private String uacSimid = "844290053110005";
+    //支付标记
+    private String payFlag;
+    //退款标记
+    private String refundFlag;
+
+}

+ 42 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/BaofooRechargePayConfig.java

@@ -0,0 +1,42 @@
+package com.tzy.framework.pay.config;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class BaofooRechargePayConfig {
+
+    private String merchantName;
+
+    private String appid;
+    //商户号
+    private String mid = "100026760";
+    //终端号
+    private String tid = "200001936";
+    //来源编号
+    private String msgSrcId = "200001936";
+    //私钥
+    private String privateKey = "C:\\home\\tzy\\宝付\\bofooRecharge\\bofooRecharge\\src\\main\\resources\\lib\\bfkey_100026760@@200001936.pfx";
+    //私钥密码
+    private String privateKeyPwd = "100026760_604628";
+    //公钥
+    private String publicKey = "C:\\home\\tzy\\宝付\\bofooRecharge\\bofooRecharge\\src\\main\\resources\\lib\\bfkey_100026760@@200001936.cer";
+    //支付回调地址
+    private String payNotifyUrl;
+    //退款回调地址
+    private String refundNotifyUrl;
+    //支付宝二级商户号
+    private String alipaySimid = "2088620820601391";
+    //微信商户号
+    private String wxSimid = "";
+    //云闪付
+    private String uacSimid = "";
+    //支付标记
+    private String payFlag;
+    //退款标记
+    private String refundFlag;
+
+}

+ 89 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/BfPayConfig.java

@@ -0,0 +1,89 @@
+package com.tzy.framework.pay.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+
+/**
+ * 宝付支付配置
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.bf.app")
+public class BfPayConfig {
+
+    private String name = "bf";
+
+    private String format;
+    //#商户在慧收钱的商户号,由慧收钱生成并下发
+    private String appid;
+
+    private String signType;
+
+    private String version;
+    //#门店编号
+    private String subMerchantNo;
+    //后端通知地址-支付成功
+    private String payNotifyUrl;
+    //后端通知地址-退款
+    private String refundNotifyUrl;
+    //前台通知地址
+    private String pageUrl;
+    //
+    private String privateKeyPath;
+    //私钥密码
+    private String privatePwd;
+
+    private String publicKeyPath;
+
+    private String key;
+
+    public String getPrivateKey(){
+        String privateKey = "";
+        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(privateKeyPath);
+        if(null == inputStream ) {
+            try {
+                inputStream = new FileInputStream(new File(privateKeyPath));
+                StringBuilder sb = new StringBuilder();
+                String line;
+
+                BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                while ((line = br.readLine()) != null) {
+                    sb.append(line);
+                }
+                privateKey = sb.toString();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return privateKey;
+    }
+
+    public String getPublicKey(){
+        String publicKey = "";
+        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(publicKeyPath);
+        if(null == inputStream ) {
+            try {
+                inputStream = new FileInputStream(new File(publicKeyPath));
+                StringBuilder sb = new StringBuilder();
+                String line;
+
+                BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                while ((line = br.readLine()) != null) {
+                    sb.append(line);
+                }
+                publicKey = sb.toString();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return publicKey;
+    }
+
+}

+ 39 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/HfPayConfig.java

@@ -0,0 +1,39 @@
+package com.tzy.framework.pay.config;
+
+import com.huifu.adapay.model.MerConfig;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 汇付配置
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.hf.app")
+public class HfPayConfig extends MerConfig {
+
+    private String name = "hf";
+
+    private String appid;
+    /**
+     * 商户key
+     */
+    private String merchantKey;
+    /**
+     * debug 模式,开启后有详细的日志
+     */
+    private boolean debug = true;
+    /**
+     * prodMode 模式,默认为生产模式,false可以使用mock模式
+     */
+    private boolean prodMode = true;
+
+    private String notify_url;
+
+    private String refundNotifyUrl;
+
+    private String reverseNotifyUrl;
+
+
+}

+ 54 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/HmPayConfig.java

@@ -0,0 +1,54 @@
+package com.tzy.framework.pay.config;
+
+import com.alipay.api.AlipayConfig;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.hm.app")
+public class HmPayConfig extends AlipayConfig {
+
+    private String name = "hm";
+
+    private String app_id;
+    private String wxMchID;
+    private String privateKey;
+    private String publicKey;
+    private String hmPublicKey;
+    private String privateKeyPath;
+    private String format;
+    private String version;
+    private String storeId;
+    private String payNotifyUrl;
+    private String returnUrl;
+    private String ghStaticUrl;
+
+    public String getPrivateKey(){
+        String privateKey = "";
+        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(privateKeyPath);
+        if(null == inputStream ) {
+            try {
+                inputStream = new FileInputStream(new File(privateKeyPath));
+                StringBuilder sb = new StringBuilder();
+                String line;
+
+                BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                while ((line = br.readLine()) != null) {
+                    sb.append(line);
+                }
+                privateKey = sb.toString();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return privateKey;
+    }
+
+
+}

+ 170 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/PayConfig.java

@@ -0,0 +1,170 @@
+package com.tzy.framework.pay.config;
+
+import com.tzy.common.utils.StringUtils;
+import com.tzy.common.utils.bean.BeanUtils;
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 加载支付配置
+ */
+@Data
+@Component
+public class PayConfig {
+
+    @Autowired
+    private AliPayConfig aliPayConfig;
+
+    @Autowired
+    private AliPaySpareConfig aliPaySpareConfig;
+
+    @Autowired
+    private BfPayConfig bfPayConfig;
+
+    @Autowired
+    private HmPayConfig hmPayConfig;
+
+    @Autowired
+    private QmPayConfig qmPayConfig;
+
+    @Autowired
+    private QmPay1Config qmPay1Config;
+
+    @Autowired
+    private QmPay2Config qmPay2Config;
+
+    @Autowired
+    private QmH5PayConfig qmH5PayConfig;
+
+    @Autowired
+    private WxPayAppConfig wxPayAppConfig;
+    /**
+     * 汇付支付配置
+     */
+    @Autowired
+    private HfPayConfig hfPayConfig;
+
+
+    public Object get(String appid){
+        if(StringUtils.isEmpty(appid)){
+            return null;
+        }
+        if(appid.equals(aliPayConfig.getAppId())) {  //支付宝直连
+            return aliPayConfig;
+        }else if(appid.equals(aliPaySpareConfig.getAppId())) { //支付宝直连-备用1
+            AliPayConfig alipayConfig = new AliPayConfig();
+            BeanUtils.copyBeanProp(alipayConfig,aliPaySpareConfig);
+            return alipayConfig;
+        }else if(appid.equals(wxPayAppConfig.getAppID())) { //微信直连
+            return wxPayAppConfig;
+        } else if (appid.equals(qmH5PayConfig.getAppid())) { //全民-H5
+            return qmH5PayConfig;
+        }else if(appid.equals(bfPayConfig.getAppid())) { //宝付
+            return bfPayConfig;
+        }else if(appid.equals(hmPayConfig.getApp_id())) { //杉德
+            return hmPayConfig;
+        }else if(appid.equals(qmPay2Config.getAppid())) { //全民2
+            return qmPay2Config;
+        }else if(appid.equals(qmPay1Config.getAppid())) { //全民1
+            return qmPay1Config;
+        }else if(appid.equals(qmPayConfig.getAppid())) { //全民
+            return qmPayConfig;
+        }else if(appid.equals(hfPayConfig.getAppid())) { //汇付
+            return hfPayConfig;
+        }
+        return null;
+    }
+    /**
+     * 根据支付类型获取对应的支付配置
+     * @param payType
+     * @return
+     */
+    public Object getByPayType(String payType){
+        if(StringUtils.isEmpty(payType)){
+            return null;
+        }
+        if(payType.equals(aliPayConfig.getName())) { //支付宝直连
+            return aliPayConfig;
+        } else if (payType.equals(aliPaySpareConfig.getName())) { //支付宝直连-备用1
+            AliPayConfig alipayConfig = new AliPayConfig();
+            BeanUtils.copyBeanProp(alipayConfig,aliPaySpareConfig);
+            return alipayConfig;
+        } else if (payType.equals(wxPayAppConfig.getName())) {  //微信直连
+            return wxPayAppConfig;
+        } else if (payType.contains(qmH5PayConfig.getName())) { //全民-H5
+            return qmH5PayConfig;
+        } else if (payType.contains(hmPayConfig.getName())) { //杉德
+            return hmPayConfig;
+        } else if (payType.contains(qmPay2Config.getName())) { //全民2
+            return qmPay2Config;
+        } else if (payType.contains(qmPay1Config.getName())) { //全民1
+            return qmPay1Config;
+        } else if (payType.contains(qmPayConfig.getName())) { //全民
+            return qmPayConfig;
+        } else if (payType.contains(bfPayConfig.getName())) { //宝付
+            return bfPayConfig;
+        } else if (payType.contains(hfPayConfig.getName())) { //汇付
+            return hfPayConfig;
+        }
+        return null;
+    }
+    /**
+     * 根据支付类型获取对应的支付配置
+     * @param payType
+     * @return
+     */
+    public String getAppidByPayType(String payType){
+        if(StringUtils.isEmpty(payType)){
+            return null;
+        }
+        if(payType.equals(aliPayConfig.getName())) { //支付宝直连
+            return aliPayConfig.getAppId();
+        } else if (payType.equals(aliPaySpareConfig.getName())) { //支付宝直连-备用1
+            return aliPaySpareConfig.getAppId();
+        } else if (payType.equals(wxPayAppConfig.getName())) { //微信直连
+            return wxPayAppConfig.getAppID();
+        } else if (payType.contains(qmH5PayConfig.getName())) { //全民-H5
+            return qmH5PayConfig.getAppid();
+        } else if (payType.contains(bfPayConfig.getName())) { //宝付
+            return bfPayConfig.getAppid();
+        } else if (payType.contains(hmPayConfig.getName())) { //杉德
+            return hmPayConfig.getApp_id();
+        } else if (payType.contains(qmPay2Config.getName())) { //全民2
+            return qmPay2Config.getAppid();
+        } else if (payType.contains(qmPay1Config.getName())) { //全民1
+            return qmPay1Config.getAppid();
+        } else if (payType.contains(qmPayConfig.getName())) { //全民
+            return qmPayConfig.getAppid();
+        } else if (payType.contains(hfPayConfig.getName())) { //汇付
+            return hfPayConfig.getAppid();
+        }
+        return null;
+    }
+
+    /**
+     * 获取 子支付类型
+     * @param appid
+     * @return
+     */
+    public String getSubPayTypeByAppid(String appid){
+        if(StringUtils.isEmpty(appid)){
+            return null;
+        }
+        if(appid.equals(aliPayConfig.getAppId())) { //支付宝直连
+            return aliPayConfig.getName();
+        } else if (appid.equals(aliPaySpareConfig.getAppId())) { //支付宝直连-备用1
+            return aliPaySpareConfig.getName();
+       /* } else if (payType.equals(wxPayAppConfig.getName())) {  //微信直连
+            return wxPayAppConfig;
+        } else if (payType.contains(hmPayConfig.getName())) { //杉德
+            return hmPayConfig;
+        } else if (payType.contains(qmPayConfig.getName())) { //全民
+            return qmPayConfig;
+        } else if (payType.contains(bfPayConfig.getName())) { //宝付
+            return bfPayConfig;*/
+        }
+        return null;
+    }
+
+}

+ 77 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/QmH5PayConfig.java

@@ -0,0 +1,77 @@
+package com.tzy.framework.pay.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+
+/**
+ * 全民h5 支付
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.qm.h5")
+public class QmH5PayConfig {
+
+    private String name = "qm-h5";
+    //appid
+    private String appid;
+    //appkey
+    private String appkey;
+    //商户号
+    private String mid;
+    private String mid_ali;
+    private String mid_uac;
+    private String mid_wxh5;
+    //终端号
+    private String tid;
+    //来源编号
+    private String msgSrcId;
+    //机构商户号
+    private String instMid;
+    //私钥
+    private String privateKey;
+
+    private String privateKeyPath;
+    //支付回调地址
+    private String payNotifyUrl;
+    //退款回调地址
+    private String refundNotifyUrl;
+    //订单展示页面
+    private String showUrl;
+    //支付标记
+    private String payFlag;
+    //退款标记
+    private String refundFlag;
+    //微信子商户appid
+    private String subAppId;
+
+    private String url = "https://test-api-open.chinaums.com/v1/netpay/trade/h5-pay?";
+
+
+    public String getPrivateKey(){
+        String privateKey = this.privateKey;
+        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(privateKeyPath);
+        if(null == inputStream ) {
+            try {
+                inputStream = new FileInputStream(new File(privateKeyPath));
+                StringBuilder sb = new StringBuilder();
+                String line;
+
+                BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                while ((line = br.readLine()) != null) {
+                    sb.append(line);
+                }
+                privateKey = sb.toString();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return privateKey;
+    }
+
+
+}

+ 76 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/QmPay1Config.java

@@ -0,0 +1,76 @@
+package com.tzy.framework.pay.config;
+
+import com.alipay.api.AlipayConfig;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+
+/**
+ * 全民付配置文件
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.qm1.app")
+public class QmPay1Config extends AlipayConfig {
+
+    private String name = "qm1";
+    //appid
+    private String appid;
+    //appkey
+    private String appkey;
+    //商户号
+    private String mid;
+    //终端号
+    private String tid;
+    //子商户号
+    private String sub_mid;
+    //子终端号
+    private String sub_tid;
+    //来源编号
+    private String msgSrcId;
+    //机构商户号
+    private String instMid;
+    //私钥
+    private String privateKey;
+
+    private String privateKeyPath;
+    //支付回调地址
+    private String payNotifyUrl;
+    //退款回调地址
+    private String refundNotifyUrl;
+    //订单展示页面
+    private String showUrl;
+    //支付标记
+    private String payFlag;
+    //退款标记
+    private String refundFlag;
+    //微信子商户appid
+    private String subAppId;
+
+
+    public String getPrivateKey(){
+        String privateKey = "";
+        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(privateKeyPath);
+        if(null == inputStream ) {
+            try {
+                inputStream = new FileInputStream(new File(privateKeyPath));
+                StringBuilder sb = new StringBuilder();
+                String line;
+
+                BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                while ((line = br.readLine()) != null) {
+                    sb.append(line);
+                }
+                privateKey = sb.toString();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return privateKey;
+    }
+
+}

+ 76 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/QmPay2Config.java

@@ -0,0 +1,76 @@
+package com.tzy.framework.pay.config;
+
+import com.alipay.api.AlipayConfig;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+
+/**
+ * 全民付配置文件
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.qm2.app")
+public class QmPay2Config extends AlipayConfig {
+
+    private String name = "qm2";
+    //appid
+    private String appid;
+    //appkey
+    private String appkey;
+    //商户号
+    private String mid;
+    //终端号
+    private String tid;
+    //子商户号
+    private String sub_mid;
+    //子终端号
+    private String sub_tid;
+    //来源编号
+    private String msgSrcId;
+    //机构商户号
+    private String instMid;
+    //私钥
+    private String privateKey;
+
+    private String privateKeyPath;
+    //支付回调地址
+    private String payNotifyUrl;
+    //退款回调地址
+    private String refundNotifyUrl;
+    //订单展示页面
+    private String showUrl;
+    //支付标记
+    private String payFlag;
+    //退款标记
+    private String refundFlag;
+    //微信子商户appid
+    private String subAppId;
+
+
+    public String getPrivateKey(){
+        String privateKey = "";
+        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(privateKeyPath);
+        if(null == inputStream ) {
+            try {
+                inputStream = new FileInputStream(new File(privateKeyPath));
+                StringBuilder sb = new StringBuilder();
+                String line;
+
+                BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                while ((line = br.readLine()) != null) {
+                    sb.append(line);
+                }
+                privateKey = sb.toString();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return privateKey;
+    }
+
+}

+ 94 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/QmPayConfig.java

@@ -0,0 +1,94 @@
+package com.tzy.framework.pay.config;
+
+import com.alipay.api.AlipayConfig;
+import com.tzy.common.utils.StringUtils;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+
+/**
+ * 全民付配置文件
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.qm.app")
+@NoArgsConstructor
+@AllArgsConstructor
+public class QmPayConfig extends AlipayConfig {
+
+    public QmPayConfig(String appid, String appkey, String privateKey, String instMid){
+        this.appid = appid;
+        this.appkey = appkey;
+        this.privateKey = privateKey;
+        this.instMid = instMid;
+    }
+    private String name = "qm";
+    //appid
+    private String appid;
+    //appkey
+    private String appkey;
+    //商户号
+    private String mid;
+    //终端号
+    private String tid;
+    //子商户号
+    private String sub_mid;
+    //子终端号
+    private String sub_tid;
+    //来源编号
+    private String msgSrcId;
+    //机构商户号
+    private String instMid;
+    //私钥
+    private String privateKey;
+
+    private String privateKeyPath;
+    //支付回调地址
+    private String payNotifyUrl;
+    //退款回调地址
+    private String refundNotifyUrl;
+    //订单展示页面
+    private String showUrl;
+    //支付标记
+    private String payFlag;
+    //退款标记
+    private String refundFlag;
+    //微信子商户appid
+    private String subAppId;
+    //企业用户号
+    private String businessUserNo;
+    //企业用户号
+//    private boolean limitCreditCard = false;
+
+
+    public String getPrivateKey(){
+        String privateKey = this.privateKey;
+        if(StringUtils.isNotEmpty(privateKey)){
+            return privateKey;
+        }
+        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(privateKeyPath);
+        if(null == inputStream ) {
+            try {
+                inputStream = new FileInputStream(new File(privateKeyPath));
+                StringBuilder sb = new StringBuilder();
+                String line;
+
+                BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+                while ((line = br.readLine()) != null) {
+                    sb.append(line);
+                }
+                privateKey = sb.toString();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return privateKey;
+    }
+
+}

+ 35 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/QmPayZgConfig.java

@@ -0,0 +1,35 @@
+package com.tzy.framework.pay.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 全民付资管配置文件
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "pay.qm.am")
+public class QmPayZgConfig {
+    //商户集团编号 默认
+    private String merchantNo;
+    //企业用户号 默认
+    private String businessUserNo;
+    //
+    private String sub_businessUserNo;
+    //商户加签私钥
+    private String upPublicKeyPath;
+    //商户加签私钥
+    private String upPrivateKeyPath;
+    //私钥密码
+    private String upPrivateKeyPwd;
+
+    private String dwPublicKeyPath;
+    //账号
+    private String userName;
+    //密码
+    private String pwd;
+    //ip
+    private String ip;
+
+}

+ 82 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/config/WxPayAppConfig.java

@@ -0,0 +1,82 @@
+package com.tzy.framework.pay.config;
+
+import com.github.wxpay.sdk.WXPayConfig;
+import lombok.Data;
+import lombok.ToString;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+@Data
+@ToString
+@Component
+@ConfigurationProperties(prefix = "pay.wxpay.app")
+public class WxPayAppConfig implements WXPayConfig {
+
+    private String name = "wx";
+    /**
+     * appID
+     */
+    private String appID;
+
+    private String appletID;
+    private String thirdAndriID;
+
+    /**
+     * 商户号
+     */
+    private String mchID;
+
+    /**
+     * API 密钥
+     */
+    private String key;
+
+    /**
+     * API证书绝对路径
+     */
+    private String certPath;
+
+    /**
+     * HTTP(S) 连接超时时间,单位毫秒
+     */
+    private int httpConnectTimeoutMs = 8000;
+
+    /**
+     * HTTP(S) 读数据超时时间,单位毫秒
+     */
+    private int httpReadTimeoutMs = 10000;
+
+    /**
+     * 微信支付异步通知地址
+     */
+    private String payNotifyUrl;
+
+    /**
+     * 微信退款异步通知地址
+     */
+    private String refundNotifyUrl;
+
+    /**
+     * 获取商户证书内容(这里证书需要到微信商户平台进行下载)
+     *
+     * @return 商户证书内容
+     */
+    @Override
+    public InputStream getCertStream() {
+        InputStream certStream = getClass().getClassLoader().getResourceAsStream(certPath);
+        if(null == certStream ) {
+            try {
+                certStream = new FileInputStream(new File(certPath));
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+        }
+        return certStream;
+    }
+
+}

+ 24 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/AlipayData.java

@@ -0,0 +1,24 @@
+package com.tzy.framework.pay.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+/**
+ *
+ */
+@Data
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class AlipayData {
+
+    private String appid;
+
+    private String privateKey;
+
+    private String publicKey;
+
+
+}

+ 110 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/BankInfo.java

@@ -0,0 +1,110 @@
+package com.tzy.framework.pay.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.common.dto.Result;
+import com.tzy.common.utils.StringUtils;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class BankInfo<T> extends Result {
+
+    public BankInfo(Integer userId,String bankType, String bankNo, String realName, String cardNo, String phone){
+        this.userId = userId;
+        this.bankType = bankType;
+        this.bankNo = bankNo;
+        this.realName = realName;
+        this.cardNo = cardNo;
+        this.phone = phone;
+    }
+    //用户id
+    private Integer userId;
+    //银行卡号
+    private String bankNo;
+    //银行卡名
+    private String bankName;
+    //银行卡类型 卡类型 101 借记卡,102 信用卡
+    private String bankType;
+    //姓名
+    private String realName;
+    //身份证号
+    private String cardNo;
+    //手机号
+    private String phone;
+    //预签约唯一码
+    private String uniqueCode;
+    //短信验证码
+    private String phoneCode;
+    //协议号: 1202304241415275791952576173
+    private String protocolNo = "1202304241415275791952576173";
+    //协议列表
+    private String protocols;
+
+    public BankInfo setConfirm(String uniqueCode,String phoneCode){
+        this.uniqueCode = uniqueCode;
+        this.phoneCode = phoneCode;
+        return this;
+    }
+    public BankInfo setProtocolNo(String protocolNo){
+        this.protocolNo = protocolNo;
+        return this;
+    }
+
+    //账户信息[银行卡号|持卡人姓名|证件号|手机号|银行卡安全码|银行卡有效期]
+    public String getFormat(){
+       StringBuffer stb = new StringBuffer();
+       return stb.append(StringUtils.isNotEmpty(bankNo) ? bankNo+"" : "")
+                       .append("|")
+           .append(StringUtils.isNotEmpty(realName) ? realName : "")
+               .append("|")
+           .append(StringUtils.isNotEmpty(cardNo) ? cardNo : "")
+               .append("|")
+           .append(StringUtils.isNotEmpty(phone) ? phone : "")
+               .append("||").toString();
+    }
+
+    private JSONObject payConfig;
+
+    public T getPayConfigByClass( Class<T> clazz){
+        return JSONObject.parseObject(payConfig.toJSONString(), clazz);
+    }
+
+    public static BankInfo ok(){
+        return new BankInfo();
+    }
+
+    public static BankInfo ok(String msg) {
+        return new BankInfo(true,200,msg);
+    }
+
+    public BankInfo success() {
+        this.setSuccess(true);
+        this.setCode(0);
+        return this ;
+    }
+    public BankInfo success(String msg) {
+        this.setSuccess(true);
+        this.setCode(0);
+        this.setMsg(msg);
+        return this ;
+    }
+
+    public BankInfo fail(String msg) {
+        this.setSuccess(false);
+        this.setCode(-1);
+        this.setMsg(msg);
+        return this ;
+    }
+    public static BankInfo error(String msg) {
+        return new BankInfo(false, -1, msg);
+    }
+    public BankInfo(boolean success, Integer code, String msg){
+        this.setSuccess(success);
+        this.setCode(code);
+        this.setMsg(msg);
+    }
+
+}

+ 40 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/CheckPaymentInfoDto.java

@@ -0,0 +1,40 @@
+package com.tzy.framework.pay.dto;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 同步支付订单
+ */
+@Data
+@ToString
+public class CheckPaymentInfoDto implements Serializable {
+
+    private static final long serializableUID = 1l;
+    //按照组队id
+    private Integer groupInfoId;
+
+    private String groupInfoName;
+    //支付方式
+    private String payWay;
+    //支付渠道
+    private String payChannel;
+    //支付appid
+    private String appid;
+    //用户id
+    private Integer userId;
+    //用户openid
+    private String openid;
+    //订单单号
+    private String orderNo;
+    //支付时间-开始时间
+    private Date startPaymentTime;
+    //支付时间-结束时间
+    private Date endPaymentTime;
+
+
+
+}

+ 120 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/PayConstants.java

@@ -0,0 +1,120 @@
+package com.tzy.framework.pay.dto;
+
+/**
+ * 支付参数
+ */
+public class PayConstants {
+
+    public static final String SUCCESS = "SUCCESS";
+    public static final String TRADE_SUCCESS = "TRADE_SUCCESS";
+
+    public static final String PAY_TYPE_WX = "wxpay";//微信支付
+    public static final String PAY_TYPE_ALIPAY = "alipay";//支付宝支付
+    public static final String HMPAY_TYPE_WX = "wxpay-hm";//杉德-微信
+    public static final String HMPAY_TYPE_ALIPAY = "alipay-hm";//杉德-支付宝
+    public static final String QMPAY_TYPE_WX = "wxpay-qm";//全民付-微信
+    public static final String QMPAY_TYPE_ALIPAY = "alipay-qm";//全民付-支付宝
+    public static final String QMPAY_TYPE_ALIPAY2APPLET = "alipay-applet-qm";//全民付-支付宝跳转小程序
+    public static final String QMPAY_TYPE_ALIPAY2H5 = "alipay-qm-h5";//全民付-支付宝h5
+    public static final String QMPAY_TYPE_WX2H5 = "wxpay-qm-h5";//全民付-微信h5
+    public static final String QMPAY_TYPE_UAC2H5 = "uac-qm-h5";//全民付-云闪付H5
+    public static final String QMPAY_TYPE_UAC = "uac-qm";//全民付-云闪付
+    public static final String BFPAY_TYPE_MAIN_WX = "wxpay-main-bf";//宝付-微信-主扫
+    public static final String BFPAY_TYPE_MAIN_ALIPAY = "alipay-main-bf";//宝付-支付宝-主扫
+    public static final String BFPAY_TYPE_MAIN_UAC = "uac-main-bf";//宝付-云闪付-主扫
+    public static final String BFPAY_TYPE_APP_WX = "wxpay-app-bf";//宝付-微信-app
+    public static final String BFPAY_TYPE_APP_ALIPAY = "alipay-app-bf";//宝付-微信-app
+
+    public static final String QMPAY_METHOD_TRADE_CREATE = "TRADE_CREATE";//统一下单
+    public static final String QMPAY_METHOD_QUERY_ORDER = "QUERY_ORDER";//查询订单
+    public static final String QMPAY_METHOD_REFUND = "REFUND";//退款
+    public static final String QMPAY_METHOD_REFUND_QUERY = "REFUND_QUERY";//退款查询
+    public static final String QMPAY_METHOD_CLOSE = "CLOSE";//关闭订单
+    //全民付-统一下单
+    public static final String QMPAY_HOST_SANDBOX = "https://test-api-open.chinaums.com/v1/netpay/";
+    public static final String QMPAY_HOST = "https://api-mop.chinaums.com/v1/netpay/";
+    public static final String QMPAY_HOST_MINI = "https://api-mop.dtums.com/v1/netpay/";
+
+    public static final String QMPAY_TRADE_URL_WX_SANDBOX = QMPAY_HOST_SANDBOX+"wx/app-pre-order";//全民付-统一下单-微信
+    public static final String QMPAY_TRADE_URL_WX = QMPAY_HOST+"wx/app-pre-order";//全民付-统一下单-微信
+//    public static final String QMPAY_TRADE_URL_WX_MINI = QMPAY_HOST_MINI+"wx/unified-order";//全民付-统一下单-微信小程序-mini
+    public static final String QMPAY_TRADE_URL_WX_MINI = QMPAY_HOST+"wx/unified-order";//全民付-统一下单-微信小程序-mini
+    public static final String QMPAY_TRADE_URL_WX2H5_MINI = QMPAY_HOST_MINI+"wxpay/h5-pay";//全民付-统一下单-微信小程序-H5
+
+    public static final String QMPAY_TRADE_URL_ALIPAY_SANDBOX =  QMPAY_HOST_SANDBOX+"trade/precreate";//全民付-统一下单-支付宝
+    public static final String QMPAY_TRADE_URL_ALIPAY = QMPAY_HOST+"trade/precreate";//全民付-统一下单-支付宝
+    public static final String QMPAY_TRADE_URL_QM_SANDBOX =  QMPAY_HOST_SANDBOX+"qmf/order";//全民付-统一下单-全民付
+    public static final String QMPAY_TRADE_URL_QM = QMPAY_HOST+"qmf/order";//全民付-统一下单-全民付
+
+    public static final String QMPAY_TRADE_URL_UAC_SANDBOX =  QMPAY_HOST_SANDBOX+"uac/app-order";//全民付-统一下单-银联云闪付
+    public static final String QMPAY_TRADE_URL_UAC = QMPAY_HOST+"uac/app-order";//全民付-统一下单-银联云闪付
+    public static final String QMPAY_TRADE_URL_UAC_MINI = QMPAY_HOST_MINI+"uac/mini-order";//全民付-统一下单-银联云闪付-mini
+
+    public static final String QMPAY_TRADE_URL_ALIPAY2APPLET_SANDBOX =  QMPAY_HOST_SANDBOX+"trade/app-pre-order";//全民付-统一下单-支付宝跳转小程序
+    public static final String QMPAY_TRADE_URL_ALIPAY2APPLET = QMPAY_HOST+"trade/app-pre-order";//全民付-统一下单-支付宝跳转小程序
+    public static final String QMPAY_TRADE_URL_ALIPAY2APPLET_MINI = QMPAY_HOST_MINI+"trade/create";//全民付-统一下单-支付宝跳转小程序-mini
+
+    public static final String QMPAY_TRADE_URL_ALIPAY2H5_SANDBOX =  QMPAY_HOST_SANDBOX+"trade/h5-pay";//全民付-统一下单-支付宝h5
+    public static final String QMPAY_TRADE_URL_ALIPAY2H5 = QMPAY_HOST+"trade/h5-pay";//全民付-统一下单-支付宝h5
+    public static final String QMPAY_TRADE_URL_ALIPAY2H5_MINI = QMPAY_HOST_MINI+"trade/h5-pay";//全民付-统一下单-支付宝h5
+
+    public static final String QMPAY_TRADE_URL_UAC2H5_SANDBOX = QMPAY_HOST_SANDBOX+"uac/order";//全民付-统一下单-云闪付h5
+    public static final String QMPAY_TRADE_URL_UAC2H5 = QMPAY_HOST+"uac/order";//全民付-统一下单-云闪付h5
+    public static final String QMPAY_TRADE_URL_UAC2H5_MINI = QMPAY_HOST_MINI+"uac/order";//全民付-统一下单-云闪付-H5
+    //--全民付订单查询
+    public static final String QMPAY_QUERY_URL_SANDBOX =  QMPAY_HOST_SANDBOX+"query";//全民付-查询
+    public static final String QMPAY_QUERY_URL= QMPAY_HOST+"query";//全民付-查询
+    public static final String QMPAY_QUERY_URL_MINI= QMPAY_HOST_MINI+"query";//全民付-查询
+    public static final String QMPAY_QUERY_URL_WX_SANDBOX =  QMPAY_HOST_SANDBOX+"wx/app-pre-query";//全民付-查询-微信
+    public static final String QMPAY_QUERY_URL_WX = QMPAY_HOST+"wx/app-pre-query";//全民付-查询-微信
+    public static final String QMPAY_QUERY_URL_ALIPAY2APPLET_SANDBOX =  QMPAY_HOST_SANDBOX+"trade/app-pre-query";//全民付-查询-支付宝跳转小程序
+    public static final String QMPAY_QUERY_URL_ALIPAY2APPLET = QMPAY_HOST+"trade/app-pre-query";//全民付-查询-支付宝跳转小程序
+    //--全民付-退款
+    public static final String QMPAY_REFUND_URL_SANDBOX =  QMPAY_HOST_SANDBOX+"refund";//全民付-退款
+    public static final String QMPAY_REFUND_URL= QMPAY_HOST+"refund";//全民付-退款
+    public static final String QMPAY_REFUND_URL_MINI= QMPAY_HOST+"refund";//全民付-退款
+//    public static final String QMPAY_REFUND_URL_MINI= QMPAY_HOST_MINI+"refund";//全民付-退款
+    //--全民付-退款查询
+    public static final String QMPAY_QUERY_REFUND_URL_SANDBOX =  QMPAY_HOST_SANDBOX+"refund-query";//全民付-退款
+    public static final String QMPAY_QUERY_REFUND_URL= QMPAY_HOST+"refund-query";//全民付-退款
+    public static final String QMPAY_QUERY_REFUND_URL_MINI= QMPAY_HOST+"refund-query";//全民付-退款
+//    public static final String QMPAY_QUERY_REFUND_URL_MINI= QMPAY_HOST_MINI+"refund-query";//全民付-退款
+    //--全民付-退款查询
+    public static final String QMPAY_CLOSE_URL_SANDBOX =  QMPAY_HOST_SANDBOX+"close";//全民付-关闭订单
+    public static final String QMPAY_CLOSE_URL= QMPAY_HOST+"close";//全民付-关闭订单
+    public static final String QMPAY_CLOSE_URL_WX_SANDBOX =  QMPAY_HOST_SANDBOX+"wx/app-pre-close";//全民付-关闭订单-微信跳转小程序
+    public static final String QMPAY_CLOSE_URL_WX= QMPAY_HOST+"wx/app-pre-close";//全民付-关闭订单-微信跳转小程序
+    public static final String QMPAY_CLOSE_URL_ALIPAY2APPLET_SANDBOX =  QMPAY_HOST_SANDBOX+"trade/app-pre-close";//全民付-关闭订单-支付宝跳转小程序
+    public static final String QMPAY_CLOSE_URL_ALIPAY2APPLET= QMPAY_HOST+"trade/app-pre-close";//全民付-关闭订单-支付宝跳转小程序
+
+    //宝付 -主扫
+    public static final String BF_TEST_HOST = "https://test-api.huishouqian.com/api/acquiring";
+    public static final String BF_HOST = "https://api.huishouqian.com/api/acquiring";
+    //宝付-统一下单
+    public static final String BF_METHOD_TRADE_MAIN = "POLYMERIZE_MAIN_SWEPTN";
+    public static final String BF_METHOD_TRADE_APP = "POLYMERIZE_PROGRAM_CASHIER";
+    //宝付-查询订单
+    public static final String BF_METHOD_QUERY_MAIN = "POLYMERIZE_QUERY";
+    //宝付-申请退款
+    public static final String BF_METHOD_REFUND_MAIN = "POLYMERIZE_REFUND";
+    //宝付-退款查询
+    public static final String BF_METHOD_REFUND_QUERY_MAIN = "POLYMERIZE_REFUND_QUERY";
+    //宝付-下载账单
+    public static final String BF_METHOD_QUERY_TRADE_FILE_MAIN = "QUERY_TRADE_FILE";
+
+    //baofu =统一下单
+    public static final String BFPAY_METHOD_UNIFIED_ORDER = "unified_order";//统一下单
+    public static final String BFPAY_METHOD_ORDER_QUERY = "order_query";//查询订单
+    public static final String BFPAY_METHOD_ORDER_REFUND = "order_refund";//退款申请
+    /**
+     * 退款查询
+     */
+    public static final String BFPAY_METHOD_REFUND_QUERY = "refund_query";
+    //宝付 支付宝主扫
+    public static final String BFPAY_ALIPAY_NATIVE= "ALIPAY_NATIVE";
+    //宝付 云闪付主扫
+    public static final String BFPAY_QUICK_PASS_NATIVEE= "QUICK_PASS_NATIVE";
+
+
+
+}

+ 93 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/PaymentInfoResponseDto.java

@@ -0,0 +1,93 @@
+package com.tzy.framework.pay.dto;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 订单信息
+ */
+@Data
+@ToString
+public class PaymentInfoResponseDto implements Serializable {
+
+    private static final long serializableUid = 1l;
+    //订单编码
+    private String orderNo;
+    //平台类型
+    private String payWay;
+    //平台 appid
+    private String appid;
+    //平台支付编码
+    private String paymentNo;
+    /** 应付款 */
+    private BigDecimal paymentPrice;
+    /** 实付款-用户支付款 */
+    private BigDecimal actualPayment;
+    //下单时间
+    private Date paymentTime;
+    //支付成功时间
+    private Date paymentSuccessTime;
+
+    private Integer code = 0;
+
+    private String msg = "SUCCESS";
+
+    private boolean success = false;
+
+    private String tradeState;
+
+    private String tradeStateDesc;
+
+    private Map<String ,Object> data = new HashMap<>();
+
+    public static PaymentInfoResponseDto ok(){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        paymentInfoResponseDto.setSuccess(true);
+        return paymentInfoResponseDto;
+    }
+
+    public static PaymentInfoResponseDto ok(String msg){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        paymentInfoResponseDto.setSuccess(true);
+        paymentInfoResponseDto.setMsg(msg);
+        return paymentInfoResponseDto;
+    }
+
+    public static PaymentInfoResponseDto ok(Integer code, String msg){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        paymentInfoResponseDto.setSuccess(true);
+        paymentInfoResponseDto.setCode(code);
+        paymentInfoResponseDto.setMsg(msg);
+        return paymentInfoResponseDto;
+    }
+
+    public static PaymentInfoResponseDto error(Integer code, String msg){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        paymentInfoResponseDto.setCode(code);
+        paymentInfoResponseDto.setMsg(msg);
+        paymentInfoResponseDto.setSuccess(false);
+        return paymentInfoResponseDto;
+    }
+
+    public PaymentInfoResponseDto put(String key, Object value){
+        if(null == this.data) this.data = new HashMap<>();
+        this.data.put(key,value);
+        return this;
+    }
+
+    public String getString(String key){
+        if(null == this.data) return null;
+        return (String) this.data.get(key);
+    }
+
+    public Object get(String key){
+        if(null == this.data) return null;
+        return this.data.get(key);
+    }
+}

+ 96 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/PaymentRequestDto.java

@@ -0,0 +1,96 @@
+package com.tzy.framework.pay.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
+import lombok.ToString;
+
+import javax.validation.constraints.NotEmpty;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 支付 dto
+ */
+@Data
+@ToString
+public class PaymentRequestDto<T> implements Serializable {
+
+    private static long serializableUid = 1l;
+    //请求类型
+    @NotEmpty
+    private String userType;
+    //订单编码
+    @NotEmpty
+    private String orderNo;
+    //订单编码-商户订单号(第三方平台订单号)
+    private String merOrderId;
+    //订单金额
+    private BigDecimal orderAmount;
+    //支付金额
+    @NotEmpty
+    private BigDecimal totalAmount;
+    //支付商品描述
+    @NotEmpty
+    private String body;
+    //支付方式
+    @NotEmpty
+    private String payWay;
+    //订单类型:group
+    private String orderCategory;
+
+    private String category;
+    private String paySubWay;
+    //云闪付-支付银行
+    private String uacBank;
+    //云闪付-卡号
+    private String bankCardNo;
+    //appid
+    private String wxAppid;
+    //openid
+    private String wxOpenid;
+    //返回地址
+    private String returnUrl;
+    //页面地址
+    private String path_url;
+    //订单创建时间
+    private Date createOrderTime;
+    //订单expireTime
+    private Date expireTime=new Date();
+    //mid
+    private String mid;
+    //tid
+    private String tid;
+    //请求ip
+    private String createip;
+    //商户号
+    private String appid;
+    //子商户号
+    private String subAppid;
+    /**指定路由*/
+    private Boolean assignPayType;
+    //操作描述
+    private String msg;
+
+    private JSONObject payConfig;
+
+    //组团商户id
+    private Long merchantId;
+    //分账编码(宝付为客户账户号)
+    private String contractNo;
+
+    private String accountType;
+
+    private String phoneCode;
+
+    private BankInfo bankInfo;
+
+    private PaymentUserInfo paymentUserInfo;
+    //请求用户信息
+    private RechargeUserInfoDto rechargeUserInfoDto;
+
+    public T getPayConfigByClass( Class<T> clazz){
+        return JSONObject.parseObject(payConfig.toJSONString(), clazz);
+    }
+
+}

+ 35 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/PaymentUserInfo.java

@@ -0,0 +1,35 @@
+package com.tzy.framework.pay.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class PaymentUserInfo {
+
+    //行业类目 01 电商
+    private String  goodsCategory;
+    //收货人姓名
+    private  String csName;
+    //收货人手机号
+    private String csMobile;
+    //收货人省份
+    private String csProvince;
+    //收货人城市
+    private String csCity;
+    //收货人地址 不包含国家、省份/州、城 市信息的详细地址
+    private String csAddress;
+    //商品名称
+    private String prodNameList;
+    //商品类目 008 运动户外
+    private String prodTypeList;
+    //商品数量
+    private String prodQtyList;
+    //商品总价
+    private String prodAmtList;
+
+
+
+}

+ 41 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/PrePayRespDTO.java

@@ -0,0 +1,41 @@
+package com.tzy.framework.pay.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 支付 dto
+ */
+@Data
+public class PrePayRespDTO implements Serializable {
+
+    private static long serializableUid = 1l;
+    //请求类型
+    private String userType;
+    //订单编码
+
+    private String orderNo;
+
+    private String merOrderId;
+    private String data;
+    private String payWay;
+    private String paymentSubType;
+    //云闪付-支付银行
+    private String uacBank;
+    //appid
+    private String wxAppid;
+    //openid
+    private String wxOpenid;
+    //返回地址
+    private String returnUrl;
+
+    private String path_url;
+    //订单的创建时间
+    private Date CreateOrderTime;
+
+    private String mid;
+
+    private String tid;
+}

+ 25 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/QmZgOrderInfoDto.java

@@ -0,0 +1,25 @@
+package com.tzy.framework.pay.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.io.Serializable;
+
+/**
+ * 全民资管平台订单
+ */
+@Data
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class QmZgOrderInfoDto implements Serializable {
+
+    private static final long serializableUid = 1l;
+    //订单编码
+    private String orderNo;
+    //订单金额 单位分
+    private Integer price;
+
+}

+ 54 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/RechargeUserInfoDto.java

@@ -0,0 +1,54 @@
+package com.tzy.framework.pay.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class RechargeUserInfoDto<T> implements Serializable {
+    public RechargeUserInfoDto( String userName, String certificateNo){
+        this.userName = userName;
+        this.certificateNo = certificateNo;
+    }
+    //应用用户的会员编号
+    private String loginNo;
+    //是否验证用户实名
+    private boolean checkUserAuth;
+    //用户姓名
+    private String userName;
+    //身份证号
+    private String certificateNo;
+    //身份证正面
+    private String idCardFront;
+    //身份证反面
+    private String idCardBack;
+    //银行卡类型
+    private String bankType;
+    //银行卡号
+    private String bankNo;
+    //银行卡预留手机号
+    private String bankPhone;
+    //预绑卡关联号
+    private String requestNo;
+    //短信验证码
+    private String phoneCode;
+    //已绑定卡协议号
+    private String agreementNo;
+
+    //唤起类型
+    private String callType;
+    //支付参数:退款等使用
+    private String payParam;
+
+    private JSONObject payConfig;
+
+    public T getPayConfigByClass( Class<T> clazz){
+        return JSONObject.parseObject(payConfig.toJSONString(), clazz);
+    }
+
+}

+ 82 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/RefundRequestDto.java

@@ -0,0 +1,82 @@
+package com.tzy.framework.pay.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 退款信息
+ */
+@Data
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class RefundRequestDto<T> implements Serializable {
+
+        private static long serializableUid = 1l;
+
+        public RefundRequestDto(String payWay, String orderNo, BigDecimal totalAmount, BigDecimal refundAmount, String refundMsg) {
+                this.payWay = payWay;
+                this.orderNo = orderNo;
+                this.totalAmount = totalAmount;
+                this.refundAmount = refundAmount;
+                this.refundMsg = refundMsg;
+        }
+
+        //请求类型
+        private String userType;
+        //订单编码
+        private String orderNo;
+        //退款编码
+        private String refundNo;
+        //订单编码-商户订单号(全民付)
+        private String merOrderId;
+        //支付订单号
+        private String tradeNo;
+        //支付金额
+        private BigDecimal totalAmount;
+        //支付方式
+        private String payWay;
+        //云闪付-支付银行
+        private String uacBank;
+        //appid
+        private String wxAppid;
+        //openid
+        private String wxOpenid;
+        //返回地址
+        private String returnUrl;
+        //页面地址
+        private String path_url;
+        //订单创建时间
+        private Date createOrderTime;
+        //mid
+        private String mid;
+        //tid
+        private String tid;
+        //请求ip
+        private String createip;
+        //商户号
+        private String appid;
+        //子商户号
+        private String subAppid;
+
+        private BigDecimal orderPrice;
+
+        private BigDecimal refundAmount;
+
+        private String refundMsg;
+
+        private JSONObject payConfig;
+        //请求用户信息
+        private RechargeUserInfoDto rechargeUserInfoDto;
+
+        public T getPayConfigByClass( Class<T> clazz){
+                return JSONObject.parseObject(payConfig.toJSONString(), clazz);
+        }
+}

+ 80 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/ResourceData.java

@@ -0,0 +1,80 @@
+package com.tzy.framework.pay.dto;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+
+@Data
+@ToString
+public class ResourceData implements Serializable
+{
+    private static final long serializableUID = 1L;
+    //应用ID
+    private String appid;
+    //商户号
+    private String mchid;
+    //商户订单号
+    private String out_trade_no;
+    //微信支付订单号
+    private String transaction_id;
+    //交易类型
+    // JSAPI:公众号支付
+    //NATIVE:扫码支付
+    //APP:APP支付
+    //MICROPAY:付款码支付
+    //MWEB:H5支付
+    //FACEPAY:刷脸支付
+    private String trade_type;
+    //交易状态:
+    // SUCCESS:支付成功
+    //REFUND:转入退款
+    //NOTPAY:未支付
+    //CLOSED:已关闭
+    //REVOKED:已撤销(付款码支付)
+    //USERPAYING:用户支付中(付款码支付)
+    //PAYERROR:支付失败(其他原因,如银行返回失败)
+    private String trade_state;
+    //交易状态描述
+    private String trade_state_desc;
+    //付款银行
+    private String bank_type;
+    //支付完成时间
+    private String success_time;
+    //支付者
+    private  Payer payer;
+    //订单金额
+    private PayAmount amount;
+
+    @ToString
+    @Data
+    public static class Payer{
+        //用户标识 用户在直连商户appid下的唯一标识。
+        private String openid;
+    }
+    @ToString
+    @Data
+    public static class PayAmount{
+
+        public PayAmount(){
+        }
+        public PayAmount(Integer total,Integer payer_total,String currency,String payer_currency){
+            this.total = total;
+            this.payer_total =  payer_total;
+            this.currency = currency;
+            this.payer_currency= payer_currency;
+        }
+        //总金额
+        private Integer total;
+        //用户支付金额
+        private Integer payer_total;
+        //货币类型
+        private String currency;
+        //用户支付币种
+        private String payer_currency;
+
+
+    }
+}
+
+

+ 56 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/dto/ResultMap.java

@@ -0,0 +1,56 @@
+package com.tzy.framework.pay.dto;
+import org.apache.http.HttpStatus;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Description 通用返回结果集
+ * @Author
+ * @Date 2021/6/12 15:13
+ */
+public class ResultMap extends HashMap<String, Object> {
+    public ResultMap() {
+        put("state", true);
+        put("code", 0);
+        put("msg", "success");
+    }
+
+    public static ResultMap error(int code, String msg) {
+        ResultMap r = new ResultMap();
+        r.put("state", false);
+        r.put("code", code);
+        r.put("msg", msg);
+        return r;
+    }
+
+    public static ResultMap error(String msg) {
+        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
+    }
+
+    public static ResultMap error() {
+        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
+    }
+
+    public static ResultMap ok(String msg) {
+        ResultMap r = new ResultMap();
+        r.put("msg", msg);
+        return r;
+    }
+
+    public static ResultMap ok(Map<String, Object> par) {
+        ResultMap r = new ResultMap();
+        r.putAll(par);
+        return r;
+    }
+
+    public static ResultMap ok() {
+        return new ResultMap();
+    }
+
+    public ResultMap put(String key, Object value) {
+        super.put(key, value);
+        return this;
+    }
+
+}

+ 56 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/AlipayService.java

@@ -0,0 +1,56 @@
+package com.tzy.framework.pay.service;
+
+import com.alipay.api.response.AlipayTradeQueryResponse;
+import com.tzy.framework.pay.config.AliPayConfig;
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 支付宝
+ */
+public interface AlipayService {
+    //加载alipay配置
+    public AliPayConfig initConfig(String appid,String type);
+
+    //统一支付接口
+    public ResultMap unifiedOrder(String orderNo, BigDecimal amount, String body);
+
+    /**
+     * @param orderNo
+     * @param amount
+     * @param body
+     * @param expireTime 指定过期时间,当前时间3分钟后过期
+     * @return
+     */
+    public ResultMap unifiedOrder(String orderNo, BigDecimal amount, String body, Date expireTime);
+    //统一支付接口
+    public ResultMap unifiedOrder(PaymentRequestDto paymentRequestDto);
+    //退款接口
+    public ResultMap aliRefundNotify(String appid,String orderNo, BigDecimal amount, String body);
+    /**
+     * 查询订单支付情况
+     * @param orderNo
+     * @return
+     */
+    AlipayTradeQueryResponse searchOrder(String orderNo);
+
+    public PaymentInfoResponseDto queryOrder(String appid,String orderNo);
+
+    boolean closeTradeOrder(String orderNo);
+
+    //关闭订单-新
+    public ResultMap closeTradeOrderNew(String appid,String orderNo);
+
+    public ResultMap unifiedOrderNew(PaymentRequestDto paymentRequestDto);
+
+    public ResultMap aliRefundNotify(RefundRequestDto refundRequestDto);
+
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto);
+
+    public ResultMap queryRefundOrder(RefundRequestDto refundRequestDto);
+}

+ 31 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/BankService.java

@@ -0,0 +1,31 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.framework.pay.dto.BankInfo;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+public interface BankService {
+
+    public BankInfo ReadySign(BankInfo bankInfo);
+    public BankInfo ConfirmSign(BankInfo bankInfo);
+    public BankInfo QueryBind(BankInfo bankInfo);
+    public BankInfo unBind(BankInfo bankInfo);
+    /**
+     * 免密支付
+     * @param payRequestBody
+     * @return
+     */
+    public ResultMap SinglePay(PaymentRequestDto payRequestBody);
+    /**
+     * 预支付
+     * @param payRequestBody
+     */
+    public ResultMap ReadyPay(PaymentRequestDto payRequestBody);
+
+    /**
+     * 确认支付
+     * @param payRequestBody
+     */
+    public ResultMap ConfirmPay(PaymentRequestDto payRequestBody);
+
+}

+ 40 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/BaoFooBankPayService.java

@@ -0,0 +1,40 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+/**
+ * 宝付 银行支付
+ */
+public interface BaoFooBankPayService {
+
+    public ResultMap getBankList(PaymentRequestDto payRequestBody);
+
+    /**
+     * 下单
+     * @param payRequestBody
+     * @throws Exception
+     */
+    public ResultMap unifiedOrder(PaymentRequestDto payRequestBody);
+
+    /**
+     * 查询
+     * @param paymentRequestDto
+     * @return
+     * @throws Exception
+     */
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto);
+
+    /**
+     * 退款
+     * @param refundRequestDto
+     * @throws Exception
+     */
+    public ResultMap refund(RefundRequestDto refundRequestDto);
+
+
+    public ResultMap refundQuery( RefundRequestDto refundRequestDto);
+
+}

+ 39 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/BaoFooPayService.java

@@ -0,0 +1,39 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+public interface BaoFooPayService {
+
+    /**
+     * 下单
+     * @param payRequestBody
+     * @throws Exception
+     */
+    public ResultMap unifiedOrder(PaymentRequestDto payRequestBody);
+
+    /**
+     * 查询
+     * @param paymentRequestDto
+     * @return
+     * @throws Exception
+     */
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto);
+
+    /**
+     * 退款
+     * @param refundRequestDto
+     * @throws Exception
+     */
+    public ResultMap refund(RefundRequestDto refundRequestDto);
+
+    /**
+     * 退款查询
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap refundQuery( RefundRequestDto refundRequestDto);
+
+}

+ 17 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/BaofooRechargePayService.java

@@ -0,0 +1,17 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+public interface BaofooRechargePayService {
+    //余额支付
+    public ResultMap paymentSplitApi(PaymentRequestDto payRequestBody);
+    //聚合支付(支付宝)
+    public ResultMap payment(PaymentRequestDto payRequestBody);
+    //退款申请
+    public ResultMap profitShareRefundApply(RefundRequestDto refundRequestDto);
+    //订单查询(根据订单号查询是退款还是支付)
+    public ResultMap queryOrder(PaymentRequestDto payRequestBody);
+
+}

+ 31 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/BfPayService.java

@@ -0,0 +1,31 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.framework.pay.config.BfPayConfig;
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+import java.math.BigDecimal;
+
+public interface BfPayService {
+    public boolean verifyCallBack(String appid,String respSign,String sign);
+
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto);
+
+    public PaymentInfoResponseDto queryOrder(String appid,String payWay, String  orderNo);
+
+    public ResultMap refund(String appid,String orderNo, BigDecimal orderPrice, BigDecimal refundPrice, String refundMsg);
+
+    public ResultMap refundQuery( String appid,String outRefundNo);
+
+    public boolean verifyCallBackNew(BfPayConfig bfPayConfig, String respSign, String sign);
+
+    public ResultMap tradeCreateNew(PaymentRequestDto paymentRequestDto);
+
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto);
+
+    public ResultMap refund(RefundRequestDto refundRequestDto);
+
+    public ResultMap refundQuery( RefundRequestDto refundRequestDto);
+}

+ 64 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/BofooAgreementService.java

@@ -0,0 +1,64 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.framework.pay.dto.*;
+
+public interface BofooAgreementService {
+    /**
+     * 协议支付-预绑卡接口
+     */
+    public BankInfo ReadySign(BankInfo bankInfo);
+    /**
+     * 确认绑卡(协议支付)
+     */
+    public BankInfo ConfirmSign(BankInfo bankInfo);
+    /**
+     * 查询绑定的银行卡
+     * @param bankInfo
+     */
+    public BankInfo QueryBind(BankInfo bankInfo);
+    /**
+     * 解绑
+     * @param bankInfo
+     */
+    public BankInfo unBind(BankInfo bankInfo);
+    /**
+     * 免密支付
+     * @param payRequestBody
+     * @return
+     */
+    public ResultMap SinglePay(PaymentRequestDto payRequestBody);
+    /**
+     * 预支付
+     * @param payRequestBody
+     */
+    public ResultMap ReadyPay(PaymentRequestDto payRequestBody);
+
+    /**
+     * 确认支付
+     * @param payRequestBody
+     */
+    public ResultMap ConfirmPay(PaymentRequestDto payRequestBody);
+
+    /**
+     * 查询
+     * @param payRequestBody
+     */
+    public PaymentInfoResponseDto QueryOrder(PaymentRequestDto payRequestBody);
+
+    /**
+     * 退款
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap OrderRefund(RefundRequestDto refundRequestDto);
+    /**
+     * 退款查询
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap queryRefund(RefundRequestDto refundRequestDto);
+
+
+
+
+}

+ 27 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/HfPayService.java

@@ -0,0 +1,27 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+import java.util.Map;
+
+public interface HfPayService {
+
+    //统一下单
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto);
+    //查询订单
+    public PaymentInfoResponseDto queryOrder(String appid, String payWay, String  orderNo);
+    //撤销支付
+    public Map<String, Object> reverse(PaymentRequestDto paymentRequestDto);
+    //查询撤销对象
+    public Map<String, Object> queryReverse(String reverse_id);
+    //退款
+    public ResultMap refund(RefundRequestDto refundRequestDto);
+    //退款查询
+    public ResultMap queryRefund(RefundRequestDto refundRequestDto);
+    //关闭订单
+    public ResultMap close(PaymentRequestDto paymentRequestDto);
+
+}

+ 36 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/HmPayService.java

@@ -0,0 +1,36 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.common.dto.OutDTO;
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+public interface HmPayService {
+
+    public String hmTradeCreate(String payWay ,String buyerId, String orderNo, BigDecimal totalAmount, String body);
+
+    public String tradeCreate(Map<String,Object> param);
+
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto);
+
+    public ResultMap refundOrder(Map<String,Object> param);
+
+    public OutDTO queryOrder(Map<String,Object> param);
+
+    public PaymentInfoResponseDto queryOrder(String appid,String orderNo);
+
+    public OutDTO queryRefundOrder(Map<String,Object> param);
+
+    public OutDTO cancelOrder(Map<String,Object> param);
+
+    public ResultMap tradeCreateNew(PaymentRequestDto paymentRequestDto);
+
+    public ResultMap refundOrder(RefundRequestDto refundRequestDto);
+
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto);
+
+}

+ 153 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/PaymentBaseService.java

@@ -0,0 +1,153 @@
+package com.tzy.framework.pay.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.base.dto.DictBaseDto;
+import com.tzy.base.service.SysBaseService;
+import com.tzy.common.utils.StringUtils;
+import com.tzy.common.utils.http.HttpClientUtil;
+import com.tzy.framework.pay.config.PayConfig;
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+import com.tzy.framework.util.RedisUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service("paymentBaseConfigService")
+public class PaymentBaseService {
+
+    public static final String NEW_PAY_MODAL = "new_pay_modal";
+    @Autowired
+    protected SysBaseService sysBaseService;
+    @Autowired
+    protected HmPayService hmPayService;
+    @Autowired
+    protected QmPayService qmPayService;
+    @Autowired
+    protected QmH5PayService qmH5PayService;
+    @Autowired
+    protected WxPayService wxPayService;
+    @Autowired
+    protected AlipayService alipayApiService;
+    @Autowired
+    protected BfPayService bfPayService;
+    @Autowired
+    protected RedisUtils redisUtils;
+    @Autowired
+    protected PayConfig payConfig;
+    @Autowired
+    protected HfPayService hfPayService;
+    @Autowired
+    protected BaoFooPayService baoFooPayService;
+    @Autowired
+    protected BaoFooBankPayService baoFooBankPayService;
+    @Autowired
+    protected BankService bankService;
+    @Autowired
+    protected BofooAgreementService bofooAgreementService;
+    @Autowired
+    protected BaofooRechargePayService baofooRechargePayService;
+    @Autowired
+    protected Qme1PayService qme1PayService;
+    @Value("${pay.recharge.readPay:http://localhost:8082/p1/readPay}")
+    protected String readPayUrl;
+    @Value("${pay.recharge.confirmPay:http://localhost:8082/p1/confirmPay}")
+    protected String confirmPayUrl;
+    @Value("${pay.server.refund:http://localhost:8082/p1/v2/refund}")
+    protected String refundUrl;
+    @Value("${pay.server.refundQuery:http://localhost:8082/p1/v2/refundQuery}")
+    protected String refundQueryUrl;
+    @Value("${pay.server.query:http://localhost:8082/p1/query}")
+    protected String queryUrl;
+
+    public JSONObject initPayConfig(String payWay){
+        return JSONObject.parseObject(sysBaseService.getAppMenuByCode(payWay));
+    }
+    /**
+     * 判断是否是在新支付模块中指定的通道
+     * @param payway
+     * @throws Exception
+     */
+    public void isNewPayModal(String payway) throws Exception{
+        List<DictBaseDto> dictBaseDtos = sysBaseService.selectDictData(NEW_PAY_MODAL, "all");
+        if(null == dictBaseDtos || dictBaseDtos.isEmpty()){
+            dictBaseDtos = sysBaseService.selectDictData(NEW_PAY_MODAL,payway);
+        }
+        if(null == dictBaseDtos || dictBaseDtos.size() == 0){
+            throw new Exception("不是新支付模块!");
+        }
+    }
+    /**
+     * 新模块退款
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap refundPost(RefundRequestDto refundRequestDto) throws Exception {
+        //
+        isNewPayModal(refundRequestDto.getPayWay());
+        String jsonString = JSONObject.toJSONString(refundRequestDto);
+        String retStr = post(refundUrl,jsonString);
+        log.info(" `new 调用退款接口>>>{} 返回结果>>>{} ",refundUrl,retStr);
+        if(StringUtils.isEmpty(retStr)){
+            return ResultMap.error();
+        }else{
+            try{
+                ResultMap resultMap = JSONObject.parseObject(retStr, ResultMap.class);
+                return resultMap;
+            }catch (Exception e){
+                e.printStackTrace();
+                return ResultMap.error();
+            }
+        }
+    }
+
+    /**
+     * 新模块查询支付
+     * @param paymentRequestDto
+     * @return
+     */
+    public PaymentInfoResponseDto queryPost(PaymentRequestDto paymentRequestDto) throws Exception {
+        isNewPayModal(paymentRequestDto.getPayWay());
+        String jsonString = JSONObject.toJSONString(paymentRequestDto);
+        String retStr = post(queryUrl,jsonString);
+        log.info(" `new 调用查询接口>>>{} 返回结果>>>{} ",queryUrl,retStr);
+        if(StringUtils.isEmpty(retStr)){
+            return PaymentInfoResponseDto.error(1,"查询失败");
+        }else{
+            try {
+                JSONObject jsonObject = JSONObject.parseObject(retStr);
+                PaymentInfoResponseDto resultMap = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.get("data")), PaymentInfoResponseDto.class);
+                if(null == resultMap){
+                    throw new Exception("查询失败");
+                }
+                resultMap.setSuccess(jsonObject.getBoolean("success"));
+                log.info(" `new 调用查询接口>>>{} 返回结果>>>{} ",resultMap,jsonObject.get("data"));
+                return resultMap;
+            }catch (Exception e){
+                throw new Exception("查询失败");
+            }
+        }
+    }
+
+    private String post(String url, String jsonString) {
+        Map<String,String > header = new HashMap<>();
+        header.put("Content-Type","application/json");
+        String retStr = "";
+        if(url.startsWith("https:")){
+            retStr = HttpClientUtil.httpsRequest(url, HttpClientUtil.POST, jsonString, header);
+        }else{
+            retStr = HttpClientUtil.httpRequest(url,HttpClientUtil.POST, jsonString,header);
+        }
+        return retStr;
+    }
+
+
+}

+ 76 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/PaymentService.java

@@ -0,0 +1,76 @@
+package com.tzy.framework.pay.service;
+
+
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+import java.math.BigDecimal;
+
+/**
+ * 支付
+ */
+public interface PaymentService<T> {
+    //支付统一下单
+    public ResultMap unifiedOrder(PaymentRequestDto paymentRequestDto);
+    //查询订单
+    public PaymentInfoResponseDto queryPaymentOrder(String payWay, String orderNo);
+    //支付退款
+    @Deprecated
+    public ResultMap refund(String payWay, String orderNo, BigDecimal orderPrice, BigDecimal refundAmount, String refundMsg);
+    //关闭订单
+    public ResultMap close(String payWay, String orderNo);
+    //查询退款订单
+    public ResultMap refundQuery(String payWay,String tradeNo, String refundNo);
+
+    //
+    public PaymentInfoResponseDto queryPaymentOrder(PaymentRequestDto paymentRequestDto);
+
+    @Deprecated
+    public ResultMap close(PaymentRequestDto paymentRequestDto);
+
+    @Deprecated
+    public ResultMap refund(RefundRequestDto refundRequestDto);
+
+    public ResultMap refundQuery(RefundRequestDto refundRequestDto);
+    /*********************新支付逻辑********************/
+
+    public T initPayConfigs(String payWay, Class<T> tClass);
+
+    //获取银行列表
+    public ResultMap getBankList(PaymentRequestDto paymentRequestDto);
+
+    /**
+     * 预支付
+     * @param payRequestBody
+     */
+    public ResultMap readPay(PaymentRequestDto payRequestBody);
+
+    /**
+     * 确认支付
+     * @param payRequestBody
+     */
+    public ResultMap confirmPay(PaymentRequestDto payRequestBody);
+
+    //支付统一下单
+    public ResultMap unifiedOrderNew(PaymentRequestDto paymentRequestDto);
+    //查询订单
+    public PaymentInfoResponseDto queryPaymentOrderNew(String payWay, String orderNo);
+    //支付退款
+    @Deprecated
+    public ResultMap refundNew(String payWay, String orderNo, BigDecimal orderPrice, BigDecimal refundAmount, String refundMsg);
+    //关闭订单
+    public ResultMap closeNew(String payWay, String orderNo);
+    //查询退款订单
+    public ResultMap refundQueryNew(String payWay,String tradeNo, String refundNo);
+
+    //
+    public PaymentInfoResponseDto queryPaymentOrderNew(PaymentRequestDto paymentRequestDto);
+
+    public ResultMap closeNew(PaymentRequestDto paymentRequestDto);
+
+    public ResultMap refundNew(RefundRequestDto refundRequestDto);
+
+    public ResultMap refundQueryNew(RefundRequestDto refundRequestDto);
+}

+ 31 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/QmH5PayService.java

@@ -0,0 +1,31 @@
+package com.tzy.framework.pay.service;
+
+
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+import java.math.BigDecimal;
+
+public interface QmH5PayService {
+
+    //统一下单
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto);
+    //查询订单
+    public PaymentInfoResponseDto queryOrder(String appid, String payWay, String  orderNo);
+    //退款
+    public ResultMap refund(String appid, String payWay,String orderNo, BigDecimal refundPrice, String refundMsg);
+    //退款查询
+    public ResultMap refundQuery(String appid,String payWay,String outRefundNo);
+    //关闭订单
+    public ResultMap colse(String appid,String payWay,String orderNo);
+    //统一下单
+    public ResultMap tradeCreateNew(PaymentRequestDto paymentRequestDto);
+    //查询订单
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto);
+    //退款
+    public ResultMap refund(RefundRequestDto refundRequestDto);
+    //退款查询
+    public ResultMap refundQuery(RefundRequestDto refundRequestDto);
+}

+ 12 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/QmPayAssetService.java

@@ -0,0 +1,12 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.framework.pay.dto.QmZgOrderInfoDto;
+
+import java.util.List;
+
+public interface QmPayAssetService {
+
+    public void upAtPrice02(List<QmZgOrderInfoDto> params,String timeStr);
+
+
+}

+ 45 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/QmPayService.java

@@ -0,0 +1,45 @@
+package com.tzy.framework.pay.service;
+
+
+import com.tzy.framework.pay.config.QmPayConfig;
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+import java.math.BigDecimal;
+
+public interface QmPayService {
+    //统一下单
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto);
+    //查询订单
+    public PaymentInfoResponseDto queryOrder(String appid,String payWay, String  orderNo);
+    //退款
+    public ResultMap refund(String appid,String payWay,String orderNo, BigDecimal refundPrice, String refundMsg);
+    //退款查询
+    public ResultMap refundQuery(String appid,String payWay,String outRefundNo);
+    //关闭订单
+    public ResultMap colse(String appid,String payWay,String orderNo);
+
+    public  String getMerchantOrderId(QmPayConfig qmPayConfig);
+
+    public String getBoxUrl(String payWay,String method) throws Exception;
+
+    public String getUrl(String payWay,String method) throws Exception;
+
+    public String getUrlNew(String payWay,QmPayConfig qmPayConfig,String method) throws Exception;
+
+    public String getOpenBodySig(String appId, String appKey, String body);
+
+    public String send(String url, String entity , String authorization) throws Exception;
+    //统一下单
+    public ResultMap tradeCreateNew(PaymentRequestDto paymentRequestDto);
+    //查询订单
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto);
+    //退款
+    public ResultMap refund(RefundRequestDto refundRequestDto);
+    //退款查询
+    public ResultMap refundQuery( RefundRequestDto refundRequestDto);
+    //关闭订单
+    public ResultMap colseNew(PaymentRequestDto paymentRequestDto);
+}

+ 19 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/Qme1PayService.java

@@ -0,0 +1,19 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+public interface Qme1PayService {
+
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto);
+
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto);
+
+    public ResultMap refund(RefundRequestDto refundRequestDto);
+
+    public ResultMap refundQuery(RefundRequestDto refundRequestDto);
+
+
+}

+ 86 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/WxPayService.java

@@ -0,0 +1,86 @@
+package com.tzy.framework.pay.service;
+
+import com.tzy.common.dto.InDto;
+import com.tzy.common.dto.OutDTO;
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+
+import java.math.BigDecimal;
+
+/**
+ * 微信支付
+ */
+public interface WxPayService {
+
+    /**
+     * @Description: 微信支付统一下单
+     * @param inDto
+     * @param orderNo: 订单编号
+     * @param amount: 实际支付金额
+     * @param body: 订单描述
+     * @Author:
+     * @Date: 2019/8/1
+     * @return
+     */
+    ResultMap unifiedOrder(InDto inDto, String orderNo, BigDecimal amount, String body) ;
+
+    /**
+     * @Description: 微信支付统一下单
+     * @param paymentRequestDto
+     * @return
+     */
+    public ResultMap unifiedOrder(PaymentRequestDto paymentRequestDto);
+    /**
+     * 查询已支付订单
+     * @param orderNo
+     * @return
+     */
+    public OutDTO searchOrder(String orderNo);
+    /**
+     * 查询已支付订单
+     * @param orderNo
+     * @return
+     */
+    public PaymentInfoResponseDto queryOrder(String appid,String orderNo);
+    /**
+     * 关闭已支付的订单
+     * @param orderNo
+     * @return
+     */
+    public OutDTO closeOrder(String orderNo);
+    /**
+     * 关闭订单-新
+     * @param orderNo
+     * @return
+     */
+    public ResultMap closeOrderNew(String appid,String orderNo);
+    /**
+     * 退款
+     * @param orderNo
+     * @param amount
+     * @param refundReason
+     * @return
+     */
+    public ResultMap wxRefund(String appid,String orderNo, BigDecimal amount, String refundReason);
+    /**
+     * @Description: 微信支付统一下单
+     * @param paymentRequestDto
+     * @return
+     */
+    public ResultMap unifiedOrderNew(PaymentRequestDto paymentRequestDto);
+    /**
+     * 查询已支付订单
+     * @param paymentRequestDto
+     * @return
+     */
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto);
+    /**
+     * 退款
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap wxRefund(RefundRequestDto refundRequestDto);
+
+}

+ 803 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/AlipayServiceImpl.java

@@ -0,0 +1,803 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.AlipayClient;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.domain.AlipayTradeAppPayModel;
+import com.alipay.api.domain.AlipayTradePrecreateModel;
+import com.alipay.api.domain.ExtUserInfo;
+import com.alipay.api.request.*;
+import com.alipay.api.response.*;
+import com.tzy.common.constant.Constants;
+import com.tzy.common.core.domain.entity.SysDictData;
+import com.tzy.common.utils.Base64Util;
+import com.tzy.common.utils.DateUtils;
+import com.tzy.common.utils.LogSyncUtil;
+import com.tzy.common.utils.StringUtils;
+import com.tzy.framework.pay.config.AliPayConfig;
+import com.tzy.framework.pay.config.PayConfig;
+import com.tzy.framework.pay.dto.*;
+import com.tzy.framework.pay.service.AlipayService;
+import com.tzy.framework.pay.util.AlipayConfigUtil;
+import com.tzy.framework.util.RandomUtil;
+import com.tzy.framework.util.RedisUtils;
+import com.tzy.system.service.ISysDictDataService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+@Slf4j
+@Service
+public class AlipayServiceImpl implements AlipayService {
+
+    @Autowired
+    private AliPayConfig aliPayConfig ;
+    @Value("${pay.alipay.app.payNotifyUrl}")
+    private String notifyUrl;
+    @Value("${pay.alipay.app.refundNotifyUrl}")
+    private String refundNotifyUrl;
+    public static final String searchUrl="https://openapi.alipay.com/gateway.do";
+    @Autowired
+    private ISysDictDataService dictDataService;
+    @Autowired
+    private RedisUtils redisUtils;
+    @Autowired
+    private PayConfig payConfig;
+
+    @Override
+    public AliPayConfig initConfig(String appid,String type){
+        //查询redis 生效的支付配置
+        AtomicReference<AliPayConfig> aliPayConfig = null ;
+        try{
+            if(StringUtils.isNotEmpty(appid)) { //如果传入appid 不为空 则取缓存配置
+                aliPayConfig.set((AliPayConfig) redisUtils.hget("payment_alipay", appid));
+                if (null != aliPayConfig.get() && StringUtils.isNotEmpty(aliPayConfig.get().getAppId())) {
+                    return aliPayConfig.get();
+                }
+            }
+            if(StringUtils.isEmpty(appid) && !"unifiedOrder".equals(type)){
+                //如果不是统一下单,则使用默认配置(配置文件)
+                return this.aliPayConfig;
+            }
+            //如果 缓存中未查到 该配置 则启用其他配置
+            Map<Object, Object> paymentAlipayMap = redisUtils.hmget("payment_alipay");
+            if(null != paymentAlipayMap && !paymentAlipayMap.isEmpty()){
+                aliPayConfig.set((AliPayConfig) paymentAlipayMap.values().stream().findFirst().get());
+                return aliPayConfig.get();
+            }
+        } catch (Exception e) {
+            log.error(" 获取缓存支付配置失败,从数据库获取支付配置 ");
+        }
+        //查询字典配置生效的选项
+        List<SysDictData> paymentAlipays = dictDataService.getByTypeAndStatus("payment_alipay", "1");
+        if(null != paymentAlipays && !paymentAlipays.isEmpty()){
+            paymentAlipays.forEach(sysDictData -> {
+                AliPayConfig aliPayConfig1 = new AliPayConfig();
+                //根据字典表配置的 商户号,加载 配置的密钥等参数
+                AlipayData alipayData = AlipayConfigUtil.initConfig(sysDictData.getDictValue());
+                if(null != alipayData && StringUtils.isNotEmpty(alipayData.getAppid()) ){
+                    aliPayConfig1.setAppId(alipayData.getAppid());
+                    aliPayConfig1.setAlipayPublicKey(alipayData.getPublicKey());
+                    aliPayConfig1.setPrivateKey(alipayData.getPrivateKey());
+                }
+                if(appid.equals(sysDictData.getDictValue())){
+                    //如果有配置的选项则设置为配置选项
+                    aliPayConfig.set(aliPayConfig1);
+                }
+                redisUtils.hset("appPayConfig",sysDictData.getDictValue(),aliPayConfig1);
+            });
+            //判断是否有配置选项,如果没有则使用 其他配置
+            if(null == aliPayConfig || null == aliPayConfig.get() || StringUtils.isEmpty(aliPayConfig.get().getAppId())){
+                Map<Object, Object> paymentAlipayMap = redisUtils.hmget("payment_alipay");
+                if(null != paymentAlipayMap && !paymentAlipayMap.isEmpty()){
+                    aliPayConfig.set((AliPayConfig) paymentAlipayMap.values().stream().findFirst().get());
+                }else{
+                    //如果数据库中没有查到则使用配置文件中配置
+                    redisUtils.hset("appPayConfig",this.aliPayConfig.getAppId(),this.aliPayConfig);
+                    return this.aliPayConfig;
+                }
+            }
+        }else{
+            //如果数据库中没有查到则使用配置文件中配置
+            redisUtils.hset("appPayConfig",this.aliPayConfig.getAppId(),this.aliPayConfig);
+            return this.aliPayConfig;
+        }
+        return aliPayConfig.get();
+    }
+
+    public AliPayConfig initConfig2(String appid){
+        return (AliPayConfig) payConfig.get(appid);
+    }
+
+
+    @Override
+    public ResultMap unifiedOrder(String orderNo, BigDecimal amount, String body) {
+        return unifiedOrder(orderNo,amount,body,new Date());
+    }
+
+    /**
+     * 支付宝统一下单
+     * @param orderNo
+     * @param amount
+     * @param body
+     * @return
+     */
+    @Override
+    public ResultMap unifiedOrder(String orderNo, BigDecimal amount, String body,Date expireTime){
+        if(StringUtils.isNotEmpty(body) ){
+            body = Base64Util.subStringByBytes(body,120)+"...";
+        }
+        String serverUrl = aliPayConfig.getServerUrl();
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        String signType = aliPayConfig.getSignType();
+        //实例化客户端
+//        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", APP_ID, APP_PRIVATE_KEY, "json", CHARSET, ALIPAY_PUBLIC_KEY, "RSA2");
+        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl, appId, privateKey, format, charset, alipayPublicKey, signType);
+        //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
+        AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
+        //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
+        AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+        model.setBody("");
+        model.setSubject(body);
+        model.setOutTradeNo(orderNo);
+        //model.setTimeExpire(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,new Date(System.currentTimeMillis()+2800*60)));
+        model.setTimeExpire(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,new Date(expireTime.getTime()+2900*60)));
+        //model.setTimeoutExpress("3m");
+//        model.setTotalAmount("0.01");
+        model.setTotalAmount(String.valueOf(amount));
+        model.setProductCode("QUICK_MSECURITY_PAY");
+        request.setBizModel(model);
+        request.setNotifyUrl(notifyUrl);
+        try {
+            LogSyncUtil.logSync("支付宝直连统一下单,交易编号:{},请求参数:{}",orderNo,request);
+            //这里和普通的接口调用不同,使用的是sdkExecute
+            AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
+            if (response.isSuccess()) {
+                LogSyncUtil.logSync("支付宝直连统一下单,交易编号:{},返回结果:{}",orderNo,response.getBody());
+                return ResultMap.ok().put("data",response.getBody());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return ResultMap.error(-1,"调用失败");
+    }
+
+    /**
+     * 统一下单-新
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap unifiedOrder(PaymentRequestDto paymentRequestDto){
+        LogSyncUtil.logSync("支付宝直连统一下单,交易编号:{},请求参数:{}",paymentRequestDto.getOrderNo(),paymentRequestDto);
+        if(StringUtils.isNotEmpty(paymentRequestDto.getBody()) ){
+            paymentRequestDto.setBody(Base64Util.subStringByBytes(paymentRequestDto.getBody(),120)+"...");
+        }
+        AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(paymentRequestDto.getAppid());
+        if(null == aliPayConfig){
+            aliPayConfig = this.aliPayConfig;
+        }
+        String serverUrl = aliPayConfig.getServerUrl();
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        String signType = aliPayConfig.getSignType();
+        //实例化客户端
+//        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", APP_ID, APP_PRIVATE_KEY, "json", CHARSET, ALIPAY_PUBLIC_KEY, "RSA2");
+        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl, appId, privateKey, format, charset, alipayPublicKey, signType);
+        //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
+        AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
+        //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
+        AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+        model.setBody("");
+        model.setSubject(paymentRequestDto.getBody());
+        model.setOutTradeNo(paymentRequestDto.getOrderNo());
+        model.setTimeExpire(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,new Date(paymentRequestDto.getCreateOrderTime().getTime()+2800*60)));
+        //model.setTimeoutExpress("3m");
+//        model.setTotalAmount("0.01");
+        model.setTotalAmount(String.valueOf(paymentRequestDto.getTotalAmount().setScale(2,BigDecimal.ROUND_DOWN)));
+        model.setProductCode("QUICK_MSECURITY_PAY");
+        request.setBizModel(model);
+        request.setNotifyUrl(aliPayConfig.getPayNotifyUrl());
+        try {
+            //这里和普通的接口调用不同,使用的是sdkExecute
+            AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
+            LogSyncUtil.logSync("支付宝直连统一下单,交易编号:{},返回结果:{}",paymentRequestDto.getOrderNo(),response);
+            if (response.isSuccess()) {
+                return ResultMap.ok()
+                        .put("data",response.getBody())
+                        .put("paySubType",aliPayConfig.getName())
+                        ;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return ResultMap.error(-1,"调用失败");
+    }
+    /**
+     * 支付宝退款
+     * @param orderNo
+     * @param amount
+     * @param body
+     * @return
+     */
+    @Override
+    public ResultMap aliRefundNotify(String appid,String orderNo, BigDecimal amount, String body){
+        AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(appid);
+        if(null == aliPayConfig){
+            aliPayConfig = this.aliPayConfig;
+        }
+        String serverUrl = aliPayConfig.getServerUrl();
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        String signType = aliPayConfig.getSignType();
+        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl,appId,privateKey,format,charset,alipayPublicKey,signType);
+        AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", orderNo);
+        bizContent.put("refund_amount", amount);
+        String out_request_no = RandomUtil.getRandom(RandomUtil.REFUND_NO);
+        bizContent.put("out_request_no", out_request_no);
+        bizContent.put("refund_reason", body);
+        //// 返回参数选项,按需传入
+        JSONArray queryOptions = new JSONArray();
+        queryOptions.add("refund_detail_item_list");
+        bizContent.put("query_options", queryOptions);
+        request.setBizContent(bizContent.toString());
+        try {
+            LogSyncUtil.logSync("支付宝直连 退款,交易编号:{},请求参数:{}",orderNo,request);
+            AlipayTradeRefundResponse response = alipayClient.execute(request);
+            String responseBody = response.getBody();
+            JSONObject jsonObject = JSONObject.parseObject(responseBody);
+            LogSyncUtil.logSync("支付宝直连 退款,交易编号:{},返回结果:{}",orderNo,jsonObject);
+            log.debug("返回数据》》》{}",jsonObject);
+            JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response");
+            if(response.isSuccess()){
+                System.out.println("调用成功");
+                if("10000".equals(alipay_trade_refund_response.getString("code"))){//网关返回状态 10000 代表成功
+                    alipay_trade_refund_response.put("out_refund_no",out_request_no);
+                    alipay_trade_refund_response.put("refund_id",out_request_no);
+                    String refund_fee = alipay_trade_refund_response.get("refund_fee").toString();
+                    alipay_trade_refund_response.put("refund_fee", (StringUtils.isEmpty(refund_fee) ? 0 : Double.valueOf(refund_fee)) * 100);
+                    String send_back_fee = alipay_trade_refund_response.get("send_back_fee").toString();
+                    alipay_trade_refund_response.put("send_back_fee", (StringUtils.isEmpty(send_back_fee) ? 0 : Double.valueOf(send_back_fee)) * 100);
+                    return ResultMap.ok()
+                            .put("data",alipay_trade_refund_response)
+                            ;
+                } else {
+                    return ResultMap.error(Integer.parseInt(alipay_trade_refund_response.getString("code")),alipay_trade_refund_response.getString("sub_msg"));
+                }
+            } else {
+                System.out.println("调用失败");
+//                return ResultMap.error(-1,"调用失败");
+                return ResultMap.error(Integer.parseInt(alipay_trade_refund_response.getString("code")),alipay_trade_refund_response.getString("sub_msg"));
+            }
+        } catch (AlipayApiException e) {
+            e.printStackTrace();
+        }
+        return ResultMap.error(-1,"调用失败");
+    }
+
+    /**
+     * 查询订单
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public AlipayTradeQueryResponse searchOrder(String orderNo){
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String signType = aliPayConfig.getSignType();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        AlipayClient alipayClient = new DefaultAlipayClient(searchUrl, appId,privateKey,format, charset,alipayPublicKey,signType);
+        AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", orderNo);
+        request.setBizContent(bizContent.toString());
+        try{
+            return alipayClient.execute(request);
+        }catch (Exception e){}
+        return null;
+    }
+
+    /**
+     * 查询订单
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public PaymentInfoResponseDto queryOrder(String appid,String orderNo){
+        AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(appid);
+        if(null == aliPayConfig){
+            aliPayConfig = this.aliPayConfig;
+        }
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String signType = aliPayConfig.getSignType();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        AlipayClient alipayClient = new DefaultAlipayClient(searchUrl, appId,privateKey,format, charset,alipayPublicKey,signType);
+        AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", orderNo);
+        request.setBizContent(bizContent.toString());
+        try{
+            LogSyncUtil.logSync("支付宝直连 查询,交易编号:{},请求参数:{}",orderNo,request);
+            AlipayTradeQueryResponse response = alipayClient.execute(request);
+            LogSyncUtil.logSync("支付宝直连 查询,交易编号:{},返回结果:{}",orderNo,response);
+            PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+            if(response!=null &&response.isSuccess()&& Constants.ALIPAY_TRADE_SUCCESS.equals(response.getTradeStatus())){
+                paymentInfoResponseDto.setOrderNo(orderNo);
+                paymentInfoResponseDto.setPayWay("alipay");
+                paymentInfoResponseDto.setAppid(appId);
+                paymentInfoResponseDto.setPaymentNo(response.getTradeNo());
+                paymentInfoResponseDto.setPaymentPrice(new BigDecimal(response.getTotalAmount()));
+                paymentInfoResponseDto.setActualPayment(new BigDecimal(response.getBuyerPayAmount()));
+                paymentInfoResponseDto.setPaymentSuccessTime(response.getSendPayDate());
+                paymentInfoResponseDto.setTradeState(response.getTradeStatus());
+                paymentInfoResponseDto.setTradeStateDesc(response.getTradeStatus());
+                paymentInfoResponseDto.setSuccess(true);
+                return paymentInfoResponseDto;
+            }else{
+                return PaymentInfoResponseDto.error(-1,response.getMsg());
+            }
+        }catch (Exception e){}
+        return PaymentInfoResponseDto.error(-1,"查询支付宝支付订单失败");
+    }
+
+    /**
+     * 关闭订单
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public boolean closeTradeOrder(String orderNo){
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String signType = aliPayConfig.getSignType();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        AlipayClient alipayClient = new DefaultAlipayClient(searchUrl, appId,privateKey,format, charset,alipayPublicKey,signType);
+        AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", orderNo);
+        request.setBizContent(bizContent.toString());
+        try{
+            AlipayTradeCloseResponse response = alipayClient.execute(request);
+            if(response.isSuccess()){
+                return true;
+            }
+        }catch (Exception e){}
+        return false;
+    }
+    /**
+     * 关闭订单-新
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public ResultMap closeTradeOrderNew(String appid,String orderNo){
+        AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(appid);
+        if(null == aliPayConfig){
+            aliPayConfig = this.aliPayConfig;
+        }
+        String errMsg = "";
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String signType = aliPayConfig.getSignType();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        AlipayClient alipayClient = new DefaultAlipayClient(searchUrl, appId,privateKey,format, charset,alipayPublicKey,signType);
+        AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", orderNo);
+        request.setBizContent(bizContent.toString());
+        try{
+            AlipayTradeCloseResponse response = alipayClient.execute(request);
+            if(response.isSuccess()){
+                return ResultMap.ok();
+            }else{
+                errMsg = response.getMsg();
+            }
+        }catch (Exception e){
+            log.error("支付宝关闭订单【"+orderNo+"】错误{}",e.getMessage());
+            errMsg = "支付宝关闭订单【"+orderNo+"】错误:"+e.getMessage();
+        }
+        return ResultMap.error(-1,errMsg);
+    }
+
+/*****************************新逻辑**********************/
+    /**
+     * 统一下单-新
+     * @param paymentRequestDto
+     * @return
+     */
+    /*@Override
+    public ResultMap unifiedOrderNew(PaymentRequestDto paymentRequestDto){
+        if(StringUtils.isNotEmpty(paymentRequestDto.getBody()) && paymentRequestDto.getBody().getBytes().length >128){
+            paymentRequestDto.setBody(Base64Util.subStringByBytes(paymentRequestDto.getBody(),120)+"...");
+        }
+        AliPayConfig aliPayConfig = (AliPayConfig) paymentRequestDto.getPayConfigByClass(AliPayConfig.class);
+        *//*AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(paymentRequestDto.getAppid());
+        if(null == aliPayConfig){
+            aliPayConfig = this.aliPayConfig;
+        }*//*
+        String serverUrl = aliPayConfig.getServerUrl();
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        String signType = aliPayConfig.getSignType();
+        //实例化客户端
+//        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", APP_ID, APP_PRIVATE_KEY, "json", CHARSET, ALIPAY_PUBLIC_KEY, "RSA2");
+        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl, appId, privateKey, format, charset, alipayPublicKey, signType);
+        //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
+        AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
+        //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
+        AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+        model.setBody("");
+        model.setSubject(paymentRequestDto.getBody());
+        model.setOutTradeNo(paymentRequestDto.getOrderNo());
+        String expireTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,paymentRequestDto.getExpireTime());
+        model.setTimeExpire(expireTime);
+        //model.setTimeoutExpress("3m");
+//        model.setTotalAmount("0.01");
+        model.setTotalAmount(String.valueOf(paymentRequestDto.getTotalAmount().setScale(2,BigDecimal.ROUND_DOWN)));
+        model.setProductCode("QUICK_MSECURITY_PAY");
+        model.setPassbackParams(paymentRequestDto.getPayWay());
+        request.setBizModel(model);
+        request.setNotifyUrl(aliPayConfig.getPayNotifyUrl());
+        try {
+            //这里和普通的接口调用不同,使用的是sdkExecute
+            AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
+            if (response.isSuccess()) {
+                return ResultMap.ok()
+                        .put("data",response.getBody())
+                        .put("paySubType",aliPayConfig.getName())
+                        ;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return ResultMap.error(-1,"调用失败");
+    }*/
+    /**
+     * 统一下单-新
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap unifiedOrderNew(PaymentRequestDto paymentRequestDto){
+        if(StringUtils.isNotEmpty(paymentRequestDto.getBody()) ){
+            paymentRequestDto.setBody(Base64Util.subStringByBytes(paymentRequestDto.getBody(),120)+"...");
+        }
+        if(paymentRequestDto.getPayWay().contains("web")){
+            return mainPay(paymentRequestDto);
+        }
+        return appPay(paymentRequestDto);
+    }
+
+    /**
+     * app支付
+     * @param paymentRequestDto
+     * @return
+     */
+    public ResultMap appPay(PaymentRequestDto paymentRequestDto){
+        RechargeUserInfoDto rechargeUserInfoDto = paymentRequestDto.getRechargeUserInfoDto();
+        AliPayConfig aliPayConfig = (AliPayConfig) paymentRequestDto.getPayConfigByClass(AliPayConfig.class);
+        /*AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(paymentRequestDto.getAppid());
+        if(null == aliPayConfig){
+            aliPayConfig = this.aliPayConfig;
+        }*/
+        String serverUrl = aliPayConfig.getServerUrl();
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        String signType = aliPayConfig.getSignType();
+        //实例化客户端
+//        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", APP_ID, APP_PRIVATE_KEY, "json", CHARSET, ALIPAY_PUBLIC_KEY, "RSA2");
+        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl, appId, privateKey, format, charset, alipayPublicKey, signType);
+        //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
+        AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
+        //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
+        AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+        model.setBody("");
+        model.setSubject(paymentRequestDto.getBody());
+        model.setOutTradeNo(paymentRequestDto.getOrderNo());
+        model.setTimeExpire(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,paymentRequestDto.getExpireTime()));
+        //model.setTimeoutExpress("3m");
+//        model.setTotalAmount("0.01");
+        model.setTotalAmount(String.valueOf(paymentRequestDto.getTotalAmount().setScale(2,BigDecimal.ROUND_DOWN)));
+        model.setProductCode("QUICK_MSECURITY_PAY");
+        model.setPassbackParams(paymentRequestDto.getPayWay());
+        //设置支付用户信息
+        if(null != rechargeUserInfoDto && rechargeUserInfoDto.isCheckUserAuth()){
+            ExtUserInfo userInfo = new ExtUserInfo();
+            userInfo.setName(rechargeUserInfoDto.getUserName());//实名认证姓名
+            userInfo.setCertType("IDENTITY_CARD");//实名认证证件类型
+            userInfo.setCertNo(rechargeUserInfoDto.getCertificateNo());//实名认证证件号
+            userInfo.setNeedCheckInfo("T");//是否需要实名认证
+            model.setExtUserInfo(userInfo);
+        }
+        request.setBizModel(model);
+        request.setNotifyUrl(aliPayConfig.getPayNotifyUrl());
+
+        try {
+            LogSyncUtil.logSync("支付宝直连 下单,交易编号:{},请求参数:{}",paymentRequestDto.getOrderNo(),request);
+            //这里和普通的接口调用不同,使用的是sdkExecute
+            AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
+            LogSyncUtil.logSync("支付宝直连 下单,交易编号:{},返回结果:{}",paymentRequestDto.getOrderNo(),response);
+            if (response.isSuccess()) {
+                return ResultMap.ok()
+                        .put("data",response.getBody())
+                        .put("paySubType",aliPayConfig.getName())
+                        ;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return ResultMap.error(-1,"调用失败");
+    }
+
+    /**
+     * 主扫
+     * @param paymentRequestDto
+     * @return
+     */
+    public ResultMap mainPay(PaymentRequestDto paymentRequestDto){
+        RechargeUserInfoDto rechargeUserInfoDto = paymentRequestDto.getRechargeUserInfoDto();
+        AliPayConfig aliPayConfig = (AliPayConfig) paymentRequestDto.getPayConfigByClass(AliPayConfig.class);
+        /*AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(paymentRequestDto.getAppid());
+        if(null == aliPayConfig){
+            aliPayConfig = this.aliPayConfig;
+        }*/
+        String serverUrl = aliPayConfig.getServerUrl();
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        String signType = aliPayConfig.getSignType();
+        //实例化客户端
+//        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", APP_ID, APP_PRIVATE_KEY, "json", CHARSET, ALIPAY_PUBLIC_KEY, "RSA2");
+        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl, appId, privateKey, format, charset, alipayPublicKey, signType);
+        //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
+        AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
+        //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
+        AlipayTradePrecreateModel model = new AlipayTradePrecreateModel();
+        model.setBody("");
+        model.setSubject(paymentRequestDto.getBody());
+        model.setOutTradeNo(paymentRequestDto.getOrderNo());
+//        model.setTimeExpire(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,paymentRequestDto.getExpireTime()));
+        //model.setTimeoutExpress("3m");
+//        model.setTotalAmount("0.01");
+        model.setTotalAmount(String.valueOf(paymentRequestDto.getTotalAmount().setScale(2,BigDecimal.ROUND_DOWN)));
+        model.setPassbackParams(paymentRequestDto.getPayWay());
+        //设置支付用户信息
+        if(null != rechargeUserInfoDto && rechargeUserInfoDto.isCheckUserAuth()){
+            ExtUserInfo userInfo = new ExtUserInfo();
+            userInfo.setName(rechargeUserInfoDto.getUserName());//实名认证姓名
+            userInfo.setCertType("IDENTITY_CARD");//实名认证证件类型
+            userInfo.setCertNo(rechargeUserInfoDto.getCertificateNo());//实名认证证件号
+            userInfo.setNeedCheckInfo("T");//是否需要实名认证
+            model.setExtUserInfo(userInfo);
+        }
+        request.setBizModel(model);
+        request.setNotifyUrl(aliPayConfig.getPayNotifyUrl());
+        try {
+            LogSyncUtil.logSync("支付宝直连 主扫下单,交易编号:{},请求参数:{}",paymentRequestDto.getOrderNo(),request);
+            //这里和普通的接口调用不同,使用的是sdkExecute
+            AlipayTradePrecreateResponse response = alipayClient.execute(request);
+            LogSyncUtil.logSync("支付宝直连 主扫下单,交易编号:{},返回结果:{}",paymentRequestDto.getOrderNo(),response);
+            if (response.isSuccess()) {
+                String url = response.getQrCode();
+                Map<String, String> data = new HashMap<>();
+                data.put("url", "alipays://platformapi/startapp?appId=20000067&url="+url);
+                return ResultMap.ok()
+                        .put("data",data)
+                        .put("paySubType",aliPayConfig.getName())
+                        ;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return ResultMap.error(-1,"调用失败");
+    }
+
+
+    /**
+     * 支付宝退款
+     * @param refundRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap aliRefundNotify(RefundRequestDto refundRequestDto){
+        AliPayConfig aliPayConfig = (AliPayConfig) refundRequestDto.getPayConfigByClass(AliPayConfig.class);
+        String orderNo = refundRequestDto.getOrderNo();
+        BigDecimal amount = refundRequestDto.getRefundAmount();
+        String body = refundRequestDto.getRefundMsg();
+//        AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(appid);
+//        if(null == aliPayConfig){
+//            aliPayConfig = this.aliPayConfig;
+//        }
+        String serverUrl = aliPayConfig.getServerUrl();
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        String signType = aliPayConfig.getSignType();
+        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl,appId,privateKey,format,charset,alipayPublicKey,signType);
+        AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", orderNo);
+        bizContent.put("refund_amount", amount);
+        String out_request_no = RandomUtil.getRandom(RandomUtil.REFUND_NO);
+        bizContent.put("out_request_no", out_request_no);
+        bizContent.put("refund_reason", body);
+        //// 返回参数选项,按需传入
+        JSONArray queryOptions = new JSONArray();
+        queryOptions.add("refund_detail_item_list");
+        bizContent.put("query_options", queryOptions);
+        request.setBizContent(bizContent.toString());
+        try {
+            LogSyncUtil.logSync("支付宝直连 退款,交易编号:{},请求参数:{}",refundRequestDto.getRefundNo(),request);
+            AlipayTradeRefundResponse response = alipayClient.execute(request);
+            String responseBody = response.getBody();
+            JSONObject jsonObject = JSONObject.parseObject(responseBody);
+            log.debug("返回数据》》》{}",jsonObject);
+            JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response");
+            LogSyncUtil.logSync("支付宝直连 退款,交易编号:{},返回结果:{}",refundRequestDto.getRefundNo(),response);
+            if(response.isSuccess()){
+                System.out.println("调用成功");
+                if("10000".equals(alipay_trade_refund_response.getString("code"))){//网关返回状态 10000 代表成功
+                    alipay_trade_refund_response.put("out_refund_no",out_request_no);
+                    alipay_trade_refund_response.put("refund_id",out_request_no);
+                    String refund_fee = alipay_trade_refund_response.get("refund_fee").toString();
+                    alipay_trade_refund_response.put("refund_fee", (StringUtils.isEmpty(refund_fee) ? 0 : Double.valueOf(refund_fee)) * 100);
+                    String send_back_fee = alipay_trade_refund_response.get("send_back_fee").toString();
+                    alipay_trade_refund_response.put("send_back_fee", (StringUtils.isEmpty(send_back_fee) ? 0 : Double.valueOf(send_back_fee)) * 100);
+                    alipay_trade_refund_response.put("fund_change","Y");
+                    return ResultMap.ok()
+                            .put("data",alipay_trade_refund_response)
+                            ;
+                } else {
+                    return ResultMap.error(Integer.parseInt(alipay_trade_refund_response.getString("code")),alipay_trade_refund_response.getString("sub_msg"));
+                }
+            } else {
+                System.out.println("调用失败");
+//                return ResultMap.error(-1,"调用失败");
+                return ResultMap.error(Integer.parseInt(alipay_trade_refund_response.getString("code")),alipay_trade_refund_response.getString("sub_msg"));
+            }
+        } catch (AlipayApiException e) {
+            e.printStackTrace();
+        }
+        return ResultMap.error(-1,"调用失败");
+    }
+
+    /**
+     * 查询订单
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto){
+        AliPayConfig aliPayConfig = (AliPayConfig) paymentRequestDto.getPayConfigByClass(AliPayConfig.class);
+        String orderNo = paymentRequestDto.getOrderNo();
+//        AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(appid);
+//        if(null == aliPayConfig){
+//            aliPayConfig = this.aliPayConfig;
+//        }
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String signType = aliPayConfig.getSignType();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        AlipayClient alipayClient = new DefaultAlipayClient(searchUrl, appId,privateKey,format, charset,alipayPublicKey,signType);
+        AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", orderNo);
+        request.setBizContent(bizContent.toString());
+        try{
+            LogSyncUtil.logSync("支付宝直连 查询,交易编号:{},请求参数:{}",paymentRequestDto.getOrderNo(),request);
+            AlipayTradeQueryResponse response = alipayClient.execute(request);
+            PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+            log.info(" 支付宝查询结果:{} ",paymentInfoResponseDto);
+            LogSyncUtil.logSync("支付宝直连 查询,交易编号:{},返回结果:{}",paymentRequestDto.getOrderNo(),paymentInfoResponseDto);
+            if(response!=null &&response.isSuccess()&& Constants.ALIPAY_TRADE_SUCCESS.equals(response.getTradeStatus())){
+                paymentInfoResponseDto.setOrderNo(orderNo);
+                paymentInfoResponseDto.setPayWay("alipay");
+                paymentInfoResponseDto.setAppid(appId);
+                paymentInfoResponseDto.setPaymentNo(response.getTradeNo());
+                paymentInfoResponseDto.setPaymentPrice(new BigDecimal(response.getTotalAmount()));
+                paymentInfoResponseDto.setActualPayment(new BigDecimal(response.getBuyerPayAmount()));
+                paymentInfoResponseDto.setPaymentSuccessTime(response.getSendPayDate());
+                paymentInfoResponseDto.setSuccess(true);
+                return paymentInfoResponseDto;
+            }else{
+                return PaymentInfoResponseDto.error(-1,response.getMsg());
+            }
+        }catch (Exception e){}
+        return PaymentInfoResponseDto.error(-1,"查询支付宝支付订单失败");
+    }
+    /**
+     * 查询退款订单
+     * @param refundRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap queryRefundOrder(RefundRequestDto refundRequestDto){
+        AliPayConfig aliPayConfig = (AliPayConfig) refundRequestDto.getPayConfigByClass(AliPayConfig.class);
+        String orderNo = refundRequestDto.getMerOrderId();
+        String refundNo = StringUtils.isEmpty(refundRequestDto.getRefundNo()) ? orderNo : refundRequestDto.getRefundNo();
+//        AliPayConfig aliPayConfig = (AliPayConfig) payConfig.get(appid);
+//        if(null == aliPayConfig){
+//            aliPayConfig = this.aliPayConfig;
+//        }
+        String appId = aliPayConfig.getAppId();
+        String privateKey = aliPayConfig.getPrivateKey();
+        String format = aliPayConfig.getFormat();
+        String charset = aliPayConfig.getCharset();
+        String signType = aliPayConfig.getSignType();
+        String alipayPublicKey = aliPayConfig.getAlipayPublicKey();
+        AlipayClient alipayClient = new DefaultAlipayClient(searchUrl, appId,privateKey,format, charset,alipayPublicKey,signType);
+        AlipayTradeFastpayRefundQueryRequest  request = new AlipayTradeFastpayRefundQueryRequest ();
+        JSONObject bizContent = new JSONObject();
+        bizContent.put("out_trade_no", orderNo);
+        bizContent.put("out_request_no", refundNo);
+        bizContent.put("query_options", new String[]{"gmt_refund_pay"});
+        request.setBizContent(bizContent.toString());
+        try{
+            LogSyncUtil.logSync("支付宝直连 退款查询,交易编号:{},请求参数:{}",refundRequestDto.getOrderNo(),request);
+            AlipayTradeFastpayRefundQueryResponse response = alipayClient.execute(request);
+            PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+            JSONObject alipay_trade_refund_response = (JSONObject) JSONObject.toJSON(paymentInfoResponseDto);
+            LogSyncUtil.logSync("支付宝直连 退款查询,交易编号:{},返回结果:{}",refundRequestDto.getOrderNo(),paymentInfoResponseDto);
+            if(response!=null &&response.isSuccess() && Constants.ALIPAY_REFUND_SUCCESS.equals(response.getRefundStatus())){
+                alipay_trade_refund_response.put("out_refund_no",refundNo);
+                alipay_trade_refund_response.put("refund_id",response.getTradeNo());
+                String refund_fee = response.getRefundAmount();
+                alipay_trade_refund_response.put("refund_fee", (StringUtils.isEmpty(refund_fee) ? 0 : Double.valueOf(refund_fee)) * 100);
+                String send_back_fee = response.getSendBackFee();
+                alipay_trade_refund_response.put("send_back_fee", (StringUtils.isEmpty(send_back_fee) ? 0 : Double.valueOf(send_back_fee)) * 100);
+                alipay_trade_refund_response.put("fund_change","Y");
+                Date gmt_refund_pay = response.getGmtRefundPay();
+                alipay_trade_refund_response.put("refund_time",gmt_refund_pay);
+                return ResultMap.ok()
+                        .put("data",alipay_trade_refund_response)
+                        ;
+            }else{
+                return ResultMap.error(-1,response.getMsg());
+            }
+        }catch (Exception e){}
+        return ResultMap.error(-1,"查询支付宝退款订单失败");
+    }
+}

+ 53 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BankServiceImpl.java

@@ -0,0 +1,53 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.tzy.framework.pay.dto.BankInfo;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+import com.tzy.framework.pay.service.BankService;
+import com.tzy.framework.pay.service.BofooAgreementService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class BankServiceImpl implements BankService {
+
+    @Autowired
+    private BofooAgreementService bofooAgreementService;
+
+    public BankInfo ReadySign(BankInfo bankInfo){
+        return bofooAgreementService.ReadySign(bankInfo);
+    }
+
+    public BankInfo ConfirmSign(BankInfo bankInfo){
+        return bofooAgreementService.ConfirmSign(bankInfo);
+    }
+
+    public BankInfo QueryBind(BankInfo bankInfo) {
+        return bofooAgreementService.QueryBind(bankInfo);
+    }
+
+    public BankInfo unBind(BankInfo bankInfo) {
+        return bofooAgreementService.unBind(bankInfo);
+    }
+
+    public ResultMap SinglePay(PaymentRequestDto payRequestBody){
+        return bofooAgreementService.SinglePay(payRequestBody);
+    }
+    /**
+     * 预支付
+     * @param payRequestBody
+     */
+    public ResultMap ReadyPay(PaymentRequestDto payRequestBody) {
+        return bofooAgreementService.ReadyPay(payRequestBody);
+    }
+
+    /**
+     * 确认支付
+     * @param payRequestBody
+     */
+    public ResultMap ConfirmPay(PaymentRequestDto payRequestBody) {
+        return bofooAgreementService.ConfirmPay(payRequestBody);
+    }
+
+
+}

+ 492 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BaoFooBankPayServiceImpl.java

@@ -0,0 +1,492 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.base.dto.DictBaseDto;
+import com.tzy.base.service.SysBaseService;
+import com.tzy.common.utils.Base64Util;
+import com.tzy.common.utils.DateUtils;
+import com.tzy.common.utils.LogSyncUtil;
+import com.tzy.common.utils.StringUtils;
+import com.tzy.framework.pay.config.BaoFooPayConfig;
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+import com.tzy.framework.pay.service.BaoFooBankPayService;
+import com.tzy.framework.pay.util.bofoo.bank.HttpUtil;
+import com.tzy.framework.pay.util.bofoo.bank.RsaCodingUtil;
+import com.tzy.framework.pay.util.bofoo.bank.SecurityUtil;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 宝付银行卡支付
+ */
+@Slf4j
+@Service
+public class BaoFooBankPayServiceImpl implements BaoFooBankPayService {
+
+    public static final String URL = "https://mch-juhe.baofoo.com/api";
+    @Value("${tzy.app-version:dev}")
+    private String appversion ;
+    @Autowired
+    private BaoFooPayConfig baoFooPayConfig ;
+    @Autowired
+    private SysBaseService sysBaseService;
+
+    public static void main(String[] args) throws Exception{
+        BaoFooBankPayServiceImpl service = new BaoFooBankPayServiceImpl();
+        service.baoFooPayConfig = new BaoFooPayConfig();
+        PaymentRequestDto payRequestBody = new PaymentRequestDto();
+        payRequestBody.setBody("测试支付");
+        payRequestBody.setTotalAmount(new BigDecimal("1000"));
+        payRequestBody.setOrderNo(RandomUtil.getRandomNew(RandomUtil.GROUP_USER_ORDER));
+//        ResultMap bankType = service.getBankType(payRequestBody);
+//        log.info("获取银行卡列表>>>>"+bankType);
+//        ResultMap order = service.createOrder(payRequestBody);
+//        payRequestBody.setUacBank("4020039");
+//        payRequestBody.setMerOrderId(String.valueOf(order.get("trade_no")));
+//        log.info("下单结果>>>>"+service.unifiedOrder(payRequestBody));
+        //查询
+        PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
+        paymentRequestDto.setMerOrderId("GU202304201247511431");//GU202304141528385870
+        log.info("查询结果>>>>"+service.queryOrder(paymentRequestDto));
+        //退款
+//        RefundRequestDto refundRequestDto = new RefundRequestDto();
+//        refundRequestDto.setTradeNo("GU202304141637244105");
+//        refundRequestDto.setRefundAmount(new BigDecimal(1000));
+//        refundRequestDto.setRefundMsg("退款测试!");//RN202304141640122746
+//        log.info("退款申请>>>>"+service.refund(refundRequestDto));
+        //退款查询
+//        RefundRequestDto refundRequestDto = new RefundRequestDto();
+//        refundRequestDto.setRefundNo("RN202304141640122746");//RN202304141601525321
+//        log.info("退款查询>>>>"+service.refundQuery(refundRequestDto));
+    }
+
+    @Override
+    public ResultMap getBankList(PaymentRequestDto payRequestBody){
+        ResultMap resultMap = createOrder(payRequestBody);
+        if(null != resultMap && 0 == (int)resultMap.get("code")){
+            try {
+                //获取银行列表
+                baoFooPayConfig = initPayConfig(payRequestBody);
+                String memberId = baoFooPayConfig.getMid();
+                String terminalId = baoFooPayConfig.getTid();
+                String trade_no = String.valueOf(resultMap.get("trade_no"));//(下单接口中的商户订单号)
+//                String ServerUrl = "https://vgw.baofoo.com/union-gw/api/T-1001-024-02/transReq.do";//test
+                String ServerUrl = "https://public.baofu.com/union-gw/api/T-1001-024-02/transReq.do";
+                String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+                String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+                String pfx_pwd = baoFooPayConfig.getPrivateKeyPwd();
+                Map<String, String> HeaderPost = new HashMap<String, String>();
+                HeaderPost.put("memberId", memberId);// 宝付提供给商户的唯一编号
+                HeaderPost.put("terminalId", terminalId);
+                HeaderPost.put("serviceTp", "T-1001-024-02");//
+                HeaderPost.put("verifyType", "1");// 加密方式目前只有1种,请填:1
+                Map<String, String> BodyData = new TreeMap<String, String>();
+                BodyData.put("memberTransId", trade_no);// 商户订单号
+                BodyData.put("memberId", memberId);//商户号
+                BodyData.put("cardType", "1");//类型  1 借记卡
+                Map<String, Object> contentData = new TreeMap<String, Object>();
+                contentData.put("header", HeaderPost);
+                contentData.put("body", BodyData);
+                String jsonString = JSONObject.toJSONString(contentData);
+                log.info("序列化:" + jsonString);
+                String base64str = SecurityUtil.Base64Encode(jsonString);
+                String data_content = RsaCodingUtil.encryptByPriPfxFile(base64str, pfxpath, pfx_pwd);
+                HeaderPost.put("content", data_content);
+                LogSyncUtil.logSync("宝付手机银行支付 获取银行卡列表,交易编号:{},请求参数:{}",trade_no,HeaderPost);
+                String retStr = HttpUtil.RequestForm(ServerUrl, HeaderPost);
+                log.info("请求返回:" + retStr);
+                LogSyncUtil.logSync("宝付手机银行支付 获取银行卡列表,交易编号:{},返回结果:{}",trade_no,retStr);
+                String retStrDe = SecurityUtil.Base64Decode(RsaCodingUtil.decryptByPubCerFile(retStr, cerpath));
+                JSONObject jsonObject = JSONObject.parseObject(retStrDe);
+                log.info("下单返回结果 >>> " + jsonObject);
+                JSONObject retBody = jsonObject.getJSONObject("body");
+                if("0000".equals(retBody.getString("errorCode"))){
+                    JSONArray bankList = retBody.getJSONArray("bankList");
+                    Map<String , JSONObject> bankMap = new HashMap<>();
+                    bankList.forEach(item->{
+                        JSONObject jsonItem = (JSONObject) item;
+                        String bankName = jsonItem.getString("functionId");
+                        bankMap.put(bankName,jsonItem);
+                    });
+                    List<DictBaseDto> bankListDicts = sysBaseService.selectDictDataByDictType("bank_list");
+                    JSONArray bankitems = new JSONArray();
+                    if(null != bankListDicts && bankListDicts.size() > 0){
+                        bankListDicts.forEach(item->{
+                            JSONObject bankValue = bankMap.get(item.getKey());
+                            bankValue.put("url",item.getRemark());
+                            bankitems.add(bankValue);
+                        });
+                    }
+                    return ResultMap.ok()
+                            .put("bankList",bankitems)
+                            .put("trade_no",trade_no)
+                            ;
+                } else {
+                    return ResultMap.error(retBody.getString("errorMsg"));
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+                log.error("getBankList  下单失败  {}",e);
+            }
+            return ResultMap.error("下单失败");
+        }
+        return resultMap;
+    }
+
+    private ResultMap createOrder(PaymentRequestDto payRequestBody){
+        try {
+            String body = String.valueOf(payRequestBody.getBody());
+            if(StringUtils.isNotEmpty(body) ){
+                body = Base64Util.subStringByBytes(body,80)+"...";
+            }
+            baoFooPayConfig = initPayConfig(payRequestBody);
+            String memberId = baoFooPayConfig.getMid();
+            String terminalId = baoFooPayConfig.getTid();
+            String orderAmt = String.valueOf(payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue());
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfx_pwd = baoFooPayConfig.getPrivateKeyPwd();
+            String trade_no = payRequestBody.getMerOrderId();
+            String ServerUrl = "https://public.baofu.com/union-gw/api/T-1001-024-01/transReq.do";
+            Map<String, String> HeaderPost = new HashMap<String, String>();
+            HeaderPost.put("memberId", memberId);// 宝付提供给商户的唯一编号
+            HeaderPost.put("terminalId", terminalId);
+            HeaderPost.put("serviceTp", "T-1001-024-01");//
+            HeaderPost.put("verifyType", "1");// 加密方式目前只有1种,请填:1
+            String tradeDate = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+            Map<String, String> BodyData = new TreeMap<String, String>();
+            BodyData.put("memberTransId", trade_no);// 商户订单号
+//            BodyData.put("memberTransId", payRequestBody.getOrderNo());// 商户订单号
+            BodyData.put("memberId", memberId);//商户号
+            BodyData.put("terminalId", terminalId);//终端号
+            BodyData.put("tradeDate", tradeDate);//交易日期 格式:yyyyMMddHHmms
+            BodyData.put("orderAmt", orderAmt);//单位:分
+            BodyData.put("notifyUrl", baoFooPayConfig.getPayNotifyUrl());//交易异步通知地址。
+            BodyData.put("reqAddtion", body);//请求附加信息
+            BodyData.put("tradeCode", "0");//0⼿机银⾏	1⼿机银
+//            BodyData.put("shareInfo", "");//分账信息
+//            BodyData.put("shareNotifyUrl", "");//分账通知地址
+            Map<String, Object> contentData = new TreeMap<String, Object>();
+            contentData.put("header", HeaderPost);
+            contentData.put("body", BodyData);
+            String Jsonstr = JSONObject.toJSONString(contentData);
+            log.info("序列化:" + Jsonstr);
+            String base64str = SecurityUtil.Base64Encode(Jsonstr);
+            String data_content = RsaCodingUtil.encryptByPriPfxFile(base64str, pfxpath, pfx_pwd);
+            log.info("加密参数data_content》》》" + data_content);
+//            String s = RsaCodingUtil.decryptByPubCerFile(data_content, "C:\\poyi\\project\\admin\\poyee-pay\\src\\main\\resources\\lib\\bofooPublic.cer");
+//            String s = RsaCodingUtil.decryptByPubCerFile(data_content, "/app/configs/bofooPublic.cer");
+//            String inStrDe = SecurityUtil.Base64Decode(s);
+//            log.info("解密请求参数返回:" + inStrDe);
+            HeaderPost.put("content", data_content);
+            LogSyncUtil.logSync("宝付手机银行支付 创建订单,交易编号:{},请求参数:{}",trade_no,HeaderPost);
+            String retString = HttpUtil.RequestForm(ServerUrl, HeaderPost);
+            LogSyncUtil.logSync("宝付手机银行支付 创建订单,交易编号:{},返回结果:{}",trade_no,retString);
+            log.info("请求返回:" + retString);
+            retString = RsaCodingUtil.decryptByPubCerFile(retString, cerpath);
+            String retStrDe = SecurityUtil.Base64Decode(retString);
+            log.info("请求返回(明):" + retStrDe);
+            JSONObject jsonObject = JSONObject.parseObject(retStrDe);
+            log.info("下单返回结果 >>> " + jsonObject);
+            JSONObject retBody = jsonObject.getJSONObject("body");
+            if("0000".equals(retBody.getString("errorCode"))){
+                return ResultMap.ok()
+                        .put("trade_no",trade_no)
+                        ;
+            } else {
+                return ResultMap.error(retBody.getString("errorMsg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(" createOrder  下单失败  {}",e);
+        }
+        return ResultMap.error("下单失败");
+    }
+
+    @Override
+    public ResultMap unifiedOrder(PaymentRequestDto payRequestBody){
+        try{
+            baoFooPayConfig = initPayConfig(payRequestBody);
+            String memberId = baoFooPayConfig.getMid();
+            String terminalId = baoFooPayConfig.getTid();
+            String functionId = payRequestBody.getUacBank();//通过获取银行例表返回
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfx_pwd = baoFooPayConfig.getPrivateKeyPwd();
+            String trade_no = payRequestBody.getMerOrderId();//(下单接口中的商户订单号)
+//            String ServerUrl = "https://vgw.baofoo.com/union-gw/api/T-1001-024-03/transReq.do";//test
+            String ServerUrl = "https://public.baofu.com/union-gw/api/T-1001-024-03/transReq.do";
+            Map<String, String> HeaderPost = new HashMap<String, String>();
+            HeaderPost.put("memberId", memberId);// 宝付提供给商户的唯一编号
+            HeaderPost.put("terminalId",terminalId);
+            HeaderPost.put("serviceTp", "T-1001-024-03");//
+            HeaderPost.put("verifyType", "1");// 加密方式目前只有1种,请填:1
+            Map<String, String> BodyData = new TreeMap<String, String>();
+            BodyData.put("memberTransId",trade_no);// 商户订单号
+            BodyData.put("memberId", memberId);//商户号
+            BodyData.put("functionId", functionId);
+            BodyData.put("channelType", "H5");//受理⽅式: APP、H5, 默认H5
+            BodyData.put("clientIp", "101.229.133.177");//用户IP
+            Map<String, Object> contentData = new TreeMap<String, Object>();
+            contentData.put("header", HeaderPost);
+            contentData.put("body", BodyData);
+            String Jsonstr = JSONObject.toJSONString(contentData);
+            log.info("序列化:" + Jsonstr);
+            String base64str = SecurityUtil.Base64Encode(Jsonstr);
+            String data_content = RsaCodingUtil.encryptByPriPfxFile(base64str, pfxpath, pfx_pwd);
+            log.info("序列化:" + Jsonstr);
+            HeaderPost.put("content", data_content);
+            LogSyncUtil.logSync("宝付手机银行支付 预下单,交易编号:{},请求参数:{}",trade_no,HeaderPost);
+            String PostString = HttpUtil.RequestForm(ServerUrl, HeaderPost);
+            LogSyncUtil.logSync("宝付手机银行支付 预下单,交易编号:{},返回结果:{}",trade_no,PostString);
+            log.info("请求返回:" + PostString);
+            String retStrDe = SecurityUtil.Base64Decode(RsaCodingUtil.decryptByPubCerFile(PostString, cerpath));
+            log.info("请求返回(明):" + retStrDe);
+            JSONObject jsonObject = JSONObject.parseObject(retStrDe);
+            log.info("下单返回结果 >>> " + jsonObject);
+            JSONObject retBody = jsonObject.getJSONObject("body");
+            if("0000".equals(retBody.getString("errorCode"))){
+                //根据不同银行处理不同的请求方式
+                retBody.remove("memberId");
+                return ResultMap.ok()
+                        .put("merOrderId",trade_no)
+                        .put("orderNo",payRequestBody.getOrderNo())
+                        .put("data",retBody)
+                        ;
+            } else {
+                return ResultMap.error(retBody.getString("errorMsg"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("unifiedOrder  下单失败  {}",e);
+        }
+        return ResultMap.error("下单失败");
+    }
+
+    @Override
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        try {
+//            baoFooPayConfig = initPayConfig(payRequestBody);
+            String memberId = baoFooPayConfig.getMid();
+            String terminalId = baoFooPayConfig.getTid();
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfx_pwd = baoFooPayConfig.getPrivateKeyPwd();
+            String trade_no = paymentRequestDto.getOrderNo();//(下单接口中的商户订单号)
+//            String ServerUrl = "https://vgw.baofoo.com/union-gw/api/T-1001-024-04/transReq.do";//test
+            String ServerUrl = "https://public.baofu.com/union-gw/api/T-1001-024-04/transReq.do";
+            Map<String, String> HeaderPost = new HashMap<String, String>();
+            HeaderPost.put("memberId", memberId);// 宝付提供给商户的唯一编号
+            HeaderPost.put("terminalId", terminalId);
+            HeaderPost.put("serviceTp", "T-1001-024-04");//
+            HeaderPost.put("verifyType", "1");// 加密方式目前只有1种,请填:1
+            Map<String, String> BodyData = new TreeMap<String, String>();
+            BodyData.put("memberTransId", trade_no);// 商户订单号
+            BodyData.put("memberId", memberId);//商户号
+            Map<String, Object> contentData = new TreeMap<String, Object>();
+            contentData.put("header", HeaderPost);
+            contentData.put("body", BodyData);
+            String Jsonstr = JSONObject.toJSONString(contentData);
+            log.info("序列化:" + Jsonstr);
+            String base64str = SecurityUtil.Base64Encode(Jsonstr);
+            String data_content = RsaCodingUtil.encryptByPriPfxFile(base64str, pfxpath, pfx_pwd);
+            HeaderPost.put("content", data_content);
+            LogSyncUtil.logSync("宝付手机银行支付 订单查询,交易编号:{},请求参数:{}",trade_no,HeaderPost);
+            String PostString = HttpUtil.RequestForm(ServerUrl, HeaderPost);
+            LogSyncUtil.logSync("宝付手机银行支付 订单查询,交易编号:{},返回结果:{}",trade_no,PostString);
+            log.info("请求返回:" + PostString);
+            String retStrDe = SecurityUtil.Base64Decode(RsaCodingUtil.decryptByPubCerFile(PostString, cerpath));
+            log.info("请求返回(明):" + retStrDe);
+            JSONObject jsonObject = JSONObject.parseObject(retStrDe);
+            log.info("下单返回结果 >>> " + jsonObject);
+            JSONObject retBody = jsonObject.getJSONObject("body");
+            if("0000".equals(retBody.getString("errorCode"))){
+                //根据不同银行处理不同的请求方式
+                if("S".equals(retBody.getString("orderState"))){
+                    //下单成功
+                    paymentInfoResponseDto.setOrderNo(trade_no);
+                    paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
+                    paymentInfoResponseDto.setPaymentNo(StringUtils.isNotEmpty(jsonObject.getString("orderId")) ? jsonObject.getString("orderId") : null);
+                    Integer orderAmt = null != jsonObject.getInteger("orderAmt") ? jsonObject.getInteger("orderAmt") : 0;
+                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                    paymentInfoResponseDto.setActualPayment(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                    Date finishedDate = StringUtils.isNotEmpty(jsonObject.getString("succTime")) ? DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, jsonObject.getString("succTime")) : null;
+                    paymentInfoResponseDto.setPaymentSuccessTime(finishedDate);
+                    paymentInfoResponseDto.setSuccess(true);
+                    return paymentInfoResponseDto
+                            ;
+                }else
+                if("C".equals(retBody.getString("orderState"))){
+                    return PaymentInfoResponseDto.error(-1,"交易关闭");
+                }else
+                if("P".equals(retBody.getString("orderState"))){
+                    return PaymentInfoResponseDto.error(1,"处理中");
+                }else
+                if("F".equals(retBody.getString("orderState"))){
+                    return PaymentInfoResponseDto.error(-1,"支付失败");
+                }
+            } else {
+                return PaymentInfoResponseDto.error(-1,retBody.getString("errorMsg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return PaymentInfoResponseDto.error(-1,"查询失败!");
+    }
+
+    @Override
+    public ResultMap refund( RefundRequestDto refundRequestDto){
+        try {
+            baoFooPayConfig = initRefundConfig(refundRequestDto);
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+            String merId = baoFooPayConfig.getMid();
+            String terId = baoFooPayConfig.getTid();
+            String ServerUrl = "https://public.baofoo.com/cutpayment/api/backTransRequest";
+            String txnTime = getTxnTime();//报文发送日期时间
+            String originOutTradeNo = refundRequestDto.getOrderNo();//原支付订单商户订单号 [与原支付订单宝付交易号二选一比传]
+            String outTradeNo = RandomUtil.getRandomNew(RandomUtil.REFUND_NO);
+            String refundAmt = String.valueOf(refundRequestDto.getRefundAmount().multiply(new BigDecimal(100)).intValue());//退款金额
+            Map<String, String> HeaderPost = new HashMap<String, String>();
+            HeaderPost.put("member_id", merId);// 宝付提供给商户的唯一编号
+            HeaderPost.put("terminal_id", terId);
+            HeaderPost.put("version", "4.0.0.0");//
+            HeaderPost.put("txn_type", "331");
+            HeaderPost.put("txn_sub_type", "09");
+            HeaderPost.put("data_type", "json");
+            Map<String, Object> Biz_Content = new HashMap<String, Object>();
+            Biz_Content.put("member_id", merId);
+            Biz_Content.put("terminal_id", terId);
+            Biz_Content.put("txn_sub_type", "09");
+            Biz_Content.put("refund_type", "1");
+            Biz_Content.put("trans_id", originOutTradeNo);
+            Biz_Content.put("refund_order_no", outTradeNo);
+            Biz_Content.put("trans_serial_no", RandomUtil.getRandomNew(RandomUtil.REFUND_NO));
+            Biz_Content.put("refund_reason", refundRequestDto.getRefundMsg());
+            Biz_Content.put("refund_amt", refundAmt);
+            Biz_Content.put("refund_time", txnTime);
+            Biz_Content.put("notice_url", baoFooPayConfig.getRefundNotifyUrl());
+            String Jsonstr = JSONObject.toJSONString(Biz_Content).toString();
+            log.info("序列化:" + Jsonstr);
+            String base64str = SecurityUtil.Base64Encode(Jsonstr);
+            String data_content = RsaCodingUtil.encryptByPriPfxFile(base64str, pfxpath, pfxpwd);
+            HeaderPost.put("data_content", data_content);
+            LogSyncUtil.logSync("宝付手机银行支付 退款,交易编号:{},请求参数:{}",originOutTradeNo,HeaderPost);
+            String PostString = HttpUtil.RequestForm(ServerUrl, HeaderPost);
+            LogSyncUtil.logSync("宝付手机银行支付 退款,交易编号:{},返回结果:{}",originOutTradeNo,PostString);
+            log.info("请求返回:" + PostString);
+            String retStrDe = SecurityUtil.Base64Decode(RsaCodingUtil.decryptByPubCerFile(PostString, cerpath));
+            log.info("请求返回(明):" + retStrDe);
+            JSONObject jsonObject = JSONObject.parseObject(retStrDe);
+            log.info("下单返回结果 >>> " + jsonObject);
+            if("0000".equals(jsonObject.getString("resp_code"))){
+                //根据不同银行处理不同的请求方式
+                log.info("[申请退款结果]交易成功,成功金额:" + refundAmt.toString() + "分。");
+                //下单成功
+                Map<String, String> stringStringMap = new HashMap<>();
+                stringStringMap.put("out_refund_no", outTradeNo);
+                stringStringMap.put("refund_id", jsonObject.getString("refund_business_no"));
+                stringStringMap.put("refund_fee", String.valueOf(jsonObject.getInteger("refund_amt")));
+                stringStringMap.put("fund_change", "Y");
+//                                stringStringMap.put("finishedDate", result.get("finishedDate"));
+                return ResultMap.ok(jsonObject.getString("resp_msg"))
+                        .put("data", stringStringMap)
+                        ;
+            } else {
+                return ResultMap.error(-1, jsonObject.getString("resp_msg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+    @Override
+    public ResultMap refundQuery( RefundRequestDto refundRequestDto){
+        try {
+            baoFooPayConfig = initRefundConfig(refundRequestDto);
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+            String merId = baoFooPayConfig.getMid();
+            String terId = baoFooPayConfig.getTid();
+            String ServerUrl = "https://public.baofoo.com/cutpayment/api/backTransRequest";
+            String outTradeNo = refundRequestDto.getRefundNo();//原支付订单商户订单号 [与原支付订单宝付交易号二选一比传]
+            String refundAmt = String.valueOf(refundRequestDto.getRefundAmount());//退款金额
+            Map<String, String> HeaderPost = new HashMap<String, String>();
+            HeaderPost.put("member_id", merId);// 宝付提供给商户的唯一编号
+            HeaderPost.put("terminal_id", terId);
+            HeaderPost.put("version", "4.0.0.0");//
+            HeaderPost.put("txn_type", "331");
+            HeaderPost.put("txn_sub_type", "10");
+            HeaderPost.put("data_type", "json");
+            Map<String, Object> Biz_Content = new HashMap<String, Object>();
+            Biz_Content.put("member_id", merId);
+            Biz_Content.put("terminal_id", terId);
+            Biz_Content.put("txn_sub_type", "10");
+            Biz_Content.put("refund_order_no", outTradeNo);
+            Biz_Content.put("trans_serial_no", RandomUtil.getRandomNew(RandomUtil.REFUND_NO));
+            String Jsonstr = JSONObject.toJSONString(Biz_Content).toString();
+            log.info("序列化:" + Jsonstr);
+            String base64str = SecurityUtil.Base64Encode(Jsonstr);
+            String data_content = RsaCodingUtil.encryptByPriPfxFile(base64str, pfxpath, pfxpwd);
+            HeaderPost.put("data_content", data_content);
+            LogSyncUtil.logSync("宝付手机银行支付 退款查询,交易编号:{},请求参数:{}",outTradeNo,HeaderPost);
+            String PostString = HttpUtil.RequestForm(ServerUrl, HeaderPost);
+            LogSyncUtil.logSync("宝付手机银行支付 退款查询,交易编号:{},返回结果:{}",outTradeNo,PostString);
+            log.info("请求返回:" + PostString);
+            String retStrDe = SecurityUtil.Base64Decode(RsaCodingUtil.decryptByPubCerFile(PostString, cerpath));
+            log.info("请求返回(明):" + retStrDe);
+            JSONObject jsonObject = JSONObject.parseObject(retStrDe);
+            log.info("下单返回结果 >>> " + jsonObject);
+            if("0000".equals(jsonObject.getString("resp_code"))){
+                //根据不同银行处理不同的请求方式
+                log.info("[申请退款结果]交易成功,成功金额:" + refundAmt.toString() + "分。");
+                //下单成功
+                Map<String, String> stringStringMap = new HashMap<>();
+                stringStringMap.put("out_refund_no", outTradeNo);
+                stringStringMap.put("refund_id", jsonObject.getString("refund_business_no"));
+                stringStringMap.put("refund_fee", String.valueOf(jsonObject.getInteger("refund_amt")));
+                stringStringMap.put("fund_change", "Y");
+//                                stringStringMap.put("finishedDate", result.get("finishedDate"));
+                return ResultMap.ok(jsonObject.getString("resp_msg"))
+                        .put("data", stringStringMap)
+                        ;
+            } else {
+                return ResultMap.error(-1, jsonObject.getString("resp_msg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+
+    private static String getTxnTime() {
+        return DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSS);
+    }
+
+    private BaoFooPayConfig initPayConfig(PaymentRequestDto paymentRequestDto){
+        BaoFooPayConfig config = StringUtils.isNotEmpty(appversion) && appversion.equals("prod")
+                ? baoFooPayConfig = (BaoFooPayConfig) paymentRequestDto.getPayConfigByClass(BaoFooPayConfig.class) : new BaoFooPayConfig();
+        log.info(" baoFooPayConfig>> "+config);
+        return config;
+    }
+    private BaoFooPayConfig initRefundConfig(RefundRequestDto refundRequestDto){
+        return StringUtils.isNotEmpty(appversion) && appversion.equals("prod")
+                ? baoFooPayConfig = (BaoFooPayConfig) refundRequestDto.getPayConfigByClass(BaoFooPayConfig.class) : new BaoFooPayConfig();
+    }
+}

+ 496 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BaoFooPayServiceImpl.java

@@ -0,0 +1,496 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.common.utils.DateUtils;
+import com.tzy.common.utils.LogSyncUtil;
+import com.tzy.common.utils.StringUtils;
+import com.tzy.framework.pay.Entity.PostMasterEntity;
+import com.tzy.framework.pay.Entity.ResultMasterEntity;
+import com.tzy.framework.pay.Entity.RiskInfoEntity;
+import com.tzy.framework.pay.Entity.TerminalInfoEntity;
+import com.tzy.framework.pay.config.BaoFooPayConfig;
+import com.tzy.framework.pay.dto.*;
+import com.tzy.framework.pay.service.BaoFooPayService;
+import com.tzy.framework.pay.util.HttpUtil;
+import com.tzy.framework.pay.util.bofoo.rsa.SignatureUtils;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 宝付支付
+ */
+@Slf4j
+@Service
+public class BaoFooPayServiceImpl implements BaoFooPayService {
+
+//    public static final String URL = "https://mch-juhe.baofoo.com/api";//test
+    public static final String URL = "https://juhe.baofoo.com/api";
+    @Value("${tzy.app-version:dev}")
+    private String appversion;
+    @Autowired
+    private BaoFooPayConfig baoFooPayConfig ;
+
+    public static void main(String[] args) throws Exception{
+        BaoFooPayServiceImpl service = new BaoFooPayServiceImpl();
+        service.baoFooPayConfig = new BaoFooPayConfig();
+        service.appversion = "prod1";
+        PaymentRequestDto payRequestBody = new PaymentRequestDto();
+        payRequestBody.setBody("测试支付");
+        payRequestBody.setPaySubWay("ALIPAY_NATIVE");
+        payRequestBody.setTotalAmount(new BigDecimal("1000"));
+        payRequestBody.setPayWay("QUICK_PASS_NATIVE");//"ALIPAY_NATIVE";//"WECHAT_JSAPI";//QUICK_PASS_NATIVE
+        log.info("下单结果>>>>"+service.unifiedOrder(payRequestBody));
+        //查询
+//        PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
+//        paymentRequestDto.setOrderNo("GU202304141637244105");//GU202304141528385870
+//        log.info("查询结果>>>>"+service.queryOrder(paymentRequestDto));
+        //退款
+//        RefundRequestDto refundRequestDto = new RefundRequestDto();
+//        refundRequestDto.setTradeNo("GU202304141637244105");
+//        refundRequestDto.setRefundAmount(new BigDecimal(1000));
+//        refundRequestDto.setRefundMsg("退款测试!");//RN202304141640122746
+//        log.info("退款申请>>>>"+service.refund(refundRequestDto));
+        //退款查询
+//        RefundRequestDto refundRequestDto = new RefundRequestDto();
+//        refundRequestDto.setRefundNo("RN202304141640122746");//RN202304141601525321
+//        log.info("退款查询>>>>"+service.refundQuery(refundRequestDto));
+    }
+    /**
+     * 下单
+     * @param payRequestBody
+     * @throws Exception
+     */
+    /*public ResultMap unifiedOrder(PaymentRequestDto payRequestBody){
+        if(payRequestBody.getPayWay().contains("alipay")){
+            return alipayUnifiedOrder(payRequestBody);
+        }
+
+
+        return ResultMap.error("未找到支付方式");
+    }*/
+
+    /**
+     * 下单-支付宝
+     * @param payRequestBody
+     * @throws Exception
+     */
+    public ResultMap unifiedOrder(PaymentRequestDto payRequestBody) {
+        ResultMap resultMap = new ResultMap();
+        try {
+            String appScheme = "";
+            baoFooPayConfig = initPayConfig(payRequestBody);
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+            String txnAmt = String.valueOf(payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue());//用户实际付款金额
+            String totalAmt = String.valueOf(payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue());//订单总金额
+            String txnTime = getTxnTime();//报文发送日期时间
+            String payCode = payRequestBody.getPaySubWay(); //"ALIPAY_NATIVE"; //"ALIPAY_NATIVE";//"WECHAT_JSAPI";//QUICK_PASS_NATIVE
+            String subMchId = StringUtils.isNotEmpty(appversion) && appversion.equals("prod") ? "SIMID": "";//测试传空,生产传SIMID
+            //569520824 微信
+            ///微信支付参数。
+            String sub_appid = "";
+            String sub_openid = "";
+            ///支付宝参数
+            String buyer_id = "";
+            //buyer_id,auth_code
+            String trade_no = RandomUtil.getRandomNew(RandomUtil.GROUP_USER_ORDER);
+            Map<String, Object> Biz_Content = new HashMap<String, Object>();
+            Biz_Content.put("agentMerId", "");
+            Biz_Content.put("agentTerId", "");
+            Biz_Content.put("merId", baoFooPayConfig.getMid());
+            Biz_Content.put("terId", baoFooPayConfig.getTid());
+            Biz_Content.put("outTradeNo", trade_no);
+            Biz_Content.put("txnAmt", txnAmt);
+            Biz_Content.put("txnTime", txnTime);
+            Biz_Content.put("totalAmt", totalAmt);
+            int i = DateUtils.differentMinutesByMillisecond(payRequestBody.getExpireTime(), DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, txnTime));
+            Biz_Content.put("timeExpire", String.valueOf(i));//订单支付的有效时间,单位:分钟
+            Biz_Content.put("prodType", "ORDINARY");//SHARING:分账产品,ORDINARY:普通产品
+            Biz_Content.put("payCode", payCode);
+            /**
+             * WECHAT_JSAPI	微信JSAPI
+             * ALIPAY_NATIVE8 支付宝扫码支付(主扫)
+             * ALIPAY_JSAPI	支付宝生活号支付
+             * QUICK_PASS_NATIVE 云闪付主扫
+             * QUICK_PASS_NATIVE_JS	云闪付主扫JS
+             *
+             */
+            Map<String, Object> Pay_Extend = new HashMap<String, Object>();
+            if (payCode.startsWith("WECHAT")) {
+                ///微信支付属性-公共属性
+                Pay_Extend.put("name", "");
+                Pay_Extend.put("number", "");
+                Pay_Extend.put("type", "");
+                Pay_Extend.put("body",  payRequestBody.getBody());
+                Pay_Extend.put("area_info", "");
+                ////terminal_info 终端信息参数     支付方式为:WECHAT_MICROPAY该字段必填
+                String Deviceid = "";///终端设备号
+                TerminalInfoEntity Terminal_Info = new TerminalInfoEntity(payCode, Deviceid);
+                Pay_Extend.put("terminal_info", Terminal_Info);
+                ///场景信息	scene_info
+                Map<String, String> Scene_Info = new HashMap<String, String>();
+                Scene_Info.put("id", "");///门店唯一标识
+                Scene_Info.put("name", "");
+                Scene_Info.put("area_code", "");
+                Scene_Info.put("address", "");
+                Pay_Extend.put("scene_info", Scene_Info);
+                if (payCode.equals("WECHAT_JSAPI")) {
+                    Pay_Extend.put("sub_appid", sub_appid);
+                    Pay_Extend.put("sub_openid", sub_openid);
+                } else if (payCode.equals("WECHAT_MICROPAY")) {
+                }
+                subMchId = baoFooPayConfig.getWxSimid(); //"569520824";
+            } else if (payCode.startsWith("ALIPAY")) {
+                Pay_Extend.put("subject", payRequestBody.getBody());
+                Pay_Extend.put("area_info", "156"+"2901");
+                ////terminal_info 终端信息参数     支付方式为:ALIPAY_MICROPAY该字段必填
+                String Deviceid = "";///终端设备号
+                TerminalInfoEntity Terminal_Info = new TerminalInfoEntity(payCode, Deviceid);
+                Pay_Extend.put("terminal_info", Terminal_Info);
+                Pay_Extend.put("store_id", "");
+                Pay_Extend.put("hb_fq_num", "");
+                Pay_Extend.put("hb_fq_seller_percent", "");
+                Pay_Extend.put("enable_pay_channels", "");
+                Pay_Extend.put("disable_pay_channels", "");
+                if (payCode.equals("ALIPAY_JSAPI")) {
+                    Pay_Extend.put("buyer_id", buyer_id);
+                } else if (payCode.equals("ALIPAY_MICROPAY")) {
+
+                }
+                subMchId = baoFooPayConfig.getAlipaySimid(); //"2088620820601391";//二级商户
+                appScheme = "alipays://platformapi/startapp?appId=20000067&url=";
+            } else if (payCode.startsWith("QUICK_PASS_NATIVE")) {
+                subMchId = baoFooPayConfig.getUacSimid(); //"844290053110005";
+                Pay_Extend.put("areaInfo", "156"+"2901");
+            }
+            Biz_Content.put("payExtend", Pay_Extend);
+            Biz_Content.put("feeMerId", "");
+            Biz_Content.put("subMchId", subMchId);
+            Biz_Content.put("notifyUrl", baoFooPayConfig.getPayNotifyUrl());
+            Biz_Content.put("pageUrl", "");
+            Biz_Content.put("forbidCredit", "0");//1:禁止,0:不禁止;不传默认为0
+            Biz_Content.put("attach", "");
+            Biz_Content.put("reqReserved", payRequestBody.getPayWay());
+            ///风控参数
+            RiskInfoEntity rie = new RiskInfoEntity();
+            rie.setLocationPoint("");
+            rie.setClientIp(payRequestBody.getCreateip());
+            Biz_Content.put("riskInfo", rie);
+            PostMasterEntity pme = new PostMasterEntity();
+            String BizContent = JSONObject.toJSONString(Biz_Content);
+            log.info("签名参数 >>> " + BizContent);
+            String BizContentEn = SignatureUtils.encryptByRSA(BizContent, pfxpath, pfxpwd);
+            pme.setBizContent(BizContent);
+            pme.setSignStr(BizContentEn);
+            log.info("签名 >>> " + BizContentEn);
+            pme.setMerId(baoFooPayConfig.getMid());
+            pme.setTerId(baoFooPayConfig.getTid());
+            pme.setMethod(PayConstants.BFPAY_METHOD_UNIFIED_ORDER);
+            log.info("pme.getParmFormat >>> " + pme.getParmFormat());
+            LogSyncUtil.logSync("宝付支付 预下单,交易编号:{},请求参数:{}",payRequestBody.getOrderNo(),pme);
+            String PostString = HttpUtil.RequestForm(URL, pme.getParmFormat());
+            LogSyncUtil.logSync("宝付支付 预下单,交易编号:{},返回结果:{}",payRequestBody.getOrderNo(),PostString);
+            log.info("请求连接 >>> " + PostString);
+            ResultMasterEntity rme = JSONObject.parseObject(PostString, ResultMasterEntity.class);
+            log.info("下单返回结果 >>> " + rme.toString());
+            if (SignatureUtils.verifySignature(cerpath, rme.getDataContent(), rme.getSignStr())) {
+                if("SUCCESS".equals(rme.getReturnCode())){
+                    JSONObject jsonObject = JSONObject.parseObject(rme.getDataContent());
+                    if(null != jsonObject ){
+                        String resultCode = jsonObject.getString("resultCode");
+                        if("SUCCESS".equals(resultCode)){
+                            log.info("[交易结果]交易成功,成功金额:"+totalAmt.toString()+"分。");
+                            Map<String ,String > data = new HashMap<>();
+                            data.put("orderNo",jsonObject.getString("outTradeNo"));
+                            data.put("tradeNo",jsonObject.getString("tradeNo"));
+                            if (payCode.startsWith("QUICK_PASS_NATIVE")){
+                                String string = jsonObject.getJSONObject("chlRetParam").getString("qrCode");
+                                string = string.replace("https://", "upwallet://html/");
+                                data.put("url", string );
+                            } else {
+                                data.put("url",appScheme+jsonObject.getJSONObject("chlRetParam").getString("qr_code"));
+                            }
+                            resultMap.put("data",data);
+                            resultMap.put("merOrderId",trade_no);
+                            return resultMap;
+                        }else{
+                           return ResultMap.error( jsonObject.getString("errMsg"));
+                        }
+                    }
+                } else {
+                    return ResultMap.error(rme.getReturnMsg());
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getLocalizedMessage());
+        }
+        return ResultMap.error("下单失败");
+    }
+
+    /**
+     * 查询
+     * @param paymentRequestDto
+     * @return
+     * @throws Exception
+     */
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        try {
+            baoFooPayConfig = initPayConfig(paymentRequestDto);
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+            String merId = baoFooPayConfig.getMid();
+            String terId = baoFooPayConfig.getTid();
+            String tradeNo = "";//宝付订单号
+            String outTradeNo = paymentRequestDto.getOrderNo();//商户系统内部订单号,同一个商户号下唯
+            Map<String, Object> Biz_Content = new HashMap<String, Object>();
+            Biz_Content.put("agentMerId", "");
+            Biz_Content.put("agentTerId", "");
+            Biz_Content.put("merId", merId);
+            Biz_Content.put("terId", terId);
+            Biz_Content.put("tradeNo", tradeNo);
+            Biz_Content.put("outTradeNo", outTradeNo);
+            PostMasterEntity pme = new PostMasterEntity();
+            String BizContent = JSONObject.toJSONString(Biz_Content).toString();
+            log.info(BizContent);
+            String BizContentEn = SignatureUtils.encryptByRSA(BizContent, pfxpath, pfxpwd);
+            pme.setBizContent(BizContent);
+            pme.setSignStr(BizContentEn);
+            pme.setMerId(merId);
+            pme.setTerId(terId);
+            pme.setMethod(PayConstants.BFPAY_METHOD_ORDER_QUERY);
+            log.info(pme.getParmFormat());
+            LogSyncUtil.logSync("宝付支付 订单查询,交易编号:{},请求参数:{}",paymentRequestDto.getOrderNo(),pme);
+            String PostString = HttpUtil.RequestForm(URL, pme.getParmFormat());
+            LogSyncUtil.logSync("宝付支付 订单查询,交易编号:{},返回结果:{}",paymentRequestDto.getOrderNo(),PostString);
+            log.info(PostString);
+            ResultMasterEntity rme = JSONObject.parseObject(PostString, ResultMasterEntity.class);
+            log.info(rme.toString());
+            if (SignatureUtils.verifySignature(cerpath, rme.getDataContent(), rme.getSignStr())) {
+                if("SUCCESS".equals(rme.getReturnCode())){
+                    JSONObject jsonObject = JSONObject.parseObject(rme.getDataContent());
+                    log.info("解析结果:{}",jsonObject);
+                    if(null != jsonObject ){
+                        String resultCode = jsonObject.getString("resultCode");
+                        if("SUCCESS".equals(resultCode)){
+                            if("SUCCESS".equals(jsonObject.getString("txnState"))){
+                                //下单成功
+                                paymentInfoResponseDto.setOrderNo(outTradeNo);
+                                paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
+                                paymentInfoResponseDto.setPaymentNo(StringUtils.isNotEmpty(jsonObject.getString("tradeNo")) ? jsonObject.getString("tradeNo") : null);
+                                Integer orderAmt = null != jsonObject.getInteger("succAmt") ? jsonObject.getInteger("succAmt") : 0;
+                                paymentInfoResponseDto.setPaymentPrice(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                                paymentInfoResponseDto.setActualPayment(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                                Date finishedDate = StringUtils.isNotEmpty(jsonObject.getString("finishTime")) ? DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, jsonObject.getString("finishTime")) : null;
+                                paymentInfoResponseDto.setPaymentSuccessTime(finishedDate);
+                                paymentInfoResponseDto.setSuccess(true);
+                                return paymentInfoResponseDto;
+                            }else{
+                                return paymentInfoResponseDto.error(-1,jsonObject.getString("txnState"));
+                            }
+                        }else{
+                            return paymentInfoResponseDto.error(-1,jsonObject.getString("errMsg"));
+                        }
+                    }
+                } else {
+                    return paymentInfoResponseDto.error(-1,rme.getReturnMsg());
+                }
+            } else {
+                log.info("验签失败");
+                return PaymentInfoResponseDto.error(-1,"验签失败!");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return PaymentInfoResponseDto.error(-1,"签名生成异常!");
+        }
+        return PaymentInfoResponseDto.error(-1,"查询失败!");
+    }
+
+    /**
+     * 退款
+     * @param refundRequestDto
+     * @throws Exception
+     */
+    public ResultMap refund(RefundRequestDto refundRequestDto){
+        try {
+            baoFooPayConfig = initRefundConfig(refundRequestDto);
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+            String merId = baoFooPayConfig.getMid();
+            String terId = baoFooPayConfig.getTid();
+            String txnTime = getTxnTime();//报文发送日期时间
+            String originOutTradeNo = refundRequestDto.getOrderNo();//原支付订单商户订单号 [与原支付订单宝付交易号二选一比传]
+            String outTradeNo = RandomUtil.getRandomNew(RandomUtil.REFUND_NO);
+            String refundAmt = String.valueOf(refundRequestDto.getRefundAmount().multiply(new BigDecimal(100)).intValue());//退款金额
+            String totalAmt = String.valueOf(refundRequestDto.getRefundAmount().multiply(new BigDecimal(100)).intValue());//订单总金额
+            Map<String, Object> Biz_Content = new HashMap<String, Object>();
+            Biz_Content.put("agentMerId", "");
+            Biz_Content.put("agentTerId", "");
+            Biz_Content.put("merId", merId);
+            Biz_Content.put("terId", terId);
+            Biz_Content.put("originTradeNo", "");
+            Biz_Content.put("originOutTradeNo", originOutTradeNo);
+            Biz_Content.put("outTradeNo", outTradeNo);
+            Biz_Content.put("notifyUrl", baoFooPayConfig.getRefundNotifyUrl());
+            Biz_Content.put("merchantName", baoFooPayConfig.getMerchantName());
+            Biz_Content.put("refundAmt", refundAmt);
+            Biz_Content.put("totalAmt", totalAmt);
+            Biz_Content.put("txnTime", txnTime);
+            Biz_Content.put("attach", "");//预留字段
+            Biz_Content.put("reqReserved", refundRequestDto.getPayWay());//请求方保留域
+            Biz_Content.put("refundReason", refundRequestDto.getRefundMsg());
+            PostMasterEntity pme = new PostMasterEntity();
+            String BizContent = JSONObject.toJSONString(Biz_Content).toString();
+            log.info(BizContent);
+            String BizContentEn = SignatureUtils.encryptByRSA(BizContent, pfxpath, pfxpwd);
+            pme.setBizContent(BizContent);
+            pme.setSignStr(BizContentEn);
+            pme.setMerId(merId);
+            pme.setTerId(terId);
+            pme.setMethod(PayConstants.BFPAY_METHOD_ORDER_REFUND);
+            log.info(pme.getParmFormat());
+            LogSyncUtil.logSync("宝付支付 退款,交易编号:{},请求参数:{}",originOutTradeNo,pme);
+            String PostString = HttpUtil.RequestForm(URL, pme.getParmFormat());
+            LogSyncUtil.logSync("宝付支付 退款,交易编号:{},返回结果:{}",originOutTradeNo,PostString);
+            log.info(PostString);
+            ResultMasterEntity rme = JSONObject.parseObject(PostString, ResultMasterEntity.class);
+            log.info("响应] 响应内容:{}",rme);
+            if (SignatureUtils.verifySignature(cerpath, rme.getDataContent(), rme.getSignStr())) {
+                log.info("解析结果:{}",rme.getDataContent());
+                if("SUCCESS".equals(rme.getReturnCode())){
+                    JSONObject jsonObject = JSONObject.parseObject(rme.getDataContent());
+                    if(null != jsonObject ){
+                        String resultCode = jsonObject.getString("resultCode");
+                        if("SUCCESS".equals(resultCode)) {
+                            if("REFUND".equals(jsonObject.getString("refundState"))){
+                                log.info("[申请退款结果]交易成功,成功金额:" + totalAmt.toString() + "分。");
+                                //下单成功
+                                Map<String, String> stringStringMap = new HashMap<>();
+                                stringStringMap.put("out_refund_no", outTradeNo);
+                                stringStringMap.put("refund_id", jsonObject.getString("tradeNo"));
+                                stringStringMap.put("refund_fee", String.valueOf(jsonObject.getInteger("refundAmt")));
+                                stringStringMap.put("fund_change", "Y");
+//                                stringStringMap.put("finishedDate", result.get("finishedDate"));
+                                return ResultMap.ok(jsonObject.getString("refundState"))
+                                        .put("data", stringStringMap)
+                                        ;
+                            }else{
+                                return ResultMap.error(-1,jsonObject.getString("errMsg"));
+                            }
+                        }else{
+                            return ResultMap.error(-1,jsonObject.getString("errMsg"));
+                        }
+                    }else{
+                        return ResultMap.error(rme.getReturnMsg());
+                    }
+                }
+            } else {
+                return ResultMap.error(-1,"验签失败!");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+        return ResultMap.error(-1,"退款失败!");
+    }
+
+    /**
+     * 退款查询
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap refundQuery( RefundRequestDto refundRequestDto){
+        try {
+            baoFooPayConfig = initRefundConfig(refundRequestDto);
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+            String merId = baoFooPayConfig.getMid();
+            String terId = baoFooPayConfig.getTid();
+            String tradeNo = "";//宝付订单号
+            String outTradeNo = refundRequestDto.getRefundNo();//商户系统内部订单号,同一个商户号下唯
+            Map<String, Object> Biz_Content = new HashMap<String, Object>();
+            Biz_Content.put("agentMerId", "");
+            Biz_Content.put("agentTerId", "");
+            Biz_Content.put("merId", merId);
+            Biz_Content.put("terId", terId);
+            Biz_Content.put("outTradeNo", outTradeNo);
+            Biz_Content.put("tradeNo", tradeNo);
+            PostMasterEntity pme = new PostMasterEntity();
+            String BizContent = JSONObject.toJSONString(Biz_Content).toString();
+            log.info(BizContent);
+            String BizContentEn = SignatureUtils.encryptByRSA(BizContent, pfxpath, pfxpwd);
+            pme.setBizContent(BizContent);
+            pme.setSignStr(BizContentEn);
+            pme.setMerId(merId);
+            pme.setTerId(terId);
+            pme.setMethod(PayConstants.BFPAY_METHOD_REFUND_QUERY);
+            log.info(pme.getParmFormat());
+            LogSyncUtil.logSync("宝付支付 退款查询,交易编号:{},请求参数:{}",outTradeNo,pme);
+            String PostString = HttpUtil.RequestForm(URL, pme.getParmFormat());
+            LogSyncUtil.logSync("宝付支付 退款查询,交易编号:{},返回结果:{}",outTradeNo,PostString);
+            log.info(PostString);
+            ResultMasterEntity rme = JSONObject.parseObject(PostString, ResultMasterEntity.class);
+            log.info("响应] 响应内容:{}",rme);
+            if (SignatureUtils.verifySignature(cerpath, rme.getDataContent(), rme.getSignStr())) {
+                log.info("解析结果:{}",rme.getDataContent());
+                if("SUCCESS".equals(rme.getReturnCode())) {
+                    JSONObject jsonObject = JSONObject.parseObject(rme.getDataContent());
+                    if (null != jsonObject) {
+                        String resultCode = jsonObject.getString("resultCode");
+                        if ("SUCCESS".equals(resultCode)) {
+                            if ("SUCCESS".equals(jsonObject.getString("refundState"))) {
+                                log.info("[申请退款结果]交易成功,金额:"+jsonObject.getInteger("succAmt")+"分。");
+                                Map<String, String> stringStringMap = new HashMap<>();
+                                stringStringMap.put("out_refund_no", outTradeNo);
+                                stringStringMap.put("refund_id",  jsonObject.getString("tradeNo"));
+                                stringStringMap.put("refund_fee", String.valueOf(jsonObject.getInteger("succAmt")));
+                                stringStringMap.put("fund_change", "Y");
+                                stringStringMap.put("finishedDate", jsonObject.getString("finishTime"));
+                                return ResultMap.ok()
+                                        .put("data",stringStringMap)
+                                        ;
+                            } else {
+                                return ResultMap.error(-1,jsonObject.getString("errMsg"));
+                            }
+                        }else{
+                            return ResultMap.error(-1,jsonObject.getString("errMsg"));
+                        }
+                    }
+                }
+            } else {
+                return ResultMap.error(-1,"验签失败!");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+        return ResultMap.error(-1,"退款查询失败!");
+    }
+
+    private static String getTxnTime() {
+        return DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSS);
+    }
+
+    private BaoFooPayConfig initPayConfig(PaymentRequestDto paymentRequestDto){
+        return StringUtils.isNotEmpty(appversion) && appversion.equals("prod")
+                ? baoFooPayConfig = (BaoFooPayConfig) paymentRequestDto.getPayConfigByClass(BaoFooPayConfig.class) : new BaoFooPayConfig();
+    }
+    private BaoFooPayConfig initRefundConfig(RefundRequestDto refundRequestDto){
+        return StringUtils.isNotEmpty(appversion) && appversion.equals("prod")
+                ? baoFooPayConfig = (BaoFooPayConfig) refundRequestDto.getPayConfigByClass(BaoFooPayConfig.class) : new BaoFooPayConfig();
+    }
+
+}

+ 1256 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BaofooRechargePayServiceImpl.java

@@ -0,0 +1,1256 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.common.utils.Base64Util;
+import com.tzy.common.utils.DateUtils;
+import com.tzy.common.utils.LogSyncUtil;
+import com.tzy.common.utils.StringUtils;
+import com.tzy.framework.pay.config.BaofooRechargePayConfig;
+import com.tzy.framework.pay.dto.*;
+import com.tzy.framework.pay.service.BaofooRechargePayService;
+import com.tzy.framework.pay.util.FormatUtil;
+import com.tzy.framework.pay.util.bofoo.bank.HttpUtil;
+import com.tzy.framework.pay.util.bofoo.bank.RsaCodingUtil;
+import com.tzy.framework.pay.util.bofoo.bank.SecurityUtil;
+import com.tzy.framework.pay.util.bofoo.bank.SignatureUtils;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+
+@Slf4j
+@Service
+public class BaofooRechargePayServiceImpl implements BaofooRechargePayService {
+
+    @Value("${pay.version:dev}")
+    private String appversion;
+
+    private String baseUrl = "https://bht.mandao.com/api/";//生产
+    private String baseUrlBox = "https://account.baofoo.com/api/";//测试
+    private String serviceOrderUrl = "order/{0}/{1}";
+    private String serviceTradeUrl = "trade/{0}/{1}";
+    private String serviceWalletUrl = "wallet/{0}/{1}";
+
+    public static void main(String[] args) {
+        Date createTime = new Date();
+        BaofooRechargePayServiceImpl service = new BaofooRechargePayServiceImpl();
+        RechargeUserInfoDto rechargeUserInfoDto = new RechargeUserInfoDto();
+        rechargeUserInfoDto.setLoginNo("1000000002");//1000000002//lsz-3
+        rechargeUserInfoDto.setUserName("邓力");//3177000000478634//邓力
+        rechargeUserInfoDto.setCertificateNo("360902200005081816");//360902200005081816 //lsz-3177000000478764
+        rechargeUserInfoDto.setAgreementNo("312023052400000006288");
+        PaymentRequestDto payRequestBody = new PaymentRequestDto();
+        payRequestBody.setPayConfig(JSONObject.parseObject(JSONObject.toJSONString(new BaofooRechargePayConfig())));
+        payRequestBody.setRechargeUserInfoDto(rechargeUserInfoDto);
+        payRequestBody.setBody("个人充值测试!");
+        payRequestBody.setOrderNo(RandomUtil.getRandomOld(RandomUtil.GROUP_USER_ORDER));
+        payRequestBody.setTotalAmount(new BigDecimal(0.01));//
+//        log.info(" log-个人充值:{} ",service.recharge(payRequestBody));//20000193620230524551801797116449
+        rechargeUserInfoDto.setCallType("WALLET_PAY");
+        payRequestBody.setRechargeUserInfoDto(rechargeUserInfoDto);
+//        log.info(" log-个人钱包:{} ",service.wallet(payRequestBody));//
+        payRequestBody.setPaySubWay("BALANCE");
+//        log.info(" log-分账支付:{} ",service.paymentSplitApi(payRequestBody));//
+        payRequestBody.setCreateOrderTime(createTime);
+        payRequestBody.setExpireTime(DateUtils.addCalendar(createTime,DateUtils.minute,3));// 3分钟后过期
+        payRequestBody.setPaySubWay("ALIPAY_NATIVE");//  ALIPAY_NATIVE ALIPAY_ALXCX
+//        log.info(" log-聚合支付:{} ",service.payment(payRequestBody));//
+        //退款
+        RefundRequestDto refundRequestDto = new RefundRequestDto();
+        refundRequestDto.setRechargeUserInfoDto(rechargeUserInfoDto);
+        refundRequestDto.setPayConfig(JSONObject.parseObject(JSONObject.toJSONString(new BaofooRechargePayConfig())));
+        refundRequestDto.setTradeNo("20000193620230525041710415212733");
+        refundRequestDto.setRefundAmount(new BigDecimal(0.01));
+        refundRequestDto.setRefundMsg("退款测试");
+//        log.info(" log-聚合支付:{} ",service.profitShareRefundApply(refundRequestDto));//
+
+    }
+    /**
+     * 2.1.1 个人充值-API
+     * 暂时不用
+     *
+     * @param payRequestBody
+     * @return
+     * @throws Exception
+     */
+    public ResultMap recharge(PaymentRequestDto payRequestBody) {
+        try {
+            RechargeUserInfoDto rechargeUserInfoDto = payRequestBody.getRechargeUserInfoDto();
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) payRequestBody.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            String amount = payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue()+"";
+            String agreementNo = rechargeUserInfoDto.getAgreementNo();
+            String notifyUrl = payConfig.getPayNotifyUrl();
+            String outOrderNo = getMerchantOrderId(payConfig);
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            SendData.put("outOrderNo", outOrderNo);
+            SendData.put("amount", amount);
+            agreementNo = SecurityUtil.Base64Encode(agreementNo);
+            agreementNo = RsaCodingUtil.encryptByPubCerFile(agreementNo, payConfig.getPublicKey());
+            SendData.put("agreementNo", agreementNo);
+            SendData.put("notifyUrl", notifyUrl);
+            String OsignData = FormatUtil.formatVerify(
+                    "orgNo|merchantNo|terminalNo|loginNo|requestDate|outOrderNo|amount|agreementNo", SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String PostString = HttpUtil.requestPostByType(getServiceOrderUrl("v3.0.0","recharge"), SendData,
+                    "application/json");
+            if (null == PostString || PostString.isEmpty()) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                // 自行处理
+                String result = jsonObject.getString("result");
+                log.info("密码链接-->" + result);
+                return ResultMap.ok()
+                        .put("merOrderId",outOrderNo)
+                        .put("orderNo",payRequestBody.getOrderNo())
+                        .put("redirectUrl",result)
+                        ;
+            } else {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(" 下单失败:{} ",e);
+        }
+        return ResultMap.error("下单失败");
+    }
+    /**
+     * 2.2.1 个人提现-API
+     * 暂时不用
+     * @param refundRequestDto
+     * @return
+     * @throws Exception
+     */
+    public ResultMap withdraw(RefundRequestDto refundRequestDto) {
+        String errMsg = "";
+       try {
+           RechargeUserInfoDto rechargeUserInfoDto = refundRequestDto.getRechargeUserInfoDto();
+           BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) refundRequestDto.getPayConfigByClass(BaofooRechargePayConfig.class);
+           String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+           String amount = refundRequestDto.getRefundAmount().multiply(new BigDecimal(100)).intValue()+"";
+           String agreementNo = rechargeUserInfoDto.getAgreementNo();
+           String notifyUrl = payConfig.getRefundNotifyUrl();
+           Map<String, Object> SendData = new HashMap<String, Object>();
+           String outOrderNo = getMerchantOrderId(payConfig);
+           SendData.put("orgNo", payConfig.getMid());
+           SendData.put("merchantNo", payConfig.getMid());
+           SendData.put("terminalNo", payConfig.getTid());
+           SendData.put("loginNo", loginNo);
+           SendData.put("requestDate", DateUtils.dateTimeNow());
+           SendData.put("outOrderNo", outOrderNo);
+           SendData.put("amount", amount);
+           agreementNo = SecurityUtil.Base64Encode(agreementNo);
+           agreementNo = RsaCodingUtil.encryptByPubCerFile(agreementNo, payConfig.getPublicKey());
+           SendData.put("agreementNo", agreementNo);
+           SendData.put("notifyUrl", notifyUrl);
+           String OsignData = FormatUtil.formatVerify(
+                   "orgNo|merchantNo|terminalNo|loginNo|requestDate|outOrderNo|amount|agreementNo", SendData);
+           log.info("签名拼接参数:" + OsignData);
+           String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+           log.info("签名结果:" + Sign);
+           SendData.put("signData", Sign);// 签名结果。
+           String PostString = HttpUtil.requestPostByType(getServiceOrderUrl("v3.0.0","withdraw"), SendData,
+                   "application/json");
+           if (null == PostString || PostString.isEmpty()) {
+               log.info("PostString  为空");
+               return ResultMap.error(-1,"返回出错【404】");
+           }
+           JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+           if (!jsonObject.containsKey("success")) {
+               return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+           }
+           if (jsonObject.getBoolean("success")) {
+               // 自行处理
+               String result = jsonObject.getString("result");
+               log.info("密码链接-->" + result);
+               return ResultMap.ok()
+                       .put("merOrderId",outOrderNo)
+                       .put("orderNo",refundRequestDto.getOrderNo())
+                       .put("redirectUrl",result)
+                       ;
+           } else {
+               return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+           }
+       }catch (Exception e){
+           e.printStackTrace();
+           log.error(" 退款请求失败:{} ",e);
+           errMsg = "退款请求失败";
+       }
+        return ResultMap.error(-2,errMsg);
+    }
+
+    /**
+     * H5页面统一唤起接口,根据唤起类型区分交易,返回redirectUrl链接10分钟内有效
+     * 暂时不用
+     * @param payRequestBody
+     * @return
+     * @throws Exception
+     */
+    public ResultMap wallet(PaymentRequestDto payRequestBody)  {
+        try {
+            RechargeUserInfoDto rechargeUserInfoDto = payRequestBody.getRechargeUserInfoDto();
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) payRequestBody.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            String callType = rechargeUserInfoDto.getCallType();// 唤起类型
+            log.info("H5页面唤起类型:" + callType);
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("callType", callType);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            Map<String, Object> DC = new HashMap<String, Object>();
+            String outOrderNo = getMerchantOrderId(payConfig);
+            String body = payRequestBody.getBody();
+            if(org.apache.commons.lang3.StringUtils.isNotEmpty(body) ){
+                body = Base64Util.subStringByBytes(body,80)+"...";
+            }
+            int totalPrice = payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue();
+            String dataContent = "";
+            /*if (callType.equals("EXPENSE_RECHARGE") || callType.equals("EXPENSE_PAYMENT") || callType.equals("ASSURE_PAY")
+                    || callType.equals("EXPENSE_RECHARGE") || callType.equals("PAYMENT_SPLIT")
+                    || callType.equals("BM_PAYMENT_SPLIT") || callType.equals("B_PAYMENT_SPLIT")
+                    || callType.equals("WALLET_ASSURE_PAY")) {
+                DC.put("goodsName", body);// 商品名
+                DC.put("amount", totalPrice);// 订单金额
+                DC.put("outOrderNo", outOrderNo);// 商户订单号
+                DC.put("notifyUrl", payConfig.getPayNotifyUrl());// 异步通知地址
+                DC.put("expireDate", payRequestBody.getExpireTime());// 设置订单失效时间
+
+                if (callType.equals("EXPENSE_PAYMENT")) {
+                    DC.put("oldOutOrderNo", request.getParameter("oldOutOrderNo"));
+                }
+                if (callType.equals("EXPENSE_RECHARGE")|| callType.equals("WALLET_ASSURE_PAY")) {
+                    DC.put("validDate", request.getParameter("validDate"));
+                }
+
+                if (callType.equals("ASSURE_PAY") || callType.equals("EXPENSE_PAYMENT") || callType.equals("PAYMENT_SPLIT")
+                        || callType.equals("BM_PAYMENT_SPLIT") || callType.equals("B_PAYMENT_SPLIT")
+                        || callType.equals("WALLET_ASSURE_PAY")) {
+                    String SplitInfoList = request.getParameter("SplitInfoList");
+                    log.info(SplitInfoList);
+                    if ("[]".equals(SplitInfoList)) {// 分账信息不能为空
+                        return "分账信息不能为空,请检查";
+                    }
+                    JSONArray js = JSONArray.fromObject(SplitInfoList);
+                    for (int i = 0; i < js.size(); i++) {
+                        JSONObject jo = js.getJSONObject(i);
+                        jo.put("subOutOrderNo", DC.get("outOrderNo") + "_" + i);
+                    }
+                    DC.put("splitInfoList", js);// 放入分账参数
+                }
+                JSONObject DCString = JSONObject.parseObject(JSONObject.toJSONString(DC));
+                SendData.put("dataContent", DCString.toString());
+            } else*/ if (callType.equals("PAYMENT") || callType.equals("B_PAYMENT") || callType.equals("BM_PAYMENT")) {
+                String str = body + "||" + totalPrice + "||" + outOrderNo + "||" + payConfig.getPayNotifyUrl();
+                SendData.put("dataContent", str);
+            } else if (callType.equals("B_WITHDRAW")) {
+                DC.put("amount", totalPrice);
+                DC.put("outOrderNo", outOrderNo);
+                DC.put("notifyUrl", payConfig.getPayNotifyUrl());
+                JSONObject DCString = JSONObject.parseObject(JSONObject.toJSONString(DC));
+                SendData.put("dataContent", DCString.toString());
+            } else if (callType.equals("WALLET_PAY")) {
+                DC.put("notifyUrl", payConfig.getPayNotifyUrl());
+                JSONObject DCString = JSONObject.parseObject(JSONObject.toJSONString(DC));
+                SendData.put("dataContent", DCString.toString());
+            } else {
+                SendData.put("dataContent", dataContent);
+            }
+            String OsignData = FormatUtil
+                    .formatVerify("orgNo|merchantNo|terminalNo|callType|loginNo|requestDate|dataContent", SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String PostString = HttpUtil.requestPostByType(getServiceWalletUrl("v3.0.0","login"), SendData,
+                    "");
+            log.info("后端请求表单:" + PostString);
+            if (StringUtils.isEmpty(PostString)) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("retCode")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            String redirectUrl = "";
+            if (jsonObject.getString("retCode").toString().equals("SUCCESS")) {
+                if (jsonObject.containsKey("redirectUrl")) {
+                    redirectUrl = jsonObject.getString("redirectUrl");
+                    log.info("返回地址值:" + redirectUrl);
+                }
+                return ResultMap.ok()
+                        .put("redirectUrl",redirectUrl)
+                        ;
+            } else {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        } catch (Exception e) {
+            log.error(" 支付异常{} ",e);
+        }
+        return ResultMap.error(-1,"支付异常!");
+    }
+    /**
+     * 3.3 修改分账信息
+     * @param payRequestBody
+     * @return
+     * @throws Exception
+     */
+    public ResultMap updateSplitInfo(PaymentRequestDto payRequestBody) {
+        try {
+            RechargeUserInfoDto rechargeUserInfoDto = payRequestBody.getRechargeUserInfoDto();
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) payRequestBody.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            int totalPrice = payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue();
+            String oldOutOrderNo = payRequestBody.getMerOrderId();
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            Map<String, Object> JSONDataContent = new HashMap<String, Object>();
+            JSONDataContent.put("oldOutOrderNo", oldOutOrderNo);
+            JSONDataContent.put("amount", totalPrice);
+            //设置分账参数
+            JSONObject splitInfo = new JSONObject();
+            splitInfo.put("oldSubOutOrderNo",oldOutOrderNo);//原分账子订单号。
+            splitInfo.put("contractNo",payConfig.getMid());//客户类型为ORG时传机构/平台号
+            splitInfo.put("customerType","ORG");//ORG-机构/平台 PERSON-个人账户 B_ACCOUNT-B端账户
+            splitInfo.put("splitAmount",totalPrice); //单位:分;分账金额总和不能超过订单金额
+            splitInfo.put("sellerFlag","0");//0-不是卖家(如参与分账的平台) 1-是卖家(一笔担保交易只能有一个卖家)
+            JSONArray js = new JSONArray();
+            js.add(splitInfo);
+            JSONDataContent.put("splitInfoList", js);
+            JSONObject jo = JSONObject.parseObject(JSONObject.toJSONString(JSONDataContent));
+            SendData.put("dataContent", jo.toString());
+            String OsignData = FormatUtil.formatVerify("orgNo|merchantNo|loginNo|terminalNo|requestDate|dataContent",
+                    SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String PostString = HttpUtil.requestPostByType(getServiceWalletUrl("v3.0.0","updateSplitInfo"),
+                    SendData, "application/json");
+            if (null == PostString || PostString.isEmpty()) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                // 自行处理
+                //如果修改成功则进行确认分账
+                return ResultMap.ok()
+                        ;
+            }else{
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        }catch (Exception e){
+            log.error(" 分账失败请重试:{} ",e);
+        }
+        return ResultMap.error(-1,"分账失败");
+    }
+
+    /**
+     * 2.1.1 余额和卡-API
+     *
+     * @param payRequestBody
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public ResultMap paymentSplitApi(PaymentRequestDto payRequestBody) {
+        try {
+            log.info(" 宝付钱包支付请求参数:{} ",payRequestBody);
+            String version = "v3.0.0";
+            String method = "paymentSplitApi" ;
+            RechargeUserInfoDto rechargeUserInfoDto = payRequestBody.getRechargeUserInfoDto();
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) payRequestBody.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            int totalPrice = payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue();
+            String outOrderNo = getMerchantOrderId(payConfig);
+            String paidType = payRequestBody.getPaySubWay(); //BALANCE 余额支付 CARD 银行卡支付
+            String notifyUrl = payConfig.getPayNotifyUrl();
+            String agreementNo = rechargeUserInfoDto.getAgreementNo();//银行卡协议号 (如果是银行卡支付)
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            SendData.put("outOrderNo", outOrderNo);
+            SendData.put("amount", totalPrice+"");
+            SendData.put("paidType", paidType);
+            SendData.put("pwdPayExpTime", DateUtils.differentSecond(DateUtils.getNowDate(),payRequestBody.getExpireTime()));
+            if(StringUtils.isNotEmpty(agreementNo)){
+                agreementNo = RsaCodingUtil.encryptByPubCerFile(SecurityUtil.Base64Encode(agreementNo), payConfig.getPublicKey());
+                SendData.put("agreementNo", agreementNo);
+            }
+            SendData.put("notifyUrl", notifyUrl);
+            JSONArray js = new JSONArray();
+            //计算分账金额
+            int merchantPrice = totalPrice;
+            int appPrice = 0;
+            if(StringUtils.isNotEmpty(payRequestBody.getAccountType()) && "merchant".equals(payRequestBody.getAccountType())) {
+                //如果是商家  平台30%
+                appPrice = payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).multiply(new BigDecimal(70)).divide(new BigDecimal(100)).intValue();
+                if (appPrice > 0 && totalPrice > appPrice) {
+                    merchantPrice = totalPrice - appPrice;
+                }
+            } else { //默认 平台
+                merchantPrice = totalPrice - appPrice;
+            }
+            if(appPrice > 0) {
+                //设置分账参数-平台
+                JSONObject splitInfo = new JSONObject();
+                splitInfo.put("subOutOrderNo", outOrderNo + "P1");//分账订单号-平台。
+                splitInfo.put("contractNo", payConfig.getMid());//客户类型为ORG时传机构/平台号
+                splitInfo.put("customerType", "ORG");//ORG-机构/平台 PERSON-个人账户 B_ACCOUNT-B端账户
+                splitInfo.put("splitAmount", appPrice); //单位:分;分账金额总和不能超过订单金额
+                splitInfo.put("sellerFlag", "0");//0-不是卖家(如参与分账的平台) 1-是卖家(一笔担保交易只能有一个卖家)
+                js.add(splitInfo);
+            }
+            //设置分账参数-商家
+            JSONObject merchantSplitInfo = new JSONObject();
+            merchantSplitInfo.put("subOutOrderNo",outOrderNo+"M1");//分账订单号-商家。
+            merchantSplitInfo.put("contractNo",payRequestBody.getContractNo());//商家编号
+            merchantSplitInfo.put("customerType","B_ACCOUNT");//ORG-机构/平台 PERSON-个人账户 B_ACCOUNT-B端账户
+            merchantSplitInfo.put("splitAmount",merchantPrice); //单位:分;分账金额总和不能超过订单金额
+            merchantSplitInfo.put("sellerFlag","1");//0-不是卖家(如参与分账的平台) 1-是卖家(一笔担保交易只能有一个卖家)
+            js.add(merchantSplitInfo);
+            SendData.put("splitInfoList", JSONObject.toJSONString(js));
+            String OsignData = FormatUtil.formatVerify(
+                    "orgNo|merchantNo|terminalNo|loginNo|requestDate|outOrderNo|amount|paidType|splitInfoList", SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            LogSyncUtil.logSync("宝付钱包支付 下单,交易编号:{},请求参数:{}",payRequestBody.getOrderNo(),SendData);
+            String PostString = HttpUtil.requestPostByType(getServiceOrderUrl(version,method), SendData, "application/json");
+            LogSyncUtil.logSync("宝付钱包支付 下单,交易编号:{},返回结果:{}",payRequestBody.getOrderNo(),PostString);
+            if (StringUtils.isEmpty(PostString)) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                // 自行处理
+                String link = jsonObject.getString("result");
+                log.info("密码链接-->" + link);
+                SendData.remove("signData");
+                JSONObject data = new JSONObject();
+                data.put("url",link);
+                return ResultMap.ok()
+                        .put("merOrderId",outOrderNo)
+                        .put("data",data)
+                        .put("payParam",SendData)
+                        ;
+            } else {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        }catch (Exception e){
+            log.error(" 支付异常{} ",e);
+        }
+        return ResultMap.error(-1,"支付异常!");
+    }
+
+    /**
+     * 3.1.3 个人-绑卡、余额支付API下单
+     *
+     * @param payRequestBody
+     * @return
+     * @throws Exception
+     */
+    public ResultMap assurePaymentSplit(PaymentRequestDto payRequestBody) {
+        try {
+            log.info(" 宝付钱包支付请求参数:{} ",payRequestBody);
+            String version = "v3.0.0";
+            String method = "assurePaymentSplit" ;
+            RechargeUserInfoDto rechargeUserInfoDto = payRequestBody.getRechargeUserInfoDto();
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) payRequestBody.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            int totalPrice = payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue();
+            String paidType = payRequestBody.getPaySubWay(); //BALANCE 余额支付 CARD 银行卡支付
+            String notifyUrl = payConfig.getPayNotifyUrl();
+            String agreementNo =  rechargeUserInfoDto.getAgreementNo();//银行卡协议号 (如果是银行卡支付)
+            String outOrderNo = getMerchantOrderId(payConfig);
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            SendData.put("validDate", DateUtils.dateTimeNow(DateUtils.YYYYMMDD));
+            SendData.put("expireDate", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS,payRequestBody.getExpireTime()));
+            SendData.put("outOrderNo", outOrderNo);
+            SendData.put("amount",  totalPrice+"");
+            SendData.put("paidType", paidType);
+            agreementNo = SecurityUtil.Base64Encode(agreementNo);
+            agreementNo = RsaCodingUtil.encryptByPubCerFile(agreementNo, payConfig.getPublicKey());
+            SendData.put("agreementNo", agreementNo);
+            SendData.put("notifyUrl", notifyUrl);
+            JSONArray js = new JSONArray();
+            //计算分账金额
+            int merchantPrice = totalPrice;
+            int appPrice = 0;
+            if(StringUtils.isNotEmpty(payRequestBody.getAccountType()) && "merchant".equals(payRequestBody.getAccountType())) {
+                //如果是商家  平台30%
+                appPrice = payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).multiply(new BigDecimal(70)).divide(new BigDecimal(100)).intValue();
+                if (appPrice > 0 && totalPrice > appPrice) {
+                    merchantPrice = totalPrice - appPrice;
+                }
+            } else { //默认 平台
+                merchantPrice = totalPrice - appPrice;
+            }
+            if(appPrice > 0) {
+                //设置分账参数-平台
+                JSONObject splitInfo = new JSONObject();
+                splitInfo.put("subOutOrderNo", outOrderNo + "P1");//分账订单号-平台。
+                splitInfo.put("contractNo", payConfig.getMid());//客户类型为ORG时传机构/平台号
+                splitInfo.put("customerType", "ORG");//ORG-机构/平台 PERSON-个人账户 B_ACCOUNT-B端账户
+                splitInfo.put("splitAmount", appPrice); //单位:分;分账金额总和不能超过订单金额
+                splitInfo.put("sellerFlag", "0");//0-不是卖家(如参与分账的平台) 1-是卖家(一笔担保交易只能有一个卖家)
+                js.add(splitInfo);
+            }
+            //设置分账参数-商家
+            JSONObject merchantSplitInfo = new JSONObject();
+            merchantSplitInfo.put("subOutOrderNo",outOrderNo+"M1");//分账订单号-商家。
+            merchantSplitInfo.put("contractNo",payRequestBody.getContractNo());//客户类型为ORG时传机构/平台号
+            merchantSplitInfo.put("customerType","B_ACCOUNT");//ORG-机构/平台 PERSON-个人账户 B_ACCOUNT-B端账户
+            merchantSplitInfo.put("splitAmount",merchantPrice); //单位:分;分账金额总和不能超过订单金额
+            merchantSplitInfo.put("sellerFlag","1");//0-不是卖家(如参与分账的平台) 1-是卖家(一笔担保交易只能有一个卖家)
+            js.add(merchantSplitInfo);
+            SendData.put("splitInfoList", JSONObject.toJSONString(js));
+            String OsignData = FormatUtil.formatVerify(
+                    "orgNo|merchantNo|terminalNo|loginNo|requestDate|outOrderNo|amount|paidType|splitInfoList", SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String PostString = HttpUtil.requestPostByType(getServiceOrderUrl(version,method), SendData, "application/json");
+            if (null == PostString || PostString.isEmpty()) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                // 自行处理
+                String link = jsonObject.getString("result");
+                log.info("密码链接-->" + link);
+                return ResultMap.ok()
+                        .put("redirectUrl",link)
+                        ;
+            } else {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        }catch (Exception e){
+            log.error(" 支付异常{} ",e);
+        }
+        return ResultMap.error(-1,"支付异常!");
+    }
+    /**
+     * 聚合支付下单API
+     *
+     * @param payRequestBody
+     * @return
+     */
+    @Override
+    public ResultMap payment(PaymentRequestDto payRequestBody) {
+        try {
+            RechargeUserInfoDto rechargeUserInfoDto = payRequestBody.getRechargeUserInfoDto();
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) payRequestBody.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            String totalPrice = payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue()+"";
+            String outOrderNo = getMerchantOrderId(payConfig);
+            String paidType = payRequestBody.getPaySubWay();// 支付类型
+            String notifyUrl = payConfig.getPayNotifyUrl();
+            String validDate = DateUtils.parseDateToStr(DateUtils.YYYYMMDD,DateUtils.addCalendar(payRequestBody.getCreateOrderTime(),DateUtils.day,1));// 担保有效日期 (1天)
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            String body = payRequestBody.getBody();
+            if(org.apache.commons.lang3.StringUtils.isNotEmpty(body) ){
+                body = Base64Util.subStringByBytes(body,80)+"...";
+            }
+            String alipaySimid = payConfig.getAlipaySimid();
+            String appid = payConfig.getAppid();
+            String chanalId = "";
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            SendData.put("callType", "PAYMENT_SPLIT");//聚合支付
+            SendData.put("chanalId", chanalId);// 微信支付(公众号、小程序)需填公众号授权获取微信用户openid,支付宝支付(生活号、小程序)需填生活号授权获取支付宝用户userid
+            SendData.put("simId", "");
+            SendData.put("appId", "");
+            SendData.put("isRaw", "0");
+            //分账明细
+            Map<String, Object> dataContent = new HashMap<String, Object>();// 分账明细数据1
+            dataContent.put("goodsName", body);// 商品名称
+            dataContent.put("amount", totalPrice);// 订单金额
+            dataContent.put("outOrderNo", outOrderNo);// 商户订单号
+            dataContent.put("paidType", paidType);// 支付类型
+            dataContent.put("notifyUrl", notifyUrl);// 回调通知地址
+            dataContent.put("expireDate", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS,payRequestBody.getExpireTime()));// 订单支付有效期,默认不填写
+            dataContent.put("validDate", validDate);// 担保到期日
+            dataContent.put("remark", payRequestBody.getPayWay());// 备注
+            //设置分账信息
+            //平台
+            JSONArray js = new JSONArray();
+            JSONObject splitInfo = new JSONObject();
+            splitInfo.put("subOutOrderNo",outOrderNo);//分账订单号。
+            splitInfo.put("contractNo",payConfig.getMid());//客户类型为ORG时传机构/平台号
+            splitInfo.put("customerType","ORG");//ORG-机构/平台 PERSON-个人账户 B_ACCOUNT-B端账户
+            splitInfo.put("splitAmount",totalPrice); //单位:分;分账金额总和不能超过订单金额
+            splitInfo.put("sellerFlag","0");//0-不是卖家(如参与分账的平台) 1-是卖家(一笔担保交易只能有一个卖家)
+//            js.add(splitInfo);
+            //卖家
+            JSONObject splitInfo1 = new JSONObject();
+            splitInfo1.put("subOutOrderNo",outOrderNo);//分账订单号。
+            splitInfo1.put("contractNo", "3177000000478764");//客户类型为ORG时传机构/平台号
+            splitInfo1.put("customerType","PERSON");//ORG-机构/平台 PERSON-个人账户 B_ACCOUNT-B端账户
+            splitInfo1.put("splitAmount",totalPrice); //单位:分;分账金额总和不能超过订单金额
+            splitInfo1.put("sellerFlag","1");//0-不是卖家(如参与分账的平台) 1-是卖家(一笔担保交易只能有一个卖家)
+            js.add(splitInfo1);
+            dataContent.put("splitInfoList", js);
+            JSONObject dc = JSONObject.parseObject(JSONObject.toJSONString(dataContent));
+            SendData.put("dataContent", dc.toString());
+            String OsignData = FormatUtil
+                    .formatVerify("orgNo|merchantNo|terminalNo|callType|loginNo|requestDate|dataContent", SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String version = "v3.0.0";
+            String method = "payment" ;
+            LogSyncUtil.logSync("宝付聚合支付 下单,交易编号:{},请求参数:{}",payRequestBody.getOrderNo(),SendData);
+            String PostString = HttpUtil.requestPostByType(getServiceWalletUrl(version,method), SendData, "application/json");
+            LogSyncUtil.logSync("宝付聚合支付 下单,交易编号:{},返回结果:{}",payRequestBody.getOrderNo(),PostString);
+//            String PostString = HttpUtil.requestPostByType(getServiceWalletUrl("v3.0.0","payment"), SendData, "application/json");
+            if (StringUtils.isEmpty(PostString)) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                // 自行处理
+                String result = jsonObject.getString("result");
+                String retStr = SecurityUtil.Base64Decode(result);
+                log.info("result==>" + retStr);
+                return ResultMap.ok()
+                        .put("merOrderId",outOrderNo)
+                        .put("orderNo",payRequestBody.getOrderNo())
+                        .put("appPayRequest",jsonObject.getJSONObject("appPayRequest"))
+                        .put("data",JSONObject.parseObject(retStr))
+                        ;
+            } else {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        }catch (Exception e){
+
+        }
+        return ResultMap.error(-1,"支付异常!");
+    }
+    /**
+     * 5.2.1 退款申请
+     *
+     * @param refundRequestDto
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public ResultMap profitShareRefundApply(RefundRequestDto refundRequestDto) {
+        try {
+            RechargeUserInfoDto rechargeUserInfoDto = refundRequestDto.getRechargeUserInfoDto();
+            if(null == rechargeUserInfoDto ){
+                return ResultMap.error("无法获取支付数据,请联系管理员确认!");
+            }
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) refundRequestDto.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            String orgTradeId = refundRequestDto.getOrderNo();// 原支付订单号
+            int refundAmount = refundRequestDto.getRefundAmount().multiply(new BigDecimal(100)).intValue();
+            JSONArray js = new JSONArray();
+            if(StringUtils.isEmpty(loginNo)){
+                JSONObject payJson = JSONObject.parseObject(rechargeUserInfoDto.getPayParam());
+                JSONObject sendData = payJson.getJSONObject("payParam");
+                loginNo = sendData.getString("loginNo");
+                //获取分账参数
+                String splitInfoStr = sendData.getString("splitInfoList");
+                JSONArray splitInfoArray = JSONArray.parseArray(splitInfoStr);
+                final int[] refundPrice = {refundAmount};
+                if(null != splitInfoArray){
+                    for (Object item : splitInfoArray) {
+                        JSONObject sp = (JSONObject) item;
+                        int splitAmount = sp.getIntValue("splitAmount");
+                        if (refundPrice[0] > 0) {
+                            refundPrice[0] = refundPrice[0] - splitAmount;
+                            if (refundPrice[0] < 0) {
+                                splitAmount = splitAmount + refundPrice[0];
+                            }
+                            JSONObject refundSplitInfo = new JSONObject();
+                            refundSplitInfo.put("orgSubOutOrderNo", sp.getString("subOutOrderNo"));
+                            refundSplitInfo.put("refundAmount", splitAmount+"");
+                            js.add(refundSplitInfo);
+                        }
+                        if(refundPrice[0] < 0){
+                            break;
+                        }
+                    }
+                }
+            }
+            String refundReason = refundRequestDto.getRefundMsg();
+            String refundTradeId = getMerchantOrderId(payConfig);// 退款请求订单号
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("refundTradeId", refundTradeId);// 退款请求订单号
+            SendData.put("refundTradeType", "REFUND_APPLY");
+            SendData.put("orgTradeId", orgTradeId);// 退款原始支付订单号
+            SendData.put("refundAmount", refundAmount+"");
+            SendData.put("refundReason", refundReason);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            SendData.put("remark",refundRequestDto.getPayWay());
+            SendData.put("refundSplitInfoList", js);
+            String OsignData = FormatUtil.formatVerify(
+                    "orgNo|merchantNo|terminalNo|loginNo|requestDate|refundTradeId|orgTradeId|refundAmount|refundSplitInfoList",
+                    SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String version = "v3.0.0";
+            String method = "profitShareRefundApply" ;
+            LogSyncUtil.logSync("宝付聚合,钱包支付 退款申请,交易编号:{},请求参数:{}",orgTradeId,SendData);
+            String PostString = HttpUtil.requestPostByType(getServiceTradeUrl(version,method), SendData, "application/json");
+            LogSyncUtil.logSync("宝付聚合,钱包支付 退款申请,交易编号:{},返回结果:{}",orgTradeId,PostString);
+//            String PostString = HttpUtil.requestPostByType(getServiceTradeUrl("v3.0.0","profitShareRefundApply"), SendData, "json");
+            if (StringUtils.isEmpty(PostString)) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                //判断结果
+//                String result = jsonObject.getString("result");
+//                JSONObject resultJson = JSONObject.parseObject(result);
+//                String refundOrderId = resultJson.getString("refundOrderId");
+//                String refundAmountStr = resultJson.getString("refundAmount");
+//                JSONArray refundSplitResultList = resultJson.getJSONArray("refundSplitResultList");
+                //如果成功则调用确认退款接口
+                rechargeUserInfoDto.setLoginNo(loginNo);
+                refundRequestDto.setRechargeUserInfoDto(rechargeUserInfoDto);
+                refundRequestDto.setRefundNo(refundTradeId);
+                return profitShareRefundConfirm(refundRequestDto);
+            } else if("NOT_EXIT_ASSURE_SPLIT_INFO".equals(jsonObject.getString("errorCode"))){
+                //子单未确认分账不能进行分账后退款
+                //进行分帐前退款
+                log.info(" -----不能进行分帐后退款, 调用分帐前退款操作: {} ",orgTradeId);
+                return refundRequest(refundRequestDto);
+            } else {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(" 退款请求失败:{} ",e);
+        }
+        return ResultMap.error(-1,"退款异常!");
+    }
+
+    /**
+     * 5.2.2 退款确认
+     *
+     * @param refundRequestDto
+     * @return
+     * @throws Exception
+     */
+    private ResultMap profitShareRefundConfirm(RefundRequestDto refundRequestDto) {
+        try {
+            RechargeUserInfoDto rechargeUserInfoDto = refundRequestDto.getRechargeUserInfoDto();
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) refundRequestDto.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            String orgTradeId = refundRequestDto.getOrderNo();// 原支付订单号
+            String refundTradeId = refundRequestDto.getRefundNo();// refundTradeId
+            String notifyUrl = payConfig.getRefundNotifyUrl();
+            String refundAmount = refundRequestDto.getRefundAmount().multiply(new BigDecimal(100)).intValue()+"";
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            SendData.put("refundTradeId", refundTradeId);
+            SendData.put("refundTradeType", "REFUND_CONFIRM");
+            SendData.put("orgTradeId", orgTradeId);// 退款原始支付订单号
+            SendData.put("refundAmount", refundAmount);
+            SendData.put("notifyUrl", notifyUrl);// 地址根据商户自定议,接收方法可参考【notifyUrl】
+            String OsignData = FormatUtil
+                    .formatVerify("orgNo|merchantNo|terminalNo|loginNo|requestDate|refundTradeId|refundAmount", SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String version = "v3.0.0";
+            String method = "profitShareRefundConfirm" ;
+            LogSyncUtil.logSync("宝付聚合,钱包支付 退款确认,交易编号:{},请求参数:{}",orgTradeId,SendData);
+            String PostString = HttpUtil.requestPostByType(getServiceTradeUrl(version,method), SendData, "application/json");
+            LogSyncUtil.logSync("宝付聚合,钱包支付 退款确认,交易编号:{},返回结果:{}",orgTradeId,PostString);
+//            String PostString = HttpUtil.requestPostByType(getServiceTradeUrl("v3.0.0","profitShareRefundConfirm") , SendData, "application/json");
+            if (StringUtils.isEmpty(PostString)) {
+                log.info("PostString  为空");
+                ResultMap resultMap = profitShareRefundCancel(refundRequestDto);
+                log.info(" 退款撤回操作111:{} ",resultMap);
+                return ResultMap.error(-1,"退款失败[401]");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                ResultMap resultMap = profitShareRefundCancel(refundRequestDto);
+                log.info(" 退款撤回操作2222:{} ",resultMap);
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                String result = jsonObject.getString("result");
+                log.info(" 退款结果:{} ",result);
+                JSONObject resultJson = JSONObject.parseObject(result);
+                String refundStatus = resultJson.getString("refundStatus");
+                Map<String, String> stringStringMap = new HashMap<>();
+                String refundOrderId = resultJson.getString("refundOrderId");
+                String refundTradeIdRet = resultJson.getString("refundTradeId");
+                String refundMoney = resultJson.getString("refundMoney");
+                if("S".equals(refundStatus)){//成功
+                    stringStringMap.put("out_refund_no", refundTradeIdRet);
+                    stringStringMap.put("refund_id", refundOrderId);
+                    stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(refundMoney)));
+                    stringStringMap.put("fund_change", "Y");
+                    stringStringMap.put("refund_status",refundStatus);
+                    return  ResultMap.ok()
+                            .put("data",stringStringMap)
+                            ;
+                } else if ("P".equals(refundStatus)) {
+                    stringStringMap.put("out_refund_no", refundTradeIdRet);
+                    stringStringMap.put("refund_id", refundOrderId);
+                    stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(refundMoney)));
+                    stringStringMap.put("fund_change", "P");
+                    stringStringMap.put("refund_status",refundStatus);
+                    return  ResultMap.ok()
+                            .put("data",stringStringMap)
+                            ;
+                }else{
+                    ResultMap resultMap = profitShareRefundCancel(refundRequestDto);
+                    log.info(" 退款撤回操作3333:{} ",resultMap);
+                    return ResultMap.error(-1,resultJson.getString("message"));
+                }
+            }else {
+                ResultMap resultMap = profitShareRefundCancel(refundRequestDto);
+                log.info(" 退款撤回操作44444:{} ",resultMap);
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(" 确认退款异常:{} ",e);
+        }
+        return ResultMap.error(-1,"退款失败[403]");
+    }
+
+    /**
+     * 5.2.3 退款撤销
+     *
+     * @param refundRequestDto
+     * @return
+     * @throws Exception
+     */
+    private ResultMap profitShareRefundCancel(RefundRequestDto refundRequestDto) {
+        try {
+            RechargeUserInfoDto rechargeUserInfoDto = refundRequestDto.getRechargeUserInfoDto();
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) refundRequestDto.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            String refundTradeId = refundRequestDto.getRefundNo();// 原支付订单号
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            SendData.put("refundTradeId", refundTradeId);
+            SendData.put("refundTradeType", "REFUND_CANCEL");
+            String OsignData = FormatUtil.formatVerify("orgNo|merchantNo|terminalNo|loginNo|requestDate|refundTradeId",
+                    SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData,  payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String version = "v3.0.0";
+            String method = "profitShareRefundCancel" ;
+            LogSyncUtil.logSync("宝付聚合,钱包支付 退款确认,交易编号:{},请求参数:{}",refundTradeId,SendData);
+            String PostString = HttpUtil.requestPostByType(getServiceTradeUrl(version,method), SendData, "application/json");
+            LogSyncUtil.logSync("宝付聚合,钱包支付 退款确认,交易编号:{},返回结果:{}",refundTradeId,PostString);
+//            String PostString = HttpUtil.requestPostByType(getServiceTradeUrl("v3.0.0","profitShareRefundCancel"), SendData, "application/json");
+            if (null == PostString || PostString.isEmpty()) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                /**
+                 * 省略
+                 */
+                return ResultMap.ok("退款撤回成功!");
+            }else{
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(" 撤回退款异常:{} ",e);
+        }
+        return ResultMap.error(-2,"退款撤回异常!");
+    }
+
+    /**
+     * 5.1 分账前退款
+     *
+     * @param refundRequestDto
+     * @return
+     * @throws Exception
+     */
+    public ResultMap refundRequest(RefundRequestDto refundRequestDto)  {
+        try {
+            log.info(" 分帐前退款--refundRequest--  ");
+            RechargeUserInfoDto rechargeUserInfoDto = refundRequestDto.getRechargeUserInfoDto();
+            if(null == rechargeUserInfoDto ){
+                return ResultMap.error("无法获取支付数据,请联系管理员确认!");
+            }
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) refundRequestDto.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            String orgTradeId = refundRequestDto.getOrderNo();// 原支付订单号
+            int refundAmount = refundRequestDto.getRefundAmount().multiply(new BigDecimal(100)).intValue();
+            JSONArray js = new JSONArray();
+            if(StringUtils.isEmpty(loginNo)){
+                JSONObject payJson = JSONObject.parseObject(rechargeUserInfoDto.getPayParam());
+                JSONObject sendData = payJson.getJSONObject("payParam");
+                loginNo = sendData.getString("loginNo");
+                //获取分账参数
+                String splitInfoStr = sendData.getString("splitInfoList");
+                JSONArray splitInfoArray = JSONArray.parseArray(splitInfoStr);
+                final int[] refundPrice = {refundAmount};
+                if(null != splitInfoArray){
+                    for (Object item : splitInfoArray) {
+                        JSONObject sp = (JSONObject) item;
+                        int splitAmount = sp.getIntValue("splitAmount");
+                        if (refundPrice[0] > 0) {
+                            refundPrice[0] = refundPrice[0] - splitAmount;
+                            if (refundPrice[0] < 0) {
+                                splitAmount = splitAmount + refundPrice[0];
+                            }
+                            JSONObject refundSplitInfo = new JSONObject();
+                            refundSplitInfo.put("oldSubOutOrderNo", sp.getString("subOutOrderNo"));
+                            refundSplitInfo.put("splitRefundAmount", splitAmount+"");
+                            js.add(refundSplitInfo);
+                        }
+                        if(refundPrice[0] < 0){
+                            break;
+                        }
+                    }
+                }
+            }
+            String refundTradeId = getMerchantOrderId(payConfig);// 退款请求订单号
+            String notifyUrl = payConfig.getRefundNotifyUrl();
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("refundTradeId", refundTradeId);// 退款请求订单号
+            SendData.put("orgTradeId", orgTradeId);// 退款原始支付订单号
+            SendData.put("refundMoney", refundAmount+"");// 单位分
+            SendData.put("refundReason",refundRequestDto.getRefundMsg());
+            SendData.put("notifyUrl", notifyUrl);// 地址根据商户自定议,接收方法可参考【notifyUrl】
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            SendData.put("remark",refundRequestDto.getPayWay());
+            SendData.put("refundSplitInfoList", js);
+            String OsignData = FormatUtil.formatVerify(
+                    "orgNo|merchantNo|terminalNo|requestDate|refundTradeId|orgTradeId|refundMoney|refundReason|notifyUrl",
+                    SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String PostString = HttpUtil.requestPostByType(getServiceTradeUrl("v3.0.0","refundRequest"), SendData, "application/json");
+            if (null == PostString || PostString.isEmpty()) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                String result = jsonObject.getString("result");
+                log.info(" 退款结果:{} ",result);
+                JSONObject resultJson = JSONObject.parseObject(result);
+                String refundStatus = resultJson.getString("refundStatus");
+                Map<String, String> stringStringMap = new HashMap<>();
+                String refundOrderId = resultJson.getString("refundOrderId");
+                String refundTradeIdRet = resultJson.getString("refundTradeId");
+                String refundMoney = resultJson.getString("refundMoney");
+                stringStringMap.put("out_refund_no", refundTradeIdRet);
+                stringStringMap.put("refund_id", refundOrderId);
+                stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(refundMoney)));
+                stringStringMap.put("refund_status",refundStatus);
+                if("S".equals(refundStatus)){//成功
+                    stringStringMap.put("fund_change", "Y");
+                    return  ResultMap.ok()
+                            .put("data",stringStringMap)
+                            ;
+                } else if ("P".equals(refundStatus)) {
+                    stringStringMap.put("fund_change", "P");
+                    return  ResultMap.ok()
+                            .put("data",stringStringMap)
+                            ;
+                }else{
+                    return ResultMap.error(-1,resultJson.getString("message"));
+                }
+//                return ResultMap.ok()
+//                        .put("jsonObject",jsonObject)
+//                        ;
+            } else {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        }catch (Exception e){
+
+        }
+        return ResultMap.error(-1,"退款异常!");
+    }
+
+    /**
+     * 5.10 交易订单信息查询
+     *
+     * @param payRequestBody
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public ResultMap queryOrder(PaymentRequestDto payRequestBody)  {
+        String errMsg = "";
+        try {
+            String tradeId = payRequestBody.getOrderNo();// 支付订单号/退款单号
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) payRequestBody.getPayConfigByClass(BaofooRechargePayConfig.class);
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("tradeId", tradeId);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            String OsignData = FormatUtil.formatVerify("orgNo|merchantNo|terminalNo|requestDate|tradeId", SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String version = "v3.0.0";
+            String method = "queryOrder" ;
+            LogSyncUtil.logSync("宝付聚合,钱包支付 查询,交易编号:{},请求参数:{}",tradeId,SendData);
+            String PostString = HttpUtil.requestPostByType(getServiceWalletUrl(version,method), SendData, "application/json");
+            LogSyncUtil.logSync("宝付聚合,钱包支付 查询,交易编号:{},返回结果:{}",tradeId,PostString);
+//            String PostString = HttpUtil.requestPostByType(getServiceWalletUrl("v3.0.0","queryOrder"), SendData, "application/json");
+            if (StringUtils.isEmpty(PostString)) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                if (jsonObject.containsKey("result")) {
+                    JSONObject ResultObject = (JSONObject) jsonObject.get("result");
+                    log.info("结果值:" + ResultObject.getString("contractNo"));
+                    //判断交易状态
+                    if(ResultObject.getString("status").contains(PayConstants.SUCCESS) ||
+                            ResultObject.getString("status").contains("FINISH")
+                    ) {
+                        if(ResultObject.getString("tradeType").equals("RECHARGE") || ResultObject.getString("tradeType").equals("ASSURE_RECHARGE")) {
+                            //支付,充值
+                            return ResultMap.ok()
+                                    .put("orderNo",payRequestBody.getOrderNo())
+                                    .put("payWay",payRequestBody.getPayWay())
+                                    .put("paymentNo",ResultObject.getString("transactionId"))
+                                    .put("paymentPrice",new BigDecimal(ResultObject.getString("amount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN))
+                                    .put("actualPayment",new BigDecimal(ResultObject.getString("amount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN))
+                                    .put("paymentSuccessTime",DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, ResultObject.getString("finishDate")))
+                                    ;
+                        }else if(ResultObject.getString("tradeType").equals("REFUND") || ResultObject.getString("tradeType").equals("WITHDRAW")){
+                            //提现退款
+                            Map<String, String> stringStringMap = new HashMap<>();
+                            stringStringMap.put("out_refund_no", tradeId);
+                            stringStringMap.put("refund_id", ResultObject.getString("transactionId"));
+                            stringStringMap.put("refund_fee", new BigDecimal(ResultObject.getString("amount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN).toString());
+                            stringStringMap.put("fund_change", "Y");
+                            return ResultMap.ok()
+                                    .put("data",stringStringMap)
+                                    ;
+                        }
+                    }else{
+                        errMsg = ResultObject.getString("status");
+                    }
+                }
+            }else{
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(" 查询异常{} ",e);
+            errMsg = "下单失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+
+    /**
+     * 3.4 确认分账
+     *
+     * @Description 消费担保支付需确认才能进行分账
+     * @param payRequestBody
+     * @return
+     * @throws Exception
+     */
+    public ResultMap confirmAssurePay(PaymentRequestDto payRequestBody) {
+        try {
+            RechargeUserInfoDto rechargeUserInfoDto = payRequestBody.getRechargeUserInfoDto();
+            if(null == rechargeUserInfoDto ){
+                return ResultMap.error("无法获取支付数据,请联系管理员确认!");
+            }
+            BaofooRechargePayConfig payConfig = (BaofooRechargePayConfig) payRequestBody.getPayConfigByClass(BaofooRechargePayConfig.class);
+            String loginNo = rechargeUserInfoDto.getLoginNo();// 登录号
+            String notifyUrl = payConfig.getPayNotifyUrl();// 通知地址
+            int totalPrice = payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue();// 总金额
+            String oldOutOrderNo = payRequestBody.getOrderNo();// 原担保支付/消费充值单号
+            String outOrderNo = getMerchantOrderId(payConfig);
+            Map<String, Object> SendData = new HashMap<String, Object>();
+            SendData.put("orgNo", payConfig.getMid());
+            SendData.put("merchantNo", payConfig.getMid());
+            SendData.put("terminalNo", payConfig.getTid());
+            SendData.put("loginNo", loginNo);
+            SendData.put("requestDate", DateUtils.dateTimeNow());
+            SendData.put("notifyUrl", notifyUrl);
+            Random random = new Random();
+            Map<String, Object> DC = new HashMap<String, Object>();
+            DC.put("amount", totalPrice+"");// 订单金额
+            DC.put("outOrderNo", outOrderNo);// 商户订单号
+            DC.put("oldOutOrderNo", oldOutOrderNo);// 原商户订单号
+            JSONArray js = new JSONArray();
+            if(StringUtils.isEmpty(loginNo)){
+                JSONObject payJson = JSONObject.parseObject(rechargeUserInfoDto.getPayParam());
+                JSONObject sendData = payJson.getJSONObject("payParam");
+                //获取分账参数
+                String splitInfoStr = sendData.getString("splitInfoList");
+                JSONArray splitInfoArray = JSONArray.parseArray(splitInfoStr);
+                if(null != splitInfoArray){
+                    for (Object item : splitInfoArray) {
+                        JSONObject sp = (JSONObject) item;
+                        int splitAmount = sp.getIntValue("splitAmount");
+                        JSONObject refundSplitInfo = new JSONObject();
+                        refundSplitInfo.put("oldSubOutOrderNo", sp.getString("subOutOrderNo"));
+                        refundSplitInfo.put("splitAmount", splitAmount+"");
+                        js.add(refundSplitInfo);
+                    }
+                }
+            }
+            DC.put("assureConfirmSplitInfoList", js);// 放入分账参数
+            JSONObject DCString = JSONObject.parseObject(JSONObject.toJSONString(DC));
+            SendData.put("dataContent", DCString.toString());
+            String OsignData = FormatUtil.formatVerify("orgNo|merchantNo|loginNo|terminalNo|requestDate|dataContent", SendData);
+            log.info("签名拼接参数:" + OsignData);
+            String Sign = SignatureUtils.encryptByRSA(OsignData, payConfig.getPrivateKey(), payConfig.getPrivateKeyPwd());
+            log.info("签名结果:" + Sign);
+            SendData.put("signData", Sign);// 签名结果。
+            String PostString = HttpUtil.requestPostByType(getServiceWalletUrl("v3.0.0","confirmAssurePay"), SendData, "application/json");
+            if (null == PostString || PostString.isEmpty()) {
+                log.info("PostString  为空");
+                return ResultMap.error(-1,"返回出错【404】");
+            }
+            JSONObject jsonObject = JSONObject.parseObject(PostString.trim());
+            if (!jsonObject.containsKey("success")) {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+            if (jsonObject.getBoolean("success")) {
+                /**
+                 * 省略
+                 */
+                return ResultMap.ok("操作成功,等待分账结果通知!");
+            }else {
+                return ResultMap.error(-1,jsonObject.getString("errorMsg"));
+            }
+        }catch (Exception e){
+            log.error(" 确认分账异常{} ",e);
+        }
+        return ResultMap.error(-1,"确认分账异常!");
+    }
+
+    private String getServiceOrderUrl(String version ,String method){
+        String url = baseUrlBox + serviceOrderUrl ;
+        if(StringUtils.isNotEmpty(appversion) && "prod".equals(appversion) ){
+            url = baseUrl+serviceOrderUrl ;
+        }
+        return MessageFormat.format(url,version,method);
+    }
+    private String getServiceTradeUrl(String version ,String method){
+        String url = baseUrlBox + serviceTradeUrl ;
+        if(StringUtils.isNotEmpty(appversion) && "prod".equals(appversion) ){
+            url = baseUrl+serviceTradeUrl ;
+        }
+        return MessageFormat.format(url,version,method);
+    }
+    private String getServiceWalletUrl(String version ,String method){
+        String url = baseUrlBox + serviceWalletUrl ;
+        if(StringUtils.isNotEmpty(appversion) && "prod".equals(appversion) ){
+            url = baseUrl+serviceWalletUrl ;
+        }
+        return MessageFormat.format(url,version,method);
+    }
+
+    public  String getMerchantOrderId(BaofooRechargePayConfig payConfig){
+        return payConfig.getMsgSrcId()+ DateUtils.parseDateToStr("yyyyMMddmmHHssSSS",new Date())+ RandomUtil.random(4);
+    }
+
+}

+ 779 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BfPayServiceImpl.java

@@ -0,0 +1,779 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.common.utils.Base64Util;
+import com.tzy.common.utils.BeanUtil;
+import com.tzy.common.utils.DateUtils;
+import com.tzy.common.utils.StringUtils;
+import com.tzy.common.utils.http.HttpUtils;
+import com.tzy.framework.pay.config.BfPayConfig;
+import com.tzy.framework.pay.config.PayConfig;
+import com.tzy.framework.pay.dto.*;
+import com.tzy.framework.pay.service.BfPayService;
+import com.tzy.framework.pay.util.RSA2EncriptUtil;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 宝付支付
+ */
+@Slf4j
+@Service
+public class BfPayServiceImpl implements BfPayService {
+
+    @Autowired
+    private BfPayConfig bfPayConfig;
+    @Autowired
+    private PayConfig payConfig;
+
+    public static final String MAIN_WX = "DYNAMIC_WECHAT";//宝付-微信-主扫
+    public static final String MAIN_ALIPAY = "DYNAMIC_ALPAY";//宝付-支付宝-主扫
+    public static final String MAIN_UAC = "DYNAMIC_UNION";//宝付-云闪付-主扫
+    public static final String APP_WX = "WECHAT_APPLET";//宝付-微信-APP
+    public static final String APP_ALIPAY = "ALI_APPLET";//宝付-支付宝-APP
+
+    public static final String reusePay = "TRUE";//是否支持重复扫码,默认是
+    public static String regSpecial = "[`~!@$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()_+|{}‘;:”“’。,、?]";
+
+
+    private Map<String,Object> init(String appid,String method) {
+        BfPayConfig bfPayConfig = (BfPayConfig) payConfig.get(appid);
+        if(null == bfPayConfig){
+            bfPayConfig = this.bfPayConfig;
+        }
+        Map<String,Object> publicParam = new HashMap();
+        publicParam.put("method", method);// 请求方法
+//        publicParam.put("version","1.0");// 版本
+//        publicParam.put("format","JSON");// 请求格式
+//        publicParam.put("merchantNo","818000802925"); //商户号
+//        publicParam.put("signType","RSA2");  //加密方式
+        publicParam.put("version",bfPayConfig.getVersion());// 版本
+        publicParam.put("format",bfPayConfig.getFormat());// 请求格式
+        publicParam.put("merchantNo",bfPayConfig.getAppid()); //商户号
+        publicParam.put("signType",bfPayConfig.getSignType());  //加密方式
+        return publicParam;
+    }
+    private String initSignStr(String appid,String method,String signContent ) throws Exception {
+        BfPayConfig bfPayConfig = (BfPayConfig) payConfig.get(appid);
+        if(null == bfPayConfig){
+            bfPayConfig = this.bfPayConfig;
+        }
+        /**
+         * rsa 验签算法流程,当signType为RSA2时
+         * 1.先按固定格式拼接
+         * 2.RSA签名
+         */
+//        String signStr = RSA2EncriptUtil.reqSingStr(method,"1.0","JSON","818000802925","RSA2",signContent,"7c16c26a6c5550289ab65e6a69e89ee1");
+        String signStr = RSA2EncriptUtil.reqSingStr(method,bfPayConfig.getVersion(),bfPayConfig.getFormat(),bfPayConfig.getAppid(),bfPayConfig.getSignType(),signContent,bfPayConfig.getKey());;
+        log.info("[请求]固定格式拼接后明文:{}",signStr);
+//        String sign = RSA2EncriptUtil.sign(signStr,"/home/tzy/bf/bfPrivateKey.pfx","880615sandy");
+        String sign = RSA2EncriptUtil.sign(signStr,bfPayConfig.getPrivateKeyPath(),bfPayConfig.getPrivatePwd());
+        log.info("[请求]RSA加签后内容:{}",sign);
+        return sign;
+    }
+
+    public boolean verifyCallBack(String appid,String respSign,String sign ){
+        BfPayConfig bfPayConfig = (BfPayConfig) payConfig.get(appid);
+        if(null == bfPayConfig){
+            bfPayConfig = this.bfPayConfig;
+        }
+        log.info("[响应] 固定格式拼接后:{}",respSign);
+//        return RSA2EncriptUtil.verify(respSign , respMap.get("sign").toString() ,"/home/tzy/bf/bfPublicKey.cer");
+        return RSA2EncriptUtil.verify(respSign,sign,bfPayConfig.getPublicKeyPath());
+    }
+
+    public boolean verify(String appid,Map respMap ){
+        BfPayConfig bfPayConfig = (BfPayConfig) payConfig.get(appid);
+        if(null == bfPayConfig){
+            bfPayConfig = this.bfPayConfig;
+        }
+//        String respSign = RSA2EncriptUtil.resSingStr(respMap,"7c16c26a6c5550289ab65e6a69e89ee1");
+        String respSign = RSA2EncriptUtil.resSingStr(respMap,bfPayConfig.getKey());
+        log.info("[响应] 固定格式拼接后:{}",respSign);
+//        return RSA2EncriptUtil.verify(respSign , respMap.get("sign").toString() ,"/home/tzy/bf/bfPublicKey.cer");
+        return RSA2EncriptUtil.verify(respSign,respMap.get("sign").toString(),bfPayConfig.getPublicKeyPath());
+    }
+
+    @Override
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto){
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+//        String ipAddr = IpUtils.getIpAddr(request);
+        String ipAddr = "127.0.0.1";
+        ResultMap resultMap = new ResultMap();
+        String method = PayConstants.BF_METHOD_TRADE_MAIN;
+        String appScheme = "";
+        String payType = "";
+        String type = "main";
+        switch (paymentRequestDto.getPayWay()){
+            case PayConstants.BFPAY_TYPE_MAIN_WX:
+                payType= MAIN_WX;
+                appScheme = "";
+                break;
+            case PayConstants.BFPAY_TYPE_MAIN_ALIPAY:
+                payType= MAIN_ALIPAY; //支付类型-支付宝
+                appScheme = "alipays://platformapi/startapp?appId=20000067&url=";
+                break;
+            case PayConstants.BFPAY_TYPE_MAIN_UAC:
+                payType= MAIN_UAC; //支付类型-云闪付
+                appScheme = "";
+                break;
+            case PayConstants.BFPAY_TYPE_APP_WX:
+                payType= APP_WX; //支付类型-微信-app
+                appScheme = "";
+                type = "app";
+                method = PayConstants.BF_METHOD_TRADE_APP;
+                break;
+            case PayConstants.BFPAY_TYPE_APP_ALIPAY:
+                payType= APP_ALIPAY; //支付类型-支付宝-app
+                appScheme = "";
+                type = "app";
+                method = PayConstants.BF_METHOD_TRADE_APP;
+                break;
+        }
+        String url = PayConstants.BF_HOST;
+        Map<String,Object> publicParam = init(paymentRequestDto.getAppid(),method);
+        /**
+         * 业务请求参数
+         */
+        String msg = Base64Util.subStringByBytes(String.valueOf(paymentRequestDto.getBody()),80).replaceAll(regSpecial," ")+"...";
+        JSONObject body = new JSONObject();
+//		body.put("subMerchantNo",bfPayConfig.getSubMerchantNo());//门店编号
+        body.put("transNo",paymentRequestDto.getMerOrderId());//商户订单号
+        body.put("payType",payType); //支付类型
+        body.put("orderAmt",paymentRequestDto.getTotalAmount().multiply(new BigDecimal(100)).intValue());        //交易金额
+        body.put("goodsInfo",msg);//商品信息摘要
+//        body.put("returnUrl","https://m2-dev.hobbystocks.cn/api/bf/paymentBack");//后台回调地址
+        body.put("returnUrl",bfPayConfig.getPayNotifyUrl());//后台回调地址
+        body.put("requestDate", DateFormatUtils.format(new Date(), "yyyyMMddHHmmss"));//请求时间
+        body.put("pageUrl","");//前台跳转地址
+//        body.put("pageUrl",bfPayConfig.getPageUrl());//前台跳转地址
+        if("main".equals(type))body.put("reusePay",reusePay);//是否支持重复扫码,默认是
+        body.put("extend",paymentRequestDto.getPayWay());//原样返回字段
+        JSONObject extendmemo = new JSONObject();
+//        extendmemo.put("paylimit","balance");//限制卡类型
+        extendmemo.put("timeExpire", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS,new Date(paymentRequestDto.getCreateOrderTime().getTime()+2800*60))); //交易结束时间
+        //分账域,分账时必填
+//		String shareInfo = "100000178,1";
+//		extendmemo.put("shareInfo",shareInfo);
+        extendmemo.put("spbillCreateIp",ipAddr); //终端用户IP
+//        extendmemo.put("spbillCreateIp",paymentRequestDto.getCreateip()); //终端用户IP
+        extendmemo.put("longitude","116.397128");//经度
+        extendmemo.put("latitude","39.916527");//纬度
+        //以下银联需要上送
+//        extendmemo.put("areaInfo","");
+//        extendmemo.put("appVersion","");
+//        extendmemo.put("deviceType","");
+//        extendmemo.put("deviceNo","");
+        body.put("memo", extendmemo.toJSONString());
+        publicParam.put("signContent",body.toJSONString());
+        try {
+            String sign = initSignStr(paymentRequestDto.getAppid(),method, body.toJSONString());
+            publicParam.put("sign",sign);
+            log.info(" 请求参数: {}",publicParam);
+            String resp = HttpUtils.httpsRequest(url , "POST", BeanUtil.map2str(publicParam), null);
+            log.info("响应] 响应内容:{}",resp);
+            Map<String,Object> respMap = (Map<String, Object>) JSONObject.parseObject(resp,Map.class);
+            if(verify(paymentRequestDto.getAppid(),respMap)){
+                String resResult =  respMap.get("result").toString();
+                Map<String,String> result = (Map<String, String>) JSONObject.parseObject(resResult,Map.class);
+                log.info("解析结果:{}",result);
+                if(result.get("orderStatus").toString().equals("SUCCESS")){
+                    log.info("[交易结果]交易成功,成功金额:"+result.get("orderAmt").toString()+"分。");
+                    Map<String ,String > data = new HashMap<>();
+                    data.put("orderNo",paymentRequestDto.getOrderNo());
+                    data.put("url",appScheme+result.get("qrCode"));
+                    resultMap.put("data",data);
+                    return resultMap;
+                } else if(result.get("orderStatus").toString().equals("INIT")){
+                    log.info("[交易结果]交易未成功,"+result.get("respMsg").toString());
+                    Map<String ,String > data = new HashMap<>();
+                    data.put("orderNo",paymentRequestDto.getOrderNo());
+                    data.put("url",appScheme+result.get("qrCode"));
+                    resultMap.put("merOrderId",paymentRequestDto.getMerOrderId());
+                    resultMap.put("data",data);
+                    return resultMap;
+                }else {
+                    log.info("[交易结果]交易未成功,"+result.get("respMsg").toString());
+                    return ResultMap.error(Integer.parseInt(result.get("respCode")),(String) result.get("respMsg"));
+                }
+            }
+            else{
+                log.info("验签失败");
+                return ResultMap.error(-1,"验签失败!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+    @Override
+    public PaymentInfoResponseDto queryOrder(String appid ,String payWay, String  orderNo){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        String method = PayConstants.BF_METHOD_QUERY_MAIN;
+        String url = PayConstants.BF_HOST;
+        Map<String,Object> publicParam = init(appid,method);
+        JSONObject body = new JSONObject();
+        body.put("transNo",orderNo);
+        body.put("queryType","2");//查询类型 默认:2
+        log.info("[请求]业务请求参数:{}",body.toJSONString());
+        publicParam.put("signContent",body.toJSONString());
+        try {
+            String sign = initSignStr(appid,method, body.toJSONString());
+            publicParam.put("sign",sign);
+            log.info(" 请求参数: {}",publicParam);
+            String resp = HttpUtils.httpsRequest(url , "POST", BeanUtil.map2str(publicParam), null);
+            log.info("响应] 响应内容:{}",resp);
+            Map<String,Object> respMap = (Map<String, Object>) JSONObject.parseObject(resp,Map.class);
+            if(verify(appid,respMap)){
+                String resResult =  respMap.get("result").toString();
+                Map<String,String> result = (Map<String, String>) JSONObject.parseObject(resResult,Map.class);
+                log.info("解析结果:{}",result);
+                if(result.get("orderStatus").toString().equals("SUCCESS")){
+                    log.info("[查询结果]交易成功,金额:"+result.get("orderAmt").toString()+"分。");
+                    paymentInfoResponseDto.setOrderNo(orderNo);
+                    paymentInfoResponseDto.setPayWay(payWay);
+                    paymentInfoResponseDto.setPaymentNo(result.get("tradeNo"));
+                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(result.get("orderAmt")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                    paymentInfoResponseDto.setActualPayment(new BigDecimal(result.get("orderAmt")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                    paymentInfoResponseDto.setPaymentSuccessTime(DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, result.get("finishedDate")));
+                    paymentInfoResponseDto.setSuccess(true);
+                    return paymentInfoResponseDto;
+                } else {
+                    log.info("[查询结果]交易未成功,"+result.get("respMsg").toString());
+                    return PaymentInfoResponseDto.error(Integer.valueOf(result.get("respCode")),(String) result.get("respMsg"));
+                }
+                /*Object ret = respMap.get("result");
+                if(null != ret) {
+                    String resResult = respMap.get("result").toString();
+                    try {
+                        Map<String, String> result = (Map<String, String>) JSONObject.parseObject(resResult, Map.class);
+                        log.info("解析结果:{}", result);
+                        paymentInfoResponseDto.setOrderNo(orderNo);
+                        paymentInfoResponseDto.setPayWay(payWay);
+                        paymentInfoResponseDto.setPaymentNo(StringUtils.isNotEmpty(result.get("tradeNo")) ? result.get("tradeNo") : null);
+                        String orderAmt = StringUtils.isNotEmpty(result.get("orderAmt")) ? result.get("orderAmt") : "0";
+                        paymentInfoResponseDto.setPaymentPrice(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                        paymentInfoResponseDto.setActualPayment(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                        Date finishedDate = StringUtils.isNotEmpty(result.get("finishedDate")) ? DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, result.get("finishedDate")) : null;
+                        paymentInfoResponseDto.setPaymentSuccessTime(finishedDate);
+                        String respCode = StringUtils.isNotEmpty(result.get("respCode")) ? result.get("respCode") : "-1";
+                        paymentInfoResponseDto.setCode(Integer.valueOf(respCode));
+                        paymentInfoResponseDto.setTradeState(respCode);
+                        String respMsg = StringUtils.isNotEmpty(result.get("respMsg")) ? result.get("respCode") : "未找到状态";
+                        paymentInfoResponseDto.setMsg(respMsg);
+                        paymentInfoResponseDto.setTradeStateDesc(respMsg);
+                        if (StringUtils.isNotEmpty(result.get("orderStatus")) && result.get("orderStatus").equals("SUCCESS")) {
+                            log.info("[查询结果]交易成功,金额:" + result.get("orderAmt").toString() + "分。");
+                        } else {
+                            log.info("[查询结果]交易未成功," + result.get("respMsg").toString());
+                        }
+                    }catch (Exception e){
+                        e.printStackTrace();
+                        paymentInfoResponseDto = PaymentInfoResponseDto.error(-1,"解析返回数据异常!");
+                    }
+                }
+                return paymentInfoResponseDto;*/
+            }
+            else{
+                log.info("验签失败");
+                return PaymentInfoResponseDto.error(-1,"验签失败!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return PaymentInfoResponseDto.error(-1,"签名生成异常!");
+        }
+    }
+
+    @Override
+    public ResultMap refund(String appid , String orderNo, BigDecimal orderPrice, BigDecimal refundPrice, String refundMsg){
+        String method = PayConstants.BF_METHOD_REFUND_MAIN;
+        String url = PayConstants.BF_HOST;
+        Map<String,Object> publicParam = init(appid,method);
+        JSONObject body = new JSONObject();
+        String refundNo = RandomUtil.getRandom(RandomUtil.REFUND_NO);
+        body.put("transNo",refundNo);//商户订单号
+        body.put("refundType","2");//退款类型
+        body.put("origTransNo",orderNo);//原商户订单号
+        body.put("origOrderAmt",orderPrice.multiply(new BigDecimal(100)).intValue());//原交易金额 单位: 分
+        body.put("orderAmt", refundPrice.multiply(new BigDecimal(100)).intValue());//退款金额 单位: 分
+        body.put("requestDate",DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS,new Date()));//交易日期
+        body.put("refundReason",refundMsg); //退款原因
+        body.put("returnUrl",bfPayConfig.getRefundNotifyUrl());//回调地址
+        body.put("extend",orderNo); //扩展字段
+        publicParam.put("signContent",body.toJSONString());
+        try {
+            String sign = initSignStr(appid,method, body.toJSONString());
+            publicParam.put("sign",sign);
+            log.info(" 请求参数: {}",publicParam);
+            String resp = HttpUtils.httpsRequest(url , "POST", BeanUtil.map2str(publicParam), null);
+            log.info("响应] 响应内容:{}",resp);
+            Map<String,Object> respMap = (Map<String, Object>) JSONObject.parseObject(resp,Map.class);
+            if(verify(appid,respMap)){
+                String resResult =  respMap.get("result").toString();
+                Map<String,String> result = (Map<String, String>) JSONObject.parseObject(resResult,Map.class);
+                log.info("解析结果:{}",result);
+                if(result.get("orderStatus").equals("SUCCESS")|| result.get("orderStatus").equals("PROCESSING")){
+                    log.info("[申请退款结果]交易成功,金额:"+result.get("orderAmt")+"分。");
+                    Map<String, String> stringStringMap = new HashMap<>();
+                    stringStringMap.put("out_refund_no", refundNo);
+                    stringStringMap.put("refund_id", result.get("tradeNo"));
+                    stringStringMap.put("refund_fee", result.get("orderAmt"));
+                    stringStringMap.put("fund_change", "Y");
+                    stringStringMap.put("finishedDate", result.get("finishedDate"));
+                    return ResultMap.ok(result.get("respMsg"))
+                            .put("data",stringStringMap)
+                            ;
+                }else {
+                    log.info("[申请退款结果]交易未成功,"+result.get("respMsg").toString());
+                    return ResultMap.error(Integer.parseInt(result.get("respCode")),(String) result.get("respMsg"));
+                }
+            }
+            else{
+                log.info("验签失败");
+                return ResultMap.error(-1,"验签失败!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+    @Override
+    public ResultMap refundQuery( String appid ,String outRefundNo){
+        String method = PayConstants.BF_METHOD_REFUND_QUERY_MAIN;
+        String url = PayConstants.BF_HOST;
+        Map<String,Object> publicParam = init(appid,method);
+        JSONObject body = new JSONObject();
+        body.put("transNo",outRefundNo);//商户订单号
+        publicParam.put("signContent",body.toJSONString());
+        try {
+            String sign = initSignStr(appid,method, body.toJSONString());
+            publicParam.put("sign",sign);
+            log.info(" 请求参数: {}",publicParam);
+            String resp = HttpUtils.httpsRequest(url , "POST", BeanUtil.map2str(publicParam), null);
+            log.info("响应] 响应内容:{}",resp);
+            Map<String,Object> respMap = (Map<String, Object>) JSONObject.parseObject(resp,Map.class);
+            if(verify(appid,respMap)){
+                String resResult =  respMap.get("result").toString();
+                Map<String,String> result = (Map<String, String>) JSONObject.parseObject(resResult,Map.class);
+                log.info("解析结果:{}",result);
+                if(result.get("orderStatus").equals("SUCCESS")){
+                    log.info("[申请退款结果]交易成功,金额:"+result.get("orderAmt")+"分。");
+                    Map<String, String> stringStringMap = new HashMap<>();
+                    stringStringMap.put("out_refund_no", outRefundNo);
+                    stringStringMap.put("refund_id", result.get("tradeNo"));
+                    stringStringMap.put("refund_fee", result.get("orderAmt"));
+                    stringStringMap.put("fund_change", "Y");
+                    stringStringMap.put("finishedDate", result.get("finishedDate"));
+                    return ResultMap.ok()
+                            .put("data",stringStringMap)
+                            ;
+                }else {
+                    log.info("[申请退款结果]交易未成功,"+result.get("respMsg").toString());
+                    return ResultMap.error(Integer.parseInt(result.get("respCode")),(String) result.get("respMsg"));
+                }
+            }
+            else{
+                log.info("验签失败");
+                return ResultMap.error(-1,"验签失败!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+
+
+    public static void main(String[] args) {
+        BfPayService bfPaymentService = new BfPayServiceImpl();
+        PaymentRequestDto p = new PaymentRequestDto();
+//        p.setPayWay("wxpay-main-bf");
+//        p.setPayWay("alipay-main-bf");
+        p.setPayWay(PayConstants.BFPAY_TYPE_MAIN_ALIPAY);
+        p.setBody("测试");
+        p.setOrderNo(RandomUtil.getRandomOld(RandomUtil.GROUP_USER_ORDER));
+        p.setTotalAmount(new BigDecimal(0.01));
+        p.setCreateOrderTime(new Date());
+        p.setCreateip("192.168.1.1");
+        log.info(" 统一下单结果:{} ",bfPaymentService.tradeCreate(p));
+//        String orderNo = "GU202205061137016431";
+//        log.info(" 统一下单结果:{} ",bfPaymentService.queryOrder("alipay-main-bf",orderNo));
+    }
+
+    /****************************新支付逻辑*******************************/
+
+    /**
+     * new
+     * @param bfPayConfig
+     * @param method
+     * @return
+     */
+    private Map<String,Object> init(BfPayConfig bfPayConfig,String method) {
+        if(null == bfPayConfig){
+            return new HashMap<>();
+        }
+        Map<String,Object> publicParam = new HashMap();
+        publicParam.put("method", method);// 请求方法
+        publicParam.put("version",bfPayConfig.getVersion());// 版本
+        publicParam.put("format",bfPayConfig.getFormat());// 请求格式
+        publicParam.put("merchantNo",bfPayConfig.getAppid()); //商户号
+        publicParam.put("signType",bfPayConfig.getSignType());  //加密方式
+        return publicParam;
+    }
+    /**
+     * new
+     * @param bfPayConfig
+     * @param method
+     * @param signContent
+     * @return
+     * @throws Exception
+     */
+    private String initSignStr(BfPayConfig bfPayConfig,String method,String signContent ) throws Exception {
+        if(null == bfPayConfig){
+            return null;
+        }
+        /**
+         * rsa 验签算法流程,当signType为RSA2时
+         * 1.先按固定格式拼接
+         * 2.RSA签名
+         */
+        String signStr = RSA2EncriptUtil.reqSingStr(method,bfPayConfig.getVersion(),bfPayConfig.getFormat(),bfPayConfig.getAppid(),bfPayConfig.getSignType(),signContent,bfPayConfig.getKey());;
+        log.info("[请求]固定格式拼接后明文:{}",signStr);
+        String sign = RSA2EncriptUtil.sign(signStr,bfPayConfig.getPrivateKeyPath(),bfPayConfig.getPrivatePwd());
+        log.info("[请求]RSA加签后内容:{}",sign);
+        return sign;
+    }
+
+    /**
+     * new
+     * @param bfPayConfig
+     * @param respSign
+     * @param sign
+     * @return
+     */
+    public boolean verifyCallBackNew(BfPayConfig bfPayConfig,String respSign,String sign ){
+        if(null == bfPayConfig){
+            return false;
+        }
+        log.info("[响应] 固定格式拼接后:{}",respSign);
+        return RSA2EncriptUtil.verify(respSign,sign,bfPayConfig.getPublicKeyPath());
+    }
+    /**
+     * new
+     * @param bfPayConfig
+     * @param respMap
+     * @return
+     */
+    public boolean verify(BfPayConfig bfPayConfig,Map respMap ){
+        if(null == bfPayConfig){
+            return false;
+        }
+//        String respSign = RSA2EncriptUtil.resSingStr(respMap,"7c16c26a6c5550289ab65e6a69e89ee1");
+        String respSign = RSA2EncriptUtil.resSingStr(respMap,bfPayConfig.getKey());
+        log.info("[响应] 固定格式拼接后:{}",respSign);
+//        return RSA2EncriptUtil.verify(respSign , respMap.get("sign").toString() ,"/home/tzy/bf/bfPublicKey.cer");
+        return RSA2EncriptUtil.verify(respSign,respMap.get("sign").toString(),bfPayConfig.getPublicKeyPath());
+    }
+
+    /**
+     * 新支付逻辑
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap tradeCreateNew(PaymentRequestDto paymentRequestDto){
+//        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+//        String ipAddr = IpUtils.getIpAddr(request);
+        BfPayConfig bfPayConfig = (BfPayConfig) paymentRequestDto.getPayConfigByClass(BfPayConfig.class);
+        String ipAddr = "127.0.0.1";
+        ResultMap resultMap = new ResultMap();
+        String method = PayConstants.BF_METHOD_TRADE_MAIN;
+        String appScheme = "";
+        String payType = "";
+        String type = "main";
+        switch (paymentRequestDto.getPayWay()){
+            case PayConstants.BFPAY_TYPE_MAIN_WX:
+                payType= MAIN_WX;
+                appScheme = "";
+                break;
+            case PayConstants.BFPAY_TYPE_MAIN_ALIPAY:
+                payType= MAIN_ALIPAY; //支付类型-支付宝
+                appScheme = "alipays://platformapi/startapp?appId=20000067&url=";
+                break;
+            case PayConstants.BFPAY_TYPE_MAIN_UAC:
+                payType= MAIN_UAC; //支付类型-云闪付
+                appScheme = "";
+                break;
+            case PayConstants.BFPAY_TYPE_APP_WX:
+                payType= APP_WX; //支付类型-微信-app
+                appScheme = "";
+                type = "app";
+                method = PayConstants.BF_METHOD_TRADE_APP;
+                break;
+            case PayConstants.BFPAY_TYPE_APP_ALIPAY:
+                payType= APP_ALIPAY; //支付类型-支付宝-app
+                appScheme = "";
+                type = "app";
+                method = PayConstants.BF_METHOD_TRADE_APP;
+                break;
+        }
+        String url = PayConstants.BF_HOST;
+//        Map<String,Object> publicParam = init(paymentRequestDto.getAppid(),method);
+        Map<String,Object> publicParam = init(bfPayConfig,method);
+        /**
+         * 业务请求参数
+         */
+        String msg = String.valueOf(paymentRequestDto.getBody());
+        msg = Base64Util.subStringByBytes(msg,80).replaceAll(regSpecial," ")+"...";
+        JSONObject body = new JSONObject();
+//		body.put("subMerchantNo",bfPayConfig.getSubMerchantNo());//门店编号
+        body.put("transNo",paymentRequestDto.getOrderNo());//商户订单号
+        body.put("payType",payType); //支付类型
+        body.put("orderAmt",paymentRequestDto.getTotalAmount().multiply(new BigDecimal(100)).intValue());        //交易金额
+        body.put("goodsInfo",msg);//商品信息摘要
+//        body.put("returnUrl","https://m2-dev.hobbystocks.cn/api/bf/paymentBack");//后台回调地址
+        body.put("returnUrl",bfPayConfig.getPayNotifyUrl());//后台回调地址
+        body.put("requestDate", DateFormatUtils.format(new Date(), "yyyyMMddHHmmss"));//请求时间
+        body.put("pageUrl","");//前台跳转地址
+//        body.put("pageUrl",bfPayConfig.getPageUrl());//前台跳转地址
+        if("main".equals(type))body.put("reusePay",reusePay);//是否支持重复扫码,默认是
+        body.put("extend",paymentRequestDto.getPayWay());//原样返回字段
+        JSONObject extendmemo = new JSONObject();
+//        extendmemo.put("paylimit","balance");//限制卡类型
+        String expireTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,paymentRequestDto.getExpireTime());
+        extendmemo.put("timeExpire", expireTime); //交易结束时间
+        //分账域,分账时必填
+//		String shareInfo = "100000178,1";
+//		extendmemo.put("shareInfo",shareInfo);
+        extendmemo.put("spbillCreateIp",ipAddr); //终端用户IP
+//        extendmemo.put("spbillCreateIp",paymentRequestDto.getCreateip()); //终端用户IP
+        extendmemo.put("longitude","116.397128");//经度
+        extendmemo.put("latitude","39.916527");//纬度
+        //以下银联需要上送
+//        extendmemo.put("areaInfo","");
+//        extendmemo.put("appVersion","");
+//        extendmemo.put("deviceType","");
+//        extendmemo.put("deviceNo","");
+        body.put("memo", extendmemo.toJSONString());
+        publicParam.put("signContent",body.toJSONString());
+        try {
+//            String sign = initSignStr(paymentRequestDto.getAppid(),method, body.toJSONString());
+            String sign = initSignStr(bfPayConfig,method, body.toJSONString());
+            publicParam.put("sign",sign);
+            log.info(" 请求参数: {}",publicParam);
+            String resp = HttpUtils.httpsRequest(url , "POST", BeanUtil.map2str(publicParam), null);
+            log.info("响应] 响应内容:{}",resp);
+            Map<String,Object> respMap = (Map<String, Object>) JSONObject.parseObject(resp,Map.class);
+//            if(verify(paymentRequestDto.getAppid(),respMap)){
+            if(verify(bfPayConfig,respMap)){
+                String resResult =  respMap.get("result").toString();
+                Map<String,String> result = (Map<String, String>) JSONObject.parseObject(resResult,Map.class);
+                log.info("解析结果:{}",result);
+                if(result.get("orderStatus").toString().equals("SUCCESS")){
+                    log.info("[交易结果]交易成功,成功金额:"+result.get("orderAmt").toString()+"分。");
+                    Map<String ,String > data = new HashMap<>();
+                    data.put("orderNo",paymentRequestDto.getOrderNo());
+                    data.put("url",appScheme+result.get("qrCode"));
+                    resultMap.put("data",data);
+                    return resultMap;
+                } else if(result.get("orderStatus").toString().equals("INIT")){
+                    log.info("[交易结果]交易未成功,"+result.get("respMsg").toString());
+                    Map<String ,String > data = new HashMap<>();
+                    data.put("orderNo",paymentRequestDto.getOrderNo());
+                    data.put("url",appScheme+result.get("qrCode"));
+                    resultMap.put("data",data);
+                    return resultMap;
+                }else {
+                    log.info("[交易结果]交易未成功,"+result.get("respMsg").toString());
+                    return ResultMap.error(Integer.parseInt(result.get("respCode")),(String) result.get("respMsg"));
+                }
+            }
+            else{
+                log.info("验签失败");
+                return ResultMap.error(-1,"验签失败!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+    @Override
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        String orderNo = paymentRequestDto.getOrderNo();
+        String payWay = paymentRequestDto.getPayWay();
+        BfPayConfig bfPayConfig = (BfPayConfig) paymentRequestDto.getPayConfigByClass(BfPayConfig.class);
+
+        String method = PayConstants.BF_METHOD_QUERY_MAIN;
+        String url = PayConstants.BF_HOST;
+//        Map<String,Object> publicParam = init(appid,method);
+        Map<String,Object> publicParam = init(bfPayConfig,method);
+        JSONObject body = new JSONObject();
+        body.put("transNo",orderNo);
+        body.put("queryType","2");//查询类型 默认:2
+        log.info("[请求]业务请求参数:{}",body.toJSONString());
+        publicParam.put("signContent",body.toJSONString());
+        try {
+//            String sign = initSignStr(appid,method, body.toJSONString());
+            String sign = initSignStr(bfPayConfig,method, body.toJSONString());
+            publicParam.put("sign",sign);
+            log.info(" 请求参数: {}",publicParam);
+            String resp = HttpUtils.httpsRequest(url , "POST", BeanUtil.map2str(publicParam), null);
+            log.info("响应] 响应内容:{}",resp);
+            Map<String,Object> respMap = (Map<String, Object>) JSONObject.parseObject(resp,Map.class);
+//            if(verify(appid,respMap)){
+            if(verify(bfPayConfig,respMap)){
+                String resResult =  respMap.get("result").toString();
+                Map<String,String> result = (Map<String, String>) JSONObject.parseObject(resResult,Map.class);
+                log.info("解析结果:{}",result);
+                paymentInfoResponseDto.setOrderNo(orderNo);
+                paymentInfoResponseDto.setPayWay(payWay);
+                paymentInfoResponseDto.setPaymentNo(StringUtils.isNotEmpty(result.get("tradeNo")) ? result.get("tradeNo") : null);
+                String orderAmt = StringUtils.isNotEmpty(result.get("orderAmt")) ? result.get("orderAmt") : "0";
+                paymentInfoResponseDto.setPaymentPrice(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                paymentInfoResponseDto.setActualPayment(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                Date finishedDate =StringUtils.isNotEmpty(result.get("finishedDate")) ? DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, result.get("finishedDate")) : null;
+                paymentInfoResponseDto.setPaymentSuccessTime(finishedDate);
+                if(StringUtils.isNotEmpty(result.get("orderStatus")) && result.get("orderStatus").equals("SUCCESS")){
+                    log.info("[查询结果]交易成功,金额:"+result.get("orderAmt").toString()+"分。");
+                    paymentInfoResponseDto.setSuccess(true);
+                    return paymentInfoResponseDto;
+                } else {
+                    log.info("[查询结果]交易未成功,"+result.get("respMsg").toString());
+                    return PaymentInfoResponseDto.error(Integer.valueOf(result.get("respCode")),(String) result.get("respMsg"));
+                }
+            }
+            else{
+                log.info("验签失败");
+                return PaymentInfoResponseDto.error(-1,"验签失败!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return PaymentInfoResponseDto.error(-1,"签名生成异常!");
+        }
+    }
+
+    @Override
+    public ResultMap refund(RefundRequestDto refundRequestDto){
+        String method = PayConstants.BF_METHOD_REFUND_MAIN;
+        String url = PayConstants.BF_HOST;
+        BfPayConfig bfPayConfig = (BfPayConfig) refundRequestDto.getPayConfigByClass(BfPayConfig.class);
+        String orderNo = refundRequestDto.getOrderNo();
+        BigDecimal orderPrice = refundRequestDto.getOrderPrice();
+        BigDecimal refundPrice = refundRequestDto.getRefundAmount();
+        String refundMsg = refundRequestDto.getRefundMsg();
+
+        Map<String,Object> publicParam = init(bfPayConfig,method);
+        JSONObject body = new JSONObject();
+        String refundNo = RandomUtil.getRandom(RandomUtil.REFUND_NO);
+        body.put("transNo",refundNo);//商户订单号
+        body.put("refundType","2");//退款类型
+        body.put("origTransNo",orderNo);//原商户订单号
+        body.put("origOrderAmt",orderPrice.multiply(new BigDecimal(100)).intValue());//原交易金额 单位: 分
+        body.put("orderAmt", refundPrice.multiply(new BigDecimal(100)).intValue());//退款金额 单位: 分
+        body.put("requestDate",DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS,new Date()));//交易日期
+        body.put("refundReason",refundMsg); //退款原因
+//        String returnUrl = "https://www.merchant.com"; //回调地址
+        body.put("returnUrl",bfPayConfig.getRefundNotifyUrl());
+        body.put("extend",refundRequestDto.getPayWay()); //扩展字段
+        publicParam.put("signContent",body.toJSONString());
+        try {
+            String sign = initSignStr(bfPayConfig,method, body.toJSONString());
+            publicParam.put("sign",sign);
+            log.info(" 请求参数: {}",publicParam);
+            String resp = HttpUtils.httpsRequest(url , "POST", BeanUtil.map2str(publicParam), null);
+            log.info("响应] 响应内容:{}",resp);
+            Map<String,Object> respMap = (Map<String, Object>) JSONObject.parseObject(resp,Map.class);
+            if(verify(bfPayConfig,respMap)){
+                String resResult =  respMap.get("result").toString();
+                Map<String,String> result = (Map<String, String>) JSONObject.parseObject(resResult,Map.class);
+                log.info("解析结果:{}",result);
+                if(result.get("orderStatus").equals("SUCCESS") || result.get("orderStatus").equals("PROCESSING")){
+                    log.info("[申请退款结果]交易成功,金额:"+result.get("orderAmt")+"分。");
+                    Map<String, String> stringStringMap = new HashMap<>();
+                    stringStringMap.put("out_refund_no", refundNo);
+                    stringStringMap.put("refund_id", result.get("tradeNo"));
+                    stringStringMap.put("refund_fee", result.get("orderAmt"));
+                    stringStringMap.put("fund_change", "Y");
+                    stringStringMap.put("finishedDate", result.get("finishedDate"));
+                    return ResultMap.ok(result.get("respMsg"))
+                            .put("data",stringStringMap)
+                            ;
+                } else {
+                    log.info("[申请退款结果]交易未成功,"+result.get("respMsg").toString());
+                    return ResultMap.error(Integer.parseInt(result.get("respCode")),(String) result.get("respMsg"));
+                }
+            }
+            else{
+                log.info("验签失败");
+                return ResultMap.error(-1,"验签失败!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+    @Override
+    public ResultMap refundQuery(RefundRequestDto refundRequestDto){
+        String method = PayConstants.BF_METHOD_REFUND_QUERY_MAIN;
+        String url = PayConstants.BF_HOST;
+        BfPayConfig bfPayConfig = (BfPayConfig) refundRequestDto.getPayConfigByClass(BfPayConfig.class);
+        String outRefundNo= refundRequestDto.getRefundNo();
+        Map<String,Object> publicParam = init(bfPayConfig,method);
+        JSONObject body = new JSONObject();
+        body.put("transNo",outRefundNo);//商户订单号
+        publicParam.put("signContent",body.toJSONString());
+        try {
+            String sign = initSignStr(bfPayConfig,method, body.toJSONString());
+            publicParam.put("sign",sign);
+            log.info(" 请求参数: {}",publicParam);
+            String resp = HttpUtils.httpsRequest(url , "POST", BeanUtil.map2str(publicParam), null);
+            log.info("响应] 响应内容:{}",resp);
+            Map<String,Object> respMap = (Map<String, Object>) JSONObject.parseObject(resp,Map.class);
+            if(verify(bfPayConfig,respMap)){
+                String resResult =  respMap.get("result").toString();
+                Map<String,String> result = (Map<String, String>) JSONObject.parseObject(resResult,Map.class);
+                log.info("解析结果:{}",result);
+                if(result.get("orderStatus").equals("SUCCESS")){
+                    log.info("[申请退款结果]交易成功,金额:"+result.get("orderAmt")+"分。");
+                    Map<String, String> stringStringMap = new HashMap<>();
+                    stringStringMap.put("out_refund_no", outRefundNo);
+                    stringStringMap.put("refund_id", result.get("tradeNo"));
+                    stringStringMap.put("refund_fee", result.get("orderAmt"));
+                    stringStringMap.put("fund_change", "Y");
+                    stringStringMap.put("finishedDate", result.get("finishedDate"));
+                    return ResultMap.ok()
+                            .put("data",stringStringMap)
+                            ;
+                }else {
+                    log.info("[申请退款结果]交易未成功,"+result.get("respMsg").toString());
+                    return ResultMap.error(Integer.parseInt(result.get("respCode")),(String) result.get("respMsg"));
+                }
+            }
+            else{
+                log.info("验签失败");
+                return ResultMap.error(-1,"验签失败!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+
+}

+ 829 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/BofooAgreementServiceImpl.java

@@ -0,0 +1,829 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.common.utils.DateUtils;
+import com.tzy.common.utils.LogSyncUtil;
+import com.tzy.common.utils.StringUtils;
+import com.tzy.framework.pay.config.BaoFooPayConfig;
+import com.tzy.framework.pay.dto.*;
+import com.tzy.framework.pay.service.BofooAgreementService;
+import com.tzy.framework.pay.util.FormatUtil;
+import com.tzy.framework.pay.util.bofoo.bank.HttpUtil;
+import com.tzy.framework.pay.util.bofoo.bank.SecurityUtil;
+import com.tzy.framework.pay.util.bofoo.bank.SignatureUtils;
+import com.tzy.framework.pay.util.bofoo.rsa.RsaCodingUtil;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+@Slf4j
+@Service
+public class BofooAgreementServiceImpl implements BofooAgreementService {
+
+    @Autowired
+    private BaoFooPayConfig baoFooPayConfig ;
+    @Value("${tzy.app-version:dev}")
+    private String appversion;
+
+    private String serverUrl_box = "https://vgw.baofoo.com/cutpayment/protocol/backTransRequest";
+    private String serverUrl = "https://public.baofoo.com/cutpayment/protocol/backTransRequest";
+
+    public static final String URL = "https://juhe.baofoo.com/api";
+
+    public static void main(String[] args) {
+        BofooAgreementServiceImpl service = new BofooAgreementServiceImpl();
+        service.appversion = "prod";
+        service.baoFooPayConfig = new BaoFooPayConfig();
+        Integer userId = 1;
+        String bankNo = "6217001180060827147";
+        String realName = "邓力";
+        String cardNo = "360902200005081816";
+        String phone = "15679535223";
+        BankInfo bankInfo = new BankInfo(userId,"101",bankNo,realName,cardNo,phone);
+        //
+//        bankInfo = service.ReadySign(bankInfo);
+        log.info(" 预绑定{} ",bankInfo);
+        //
+        String uniqueCode = "202304242027493083040";
+        String phoneCode = "134132";
+//        service.ConfirmSign(bankInfo.setConfirm(uniqueCode,phoneCode));
+        //
+        String protocol_no ="1202304261110285241954482970";
+        //"1202304241415275791952576173"-liu
+        bankInfo = bankInfo.setProtocolNo(protocol_no);
+//        service.QueryBind(bankInfo.setProtocolNo(protocol_no));
+        PaymentRequestDto payRequestBody = new PaymentRequestDto();
+        payRequestBody.setBody("精美卡片");
+        payRequestBody.setTotalAmount(new BigDecimal(1));
+//        PaymentUserInfo paymentUserInfo = new PaymentUserInfo("01","刘XX","15900745701","2900","2907","陕西南路285号","精美卡片","008","1","1");
+        PaymentUserInfo paymentUserInfo = new PaymentUserInfo("01","","","","","","精美卡片","008","1","1");
+        payRequestBody.setPaymentUserInfo(paymentUserInfo);
+        payRequestBody.setBankInfo(bankInfo);
+        //
+//        service.SinglePay(payRequestBody);
+//        System.out.println(service.ReadyPay(payRequestBody)); //预支付
+        String payNo = "20230425144027013031129578633693";
+        payRequestBody.setPhoneCode("592726");
+        payRequestBody.setMerOrderId(payNo);
+//        service.ConfirmPay(payRequestBody);//确认支付
+        //GU202304251440269438
+        String orderCode = "GU202304251440261117";
+        //GU202304241534421135
+        //GU202304251440261117
+        payRequestBody.setOrderNo(orderCode);
+        service.QueryOrder(payRequestBody);//查询订单
+        RefundRequestDto refundRequestDto = new RefundRequestDto();
+        refundRequestDto.setTradeNo(orderCode);
+        refundRequestDto.setRefundMsg("退款测试");
+        refundRequestDto.setRefundAmount(new BigDecimal(1));
+        refundRequestDto.setTotalAmount(new BigDecimal(1));
+//        System.out.println(service.OrderRefund(refundRequestDto));//退款
+        refundRequestDto.setRefundNo("RN202304251457171831");
+//        service.queryRefund(refundRequestDto);//退款查询
+
+    }
+
+    /**
+     * 协议支付-预绑卡接口
+     */
+    public BankInfo ReadySign(BankInfo bankInfo){
+        try {
+            ResultMap resultMap = initData("ReadySign", bankInfo);
+            if(0 != (Integer) resultMap.get("code")){
+                return BankInfo.error( (String) resultMap.get("msg"));
+            }
+            Map<String, String> ReturnData = (Map<String, String>) resultMap.get("data");
+            String RAesKey = (String) resultMap.get("RAesKey");
+            if(ReturnData.get("resp_code").toString().equals("S")){
+                String unique_code = SecurityUtil.Base64Decode(SecurityUtil.AesDecrypt(ReturnData.get("unique_code"), RAesKey));
+                log.info("唯一码:" + unique_code);
+                bankInfo = bankInfo.success();
+                bankInfo.setUniqueCode(unique_code);
+                return bankInfo
+                        ;
+            }else if(ReturnData.get("resp_code").toString().equals("I")){
+                log.info("处理中!");
+                return BankInfo.error( "处理中!");
+            }else if(ReturnData.get("resp_code").toString().equals("F")){
+                log.info("失败!");
+                return BankInfo.error( ReturnData.get("biz_resp_msg"));
+            }else{
+                return BankInfo.error( (String) resultMap.get("msg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return BankInfo.error("绑卡失败");
+    }
+    /**
+     * 确认绑卡(协议支付)
+     */
+    public BankInfo ConfirmSign(BankInfo bankInfo){
+        try {
+            ResultMap resultMap = initData("ConfirmSign", bankInfo);
+            if(0 != (Integer) resultMap.get("code")){
+                return BankInfo.error( (String) resultMap.get("msg"));
+            }
+            Map<String, String> ReturnData = (Map<String, String>) resultMap.get("data");
+            String RAesKey = (String) resultMap.get("RAesKey");
+            if(ReturnData.get("resp_code").toString().equals("S")){
+                String protocol_no = SecurityUtil.Base64Decode(SecurityUtil.AesDecrypt(ReturnData.get("protocol_no"),RAesKey));
+                log.info("签约协议号:" + protocol_no);
+                bankInfo = bankInfo.success();
+                bankInfo.setProtocolNo(protocol_no);
+                return bankInfo
+                        ;
+            }else if(ReturnData.get("resp_code").toString().equals("I")){
+                log.info("处理中!");
+                return BankInfo.error( "处理中!");
+            }else if(ReturnData.get("resp_code").toString().equals("F")){
+                log.info("失败!");
+                return BankInfo.error( ReturnData.get("biz_resp_msg"));
+            }else{
+                return BankInfo.error( (String) resultMap.get("msg"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return BankInfo.error("绑卡失败");
+    }
+
+    /**
+     * 查询绑定的银行卡
+     * @param bankInfo
+     */
+    public BankInfo QueryBind(BankInfo bankInfo){
+        try{
+            ResultMap resultMap = initData("QueryBind", bankInfo);
+            if(0 != (Integer) resultMap.get("code")){
+                return BankInfo.error( (String) resultMap.get("msg"));
+            }
+            Map<String, String> ReturnData = (Map<String, String>) resultMap.get("data");
+            String RAesKey = (String) resultMap.get("RAesKey");
+            if(ReturnData.get("resp_code").toString().equals("S")){
+                String protocols = SecurityUtil.Base64Decode(SecurityUtil.AesDecrypt(ReturnData.get("protocols"),RAesKey));
+                log.info("协议列表:" + protocols);
+                bankInfo = bankInfo.success();
+                bankInfo.setProtocols(protocols);
+                return bankInfo
+                        ;
+            }else if(ReturnData.get("resp_code").toString().equals("I")){
+                log.info("处理中!");
+                return BankInfo.error( "处理中!");
+            }else if(ReturnData.get("resp_code").toString().equals("F")){
+                log.info("失败!");
+                return BankInfo.error( ReturnData.get("biz_resp_msg"));
+            }else{
+                return BankInfo.error( (String) resultMap.get("msg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return BankInfo.error("查询失败");
+    }
+
+    /**
+     * 解绑
+     * @param bankInfo
+     */
+    public BankInfo unBind(BankInfo bankInfo){
+        try{
+            ResultMap resultMap = initData("unBind", bankInfo);
+            if(0 != (Integer) resultMap.get("code")){
+                return BankInfo.error( (String) resultMap.get("msg"));
+            }
+            Map<String, String> ReturnData = (Map<String, String>) resultMap.get("data");
+            if(ReturnData.get("resp_code").toString().equals("S")){
+                log.info("解绑成功!");
+                bankInfo = bankInfo.success("解绑成功!");
+                return bankInfo
+                        ;
+            }else if(ReturnData.get("resp_code").toString().equals("I")){
+                log.info("处理中!");
+                return BankInfo.error( "处理中!");
+            }else if(ReturnData.get("resp_code").toString().equals("F")){
+                log.info("解绑失败!");
+                BankInfo retBankInfo = BankInfo.error(ReturnData.get("biz_resp_msg"));
+                if(Objects.equals(ReturnData.get("biz_resp_code"), "BF00134")){
+                    //绑定关系不存在
+                    retBankInfo.setCode(1404);
+                }
+                return retBankInfo;
+            }else{
+                return BankInfo.error( (String) resultMap.get("msg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return BankInfo.error( "解绑失败!");
+    }
+
+    /**
+     * 免密支付
+     * @param payRequestBody
+     * @return
+     */
+    public ResultMap SinglePay(PaymentRequestDto payRequestBody){
+        try{
+            ResultMap resultMap = paymentOrder("SinglePay", payRequestBody);
+            if(0 != (Integer) resultMap.get("code")){
+                return resultMap;
+            }
+            Map<String, String> ReturnData = (Map<String, String>) resultMap.get("data");
+            log.info(" 免密支付 返回结果》》{} ",ReturnData);
+            if(ReturnData.get("resp_code").toString().equals("S")){
+                if(!ReturnData.containsKey("dgtl_envlp")){
+                    throw new Exception("缺少dgtl_envlp参数!");
+                }
+                if(!ReturnData.containsKey("unique_code")){
+                    throw new Exception("缺少unique_code参数!");
+                }
+                String pfxpath = ReturnData.get("pfxpath");
+                String pfxpwd = ReturnData.get("pfxpwd");
+                String RDgtlEnvlp = SecurityUtil.Base64Decode(RsaCodingUtil.decryptByPriPfxFile(ReturnData.get("dgtl_envlp"), pfxpath, pfxpwd));
+                log.info("返回数字信封:"+RDgtlEnvlp);
+                String RAesKey=FormatUtil.getAesKey(RDgtlEnvlp);//获取返回的AESkey
+                log.info("返回的AESkey:"+RAesKey);
+                String unique_code = SecurityUtil.Base64Decode(SecurityUtil.AesDecrypt(ReturnData.get("unique_code"), RAesKey));
+                log.info("预支付唯一码:"+unique_code);
+                return resultMap
+                        .put("unique_code",unique_code)
+                        ;
+            }else{
+                log.info("失败!");
+                return ResultMap.error(ReturnData.get("msg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return ResultMap.error("免密支付失败!");
+    }
+
+    /**
+     * 预支付
+     * @param payRequestBody
+     */
+    public ResultMap ReadyPay(PaymentRequestDto payRequestBody){
+        try{
+            ResultMap resultMap = paymentOrder("ReadyPay", payRequestBody);
+            if(0 != (Integer) resultMap.get("code")){
+                return resultMap;
+            }
+            Map<String, String> ReturnData = (Map<String, String>) resultMap.get("data");
+            log.info(" 预支付 返回结果》》{} ",ReturnData);
+            if(ReturnData.get("resp_code").toString().equals("S")){
+                if(!ReturnData.containsKey("dgtl_envlp")){
+                    throw new Exception("缺少dgtl_envlp参数!");
+                }
+                if(!ReturnData.containsKey("unique_code")){
+                    throw new Exception("缺少unique_code参数!");
+                }
+                String pfxpath = String.valueOf(resultMap.get("pfxpath"));
+                String pfxpwd = String.valueOf(resultMap.get("pfxpwd"));
+                String RDgtlEnvlp = SecurityUtil.Base64Decode(RsaCodingUtil.decryptByPriPfxFile(ReturnData.get("dgtl_envlp"), pfxpath, pfxpwd));
+                log.info("返回数字信封:"+RDgtlEnvlp);
+                String RAesKey=FormatUtil.getAesKey(RDgtlEnvlp);//获取返回的AESkey
+                log.info("返回的AESkey:"+RAesKey);
+                String unique_code = SecurityUtil.Base64Decode(SecurityUtil.AesDecrypt(ReturnData.get("unique_code"), RAesKey));
+                log.info("预支付唯一码:"+unique_code);
+                String trade_no = String.valueOf(resultMap.get("trade_no"));
+                return resultMap
+                        .put("unique_code",unique_code)
+                        .put("trade_no",trade_no)
+                        ;
+            }else{
+                log.info("失败!");
+                String msg = ReturnData.get("msg");
+                try{
+                    msg = ReturnData.get("biz_resp_msg");
+                }catch (Exception e ){
+                }
+                return ResultMap.error(msg);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return ResultMap.error("预支付失败!");
+    }
+
+    /**
+     * 确认支付
+     * @param payRequestBody
+     */
+    public ResultMap ConfirmPay(PaymentRequestDto payRequestBody){
+        try {
+            ResultMap resultMap = paymentOrder("ConfirmPay", payRequestBody);
+            if(0 != (Integer) resultMap.get("code")){
+                return resultMap;
+            }
+            Map<String, String> ReturnData = (Map<String, String>) resultMap.get("data");
+            log.info(" 确认支付 返回结果》》{} ",ReturnData);
+            if(ReturnData.get("resp_code").toString().equals("S")){
+                return resultMap
+                        .put("order_id",ReturnData.get("order_id"))
+                        .put("trans_id",ReturnData.get("trans_id"))
+                        .put("succ_time",ReturnData.get("succ_time"))
+                        .put("succ_amt",ReturnData.get("succ_amt"))
+                        ;
+            }else if(ReturnData.get("resp_code").toString().equals("I")){
+                log.info("处理中!");
+                return ResultMap.error("处理中!");
+            }else if(ReturnData.get("resp_code").toString().equals("F")){
+                log.info("失败!");
+                return ResultMap.error(ReturnData.get("biz_resp_msg"));
+            }else{
+                return ResultMap.error("反回异常!");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return ResultMap.error("支付失败!");
+    }
+
+    /**
+     * 查询
+     * @param payRequestBody
+     */
+    public PaymentInfoResponseDto QueryOrder(PaymentRequestDto payRequestBody){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        try{
+            ResultMap resultMap = paymentOrder("QueryOrder", payRequestBody);
+            if(0 != (Integer) resultMap.get("code")){
+                return PaymentInfoResponseDto.error(-1, String.valueOf(resultMap.get("msg")));
+            }
+            Map<String, String> ReturnData = (Map<String, String>) resultMap.get("data");
+            log.info(" 查询返回结果》》{} ",ReturnData);
+            if(ReturnData.get("resp_code").toString().equals("S")){
+                //下单成功
+                paymentInfoResponseDto.setOrderNo(payRequestBody.getOrderNo());
+                paymentInfoResponseDto.setPayWay(payRequestBody.getPayWay());
+                paymentInfoResponseDto.setPaymentNo(ReturnData.get("order_id"));
+                Integer orderAmt = StringUtils.isNotEmpty(ReturnData.get("succ_amt"))  ? Integer.valueOf(ReturnData.get("succ_amt")) : 0;
+                paymentInfoResponseDto.setPaymentPrice(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                paymentInfoResponseDto.setActualPayment(new BigDecimal(orderAmt).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_FLOOR));
+                Date finishedDate = StringUtils.isNotEmpty(ReturnData.get("succ_time")) ? DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, ReturnData.get("succ_time")) : null;
+                paymentInfoResponseDto.setPaymentSuccessTime(finishedDate);
+                paymentInfoResponseDto.setSuccess(true);
+                return paymentInfoResponseDto
+                        ;
+            }else if(ReturnData.get("resp_code").toString().equals("I")){
+                log.info("处理中!");
+                return PaymentInfoResponseDto.error(-1,"处理中!");
+            }else if(ReturnData.get("resp_code").toString().equals("F")){
+                log.info("失败!");
+                return PaymentInfoResponseDto.error(-1,ReturnData.get("biz_resp_msg"));
+            }else{
+                return PaymentInfoResponseDto.error(-1,"查询异常!");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return PaymentInfoResponseDto.error(-1,"查询失败!");
+    }
+
+    /**
+     * 退款
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap OrderRefund(RefundRequestDto refundRequestDto){
+        try {
+            baoFooPayConfig = initRefundConfig(refundRequestDto);
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+            String merId = baoFooPayConfig.getMid();
+            String terId = baoFooPayConfig.getTid();
+            String txnTime = getTxnTime();//报文发送日期时间
+            String originOutTradeNo = refundRequestDto.getOrderNo();//原支付订单商户订单号 [与原支付订单宝付交易号二选一比传]
+            String outTradeNo = RandomUtil.getRandomNew(RandomUtil.REFUND_NO);
+            String refundAmt = String.valueOf(refundRequestDto.getRefundAmount());//退款金额
+            Map<String,String> Headparm = new HashMap<String,String>();
+            Headparm.put("version", "4.0.0.0");//版本号
+            Headparm.put("terminal_id", terId);//终端号
+            Headparm.put("txn_type", "331");
+            Headparm.put("txn_sub_type", "09");
+            Headparm.put("member_id", merId);//商户号
+            Headparm.put("data_type", "json");//加密报文的数据类型(xml/json)
+            Headparm.put("risk_item", "");//风险控制
+            Map<String,String> ArrayData = new HashMap<String,String>();
+            ArrayData.put("txn_sub_type", Headparm.get("txn_sub_type"));
+            ArrayData.put("terminal_id", Headparm.get("terminal_id"));
+            ArrayData.put("member_id", Headparm.get("member_id"));
+            ArrayData.put("trans_id", originOutTradeNo);
+            ArrayData.put("refund_order_no", outTradeNo);//退款时商户端生成的订单号
+            ArrayData.put("refund_reason", refundRequestDto.getRefundMsg());
+            ArrayData.put("refund_amt", refundAmt);//退款金额
+            ArrayData.put("refund_time", txnTime);//退款发起时间
+            ArrayData.put("additional_info", "");
+            ArrayData.put("req_reserved", "");
+            ArrayData.put("trans_serial_no", outTradeNo);//退款流水号
+            ArrayData.put("notice_url", baoFooPayConfig.getRefundNotifyUrl());//退款成功后通知地址。
+            ArrayData.put("refund_type", "8");//1:网银、2:认证支付
+            String jsonString = JSONObject.toJSONString(ArrayData);
+            log.info("====请求明文:" + jsonString);
+            String base64str = SecurityUtil.Base64Encode(jsonString);
+            String data_content = RsaCodingUtil.encryptByPriPfxFile(base64str,pfxpath,pfxpwd);
+            log.info("====加密结果:"+data_content);
+            Headparm.put("data_content", data_content);
+            log.info("====请求表单:"+Headparm);
+            String ServerUrl = "https://public.baofoo.com/cutpayment/api/backTransRequest";
+            LogSyncUtil.logSync("宝付协议支付 退款,交易编号:{},请求参数:{}",originOutTradeNo,Headparm);
+            String PostString = HttpUtil.RequestForm( ServerUrl, Headparm);
+            LogSyncUtil.logSync("宝付协议支付 退款,交易编号:{},返回结果:{}",originOutTradeNo,PostString);
+//            String PostString  = HttpUtil.RequestForm(ServerUrl, Headparm);
+            log.info("====同步返回报文:"+PostString);
+            PostString = RsaCodingUtil.decryptByPubCerFile(PostString,cerpath);
+            PostString = SecurityUtil.Base64Decode(PostString);
+            log.info("====解密同步返回:"+PostString);
+            JSONObject jsonObject = JSONObject.parseObject(PostString);
+            if(jsonObject.get("resp_code").equals("0000")){
+                System.out.println("YES");
+                Map<String, String> stringStringMap = new HashMap<>();
+                stringStringMap.put("out_refund_no", outTradeNo);
+                stringStringMap.put("refund_id", jsonObject.getString("refund_business_no"));
+                stringStringMap.put("refund_fee", String.valueOf(jsonObject.getString("refund_amt")));
+                stringStringMap.put("fund_change", "Y");
+                return ResultMap.ok(jsonObject.getString("resp_msg"))
+                        .put("data", stringStringMap)
+                        ;
+            }else{
+                return ResultMap.error(-1,jsonObject.getString("resp_msg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+    /**
+     * 退款查询
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap queryRefund(RefundRequestDto refundRequestDto){
+        try{
+            baoFooPayConfig = initRefundConfig(refundRequestDto);
+            String MemberId = baoFooPayConfig.getMid();//商户号
+            String TerminalId = baoFooPayConfig.getTid();//终端号
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+            String outTradeNo = RandomUtil.getRandomNew(RandomUtil.REFUND_NO);
+            Map<String,String> Headparm = new HashMap<String,String>();
+            Headparm.put("version", "4.0.0.0");//版本号
+            Headparm.put("terminal_id", TerminalId);//终端号
+            Headparm.put("txn_type", "331");
+            Headparm.put("txn_sub_type", "10");
+            Headparm.put("member_id", MemberId);//商户号
+            Headparm.put("data_type", "json");//加密报文的数据类型(xml/json)
+            Map<String,String> ArrayData = new HashMap<String,String>();
+            ArrayData.put("txn_sub_type", Headparm.get("txn_sub_type"));
+            ArrayData.put("terminal_id", Headparm.get("terminal_id"));
+            ArrayData.put("member_id", Headparm.get("member_id"));
+            ArrayData.put("refund_order_no", refundRequestDto.getRefundNo());//商户退款时生成的订单号
+            ArrayData.put("trans_serial_no", outTradeNo);//退款流水号
+            ArrayData.put("additional_info", "");
+            ArrayData.put("req_reserved", "");
+            String jsonString = JSONObject.toJSONString(ArrayData);
+            log.info("====请求明文:"+jsonString);
+            String base64str = SecurityUtil.Base64Encode(jsonString);
+            String data_content = RsaCodingUtil.encryptByPriPfxFile(base64str,pfxpath,pfxpwd);
+            log.info("====加密结果:"+data_content);
+            Headparm.put("data_content", data_content);
+            log.info("====请求表单:"+Headparm.toString());
+            String ServerUrl = "https://public.baofoo.com/cutpayment/api/backTransRequest";
+//            String PostString = HttpUtil.RequestForm(ServerUrl, Headparm);
+            LogSyncUtil.logSync("宝付协议支付 退款查询,交易编号:{},请求参数:{}",refundRequestDto.getRefundNo(),Headparm);
+            String PostString = HttpUtil.RequestForm( ServerUrl, Headparm);
+            LogSyncUtil.logSync("宝付协议支付 退款查询,交易编号:{},返回结果:{}",refundRequestDto.getRefundNo(),PostString);
+            log.info("====同步返回报文:"+PostString);
+            PostString = RsaCodingUtil.decryptByPubCerFile(PostString,cerpath);
+            PostString = SecurityUtil.Base64Decode(PostString);
+            log.info("====解密同步返回:"+PostString);
+            JSONObject jsonObject = JSONObject.parseObject(PostString);
+            if(jsonObject.get("resp_code").equals("0000")){
+                System.out.println("YES");
+                Map<String, String> stringStringMap = new HashMap<>();
+                stringStringMap.put("out_refund_no", outTradeNo);
+                stringStringMap.put("refund_id", jsonObject.getString("refund_business_no"));
+                stringStringMap.put("refund_fee", String.valueOf(jsonObject.getString("refund_amt")));
+                stringStringMap.put("fund_change", "Y");
+                return ResultMap.ok(jsonObject.getString("resp_msg"))
+                        .put("data", stringStringMap)
+                        ;
+            }else{
+                return ResultMap.error(-1,jsonObject.getString("resp_msg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultMap.error(-1,"签名生成异常!");
+        }
+    }
+
+    /**
+     * 绑卡统一方法
+     * @param type
+     * @param bankInfo
+     * @return
+     */
+    private ResultMap initData(String type,BankInfo bankInfo){
+        String send_time = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS);//报文发送日期时间
+        BaoFooPayConfig baoFooPayConfig = initConfig(bankInfo);
+        String MemberId = baoFooPayConfig.getMid();//商户号
+        String TerminalId = baoFooPayConfig.getTid();//终端号
+        String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+        String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+        String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+        String AesKey = RandomUtil.getRandomNew("",16);//商户自定义(可随机生成  商户自定义(AES key长度为=16位))
+        String dgtl_envlp = "01|" + AesKey;//使用接收方的公钥加密后的对称密钥,并做Base64转码,明文01|对称密钥,01代表AES[密码商户自定义]
+        try{
+            log.info("密码dgtl_envlp:" + dgtl_envlp);
+            dgtl_envlp = RsaCodingUtil.encryptByPubCerFile(SecurityUtil.Base64Encode(dgtl_envlp), cerpath);//公钥加密
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        Map<String, String> DateArry = new TreeMap<String, String>();
+        DateArry.put("send_time", send_time);
+        DateArry.put("msg_id", RandomUtil.getRandomNew(RandomUtil.MSGID));//报文流水号
+        DateArry.put("version", "4.0.0.0");
+        DateArry.put("terminal_id", TerminalId);
+        DateArry.put("member_id", MemberId);
+        DateArry.put("dgtl_envlp", dgtl_envlp);
+        try {
+            switch (type){
+                case "ReadySign": //预绑定
+                        String Cardinfo = bankInfo.getFormat();
+                        Cardinfo = SecurityUtil.AesEncrypt(SecurityUtil.Base64Encode(Cardinfo), AesKey);//先BASE64后进行AES加密
+                        log.info("AES结果:" + Cardinfo);
+                        DateArry.put("txn_type", "01");//交易类型
+                        DateArry.put("user_id", String.valueOf(bankInfo.getUserId()));
+                        DateArry.put("card_type", bankInfo.getBankType());//卡类型  101	借记卡,102 信用卡
+                        DateArry.put("id_card_type", "01");//证件类型
+                        DateArry.put("acc_info", Cardinfo);
+                    break;
+                case "ConfirmSign": //确认绑卡(协议支付)
+                        String SMSStr = bankInfo.getPhoneCode();//短信验证码,测试环境随机6位数;生产环境验证码预绑卡成功后发到用户手机。确认绑卡时回传。
+                        String UniqueCode = bankInfo.getUniqueCode() + "|" + SMSStr;//预签约唯一码(预绑卡返回的值)[格式:预签约唯一码|短信验证码]
+                        log.info("预签约唯一码:" + UniqueCode);
+                        UniqueCode = SecurityUtil.AesEncrypt(SecurityUtil.Base64Encode(UniqueCode), AesKey);//先BASE64后进行AES加密
+                        log.info("AES结果:" + UniqueCode);
+                        DateArry.put("txn_type", "02");//交易类型
+                        DateArry.put("unique_code", UniqueCode);//预签约唯一码
+                    break;
+                case "QueryBind": //查询绑定
+                        DateArry.put("txn_type", "03");//交易类型
+                        String AccNo = bankInfo.getBankNo();//查询银行卡号
+                        AccNo = SecurityUtil.AesEncrypt(SecurityUtil.Base64Encode(AccNo), AesKey);//先BASE64后进行AES加密
+                        log.info("银行卡号AES结果:"+AccNo);
+                        DateArry.put("user_id", String.valueOf(bankInfo.getUserId()));//用户在平台的唯一ID
+                        DateArry.put("acc_no", AccNo);//银行卡号密文[与user_id必须其中一个有值]
+                    break;
+                case "unBind":
+                        DateArry.put("txn_type", "04");//交易类型
+                        String ProtocolNo = bankInfo.getProtocolNo();//签约协议号(确认绑卡返回)
+                        log.info("签约协议号:"+ProtocolNo);
+                        ProtocolNo = SecurityUtil.AesEncrypt(SecurityUtil.Base64Encode(ProtocolNo), AesKey);//先BASE64后进行AES加密
+                        log.info("签约协议号AES结果:"+ProtocolNo);
+                        DateArry.put("user_id", String.valueOf(bankInfo.getUserId()));//用户在商户平台唯一ID (和绑卡时要一致)
+                        DateArry.put("protocol_no", ProtocolNo);//签约协议号(密文)
+                    break;
+                default:
+                    return ResultMap.error("未知操作[bank]");
+            }
+            String SignVStr = FormatUtil.coverMap2String(DateArry);
+            log.info("SHA-1摘要字串:" + SignVStr);
+            String signature = SecurityUtil.sha1X16(SignVStr, "UTF-8");//签名
+            log.info("SHA-1摘要结果:" + signature);
+            String Sign = SignatureUtils.encryptByRSA(signature, pfxpath, pfxpwd);
+
+            log.info("RSA签名结果:" + Sign);
+            DateArry.put("signature", Sign);//签名域
+            LogSyncUtil.logSync("宝付协议支付【{}】 查询,交易编号:{},请求参数:{}",type,bankInfo.getUserId(),DateArry);
+            String PostString = HttpUtil.RequestForm( getUrl(), DateArry);
+            LogSyncUtil.logSync("宝付协议支付【{}】 查询,交易编号:{},返回结果:{}",type,bankInfo.getUserId(),PostString);
+            log.info("请求返回:" + PostString);
+            Map<String, String> ReturnData = FormatUtil.getParm(PostString);
+            if (!ReturnData.containsKey("signature")) {
+                return ResultMap.error("缺少验签参数!");
+            }
+            String RSign = ReturnData.get("signature");
+            log.info("返回的验签值:" + RSign);
+            ReturnData.remove("signature");//需要删除签名字段
+            String RSignVStr = FormatUtil.coverMap2String(ReturnData);
+            log.info("返回SHA-1摘要字串:" + RSignVStr);
+            String RSignature = SecurityUtil.sha1X16(RSignVStr, "UTF-8");//签名
+            log.info("返回SHA-1摘要结果:" + RSignature);
+            if (SignatureUtils.verifySignature(cerpath, RSignature, RSign)) {
+                log.info("验签成功 Yes" );//验签成功
+                String RAesKey = "";
+                if (ReturnData.containsKey("dgtl_envlp")) {
+                    try {
+                        String RDgtlEnvlp = SecurityUtil.Base64Decode(RsaCodingUtil.decryptByPriPfxFile(ReturnData.get("dgtl_envlp"), pfxpath, pfxpwd));
+                        log.info("返回数字信封:" + RDgtlEnvlp);
+                        RAesKey = FormatUtil.getAesKey(RDgtlEnvlp);//获取返回的AESkey
+                        log.info("返回的AESkey:" + RAesKey);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+                return ResultMap.ok()
+                        .put("data",ReturnData)
+                        .put("RAesKey",RAesKey)
+                        ;
+            }else{
+                return ResultMap.error("验签失败");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(" 请求异常:{} ",e);
+            return ResultMap.error(""+e);
+        }
+    }
+
+    /**
+     * 支付方法
+     * @param type
+     * @param payRequestBody
+     * @return
+     */
+    private ResultMap paymentOrder(String type,PaymentRequestDto payRequestBody){
+        try {
+            String send_time = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS);//报文发送日期时间
+            baoFooPayConfig = initPaymentConfig(payRequestBody);
+            String MemberId = baoFooPayConfig.getMid();//商户号
+            String TerminalId = baoFooPayConfig.getTid();//终端号
+            String pfxpath = baoFooPayConfig.getPrivateKey();//商户私钥
+            String cerpath = baoFooPayConfig.getPublicKey();//宝付公钥
+            String pfxpwd = baoFooPayConfig.getPrivateKeyPwd();//私钥密码
+            String ReturnUrl= baoFooPayConfig.getAgreementpayNotifyUrl(); //异步通知地址
+            String AesKey = RandomUtil.getRandomNew("",16);//商户自定义(可随机生成  AES key长度为=16位)
+            String dgtl_envlp = "01|"+AesKey;//使用接收方的公钥加密后的对称密钥,并做Base64转码,明文01|对称密钥,01代表AES[密码商户自定义]
+            log.info("密码dgtl_envlp:"+dgtl_envlp);
+            String bas64 = SecurityUtil.Base64Encode(dgtl_envlp);
+            log.info("密码Base64:"+bas64);
+            dgtl_envlp = RsaCodingUtil.encryptByPubCerFile(bas64, cerpath);//公钥加密
+            Map<String,String> DateArry = new TreeMap<String,String>();
+            DateArry.put("send_time", send_time);
+            DateArry.put("msg_id", RandomUtil.getRandomNew(RandomUtil.MSGID));//报文流水号
+            DateArry.put("version", "4.0.0.0");
+            DateArry.put("terminal_id", TerminalId);
+            DateArry.put("member_id", MemberId);
+            String trade_no = "";//商户订单号
+            String ProtocolNo = "";//签约协议号(确认绑卡返回)
+            /**--------风控基础参数-------------**/
+            Map<String,String> RiskItem = new HashMap<String,String>();
+            String price = null == payRequestBody.getTotalAmount() ? BigDecimal.ZERO.toString(): String.valueOf(payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).intValue());
+            switch (type){
+                case "SinglePay": //免密支付
+                    DateArry.put("dgtl_envlp", dgtl_envlp);
+                    DateArry.put("user_id", "");//用户在商户平台唯一ID (和绑卡时要一致)
+                    DateArry.put("txn_type", "08");//交易类型(参看:文档中《交易类型枚举》)
+                    trade_no = RandomUtil.getRandomNew(RandomUtil.GROUP_USER_ORDER);//商户订单号
+                    DateArry.put("trans_id", trade_no);
+                    ProtocolNo = payRequestBody.getBankInfo().getProtocolNo();//签约协议号(确认绑卡返回)
+                    ProtocolNo = SecurityUtil.AesEncrypt(SecurityUtil.Base64Encode(ProtocolNo), AesKey);//先BASE64后进行AES加密
+                    log.info("签约协议号AES结果:"+ProtocolNo);
+                    DateArry.put("protocol_no", ProtocolNo);//签约协议号(密文)
+                    DateArry.put("txn_amt", price);//交易金额 [单位:分  例:1元则提交100],此处注意数据类型的转转,建议使用BigDecimal类弄进行转换为字串
+                    extracted(payRequestBody, DateArry, RiskItem);
+                    DateArry.put("return_url", ReturnUrl);//最多填写三个地址,不同地址用间使用‘|’分隔
+                    break;
+                case "ReadyPay": //预支付
+                    DateArry.put("dgtl_envlp", dgtl_envlp);
+                    DateArry.put("user_id", "");//用户在商户平台唯一ID (和绑卡时要一致)
+                    DateArry.put("txn_type", "05");//交易类型(参看:文档中《交易类型枚举》)
+                    trade_no = RandomUtil.getRandomNew(RandomUtil.GROUP_USER_ORDER);//商户订单号
+                    DateArry.put("trans_id", trade_no);
+                    ProtocolNo = payRequestBody.getBankInfo().getProtocolNo();//签约协议号(确认绑卡返回)
+                    ProtocolNo = SecurityUtil.AesEncrypt(SecurityUtil.Base64Encode(ProtocolNo), AesKey);//先BASE64后进行AES加密
+                    log.info("签约协议号AES结果:"+ProtocolNo);
+                    DateArry.put("protocol_no", ProtocolNo);//签约协议号(密文)
+                    DateArry.put("txn_amt", price);//交易金额 [单位:分  例:1元则提交100],此处注意数据类型的转转,建议使用BigDecimal类弄进行转换为字串
+                    extracted(payRequestBody, DateArry, RiskItem);
+                    DateArry.put("return_url", ReturnUrl);//最多填写三个地址,不同地址用间使用‘|’分隔
+                    break;
+                case "ConfirmPay": //确认支付
+                    DateArry.put("dgtl_envlp", dgtl_envlp);
+                    DateArry.put("txn_type", "06");//交易类型(参看:文档中《交易类型枚举》)
+                    String CardInfo="";//信用卡(格式):信用卡有效期|安全码;借记卡:传空
+                    String SMSStr= payRequestBody.getPhoneCode();//短信验证码,测试环境随机6位数;生产环境验证码预绑卡成功后发到用户手机。确认绑卡时回传。
+                    String UniqueCode = payRequestBody.getMerOrderId()+ "|"+SMSStr;//预支付唯一码(预支付返回的值)[格式:预支付一码|短信验证码]
+                    UniqueCode = SecurityUtil.AesEncrypt(SecurityUtil.Base64Encode(UniqueCode), AesKey);//先BASE64后进行AES加密
+                    log.info("AES[UniqueCode]结果:"+UniqueCode);
+                    DateArry.put("unique_code", UniqueCode);//预支付唯一码
+                    DateArry.put("card_info", CardInfo);//卡信息
+                    break;
+                case "QueryOrder": //查询
+                    DateArry.put("txn_type", "07");//交易类型(参看:文档中《交易类型枚举》)
+                    trade_no = payRequestBody.getOrderNo();//原交易商户订单号
+                    DateArry.put("orig_trans_id", trade_no);//交易时的trans_id
+                    DateArry.put("orig_trade_date", send_time);//
+                    break;
+            }
+            String SignVStr = FormatUtil.coverMap2String(DateArry);
+            log.info("SHA-1摘要字串:"+SignVStr);
+            String signature = SecurityUtil.sha1X16(SignVStr, "UTF-8");//签名
+            log.info("SHA-1摘要结果:"+signature);
+            String Sign = SignatureUtils.encryptByRSA(signature, pfxpath, pfxpwd);
+            log.info("RSA签名结果:"+Sign);
+            DateArry.put("signature", Sign);//签名域
+            LogSyncUtil.logSync("宝付协议支付【{}】 查询,交易编号:{},请求参数:{}",type,trade_no,DateArry);
+            String PostString = HttpUtil.RequestForm( getUrl(), DateArry);
+            LogSyncUtil.logSync("宝付协议支付【{}】 查询,交易编号:{},返回结果:{}",type,trade_no,PostString);
+//            String PostString  = HttpUtil.RequestForm(getUrl(), DateArry);
+            log.info("请求返回:"+PostString);
+            Map<String, String> ReturnData = FormatUtil.getParm(PostString);
+            if(!ReturnData.containsKey("signature")){
+                return ResultMap.error("缺少验签参数!");
+            }
+            String RSign=ReturnData.get("signature");
+            log.info("返回的验签值:"+RSign);
+            ReturnData.remove("signature");//需要删除签名字段
+            String RSignVStr = FormatUtil.coverMap2String(ReturnData);
+            log.info("返回SHA-1摘要字串:"+RSignVStr);
+            String RSignature = SecurityUtil.sha1X16(RSignVStr, "UTF-8");//签名
+            log.info("返回SHA-1摘要结果:"+RSignature);
+            if(SignatureUtils.verifySignature(cerpath,RSignature,RSign)){
+                log.info("验签成功 Yes" );//验签成功
+                if(!ReturnData.containsKey("resp_code")){
+                    return ResultMap.error("缺少resp_code参数!");
+                }
+                return ResultMap.ok()
+                        .put("data",ReturnData)
+                        .put("pfxpath",pfxpath)
+                        .put("pfxpwd",pfxpwd)
+                        .put("trade_no",trade_no)
+                        ;
+            }else{
+                return ResultMap.error("验签失败");
+            }
+        } catch (Exception e) {
+            log.error(" 请求异常:{} ",e);
+            return ResultMap.error(e+"");
+        }
+    }
+
+    /**
+     * 风控参数
+     * @param payRequestBody
+     * @param DateArry
+     * @param RiskItem
+     */
+    private static void extracted(PaymentRequestDto payRequestBody, Map<String, String> DateArry, Map<String, String> RiskItem) {
+        /**
+         * 说明风控参数必须,按商户开通行业、真实交易信息传,不可传固定值。
+         */
+        RiskItem.put("goodsCategory", payRequestBody.getPaymentUserInfo().getGoodsCategory());//商品类目 详见附录《商品类目》
+        /**--------行业参数  (以下为游戏行业风控参,请参看接口文档附录风控参数)-------------**/
+        RiskItem.put("csName", payRequestBody.getPaymentUserInfo().getCsName());//收货人姓名
+        RiskItem.put("csMobile", payRequestBody.getPaymentUserInfo().getCsMobile());//收货人手机号
+        RiskItem.put("csProvince", payRequestBody.getPaymentUserInfo().getCsProvince());//收货人省份
+        RiskItem.put("csCity", payRequestBody.getPaymentUserInfo().getCsCity());//收货人城市
+        RiskItem.put("csAddress", payRequestBody.getPaymentUserInfo().getCsAddress());//收货人地址 不包含国家、省份/州、城 市信息的详细地址
+        RiskItem.put("prodNameList", payRequestBody.getPaymentUserInfo().getProdNameList());//商品名称
+        RiskItem.put("prodTypeList", payRequestBody.getPaymentUserInfo().getProdTypeList());//商品类目 008 运动户外
+        RiskItem.put("prodQtyList", payRequestBody.getPaymentUserInfo().getProdQtyList());//商品数量
+        String price = StringUtils.isEmpty(payRequestBody.getPaymentUserInfo().getProdAmtList())
+                ? BigDecimal.ZERO.toString(): String.valueOf(new BigDecimal(payRequestBody.getPaymentUserInfo().getProdAmtList()).multiply(new BigDecimal(100)).intValue());
+        RiskItem.put("prodAmtList", price);//商品总价
+        DateArry.put("risk_item", JSONObject.toJSONString(RiskItem));//放入风控参数
+    }
+
+    private static String getTxnTime() {
+        return DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSS);
+    }
+
+    private String getUrl (String type){
+        return StringUtils.isNotEmpty(appversion) && appversion.equals("prod")
+                ? serverUrl+type : serverUrl_box + type;
+    }
+
+    private String getUrl (){
+        return serverUrl;
+//        return StringUtils.isNotEmpty(appversion) && appversion.equals("prod")
+//                ? serverUrl : serverUrl_box ;
+    }
+
+    private BaoFooPayConfig initConfig(BankInfo bankInfo){
+        return new BaoFooPayConfig();
+//        return StringUtils.isNotEmpty(appversion) && appversion.equals("prod")
+//                ? baoFooPayConfig = (BaoFooPayConfig) bankInfo.getPayConfigByClass(BaoFooPayConfig.class) : new BaoFooPayConfig();
+    }
+
+    private BaoFooPayConfig initPaymentConfig(PaymentRequestDto payRequestBody){
+        return StringUtils.isNotEmpty(appversion) && appversion.equals("prod")
+                ? baoFooPayConfig = (BaoFooPayConfig) payRequestBody.getPayConfigByClass(BaoFooPayConfig.class) : new BaoFooPayConfig();
+    }
+
+    private BaoFooPayConfig initRefundConfig(RefundRequestDto refundRequestDto){
+        return StringUtils.isNotEmpty(appversion) && appversion.equals("prod")
+                ? baoFooPayConfig = (BaoFooPayConfig) refundRequestDto.getPayConfigByClass(BaoFooPayConfig.class) : new BaoFooPayConfig();
+    }
+
+}

+ 417 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/HfPayServiceImpl.java

@@ -0,0 +1,417 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.huifu.adapay.Adapay;
+import com.huifu.adapay.core.exception.BaseAdaPayException;
+import com.huifu.adapay.model.MerConfig;
+import com.huifu.adapay.model.Payment;
+import com.huifu.adapay.model.PaymentReverse;
+import com.huifu.adapay.model.Refund;
+import com.tzy.common.utils.*;
+import com.tzy.framework.pay.config.HfPayConfig;
+import com.tzy.framework.pay.dto.*;
+import com.tzy.framework.pay.service.HfPayService;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class HfPayServiceImpl implements HfPayService {
+
+    @Autowired
+    private HfPayConfig hfPayConfig;;
+
+    private static String appid = "app_db57e4cc-6324-430a-9ffc-dd836f412cb9";
+
+    public static String regSpecial = "[`~!@$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()_+|{}‘;:”“’。,、?]";
+
+    /**
+     * 预加载 注册宝付配置
+     */
+    @PostConstruct
+    public void init() throws Exception {
+        if (null == hfPayConfig) hfPayConfig = new HfPayConfig();
+        /**
+         * debug 模式,开启后有详细的日志
+         */
+        Adapay.debug = hfPayConfig.isDebug();
+//        Adapay.debug = false;
+        /**
+         * prodMode 模式,默认为生产模式,false可以使用mock模式
+         */
+        Adapay.prodMode = hfPayConfig.isProdMode();
+        log.info("  prodMode 模式 {} ",Adapay.prodMode);
+//        Adapay.prodMode = true;
+        /**
+         * 初始化商户配置,服务器启动前,必须通过该方式初始化商户配置完成
+         * apiKey为prod模式的API KEY
+         * mockApiKey为mock模式的API KEY
+         * rsaPrivateKey为商户发起请求时,用于请求参数加签所需要的RSA私钥
+         */
+        String apiKey = "api_live_62f4a9d5-905e-4d64-85f0-136a9c0620a5";
+        String mockApiKey = "api_test_29708ffc-1d3f-4b24-8e7b-60073b138b9e";
+        String rsaPrivateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIl2NugFoWa+HUk/xQyUx69u85pC7vbtZbtOWjD3Yqt6PnE7mT6B4GOf7lDYd4NrggzPaJ067yo8xv8GCNla+flP7KbRhbrp6h+U4L3NX32PQSvZJWjnGxUkOm+tDp3PfBPl48pf8/X7oocafn0ZGqZslNZh8/BTVJhwOi52G8i3AgMBAAECgYBPXbi/6BhTaOsh0rbj17cffHEcHQ859MFrDwcWBI+ssC0DVcTaCUTUYI/Jj+IZN+ZjnREqzs8t1N+UeRh83oE676Gl/+dQVgeQ7muugoCZ0FI7kEKsFQILSSXq0wAC7kfZJv3fVs3p9WEyjd9e90nWqO45vszAuCAijnIRV8vGeQJBALyvvgJGAGfMCqqFZdMdk9C+SEf8rjtuTezQzHOAw+kIYvyZZvmCeJRbYbZ7myoa6QaVquy52MSR2IDZyqPsQhUCQQC6gD++Gl/jhWsWejAl1VaMLq+sGQYtAp+rt5OQMAHebDnMgovoTjWXpLocDA0IPFNGuHjvsxN43J3OUOe1cC6bAkBN9D2IKuuX9pChiqNa6WlcYID0XMyO+S9wm4McZSKLcE+VFLuacfDnOinQfpjIeH21nrgTPWT1MVxFP7Wcq8tRAkEApIDhOL6s29RgK/hlJcnyyD2Z6LQ99U++JUoM1/7wdw+BP/najHMH5JWBL6IVkLEdR2EKE2wifdYjP8uvRiQIhwJABYPLM4gq099OjkyA9U0zm8bbKqFDQYdrRhmDUjUiojFw9QHlck7BcBc01PmUjg7TN5uBTWyTTJY7pOWtS7s6Ag==";
+        MerConfig merConfig = new MerConfig();
+//        merConfig.setApiKey(apiKey);
+//        merConfig.setApiMockKey(mockApiKey);
+//        merConfig.setRSAPrivateKey(rsaPrivateKey);
+        merConfig.setApiKey(hfPayConfig.getApiKey());
+        merConfig.setApiMockKey(hfPayConfig.getApiMockKey());
+        merConfig.setRSAPrivateKey(hfPayConfig.getRSAPrivateKey());
+        Adapay.initWithMerConfig(merConfig);
+    }
+
+    /**
+     * 执行一个支付交易
+     *
+     * @return 创建的支付对象
+     * @throws Exception 异常
+     */
+    @Override
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto) {
+        ResultMap resultMap = new ResultMap();
+        try {
+            RechargeUserInfoDto rechargeUserInfoDto = paymentRequestDto.getRechargeUserInfoDto();
+            System.out.println("=======execute payment begin=======");
+            //创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
+            Map<String, Object> paymentParams = new HashMap<>(10);
+            paymentParams.put("app_id", hfPayConfig.getAppid());
+//            paymentParams.put("app_id", appid);
+            String expireTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,paymentRequestDto.getExpireTime());
+            paymentParams.put("time_expire", expireTime);
+            paymentParams.put("order_no", paymentRequestDto.getOrderNo());
+            paymentParams.put("pay_channel", paymentRequestDto.getPayWay());
+            paymentParams.put("pay_amt", paymentRequestDto.getTotalAmount().toString());
+            paymentParams.put("notify_url", hfPayConfig.getNotify_url());
+            String msg = String.valueOf(paymentRequestDto.getBody());
+            msg = Base64Util.subStringByBytes(msg,20).replaceAll(regSpecial," ");
+            paymentParams.put("goods_title",msg );
+            paymentParams.put("goods_desc", msg);
+            Map device_info = new HashMap();
+            device_info.put("device_ip", IpUtils.getIpAddr(ServletUtils.getRequest()));
+//            device_info.put("device_ip", "116.232.75.101");
+            paymentParams.put("device_info", device_info);
+
+            //填写用户的实名认证信息
+            if(null != rechargeUserInfoDto && rechargeUserInfoDto.isCheckUserAuth()){
+                paymentParams.put("name",rechargeUserInfoDto.getUserName());//实名认证姓名
+                paymentParams.put("certType","IDENTITY_CARD");//实名认证证件类型
+                paymentParams.put("certNo",rechargeUserInfoDto.getCertificateNo());//实名认证证件号
+                paymentParams.put("fixBuyer","T");//是否需要实名认证
+            }
+            //调用sdk方法,创建支付,得到支付对象
+            log.info("汇付支付交易,请求参数:{}" , JSONObject.toJSONString(paymentParams));
+            Map<String, Object> payment = Payment.create(paymentParams);
+            JSONObject jsonResult = (JSONObject) payment;
+            log.info("汇付支付交易,返回结果:{}" , jsonResult);
+            if(null != jsonResult && !jsonResult.isEmpty() ) {
+                String status = jsonResult.getString("status");
+                if(!"succeeded".equals(status)){
+                    return ResultMap.error(jsonResult.getString("error_msg"));
+                }
+                String paymentId = (String) jsonResult.get("id");
+                JSONObject expend = (JSONObject) jsonResult.get("expend");
+                String pay_info = expend.getString("pay_info");
+                if (StringUtils.isEmpty(pay_info)) pay_info = expend.getString("qrcode_url");
+                Map<String, String> data = new HashMap<>();
+                data.put("url", pay_info);
+                resultMap.put("data", data);
+                resultMap.put("merOrderId", paymentId);
+                resultMap.put("orderNo", paymentRequestDto.getOrderNo());
+                return resultMap;
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return ResultMap.error("下单失败");
+    }
+
+    /**
+     * 查询
+     * @param appid
+     * @throws Exception
+     */
+    @Override
+    public PaymentInfoResponseDto queryOrder(String appid, String payWay, String  id) {
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        String errMsg = "";
+        try {
+            System.out.println("=======query payment begin=======");
+            System.out.println("支付查询请求参数:" + JSONObject.toJSONString(id));
+            Map<String, Object> payment = Payment.query(id);
+            System.out.println("支付查询返回参数:" + JSONObject.toJSONString(payment));
+            System.out.println("=======query payment end=======");
+            JSONObject jsonResult = (JSONObject) payment;
+            log.info("汇付支付交易,返回结果:{}" , jsonResult);
+            if(null != jsonResult && !jsonResult.isEmpty() ) {
+                String status = jsonResult.getString("status");
+                if("succeeded".equals(status)){
+                    paymentInfoResponseDto = PaymentInfoResponseDto.ok();
+                    paymentInfoResponseDto.setOrderNo(id);
+                    paymentInfoResponseDto.setPayWay(payWay);
+                    paymentInfoResponseDto.setPaymentNo(id);
+                    String orderAmt = StringUtils.isNotEmpty((String) payment.get("pay_amt")) ? (String) payment.get("pay_amt") : "0";
+                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(orderAmt));
+                    paymentInfoResponseDto.setActualPayment(new BigDecimal(orderAmt));
+                    Date finishedDate = new Date();
+                    paymentInfoResponseDto.setPaymentSuccessTime(finishedDate);
+                    paymentInfoResponseDto.setSuccess(true);
+                    return paymentInfoResponseDto;
+                }
+                return paymentInfoResponseDto.error(-1,jsonResult.getString("error_msg"));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "下单失败";
+        }
+        return PaymentInfoResponseDto.error(-2,errMsg);
+    }
+
+    /**
+     * 撤销交易
+     * @param paymentRequestDto
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public Map<String, Object> reverse(PaymentRequestDto paymentRequestDto)  {
+        System.out.println("=======create Reverse  begin=======");
+        Map<String, Object> reverse = new HashMap<>();
+        try {
+            reverse.put("payment_id", paymentRequestDto.getMerOrderId());
+            reverse.put("app_id", hfPayConfig.getAppid());
+//            reverse.put("app_id", appid);
+            reverse.put("order_no", paymentRequestDto.getOrderNo());
+            reverse.put("notify_url", hfPayConfig.getNotify_url());
+            reverse.put("reverse_amt", paymentRequestDto.getTotalAmount().toString());
+            reverse.put("reason", paymentRequestDto.getMsg());
+            reverse.put("expand", paymentRequestDto.getOrderNo());
+            System.out.println("创建撤销对象" + JSONObject.toJSONString(reverse));
+            reverse = PaymentReverse.create(reverse);
+        } catch (BaseAdaPayException e) {
+            e.printStackTrace();
+        }
+        System.out.println("创建撤销对象返回参数:" + JSONObject.toJSONString(reverse));
+        System.out.println("=======create Reverse  end=======");
+        return reverse;
+    }
+    /**
+     * 查询撤销对象
+     *
+     * @param reverse_id 要查询的支付id
+     * @return 查询的支付对象
+     * @throws Exception 异常
+     */
+    @Override
+    public Map<String, Object> queryReverse(String reverse_id) {
+        System.out.println("=======query Reverse  begin=======");
+        Map<String, Object> reverse = new HashMap<>();
+        try {
+            reverse.put("reverse_id", reverse_id);
+            System.out.println("查询撤销对象请求参数:" + JSONObject.toJSONString(reverse));
+            reverse = PaymentReverse.query(reverse);
+        } catch (BaseAdaPayException e) {
+            e.printStackTrace();
+        }
+        System.out.println("查询撤销对象返回参数:" + JSONObject.toJSONString(reverse));
+        System.out.println("=======query Reverse  end=======");
+        return reverse;
+    }
+    /**
+     * 退款交易
+     *
+     * @param refundRequestDto 要退款
+     * @return 创建的退款对象
+     * @throws Exception 异常
+     */
+    @Override
+    public ResultMap refund(RefundRequestDto refundRequestDto) {
+        System.out.println("=======execute refund begin=======");
+        String errMsg = "";
+        ResultMap refund = new ResultMap();
+        try {
+            String refundOrderId = RandomUtil.getRandomOld(RandomUtil.REFUND_NO);
+            Map<String, Object> refundParams = new HashMap<String, Object>(2);
+            refundParams.put("refund_amt", refundRequestDto.getRefundAmount().setScale(2).toString());
+            refundParams.put("app_id", refundRequestDto.getAppid());
+            refundParams.put("refund_order_no", refundOrderId);
+//            refundParams.put("refund_order_no", refundRequestDto.getRefundNo());
+            refundParams.put("notify_url",hfPayConfig.getRefundNotifyUrl());
+            System.out.println("退款请求参数:" + JSONObject.toJSONString(refundParams));
+            JSONObject retJson = (JSONObject) Refund.create(refundRequestDto.getOrderNo(), refundParams);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                //判断交易状态
+                Map<String, String> stringStringMap = new HashMap<>();
+                if("succeeded".equals(retJson.getString("status")) ) {
+                    stringStringMap.put("out_refund_no", refundOrderId);
+                    stringStringMap.put("refund_id", String.valueOf(retJson.get("id")));
+                    try{
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("refund_amt")))));
+                    }catch (NumberFormatException e){
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("refund_amt")))));
+                    }
+                    stringStringMap.put("fund_change", "Y");
+                    return  ResultMap.ok()
+                            .put("data",stringStringMap)
+                            ;
+                }else if("pending".equals(retJson.getString("status")) ) {//交易处理中
+                    stringStringMap.put("out_refund_no", refundOrderId);
+                    stringStringMap.put("fund_change", "P");
+                    return  ResultMap.ok()
+                            .put("data",stringStringMap)
+                            ;
+                } else {
+                    errMsg = retJson.getString("error_msg");
+                }
+            }else{
+                errMsg = "退款请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        System.out.println("退款返回参数:" + JSONObject.toJSONString(refund));
+        System.out.println("=======execute refund end=======");
+        return ResultMap.error(-2,errMsg);
+    }
+    /**
+     * 根据refundNo查询一个退款交易
+     *
+     * @param refundRequestDto 要查询退款的 refundNo
+     * @return 查询的退款对象,可能含多个退款明细RefundDetail
+     * @throws Exception 异常
+     */
+    @Override
+    public ResultMap queryRefund( RefundRequestDto refundRequestDto)  {
+        String errMsg = "";
+        System.out.println("=======query refund by paymentId begin=======");
+        try {
+            Map<String, Object> refundParams = new HashMap<String, Object>(1);
+            if(StringUtils.isNotEmpty(refundRequestDto.getRefundNo())){
+                refundParams.put("refund_order_no", refundRequestDto.getRefundNo());
+            }else if(StringUtils.isNotEmpty(refundRequestDto.getMerOrderId())){
+                refundParams.put("payment_id", refundRequestDto.getMerOrderId());
+            }else if(StringUtils.isNotEmpty(refundRequestDto.getOrderNo())){
+                refundParams.put("payment_id", refundRequestDto.getOrderNo());
+            }
+            log.info("通过refundNo查询退款交易,请求参数:{}" , JSONObject.toJSONString(refundParams));
+            JSONObject retJson = (JSONObject) Refund.query(refundParams);
+            log.info("通过refundNo查询退款交易,返回参数:{}" , retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if("succeeded".equals(retJson.getString("status"))){
+                    //判断交易状态-退款状态
+                    if(retJson.getString("status").contains("succeeded") ){
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        JSONArray refunds = retJson.getJSONArray("refunds");
+                        StringBuffer out_refund_no = new StringBuffer();
+                        StringBuffer refundTargetOrderId = new StringBuffer();
+                        final BigDecimal[] refundFree = {new BigDecimal(0)};
+                        if(null != refunds && refunds.size() > 0){
+                            refunds.forEach( obj->{
+                                JSONObject objson = (JSONObject)obj;
+                                String refund_amt = objson.getString("refund_amt");
+                                refundFree[0] = refundFree[0].add(new BigDecimal(refund_amt));
+                                out_refund_no.append(objson.getString("refund_order_no"));
+                                refundTargetOrderId.append(objson.getString("refund_id"));
+                            });
+                        }
+                        stringStringMap.put("out_refund_no", out_refund_no.toString());
+                        stringStringMap.put("refund_id", refundTargetOrderId.toString());
+                        stringStringMap.put("refund_fee", String.valueOf(refundFree[0]));
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = retJson.getString("error_msg");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("error_msg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("error_code");
+                    }
+                }
+            }else{
+                errMsg = "退款查询请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        System.out.println("=======query refund by paymentId end=======");
+        return ResultMap.error(-2,errMsg);
+    }
+    @Override
+    public ResultMap close(PaymentRequestDto paymentRequestDto) {
+        System.out.println("=======close payment begin=======");
+        //关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
+        //调用sdk方法,关闭支付,得到支付对象
+        String errMsg = "";
+        try {
+            Map<String, Object> paymentParams = new HashMap<>(10);
+            paymentParams.put("payment_id", paymentRequestDto.getOrderNo());
+            paymentParams.put("reason", paymentRequestDto.getMsg());
+            paymentParams.put("expend", "expend");
+            paymentParams.put("notify_url", "notify_url");
+            Map<String, Object> payment = Payment.close(paymentParams);
+            return ResultMap.ok()
+                    .put("data", payment)
+                    ;
+        } catch (BaseAdaPayException e) {
+            e.printStackTrace();
+        }
+        System.out.println("=======close payment end=======");
+        return ResultMap.error(-2, errMsg);
+    }
+
+    public static void main(String[] args) throws Exception {
+//        String tradeNo  = "GU202206081400199998";
+        PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
+        paymentRequestDto.setBody("test");
+//        paymentRequestDto.setOrderNo(tradeNo);
+        paymentRequestDto.setOrderNo(RandomUtil.getRandomOld(RandomUtil.GROUP_USER_ORDER));
+        paymentRequestDto.setTotalAmount(new BigDecimal("0.01"));
+        paymentRequestDto.setCreateOrderTime(new Date());
+        paymentRequestDto.setPayWay("alipay");
+        HfPayServiceImpl h = new HfPayServiceImpl();
+        h.init();
+        Map<String, Object> stringObjectMap = h.tradeCreate(paymentRequestDto);
+        log.info(" 下单返回数据:{} ",stringObjectMap);
+        paymentRequestDto.setCreateOrderTime(new Date());
+//        Map<String, Object> stringObjectMap2 = h.tradeCreate(paymentRequestDto);
+//        log.info(" 下单2返回数据:{} ",stringObjectMap2);
+//        paymentRequestDto.setMerOrderId("002112022060718112010380190186975551488");
+//        Map<String, Object> reverse = h.reverse(paymentRequestDto);
+//        log.info(" 撤销订单返回数据:{} ",reverse);
+//        Map<String, Object> queryReverse = h.queryReverse("");
+//        log.info(" 撤单查询:{} ",queryReverse);
+
+//        tradeNo = "002112022060814001410380489386883682304";
+//        PaymentInfoResponseDto queryOrder = h.queryOrder(null, null, tradeNo);
+//        log.info(" 查询订单返回数据:{} ",queryOrder);
+//        RefundRequestDto refundRequestDto = new RefundRequestDto();
+//        String randomOld = RandomUtil.getRandomOld(RandomUtil.REFUND_NO);
+//        refundRequestDto.setTradeNo(tradeNo);
+//        refundRequestDto.setRefundAmount(new BigDecimal("0.01"));
+//        refundRequestDto.setRefundNo(randomOld);
+//        ResultMap resultMap = h.refund(refundRequestDto);
+//        log.info(" 退款返回数据:{} ",resultMap);
+//        ResultMap refundResult = h.queryRefund(null, null, "RN202206071807072015");
+//        log.info(" 退款返回结果:{} ",refundResult);
+//        System.out.println(stringObjectMap);
+    }
+
+
+}

+ 967 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/HmPayServiceImpl.java

@@ -0,0 +1,967 @@
+package com.tzy.framework.pay.service.impl;
+
+import cn.com.sand.hmpay.HmpayClient;
+import cn.com.sand.hmpay.contants.TradeContants;
+import cn.com.sand.hmpay.enums.TradeApiMethodEnums;
+import cn.com.sand.hmpay.enums.TradeBizPayTypeEnums;
+import cn.com.sand.hmpay.util.JacksonUtil;
+import cn.com.sand.hmpay.util.RsaUtil;
+import cn.com.sand.hmpay.vo.request.TradeRequest;
+import cn.com.sand.hmpay.vo.request.biz.*;
+import cn.com.sand.hmpay.vo.response.TradeResponse;
+import cn.com.sand.hmpay.vo.response.biz.TradeBizCreateResponse;
+import com.alibaba.fastjson.JSONObject;
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.internal.util.AlipaySignature;
+import com.tzy.common.dto.OutDTO;
+import com.tzy.common.utils.*;
+import com.tzy.framework.pay.config.HmPayConfig;
+import com.tzy.framework.pay.config.PayConfig;
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+import com.tzy.framework.pay.service.HmPayService;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * 河马付
+ */
+@Slf4j
+@Service
+public class HmPayServiceImpl implements HmPayService {
+    @Autowired
+    private HmPayConfig hmPayConfig ;
+    @Value("${pay.hm.app.payNotifyUrl:1}")
+    private String notifyUrl;
+    @Value("${pay.hm.app.refundNotifyUrl:1}")
+    private String refundNotifyUrl;
+    private String host = "https://hmpay.sandpay.com.cn/gateway";
+//    private String host = "http://star.sandgate.cn/gateway";
+    HmpayClient hmpayClient = new HmpayClient(host+"/api");
+    @Autowired
+    private PayConfig payConfig;
+
+    /**
+     * 统一下单
+     */
+    @Override
+    public String hmTradeCreate(String payWay ,String buyerId, String orderNo, BigDecimal totalAmount, String body) {
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+        String ipAddr = IpUtils.getIpAddr(request);
+        String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH,mm,ss"));
+        String merAppId = null;
+        String merBuyerId = null;
+        long startTime = System.currentTimeMillis();
+        String payType = TradeBizPayTypeEnums.MWEB.name();
+        String method = TradeApiMethodEnums.TRADE_CREATE.getMethod();
+        String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+        String expireTime = LocalDateTime.now().plusMinutes(5).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));//设置5分钟失效
+        TradeRequest tradeRequest = TradeRequest
+                .builder()
+                .appId(hmPayConfig.getApp_id())
+//                .subAppId(hmPayConfig.getWxMchID())
+                .format(hmPayConfig.getFormat())
+                .charset("UTF-8")
+                .method(method)
+                .signType("RSA")
+                .timestamp(timestamp)
+                .nonce(RandomUtil.random(8))
+                .bizContent(
+                        TradeCreateRequest
+                                .builder()
+                                .payType(payType)
+                                .buyerId(buyerId)
+                                .merAppId(merAppId)
+                                .merBuyerId(merBuyerId)
+                                .body(body)
+                                .createIp(ipAddr)
+                                .createTime(createTime)
+                                .expireTime(expireTime)
+                                .notifyUrl(notifyUrl)
+//                                .operatorId(operatorId)
+                                .outOrderNo(orderNo)
+                                .payWay( (StringUtils.isNotEmpty(payWay) && payWay.equals("wxpay") ? "WECHAT" : payWay).toUpperCase() )
+                                .storeId(hmPayConfig.getStoreId())
+//                                .terminalId(terminalId)
+                                .totalAmount(totalAmount.doubleValue())
+//                                .extendParams(ExtendParams.builder().accessPartyCode("SDK_TEST").build())
+//                                .discountInfo(DisCountInfo.builder()
+//                                        .goodsTag(goodsTag)
+//                                        .discountableAmount(discountableAmount)
+//                                        .productCode(productCode)
+//                                        .build())
+//                                .goodsDetails(goodsDetail)
+//                                .limitPay(limitPay)
+                                .build()
+                                .toJsonString()
+                )
+                .version(hmPayConfig.getVersion())
+                .build()
+                .buildSign(hmPayConfig.getPrivateKey());
+
+        System.out.println(tradeRequest);
+        TradeResponse tradeResponse = hmpayClient.execute(tradeRequest);
+        System.out.println(tradeResponse);
+
+        long endTime = System.currentTimeMillis();
+
+        System.out.println("花费时间, " + (endTime - startTime) + "ms");
+        boolean b = RsaUtil.rsaCheckV2(tradeResponse.toMap(), hmPayConfig.getPublicKey(), TradeContants.CHARSET);
+        System.out.println("验签结果:" + b);
+
+        String callbackUrl = "";
+        String cancelUrl = "";
+
+        String payUrl = host + "/trade/jsApiPay?";
+
+        String param = "pay_way=%s&pay_data=%s&callback_url=%s&cancel_url=%s";
+        String data = tradeResponse.getData();
+        TradeBizCreateResponse tradeBizCreateResponse = JacksonUtil.jsonToBean(data, TradeBizCreateResponse.class);
+        String payData = tradeBizCreateResponse.getPayData();
+
+        try {
+            payWay = URLEncoder.encode(payWay, "UTF-8");
+            payData = URLEncoder.encode(payData, "UTF-8");
+            callbackUrl = URLEncoder.encode(callbackUrl, "UTF-8");
+            cancelUrl = URLEncoder.encode(cancelUrl, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        param = String.format(param, payWay, payData, callbackUrl, cancelUrl);
+        String payCodeUrl = payUrl + param;
+        System.out.println("支付地址:" + payCodeUrl);
+        return payCodeUrl;
+    }
+    /**
+     * 统一下单
+     */
+    @Override
+    public String tradeCreate(Map<String,Object> param){
+        try {
+            String body = String.valueOf(param.get("body"));
+            if(StringUtils.isNotEmpty(body)){
+                body = Base64Util.subStringByBytes(body,120)+"...";
+            }
+            body = URLEncoder.encode(body, "UTF-8");
+            BigDecimal totalAmount = (BigDecimal) param.get("totalAmount");
+
+            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+            String ipAddr = IpUtils.getIpAddr(request);
+            ipAddr = (StringUtils.isEmpty(ipAddr) ? "116.233.194.22" : ipAddr).replaceAll("\\.", "_");
+            if(ipAddr.indexOf(",") != -1){
+                ipAddr = ipAddr.split(",")[0];
+            }
+            String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+            String expireTime = LocalDateTime.now().plusMinutes(5).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));//设置5分钟失效
+            Map<String ,String > map = new TreeMap<>();
+            map.put("create_ip",ipAddr);
+            map.put("version", hmPayConfig.getVersion());
+            map.put("mer_no", hmPayConfig.getAppId());
+            map.put("mer_order_no", String.valueOf(param.get("orderNo")));
+            map.put("create_time", createTime);
+            map.put("order_amt", String.valueOf(totalAmount.setScale(2,BigDecimal.ROUND_DOWN).doubleValue()));
+            map.put("notify_url", hmPayConfig.getPayNotifyUrl());
+            map.put("return_url", hmPayConfig.getReturnUrl());
+            map.put("store_id", hmPayConfig.getStoreId());
+            map.put("sign_type", "RSA");
+            //map.put("accsplit_flag", "NO");
+            String appid=param.get("appid")==null?"":param.get("appid").toString();
+            String openid=param.get("openid")==null?"":param.get("openid").toString();
+            String path_url=param.get("path_url")==null?"":param.get("path_url").toString();
+            String pay_extra = "{\"mer_app_id\":\"\",\"openid\":\"" +
+                    "\"wx_app_id\":\""+appid+"\",\"gh_ori_id\":" +openid+"\",\"path_url\":\"" +path_url+"\",\"miniProgramType\":\"2\"" +"\"}";
+
+            map.put("gh_static_url",hmPayConfig.getGhStaticUrl());
+            String content = BeanUtil.param2str(map) ;
+            String rsa = AlipaySignature.rsaSign(content, hmPayConfig.getPrivateKey(), "UTF-8", "RSA");
+            //--------------不参与签名
+            log.info("sign参数》》{}",content);
+            log.info("签名》》{}",rsa);
+            map.put("notify_url", URLEncoder.encode(hmPayConfig.getPayNotifyUrl() ,"UTF-8"));
+            map.put("return_url", URLEncoder.encode(hmPayConfig.getReturnUrl() ,"UTF-8"));
+//            String pay_extra = "{\"mer_app_id\":\""+param.get("appid")+"\",\"openid\":\""+param.get("openid")
+            map.put("pay_extra", "");
+            //map.put("pay_extra", URLEncoder.encode( pay_extra,"UTF-8"));
+            map.put("expire_time", expireTime);
+            map.put("goods_name",  body);
+            map.put("clear_cycle", "0");
+            map.put("jump_scheme", "hemacash://hmpay");
+            map.put("sign",  URLEncoder.encode(rsa,"UTF-8"));
+            map.put("meta_option", URLEncoder.encode( "[{\"s\":\"Android\",\"n\":\"HOBBYSTOCKS\",\"id\":\"com.hobbystocks\",\"sc\":\"\"},{\"s\":\"IOS\",\"n\":\"HOBBYSTOCKS\",\"id\":\"com.hobbystocks\",\"sc\":\"\"}]","UTF-8"));
+            if(String.valueOf(param.get("payWay")).equals("alipay")){
+                map.put("product_code", "01020002");//支付宝H5
+                // 支付宝app 01020004
+                String retStr = BeanUtil.param2str(map) ;
+                return "https://cash.sandgate.cn/h5/?"+retStr+"#/hippoh5";
+            }else{
+//                map.put("product_code", "01010005"); //微信app
+                //map.put("product_code", "01010002,01010005,02010006");//微信H5
+                map.put("product_code", "01010006");//云函数
+                String retStr = BeanUtil.param2str(map) ;
+                return "https://cash.sandgate.cn/h5/?"+retStr+"#/applet";
+            }
+            //return "https://cash.sandgate.cn/h5/?"+retStr+"#/applet";
+//            return "https://cash.sandgate.cn/h5/?"+retStr+"#/sandcashier1";
+//            return "https://cash.sandgate.cn/h5/?"+retStr+"#/hippoPublic";
+        } catch (AlipayApiException e) {
+            e.printStackTrace();
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+    /**
+     * 统一下单
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto){
+        ResultMap resultMap = new ResultMap();
+        try {
+            HmPayConfig hmPayConfig = (HmPayConfig) payConfig.get(paymentRequestDto.getAppid());
+            if(null == hmPayConfig){
+                hmPayConfig = this.hmPayConfig;
+            }
+            String body = String.valueOf(paymentRequestDto.getBody());
+            if(StringUtils.isNotEmpty(body) ){
+                body = Base64Util.subStringByBytes(body,80)+"...";
+            }
+            body = URLEncoder.encode(body, "UTF-8");
+            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+            String ipAddr = IpUtils.getIpAddr(request);
+            ipAddr = (StringUtils.isEmpty(ipAddr) ? "116.233.194.22" : ipAddr).replaceAll("\\.", "_");
+            if(ipAddr.indexOf(",") != -1){
+                ipAddr = ipAddr.split(",")[0];
+            }
+            String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+            String expireTime = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS,new Date(paymentRequestDto.getCreateOrderTime().getTime()+2800*60));//设置3分钟失效
+            Map<String ,String > map = new TreeMap<>();
+            map.put("create_ip",ipAddr);
+            map.put("version", hmPayConfig.getVersion());
+            map.put("mer_no", hmPayConfig.getAppId());
+            map.put("mer_order_no", paymentRequestDto.getOrderNo());
+            map.put("create_time", createTime);
+            map.put("order_amt", String.valueOf(paymentRequestDto.getTotalAmount().setScale(2,BigDecimal.ROUND_DOWN).doubleValue()));
+            map.put("notify_url", hmPayConfig.getPayNotifyUrl());
+            map.put("return_url", hmPayConfig.getReturnUrl());
+            map.put("store_id", hmPayConfig.getStoreId());
+            map.put("sign_type", "RSA");
+            //map.put("accsplit_flag", "NO");
+            String pay_extra = "{\"mer_app_id\":\"\",\"openid\":\"" +
+                    "\"wx_app_id\":\""+ paymentRequestDto.getWxAppid()+"\",\"gh_ori_id\":" + paymentRequestDto.getWxOpenid()+"\",\"path_url\":\"" + paymentRequestDto.getPath_url()+"\",\"miniProgramType\":\"2\"" +"\"}";
+
+            map.put("gh_static_url",hmPayConfig.getGhStaticUrl());
+            String content = BeanUtil.param2str(map) ;
+            String rsa = AlipaySignature.rsaSign(content, hmPayConfig.getPrivateKey(), "UTF-8", "RSA");
+            //--------------不参与签名
+            log.info("sign参数》》{}",content);
+            log.info("签名》》{}",rsa);
+            map.put("notify_url", URLEncoder.encode(hmPayConfig.getPayNotifyUrl() ,"UTF-8"));
+            map.put("return_url", URLEncoder.encode(hmPayConfig.getReturnUrl() ,"UTF-8"));
+//            String pay_extra = "{\"mer_app_id\":\""+param.get("appid")+"\",\"openid\":\""+param.get("openid")
+            map.put("pay_extra", "");
+            //map.put("pay_extra", URLEncoder.encode( pay_extra,"UTF-8"));
+            map.put("expire_time", expireTime);
+            map.put("goods_name",  body);
+            map.put("clear_cycle", "0");
+            map.put("jump_scheme", "hemacash://hmpay");
+            map.put("sign",  URLEncoder.encode(rsa,"UTF-8"));
+            map.put("meta_option", URLEncoder.encode( "[{\"s\":\"Android\",\"n\":\"HOBBYSTOCKS\",\"id\":\"com.hobbystocks\",\"sc\":\"\"},{\"s\":\"IOS\",\"n\":\"HOBBYSTOCKS\",\"id\":\"com.hobbystocks\",\"sc\":\"\"}]","UTF-8"));
+            String paymentUrl = "";
+            if(paymentRequestDto.getPayWay().contains("alipay")){
+                map.put("product_code", "01020002");//支付宝H5
+                // 支付宝app 01020004
+                paymentUrl = "https://cash.sandgate.cn/h5/?"+BeanUtil.param2str(map)+"#/hippoh5";
+            }else{
+                map.put("product_code", "01010006");//云函数
+                paymentUrl = "https://cash.sandgate.cn/h5/?"+BeanUtil.param2str(map)+"#/applet";
+            }
+            //return "https://cash.sandgate.cn/h5/?"+retStr+"#/applet";
+//            return "https://cash.sandgate.cn/h5/?"+retStr+"#/sandcashier1";
+//            return "https://cash.sandgate.cn/h5/?"+retStr+"#/hippoPublic";
+            Map dataMap = new HashMap();
+            dataMap.put("hmUrl", paymentUrl);
+            resultMap.put("data", dataMap);
+            return resultMap;
+        } catch (AlipayApiException e) {
+            e.printStackTrace();
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return ResultMap.error("下单失败!");
+    }
+
+    /**
+     * {
+     * 	map.put("create_ip", "127_0_0_1");
+     * 	map.put("store_id", "100001");
+     * 	map.put("goods_name", "测试商品");
+     * 	map.put("pay_extra", "{\"mer_app_id\",\"wxdc71tul975fd3drr\",\"openid\",\"oUnDDFGererfZPzspzi_bEhMM\"}");
+     * 	map.put("mer_no", "123456");
+     * 	map.put("create_time", "20200831160114");
+     * 	map.put("mer_key", "123");
+     * 	map.put("expire_time", "20200831160118");
+     * 	map.put("notify_url", "https,//baidu.com.cn/notify_test/sand");
+     * 	map.put("product_code", "01010001,01010002");
+     * 	map.put("version", "10");
+     * 	map.put("accsplit_info", "NO");
+     * 	map.put("return_url", "https,//baidu.com.cn/notify_test/returnUrl");
+     * 	map.put("clear_cycle", "0");
+     * 	map.put("order_amt", "0.01");
+     * 	map.put("mer_order_no", "1598860874173");
+     * 	map.put("sign", "820AB93E4A3CB968BF78F4ADD75E9C4D");
+     * }
+     */
+//    String AlipaySignature.rsaSign(String content, String privateKey, String charset,String signType)
+
+    /**
+     * 退款
+     * @param param
+     * @return
+     */
+    @Override
+    public ResultMap refundOrder(Map<String,Object> param) {
+        String appid = (String) param.getOrDefault("appid",null);
+        HmPayConfig hmPayConfig = (HmPayConfig) payConfig.get(appid);
+        if(null == hmPayConfig){
+            hmPayConfig = this.hmPayConfig;
+        }
+        BigDecimal totalAmount = (BigDecimal) param.get("totalAmount");
+        String outOrderNo = (String) param.get("orderNo");
+        String refund_request_no = (String) param.get("refund_request_no");
+        String method = TradeApiMethodEnums.TRADE_REFUND.getMethod();
+        TradeRequest tradeRequest = TradeRequest
+                .builder()
+                .appId(hmPayConfig.getApp_id())
+                .format(hmPayConfig.getFormat())
+                .charset("utf-8")
+                .method(method)
+                .signType("RSA")
+                .timestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .nonce(String.valueOf(System.currentTimeMillis()))
+                .bizContent(
+                        TradeRefundRequest
+                                .builder()
+                                .outOrderNo(outOrderNo)
+                                .refundAmount(Double.valueOf(String.valueOf(totalAmount.setScale(2, BigDecimal.ROUND_DOWN).doubleValue())))
+                                .refundRequestNo(refund_request_no)
+                                .refundReason((String) param.get("refundMsg"))
+                                .storeId(hmPayConfig.getStoreId())
+                                .build()
+                                .toJsonString()
+                )
+                .version(hmPayConfig.getVersion())
+                .build()
+                .buildSign(hmPayConfig.getPrivateKey());
+        TradeResponse tradeResponse = hmpayClient.execute(tradeRequest);
+        String errMsg = "";
+        if(StringUtils.isNotEmpty(tradeResponse.getCode()) && "200".equals(tradeResponse.getCode()) ){
+            boolean b = RsaUtil.rsaCheckV2(tradeResponse.toMap(), hmPayConfig.getHmPublicKey(), TradeContants.CHARSET);
+            log.info("验签结果:" + b);
+            if(b) {
+                //请求成功:
+                Map<String, String> stringStringMap = tradeResponse.toMap();
+                if (null != stringStringMap && !stringStringMap.isEmpty()) {
+                    String data = stringStringMap.get("data");
+                    JSONObject jsonObject = JSONObject.parseObject(data);
+                    String code = jsonObject.getString("sub_code");
+                    if ("REFUND_SUCCESS".equals(code)) {
+                        stringStringMap.put("out_refund_no", String.valueOf(jsonObject.get("refund_request_no")));
+                        stringStringMap.put("refund_id", String.valueOf(jsonObject.get("refund_plat_trx_no")));
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(jsonObject.get("refund_settle_amount"))) * 100));
+                        stringStringMap.put("fund_change", "Y");
+                        //退款成功
+                        return ResultMap.ok()
+                                .put("data", stringStringMap)
+                                ;
+                    } else {
+                        errMsg = stringStringMap.get("sub_msg");
+                    }
+                } else if (null == stringStringMap) {
+                    errMsg = "退款请求失败!";
+                } else {
+                    errMsg = stringStringMap.get("sub_msg");
+                }
+            }else {
+                errMsg = "退款错误[SIGN ERROR],请联系开发人员!";
+            }
+        }else{
+            errMsg = tradeResponse.getMsg();
+        }
+        return ResultMap.error(errMsg)
+                ;
+    }
+
+    /**
+     * 查询订单信息
+     */
+    @Override
+    public PaymentInfoResponseDto queryOrder(String appid,String orderNo){
+        HmPayConfig hmPayConfig = (HmPayConfig) payConfig.get(appid);
+        if(null == hmPayConfig){
+            hmPayConfig = this.hmPayConfig;
+        }
+        String platTrxNo = "";
+        String bankOrderNo = "";
+        String method = TradeApiMethodEnums.TRADE_QUERY.getMethod();
+        TradeRequest tradeRequest = TradeRequest
+                .builder()
+                .appId(hmPayConfig.getApp_id())
+                .format(hmPayConfig.getFormat())
+                .charset("utf-8")
+                .method(method)
+                .signType("RSA")
+                .timestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .nonce(String.valueOf(System.currentTimeMillis()))
+                .bizContent(
+                        TradeQueryRequest
+                        .builder()
+                        .outOrderNo(orderNo)
+                        .platTrxNo(platTrxNo)
+                        .bankOrderNo(bankOrderNo)
+                        .build()
+                        .toJsonString()
+                )
+                .version(hmPayConfig.getVersion())
+                .build()
+                .buildSign(hmPayConfig.getPrivateKey());
+        TradeResponse tradeResponse = hmpayClient.execute(tradeRequest);
+        String errMsg = "";
+        if(StringUtils.isNotEmpty(tradeResponse.getCode()) && "200".equals(tradeResponse.getCode()) ){
+            boolean b = RsaUtil.rsaCheckV2(tradeResponse.toMap(), hmPayConfig.getHmPublicKey(), TradeContants.CHARSET);
+            log.info("验签结果:" + b);
+            if(b){
+                //请求成功:
+                Map<String, String> stringStringMap = tradeResponse.toMap();
+                if(null != stringStringMap && !stringStringMap.isEmpty()){
+                    String data = stringStringMap.get("data");
+                    JSONObject jsonObject = JSONObject.parseObject(data);
+                    String code = jsonObject.getString("sub_code");
+                    if("SUCCESS".equals(code)){
+                        //查询
+                        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+                        paymentInfoResponseDto.setSuccess(true);
+                        paymentInfoResponseDto.setOrderNo(orderNo);
+                        paymentInfoResponseDto.setPayWay(jsonObject.getString("pay_way_code"));
+                        paymentInfoResponseDto.setAppid(hmPayConfig.getApp_id());
+                        paymentInfoResponseDto.setPaymentNo(jsonObject.getString("plat_trx_no"));
+                        paymentInfoResponseDto.setPaymentPrice(new BigDecimal(jsonObject.getDouble("total_amount")));
+                        paymentInfoResponseDto.setActualPayment(new BigDecimal(jsonObject.getDouble("total_amount")));
+                        paymentInfoResponseDto.setTradeState(code);
+                        paymentInfoResponseDto.setTradeStateDesc(code);
+    //                        paymentInfoResponseDto.setPaymentTime();
+                        SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMddHHmmss");
+                        try {
+                            paymentInfoResponseDto.setPaymentSuccessTime(sdf.parse(jsonObject.getString("success_time")));
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                        return paymentInfoResponseDto;
+                    }else{
+                        errMsg = stringStringMap.get("sub_msg");
+                    }
+                }else if(null == stringStringMap){
+                    errMsg = "查询请求失败!";
+                }else{
+                    errMsg = stringStringMap.get("sub_msg");
+                }
+            }else {
+                errMsg = "退款错误[SIGN ERROR],请联系开发人员!";
+            }
+        }else{
+            errMsg = tradeResponse.getMsg();
+        }
+        return PaymentInfoResponseDto.error(-2,errMsg);
+    }
+    /**
+     * 查询订单信息
+     */
+    @Override
+    public OutDTO queryOrder(Map<String,Object> param){
+        String appid = (String) param.getOrDefault("appid",null);
+        HmPayConfig hmPayConfig = (HmPayConfig) payConfig.get(appid);
+        if(null == hmPayConfig){
+            hmPayConfig = this.hmPayConfig;
+        }
+        String platTrxNo = "";
+        String bankOrderNo = "";
+        String outOrderNo = (String) param.get("orderNo");
+        String method = TradeApiMethodEnums.TRADE_QUERY.getMethod();
+        TradeRequest tradeRequest = TradeRequest
+                .builder()
+                .appId(hmPayConfig.getApp_id())
+                .format(hmPayConfig.getFormat())
+                .charset("utf-8")
+                .method(method)
+                .signType("RSA")
+                .timestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .nonce(String.valueOf(System.currentTimeMillis()))
+                .bizContent(
+                        TradeQueryRequest
+                                .builder()
+                                .outOrderNo(outOrderNo)
+                                .platTrxNo(platTrxNo)
+                                .bankOrderNo(bankOrderNo)
+                                .build()
+                                .toJsonString()
+                )
+                .version(hmPayConfig.getVersion())
+                .build()
+                .buildSign(hmPayConfig.getPrivateKey());
+        TradeResponse tradeResponse = hmpayClient.execute(tradeRequest);
+        String errMsg = "";
+        if(StringUtils.isNotEmpty(tradeResponse.getCode()) && "200".equals(tradeResponse.getCode()) ){
+            boolean b = RsaUtil.rsaCheckV2(tradeResponse.toMap(), hmPayConfig.getHmPublicKey(), TradeContants.CHARSET);
+            log.info("验签结果:" + b);
+            if(b){
+                //请求成功:
+                Map<String, String> stringStringMap = tradeResponse.toMap();
+                if(null != stringStringMap && !stringStringMap.isEmpty()){
+                    String data = stringStringMap.get("data");
+                    JSONObject jsonObject = JSONObject.parseObject(data);
+                    String code = jsonObject.getString("sub_code");
+                    if("SUCCESS".equals(code)){
+                        //退款成功
+                        return OutDTO.ok(jsonObject.getString("sub_msg"))
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = stringStringMap.get("sub_msg");
+                    }
+                }else if(null == stringStringMap){
+                    errMsg = "退款请求失败!";
+                }else{
+                    errMsg = stringStringMap.get("sub_msg");
+                }
+            }else {
+                errMsg = "退款错误[SIGN ERROR],请联系开发人员!";
+            }
+        }else{
+            errMsg = tradeResponse.getMsg();
+        }
+        return OutDTO.error(-2,errMsg)
+                ;
+    }
+    /**
+     * 查询退款订单信息
+     */
+    @Override
+    public OutDTO queryRefundOrder(Map<String,Object> param){
+        String appid = (String) param.getOrDefault("appid",null);
+        HmPayConfig hmPayConfig = (HmPayConfig) payConfig.get(appid);
+        if(null == hmPayConfig){
+            hmPayConfig = this.hmPayConfig;
+        }
+        String outOrderNo = (String) param.get("orderNo");
+        String platTrxNo = "";
+        String bankOrderNo = "";
+        String refundRequestNo = (String) param.get("refund_request_no");
+        String method = TradeApiMethodEnums.TRADE_REFUND_QUERY.getMethod();
+        TradeRequest tradeRequest = TradeRequest
+                .builder()
+                .appId(hmPayConfig.getApp_id())
+                .format(hmPayConfig.getFormat())
+                .charset("utf-8")
+                .method(method)
+                .signType("RSA")
+                .timestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .nonce(String.valueOf(System.currentTimeMillis()))
+                .bizContent(
+                        TradeRefundQueryRequest
+                                .builder()
+                                .outOrderNo(outOrderNo)
+                                .platTrxNo(platTrxNo)
+                                .bankOrderNo(bankOrderNo)
+                                .refundRequestNo(refundRequestNo)
+                                .build()
+                                .toJsonString()
+                )
+                .version(hmPayConfig.getVersion())
+                .build()
+                .buildSign(hmPayConfig.getPrivateKey());
+        TradeResponse tradeResponse = hmpayClient.execute(tradeRequest);
+        String errMsg = "";
+        if(StringUtils.isNotEmpty(tradeResponse.getCode()) && "200".equals(tradeResponse.getCode()) ){
+            boolean b = RsaUtil.rsaCheckV2(tradeResponse.toMap(), hmPayConfig.getHmPublicKey(), TradeContants.CHARSET);
+            log.info("验签结果:" + b);
+            if(b) {
+                //请求成功:
+                Map<String, String> stringStringMap = tradeResponse.toMap();
+                if (null != stringStringMap && !stringStringMap.isEmpty()) {
+                    String data = stringStringMap.get("data");
+                    JSONObject jsonObject = JSONObject.parseObject(data);
+                    String code = jsonObject.getString("sub_code");
+                    if ("REFUND_SUCCESS".equals(code)) {
+                        stringStringMap.put("out_refund_no", String.valueOf(jsonObject.get("refund_request_no")));
+                        stringStringMap.put("refund_id", String.valueOf(jsonObject.get("refund_plat_trx_no")));
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(jsonObject.get("refund_success_amount"))) * 100));
+                        stringStringMap.put("fund_change", "Y");
+                        //退款成功
+                        return OutDTO.ok(jsonObject.getString("sub_msg"))
+                                .put("data", stringStringMap)
+                                ;
+                    } else {
+                        errMsg = stringStringMap.get("sub_msg");
+                    }
+                } else if (null == stringStringMap) {
+                    errMsg = "退款请求失败!";
+                } else {
+                    errMsg = stringStringMap.get("sub_msg");
+                }
+            }else {
+                errMsg = "退款错误[SIGN ERROR],请联系开发人员!";
+            }
+        }else{
+            errMsg = tradeResponse.getMsg();
+        }
+        return OutDTO.error(-2,errMsg)
+                ;
+    }
+    /**
+     * 取消订单
+     */
+    @Override
+    public OutDTO cancelOrder(Map<String,Object> param){
+        String appid = (String) param.getOrDefault("appid",null);
+        HmPayConfig hmPayConfig = (HmPayConfig) payConfig.get(appid);
+        if(null == hmPayConfig){
+            hmPayConfig = this.hmPayConfig;
+        }
+        String outOrderNo = (String) param.get("orderNo");
+        String platTrxNo = "";
+        String bankOrderNo = "";
+        String method = TradeApiMethodEnums.TRADE_CANCEL.getMethod();
+        TradeRequest tradeRequest = TradeRequest
+                .builder()
+                .appId(hmPayConfig.getApp_id())
+                .format(hmPayConfig.getFormat())
+                .charset("utf-8")
+                .method(method)
+                .signType("RSA")
+                .timestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .nonce(String.valueOf(System.currentTimeMillis()))
+                .bizContent(
+                        TradeCancelRequest
+                                .builder()
+                                .outOrderNo(outOrderNo)
+                                .platTrxNo(platTrxNo)
+                                .bankOrderNo(bankOrderNo)
+                                .storeId(hmPayConfig.getStoreId())
+                                .build()
+                                .toJsonString()
+                )
+                .version(hmPayConfig.getVersion())
+                .build()
+                .buildSign(hmPayConfig.getPrivateKey());
+        System.out.println(tradeRequest);
+        TradeResponse tradeResponse = hmpayClient.execute(tradeRequest);
+        String errMsg = "";
+        if(StringUtils.isNotEmpty(tradeResponse.getCode()) && "200".equals(tradeResponse.getCode()) ){
+            System.out.println(tradeResponse);
+            boolean b = RsaUtil.rsaCheckV2(tradeResponse.toMap(), hmPayConfig.getHmPublicKey(), TradeContants.CHARSET);
+            log.info("验签结果:" + b);
+            if(b){
+                //请求成功:
+                Map<String, String> stringStringMap = tradeResponse.toMap();
+                if(null != stringStringMap && !stringStringMap.isEmpty()){
+                    String data = stringStringMap.get("data");
+                    JSONObject jsonObject = JSONObject.parseObject(data);
+                    String code = jsonObject.getString("sub_code");
+                    if("REFUND_SUCCESS".equals(code)){
+                        stringStringMap.put("out_refund_no", String.valueOf(jsonObject.get("refund_request_no")));
+                        stringStringMap.put("refund_id", String.valueOf(jsonObject.get("refund_plat_trx_no")));
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(jsonObject.get("refund_success_amount")))*100));
+                        stringStringMap.put("fund_change", "Y");
+                        //退款成功
+                        return OutDTO.ok(jsonObject.getString("sub_msg"))
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = stringStringMap.get("sub_msg");
+                    }
+                }else if(null == stringStringMap){
+                    errMsg = "退款请求失败!";
+                }else{
+                    errMsg = stringStringMap.get("sub_msg");
+                }
+            }else {
+                errMsg = "退款错误[SIGN ERROR],请联系开发人员!";
+            }
+        }else{
+            errMsg = tradeResponse.getMsg();
+        }
+        return OutDTO.error(-2,errMsg)
+                ;
+    }
+
+
+    /************新逻辑***************/
+    /**
+     * 统一下单
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap tradeCreateNew(PaymentRequestDto paymentRequestDto){
+        ResultMap resultMap = new ResultMap();
+        try {
+            HmPayConfig hmPayConfig = (HmPayConfig) paymentRequestDto.getPayConfigByClass(HmPayConfig.class);
+//            HmPayConfig hmPayConfig = (HmPayConfig) payConfig.get(paymentRequestDto.getAppid());
+//            if(null == hmPayConfig){
+//                hmPayConfig = this.hmPayConfig;
+//            }
+            String body = String.valueOf(paymentRequestDto.getBody());
+            if(StringUtils.isNotEmpty(body) ){
+                body = Base64Util.subStringByBytes(body,80)+"...";
+            }
+            body = URLEncoder.encode(body, "UTF-8");
+            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+            String ipAddr = IpUtils.getIpAddr(request);
+            ipAddr = (StringUtils.isEmpty(ipAddr) ? "116.233.194.22" : ipAddr).replaceAll("\\.", "_");
+            if(ipAddr.indexOf(",") != -1){
+                ipAddr = ipAddr.split(",")[0];
+            }
+            String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+
+            //String expireTime = LocalDateTime.now().plusMinutes(5).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+            String expireTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,paymentRequestDto.getExpireTime());
+            Map<String ,String > map = new TreeMap<>();
+            map.put("create_ip",ipAddr);
+            map.put("version", hmPayConfig.getVersion());
+            map.put("mer_no", hmPayConfig.getAppId());
+            map.put("mer_order_no", paymentRequestDto.getOrderNo());
+            map.put("create_time", createTime);
+            map.put("order_amt", String.valueOf(paymentRequestDto.getTotalAmount().setScale(2,BigDecimal.ROUND_DOWN).doubleValue()));
+            map.put("notify_url", hmPayConfig.getPayNotifyUrl());
+            map.put("return_url", hmPayConfig.getReturnUrl());
+            map.put("store_id", hmPayConfig.getStoreId());
+            map.put("sign_type", "RSA");
+            //map.put("accsplit_flag", "NO");
+            String pay_extra = "{\"mer_app_id\":\"\",\"openid\":\"" +
+                    "\"wx_app_id\":\""+ paymentRequestDto.getWxAppid()+"\",\"gh_ori_id\":" + paymentRequestDto.getWxOpenid()+"\",\"path_url\":\"" + paymentRequestDto.getPath_url()+"\",\"miniProgramType\":\"2\"" +"\"}";
+
+            map.put("gh_static_url",hmPayConfig.getGhStaticUrl());
+            String content = BeanUtil.param2str(map) ;
+            String rsa = AlipaySignature.rsaSign(content, hmPayConfig.getPrivateKey(), "UTF-8", "RSA");
+            //--------------不参与签名
+            log.info("sign参数》》{}",content);
+            log.info("签名》》{}",rsa);
+            map.put("notify_url", URLEncoder.encode(hmPayConfig.getPayNotifyUrl() ,"UTF-8"));
+            map.put("return_url", URLEncoder.encode(hmPayConfig.getReturnUrl() ,"UTF-8"));
+//            String pay_extra = "{\"mer_app_id\":\""+param.get("appid")+"\",\"openid\":\""+param.get("openid")
+            map.put("pay_extra", "");
+            //map.put("pay_extra", URLEncoder.encode( pay_extra,"UTF-8"));
+            map.put("expire_time", expireTime);
+            map.put("goods_name",  body);
+            map.put("clear_cycle", "0");
+            map.put("jump_scheme", "hemacash://hmpay");
+            map.put("sign",  URLEncoder.encode(rsa,"UTF-8"));
+            map.put("meta_option", URLEncoder.encode( "[{\"s\":\"Android\",\"n\":\"HOBBYSTOCKS\",\"id\":\"com.hobbystocks\",\"sc\":\"\"},{\"s\":\"IOS\",\"n\":\"HOBBYSTOCKS\",\"id\":\"com.hobbystocks\",\"sc\":\"\"}]","UTF-8"));
+            String paymentUrl = "";
+            if(paymentRequestDto.getPayWay().contains("alipay")){
+                map.put("product_code", "01020002");//支付宝H5
+                // 支付宝app 01020004
+                paymentUrl = "https://cash.sandgate.cn/h5/?"+BeanUtil.param2str(map)+"#/hippoh5";
+            }else{
+                map.put("product_code", "01010006");//云函数
+                paymentUrl = "https://cash.sandgate.cn/h5/?"+BeanUtil.param2str(map)+"#/applet";
+            }
+            //return "https://cash.sandgate.cn/h5/?"+retStr+"#/applet";
+//            return "https://cash.sandgate.cn/h5/?"+retStr+"#/sandcashier1";
+//            return "https://cash.sandgate.cn/h5/?"+retStr+"#/hippoPublic";
+            Map dataMap = new HashMap();
+            dataMap.put("hmUrl", paymentUrl);
+            resultMap.put("data", dataMap);
+            return resultMap;
+        } catch (AlipayApiException e) {
+            e.printStackTrace();
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return ResultMap.error("下单失败!");
+    }
+    /**
+     * 退款
+     * @param refundRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap refundOrder(RefundRequestDto refundRequestDto) {
+        HmPayConfig hmPayConfig = (HmPayConfig) refundRequestDto.getPayConfigByClass(HmPayConfig.class);
+        /*String appid = (String) param.getOrDefault("appid",null);
+        HmPayConfig hmPayConfig = (HmPayConfig) payConfig.get(appid);
+        if(null == hmPayConfig){
+            hmPayConfig = this.hmPayConfig;
+        }*/
+        BigDecimal totalAmount = refundRequestDto.getRefundAmount();
+        String outOrderNo = refundRequestDto.getOrderNo();
+        String refund_request_no = refundRequestDto.getRefundNo();
+        String method = TradeApiMethodEnums.TRADE_REFUND.getMethod();
+        String refundMsg = refundRequestDto.getRefundMsg();
+        TradeRequest tradeRequest = TradeRequest
+                .builder()
+                .appId(hmPayConfig.getApp_id())
+                .format(hmPayConfig.getFormat())
+                .charset("utf-8")
+                .method(method)
+                .signType("RSA")
+                .timestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .nonce(String.valueOf(System.currentTimeMillis()))
+                .bizContent(
+                        TradeRefundRequest
+                                .builder()
+                                .outOrderNo(outOrderNo)
+                                .refundAmount(Double.valueOf(String.valueOf(totalAmount.setScale(2, BigDecimal.ROUND_UP).doubleValue())))
+                                .refundRequestNo(refund_request_no)
+                                .refundReason(refundMsg)
+                                .storeId(hmPayConfig.getStoreId())
+                                .build()
+                                .toJsonString()
+                )
+                .version(hmPayConfig.getVersion())
+                .build()
+                .buildSign(hmPayConfig.getPrivateKey());
+        TradeResponse tradeResponse = hmpayClient.execute(tradeRequest);
+        String errMsg = "";
+        if(StringUtils.isNotEmpty(tradeResponse.getCode()) && "200".equals(tradeResponse.getCode()) ){
+            boolean b = RsaUtil.rsaCheckV2(tradeResponse.toMap(), hmPayConfig.getHmPublicKey(), TradeContants.CHARSET);
+            log.info("验签结果:" + b);
+            if(b) {
+                //请求成功:
+                Map<String, String> stringStringMap = tradeResponse.toMap();
+                if (null != stringStringMap && !stringStringMap.isEmpty()) {
+                    String data = stringStringMap.get("data");
+                    JSONObject jsonObject = JSONObject.parseObject(data);
+                    String code = jsonObject.getString("sub_code");
+                    if ("REFUND_SUCCESS".equals(code)) {
+                        stringStringMap.put("out_refund_no", String.valueOf(jsonObject.get("refund_request_no")));
+                        stringStringMap.put("refund_id", String.valueOf(jsonObject.get("refund_plat_trx_no")));
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(jsonObject.get("refund_settle_amount"))) * 100));
+                        stringStringMap.put("fund_change", "Y");
+                        //退款成功
+                        return ResultMap.ok()
+                                .put("data", stringStringMap)
+                                ;
+                    } else {
+                        errMsg = stringStringMap.get("sub_msg");
+                    }
+                } else if (null == stringStringMap) {
+                    errMsg = "退款请求失败!";
+                } else {
+                    errMsg = stringStringMap.get("sub_msg");
+                }
+            }else {
+                errMsg = "退款错误[SIGN ERROR],请联系开发人员!";
+            }
+        }else{
+            errMsg = tradeResponse.getMsg();
+        }
+        return ResultMap.error(errMsg)
+                ;
+    }
+
+    /**
+     * 查询订单信息
+     */
+    @Override
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto){
+//        HmPayConfig hmPayConfig = (HmPayConfig) payConfig.get(paymentRequestDto.getAppid());
+        HmPayConfig hmPayConfig = (HmPayConfig) paymentRequestDto.getPayConfigByClass(HmPayConfig.class);
+        if(null == hmPayConfig){
+            hmPayConfig = this.hmPayConfig;
+        }
+        String platTrxNo = "";
+        String bankOrderNo = "";
+        String method = TradeApiMethodEnums.TRADE_QUERY.getMethod();
+        TradeRequest tradeRequest = TradeRequest
+                .builder()
+                .appId(hmPayConfig.getApp_id())
+                .format(hmPayConfig.getFormat())
+                .charset("utf-8")
+                .method(method)
+                .signType("RSA")
+                .timestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
+                .nonce(String.valueOf(System.currentTimeMillis()))
+                .bizContent(
+                        TradeQueryRequest
+                                .builder()
+                                .outOrderNo(paymentRequestDto.getOrderNo())
+                                .platTrxNo(platTrxNo)
+                                .bankOrderNo(bankOrderNo)
+                                .build()
+                                .toJsonString()
+                )
+                .version(hmPayConfig.getVersion())
+                .build()
+                .buildSign(hmPayConfig.getPrivateKey());
+        TradeResponse tradeResponse = hmpayClient.execute(tradeRequest);
+        String errMsg = "";
+        if(StringUtils.isNotEmpty(tradeResponse.getCode()) && "200".equals(tradeResponse.getCode()) ){
+            boolean b = RsaUtil.rsaCheckV2(tradeResponse.toMap(), hmPayConfig.getHmPublicKey(), TradeContants.CHARSET);
+            log.info("验签结果:" + b);
+            if(b){
+                //请求成功:
+                Map<String, String> stringStringMap = tradeResponse.toMap();
+                if(null != stringStringMap && !stringStringMap.isEmpty()){
+                    String data = stringStringMap.get("data");
+                    JSONObject jsonObject = JSONObject.parseObject(data);
+                    String code = jsonObject.getString("sub_code");
+                    if("SUCCESS".equals(code)){
+                        //查询
+                        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+                        paymentInfoResponseDto.setSuccess(true);
+                        paymentInfoResponseDto.setOrderNo(paymentRequestDto.getOrderNo());
+                        paymentInfoResponseDto.setPayWay(jsonObject.getString("pay_way_code"));
+                        paymentInfoResponseDto.setAppid(hmPayConfig.getApp_id());
+                        paymentInfoResponseDto.setPaymentNo(jsonObject.getString("plat_trx_no"));
+                        paymentInfoResponseDto.setPaymentPrice(new BigDecimal(jsonObject.getDouble("total_amount")));
+                        paymentInfoResponseDto.setActualPayment(new BigDecimal(jsonObject.getDouble("total_amount")));
+                        //                        paymentInfoResponseDto.setPaymentTime();
+                        SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMddHHmmss");
+                        try {
+                            paymentInfoResponseDto.setPaymentSuccessTime(sdf.parse(jsonObject.getString("success_time")));
+                        } catch (ParseException e) {
+                            e.printStackTrace();
+                        }
+                        return paymentInfoResponseDto;
+                    }else{
+                        errMsg = stringStringMap.get("sub_msg");
+                    }
+                }else if(null == stringStringMap){
+                    errMsg = "查询请求失败!";
+                }else{
+                    errMsg = stringStringMap.get("sub_msg");
+                }
+            }else {
+                errMsg = "退款错误[SIGN ERROR],请联系开发人员!";
+            }
+        }else{
+            errMsg = tradeResponse.getMsg();
+        }
+        return PaymentInfoResponseDto.error(-2,errMsg);
+    }
+
+
+}

+ 946 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/PaymentServiceImpl.java

@@ -0,0 +1,946 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.common.utils.StringUtils;
+import com.tzy.common.utils.http.HttpClientUtil;
+import com.tzy.framework.pay.config.PayConfig;
+import com.tzy.framework.pay.dto.*;
+import com.tzy.framework.pay.service.PaymentBaseService;
+import com.tzy.framework.pay.service.PaymentService;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 支付
+ */
+@Slf4j
+@Service("paymentManagerServiceImpl")
+public class PaymentServiceImpl<T> extends PaymentBaseService implements PaymentService<T> {
+
+    @Override
+    public T initPayConfigs(String payWay, Class<T> tClass){
+        return JSONObject.parseObject(sysBaseService.getAppMenuByCode(payWay),tClass);
+    }
+
+    /**
+     * 预加载支付配置
+     * @return
+     */
+    @PostConstruct
+    public void initDefaultPayConfig(){
+        PayConfig payConfig1 = payConfig;
+        log.debug(" 加载支付配置 payConfig {} ",payConfig);
+        //System.out.println("--------");
+    }
+
+    /**
+     * 统一下单
+     * 调用不同的支付方式
+     * @param paymentRequestDto
+     */
+    @Override
+    public ResultMap unifiedOrder(PaymentRequestDto paymentRequestDto){
+        if(null != paymentRequestDto)
+        {
+            return unifiedOrderNew(paymentRequestDto);
+        }
+        return ResultMap.error(-1,"下单失败");
+    }
+
+    /**
+     * 查询订单
+     * 调用不同的支付方式
+     * @param payWay
+     * @param orderNo
+     */
+    @Override
+    public PaymentInfoResponseDto queryPaymentOrder(String payWay, String orderNo){
+        if(StringUtils.isNotEmpty(payWay)){
+            return queryPaymentOrderNew(payWay, orderNo);
+        }
+        return PaymentInfoResponseDto.error(-1, "下单失败");
+    }
+
+    /**
+     * 退款
+     * 调用不同的支付方式
+     * @param payWay
+     * @param orderNo
+     * @param refundAmount
+     * @param refundMsg
+     * @return
+     */
+    @Deprecated
+    @Override
+    public ResultMap refund(String payWay, String orderNo, BigDecimal orderPrice, BigDecimal refundAmount,String refundMsg){
+        if(StringUtils.isNotEmpty(payWay)){
+            return refundNew(payWay, orderNo, orderPrice, refundAmount, refundMsg);
+        }
+        return  ResultMap.error(-1, "下单失败");
+    }
+
+    /**
+     * 关闭订单
+     * @param payWay
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public ResultMap close(String payWay, String orderNo){
+        if(StringUtils.isNotEmpty(payWay)){
+            return closeNew(payWay, orderNo);
+        }
+        return ResultMap.error(-1, "下单失败");
+    }
+
+    /**
+     * 查询退款订单
+     * @param payWay
+     * @param tradeNo
+     * @param refundNo
+     * @return
+     */
+    @Override
+    public ResultMap refundQuery(String payWay,String tradeNo ,String refundNo){
+        if(StringUtils.isNotEmpty(payWay)){
+            RefundRequestDto refundRequestDto = new RefundRequestDto();
+            refundRequestDto.setPayWay(payWay);
+            refundRequestDto.setTradeNo(tradeNo);
+            refundRequestDto.setPayWay(refundNo);
+            return refundQueryNew(refundRequestDto);
+        }
+        return ResultMap.error(-1, "下单失败");
+    }
+
+    /**
+     * 查询订单
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public PaymentInfoResponseDto queryPaymentOrder(PaymentRequestDto paymentRequestDto) {
+        if(null != paymentRequestDto){
+            return queryPaymentOrderNew(paymentRequestDto);
+        }
+        return PaymentInfoResponseDto.error(-1, "下单失败");
+    }
+    @Deprecated
+    @Override
+    public ResultMap close(PaymentRequestDto paymentRequestDto) {
+        if(null != paymentRequestDto){
+            return closeNew(paymentRequestDto);
+        }
+        return ResultMap.error(-1, "下单失败");
+    }
+    @Deprecated
+    @Override
+    public ResultMap refund(RefundRequestDto refundRequestDto) {
+        if(null != refundRequestDto){
+            return refundNew(refundRequestDto);
+        }
+        return ResultMap.error(-1, "下单失败");
+    }
+
+    @Override
+    public ResultMap refundQuery(RefundRequestDto refundRequestDto) {
+        if(null != refundRequestDto){
+            return refundQueryNew(refundRequestDto);
+        }
+        return ResultMap.error(-1, "下单失败");
+    }
+
+    /*********************新支付逻辑*******************/
+
+    //获取银行列表
+    public ResultMap getBankList(PaymentRequestDto paymentRequestDto){
+        ResultMap resultMap = new ResultMap();
+        try {
+            String paymentType = paymentRequestDto.getPayWay();
+            paymentRequestDto.setPayConfig(initPayConfig(paymentType));
+            if (paymentType.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
+                resultMap = baoFooBankPayService.getBankList(paymentRequestDto);
+            } else {
+                resultMap = ResultMap.error(-1, "不支持手机银行支付");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = ResultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+
+    public ResultMap readPay(PaymentRequestDto paymentRequestDto){
+        ResultMap resultMap = new ResultMap();
+        try {
+            String paymentType = paymentRequestDto.getPayWay();
+            paymentRequestDto.setPayConfig(initPayConfig(paymentType));
+            if (paymentType.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
+                resultMap = bankService.ReadyPay(paymentRequestDto);
+                resultMap.put("payWay","agreement");
+            } else {
+                Map<String ,String> header = new HashMap<>();
+                header.put("Content-Type","application/json");
+                //调用接口进行下单
+                String readPayResult = HttpClientUtil.httpRequest(readPayUrl, "POST", JSONObject.toJSONString(paymentRequestDto), header);
+                log.info(" 调用支付服务预下单 ",readPayResult);
+//                resultMap = ResultMap.error(-1, "不支持该类型");
+                resultMap = JSONObject.parseObject(readPayResult, ResultMap.class);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = ResultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+    public ResultMap confirmPay(PaymentRequestDto paymentRequestDto){
+        ResultMap resultMap = new ResultMap();
+        try {
+            String paymentType = paymentRequestDto.getPayWay();
+            paymentRequestDto.setPayConfig(initPayConfig(paymentType));
+            if (paymentType.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
+                resultMap = bankService.ConfirmPay(paymentRequestDto);
+            } else {
+                resultMap = ResultMap.error(-1, "不支持该类型");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = ResultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+    /**
+     * 统一下单
+     * 调用不同的支付方式
+     * @param paymentRequestDto
+     */
+    @Override
+    public ResultMap unifiedOrderNew(PaymentRequestDto paymentRequestDto){
+        ResultMap resultMap = new ResultMap();
+        try{
+            RechargeUserInfoDto rechargeUserInfoDto = paymentRequestDto.getRechargeUserInfoDto();
+            if( null != rechargeUserInfoDto && rechargeUserInfoDto.isCheckUserAuth()
+                    && ( StringUtils.isEmpty(rechargeUserInfoDto.getUserName())
+                    || StringUtils.isEmpty(rechargeUserInfoDto.getCertificateNo()))){
+                //如果需要进行身份信息验证
+                return ResultMap.error(100401, "请用户先进行身份验证!");
+            }
+            String paymentType = paymentRequestDto.getPayWay();
+            /*if(null != paymentRequestDto.getMerchantId()){
+                //如果有商家id
+                MerchantDto merchantDto = sysBaseService.selectMerchantInfo(paymentRequestDto.getMerchantId());
+                if(null != merchantDto && StringUtils.isNotEmpty( merchantDto.getPay_config())){
+                    String[] split = merchantDto.getPay_config().split(",");
+                    paymentType = split[0];
+                    paymentRequestDto.setPayWay(paymentType);
+                }
+            }*/
+            paymentRequestDto.setPayConfig(initPayConfig(paymentType));
+            paymentRequestDto.setAppid(payConfig.getAppidByPayType(paymentType));
+            //判断是否是直连 【默认备用为直连】
+            if(paymentType.contains("alipay-spare")){
+                paymentType = "alipay";
+            }else if(paymentType.contains("wxpay-spare")){
+                paymentType = "wxpay";
+            }else
+            if(paymentType.contains("alipay-web-spare")){
+                paymentType = "alipay";
+            }
+            int payWay = 0;
+            if (paymentType.contains("wxpay-hm")) { //杉德-微信
+                resultMap = hmPayService.tradeCreateNew(paymentRequestDto);
+                payWay = 3;
+            } else if (paymentType.contains("alipay-hm")) { //杉德-支付宝
+                resultMap = hmPayService.tradeCreateNew(paymentRequestDto);
+                payWay = 4;
+            } else if (paymentType.contains("alipay-applet-qm")) { //全民-支付宝调小程序
+                resultMap = qmPayService.tradeCreateNew(paymentRequestDto);
+                JSONObject appPayRequest = (JSONObject) resultMap.get("appPayRequest");
+                appPayRequest.put("appScheme", "hobbystocks");
+                resultMap.put("appPayRequest", appPayRequest);
+                payWay = 7;
+            } else if (paymentType.contains("alipay-qme1")) { //全民支付宝-易一
+                paymentRequestDto.setPaySubWay("ALI_LITE_FACE");//⽀付宝⼩程序⾯对⾯
+                resultMap = qme1PayService.tradeCreate(paymentRequestDto);
+                payWay = 10;
+            } else if (paymentType.contains("wxpay-main-bf")) { //宝付-微信-主扫
+                resultMap = bfPayService.tradeCreateNew(paymentRequestDto);
+                payWay = 9;
+            } else if (paymentType.contains("alipay-main-bf")) { //宝付-支付宝-主扫
+                resultMap = bfPayService.tradeCreateNew(paymentRequestDto);
+                payWay = 10;
+            } else if (paymentType.contains("uac-main-bf")) { //宝付-云闪付-主扫
+                resultMap = bfPayService.tradeCreateNew(paymentRequestDto);
+                payWay = 11;
+            } else if (paymentType.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
+                paymentRequestDto.setPaySubWay(PayConstants.BFPAY_ALIPAY_NATIVE);
+                resultMap = baoFooPayService.unifiedOrder(paymentRequestDto);
+                payWay = 10;
+            } else if (paymentType.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
+                paymentRequestDto.setPaySubWay(PayConstants.BFPAY_QUICK_PASS_NATIVEE);
+                resultMap = baoFooPayService.unifiedOrder(paymentRequestDto);
+                payWay = 11;
+            } else if (paymentType.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
+                resultMap = baoFooBankPayService.unifiedOrder(paymentRequestDto);
+                payWay = 18;
+            } else if (paymentType.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
+                paymentRequestDto.setPaySubWay("ALIPAY_NATIVE");//支付包主扫
+                resultMap = baofooRechargePayService.payment(paymentRequestDto);
+                payWay = 10;
+            } else if (paymentType.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
+//                paymentRequestDto.setPaySubWay("CARD");//银行卡支付
+                resultMap = baofooRechargePayService.paymentSplitApi(paymentRequestDto);
+                resultMap.put("payWay","webview");
+                payWay = -1;
+            } else if (paymentType.contains("alipay-qm-h5")) { //全民-支付宝h5
+                resultMap = qmH5PayService.tradeCreateNew(paymentRequestDto);
+                JSONObject qmH5PayRequest = (JSONObject) resultMap.get("appPayRequest");
+                resultMap.put("qmH5PayRequest", qmH5PayRequest);
+                payWay = 12;
+            } else if (paymentType.contains("uac-qm-h5")) { //全民-云闪付h5
+                resultMap = qmH5PayService.tradeCreateNew(paymentRequestDto);
+                JSONObject uacH5PayRequest = (JSONObject) resultMap.get("appPayRequest");
+                resultMap.put("qmUacH5Request", uacH5PayRequest);
+                payWay = 13;
+            } else if (paymentType.contains("wxpay-qm-h5")) { //全民-支付宝h5
+                resultMap = qmH5PayService.tradeCreateNew(paymentRequestDto);
+                JSONObject qmH5PayRequest = (JSONObject) resultMap.get("appPayRequest");
+                resultMap.put("qmH5PayRequest", qmH5PayRequest);
+                payWay = 15;
+            } else if (paymentType.contains("uac-qm")) { //全民-云闪付
+                resultMap = qmPayService.tradeCreateNew(paymentRequestDto);
+                JSONObject uacPayRequest = (JSONObject) resultMap.get("appPayRequest");
+                uacPayRequest.put("appScheme", "hobbystocks");
+                resultMap.put("appPayRequest", uacPayRequest);
+                payWay = 8;
+            } else if (paymentType.contains("wxpay-qm")) { //全民-微信
+                resultMap = qmPayService.tradeCreateNew(paymentRequestDto);
+                payWay = 5;
+            } else if (paymentType.contains("alipay-qm")) { //全民-支付宝
+                resultMap = qmPayService.tradeCreateNew(paymentRequestDto);
+                payWay = 6;
+            } else if (paymentType.contains("alipay-hf") ) { //汇付-支付宝
+                paymentRequestDto.setPayWay("alipay");
+                resultMap = hfPayService.tradeCreate(paymentRequestDto);//需要在启动服务时加载配置,后续修改
+                payWay = 14;
+            } else if (paymentType.contains("alipay-web-spare") ) { //支付宝
+                resultMap = alipayApiService.unifiedOrderNew(paymentRequestDto);
+                paymentType = (String) resultMap.getOrDefault("paySubType", "alipay");
+                payWay = 14;
+            } else if ("wxpay".equals(paymentType)) { //微信
+                resultMap = wxPayService.unifiedOrderNew(paymentRequestDto);
+                paymentType = (String) resultMap.getOrDefault("paySubType", "wxpay");
+                payWay = 1;
+            } else if ("alipay".equals(paymentType)) { //支付宝
+                resultMap = alipayApiService.unifiedOrderNew(paymentRequestDto);
+                paymentType = (String) resultMap.getOrDefault("paySubType", "alipay");
+                payWay = 2;
+            } else {
+                payWay = 0;
+                paymentType = "";
+                resultMap = ResultMap.error(-1, "未找到支付类型");
+            }
+            if(payWay > -1) resultMap.put("payWay", payWay);
+            resultMap.put("paymentSubType", paymentType);
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = ResultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+
+    /**
+     * 查询订单
+     * 调用不同的支付方式
+     * @param payWay
+     * @param orderNo
+     */
+    @Override
+    public PaymentInfoResponseDto queryPaymentOrderNew(String payWay, String orderNo){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        try{
+            String appid = payConfig.getAppidByPayType(payWay);
+            PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
+            paymentRequestDto.setPayWay(payWay);
+            paymentRequestDto.setAppid(appid);
+            paymentRequestDto.setOrderNo(orderNo);
+            //
+            try{
+                return queryPost(paymentRequestDto);
+            }catch (Exception e){
+                log.warn(" 不是新支付模块通道【查询订单】 ");
+            }
+            paymentRequestDto.setPayConfig(initPayConfig(payWay));//从数据库加载数据
+            if (payWay.contains("wxpay-hm")) { //杉德-微信
+                paymentInfoResponseDto = hmPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-hm")) { //杉德-支付宝
+                paymentInfoResponseDto = hmPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-applet-qm")) { //全民-支付宝调小程序
+                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-qme1")) { //全民支付宝-易一
+                paymentRequestDto.setPaySubWay("ALI_LITE_FACE");//⽀付宝⼩程序⾯对⾯
+                paymentInfoResponseDto = qme1PayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("uac-qm")) { //全民-云闪付
+                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("wxpay-main-bf")) { //宝付-微信-主扫
+                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-main-bf")) { //宝付-支付宝-主扫
+                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("uac-main-bf")) { //宝付-云闪付-主扫
+                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-qm-h5")) { //全民-h5
+                paymentInfoResponseDto = qmH5PayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("uac-qm-h5")) { //全民-h5
+                paymentInfoResponseDto = qmH5PayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("wxpay-qm")) { //全民-微信
+                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-qm")) { //全民-支付宝
+                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-hf")) { //汇付-支付宝
+                paymentInfoResponseDto = hfPayService.queryOrder(appid, payWay, orderNo);//暂时不能优化, 需要找到解决办法
+            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
+                paymentInfoResponseDto = alipayApiService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
+                paymentInfoResponseDto = baoFooPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
+                paymentInfoResponseDto = baoFooPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
+                paymentInfoResponseDto = baoFooBankPayService.queryOrder(paymentRequestDto);
+            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
+                paymentInfoResponseDto = bofooAgreementService.QueryOrder(paymentRequestDto);
+            } else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
+                ResultMap resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
+                if((boolean)resultMap.get("state")){
+                    paymentInfoResponseDto.setOrderNo(paymentRequestDto.getOrderNo());
+                    paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
+                    paymentInfoResponseDto.setPaymentNo(String.valueOf(resultMap.get("paymentNo")));
+                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(String.valueOf(resultMap.get("paymentPrice"))));
+                    paymentInfoResponseDto.setActualPayment(new BigDecimal(String.valueOf(resultMap.get("actualPayment"))));
+                    paymentInfoResponseDto.setPaymentSuccessTime((Date) resultMap.get("paymentSuccessTime"));
+                }else{
+                    paymentInfoResponseDto = PaymentInfoResponseDto.error((Integer) resultMap.get("code"), String.valueOf(resultMap.get("msg")));
+                }
+            } else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
+                ResultMap resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
+                if((boolean)resultMap.get("state")){
+                    paymentInfoResponseDto.setOrderNo(paymentRequestDto.getOrderNo());
+                    paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
+                    paymentInfoResponseDto.setPaymentNo(String.valueOf(resultMap.get("paymentNo")));
+                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(String.valueOf(resultMap.get("paymentPrice"))));
+                    paymentInfoResponseDto.setActualPayment(new BigDecimal(String.valueOf(resultMap.get("actualPayment"))));
+                    paymentInfoResponseDto.setPaymentSuccessTime((Date) resultMap.get("paymentSuccessTime"));
+                }else{
+                    paymentInfoResponseDto = PaymentInfoResponseDto.error((Integer) resultMap.get("code"), String.valueOf(resultMap.get("msg")));
+                }
+            } else  if ("wxpay".equals(payWay)) { //微信
+                paymentInfoResponseDto = wxPayService.queryOrder(paymentRequestDto);
+            } else if ("alipay".equals(payWay)) { //支付宝
+                paymentInfoResponseDto = alipayApiService.queryOrder(paymentRequestDto);
+            } else {
+                paymentInfoResponseDto = paymentInfoResponseDto.error(-1, "未找到支付类型");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            paymentInfoResponseDto = paymentInfoResponseDto.error(-1, "下单失败");
+        }
+        return paymentInfoResponseDto;
+    }
+
+    /**
+     * 退款
+     * 调用不同的支付方式
+     * @param payWay
+     * @param orderNo
+     * @param refundAmount
+     * @param refundMsg
+     * @return
+     */
+    @Override
+    @Deprecated
+    public ResultMap refundNew(String payWay, String orderNo, BigDecimal orderPrice, BigDecimal refundAmount,String refundMsg){
+        ResultMap resultMap = new ResultMap();
+//        Map<String, Object> refundParam = new HashMap<>();
+        RefundRequestDto refundRequestDto = new RefundRequestDto();
+        refundRequestDto.setRefundNo(RandomUtil.getRandom(RandomUtil.REFUND_NO));
+        refundRequestDto.setOrderNo(orderNo);
+        refundRequestDto.setPayWay(payWay);
+        refundRequestDto.setOrderPrice(orderPrice);
+        refundRequestDto.setRefundAmount(refundAmount);
+        refundRequestDto.setRefundMsg(refundMsg);
+        refundRequestDto.setTradeNo(orderNo);
+        refundRequestDto.setPayConfig(initPayConfig(payWay));
+        try{
+            String appid = payConfig.getAppidByPayType(payWay);
+            if (payWay.contains("wxpay-hm") ) { //杉德-微信
+//                refundParam.put("totalAmount", refundAmount);
+//                refundParam.put("orderNo", orderNo);
+//                refundParam.put("refund_request_no", RandomUtil.getRandom(RandomUtil.REFUND_NO));
+//                refundParam.put("refundMsg", refundMsg);
+                resultMap = hmPayService.refundOrder(refundRequestDto);
+            } else if (payWay.contains("alipay-hm" )) { //杉德-支付宝
+//                refundParam.put("totalAmount", refundAmount);
+//                refundParam.put("orderNo", orderNo);
+//                refundParam.put("refund_request_no", RandomUtil.getRandom(RandomUtil.REFUND_NO));
+//                refundParam.put("refundMsg", refundMsg);
+                resultMap = hmPayService.refundOrder(refundRequestDto);
+            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
+                resultMap = qmPayService.refund(refundRequestDto);
+            } else if (payWay.contains("wxpay-main-bf" )) { //宝付-微信-主扫
+                resultMap = bfPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-main-bf" )) { //宝付-支付宝-主扫
+                resultMap = bfPayService.refund(refundRequestDto);
+            } else if (payWay.contains("uac-main-bf" )) { //宝付-云闪付-主扫
+                resultMap = bfPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-qm-h5" )) { //全民-h5
+                resultMap = qmH5PayService.refund(refundRequestDto);
+            } else if (payWay.contains("uac-qm-h5" )) { //全民-h5
+                resultMap = qmH5PayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-qme1")) { //全民支付宝-易一
+                resultMap = qme1PayService.refund(refundRequestDto);
+            } else if (payWay.contains("wxpay-qm" )) { //全民-微信
+                resultMap = qmPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-qm" )) { //全民-支付宝
+                resultMap = qmPayService.refund(refundRequestDto);
+            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
+                resultMap = qmPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-hf" )) { //汇付-支付宝
+                resultMap = hfPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
+                resultMap = alipayApiService.aliRefundNotify(refundRequestDto);
+            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
+                resultMap = baoFooPayService.refund(refundRequestDto);
+            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
+                resultMap = baoFooPayService.refund(refundRequestDto);
+            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
+                resultMap = baoFooBankPayService.refund(refundRequestDto);
+            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
+                resultMap = bofooAgreementService.OrderRefund(refundRequestDto);
+            }else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
+                resultMap = baofooRechargePayService.profitShareRefundApply(refundRequestDto);
+            }else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
+                resultMap = baofooRechargePayService.profitShareRefundApply(refundRequestDto);
+            } else if ("wxpay".equals(payWay)) { //微信
+                resultMap = wxPayService.wxRefund(refundRequestDto);
+            } else if ("alipay".equals(payWay)) { //支付宝
+                resultMap = alipayApiService.aliRefundNotify(refundRequestDto);
+            } else {
+                resultMap = resultMap.error(-1, "未找到支付类型");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = resultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+
+    /**
+     * 关闭订单
+     * @param payWay
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public ResultMap closeNew(String payWay, String orderNo){
+        ResultMap resultMap = new ResultMap();
+        try{
+            String appid = payConfig.getAppidByPayType(payWay);
+            PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
+            paymentRequestDto.setPayWay(payWay);
+            paymentRequestDto.setOrderNo(orderNo);
+            paymentRequestDto.setPayConfig(initPayConfig(payWay));
+            paymentRequestDto.setAppid(payConfig.getAppidByPayType(payWay));
+            //杉德-微信
+            //杉德-支付宝
+            if ("wxpay".equals(payWay)) { //微信
+                resultMap = wxPayService.closeOrderNew(appid, orderNo);
+            } else if ("alipay".equals(payWay)) { //支付宝
+                resultMap = alipayApiService.closeTradeOrderNew(appid, orderNo);
+            } else if ("wxpay-hm".equals(payWay)) {
+            } else if ("alipay-hm".equals(payWay)) {
+            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
+                resultMap = qmPayService.colseNew(paymentRequestDto);
+            } else if ("alipay-qm-h5".equals(payWay)) { //全民-h5
+                resultMap = qmH5PayService.colse(appid, payWay, orderNo);
+            } else if ("uac-qm-h5".equals(payWay)) { //全民-h5
+                resultMap = qmH5PayService.colse(appid, payWay, orderNo);
+            } else if ("wxpay-qm".equals(payWay)) { //全民-微信
+                resultMap = qmPayService.colse(appid, payWay, orderNo);
+            } else if ("alipay-qm".equals(payWay)) { //全民-支付宝
+                resultMap = qmPayService.colse(appid, payWay, orderNo);
+            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
+                resultMap = qmPayService.colseNew(paymentRequestDto);
+            } else if ("alipay-hf".equals(payWay)) { //汇付-支付宝
+                resultMap = hfPayService.close(paymentRequestDto);
+            } else {
+                resultMap = resultMap.error(-1, "未找到支付类型");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = resultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+
+    /**
+     * 查询退款订单
+     * @param payWay
+     * @param tradeNo
+     * @param refundNo
+     * @return
+     */
+    @Override
+    public ResultMap refundQueryNew(String payWay,String tradeNo ,String refundNo){
+        ResultMap resultMap = new ResultMap();
+        try{
+            String appid = payConfig.getAppidByPayType(payWay);
+            RefundRequestDto refundRequestDto = new RefundRequestDto();
+            refundRequestDto.setAppid(appid);
+            refundRequestDto.setPayWay(payWay);
+            refundRequestDto.setRefundNo(refundNo);
+            refundRequestDto.setTradeNo(tradeNo);
+            refundRequestDto.setMerOrderId(tradeNo);
+            refundRequestDto.setPayConfig(initPayConfig(payWay));
+            //微信
+            //支付宝
+            //杉德-微信
+            //杉德-支付宝
+            if (payWay.contains("wxpay-hm")) {
+                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else if (payWay.contains("alipay-hm" )) {
+                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
+                resultMap = qmPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("wxpay-main-bf" )) { //宝付-微信-主扫
+                resultMap = bfPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-main-bf" )) { //宝付-支付宝-主扫
+                resultMap = bfPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("uac-main-bf" )) { //宝付-云闪付-主扫
+                resultMap = bfPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-qm-h5" )) { //全民-h5
+                resultMap = qmH5PayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("uac-qm-h5" )) { //全民-h5
+                resultMap = qmH5PayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-qme1")) { //全民支付宝-易一
+                resultMap = qme1PayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("wxpay-qm" )) { //全民-微信
+                resultMap = qmPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-qm" )) { //全民-支付宝
+                resultMap = qmPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
+                resultMap = qmPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-hf" )) { //汇付-支付宝
+                resultMap = hfPayService.queryRefund(refundRequestDto);
+            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
+                resultMap = baoFooPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
+                resultMap = baoFooPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
+                resultMap = baoFooBankPayService.refundQuery(refundRequestDto);
+            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
+                resultMap = bofooAgreementService.queryRefund(refundRequestDto);
+            } else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
+                PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
+                paymentRequestDto.setPayConfig(refundRequestDto.getPayConfig());
+                paymentRequestDto.setOrderNo(refundNo);
+                resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
+                PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
+                paymentRequestDto.setPayConfig(refundRequestDto.getPayConfig());
+                paymentRequestDto.setOrderNo(refundNo);
+                resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
+                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else if ("wxpay".equals(payWay)) {
+                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else if ("alipay".equals(payWay)) {
+                resultMap = alipayApiService.queryRefundOrder(refundRequestDto);
+//                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else {
+                resultMap = resultMap.error(-1, "未找到支付类型");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = resultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+
+    /**
+     * 查询订单
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public PaymentInfoResponseDto queryPaymentOrderNew(PaymentRequestDto paymentRequestDto) {
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        try{
+            String payWay = paymentRequestDto.getPayWay();
+            paymentRequestDto.setPayConfig(initPayConfig(payWay));//从数据库加载数据
+            if (payWay.contains("wxpay-hm")) { //杉德-微信
+                paymentInfoResponseDto = hmPayService.queryOrder(paymentRequestDto);
+            } else if ("alipay-hm".equals(payWay)) { //杉德-支付宝
+                paymentInfoResponseDto = hmPayService.queryOrder(paymentRequestDto);
+            } else if ("alipay-applet-qm".equals(payWay)) { //全民-支付宝调小程序
+                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
+            } else if ("wxpay-main-bf".equals(payWay)) { //宝付-微信-主扫
+                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
+            } else if ("alipay-main-bf".equals(payWay)) { //宝付-支付宝-主扫
+                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
+            } else if ("uac-main-bf".equals(payWay)) { //宝付-云闪付-主扫
+                paymentInfoResponseDto = bfPayService.queryOrder(paymentRequestDto);
+            } else if ("alipay-qm-h5".equals(payWay)) { //全民-h5
+                paymentInfoResponseDto = qmH5PayService.queryOrder(paymentRequestDto);
+            } else if ("uac-qm-h5".equals(payWay)) { //全民-h5
+                paymentInfoResponseDto = qmH5PayService.queryOrder(paymentRequestDto);
+            } else if ("wxpay-qm".equals(payWay)) { //全民-微信
+                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
+            } else if ("alipay-qm".equals(payWay)) { //全民-支付宝
+                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
+            } else if ("uac-qm".equals(payWay)) { //全民-云闪付
+                paymentInfoResponseDto = qmPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
+                paymentInfoResponseDto = alipayApiService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
+                paymentInfoResponseDto = baoFooPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
+                paymentInfoResponseDto = baoFooPayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
+                paymentInfoResponseDto = baoFooBankPayService.queryOrder(paymentRequestDto);
+            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
+                paymentInfoResponseDto = bofooAgreementService.QueryOrder(paymentRequestDto);
+            } else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
+                ResultMap resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
+                if((boolean)resultMap.get("state")){
+                    paymentInfoResponseDto.setOrderNo(paymentRequestDto.getOrderNo());
+                    paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
+                    paymentInfoResponseDto.setPaymentNo(String.valueOf(resultMap.get("paymentNo")));
+                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(String.valueOf(resultMap.get("paymentPrice"))));
+                    paymentInfoResponseDto.setActualPayment(new BigDecimal(String.valueOf(resultMap.get("actualPayment"))));
+                    paymentInfoResponseDto.setPaymentSuccessTime((Date) resultMap.get("paymentSuccessTime"));
+                }else{
+                    paymentInfoResponseDto = PaymentInfoResponseDto.error((Integer) resultMap.get("code"), String.valueOf(resultMap.get("msg")));
+                }
+            } else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
+                ResultMap resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
+                if((boolean)resultMap.get("state")){
+                    paymentInfoResponseDto.setOrderNo(paymentRequestDto.getOrderNo());
+                    paymentInfoResponseDto.setPayWay(paymentRequestDto.getPayWay());
+                    paymentInfoResponseDto.setPaymentNo(String.valueOf(resultMap.get("paymentNo")));
+                    paymentInfoResponseDto.setPaymentPrice(new BigDecimal(String.valueOf(resultMap.get("paymentPrice"))));
+                    paymentInfoResponseDto.setActualPayment(new BigDecimal(String.valueOf(resultMap.get("actualPayment"))));
+                    paymentInfoResponseDto.setPaymentSuccessTime((Date) resultMap.get("paymentSuccessTime"));
+                }else{
+                    paymentInfoResponseDto = PaymentInfoResponseDto.error((Integer) resultMap.get("code"), String.valueOf(resultMap.get("msg")));
+                }
+            } else  if ("wxpay".equals(payWay)) { //微信
+                paymentInfoResponseDto = wxPayService.queryOrder(paymentRequestDto);
+            } else if ("alipay".equals(payWay)) { //支付宝
+                paymentInfoResponseDto = alipayApiService.queryOrder(paymentRequestDto);
+            } else{
+                paymentInfoResponseDto = paymentInfoResponseDto.error(-1, "未找到支付类型");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            paymentInfoResponseDto = paymentInfoResponseDto.error(-1, "下单失败");
+        }
+        return paymentInfoResponseDto;
+    }
+
+    @Override
+    public ResultMap closeNew(PaymentRequestDto paymentRequestDto) {
+        ResultMap resultMap = new ResultMap();
+        try{
+            String payWay = paymentRequestDto.getPayWay();
+            String orderNo = paymentRequestDto.getOrderNo();
+            String appid = paymentRequestDto.getAppid();
+            switch (payWay) {
+                case "wxpay": //微信
+                    resultMap = wxPayService.closeOrderNew(appid,orderNo);
+                    break;
+                case "alipay": //支付宝
+                    resultMap = alipayApiService.closeTradeOrderNew(appid,orderNo);
+                    break;
+                case "wxpay-hm": //杉德-微信
+                    break;
+                case "alipay-hm": //杉德-支付宝
+                    break;
+                case "uac-qm1": //全民-云闪付
+                    resultMap = qmPayService.colse(appid,payWay, orderNo);
+                    break;
+                case "uac-qm2": //全民-云闪付
+                    resultMap = qmPayService.colse(appid,payWay, orderNo);
+                    break;
+                case "alipay-applet-qm": //全民-支付宝调小程序
+                    resultMap = qmPayService.colse(appid,payWay, orderNo);
+                    break;
+                case "alipay-qm-h5": //全民-h5
+                    resultMap = qmH5PayService.colse(appid,payWay, orderNo);
+                    break;
+                case "wxpay-qm": //全民-微信
+                    resultMap = qmPayService.colse(appid,payWay, orderNo);
+                    break;
+                case "alipay-qm": //全民-支付宝
+                    resultMap = qmPayService.colse(appid,payWay, orderNo);
+                    break;
+                case "uac-qm": //全民-云闪付
+                    resultMap = qmPayService.colse(appid,payWay, orderNo);
+                    break;
+                default:
+                    resultMap = resultMap.error(-1,"未找到支付类型");
+                    break;
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = resultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+
+    @Override
+    public ResultMap refundNew(RefundRequestDto refundRequestDto) {
+        ResultMap resultMap = new ResultMap();
+        Map<String, Object> refundParam = new HashMap<>();
+        try{
+            String payWay = refundRequestDto.getPayWay();
+            refundRequestDto.setPayConfig(initPayConfig(refundRequestDto.getPayWay()));
+            refundRequestDto.setRefundNo(RandomUtil.getRandom(RandomUtil.REFUND_NO));
+            refundRequestDto.setTradeNo(StringUtils.isNotEmpty(refundRequestDto.getTradeNo())? refundRequestDto.getTradeNo() : refundRequestDto.getOrderNo());
+            //
+            try{
+                return refundPost(refundRequestDto);
+            }catch (Exception e){
+                log.warn(" 不是新支付模块通道【退款】 ");
+            }
+
+            if (payWay.contains("wxpay-hm") ) { //杉德-微信
+//                refundParam.put("totalAmount", refundAmount);
+//                refundParam.put("orderNo", orderNo);
+//                refundParam.put("refund_request_no", RandomUtil.getRandom(RandomUtil.REFUND_NO));
+//                refundParam.put("refundMsg", refundMsg);
+                resultMap = hmPayService.refundOrder(refundRequestDto);
+            } else if (payWay.contains("alipay-hm" )) { //杉德-支付宝
+//                refundParam.put("totalAmount", refundAmount);
+//                refundParam.put("orderNo", orderNo);
+//                refundParam.put("refund_request_no", RandomUtil.getRandom(RandomUtil.REFUND_NO));
+//                refundParam.put("refundMsg", refundMsg);
+                resultMap = hmPayService.refundOrder(refundRequestDto);
+            } else if (payWay.contains("wxpay-qm" )) { //全民-微信
+                resultMap = qmPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-qm" )) { //全民-支付宝
+                resultMap = qmPayService.refund(refundRequestDto);
+            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
+                resultMap = qmPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
+                resultMap = qmPayService.refund(refundRequestDto);
+            } else if (payWay.contains("wxpay-main-bf" )) { //宝付-微信-主扫
+                resultMap = bfPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-main-bf" )) { //宝付-支付宝-主扫
+                resultMap = bfPayService.refund(refundRequestDto);
+            } else if (payWay.contains("uac-main-bf" )) { //宝付-云闪付-主扫
+                resultMap = bfPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-qm-h5" )) { //全民-h5
+                resultMap = qmH5PayService.refund(refundRequestDto);
+            } else if (payWay.contains("uac-qm-h5" )) { //全民-h5
+                resultMap = qmH5PayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-hf" )) { //汇付-支付宝
+                resultMap = hfPayService.refund(refundRequestDto);
+            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
+                resultMap = alipayApiService.aliRefundNotify(refundRequestDto);
+            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
+                resultMap = baoFooPayService.refund(refundRequestDto);
+            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
+                resultMap = baoFooPayService.refund(refundRequestDto);
+            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
+                resultMap = baoFooBankPayService.refund(refundRequestDto);
+            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
+                resultMap = bofooAgreementService.OrderRefund(refundRequestDto);
+            }else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
+                resultMap = baofooRechargePayService.profitShareRefundApply(refundRequestDto);
+            }else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
+                resultMap = baofooRechargePayService.profitShareRefundApply(refundRequestDto);
+            } else if ("wxpay".equals(payWay)) { //微信
+                resultMap = wxPayService.wxRefund(refundRequestDto);
+            } else if ("alipay".equals(payWay)) { //支付宝
+                resultMap = alipayApiService.aliRefundNotify(refundRequestDto);
+            } else {
+                resultMap = resultMap.error(-1, "未找到支付类型");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = resultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+
+    @Override
+    public ResultMap refundQueryNew(RefundRequestDto refundRequestDto) {
+        ResultMap resultMap = new ResultMap();
+        try{
+            String payWay = refundRequestDto.getPayWay();
+            PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+            refundRequestDto.setPayConfig(initPayConfig(payWay));
+            //杉德-微信
+            //杉德-支付宝
+            if (payWay.contains("wxpay-hm")) {
+                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else if (payWay.contains("alipay-hm" )) {
+                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else if (payWay.contains("wxpay-qm" )) { //全民-微信
+                resultMap = qmPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-qm" )) { //全民-支付宝
+                resultMap = qmPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("uac-qm" )) { //全民-云闪付
+                resultMap = qmPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-applet-qm" )) { //全民-支付宝调小程序
+                resultMap = qmPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("wxpay-main-bf" )) { //宝付-微信-主扫
+                resultMap = bfPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-main-bf" )) { //宝付-支付宝-主扫
+                resultMap = bfPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("uac-main-bf" )) { //宝付-云闪付-主扫
+                resultMap = bfPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-main-bof")) { //宝付-支付宝-主扫-bofoo
+                resultMap = baoFooPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("uac-main-bof")) { //宝付-云闪付-主扫-bofoo
+                resultMap = baoFooPayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("bank-app-bof")) { //宝付-手机银行支付-bofoo
+                resultMap = baoFooBankPayService.refundQuery(refundRequestDto);
+            }else if (payWay.contains("agreement-bank-bof")) { //宝付-协议支付-bofoo
+                resultMap = bofooAgreementService.queryRefund(refundRequestDto);
+            } else if (payWay.contains("recharge-alipay-baofoo")) { //宝付-钱包支付宝主扫支付-baofoo
+                PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
+                paymentRequestDto.setPayConfig(refundRequestDto.getPayConfig());
+                resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("recharge-bank-baofoo")) { //宝付-钱包余额银行卡支付-baofoo
+                PaymentRequestDto paymentRequestDto = new PaymentRequestDto();
+                paymentRequestDto.setPayConfig(refundRequestDto.getPayConfig());
+                resultMap = baofooRechargePayService.queryOrder(paymentRequestDto);
+            } else if (payWay.contains("alipay-qm-h5" )) { //全民-h5
+                resultMap = qmH5PayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("uac-qm-h5" )) { //全民-h5
+                resultMap = qmH5PayService.refundQuery(refundRequestDto);
+            } else if (payWay.contains("alipay-hf" )) { //汇付-支付宝
+                resultMap = hfPayService.queryRefund(refundRequestDto);
+            } else if (payWay.contains("alipay-web-spare") ) { //支付宝
+                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else if ("wxpay".equals(payWay)) {
+                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else if ("alipay".equals(payWay)) {
+                resultMap = alipayApiService.queryRefundOrder(refundRequestDto);
+//                resultMap = resultMap.error(-1, "不支持退款查询");
+            } else {
+                resultMap = resultMap.error(-1, "未找到支付类型");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap = resultMap.error(-1, "下单失败");
+        }
+        return resultMap;
+    }
+}

+ 657 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/QmH5PayServiceImpl.java

@@ -0,0 +1,657 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.common.utils.DateUtils;
+import com.tzy.framework.pay.config.PayConfig;
+import com.tzy.framework.pay.config.QmH5PayConfig;
+import com.tzy.framework.pay.config.QmPayConfig;
+import com.tzy.framework.pay.dto.*;
+import com.tzy.framework.pay.service.QmH5PayService;
+import com.tzy.framework.pay.service.QmPayService;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class QmH5PayServiceImpl implements QmH5PayService {
+
+    @Autowired
+    private QmPayService qmPayService;
+    @Autowired
+    private QmH5PayConfig qmH5PayConfig;
+    @Value("${tzy.app-version:dev}")
+    private String appversion;
+    @Autowired
+    private PayConfig payConfig;
+
+
+    @Override
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto) {
+        ResultMap resultMap = new ResultMap();
+        try {
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmH5PayConfig;
+            }
+//            String url = getBoxUrl(paymentRequestDto.getPayWay(),PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            if(appversion.equals("prod")){
+                String url = getUrl(paymentRequestDto.getPayWay(),PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            }
+            String merchantOrderId = getMerchantOrderId(qmPayConfig);
+            JSONObject json = new JSONObject();
+//            json.put("requestTimestamp", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,new Date()));    // 报文请求时间
+            json.put("requestTimestamp", DateFormatUtils.format(paymentRequestDto.getExpireTime(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", merchantOrderId); // 商户订单号
+            json.put("mid", qmPayConfig.getMid_ali()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            json.put("totalAmount", paymentRequestDto.getTotalAmount().multiply(new BigDecimal(100)).intValue());
+            json.put("notifyUrl", qmPayConfig.getPayNotifyUrl()); // 支付地址
+            /**云闪付*/
+            if(paymentRequestDto.getPayWay().equals(PayConstants.QMPAY_TYPE_UAC2H5)){
+                json.put("cardNoLockFlag", true); // 卡号锁定标识
+            }
+            /* 分账部分 */
+//        json.put("divisionFlag", true); // 分账标记
+//        json.put("platformAmount", 10); // 平台商户分账金额
+//        ArrayList subOrders = new ArrayList<>();
+//        JSONObject jsonObject = new JSONObject();
+//        jsonObject.put("mid", "子商户号");
+//        jsonObject.put("totalAmount", 10);
+//        subOrders.add(jsonObject);
+//        json.put("subOrders", subOrders);
+            log.info("请求报文:{}" + json);
+            String param = getOpenBodySigForNetpay(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()), qmPayConfig.getPayFlag(), json.toString());
+            url = url +"?"+ param;
+            JSONObject data = new JSONObject();
+            data.put("url",url);
+            log.info(" 全民h5下单链接:{} ",data);
+            return resultMap
+                    .put("data",data)
+                    ;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    @Override
+    public PaymentInfoResponseDto queryOrder(String appid, String payWay, String orderNo) {
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        String errMsg = "";
+        try{
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmH5PayConfig;
+            }
+//            String url = getBoxUrl(payWay, PayConstants.QMPAY_METHOD_QUERY_ORDER);
+//            if("prod".equals(appversion)){
+               String url = getUrl(payWay,PayConstants.QMPAY_METHOD_QUERY_ORDER);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid_ali()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("查询地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+            String retJsonStr = send(url, json.toString(), authorization);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单查询,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS) ||
+                            retJson.getString("status").contains(PayConstants.SUCCESS)
+                    ) {
+                        paymentInfoResponseDto.setSuccess(true);
+                        paymentInfoResponseDto.setOrderNo(orderNo);
+                        paymentInfoResponseDto.setPayWay(payWay);
+                        paymentInfoResponseDto.setPaymentNo(retJson.getString("targetOrderId"));
+                        paymentInfoResponseDto.setPaymentPrice(new BigDecimal(retJson.getString("totalAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        paymentInfoResponseDto.setActualPayment(new BigDecimal(retJson.getString("totalAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        if (PayConstants.QMPAY_TYPE_ALIPAY.equals(payWay) || PayConstants.QMPAY_TYPE_ALIPAY2APPLET.equals(payWay)) {
+                            paymentInfoResponseDto.setActualPayment(new BigDecimal(retJson.getIntValue("buyerPayAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        }
+                        paymentInfoResponseDto.setPaymentSuccessTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, retJson.getString("payTime")));
+                        return paymentInfoResponseDto;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "查询请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "下单失败";
+        }
+        return PaymentInfoResponseDto.error(-2,errMsg);
+    }
+
+    @Override
+    public ResultMap refund(String appid, String payWay, String orderNo, BigDecimal refundPrice, String refundMsg) {
+        String errMsg = "";
+        try{
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmH5PayConfig;
+            }
+            String refundOrderId = getMerchantOrderId(qmPayConfig);
+//            String url = getBoxUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+//            if("prod".equals(appversion)){
+               String url = getUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid_ali()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            json.put("refundAmount", refundPrice.multiply(new BigDecimal(100)).intValue()); // 退款金额
+            json.put("refundOrderId", refundOrderId); // 退款订单号
+            json.put("refundDesc", refundMsg); // 退款说明
+            json.put("msgId", qmPayConfig.getRefundFlag());  // 退款标记
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("退款地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+            String retJsonStr = send(url, json.toString(), authorization);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单退款,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS)
+                            || retJson.getString("status").contains(PayConstants.SUCCESS)
+                    ) {
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", refundOrderId);
+                        stringStringMap.put("refund_id", String.valueOf(retJson.get("refundTargetOrderId")));
+                        try{
+                            stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("refundAmount")))));
+                        }catch (NumberFormatException e){
+                            stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("refundInvoiceAmount")))));
+                        }
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "退款请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+
+    @Override
+    public ResultMap refundQuery(String appid,String payWay,  String outRefundNo) {
+        String errMsg = "";
+        try{
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmH5PayConfig;
+            }
+//            String url = getBoxUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+//            if("prod".equals(appversion)){
+               String url = getUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", outRefundNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid_ali()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("退款地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+            String retJsonStr = send(url, json.toString(), authorization);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单退款查询,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态-退款状态
+                    if(retJson.getString("refundStatus").contains(PayConstants.SUCCESS)) {
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", String.valueOf(retJson.get("refundOrderId")));
+                        stringStringMap.put("refund_id", String.valueOf(retJson.get("refundTargetOrderId")));
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("sendBackAmount")))));
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "退款查询请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款查询请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+
+    @Override
+    public ResultMap colse(String appid, String payWay, String orderNo) {
+        String errMsg = "";
+        try{
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) payConfig.getByPayType(appid);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmH5PayConfig;
+            }
+//            String url = getBoxUrl(payWay,PayConstants.QMPAY_METHOD_CLOSE);
+//            if("prod".equals(appversion)){
+               String url = getUrl(payWay,PayConstants.QMPAY_METHOD_CLOSE);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid_ali()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("查询地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+            String retJsonStr = send(url, json.toString(), authorization);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单-关闭订单,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS)) {
+                        return  ResultMap.ok("关闭成功!")
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                } else {
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "关闭订单请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "关闭订单失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+    public  String getMerchantOrderId(){
+        return qmH5PayConfig.getMsgSrcId()+ DateUtils.parseDateToStr("yyyyMMddmmHHssSSS",new Date())+ RandomUtil.random(7);
+    }
+    public  String getMerchantOrderId(QmH5PayConfig qmPayConfig){
+        return qmPayConfig.getMsgSrcId()+ DateUtils.parseDateToStr("yyyyMMddmmHHssSSS",new Date())+ RandomUtil.random(7);
+    }
+    private static String getOpenBodySigForNetpay(String appId, String appKey, String timestamp, String nonce, String content) throws IOException, NoSuchAlgorithmException, InvalidKeyException {
+//        String bodyDigest = DigestUtils.sha256Hex(URLDecoder.decode(content, "UTF-8")); //eg:cc18f43baa87fe658146221d3f16e3b5a50d30f0c984407f74913ef6dcda8ee1
+        String bodyDigest = DigestUtils.sha256Hex(new ByteArrayInputStream(content.getBytes("utf-8")));
+        String str1_C = appId + timestamp + nonce + bodyDigest;
+        byte[] localSignature = hmacSHA256(str1_C.getBytes(), appKey.getBytes());
+        String signature = Base64.encodeBase64String(localSignature);
+        System.out.println(signature);
+        return ("authorization=OPEN-FORM-PARAM" + "&appId=" + appId + "&timestamp=" + timestamp + "&nonce=" + nonce + "&content=" + URLEncoder.encode(content, "UTF-8") + "&signature=" + URLEncoder.encode(signature, "UTF-8"));
+//        return ( "appId=" + appId + "&timestamp=" + timestamp + "&nonce=" + nonce + "&content=" + URLEncoder.encode(content, "UTF-8") + "&signature=" + URLEncoder.encode(signature, "UTF-8"));
+    }
+
+    /**
+     * @param data
+     * @param key
+     * @return
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeyException
+     * @Description
+     */
+    private static byte[] hmacSHA256(byte[] data, byte[] key) throws NoSuchAlgorithmException, InvalidKeyException {
+        String algorithm = "HmacSHA256";
+        Mac mac = Mac.getInstance(algorithm);
+        mac.init(new SecretKeySpec(key, algorithm));
+        return mac.doFinal(data);
+    }
+
+    public String getBoxUrl(String payWay,String method) throws Exception {
+        return qmPayService.getBoxUrl(payWay,method);
+    }
+
+    public String getUrl(String payWay, String method) throws Exception {
+        return qmPayService.getUrl(payWay,method);
+    }
+    public String getUrlNew(String payWay, QmPayConfig qmPayConfig, String method) throws Exception {
+        return qmPayService.getUrlNew(payWay,qmPayConfig,method);
+    }
+    public String getOpenBodySig(String appId, String appKey, String body){
+        return qmPayService.getOpenBodySig(appId, appKey, body);
+    }
+
+    public  String send(String url, String entity , String authorization) throws Exception{
+        return qmPayService.send(url, entity, authorization);
+    }
+
+    /**********************新逻辑***********************/
+    @Override
+    public ResultMap tradeCreateNew(PaymentRequestDto paymentRequestDto) {
+        ResultMap resultMap = new ResultMap();
+        try {
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) paymentRequestDto.getPayConfigByClass(QmH5PayConfig.class);
+//            QmH5PayConfig qmPayConfig = (QmH5PayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+//            if(null == qmPayConfig){
+//                qmPayConfig = this.qmH5PayConfig;
+//            }
+//            String url = getBoxUrl(paymentRequestDto.getPayWay(),PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            if(appversion.equals("prod")){
+            String url = getUrlNew(paymentRequestDto.getPayWay(),new QmPayConfig(qmPayConfig.getAppid(),qmPayConfig.getAppkey(),qmPayConfig.getPrivateKey(),qmPayConfig.getInstMid()),PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            }
+            String merchantOrderId = getMerchantOrderId(qmPayConfig);
+            JSONObject json = new JSONObject();
+//            json.put("requestTimestamp", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,new Date()));    // 报文请求时间
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", merchantOrderId); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            json.put("totalAmount", paymentRequestDto.getTotalAmount().multiply(new BigDecimal(100)).intValue());
+            json.put("notifyUrl", qmPayConfig.getPayNotifyUrl()); // 支付地址
+            json.put("returnUrl", paymentRequestDto.getReturnUrl()); // 支付返回商家页面地址
+            json.put("attachedData", paymentRequestDto.getPayWay()); // 备注
+            json.put("expireTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,paymentRequestDto.getExpireTime()));  // 订单过期时间
+            /**云闪付*/
+            if(paymentRequestDto.getPayWay().contains(PayConstants.QMPAY_TYPE_UAC2H5)){
+                json.put("cardNoLockFlag", true); // 卡号锁定标识
+            }
+            /* 分账部分 */
+//        json.put("divisionFlag", true); // 分账标记
+//        json.put("platformAmount", 10); // 平台商户分账金额
+//        ArrayList subOrders = new ArrayList<>();
+//        JSONObject jsonObject = new JSONObject();
+//        jsonObject.put("mid", "子商户号");
+//        jsonObject.put("totalAmount", 10);
+//        subOrders.add(jsonObject);
+//        json.put("subOrders", subOrders);
+            log.info("请求报文:{}" + json);
+            String param = getOpenBodySigForNetpay(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()), qmPayConfig.getPayFlag(), json.toString());
+            url = url +"?"+ param;
+            JSONObject data = new JSONObject();
+            data.put("url",url);
+            log.info(" 全民h5下单链接:{} ",data);
+            return resultMap
+                    .put("merOrderId",merchantOrderId)
+                    .put("orderNo",paymentRequestDto.getOrderNo())
+                    .put("data",data)
+                    ;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    @Override
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto) {
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        String errMsg = "";
+        try{
+            String payWay = paymentRequestDto.getPayWay();
+            String orderNo = paymentRequestDto.getOrderNo();
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) paymentRequestDto.getPayConfigByClass(QmH5PayConfig.class);
+            /*if(null == qmPayConfig){
+                qmPayConfig = this.qmH5PayConfig;
+            }*/
+//            String url = getBoxUrl(payWay, PayConstants.QMPAY_METHOD_QUERY_ORDER);
+//            if("prod".equals(appversion)){
+            String url = getUrlNew(paymentRequestDto.getPayWay(),new QmPayConfig(qmPayConfig.getAppid(),qmPayConfig.getAppkey(),qmPayConfig.getPrivateKey(),qmPayConfig.getInstMid()),PayConstants.QMPAY_METHOD_QUERY_ORDER);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("查询地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+            String retJsonStr = send(url, json.toString(), authorization);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单查询,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS) ||
+                            retJson.getString("status").contains(PayConstants.SUCCESS)
+                    ) {
+                        paymentInfoResponseDto.setOrderNo(orderNo);
+                        paymentInfoResponseDto.setPayWay(payWay);
+                        paymentInfoResponseDto.setPaymentNo(retJson.getString("targetOrderId"));
+                        paymentInfoResponseDto.setPaymentPrice(new BigDecimal(retJson.getString("totalAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        paymentInfoResponseDto.setActualPayment(new BigDecimal(retJson.getString("totalAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY ) || payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2APPLET) ) {
+                            paymentInfoResponseDto.setActualPayment(new BigDecimal(retJson.getIntValue("buyerPayAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        }
+                        paymentInfoResponseDto.setPaymentSuccessTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, retJson.getString("payTime")));
+                        return paymentInfoResponseDto;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "查询请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "下单失败";
+        }
+        return PaymentInfoResponseDto.error(-2,errMsg);
+    }
+
+    @Override
+    public ResultMap refund(RefundRequestDto refundRequestDto) {
+        String errMsg = "";
+        try{
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) refundRequestDto.getPayConfigByClass(QmH5PayConfig.class);
+            String orderNo = refundRequestDto.getOrderNo();
+            String refundMsg = refundRequestDto.getRefundMsg();
+            BigDecimal refundPrice = refundRequestDto.getRefundAmount();
+/*
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmH5PayConfig;
+            }
+*/
+            String refundOrderId = getMerchantOrderId(qmPayConfig);
+//            String url = getBoxUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+//            if("prod".equals(appversion)){
+            String url = getUrlNew(null,new QmPayConfig(qmPayConfig.getAppid(),qmPayConfig.getAppkey(),qmPayConfig.getPrivateKey(),qmPayConfig.getInstMid()),PayConstants.QMPAY_METHOD_REFUND);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            json.put("refundAmount", refundPrice.multiply(new BigDecimal(100)).intValue()); // 退款金额
+            json.put("refundOrderId", refundOrderId); // 退款订单号
+            json.put("refundDesc", refundMsg); // 退款说明
+            json.put("msgId", qmPayConfig.getRefundFlag());  // 退款标记
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("退款地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+            String retJsonStr = send(url, json.toString(), authorization);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单退款,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS)
+                            || retJson.getString("status").contains(PayConstants.SUCCESS)
+                    ) {
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", refundOrderId);
+                        stringStringMap.put("refund_id", String.valueOf(retJson.get("refundTargetOrderId")));
+                        try{
+                            stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("totalAmount")))));
+                        }catch (NumberFormatException e){
+//                            stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("refundInvoiceAmount")))));
+                        }
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "退款请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+
+    /**
+     *
+     * @param refundRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap refundQuery(RefundRequestDto refundRequestDto) {
+        String errMsg = "";
+        try{
+            QmH5PayConfig qmPayConfig = (QmH5PayConfig) refundRequestDto.getPayConfigByClass(QmH5PayConfig.class);
+            String outRefundNo = refundRequestDto.getRefundNo();
+//            QmH5PayConfig qmPayConfig = (QmH5PayConfig) payConfig.getByPayType(payWay);
+//            if(null == qmPayConfig){
+//                qmPayConfig = this.qmH5PayConfig;
+//            }
+//            String url = getBoxUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+//            if("prod".equals(appversion)){
+            String url = getUrlNew(null,new QmPayConfig(qmPayConfig.getAppid(),qmPayConfig.getAppkey(),qmPayConfig.getPrivateKey(),qmPayConfig.getInstMid()),PayConstants.QMPAY_METHOD_REFUND);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", outRefundNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("退款地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+            String retJsonStr = send(url, json.toString(), authorization);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单退款查询,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态-退款状态
+                    if(retJson.getString("refundStatus").contains(PayConstants.SUCCESS)) {
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", String.valueOf(retJson.get("refundOrderId")));
+                        stringStringMap.put("refund_id", String.valueOf(retJson.get("refundTargetOrderId")));
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("sendBackAmount")))));
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "退款查询请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款查询请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+}

+ 174 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/QmPayAssetServiceImpl.java

@@ -0,0 +1,174 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.tzy.common.utils.DateUtils;
+import com.tzy.framework.pay.config.QmPayZgConfig;
+import com.tzy.framework.pay.dto.QmZgOrderInfoDto;
+import com.tzy.framework.pay.service.QmPayAssetService;
+import com.tzy.framework.pay.util.MD5Util;
+import com.tzy.framework.pay.util.Util;
+import com.tzy.framework.pay.util.sftp.SFtpTools;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.input.BOMInputStream;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.security.cert.X509Certificate;
+import java.io.*;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import static com.tzy.framework.pay.util.Util.*;
+
+/**
+ *
+ *
+ */
+@Slf4j
+@Service
+public class QmPayAssetServiceImpl implements QmPayAssetService {
+
+    static PrivateKey batchPrivateKey = null;
+    static PublicKey countPubKey = null;
+    protected static MessageDigest messagedigest = null;
+    @Autowired
+    private QmPayZgConfig qmPayZgConfig;
+
+    public void init(){
+        try {
+            //商户批量文件加签私钥--商户用
+            InputStream batchPriKeyStoreFileStream = new FileInputStream(new File(qmPayZgConfig.getUpPrivateKeyPath()));
+//            batchPrivateKey = getPriKeyPkcs12(batchPriKeyStoreFileStream, qmPayZgConfig.getUpPrivateKeyPwd());
+            batchPrivateKey = getPriKeyPkcs12(batchPriKeyStoreFileStream, qmPayZgConfig.getUpPrivateKeyPwd());
+            //回盘文件验签公钥--商户用
+            InputStream countPubKeyStoreFileStream = new FileInputStream(new File(qmPayZgConfig.getUpPublicKeyPath()));
+            X509Certificate countCert = X509Certificate.getInstance(countPubKeyStoreFileStream);
+            countPubKey = countCert.getPublicKey();
+            System.out.println("回盘验签公钥:" + countPubKey);
+            messagedigest = MessageDigest.getInstance("MD5");
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException("初始化失败,MessageDigest不支持MD5Util.");
+        } catch (Exception e) {
+            throw new RuntimeException("配置文件读取失败!");
+        }
+    }
+
+    public static void init2(){
+        try {
+            //商户批量文件加签私钥--商户用
+//            InputStream batchPriKeyStoreFileStream = new FileInputStream(new File("/home/tzy/qm/am/upPrivateKey.pfx"));
+//            batchPrivateKey = getPriKeyPkcs12(batchPriKeyStoreFileStream, "123456");
+            InputStream batchPriKeyStoreFileStream = new FileInputStream(new File("/home/tzy/py/pyPrivateKey.pfx"));
+            batchPrivateKey = getPriKeyPkcs12(batchPriKeyStoreFileStream, "880615sandy");
+            //回盘文件验签公钥--商户用
+            InputStream countPubKeyStoreFileStream = new FileInputStream(new File("/home/tzy/qm/am/upPublicKey.cer"));
+            X509Certificate countCert = X509Certificate.getInstance(countPubKeyStoreFileStream);
+            countPubKey = countCert.getPublicKey();
+            System.out.println("回盘验签公钥:" + countPubKey);
+            messagedigest = MessageDigest.getInstance("MD5");
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException("初始化失败,MessageDigest不支持MD5Util.");
+        } catch (Exception e) {
+            throw new RuntimeException("配置文件读取失败!");
+        }
+    }
+
+//    public static void main(String[] args) {
+////        QmPayAssetService qmPayAssetService = new QmPayAssetServiceImpl();
+////        qmPayAssetService.upAtPrice02(null,null);
+//        init2();
+//    }
+
+    public void upAtPrice02(List<QmZgOrderInfoDto> params,String timeStrs){
+        try {
+            init();
+//            init2();
+            String timeStr = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date());
+            String timeStrYMD = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, new Date());
+            File file = formatStr(params,timeStr);
+            String md5 = MD5Util.getFileMD5String(file);
+            //签名
+            byte[] signB = Util.sign(md5.getBytes(), batchPrivateKey, ALGORITHM_SHA256WITHRSA);
+            File chkFile = new File("D:\\home\\tzy\\uploadpath\\qm\\02_SHPYDZ_"+timeStr+".txt.chk");
+            BufferedWriter bwChk = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(chkFile)));
+            bwChk.write(byteArr2HexString(signB) + "\r\n");
+            bwChk.flush();
+            bwChk.close();
+            log.info("批量文件签名结束");
+//            SFtpTools TPMX = new SFtpTools("180.169.95.129", 22, "SHPYDZ_fan", "aL1Jn$kg","/upload/", "");
+            SFtpTools TPMX = new SFtpTools(qmPayZgConfig.getIp(), 22, qmPayZgConfig.getUserName(), qmPayZgConfig.getPwd(),"/upload/"+timeStrYMD+"/", "");
+            TPMX.uploadFiles(file);
+            TPMX.uploadFiles(chkFile);
+            log.info("批量文件上传");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public File formatStr (List<QmZgOrderInfoDto> params,String timeStr){
+        File file = new File("D:\\home\\tzy\\uploadpath\\qm\\02_SHPYDZ_" + timeStr + ".txt");
+        try {
+            String title = qmPayZgConfig.getMerchantNo() + "|" + params.size() + "\r\n";
+            StringBuffer stb = new StringBuffer(title);
+            if (null != params && !params.isEmpty()) {
+                params.forEach(qmZgOrderInfoDto -> {
+                    stb.append(qmZgOrderInfoDto.getOrderNo()).append("|")
+                            .append(qmPayZgConfig.getBusinessUserNo()).append("|")
+                            .append("0|")
+                            .append(qmZgOrderInfoDto.getPrice()).append("\r\n");
+                });
+            }
+            String str = stb.toString().substring(0,stb.length()-"\r\n".length());
+            System.out.println("  ********************* ");
+            System.out.println(str);
+            BufferedWriter bwChk = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
+            bwChk.write(str);
+            bwChk.flush();
+            bwChk.close();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return file;
+    }
+
+    /**
+     * 单个文件控制明细数不超过1万条,如超出请拆分至多个文件,间隔20分钟-+分批上传。
+     * @param params
+     */
+    public void dwAtPrice02(List<Map<String,String>> params){
+        try {
+            init();
+            SFtpTools TPMX = new SFtpTools(qmPayZgConfig.getIp(), 22, qmPayZgConfig.getUserName(), qmPayZgConfig.getPwd(),"", "/upload");
+            File retFile = new File("D:/cert/04_000000_20190506103045.txt.ret");
+            //获取签名文件中的签名
+            File verRetChkFile = new File("D:/cert/04_000000_20190506103045.txt.ret.chk");
+            TPMX.downloadFiles("",retFile);
+            TPMX.downloadFiles("",verRetChkFile);
+
+
+            String retMd5 = MD5Util.getFileMD5String(retFile);
+            BufferedReader verBr = new BufferedReader(new InputStreamReader(new BOMInputStream(new FileInputStream(verRetChkFile))));
+            String verSignature = verBr.readLine();
+            Boolean verResult = verify(retMd5.getBytes("UTF-8"), hexString2ByteArr(verSignature) , countPubKey, ALGORITHM_SHA256WITHRSA);
+            System.out.println("回盘文件验签结果:"+verResult);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 工作日9点到19点放入的文件,首次回盘在文件大约放入1小时内生成;日终回盘在第二天凌晨2点左右生成。
+     */
+    public void download(){
+
+    }
+
+
+}

+ 1342 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/QmPayServiceImpl.java

@@ -0,0 +1,1342 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzy.common.utils.Base64Util;
+import com.tzy.common.utils.DateUtils;
+import com.tzy.common.utils.LogSyncUtil;
+import com.tzy.common.utils.StringUtils;
+import com.tzy.common.utils.bean.BeanUtils;
+import com.tzy.framework.pay.config.PayConfig;
+import com.tzy.framework.pay.config.QmPay1Config;
+import com.tzy.framework.pay.config.QmPay2Config;
+import com.tzy.framework.pay.config.QmPayConfig;
+import com.tzy.framework.pay.dto.*;
+import com.tzy.framework.pay.service.QmPayService;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * 全民付
+ */
+@Slf4j
+@Service
+public class QmPayServiceImpl implements QmPayService {
+
+    @Autowired
+    private QmPayConfig qmPayConfig ;
+    @Autowired
+    private QmPay1Config qmPay1Config ;
+    @Autowired
+    private QmPay2Config qmPay2Config ;
+
+    @Value("${tzy.app-version:dev}")
+    private String appversion;
+    @Autowired
+    private PayConfig payConfig;
+
+    /**
+     * 统一下单
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap tradeCreate(PaymentRequestDto paymentRequestDto){
+        ResultMap resultMap = new ResultMap();
+        try{
+            RechargeUserInfoDto rechargeUserInfoDto = paymentRequestDto.getRechargeUserInfoDto();
+            String payWay = paymentRequestDto.getPayWay();
+            QmPayConfig qmPayConfig = new QmPayConfig();
+            boolean isSub = false;
+            if(paymentRequestDto.getPayWay().contains("qm1")){
+//                QmPay1Config qmPayConfig1 = (QmPay1Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay1Config);
+                payWay = payWay.substring(0,payWay.length()-1);
+                isSub = true;
+            }else
+            if(paymentRequestDto.getPayWay().contains("qm2")){
+//                QmPay2Config qmPayConfig2 = (QmPay2Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay2Config);
+                payWay = payWay.substring(0,payWay.length()-1);
+                isSub = true;
+            }else{
+//                QmPayConfig qmPayConfig0 = (QmPayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                qmPayConfig = this.qmPayConfig;
+            }
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }
+            String url = getUrl(payWay,PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            String url = getBoxUrl(payWay, PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            if("prod".equals(appversion)){
+//                url = getUrl(payWay,PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            }
+            String body = String.valueOf(paymentRequestDto.getBody());
+            if(StringUtils.isNotEmpty(body) ){
+                body = Base64Util.subStringByBytes(body,80)+"...";
+            }
+            String merchantOrderId = getMerchantOrderId(qmPayConfig);
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", merchantOrderId); // 商户订单号
+//            json.put("merOrderId", paymentRequestDto.getOrderNo()); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            JSONObject attachedData = new JSONObject();
+            int totalPrice = paymentRequestDto.getTotalAmount().multiply(new BigDecimal(100)).intValue();//总金额
+            //判断子商户信息
+            if(isSub){
+                //设置平台分账金额
+                int platformAmount = 0;
+//                int platformAmount = paymentRequestDto.getTotalAmount().multiply(new BigDecimal(100)).multiply(new BigDecimal(30)).divide(new BigDecimal(100)).intValue();
+                //如果是 子商户模式(分账模式)则设置分账金额
+                int subPrice = totalPrice - platformAmount;
+                json.put("platformAmount", platformAmount);    // 平台分账金额
+                json.put("divisionFlag", true);    // 分账标记 购物车模式
+                JSONArray subOrders = new JSONArray();
+                JSONObject suborder = new JSONObject();
+                suborder.put("mid",qmPayConfig.getSub_mid());
+                suborder.put("totalAmount",subPrice);
+                String subMerOrderId = getMerchantOrderId(qmPayConfig);
+                suborder.put("merOrderId",subMerOrderId);
+                subOrders.add(suborder);
+                json.put("subOrders", subOrders);    // 子商户信息
+                attachedData.put("subOrders",subOrders);
+            }
+            json.put("attachedData",payWay); //附加数据
+            json.put("instMid", "APPDEFAULT"); // 业务类型
+            json.put("totalAmount", totalPrice);      // 平台支付总金额
+            json.put("tradeType", "APP");  // 交易类型,微信必传
+            json.put("expireTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,new Date(paymentRequestDto.getCreateOrderTime().getTime()+2800*60)));  // 订单过期时间
+            json.put("orderDesc", body);  // 商品描述
+            json.put("notifyUrl", qmPayConfig.getPayNotifyUrl());  // 支付结果通知地址
+            json.put("showUrl", qmPayConfig.getShowUrl());  // 订单展示页面
+            json.put("msgId", qmPayConfig.getPayFlag());  // 支付标记
+            json.put("subAppId", qmPayConfig.getSubAppId());  // 微信子商户appId
+            //是否是uac
+            /*if(PayConstants.QMPAY_TYPE_UAC.equals(payWay)){//云闪付参数
+                //invokeType
+                json.put("invokeType", "H5");  // 云闪付参数
+                json.put("supportBank", "");  // 支持的银行
+            }*/
+            //填写用户的实名认证信息
+            if(null != rechargeUserInfoDto && rechargeUserInfoDto.isCheckUserAuth()){
+                json.put("name",rechargeUserInfoDto.getUserName());//实名认证姓名
+                json.put("certType","IDENTITY_CARD");//实名认证证件类型
+                json.put("certNo",rechargeUserInfoDto.getCertificateNo());//实名认证证件号
+                json.put("fixBuyer","T");//是否需要实名认证
+            }
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("下单地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+            LogSyncUtil.logSync("全民银商支付 预下单,交易编号:{},请求参数:{}",paymentRequestDto.getOrderNo(),json);
+            String retJson = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 预下单,交易编号:{},返回结果:{}",paymentRequestDto.getOrderNo(),retJson);
+            JSONObject jsonObject = JSONObject.parseObject(retJson);//转换为json格式数据
+            log.info("全民付统一下单,返回数据》{}",jsonObject);
+            resultMap.put("merOrderId",merchantOrderId);
+            resultMap.put("orderNo",paymentRequestDto.getOrderNo());
+            resultMap.put("appPayRequest",jsonObject.getJSONObject("appPayRequest"));
+            resultMap.put("data",jsonObject);
+            return resultMap;
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return ResultMap.error("下单失败");
+    }
+    /**
+     * 查询订单
+     * @param payWay
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public PaymentInfoResponseDto queryOrder(String appid,String payWay, String  orderNo){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        String errMsg = "";
+        try{
+            String payWay1 = payWay;
+            QmPayConfig qmPayConfig = new QmPayConfig();
+            if(payWay.contains("qm1")){
+//                QmPay1Config qmPayConfig1 = (QmPay1Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay1Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else
+            if(payWay.contains("qm2")){
+//                QmPay2Config qmPayConfig2 = (QmPay2Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay2Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else{
+//                QmPayConfig qmPayConfig0 = (QmPayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                qmPayConfig = this.qmPayConfig;
+            }
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }
+            /*QmPayConfig qmPayConfig = (QmPayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+            String url = getUrl(payWay1,PayConstants.QMPAY_METHOD_QUERY_ORDER);
+//            if("prod".equals(appversion)){
+//                url = getUrl(payWay1,PayConstants.QMPAY_METHOD_QUERY_ORDER);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", "APPDEFAULT"); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("查询地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+//            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 查询,交易编号:{},请求参数:{}",orderNo,json);
+            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 查询,交易编号:{},返回结果:{}",orderNo,retJsonStr);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单查询,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS) ||
+                            retJson.getString("status").contains(PayConstants.SUCCESS)
+                    ) {
+                        paymentInfoResponseDto.setTradeState(retJson.getString("status"));
+                        paymentInfoResponseDto.setTradeStateDesc(retJson.getString("status"));
+                        paymentInfoResponseDto.setOrderNo(orderNo);
+                        paymentInfoResponseDto.setPayWay(payWay);
+                        paymentInfoResponseDto.setPaymentNo(retJson.getString("targetOrderId"));
+                        paymentInfoResponseDto.setPaymentPrice(new BigDecimal(retJson.getString("totalAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        paymentInfoResponseDto.setActualPayment(new BigDecimal(retJson.getString("totalAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        if (PayConstants.QMPAY_TYPE_ALIPAY.equals(payWay) || PayConstants.QMPAY_TYPE_ALIPAY2APPLET.equals(payWay)) {
+                            paymentInfoResponseDto.setActualPayment(new BigDecimal(retJson.getIntValue("buyerPayAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        }
+                        paymentInfoResponseDto.setPaymentSuccessTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, retJson.getString("payTime")));
+                        paymentInfoResponseDto.setSuccess(true);
+                        return paymentInfoResponseDto;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "查询请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "下单失败";
+        }
+        return PaymentInfoResponseDto.error(-2,errMsg);
+    }
+    /**
+     * 退款
+     * @param orderNo
+     * @param refundPrice
+     * @param refundMsg
+     * @return
+     */
+    @Override
+    public ResultMap refund( String appid,String payWay, String orderNo,BigDecimal refundPrice,String refundMsg){
+        String errMsg = "";
+        try{
+            String payWay1 = payWay;
+            boolean isSub = false;
+            QmPayConfig qmPayConfig = new QmPayConfig();
+            if(payWay.contains("qm1")){
+//                QmPay1Config qmPayConfig1 = (QmPay1Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay1Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+                isSub = true;
+            }else
+            if(payWay.contains("qm2")){
+//                QmPay2Config qmPayConfig2 = (QmPay2Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay2Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+                isSub = true;
+            }else{
+//                QmPayConfig qmPayConfig0 = (QmPayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                qmPayConfig = this.qmPayConfig;
+            }
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }
+            /*QmPayConfig qmPayConfig = (QmPayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+            String refundOrderId = getMerchantOrderId(qmPayConfig);
+            String url = getUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+            /*String url = getBoxUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+            if("prod".equals(appversion)){
+                url = getUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+            }*/
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            int totalPrice = refundPrice.multiply(new BigDecimal(100)).intValue();
+            //判断子商户信息
+            if(isSub){
+                //设置平台分账金额
+//                int platformAmount = refundPrice.multiply(new BigDecimal(100)).multiply(new BigDecimal(30)).divide(new BigDecimal(100)).intValue();
+                int platformAmount = 0;
+                //如果是 子商户模式(分账模式)则设置分账金额
+                int subPrice = totalPrice - platformAmount;
+                json.put("platformAmount", platformAmount);    // 平台分账金额
+                JSONArray subOrders = new JSONArray();
+                JSONObject suborder = new JSONObject();
+                suborder.put("mid",qmPayConfig.getSub_mid());
+                suborder.put("totalAmount",subPrice);
+                String subRefundOrderId = getMerchantOrderId(qmPayConfig);
+                suborder.put("refundOrderId",subRefundOrderId);
+                subOrders.add(suborder);
+                json.put("subOrders", subOrders);    // 子商户信息
+            }
+            json.put("instMid", "APPDEFAULT"); // 业务类型
+            json.put("refundAmount", totalPrice); // 退款金额
+            json.put("refundOrderId", refundOrderId); // 退款订单号
+            json.put("refundDesc", refundMsg); // 退款说明
+            json.put("msgId", qmPayConfig.getRefundFlag());  // 退款标记
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("退款地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+//            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 退款,交易编号:{},请求参数:{}",orderNo,json);
+            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 退款,交易编号:{},返回结果:{}",orderNo,retJsonStr);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单退款,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                log.info("全民订单退款,判断》{}",PayConstants.SUCCESS.equals(retJson.getString("errCode")));
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS)
+                        || retJson.getString("status").contains(PayConstants.SUCCESS)
+                    ) {
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", refundOrderId);
+                        stringStringMap.put("refund_id", String.valueOf(retJson.get("refundTargetOrderId")));
+                        try{
+                            stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("refundAmount")))));
+                        }catch (NumberFormatException e){
+                            stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("refundInvoiceAmount")))));
+                        }
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "退款请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+    /**
+     * 退款 查询
+     * @param outRefundNo
+     * @return
+     */
+    @Override
+    public ResultMap refundQuery( String appid,String payWay ,String outRefundNo){
+        String errMsg = "";
+        try{
+            String payWay1 = payWay;
+            QmPayConfig qmPayConfig = new QmPayConfig();
+            if(payWay.contains("qm1")){
+//                QmPay1Config qmPayConfig1 = (QmPay1Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay1Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else
+            if(payWay.contains("qm2")){
+//                QmPay2Config qmPayConfig2 = (QmPay2Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay2Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else{
+//                QmPayConfig qmPayConfig0 = (QmPayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                qmPayConfig = this.qmPayConfig;
+            }
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }
+            /*QmPayConfig qmPayConfig = (QmPayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+//            String url = getBoxUrl(null,PayConstants.QMPAY_METHOD_REFUND_QUERY);
+//            if("prod".equals(appversion)){
+               String url = getUrl(null,PayConstants.QMPAY_METHOD_REFUND_QUERY);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", outRefundNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", "APPDEFAULT"); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("退款地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+//            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 退款查询,交易编号:{},请求参数:{}",outRefundNo,json);
+            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 退款查询,交易编号:{},返回结果:{}",outRefundNo,retJsonStr);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单退款查询,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态-退款状态
+                    if(retJson.getString("refundStatus").contains(PayConstants.SUCCESS)) {
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", String.valueOf(retJson.get("refundOrderId")));
+                        stringStringMap.put("refund_id", String.valueOf(retJson.get("refundTargetOrderId")));
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("sendBackAmount")))));
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "退款查询请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款查询请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+
+    /**
+     * 关闭订单
+     * @param payWay
+     * @param orderNo
+     * @return
+     */
+    @Override
+    public ResultMap colse(String appid,String payWay,String orderNo){
+        String errMsg = "";
+        try{
+            String payWay1 = payWay;
+            QmPayConfig qmPayConfig = new QmPayConfig();
+            if(payWay.contains("qm1")){
+//                QmPay1Config qmPayConfig1 = (QmPay1Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay1Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else
+            if(payWay.contains("qm2")){
+//                QmPay2Config qmPayConfig2 = (QmPay2Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay2Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else{
+//                QmPayConfig qmPayConfig0 = (QmPayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                qmPayConfig = this.qmPayConfig;
+            }
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }
+            /*QmPayConfig qmPayConfig = (QmPayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+            String url = getUrl(payWay,PayConstants.QMPAY_METHOD_CLOSE);
+//            if("prod".equals(appversion)){
+//                url = getUrl(payWay,PayConstants.QMPAY_METHOD_CLOSE);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", "APPDEFAULT"); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("查询地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+//            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 关闭订单,交易编号:{},请求参数:{}",orderNo,json);
+            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 关闭订单,交易编号:{},返回结果:{}",orderNo,retJsonStr);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单-关闭订单,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS)) {
+                        return  ResultMap.ok("关闭成功!")
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                } else {
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "关闭订单请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "关闭订单失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+    /******************************新逻辑*********************************/
+    /**
+     * 统一下单
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap tradeCreateNew(PaymentRequestDto paymentRequestDto){
+        ResultMap resultMap = new ResultMap();
+        try{
+            RechargeUserInfoDto rechargeUserInfoDto = paymentRequestDto.getRechargeUserInfoDto();
+            String payWay = paymentRequestDto.getPayWay();
+            QmPayConfig qmPayConfig = (QmPayConfig) paymentRequestDto.getPayConfigByClass( QmPayConfig.class);
+            boolean isSub = paymentRequestDto.getPayConfig().getBooleanValue("isSub");
+            /*if(paymentRequestDto.getPayWay().contains("qm1")){
+//                QmPay1Config qmPayConfig1 = (QmPay1Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay1Config);
+                payWay = payWay.substring(0,payWay.length()-1);
+                isSub = true;
+            }else
+            if(paymentRequestDto.getPayWay().contains("qm2")){
+//                QmPay2Config qmPayConfig2 = (QmPay2Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay2Config);
+                payWay = payWay.substring(0,payWay.length()-1);
+                isSub = true;
+            }else{
+//                QmPayConfig qmPayConfig0 = (QmPayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                qmPayConfig = this.qmPayConfig;
+            }
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+            String url = getUrlNew(payWay,qmPayConfig,PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            String url = getBoxUrl(payWay, PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            if("prod".equals(appversion)){
+//                url = getUrl(payWay,PayConstants.QMPAY_METHOD_TRADE_CREATE);
+//            }
+            String body = String.valueOf(paymentRequestDto.getBody());
+            if(StringUtils.isNotEmpty(body) ){
+                body = Base64Util.subStringByBytes(body,80)+"...";
+            }
+            String merchantOrderId = getMerchantOrderId(qmPayConfig);
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", merchantOrderId); // 商户订单号
+//            json.put("merOrderId", paymentRequestDto.getOrderNo()); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            JSONObject attachedData = new JSONObject();
+            int totalPrice = paymentRequestDto.getTotalAmount().multiply(new BigDecimal(100)).intValue();
+            //判断子商户信息
+            if(isSub){
+                //设置平台分账金额
+                int platformAmount = 0;
+//                int platformAmount = paymentRequestDto.getTotalAmount().multiply(new BigDecimal(100)).multiply(new BigDecimal(30)).divide(new BigDecimal(100)).intValue();
+                //如果是 子商户模式(分账模式)则设置分账金额
+                int subPrice = totalPrice - platformAmount;
+                json.put("platformAmount", platformAmount);    // 平台分账金额
+                json.put("divisionFlag", true);    // 分账标记 购物车模式
+                JSONArray subOrders = new JSONArray();
+                JSONObject suborder = new JSONObject();
+                suborder.put("mid",qmPayConfig.getSub_mid());
+                suborder.put("totalAmount",subPrice);
+                String subMerOrderId = getMerchantOrderId(qmPayConfig);
+                suborder.put("merOrderId",subMerOrderId);
+                subOrders.add(suborder);
+                json.put("subOrders", subOrders);    // 子商户信息
+                attachedData.put("subOrders",subOrders);
+            }
+//            json.put("instMid", "APPDEFAULT"); // 业务类型
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            json.put("totalAmount", totalPrice);      // 平台支付总金额
+            json.put("expireTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,paymentRequestDto.getExpireTime()));  // 订单过期时间
+            json.put("orderDesc", body);  // 商品描述
+            json.put("notifyUrl", qmPayConfig.getPayNotifyUrl());  // 支付结果通知地址
+            json.put("showUrl", qmPayConfig.getShowUrl());  // 订单展示页面
+            json.put("msgId", qmPayConfig.getPayFlag());  // 支付标记
+            json.put("subAppId", qmPayConfig.getSubAppId());  // 微信子商户appId
+            if("MINIDEFAULT".equals(qmPayConfig.getInstMid()) && payWay.contains("wxpay")){
+                json.put("subOpenId", paymentRequestDto.getWxOpenid());  // 微信子用户openid
+                json.put("tradeType", "MINI");  // 交易类型,微信必传
+                json.put("srcReserve",payWay); //附加数据
+            } else {
+                json.put("tradeType", "APP");  // 交易类型,微信必传
+                json.put("attachedData", payWay); //附加数据
+            }
+//            json.put("limitCreditCard", ""+qmPayConfig.isLimitCreditCard());  // 是否需要 限制信用 卡支付
+            //是否是uac
+            /*if(PayConstants.QMPAY_TYPE_UAC.equals(payWay)){//云闪付参数
+                //invokeType
+                json.put("invokeType", "H5");  // 云闪付参数
+                json.put("supportBank", "");  // 支持的银行
+            }*/
+            //填写用户的实名认证信息
+            if(null != rechargeUserInfoDto && rechargeUserInfoDto.isCheckUserAuth()){
+                json.put("name",rechargeUserInfoDto.getUserName());//实名认证姓名
+                json.put("certType","IDENTITY_CARD");//实名认证证件类型
+                json.put("certNo",rechargeUserInfoDto.getCertificateNo());//实名认证证件号
+                json.put("fixBuyer","T");//是否需要实名认证
+            }
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("下单地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+//            String retJson = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 预下单,交易编号:{},请求参数:{}",paymentRequestDto.getOrderNo(),json);
+            String retJson = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 预下单,交易编号:{},返回结果:{}",paymentRequestDto.getOrderNo(),retJson);
+            log.info("全民付统一下单,返回数据》{}",retJson);
+            JSONObject jsonObject = JSONObject.parseObject(retJson);//转换为json格式数据
+            log.info("全民付统一下单,返回数据》{}",jsonObject);
+            resultMap.put("merOrderId",merchantOrderId);
+            resultMap.put("orderNo",paymentRequestDto.getOrderNo());
+            resultMap.put("appPayRequest",jsonObject.getJSONObject("appPayRequest"));
+            resultMap.put("data",jsonObject);
+            return resultMap;
+        }catch (Exception e){
+            log.error("下单异常信息 {}",e);
+        }
+        return ResultMap.error("下单失败");
+    }
+    /**
+     * 关闭订单
+     * @param paymentRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap colseNew(PaymentRequestDto paymentRequestDto){
+        String errMsg = "";
+        try{
+            String payWay = paymentRequestDto.getPayWay();
+            QmPayConfig qmPayConfig = (QmPayConfig) paymentRequestDto.getPayConfigByClass( QmPayConfig.class);
+            String url = getUrlNew(payWay,qmPayConfig,PayConstants.QMPAY_METHOD_CLOSE);
+//            if("prod".equals(appversion)){
+//                url = getUrl(payWay,PayConstants.QMPAY_METHOD_CLOSE);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", paymentRequestDto.getOrderNo()); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("查询地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+//            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 关闭订单,交易编号:{},请求参数:{}",paymentRequestDto.getOrderNo(),json);
+            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 关闭订单,交易编号:{},返回结果:{}",paymentRequestDto.getOrderNo(),retJsonStr);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单-关闭订单,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS)) {
+                        return  ResultMap.ok("关闭成功!")
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                } else {
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "关闭订单请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "关闭订单失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+    /**
+     * 查询订单
+     * @return
+     */
+    @Override
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto paymentRequestDto){
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        String errMsg = "";
+        try{
+            String payWay = paymentRequestDto.getPayWay();
+            String orderNo = paymentRequestDto.getOrderNo();
+            QmPayConfig qmPayConfig = (QmPayConfig) paymentRequestDto.getPayConfigByClass(QmPayConfig.class);
+            /*QmPayConfig qmPayConfig = new QmPayConfig();
+            if(payWay.contains("qm1")){
+//                QmPay1Config qmPayConfig1 = (QmPay1Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay1Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else
+            if(payWay.contains("qm2")){
+//                QmPay2Config qmPayConfig2 = (QmPay2Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay2Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else{
+//                QmPayConfig qmPayConfig0 = (QmPayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                qmPayConfig = this.qmPayConfig;
+            }
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+            /*QmPayConfig qmPayConfig = (QmPayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+            String url = getUrlNew(payWay,qmPayConfig,PayConstants.QMPAY_METHOD_QUERY_ORDER);
+//            String url = getBoxUrl(payWay1,PayConstants.QMPAY_METHOD_QUERY_ORDER);
+//            if("prod".equals(appversion)){
+//                url = getUrl(payWay,PayConstants.QMPAY_METHOD_QUERY_ORDER);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("查询地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+//            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 查询订单,交易编号:{},请求参数:{}",paymentRequestDto.getOrderNo(),json);
+            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 查询订单,交易编号:{},返回结果:{}",paymentRequestDto.getOrderNo(),retJsonStr);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单查询,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS) ||
+                            retJson.getString("status").contains(PayConstants.SUCCESS)
+                    ) {
+                        paymentInfoResponseDto.setOrderNo(orderNo);
+                        paymentInfoResponseDto.setPayWay(payWay);
+                        paymentInfoResponseDto.setPaymentNo(retJson.getString("targetOrderId"));
+                        paymentInfoResponseDto.setPaymentPrice(new BigDecimal(retJson.getString("totalAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_UP));
+                        paymentInfoResponseDto.setActualPayment(new BigDecimal(retJson.getString("totalAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_UP));
+                        if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY) || payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2APPLET)) {
+                            paymentInfoResponseDto.setActualPayment(new BigDecimal(retJson.getIntValue("buyerPayAmount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_UP));
+                        }
+                        paymentInfoResponseDto.setPaymentSuccessTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, retJson.getString("payTime")));
+                        paymentInfoResponseDto.setSuccess(true);
+                        return paymentInfoResponseDto;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "查询请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "下单失败";
+        }
+        return PaymentInfoResponseDto.error(-2,errMsg);
+    }
+    /**
+     * 退款
+     * @param refundRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap refund( RefundRequestDto refundRequestDto){
+        String errMsg = "";
+        try{
+            String payWay = refundRequestDto.getPayWay();
+            boolean isSub = refundRequestDto.getPayConfig().getBooleanValue("isSub");
+            String orderNo = refundRequestDto.getOrderNo();
+            BigDecimal refundPrice = refundRequestDto.getRefundAmount();
+            String refundMsg = refundRequestDto.getRefundMsg();
+            QmPayConfig qmPayConfig = (QmPayConfig) refundRequestDto.getPayConfigByClass(QmPayConfig.class);
+            /*if(payWay.contains("qm1")){
+//                QmPay1Config qmPayConfig1 = (QmPay1Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay1Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+                isSub = true;
+            }else
+            if(payWay.contains("qm2")){
+//                QmPay2Config qmPayConfig2 = (QmPay2Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay2Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+                isSub = true;
+            }else{
+//                QmPayConfig qmPayConfig0 = (QmPayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                qmPayConfig = this.qmPayConfig;
+            }
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+            /*QmPayConfig qmPayConfig = (QmPayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+            String refundOrderId = getMerchantOrderId(qmPayConfig);
+//            String url = getBoxUrl(null,PayConstants.QMPAY_METHOD_REFUND);
+//            if("prod".equals(appversion)){
+                String url = getUrlNew(null,qmPayConfig,PayConstants.QMPAY_METHOD_REFUND);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", orderNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            int totalPrice = refundPrice.multiply(new BigDecimal(100)).intValue();
+            //判断子商户信息
+            if(isSub){
+                //设置平台分账金额
+//                int platformAmount = refundPrice.multiply(new BigDecimal(100)).multiply(new BigDecimal(30)).divide(new BigDecimal(100)).intValue();
+                int platformAmount = 0;
+                //如果是 子商户模式(分账模式)则设置分账金额
+                int subPrice = totalPrice - platformAmount;
+                json.put("platformAmount", 0);    // 平台分账金额
+                JSONArray subOrders = new JSONArray();
+                JSONObject suborder = new JSONObject();
+                suborder.put("mid",qmPayConfig.getSub_mid());
+                suborder.put("totalAmount",subPrice);
+                String subRefundOrderId = getMerchantOrderId(qmPayConfig);
+                suborder.put("refundOrderId",subRefundOrderId);
+                subOrders.add(suborder);
+                json.put("subOrders", subOrders);    // 子商户信息
+            }
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            json.put("refundAmount", totalPrice); // 退款金额
+            json.put("refundOrderId", refundOrderId); // 退款订单号
+            json.put("refundDesc", refundMsg); // 退款说明
+            json.put("msgId", qmPayConfig.getRefundFlag());  // 退款标记
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("退款地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+//            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 退款,交易编号:{},请求参数:{}",orderNo,json);
+            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 退款,交易编号:{},返回结果:{}",orderNo,retJsonStr);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单退款,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态
+                    if(retJson.getString("status").contains(PayConstants.TRADE_SUCCESS)
+                            || retJson.getString("status").contains(PayConstants.SUCCESS)
+                    ) {
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", refundOrderId);
+                        stringStringMap.put("refund_id", String.valueOf(retJson.get("refundTargetOrderId")));
+                        try{
+                            stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("refundAmount")))));
+                        }catch (NumberFormatException e){
+                            stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("refundInvoiceAmount")))));
+                        }
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "退款请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+    /**
+     * 退款 查询
+     * @param refundRequestDto
+     * @return
+     */
+    @Override
+    public ResultMap refundQuery( RefundRequestDto refundRequestDto){
+        String errMsg = "";
+        try{
+            String payWay = refundRequestDto.getPayWay();
+            QmPayConfig qmPayConfig = (QmPayConfig) refundRequestDto.getPayConfigByClass(QmPayConfig.class);
+            String outRefundNo = refundRequestDto.getRefundNo();
+            /*if(payWay.contains("qm1")){
+//                QmPay1Config qmPayConfig1 = (QmPay1Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay1Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else
+            if(payWay.contains("qm2")){
+//                QmPay2Config qmPayConfig2 = (QmPay2Config) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                BeanUtils.copyBeanProp(qmPayConfig,this.qmPay2Config);
+                payWay1 = payWay.substring(0,payWay.length()-1);
+            }else{
+//                QmPayConfig qmPayConfig0 = (QmPayConfig) payConfig.getByPayType(paymentRequestDto.getPayWay());
+                qmPayConfig = this.qmPayConfig;
+            }
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+            /*QmPayConfig qmPayConfig = (QmPayConfig) payConfig.getByPayType(payWay);
+            if(null == qmPayConfig){
+                qmPayConfig = this.qmPayConfig;
+            }*/
+//            String url = getBoxUrl(null,PayConstants.QMPAY_METHOD_REFUND_QUERY);
+//            if("prod".equals(appversion)){
+                String url = getUrlNew(null,qmPayConfig,PayConstants.QMPAY_METHOD_REFUND_QUERY);
+//            }
+            JSONObject json = new JSONObject();
+            json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));    // 报文请求时间
+            json.put("merOrderId", outRefundNo); // 商户订单号
+            json.put("mid", qmPayConfig.getMid()); // 商户号
+            json.put("tid", qmPayConfig.getTid());    // 终端号
+            json.put("instMid", qmPayConfig.getInstMid()); // 业务类型
+            String authorization = getOpenBodySig(qmPayConfig.getAppid(), qmPayConfig.getAppkey(), json.toString());
+            log.info("退款地址》{}",url);
+            log.info("请求参数》{}",json);
+            log.info("请求头参数》{}",authorization);
+//            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 退款查询,交易编号:{},请求参数:{}",outRefundNo,json);
+            String retJsonStr = send(url, json.toString(), authorization);
+            LogSyncUtil.logSync("全民银商支付 退款查询,交易编号:{},返回结果:{}",outRefundNo,retJsonStr);
+            JSONObject retJson = JSONObject.parseObject(retJsonStr);//转换为json格式数据
+            log.info("全民订单退款查询,返回数据》{}",retJson);
+            if(null != retJson && !retJson.isEmpty()) {
+                //判断状态
+                if(PayConstants.SUCCESS.equals(retJson.getString("errCode"))){
+                    //判断交易状态-退款状态
+                    if(retJson.getString("refundStatus").contains(PayConstants.SUCCESS)) {
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", String.valueOf(retJson.get("refundOrderId")));
+                        stringStringMap.put("refund_id", String.valueOf(retJson.get("refundTargetOrderId")));
+                        stringStringMap.put("refund_fee", String.valueOf(Double.parseDouble(String.valueOf(retJson.get("sendBackAmount")))));
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        errMsg = retJson.getString("status");
+                    }
+                }else{
+                    try{
+                        errMsg = retJson.getString("errMsg");
+                    }catch (Exception e){
+                        errMsg = retJson.getString("errInfo");
+                    }
+                }
+            }else{
+                errMsg = "退款查询请求失败!";
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款查询请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+    /**
+     *
+     * @param url
+     * @param entity
+     * @param authorization
+     * @return
+     * @throws Exception
+     */
+    public String send(String url, String entity , String authorization) throws Exception {
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        HttpPost httpPost = new HttpPost(url);
+        httpPost.addHeader("Authorization", authorization);
+        StringEntity se = new StringEntity(entity, "UTF-8");
+        se.setContentType("application/json");
+        httpPost.setEntity(se);
+        CloseableHttpResponse response = httpClient.execute(httpPost);
+        HttpEntity entity1 = response.getEntity();
+        String resStr = null;
+        if (entity1 != null) {
+            resStr = EntityUtils.toString(entity1, "UTF-8");
+        }
+        httpClient.close();
+        response.close();
+        return resStr;
+    }
+    /**
+     * {来源编号(4位)}{时间(yyyyMMddmmHHssSSS)(17位)}{7位随机数}
+     * @return
+     */
+    public  String getMerchantOrderId(QmPayConfig qmPayConfig){
+        return qmPayConfig.getMsgSrcId()+ DateUtils.parseDateToStr("yyyyMMddmmHHssSSS",new Date())+ RandomUtil.random(7);
+    }
+
+    /**
+     * open-body-sig方式获取到Authorization 的值
+     * @param appId  f0ec96ad2c3848b5b810e7aadf369e2f
+     * @param appKey 775481e2556e4564985f5439a5e6a277
+     * @param body   json字符串 String body = "{\"merchantCode\":\"123456789900081\",\"terminalCode\":\"00810001\",\"merchantOrderId\":\"20123333644493200\",\"transactionAmount\":\"1\",\"merchantRemark\":\"测试\",\"payMode\":\"CODE_SCAN\",\"payCode\":\"285668667587422761\",\"transactionCurrencyCode\":\"156\"}";
+     * @return
+     * @throws Exception
+     */
+    public String getOpenBodySig(String appId, String appKey, String body)  {
+        try{
+            String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+            String nonce = UUID.randomUUID().toString().replace("-", "");
+            byte[] data = body.getBytes("UTF-8");
+            InputStream is = new ByteArrayInputStream(data);
+            String bodyDigest = DigestUtils.sha256Hex(is);
+            String str1_C = appId + timestamp + nonce + bodyDigest;
+            byte[] localSignature = hmacSHA256(str1_C.getBytes(), appKey.getBytes());
+            String localSignatureStr = Base64.encodeBase64String(localSignature);   // Signature
+            is.close();
+            return ("OPEN-BODY-SIG AppId=" + "\"" + appId + "\"" + ", Timestamp=" + "\"" + timestamp + "\"" + ", Nonce=" + "\"" + nonce + "\"" + ", Signature=" + "\"" + localSignatureStr + "\"");
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 加密
+     * @param data
+     * @param key
+     * @return
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeyException
+     */
+    public static byte[] hmacSHA256(byte[] data, byte[] key) throws NoSuchAlgorithmException, InvalidKeyException {
+        String algorithm = "HmacSHA256";
+        Mac mac = Mac.getInstance(algorithm);
+        mac.init(new SecretKeySpec(key, algorithm));
+        return mac.doFinal(data);
+    }
+
+    /**
+     *
+     * @param payWay
+     * @param method
+     * @return
+     */
+    public String getBoxUrl(String payWay,String method) throws Exception {
+        if(StringUtils.isEmpty(method)){
+            throw new Exception("操作失败["+method+"]!");
+        }
+        String url = "";
+        switch (method){
+            case PayConstants.QMPAY_METHOD_TRADE_CREATE: //统一下单
+                if(StringUtils.isEmpty(payWay) ){
+                    throw new Exception("请选择支付类型!");
+                }
+                if(payWay.contains(PayConstants.QMPAY_TYPE_WX )) {//微信支付
+                    url = PayConstants.QMPAY_TRADE_URL_WX_SANDBOX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY )){//支付宝
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY_SANDBOX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2APPLET )){//支付宝跳小程序
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY2APPLET_SANDBOX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2H5 )){//支付宝h5
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY2H5_SANDBOX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_UAC2H5 )){//云闪付h5
+                    url = PayConstants.QMPAY_TRADE_URL_UAC2H5_SANDBOX;
+                }else if(payWay.contains(PayConstants.QMPAY_TYPE_UAC )){
+                    url = PayConstants.QMPAY_TRADE_URL_UAC_SANDBOX;
+                }else if(payWay.equals("CCB") || payWay.equals("CNCB") || payWay.equals("CEB") || payWay.equals(" PAB") ){
+                    url = PayConstants.QMPAY_TRADE_URL_UAC_SANDBOX;
+                }
+                break;
+            case PayConstants.QMPAY_METHOD_QUERY_ORDER: //查询订单
+                url = PayConstants.QMPAY_QUERY_URL_SANDBOX;
+                /*if(StringUtils.isEmpty(payWay) ){
+                    throw new Exception("请选择支付类型!");
+                }
+                if(PayConstants.QMPAY_TYPE_WX.equals(payWay)) {//微信支付
+                    url = PayConstants.QMPAY_QUERY_URL_WX_SANDBOX;
+                }else if (PayConstants.QMPAY_TYPE_ALIPAY.equals(payWay)){//支付宝
+                    url = PayConstants.QMPAY_QUERY_URL_SANDBOX;
+                }else if (PayConstants.QMPAY_TYPE_ALIPAY2APPLET.equals(payWay)){//支付宝跳小程序
+                    url = PayConstants.QMPAY_QUERY_URL_ALIPAY2APPLET_SANDBOX;
+                }else if (PayConstants.QMPAY_TYPE_ALIPAY2H5.equals(payWay)){//支付宝跳小程序
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY2H5_SANDBOX;
+                }*/
+                break;
+            case PayConstants.QMPAY_METHOD_REFUND: //退款
+                    url = PayConstants.QMPAY_REFUND_URL_SANDBOX;
+                break;
+            case PayConstants.QMPAY_METHOD_REFUND_QUERY: //退款-查询
+                    url = PayConstants.QMPAY_QUERY_REFUND_URL_SANDBOX;
+                break;
+            case PayConstants.QMPAY_METHOD_CLOSE: //关闭订单
+                if(StringUtils.isEmpty(payWay) ){
+                    throw new Exception("请选择支付类型!");
+                }
+                if(payWay.contains(PayConstants.QMPAY_TYPE_WX )) {//微信支付
+                    url = PayConstants.QMPAY_CLOSE_URL_WX_SANDBOX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY )){//支付宝
+                    url = PayConstants.QMPAY_CLOSE_URL_SANDBOX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2APPLET )){//支付宝跳小程序
+                    url = PayConstants.QMPAY_CLOSE_URL_ALIPAY2APPLET_SANDBOX;
+                }else{
+                    url = PayConstants.QMPAY_CLOSE_URL_SANDBOX;
+                }
+                break;
+        }
+        if(StringUtils.isEmpty(url)){
+            throw new Exception("请选择支付类型!");
+        }
+        return url;
+    }
+    /**
+     *
+     * @param payWay
+     * @param method
+     * @return
+     */
+    public String getUrl(String payWay,String method) throws Exception {
+        if(StringUtils.isEmpty(method)){
+            throw new Exception("操作失败["+method+"]!");
+        }
+        String url = "";
+        switch (method){
+            case PayConstants.QMPAY_METHOD_TRADE_CREATE: //统一下单
+                if(StringUtils.isEmpty(payWay) ){
+                    throw new Exception("请选择支付类型!");
+                }
+                if(payWay.contains(PayConstants.QMPAY_TYPE_WX)) {//微信支付
+                    url = PayConstants.QMPAY_TRADE_URL_WX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY )){//支付宝
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2APPLET )){//支付宝跳小程序
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY2APPLET;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2H5 )){//支付宝跳小程序
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY2H5;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_UAC2H5 )){//云闪付h5
+                    url = PayConstants.QMPAY_TRADE_URL_UAC2H5;
+                }else if(payWay.contains(PayConstants.QMPAY_TYPE_UAC )){
+                    url = PayConstants.QMPAY_TRADE_URL_UAC;
+                }else if(payWay.equals("CCB") || payWay.equals("CNCB") || payWay.equals("CEB") || payWay.equals(" PAB") ){
+                    url = PayConstants.QMPAY_TRADE_URL_UAC;
+                }
+                break;
+            case PayConstants.QMPAY_METHOD_QUERY_ORDER: //查询订单
+                url = PayConstants.QMPAY_QUERY_URL;
+               /* if(StringUtils.isEmpty(payWay) ){
+                    throw new Exception("请选择支付类型!");
+                }
+                if(PayConstants.QMPAY_TYPE_WX.equals(payWay)) {//微信支付
+                    url = PayConstants.QMPAY_QUERY_URL_WX;
+                }else if (PayConstants.QMPAY_TYPE_ALIPAY.equals(payWay)){//支付宝
+                    url = PayConstants.QMPAY_QUERY_URL;
+                }else if (PayConstants.QMPAY_TYPE_ALIPAY2APPLET.equals(payWay)){//支付宝跳小程序
+                    url = PayConstants.QMPAY_QUERY_URL_ALIPAY2APPLET;
+                }*/
+                break;
+            case PayConstants.QMPAY_METHOD_REFUND: //退款
+                url = PayConstants.QMPAY_REFUND_URL;
+                break;
+            case PayConstants.QMPAY_METHOD_REFUND_QUERY: //退款
+                url = PayConstants.QMPAY_QUERY_REFUND_URL;
+                break;
+            case PayConstants.QMPAY_METHOD_CLOSE: //关闭订单
+                if(StringUtils.isEmpty(payWay) ){
+                    throw new Exception("请选择支付类型!");
+                }
+                if(payWay.contains(PayConstants.QMPAY_TYPE_WX )) {//微信支付
+                    url = PayConstants.QMPAY_CLOSE_URL_WX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY )){//支付宝
+                    url = PayConstants.QMPAY_CLOSE_URL;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2APPLET )){//支付宝跳小程序
+                    url = PayConstants.QMPAY_CLOSE_URL_ALIPAY2APPLET;
+                }else{
+                    url = PayConstants.QMPAY_CLOSE_URL;
+                }
+                break;
+            default :
+                break;
+        }
+        if(StringUtils.isEmpty(url)){
+            throw new Exception("请选择支付类型!");
+        }
+        return url;
+    }
+    /**
+     *
+     * @param payWay
+     * @param method
+     * @return
+     */
+    public String getUrlNew(String payWay,QmPayConfig qmPayConfig,String method) throws Exception {
+        if(StringUtils.isEmpty(method)){
+            throw new Exception("操作失败["+method+"]!");
+        }
+        String instMid = qmPayConfig.getInstMid();
+        String url = "";
+        switch (method){
+            case PayConstants.QMPAY_METHOD_TRADE_CREATE: //统一下单
+                if(StringUtils.isEmpty(payWay) ){
+                    throw new Exception("请选择支付类型!");
+                }if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2APPLET ) && "APPDEFAULT".equals(instMid)){//支付宝跳小程序
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY2APPLET;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2APPLET ) && "MINIDEFAULT".equals(instMid)){//支付宝跳小程序-mini
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY2APPLET_MINI;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2H5 ) && "APPDEFAULT".equals(instMid)){//支付宝跳小程序-app
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY2H5;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2H5 ) && "H5DEFAULT".equals(instMid) ){//支付宝-h5
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY2H5_MINI;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_WX2H5 ) && "H5DEFAULT".equals(instMid) ){//微信-h5
+                    url = PayConstants.QMPAY_TRADE_URL_WX2H5_MINI;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_UAC2H5 ) && "H5DEFAULT".equals(instMid) ){//云闪付h5
+                    url = PayConstants.QMPAY_TRADE_URL_UAC2H5_MINI;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_UAC2H5 )){//云闪付h5
+                    url = PayConstants.QMPAY_TRADE_URL_UAC2H5;
+                }else if(payWay.contains(PayConstants.QMPAY_TYPE_UAC ) && "APPDEFAULT".equals(instMid)){
+                    url = PayConstants.QMPAY_TRADE_URL_UAC;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_UAC ) && "MINIDEFAULT".equals(instMid)){//云闪付跳小程序-mini
+                    url = PayConstants.QMPAY_TRADE_URL_UAC_MINI;
+                }else if(payWay.equals("CCB") || payWay.equals("CNCB") || payWay.equals("CEB") || payWay.equals(" PAB") ){
+                    url = PayConstants.QMPAY_TRADE_URL_UAC;
+                }else if(payWay.contains(PayConstants.QMPAY_TYPE_WX) && "APPDEFAULT".equals(instMid)) {//微信支付
+                    url = PayConstants.QMPAY_TRADE_URL_WX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_WX ) && "MINIDEFAULT".equals(instMid)){//微信跳小程序-mini
+                    url = PayConstants.QMPAY_TRADE_URL_WX_MINI;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY )){//支付宝
+                    url = PayConstants.QMPAY_TRADE_URL_ALIPAY;
+                }
+                    break;
+            case PayConstants.QMPAY_METHOD_QUERY_ORDER: //查询订单
+                url = PayConstants.QMPAY_QUERY_URL;
+                if("MINIDEFAULT".equals(instMid)||"H5DEFAULT".equals(instMid)){
+                    url = PayConstants.QMPAY_QUERY_URL_MINI;
+                }
+               /* if(StringUtils.isEmpty(payWay) ){
+                    throw new Exception("请选择支付类型!");
+                }
+                if(PayConstants.QMPAY_TYPE_WX.equals(payWay)) {//微信支付
+                    url = PayConstants.QMPAY_QUERY_URL_WX;
+                }else if (PayConstants.QMPAY_TYPE_ALIPAY.equals(payWay)){//支付宝
+                    url = PayConstants.QMPAY_QUERY_URL;
+                }else if (PayConstants.QMPAY_TYPE_ALIPAY2APPLET.equals(payWay)){//支付宝跳小程序
+                    url = PayConstants.QMPAY_QUERY_URL_ALIPAY2APPLET;
+                }*/
+                break;
+            case PayConstants.QMPAY_METHOD_REFUND: //退款
+                url = PayConstants.QMPAY_REFUND_URL;
+                if("MINIDEFAULT".equals(instMid)||"H5DEFAULT".equals(instMid)){
+                    url = PayConstants.QMPAY_REFUND_URL_MINI;
+                }
+                break;
+            case PayConstants.QMPAY_METHOD_REFUND_QUERY: //退款
+                url = PayConstants.QMPAY_QUERY_REFUND_URL;
+                if("MINIDEFAULT".equals(instMid)||"H5DEFAULT".equals(instMid)){
+                    url = PayConstants.QMPAY_QUERY_REFUND_URL_MINI;
+                }
+                break;
+            case PayConstants.QMPAY_METHOD_CLOSE: //关闭订单
+                if(StringUtils.isEmpty(payWay) ){
+                    throw new Exception("请选择支付类型!");
+                }
+                if(payWay.contains(PayConstants.QMPAY_TYPE_WX )) {//微信支付
+                    url = PayConstants.QMPAY_CLOSE_URL_WX;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY )){//支付宝
+                    url = PayConstants.QMPAY_CLOSE_URL;
+                }else if (payWay.contains(PayConstants.QMPAY_TYPE_ALIPAY2APPLET )){//支付宝跳小程序
+                    url = PayConstants.QMPAY_CLOSE_URL_ALIPAY2APPLET;
+                }else{
+                    url = PayConstants.QMPAY_CLOSE_URL;
+                }
+                break;
+            default :
+                break;
+        }
+        if(StringUtils.isEmpty(url)){
+            throw new Exception("请选择支付类型!");
+        }
+        return url;
+    }
+
+}

+ 354 - 0
tzy-framework/src/main/java/com/tzy/framework/pay/service/impl/Qme1PayServiceImpl.java

@@ -0,0 +1,354 @@
+package com.tzy.framework.pay.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.jeequan.jeepay.JeepayClient;
+import com.jeequan.jeepay.model.PayOrderCreateReqModel;
+import com.jeequan.jeepay.model.PayOrderQueryReqModel;
+import com.jeequan.jeepay.model.RefundOrderCreateReqModel;
+import com.jeequan.jeepay.model.RefundOrderQueryReqModel;
+import com.jeequan.jeepay.request.PayOrderCreateRequest;
+import com.jeequan.jeepay.request.PayOrderQueryRequest;
+import com.jeequan.jeepay.request.RefundOrderCreateRequest;
+import com.jeequan.jeepay.request.RefundOrderQueryRequest;
+import com.jeequan.jeepay.response.PayOrderCreateResponse;
+import com.jeequan.jeepay.response.PayOrderQueryResponse;
+import com.jeequan.jeepay.response.RefundOrderCreateResponse;
+import com.jeequan.jeepay.response.RefundOrderQueryResponse;
+import com.tzy.common.utils.Base64Util;
+import com.tzy.common.utils.IpUtils;
+import com.tzy.common.utils.LogSyncUtil;
+import com.tzy.common.utils.ServletUtils;
+import com.tzy.framework.pay.config.QmPayConfig;
+import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
+import com.tzy.framework.pay.dto.PaymentRequestDto;
+import com.tzy.framework.pay.dto.RefundRequestDto;
+import com.tzy.framework.pay.dto.ResultMap;
+import com.tzy.framework.pay.service.Qme1PayService;
+import com.tzy.framework.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 全民 易一 支付
+ */
+@Slf4j
+@Service
+public class Qme1PayServiceImpl implements Qme1PayService {
+
+//    private String apiHost = "https://payapi.e1tech.cn";
+    private String apiHost = "https://payapi.proxy.sygorun.com";
+
+    /**
+     * 统一下单
+     * @param payRequestBody
+     * @return
+     */
+    public ResultMap tradeCreate(PaymentRequestDto payRequestBody){
+        ResultMap resultMap = new ResultMap();
+        try{
+            String payWay = payRequestBody.getPayWay();
+            QmPayConfig qmPayConfig = (QmPayConfig) payRequestBody.getPayConfigByClass( QmPayConfig.class);
+//            boolean isSub = payRequestBody.getPayConfig().getBooleanValue("isSub");
+            String body = String.valueOf(payRequestBody.getBody());
+            if(StringUtils.isNotEmpty(body) ){
+                body = Base64Util.subStringByBytes(body,80)+"...";
+            }
+            String subject = "集换式卡牌";
+            String merchantOrderId = RandomUtil.getRandomNew(RandomUtil.GROUP_USER_ORDER);
+            JeepayClient jeepayClient = JeepayClient.getInstance(qmPayConfig.getAppId(), qmPayConfig.getAppkey(), apiHost);
+            // 构建请求数据
+            PayOrderCreateReqModel model = new PayOrderCreateReqModel();
+            model.setExpiredTime(String.valueOf(payRequestBody.getExpireTime().getTime()-payRequestBody.getCreateOrderTime().getTime()));
+            // 商户号
+            model.setMchNo(qmPayConfig.getMid());
+            // 应用ID
+            model.setAppId(jeepayClient.getAppId());
+            // 商户订单号
+            model.setMchOrderNo(merchantOrderId);
+            // 支付方式
+            model.setWayCode(payRequestBody.getPaySubWay());
+            // 金额,单位分
+            model.setAmount(payRequestBody.getTotalAmount().multiply(new BigDecimal(100)).longValue());
+            // 币种,目前只支持cny
+            model.setCurrency("CNY");
+            // 发起支付请求客户端的IP地址
+            String ipAddr = IpUtils.getIpAddr(ServletUtils.getRequest());
+            if(StringUtils.isNotEmpty(ipAddr)) {
+                String[] ipArray = ipAddr.split(",");
+                String ip = ipArray[0];
+                model.setClientIp(ip);
+            }else{
+                return ResultMap.error("下单失败[IP异常]!");
+            }
+            // 商品标题
+            model.setSubject(subject);
+            // 商品描述
+            model.setBody(body);
+            // 后台服务器回调地址,
+            model.setNotifyUrl(qmPayConfig.getPayNotifyUrl());
+            model.setExtParam(payWay);//扩展参数验证支付方式
+            PayOrderCreateRequest request = new PayOrderCreateRequest();
+            request.setBizModel(model);
+            log.info(" 请求参数:{} ",JSONObject.toJSONString(request));
+            // 发起统一下单
+            LogSyncUtil.logSync("全民易一支付 预下单,交易编号:{},请求参数:{}",payRequestBody.getOrderNo(),request);
+            PayOrderCreateResponse response = jeepayClient.execute(request);
+            LogSyncUtil.logSync("全民易一支付 预下单,交易编号:{},返回结果:{}",payRequestBody.getOrderNo(),response);
+            log.info(" 统一下单返回结果:{} ",response);
+            // 验证返回数据签名
+            if(response.checkSign(qmPayConfig.getAppkey())) {
+                // 判断下单是否返回成功
+                if(response.isSuccess(qmPayConfig.getAppkey())){
+                    JSONObject data = response.getData();
+                    String payData = data.getString("payData");
+                    resultMap.put("merOrderId",merchantOrderId);
+                    resultMap.put("orderNo",payRequestBody.getOrderNo());
+                    resultMap.put("qrcode",payData);
+                    data.put("merOrderId",merchantOrderId);
+                    data.put("url",payData);
+                    resultMap.put("data",data);
+                    return resultMap;
+                } else {
+                    return ResultMap.error(response.getMsg());
+                }
+            } else {
+                return ResultMap.error("签名验证失败");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return ResultMap.error("下单失败");
+    }
+
+    /**
+     * 支付查询
+     * @param payRequestBody
+     * @return
+     */
+    public PaymentInfoResponseDto queryOrder(PaymentRequestDto payRequestBody) {
+        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
+        String errMsg = "";
+        try{
+            String payWay = payRequestBody.getPayWay();
+            String orderNo = payRequestBody.getOrderNo();
+            QmPayConfig qmPayConfig = (QmPayConfig) payRequestBody.getPayConfigByClass(QmPayConfig.class);
+            JeepayClient jeepayClient = JeepayClient.getInstance(qmPayConfig.getAppId(), qmPayConfig.getAppkey(), apiHost);
+            PayOrderQueryRequest request = new PayOrderQueryRequest();
+            PayOrderQueryReqModel model = new PayOrderQueryReqModel();
+            model.setAppId(qmPayConfig.getAppId());//应⽤ID
+            model.setMchNo(qmPayConfig.getMid());//商户号
+            model.setMchOrderNo(orderNo);//商户订单号
+            request.setBizModel(model);
+            log.info(" 请求参数:{} ",JSONObject.toJSONString(request));
+            // 发起统一下单
+//            PayOrderQueryResponse response = jeepayClient.execute(request);
+            LogSyncUtil.logSync("全民易一支付 查询,交易编号:{},请求参数:{}",payRequestBody.getOrderNo(),request);
+            PayOrderQueryResponse response = jeepayClient.execute(request);
+            LogSyncUtil.logSync("全民易一支付 查询,交易编号:{},返回结果:{}",payRequestBody.getOrderNo(),response);
+            log.info(" 统一下单返回结果:{} ",response);
+            // 验证返回数据签名
+            if(response.checkSign(qmPayConfig.getAppkey())) {
+                // 判断下单是否返回成功
+                if(response.isSuccess(qmPayConfig.getAppkey())){
+                    JSONObject data = response.getData();
+                    if(data.getInteger("state") == 2){
+                        paymentInfoResponseDto.setSuccess(true);
+                        paymentInfoResponseDto.setOrderNo(orderNo);
+                        paymentInfoResponseDto.setPayWay(payWay);
+                        paymentInfoResponseDto.setPaymentNo(data.getString("payOrderId"));
+                        paymentInfoResponseDto.setPaymentPrice(new BigDecimal(data.getString("amount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        paymentInfoResponseDto.setActualPayment(new BigDecimal(data.getString("amount")).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN));
+                        paymentInfoResponseDto.setPaymentSuccessTime(new Date(data.getLong("successTime")));
+//                        paymentInfoResponseDto.setPaymentSuccessTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, data.getString("successTime")));
+                        return paymentInfoResponseDto;
+                    }else{
+                        return PaymentInfoResponseDto.error(-1,getPayStateMsg(data.getInteger("state")));
+                    }
+                } else {
+                    return PaymentInfoResponseDto.error(-1,response.getMsg());
+                }
+            } else {
+                return PaymentInfoResponseDto.error(-1,"签名验证失败");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "下单失败";
+        }
+        return PaymentInfoResponseDto.error(-2,errMsg);
+    }
+
+    /**
+     * 退款
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap refund(RefundRequestDto refundRequestDto) {
+        String errMsg = "";
+        try{
+            QmPayConfig qmPayConfig = (QmPayConfig) refundRequestDto.getPayConfigByClass(QmPayConfig.class);
+            JeepayClient jeepayClient = JeepayClient.getInstance(qmPayConfig.getAppId(), qmPayConfig.getAppkey(), apiHost);
+            RefundOrderCreateReqModel model = new RefundOrderCreateReqModel();
+            String refundOrderId = RandomUtil.getRandomOld(RandomUtil.REFUND_NO);
+            model.setAppId(qmPayConfig.getAppId());
+            model.setMchNo(qmPayConfig.getMid());
+            model.setMchRefundNo(refundOrderId);//退款编码
+            model.setMchOrderNo(refundRequestDto.getOrderNo());//商户订单号
+            model.setRefundAmount(refundRequestDto.getRefundAmount().multiply(new BigDecimal(100)).longValue());//退款金额
+            model.setCurrency("cny");//货币代码
+            model.setRefundReason(refundRequestDto.getRefundMsg());//退款原因
+            model.setExtParam(refundRequestDto.getPayWay());//扩展参数
+            RefundOrderCreateRequest  request = new RefundOrderCreateRequest();
+            request.setBizModel(model);
+            log.info(" 请求参数:{} ",JSONObject.toJSONString(request));
+            // 发起统一下单
+//            RefundOrderCreateResponse response = jeepayClient.execute(request);
+            LogSyncUtil.logSync("全民易一支付 退款,交易编号:{},请求参数:{}",refundRequestDto.getOrderNo(),request);
+            RefundOrderCreateResponse response = jeepayClient.execute(request);
+            LogSyncUtil.logSync("全民易一支付 退款,交易编号:{},返回结果:{}",refundRequestDto.getOrderNo(),response);
+            log.info(" 退款返回结果:{} ",response);
+            // 验证返回数据签名
+            if(response.checkSign(qmPayConfig.getAppkey())) {
+                // 判断下单是否返回成功
+                if(response.isSuccess(qmPayConfig.getAppkey())){
+                    JSONObject data = response.getData();
+                    if(data.getInteger("state") == 2){
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", refundOrderId);
+                        stringStringMap.put("refund_id", data.getString("refundOrderId"));
+                        stringStringMap.put("refund_fee", String.valueOf(model.getRefundAmount()));
+                        stringStringMap.put("fund_change", "Y");
+                        stringStringMap.put("refund_status","SUCCESS");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        return ResultMap.error(-1,getRefundStateMsg(data.getInteger("state")));
+                    }
+                } else {
+                    return ResultMap.error(-1,response.getMsg());
+                }
+            } else {
+                return ResultMap.error(-1,"签名验证失败");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+
+    /**
+     * 退款 查询
+     * @param refundRequestDto
+     * @return
+     */
+    public ResultMap refundQuery(RefundRequestDto refundRequestDto) {
+        String errMsg = "";
+        try{
+            QmPayConfig qmPayConfig = (QmPayConfig) refundRequestDto.getPayConfigByClass(QmPayConfig.class);
+            JeepayClient jeepayClient = JeepayClient.getInstance(qmPayConfig.getAppId(), qmPayConfig.getAppkey(), apiHost);
+            RefundOrderQueryReqModel model = new RefundOrderQueryReqModel();
+            model.setMchRefundNo(refundRequestDto.getRefundNo());//退款编码
+            model.setAppId(qmPayConfig.getAppId());
+            model.setMchNo(qmPayConfig.getMid());
+            RefundOrderQueryRequest request = new RefundOrderQueryRequest();
+            request.setBizModel(model);
+            log.info(" 请求参数:{} ",JSONObject.toJSONString(request));
+            // 发起统一下单
+//            RefundOrderQueryResponse response = jeepayClient.execute(request);
+            LogSyncUtil.logSync("全民易一支付 退款查询,交易编号:{},请求参数:{}",refundRequestDto.getRefundNo(),request);
+            RefundOrderQueryResponse response = jeepayClient.execute(request);
+            LogSyncUtil.logSync("全民易一支付 退款查询,交易编号:{},返回结果:{}",refundRequestDto.getRefundNo(),response);
+            log.info(" 退款 查询返回结果:{} ",response);
+            // 验证返回数据签名
+            if(response.checkSign(qmPayConfig.getAppkey())) {
+                // 判断下单是否返回成功
+                if(response.isSuccess(qmPayConfig.getAppkey())){
+                    JSONObject data = response.getData();
+                    if(data.getInteger("state") == 2){
+                        Map<String, String> stringStringMap = new HashMap<>();
+                        stringStringMap.put("out_refund_no", refundRequestDto.getRefundNo());
+                        stringStringMap.put("refund_id", data.getString("refundOrderId"));
+                        stringStringMap.put("refund_fee", String.valueOf(data.getInteger("refundAmount")));
+                        stringStringMap.put("fund_change", "Y");
+                        return  ResultMap.ok()
+                                .put("data",stringStringMap)
+                                ;
+                    }else{
+                        return ResultMap.error(-1,getRefundStateMsg(data.getInteger("state")));
+                    }
+                } else {
+                    return ResultMap.error(-1,response.getMsg());
+                }
+            } else {
+                return ResultMap.error(-1,"签名验证失败");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error(e.getMessage());
+            errMsg = "退款请求失败";
+        }
+        return ResultMap.error(-2,errMsg);
+    }
+
+
+    private String getPayStateMsg(Integer state){
+        String stateMsg = "下单失败[-1]";
+        switch (state){
+            case 0:
+                stateMsg = "待支付[0]";
+                break;
+            case 1:
+                stateMsg = "⽀付中[1]";
+                break;
+            case 2:
+                stateMsg = "⽀付成功[2]";
+                break;
+            case 3:
+                stateMsg = "⽀付失败[3]";
+                break;
+            case 4:
+                stateMsg = "已撤销[4]";
+                break;
+            case 5:
+                stateMsg = "已退款[5]";
+                break;
+            case 6:
+                stateMsg = "订单关闭[6]";
+                break;
+        }
+        return stateMsg;
+    }
+
+    private String getRefundStateMsg(Integer state){
+        String stateMsg = "下单失败[-1]";
+        switch (state){
+            case 0:
+                stateMsg = "退款中[0]";
+                break;
+            case 1:
+                stateMsg = "退款中[1]";
+                break;
+            case 2:
+                stateMsg = "退款成功[2]";
+                break;
+            case 3:
+                stateMsg = "退款失败[3]";
+                break;
+            case 4:
+                stateMsg = "退款关闭[4]";
+                break;
+        }
+        return stateMsg;
+    }
+
+}

Некоторые файлы не были показаны из-за большого количества измененных файлов