| New file |
| | |
| | | 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 ""; |
| | | } |
| | | } |
| | |
| | | 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.*; |
| | | |
| | | /** |
| | | * 用户余额变更拦截器 |
| | |
| | | } |
| | | |
| | | // 关键:先执行前查旧值(需要拿 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)) { |
| | |
| | | /** |
| | | * 获取用户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"); |
| | |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | 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); |
| | |
| | | </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> |
| | |
| | | @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; |
| | | } |
| | |
| | | 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{" + |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | |
| | | */ |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | 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); |
| | | |
| | |
| | | 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; |
| | |
| | | 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); |
| New file |
| | |
| | | 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 ""; |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | 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++) { |
| | |
| | | */ |
| | | private Integer type; |
| | | |
| | | /** |
| | | * 变更类型 |
| | | * 1、充值,2消费、3退款、4出行卡兑换 |
| | | * {@link com.stylefeng.guns.core.common.constant.state.BalanceChangeType} |
| | | */ |
| | | private Integer balanceChangeType; |
| | | |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | |
| | | return this.id; |
| | | } |
| | | |
| | | public Integer getBalanceChangeType() { |
| | | return balanceChangeType; |
| | | } |
| | | |
| | | public void setBalanceChangeType(Integer balanceChangeType) { |
| | | this.balanceChangeType = balanceChangeType; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "TBalanceModifyRecord{" + |
| New file |
| | |
| | | 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 ""; |
| | | } |
| | | } |
| | |
| | | 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.*; |
| | | |
| | | /** |
| | | * 用户余额变更拦截器 |
| | |
| | | } |
| | | |
| | | // 关键:先执行前查旧值(需要拿 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)) { |
| | |
| | | /** |
| | | * 获取用户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"); |
| | |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | 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; |
| | |
| | | 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())); |
| | |
| | | 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; |
| | |
| | | // 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()); |
| | |
| | | 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.*; |
| | |
| | | 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()); |
| | |
| | | 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()); |
| | |
| | | // 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); |
| | |
| | | } |
| | | |
| | | if (orderCrossCity.getPayType() == 3) {//余额支付 |
| | | userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode()); |
| | | userInfo.setBalance(userInfo.getBalance() + orderCrossCity.getPayMoney()); |
| | | userInfoService.updateById(userInfo); |
| | | //添加交易明细 |
| | |
| | | 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); |
| | | //添加交易明细 |
| | |
| | | // 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()); |
| | |
| | | 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; |
| | |
| | | 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) { |
| | |
| | | |
| | | 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; |
| | |
| | | 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){ |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | 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()); |
| | |
| | | // 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()); |
| | |
| | | // 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()); |
| | |
| | | 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()); |
| | |
| | | } |
| | | 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()); |
| | |
| | | // 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()); |
| | |
| | | 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; |
| | |
| | | // 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); |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | // 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()); |
| | |
| | | </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> |
| | |
| | | @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; |
| | | |
| | |
| | | this.totalOrders = totalOrders; |
| | | } |
| | | |
| | | public Integer getBalanceChangeType() { |
| | | return balanceChangeType; |
| | | } |
| | | |
| | | public void setBalanceChangeType(Integer balanceChangeType) { |
| | | this.balanceChangeType = balanceChangeType; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "UserInfo{" + |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | |
| | | */ |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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; |
| | |
| | | // 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()); |
| | |
| | | |
| | | 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; |
| | |
| | | } |
| | | 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); // 已充值 |
| | |
| | | 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; |
| | |
| | | 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); |
| | | |
| | |
| | | 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; |
| | |
| | | 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(); |
| | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | // 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); |
| | |
| | | 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); |
| | |
| | | // 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); |
| | |
| | | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | // 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()); |