localizer
parent
7a81fc13d3
commit
ee4247503a
|
|
@ -1,6 +1,5 @@
|
|||
package com.njzscloud.supervisory.money.controller;
|
||||
|
||||
import com.njzscloud.common.core.ex.Exceptions;
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
|
|
@ -38,10 +37,6 @@ public class MoneyAccountController {
|
|||
*/
|
||||
@PostMapping("/modify")
|
||||
public R<?> modify(@RequestBody MoneyAccountEntity moneyAccountEntity) {
|
||||
if (moneyAccountEntity.getRechargeMoney() == null || moneyAccountEntity.getRechargeMoney().signum() <= 0) {
|
||||
throw Exceptions.clierr("充值金额需大于0");
|
||||
}
|
||||
moneyAccountEntity.setMoney(moneyAccountEntity.getMoney().add(moneyAccountEntity.getRechargeMoney()));
|
||||
moneyAccountService.modify(moneyAccountEntity);
|
||||
return R.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ public class MoneyChangeDetailEntity {
|
|||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 公司id
|
||||
*/
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,12 +4,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njzscloud.common.core.ex.Exceptions;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.common.security.util.SecurityUtil;
|
||||
import com.njzscloud.supervisory.money.contant.MoneyChangeCategory;
|
||||
import com.njzscloud.supervisory.money.mapper.MoneyAccountMapper;
|
||||
import com.njzscloud.supervisory.money.pojo.entity.MoneyAccountEntity;
|
||||
import com.njzscloud.supervisory.money.pojo.entity.MoneyChangeDetailEntity;
|
||||
import com.njzscloud.supervisory.money.pojo.result.MoneyAccountResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -21,8 +25,11 @@ import java.util.List;
|
|||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MoneyAccountService extends ServiceImpl<MoneyAccountMapper, MoneyAccountEntity> implements IService<MoneyAccountEntity> {
|
||||
|
||||
private final MoneyChangeDetailService moneyChangeDetailService;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
|
|
@ -34,8 +41,35 @@ public class MoneyAccountService extends ServiceImpl<MoneyAccountMapper, MoneyAc
|
|||
/**
|
||||
* 修改
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modify(MoneyAccountEntity moneyAccountEntity) {
|
||||
if (moneyAccountEntity.getRechargeMoney() == null || moneyAccountEntity.getRechargeMoney().signum() <= 0) {
|
||||
throw Exceptions.clierr("充值金额需大于0");
|
||||
}
|
||||
// 记录资金变动明细
|
||||
MoneyChangeDetailEntity changeDetail = new MoneyChangeDetailEntity()
|
||||
.setMoneyAccountId(moneyAccountEntity.getId())
|
||||
.setOldMoney(moneyAccountEntity.getMoney())
|
||||
.setDelta(moneyAccountEntity.getRechargeMoney()) // 充值
|
||||
.setMoneyChangeCategory(MoneyChangeCategory.ChongZhi)
|
||||
.setMemo("账户充值");
|
||||
|
||||
moneyAccountEntity.setMoney(moneyAccountEntity.getMoney().add(moneyAccountEntity.getRechargeMoney()));
|
||||
|
||||
changeDetail.setNewMoney(moneyAccountEntity.getMoney());
|
||||
|
||||
MoneyAccountResult result = baseMapper.selectMoneyAccountDetailById(moneyAccountEntity.getId());
|
||||
if (null == result) {
|
||||
throw Exceptions.clierr("未找到该账户");
|
||||
}
|
||||
changeDetail.setUserId(result.getUserId());
|
||||
changeDetail.setCompanyId(result.getStationId());
|
||||
this.updateById(moneyAccountEntity);
|
||||
|
||||
moneyChangeDetailService.save(changeDetail);
|
||||
|
||||
log.info("公司账户充值成功,充值金额:{},余额:{} -> {}",
|
||||
moneyAccountEntity.getRechargeMoney(), changeDetail.getOldMoney(), changeDetail.getNewMoney());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -197,7 +197,8 @@ public class PaymentController {
|
|||
|
||||
// 记录资金变动明细
|
||||
MoneyChangeDetailEntity changeDetail = new MoneyChangeDetailEntity()
|
||||
.setUserId(ctx.getCompanyUserId())
|
||||
// .setUserId(ctx.getCompanyUserId())
|
||||
.setCompanyId(ctx.getTransCompanyId())
|
||||
.setOrderId(orderId)
|
||||
.setMoneyAccountId(companyAccount.getId())
|
||||
.setOldMoney(oldBalance)
|
||||
|
|
|
|||
|
|
@ -14,14 +14,20 @@
|
|||
mcd.money_change_category,
|
||||
mcd.extend_info,
|
||||
mcd.memo,
|
||||
mcd.company_id,
|
||||
mcd.creator_id,
|
||||
mcd.modifier_id,
|
||||
mcd.create_time,
|
||||
mcd.modify_time,
|
||||
mcd.deleted,
|
||||
u.nickname
|
||||
CASE
|
||||
WHEN mcd.user_id IS NOT NULL THEN u.nickname
|
||||
WHEN mcd.company_id IS NOT NULL THEN bc.company_name
|
||||
ELSE NULL
|
||||
END as nickname
|
||||
FROM money_change_detail mcd
|
||||
LEFT JOIN sys_user u ON mcd.user_id = u.id
|
||||
LEFT JOIN biz_company bc ON mcd.company_id = bc.id
|
||||
<where>
|
||||
<if test="entity.nickname != null and entity.nickname != ''">
|
||||
AND u.nickname LIKE CONCAT('%', #{entity.nickname}, '%')
|
||||
|
|
|
|||
Loading…
Reference in New Issue