From f9b9131367d9ba6fe852130b12083c0f5ea68bbb Mon Sep 17 00:00:00 2001
From: zhibing.pu <393733352@qq.com>
Date: 星期一, 27 五月 2024 17:26:16 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0' into 2.0

---
 DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java |   89 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 71 insertions(+), 18 deletions(-)

diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java
index 1f791cd..dc8cfd9 100644
--- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java
+++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java
@@ -4,19 +4,23 @@
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.stylefeng.guns.core.util.ToolUtil;
 import com.stylefeng.guns.modular.system.dao.SettlementRecordMapper;
 import com.stylefeng.guns.modular.system.model.*;
 import com.stylefeng.guns.modular.system.service.*;
+import com.stylefeng.guns.modular.system.util.DateUtil;
 import com.stylefeng.guns.modular.system.util.ResultUtil;
 import com.stylefeng.guns.modular.system.util.Tingg.TinggPayUtil;
 import com.stylefeng.guns.modular.system.util.Tingg.model.CheckoutRequest;
 import com.stylefeng.guns.modular.system.warpper.QueryHistoricalSettlement;
 import com.stylefeng.guns.modular.system.warpper.QuerySettlementAmount;
 import com.stylefeng.guns.modular.system.warpper.QuerySettlementAmountDetails;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -45,6 +49,9 @@
 
     @Value("${callbackPath}")
     private String callbackPath;//支付回调网关地址
+    
+    @Resource
+    private IBalanceUsageRecordService balanceUsageRecordService;
 
 
 
@@ -54,7 +61,7 @@
      * @return
      */
     @Override
-    public QuerySettlementAmount querySettlementAmount(Integer driverId) {
+    public QuerySettlementAmount querySettlementAmount(Integer language, Integer driverId) {
         QuerySettlementAmount querySettlementAmount = new QuerySettlementAmount();
         SettlementRecord settlementRecord = this.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", driverId).eq("paymentStatus", 1));
         if(null != settlementRecord){
@@ -67,7 +74,7 @@
                 QuerySettlementAmountDetails querySettlementAmountDetails = new QuerySettlementAmountDetails();
                 querySettlementAmountDetails.setOrderMoney(s.getOrderMoney());
                 querySettlementAmountDetails.setPayMoney(s.getPrice());
-                querySettlementAmountDetails.setOrderTime(sdf.format(s.getCreateTime()));
+                querySettlementAmountDetails.setOrderTime(DateUtil.conversionFormat(language, sdf.format(s.getCreateTime())));
                 list.add(querySettlementAmountDetails);
             });
             querySettlementAmount.setList(list);
@@ -91,7 +98,7 @@
         Driver driver1 = driverService.selectById(driverId);
         SettlementRecord settlementRecord = this.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", driverId).eq("paymentStatus", 1));
         if(null == settlementRecord){
-            return ResultUtil.error(language == 1 ? "暂无需支付" : language == 2 ? "No need to pay" : "Pas besoin de payer");
+            return ResultUtil.error(language == 1 ? "暂无需支付" : language == 2 ? "No need to make payments for the time being" : "Pas besoin d’effectuer de paiements pour le moment");
         }
         Double payMoney = settlementRecord.getPayMoney();
         ResultUtil resultUtil = ResultUtil.success("");
@@ -114,7 +121,7 @@
             resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest);
 
             if(resultUtil.getCode()!=200){
-                resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", "");
+                resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Échec de paiement", "");
             }
             return resultUtil;
         }
@@ -138,34 +145,51 @@
             resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest);
 
             if(resultUtil.getCode()!=200){
-                resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", "");
+                resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Échec de paiement", "");
             }
             return resultUtil;
         }
         if(payType == 3){//余额支付
             if(driver1.getBalance() == null || driver1.getBalance() < payMoney){
-                return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient account balance" : "Solde de compte insuffisant", "");
+                return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient balance" : "Solde insuffisant", "");
             }
 
             Double laveActivityMoney = driver1.getLaveActivityMoney();
             Double laveBusinessMoney = driver1.getLaveBusinessMoney();
-            if(laveBusinessMoney.compareTo(payMoney) < 0){
-                driver1.setLaveBusinessMoney(0D);
-                BigDecimal m = new BigDecimal(payMoney).subtract(new BigDecimal(laveBusinessMoney));
-                driver1.setLaveActivityMoney(new BigDecimal(laveActivityMoney).subtract(m).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+            if(laveActivityMoney.compareTo(payMoney) < 0){
+                driver1.setLaveActivityMoney(0D);
+                BigDecimal m = new BigDecimal(payMoney).subtract(new BigDecimal(laveActivityMoney));
+                driver1.setLaveBusinessMoney(new BigDecimal(laveBusinessMoney).subtract(m).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+                settlementRecord.setPayMoney(laveActivityMoney);
+                settlementRecord.setPaymentStatus(2);
+                settlementRecord.setPayType(payType);
+                settlementRecord.setBalanceType(1);
+                settlementRecord.setPayTime(new Date());
+                this.updateById(settlementRecord);
+                balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 1, laveActivityMoney, settlementRecord.getType() + 2);
+                balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 2, m.doubleValue(), settlementRecord.getType() + 2);
+    
+                SettlementRecord settlementRecord1 = new SettlementRecord();
+                BeanUtils.copyProperties(settlementRecord, settlementRecord1);
+                settlementRecord1.setId(null);
+                settlementRecord1.setPayMoney(m.doubleValue());
+                settlementRecord1.setBalanceType(2);
+                this.insert(settlementRecord1);
+                
             }else{
-                driver1.setLaveBusinessMoney(new BigDecimal(laveBusinessMoney).subtract(new BigDecimal(payMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+                driver1.setLaveActivityMoney(new BigDecimal(laveActivityMoney).subtract(new BigDecimal(payMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+                settlementRecord.setPaymentStatus(2);
+                settlementRecord.setPayType(payType);
+                settlementRecord.setBalanceType(1);
+                settlementRecord.setPayTime(new Date());
+                this.updateById(settlementRecord);
+                balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 1, payMoney, settlementRecord.getType() + 2);
             }
             driver1.setBalance(new BigDecimal(driver1.getBalance()).subtract(new BigDecimal(payMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
 
             //添加交易明细
             transactionDetailsService.saveData(driverId, "线下结算", payMoney, 2, 1, 2, null, null);
             driverService.updateById(driver1);
-
-            settlementRecord.setPaymentStatus(2);
-            settlementRecord.setPayType(payType);
-            settlementRecord.setPayTime(new Date());
-            this.updateById(settlementRecord);
             return ResultUtil.success("");
         }
         return resultUtil;
@@ -178,9 +202,38 @@
      * @return
      */
     @Override
-    public List<QueryHistoricalSettlement> queryHistoricalSettlement(Integer driverId, Integer pageNum, Integer size) {
+    public List<QueryHistoricalSettlement> queryHistoricalSettlement(Integer language, Integer driverId, Integer pageNum, Integer size) {
         pageNum = (pageNum - 1) * size;
-        return this.baseMapper.queryHistoricalSettlement(driverId, pageNum, size);
+        List<Map<String, Object>> list = this.baseMapper.queryHistoricalSettlement(driverId, pageNum, size);
+        List<QueryHistoricalSettlement> datas = new ArrayList<>();
+        for (Map<String, Object> map : list) {
+            QueryHistoricalSettlement queryHistoricalSettlement = new QueryHistoricalSettlement();
+            if(null != map.get("createTime")){
+                queryHistoricalSettlement.setCreateTime(DateUtil.conversionFormat(language, map.get("createTime").toString()));
+            }
+            if(null != map.get("price")){
+                queryHistoricalSettlement.setPrice(Double.valueOf(map.get("price").toString()));
+            }
+            if(null != map.get("type")){
+                queryHistoricalSettlement.setType(Integer.valueOf(map.get("type").toString()));
+            }
+            if(null != map.get("payType")){
+                Integer balanceType = Integer.valueOf(map.get("balanceType").toString());
+                switch (map.get("payType").toString()){
+                    case "1":
+                        queryHistoricalSettlement.setPayType(language == 1 ? "手机支付" : language == 2 ? "Mobile Money" : "Paiement mobile");
+                        break;
+                    case "2":
+                        queryHistoricalSettlement.setPayType(language == 1 ? "线上支付" : language == 2 ? "Bank Card" : "Carte bancaire");
+                        break;
+                    default:
+                        queryHistoricalSettlement.setPayType(language == 1 ? "余额支付(" + (balanceType == 1 ? "奖励" : "收入") + ")" : language == 2 ? "Wallet (" + (balanceType == 1 ? "Reward" : "Income") + ")" : "Portefeuille (" + (balanceType == 1 ? "Récompense" : "Revenu") + ")");
+                        break;
+                }
+            }
+            datas.add(queryHistoricalSettlement);
+        }
+        return datas;
     }
 
 

--
Gitblit v1.7.1