add 新增运营端小程序"我的钱包"界面接口

This commit is contained in:
YAS\29473
2026-01-17 16:33:12 +08:00
parent 0f763c8deb
commit 5f6631e3b9
5 changed files with 331 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
package com.jsowell.api.uniapp.business;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.pile.dto.MerchantOrderReportDTO;
import com.jsowell.pile.service.BusinessFinancialService;
import com.jsowell.pile.vo.uniapp.business.BusinessFinancialQueryResultVO;
import org.apache.commons.lang3.StringUtils;
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;
/**
* 运营端财务信息相关Controller
*
* @author Lemon
*/
@RestController
@RequestMapping("/business/financial")
public class BusinessFinancialController extends BaseController {
@Autowired
private BusinessFinancialService businessFinancialService;
/**
* 我的钱包界面查询接口
*
* @param dto 查询参数
* @return 钱包信息查询结果
*/
@PostMapping("/")
public RestApiResponse<?> getMyWallet(@RequestBody MerchantOrderReportDTO dto) {
logger.info("我的钱包查询 merchantId:{}", dto != null ? dto.getMerchantId() : null);
RestApiResponse<?> response;
try {
// 参数验证
if (dto == null || StringUtils.isBlank(dto.getMerchantId())) {
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
}
BusinessFinancialQueryResultVO result = businessFinancialService.getMyWallet(dto);
response = new RestApiResponse<>(result);
logger.info("我的钱包查询成功 merchantId:{}", dto.getMerchantId());
} catch (BusinessException e) {
logger.warn("我的钱包查询业务异常 merchantId:{}, code:{}, message:{}",
dto != null ? dto.getMerchantId() : null, e.getCode(), e.getMessage(), e);
response = new RestApiResponse<>(e.getCode(), e.getMessage());
} catch (Exception e) {
logger.error("我的钱包查询系统异常 merchantId:{}",
dto != null ? dto.getMerchantId() : null, e);
response = new RestApiResponse<>(e);
}
return response;
}
}

View File

@@ -0,0 +1,101 @@
import com.alibaba.fastjson.JSON;
import com.jsowell.pile.dto.QueryOrderSplitRecordDTO;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;
import java.util.Arrays;
import java.util.List;
public class MemberBindingCarNoHttpTest {
public static void main(String[] args) {
// 1⃣ 接口地址(和 curl 完全一致)
String url = "https://apitest.jsowellcloud.com/order/commission/retryMerchantSplit";
// 2⃣ 登录态 token去掉 Bearer 前缀setBearerAuth 会自动添加)
String token = "Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImEyNmNhZmNiLTk5YzQtNDZkNi05M2EyLTg2NGYyOGVmYmFkYSJ9.Hv5-CztUtq04POwcUeBwvPLr2CzAnXcvnAZzNTH0zFo8ZxsP1ZoeqK7Pnohg4a-cdwvlpGFrXLDQ_gkr5psyBw";
String endTime = "2025-11-28";
String startTime = "2025-11-28";
List<Integer> merchantIds = Arrays.asList(
444, 281, 399, 355, 86, 162, 252, 341, 267, 327,
312, 400, 384, 282, 297, 370, 87, 356, 41, 313,
222, 255, 343, 447, 177, 25, 329, 147, 268, 283,
298, 101, 314, 385, 401, 132, 193, 118, 166, 209,
56, 357, 223, 416, 269, 88, 449, 330, 284, 402,
102, 475, 149, 299, 237, 375, 210, 345, 72, 270,
167, 134, 179, 26, 386, 316, 417, 89, 331, 451,
195, 358, 103, 44, 376, 211, 432, 150, 119, 459,
58, 259, 285, 301, 180, 73, 238, 477, 387, 28,
452, 403, 226, 196, 272, 136, 332, 104, 45, 435,
151, 460, 418, 377, 59, 302, 212, 319, 359, 349,
273, 453, 388, 404, 170, 239, 29, 121, 227, 419,
261, 106, 436, 138, 183, 76, 287, 198, 60, 462,
47, 304, 389, 378, 481, 274, 351, 334, 214, 122,
420, 321, 30, 405, 154, 228, 437, 172, 288, 352,
108, 184, 263, 139, 322, 363, 275, 97, 199, 31,
78, 421, 155, 391, 307, 123, 229, 353, 215, 173,
380, 408, 185, 241, 364, 336, 276, 466, 140, 63,
110, 422, 392, 32, 354, 230, 409, 309, 124, 324,
186, 201, 51, 393, 141, 277, 337, 382, 33, 292,
64, 366, 442, 310, 187, 489, 244, 468, 158, 410,
232, 111, 425, 202, 125, 338, 81, 443, 188, 160,
221, 34, 469, 143, 397, 427, 233, 294, 66, 54,
126, 471, 367, 161, 189, 144, 113, 429, 295, 190,
145, 114, 246, 127, 474, 82, 236, 368, 70, 146,
369, 278, 115, 130, 248, 279, 131, 83, 280, 84,
251, 116, 85, 35, 36, 3, 37, 9,
17, 18, 19, 21, 22, 23, 24
);
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(MediaType.parseMediaTypes("*/*"));
headers.setBearerAuth(token); // 等价于 Authorization: Bearer xxx
int success = 0;
int fail = 0;
for (Integer merchantId : merchantIds) {
QueryOrderSplitRecordDTO dto = new QueryOrderSplitRecordDTO();
dto.setMerchantId(String.valueOf(merchantId));
dto.setStartTime(startTime);
dto.setEndTime(endTime);
HttpEntity<String> request =
new HttpEntity<>(JSON.toJSONString(dto), headers);
try {
ResponseEntity<String> response =
restTemplate.postForEntity(url, request, String.class);
System.out.println("成功处理 merchantId=" + merchantId
+ " response=" + response.getBody());
success++;
// 👇 可选:防止接口被限流
Thread.sleep(100);
} catch (Exception e) {
fail++;
System.err.println("处理失败 merchantId=" + merchantId);
e.printStackTrace();
}
}
System.out.println("====== 批量处理完成 ======");
System.out.println("成功:" + success);
System.out.println("失败:" + fail);
}
}

View File

@@ -0,0 +1,8 @@
package com.jsowell.pile.service;
import com.jsowell.pile.dto.MerchantOrderReportDTO;
import com.jsowell.pile.vo.uniapp.business.BusinessFinancialQueryResultVO;
public interface BusinessFinancialService {
BusinessFinancialQueryResultVO getMyWallet(MerchantOrderReportDTO dto);
}

View File

@@ -0,0 +1,86 @@
package com.jsowell.pile.service.impl;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.jsowell.adapay.service.AdapayService;
import com.jsowell.adapay.vo.AdapayAccountBalanceVO;
import com.jsowell.pile.dto.MerchantOrderReportDTO;
import com.jsowell.pile.service.BusinessFinancialService;
import com.jsowell.pile.service.ClearingWithdrawInfoService;
import com.jsowell.pile.service.SettleOrderReportService;
import com.jsowell.pile.vo.uniapp.business.BusinessFinancialQueryResultVO;
import com.jsowell.pile.vo.web.MerchantOrderReportVO;
import com.jsowell.pile.vo.web.OrderReportDetail;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/**
* 运营端小程序财务相关Service
*/
@Slf4j
@Service
public class BusinessFinancialServiceImpl implements BusinessFinancialService {
@Autowired
private SettleOrderReportService settleOrderReportService;
@Autowired
private AdapayService adapayService;
@Autowired
private ClearingWithdrawInfoService clearingWithdrawInfoService;
/**
* 我的钱包查询
* @param dto
* @return
*/
@Override
public BusinessFinancialQueryResultVO getMyWallet(MerchantOrderReportDTO dto) {
// 查询运营商订单报表
MerchantOrderReportVO merchantOrderReportVO = settleOrderReportService.getMerchantOrderReportV2(dto);
// 构建返回结果
BusinessFinancialQueryResultVO result = new BusinessFinancialQueryResultVO();
// 从订单报表中获取收入金额、交易金额、交易手续费
if (merchantOrderReportVO != null && merchantOrderReportVO.getMerchantOrderReport() != null) {
OrderReportDetail report = merchantOrderReportVO.getMerchantOrderReport();
result.setTotalAmount(report.getTotalAmount() != null ? report.getTotalAmount() : BigDecimal.ZERO);
result.setTradeAmount(report.getTradeAmount() != null ? report.getTradeAmount() : BigDecimal.ZERO);
result.setTradeFee(report.getTradeFee() != null ? report.getTradeFee() : BigDecimal.ZERO);
} else {
result.setTotalAmount(BigDecimal.ZERO);
result.setTradeAmount(BigDecimal.ZERO);
result.setTradeFee(BigDecimal.ZERO);
}
// 查询账户余额
BigDecimal acctBalance = BigDecimal.ZERO;
try {
AdapayAccountBalanceVO accountBalanceVO = adapayService.queryAdapayAccountBalance(dto.getMerchantId());
if (accountBalanceVO != null && accountBalanceVO.getAcctBalance() != null) {
acctBalance = accountBalanceVO.getAcctBalance();
}
} catch (BaseAdaPayException e) {
log.error("查询汇付账户余额异常 merchantId:{}", dto.getMerchantId(), e);
}
result.setAcctBalance(acctBalance);
// 查询累计提现金额
BigDecimal totalWithdraw = BigDecimal.ZERO;
try {
BigDecimal withdraw = clearingWithdrawInfoService.queryTotalWithdraw(dto.getMerchantId());
if (withdraw != null) {
totalWithdraw = withdraw;
}
} catch (Exception e) {
log.error("查询累计提现金额异常 merchantId:{}", dto.getMerchantId(), e);
}
result.setTotalWithdraw(totalWithdraw);
return result;
}
}

View File

@@ -0,0 +1,77 @@
package com.jsowell.pile.vo.uniapp.business;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@Builder
@NoArgsConstructor
public class BusinessFinancialQueryResultVO {
/**
* 账户总余额
*/
private BigDecimal acctBalance;
/**
* 累计提现金额
*/
private BigDecimal totalWithdraw;
/**
* 收入金额
*/
private BigDecimal totalAmount;
/**
* 交易金额
*/
private BigDecimal tradeAmount;
/**
* 交易手续费
*/
private BigDecimal tradeFee;
@Data
@AllArgsConstructor
@Builder
@NoArgsConstructor
public static class BusinessFinancialQueryResultList{
/**
* 账单金额
*/
private BigDecimal billAmount;
/**
* 账单状态
* 0-未清分1-清分在途2-可提现3-提现申请中4-已提现5等待处理6-线下结算)
*/
private String billStatus;
/**
* 交易日期
*/
private String tradeDate;
/**
* 提现申请时间
*/
private String applicationTime;
/**
* 提现订单号
*/
private String withdrawCode;
}
}