提现列表

查询提现渠道列表
调整生成账变记录方法
This commit is contained in:
邱贞招 2024-10-13 20:59:57 +08:00
parent 2c221178d5
commit b46a7b875e
21 changed files with 417 additions and 156 deletions

View File

@ -19,6 +19,8 @@ import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.system.domain.agent.RlAgentVO;
import com.ruoyi.system.domain.changeBalance.RlChangeBalance;
import com.ruoyi.system.domain.changeBalance.RlChangeBalanceQuery;
import com.ruoyi.system.domain.channelWithdraw.ChannelWithdrawQuery;
import com.ruoyi.system.domain.channelWithdraw.ChannelWithdrawVO;
import com.ruoyi.system.domain.deliveryOrder.RlDeliveryOrderVO;
import com.ruoyi.system.domain.device.RlDeviceQuery;
import com.ruoyi.system.domain.device.RlDeviceVO;
@ -90,6 +92,9 @@ public class AppAdminController extends BaseController
@Resource
private IRlAgentService rlAgentService;
@Autowired
private RlChannelWithdrawService etChannelWithdrawService;
/**
* 首页统计
*/
@ -278,6 +283,16 @@ public class AppAdminController extends BaseController
return toAjax(i);
}
/**
* 查询提现渠道列表
*/
@GetMapping("/withdrawList")
public AjaxResult withdrawList(ChannelWithdrawQuery query)
{
List<ChannelWithdrawVO> list = etChannelWithdrawService.selectChannelWithdrawList(query);
return success(list);
}
/**
* 获取商户详细信息
*/

View File

@ -1,20 +1,31 @@
package com.ruoyi.web.controller.rl;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.RlUser;
import com.ruoyi.common.core.domain.entity.RlUserVO;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.agent.RlAgentVO;
import com.ruoyi.system.domain.userExt.RlUserExt;
import com.ruoyi.system.domain.vo.RlUserQuery;
import com.ruoyi.system.service.IRlAgentService;
import com.ruoyi.system.service.IRlUserExtService;
import com.ruoyi.system.service.IRlUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;
/**
@ -27,7 +38,16 @@ import java.util.List;
public class RlUserController extends BaseController
{
@Resource
private IRlUserService eUserService;
private IRlUserService userService;
@Autowired
private TransactionTemplate transactionTemplate;
@Autowired
private IRlUserExtService userExtService;
@Autowired
private IRlAgentService agentService;
/**
* 获取用户列表
@ -36,7 +56,7 @@ public class RlUserController extends BaseController
public TableDataInfo list(RlUserQuery rlUser)
{
startPage();
List<RlUserVO> list = eUserService.selectUserList(rlUser);
List<RlUserVO> list = userService.selectUserList(rlUser);
return getDataTable(list);
}
@ -78,58 +98,101 @@ public class RlUserController extends BaseController
AjaxResult ajax = AjaxResult.success();
if (StringUtils.isNotNull(userId))
{
RlUser rlUser = eUserService.selectUserById(userId);
RlUser rlUser = userService.selectUserById(userId);
ajax.put(AjaxResult.DATA_TAG, rlUser);
}
return ajax;
}
// /**
// * 新增用户
// */
// @Log(title = "用户管理", businessType = BusinessType.INSERT)
// @PostMapping
// public AjaxResult add(@Validated @RequestBody EUser user)
// {
// if (!eUserService.checkUserNameUnique(user))
// {
// return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
// }
// else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !eUserService.checkPhoneUnique(user))
// {
// return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
// }
// else if (StringUtils.isNotEmpty(user.getEmail()) && !eUserService.checkEmailUnique(user))
// {
// return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
// }
// user.setCreateBy(getUsername());
// user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
// return toAjax(eUserService.insertUser(user));
// }
//
// /**
// * 修改用户
// */
// @Log(title = "用户管理", businessType = BusinessType.UPDATE)
// @PutMapping
// public AjaxResult edit(@Validated @RequestBody EUser user)
// {
// if (!eUserService.checkUserNameUnique(user))
// {
// return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
// }
// else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !eUserService.checkPhoneUnique(user))
// {
// return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
// }
// else if (StringUtils.isNotEmpty(user.getEmail()) && !eUserService.checkEmailUnique(user))
// {
// return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
// }
// user.setUpdateBy(getUsername());
// return toAjax(eUserService.updateUser(user));
// }
/**
* 新增商户
*/
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody RlUserQuery user)
{
if (!userService.checkUserNameUnique(user))
{
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
{
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
{
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setCreateBy(getUsername());
user.setUserType(ServiceConstants.USER_TYPE_MERCHANT);
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
Boolean execute = transactionTemplate.execute(e -> {
int i = userService.insertUser(user);
if(i == 0){
throw new ServiceException("【新增用户】失败");
}
/** 新增用户扩展表 */
saveUserExt(user);
return Boolean.TRUE;
});
if(!execute)throw new ServiceException("【新增商户】失败");
return toAjax(1);
}
private void saveUserExt(RlUserQuery user) {
RlUserExt userExt = new RlUserExt();
userExt.setUserId(user.getUserId());
userExt.setDividendProportion(user.getDividendProportion().divide(BigDecimal.valueOf(100)));
userExt.setCooperationTime(user.getCooperationTime());
userExt.setDividendStatus(user.getDividendStatus());
userExt.setHandlingChargeType(user.getHandlingChargeType());
userExt.setWithdrawHandlingCharge(user.getWithdrawHandlingCharge());
RlAgentVO agentVO = agentService.selectRlAgentByCityId(user.getCityId());
userExt.setAgentId(agentVO.getAgentId());
int i1 = userExtService.insertRlUserExt(userExt);
if(i1 == 0){
throw new ServiceException("【新增用户扩展表】失败");
}
}
/**
* 修改用户
*/
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody RlUserQuery user)
{
if (!userService.checkUserNameUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(getUsername());
user.setUserType(ServiceConstants.USER_TYPE_MERCHANT);
Boolean execute = transactionTemplate.execute(e -> {
int i = userService.updateUser(user);
if(i == 0){
throw new ServiceException("【修改商户】失败");
}
int i3 = userExtService.deleteRlUserExtByUserId(user.getUserId());
if(i3 == 0){
throw new ServiceException("【删除用户扩展表】失败");
}else{
/** 修改用户扩展表 */
saveUserExt(user);
}
return Boolean.TRUE;
});
if(!execute)throw new ServiceException("【修改商户】失败");
return toAjax(1);
}
// /**
@ -176,7 +239,7 @@ public class RlUserController extends BaseController
public AjaxResult changeStatus(@RequestBody RlUser user)
{
user.setUpdateBy(getUsername());
return toAjax(eUserService.updateUserStatus(user));
return toAjax(userService.updateUserStatus(user));
}

View File

@ -747,31 +747,19 @@ public class ServiceConstants {
/**----------------------------业务类型start----------------------------*/
/** 业务类型1-骑行订单2-押金订单3-押金订单退款4-骑行订单退款包含调度费、停车点外调度费5-提现6-提现失败7-车损收入8-短信扣费 */
/** 业务类型1-骑行订单 */
/** 业务类型1-订单收入2-续租订单收入4-订单退款5-提现6-提现失败8-短信扣费 */
/** 业务类型1-订单收入 */
public static final String RIDE_ORDER = "1";
/** 业务类型2-押金订单 */
public static final String DEPOSIT_ORDER = "2";
/** 业务类型3-押金订单退款 */
public static final String DEPOSIT_REFUND_ORDER = "3";
/** 业务类型4-骑行订单退款(包含调度费、停车点外调度费) */
public static final String RIDE_REFUND_ORDER = "4";
/** 业务类型5-提现 */
/** 续租订单收入 */
public static final String RENEW_ORDER = "2";
/** 订单退款 */
public static final String ORDER_REFUND = "4";
/** 提现 */
public static final String WITHDRAWAL = "5";
/** 业务类型6-提现失败 */
public static final String WITHDRAWAL_FAILURE = "6";
/** 业务类型7-车损收入 */
public static final String CAR_DAMAGE_INCOME = "7";
/** 业务类型8-短信扣费 */
public static final String SMS_FEE_DEDUCTION = "8";
/** 提现失败 */
public static final String WITHDRAWAL_FAILED = "6";
/** 短信扣费 */
public static final String SMS_DEDUCTION = "8";
/**----------------------------业务类型end----------------------------*/
/**----------------------------用户类型start----------------------------*/

View File

@ -4,7 +4,6 @@ import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
public class RlUserVO extends RlUser{
@ -18,6 +17,9 @@ public class RlUserVO extends RlUser{
/** 店铺名称 */
private String storeName;
/** 城市名称 */
private String cityName;
/** 扩展id */
private Long extId;

View File

@ -5,7 +5,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 短信日志对象 et_msg_log
* 短信日志对象 rl_msg_log
*
* @author qiuzhenzhen
* @date 2024-07-24

View File

@ -25,17 +25,13 @@ public class ChannelWithdraw extends BaseEntity
@ApiModelProperty("渠道名称")
private String name;
@Excel(name = "对应账户类型")
@ApiModelProperty("对应账户类型")
private String accountType;
@Excel(name = "服务费收取类型")
@ApiModelProperty("服务费收取类型")
private String serviceType;
private String handlingChargeType;
@Excel(name = "服务费")
@ApiModelProperty("服务费")
private BigDecimal serviceRate;
private BigDecimal withdrawHandlingCharge;
@Excel(name = "是否启用")
@ApiModelProperty("是否启用")

View File

@ -3,6 +3,7 @@ package com.ruoyi.system.domain.userExt;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
@ -50,4 +51,10 @@ public class RlUserExt extends BaseEntity
/** 代理商id */
private Long agentId;
/** 提现手续费类型1-按比例2-按每笔 */
private String handlingChargeType;
/** 服务费 */
private BigDecimal withdrawHandlingCharge;
}

View File

@ -3,10 +3,31 @@ package com.ruoyi.system.domain.vo;
import com.ruoyi.common.core.domain.entity.RlUser;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class RlUserQuery extends RlUser {
private String[] typeList;
private Long agentId;
/** 城市id */
private Long cityId;
/** 分红比例:百分比 */
private BigDecimal dividendProportion;
/** 合作时间 */
private Date cooperationTime;
/** 分账状态 */
private Boolean dividendStatus;
/** 服务费收取类型 */
private String handlingChargeType;
/** 服务费 */
private BigDecimal withdrawHandlingCharge;
}

View File

@ -58,8 +58,14 @@ public class RlWithdraw extends BaseEntity
@Excel(name = "成本")
private BigDecimal cost;
/** 打款方式 */
@Excel(name = "打款方式")
private String paymentMethod;
/** 提现渠道id */
@Excel(name = "提现渠道id")
private Long withdrawChannelId;
/** 提现手续费类型1-按比例2-按每笔 */
private String handlingChargeType;
/** 服务费 */
private BigDecimal withdrawHandlingCharge;
}

View File

@ -67,4 +67,12 @@ public interface RlUserExtMapper
* @return 结果
*/
public int deleteRlUserExtByExtIds(Long[] extIds);
/**
* 根据userId删除用户扩展信息
*
* @param userId 用户id
* @return 结果
*/
int deleteRlUserExtByUserId(Long userId);
}

View File

@ -2,7 +2,9 @@ package com.ruoyi.system.service;
import com.ruoyi.system.domain.changeBalance.RlChangeBalance;
import com.ruoyi.system.domain.changeBalance.RlChangeBalanceQuery;
import com.ruoyi.system.domain.order.RlOrder;
import java.math.BigDecimal;
import java.util.List;
/**
@ -69,4 +71,19 @@ public interface IRlChangeBalanceService
* @return 结果
*/
public int deleteRlChangeBalanceByChangeId(Long changeId);
/**
* 根据订单信息生成账变记录
*
* @param orderNo 订单号
* @param outTradeNo 第三方流水号
* @param type 收支类型1-收入2-支出
* @param busType 业务类型
* @param payFee 支付金额
* @param userId 用户id
* @param userName 用户名称
* @param phone 用户电话
* @return 结果
*/
public int generateChanggeBalance(String orderNo, String outTradeNo, String type, String busType, BigDecimal payFee, Long userId, String userName, String phone);
}

View File

@ -67,4 +67,12 @@ public interface IRlUserExtService
* @return 结果
*/
public int deleteRlUserExtByExtId(Long extId);
/**
* 删除用户扩展信息
*
* @param userId 用户扩展主键
* @return 结果
*/
public int deleteRlUserExtByUserId(Long userId);
}

View File

@ -137,7 +137,8 @@ public class CallbackServiceImpl implements CallbackService {
Boolean execute = transactionTemplate.execute(e -> {
/** 生成账变记录*/
generateChanggeBalance(originalOrder);
changeBalanceService.generateChanggeBalance(originalOrder.getOrderNo(), outTradeNo, ServiceConstants.FLOW_TYPE_INCOME,
ServiceConstants.RIDE_ORDER, originalOrder.getPayFee(), originalOrder.getUserId(), originalOrder.getUserName(), originalOrder.getPhone());
updateOrder.setPaid("1");
updateOrder.setPayTime(DateUtils.getNowDate());
updateOrder.setPayType(payType);
@ -243,26 +244,7 @@ public class CallbackServiceImpl implements CallbackService {
}
private void generateChanggeBalance(RlOrder order) {
RlChangeBalance rlChangeBalance = new RlChangeBalance();
rlChangeBalance.setOrderNo(order.getOrderNo());
rlChangeBalance.setOutTradeNo(order.getOutTradeNo());
rlChangeBalance.setType("1");
rlChangeBalance.setBusType(ServiceConstants.RIDE_ORDER);
BigDecimal balance = userService.selectUserBalanceById(order.getUserId());
rlChangeBalance.setBeforeBalance(balance);
rlChangeBalance.setAfterBalance(balance.add(order.getPayFee()));
rlChangeBalance.setAmount(order.getPayFee());
rlChangeBalance.setOwnerId(order.getUserId());
rlChangeBalance.setOwnerName(order.getUserName());
rlChangeBalance.setOwnerPhone(order.getPhone());
rlChangeBalance.setCreateTime(DateUtils.getNowDate());
rlChangeBalance.setReason("租赁订单:"+ order.getOrderNo());
int i = changeBalanceService.insertRlChangeBalance(rlChangeBalance);
if(i>0){
logger.info("【微信支付回调】账变记录插入成功");
}
}
private BigDecimal getCost(ChannelVO channel,BigDecimal payFee) {
// 获取到渠道成本

View File

@ -5,9 +5,12 @@ import com.ruoyi.system.domain.changeBalance.RlChangeBalance;
import com.ruoyi.system.domain.changeBalance.RlChangeBalanceQuery;
import com.ruoyi.system.mapper.RlChangeBalanceMapper;
import com.ruoyi.system.service.IRlChangeBalanceService;
import com.ruoyi.system.service.IRlUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
/**
@ -19,9 +22,12 @@ import java.util.List;
@Service
public class RlChangeBalanceServiceImpl implements IRlChangeBalanceService
{
@Autowired
@Resource
private RlChangeBalanceMapper rlChangeBalanceMapper;
@Autowired
private IRlUserService userService;
/**
* 查询余额变动
*
@ -107,4 +113,61 @@ public class RlChangeBalanceServiceImpl implements IRlChangeBalanceService
{
return rlChangeBalanceMapper.deleteRlChangeBalanceByChangeId(changeId);
}
/**
* 根据订单信息生成账变记录
*
* @param orderNo 订单号
* @param outTradeNo 第三方流水号
* @param type 收支类型1-收入2-支出
* @param busType 业务类型
* @param payFee 支付金额
* @param userId 用户id
* @param userName 用户名称
* @param phone 用户电话
* @return 结果
*/
@Override
public int generateChanggeBalance(String orderNo,String outTradeNo,String type,String busType,BigDecimal payFee,Long userId,String userName,String phone) {
RlChangeBalance rlChangeBalance = new RlChangeBalance();
rlChangeBalance.setOrderNo(orderNo);
rlChangeBalance.setOutTradeNo(outTradeNo);
rlChangeBalance.setType(type);
rlChangeBalance.setBusType(busType);
BigDecimal balance = userService.selectUserBalanceById(userId);
rlChangeBalance.setBeforeBalance(balance);
rlChangeBalance.setAfterBalance(balance.add(payFee));
rlChangeBalance.setAmount(payFee);
rlChangeBalance.setOwnerId(userId);
rlChangeBalance.setOwnerName(userName);
rlChangeBalance.setOwnerPhone(phone);
rlChangeBalance.setCreateTime(DateUtils.getNowDate());
// 根据 busType 生成不同的 reason 描述
String reason = "";
switch (busType) {
case "1":
reason = "订单收入:" + orderNo;
break;
case "2":
reason = "续租订单收入:" + orderNo;
break;
case "4":
reason = "订单退款:" + orderNo;
break;
case "5":
reason = "提现";
break;
case "6":
reason = "提现失败";
break;
case "8":
reason = "短信扣费";
break;
default:
reason = "未知业务类型";
break;
}
rlChangeBalance.setReason(reason);
return insertRlChangeBalance(rlChangeBalance);
}
}

View File

@ -102,4 +102,17 @@ public class RlUserExtServiceImpl implements IRlUserExtService
{
return rlUserExtMapper.deleteRlUserExtByExtId(extId);
}
/**
* 根据userId删除用户扩展信息
*
* @param userId 用户id
* @return 结果
*/
@Override
public int deleteRlUserExtByUserId(Long userId)
{
return rlUserExtMapper.deleteRlUserExtByUserId(userId);
}
}

View File

@ -7,6 +7,7 @@ import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.ChangeBalanceInterface;
import com.ruoyi.common.core.domain.entity.RlUser;
import com.ruoyi.common.core.domain.entity.RlUserVO;
@ -21,6 +22,7 @@ import com.ruoyi.system.domain.agent.RlAgentVO;
import com.ruoyi.system.domain.changeBalance.RlChangeBalance;
import com.ruoyi.system.domain.changeBalance.RlChangeBalanceQuery;
import com.ruoyi.system.domain.channel.ChannelVO;
import com.ruoyi.system.domain.channelWithdraw.ChannelWithdrawVO;
import com.ruoyi.system.domain.query.AuthenticationQuery;
import com.ruoyi.system.domain.userExt.RlUserExt;
import com.ruoyi.system.domain.vo.RlUserQuery;
@ -35,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Resource;
import javax.validation.Validator;
@ -87,6 +90,15 @@ public class RlUserServiceImpl implements IRlUserService{
@Autowired
private IRlMsgLogService msgLogService;
@Autowired
private RlChannelWithdrawService etChannelWithdrawService;
@Autowired
private TransactionTemplate transactionTemplate;
@Autowired
private IRlChangeBalanceService changeBalanceService;
@Value("${aliyun.accessKeyId}")
private String accessKeyId;
@ -622,7 +634,13 @@ public class RlUserServiceImpl implements IRlUserService{
@Override
public boolean checkUserNameUnique(RlUser user) {
return false;
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
RlUser info = rlUserMapper.checkUserNameUnique(user.getUserName());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
@Override
@ -632,12 +650,24 @@ public class RlUserServiceImpl implements IRlUserService{
@Override
public boolean checkPhoneUnique(RlUser user) {
return false;
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
RlUser info = rlUserMapper.checkPhoneUnique(user.getPhonenumber());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
@Override
public boolean checkEmailUnique(RlUser user) {
return false;
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
RlUser info = rlUserMapper.checkEmailUnique(user.getEmail());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
@Override
@ -723,11 +753,23 @@ public class RlUserServiceImpl implements IRlUserService{
/** 1. 获取当前用户*/
RlUser user = rlUserMapper.selectUserById(SecurityUtils.getUserId());
RlUserExt rlUserExt = userExtService.selectRlUserExtByUserId(user.getUserId());
RlAgentVO rlAgentVO = agentService.selectRlAgentByAgentId(rlUserExt.getAgentId());
ChannelVO channelVO = channelService.selectSmChannelByChannelId(rlAgentVO.getPayChannel());
// log.info();
/** 2. 记录提现记录*/
Boolean execute = transactionTemplate.execute(e -> {
/** 2. 记录提现记录*/
withdrawalRecord(withdraw, orderNo, user, rlUserExt);
/** 3. 扣余额,记录账变 */
int i = changeBalanceService.generateChanggeBalance(orderNo, null, ServiceConstants.FLOW_TYPE_DISBURSE,
ServiceConstants.WITHDRAWAL, withdraw.getAmount(), user.getUserId(), user.getUserName(), user.getPhonenumber());
if(i<=0)throw new ServiceException("【提现】记录账变失败");
// 发短信通知转账人
asynchronousMsg(user.getUserName());
return Boolean.TRUE;
});
if(!execute)throw new ServiceException("【提现】失败");
return 1;
}
private void withdrawalRecord(RlWithdrawQuery withdraw, String orderNo, RlUser user, RlUserExt rlUserExt) {
RlWithdraw rlWithdraw = new RlWithdraw();
rlWithdraw.setWithdrawNo(orderNo);
rlWithdraw.setCreateTime(DateUtils.getNowDate());
@ -736,16 +778,33 @@ public class RlUserServiceImpl implements IRlUserService{
rlWithdraw.setOwnerId(user.getUserId());
rlWithdraw.setOwnerName(user.getUserName());
rlWithdraw.setOwnerPhone(user.getPhonenumber());
// rlWithdraw.setHandlingCharge(new BigDecimal(0));手续费成本
rlWithdraw.setPaymentMethod(withdraw.getPaymentMethod());
ChannelWithdrawVO channelWithdrawVO = etChannelWithdrawService.selectChannelWithdrawByChannelId(withdraw.getWithdrawChannelId());
if(ObjectUtil.isNull(channelWithdrawVO)){
throw new ServiceException("提现渠道不存在");
}
BigDecimal cost;
if(channelWithdrawVO.getHandlingChargeType().equals(ServiceConstants.HANDLING_CHARGE_TYPE_PERCENT)){
cost = channelWithdrawVO.getCostRate().divide(new BigDecimal(100)).multiply(withdraw.getAmount()).setScale(2, RoundingMode.HALF_UP);
}else{
cost = channelWithdrawVO.getWithdrawHandlingCharge();
}
rlWithdraw.setCost(cost);
rlWithdraw.setWithdrawChannelId(withdraw.getWithdrawChannelId());
BigDecimal handlingCharge;
if(rlUserExt.getHandlingChargeType().equals(ServiceConstants.HANDLING_CHARGE_TYPE_PERCENT)){
BigDecimal handlingCharge1 = rlUserExt.getWithdrawHandlingCharge();// 5.4
BigDecimal bigDecimal = handlingCharge1.divide(new BigDecimal(100), 6, BigDecimal.ROUND_HALF_UP);// 0.0054
handlingCharge = bigDecimal.multiply(withdraw.getAmount()).setScale(2, RoundingMode.HALF_UP);// 0.0054 * 1000 = 0.54
}else{
handlingCharge = rlUserExt.getWithdrawHandlingCharge();
}
rlWithdraw.setHandlingCharge(handlingCharge);
rlWithdraw.setHandlingChargeType(rlUserExt.getHandlingChargeType());
rlWithdraw.setWithdrawHandlingCharge(rlUserExt.getWithdrawHandlingCharge());
int i = rlWithdrawService.insertRlWithdraw(rlWithdraw);
// 发短信通知转账人
asynchronousMsg(user.getUserName());
return 0;
if(i == 0){
throw new ServiceException("新增记录提现记录失败");
}
}
private void asynchronousMsg(String userName) {

View File

@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.system.mapper.RlChannelWithdrawMapper">
<resultMap type="ChannelWithdrawVO" id="ChannelWithdrawResult" autoMapping="true">
<result property="serviceRate" column="service_rate" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
<result property="withdrawHandlingCharge" column="withdraw_handling_charge" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
<result property="costRate" column="cost_rate" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
</resultMap>
@ -13,9 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select
scw.channel_id,
scw.name,
scw.account_type,
scw.service_type,
scw.service_rate,
scw.handling_charge_type,
scw.withdraw_handling_charge,
scw.enabled,
scw.cost_rate,
scw.picture,
@ -27,15 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="searchCondition">
<if test="query.channelId != null "> and scw.channel_id = #{query.channelId}</if>
<if test="query.name != null and query.name != ''"> and scw.name like concat('%', #{query.name}, '%')</if>
<if test="query.accountType != null and query.accountType != ''"> and scw.account_type = #{query.accountType}</if>
<if test="query.serviceType != null and query.serviceType != ''"> and scw.service_type = #{query.serviceType}</if>
<if test="query.handlingChargeType != null and query.handlingChargeType != ''"> and scw.handling_charge_type = #{query.handlingChargeType}</if>
<if test="query.enabled != null "> and scw.enabled = #{query.enabled}</if>
<if test="query.accountTypes != null and query.accountTypes.size() > 0">
and scw.account_type in
<foreach item="item" collection="query.accountTypes" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</sql>
<select id="selectChannelWithdrawList" parameterType="ChannelWithdrawQuery" resultMap="ChannelWithdrawResult">
@ -54,9 +46,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into rl_channel_withdraw
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="accountType != null and accountType != ''">account_type,</if>
<if test="serviceType != null and serviceType != ''">service_type,</if>
<if test="serviceRate != null">service_rate,</if>
<if test="handlingChargeType != null and handlingChargeType != ''">handling_charge_type,</if>
<if test="withdrawHandlingCharge != null">withdraw_handling_charge,</if>
<if test="enabled != null">enabled,</if>
<if test="costRate != null">cost_rate,</if>
<if test="picture != null">picture,</if>
@ -65,9 +56,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="accountType != null and accountType != ''">#{accountType},</if>
<if test="serviceType != null and serviceType != ''">#{serviceType},</if>
<if test="serviceRate != null">#{serviceRate},</if>
<if test="handlingChargeType != null and handlingChargeType != ''">#{handlingChargeType},</if>
<if test="withdrawHandlingCharge != null">#{withdrawHandlingCharge},</if>
<if test="enabled != null">#{enabled},</if>
<if test="costRate != null">#{costRate},</if>
<if test="picture != null">#{picture},</if>
@ -80,9 +70,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update rl_channel_withdraw
<trim prefix="SET" suffixOverrides=",">
<if test="data.name != null and data.name != ''">name = #{data.name},</if>
<if test="data.accountType != null and data.accountType != ''">account_type = #{data.accountType},</if>
<if test="data.serviceType != null and data.serviceType != ''">service_type = #{data.serviceType},</if>
<if test="data.serviceRate != null">service_rate = #{data.serviceRate},</if>
<if test="data.handlingChargeType != null and data.handlingChargeType != ''">handling_charge_type = #{data.handlingChargeType},</if>
<if test="data.withdrawHandlingCharge != null">withdraw_handling_charge = #{data.withdrawHandlingCharge},</if>
<if test="data.enabled != null">enabled = #{data.enabled},</if>
<if test="data.costRate != null">cost_rate = #{data.costRate},</if>
<if test="data.picture != null">picture = #{data.picture},</if>

View File

@ -15,7 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectEtMsgLogVo">
select id, type, templateCode, signName, content, create_time, phone from et_msg_log
select id, type, templateCode, signName, content, create_time, phone from rl_msg_log
</sql>
<select id="selectEtMsgLogList" parameterType="RlMsgLog" resultMap="EtMsgLogResult">
@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertEtMsgLog" parameterType="RlMsgLog" useGeneratedKeys="true" keyProperty="id">
insert into et_msg_log
insert into rl_msg_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="type != null">type,</if>
<if test="templateCode != null">templateCode,</if>
@ -53,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<update id="updateEtMsgLog" parameterType="RlMsgLog">
update et_msg_log
update rl_msg_log
<trim prefix="SET" suffixOverrides=",">
<if test="type != null">type = #{type},</if>
<if test="templateCode != null">templateCode = #{templateCode},</if>
@ -66,11 +66,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteEtMsgLogById" parameterType="Long">
delete from et_msg_log where id = #{id}
delete from rl_msg_log where id = #{id}
</delete>
<delete id="deleteEtMsgLogByIds" parameterType="String">
delete from et_msg_log where id in
delete from rl_msg_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -7,7 +7,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="RlUserExt" id="RlUserExtResult" autoMapping="true" />
<sql id="selectRlUserExtVo">
select ext_id, user_id, balance, dividend_proportion, cooperation_time, dividend_status, wx_collection_code, ali_collection_code, agent_id from rl_user_ext
select ext_id, user_id, balance, dividend_proportion, cooperation_time, dividend_status, wx_collection_code,
ali_collection_code, agent_id, handling_charge_type, withdraw_handling_charge from rl_user_ext
</sql>
<select id="selectRlUserExtList" parameterType="RlUserExt" resultMap="RlUserExtResult">
@ -42,6 +43,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="wxCollectionCode != null">wx_collection_code,</if>
<if test="aliCollectionCode != null">ali_collection_code,</if>
<if test="agentId != null">agent_id,</if>
<if test="handlingChargeType != null">handling_charge_type,</if>
<if test="withdrawHandlingCharge != null">withdraw_handling_charge,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
@ -52,6 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="wxCollectionCode != null">#{wxCollectionCode},</if>
<if test="aliCollectionCode != null">#{aliCollectionCode},</if>
<if test="agentId != null">#{agentId},</if>
<if test="handlingChargeType != null">#{handlingChargeType},</if>
<if test="withdrawHandlingCharge != null">#{withdrawHandlingCharge},</if>
</trim>
</insert>
@ -66,6 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="wxCollectionCode != null">wx_collection_code = #{wxCollectionCode},</if>
<if test="aliCollectionCode != null">ali_collection_code = #{aliCollectionCode},</if>
<if test="agentId != null">agent_id = #{agentId},</if>
<if test="handlingChargeType != null">handling_charge_type = #{handlingChargeType},</if>
<if test="withdrawHandlingCharge != null">withdraw_handling_charge = #{withdrawHandlingCharge},</if>
</trim>
where user_id = #{userId}
</update>
@ -74,6 +81,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from rl_user_ext where ext_id = #{extId}
</delete>
<delete id="deleteRlUserExtByUserId" parameterType="Long">
delete from rl_user_ext where user_id = #{userId}
</delete>
<delete id="deleteRlUserExtByExtIds" parameterType="String">
delete from rl_user_ext where ext_id in
<foreach item="extId" collection="array" open="(" separator="," close=")">

View File

@ -17,11 +17,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectUserList" parameterType="RlUser" resultMap="EUserResult">
select u.user_id, u.nick_name, u.user_name, u.real_name,u.email, u.avatar, u.phonenumber,u.user_type,
u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.is_authentication,
ex.balance,ex.dividend_proportion dividendProportion,ex.cooperation_time cooperationTime,ex.dividend_status dividendStatus, s.name storeName,s.store_id,
u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.is_authentication,a.city_id,c.name cityName,
ex.balance,ex.dividend_proportion dividendProportion,ex.cooperation_time cooperationTime,ex.dividend_status dividendStatus,ex.agent_id, s.name storeName,s.store_id,
u.wxopenid from rl_user u
left join rl_user_ext ex on u.user_id = ex.user_id
left join rl_store s on s.merchant_id = u.user_id
left join rl_agent a on a.agent_id = ex.agent_id
left join rl_city c on c.city_id = a.city_id
where u.del_flag = '0'
<if test="userId != null and userId != 0">
AND u.user_id = #{userId}
@ -185,6 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userId != null and userId != 0">user_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="realName != null and realName != ''">real_name,</if>
<if test="userType != null and userType != ''">user_type,</if>
<if test="idCard != null and idCard != ''">id_card,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if>
@ -201,6 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userId != null and userId != ''">#{userId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="realName != null and realName != ''">#{realName},</if>
<if test="userType != null and userType != ''">#{userType},</if>
<if test="idCard != null and idCard != ''">#{idCard},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="email != null and email != ''">#{email},</if>
@ -223,6 +227,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="realName != null and realName != ''">real_name = #{realName},</if>
<if test="idCard != null and idCard != ''">id_card = #{idCard},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="userType != null and userType != ''">user_type = #{userType},</if>
<if test="email != null ">email = #{email},</if>
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
<if test="isAuthentication != null">is_authentication = #{isAuthentication},</if>

View File

@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="RlWithdrawVO" id="RlWithdrawResult" autoMapping="true" />
<sql id="selectRlWithdrawVo">
select id, withdraw_no, amount, status, create_time, reject_reason, owner_name, owner_id, owner_phone, handling_charge, cost, payment_method from rl_withdraw
select id, withdraw_no, amount, status, create_time, reject_reason, owner_name, owner_id, owner_phone, handling_charge, cost, withdraw_channel_id, handling_charge_type, withdraw_handling_charge from rl_withdraw
</sql>
<select id="selectRlWithdrawList" parameterType="RlWithdraw" resultMap="RlWithdrawResult">
@ -22,7 +22,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ownerPhone != null and ownerPhone != ''"> and owner_phone = #{ownerPhone}</if>
<if test="handlingCharge != null "> and handling_charge = #{handlingCharge}</if>
<if test="cost != null "> and cost = #{cost}</if>
<if test="paymentMethod != null and paymentMethod != ''"> and payment_method = #{paymentMethod}</if>
<if test="withdrawChannelId != null "> and withdraw_channel_id = #{withdrawChannelId}</if>
<if test="handlingChargeType != null "> and handling_charge_type = #{handlingChargeType}</if>
<if test="withdrawHandlingCharge != null "> and withdraw_handling_charge = #{withdrawHandlingCharge}</if>
</where>
</select>
@ -50,7 +52,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ownerPhone != null">owner_phone,</if>
<if test="handlingCharge != null">handling_charge,</if>
<if test="cost != null">cost,</if>
<if test="paymentMethod != null">payment_method,</if>
<if test="withdrawChannelId != null">withdraw_channel_id,</if>
<if test="handlingChargeType != null">handling_charge_type,</if>
<if test="withdrawHandlingCharge != null">withdraw_handling_charge,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="withdrawNo != null">#{withdrawNo},</if>
@ -63,7 +67,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ownerPhone != null">#{ownerPhone},</if>
<if test="handlingCharge != null">#{handlingCharge},</if>
<if test="cost != null">#{cost},</if>
<if test="paymentMethod != null">#{paymentMethod},</if>
<if test="withdrawChannelId != null">#{withdrawChannelId},</if>
<if test="handlingChargeType != null">#{handlingChargeType},</if>
<if test="withdrawHandlingCharge != null">#{withdrawHandlingCharge},</if>
</trim>
</insert>
@ -80,7 +86,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ownerPhone != null">owner_phone = #{ownerPhone},</if>
<if test="handlingCharge != null">handling_charge = #{handlingCharge},</if>
<if test="cost != null">cost = #{cost},</if>
<if test="paymentMethod != null">payment_method = #{paymentMethod},</if>
<if test="withdrawChannelId != null">withdraw_channel_id = #{withdrawChannelId},</if>
<if test="handlingChargeType != null">handling_charge_type = #{handlingChargeType},</if>
<if test="withdrawHandlingCharge != null">withdraw_handling_charge = #{withdrawHandlingCharge},</if>
</trim>
where id = #{id}
</update>