代理商提现
This commit is contained in:
@@ -11,6 +11,7 @@ import com.alipay.api.request.AlipayFundTransUniTransferRequest;
|
|||||||
import com.alipay.api.response.AlipayFundTransToaccountTransferResponse;
|
import com.alipay.api.response.AlipayFundTransToaccountTransferResponse;
|
||||||
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
|
import com.sqx.modules.app.annotation.Login;
|
||||||
import com.sqx.modules.app.entity.UserEntity;
|
import com.sqx.modules.app.entity.UserEntity;
|
||||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||||
@@ -57,16 +58,24 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
@RequestMapping(value = "/cash")
|
@RequestMapping(value = "/cash")
|
||||||
public class CashController {
|
public class CashController {
|
||||||
|
|
||||||
/** 充值记录 */
|
/**
|
||||||
|
* 充值记录
|
||||||
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private PayDetailsService payDetailsService;
|
private PayDetailsService payDetailsService;
|
||||||
/** 提现记录 */
|
/**
|
||||||
|
* 提现记录
|
||||||
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private CashOutService cashOutService;
|
private CashOutService cashOutService;
|
||||||
/** app用户 */
|
/**
|
||||||
|
* app用户
|
||||||
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
/** 通用配置 */
|
/**
|
||||||
|
* 通用配置
|
||||||
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private CommonInfoService commonInfoService;
|
private CommonInfoService commonInfoService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -405,7 +414,6 @@ public class CashController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/refund/{cashId}/{content}", method = RequestMethod.POST)
|
@RequestMapping(value = "/refund/{cashId}/{content}", method = RequestMethod.POST)
|
||||||
@ApiOperation("管理平台退款")
|
@ApiOperation("管理平台退款")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@@ -465,10 +473,16 @@ public class CashController {
|
|||||||
|
|
||||||
@GetMapping(value = "/cashMoney")
|
@GetMapping(value = "/cashMoney")
|
||||||
@ApiOperation("发起提现")
|
@ApiOperation("发起提现")
|
||||||
public Result cashMoney(Long userId,Double money)
|
public Result cashMoney(Long userId, Double money) {
|
||||||
{
|
|
||||||
return cashOutService.sysCashMoney(userId, money);
|
return cashOutService.sysCashMoney(userId, money);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Login
|
||||||
|
@GetMapping(value = "/withdraw")
|
||||||
|
@ApiOperation("发起提现 余额 金钱")
|
||||||
|
public Result withdraw(Long userId, Double amount) {
|
||||||
|
return cashOutService.withdraw(userId, amount, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,9 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
@RequestMapping(value = "/app/cash")
|
@RequestMapping(value = "/app/cash")
|
||||||
public class AppCashController {
|
public class AppCashController {
|
||||||
|
|
||||||
/** 提现记录 */
|
/**
|
||||||
|
* 提现记录
|
||||||
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private CashOutService cashOutService;
|
private CashOutService cashOutService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -44,7 +46,7 @@ public class AppCashController {
|
|||||||
@GetMapping(value = "/withdraw")
|
@GetMapping(value = "/withdraw")
|
||||||
@ApiOperation("发起提现 余额 金钱")
|
@ApiOperation("发起提现 余额 金钱")
|
||||||
public Result withdraw(@RequestAttribute("userId") Long userId, Double amount) {
|
public Result withdraw(@RequestAttribute("userId") Long userId, Double amount) {
|
||||||
return cashOutService.withdraw(userId,amount);
|
return cashOutService.withdraw(userId, amount, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
|
|||||||
@@ -24,10 +24,8 @@ import com.sqx.modules.utils.AliPayOrderUtil;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ public interface CashOutService {
|
|||||||
*
|
*
|
||||||
* @param userId 用户Id tb_user的id
|
* @param userId 用户Id tb_user的id
|
||||||
* @param money 提现金额
|
* @param money 提现金额
|
||||||
* @return
|
* @param isSys 是否是系统用户提现
|
||||||
*/
|
*/
|
||||||
Result withdraw(Long userId, Double money);
|
Result withdraw(Long userId, Double money, boolean isSys);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
List<CashOut> cashOutList = baseMapper.selectCashOutList(cashOut1);
|
List<CashOut> cashOutList = baseMapper.selectCashOutList(cashOut1);
|
||||||
ExcelData data = new ExcelData();
|
ExcelData data = new ExcelData();
|
||||||
data.setName("提现列表");
|
data.setName("提现列表");
|
||||||
List<String> titles = new ArrayList();
|
List<String> titles = new ArrayList<>();
|
||||||
titles.add("编号");
|
titles.add("编号");
|
||||||
titles.add("用户类型");
|
titles.add("用户类型");
|
||||||
titles.add("用户名称");
|
titles.add("用户名称");
|
||||||
@@ -100,9 +100,9 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
titles.add("转账/拒绝时间");
|
titles.add("转账/拒绝时间");
|
||||||
titles.add("转账订单号");
|
titles.add("转账订单号");
|
||||||
data.setTitles(titles);
|
data.setTitles(titles);
|
||||||
List<List<Object>> rows = new ArrayList();
|
List<List<Object>> rows = new ArrayList<>();
|
||||||
for (CashOut cashOut : cashOutList) {
|
for (CashOut cashOut : cashOutList) {
|
||||||
List<Object> row = new ArrayList();
|
List<Object> row = new ArrayList<>();
|
||||||
row.add(cashOut.getId());
|
row.add(cashOut.getId());
|
||||||
if (cashOut.getUserType() == 1) {
|
if (cashOut.getUserType() == 1) {
|
||||||
row.add("用户");
|
row.add("用户");
|
||||||
@@ -186,11 +186,6 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 退款成功通知
|
* 退款成功通知
|
||||||
*
|
|
||||||
* @param
|
|
||||||
* @param date
|
|
||||||
* @param money
|
|
||||||
* @param url
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void refundSuccess(UserEntity userByWxId, String date, String money, String url, String content) {
|
public void refundSuccess(UserEntity userByWxId, String date, String money, String url, String content) {
|
||||||
@@ -296,16 +291,17 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
}
|
}
|
||||||
//手续费
|
//手续费
|
||||||
CommonInfo one1 = commonInfoService.findOne(152);
|
CommonInfo one1 = commonInfoService.findOne(152);
|
||||||
Double mul = AmountCalUtils.mul(money, Double.parseDouble(one1.getValue()));
|
double mul = AmountCalUtils.mul(money, Double.parseDouble(one1.getValue()));
|
||||||
if (mul < 0.01) {
|
if (mul < 0.01) {
|
||||||
mul = 0.01;
|
mul = 0.01;
|
||||||
}
|
}
|
||||||
// UserMoney userMoney=userMoneyService.selectUserMoneyByUserId(userId);
|
// UserMoney userMoney=userMoneyService.selectUserMoneyByUserId(userId);
|
||||||
InviteMoney inviteMoney = inviteMoneyService.selectInviteMoneyByUserId(userId);
|
InviteMoney inviteMoney = inviteMoneyService.selectInviteMoneyByUserId(userId);
|
||||||
UserEntity userEntity = userService.selectUserById(userId);
|
UserEntity userEntity = userService.selectUserById(userId);
|
||||||
//提现判断金豆是否足够
|
// 提现判断金豆是否足够 金豆=提现金豆+手续费
|
||||||
Double moneySum = AmountCalUtils.add(new BigDecimal(money), new BigDecimal(mul)).doubleValue(); //金豆=提现金豆+手续费
|
Double moneySum = AmountCalUtils.add(new BigDecimal(money), new BigDecimal(mul)).doubleValue();
|
||||||
if (inviteMoney.getMoney() >= moneySum) { //用户金豆足够
|
// 用户金豆足够
|
||||||
|
if (inviteMoney.getMoney() >= moneySum) {
|
||||||
//扣除可提现金豆
|
//扣除可提现金豆
|
||||||
inviteMoneyService.updateInviteMoneyCashOut(2, moneySum, userId);
|
inviteMoneyService.updateInviteMoneyCashOut(2, moneySum, userId);
|
||||||
//增加金豆操作记录
|
//增加金豆操作记录
|
||||||
@@ -355,16 +351,17 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
}
|
}
|
||||||
//手续费
|
//手续费
|
||||||
CommonInfo one1 = commonInfoService.findOne(152);
|
CommonInfo one1 = commonInfoService.findOne(152);
|
||||||
Double mul = AmountCalUtils.mul(money, Double.parseDouble(one1.getValue()));
|
double mul = AmountCalUtils.mul(money, Double.parseDouble(one1.getValue()));
|
||||||
if (mul < 0.01) {
|
if (mul < 0.01) {
|
||||||
mul = 0.01;
|
mul = 0.01;
|
||||||
}
|
}
|
||||||
UserMoney userMoney = userMoneyService.selectSysUserMoneyByUserId(userId);
|
UserMoney userMoney = userMoneyService.selectSysUserMoneyByUserId(userId);
|
||||||
|
|
||||||
SysUserEntity sysUserEntity = sysUserService.getById(userId);
|
SysUserEntity sysUserEntity = sysUserService.getById(userId);
|
||||||
//提现判断金豆是否足够
|
//提现判断金豆是否足够 金豆=提现金豆+手续费
|
||||||
Double moneySum = AmountCalUtils.add(new BigDecimal(money), new BigDecimal(mul)).doubleValue(); //金豆=提现金豆+手续费
|
double moneySum = AmountCalUtils.add(new BigDecimal(money), new BigDecimal(mul)).doubleValue();
|
||||||
if (userMoney.getMoney().doubleValue() >= moneySum) { //用户金豆足够
|
// 用户金豆足够
|
||||||
|
if (userMoney.getMoney().doubleValue() >= moneySum) {
|
||||||
//扣除可提现金豆
|
//扣除可提现金豆
|
||||||
userMoneyService.updateSysMoney(2, userId, moneySum);
|
userMoneyService.updateSysMoney(2, userId, moneySum);
|
||||||
//增加金豆操作记录
|
//增加金豆操作记录
|
||||||
@@ -400,25 +397,46 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Result withdraw(Long userId, Double money) {
|
public Result withdraw(Long userId, Double money, boolean isSys) {
|
||||||
if (money == null || money <= 0.00) {
|
if (money == null || money <= 0.00) {
|
||||||
return Result.error("请不要输入小于0的数字,请输入正确的提现金额!");
|
return Result.error("请不要输入小于0的数字,请输入正确的提现金额!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String alipayAccount;
|
||||||
|
String alipayName;
|
||||||
|
|
||||||
|
if (isSys) {
|
||||||
|
SysUserEntity sysUserEntity = sysUserService.getById(userId);
|
||||||
|
if (StringUtils.isBlank(sysUserEntity.getZhiFuBao()) || StringUtils.isBlank(sysUserEntity.getZhiFuBaoName())) {
|
||||||
|
return Result.error(9999, "请先绑定支付宝账号!");
|
||||||
|
}
|
||||||
|
alipayAccount = sysUserEntity.getZhiFuBao();
|
||||||
|
alipayName = sysUserEntity.getZhiFuBaoName();
|
||||||
|
} else {
|
||||||
UserEntity userInfo = userService.queryByUserId(userId);
|
UserEntity userInfo = userService.queryByUserId(userId);
|
||||||
if (StringUtils.isBlank(userInfo.getZhiFuBao()) || StringUtils.isBlank(userInfo.getZhiFuBaoName())) {
|
if (StringUtils.isBlank(userInfo.getZhiFuBao()) || StringUtils.isBlank(userInfo.getZhiFuBaoName())) {
|
||||||
return Result.error(9999, "请先绑定支付宝账号!");
|
return Result.error(9999, "请先绑定支付宝账号!");
|
||||||
}
|
}
|
||||||
|
alipayAccount = userInfo.getZhiFuBao();
|
||||||
|
alipayName = userInfo.getZhiFuBaoName();
|
||||||
|
}
|
||||||
|
|
||||||
// 最低提现金额
|
// 最低提现金额
|
||||||
// CommonInfo one = commonInfoService.findOne(112);
|
CommonInfo one = commonInfoService.findOne(112);
|
||||||
// if(one!=null && money<Double.parseDouble(one.getValue())){
|
if(one!=null && money<Double.parseDouble(one.getValue())){
|
||||||
// return Result.error("不满足最低提现金额,请重新输入!");
|
return Result.error("不满足最低提现金额,请重新输入!");
|
||||||
// }
|
}
|
||||||
|
|
||||||
CashOut cashOut = new CashOut();
|
CashOut cashOut = new CashOut();
|
||||||
cashOut.setIsOut(false);
|
cashOut.setIsOut(false);
|
||||||
cashOut.setMoney(money.toString());
|
cashOut.setMoney(money.toString());
|
||||||
cashOut.setUserId(userInfo.getUserId());
|
if (isSys) {
|
||||||
cashOut.setZhifubao(userInfo.getZhiFuBao());
|
cashOut.setSysUserId(userId);
|
||||||
cashOut.setZhifubaoName(userInfo.getZhiFuBaoName());
|
} else {
|
||||||
|
cashOut.setUserId(userId);
|
||||||
|
}
|
||||||
|
cashOut.setZhifubao(alipayAccount);
|
||||||
|
cashOut.setZhifubaoName(alipayName);
|
||||||
|
|
||||||
cashOut.setState(0);
|
cashOut.setState(0);
|
||||||
cashOut.setRate(0.00);
|
cashOut.setRate(0.00);
|
||||||
@@ -437,7 +455,12 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
userMoneyDetails.setClassify(4);
|
userMoneyDetails.setClassify(4);
|
||||||
userMoneyDetails.setMoney(new BigDecimal(money));
|
userMoneyDetails.setMoney(new BigDecimal(money));
|
||||||
userMoneyDetails.setCreateTime(date);
|
userMoneyDetails.setCreateTime(date);
|
||||||
UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
UserMoney userMoney;
|
||||||
|
if (isSys) {
|
||||||
|
userMoney = userMoneyService.selectSysUserMoneyByUserId(userId);
|
||||||
|
} else {
|
||||||
|
userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
||||||
|
}
|
||||||
//提现判断余额是否足够
|
//提现判断余额是否足够
|
||||||
if (userMoney.getAmount().doubleValue() < money) {
|
if (userMoney.getAmount().doubleValue() < money) {
|
||||||
return Result.success("可提现余额不足!");
|
return Result.success("可提现余额不足!");
|
||||||
|
|||||||
Reference in New Issue
Block a user