Browse Source

银行扣款模块修改

linbl 1 year ago
parent
commit
2c1e7b26aa
19 changed files with 357 additions and 190 deletions
  1. 10 2
      sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterface.java
  2. 11 1
      sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterfaceFallback.java
  3. 6 2
      sp-core/sp-api/src/main/java/com/pj/api/client/level_two_server/LevelTwoServerInterface.java
  4. 6 1
      sp-core/sp-api/src/main/java/com/pj/api/client/level_two_server/LevelTwoServerInterfaceFallback.java
  5. 14 0
      sp-core/sp-api/src/main/java/com/pj/api/dto/AppUserCreateDTO.java
  6. 12 0
      sp-core/sp-api/src/main/java/com/pj/api/dto/OrderDto.java
  7. 2 1
      sp-core/sp-base/src/main/java/com/pj/enummj/TradeStatus.java
  8. 1 1
      sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlement.java
  9. 15 2
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrder.java
  10. 17 3
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderAppController.java
  11. 99 50
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java
  12. 1 0
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java
  13. 2 2
      sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrders.java
  14. 8 2
      sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersApiController.java
  15. 79 54
      sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java
  16. 32 26
      sp-service/payment-server/src/main/java/com/pj/task/BankByteTask.java
  17. 6 0
      sp-service/payment-server/src/main/java/com/pj/task/PaymentController.java
  18. 6 13
      sp-service/payment-server/src/main/java/com/pj/task/PaymentService.java
  19. 30 30
      sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUser.java

+ 10 - 2
sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterface.java

@@ -144,7 +144,15 @@ public interface LevelOneServerInterface {
     @PostMapping("/app/TbCooperative/rpc/saveBankInfo")
     public boolean saveBankByCooperative(@RequestParam("id")Long id, @RequestParam("bankName")String bankName, @RequestParam("bankAccount")String bankAccount);
 
-    /** 远程调用  修改订单的叫车状态 */
+    /** (一级市场)订单扣款回执 */
     @PostMapping("/app/TbOrder/rpc/confirmOrderFromBank")
-    public boolean confirmOrderFromBank(@RequestParam("tradeNo")String tradeNo);
+    public boolean confirmOrderFromBank(@RequestParam("tradeNo")String tradeNo,@RequestParam("SXB010Status")Integer SXB010Status);
+
+    /** 收到(一级市场-通车批信息)订单打款回执 */
+    @PostMapping("/app/TbOrder/rpc/orderFinishFromBank")
+    public boolean orderFinishFromBank(@RequestParam("tradeNo")String tradeNo,@RequestParam("SXB023Status")Integer SXB023Status);
+
+    /** 收到银行退款回执 */
+    @PostMapping("/app/TbOrder/rpc/chargebackFromBank")
+    public boolean chargebackFromBank(@RequestParam("tradeNo")String tradeNo,@RequestParam("SXB023Status")Integer SXB023Status, @RequestParam("note")String note);
 }

+ 11 - 1
sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterfaceFallback.java

@@ -217,7 +217,17 @@ public class LevelOneServerInterfaceFallback implements FallbackFactory<LevelOne
             }
 
             @Override
-            public boolean confirmOrderFromBank(String tradeNo) {
+            public boolean confirmOrderFromBank(String tradeNo, Integer SXB010Status) {
+                return false;
+            }
+
+            @Override
+            public boolean orderFinishFromBank(String tradeNo, Integer SXB023Status) {
+                return false;
+            }
+
+            @Override
+            public boolean chargebackFromBank(String tradeNo, Integer SXB023Status, String note) {
                 return false;
             }
         };

+ 6 - 2
sp-core/sp-api/src/main/java/com/pj/api/client/level_two_server/LevelTwoServerInterface.java

@@ -35,7 +35,11 @@ public interface LevelTwoServerInterface {
     @RequestMapping("/app/TbOrders/rpc/getResalePriceByLevelOneOrderId")
     public Double getResalePriceByLevelOneOrderId(@RequestParam("orderId") Long orderId);
 
-    /** 查 - 根据一级市场订单id查二级市场的转售金额 */
+    /** 采购商支付成功 ——> 边民缴税以及各服务费 */
     @PostMapping("/app/TbOrders/rpc/payTax")
-    public boolean payTax(@RequestParam("orderNo") String orderNo);
+    public boolean payTax(@RequestParam("orderNo") String orderNo, @RequestParam("MKT008Status")Integer MKT008Status);
+
+    /** 收到边民缴税以及各服务费回执 */
+    @PostMapping("/app/TbOrders/rpc/payTaxFromBank")
+    public boolean payTaxFromBank(@RequestParam("orderNo") String orderNo, @RequestParam("MKT008Status")Integer MKT008Status);
 }

+ 6 - 1
sp-core/sp-api/src/main/java/com/pj/api/client/level_two_server/LevelTwoServerInterfaceFallback.java

@@ -45,7 +45,12 @@ public class LevelTwoServerInterfaceFallback implements FallbackFactory<LevelTwo
             }
 
             @Override
-            public boolean payTax(String orderNo) {
+            public boolean payTax(String orderNo, Integer MKT008Status) {
+                return false;
+            }
+
+            @Override
+            public boolean payTaxFromBank(String orderNo, Integer MKT008Status) {
                 return false;
             }
         };

+ 14 - 0
sp-core/sp-api/src/main/java/com/pj/api/dto/AppUserCreateDTO.java

@@ -1,6 +1,7 @@
 package com.pj.api.dto;
 
 import java.io.Serializable;
+import java.util.Date;
 
 public class AppUserCreateDTO implements Serializable {
 
@@ -26,6 +27,11 @@ public class AppUserCreateDTO implements Serializable {
      */
     private String auth="0";
 
+    /**
+     * 认证时间
+     */
+    private Date authTime;
+
 
     public String getPhone() {
         return phone;
@@ -66,4 +72,12 @@ public class AppUserCreateDTO implements Serializable {
     public void setAuth(String auth) {
         this.auth = auth;
     }
+
+    public Date getAuthTime() {
+        return authTime;
+    }
+
+    public void setAuthTime(Date authTime) {
+        this.authTime = authTime;
+    }
 }

+ 12 - 0
sp-core/sp-api/src/main/java/com/pj/api/dto/OrderDto.java

@@ -132,6 +132,10 @@ public class OrderDto implements Serializable {
     private String record;
 
     /**
+     * 退款状态[1=退款成功 2=退款失败]
+     */
+    private Integer refundStatus;
+    /**
      * 退款原因
      */
     private String refundReason;
@@ -636,6 +640,14 @@ public class OrderDto implements Serializable {
         this.record = record;
     }
 
+    public Integer getRefundStatus() {
+        return refundStatus;
+    }
+
+    public void setRefundStatus(Integer refundStatus) {
+        this.refundStatus = refundStatus;
+    }
+
     public String getRefundReason() {
         return refundReason;
     }

+ 2 - 1
sp-core/sp-base/src/main/java/com/pj/enummj/TradeStatus.java

@@ -12,7 +12,8 @@ import lombok.Getter;
 public enum TradeStatus {
 
     TRADE_STATUS_ZERO(0,"未支付"),
-    TRADE_STATUS_ONE(1,"已支付");
+    TRADE_STATUS_ONE(1,"已支付"),
+    TRADE_STATUS_Two(2,"支付失败");
 
     private Integer code;
 

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlement.java

@@ -218,7 +218,7 @@ public class HtTradeSettlement extends Model<HtTradeSettlement> implements Seria
 	 * 完成情况
 	 */
 	private Integer finishStatus=0;
-	private String finishTime;
+	private Date finishTime;
 
 	/**
 	 * 创建时间

+ 15 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrder.java

@@ -197,6 +197,11 @@ public class TbOrder extends Model<TbOrder> implements Serializable {
 	private Date recordTime;
 
 	/**
+	 * 退款状态[1=退款成功 2=退款失败]
+	 */
+	private Integer refundStatus;
+
+	/**
 	 * 退款原因
 	 */
 	private String refundReason;
@@ -367,13 +372,13 @@ public class TbOrder extends Model<TbOrder> implements Serializable {
 	private Date applyConfirmTime;
 
 	/**
-	 * 订单完成状态(0=未完成,1=已完成)
+	 * 订单完成状态(0=未完成,1=已完成)->车出一级市场才完成,完成后可以进行转售
 	 */
 	private Integer finishStatus;
 	/**
 	 * 完成时间
 	 */
-	private String finishTime;
+	private Date finishTime;
 
 	/**
 	 * 是否转售(0=未转售,1=已转售,2=转售中)
@@ -506,6 +511,14 @@ public class TbOrder extends Model<TbOrder> implements Serializable {
 	private String codeTs;
 
 
+	/**
+	 * (一级市场)订单扣款回执状态[0=初始值 1=扣款成功 2=扣款失败]
+	 */
+	private Integer Sxb010Status=0;
+	/**
+	 * (一级市场)订单扣款回执时间
+	 */
+	private Date Sxb010StatusTime;
 
 
 }

+ 17 - 3
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderAppController.java

@@ -134,10 +134,24 @@ public class TbOrderAppController {
 
 	/*-----           正常业务逻辑👆👆    rpc远程调用👇👇 -----*/
 
-	/** 查询当天的下单记录 */
+	/** 边民订单确认-收到银行扣款回执 */
 	@PostMapping("rpc/confirmOrderFromBank")
-	public boolean confirmOrderFromBank(@RequestParam("tradeNo")String tradeNo) {
-		boolean result = tbOrderService.confirmOrderFromBank(tradeNo);
+	public boolean confirmOrderFromBank(@RequestParam("tradeNo")String tradeNo, @RequestParam("SXB010Status")Integer SXB010Status) {
+		boolean result = tbOrderService.confirmOrderFromBank(tradeNo, SXB010Status);
+		return result;
+	}
+
+	/** 收到(一级市场-通车批信息)订单打款回执 */
+	@PostMapping("rpc/orderFinishFromBank")
+	public boolean orderFinishFromBank(@RequestParam("tradeNo")String tradeNo, @RequestParam("SXB023Status")Integer SXB023Status) {
+		boolean result = tbOrderService.orderFinishFromBank(tradeNo, SXB023Status);
+		return result;
+	}
+
+	/** 收到银行退款回执 */
+	@PostMapping("rpc/chargebackFromBank")
+	public boolean chargebackFromBank(@RequestParam("tradeNo")String tradeNo, @RequestParam("SXB010Status")Integer SXB010Status, @RequestParam("note")String note) {
+		boolean result = tbOrderService.chargebackFromBank(tradeNo, SXB010Status, note);
 		return result;
 	}
 

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

@@ -433,6 +433,8 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         TbOrder tbOrder = this.getById(orderId);
         if (tbOrder == null) {
             throw new AjaxError("订单不存在");
+        } else if(2 == tbOrder.getCheckPassStatus()) {
+            throw new AjaxError("当前订单查验不通过!边民不能进行交易确认。");
         }
         tbOrder.setPeopleConfirmTime(new Date())
                 .setPeopleConfirmStatus(ConfirmStatus.CONFIRM_STATUS_ONE.getCode())
@@ -444,29 +446,40 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 
        return update;
     }
-
     /**
-     * 边民订单确认-收到银行扣款成功回执
+     * 边民订单确认-收到银行扣款回执
      * @param tradeNo 一级市场边民订单-订单编号
+     * @param SXB010Status 回执状态-1=扣款成功 2=扣款失败
      */
-    public boolean confirmOrderFromBank(String tradeNo) {
+    public boolean confirmOrderFromBank(String tradeNo, Integer SXB010Status) {
         LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(TbOrder::getTradeNo, tradeNo);
         List<TbOrder> tbOrderList = this.list(wrapper);
         if (tbOrderList.size() <= 0) {
-            throw new AjaxError("订单不存在");
+            throw new RuntimeException("边民订单确认-收到银行扣款回执:订单不存在");
         }
         TbOrder tbOrder = tbOrderList.get(0);
+
         // TODO: 2023/8/29 更新状态保存交易记录
-        tbOrder.setPeopleConfirmTime(new Date())
-                .setPeopleConfirmStatus(ConfirmStatus.CONFIRM_STATUS_ONE.getCode())
-                .setUpdateTime(new Date());
-        if ("1".equals(tbOrder.getDeclareType())) {
-            // TODO: 2023/8/29 调用航通009接口,发送信息
-            sendConfirmMsgToHt(tbOrder);
-            //当declareType为边民时,不需要走后续两个确认,订单状态改为已完成
-            tbOrder.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
+        if(2==SXB010Status) {//扣款失败
+            tbOrder.setSxb010Status(2)
+                    .setSxb010StatusTime(new Date());
         }
+        else if(1==SXB010Status) {//扣款成功
+            tbOrder.setSxb010Status(1)
+                    .setSxb010StatusTime(new Date());
+
+            tbOrder.setPeopleConfirmTime(new Date())
+                    .setPeopleConfirmStatus(ConfirmStatus.CONFIRM_STATUS_ONE.getCode())
+                    .setUpdateTime(new Date());
+            if ("1".equals(tbOrder.getDeclareType())) {
+                // TODO: 2023/8/29 调用航通009接口,发送信息
+                sendConfirmMsgToHt(tbOrder);
+                //当declareType为边民时,不需要走后续两个确认,订单状态改为已完成
+                //tbOrder.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
+            }
+        }
+
         return super.updateById(tbOrder);
     }
 
@@ -616,10 +629,26 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 
         return update && update1;
     }
+    //收到银行退款回执
+    public boolean chargebackFromBank(String tradeNo, Integer SXB013Status, String note) {
+        LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(TbOrder::getTradeNo, tradeNo);
+        List<TbOrder> tbOrderList = this.list(wrapper);
+        if (tbOrderList.size() <= 0) {
+            throw new RuntimeException("收到银行退款回执:订单不存在");
+        }
+        TbOrder tbOrder = tbOrderList.get(0);
 
+        if(2==SXB013Status) {//退款失败
+            tbOrder.setRefundStatus(2).setRefundReason(note).setRefundTime(new Date());
+        }
+        else if(1==SXB013Status) {//退款成功
+            tbOrder.setRefundStatus(1).setRefundReason(note).setRefundTime(new Date());
+        }
+        return updateById(tbOrder);
+    }
 
-    /** TODO: 2023/8/28 系统接收到航通接口信息:车辆已出一级市场
-       (系统接收到这个信息时,证明已经查验通过,不会有进出口申报单退单)*/
+    // TODO: 2023/8/28 系统接收到航通接口信息:车辆已出一级市场(系统接收到这个信息时,证明已经查验通过,不会有进出口申报单退单)
     public boolean orderFinish(HtPassCardDTO htPassCardDTO) {
         String billCode = htPassCardDTO.getBillCode();
         //获取出了一级市场的所有边民订单
@@ -633,48 +662,68 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         for (TbOrder tbOrder : tbOrders) {
             tradeNos += tbOrder.getTradeNo() + ",";
         }
-        //1、todo: 调用银行接口发起划扣:将边民划扣至银行第三方账户的货款,支付至外籍商户的账户
+        //todo: 调用银行接口发起划扣:将边民划扣至银行第三方账户的货款,支付至外籍商户的账户
         PaymentDto paymentDto = this.getPaymentData(tbOrders.get(0));
         paymentDto.setTradeNos(tradeNos);
         paymentServerInterface.sendSXB023(paymentDto);
-        //todo: 收到划扣成功回执后,方法往下制行?目前没有这个回执接口
-
-        //2、修改一级市场订单支付状态为已支付,修改一级市场订单完成状态为已完成
-        //更新结算单状态
-        Long settleId = tbOrders.get(0).getSaleMainId();
-        HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(settleId);
-        htTradeSettlement.setFinishStatus(1).setFinishTime(htPassCardDTO.getCheckTime());
-        htTradeSettlementService.updateById(htTradeSettlement);
-        tbOrders.forEach(order -> {
-            order.setTradeStatus(TradeStatus.TRADE_STATUS_ONE.getCode()); //已支付
-            order.setTradeTime(new Date()); //支付时间
-            order.setPayType(0); //支付类型
-            order.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode()); //已完成
-            order.setFinishTime(htPassCardDTO.getCheckTime());
-            order.setUpdateTime(new Date());
-
-            boolean result = updateById(order);
-            //修改失败记录是否应该存表??
-            //if(!result) throw new RuntimeException("当前订单状态修改失败,请联系管理员!");
-
-            if (result) {
-                //todo:通知边民转售已经采购的商品;边民上架商品,初步定价
-
-                //发送短信
-                TbPeople tbPeople = tbPeopleService.getById(order.getBuyUserId());
-                String content = "您好,您的边民互市订单商品[车辆已出一级市场],订单商品是[" + order.getGoodsNames() + "]。请前往app进行商品转售";
-                SystemObject.smsFactory.handler().sendSMS(tbPeople.getPhone(), content);
-
-                MessageDto dto = new MessageDto();
-                dto.setUrl("/pages/market/one/leader/order");
-                dto.setUserId(order.getBuyUserId());
-                dto.setContents("你采购的《" + order.getGoodsNames() + "》订单已完成。请及时上架商品到二级市场。");
-                adminInterface.messageSave(dto);
-            }
-        });
+
         return true;
     }
+    // TODO: 收到(一级市场-通车批信息)订单打款回执, tradeNos:订单号 n个
+    public boolean orderFinishFromBank(String tradeNos, Integer SXB023Status) {
+        String[] tradeNoArr = tradeNos.split(",");
+        LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
+        for (String tradeNo : tradeNoArr) {
+            wrapper.or().eq(TbOrder::getTradeNo, tradeNo);
+        }
+        List<TbOrder> tbOrderList = this.list(wrapper);
+        if (tbOrderList.size() <= 0) {
+            throw new RuntimeException("收到(一级市场-通车批信息)订单打款回执:订单不存在");
+        }
 
+        // 更新状态保存交易记录
+        if(2==SXB023Status) {
+            tbOrderList.forEach(order -> {
+                order.setTradeStatus(TradeStatus.TRADE_STATUS_Two.getCode()); //支付失败
+                order.setTradeTime(new Date()); //支付回执时间
+                order.setUpdateTime(new Date());
+
+                boolean result = updateById(order);
+            });
+        } else if(1==SXB023Status) {
+            //更新结算单状态
+            Long settleId = tbOrderList.get(0).getSaleMainId();
+            HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(settleId);
+            htTradeSettlement.setFinishStatus(1).setFinishTime(new Date());
+            htTradeSettlementService.updateById(htTradeSettlement);
+            tbOrderList.forEach(order -> {
+                order.setTradeStatus(TradeStatus.TRADE_STATUS_ONE.getCode()); //已支付
+                order.setTradeTime(new Date()); //支付回执时间
+                order.setPayType(0); //支付类型
+                order.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode()); //已完成->完成后可以进行转售
+                order.setFinishTime(new Date());
+                order.setUpdateTime(new Date());
+
+                boolean result = updateById(order);
+
+                if (result) {
+                    //todo:通知边民转售已经采购的商品;边民上架商品,初步定价
+
+                    //发送短信
+                    TbPeople tbPeople = tbPeopleService.getById(order.getBuyUserId());
+                    String content = "您好,您的边民互市订单商品[车辆已出一级市场],订单商品是[" + order.getGoodsNames() + "]。请前往app进行商品转售";
+                    SystemObject.smsFactory.handler().sendSMS(tbPeople.getPhone(), content);
+
+                    MessageDto dto = new MessageDto();
+                    dto.setUrl("/pages/market/one/leader/order");
+                    dto.setUserId(order.getBuyUserId());
+                    dto.setContents("你采购的《" + order.getGoodsNames() + "》订单已完成。请及时上架商品到二级市场。");
+                    adminInterface.messageSave(dto);
+                }
+            });
+        }
+        return true;
+    }
 
     /**
      * 远程调用:根据时间和登陆人查询订单

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

@@ -578,6 +578,7 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
             //给边民生成账号
             AppUserCreateDTO createDTO = new AppUserCreateDTO();
             createDTO.setAuth("1");
+            createDTO.setAuthTime(new Date());
             createDTO.setUserType(UserType.USER_TYPE_PEOPLE.getCode() + "");
             createDTO.setPhone(peopleDto.getBorderTel());
             createDTO.setName(peopleDto.getBorderName());

+ 2 - 2
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrders.java

@@ -226,7 +226,7 @@ public class TbOrders extends Model<TbOrders> implements Serializable {
 	private Double resalePrice;
 
 	/**
-	 * 是否支付(0=未支付,1=已支付)
+	 * 是否支付(0=未支付,1=已支付,2=支付失败)
 	 */
 	private Integer isPay;
 
@@ -236,7 +236,7 @@ public class TbOrders extends Model<TbOrders> implements Serializable {
 	private Date payTime;
 
 	/**
-	 * 是否缴税缴费
+	 * 是否缴税缴费(0=未缴费,1=已缴费,2=缴费失败)
 	 */
 	private Integer payTax;
 

+ 8 - 2
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersApiController.java

@@ -156,8 +156,14 @@ public class TbOrdersApiController {
 
 	/** 采购商支付成功 ——> 边民缴税以及各服务费 */
 	@PostMapping("rpc/payTax")
-	public boolean payTax(@RequestParam("orderNo")String orderNo) {
-		boolean result = tbOrdersService.payTax(orderNo);
+	public boolean payTax(@RequestParam("orderNo")String orderNo, @RequestParam("MKT008Status")Integer MKT008Status) {
+		boolean result = tbOrdersService.payTax(orderNo, MKT008Status);
+		return result;
+	}
+	/** 收到边民缴税以及各服务费回执 */
+	@PostMapping("rpc/payTaxFromBank")
+	public boolean payTaxFromBank(@RequestParam("orderNo")String orderNo, @RequestParam("MKT008Status")Integer MKT008Status) {
+		boolean result = tbOrdersService.payTaxFromBank(orderNo, MKT008Status);
 		return result;
 	}
 

+ 79 - 54
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java

@@ -162,11 +162,6 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
         TbOrders orders = new TbOrders();
         orders.setPurchaserId(purchaser.getId());
         orders.setPurchaserName(purchaser.getName());
-        orders.setIsPay(1);//支付成功
-        orders.setPayTime(new Date());
-        OrdersDto ordersDto = new OrdersDto();
-        BeanUtils.copyProperties(orders,ordersDto);
-        asyncServerInterface.sendLevelTwoOrdersDto(ordersDto, DataType.DATA_TYPE_FOUR.getCode()); // 发送航通
 
         for (Long id : idArr) {
 
@@ -184,81 +179,111 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
             PaymentTwoDto paymentTwoDto = this.getPaymentData(orderTwo,orderOne);
             paymentServerInterface.sendMKT006_NoCommission(paymentTwoDto);
 
-            //todo:给每个购买他商品的边民发一条支付成功消息,通知边民发起缴税申请以及缴费申请
+            //给每个购买他商品的边民发一条支付成功消息,通知边民发起缴税申请以及缴费申请
            /* MessageDto dto = new MessageDto();
             dto.setUrl("/pages/market/two/leader/order");
             dto.setUserId(t.getLeaderId());
             dto.setContents("你转售的《" + t.getGoodsName() + "》收购商已付款。请及时发起缴税申请以及缴费申请。");
             adminInterface.messageSave(dto);*/
         }
-
         // 清空购物车
         LambdaQueryWrapper<TbOrdersCart> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(TbOrdersCart::getOrderId, Arrays.asList(idArr));
         int del = tbOrdersCartMapper.delete(wrapper);
-
         return true;
     }
 
     /**
-     * 采购商支付成功 ——> 边民缴税以及各服务费
+     * 收到采购商支付扣款回执:成功——> 边民缴税以及各服务费
      * @param orderNo 二级市场边民订单-订单编号
      */
-    boolean payTax(String orderNo) {
+    boolean payTax(String orderNo, Integer MKT008Status) {
         LambdaQueryWrapper<TbOrders> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(TbOrders::getOrderNo, orderNo);
         List<TbOrders> list = this.list(queryWrapper);
-        if (list.size() <= 0) return false;
-
+        if (list.size() <= 0) new RuntimeException("收到采购商支付扣款回执:二级市场订单不存在");
         TbOrders orderTwo = list.get(0);
-        //if (orders.getPayTax() == 1) throw new RuntimeException("你已缴清费用");
 
         OrderDto orderOne = levelOneServerInterface.getOrderDtoById(orderTwo.getLevelOneOrderId());
-        if (null == orderOne) return false;
+        if (null == orderOne) new RuntimeException("收到采购商支付扣款回执:一级市场订单不存在");
 
-        //todo 订单状态更新,系统将服务费自动分账,将分账信息自动发送至银行进行划扣
-        List<TbItemRules> ruleList = new ArrayList<>();
-        List<TbFeeItem> feeItemList = tbFeeItemService.getFeeItems();
-        feeItemList.forEach(feeItem -> {
-            ruleList.addAll(tbItemRulesService.getList(new SoMap().set("itemId", feeItem.getId())));
-        });
-        //目前逻辑为一个边民订单只有一个商品
-        GoodsDto goods = levelOneServerInterface.getByGoodsId(orderOne.getGoodsId());
-        //找出所有含有该商品的费项规则
-        List<TbItemRules> newRuleList = ruleList.stream().filter(rule -> rule.getGoodsCodes().contains(goods.getCode())).collect(Collectors.toList());
-        List<CompanyDto> companyDtoList = new ArrayList<>();
-        for (TbItemRules ruleItem : newRuleList) {
-            BigDecimal chargesPrice = BigDecimal.ZERO;
-            BigDecimal TotalPrice = new BigDecimal(orderOne.getTotalPrice());
-            BigDecimal Percent = new BigDecimal(ruleItem.getPercent());
-            //类型(1=按交易额收取,2=按次收取,3=按吨)
-            if ("1".equals(ruleItem.getFeeType())) {
-                chargesPrice = TotalPrice.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);//保留两位小数,四舍五入
-            } else if ("2".equals(ruleItem.getFeeType())) {
-                chargesPrice = ruleItem.getFeeMoney();
-            } else if ("3".equals(ruleItem.getFeeType())) {
-                chargesPrice = TotalPrice.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);//保留两位小数,四舍五入
-            }
-            CompanyDto companyDto = new CompanyDto();
-            List<TbFeeItem> feeItems = feeItemList.stream().filter(feeItem -> feeItem.getId().equals(ruleItem.getItemId())).collect(Collectors.toList());
-            if (feeItems.size() > 0) {
-                TbCompany company = companyService.getById(feeItems.get(0).getCompanyId());
-                BeanUtils.copyProperties(company,companyDto);
-                companyDto.setChargesPrice(chargesPrice);
+        if(2==MKT008Status) {//扣款失败
+            //todo 订单状态更新
+            orderTwo.setIsPay(2);//支付失败
+            orderTwo.setPayTime(new Date());
+        }
+        else if(1==MKT008Status) {//扣款成功
+            //todo 1、订单状态更新
+            orderTwo.setIsPay(1);//支付成功
+            orderTwo.setPayTime(new Date());
+
+            //todo 2、同步订单信息,发送航通
+            OrdersDto ordersDto = new OrdersDto();
+            BeanUtils.copyProperties(orderTwo,ordersDto);
+            asyncServerInterface.sendLevelTwoOrdersDto(ordersDto, DataType.DATA_TYPE_FOUR.getCode());
+
+            //todo 3、系统将服务费自动分账,将分账信息自动发送至银行进行划扣
+            List<TbItemRules> ruleList = new ArrayList<>();
+            List<TbFeeItem> feeItemList = tbFeeItemService.getFeeItems();
+            feeItemList.forEach(feeItem -> {
+                ruleList.addAll(tbItemRulesService.getList(new SoMap().set("itemId", feeItem.getId())));
+            });
+            //目前逻辑为一个边民订单只有一个商品
+            GoodsDto goods = levelOneServerInterface.getByGoodsId(orderOne.getGoodsId());
+            //找出所有含有该商品的费项规则
+            List<TbItemRules> newRuleList = ruleList.stream().filter(rule -> rule.getGoodsCodes().contains(goods.getCode())).collect(Collectors.toList());
+            List<CompanyDto> companyDtoList = new ArrayList<>();
+            for (TbItemRules ruleItem : newRuleList) {
+                BigDecimal chargesPrice = BigDecimal.ZERO;
+                BigDecimal TotalPrice = new BigDecimal(orderOne.getTotalPrice());
+                BigDecimal Percent = new BigDecimal(ruleItem.getPercent());
+                //类型(1=按交易额收取,2=按次收取,3=按吨)
+                if ("1".equals(ruleItem.getFeeType())) {
+                    chargesPrice = TotalPrice.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);//保留两位小数,四舍五入
+                } else if ("2".equals(ruleItem.getFeeType())) {
+                    chargesPrice = ruleItem.getFeeMoney();
+                } else if ("3".equals(ruleItem.getFeeType())) {
+                    chargesPrice = TotalPrice.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);//保留两位小数,四舍五入
+                }
+                CompanyDto companyDto = new CompanyDto();
+                List<TbFeeItem> feeItems = feeItemList.stream().filter(feeItem -> feeItem.getId().equals(ruleItem.getItemId())).collect(Collectors.toList());
+                if (feeItems.size() > 0) {
+                    TbCompany company = companyService.getById(feeItems.get(0).getCompanyId());
+                    BeanUtils.copyProperties(company,companyDto);
+                    companyDto.setChargesPrice(chargesPrice);
+                }
+                companyDtoList.add(companyDto);
             }
-            companyDtoList.add(companyDto);
+
+            PaymentTwoDto paymentTwoDto = this.getPaymentData(orderTwo,orderOne);
+            paymentTwoDto.setCompanyDtoList(companyDtoList);
+            paymentServerInterface.sendMKT006(paymentTwoDto);
         }
 
-        PaymentTwoDto paymentTwoDto = this.getPaymentData(orderTwo,orderOne);
-        paymentTwoDto.setCompanyDtoList(companyDtoList);
-        paymentServerInterface.sendMKT006(paymentTwoDto);
+        return updateById(orderTwo);
+    }
+    /**
+     * 收到边民缴税以及各服务费回执
+     * @param orderNo 二级市场边民订单-订单编号
+     */
+    boolean payTaxFromBank(String orderNo, Integer MKT008Status) {
+        LambdaQueryWrapper<TbOrders> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(TbOrders::getOrderNo, orderNo);
+        List<TbOrders> list = this.list(queryWrapper);
+        if (list.size() <= 0) new RuntimeException("收到边民缴税以及各服务费回执:二级市场订单不存在");
+        TbOrders orderTwo = list.get(0);
 
+        if(2==MKT008Status) {//缴费失败
+            //todo 订单状态更新
+            orderTwo.setPayTax(2);
+            orderTwo.setPayTaxTime(new Date());
+        }
+        else if(1==MKT008Status) {//缴费成功
+            //todo 订单状态更新
+            orderTwo.setPayTax(1);
+            orderTwo.setPayTaxTime(new Date());
+            orderTwo.setOrderFinish(1);//缴费成功订单完成
 
-        //todo 订单状态更新
-        orderTwo.setPayTax(1);
-        orderTwo.setPayTaxTime(new Date());
-        orderTwo.setOrderFinish(1);//缴费成功订单完成
-        if (updateById(orderTwo)) {
             //保存缴费记录
             List<TbFeeItem> feeItems = tbFeeItemService.getFeeItems();
             feeItems.stream().forEach(e -> {
@@ -280,9 +305,9 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
             dto.setUserId(orderTwo.getPurchaserId());
             dto.setContents("你购买的《" + orderTwo.getGoodsName() + "》边民已缴清税以及各服务费。");
             adminInterface.messageSave(dto);
-            return true;
         }
-        return false;
+
+        return updateById(orderTwo);
     }
 
     List<TbOrders> getDetailById(SoMap so) {

+ 32 - 26
sp-service/payment-server/src/main/java/com/pj/task/BankByteTask.java

@@ -64,7 +64,7 @@ public class BankByteTask {
     /**
      * 启动定时任务
      */
-    @Scheduled(cron = "*/10 * * * * ?")  // 每10秒扫描一次
+    //@Scheduled(cron = "*/10 * * * * ?")  // 每10秒扫描一次
     private void bankByteTask() {
 
         //扫描表内是否有待处理任务
@@ -222,45 +222,51 @@ public class BankByteTask {
             //(一级市场)订单扣款-成功
             if(bankInfo.getOperation().equalsIgnoreCase("SXB011")) {
                 //参数:一级市场边民订单-订单编号
-                result = levelOneServerInterface.confirmOrderFromBank(bankInfo.getSource());
+                result = levelOneServerInterface.confirmOrderFromBank(bankInfo.getSource(),1);
             }
             //(一级市场)订单扣款-失败
-            else if(bankInfo.getOperation().equalsIgnoreCase("SXB012")) { }
+            else if(bankInfo.getOperation().equalsIgnoreCase("SXB012")) {
+                result = levelOneServerInterface.confirmOrderFromBank(bankInfo.getSource(),2);
+            }
             //(一级市场)订单退款-成功
-            else if(bankInfo.getOperation().equalsIgnoreCase("SXB014")) { }
+            else if(bankInfo.getOperation().equalsIgnoreCase("SXB014")) {
+                result = levelOneServerInterface.chargebackFromBank(bankInfo.getSource(),1, bankInfo.getNote());
+            }
             //(一级市场)订单退款-失败
-            else if(bankInfo.getOperation().equalsIgnoreCase("SXB015")) { }
+            else if(bankInfo.getOperation().equalsIgnoreCase("SXB015")) {
+                result = levelOneServerInterface.chargebackFromBank(bankInfo.getSource(),2, bankInfo.getNote());
+            }
             //(一级市场-通车批信息)订单打款-成功
             else if(bankInfo.getOperation().equalsIgnoreCase("SXB017")) {
-                //参数:一级市场边民订单-订单编号
-                result = levelOneServerInterface.confirmOrderFromBank(bankInfo.getSource());
+                //参数:一级市场边民订单-订单编号, n个
+                result = levelOneServerInterface.orderFinishFromBank(bankInfo.getSource(), 1);
+            }
+            //(一级市场-通车批信息)订单打款-失败
+            else if(bankInfo.getOperation().equalsIgnoreCase("SXB018")) {
+                result = levelOneServerInterface.orderFinishFromBank(bankInfo.getSource(), 2);
             }
-            //(一级市场-通车批信息)订单打款-失败()
-            else if(bankInfo.getOperation().equalsIgnoreCase("SXB018")) { }
 
-            //001:扣款订单    002:退款订单    003:打款订单
-            //(二级市场)订单扣款
+            //(二级市场)订单扣款            001:扣款订单    002:退款订单    003:打款订单
             else if(bankInfo.getOperation().equalsIgnoreCase("MKT008") && "001".equals(bankInfo.getType())) {
-                if(hasCommission) {//有手续费模式
-
+                if(!hasCommission) {//无手续费模式——采购商支付扣款
+                    if("200".equals(bankInfo.getCode())) {//回执代码为200则表示支付成功
+                        //参数:二级市场边民订单-订单编号
+                        result = levelTwoServerInterface.payTax(bankInfo.getSource(),1);
+                    } else {//支付失败
+                        result = levelTwoServerInterface.payTax(bankInfo.getSource(),2);
+                    }
                 }
-                else {//无手续费模式
-                    //回执代码为200则表示支付成功
-                    if("200".equals(bankInfo.getCode())) {
+                else {//有手续费模式——边民缴税以及各服务费
+                    if("200".equals(bankInfo.getCode())) {//回执代码为200则表示缴费成功
                         //参数:二级市场边民订单-订单编号
-                        result = levelTwoServerInterface.payTax(bankInfo.getSource());
-                    } else {
-
+                        result = levelTwoServerInterface.payTaxFromBank(bankInfo.getSource(),1);
+                    } else {//缴费失败
+                        result = levelTwoServerInterface.payTaxFromBank(bankInfo.getSource(),2);
                     }
                 }
             }
-            //(二级市场)订单退款
-            else if(bankInfo.getOperation().equalsIgnoreCase("MKT008") && "002".equals(bankInfo.getType())) {
-
-            }
-
-            //todo: 届时开启该数据校验
-            //amqpTemplateFeign.verifyContent(dataDto);
+            //(二级市场)订单退款-----暂无调用订单退款
+            //else if(bankInfo.getOperation().equalsIgnoreCase("MKT008") && "002".equals(bankInfo.getType())) { }
 
             //数据处理完成状态
             if(result) {//处理成功

+ 6 - 0
sp-service/payment-server/src/main/java/com/pj/task/PaymentController.java

@@ -2,6 +2,7 @@ package com.pj.task;
 
 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.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -14,6 +15,11 @@ public class PaymentController {
     @Autowired
     private PaymentService paymentService;
 
+    @RequestMapping("rpc/testSend")
+    public void testSend(@RequestBody DataDto dataDto) {
+        paymentService.testSend(dataDto);
+    }
+
     @RequestMapping("rpc/sendSXB010")
     public void sendSXB010(@RequestBody PaymentDto paymentDto) {
         paymentService.sendSXB010(paymentDto);

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

@@ -20,6 +20,12 @@ public class PaymentService {
     @Autowired
     private AmqpTemplate amqpTemplate;
 
+    public void testSend(DataDto dataDto) {
+        System.out.println("开始发送----------\n"+dataDto.toString());
+        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE, dataDto);
+        System.out.println("结束发送----------");
+    }
+
     /**
      * ※ 订单扣款
      * 报文名称:SXB010.xml  数据流向:一级市场--->银行
@@ -120,18 +126,5 @@ public class PaymentService {
         log.info("send mq msg finish:{}", JSON.toJSONString(xml));
     }
 
-    /**
-     * 获取航通数据时,验证其是否被篡改
-     */
-    /*public boolean verifyContent(DataDto dataDto){
-        //获取其签名
-        String sign = dataDto.getSign();
-        String signString = "msgId=" + dataDto.getMsgId() + "&appId=" + dataDto.getAppId() + "&dataType=" + dataDto.getDataType() + "&msgTime=" + dataDto.getMsgTime() + "&data=" + dataDto.getData();
-        String md5 = MD5.getMd5(signString, 32);
-        if(!sign.equals(md5))
-            throw new ServiceException("报文已经被修改。");
-        return true;
-    }*/
-
 
 }

+ 30 - 30
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUser.java

@@ -12,7 +12,7 @@ import lombok.experimental.Accessors;
 
 /**
  * Model: app_user -- 移动端账号
- * @author qzy 
+ * @author qzy
  */
 @Data
 @Accessors(chain = true)
@@ -22,15 +22,15 @@ public class AppUser extends Model<AppUser> implements Serializable {
 
 	// ---------- 模块常量 ----------
 	/**
-	 * 序列化版本id 
+	 * 序列化版本id
 	 */
-	private static final long serialVersionUID = 1L;	
+	private static final long serialVersionUID = 1L;
 	/**
-	 * 此模块对应的表名 
+	 * 此模块对应的表名
 	 */
-	public static final String TABLE_NAME = "app_user";	
+	public static final String TABLE_NAME = "app_user";
 	/**
-	 * 此模块对应的权限码 
+	 * 此模块对应的权限码
 	 */
 	public static final String PERMISSION_CODE = "app-user";
 	public static final String PERMISSION_CODE_ADD = "app-user-add";
@@ -42,78 +42,78 @@ public class AppUser extends Model<AppUser> implements Serializable {
 
 	// ---------- 表中字段 ----------
 	/**
-	 * 主键 
+	 * 主键
 	 */
 	@TableId(type = IdType.AUTO)
-	private Long id;	
+	private Long id;
 
 	/**
-	 * 手机号码 
+	 * 手机号码
 	 */
-	private String phone;	
+	private String phone;
 
 	/**
-	 * 姓名 
+	 * 姓名
 	 */
-	private String name;	
+	private String name;
 
 	/**
-	 * 类型(1=边民,2=组长,3=商户,4=收购商,5=司机) 
+	 * 类型(1=边民,2=组长,3=商户,4=收购商,5=司机)
 	 */
 	private Integer userType;
 
 	/**
-	 * 外联id,user_type=1=>边民ID;user_type=3=>商户ID 
+	 * 外联id,user_type=1=>边民ID;user_type=3=>商户ID
 	 */
 	private Long fkId;
 
 	/**
-	 * 状态(0=禁用,1=启用) 
+	 * 状态(0=禁用,1=启用)
 	 */
-	private String status;	
+	private String status;
 
 	/**
-	 * 是否认证(0=未认证,1=已认证) 
+	 * 是否认证(0=未认证,1=已认证)
 	 */
-	private String auth;	
+	private String auth;
 
 	/**
-	 * 人证时间 
+	 * 认证时间
 	 */
-	private String authTime;
+	private Date authTime;
 	/**
 	 *人脸库ID
 	 */
 	private String faceId;
 
 	/**
-	 * 登录次数 
+	 * 登录次数
 	 */
-	private Long loginCount;	
+	private Long loginCount;
 
 	/**
-	 * 上次登录时间 
+	 * 上次登录时间
 	 */
 	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	private Date lastLoginTime;
 
 	/**
-	 * 创建时间 
+	 * 创建时间
 	 */
-	private Date createTime;	
+	private Date createTime;
 
 	/**
-	 * 更新者id 
+	 * 更新者id
 	 */
-	private String updateById;	
+	private String updateById;
 
 	/**
-	 * 更新者名称 
+	 * 更新者名称
 	 */
-	private String updateByName;	
+	private String updateByName;
 
 	/**
-	 * 更新时间 
+	 * 更新时间
 	 */
 	private Date updateTime;