H5去除APP版本校验
This commit is contained in:
@@ -37,6 +37,8 @@ public class ApplicationConstant {
|
||||
|
||||
public static final String H5_TOKEN = "h5_token";
|
||||
public static final String CLIENT = "client";
|
||||
|
||||
public static final String H5 = "h5";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2716,6 +2716,7 @@ public class Constant {
|
||||
public static final String ANDROID = "android";
|
||||
public static final String ALL = "all";
|
||||
public static final String NONE = "none";
|
||||
|
||||
}
|
||||
|
||||
public static class RankingType {
|
||||
|
@@ -12,6 +12,10 @@ public class ApiException extends RuntimeException {
|
||||
this(status.value(), status.getReasonPhrase());
|
||||
}
|
||||
|
||||
public ApiException(String message) {
|
||||
this(BusiStatus.SERVERERROR.value(), message);
|
||||
}
|
||||
|
||||
public ApiException(int responseCode, String message) {
|
||||
super(message);
|
||||
this.responseCode = responseCode;
|
||||
|
@@ -1,36 +0,0 @@
|
||||
package com.accompany.business.enums.withdraw;
|
||||
|
||||
import com.accompany.business.constant.withdraw.WithdrawAccountTypeConstant;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
* @date: 2023/7/11 12:08
|
||||
* @description:
|
||||
*/
|
||||
public enum WithdrawAccountEnum {
|
||||
|
||||
CHINA_UNION_PAY("中国大陆银联", WithdrawAccountTypeConstant.CHINA_UNION_PAY),
|
||||
|
||||
MAY_BANK("马来西亚银行", WithdrawAccountTypeConstant.MAY_BANK),
|
||||
|
||||
BANK_OF_SINGAPORE("新加坡银行", WithdrawAccountTypeConstant.BANK_OF_SINGAPORE),
|
||||
|
||||
OTHER("其它账户", WithdrawAccountTypeConstant.ORDER_ACCOUNT);
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Integer value;
|
||||
|
||||
WithdrawAccountEnum(String name, Integer value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@@ -1,8 +1,12 @@
|
||||
package com.accompany.business.service.withdraw;
|
||||
|
||||
import com.accompany.business.model.withdraw.WithdrawUserAccount;
|
||||
import com.accompany.business.vo.withdraw.WithdrawUserAccountVo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
* @date: 2023/7/7 14:54
|
||||
@@ -16,4 +20,22 @@ public interface WithdrawUserAccountService extends IService<WithdrawUserAccount
|
||||
* @param account
|
||||
*/
|
||||
void saveAccount(WithdrawUserAccount account);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
List<WithdrawUserAccountVo> accountList(Long uid);
|
||||
|
||||
/**
|
||||
* 汇率计算
|
||||
*
|
||||
* @param uid
|
||||
* @param accountType
|
||||
* @param goldNum
|
||||
* @return
|
||||
*/
|
||||
BigDecimal calculate(Long uid, Integer accountType, Integer goldNum);
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.accompany.business.service.withdraw.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.accompany.business.enums.withdraw.WithdrawAccountEnum;
|
||||
import com.accompany.business.constant.withdraw.WithdrawAccountTypeConstant;
|
||||
import com.accompany.business.model.withdraw.WithdrawAccountDtl;
|
||||
import com.accompany.business.model.withdraw.WithdrawUserAccount;
|
||||
import com.accompany.business.mybatismapper.withdraw.WithdrawAccountDtlMapper;
|
||||
@@ -16,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
@@ -31,6 +30,9 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class WithdrawAccountDtlServiceImpl extends ServiceImpl<WithdrawAccountDtlMapper, WithdrawAccountDtl> implements WithdrawAccountDtlService {
|
||||
|
||||
@Autowired
|
||||
private WithdrawAccountDtlService withdrawAccountDtlService;
|
||||
|
||||
@Autowired
|
||||
private WithdrawUserAccountService withdrawUserAccountService;
|
||||
|
||||
@@ -38,17 +40,23 @@ public class WithdrawAccountDtlServiceImpl extends ServiceImpl<WithdrawAccountDt
|
||||
public List<WithdrawAccountDtlVo> getAccounts(Long uid) {
|
||||
List<WithdrawUserAccount> userAccounts = withdrawUserAccountService.list(Wrappers.<WithdrawUserAccount>lambdaQuery()
|
||||
.eq(WithdrawUserAccount::getUid, uid)
|
||||
.in(WithdrawUserAccount::getAccountType, Arrays.stream(WithdrawAccountEnum.values()).map(WithdrawAccountEnum::getValue).collect(Collectors.toList())));
|
||||
.in(WithdrawUserAccount::getAccountType,
|
||||
WithdrawAccountTypeConstant.ORDER_ACCOUNT,
|
||||
WithdrawAccountTypeConstant.CHINA_UNION_PAY,
|
||||
WithdrawAccountTypeConstant.MAY_BANK,
|
||||
WithdrawAccountTypeConstant.BANK_OF_SINGAPORE
|
||||
));
|
||||
Map<Integer, WithdrawUserAccount> accountMap = null;
|
||||
if (CollectionUtil.isNotEmpty(userAccounts)) {
|
||||
accountMap = userAccounts.stream().collect(Collectors.toMap(WithdrawUserAccount::getAccountType, Function.identity(), (v1, v2) -> v1));
|
||||
}
|
||||
List<WithdrawAccountDtlVo> accounts = new ArrayList<>();
|
||||
for (WithdrawAccountEnum withdrawAccount : WithdrawAccountEnum.values()) {
|
||||
Integer accountType = withdrawAccount.getValue();
|
||||
List<WithdrawAccountDtl> accountDtls = withdrawAccountDtlService.list();
|
||||
for (WithdrawAccountDtl accountDtl : accountDtls) {
|
||||
Integer accountType = accountDtl.getAccountType();
|
||||
WithdrawAccountDtlVo account = new WithdrawAccountDtlVo();
|
||||
account.setAccountName(withdrawAccount.getName());
|
||||
account.setAccountType(withdrawAccount.getValue());
|
||||
account.setAccountName(accountDtl.getAccountName());
|
||||
account.setAccountType(accountType);
|
||||
account.setIsBind(accountMap != null && accountMap.containsKey(accountType) ? Constant.Yes1No0.YES : Constant.Yes1No0.NO);
|
||||
accounts.add(account);
|
||||
}
|
||||
|
@@ -1,14 +1,27 @@
|
||||
package com.accompany.business.service.withdraw.impl;
|
||||
|
||||
import com.accompany.business.constant.withdraw.WithdrawAccountTypeConstant;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.accompany.business.model.withdraw.ExchangeRate;
|
||||
import com.accompany.business.model.withdraw.WithdrawAccountDtl;
|
||||
import com.accompany.business.model.withdraw.WithdrawConfig;
|
||||
import com.accompany.business.model.withdraw.WithdrawUserAccount;
|
||||
import com.accompany.business.mybatismapper.withdraw.WithdrawUserAccountMapper;
|
||||
import com.accompany.business.service.withdraw.ExchangeRateService;
|
||||
import com.accompany.business.service.withdraw.WithdrawAccountDtlService;
|
||||
import com.accompany.business.service.withdraw.WithdrawConfigService;
|
||||
import com.accompany.business.service.withdraw.WithdrawUserAccountService;
|
||||
import com.accompany.business.vo.withdraw.WithdrawUserAccountVo;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.exception.ApiException;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
@@ -19,13 +32,96 @@ import java.util.Date;
|
||||
@Service
|
||||
public class WithdrawUserAccountServiceImpl extends ServiceImpl<WithdrawUserAccountMapper, WithdrawUserAccount> implements WithdrawUserAccountService {
|
||||
|
||||
@Autowired
|
||||
private WithdrawConfigService withdrawConfigService;
|
||||
|
||||
@Autowired
|
||||
private ExchangeRateService exchangeRateService;
|
||||
|
||||
@Autowired
|
||||
private WithdrawAccountDtlService withdrawAccountDtlService;
|
||||
|
||||
@Autowired
|
||||
private WithdrawUserAccountService withdrawUserAccountService;
|
||||
|
||||
@Override
|
||||
public void saveAccount(WithdrawUserAccount account) {
|
||||
Date now = new Date();
|
||||
Long id = account.getId();
|
||||
if (id != null) {
|
||||
account.setUpdateTime(now);
|
||||
} else {
|
||||
Long uid = account.getUid();
|
||||
Integer accountType = account.getAccountType();
|
||||
int count = count(Wrappers.<WithdrawUserAccount>lambdaQuery()
|
||||
.eq(WithdrawUserAccount::getUid, uid)
|
||||
.eq(WithdrawUserAccount::getAccountType, accountType));
|
||||
if (count > 0) {
|
||||
throw new ApiException(BusiStatus.SERVERERROR.value(), "该提现方式已添加");
|
||||
}
|
||||
}
|
||||
saveOrUpdate(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WithdrawUserAccountVo> accountList(Long uid) {
|
||||
List<WithdrawAccountDtl> accountDtls = withdrawAccountDtlService.list();
|
||||
List<WithdrawUserAccount> userAccounts = list(Wrappers.<WithdrawUserAccount>lambdaQuery()
|
||||
.eq(WithdrawUserAccount::getUid, uid));
|
||||
List<WithdrawUserAccountVo> accounts = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(userAccounts)) {
|
||||
for (WithdrawUserAccount userAccount : userAccounts) {
|
||||
Integer accountType = userAccount.getAccountType();
|
||||
WithdrawUserAccountVo account = new WithdrawUserAccountVo();
|
||||
account.setAccountType(accountType);
|
||||
if (CollectionUtil.isNotEmpty(accountDtls)) {
|
||||
Optional<WithdrawAccountDtl> any = accountDtls.stream().filter(v -> v.getAccountType().equals(accountType)).findAny();
|
||||
if (any.isPresent()) {
|
||||
WithdrawAccountDtl withdrawAccountDtl = any.get();
|
||||
account.setAccountName(withdrawAccountDtl.getAccountName());
|
||||
account.setCurrencyType(withdrawAccountDtl.getCurrencyType());
|
||||
}
|
||||
}
|
||||
accounts.add(account);
|
||||
}
|
||||
}
|
||||
return accounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal calculate(Long uid, Integer accountType, Integer goldNum) {
|
||||
List<WithdrawConfig> configs = withdrawConfigService.list(Wrappers.<WithdrawConfig>lambdaQuery()
|
||||
.eq(WithdrawConfig::getIsEnabled, Constant.Yes1No0.YES));
|
||||
if (CollectionUtil.isEmpty(configs)) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
int count = withdrawUserAccountService.count(Wrappers.<WithdrawUserAccount>lambdaQuery()
|
||||
.eq(WithdrawUserAccount::getUid, uid)
|
||||
.eq(WithdrawUserAccount::getAccountType, accountType));
|
||||
if (count == 0) {
|
||||
throw new ApiException("非法账户");
|
||||
}
|
||||
List<WithdrawAccountDtl> accountDtls = withdrawAccountDtlService.list(Wrappers.<WithdrawAccountDtl>lambdaQuery()
|
||||
.eq(WithdrawAccountDtl::getAccountType, accountType));
|
||||
if (CollectionUtil.isEmpty(accountDtls)) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
WithdrawAccountDtl withdrawAccountDtl = accountDtls.get(0);
|
||||
String currencyType = withdrawAccountDtl.getCurrencyType();
|
||||
List<ExchangeRate> exchangeRates = exchangeRateService.list(Wrappers.<ExchangeRate>lambdaQuery()
|
||||
.eq(ExchangeRate::getCurrency, currencyType));
|
||||
WithdrawConfig withdrawConfig = configs.get(0);
|
||||
ExchangeRate exchangeRate = exchangeRates.get(0);
|
||||
BigDecimal rate = exchangeRate.getRate();
|
||||
//提现手续费
|
||||
BigDecimal handlingRate = withdrawConfig.getChargeRate();
|
||||
//扣除手续费后的金币
|
||||
BigDecimal afterGoldNum = new BigDecimal(goldNum).subtract(new BigDecimal(goldNum).multiply(handlingRate.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)));
|
||||
//金币:美元 = 1:1000
|
||||
BigDecimal dollarAmount = afterGoldNum.divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP);
|
||||
//美元乘于汇率
|
||||
BigDecimal amount = dollarAmount.multiply(rate);
|
||||
log.info("rate : {}, handlingRate : {}, afterGoldNum : {}, dollarAmount : {}, amount : {}", rate, handlingRate, afterGoldNum, dollarAmount, amount);
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,33 @@
|
||||
package com.accompany.business.vo.withdraw;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
* @date: 2023/7/11 16:59
|
||||
* @description:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class WithdrawUserAccountVo {
|
||||
|
||||
/**
|
||||
* 账户名称
|
||||
*/
|
||||
@ApiModelProperty("账户名称")
|
||||
private String accountName;
|
||||
|
||||
/**
|
||||
* 币种
|
||||
*/
|
||||
@ApiModelProperty("币种")
|
||||
private String currencyType;
|
||||
|
||||
/**
|
||||
* 账户类型
|
||||
*/
|
||||
@ApiModelProperty("账户类型")
|
||||
private Integer accountType;
|
||||
}
|
@@ -2,14 +2,15 @@ package com.accompany.business.controller.withdraw;
|
||||
|
||||
import com.accompany.business.model.withdraw.WithdrawUserAccount;
|
||||
import com.accompany.business.service.withdraw.WithdrawUserAccountService;
|
||||
import com.accompany.business.vo.withdraw.WithdrawUserAccountVo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
@@ -33,7 +34,36 @@ public class WithdrawUserAccountController {
|
||||
@ApiOperation("保存")
|
||||
@PostMapping("save")
|
||||
public BusiResult<Void> save(@RequestBody WithdrawUserAccount account) {
|
||||
|
||||
withdrawUserAccountService.saveAccount(account);
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("列表")
|
||||
@GetMapping("list")
|
||||
public BusiResult<List<WithdrawUserAccountVo>> accountList(@RequestParam("uid") Long uid) {
|
||||
return BusiResult.success(withdrawUserAccountService.accountList(uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇率计算
|
||||
*
|
||||
* @param uid
|
||||
* @param accountType
|
||||
* @param goldNum
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("汇率计算")
|
||||
@GetMapping("calculate")
|
||||
public BusiResult<BigDecimal> calculate(@RequestParam("uid") Long uid, @RequestParam("accountType") Integer accountType, @RequestParam("goldNum") Integer goldNum) {
|
||||
BigDecimal amount = withdrawUserAccountService.calculate(uid, accountType, goldNum);
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.oauth2.support.password;
|
||||
|
||||
import com.accompany.common.constant.ApplicationConstant;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.device.DeviceInfo;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
@@ -84,10 +85,13 @@ public class PasswordAuthenticationProvider implements AuthenticationProvider {
|
||||
loginTypeEnum = LoginTypeEnum.PASSWORD;
|
||||
}
|
||||
// 低于1.5版本不能进行登录
|
||||
String client = deviceInfo.getClient();
|
||||
if (!ApplicationConstant.PublicParameters.H5.equals(client)) {
|
||||
String limitAppVersion = sysConfService.getDefaultSysConfValueById(Constant.SysConfId.APP_VERSION_LIMIT, Constant.LOWEST_VERSION_FOR_USE);
|
||||
if (deviceInfo.getAppVersion() == null || AppVersionUtil.compareVersion(deviceInfo.getAppVersion(), limitAppVersion) < 0) {
|
||||
throw new CustomOAuth2Exception(CustomOAuth2Exception.APP_VERSION_TOO_OLD, OAuthStatus.APP_VERSION_TOO_OLD.getReasonPhrase());
|
||||
}
|
||||
}
|
||||
if (phoneBlackService.checkIsNeedIntercept(username)) {
|
||||
throw new CustomOAuth2Exception(CustomOAuth2Exception.PHONE_BE_INTERCEPTED,
|
||||
OAuthStatus.PHONE_BE_INTERCEPTED.getReasonPhrase());
|
||||
|
Reference in New Issue
Block a user