|
@@ -1,31 +1,37 @@
|
|
package com.txz.cif.web;
|
|
package com.txz.cif.web;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
-import cn.hutool.json.JSONObject;
|
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
|
|
|
+import com.baomidou.lock.LockInfo;
|
|
|
|
+import com.baomidou.lock.LockTemplate;
|
|
|
|
+import com.baomidou.lock.executor.RedisTemplateLockExecutor;
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
|
+import com.txz.cif.constants.MyConstants;
|
|
|
|
+import com.txz.cif.core.AuthService;
|
|
import com.txz.cif.core.Result;
|
|
import com.txz.cif.core.Result;
|
|
|
|
+import com.txz.cif.core.ResultCode;
|
|
import com.txz.cif.core.ResultGenerator;
|
|
import com.txz.cif.core.ResultGenerator;
|
|
|
|
+import com.txz.cif.dto.tfpay.CheckWithdrawSignDTO;
|
|
import com.txz.cif.dubbo.client.OperatingConfigDubboServiceClient;
|
|
import com.txz.cif.dubbo.client.OperatingConfigDubboServiceClient;
|
|
import com.txz.cif.model.*;
|
|
import com.txz.cif.model.*;
|
|
import com.txz.cif.service.*;
|
|
import com.txz.cif.service.*;
|
|
-
|
|
|
|
-import com.txz.cif.core.ResultCode;
|
|
|
|
-
|
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
|
-import com.github.pagehelper.PageInfo;
|
|
|
|
|
|
+import com.txz.cif.util.TFPayUtil;
|
|
import com.txz.cif.web.para.RecordParam;
|
|
import com.txz.cif.web.para.RecordParam;
|
|
import com.txz.cif.web.para.WithdrawParam;
|
|
import com.txz.cif.web.para.WithdrawParam;
|
|
-import com.txz.cif.core.AuthService;
|
|
|
|
|
|
+import com.txz.cif.web.ro.TFWithdrawCallbackDTO;
|
|
import com.txz.operating.dto.ConfigDTO;
|
|
import com.txz.operating.dto.ConfigDTO;
|
|
import io.jsonwebtoken.Claims;
|
|
import io.jsonwebtoken.Claims;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.tuple.Triple;
|
|
import org.apache.commons.lang3.tuple.Triple;
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
-import io.swagger.annotations.Api;
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
|
-
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
|
|
+import tk.mybatis.mapper.entity.Example;
|
|
import tk.mybatis.mapper.entity.Example.Criteria;
|
|
import tk.mybatis.mapper.entity.Example.Criteria;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -37,193 +43,257 @@ import java.util.List;
|
|
import static com.txz.cif.core.AbstractApiController.X_CLIENT_TOKEN;
|
|
import static com.txz.cif.core.AbstractApiController.X_CLIENT_TOKEN;
|
|
|
|
|
|
/**
|
|
/**
|
|
-* Created by CodeGenerator on 2025/07/15.
|
|
|
|
-*/
|
|
|
|
|
|
+ * Created by CodeGenerator on 2025/07/15.
|
|
|
|
+ */
|
|
@Api(tags = "[api]提现管理")
|
|
@Api(tags = "[api]提现管理")
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/api/withdraw/record")
|
|
@RequestMapping("/api/withdraw/record")
|
|
public class WithdrawRecordApiController {
|
|
public class WithdrawRecordApiController {
|
|
-
|
|
|
|
- private static Logger log = LoggerFactory.getLogger(WithdrawRecordApiController.class);
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ private static Logger log = LoggerFactory.getLogger(WithdrawRecordApiController.class);
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private WithdrawRecordService withdrawRecordService;
|
|
private WithdrawRecordService withdrawRecordService;
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private SequenceService sequenceService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private AuthService authService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private AccountService accountService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private BizLogService bizLogService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private UserService userService;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private OperatingConfigDubboServiceClient operatingConfigDubboServiceClient;
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SequenceService sequenceService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private AuthService authService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private AccountService accountService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private BizLogService bizLogService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private PaymentChannelService paymentChannelService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private UserService userService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private LockTemplate lockTemplate;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private OperatingConfigDubboServiceClient operatingConfigDubboServiceClient;
|
|
|
|
+
|
|
@PostMapping("/add")
|
|
@PostMapping("/add")
|
|
- @ApiOperation(value = "新增提现订单",httpMethod = "POST")
|
|
|
|
- public Result add(@RequestBody WithdrawParam param,@RequestHeader(value = X_CLIENT_TOKEN,required = false) String token) {
|
|
|
|
- if(param == null){
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- Triple<Boolean, String, Claims> result = authService.verifyToken(token);
|
|
|
|
-
|
|
|
|
- if (!result.getLeft()) {
|
|
|
|
- // token无效
|
|
|
|
- String errorMsg = result.getMiddle();
|
|
|
|
- // 处理错误情况...
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.OAUTH_INVALID_ACCESS_TOKEN);
|
|
|
|
- }
|
|
|
|
- Claims claims = result.getRight();
|
|
|
|
- Long userId = Long.valueOf(claims.get("userId").toString());
|
|
|
|
- User user = userService.findById(userId);
|
|
|
|
- if (user == null){
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
|
|
|
|
- }
|
|
|
|
- if(StrUtil.isBlank(user.getBank()) ){
|
|
|
|
- if (StrUtil.isBlank(param.getBank()) || StrUtil.isBlank(param.getBankAccount()) ||StrUtil.isBlank(param.getBankAccountName()) ) {
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.BANK_IS_NULL);
|
|
|
|
- }
|
|
|
|
- userService.update(User.builder().
|
|
|
|
- id(user.getId()).bank(param.getBank())
|
|
|
|
- .bankAccountName(param.getBankAccountName())
|
|
|
|
- .bankAccount(param.getBankAccount()).build());
|
|
|
|
- user.setBank(param.getBank());
|
|
|
|
- user.setBankAccount(param.getBankAccount());
|
|
|
|
- user.setBankAccountName(param.getBankAccountName());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- com.txz.operating.result.Result<ConfigDTO> openRedEnvelopeRate = operatingConfigDubboServiceClient.getConfigByCode("join_red_envelope_rate");
|
|
|
|
- String rate = openRedEnvelopeRate.getData().getValueInfo();
|
|
|
|
- BigDecimal fee = param.getAmount().multiply(new BigDecimal(rate)).divide(BigDecimal.valueOf(100),2, RoundingMode.DOWN);
|
|
|
|
-
|
|
|
|
- Account account = accountService.getAccount(userId, param.getAccountType());
|
|
|
|
- if (account == null){
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.ACCOUNT_IS_NULL);
|
|
|
|
- }
|
|
|
|
- if (account.getEffectiveBalance().compareTo(param.getAmount().add(fee)) <0) {
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.EFFECTIVE_BALANCE_IS_INSUFFICIENT);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String orderNo = sequenceService.genSerialNumber("withdraw_rule",null);
|
|
|
|
-
|
|
|
|
- WithdrawRecord withdrawRecord = new WithdrawRecord();
|
|
|
|
- withdrawRecord.setOrderNo(orderNo);
|
|
|
|
- withdrawRecord.setStatus(1);
|
|
|
|
- withdrawRecord.setUserName(user.getName());
|
|
|
|
- withdrawRecord.setUserPhone(user.getPhoneNo());
|
|
|
|
- withdrawRecord.setTransTime(DateUtil.date());
|
|
|
|
- withdrawRecord.setUserId(userId);
|
|
|
|
- withdrawRecord.setAccountType(param.getAccountType());
|
|
|
|
- withdrawRecord.setFee(fee);
|
|
|
|
- withdrawRecord.setBank(user.getBank());
|
|
|
|
- withdrawRecord.setBankAccount(user.getBankAccount());
|
|
|
|
- withdrawRecord.setBankAccountName(user.getBankAccountName());
|
|
|
|
- withdrawRecord.setChannel(param.getChannel());
|
|
|
|
- withdrawRecord.setCurrency(param.getCurrency());
|
|
|
|
- withdrawRecord.setAmount(param.getAmount());
|
|
|
|
- withdrawRecord.setCreateTime(DateUtil.date());
|
|
|
|
- withdrawRecordService.add(withdrawRecord);
|
|
|
|
- return ResultGenerator.genSuccessResult(withdrawRecord);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("新增对象操作异常e:{}",e);
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ @ApiOperation(value = "新增提现订单", httpMethod = "POST")
|
|
|
|
+ public Result add(@RequestBody WithdrawParam param, @RequestHeader(value = X_CLIENT_TOKEN, required = false) String token) {
|
|
|
|
+ if (param == null) {
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ Triple<Boolean, String, Claims> result = authService.verifyToken(token);
|
|
|
|
+
|
|
|
|
+ if (!result.getLeft()) {
|
|
|
|
+ // token无效
|
|
|
|
+ String errorMsg = result.getMiddle();
|
|
|
|
+ // 处理错误情况...
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.OAUTH_INVALID_ACCESS_TOKEN);
|
|
|
|
+ }
|
|
|
|
+ Claims claims = result.getRight();
|
|
|
|
+ Long userId = Long.valueOf(claims.get("userId").toString());
|
|
|
|
+ User user = userService.findById(userId);
|
|
|
|
+ if (user == null) {
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isBlank(user.getBank())) {
|
|
|
|
+ if (StrUtil.isBlank(param.getBank()) || StrUtil.isBlank(param.getBankAccount()) || StrUtil.isBlank(param.getBankAccountName())) {
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.BANK_IS_NULL);
|
|
|
|
+ }
|
|
|
|
+ userService.update(User.builder().
|
|
|
|
+ id(user.getId()).bank(param.getBank())
|
|
|
|
+ .bankAccountName(param.getBankAccountName())
|
|
|
|
+ .bankAccount(param.getBankAccount()).build());
|
|
|
|
+ user.setBank(param.getBank());
|
|
|
|
+ user.setBankAccount(param.getBankAccount());
|
|
|
|
+ user.setBankAccountName(param.getBankAccountName());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ com.txz.operating.result.Result<ConfigDTO> openRedEnvelopeRate = operatingConfigDubboServiceClient.getConfigByCode("join_red_envelope_rate");
|
|
|
|
+ String rate = openRedEnvelopeRate.getData().getValueInfo();
|
|
|
|
+ BigDecimal fee = param.getAmount().multiply(new BigDecimal(rate)).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN);
|
|
|
|
+
|
|
|
|
+ Account account = accountService.getAccount(userId, param.getAccountType());
|
|
|
|
+ if (account == null) {
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.ACCOUNT_IS_NULL);
|
|
|
|
+ }
|
|
|
|
+ if (account.getEffectiveBalance().compareTo(param.getAmount().add(fee)) < 0) {
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.EFFECTIVE_BALANCE_IS_INSUFFICIENT);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String orderNo = sequenceService.genSerialNumber("withdraw_rule", null);
|
|
|
|
+
|
|
|
|
+ WithdrawRecord withdrawRecord = new WithdrawRecord();
|
|
|
|
+ withdrawRecord.setOrderNo(orderNo);
|
|
|
|
+ withdrawRecord.setStatus(1);
|
|
|
|
+ withdrawRecord.setUserName(user.getName());
|
|
|
|
+ withdrawRecord.setUserPhone(user.getPhoneNo());
|
|
|
|
+ withdrawRecord.setTransTime(DateUtil.date());
|
|
|
|
+ withdrawRecord.setUserId(userId);
|
|
|
|
+ withdrawRecord.setAccountType(param.getAccountType());
|
|
|
|
+ withdrawRecord.setFee(fee);
|
|
|
|
+ withdrawRecord.setBank(user.getBank());
|
|
|
|
+ withdrawRecord.setBankAccount(user.getBankAccount());
|
|
|
|
+ withdrawRecord.setBankAccountName(user.getBankAccountName());
|
|
|
|
+ // withdrawRecord.setChannel(param.getChannel());
|
|
|
|
+ withdrawRecord.setCurrency(param.getCurrency());
|
|
|
|
+ withdrawRecord.setAmount(param.getAmount());
|
|
|
|
+ withdrawRecord.setCreateTime(DateUtil.date());
|
|
|
|
+ withdrawRecordService.add(withdrawRecord);
|
|
|
|
+ return ResultGenerator.genSuccessResult(withdrawRecord);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("新增对象操作异常e:{}", e);
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@PostMapping("/list")
|
|
@PostMapping("/list")
|
|
- @ApiOperation(value = "withdrawRecord获取列表",httpMethod = "POST")
|
|
|
|
- public Result<List<WithdrawRecord>> list(@RequestBody RecordParam param, HttpServletRequest request) {
|
|
|
|
- Long userId = authService.getTokenUserId(request);
|
|
|
|
- if (userId == null ){
|
|
|
|
- ResultGenerator.genFailResult(ResultCode.OAUTH_INVALID_ACCESS_TOKEN);
|
|
|
|
- }
|
|
|
|
- PageHelper.startPage(param.getPage(), param.getSize());
|
|
|
|
-
|
|
|
|
- Condition condition = new Condition(WithdrawRecord.class);
|
|
|
|
- Criteria criteria = condition.createCriteria();
|
|
|
|
- criteria.andEqualTo("userId", userId);
|
|
|
|
- if (StrUtil.isNotBlank(param.getChannel())){
|
|
|
|
- criteria.andEqualTo("channel", param.getChannel());
|
|
|
|
- }
|
|
|
|
- if (StrUtil.isNotBlank(param.getUserName())){
|
|
|
|
- criteria.andEqualTo("userName", param.getUserName());
|
|
|
|
- }
|
|
|
|
- if (StrUtil.isNotBlank(param.getUserPhone())){
|
|
|
|
- criteria.andEqualTo("userPhone", param.getUserPhone());
|
|
|
|
- }
|
|
|
|
- if (StrUtil.isNotBlank(param.getOrderNo())){
|
|
|
|
- criteria.andEqualTo("orderNo", param.getOrderNo());
|
|
|
|
- }
|
|
|
|
- if (param.getStatus() != null){
|
|
|
|
- criteria.andEqualTo("status", param.getStatus());
|
|
|
|
- }
|
|
|
|
- if (param.getAccountType() != null){
|
|
|
|
- criteria.andEqualTo("accountType", param.getAccountType());
|
|
|
|
- }
|
|
|
|
- if (param.getTimeType() != null){
|
|
|
|
- if (param.getTimeType() ==1 ){
|
|
|
|
- if (StrUtil.isNotBlank(param.getStartTime())){
|
|
|
|
- criteria.andBetween("createTime", param.getStartTime(),param.getEndTime());
|
|
|
|
- }
|
|
|
|
- } else if (param.getTimeType() ==2 ){
|
|
|
|
- if (StrUtil.isNotBlank(param.getStartTime())){
|
|
|
|
- criteria.andBetween("successTime", param.getStartTime(),param.getEndTime());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- PageInfo pageInfo = null;
|
|
|
|
- try {
|
|
|
|
- condition.setOrderByClause("create_time desc");
|
|
|
|
- List<WithdrawRecord> list = withdrawRecordService.findByCondition(condition);
|
|
|
|
- pageInfo = new PageInfo(list);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("查询对象操作异常e:{}",e);
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
|
- }
|
|
|
|
- return ResultGenerator.genSuccessResult(pageInfo);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @GetMapping("/callback")
|
|
|
|
- @ApiOperation(value = "三方回调",httpMethod = "GET")
|
|
|
|
- public Result<RechargeRecord> callback(@RequestParam String data) {
|
|
|
|
- //TODO 回调成功
|
|
|
|
- JSONObject json = JSONUtil.parseObj(data);
|
|
|
|
- String orderNo = json.getStr("orderNo");
|
|
|
|
- WithdrawRecord record = withdrawRecordService.findBy("orderNo", orderNo);
|
|
|
|
- if (record == null){
|
|
|
|
- return ResultGenerator.genFailResult("订单未找到");
|
|
|
|
- }
|
|
|
|
- Integer type= 8;
|
|
|
|
- if (StrUtil.equals("1",json.getStr("status"))){
|
|
|
|
- withdrawRecordService.success(record);
|
|
|
|
- } else {
|
|
|
|
- withdrawRecordService.fail(record);
|
|
|
|
- type= 9;
|
|
|
|
- }
|
|
|
|
- try{
|
|
|
|
- //新增充值回调日志
|
|
|
|
- bizLogService.save(BizLog.builder().bizType(2).bizNo(orderNo)
|
|
|
|
- .type(type).createTime(DateUtil.date()).createUser("第三方")
|
|
|
|
- .memo("提现回调").build());
|
|
|
|
- }catch (Exception e){
|
|
|
|
- log.error("新增充值回调日志失败",e);
|
|
|
|
- }
|
|
|
|
- return ResultGenerator.genSuccessResult();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ @ApiOperation(value = "withdrawRecord获取列表", httpMethod = "POST")
|
|
|
|
+ public Result<List<WithdrawRecord>> list(@RequestBody RecordParam param, HttpServletRequest request) {
|
|
|
|
+ Long userId = authService.getTokenUserId(request);
|
|
|
|
+ if (userId == null) {
|
|
|
|
+ ResultGenerator.genFailResult(ResultCode.OAUTH_INVALID_ACCESS_TOKEN);
|
|
|
|
+ }
|
|
|
|
+ PageHelper.startPage(param.getPage(), param.getSize());
|
|
|
|
+
|
|
|
|
+ Condition condition = new Condition(WithdrawRecord.class);
|
|
|
|
+ Criteria criteria = condition.createCriteria();
|
|
|
|
+ criteria.andEqualTo("userId", userId);
|
|
|
|
+ if (StrUtil.isNotBlank(param.getChannel())) {
|
|
|
|
+ criteria.andEqualTo("channel", param.getChannel());
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isNotBlank(param.getUserName())) {
|
|
|
|
+ criteria.andEqualTo("userName", param.getUserName());
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isNotBlank(param.getUserPhone())) {
|
|
|
|
+ criteria.andEqualTo("userPhone", param.getUserPhone());
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isNotBlank(param.getOrderNo())) {
|
|
|
|
+ criteria.andEqualTo("orderNo", param.getOrderNo());
|
|
|
|
+ }
|
|
|
|
+ if (param.getStatus() != null) {
|
|
|
|
+ criteria.andEqualTo("status", param.getStatus());
|
|
|
|
+ }
|
|
|
|
+ if (param.getAccountType() != null) {
|
|
|
|
+ criteria.andEqualTo("accountType", param.getAccountType());
|
|
|
|
+ }
|
|
|
|
+ if (param.getTimeType() != null) {
|
|
|
|
+ if (param.getTimeType() == 1) {
|
|
|
|
+ if (StrUtil.isNotBlank(param.getStartTime())) {
|
|
|
|
+ criteria.andBetween("createTime", param.getStartTime(), param.getEndTime());
|
|
|
|
+ }
|
|
|
|
+ } else if (param.getTimeType() == 2) {
|
|
|
|
+ if (StrUtil.isNotBlank(param.getStartTime())) {
|
|
|
|
+ criteria.andBetween("successTime", param.getStartTime(), param.getEndTime());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ PageInfo pageInfo = null;
|
|
|
|
+ try {
|
|
|
|
+ condition.setOrderByClause("create_time desc");
|
|
|
|
+ List<WithdrawRecord> list = withdrawRecordService.findByCondition(condition);
|
|
|
|
+ pageInfo = new PageInfo(list);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ return ResultGenerator.genSuccessResult(pageInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * tfpay提现通知
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/callback/tfpay")
|
|
|
|
+ public String callback(@ModelAttribute TFWithdrawCallbackDTO dto) {
|
|
|
|
+ LockInfo lockInfo = lockTemplate.lock(String.format(MyConstants.TF_PAY_WITHDRAW_NOTIFY_LOCK, dto.getOrderid()), Long.valueOf(1000 * 60 * 2), Long.valueOf(1000 * 1), RedisTemplateLockExecutor.class);
|
|
|
|
+ if (null == lockInfo) {
|
|
|
|
+ return "WAIT";
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ log.info("提现渠道--->tfpay,提现回调通知--->" + dto);
|
|
|
|
+ Condition channelCondition = new Condition(PaymentChannel.class);
|
|
|
|
+ Example.Criteria channelCriteria = channelCondition.createCriteria();
|
|
|
|
+ channelCriteria.andEqualTo("channelName", "TFPAY");
|
|
|
|
+ channelCriteria.andEqualTo("isValid", 1);
|
|
|
|
+ List<PaymentChannel> paymentChannels = paymentChannelService.findByCondition(channelCondition);
|
|
|
|
+ if (CollectionUtil.isEmpty(paymentChannels)) {
|
|
|
|
+ log.error("支付渠道不存在");
|
|
|
|
+ return "FAIL";
|
|
|
|
+ }
|
|
|
|
+ boolean checkSignResult = TFPayUtil.verifySignature(BeanUtil.copyProperties(dto, CheckWithdrawSignDTO.class), paymentChannels.get(0).getSecretKey(), dto.getSign());
|
|
|
|
+
|
|
|
|
+ if (!checkSignResult) {
|
|
|
|
+ log.error("签名校验失败");
|
|
|
|
+ return "FAIL";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Condition condition = new Condition(WithdrawRecord.class);
|
|
|
|
+ Example.Criteria criteria = condition.createCriteria();
|
|
|
|
+ criteria.andEqualTo("thirdOrderNo", dto.getOrderid());
|
|
|
|
+ criteria.andEqualTo("status", 2);
|
|
|
|
+ List<WithdrawRecord> records = withdrawRecordService.findByCondition(condition);
|
|
|
|
+ if (CollectionUtil.isEmpty(records)) {
|
|
|
|
+ log.error("提现订单不存在");
|
|
|
|
+ return "FAIL";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // //TODO 回调成功
|
|
|
|
+ // JSONObject json = JSONUtil.parseObj(data);
|
|
|
|
+ // String orderNo = json.getStr("orderNo");
|
|
|
|
+ // WithdrawRecord record = withdrawRecordService.findBy("orderNo", orderNo);
|
|
|
|
+ // if (record == null) {
|
|
|
|
+ // return ResultGenerator.genFailResult("订单未找到");
|
|
|
|
+ // }
|
|
|
|
+ // Integer type = 8;
|
|
|
|
+ // if (StrUtil.equals("1", json.getStr("status"))) {
|
|
|
|
+ // withdrawRecordService.success(record);
|
|
|
|
+ // } else {
|
|
|
|
+ // withdrawRecordService.fail(record);
|
|
|
|
+ // type = 9;
|
|
|
|
+ // }
|
|
|
|
+ // try {
|
|
|
|
+ // // 新增充值回调日志
|
|
|
|
+ // bizLogService.save(BizLog.builder().bizType(2).bizNo(orderNo)
|
|
|
|
+ // .type(type).createTime(DateUtil.date()).createUser("第三方")
|
|
|
|
+ // .memo("提现回调").build());
|
|
|
|
+ // } catch (Exception e) {
|
|
|
|
+ // log.error("新增充值回调日志失败", e);
|
|
|
|
+ // }
|
|
|
|
+ // return ResultGenerator.genSuccessResult();
|
|
|
|
+
|
|
|
|
+ Integer type = 8;
|
|
|
|
+ if (StrUtil.equals("1", dto.getReturncode())) {
|
|
|
|
+ withdrawRecordService.success(records.get(0));
|
|
|
|
+ } else {
|
|
|
|
+ withdrawRecordService.fail(records.get(0));
|
|
|
|
+ type = 9;
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ // 新增充值回调日志
|
|
|
|
+ bizLogService.save(BizLog.builder()
|
|
|
|
+ .bizType(2)
|
|
|
|
+ .bizNo(dto.getOrderid())
|
|
|
|
+ .type(type)
|
|
|
|
+ .receiveMessage(dto.toString())
|
|
|
|
+ .createTime(DateUtil.date())
|
|
|
|
+ .createUser("TFPAY")
|
|
|
|
+ .memo("提现回调").build());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("新增充值回调日志失败", e);
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return "OK";
|
|
|
|
+ } finally {
|
|
|
|
+ lockTemplate.releaseLock(lockInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|