Commit 72556a16 authored by machengbo's avatar machengbo

充值 提交审核

parent a0c7214e
......@@ -2,3 +2,4 @@ alter table t_finance_customer_assets add remark text COMMENT '备注';
alter table t_platform_log add caller_type char(2) NOT NULL COMMENT '调用类型:01商城用户,02平台用户';
alter table t_finance_trade_flow add assets_id Bigint(20) default NULL COMMENT'企业资产id';
alter table t_finance_customer_balance add balance_time datetime default NULL COMMENT'充值时间';
alter table t_finance_trade_flow add balance_money decimal(20,5) NOT NULL DEFAULT '0' COMMENT '结余';
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.jz.common.bean.PageInfoResponse;
import com.jz.common.constant.Constants;
import com.jz.common.utils.Result;
import com.jz.manage.moduls.controller.BaseController;
import com.jz.manage.moduls.controller.finance.platForm.BalanceAuditRequest;
import com.jz.manage.moduls.controller.finance.platForm.BalanceInfoDto;
import com.jz.manage.moduls.controller.finance.platForm.BalanceListDto;
import com.jz.manage.moduls.controller.finance.platForm.BalanceListRequest;
......@@ -79,4 +80,25 @@ public class FinanceCustomerBalanceController extends BaseController {
result.setData(dto);
return result;
}
/**
* 充值管理--充值审核
*
* @return
* @author Bellamy
* @since 2020-12-08
*/
@PostMapping(value = "/balanceInfoAudit")
@ApiOperation(value = "充值管理--充值审核", notes = "充值审核")
public Result<Object> getBalanceInfoAudit(@RequestBody BalanceAuditRequest balanceAuditRequest, HttpServletRequest httpRequest) throws Exception {
Result<Object> result = new Result<>();
if (StringUtils.isEmpty(balanceAuditRequest.getCustomerBalanceId())) {
return Result.error("参数不能为空!");
}
if (StringUtils.isEmpty(balanceAuditRequest.getAuditStatus())) {
return Result.error("参数不能为空!");
}
Result<Object> dto = financeCustomerBalanceService.uptBalanceInfoAuditByid(balanceAuditRequest);
return dto;
}
}
\ No newline at end of file
package com.jz.manage.moduls.controller.finance.platForm;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 平台利润中心--充值管理--充值审核参数对象
*
* @author Bellamy
* @since 2020-12-08 10:41:43
*/
@ApiModel(value = "充值管理--充值审核参数对象", description = "充值审核参数对象")
public class BalanceAuditRequest {
/**
* 审核意见
*/
@ApiModelProperty(value = "审核意见")
private String rejectReason;
/**
* 充值id
*/
@ApiModelProperty(value = "充值id")
private String customerBalanceId;
/**
* 审核状态:01待审核,02审核通过,03未通过
*/
@ApiModelProperty(value = "审核状态")
private String auditStatus;
public String getRejectReason() {
return rejectReason;
}
public void setRejectReason(String rejectReason) {
this.rejectReason = rejectReason;
}
public String getAuditStatus() {
return auditStatus;
}
public void setAuditStatus(String auditStatus) {
this.auditStatus = auditStatus;
}
public String getCustomerBalanceId() {
return customerBalanceId;
}
public void setCustomerBalanceId(String customerBalanceId) {
this.customerBalanceId = customerBalanceId;
}
}
\ No newline at end of file
package com.jz.manage.moduls.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
......@@ -20,6 +22,7 @@ public class FinanceCustomerBalance implements Serializable {
/**
* 充值id
*/
@TableId(value = "customer_balance_id",type = IdType.AUTO)
private Long customerBalanceId;
/**
* 企业客户资产id
......@@ -54,6 +57,15 @@ public class FinanceCustomerBalance implements Serializable {
*/
private String rejectReason;
/**
* 更新时间
*/
private Date uptTime;
/**
* 更新人
*/
private String uptPerson;
public Long getCustomerBalanceId() {
return customerBalanceId;
......@@ -127,4 +139,19 @@ public class FinanceCustomerBalance implements Serializable {
this.rejectReason = rejectReason;
}
public Date getUptTime() {
return uptTime;
}
public void setUptTime(Date uptTime) {
this.uptTime = uptTime;
}
public String getUptPerson() {
return uptPerson;
}
public void setUptPerson(String uptPerson) {
this.uptPerson = uptPerson;
}
}
\ No newline at end of file
package com.jz.manage.moduls.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
......@@ -61,10 +62,12 @@ public class FinanceTradeFlow implements Serializable {
/**
* 资产id
*/
@TableField(value = "assets_id")
private Long assetsId;
/**
* 资产结余
*/
@TableField(value = "balance_money")
private BigDecimal balanceMoney;
......
package com.jz.manage.moduls.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.common.entity.FinanceCustomerBalance;
import com.jz.manage.moduls.controller.finance.platForm.BalanceInfoDto;
import com.jz.manage.moduls.controller.finance.platForm.BalanceListDto;
import com.jz.manage.moduls.entity.FinanceCustomerBalance;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......
package com.jz.manage.moduls.service;
import com.jz.common.bean.PageInfoResponse;
import com.jz.common.utils.Result;
import com.jz.manage.moduls.controller.finance.platForm.BalanceAuditRequest;
import com.jz.manage.moduls.controller.finance.platForm.BalanceInfoDto;
import com.jz.manage.moduls.controller.finance.platForm.BalanceListDto;
import com.jz.manage.moduls.controller.finance.platForm.BalanceListRequest;
......@@ -19,4 +21,6 @@ public interface FinanceCustomerBalanceService {
PageInfoResponse<BalanceListDto> findListBalance(BalanceListRequest balanceListRequest, HttpServletRequest httpRequest) throws Exception;
BalanceInfoDto queryBalanceByid(String customerBalanceId) throws Exception;
Result<Object> uptBalanceInfoAuditByid(BalanceAuditRequest balanceAuditRequest) throws Exception;
}
\ No newline at end of file
package com.jz.manage.moduls.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.common.bean.PageInfoResponse;
import com.jz.common.constant.Constants;
import com.jz.common.enums.AuditStatusEnum;
import com.jz.common.enums.TradeFlowEnum;
import com.jz.common.utils.Result;
import com.jz.manage.moduls.controller.finance.platForm.BalanceAuditRequest;
import com.jz.manage.moduls.controller.finance.platForm.BalanceInfoDto;
import com.jz.manage.moduls.controller.finance.platForm.BalanceListDto;
import com.jz.manage.moduls.controller.finance.platForm.BalanceListRequest;
import com.jz.manage.moduls.entity.FinanceCustomerAssets;
import com.jz.manage.moduls.entity.FinanceCustomerBalance;
import com.jz.manage.moduls.entity.FinanceTradeFlow;
import com.jz.manage.moduls.mapper.FinanceCustomerAssetsDao;
import com.jz.manage.moduls.mapper.FinanceCustomerBalanceDao;
import com.jz.manage.moduls.mapper.FinanceTradeFlowDao;
import com.jz.manage.moduls.service.FinanceCustomerBalanceService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -25,11 +40,19 @@ import java.util.Map;
* @since 2020-12-01 10:41:39
*/
@Service("financeCustomerBalanceService")
@Transactional
public class FinanceCustomerBalanceServiceImpl implements FinanceCustomerBalanceService {
private static final Logger logger = LoggerFactory.getLogger(FinanceCustomerBalanceServiceImpl.class);
@Autowired
private FinanceCustomerBalanceDao financeCustomerBalanceDao;
@Autowired
private FinanceCustomerAssetsDao financeCustomerAssetsDao;
@Autowired
private FinanceTradeFlowDao financeTradeFlowDao;
@Override
public PageInfoResponse<BalanceListDto> findListBalance(BalanceListRequest balanceListRequest, HttpServletRequest httpRequest) throws Exception {
......@@ -72,4 +95,85 @@ public class FinanceCustomerBalanceServiceImpl implements FinanceCustomerBalance
public BalanceInfoDto queryBalanceByid(String customerBalanceId) throws Exception {
return financeCustomerBalanceDao.queryBalanceByid(customerBalanceId);
}
@Override
public Result<Object> uptBalanceInfoAuditByid(BalanceAuditRequest balanceAuditRequest) throws Exception {
//1.修改充值记录状态
FinanceCustomerBalance balance = new FinanceCustomerBalance();
balance.setAuditStatus(balanceAuditRequest.getAuditStatus());
balance.setRejectReason(balanceAuditRequest.getRejectReason());
balance.setCustomerBalanceId(Long.valueOf(balanceAuditRequest.getCustomerBalanceId()));
//balance.setUptPerson();
balance.setUptTime(new Date());
int len = financeCustomerBalanceDao.updateById(balance);
if (len > 0) {
logger.info("###########################修改充值审核状态成功####################################");
//2.查询出充值金额 和 账户id
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("customer_balance_id", balanceAuditRequest.getCustomerBalanceId());
wrapper.eq("del_flag", "N");
FinanceCustomerBalance financeCustomerBalance = financeCustomerBalanceDao.selectOne(wrapper);
Long assetsId = financeCustomerBalance.getAssetsId(); //企业用户资产id
String balanceMoney = financeCustomerBalance.getBalanceMoney().toString(); //充值金额
BigDecimal balanceMoneyObj = new BigDecimal(balanceMoney);
//3.查询资产金额
QueryWrapper assetsWrapper = new QueryWrapper();
assetsWrapper.eq("assets_id", assetsId);
wrapper.eq("del_flag", "N");
FinanceCustomerAssets financeCustomerAssets = financeCustomerAssetsDao.selectOne(assetsWrapper);
String frozenMoney = financeCustomerAssets.getFrozenMoney().toString(); // 冻结金额
BigDecimal frozenMoneyObj = new BigDecimal(frozenMoney);
frozenMoneyObj = frozenMoneyObj.subtract(balanceMoneyObj);
if (AuditStatusEnum.YSH.getValue().equals(balanceAuditRequest.getAuditStatus())) {
//审核成功 给总金额和可用余额加上充值金额 ,冻结减去
String useMoney = financeCustomerAssets.getUseMoney().toString(); // 可用金额
BigDecimal useMoneyObj = new BigDecimal(useMoney);
useMoneyObj = useMoneyObj.add(balanceMoneyObj);
String totalMoney = financeCustomerAssets.getTotalMoney().toString(); //总金额
BigDecimal totalMoneyObj = new BigDecimal(totalMoney);
totalMoneyObj = totalMoneyObj.add(balanceMoneyObj);
//4.更新 企业资产
FinanceCustomerAssets saveAssets = new FinanceCustomerAssets();
saveAssets.setAssetsId(assetsId);
saveAssets.setUseMoney(useMoneyObj);
saveAssets.setTotalMoney(totalMoneyObj);
saveAssets.setFrozenMoney(frozenMoneyObj);
saveAssets.setUptTime(new Date());
//saveAssets.setUptPerson();
financeCustomerAssetsDao.updateById(saveAssets);
logger.info("###########################充值审核通过---更新企业资产成功####################################");
//添加流水记录
FinanceTradeFlow financeTradeFlow = new FinanceTradeFlow();
financeTradeFlow.setCreTime(new Date());
financeTradeFlow.setTradeMoney(balanceMoneyObj);
financeTradeFlow.setAssetsId(assetsId);
financeTradeFlow.setTradeType(TradeFlowEnum.CZ.getValue());
financeTradeFlow.setTradeFlowNumber("123132");
financeTradeFlow.setBalanceMoney(useMoneyObj);
financeTradeFlow.setDelFlag("N");
//financeTradeFlow.setCashOutId();
//financeTradeFlow.setCrePerson();
financeTradeFlowDao.insert(financeTradeFlow);
logger.info("#####################商城提现流水记录添加成功#####################");
}
if (AuditStatusEnum.WTG.getValue().equals(balanceAuditRequest.getAuditStatus())) {
//4.审核未通过 更新 企业资产
FinanceCustomerAssets saveAssets = new FinanceCustomerAssets();
saveAssets.setAssetsId(assetsId);
saveAssets.setFrozenMoney(frozenMoneyObj);
saveAssets.setUptTime(new Date());
//saveAssets.setUptPerson();
financeCustomerAssetsDao.updateById(saveAssets);
logger.info("###########################充值审核未通过--更新企业资产成功####################################");
}
return Result.ok();
} else {
return Result.error("提交失败!");
}
}
}
\ No newline at end of file
......@@ -72,10 +72,10 @@
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="tradeFlowId" useGeneratedKeys="true">
<!--<insert id="insert" keyProperty="tradeFlowId" useGeneratedKeys="true">
insert into t_finance_trade_flow(order_id, cash_out_id, customer_balance_id, trade_flow_number, trade_money, trade_type, cre_time, cre_person, del_flag)
values (#{orderId}, #{cashOutId}, #{customerBalanceId}, #{tradeFlowNumber}, #{tradeMoney}, #{tradeType}, #{creTime}, #{crePerson}, #{delFlag})
</insert>
</insert>-->
<insert id="insertBatch" keyProperty="tradeFlowId" useGeneratedKeys="true">
insert into t_finance_trade_flow(order_id, cash_out_id, customer_balance_id, trade_flow_number,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment