|
|
@@ -0,0 +1,224 @@
|
|
|
+package com.sckw.payment.controller;
|
|
|
+
|
|
|
+import com.sckw.core.model.enums.EntTypeEnum;
|
|
|
+import com.sckw.core.model.page.PageRes;
|
|
|
+import com.sckw.core.web.context.LoginEntHolder;
|
|
|
+import com.sckw.core.web.response.BaseResult;
|
|
|
+import com.sckw.payment.api.model.dto.TradeEntInfoResVo;
|
|
|
+import com.sckw.payment.api.model.dto.common.R;
|
|
|
+import com.sckw.payment.pojo.CashVo;
|
|
|
+import com.sckw.payment.pojo.UpdateCash;
|
|
|
+import com.sckw.payment.pojo.dto.CashWalletReq;
|
|
|
+import com.sckw.payment.pojo.vo.WalletCashVo;
|
|
|
+import com.sckw.payment.pojo.vo.WalletVo;
|
|
|
+import com.sckw.payment.pojo.vo.req.CreateUserReq;
|
|
|
+import com.sckw.payment.pojo.vo.req.WalletPayableQuery;
|
|
|
+import com.sckw.payment.pojo.vo.req.WalletPrepaidQuery;
|
|
|
+import com.sckw.payment.pojo.vo.res.HttpResult;
|
|
|
+import com.sckw.payment.pojo.vo.res.WalletPayableSummary;
|
|
|
+import com.sckw.payment.pojo.vo.res.WalletPrepaidSummary;
|
|
|
+import com.sckw.payment.pojo.vo.res.WalletSummary;
|
|
|
+import com.sckw.payment.service.IWalletPayableService;
|
|
|
+import com.sckw.payment.service.IWalletPrepaidService;
|
|
|
+import com.sckw.payment.service.WalletService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import jakarta.validation.Valid;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 钱包表Controller
|
|
|
+ *
|
|
|
+ * @author tangys
|
|
|
+ * @since 2026-01-06 11:03:35
|
|
|
+ */
|
|
|
+
|
|
|
+@Tag(name = "钱包管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/wallet")
|
|
|
+public class WalletController {
|
|
|
+
|
|
|
+
|
|
|
+ // @Autowired
|
|
|
+// private IWalletService walletService;
|
|
|
+ @Resource
|
|
|
+ private WalletService walletService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IWalletPrepaidService walletPrepaidService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IWalletPayableService walletPayableService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 【接口】开户
|
|
|
+ *
|
|
|
+ * @param createUserReq 开户请求参数
|
|
|
+ */
|
|
|
+ @Operation(summary = "开户", description = "为用户开通钱包账户")
|
|
|
+ @PostMapping("createUser")
|
|
|
+ public HttpResult createUser(@RequestBody @Valid CreateUserReq createUserReq) {
|
|
|
+ return HttpResult.ok(walletService.createUser(createUserReq));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 【接口】钱包信息
|
|
|
+ */
|
|
|
+ @Operation(summary = "查询用户钱包信息", description = "查询用户钱包信息")
|
|
|
+ @GetMapping("/info")
|
|
|
+ public R<WalletVo> userInfo() {
|
|
|
+ return walletService.userInfo();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 【接口】可提现余额
|
|
|
+ */
|
|
|
+ @Operation(summary = "可提现余额", description = "可提现余额")
|
|
|
+ @GetMapping("/cashInfo")
|
|
|
+ public R<WalletCashVo> cashInfo() {
|
|
|
+ return walletService.cashInfo();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 【接口】更新预付直提开关
|
|
|
+ */
|
|
|
+ @Operation(summary = "更新预付直提开关", description = "更新预付直提开关")
|
|
|
+ @PostMapping("/updateCash")
|
|
|
+ public R<Integer> updateCash(@RequestBody @Valid UpdateCash updateCash) {
|
|
|
+ return R.ok(walletService.updateCash(updateCash));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "查询交易对方企业列表")
|
|
|
+ @GetMapping("/queryEntList")
|
|
|
+ public BaseResult<List<TradeEntInfoResVo>> queryEntList() {
|
|
|
+ return BaseResult.success(walletService.queryEntList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 【接口】可提现余额分页查询
|
|
|
+ */
|
|
|
+ @Operation(summary = "可提现余额分页查询", description = "可提现余额分页查询")
|
|
|
+ @Parameter(name = "entId", description = "企业id", required = true)
|
|
|
+ @PostMapping("/cashPage")
|
|
|
+ public R<PageRes<CashVo>> cashPage(@RequestBody @Valid CashParaPage cashParaPage) {
|
|
|
+ return R.ok(walletService.cashPage(cashParaPage));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 【接口】提现
|
|
|
+ *
|
|
|
+ * @param cashWalletReq 提现参数
|
|
|
+ * @return 操作结果
|
|
|
+ */
|
|
|
+ @Operation(summary = "提现", description = "发起提现操作")
|
|
|
+ @PostMapping("cashOUt")
|
|
|
+ public R<Object> cashOUt(@RequestBody @Valid CashWalletReq cashWalletReq) {
|
|
|
+ return R.ok(walletService.cashOUt(cashWalletReq));
|
|
|
+ }
|
|
|
+ //1、查询钱包信息
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业用户钱包查询
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+// @GetMapping("/queryWalletInfo")
|
|
|
+// public BaseResult queryWalletInfo() {
|
|
|
+// Wallet wallet = walletService.selectWalletByEntId(LoginUserHolder.getEntId());
|
|
|
+// if (Objects.isNull(wallet)) {
|
|
|
+// return BaseResult.success("钱包账号不存在");
|
|
|
+// }
|
|
|
+// return BaseResult.success(wallet);
|
|
|
+//// BankService bankService = BankServiceUtil.getBankService(properties.getBankCode());
|
|
|
+//// bankService.queryWalletInfo(wallet);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ //查询钱包可提现、预付余额及运费的汇总接口
|
|
|
+ @Operation(summary = "查询钱包可提现、预付余额及运费的汇总接口")
|
|
|
+ @GetMapping("/querySummary")
|
|
|
+ public BaseResult<WalletSummary> querySummary() {
|
|
|
+ WalletSummary summary = new WalletSummary();
|
|
|
+ String entTypes = LoginEntHolder.get().getEntTypes();
|
|
|
+ WalletPrepaidQuery prepaidQuery = new WalletPrepaidQuery();
|
|
|
+ prepaidQuery.setCurEntId(LoginEntHolder.getEntId());
|
|
|
+ if (entTypes.contains(String.valueOf(EntTypeEnum.SUPPLIER.getCode()))) {
|
|
|
+ prepaidQuery.setEntType(EntTypeEnum.SUPPLIER.getCode());
|
|
|
+ } else if (entTypes.contains(String.valueOf(EntTypeEnum.PURCHASER.getCode()))) {
|
|
|
+ prepaidQuery.setEntType(EntTypeEnum.PURCHASER.getCode());
|
|
|
+ }
|
|
|
+ R<WalletCashVo> walletCashVoR = walletService.cashInfo();
|
|
|
+
|
|
|
+ if (HttpStatus.SUCCESS == walletCashVoR.getCode()) {
|
|
|
+ WalletCashVo data = walletCashVoR.getData();
|
|
|
+ summary.setAvailableBalance(data.getCashAmount());
|
|
|
+ summary.setId(data.getId());
|
|
|
+ summary.setCashFlag(data.getCashFlag());
|
|
|
+ }
|
|
|
+ WalletPrepaidSummary prepaidSummary = walletPrepaidService.selectWalletPrepaidSummary(prepaidQuery);
|
|
|
+ if (prepaidSummary != null) {
|
|
|
+ summary.setPreBalanceTotal(prepaidSummary.getBalanceTotal());
|
|
|
+ summary.setPreTradingAmountTotal(prepaidSummary.getTradingAmountTotal());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ WalletPayableQuery payableQuery = new WalletPayableQuery();
|
|
|
+ payableQuery.setCurEntId(LoginEntHolder.getEntId());
|
|
|
+ if (EntTypeEnum.consign(entTypes)) {
|
|
|
+ payableQuery.setFreightType(1);
|
|
|
+ } else if (EntTypeEnum.carrier(entTypes)) {
|
|
|
+ payableQuery.setFreightType(2);
|
|
|
+ }
|
|
|
+
|
|
|
+ WalletPayableSummary walletPayableSummary = walletPayableService.selectPayableSummary(payableQuery);
|
|
|
+ if (walletPayableSummary != null) {
|
|
|
+ summary.setFreightTotal(walletPayableSummary.getFreightTotal());
|
|
|
+ summary.setTradingFreightTotal(walletPayableSummary.getTradingFreightTotal());
|
|
|
+ summary.setPayingFreightTotal(walletPayableSummary.getPayingFreightTotal());
|
|
|
+ }
|
|
|
+
|
|
|
+ return BaseResult.success(summary);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增钱包
|
|
|
+ */
|
|
|
+// @Operation(summary = "新增保存钱包表")
|
|
|
+// @PostMapping("/add")
|
|
|
+// public BaseResult addSave(@RequestBody WalletInfoVo walletInfoVo) {
|
|
|
+// walletInfoVo.setEntId(LoginUserHolder.getEntId());
|
|
|
+// return BaseResult.success(walletService.createWallet(walletInfoVo));
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改钱包表
|
|
|
+ *
|
|
|
+ * @return ModelAndView
|
|
|
+ */
|
|
|
+
|
|
|
+// @Operation(summary = "修改保存钱包表")
|
|
|
+// @PostMapping(value = "/edit/{id}")
|
|
|
+// public BaseResult editSave(@PathVariable Long id) {
|
|
|
+// Wallet wallet = walletService.selectWalletById(id);
|
|
|
+// return toAjax(walletService.updateWallet(wallet));
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ // @Operation(summary = "删除钱包表",parameters = {
|
|
|
+// @Parameter(name = "ids", description = "id,多个用英文逗号分隔",required = true)
|
|
|
+// })
|
|
|
+// @PostMapping("/remove")
|
|
|
+// public BaseResult remove(String ids) {
|
|
|
+// if (StringUtils.isBlank(ids)) {
|
|
|
+// return BaseResult.failed("请选择需要删除的数据!");
|
|
|
+// }
|
|
|
+// List<Long> idList = Stream.of(ids.split(",")).filter(StringUtils::isNotBlank).map(String::trim).map(Long::valueOf).distinct().collect(Collectors.toList());
|
|
|
+// return toAjax(walletService.deleteWalletByIds(idList));
|
|
|
+// }
|
|
|
+}
|