Browse Source

Merge branch 'feature/asyncOrder' of http://git.aseanbusiness.cn/qzyReal/market-server into feature/asyncOrder

# Conflicts:
#	sp-service/payment-server/src/main/java/com/pj/listenone/BaseInfoListenOne.java
#	sp-service/payment-server/src/main/java/com/pj/rabbitmqtwo/MessageReceiver.java
#	sp-service/payment-server/src/main/java/com/pj/rabbitmqtwo/MessageSender.java
#	sp-service/payment-server/src/main/java/com/pj/rabbitmqtwo/RabbitMQProperties.java
#	sp-service/payment-server/src/main/java/com/pj/rabbitmqtwo/RabbitmqConfigTwo.java
#	sp-service/payment-server/src/main/java/com/pj/task/BankByteTask.java
#	sp-service/payment-server/src/main/java/com/pj/task/PaymentService.java
qzyReal 1 year ago
parent
commit
45e802f5f6

+ 6 - 5
sp-core/sp-api/src/main/java/com/pj/api/client/payment_server/PaymentServerInterface.java

@@ -4,6 +4,7 @@ import com.pj.api.FeignInterceptor;
 import com.pj.api.consts.FeignConsts;
 import com.pj.api.dto.*;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 
@@ -17,30 +18,30 @@ public interface PaymentServerInterface {
     /**
      * 调用银行扣款接口
      */
-    @RequestMapping("/payment/rpc/sendSXB010")
+    @GetMapping("/payment/rpc/sendSXB010")
     void sendSXB010(@RequestBody PaymentDto paymentDto);
 
     /**
      * 调用银行退款接口
      */
-    @RequestMapping("/payment/rpc/sendSXB013")
+    @GetMapping("/payment/rpc/sendSXB013")
     void sendSXB013(@RequestBody PaymentDto paymentDto);
 
     /**
      * 调用通关车批信息同步接口(车出一级市场时)
      */
-    @RequestMapping("/payment/rpc/sendSXB023")
+    @GetMapping("/payment/rpc/sendSXB023")
     void sendSXB023(@RequestBody PaymentDto paymentDto);
 
     /**
      * 订单扣款(无手续费)
      */
-    @RequestMapping("/payment/rpc/sendMKT006_NoCommission")
+    @GetMapping("/payment/rpc/sendMKT006_NoCommission")
     void sendMKT006_NoCommission(@RequestBody PaymentTwoDto paymentTwoDto);
 
     /**
      * 订单扣款(+手续费)
      */
-    @RequestMapping("/payment/rpc/sendMKT006")
+    @GetMapping("/payment/rpc/sendMKT006")
     void sendMKT006(@RequestBody PaymentTwoDto paymentTwoDto);
 }

+ 0 - 13
sp-service/async-server/src/main/java/com/pj/task/HtByteTask.java

@@ -1,36 +1,24 @@
 package com.pj.task;
 
-import cn.hutool.json.JSONUtil;
 import cn.hutool.log.StaticLog;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.pj.api.client.async_server.AsyncServerInterface;
-import com.pj.api.client.level_one_server.LevelOneServerInterface;
-import com.pj.api.client.transport.TransportInterface;
 import com.pj.api.consts.FeignFactory;
 import com.pj.api.dto.*;
 import com.pj.common.core.exception.ServiceException;
 import com.pj.dto.DataDto;
 import com.pj.api.dto.HtGoodsDto;
 import com.pj.enummj.FinishStatus;
-import com.pj.feign.AmqpTemplateFeign;
-import com.pj.ht_border_buy_goods_list.HtBorderBuyGoodsListMapper;
-import com.pj.ht_borders_list.HtBordersList;
-import com.pj.ht_borders_list.HtBordersListMapper;
 import com.pj.ht_byte.HtByte;
 import com.pj.ht_byte.HtByteMapper;
 import com.pj.ht_declare_chargeback.HtDeclareChargeback;
 import com.pj.ht_declare_chargeback.HtDeclareChargebackMapper;
 import com.pj.ht_import_declare_people.HtImportDeclarePeople;
 import com.pj.ht_import_declare_people.HtImportDeclarePeopleMapper;
-import com.pj.ht_pass_card_record.HtPassCardRecord;
 import com.pj.ht_pass_card_record.HtPassCardRecordMapper;
-import com.pj.ht_sell_goods_list.HtSellGoodsList;
-import com.pj.ht_sell_goods_list.HtSellGoodsListMapper;
 import com.pj.ht_trade_settlement.HtTradeSettlement;
 import com.pj.ht_trade_settlement.HtTradeSettlementMapper;
-import com.pj.project4sp.SP;
 import com.pj.rabbitmq.RabbitMQ;
 import com.pj.utils.ht.AESUtil;
 import org.springframework.beans.BeanUtils;
@@ -41,7 +29,6 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 

+ 57 - 0
sp-service/payment-server/src/main/java/com/pj/listenone/BaseInfoListenOne.java

@@ -0,0 +1,57 @@
+package com.pj.listenone;
+
+import cn.hutool.core.util.RandomUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.pj.bank_byte.BankByte;
+import com.pj.bank_byte.BankByteMapper;
+import com.pj.dto.DataDto;
+import com.pj.enummj.FinishStatus;
+import com.pj.rabbitmqone.RabbitMQOne;
+import com.pj.utils.ht.AESUtil;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.Queue;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Component
+public class BaseInfoListenOne {
+
+
+    @Autowired
+    private BankByteMapper bankByteMapper;
+
+    /**
+     * 监听: 接收并保存银行回执信息
+     * @param json
+     */
+    @RabbitListener(queuesToDeclare = @Queue(RabbitMQOne.TEST_ACCEPT_QUEUE))
+    public void accept(Message json){
+        System.out.println("-----------------开始接收:银行回执信息------------------------");
+        byte[] content = json.getBody();
+        //保存到数据库
+        String jsonString = new String(content);
+        bankByteMapper.insert(new BankByte(RandomUtil.randomString(64),jsonString, RabbitMQOne.TEST_ACCEPT_QUEUE, FinishStatus.FINISH_STATUS_ZERO.getCode(),new Date()));
+        System.out.println("-----------------完成接收:银行回执信息------------------------");
+
+    }
+
+
+    /**
+     * 测试接收
+     * 测试已通过
+     */
+    @RabbitListener(queuesToDeclare = @Queue(RabbitMQOne.TEST_SEND_QUEUE))
+    public void sendMessage(Message dataDto1){
+        System.out.println("---------开始发送:银行接口报文-----------------");
+        byte[] body = dataDto1.getBody();
+        String s = new String(body);
+        DataDto dataDto = JSONObject.parseObject(s, DataDto.class);
+        //String cbc = AESUtil.decryptCBC(dataDto.getData(), RabbitMQOne.ACC_KEY);
+        //OrderDto orderDto = JSONObject.parseObject(cbc, OrderDto.class);
+        System.out.println(dataDto.getData() + "\n---------结束发送:银行接口报文-----------------");
+    }
+
+}

+ 57 - 0
sp-service/payment-server/src/main/java/com/pj/listentwo/BaseInfoListenTwo.java

@@ -0,0 +1,57 @@
+package com.pj.listentwo;
+
+import cn.hutool.core.util.RandomUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.pj.bank_byte.BankByte;
+import com.pj.bank_byte.BankByteMapper;
+import com.pj.dto.DataDto;
+import com.pj.enummj.FinishStatus;
+import com.pj.rabbitmqtwo.RabbitMQTwo;
+import com.pj.utils.ht.AESUtil;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.Queue;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Component
+public class BaseInfoListenTwo {
+
+
+    @Autowired
+    private BankByteMapper bankByteMapper;
+
+    /**
+     * 监听: 接收并保存银行回执信息
+     * @param json
+     */
+    @RabbitListener(queuesToDeclare = @Queue(RabbitMQTwo.TEST_ACCEPT_QUEUE))
+    public void accept(Message json){
+        System.out.println("-----------------开始接收:银行回执信息------------------------");
+        byte[] content = json.getBody();
+        //保存到数据库
+        String jsonString = new String(content);
+        bankByteMapper.insert(new BankByte(RandomUtil.randomString(64),jsonString, RabbitMQTwo.TEST_ACCEPT_QUEUE, FinishStatus.FINISH_STATUS_ZERO.getCode(),new Date()));
+        System.out.println("-----------------完成接收:银行回执信息------------------------");
+
+    }
+
+
+    /**
+     * 测试接收
+     * 测试已通过
+     */
+    @RabbitListener(queuesToDeclare = @Queue(RabbitMQTwo.TEST_SEND_QUEUE))
+    public void sendMessage(Message dataDto1){
+        System.out.println("---------开始发送:银行接口报文-----------------");
+        byte[] body = dataDto1.getBody();
+        String s = new String(body);
+        DataDto dataDto = JSONObject.parseObject(s, DataDto.class);
+        //String cbc = AESUtil.decryptCBC(dataDto.getData(), RabbitMQOne.ACC_KEY);
+        //OrderDto orderDto = JSONObject.parseObject(cbc, OrderDto.class);
+        System.out.println(dataDto.getData() + "\n---------结束发送:银行接口报文-----------------");
+    }
+
+}

+ 36 - 0
sp-service/payment-server/src/main/java/com/pj/rabbitmqone/RabbitMQOne.java

@@ -0,0 +1,36 @@
+package com.pj.rabbitmqone;
+
+
+public class RabbitMQOne {
+
+
+    //public static final String ACC_KEY = "klfksd78974s1d4f";
+
+
+    /**
+     *  发送方队列
+     */
+    public static final String TEST_SEND_QUEUE = "BT_MARKET_INBOUND";
+
+    /**
+     *  发送方路由键
+     */
+    //public static final String TEST_SEND_ROUTING_KEY = "testAcceptKey";
+
+    /**
+     *  接收方队列
+     */
+    public static final String TEST_ACCEPT_QUEUE = "BT_MARKET_OUTBOUND";
+
+    /**
+     *  接收方路由键
+     */
+    //public static final String TEST_ACCEPT_ROUTING_KEY = "testSendKey";
+
+
+    /**
+     *  交换机
+     */
+    public static final String MQ_DIRECT_EXCHANGE = "bt_acquiring_bank_test_mrcc";
+
+}

+ 76 - 0
sp-service/payment-server/src/main/java/com/pj/rabbitmqone/RabbitmqConfigOne.java

@@ -0,0 +1,76 @@
+package com.pj.rabbitmqone;
+
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.DirectExchange;
+import org.springframework.amqp.core.Queue;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class RabbitmqConfigOne {
+//
+//
+//    @Value("${spring.rabbitmq.host}")
+//    private String host;
+//
+//    @Value("${spring.rabbitmq.port}")
+//    private int port;
+//
+//    @Value("${spring.rabbitmq.username}")
+//    private String username;
+//
+//    @Value("${spring.rabbitmq.password}")
+//    private String password;
+//
+//    @Value("${spring.rabbitmq.virtual-host}")
+//    private String virtualHost;
+
+
+
+    /**
+     * 发送时的mq队列
+     * @return
+     */
+    @Bean
+    public Queue testSend(){
+        return new Queue(RabbitMQOne.TEST_SEND_QUEUE,true);
+    }
+
+    /**
+     * 接收时的mq队列
+     * @return
+     */
+    @Bean
+    public Queue testAccept(){
+        return new Queue(RabbitMQOne.TEST_ACCEPT_QUEUE,true);
+    }
+
+    /**
+     * 交换机
+     * @return
+     */
+    @Bean
+    public DirectExchange directExchange(){
+        return new DirectExchange(RabbitMQOne.MQ_DIRECT_EXCHANGE,true,false);
+    }
+
+    /**
+     * 绑定
+     * 发送
+     */
+    /*@Bean
+    public Binding bindingSend(){
+        return BindingBuilder.bind(testSend()).to(directExchange()).with(RabbitMQOne.TEST_SEND_ROUTING_KEY);
+    }*/
+
+    /**
+     * 绑定
+     * 接收
+     */
+    /*@Bean
+    public Binding bindingAccept(){
+        return BindingBuilder.bind(testAccept()).to(directExchange()).with(RabbitMQOne.TEST_ACCEPT_ROUTING_KEY);
+    }*/
+
+}

+ 0 - 0
sp-service/payment-server/src/main/java/com/pj/rabbitmq/MessageReceiver.java → sp-service/payment-server/src/main/java/com/pj/rabbitmqtwo/MessageReceiver.java


+ 0 - 0
sp-service/payment-server/src/main/java/com/pj/rabbitmq/MessageSender.java → sp-service/payment-server/src/main/java/com/pj/rabbitmqtwo/MessageSender.java


+ 0 - 0
sp-service/payment-server/src/main/java/com/pj/rabbitmq/RabbitMQProperties.java → sp-service/payment-server/src/main/java/com/pj/rabbitmqtwo/RabbitMQProperties.java


+ 36 - 0
sp-service/payment-server/src/main/java/com/pj/rabbitmqtwo/RabbitMQTwo.java

@@ -0,0 +1,36 @@
+package com.pj.rabbitmqtwo;
+
+
+public class RabbitMQTwo {
+
+
+    //public static final String ACC_KEY = "klfksd78974s1d4f";
+
+
+    /**
+     *  发送方队列
+     */
+    public static final String TEST_SEND_QUEUE = "BT_ACQUIRING_INBOUND";
+
+    /**
+     *  发送方路由键
+     */
+    //public static final String TEST_SEND_ROUTING_KEY = "testAcceptKey";
+
+    /**
+     *  接收方队列
+     */
+    public static final String TEST_ACCEPT_QUEUE = "BT_ACQUIRING_OUTBOUND";
+
+    /**
+     *  接收方路由键
+     */
+    //public static final String TEST_ACCEPT_ROUTING_KEY = "testSendKey";
+
+
+    /**
+     *  交换机
+     */
+    public static final String MQ_DIRECT_EXCHANGE = "bt_market_bank_test_mrcc";
+
+}

+ 0 - 0
sp-service/payment-server/src/main/java/com/pj/rabbitmq/RabbitmqConfig.java → sp-service/payment-server/src/main/java/com/pj/rabbitmqtwo/RabbitmqConfigTwo.java


+ 3 - 1
sp-service/payment-server/src/main/java/com/pj/task/BankByteTask.java

@@ -11,6 +11,8 @@ import com.pj.bank_info_charges.BankInfoCharges;
 import com.pj.bank_info_charges.BankInfoChargesService;
 import com.pj.common.core.utils.StringUtils;
 import com.pj.enummj.FinishStatus;
+import com.pj.rabbitmqone.RabbitMQOne;
+import com.pj.utils.ht.AESUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
@@ -76,7 +78,7 @@ public class BankByteTask {
         byteList.forEach(item -> {
             String body = item.getBody();
             //数据解析
-            String xmlStr = "";
+            String xmlStr = body;//AESUtil.decryptCBC(body, RabbitMQOne.ACC_KEY);
 
             BankInfo bankInfo = new BankInfo();
             List<BankInfoCharges> chargesList = new ArrayList<>();

+ 11 - 10
sp-service/payment-server/src/main/java/com/pj/task/PaymentController.java

@@ -4,6 +4,7 @@ import com.pj.api.dto.PaymentDto;
 import com.pj.api.dto.PaymentTwoDto;
 import com.pj.dto.DataDto;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -20,28 +21,28 @@ public class PaymentController {
         paymentService.testSend(dataDto);
     }
 
-    @RequestMapping("rpc/sendSXB010")
-    public void sendSXB010(@RequestBody PaymentDto paymentDto) {
+    @GetMapping("rpc/sendSXB010")
+    public void sendSXB010(PaymentDto paymentDto) {
         paymentService.sendSXB010(paymentDto);
     }
 
-    @RequestMapping("rpc/sendSXB013")
-    public void sendSXB013(@RequestBody PaymentDto paymentDto) {
+    @GetMapping("rpc/sendSXB013")
+    public void sendSXB013(PaymentDto paymentDto) {
         paymentService.sendSXB013(paymentDto);
     }
 
-    @RequestMapping("rpc/sendSXB023")
-    public void sendSXB023(@RequestBody PaymentDto paymentDto) {
+    @GetMapping("rpc/sendSXB023")
+    public void sendSXB023(PaymentDto paymentDto) {
         paymentService.sendSXB023(paymentDto);
     }
 
-    @RequestMapping("rpc/sendMKT006_NoCommission")
-    public void sendMKT006_NoCommission(@RequestBody PaymentTwoDto paymentTwoDto) {
+    @GetMapping("rpc/sendMKT006_NoCommission")
+    public void sendMKT006_NoCommission(PaymentTwoDto paymentTwoDto) {
         paymentService.sendMKT006_NoCommission(paymentTwoDto);
     }
 
-    @RequestMapping("rpc/sendMKT006")
-    public void sendMKT006(@RequestBody PaymentTwoDto paymentTwoDto) {
+    @GetMapping("rpc/sendMKT006")
+    public void sendMKT006(PaymentTwoDto paymentTwoDto) {
         paymentService.sendMKT006(paymentTwoDto);
     }
 }

+ 21 - 16
sp-service/payment-server/src/main/java/com/pj/task/PaymentService.java

@@ -4,8 +4,13 @@ import com.alibaba.fastjson.JSON;
 import com.pj.api.dto.PaymentDto;
 import com.pj.api.dto.PaymentTwoDto;
 import com.pj.dto.DataDto;
+import com.pj.rabbitmqone.RabbitMQOne;
+import com.pj.rabbitmqtwo.RabbitMQTwo;
+import com.pj.utils.ht.AESUtil;
 import com.pj.xml.MessageXML;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.AmqpTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
@@ -17,7 +22,7 @@ public class PaymentService {
 
     public void testSend(DataDto dataDto) {
         System.out.println("开始发送----------\n"+dataDto.toString());
-      //  amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
+        amqpTemplate.convertAndSend(RabbitMQOne.TEST_SEND_QUEUE, dataDto);
         System.out.println("结束发送----------");
     }
 
@@ -33,11 +38,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC = "";
-        dataDto.setData(encryptCBC);
+        //String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQOne.ACC_KEY);
+        dataDto.setData(jsonString);
 
         //mq发送信息
-//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
+        amqpTemplate.convertAndSend(RabbitMQOne.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 
@@ -53,11 +58,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC = "";
-        dataDto.setData(encryptCBC);
+        //String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQOne.ACC_KEY);
+        dataDto.setData(jsonString);
 
         //mq发送信息
-//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
+        amqpTemplate.convertAndSend(RabbitMQOne.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 
@@ -73,11 +78,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC = "";
-        dataDto.setData(encryptCBC);
+        //String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQOne.ACC_KEY);
+        dataDto.setData(jsonString);
 
         //mq发送信息
-//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
+        amqpTemplate.convertAndSend(RabbitMQOne.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 
@@ -93,11 +98,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC ="";
-        dataDto.setData(encryptCBC);
+        //String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQTwo.ACC_KEY);
+        dataDto.setData(jsonString);
 
         //mq发送信息
-//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
+        amqpTemplate.convertAndSend(RabbitMQTwo.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 
@@ -113,11 +118,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC = "AESUtil.encryptCBC(jsonString, RabbitMQFactory.ACC_KEY)";
-        dataDto.setData(encryptCBC);
+        //String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQTwo.ACC_KEY);
+        dataDto.setData(jsonString);
 
         //mq发送信息
-//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
+        amqpTemplate.convertAndSend(RabbitMQTwo.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 

+ 1 - 1
sp-service/pom.xml

@@ -66,4 +66,4 @@
     </build>
 
 
-</project>
+</project>