Commit 92797cf8 authored by hezhen's avatar hezhen

123

parent 27388812
package com.github.wxiaoqi.security.admin.dto;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/17 20:22
*/
@Data
public class WalletCathSumDto {
//总金额
private BigDecimal sumAmount;
//总次数
private Integer number;
//用户余额
private BigDecimal balance;
//费率
private BigDecimal proceduReates;
//钱包id
private Integer walletId;
}
...@@ -33,7 +33,7 @@ public class MyWalletCath implements Serializable { ...@@ -33,7 +33,7 @@ public class MyWalletCath implements Serializable {
*/ */
@Column(name = "user_id") @Column(name = "user_id")
@ApiModelProperty(value = "用户iD") @ApiModelProperty(value = "用户iD")
private String userId; private Integer userId;
/** /**
* 提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡) * 提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡)
...@@ -45,9 +45,9 @@ public class MyWalletCath implements Serializable { ...@@ -45,9 +45,9 @@ public class MyWalletCath implements Serializable {
/** /**
* 商户订单号 * 商户订单号
*/ */
@Column(name = "orderno") @Column(name = "account_number")
@ApiModelProperty(value = "商户订单号") @ApiModelProperty(value = "用户账号")
private String orderno; private String accountNumber;
/** /**
* 第三方订单号:如微信,支付宝,银行卡等 * 第三方订单号:如微信,支付宝,银行卡等
...@@ -56,6 +56,15 @@ public class MyWalletCath implements Serializable { ...@@ -56,6 +56,15 @@ public class MyWalletCath implements Serializable {
@ApiModelProperty(value = "第三方订单号:如微信,支付宝,银行卡等") @ApiModelProperty(value = "第三方订单号:如微信,支付宝,银行卡等")
private String cono; private String cono;
/**
* 提现金额
*/
@Column(name = "balance")
@ApiModelProperty(value = "当前钱包余额")
private BigDecimal balance;
/** /**
* 提现金额 * 提现金额
*/ */
...@@ -64,6 +73,21 @@ public class MyWalletCath implements Serializable { ...@@ -64,6 +73,21 @@ public class MyWalletCath implements Serializable {
private BigDecimal amount; private BigDecimal amount;
/** /**
* 到账金额
*/
@Column(name = "real_amount")
@ApiModelProperty(value = "到账金额")
private BigDecimal realAmount;
/**
* 手续费
*/
@Column(name = "commission")
@ApiModelProperty(value = "手续费")
private BigDecimal commission;
/**
* 订单状态:0-未提现,待审核,1-已审核 * 订单状态:0-未提现,待审核,1-已审核
*/ */
@Column(name = "stauts") @Column(name = "stauts")
...@@ -87,9 +111,9 @@ public class MyWalletCath implements Serializable { ...@@ -87,9 +111,9 @@ public class MyWalletCath implements Serializable {
/** /**
* 操作者ID * 操作者ID
*/ */
@Column(name = "oper_user") @Column(name = "upd_user")
@ApiModelProperty(value = "操作者ID") @ApiModelProperty(value = "操作者ID")
private String operUser; private String updUser;
} }
package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 9:20
*/
@Data
public class ApplyCathVo {
/**
* 用户ID
*/
@ApiModelProperty("用户ID")
private Integer userId;
/**
* 提现金额
*/
@ApiModelProperty(value = "提现金额")
private BigDecimal amount;
/**
* 支付密码
*/
@ApiModelProperty(value = "支付密码")
private String password;
/**
* 支付账号
*/
@ApiModelProperty(value = "支付账号")
private String accountNumber;
/**
* 支付类型
*/
@ApiModelProperty(value = "支付类型")
private Integer cathType;
}
...@@ -46,6 +46,11 @@ ...@@ -46,6 +46,11 @@
<artifactId>xx-im-api</artifactId> <artifactId>xx-im-api</artifactId>
<version>2.0-SNAPSHOT</version> <version>2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-app-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>com.xxfc.platform</groupId> <groupId>com.xxfc.platform</groupId>
<artifactId>xx-activity-api</artifactId> <artifactId>xx-activity-api</artifactId>
......
package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.entity.AppUserAlipay;
import com.github.wxiaoqi.security.admin.entity.AppUserRelationTemp;
import com.github.wxiaoqi.security.admin.mapper.AppUserAlipayMapper;
import com.github.wxiaoqi.security.admin.mapper.AppUserRelationTempMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
* 支付宝账号表
*
* @author libin
* @email 18178966185@163.com
* @date 2019-07-03 16:36:44
*/
@Service
public class AppUserAlipayBiz extends BaseBiz<AppUserAlipayMapper, AppUserAlipay> {
//添加支付宝账号
public void addAlipay(Integer userId,String txAlipay){
AppUserAlipay appUserAlipay=new AppUserAlipay();
appUserAlipay.setTxAlipay(txAlipay);
appUserAlipay.setUserId(userId);
appUserAlipay.setIsDel(0);
AppUserAlipay appUserAlipay1=selectOne(appUserAlipay);
if (appUserAlipay1==null){
appUserAlipay.setIsDefault(1);
insertSelective(appUserAlipay);
}else {
appUserAlipay1.setIsDefault(1);
updateSelectiveById(appUserAlipay1);
}
}
//获取支付宝列表
public List<AppUserAlipay> getListByUserId(Integer userId){
Example example=new Example(AppUserAlipay.class);
example.createCriteria().andEqualTo("userId",userId).andEqualTo("isDel",0);
example.setOrderByClause("is_default desc");
return selectByExample(example);
}
}
\ No newline at end of file
package com.github.wxiaoqi.security.admin.biz; package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.dto.WalletCathSumDto;
import com.github.wxiaoqi.security.admin.dto.WalletFindDTO; import com.github.wxiaoqi.security.admin.dto.WalletFindDTO;
import com.github.wxiaoqi.security.admin.dto.WalletListDTO; import com.github.wxiaoqi.security.admin.dto.WalletListDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserAlipay;
import com.github.wxiaoqi.security.admin.entity.MyWallet; import com.github.wxiaoqi.security.admin.entity.MyWallet;
import com.github.wxiaoqi.security.admin.entity.MyWalletCath;
import com.github.wxiaoqi.security.admin.entity.MyWalletDetail;
import com.github.wxiaoqi.security.admin.mapper.MyWalletMapper; import com.github.wxiaoqi.security.admin.mapper.MyWalletMapper;
import com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService;
import com.github.wxiaoqi.security.admin.vo.AppletWalletVo; import com.github.wxiaoqi.security.admin.vo.AppletWalletVo;
import com.github.wxiaoqi.security.admin.vo.ApplyCathVo;
import com.github.wxiaoqi.security.admin.vo.WalletPageVo; import com.github.wxiaoqi.security.admin.vo.WalletPageVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.constant.UserConstant;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.activity.feign.ActivityFeign; import com.xxfc.platform.app.entity.vo.WithDrawRuleVo;
import com.xxfc.platform.app.feign.ConfigFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -29,6 +45,7 @@ import java.util.stream.Collectors; ...@@ -29,6 +45,7 @@ import java.util.stream.Collectors;
*/ */
@Transactional @Transactional
@Service @Service
@Slf4j
public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
@Autowired @Autowired
...@@ -37,6 +54,21 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { ...@@ -37,6 +54,21 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
@Autowired @Autowired
private MyWalletCathBiz myWalletCathBiz; private MyWalletCathBiz myWalletCathBiz;
@Autowired
private AppPermissionService permissionService;
@Autowired
private RedisTemplate userRedisTemplate;
@Autowired
private ConfigFeign configFeign;
@Autowired
private AppUserAlipayBiz alipayBiz;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
public AppletWalletVo findMyWallet(Integer userId) { public AppletWalletVo findMyWallet(Integer userId) {
...@@ -97,4 +129,227 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { ...@@ -97,4 +129,227 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
walletPageVo.setData(walletPageVos); walletPageVo.setData(walletPageVos);
return walletPageVo; return walletPageVo;
} }
//检查手机号码是否正确
public ObjectRestResponse checkCode(String phone,String mobilecod){
boolean flag=false;
String key=permissionService.checkCodeByUsername(phone,mobilecod);
if (StringUtils.isNotBlank(key)){
flag=true;
}
return ObjectRestResponse.succ(flag);
}
//设置密码type 1-设置密码;2-设置密码
public ObjectRestResponse setPwd(Integer userId,String phone,String mobilecod,String password,Integer type){
if (StringUtils.isBlank(phone)||StringUtils.isBlank(mobilecod)||StringUtils.isBlank(password)){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空");
}
String key=permissionService.checkCodeByUsername(phone,mobilecod);
if (StringUtils.isBlank(key)){
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
}
userRedisTemplate.delete(key);
MyWallet myWallet=new MyWallet();
myWallet.setUserId(userId);
myWallet = selectOne(myWallet);
if (myWallet==null){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "钱包不存在");
}
if(type==1||StringUtils.isNotBlank(myWallet.getPayPassword())){
return ObjectRestResponse.createFailedResult(ResultCode.EXIST_CODE, "密码已存在");
}
password=new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(password);
myWallet.setPayPassword(password);
updateSelectiveById(myWallet);
return ObjectRestResponse.succ();
}
//检查用户是否设置过密码
public ObjectRestResponse checkSetPwd(Integer userId){
MyWallet myWallet=new MyWallet();
myWallet.setUserId(userId);
myWallet = selectOne(myWallet);
if (myWallet==null){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "钱包不存在");
}
boolean flag=false;
if(StringUtils.isNotBlank(myWallet.getPayPassword())){
flag=true;
}
return ObjectRestResponse.succ(flag);
}
//检查提成下一步操作
public ObjectRestResponse checkAmount(Integer userId,BigDecimal amount,String password){
if (amount.compareTo(BigDecimal.ZERO)<1){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能小于0");
}
MyWallet myWallet=new MyWallet();
myWallet.setUserId(userId);
myWallet = selectOne(myWallet);
if (myWallet==null){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "钱包不存在");
}
if (amount.compareTo(myWallet.getBalance())>0){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "提现金额不能大于钱包金额");
}
if (StringUtils.isNotBlank(password)&&!encoder.matches(password,myWallet.getPayPassword())){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "支付密码错误");
}
WithDrawRuleVo ruleVo=configFeign.getWithDrawRule();
BigDecimal proceduReates=BigDecimal.ZERO;
WalletCathSumDto sumDto=new WalletCathSumDto();
if (ruleVo!=null){
proceduReates=ruleVo.getProceduReates();
//提现次数
Integer number=1;
//最小金额
BigDecimal mimAmount=ruleVo.getMinAmount();
if (mimAmount.compareTo(BigDecimal.ZERO)>0&&amount.compareTo(mimAmount)<0){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能小于"+mimAmount+"元");
}
//日额度
BigDecimal amountOfDay=ruleVo.getAmountOfDay();
//每日次数
Integer maxNumberOfDay=ruleVo.getMaxNumberOfDay()==null?0:ruleVo.getMaxNumberOfDay();
//查询当日次数和金额
sumDto=myWalletCathBiz.sumCathAmount(1);
BigDecimal ramount=amount.add(sumDto.getSumAmount());
if (amountOfDay.compareTo(BigDecimal.ZERO)>0&&ramount.compareTo(amountOfDay)>0){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额超过日额度"+amountOfDay+"元");
}
number+=sumDto.getNumber();
if (maxNumberOfDay>0&&number>maxNumberOfDay){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现当日次数超过"+maxNumberOfDay+"次");
}
number=1;
//月额度
BigDecimal amountOfMonth=ruleVo.getAmountOfMonth();
//月次数
Integer maxNumberOfMonth=ruleVo.getMaxNumberOfMonth();
//查询当月次数和金额
sumDto=myWalletCathBiz.sumCathAmount(2);
BigDecimal yamount=amount.add(sumDto.getSumAmount());
if (amountOfMonth.compareTo(BigDecimal.ZERO)>0&&yamount.compareTo(amountOfMonth)>0){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额超过月额度"+amountOfMonth+"元");
}
number+=sumDto.getNumber();
if (maxNumberOfMonth>0&&number>maxNumberOfMonth){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现当月次数超过"+maxNumberOfMonth+"次");
}
}
sumDto.setBalance(myWallet.getBalance());
sumDto.setProceduReates(proceduReates);
sumDto.setWalletId(myWallet.getId());
return ObjectRestResponse.succ(sumDto);
}
//返回提现规则
public ObjectRestResponse getCathRule(){
return ObjectRestResponse.succ(configFeign.getWithDrawRule());
}
//提现申请
public ObjectRestResponse applyCath(ApplyCathVo applyCathVo){
if (applyCathVo==null){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
}
Integer userId=applyCathVo.getUserId();
BigDecimal amount=applyCathVo.getAmount();
String password=applyCathVo.getPassword();
String accountNumber=applyCathVo.getAccountNumber();
Integer cathType=applyCathVo.getCathType()==null?1:applyCathVo.getCathType();
if (StringUtils.isBlank(password)||amount.compareTo(BigDecimal.ZERO)<1){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
}
ObjectRestResponse restResponse=checkAmount(userId,amount,password);
if (restResponse.getStatus()!=ResultCode.SUCCESS_CODE){
return restResponse;
}
WalletCathSumDto sumDto=JSONUtil.toBean( restResponse.getData().toString(),WalletCathSumDto.class);
if (sumDto==null){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
}
BigDecimal commission=amount.divide(sumDto.getProceduReates()).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
BigDecimal balnece=sumDto.getBalance();
//到账金额
BigDecimal realAmount=balnece.subtract(commission);
if (amount.compareTo(realAmount)>0){
realAmount=amount;
}
log.info("-----提现申请-----proceduReates==="+sumDto.getProceduReates()+"----commission===="+commission+"---realAmount==="+realAmount);
//添加账号
alipayBiz.addAlipay(userId,accountNumber);
MyWalletCath walletCath=new MyWalletCath();
walletCath.setUserId(userId);
walletCath.setBalance(balnece);
walletCath.setCathType(cathType);
walletCath.setAccountNumber(accountNumber);
walletCath.setAmount(amount);
walletCath.setCommission(commission);
walletCath.setRealAmount(realAmount);
myWalletCathBiz.insertSelective(walletCath);
//提现金额
BigDecimal withdrawals=realAmount.add(commission);
balnece=balnece.subtract(withdrawals).setScale(2, RoundingMode.HALF_UP);
log.info("------钱包----withdrawals==="+withdrawals+"----balnece===="+balnece);
MyWallet myWallet=new MyWallet();
myWallet.setId(sumDto.getWalletId());
myWallet.setUserId(userId);
myWallet.setBalance(balnece);
myWallet.setWithdrawals(withdrawals);
mapper.updMyWater(myWallet);
return ObjectRestResponse.succ();
}
//提现审核
public ObjectRestResponse verifyCath(Integer cathId,String cono){
if (StringUtils.isBlank(cono)||cathId==null||cathId==0){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
}
MyWalletCath cath=myWalletCathBiz.selectById(cathId);
if (cath==null){
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "提现记录不存在");
}
cath.setStauts(1);
cath.setCono(cono);
cath.setFinishTime(System.currentTimeMillis());
int num=myWalletCathBiz.updateSelectiveByIdRe(cath);
if (num>0){
Integer userId=cath.getUserId();
MyWallet wallet=new MyWallet();
wallet.setUserId(userId);
wallet=selectOne(wallet);
if (wallet!=null){
BigDecimal balance=cath.getBalance();
BigDecimal realAmount=cath.getRealAmount();
BigDecimal commission=cath.getCommission();
MyWalletDetail detail=new MyWalletDetail();
detail.setUserId(userId);
detail.setItype(1);
detail.setCono(cathId);
detail.setBalance(balance);
detail.setAmount(realAmount);
detail.setSource(10);
myWalletDetailBiz.insertSelective(detail);
detail.setId(null);
detail.setSource(13);
balance=balance.subtract(realAmount).setScale(2, RoundingMode.HALF_UP);
detail.setBalance(balance);
detail.setAmount(commission);
myWalletDetailBiz.insertSelective(detail);
}
}
return ObjectRestResponse.succ();
}
} }
...@@ -3,6 +3,7 @@ package com.github.wxiaoqi.security.admin.biz; ...@@ -3,6 +3,7 @@ package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.dto.PersonalConsumptionDTO; import com.github.wxiaoqi.security.admin.dto.PersonalConsumptionDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathFindDTO; import com.github.wxiaoqi.security.admin.dto.WalletCathFindDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathListDTO; import com.github.wxiaoqi.security.admin.dto.WalletCathListDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathSumDto;
import com.github.wxiaoqi.security.admin.entity.MyWalletCath; import com.github.wxiaoqi.security.admin.entity.MyWalletCath;
import com.github.wxiaoqi.security.admin.mapper.MyWalletCathMapper; import com.github.wxiaoqi.security.admin.mapper.MyWalletCathMapper;
import com.github.wxiaoqi.security.admin.vo.WalletCathAdminVo; import com.github.wxiaoqi.security.admin.vo.WalletCathAdminVo;
...@@ -120,4 +121,8 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> { ...@@ -120,4 +121,8 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
Map<Integer, BigDecimal> userIdAndPersonalConsumptionMap = personalConsumptions.stream().collect(Collectors.toMap(PersonalConsumptionDTO::getUserId, PersonalConsumptionDTO::getTotalConsumption)); Map<Integer, BigDecimal> userIdAndPersonalConsumptionMap = personalConsumptions.stream().collect(Collectors.toMap(PersonalConsumptionDTO::getUserId, PersonalConsumptionDTO::getTotalConsumption));
return userIdAndPersonalConsumptionMap; return userIdAndPersonalConsumptionMap;
} }
public WalletCathSumDto sumCathAmount(Integer type){
return mapper.sumCathAmount(type);
}
} }
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppUserAlipay;
import tk.mybatis.mapper.common.Mapper;
/**
* 钱包提现表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
public interface AppUserAlipayMapper extends Mapper<AppUserAlipay> {
}
...@@ -2,10 +2,10 @@ package com.github.wxiaoqi.security.admin.mapper; ...@@ -2,10 +2,10 @@ package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.dto.PersonalConsumptionDTO; import com.github.wxiaoqi.security.admin.dto.PersonalConsumptionDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathListDTO; import com.github.wxiaoqi.security.admin.dto.WalletCathListDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathSumDto;
import com.github.wxiaoqi.security.admin.entity.MyWalletCath; import com.github.wxiaoqi.security.admin.entity.MyWalletCath;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List; import java.util.List;
/** /**
...@@ -22,4 +22,12 @@ public interface MyWalletCathMapper extends Mapper<MyWalletCath> { ...@@ -22,4 +22,12 @@ public interface MyWalletCathMapper extends Mapper<MyWalletCath> {
@Param("state") Integer state); @Param("state") Integer state);
List<PersonalConsumptionDTO> findUserWithDrawingByUserIds(@Param("userIds") List<Integer> userIds); List<PersonalConsumptionDTO> findUserWithDrawingByUserIds(@Param("userIds") List<Integer> userIds);
/**
* 计算提现的金额
* @param type 1-日;2-月
* @return
*/
WalletCathSumDto sumCathAmount(@Param("type") int type);
} }
package com.github.wxiaoqi.security.admin.rest; package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.AppUserAlipayBiz;
import com.github.wxiaoqi.security.admin.biz.MyWalletBiz; import com.github.wxiaoqi.security.admin.biz.MyWalletBiz;
import com.github.wxiaoqi.security.admin.vo.AppletWalletVo; import com.github.wxiaoqi.security.admin.vo.AppletWalletVo;
import com.github.wxiaoqi.security.admin.vo.ApplyCathVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil; import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo; import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
/** /**
* @author libin * @author libin
...@@ -34,6 +35,10 @@ public class MyWalletController { ...@@ -34,6 +35,10 @@ public class MyWalletController {
@Autowired @Autowired
private MyWalletBiz myWalletBiz; private MyWalletBiz myWalletBiz;
@Autowired
private AppUserAlipayBiz alipayBiz;
@GetMapping @GetMapping
public ObjectRestResponse<AppletWalletVo> findMyWallet(HttpServletRequest request){ public ObjectRestResponse<AppletWalletVo> findMyWallet(HttpServletRequest request){
try { try {
...@@ -46,4 +51,96 @@ public class MyWalletController { ...@@ -46,4 +51,96 @@ public class MyWalletController {
} }
@GetMapping
@ApiOperation("检查验证码")
public ObjectRestResponse checkCode(
@RequestParam(value = "phone",defaultValue = "")String phone,
@RequestParam(value = "mobilecode",defaultValue = "")String mobilecod
){
return myWalletBiz.checkCode(phone,mobilecod);
}
@PostMapping("/setPwd")
@ApiOperation("设置密码")
public ObjectRestResponse setPwd(
@RequestParam(value = "phone",defaultValue = "")String phone,
@RequestParam(value = "mobilecode",defaultValue = "")String mobilecod,
@RequestParam(value = "password",defaultValue = "")String password,
@RequestParam(value = "type",defaultValue = "1")Integer type,
HttpServletRequest request){
try {
Integer userId=Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
return myWalletBiz.setPwd(userId,phone,mobilecod,password,type);
}catch (Exception e) {
throw new BaseException(e);
}
}
@GetMapping("/checkSetPwd")
@ApiOperation("检查用户是否设置过支付密码")
public ObjectRestResponse checkSetPwd(HttpServletRequest request){
try {
Integer userId=Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
return myWalletBiz.checkSetPwd(userId);
}catch (Exception e) {
throw new BaseException(e);
}
}
@GetMapping("/checkAmount")
@ApiOperation("检查提成下一步操作")
public ObjectRestResponse checkAmount(
@RequestParam(value = "amount",defaultValue = "0.00") BigDecimal amount,
HttpServletRequest request){
try {
Integer userId=Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
return myWalletBiz.checkAmount(userId,amount,null);
}catch (Exception e) {
throw new BaseException(e);
}
}
@PostMapping("/applyCath")
@ApiOperation("提现申请")
public ObjectRestResponse applyCath(@RequestBody ApplyCathVo applyCathVo, HttpServletRequest request){
try {
Integer userId=Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
return myWalletBiz.applyCath(applyCathVo);
}catch (Exception e) {
throw new BaseException(e);
}
}
@PostMapping("/verifyCath")
@ApiOperation("提现审核")
public ObjectRestResponse verifyCath(
@RequestParam(value = "cathId",defaultValue = "0") Integer cathId,
@RequestParam(value = "cono",defaultValue = "") String cono){
try {
return myWalletBiz.verifyCath(cathId,cono);
}catch (Exception e) {
throw new BaseException(e);
}
}
@GetMapping("/txAlipayList")
@ApiOperation("获取支付账号列表")
public ObjectRestResponse txAlipayList(HttpServletRequest request){
try {
Integer userId=Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
return ObjectRestResponse.succ(alipayBiz.getListByUserId(userId)) ;
}catch (Exception e) {
throw new BaseException(e);
}
}
} }
...@@ -205,6 +205,23 @@ public class AppPermissionService { ...@@ -205,6 +205,23 @@ public class AppPermissionService {
return JsonResultUtil.createSuccessResultWithObj(result); return JsonResultUtil.createSuccessResultWithObj(result);
} }
//检查验证码是否正确
public String checkCodeByUsername(String username,String mobilecode){
// 判断参数和验证码
if (StringUtils.isBlank(username) || StringUtils.isBlank(mobilecode)) {
log.info("---参数为空------");
return null;
}
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX + username + mobilecode;
String mobilecodeRedis = userRedisTemplate.opsForValue().get(redisLockKey) == null ? "" : userRedisTemplate.opsForValue().get(redisLockKey).toString();
log.error("checkCodeByUsername接口,获取redis中的验证码:" + mobilecodeRedis);
if (StringUtils.isBlank(mobilecodeRedis)) {
log.info("---验证码错误------username==="+username);
return null;
}
return redisLockKey;
}
/** /**
* 注册用户 * 注册用户
* *
......
...@@ -34,4 +34,21 @@ ...@@ -34,4 +34,21 @@
</foreach> </foreach>
GROUP BY `user_id` GROUP BY `user_id`
</select> </select>
<select id="sumCathAmount" resultType="com.github.wxiaoqi.security.admin.dto.WalletCathSumDto">
select IFNULL(SUM(amount),0) as sumAmount,COUNT(*) as `number` from my_wallet_cath
<where>
<choose>
<when test="type ==1 ">
AND date_format(from_unixtime(crt_time/1000),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
</when >
<when test="type==2 ">
AND date_format(from_unixtime(crt_time/1000),'%Y-%m') = date_format(now(),'%Y-%m')
</when >
<otherwise>
</otherwise>
</choose>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
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