yanderong
2026-07-11 1baa21c114f634b8ecc3af64efcfaab6a57a571e
feat: 增加余额变更记录
3个文件已添加
26个文件已修改
413 ■■■■■ 已修改文件
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/common/constant/state/BalanceChangeType.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/intercept/BalanceUpdateInterceptor.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserInfoMapper.xml 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/UserInfo.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/vo/BalanceModifyRecordVo.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/WithdrawalServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/common/constant/state/BalanceChangeType.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TUserController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/TBalanceModifyRecord.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/common/constant/state/BalanceChangeType.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/intercept/BalanceUpdateInterceptor.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/CharteredCar/server/impl/OrderCharteredCarServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/call/server/impl/OrderCallServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/OrderCrossCityServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/PayInfoController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/rideCommentController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserInfoMapper.xml 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/UserInfo.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/vo/BalanceModifyRecordVo.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/vo/BalanceRecordVo.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TaxiCardServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TravelCardServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserInfoServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/WithdrawalServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/common/constant/state/BalanceChangeType.java
New file
@@ -0,0 +1,36 @@
package com.stylefeng.guns.core.common.constant.state;
import lombok.Getter;
import java.util.Objects;
/**
 * 余额变更类型
 */
@Getter
public enum BalanceChangeType {
  //  1、充值,2消费、3退款、4出行卡兑换
    RECHARGE(1, "充值"),
    CONSUME(2, "消费"),
    REFUND(3, "退款"),
    EXCHANGE(4, "出行卡兑换");
    private final Integer code;
    private final String message;
    BalanceChangeType(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
  public static String convertMessage(Integer code) {
      if (code != null) {
          for (BalanceChangeType s : BalanceChangeType.values()) {
              if (Objects.equals(s.getCode(), code)) {
                  return s.getMessage();
              }
          }
      }
      return "";
  }
}
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/intercept/BalanceUpdateInterceptor.java
@@ -15,10 +15,7 @@
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
import java.util.*;
/**
 *  用户余额变更拦截器
@@ -59,13 +56,22 @@
        }
        // 关键:先执行前查旧值(需要拿 userId)
        Long userId = extractUserId(param);
        Map<String, Long> mapValues = extractUserId(param);
        Long userId = mapValues.get("userId");
        if(Objects.isNull(userId)) {
            return invocation.proceed();
        }
        // 查询旧的用户
        UserInfo oldUser = getMapper().selectById(userId);
        // 执行更新
        Object result = invocation.proceed();
        // 查新的用户
        UserInfo newUser = getMapper().selectById(userId);
        Long balanceChangeType = mapValues.get("balanceChangeType");
        if(Objects.nonNull(balanceChangeType)) {
            newUser.setBalanceChangeType(balanceChangeType.intValue());
        }
        // 新增余额的变更记录(所有余额的变更记录都需要存)
        if(Objects.nonNull(oldUser) && Objects.nonNull(newUser)) {
@@ -88,28 +94,30 @@
    /**
     * 获取用户id
     */
    private Long extractUserId(Object param) {
    private Map<String, Long> extractUserId(Object param) {
        Map<String, Long> mapValues = new HashMap<>();
        if (param == null) {
            return null;
            return mapValues;
        }
        // MyBatis ParamMap
        if (param instanceof Map) {
            Map<?, ?> map = (Map<?, ?>) param;
            // 第一种:直接传id
            try{
                Object id = map.get("id");
                if (id != null) {
                    return Long.valueOf(id.toString());
                }
            }
            catch (Exception e){
                log.error("sql中没有id");
            }
                Object balanceChangeType = map.get("balanceChangeType");
                if (Objects.nonNull(balanceChangeType)) {
                    mapValues.put("balanceChangeType", Long.valueOf(balanceChangeType.toString()));
                }
                Object id = map.get("id");
                if (Objects.nonNull(id)) {
                    mapValues.put("userId", Long.valueOf(id.toString()));
                    return mapValues;
                }
            } catch (Exception e) {
                // log.error("sql中没有id");
            }
            // 第二种:MyBatis-Plus update(entity, wrapper)
            Object entity = map.get("param1");
@@ -118,24 +126,31 @@
            }
            if (entity != null) {
                return extractId(entity);
                return extractId(entity, mapValues);
            }
        }
        // 直接就是实体
        return extractId(param);
        return extractId(param, mapValues);
    }
    private Long extractId(Object obj) {
    private Map<String, Long> extractId(Object obj, Map<String, Long> mapValues) {
        Field field = ReflectionUtils.findField(obj.getClass(), "id");
        if (field == null) {
            return null;
            return mapValues;
        }
        ReflectionUtils.makeAccessible(field);
        Object value = ReflectionUtils.getField(field, obj);
        mapValues.put("userId", value == null ? null : Long.valueOf(value.toString()));
        return value == null ? null : Long.valueOf(value.toString());
        Field fieldType = ReflectionUtils.findField(obj.getClass(), "balanceChangeType");
        if (fieldType == null) {
            return mapValues;
        }
        ReflectionUtils.makeAccessible(fieldType);
        Object valueType = ReflectionUtils.getField(fieldType, obj);
        mapValues.put("balanceChangeType", valueType == null ? null : Long.valueOf(valueType.toString()));
        return mapValues;
    }
}
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -5,6 +5,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.specialTrain.dao.OrderPrivateCarMapper;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
@@ -961,6 +962,7 @@
        if (Integer.valueOf(3).equals(orderPrivateCar.getPayType())) {
            UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId());
            if (userInfo != null) {
                userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                userInfo.setBalance(formatMoney((userInfo.getBalance() == null ? 0D : userInfo.getBalance()) + refundMoney));
                userInfoMapper.updateById(userInfo);
                finishPrepaidOrder(orderPrivateCar);
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserInfoMapper.xml
@@ -189,8 +189,8 @@
    </select>
    <select id="insertBalanceModifyRecord">
        insert into t_balance_modify_record (recordID, userId, userName, phone, money, type, createTime)
        values (#{recordVo.recordID}, #{recordVo.userId}, #{recordVo.userName}, #{recordVo.phone}, #{recordVo.money}, #{recordVo.type}, #{recordVo.createTime})
        insert into t_balance_modify_record (recordID, userId, userName, phone, money, type, createTime, balanceChangeType)
        values (#{recordVo.recordID}, #{recordVo.userId}, #{recordVo.userName}, #{recordVo.phone}, #{recordVo.money}, #{recordVo.type}, #{recordVo.createTime}, #{recordVo.balanceChangeType})
    </select>
</mapper>
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/UserInfo.java
@@ -147,6 +147,14 @@
    @TableField("onconUUID")
    private String onconUUID;
    /**
     * 账户余额变更类型(非数据库字段)
     * 1、充值,2消费、3退款、4出行卡兑换
     * {@link com.stylefeng.guns.core.common.constant.state.BalanceChangeType}
     */
    @TableField(exist = false)
    private Integer balanceChangeType;
    public Integer getBindDriverId() {
        return bindDriverId;
    }
@@ -362,7 +370,15 @@
    public void setOnconUUID(String onconUUID) {
        this.onconUUID = onconUUID;
    }
    public Integer getBalanceChangeType() {
        return balanceChangeType;
    }
    public void setBalanceChangeType(Integer balanceChangeType) {
        this.balanceChangeType = balanceChangeType;
    }
    @Override
    public String toString() {
        return "UserInfo{" +
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/vo/BalanceModifyRecordVo.java
@@ -5,6 +5,7 @@
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;
import java.util.Random;
/**
@@ -54,6 +55,13 @@
     */
    private BigDecimal money;
    /**
     * 变更类型
     * 1、充值,2消费、3退款、4出行卡兑换
     * {@link com.stylefeng.guns.core.common.constant.state.BalanceChangeType}
     */
    private Integer balanceChangeType;
    public static BalanceModifyRecordVo convert(UserInfo oldUser, UserInfo newUser) {
        Random random = new Random();
        StringBuilder result = new StringBuilder();
@@ -66,19 +74,29 @@
        recordVo.setPhone(newUser.getPhone());
        recordVo.setUserId(newUser.getId());
        recordVo.setCreateTime(new Date());
        if(Objects.nonNull(newUser.getBalanceChangeType())) {
            recordVo.setBalanceChangeType(newUser.getBalanceChangeType());
        }
        BigDecimal newBalance = newUser.getBalance() != null ? BigDecimal.valueOf(newUser.getBalance()) : BigDecimal.ZERO;
        BigDecimal oldBalance = oldUser.getBalance() != null ? BigDecimal.valueOf(oldUser.getBalance()) : BigDecimal.ZERO;
        BigDecimal amount = newBalance.subtract(oldBalance);
        // 判断方向
        if (amount.compareTo(BigDecimal.ZERO) == 0){
        if (amount.compareTo(BigDecimal.ZERO) == 0){ // 余额没变动
            return null;
        } else if (amount.compareTo(BigDecimal.ZERO) > 0) {
            recordVo.setType(1); // 增加金额(充值)
            recordVo.setMoney(amount);
            if(Objects.isNull(recordVo.getBalanceChangeType())) {
                recordVo.setBalanceChangeType(1);
            }
        } else {
            recordVo.setType(2);  // 减少金额,转为正数(消费)
            recordVo.setMoney(amount.abs());
            if(Objects.isNull(recordVo.getBalanceChangeType())) {
                recordVo.setBalanceChangeType(2);
            }
        }
        return recordVo;
    }
}
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/WithdrawalServiceImpl.java
@@ -1,6 +1,7 @@
package com.stylefeng.guns.modular.system.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.modular.system.dao.UserInfoMapper;
import com.stylefeng.guns.modular.system.dao.WithdrawalMapper;
import com.stylefeng.guns.modular.system.model.Driver;
@@ -154,6 +155,7 @@
        if(withdrawal.getUserType() == 1){//用户
            if(state == 2){//审核拒绝
                UserInfo userInfo = userInfoMapper.selectById(withdrawal.getUserId());
                userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                userInfo.setBalance(new BigDecimal(userInfo.getBalance()).add(new BigDecimal(withdrawal.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                userInfoMapper.updateById(userInfo);
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -5,6 +5,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
@@ -666,6 +667,7 @@
        if (Integer.valueOf(3).equals(orderTaxi.getPayType())) {
            UserInfo userInfo = userInfoMapper.selectById(orderTaxi.getUserId());
            if (userInfo != null) {
                userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                userInfo.setBalance(formatMoney((userInfo.getBalance() == null ? 0D : userInfo.getBalance()) + refundMoney));
                userInfoMapper.updateById(userInfo);
                finishPrepaidOrder(orderTaxi);
ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/common/constant/state/BalanceChangeType.java
New file
@@ -0,0 +1,36 @@
package com.stylefeng.guns.core.common.constant.state;
import lombok.Getter;
import java.util.Objects;
/**
 * 余额变更类型
 */
@Getter
public enum BalanceChangeType {
  //  1、充值,2消费、3退款、4出行卡兑换
    RECHARGE(1, "充值"),
    CONSUME(2, "消费"),
    REFUND(3, "退款"),
    EXCHANGE(4, "出行卡兑换");
    private final Integer code;
    private final String message;
    BalanceChangeType(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
  public static String convertMessage(Integer code) {
      if (code != null) {
          for (BalanceChangeType s : BalanceChangeType.values()) {
              if (Objects.equals(s.getCode(), code)) {
                  return s.getMessage();
              }
          }
      }
      return "";
  }
}
ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TUserController.java
@@ -5,6 +5,7 @@
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.base.tips.ErrorTip;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.SinataUtil;
@@ -188,7 +189,11 @@
            tBalanceModifyRecord.setCreateTime(DateUtil.parseTime(DateUtil.getTime()));
            tBalanceModifyRecord.setMoney(money);
            tBalanceModifyRecord.setType(updateType);
            if (1 == updateType) {  //增加
                tBalanceModifyRecord.setBalanceChangeType(BalanceChangeType.RECHARGE.getCode());
            }else{
                tBalanceModifyRecord.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            }
            Random random = new Random();
            String result = "";
            for (int i = 0; i < 8; i++) {
ManagementYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/TBalanceModifyRecord.java
@@ -52,6 +52,13 @@
     */
    private Integer type;
    /**
     * 变更类型
     * 1、充值,2消费、3退款、4出行卡兑换
     * {@link com.stylefeng.guns.core.common.constant.state.BalanceChangeType}
     */
    private Integer balanceChangeType;
    public Integer getId() {
        return id;
@@ -122,6 +129,14 @@
        return this.id;
    }
    public Integer getBalanceChangeType() {
        return balanceChangeType;
    }
    public void setBalanceChangeType(Integer balanceChangeType) {
        this.balanceChangeType = balanceChangeType;
    }
    @Override
    public String toString() {
        return "TBalanceModifyRecord{" +
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/common/constant/state/BalanceChangeType.java
New file
@@ -0,0 +1,36 @@
package com.stylefeng.guns.core.common.constant.state;
import lombok.Getter;
import java.util.Objects;
/**
 * 余额变更类型
 */
@Getter
public enum BalanceChangeType {
  //  1、充值,2消费、3退款、4出行卡兑换
    RECHARGE(1, "充值"),
    CONSUME(2, "消费"),
    REFUND(3, "退款"),
    EXCHANGE(4, "出行卡兑换");
    private final Integer code;
    private final String message;
    BalanceChangeType(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
  public static String convertMessage(Integer code) {
      if (code != null) {
          for (BalanceChangeType s : BalanceChangeType.values()) {
              if (Objects.equals(s.getCode(), code)) {
                  return s.getMessage();
              }
          }
      }
      return "";
  }
}
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/core/intercept/BalanceUpdateInterceptor.java
@@ -15,10 +15,7 @@
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
import java.util.*;
/**
 *  用户余额变更拦截器
@@ -59,13 +56,22 @@
        }
        // 关键:先执行前查旧值(需要拿 userId)
        Long userId = extractUserId(param);
        Map<String, Long> mapValues = extractUserId(param);
        Long userId = mapValues.get("userId");
        if(Objects.isNull(userId)) {
            return invocation.proceed();
        }
        // 查询旧的用户
        UserInfo oldUser = getMapper().selectById(userId);
        // 执行更新
        Object result = invocation.proceed();
        // 查新的用户
        UserInfo newUser = getMapper().selectById(userId);
        Long balanceChangeType = mapValues.get("balanceChangeType");
        if(Objects.nonNull(balanceChangeType)) {
            newUser.setBalanceChangeType(balanceChangeType.intValue());
        }
        // 新增余额的变更记录(所有余额的变更记录都需要存)
        if(Objects.nonNull(oldUser) && Objects.nonNull(newUser)) {
@@ -88,28 +94,30 @@
    /**
     * 获取用户id
     */
    private Long extractUserId(Object param) {
    private Map<String, Long> extractUserId(Object param) {
        Map<String, Long> mapValues = new HashMap<>();
        if (param == null) {
            return null;
            return mapValues;
        }
        // MyBatis ParamMap
        if (param instanceof Map) {
            Map<?, ?> map = (Map<?, ?>) param;
            // 第一种:直接传id
            try{
                Object id = map.get("id");
                if (id != null) {
                    return Long.valueOf(id.toString());
                }
            }
            catch (Exception e){
                log.error("sql中没有id");
            }
                Object balanceChangeType = map.get("balanceChangeType");
                if (Objects.nonNull(balanceChangeType)) {
                    mapValues.put("balanceChangeType", Long.valueOf(balanceChangeType.toString()));
                }
                Object id = map.get("id");
                if (Objects.nonNull(id)) {
                    mapValues.put("userId", Long.valueOf(id.toString()));
                    return mapValues;
                }
            } catch (Exception e) {
               // log.error("sql中没有id");
            }
            // 第二种:MyBatis-Plus update(entity, wrapper)
            Object entity = map.get("param1");
@@ -118,24 +126,31 @@
            }
            if (entity != null) {
                return extractId(entity);
                return extractId(entity, mapValues);
            }
        }
        // 直接就是实体
        return extractId(param);
        return extractId(param, mapValues);
    }
    private Long extractId(Object obj) {
    private Map<String, Long> extractId(Object obj, Map<String, Long> mapValues) {
        Field field = ReflectionUtils.findField(obj.getClass(), "id");
        if (field == null) {
            return null;
            return mapValues;
        }
        ReflectionUtils.makeAccessible(field);
        Object value = ReflectionUtils.getField(field, obj);
        mapValues.put("userId", value == null ? null : Long.valueOf(value.toString()));
        return value == null ? null : Long.valueOf(value.toString());
        Field fieldType = ReflectionUtils.findField(obj.getClass(), "balanceChangeType");
        if (fieldType == null) {
            return mapValues;
        }
        ReflectionUtils.makeAccessible(fieldType);
        Object valueType = ReflectionUtils.getField(fieldType, obj);
        mapValues.put("balanceChangeType", valueType == null ? null : Long.valueOf(valueType.toString()));
        return mapValues;
    }
}
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/CharteredCar/server/impl/OrderCharteredCarServiceImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.CharteredCar.dao.OrderCharteredCarMapper;
import com.stylefeng.guns.modular.CharteredCar.model.OrderCharteredCar;
@@ -241,7 +242,7 @@
            if(userInfo.getBalance() == null || userInfo.getBalance() < money){
                return ResultUtil.error("余额不足,无法完成支付");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
//            OpenCity openCity = openCityService.openCity1(orderCharteredCar.getStartLon().toString(), orderCharteredCar.getStartLat().toString());
//            SysIntegral query1 = sysIntegralService.selectOne(new EntityWrapper<SysIntegral>().eq("openCityId", openCity.getId()));
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/call/server/impl/OrderCallServiceImpl.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.modular.account.controller.AppOrderController;
import com.stylefeng.guns.modular.call.dao.OrderCallMapper;
import com.stylefeng.guns.modular.call.model.OrderCall;
@@ -84,7 +85,7 @@
//            if(resultUtil.getCode()==500){
//                return ResultUtil.error("电子余额不足,无法完成支付");
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
    
            OpenCity openCity = openCityService.openCity1(orderCall.getStartLon().toString(), orderCall.getStartLat().toString());
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/OrderCrossCityServiceImpl.java
@@ -5,6 +5,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.controller.AppOrderController;
import com.stylefeng.guns.modular.crossCity.dao.*;
@@ -839,7 +840,7 @@
            if (userInfo.getBalance() == null || userInfo.getBalance() < orderMoney) {
                return ResultUtil.error("余额不足,无法完成支付", "");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            OpenCity openCity = openCityService.openCity1(orderCrossCity.getStartLon().toString(), orderCrossCity.getStartLat().toString());
            SysIntegral query1 = sysIntegralMapper.query(openCity.getId());
@@ -1091,7 +1092,7 @@
            if (userInfo.getBalance() == null || userInfo.getBalance() < orderMoney) {
                return ResultUtil.error("余额不足,无法完成支付");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            OpenCity openCity = openCityService.openCity1(orderCrossCity.getStartLon().toString(), orderCrossCity.getStartLat().toString());
            SysIntegral query1 = sysIntegralMapper.query(openCity.getId());
@@ -1716,7 +1717,7 @@
//                if(resultUtil.getCode()==500){
//                    return ResultUtil.error("电子余额不足,无法完成支付");
//                }
                userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
                userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(query.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                //添加交易明细
                transactionDetailsService.saveData(uid, "跨城出行取消订单", query.getMoney(), 2, 1, 1, 3, id);
@@ -2108,6 +2109,7 @@
            }
            
            if (orderCrossCity.getPayType() == 3) {//余额支付
                userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                userInfo.setBalance(userInfo.getBalance() + orderCrossCity.getPayMoney());
                userInfoService.updateById(userInfo);
                //添加交易明细
@@ -2143,6 +2145,7 @@
                    transactionDetailsService.saveData(orderCrossCity.getUserId(), "跨城出行取消退款", query.getAmount(), 1, 1, 1, 3, id);
                } else if (query.getPayType() == 4) { // 云闪付
                    // TODO 退款
                    userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                    userInfo.setBalance(userInfo.getBalance() + orderCrossCity.getPayMoney());
                    userInfoService.updateById(userInfo);
                    //添加交易明细
@@ -2786,6 +2789,7 @@
//            if(resultUtil.getCode()==500){
//                return ResultUtil.error("电子余额不足,无法完成支付");
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            
            OpenCity openCity = openCityService.openCity1(orderCrossCity.getStartLon().toString(), orderCrossCity.getStartLat().toString());
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/PayInfoController.java
@@ -1,5 +1,6 @@
package com.stylefeng.guns.modular.shunfeng.controller;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.shunfeng.model.OrderRide;
import com.stylefeng.guns.modular.shunfeng.model.vo.ApiJson;
@@ -118,6 +119,7 @@
            systemNoticeService.addSystemNotice(1, "您成功支付从" + orderRide.getStartName() + "到" + orderRide.getEndName() + "的顺风车订单",
                    orderRide.getUserId(), 1);
            /*修改用户余额*/
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(userInfo.getBalance() - money);
            userInfoService.updateById(userInfo);
        } catch (Exception e) {
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/rideCommentController.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.shunfeng.model.*;
import com.stylefeng.guns.modular.shunfeng.model.vo.ApiJson;
@@ -892,6 +893,7 @@
            String finNum=OrdersUtil.getOrderNoForPrefix("fin");
            //todo 退款金额大于0需要退款
            if(orderRide.getPayType()==1){//余额
                userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                userInfo.setBalance(userInfo.getBalance()+orderRide.getTuiMoney());
                userInfoService.updateById(userInfo);
            }else if(orderRide.getPayType()==2){
@@ -1003,6 +1005,7 @@
                UserInfo userInfo=userInfoService.selectOne(new EntityWrapper<UserInfo>().eq("driverId",orderTravel.getDriverId()));
                if(userInfo!=null){
                    //用户余额可以为负数
                    userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
                    userInfo.setBalance(userInfo.getBalance()-orderTravel.getServiceMoney());
                    userInfoService.updateById(userInfo);
                }
@@ -1113,7 +1116,7 @@
                    driverRide.setTotalOrders(driverRide.getTotalOrders()+1);
                    driverRideService.updateById(driverRide);
                    /*修改用户接单数和司机提成*/
                    userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                    userInfo.setBalance(userInfo.getBalance()+(orderRide.getMoney()-orderRide.getPlatformMoney()));
                    userInfo.setTotalOrders(userInfo.getTotalOrders() + 1);
                    userInfoService.updateById(userInfo);
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -5,6 +5,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.controller.AppOrderController;
import com.stylefeng.guns.modular.crossCity.dao.OrderCrossCityMapper;
@@ -671,7 +672,7 @@
            if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){
                return ResultUtil.error("余额不足,无法完成支付", "");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
    
            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
@@ -801,6 +802,7 @@
//                    return ResultUtil.error("电子余额不足,无法完成支付");
//                }
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
    
            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
@@ -896,7 +898,7 @@
//            if(resultUtil.getCode()==500){
//                return ResultUtil.error("电子余额不足,无法完成支付");
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
    
            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
@@ -1189,6 +1191,7 @@
        if(null != orderLogistics.getPayType() && null != orderLogistics.getPayMoney()) {//已支付
            if(orderLogistics.getPayType() == 3){//余额支付
                UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
                userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                userInfo.setBalance(userInfo.getBalance() + orderLogistics.getPayMoney());
                userInfoService.updateById(userInfo);
                appOrderController.createAllocationReqUser(1, orderLogistics.getUserId(), 1,orderLogistics.getPayMoney());
@@ -1211,6 +1214,7 @@
                }
                if(query.getPayType()==4){
                    UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
                    userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                    userInfo.setBalance(userInfo.getBalance() + orderLogistics.getPayMoney());
                    userInfoService.updateById(userInfo);
                    appOrderController.createAllocationReqUser(1, orderLogistics.getUserId(), 1,orderLogistics.getPayMoney());
@@ -1656,7 +1660,7 @@
//            if(resultUtil.getCode()==500){
//                return ResultUtil.error("电子余额不足,无法完成支付");
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
    
            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -5,6 +5,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.controller.AppOrderController;
import com.stylefeng.guns.modular.crossCity.dao.OrderCrossCityMapper;
@@ -1348,6 +1349,7 @@
//                if(resultUtil.getCode()==500){
//                    return ResultUtil.error("电子余额不足,无法完成支付");
//                }
                userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
                userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(query.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                //添加交易明细
                transactionDetailsService.saveData(uid, "快车取消订单", query.getMoney(), 2, 1, 1, 1, id);
@@ -2126,7 +2128,7 @@
            if (userInfo.getBalance() == null || userInfo.getBalance() < orderMoney) {
                return ResultUtil.error("余额不足,无法完成支付", "");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            
            boolean isPrepayFirstStage = isPrivateCarPrepayFirstStage(orderPrivateCar);
@@ -2441,7 +2443,7 @@
            if (userInfo.getBalance() == null || userInfo.getBalance() < orderMoney) {
                return ResultUtil.error("余额不足,无法完成支付");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            boolean isPrepayFirstStage = isPrivateCarPrepayFirstStage(orderPrivateCar);
@@ -2843,6 +2845,7 @@
    private ResultUtil refundPrivateCarPrepayDifference(OrderPrivateCar orderPrivateCar, UserInfo userInfo, Double refundAmount) throws Exception {
        if (Integer.valueOf(3).equals(orderPrivateCar.getPayType())) {
            userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
            userInfo.setBalance(new BigDecimal(null != userInfo.getBalance() ? userInfo.getBalance() : 0D)
                    .add(toMoney(refundAmount)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            userInfoService.updateById(userInfo);
@@ -3035,6 +3038,7 @@
            if (userInfo == null) {
                throw new RuntimeException("用户信息不存在,无法退款");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
            userInfo.setBalance(new BigDecimal(null != userInfo.getBalance() ? userInfo.getBalance() : 0)
                    .add(new BigDecimal(refundAmount)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            userInfoService.updateById(userInfo);
@@ -3086,6 +3090,7 @@
            if (userInfo == null) {
                return ResultUtil.error("用户信息不存在,无法退款");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
            userInfo.setBalance(new BigDecimal(null != userInfo.getBalance() ? userInfo.getBalance() : 0)
                    .add(new BigDecimal(refundAmount)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            userInfoService.updateById(userInfo);
@@ -3411,6 +3416,7 @@
//            if(resultUtil.getCode()==500){
//                return ResultUtil.error("电子余额不足,无法完成支付");
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            
            OpenCity openCity = openCityService.openCity1(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString());
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserInfoMapper.xml
@@ -200,7 +200,7 @@
    </select>
    <select id="insertBalanceModifyRecord">
        insert into t_balance_modify_record (recordID, userId, userName, phone, money, type, createTime)
        values (#{recordVo.recordID}, #{recordVo.userId}, #{recordVo.userName}, #{recordVo.phone}, #{recordVo.money}, #{recordVo.type}, #{recordVo.createTime})
        insert into t_balance_modify_record (recordID, userId, userName, phone, money, type, createTime, balanceChangeType)
        values (#{recordVo.recordID}, #{recordVo.userId}, #{recordVo.userName}, #{recordVo.phone}, #{recordVo.money}, #{recordVo.type}, #{recordVo.createTime}, #{recordVo.balanceChangeType})
    </select>
</mapper>
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/UserInfo.java
@@ -164,6 +164,13 @@
    @TableField("onconUUID")
    private String onconUUID;
    /**
     * 账户余额变更类型(非数据库字段)
     * 1、充值,2消费、3退款、4出行卡兑换
     * {@link com.stylefeng.guns.core.common.constant.state.BalanceChangeType}
     */
    @TableField(exist = false)
    private Integer balanceChangeType;
    private Date bindDate;
@@ -425,6 +432,14 @@
        this.totalOrders = totalOrders;
    }
    public Integer getBalanceChangeType() {
        return balanceChangeType;
    }
    public void setBalanceChangeType(Integer balanceChangeType) {
        this.balanceChangeType = balanceChangeType;
    }
    @Override
    public String toString() {
        return "UserInfo{" +
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/vo/BalanceModifyRecordVo.java
@@ -5,6 +5,8 @@
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
/**
@@ -54,6 +56,13 @@
     */
    private BigDecimal money;
    /**
     * 变更类型
     * 1、充值,2消费、3退款、4出行卡兑换
     * {@link com.stylefeng.guns.core.common.constant.state.BalanceChangeType}
     */
    private Integer balanceChangeType;
    public static BalanceModifyRecordVo convert(UserInfo oldUser, UserInfo newUser) {
        Random random = new Random();
        StringBuilder result = new StringBuilder();
@@ -66,19 +75,29 @@
        recordVo.setPhone(newUser.getPhone());
        recordVo.setUserId(newUser.getId());
        recordVo.setCreateTime(new Date());
        if(Objects.nonNull(newUser.getBalanceChangeType())) {
            recordVo.setBalanceChangeType(newUser.getBalanceChangeType());
        }
        BigDecimal newBalance = newUser.getBalance() != null ? BigDecimal.valueOf(newUser.getBalance()) : BigDecimal.ZERO;
        BigDecimal oldBalance = oldUser.getBalance() != null ? BigDecimal.valueOf(oldUser.getBalance()) : BigDecimal.ZERO;
        BigDecimal amount = newBalance.subtract(oldBalance);
        // 判断方向
        if (amount.compareTo(BigDecimal.ZERO) == 0){
        if (amount.compareTo(BigDecimal.ZERO) == 0){ // 余额没变动
            return null;
        } else if (amount.compareTo(BigDecimal.ZERO) > 0) {
            recordVo.setType(1); // 增加金额(充值)
            recordVo.setMoney(amount);
            if(Objects.isNull(recordVo.getBalanceChangeType())) {
                recordVo.setBalanceChangeType(1);
            }
        } else {
            recordVo.setType(2);  // 减少金额,转为正数(消费)
            recordVo.setMoney(amount.abs());
            if(Objects.isNull(recordVo.getBalanceChangeType())) {
                recordVo.setBalanceChangeType(2);
            }
        }
        return recordVo;
    }
}
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/vo/BalanceRecordVo.java
@@ -1,5 +1,6 @@
package com.stylefeng.guns.modular.system.model.vo;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -53,14 +54,15 @@
        recordVo.setType(modifyRecordVo.getType());
        recordVo.setPayTime(modifyRecordVo.getCreateTime());
        recordVo.setMoney(modifyRecordVo.getMoney());
        if(Objects.nonNull(modifyRecordVo.getType())) {
        if(Objects.nonNull(modifyRecordVo.getBalanceChangeType())) {
            recordVo.setTypeDesc(BalanceChangeType.convertMessage(modifyRecordVo.getBalanceChangeType()));
        } else {
            if(modifyRecordVo.getType() == 1) {
                recordVo.setTypeDesc("充值");
            } else if(modifyRecordVo.getType() == 2) {
                recordVo.setTypeDesc("消费");
            }
        }
        return recordVo;
    }
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TaxiCardServiceImpl.java
@@ -5,6 +5,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.controller.AppOrderController;
import com.stylefeng.guns.modular.system.dao.TaxiCardMapper;
@@ -381,6 +382,7 @@
//            if(resultUtil.getCode()==500){
//                return ResultUtil.error("电子余额不足,无法完成支付");
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(taxiCard.getSellingPrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            //添加交易明细
            transactionDetailsService.saveData(uid, "购买出行卡", taxiCard.getSellingPrice(), 2, 1, 1, 6, taxiCardPayment.getId());
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TravelCardServiceImpl.java
@@ -2,6 +2,7 @@
import com.aliyun.oss.ServiceException;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.modular.system.dao.TravelCardMapper;
import com.stylefeng.guns.modular.system.model.TravelCard;
import com.stylefeng.guns.modular.system.model.UserInfo;
@@ -53,6 +54,7 @@
        }
        if(Objects.nonNull(travelCard.getAmount())) {
            double newBalance = new BigDecimal(String.valueOf(userInfo.getBalance())).add(travelCard.getAmount()).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
            userInfo.setBalanceChangeType(BalanceChangeType.EXCHANGE.getCode());
            userInfo.setBalance(newBalance);
            userInfoService.updateById(userInfo);
            travelCard.setStatus(2); // 已充值
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserInfoServiceImpl.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.JwtConstants;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.GetMobile;
import com.stylefeng.guns.core.util.JwtTokenUtil;
@@ -1031,6 +1032,7 @@
                transactionDetailsService.saveData(Integer.valueOf(id), "余额充值", query.getAmount(), 1, 1, 1, 5, null);
                double v = new BigDecimal(userInfo.getBalance()).add(new BigDecimal(query.getAmount())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
                System.out.println("余额:" + v);
                userInfo.setBalanceChangeType(BalanceChangeType.RECHARGE.getCode());
                userInfo.setBalance(v);
                this.updateById(userInfo);
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/WithdrawalServiceImpl.java
@@ -1,6 +1,7 @@
package com.stylefeng.guns.modular.system.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.modular.system.dao.WithdrawalMapper;
import com.stylefeng.guns.modular.system.model.UserInfo;
import com.stylefeng.guns.modular.system.model.Withdrawal;
@@ -72,6 +73,7 @@
        this.insert(withdrawal);
        double v = new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(withdrawal.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
        userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
        userInfo.setBalance(v);
        userInfoService.updateById(userInfo);
        return ResultUtil.success();
@@ -123,6 +125,7 @@
                            timer.cancel();
                        }else{
                            UserInfo userInfo = userInfoService.selectById(withdrawal.getUserId());
                            userInfo.setBalanceChangeType(BalanceChangeType.RECHARGE.getCode());
                            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).add(new BigDecimal(withdrawal.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                            userInfoService.updateById(userInfo);
                            withdrawal.setState(3);
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -6,6 +6,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.controller.AppOrderController;
import com.stylefeng.guns.modular.crossCity.dao.OrderCrossCityMapper;
@@ -699,7 +700,7 @@
//                if(resultUtil.getCode()==500){
//                    return ResultUtil.error("电子余额不足,无法完成支付");
//                }
                userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
                userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(query.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                //添加交易明细
                transactionDetailsService.saveData(uid, "出租车取消订单", query.getMoney(), 2, 1, 1, 2, id);
@@ -1379,7 +1380,7 @@
            if (userInfo.getBalance() == null || userInfo.getBalance() < orderMoney) {
                return ResultUtil.error("余额不足,无法完成支付", "");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            boolean isPrepayFirstStage = isTaxiPrepayFirstStage(orderTaxi);
@@ -1658,7 +1659,7 @@
//                    return ResultUtil.error("电子余额不足,无法完成支付");
//                }
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            boolean isPrepayFirstStage = isTaxiPrepayFirstStage(orderTaxi);
@@ -2305,6 +2306,7 @@
    private ResultUtil refundTaxiPrepayDifference(OrderTaxi orderTaxi, UserInfo userInfo, Double refundAmount) throws Exception {
        if (Integer.valueOf(3).equals(orderTaxi.getPayType())) {
            userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
            userInfo.setBalance(new BigDecimal(null != userInfo.getBalance() ? userInfo.getBalance() : 0D)
                    .add(toMoney(refundAmount)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            userInfoService.updateById(userInfo);
@@ -2490,6 +2492,7 @@
            if (userInfo == null) {
                throw new RuntimeException("用户信息不存在,无法退款");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
            userInfo.setBalance(new BigDecimal(null != userInfo.getBalance() ? userInfo.getBalance() : 0)
                    .add(new BigDecimal(refundAmount)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            userInfoService.updateById(userInfo);
@@ -2542,6 +2545,7 @@
            if (userInfo == null) {
                return ResultUtil.error("用户信息不存在,无法退款");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
            userInfo.setBalance(new BigDecimal(null != userInfo.getBalance() ? userInfo.getBalance() : 0)
                    .add(new BigDecimal(refundAmount)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            userInfoService.updateById(userInfo);
@@ -3126,6 +3130,7 @@
//            if(resultUtil.getCode()==500){
//                return ResultUtil.error("电子余额不足,无法完成支付");
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            
            OpenCity openCity = openCityService.openCity1(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString());