فهرست منبع

支付服务MQ配置,订单同步优化

qzyReal 1 سال پیش
والد
کامیت
b935e16ca7
21فایلهای تغییر یافته به همراه259 افزوده شده و 214 حذف شده
  1. 5 0
      sp-core/sp-base/src/main/java/com/pj/project4sp/spcfg/SpCfgUtil.java
  2. 16 16
      sp-service/async-server/src/main/java/com/pj/task/HtByteTask.java
  3. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java
  4. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java
  5. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java
  6. 4 0
      sp-service/level-one-server/src/main/java/com/pj/tb_order/vo/OrderVo.java
  7. 4 2
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleController.java
  8. 7 2
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java
  9. 1 1
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShop.java
  10. 14 6
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopService.java
  11. 1 1
      sp-service/payment-server/pom.xml
  12. 11 3
      sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfoController.java
  13. 0 61
      sp-service/payment-server/src/main/java/com/pj/listen/BaseInfoListen.java
  14. 54 0
      sp-service/payment-server/src/main/java/com/pj/rabbitmq/MessageReceiver.java
  15. 53 0
      sp-service/payment-server/src/main/java/com/pj/rabbitmq/MessageSender.java
  16. 0 40
      sp-service/payment-server/src/main/java/com/pj/rabbitmq/RabbitMQ.java
  17. 27 0
      sp-service/payment-server/src/main/java/com/pj/rabbitmq/RabbitMQProperties.java
  18. 44 57
      sp-service/payment-server/src/main/java/com/pj/rabbitmq/RabbitmqConfig.java
  19. 1 4
      sp-service/payment-server/src/main/java/com/pj/task/BankByteTask.java
  20. 13 18
      sp-service/payment-server/src/main/java/com/pj/task/PaymentService.java
  21. 1 0
      sp-service/pom.xml

+ 5 - 0
sp-core/sp-base/src/main/java/com/pj/project4sp/spcfg/SpCfgUtil.java

@@ -94,6 +94,11 @@ public class SpCfgUtil {
 		return SpCfgUtil.getServerCfg("throwOutSql", "2").equals("1");
 	}
 
+	// --- server
+	/** 获取默认的收益  */
+	public static String getDefaultProfit() {
+		return SpCfgUtil.getServerCfg("defaultProfit", "50");
+	}
 	
 	
 	

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

@@ -130,9 +130,9 @@ public class HtByteTask {
                     flag = FeignFactory.levelOneServerInterface.peopleDto(peopleDto);
                     methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
                     if (!flag) {
-                        System.err.println("\n边民信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                      StaticLog.error("\n边民信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     } else {
-                        System.err.println("\n边民信息处理成功。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.info("\n边民信息处理成功。 messageId = " + item.getMessageId() + "\n");
                     }
                     break;
                 case "002":
@@ -142,9 +142,9 @@ public class HtByteTask {
                     flag = FeignFactory.levelOneServerInterface.shopDto(shopDto);
                     methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
                     if (!flag) {
-                        System.err.println("\n店铺信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.error("\n店铺信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     } else {
-                        System.err.println("\n店铺信息处理完成。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.info("\n店铺信息处理完成。 messageId = " + item.getMessageId() + "\n");
                     }
                     break;
                 case "003":
@@ -154,9 +154,9 @@ public class HtByteTask {
                     flag = FeignFactory.levelOneServerInterface.groupDto(groupDto);
                     methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
                     if (!flag) {
-                        System.err.println("\n互助组信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.error("\n互助组信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     } else {
-                        System.err.println("\n互助组信息处理完成。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.info("\n互助组信息处理完成。 messageId = " + item.getMessageId() + "\n");
                     }
                     break;
                 case "004":
@@ -166,9 +166,9 @@ public class HtByteTask {
                     flag = FeignFactory.levelOneServerInterface.cooperativeDto(cooperativeDto);
                     methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
                     if (!flag) {
-                        System.err.println("\n边民合作社信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.error("\n边民合作社信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     } else {
-                        System.err.println("\n边民合作社信息处理完成。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.info("\n边民合作社信息处理完成。 messageId = " + item.getMessageId() + "\n");
                     }
                     break;
                 case "005":
@@ -178,9 +178,9 @@ public class HtByteTask {
                     flag = FeignFactory.levelOneServerInterface.goodsDto(goodsDto);
                     methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
                     if (!flag) {
-                        System.err.println("\n海关监管商品信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.error("\n海关监管商品信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     } else {
-                        System.err.println("\n海关监管商品信息处理完成。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.info("\n海关监管商品信息处理完成。 messageId = " + item.getMessageId() + "\n");
                     }
                     break;
                 case "006":
@@ -222,9 +222,9 @@ public class HtByteTask {
                     boolean result = FeignFactory.levelOneServerInterface.importOrderDto(importOrderDto);
                     methodHtByteTask.updateHtByteInfo(result, item, dataDto);
                     if (result) {
-                        System.err.println("\n进口申报单同步处理成功。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.error("\n进口申报单同步处理成功。 messageId = " + item.getMessageId() + "\n");
                     } else {
-                        System.err.println("\n进口申报单同步处理失败。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.info("\n进口申报单同步处理失败。 messageId = " + item.getMessageId() + "\n");
                     }
                     break;
                 case "009":
@@ -235,9 +235,9 @@ public class HtByteTask {
                     int insert2 = htImportDeclarePeopleMapper.insert(htImportDeclarePeople);
                     methodHtByteTask.updateHtByteInfo(insert2 == 1, item, dataDto);
                     if (insert2 == 1) {
-                        System.err.println("\n进口申报单边民确认信息处理成功。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.error("\n进口申报单边民确认信息处理成功。 messageId = " + item.getMessageId() + "\n");
                     } else {
-                        System.err.println("\n进口申报单边民确认信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.info("\n进口申报单边民确认信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     }
                     break;
                 case "010":
@@ -251,9 +251,9 @@ public class HtByteTask {
                     boolean chargeback = FeignFactory.levelOneServerInterface.chargeback(htDeclareChargebackDto);
                     methodHtByteTask.updateHtByteInfo(chargeback, item, dataDto);
                     if (insert3 == 1) {
-                        System.err.println("\n进出口申报单退单信息处理成功。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.error("\n进出口申报单退单信息处理成功。 messageId = " + item.getMessageId() + "\n");
                     } else {
-                        System.err.println("\n进出口申报单退单信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                        StaticLog.info("\n进出口申报单退单信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     }
                 default:
                     throw new ServiceException("类型错误。");

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java

@@ -158,7 +158,7 @@ public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implemen
         if (tbGoodsUnits != null) {
             tbGoods.setUnit(tbGoodsUnits.getUnits());
         }
-        this.saveOrUpdate(tbGoods);
+        super.saveOrUpdate(tbGoods);
         return true;
     }
 

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java

@@ -411,7 +411,7 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
         //修改
         BeanUtils.copyProperties(groupDto, tbGroup);
         tbGroup.setUpdateTime(new Date());
-        this.saveOrUpdate(tbGroup);
+        super.saveOrUpdate(tbGroup);
         return true;
     }
 

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java

@@ -541,7 +541,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
     /**
      * 发送009信息到航通
      */
-    private void sendConfirmMsgToHt(TbOrder tbOrder) {
+    private void sendConfirmMsgToHt(TbOrder tbOrder)  {
         TbPeople tbPeople = tbPeopleService.getById(tbOrder.getBuyUserId());
         PeopleConfirmDTO peopleConfirmDTO = new PeopleConfirmDTO();
         peopleConfirmDTO.setBorderName(tbOrder.getBuyUserName());

+ 4 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_order/vo/OrderVo.java

@@ -233,4 +233,8 @@ public class OrderVo {
      * 毛重
      */
     private Double grossWt;
+    /**
+     * 申报时间
+     */
+    private Date applyTime;
 }

+ 4 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleController.java

@@ -3,6 +3,8 @@ package com.pj.tb_people;
 import java.io.IOException;
 import java.util.List;
 
+import cn.hutool.json.JSONUtil;
+import cn.hutool.log.StaticLog;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.pj.api.dto.AppUserDto;
 import com.pj.api.dto.HtPeopleDto;
@@ -264,8 +266,8 @@ public class TbPeopleController {
      */
     @PostMapping("rpc/peopleDto")
     public boolean peopleDto(@RequestBody HtPeopleDto peopleDto) throws Exception {
-        boolean dto = tbPeopleService.peopleDto(peopleDto);
-        return dto;
+        StaticLog.info("async people:{}", JSONUtil.toJsonStr(peopleDto));
+        return tbPeopleService.peopleDto(peopleDto);
     }
 
     /**

+ 7 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java

@@ -369,7 +369,7 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
         if (tbOrder == null)
             throw new ServiceException("订单信息异常!");
         //修改订单状态
-        tbOrder.setApplyTime(new Date()); // 申报时间
+//        tbOrder.setApplyTime(new Date()); // 申报时间
         tbOrder.setPeopleConfirmStatus(ConfirmStatus.CONFIRM_STATUS_ONE.getCode()); // 默认边民确认
         tbOrder.setFinishStatus(OrderStatus.ORDER_STATUS_ONE.getCode()); // 订单状态已完成
         int update = tbOrderMapper.updateById(tbOrder);
@@ -571,7 +571,12 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
          新增备案,传空值;
          如果为变更备案,
          必须传值;*/
-        this.saveOrUpdate(tbPeople);
+      //  this.saveOrUpdate(tbPeople);
+        if (isNew){
+            this.save(tbPeople);
+        }else {
+            this.updateById(tbPeople);
+        }
         //新增
 
         if (isNew) {

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShop.java

@@ -46,7 +46,7 @@ public class TbShop extends Model<TbShop> implements Serializable {
 	 * 主键 
 	 */
 	@TableId(type = IdType.AUTO)
-	private String id;	
+	private Long id;
 
 	/**
 	 *  

+ 14 - 6
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopService.java

@@ -8,6 +8,8 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import cn.hutool.json.JSONUtil;
+import cn.hutool.log.StaticLog;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.pj.api.client.admin.AdminInterface;
@@ -117,7 +119,7 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
         List<ShopVo> shopVoList = new ArrayList<>();
         list.forEach(tbShop -> {
             ShopVo shopVo = new ShopVo();
-            BeanUtils.copyProperties(tbShop,shopVo);
+            BeanUtils.copyProperties(tbShop, shopVo);
             shopVoList.add(shopVo);
         });
         return shopVoList;
@@ -240,7 +242,9 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
     public boolean shopDto(HtShopDTO shopDto) throws Exception {
         TbTradeArea tbTradeArea = tbTradeAreaService.updateHandler(shopDto.getFieldCode(), shopDto.getFieldName());
         TbShop tbShop = this.findByCode(shopDto.getShopNo());
+        boolean newShop = false;
         if (tbShop == null) {
+            newShop = true;
             tbShop = new TbShop();
             tbShop.setCreateTime(new Date());
         }
@@ -250,7 +254,10 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
         tbShop.setTradeAreaId(tbTradeArea.getId()).setTradeAreaName(tbTradeArea.getName());
         tbShop.setCreateName("航通").setCreateTime(new Date()); // 创建人 // 创建时间
         tbShop.setStatus(Status.STATUS_ONE.getCode()); // 可用状态
-        this.saveOrUpdate(tbShop);
+        if (newShop) {
+        tbShop.insert();
+        }
+
 
         TbEnterprise enterprise = tbEnterpriseService.findBydutyParagraph(shopDto.getShopSccd());
         boolean isNew = false;
@@ -264,7 +271,7 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
         enterprise.setDeleteStatus(Long.valueOf(DeleteStatus.DELETE_STATUS_ON.getCode())); // 逻辑删除,默认未删除
         enterprise.setJudgeStatus(JudgeStatus.JUDGE_STATUS_ONE.getCode());  // 审核状态,默认审核通过
         enterprise.setJudgeTime(new Date()); // 审核时间
-        enterprise.setShopId(Long.valueOf(tbShop.getId())); // 关联自己旗下的店铺  店铺ID
+        enterprise.setShopId(tbShop.getId()); // 关联自己旗下的店铺  店铺ID
         enterprise.setShopName(shopDto.getShopName()); // 店铺ID
         enterprise.setBankAccount(shopDto.getBankAccount()); // 银行账户
         enterprise.setBank(shopDto.getBank()); // 银行名称
@@ -272,12 +279,13 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
         enterprise.setType(null);  //  商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺)
         enterprise.setIsLock(IsLock.IS_LOCK_ON.getCode()); // 默认未被锁定
         enterprise.setTradeAreaId(tbTradeArea.getId()).setBank(shopDto.getBank()).setBankAccount(shopDto.getBankAccount())
-                .setNationality(shopDto.getShopType().equals("1")?"中方商铺":"外国商铺")
+                .setNationality(shopDto.getShopType().equals("1") ? "中方商铺" : "外国商铺")
                 .setLegalPerson(shopDto.getAgentName()).setIdCard(shopDto.getAgentCiphertextIdno())
                 .setTradeAreaName(tbTradeArea.getName());
-        tbEnterpriseService.saveOrUpdate(enterprise);
+        boolean result=isNew?tbEnterpriseService.save(enterprise):tbEnterpriseService.updateById(enterprise);
         tbShop.setEnterpriseId(enterprise.getId()).setEnterpriseName(enterprise.getOwnerName());
-        this.updateById(tbShop);
+        StaticLog.info("shop:{}", JSONUtil.toJsonStr(tbShop));
+        tbShop.updateById();
         //新增外籍商户
         if (isNew) {
             //远程调用生成商家账户方法

+ 1 - 1
sp-service/payment-server/pom.xml

@@ -8,7 +8,7 @@
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <artifactId>async-server</artifactId>
+    <artifactId>payment-server</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <properties>
         <java.version>1.8</java.version>

+ 11 - 3
sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfoController.java

@@ -1,6 +1,8 @@
 package com.pj.bank_info;
 
 import java.util.List;
+
+import com.pj.rabbitmq.MessageSender;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -12,6 +14,8 @@ import com.pj.project4sp.SP;
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 
+import javax.annotation.Resource;
+
 
 /**
  * Controller: bank_info -- 银行回执信息表
@@ -77,9 +81,13 @@ public class BankInfoController {
 	}
 
 
-
-
-
+	@Resource
+	private MessageSender messageSender;
+	@RequestMapping("test")
+	public String test(){
+		messageSender.sendToLevelOneMQ("hello");
+		return "hello";
+	}
 
 
 

+ 0 - 61
sp-service/payment-server/src/main/java/com/pj/listen/BaseInfoListen.java

@@ -1,61 +0,0 @@
-package com.pj.listen;
-
-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.rabbitmq.RabbitMQ;
-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;
-
-/**
- * @Author Mechrevo
- * @Date 2023 08 25 12 30
- **/
-@Component
-public class BaseInfoListen {
-
-
-    @Autowired
-    private BankByteMapper bankByteMapper;
-
-    /**
-     * 监听: 接收并保存银行回执信息
-     * @param json
-     */
-    @RabbitListener(queuesToDeclare = @Queue(RabbitMQ.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,RabbitMQ.TEST_ACCEPT_QUEUE, FinishStatus.FINISH_STATUS_ZERO.getCode(),new Date()));
-        System.out.println("-----------------完成接收:银行回执信息------------------------");
-
-    }
-
-
-    /**
-     * 测试接收
-     * 测试已通过
-     */
-    @RabbitListener(queuesToDeclare = @Queue(RabbitMQ.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(), RabbitMQ.ACC_KEY);
-        //OrderDto orderDto = JSONObject.parseObject(cbc, OrderDto.class);
-        System.out.println(cbc + "\n---------结束发送:银行接口报文-----------------");
-    }
-
-}

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

@@ -0,0 +1,54 @@
+package com.pj.rabbitmq;
+
+import cn.hutool.core.util.RandomUtil;
+import com.pj.bank_byte.BankByte;
+import com.pj.bank_byte.BankByteMapper;
+import com.pj.enummj.FinishStatus;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Component
+public class MessageReceiver {
+
+    @Autowired
+    private BankByteMapper bankByteMapper;
+
+    private final RabbitTemplate levelOneConnectionFactory;
+    private final RabbitTemplate levelTwoConnectionFactory;
+    private final RabbitMQProperties rabbitMQProperties;
+
+    @Autowired
+    public MessageReceiver(@Qualifier("levelOneConnectionFactory") CachingConnectionFactory levelOneConnectionFactory,
+                         @Qualifier("levelTwoConnectionFactory") CachingConnectionFactory levelTwoConnectionFactory,RabbitMQProperties rabbitMQProperties) {
+        this.levelOneConnectionFactory = new RabbitTemplate(levelOneConnectionFactory);
+        this.levelTwoConnectionFactory = new RabbitTemplate(levelTwoConnectionFactory);
+        this.rabbitMQProperties=rabbitMQProperties;
+    }
+
+    /**
+     * 一级市场接收
+     * @param message
+     */
+    @RabbitListener(queues = "${mq.level-one-receive-queue}",containerFactory = "levelOneRabbitListenerContainer")
+    public void receiveLevelOneMessage(String message) {
+        System.out.println("Received levelone message: " + message);
+        bankByteMapper.insert(new BankByte(RandomUtil.randomString(64),message, rabbitMQProperties.getLevelOneReceiveQueue(), FinishStatus.FINISH_STATUS_ZERO.getCode(),new Date()));
+    }
+    /**
+     * 二级市场接收
+     * @param message
+     */
+    @RabbitListener(queues = "${mq.level-two-receive-queue}",containerFactory = "levelTwoRabbitListenerContainer")
+    public void receiveLevelTwoMessage(String message) {
+        System.out.println("Received leveltwo message: " + message);
+        bankByteMapper.insert(new BankByte(RandomUtil.randomString(64),message, rabbitMQProperties.getLevelTwoReceiveQueue(), FinishStatus.FINISH_STATUS_ZERO.getCode(),new Date()));
+
+    }
+}

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

@@ -0,0 +1,53 @@
+package com.pj.rabbitmq;
+
+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.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.amqp.rabbit.connection.CachingConnectionFactory;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 08 25 12 30
+ **/
+@Component
+public class MessageSender {
+
+
+
+
+
+
+    private final RabbitTemplate levelOneConnectionFactory;
+    private final RabbitTemplate levelTwoConnectionFactory;
+    private final RabbitMQProperties rabbitMQProperties;
+
+    @Autowired
+    public MessageSender(@Qualifier("levelOneConnectionFactory") CachingConnectionFactory levelOneConnectionFactory,
+                           @Qualifier("levelTwoConnectionFactory") CachingConnectionFactory levelTwoConnectionFactory,RabbitMQProperties rabbitMQProperties) {
+        this.levelOneConnectionFactory = new RabbitTemplate(levelOneConnectionFactory);
+        this.levelTwoConnectionFactory = new RabbitTemplate(levelTwoConnectionFactory);
+        this.rabbitMQProperties=rabbitMQProperties;
+    }
+
+    public void sendToLevelOneMQ(String message) {
+        levelOneConnectionFactory.convertAndSend(rabbitMQProperties.getLevelOneSendQueue(),message);
+    }
+    public void sendToLevelTwoMQ(String message) {
+        levelTwoConnectionFactory.convertAndSend(rabbitMQProperties.getLevelTwoSendQueue(),message);
+    }
+
+
+}

+ 0 - 40
sp-service/payment-server/src/main/java/com/pj/rabbitmq/RabbitMQ.java

@@ -1,40 +0,0 @@
-package com.pj.rabbitmq;
-
-/**
- * MQ的基本配置
- * @Author Mechrevo
- * @Date 2023 08 25 12 14
- **/
-public class RabbitMQ {
-
-
-    public static final String ACC_KEY = "klfksd78974s1d4f";
-
-
-    /**
-     *  发送方队列
-     */
-    public static final String TEST_SEND_QUEUE = "testAccept";
-
-    /**
-     *  发送方路由键
-     */
-    public static final String TEST_SEND_ROUTING_KEY = "testAcceptKey";
-
-    /**
-     *  接收方队列
-     */
-    public static final String TEST_ACCEPT_QUEUE = "testSend";
-
-    /**
-     *  接收方路由键
-     */
-    public static final String TEST_ACCEPT_ROUTING_KEY = "testSendKey";
-
-
-    /**
-     *  发送方MQ交换机名称
-     */
-    public static final String MQ_DIRECT_EXCHANGE = "test_exchange";
-
-}

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

@@ -0,0 +1,27 @@
+package com.pj.rabbitmq;
+
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Data
+@ConfigurationProperties(prefix = "mq")
+@Component
+public class RabbitMQProperties {
+
+    private String host;
+    private int port;
+
+    private String username;
+    private String password;
+    private String levelOneVirtualHost;
+    private String levelOneReceiveQueue;
+    private String levelOneSendQueue;
+
+    private String levelTwoUsername;
+    private String levelTwoPassword;
+    private String levelTwoReceiveQueue;
+    private String levelTwoSendQueue;
+    private String levelTwoVirtualHost;
+}

+ 44 - 57
sp-service/payment-server/src/main/java/com/pj/rabbitmq/RabbitmqConfig.java

@@ -1,14 +1,23 @@
 package com.pj.rabbitmq;
 
+import lombok.Data;
 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.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
+import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
+import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
 
-
+import javax.annotation.Resource;
 
 
 /**
@@ -16,69 +25,47 @@ import org.springframework.context.annotation.Configuration;
  * @Date 2023 08 25 12 21
  **/
 @Configuration
+@Data
 public class RabbitmqConfig {
-//
-//
-//    @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(RabbitMQ.TEST_SEND_QUEUE,true);
-    }
+ @Resource
+ private RabbitMQProperties rabbitMQProperties;
 
-    /**
-     * 接收时的mq队列
-     * @return
-     */
-    @Bean
-    public Queue testAccept(){
-        return new Queue(RabbitMQ.TEST_ACCEPT_QUEUE,true);
+    @Bean(name = "levelOneConnectionFactory")
+    @Primary
+    public CachingConnectionFactory levelOneConnectionFactory() {
+        CachingConnectionFactory factory = new CachingConnectionFactory();
+        factory.setHost(rabbitMQProperties.getHost());
+        factory.setPort(rabbitMQProperties.getPort());
+        factory.setUsername(rabbitMQProperties.getUsername());
+        factory.setPassword(rabbitMQProperties.getPassword());
+        factory.setVirtualHost(rabbitMQProperties.getLevelOneVirtualHost());
+        return factory;
     }
-
-    /**
-     * 交换机
-     * @return
-     */
-    @Bean
-    public DirectExchange directExchange(){
-        return new DirectExchange(RabbitMQ.MQ_DIRECT_EXCHANGE,true,false);
+    @Bean(name = "levelOneRabbitListenerContainer")
+    public SimpleRabbitListenerContainerFactory levelOneRabbitListenerContainer(SimpleRabbitListenerContainerFactoryConfigurer configurer,
+                                                                               @Qualifier("levelOneConnectionFactory") ConnectionFactory connectionFactory) {
+        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
+        configurer.configure(factory, connectionFactory);
+        return factory;
     }
 
-    /**
-     * 绑定
-     * 发送
-     */
-    @Bean
-    public Binding bindingSend(){
-        return BindingBuilder.bind(testSend()).to(directExchange()).with(RabbitMQ.TEST_SEND_ROUTING_KEY);
+    @Bean(name = "levelTwoConnectionFactory")
+    public CachingConnectionFactory levelTwoConnectionFactory() {
+        CachingConnectionFactory factory = new CachingConnectionFactory();
+        factory.setHost(rabbitMQProperties.getHost());
+        factory.setPort(rabbitMQProperties.getPort());
+        factory.setUsername(rabbitMQProperties.getLevelTwoUsername());
+        factory.setPassword(rabbitMQProperties.getLevelTwoPassword());
+        factory.setVirtualHost(rabbitMQProperties.getLevelTwoVirtualHost());
+        return factory;
     }
-
-    /**
-     * 绑定
-     * 接收
-     */
-    @Bean
-    public Binding bindingAccept(){
-        return BindingBuilder.bind(testAccept()).to(directExchange()).with(RabbitMQ.TEST_ACCEPT_ROUTING_KEY);
+    @Bean(name = "levelTwoRabbitListenerContainer")
+    public SimpleRabbitListenerContainerFactory levelTwoRabbitListenerContainer(SimpleRabbitListenerContainerFactoryConfigurer configurer,
+                                                                               @Qualifier("levelTwoConnectionFactory") ConnectionFactory connectionFactory) {
+        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
+        configurer.configure(factory, connectionFactory);
+        return factory;
     }
 
 }

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

@@ -11,12 +11,9 @@ 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.rabbitmq.RabbitMQ;
-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;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -79,7 +76,7 @@ public class BankByteTask {
         byteList.forEach(item -> {
             String body = item.getBody();
             //数据解析
-            String xmlStr = AESUtil.decryptCBC(body, RabbitMQ.ACC_KEY);
+            String xmlStr = "";
 
             BankInfo bankInfo = new BankInfo();
             List<BankInfoCharges> chargesList = new ArrayList<>();

+ 13 - 18
sp-service/payment-server/src/main/java/com/pj/task/PaymentService.java

@@ -1,28 +1,23 @@
 package com.pj.task;
 
 import com.alibaba.fastjson.JSON;
-import com.pj.api.dto.OrderDto;
 import com.pj.api.dto.PaymentDto;
 import com.pj.api.dto.PaymentTwoDto;
 import com.pj.dto.DataDto;
-import com.pj.rabbitmq.RabbitMQ;
-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
 @Slf4j
 public class PaymentService {
 
-    @Autowired
-    private AmqpTemplate amqpTemplate;
+//    @Autowired
+//    private AmqpTemplate amqpTemplate;
 
     public void testSend(DataDto dataDto) {
         System.out.println("开始发送----------\n"+dataDto.toString());
-        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE, dataDto);
+      //  amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
         System.out.println("结束发送----------");
     }
 
@@ -38,11 +33,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQ.ACC_KEY);
+        String encryptCBC = "";
         dataDto.setData(encryptCBC);
 
         //mq发送信息
-        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE, dataDto);
+//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 
@@ -58,11 +53,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQ.ACC_KEY);
+        String encryptCBC = "";
         dataDto.setData(encryptCBC);
 
         //mq发送信息
-        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE, dataDto);
+//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 
@@ -78,11 +73,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQ.ACC_KEY);
+        String encryptCBC = "";
         dataDto.setData(encryptCBC);
 
         //mq发送信息
-        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE, dataDto);
+//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 
@@ -98,11 +93,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQ.ACC_KEY);
+        String encryptCBC ="";
         dataDto.setData(encryptCBC);
 
         //mq发送信息
-        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE, dataDto);
+//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 
@@ -118,11 +113,11 @@ public class PaymentService {
         DataDto dataDto = new DataDto();
         //报文加密
         String jsonString = JSON.toJSONString(xml);
-        String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQ.ACC_KEY);
+        String encryptCBC = "AESUtil.encryptCBC(jsonString, RabbitMQFactory.ACC_KEY)";
         dataDto.setData(encryptCBC);
 
         //mq发送信息
-        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE, dataDto);
+//        amqpTemplate.convertAndSend(RabbitMQFactory.TEST_SEND_QUEUE, dataDto);
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 

+ 1 - 0
sp-service/pom.xml

@@ -19,6 +19,7 @@
         <module>transport-server</module>
         <module>sp-task</module>
         <module>async-server</module>
+        <module>payment-server</module>
     </modules>
 
 	<!-- 构建配置 -->