1.调整
This commit is contained in:
parent
b18cd3cceb
commit
ae5b9ea9e8
|
@ -109,6 +109,9 @@ public class SysUser extends BaseEntity
|
|||
/** 角色对象 */
|
||||
private List<SysRole> roles;
|
||||
|
||||
/** 角色 */
|
||||
private String roleNames;
|
||||
|
||||
/** 角色组 */
|
||||
private Long[] roleIds;
|
||||
|
||||
|
@ -132,6 +135,14 @@ public class SysUser extends BaseEntity
|
|||
/** app用户名 */
|
||||
private String appUserName;
|
||||
|
||||
public String getRoleNames() {
|
||||
return roleNames;
|
||||
}
|
||||
|
||||
public void setRoleNames(String roleNames) {
|
||||
this.roleNames = roleNames;
|
||||
}
|
||||
|
||||
public String getAppUserName() {
|
||||
return appUserName;
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import com.ruoyi.system.domain.SysUserRole;
|
|||
|
||||
/**
|
||||
* 用户与角色关联表 数据层
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysUserRoleMapper
|
||||
{
|
||||
/**
|
||||
* 通过用户ID删除用户和角色关联
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ public interface SysUserRoleMapper
|
|||
|
||||
/**
|
||||
* 批量删除用户和角色关联
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ public interface SysUserRoleMapper
|
|||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ public interface SysUserRoleMapper
|
|||
|
||||
/**
|
||||
* 批量新增用户角色信息
|
||||
*
|
||||
*
|
||||
* @param userRoleList 用户角色列表
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@ public interface SysUserRoleMapper
|
|||
|
||||
/**
|
||||
* 删除用户和角色关联信息
|
||||
*
|
||||
*
|
||||
* @param userRole 用户和角色关联信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -53,7 +53,7 @@ public interface SysUserRoleMapper
|
|||
|
||||
/**
|
||||
* 批量取消授权用户角色
|
||||
*
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要删除的用户数据ID
|
||||
* @return 结果
|
||||
|
|
|
@ -471,6 +471,7 @@ public class CallbackServiceImpl implements CallbackService {
|
|||
EtCapitalFlow capitalFlow = new EtCapitalFlow();
|
||||
if(ownerType.equals(ServiceConstants.OWNER_TYPE_OPERATOR)){//运营商
|
||||
SysDept sysDept = wxPayService.getDeptObjByAreaId(order.getAreaId());
|
||||
String separateAccount = sysDept.getSeparateAccount();
|
||||
capitalFlow.setAreaId(order.getAreaId());
|
||||
capitalFlow.setOrderNo(order.getOrderNo());
|
||||
capitalFlow.setOutTradeNo(order.getOutTradeNo());
|
||||
|
@ -496,8 +497,12 @@ public class CallbackServiceImpl implements CallbackService {
|
|||
capitalFlow.setPartnerDividend(BigDecimal.ZERO);
|
||||
capitalFlow.setPlatformServiceFee(BigDecimal.ZERO);
|
||||
capitalFlow.setOperatorDividend(separateAccountFee.negate());
|
||||
capitalFlow.setOperatorBalance(sysDept.getBalance().subtract(separateAccountFee));
|
||||
deptService.changeDeptBalance(separateAccountFee.negate(),sysDept.getDeptId());
|
||||
if(StrUtil.isNotBlank(separateAccount) && separateAccount.equals("N")){
|
||||
capitalFlow.setOperatorBalance(sysDept.getBalance().subtract(separateAccountFee));
|
||||
deptService.changeDeptBalance(separateAccountFee.negate(),sysDept.getDeptId());
|
||||
}else{
|
||||
capitalFlow.setOperatorBalance(BigDecimal.ZERO);
|
||||
}
|
||||
logger.info("【微信支付回调--保存资金流水记录】 ==============支出=====================:");
|
||||
}else{
|
||||
logger.info("【微信支付回调--保存资金流水记录】 ==============业务类型=====================:"+busType);
|
||||
|
@ -524,14 +529,22 @@ public class CallbackServiceImpl implements CallbackService {
|
|||
if(type.equals(ServiceConstants.FLOW_TYPE_INCOME)){
|
||||
capitalFlow.setPartnerDividend(partnerDividend);
|
||||
capitalFlow.setOperatorDividend(operatorDividend);
|
||||
capitalFlow.setOperatorBalance(sysDept.getBalance().add(operatorDividend));
|
||||
deptService.changeDeptBalance(operatorDividend,sysDept.getDeptId());
|
||||
if(StrUtil.isNotBlank(separateAccount) && separateAccount.equals("N")){
|
||||
capitalFlow.setOperatorBalance(sysDept.getBalance().add(operatorDividend));
|
||||
deptService.changeDeptBalance(operatorDividend,sysDept.getDeptId());
|
||||
}else{
|
||||
capitalFlow.setOperatorBalance(BigDecimal.ZERO);
|
||||
}
|
||||
logger.info("【微信支付回调--保存资金流水记录】 ==============收入=====================:");
|
||||
}else{
|
||||
capitalFlow.setPartnerDividend(partnerDividend.negate());
|
||||
capitalFlow.setOperatorDividend(operatorDividend.negate());
|
||||
capitalFlow.setOperatorBalance(sysDept.getBalance().subtract(operatorDividend));
|
||||
deptService.changeDeptBalance(operatorDividend.negate(),sysDept.getDeptId());
|
||||
if(StrUtil.isNotBlank(separateAccount) && separateAccount.equals("N")){
|
||||
capitalFlow.setOperatorBalance(sysDept.getBalance().subtract(operatorDividend));
|
||||
deptService.changeDeptBalance(operatorDividend.negate(),sysDept.getDeptId());
|
||||
}else{
|
||||
capitalFlow.setOperatorBalance(BigDecimal.ZERO);
|
||||
}
|
||||
logger.info("【微信支付回调--保存资金流水记录】 ==============支出=====================:");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -481,9 +481,13 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
if(updateEtOrder == 0){
|
||||
throw new ServiceException("还车审核失败,更新订单失败");
|
||||
}
|
||||
// 判断最后一个押金订单是否已退款,如果没有退款,则发起退款,如果有退款,则不退押金
|
||||
// 判断是否已退款
|
||||
Boolean refunded = isRefunded(etOrder.getUserId());
|
||||
|
||||
// 当前还有正在骑行中的订单,不退押金,只有用户没有正在骑行中的订单时才发起退款
|
||||
EtOrder currentOrder = etOrderService.getCurrentOrderByUserId(etOrder.getUserId());
|
||||
if(ObjectUtil.isNull(currentOrder)){
|
||||
if(ObjectUtil.isNull(currentOrder) && !refunded){
|
||||
log.info("【还车审核通过】当前用户没有正在骑行的订单,开始退押金");
|
||||
/** 2.退押金*/
|
||||
EtOrder depositOrder = getDepositOrder(etOrder.getUserId());
|
||||
|
@ -510,11 +514,45 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
}
|
||||
}
|
||||
}else{
|
||||
log.info("【还车审核通过】当前用户还有正在骑行的订单------不退押金");
|
||||
if(refunded){
|
||||
log.info("【还车审核通过】当前用户押金已退款!!------不退押金");
|
||||
}
|
||||
if(ObjectUtil.isNull(currentOrder)){
|
||||
log.info("【还车审核通过】当前用户还有正在骑行的订单------不退押金");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 判断是否已退款*/
|
||||
private Boolean isRefunded(Long userId) {
|
||||
EtOrder etOrder = new EtOrder();
|
||||
etOrder.setUserId(userId);
|
||||
etOrder.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
|
||||
etOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT);
|
||||
etOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
||||
List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(etOrder);
|
||||
if (etOrders.size() > 0 || ObjectUtil.isNotNull(etOrders) ) {
|
||||
Optional<EtOrder> latestOrderOptional = etOrders.stream()
|
||||
.max(Comparator.comparing(EtOrder::getPayTime));
|
||||
if (latestOrderOptional.isPresent()) {
|
||||
EtOrder lastOrder = latestOrderOptional.get();
|
||||
log.info("【还车审核通过】用户【{}】最后一次押金充值订单 : " + JSON.toJSONString(lastOrder),userId);
|
||||
// 根据最新的订单号,查询是否有退款记录
|
||||
List<EtRefund> etRefunds = etRefundService.selectEtRefundByOrderNo(lastOrder.getOrderNo());
|
||||
if(etRefunds.size() == 1) {
|
||||
EtRefund etRefund = etRefunds.get(0);
|
||||
// 有退款记录,判断是否成功
|
||||
if(Constants.SUCCESS2.equals(etRefund.getRefundResult())){
|
||||
log.info("【还车审核通过】押金退款成功回调,退款单号:【{}】",etRefund.getRefundNo());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 官方审核通过
|
||||
* 1.更新订单状态为订单结束
|
||||
|
@ -530,29 +568,35 @@ public class EtOrderServiceImpl implements IEtOrderService
|
|||
if(updateEtOrder == 0){
|
||||
throw new ServiceException("还车审核失败,更新订单失败");
|
||||
}
|
||||
/** 2.退剩余押金 = 押金 - 扣除金额*/
|
||||
EtOrder depositOrder = getDepositOrder(etOrder.getUserId());
|
||||
BigDecimal residualDeposit = depositOrder.getTotalFee().subtract(new BigDecimal(etOrder.getDeductionAmount()));
|
||||
Refund refund = wxPayService.refund(depositOrder, "还车审核通过后退押金",residualDeposit,IdUtils.getOrderNo("ref"));
|
||||
/** 3.记录退款表 创建退款对象*/
|
||||
depositOrder.setReason("还车审核通过后退押金");
|
||||
EtRefund refund1= createRefund(depositOrder, residualDeposit, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
|
||||
int i = etRefundService.insertEtRefund(refund1);
|
||||
if(i == 0){
|
||||
log.info("【还车审核通过】保存退款对象失败");
|
||||
throw new ServiceException("【还车审核通过】,保存退款对象失败");
|
||||
}
|
||||
/** 4.更新用户余额*/
|
||||
AsUser asUser = asUserService.selectUserById(depositOrder.getUserId());
|
||||
if(asUser!=null){
|
||||
// 更新用户并更新缓存
|
||||
asUser.setBalance(BigDecimal.ZERO);
|
||||
if (asUserService.updateUserProfile(asUser) > 0)
|
||||
{
|
||||
log.info("【还车审核通过】更新用户信息成功:"+ JSON.toJSON(asUser));
|
||||
}else{
|
||||
throw new ServiceException("【还车审核通过】,更新用户信息失败");
|
||||
Boolean refunded = isRefunded(etOrder.getUserId());
|
||||
if(!refunded){
|
||||
/** 2.退剩余押金 = 押金 - 扣除金额*/
|
||||
EtOrder depositOrder = getDepositOrder(etOrder.getUserId());
|
||||
BigDecimal residualDeposit = depositOrder.getTotalFee().subtract(new BigDecimal(etOrder.getDeductionAmount()));
|
||||
Refund refund = wxPayService.refund(depositOrder, "还车审核通过后退押金",residualDeposit,IdUtils.getOrderNo("ref"));
|
||||
/** 3.记录退款表 创建退款对象*/
|
||||
depositOrder.setReason("还车审核通过后退押金");
|
||||
EtRefund refund1= createRefund(depositOrder, residualDeposit, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
|
||||
int i = etRefundService.insertEtRefund(refund1);
|
||||
if(i == 0){
|
||||
log.info("【还车审核通过】保存退款对象失败");
|
||||
throw new ServiceException("【还车审核通过】,保存退款对象失败");
|
||||
}
|
||||
/** 4.更新用户余额*/
|
||||
AsUser asUser = asUserService.selectUserById(depositOrder.getUserId());
|
||||
if(asUser!=null){
|
||||
// 更新用户并更新缓存
|
||||
asUser.setBalance(BigDecimal.ZERO);
|
||||
if (asUserService.updateUserProfile(asUser) > 0)
|
||||
{
|
||||
log.info("【还车审核通过】更新用户信息成功:"+ JSON.toJSON(asUser));
|
||||
}else{
|
||||
throw new ServiceException("【还车审核通过】,更新用户信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
log.info("【还车审核通过】当前用户押金已退款!!------不退押金");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -111,13 +111,21 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
sysUser.setAreaName(area.getAreaName());
|
||||
}
|
||||
}
|
||||
Long appUserId = sysUser.getAppUserId();
|
||||
if(ObjectUtil.isNotNull(appUserId) && appUserId!=0){
|
||||
AsUser asUser = asUserMapper.selectUserById(appUserId);
|
||||
if(ObjectUtil.isNotNull(asUser)){
|
||||
sysUser.setAppUserName(asUser.getUserName());
|
||||
}
|
||||
AsUser asUser1 = new AsUser();
|
||||
asUser1.setSysUserId(sysUser.getUserId());
|
||||
List<AsUser> asUsers = asUserMapper.selectUserList(asUser1);
|
||||
if(ObjectUtil.isNotNull(asUsers) && asUsers.size()>0){
|
||||
String appUserName = asUsers.stream()
|
||||
.map(AsUser::getRealName)
|
||||
.collect(Collectors.joining(","));
|
||||
sysUser.setAppUserName(appUserName);
|
||||
}
|
||||
List<SysRole> sysRoles = roleMapper.selectRolePermissionByUserId(sysUser.getUserId());
|
||||
String roleNames = sysRoles.stream()
|
||||
.map(SysRole::getRoleName)
|
||||
.collect(Collectors.joining(","));
|
||||
sysUser.setRoles(sysRoles);
|
||||
sysUser.setRoleNames(roleNames);
|
||||
}
|
||||
return sysUsers;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="userId != null and userId != 0">
|
||||
AND u.user_id = #{userId}
|
||||
</if>
|
||||
<if test="sysUserId != null and sysUserId != 0">
|
||||
AND u.sys_user_id = #{sysUserId}
|
||||
</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
|
|
Loading…
Reference in New Issue
Block a user