| | |
| | | package com.nq.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.MoneyLogMapper; |
| | | import com.nq.dao.UserAssetsMapper; |
| | | import com.nq.dao.UserOptionLogMapper; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.enums.EUserAssets; |
| | | import com.nq.pojo.MoneyLog; |
| | | import com.nq.pojo.UserAssets; |
| | | import com.nq.pojo.UserOptionLog; |
| | | import com.nq.service.IUserAssetsServices; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | UserWithdrawServiceImpl withdrawService; |
| | | |
| | | @Resource |
| | | UserOptionLogMapper userOptionLogMapper; |
| | | |
| | | @Override |
| | | public UserAssets assetsByTypeAndUserId(String accetType, Integer userId) { |
| | | if(accetType.equals("SZHB")){ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse updateUserAssets(Integer id, String amt,String type) { |
| | | UserAssets userAssets = userAssetsMapper.selectById(id); |
| | | public ServerResponse updateUserAssets(Integer id, String amt,String type,String accectType) { |
| | | UserAssets userAssets = userAssetsMapper.selectOne(new LambdaQueryWrapper<>(UserAssets.class).eq(UserAssets::getUserId,id).eq(UserAssets::getAccectType,accectType)); |
| | | // 0 入款 1是扣钱 2 是充值 3 是提币 |
| | | BigDecimal bigAmt = new BigDecimal(amt); |
| | | if(type.equals("0") || type.equals("1")){ |
| | |
| | | }else{ |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(bigAmt)); |
| | | } |
| | | }else{ |
| | | if(userAssets.getAvailableBalance().compareTo(BigDecimal.ZERO) <= 0){ |
| | | return ServerResponse.createByErrorMsg("客户账户余额为0"); |
| | | }else if(userAssets.getAvailableBalance().subtract(bigAmt.abs()).compareTo(BigDecimal.ZERO) < 0){ |
| | | return ServerResponse.createByErrorMsg("客户账户余额不足扣款"); |
| | | } |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(bigAmt)); |
| | | } |
| | | if( userAssetsMapper.updateById(userAssets)>0){ |
| | | userOptionLogMapper.insert(UserOptionLog.builder() |
| | | .userId(userAssets.getUserId()) |
| | | .money(bigAmt) |
| | | .userAccectId(userAssets.getId()) |
| | | .createTime(new Date()) |
| | | .type(amt.contains("-")?0:1) |
| | | .build()); |
| | | return ServerResponse.createBySuccess(); |
| | | }else{ |
| | | return ServerResponse.createByErrorMsg("修改金额失败"); |
| | | } |
| | | }else{ |
| | | if(type.equals("2")){ |
| | | return userRechargeService.createOrder(userAssets.getUserId(),1,bigAmt.intValue(),"1"); |
| | | return userRechargeService.createOrder(id,1,bigAmt.intValue(),"1",accectType); |
| | | }else{ |
| | | |
| | | |