From b08c3ca89f463f5a6775d77107d91cadce8bdf05 Mon Sep 17 00:00:00 2001
From: zyy <zyy@email.com>
Date: Mon, 15 Sep 2025 18:09:40 +0800
Subject: [PATCH] 1
---
src/main/java/com/nq/service/impl/FundsApplyServiceImpl.java | 134 ++------------------------------------------
1 files changed, 8 insertions(+), 126 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/FundsApplyServiceImpl.java b/src/main/java/com/nq/service/impl/FundsApplyServiceImpl.java
index c790d7a..0042511 100644
--- a/src/main/java/com/nq/service/impl/FundsApplyServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/FundsApplyServiceImpl.java
@@ -8,7 +8,6 @@
import com.nq.service.IFundsApplyService;
import com.nq.service.IFundsSettingService;
import com.nq.service.IUserService;
-import com.nq.utils.DateTimeUtil;
import com.nq.utils.KeyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -19,7 +18,6 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -34,20 +32,14 @@
@Resource
private FundsApplyMapper fundsApplyMapper;
- @Autowired
+ @Resource
UserMapper userMapper;
- @Autowired
+ @Resource
UserCashDetailMapper userCashDetailMapper;
@Autowired
- FundsTradingAccountMapper fundsTradingAccountMapper;
-
- @Autowired
IUserService iUserService;
- @Autowired
- IFundsSettingService iFundsSettingService;
-
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
public ServerResponse insert(FundsApply model, HttpServletRequest request) throws Exception {
int ret = 0;
if (model == null) {
@@ -57,14 +49,8 @@
if(user == null){
return ServerResponse.createBySuccessMsg("请登录后操作");
}
- BigDecimal user_enable_amt = user.getEnableAmt();
//支付金额=保证金+管理费
BigDecimal pay_amount = model.getMargin().add(model.getManageFee());
- int compareUserAmtInt = user_enable_amt.compareTo(pay_amount);
- log.info("用户可用金额 = {} 实际购买金额 = {} 比较结果 = {} ", user_enable_amt, pay_amount, compareUserAmtInt);
- if (compareUserAmtInt == -1) {
- return ServerResponse.createByErrorMsg("申请失败,可用金额小于" + pay_amount + "元");
- }
//自动生成订单编号
model.setOrderNumber(KeyUtils.getUniqueKey());
@@ -72,9 +58,7 @@
ret = fundsApplyMapper.insert(model);
if(ret>0){
//修改用户可用余额= 当前余额-支付金额
- BigDecimal reckon_enable = user_enable_amt.subtract(pay_amount);
- user.setEnableAmt(reckon_enable);
- int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user);
+ int updateUserCount = this.userMapper.updateById(user);
if (updateUserCount > 0) {
log.info("【用户交易下单】修改用户金额成功");
UserCashDetail ucd = new UserCashDetail();
@@ -129,112 +113,10 @@
/**
* 配资申请-审核
*/
- /* */ @Transactional
- /* */ public ServerResponse audit(FundsApply model, HttpServletRequest request) throws Exception {
- /* 135 */ FundsApply fundsApply = this.fundsApplyMapper.load(model.getId().intValue());
- /* 136 */ int ret = 0;
- /* 137 */ if (model != null && model.getId().intValue() > 0) {
- /* 138 */ User user = this.userMapper.selectByPrimaryKey(fundsApply.getUserId());
- /* */
- /* 140 */ if (model.getStatus().intValue() == 1) {
- /* 141 */ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- /* 142 */ String begtime = df.format(new Date()).split(" ")[0] + " 0:00:00";
- /* 143 */ Date date = DateTimeUtil.strToDate(begtime);
- /* 144 */ Date begDate = DateTimeUtil.addDay(date, 1);
- /* 145 */ model.setBeginTime(begDate);
- /* 146 */ String endtime = df.format(new Date()).split(" ")[0] + " 23:59:59";
- /* 147 */ Date endDate = DateTimeUtil.strToDate(endtime);
- /* 148 */ endDate = DateTimeUtil.addDay(endDate, model.getTradersCycle().intValue() + 1);
- /* 149 */ model.setEndTime(endDate);
- /* 150 */ model.setEnabledTradingAmount(fundsApply.getTotalTradingAmount());
- /* 151 */ FundsSetting fundsSetting = this.iFundsSettingService.getFundsSetting();
- /* */
- /* 153 */ BigDecimal lineUnwind = fundsApply.getMargin().multiply(fundsSetting.getDaysUnwind()).add(fundsApply.getFundsAmount()).setScale(2, 4);
- /* 154 */ model.setLineUnwind(lineUnwind);
- /* */
- /* 156 */ BigDecimal lineWarning = fundsApply.getMargin().multiply(fundsSetting.getDaysWarning()).add(fundsApply.getFundsAmount()).setScale(2, 4);
- /* 157 */ model.setLineWarning(lineWarning);
- /* */ }
- /* 159 */ model.setAuditTime(DateTimeUtil.getCurrentDate());
- /* 160 */ ret = this.fundsApplyMapper.update(model);
- /* 161 */ if (ret > 0) {
- /* 162 */ BigDecimal user_enable_amt = user.getEnableAmt();
- /* */
- /* 164 */ if (model.getStatus().intValue() == 1) {
- /* 165 */ BigDecimal user_all_amt = user.getUserAmt();
- /* */
- /* 167 */ BigDecimal reckon_all = user_all_amt.subtract(fundsApply.getManageFee());
- /* */
- /* 169 */ BigDecimal tradingAmount = user.getTradingAmount().add(fundsApply.getTotalTradingAmount());
- /* 170 */ log.info("【配资审核通过】用户平总资金 = {} , 可用资金 = {} , 总操盘资金 = {}", new Object[] { reckon_all, user_enable_amt, tradingAmount });
- /* 171 */ user.setUserAmt(reckon_all);
- /* 172 */ user.setTradingAmount(tradingAmount);
- /* 173 */ int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user);
- /* 174 */ if (updateUserCount > 0) {
- /* 175 */ log.info("【配资审核通过】修改用户金额成功");
- /* */
- /* 177 */ FundsTradingAccount fundsTradingAccount = this.fundsTradingAccountMapper.getAccountByNumber(model.getSubaccountNumber());
- /* 178 */ if (fundsTradingAccount != null) {
- /* 179 */ fundsTradingAccount.setStatus(Integer.valueOf(1));
- /* 180 */ this.fundsTradingAccountMapper.update(fundsTradingAccount);
- /* */ }
- /* */
- /* 183 */ UserCashDetail ucd = new UserCashDetail();
- /* 184 */ ucd.setPositionId(fundsApply.getId());
- /* 185 */ ucd.setAgentId(user.getAgentId());
- /* 186 */ ucd.setAgentName(user.getAgentName());
- /* 187 */ ucd.setUserId(user.getId());
- /* 188 */ ucd.setUserName(user.getRealName());
- /* 189 */ ucd.setDeType("配资审核通过");
- /* 190 */ ucd.setDeAmt(fundsApply.getPayAmount());
- /* 191 */ ucd.setDeSummary("申请按天配资:" + fundsApply.getOrderNumber() + ",配资审核通过,解冻保证金到配资账户:" + fundsApply.getPayAmount());
- /* 192 */ ucd.setAddTime(new Date());
- /* 193 */ ucd.setIsRead(Integer.valueOf(0));
- /* 194 */ int insertSxfCount = this.userCashDetailMapper.insert(ucd);
- /* 195 */ if (insertSxfCount > 0) {
- /* 196 */ log.info("【配资审核通过】申请成功");
- /* */ }
- /* */ } else {
- /* 199 */ log.error("【配资审核通过】修改用户金额出错");
- /* 200 */ throw new Exception("【配资审核通过】修改用户金额出错");
- /* */ }
- /* */
- /* */ } else {
- /* */
- /* 205 */ BigDecimal reckon_enable = user_enable_amt.add(fundsApply.getPayAmount());
- /* 206 */ user.setEnableAmt(reckon_enable);
- /* 207 */ int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user);
- /* 208 */ if (updateUserCount > 0) {
- /* 209 */ log.info("【配资审核未通过】修改用户金额成功");
- /* 210 */ UserCashDetail ucd = new UserCashDetail();
- /* 211 */ ucd.setPositionId(fundsApply.getId());
- /* 212 */ ucd.setAgentId(user.getAgentId());
- /* 213 */ ucd.setAgentName(user.getAgentName());
- /* 214 */ ucd.setUserId(user.getId());
- /* 215 */ ucd.setUserName(user.getRealName());
- /* 216 */ ucd.setDeType("配资审核未通过");
- /* 217 */ ucd.setDeAmt(fundsApply.getPayAmount());
- /* 218 */ ucd.setDeSummary("申请按天配资:" + fundsApply.getOrderNumber() + ",配资审核未通过,解冻保证金到余额:" + fundsApply.getPayAmount() + ",原因:" + model.getAuditOpinion());
- /* 219 */ ucd.setAddTime(new Date());
- /* 220 */ ucd.setIsRead(Integer.valueOf(0));
- /* 221 */ int insertSxfCount = this.userCashDetailMapper.insert(ucd);
- /* 222 */ if (insertSxfCount > 0) {
- /* 223 */ log.info("【按天配资】申请成功");
- /* */ }
- /* */ } else {
- /* 226 */ log.error("【按天配资】修改用户金额出错");
- /* 227 */ throw new Exception("【按天配资】修改用户金额出错");
- /* */ }
- /* */ }
- /* */
- /* 231 */ log.info("配资申请-审核 = {} 实际购买金额 = {} 比较结果 = {} ", Integer.valueOf(0));
- /* */ }
- /* */ }
- /* 234 */ if (ret > 0) {
- /* 235 */ return ServerResponse.createBySuccessMsg("操作成功");
- /* */ }
- /* 237 */ return ServerResponse.createByErrorMsg("操作失败");
- /* */ }
+ @Transactional(rollbackFor = Exception.class)
+ public ServerResponse audit(FundsApply model, HttpServletRequest request) throws Exception {
+ return ServerResponse.createByErrorMsg("操作失败");
+ }
/*配资申请-查询列表*/
--
Gitblit v1.9.3