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