qin hace 1 año
padre
commit
52db005736

+ 12 - 9
src/main/java/com/poteviohealth/ym/ipos/controller/feign/IposFeignController.java

@@ -103,10 +103,13 @@ public class IposFeignController extends BaseFeignController {
     @ResponseBody
     public VaultsResponse<List<SplitPay>> splitOrder(@RequestBody List<SplitInfo> list) {
 
-        final BigDecimal proportion= new BigDecimal("1");
         List<SplitPay> returnList = Lists.newArrayList();
         for (SplitInfo splitInfo : list) {
             //List<SplitRecords> splitRecordsList = Lists.newArrayList();
+           PaymentRecords pr = paymentRecordsService.getPaymentRecords(splitInfo.getPayId());
+           if(pr == null){
+               continue;
+           }
             List<SplitRecordsDetail> details = Lists.newArrayList();
             SplitRecords records = new SplitRecords();
             records.setOperatorId(splitInfo.getOperatorId());
@@ -118,7 +121,7 @@ public class IposFeignController extends BaseFeignController {
             SplitRecordsDetail pt = new SplitRecordsDetail();
             pt.setSplitId(records.getSplitId());
             pt.setSourceId(0);
-
+            BigDecimal chargeAmount = new BigDecimal(pr.getChargeAmount());
             BigDecimal ptAmount = BigDecimal.ZERO;
             BigDecimal tzAmount = BigDecimal.ZERO;
             BigDecimal ptyysAmount = BigDecimal.ZERO;
@@ -135,10 +138,10 @@ public class IposFeignController extends BaseFeignController {
                 sp.setOrderId(detail.getOrderId());
                 sp.setSplitId(records.getSplitId());
                 //运算价格
-                BigDecimal price = new BigDecimal(detail.getPrice()).multiply(proportion);
+                BigDecimal price = new BigDecimal(detail.getPrice()).subtract(chargeAmount);
 
                 //平台金额
-                BigDecimal ptDecimal = new BigDecimal(split).multiply(new BigDecimal(detail.getPrice()));
+                BigDecimal ptDecimal = new BigDecimal(split).multiply(price);
                 BigDecimal valDecimal = new BigDecimal("1");
                 if(ptDecimal.longValue() > 0){
                     valDecimal = ptDecimal;
@@ -161,8 +164,8 @@ public class IposFeignController extends BaseFeignController {
                 supplierOne.setSourceId(2);
                 supplierOne.setMerchantId(s);
                 for (SplitDetail detail : oneMaps.get(s)) {
-                    supplierOneAmount = supplierOneAmount.add(new BigDecimal(detail.getConsignmentPrice()).multiply(proportion));
-                    detail.setPrice(new BigDecimal(detail.getPrice()).subtract(new BigDecimal(detail.getConsignmentPrice()).multiply(proportion)).longValue());
+                    supplierOneAmount = supplierOneAmount.add(new BigDecimal(detail.getConsignmentPrice()));
+                    detail.setPrice(new BigDecimal(detail.getPrice()).subtract(new BigDecimal(detail.getConsignmentPrice())).longValue());
                 }
 
                 if (supplierOneAmount.compareTo(BigDecimal.ZERO) == 1) {
@@ -180,7 +183,7 @@ public class IposFeignController extends BaseFeignController {
                 supplierTwo.setSourceId(2);
                 supplierTwo.setMerchantId(s);
                 for (SplitDetail detail : twoMaps.get(s)) {
-                    supplierTwoAmount = supplierTwoAmount.add(new BigDecimal(detail.getConsignmentPrice()).multiply(proportion));
+                    supplierTwoAmount = supplierTwoAmount.add(new BigDecimal(detail.getConsignmentPrice()));
                     detail.setPrice(detail.getPrice() - detail.getConsignmentPrice());
                 }
 
@@ -199,8 +202,8 @@ public class IposFeignController extends BaseFeignController {
                 supplier.setSourceId(2);
                 supplier.setMerchantId(s);
                 for (SplitDetail detail : maps.get(s)) {
-                    supplierAmount = supplierAmount.add(new BigDecimal(detail.getSettlementPrice()).multiply(proportion));
-                    detail.setPrice(new BigDecimal(detail.getPrice()).subtract(new BigDecimal(detail.getSettlementPrice()).multiply(proportion)).longValue());
+                    supplierAmount = supplierAmount.add(new BigDecimal(detail.getSettlementPrice()));
+                    detail.setPrice(new BigDecimal(detail.getPrice()).subtract(new BigDecimal(detail.getSettlementPrice())).longValue());
                    // detail.setPrice(detail.getPrice() - detail.getSettlementPrice());
                 }
 

+ 3 - 0
src/main/java/com/poteviohealth/ym/ipos/model/payment/PaymentRecords.java

@@ -71,4 +71,7 @@ public class PaymentRecords extends BaseEntity {
 
     @ApiModelProperty(value="支付平台的订单号,仅成功时有值")
     private String tradeNo;
+
+    @ApiModelProperty(value = "手续费,单位为分,仅成功时有值")
+    private Integer chargeAmount;
 }

+ 2 - 0
src/main/java/com/poteviohealth/ym/ipos/service/IPaymentRecordsService.java

@@ -9,4 +9,6 @@ import com.poteviohealth.ym.ipos.model.payment.PaymentRecords;
  */
 public interface IPaymentRecordsService extends IService<PaymentRecords> {
 
+    PaymentRecords getPaymentRecords(Long payId);
+
 }

+ 13 - 0
src/main/java/com/poteviohealth/ym/ipos/service/impl/PaymentRecordsServiceImpl.java

@@ -1,5 +1,6 @@
 package com.poteviohealth.ym.ipos.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.poteviohealth.ym.ipos.mapper.PaymentRecordsMapper;
 import com.poteviohealth.ym.ipos.model.payment.PaymentRecords;
@@ -14,4 +15,16 @@ import org.springframework.stereotype.Service;
 public class PaymentRecordsServiceImpl extends ServiceImpl<PaymentRecordsMapper, PaymentRecords> implements IPaymentRecordsService {
 
 
+    @Override
+    public PaymentRecords getPaymentRecords(Long payId) {
+
+        QueryWrapper<PaymentRecords> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("pay_id",payId);
+        try {
+            PaymentRecords pr  = this.getOne(queryWrapper);
+            return pr;
+        }catch (Exception e){
+            return null;
+        }
+    }
 }

+ 1 - 1
src/main/java/com/poteviohealth/ym/ipos/service/impl/PaymentServiceImpl.java

@@ -200,7 +200,7 @@ public class PaymentServiceImpl implements IPaymentService {
                 pr.setPayType(payNotification.getPay_type());
                 pr.setTransType(payNotification.getTrans_type());
                 pr.setTradeNo(payNotification.getTrade_no());
-
+                pr.setChargeAmount(payNotification.getCharge_amount());
                 PayReceive payReceive = new PayReceive();
                 payReceive.setPayId(pr.getPayId());
                 payReceive.setPaySn(pr.getPaySn());