修改提现
This commit is contained in:
@@ -0,0 +1,199 @@
|
|||||||
|
package com.chaozhangui.system.gateway.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MD5Util {
|
||||||
|
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(MD5Util.class);
|
||||||
|
|
||||||
|
private static final String hexDigIts[] = {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
|
||||||
|
|
||||||
|
public static String encrypt(String plainText) {
|
||||||
|
try {
|
||||||
|
return encrypt(plainText,true);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("MD5加密异常:",e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Title: encrypt
|
||||||
|
* @Description: TODO(16位或32位密码)
|
||||||
|
* @param @param
|
||||||
|
* plainText
|
||||||
|
* @param @param
|
||||||
|
* flag true为32位,false为16位
|
||||||
|
* @throws UnsupportedEncodingException
|
||||||
|
*/
|
||||||
|
public static String encrypt(String plainText, boolean flag) throws UnsupportedEncodingException {
|
||||||
|
try {
|
||||||
|
if (ObjectUtil.isEmpty(plainText)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
String encrStr = byteArrayToHexString(md.digest(plainText.getBytes("UTF-8")));
|
||||||
|
if (flag)
|
||||||
|
return encrStr;
|
||||||
|
else
|
||||||
|
return encrStr.substring(8, 24);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static String encrypt(Object obj,String privateKey){
|
||||||
|
if(obj==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Map<String, Object> map = new HashMap<String,Object>();
|
||||||
|
if(obj instanceof Map){
|
||||||
|
map=(Map<String, Object>) obj;
|
||||||
|
}else{
|
||||||
|
map = BeanUtil.transBean2Map(obj);
|
||||||
|
}
|
||||||
|
return encrypt(map,privateKey,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Title: encrypt
|
||||||
|
* @Description: TODO(16位或32位密码)
|
||||||
|
* @param @param
|
||||||
|
* plainText
|
||||||
|
* @param @param
|
||||||
|
* flag true为32位,false为16位
|
||||||
|
* @throws UnsupportedEncodingException
|
||||||
|
*/
|
||||||
|
public static String encrypt(Map<String, Object> map, String privateKey,boolean flag) {
|
||||||
|
String param = null;
|
||||||
|
map.remove("sign");
|
||||||
|
map.remove("encrypt");
|
||||||
|
String result = BeanUtil.mapOrderStr(map);
|
||||||
|
result= result.concat("&key=").concat(privateKey);
|
||||||
|
System.out.println("待加密的数据:"+result);
|
||||||
|
if (StringUtils.isEmpty(result)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
param = encrypt(encrypt(result)+privateKey);
|
||||||
|
if (flag) {
|
||||||
|
return param;
|
||||||
|
} else {
|
||||||
|
param = param.substring(8, 24);
|
||||||
|
}
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static String encrypt(Map<String, Object> map, boolean flag) {
|
||||||
|
String param = null;
|
||||||
|
map.remove("sign");
|
||||||
|
map.remove("encrypt");
|
||||||
|
String result = BeanUtil.mapOrderStr(map);
|
||||||
|
System.out.println("待加密的数据:"+result);
|
||||||
|
if (StringUtils.isEmpty(result)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
param = encrypt(encrypt(result));
|
||||||
|
if (flag) {
|
||||||
|
return param;
|
||||||
|
} else {
|
||||||
|
param = param.substring(8, 24);
|
||||||
|
}
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static String encryptString(String result, boolean flag) {
|
||||||
|
String param = null;
|
||||||
|
System.out.println("待加密的数据:"+result);
|
||||||
|
if (StringUtils.isEmpty(result)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
param = encrypt(result);
|
||||||
|
if (flag) {
|
||||||
|
return param;
|
||||||
|
} else {
|
||||||
|
param = param.substring(8, 24);
|
||||||
|
}
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Map<String, Object> mapFn(Map<String, Object> map) {
|
||||||
|
for (String key : map.keySet()) {
|
||||||
|
if (map.get(key) != null && map.get(key) != "" && (!key.equals("BTYPE") && !key.equals("SIGN"))) {
|
||||||
|
if (key.equals("INPUT")) {
|
||||||
|
if (map.get(key) != null) {
|
||||||
|
mapFn((Map<String, Object>) map.get(key));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resultMap.put(key, map.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static boolean check(Object obj,String privateKey){
|
||||||
|
Map<String,Object> map=new HashMap<String,Object>();
|
||||||
|
if(obj==null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(obj instanceof Map){
|
||||||
|
map=(Map<String, Object>) obj;
|
||||||
|
}else{
|
||||||
|
map = BeanUtil.transBean2Map(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("check:"+ JSONUtil.toJsonStr(map));
|
||||||
|
String sign=(String)map.get("sign");
|
||||||
|
if(sign==null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String str=encrypt(obj,privateKey);
|
||||||
|
System.out.println("check: "+str);
|
||||||
|
|
||||||
|
return sign.equals(str)?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String byteArrayToHexString(byte b[]){
|
||||||
|
StringBuffer resultSb = new StringBuffer();
|
||||||
|
for(int i = 0; i < b.length; i++){
|
||||||
|
resultSb.append(byteToHexString(b[i]));
|
||||||
|
}
|
||||||
|
return resultSb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String byteToHexString(byte b){
|
||||||
|
int n = b;
|
||||||
|
if(n < 0){
|
||||||
|
n += 256;
|
||||||
|
}
|
||||||
|
int d1 = n / 16;
|
||||||
|
int d2 = n % 16;
|
||||||
|
return hexDigIts[d1] + hexDigIts[d2];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package com.chaozhanggui.admin.system.controller;
|
||||||
|
|
||||||
|
import com.chaozhanggui.admin.system.service.SystemApiService;
|
||||||
|
import com.chaozhanggui.admin.system.util.RSAUtil;
|
||||||
|
import com.chaozhanggui.common.system.config.RespBody;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统设置
|
||||||
|
*/
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("systemApi")
|
||||||
|
@Slf4j
|
||||||
|
public class SystemApiController {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SystemApiService systemApiService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取appid 信息
|
||||||
|
* @param loginName
|
||||||
|
* @param token
|
||||||
|
* @param userId
|
||||||
|
* @param appId
|
||||||
|
* @param pageNum
|
||||||
|
* @param pageSize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("querySystemApis")
|
||||||
|
public RespBody querySystemApis(@RequestHeader("loginName") String loginName, @RequestHeader("token") String token, @RequestHeader("userId") String userId
|
||||||
|
,@RequestParam("appId") String appId ,@RequestParam("pageNum") Integer pageNum
|
||||||
|
,@RequestParam("pageSize") Integer pageSize
|
||||||
|
){
|
||||||
|
return systemApiService.querySystemApi(appId,pageNum,pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改api 配置
|
||||||
|
* @param loginName
|
||||||
|
* @param token
|
||||||
|
* @param userId
|
||||||
|
* @param id
|
||||||
|
* @param ip
|
||||||
|
* @param publicKey
|
||||||
|
* @param privateKey
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("modfityApi")
|
||||||
|
public RespBody modfityApi(@RequestHeader("loginName") String loginName, @RequestHeader("token") String token, @RequestHeader("userId") String userId
|
||||||
|
,@RequestParam("id") Integer id,@RequestParam("ip") String ip,@RequestParam("publicKey") String publicKey,@RequestParam("privateKey") String privateKey ){
|
||||||
|
return systemApiService.modifyApi(id,ip,publicKey,privateKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增api
|
||||||
|
* @param loginName
|
||||||
|
* @param token
|
||||||
|
* @param userId
|
||||||
|
* @param appId
|
||||||
|
* @param ip
|
||||||
|
* @param publicKey
|
||||||
|
* @param privateKey
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("initApi")
|
||||||
|
public RespBody initApi(@RequestHeader("loginName") String loginName, @RequestHeader("token") String token, @RequestHeader("userId") String userId
|
||||||
|
,@RequestParam("appId") String appId,@RequestParam("ip") String ip,@RequestParam("publicKey") String publicKey,@RequestParam("privateKey") String privateKey ){
|
||||||
|
return systemApiService.insertApi(appId,ip,publicKey,privateKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成密钥对
|
||||||
|
* @param loginName
|
||||||
|
* @param token
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("createKey")
|
||||||
|
public RespBody createKey(@RequestHeader("loginName") String loginName, @RequestHeader("token") String token, @RequestHeader("userId") String userId
|
||||||
|
){
|
||||||
|
try {
|
||||||
|
RSAUtil.KeyStore keys= RSAUtil.createKeys();
|
||||||
|
Map<String,String> map=new HashMap<>();
|
||||||
|
map.put("publicKey",keys.getPublicKey());
|
||||||
|
map.put("privateKey",keys.getPrivateKey());
|
||||||
|
return new RespBody("000000",map);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return new RespBody("999944");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -231,6 +231,10 @@ public class UserController {
|
|||||||
public RespBody withdrawalProfit(@RequestHeader("loginName") String loginName, @RequestHeader("token") String token, @RequestHeader("userId") String userId,
|
public RespBody withdrawalProfit(@RequestHeader("loginName") String loginName, @RequestHeader("token") String token, @RequestHeader("userId") String userId,
|
||||||
@RequestParam("amount") BigDecimal amount
|
@RequestParam("amount") BigDecimal amount
|
||||||
){
|
){
|
||||||
return userservice.withdrawalProfit(userId, amount);
|
try {
|
||||||
|
return userservice.withdrawalProfit(userId, amount);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.chaozhanggui.admin.system.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.chaozhanggui.common.system.config.RespBody;
|
||||||
|
import com.chaozhanggui.dao.system.dao.*;
|
||||||
|
import com.chaozhanggui.dao.system.entity.*;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SystemApiService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
GuserSetMapper guserSetMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TbPlussMerchantBaseInfoMapper baseInfoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TbPlussUserAppMapper tbPlussUserAppMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TbPlussMerchantStoreMapper tbPlussMerchantStoreMapper;
|
||||||
|
public RespBody querySystemApi(String appId,Integer pageNum,Integer pageSize){
|
||||||
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
|
List<GuserSet> list=guserSetMapper.selectByAppId(appId);
|
||||||
|
PageInfo pageInfo=new PageInfo(list);
|
||||||
|
return new RespBody("000000",pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RespBody modifyApi(Integer id,String ip,String publicKey,String privateKey){
|
||||||
|
|
||||||
|
GuserSet guserSet=guserSetMapper.selectByPrimaryKey(id);
|
||||||
|
if(ObjectUtil.isEmpty(guserSet)){
|
||||||
|
return new RespBody("000034");
|
||||||
|
}
|
||||||
|
guserSet.setIp(ip);
|
||||||
|
guserSet.setPublicKey(publicKey);
|
||||||
|
guserSet.setPrivateKey(privateKey);
|
||||||
|
guserSet.setUpdateTime(new Date());
|
||||||
|
guserSetMapper.updateByPrimaryKeySelective(guserSet);
|
||||||
|
return new RespBody("000000");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public RespBody insertApi(String appId,String ip,String publicKey,String privateKey){
|
||||||
|
TbPlussMerchantBaseInfo baseInfo= baseInfoMapper.selectByMerchantcode(appId);
|
||||||
|
if(ObjectUtil.isEmpty(baseInfo)){
|
||||||
|
return new RespBody("000034");
|
||||||
|
}
|
||||||
|
TbPlussUserApp userApp= tbPlussUserAppMapper.selectByUserId(baseInfo.getUserid());
|
||||||
|
if(ObjectUtil.isEmpty(userApp)){
|
||||||
|
return new RespBody("000034");
|
||||||
|
}
|
||||||
|
|
||||||
|
TbPlussMerchantStore store=tbPlussMerchantStoreMapper.getStoreByMerchantCode(baseInfo.getMerchantcode());
|
||||||
|
if(ObjectUtil.isEmpty(store)){
|
||||||
|
return new RespBody("000034");
|
||||||
|
}
|
||||||
|
|
||||||
|
GuserSet set=new GuserSet();
|
||||||
|
set.setAppId(appId);
|
||||||
|
set.setStoreId(store.getId().toString());
|
||||||
|
set.setStoreName(store.getStorename());
|
||||||
|
set.setStoreCode(store.getStoreid());
|
||||||
|
set.setMerchantName(store.getMerchantname());
|
||||||
|
set.setToken(userApp.getToken());
|
||||||
|
set.setIp(ip);
|
||||||
|
set.setPublicKey(publicKey);
|
||||||
|
set.setPrivateKey(privateKey);
|
||||||
|
set.setCreateTime(new Date());
|
||||||
|
guserSetMapper.insert(set);
|
||||||
|
return new RespBody("000000");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,12 +14,14 @@ import com.chaozhanggui.common.system.config.RespBody;
|
|||||||
import com.chaozhanggui.dao.system.dao.*;
|
import com.chaozhanggui.dao.system.dao.*;
|
||||||
import com.chaozhanggui.dao.system.entity.*;
|
import com.chaozhanggui.dao.system.entity.*;
|
||||||
import com.chaozhanggui.dao.system.model.CashStatus;
|
import com.chaozhanggui.dao.system.model.CashStatus;
|
||||||
|
import com.chaozhanggui.dao.system.util.N;
|
||||||
import com.chaozhanggui.system.service.AliPayService;
|
import com.chaozhanggui.system.service.AliPayService;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -52,6 +54,12 @@ public class Userservice {
|
|||||||
@Resource
|
@Resource
|
||||||
AliPayService aliPayService;
|
AliPayService aliPayService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TbPlussUserAccountMapper tbPlussUserAccountMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TbPlussUserAccountFlowMapper tbPlussUserAccountFlowMapper;
|
||||||
|
|
||||||
public RespBody doLogin(String loginName,String password,String userType,String ip) throws Exception {
|
public RespBody doLogin(String loginName,String password,String userType,String ip) throws Exception {
|
||||||
Boolean flag=false;
|
Boolean flag=false;
|
||||||
if("FO".equals(userType)||"SO".equals(userType)||"MG".equals(userType)){
|
if("FO".equals(userType)||"SO".equals(userType)||"MG".equals(userType)){
|
||||||
@@ -322,6 +330,7 @@ public class Userservice {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public RespBody modifyOutFlow(Integer id,String userId,String status) throws Exception{
|
public RespBody modifyOutFlow(Integer id,String userId,String status) throws Exception{
|
||||||
if(ObjectUtil.isEmpty(id)||ObjectUtil.isEmpty(userId)||ObjectUtil.isEmpty(status)){
|
if(ObjectUtil.isEmpty(id)||ObjectUtil.isEmpty(userId)||ObjectUtil.isEmpty(status)){
|
||||||
log.error("参数错误");
|
log.error("参数错误");
|
||||||
@@ -431,10 +440,33 @@ public class Userservice {
|
|||||||
it.setStatus("1");
|
it.setStatus("1");
|
||||||
return true;
|
return true;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
if(promotion.getTypeCode().equals("MG")){
|
if(promotion.getTypeCode().equals("MG")){
|
||||||
cash.setStatus(1);
|
cash.setStatus(1);
|
||||||
}
|
}
|
||||||
cash.setCashstatus(JSONUtil.toJsonStr(cashStatusList));
|
cash.setCashstatus(JSONUtil.toJsonStr(cashStatusList));
|
||||||
|
|
||||||
|
//释放资金
|
||||||
|
TbPlussUserAccount userAccount= tbPlussUserAccountMapper.selectByPrimaryKey(cash.getUserid());
|
||||||
|
if(ObjectUtil.isEmpty(userAccount)|| N.gt(cash.getCashamt(),userAccount.getFreezeBalance())){
|
||||||
|
throw new Exception("冻结资金不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
userAccount.setFreezeBalance(userAccount.getFreezeBalance().subtract(cash.getCashamt()));
|
||||||
|
userAccount.setUpdateTime(new Date());
|
||||||
|
tbPlussUserAccountMapper.updateByPrimaryKey(userAccount);
|
||||||
|
|
||||||
|
TbPlussUserAccountFlow flow=new TbPlussUserAccountFlow();
|
||||||
|
|
||||||
|
flow.setUserId(cash.getUserid());
|
||||||
|
flow.setBizCode("105");
|
||||||
|
flow.setBizName("提现拒绝解冻");
|
||||||
|
flow.setAmount(cash.getCashamt());
|
||||||
|
flow.setBalance(userAccount.getBalance());
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
tbPlussUserAccountFlowMapper.insert(flow);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
cashStatusList.stream().filter(it->{
|
cashStatusList.stream().filter(it->{
|
||||||
@@ -444,9 +476,9 @@ public class Userservice {
|
|||||||
//支付宝打款
|
//支付宝打款
|
||||||
try {
|
try {
|
||||||
aliPayService.alipayTransfer(cash.getVirrealcashamt().toString(),cash.getAccountno(),cash.getAccountname(),"",cash.getCashnumber());
|
aliPayService.alipayTransfer(cash.getVirrealcashamt().toString(),cash.getAccountno(),cash.getAccountname(),"",cash.getCashnumber());
|
||||||
} catch (AlipayApiException e) {
|
modFunds(cash.getUserid(),cash.getCashamt());
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
return false;
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -462,6 +494,41 @@ public class Userservice {
|
|||||||
tbPlussCashMapper.updateByPrimaryKey(cash);
|
tbPlussCashMapper.updateByPrimaryKey(cash);
|
||||||
return new RespBody("000000");
|
return new RespBody("000000");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void modFunds(Integer userId,BigDecimal amount) throws Exception {
|
||||||
|
//释放资金,扣除资金
|
||||||
|
TbPlussUserAccount userAccount= tbPlussUserAccountMapper.selectByPrimaryKey(userId);
|
||||||
|
if(ObjectUtil.isEmpty(userAccount)|| N.gt(amount,userAccount.getFreezeBalance())){
|
||||||
|
throw new Exception("冻结资金不足");
|
||||||
|
}
|
||||||
|
userAccount.setFreezeBalance(userAccount.getFreezeBalance().subtract(amount));
|
||||||
|
userAccount.setBalance(userAccount.getBalance().subtract(amount));
|
||||||
|
userAccount.setUpdateTime(new Date());
|
||||||
|
tbPlussUserAccountMapper.updateByPrimaryKey(userAccount);
|
||||||
|
|
||||||
|
TbPlussUserAccountFlow flow=new TbPlussUserAccountFlow();
|
||||||
|
flow.setUserId(userId);
|
||||||
|
flow.setBizCode("105");
|
||||||
|
flow.setBizName("提现解冻");
|
||||||
|
flow.setAmount(amount);
|
||||||
|
flow.setBalance(userAccount.getBalance());
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
tbPlussUserAccountFlowMapper.insert(flow);
|
||||||
|
|
||||||
|
|
||||||
|
flow=new TbPlussUserAccountFlow();
|
||||||
|
flow.setUserId(userId);
|
||||||
|
flow.setBizCode("106");
|
||||||
|
flow.setBizName("提现扣除");
|
||||||
|
flow.setAmount(amount);
|
||||||
|
flow.setBalance(userAccount.getBalance());
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
tbPlussUserAccountFlowMapper.insert(flow);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RespBody getUserBalance(String userId){
|
public RespBody getUserBalance(String userId){
|
||||||
@@ -482,7 +549,8 @@ public class Userservice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RespBody withdrawalProfit(String userId,BigDecimal amount){
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public RespBody withdrawalProfit(String userId,BigDecimal amount) throws Exception{
|
||||||
|
|
||||||
|
|
||||||
TbPlussUserInfo userInfo= userInfoMapper.selectByPrimaryKey(Long.valueOf(userId));
|
TbPlussUserInfo userInfo= userInfoMapper.selectByPrimaryKey(Long.valueOf(userId));
|
||||||
@@ -510,21 +578,10 @@ public class Userservice {
|
|||||||
return new RespBody("000032");
|
return new RespBody("000032");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TbPlussMerchantBaseInfo baseInfo= baseInfoMapper.selectByUserId(userId);
|
|
||||||
// if(ObjectUtil.isEmpty(baseInfo)){
|
|
||||||
// log.error("商户信息不存在");
|
|
||||||
// return new RespBody("000031");
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
TbPlussUserAccount userAccount= tbPlussUserAccountMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||||
BigDecimal profit= tbPlussCashMapper.selectByUserId(userId);
|
if(ObjectUtil.isEmpty(userAccount)|| N.gt(amount,userAccount.getBalance().subtract(userAccount.getFreezeBalance()))){
|
||||||
|
log.error("可提余额不足:{},{},{}",userId,amount,userAccount.getBalance().subtract(userAccount.getFreezeBalance()));
|
||||||
BigDecimal fronzenAmt=tbPlussCashMapper.selectCashFrozenAmountByUserId(userId);
|
|
||||||
|
|
||||||
BigDecimal successAmt=tbPlussCashMapper.selectCashAmt(userId);
|
|
||||||
|
|
||||||
if(amount.compareTo(profit.subtract(fronzenAmt).subtract(successAmt))>0){
|
|
||||||
log.error("可提余额不足:{},{},{}",userId,amount,profit.subtract(fronzenAmt).subtract(successAmt));
|
|
||||||
return new RespBody("000029");
|
return new RespBody("000029");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,10 +597,6 @@ public class Userservice {
|
|||||||
TbPlussCash cash=new TbPlussCash();
|
TbPlussCash cash=new TbPlussCash();
|
||||||
cash.setUserid(Integer.valueOf(userId));
|
cash.setUserid(Integer.valueOf(userId));
|
||||||
cash.setUsername(userInfo.getTruename());
|
cash.setUsername(userInfo.getTruename());
|
||||||
// cash.setMerchantcode(baseInfo.getMerchantcode());
|
|
||||||
// cash.setMerchantname(baseInfo.getMerchantname());
|
|
||||||
// cash.setAccountno(account.getAccountno());
|
|
||||||
// cash.setAccountname(account.getAccountname());
|
|
||||||
cash.setCashamt(amount);
|
cash.setCashamt(amount);
|
||||||
cash.setCreatedt(new Date());
|
cash.setCreatedt(new Date());
|
||||||
cash.setCashnumber(StringUtil.getBillno());
|
cash.setCashnumber(StringUtil.getBillno());
|
||||||
@@ -553,6 +606,21 @@ public class Userservice {
|
|||||||
cash.setRatiocharge(cash.getCashamt().multiply(BigDecimal.valueOf(0.08)));
|
cash.setRatiocharge(cash.getCashamt().multiply(BigDecimal.valueOf(0.08)));
|
||||||
cash.setCashstatus(JSONUtil.toJsonStr(getCashMap(promotion.getParentUserId(),new LinkedList<>())));
|
cash.setCashstatus(JSONUtil.toJsonStr(getCashMap(promotion.getParentUserId(),new LinkedList<>())));
|
||||||
tbPlussCashMapper.insertSelective(cash);
|
tbPlussCashMapper.insertSelective(cash);
|
||||||
|
|
||||||
|
|
||||||
|
userAccount.setFreezeBalance(userAccount.getFreezeBalance().add(amount));
|
||||||
|
userAccount.setUpdateTime(new Date());
|
||||||
|
tbPlussUserAccountMapper.updateByPrimaryKey(userAccount);
|
||||||
|
|
||||||
|
TbPlussUserAccountFlow flow=new TbPlussUserAccountFlow();
|
||||||
|
flow.setUserId(Integer.valueOf(userId));
|
||||||
|
flow.setBizCode("108");
|
||||||
|
flow.setBizName("提现冻结");
|
||||||
|
flow.setAmount(amount);
|
||||||
|
flow.setBalance(userAccount.getBalance());
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
tbPlussUserAccountFlowMapper.insert(flow);
|
||||||
|
|
||||||
return new RespBody("000000");
|
return new RespBody("000000");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class ExceptionUtil {
|
|||||||
map.put("000031","商户信息不存在");
|
map.put("000031","商户信息不存在");
|
||||||
map.put("000032","小于最小提现金额");
|
map.put("000032","小于最小提现金额");
|
||||||
map.put("000033","平台不允许提现");
|
map.put("000033","平台不允许提现");
|
||||||
|
map.put("000034","资源不存在");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -112,6 +113,7 @@ public class ExceptionUtil {
|
|||||||
map.put("999941","不允许成为创客");
|
map.put("999941","不允许成为创客");
|
||||||
map.put("999942","已成为创客或者正在审核中");
|
map.put("999942","已成为创客或者正在审核中");
|
||||||
map.put("999943","失败");
|
map.put("999943","失败");
|
||||||
|
map.put("999944","生成密钥对异常,请稍后重试");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -381,8 +381,13 @@ public class MerchantLklService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static String getBase64() {
|
public static String getBase64() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String encodeBase64String = org.apache.commons.codec.binary.Base64.encodeBase64String((client_id + ":" + client_secret).getBytes());
|
String encodeBase64String = org.apache.commons.codec.binary.Base64.encodeBase64String((client_id + ":" + client_secret).getBytes());
|
||||||
|
|
||||||
return encodeBase64String;
|
return encodeBase64String;
|
||||||
|
|||||||
Reference in New Issue
Block a user