(〃'▽'〃) v2.5.0 发布:又熬过 30 个夜,头发还在
This commit is contained in:
parent
133c1219ca
commit
5274e75af3
@ -1,12 +0,0 @@
|
||||
### 测试 AI 工作流
|
||||
POST {{baseUrl}}/ai/workflow/test
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
{
|
||||
"id": 4,
|
||||
"params": {
|
||||
"message": "1 + 1 = ?"
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
package cn.iocoder.yudao.module.ai.service.model.tool;
|
||||
|
||||
import cn.iocoder.yudao.framework.ai.core.util.AiUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.fasterxml.jackson.annotation.JsonClassDescription;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.ai.chat.model.ToolContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* 工具:当前用户信息查询
|
||||
*
|
||||
* 同时,也是展示 ToolContext 上下文的使用
|
||||
*
|
||||
* @author Ren
|
||||
*/
|
||||
@Component("user_profile_query")
|
||||
public class UserProfileQueryToolFunction
|
||||
implements BiFunction<UserProfileQueryToolFunction.Request, ToolContext, UserProfileQueryToolFunction.Response> {
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Data
|
||||
@JsonClassDescription("当前用户信息查询")
|
||||
public static class Request { }
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Response {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfileQueryToolFunction.Response apply(UserProfileQueryToolFunction.Request request, ToolContext toolContext) {
|
||||
LoginUser loginUser = (LoginUser) toolContext.getContext().get(AiUtils.TOOL_CONTEXT_LOGIN_USER);
|
||||
Long tenantId = (Long) toolContext.getContext().get(AiUtils.TOOL_CONTEXT_TENANT_ID);
|
||||
if (loginUser == null | tenantId == null) {
|
||||
return null;
|
||||
}
|
||||
return TenantUtils.execute(tenantId, () -> {
|
||||
AdminUserRespDTO user = adminUserApi.getUser(loginUser.getId());
|
||||
return BeanUtils.toBean(user, Response.class);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package cn.iocoder.yudao.framework.ai.chat;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.ai.chat.messages.Message;
|
||||
import org.springframework.ai.chat.messages.SystemMessage;
|
||||
import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.openai.OpenAiChatModel;
|
||||
import org.springframework.ai.openai.api.OpenAiApi;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 基于 {@link OpenAiChatModel} 集成 Coze 测试
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public class CozeChatModelTests {
|
||||
|
||||
private final OpenAiChatModel chatModel = OpenAiChatModel.builder()
|
||||
.openAiApi(OpenAiApi.builder()
|
||||
.baseUrl("http://127.0.0.1:3000")
|
||||
.apiKey("app-4hy2d7fJauSbrKbzTKX1afuP") // apiKey
|
||||
.build())
|
||||
.build();
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testCall() {
|
||||
// 准备参数
|
||||
List<Message> messages = new ArrayList<>();
|
||||
messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。"));
|
||||
messages.add(new UserMessage("1 + 1 = ?"));
|
||||
|
||||
// 调用
|
||||
ChatResponse response = chatModel.call(new Prompt(messages));
|
||||
// 打印结果
|
||||
System.out.println(response);
|
||||
System.out.println(response.getResult().getOutput());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void testStream() {
|
||||
// 准备参数
|
||||
List<Message> messages = new ArrayList<>();
|
||||
messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。"));
|
||||
messages.add(new UserMessage("1 + 1 = ?"));
|
||||
|
||||
// 调用
|
||||
Flux<ChatResponse> flux = chatModel.stream(new Prompt(messages));
|
||||
// 打印结果
|
||||
flux.doOnNext(response -> {
|
||||
// System.out.println(response);
|
||||
System.out.println(response.getResult().getOutput());
|
||||
}).then().block();
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "用户 App - 交易售后分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AppAfterSalePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "售后状态", example = "10, 20")
|
||||
private Set<Integer> statuses;
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package cn.iocoder.yudao.module.trade.service.order.handler;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.api.order.PayOrderApi;
|
||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaOrderNotifyConfirmReceiveReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaOrderUploadShippingInfoReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
|
||||
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 同步订单状态到微信小程序的 {@link TradeOrderHandler} 实现类
|
||||
*
|
||||
* 背景:电商类目的微信小程序需要上传发货信息,不然微信支付会被封 = =!
|
||||
* 注意:微信小程序开发环境下的订单不能用来发货。只有小程序正式版才会有发货,所以体验版无法调通,提示订单不存在。注意别踩坑。
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@ConditionalOnProperty(prefix = "yudao.trade.order", value = "status-sync-to-wxa-enable")
|
||||
public class TradeStatusSyncToWxaOrderHandler implements TradeOrderHandler {
|
||||
|
||||
@Resource
|
||||
private PayOrderApi payOrderApi;
|
||||
@Resource
|
||||
private SocialClientApi socialClientApi;
|
||||
|
||||
@Resource
|
||||
private DeliveryExpressService expressService;
|
||||
|
||||
@Override
|
||||
public void afterDeliveryOrder(TradeOrderDO order) {
|
||||
// 注意:只有微信小程序支付的订单,才需要同步
|
||||
if (ObjUtil.notEqual(order.getPayChannelCode(), PayChannelEnum.WX_LITE.getCode())) {
|
||||
return;
|
||||
}
|
||||
PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId());
|
||||
SocialWxaOrderUploadShippingInfoReqDTO reqDTO = new SocialWxaOrderUploadShippingInfoReqDTO()
|
||||
.setTransactionId(payOrder.getChannelOrderNo())
|
||||
.setOpenid(payOrder.getChannelUserId())
|
||||
.setItemDesc(payOrder.getSubject())
|
||||
.setReceiverContact(order.getReceiverMobile());
|
||||
if (DeliveryTypeEnum.EXPRESS.getType().equals(order.getDeliveryType()) && StrUtil.isNotEmpty(order.getLogisticsNo())) {
|
||||
reqDTO.setLogisticsType(SocialWxaOrderUploadShippingInfoReqDTO.LOGISTICS_TYPE_EXPRESS)
|
||||
.setExpressCompany(expressService.getDeliveryExpress(order.getLogisticsId()).getCode())
|
||||
.setLogisticsNo(order.getLogisticsNo());
|
||||
} else if (DeliveryTypeEnum.PICK_UP.getType().equals(order.getDeliveryType())) {
|
||||
reqDTO.setLogisticsType(SocialWxaOrderUploadShippingInfoReqDTO.LOGISTICS_TYPE_PICK_UP);
|
||||
} else {
|
||||
reqDTO.setLogisticsType(SocialWxaOrderUploadShippingInfoReqDTO.LOGISTICS_TYPE_VIRTUAL);
|
||||
}
|
||||
try {
|
||||
socialClientApi.uploadWxaOrderShippingInfo(UserTypeEnum.MEMBER.getValue(), reqDTO);
|
||||
} catch (Exception ex) {
|
||||
log.error("[afterDeliveryOrder][订单({}) 上传订单物流信息到微信小程序失败]", order, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterReceiveOrder(TradeOrderDO order) {
|
||||
// 注意:只有微信小程序支付的订单,才需要同步
|
||||
if (ObjUtil.notEqual(order.getPayChannelCode(), PayChannelEnum.WX_LITE.getCode())) {
|
||||
return;
|
||||
}
|
||||
PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId());
|
||||
SocialWxaOrderNotifyConfirmReceiveReqDTO reqDTO = new SocialWxaOrderNotifyConfirmReceiveReqDTO()
|
||||
.setTransactionId(payOrder.getChannelOrderNo())
|
||||
.setReceivedTime(order.getReceiveTime());
|
||||
try {
|
||||
socialClientApi.notifyWxaOrderConfirmReceive(UserTypeEnum.MEMBER.getValue(), reqDTO);
|
||||
} catch (Exception ex) {
|
||||
log.error("[afterReceiveOrder][订单({}) 通知订单收货到微信小程序失败]", order, ex);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @芋艿:【设置路径】 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E5%85%AD%E3%80%81%E6%B6%88%E6%81%AF%E8%B7%B3%E8%BD%AC%E8%B7%AF%E5%BE%84%E8%AE%BE%E7%BD%AE%E6%8E%A5%E5%8F%A3
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.api.transfer.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 转账单创建 Response DTO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class PayTransferCreateRespDTO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
// ========== 其它字段 ==========
|
||||
|
||||
/**
|
||||
* 渠道 package 信息
|
||||
*
|
||||
* 特殊:目前只有微信转账有这个东西!!!
|
||||
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
|
||||
*/
|
||||
private String channelPackageInfo;
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.api.wallet.dto;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 钱包 Response DTO
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class PayWalletRespDTO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户 id
|
||||
*
|
||||
* 关联 MemberUserDO 的 id 编号
|
||||
* 关联 AdminUserDO 的 id 编号
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 用户类型, 预留 多商户转帐可能需要用到
|
||||
*
|
||||
* 关联 {@link UserTypeEnum}
|
||||
*/
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 余额,单位分
|
||||
*/
|
||||
private Integer balance;
|
||||
|
||||
/**
|
||||
* 冻结金额,单位分
|
||||
*/
|
||||
private Integer freezePrice;
|
||||
|
||||
/**
|
||||
* 累计支出,单位分
|
||||
*/
|
||||
private Integer totalExpense;
|
||||
/**
|
||||
* 累计充值,单位分
|
||||
*/
|
||||
private Integer totalRecharge;
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 支付渠道的编码的枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PayChannelEnum implements ArrayValuable<String> {
|
||||
|
||||
WX_PUB("wx_pub", "微信 JSAPI 支付"), // 公众号网页
|
||||
WX_LITE("wx_lite", "微信小程序支付"),
|
||||
WX_APP("wx_app", "微信 App 支付"),
|
||||
WX_NATIVE("wx_native", "微信 Native 支付"),
|
||||
WX_WAP("wx_wap", "微信 Wap 网站支付"), // H5 网页
|
||||
WX_BAR("wx_bar", "微信付款码支付"),
|
||||
|
||||
ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付"),
|
||||
ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付"),
|
||||
ALIPAY_APP("alipay_app", "支付宝App 支付"),
|
||||
ALIPAY_QR("alipay_qr", "支付宝扫码支付"),
|
||||
ALIPAY_BAR("alipay_bar", "支付宝条码支付"),
|
||||
MOCK("mock", "模拟支付"),
|
||||
|
||||
WALLET("wallet", "钱包支付");
|
||||
|
||||
public static final String[] ARRAYS = Arrays.stream(values()).map(PayChannelEnum::getCode).toArray(String[]::new);
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*
|
||||
* 参考 <a href="https://www.pingxx.com/api/支付渠道属性值.html">支付渠道属性值</a>
|
||||
*/
|
||||
private final String code;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public String[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.enums.demo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 示例提现单的状态枚举
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PayDemoWithdrawStatusEnum {
|
||||
|
||||
WAITING(0, "等待提现"),
|
||||
SUCCESS(10, "提现成功"),
|
||||
CLOSED(20, "提现关闭");
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
public static boolean isSuccess(Integer status) {
|
||||
return Objects.equals(status, SUCCESS.getStatus());
|
||||
}
|
||||
|
||||
public static boolean isClosed(Integer status) {
|
||||
return Objects.equals(status, CLOSED.getStatus());
|
||||
}
|
||||
|
||||
public static boolean isWaiting(Integer status) {
|
||||
return Objects.equals(status, WAITING.getStatus());
|
||||
}
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.enums.demo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 示例提现单的类型枚举
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum PayDemoWithdrawTypeEnum implements ArrayValuable<Integer> {
|
||||
|
||||
WECHAT(2, "微信"),
|
||||
ALIPAY(1, "支付宝"),
|
||||
WALLET(3, "钱包"),
|
||||
;
|
||||
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(PayDemoWithdrawTypeEnum::getType).toArray(Integer[]::new);
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final Integer type;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
### 请求 /pay/demo-withdraw/create 接口(支付宝)
|
||||
POST {{baseUrl}}/pay/demo-withdraw/create
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
{
|
||||
"type": 1,
|
||||
"subject": "测试转账",
|
||||
"price": 10,
|
||||
"userAccount": "oespxk7368@sandbox.com",
|
||||
"userName": "oespxk7368"
|
||||
}
|
||||
|
||||
### 请求 /pay/demo-withdraw/create 接口(微信余额)
|
||||
POST {{baseUrl}}/pay/demo-withdraw/create
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
{
|
||||
"type": 2,
|
||||
"subject": "测试转账",
|
||||
"price": 1,
|
||||
"userAccount": "oiSC85elO_OZogXODC5RoGyXamK4",
|
||||
"userName": "芋艿"
|
||||
}
|
||||
|
||||
### 请求 /pay/demo-withdraw/create 接口(钱包余额)
|
||||
POST {{baseUrl}}/pay/demo-withdraw/create
|
||||
Authorization: Bearer {{token}}
|
||||
Content-Type: application/json
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
{
|
||||
"type": 3,
|
||||
"subject": "测试转账",
|
||||
"price": 1,
|
||||
"userAccount": "1"
|
||||
}
|
||||
|
||||
### 请求 /pay/demo-withdraw/transfer 接口(发起转账)
|
||||
POST {{baseUrl}}/pay/demo-withdraw/transfer?id=1
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
### 请求 /pay/demo-withdraw/page 接口(查询分页)
|
||||
GET {{baseUrl}}/pay/demo-withdraw/page?pageNo=1&pageSize=10
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
@ -1,64 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.admin.demo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.pay.api.notify.dto.PayTransferNotifyReqDTO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.withdraw.PayDemoWithdrawCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.withdraw.PayDemoWithdrawRespVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoWithdrawDO;
|
||||
import cn.iocoder.yudao.module.pay.service.demo.PayDemoWithdrawService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 示例提现订单") // 目的:演示转账功能
|
||||
@RestController
|
||||
@RequestMapping("/pay/demo-withdraw")
|
||||
@Validated
|
||||
public class PayDemoWithdrawController {
|
||||
|
||||
@Resource
|
||||
private PayDemoWithdrawService demoWithdrawService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建示例提现单")
|
||||
public CommonResult<Long> createDemoWithdraw(@Valid @RequestBody PayDemoWithdrawCreateReqVO createReqVO) {
|
||||
Long id = demoWithdrawService.createDemoWithdraw(createReqVO);
|
||||
return success(id);
|
||||
}
|
||||
|
||||
@PostMapping("/transfer")
|
||||
@Operation(summary = "提现单转账")
|
||||
@Parameter(name = "id", required = true, description = "提现单编号", example = "1024")
|
||||
public CommonResult<Long> transferDemoWithdraw(@RequestParam("id") Long id) {
|
||||
Long payTransferId = demoWithdrawService.transferDemoWithdraw(id);
|
||||
return success(payTransferId);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得示例提现单分页")
|
||||
public CommonResult<PageResult<PayDemoWithdrawRespVO>> getDemoWithdrawPage(@Valid PageParam pageVO) {
|
||||
PageResult<PayDemoWithdrawDO> pageResult = demoWithdrawService.getDemoWithdrawPage(pageVO);
|
||||
return success(BeanUtils.toBean(pageResult, PayDemoWithdrawRespVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/update-transferred")
|
||||
@Operation(summary = "更新示例提现单的转账状态") // 由 pay-module 转账服务,进行回调
|
||||
@PermitAll // 无需登录,安全由 PayDemoTransferService 内部校验实现
|
||||
public CommonResult<Boolean> updateDemoWithdrawTransferred(@RequestBody PayTransferNotifyReqDTO notifyReqDTO) {
|
||||
demoWithdrawService.updateDemoWithdrawTransferred(Long.valueOf(notifyReqDTO.getMerchantTransferId()),
|
||||
notifyReqDTO.getPayTransferId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.admin.demo.vo.withdraw;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.demo.PayDemoWithdrawTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 示例提现单创建 Request VO")
|
||||
@Data
|
||||
public class PayDemoWithdrawCreateReqVO {
|
||||
|
||||
@Schema(description = "提现标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿是一种菜")
|
||||
@NotEmpty(message = "提现标题不能为空")
|
||||
private String subject;
|
||||
|
||||
@Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@NotNull(message = "提现金额不能为空")
|
||||
@Min(value = 1, message = "提现金额必须大于零")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "收款人账号", requiredMode= Schema.RequiredMode.REQUIRED, example = "test1")
|
||||
@NotBlank(message = "收款人账号不能为空")
|
||||
private String userAccount;
|
||||
|
||||
@Schema(description = "收款人姓名", example = "test1")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "提现方式不能为空")
|
||||
@InEnum(PayDemoWithdrawTypeEnum.class)
|
||||
private Integer type;
|
||||
|
||||
@AssertTrue(message = "收款人姓名")
|
||||
public boolean isUserNameValid() {
|
||||
// 特殊:支付宝必须填写用户名!!!
|
||||
return ObjectUtil.notEqual(type, PayDemoWithdrawTypeEnum.ALIPAY.getType())
|
||||
|| ObjectUtil.isNotEmpty(userName);
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.admin.demo.vo.withdraw;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 示例转账单创建 Request VO")
|
||||
@Data
|
||||
public class PayDemoWithdrawRespVO {
|
||||
|
||||
@Schema(description = "转账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "提现标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "吃饭报销")
|
||||
private String subject;
|
||||
|
||||
@Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22338")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "收款人姓名", example = "test")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "收款人账号", example = "32167")
|
||||
private String userAccount;
|
||||
|
||||
@Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "提现状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer status;
|
||||
|
||||
// ========== 转账相关字段 ==========
|
||||
|
||||
@Schema(description = "转账单编号", example = "23695")
|
||||
private Long payTransferId;
|
||||
|
||||
@Schema(description = "转账渠道", example = "wx_lite")
|
||||
private String transferChannelCode;
|
||||
|
||||
@Schema(description = "转账成功时间")
|
||||
private LocalDateTime transferTime;
|
||||
|
||||
@Schema(description = "转账失败原因", example = "IP 不正确")
|
||||
private String transferErrorMsg;
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.app.transfer;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 APP - 转账单")
|
||||
@RestController
|
||||
@RequestMapping("/pay/transfer")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AppPayTransferController {
|
||||
|
||||
@Resource
|
||||
private PayTransferService transferService;
|
||||
|
||||
@GetMapping("/sync")
|
||||
@Operation(summary = "同步转账单") // 目的:解决微信转账的异步回调可能有延迟的问题
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<Boolean> syncTransfer(@RequestParam("id") Long id) {
|
||||
transferService.syncTransfer(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.dataobject.demo;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
|
||||
import cn.iocoder.yudao.module.pay.enums.demo.PayDemoWithdrawStatusEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.demo.PayDemoWithdrawTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 示例提现订单
|
||||
*
|
||||
* 演示业务系统的转账业务
|
||||
*/
|
||||
@TableName(value ="pay_demo_withdraw", autoResultMap = true)
|
||||
@KeySequence("pay_demo_withdraw_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
public class PayDemoWithdrawDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 提现单编号,自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 提现标题
|
||||
*/
|
||||
private String subject;
|
||||
/**
|
||||
* 提现金额,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
|
||||
/**
|
||||
* 收款人账号
|
||||
*/
|
||||
private String userAccount;
|
||||
/**
|
||||
* 收款人姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 提现方式
|
||||
*
|
||||
* 枚举 {@link PayDemoWithdrawTypeEnum}
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 提现状态
|
||||
*
|
||||
* 枚举 {@link PayDemoWithdrawStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
// ========== 转账相关字段 ==========
|
||||
|
||||
/**
|
||||
* 转账单编号
|
||||
*
|
||||
* 关联 {@link PayTransferDO#getId()}
|
||||
*/
|
||||
private Long payTransferId;
|
||||
/**
|
||||
* 转账渠道
|
||||
*
|
||||
* 枚举 {@link cn.iocoder.yudao.module.pay.enums.PayChannelEnum}
|
||||
*/
|
||||
private String transferChannelCode;
|
||||
/**
|
||||
* 转账成功时间
|
||||
*/
|
||||
private LocalDateTime transferTime;
|
||||
/**
|
||||
* 转账错误提示
|
||||
*/
|
||||
private String transferErrorMsg;
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.mysql.demo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoWithdrawDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PayDemoWithdrawMapper extends BaseMapperX<PayDemoWithdrawDO> {
|
||||
|
||||
default PageResult<PayDemoWithdrawDO> selectPage(PageParam pageParam){
|
||||
return selectPage(pageParam, new LambdaQueryWrapperX<PayDemoWithdrawDO>()
|
||||
.orderByDesc(PayDemoWithdrawDO::getId));
|
||||
}
|
||||
|
||||
default int updateByIdAndStatus(Long id, Integer whereStatus, PayDemoWithdrawDO updateObj) {
|
||||
return update(updateObj, new LambdaQueryWrapperX<PayDemoWithdrawDO>()
|
||||
.eq(PayDemoWithdrawDO::getId, id)
|
||||
.eq(PayDemoWithdrawDO::getStatus, whereStatus));
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.service.demo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.withdraw.PayDemoWithdrawCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoWithdrawDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 示例提现单 Service 接口
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
public interface PayDemoWithdrawService {
|
||||
|
||||
/**
|
||||
* 创建示例提现单
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemoWithdraw(@Valid PayDemoWithdrawCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 提现单转账
|
||||
*
|
||||
* @param id 提现单编号
|
||||
* @return 转账编号
|
||||
*/
|
||||
Long transferDemoWithdraw(Long id);
|
||||
|
||||
/**
|
||||
* 获得示例提现单分页
|
||||
*
|
||||
* @param pageVO 分页查询参数
|
||||
*/
|
||||
PageResult<PayDemoWithdrawDO> getDemoWithdrawPage(PageParam pageVO);
|
||||
|
||||
/**
|
||||
* 更新示例提现单的状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @param payTransferId 转账单编号
|
||||
*/
|
||||
void updateDemoWithdrawTransferred(Long id, Long payTransferId);
|
||||
|
||||
}
|
@ -1,196 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.service.demo;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.pay.api.transfer.PayTransferApi;
|
||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.withdraw.PayDemoWithdrawCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoWithdrawDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.mysql.demo.PayDemoWithdrawMapper;
|
||||
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.demo.PayDemoWithdrawStatusEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.demo.PayDemoWithdrawTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 示例转账业务 Service 实现类
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class PayDemoWithdrawServiceImpl implements PayDemoWithdrawService {
|
||||
|
||||
/**
|
||||
* 接入的支付应用标识
|
||||
*
|
||||
* 从 [支付管理 -> 应用信息] 里添加
|
||||
*/
|
||||
private static final String PAY_APP_KEY = "demo";
|
||||
|
||||
@Resource
|
||||
private PayDemoWithdrawMapper demoTransferMapper;
|
||||
|
||||
@Resource
|
||||
private PayTransferApi payTransferApi;
|
||||
|
||||
@Override
|
||||
public Long createDemoWithdraw(@Valid PayDemoWithdrawCreateReqVO reqVO) {
|
||||
PayDemoWithdrawDO withdraw = BeanUtils.toBean(reqVO, PayDemoWithdrawDO.class)
|
||||
.setTransferChannelCode(getTransferChannelCode(reqVO.getType()))
|
||||
.setStatus(PayDemoWithdrawStatusEnum.WAITING.getStatus());
|
||||
demoTransferMapper.insert(withdraw);
|
||||
return withdraw.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long transferDemoWithdraw(Long id) {
|
||||
// 1.1 校验提现单
|
||||
PayDemoWithdrawDO withdraw = validateDemoWithdrawCanTransfer(id);
|
||||
// 1.2 特殊:如果是转账失败的情况,需要充值下
|
||||
if (PayDemoWithdrawStatusEnum.isClosed(withdraw.getStatus())) {
|
||||
int updateCount = demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(),
|
||||
new PayDemoWithdrawDO().setStatus(PayDemoWithdrawStatusEnum.WAITING.getStatus()).setTransferErrorMsg(""));
|
||||
if (updateCount == 0) {
|
||||
throw exception(DEMO_WITHDRAW_TRANSFER_FAIL_STATUS_NOT_WAITING_OR_CLOSED);
|
||||
}
|
||||
withdraw.setStatus(PayDemoWithdrawStatusEnum.WAITING.getStatus());
|
||||
}
|
||||
|
||||
// 2.1 创建支付单
|
||||
PayTransferCreateReqDTO transferReqDTO = new PayTransferCreateReqDTO()
|
||||
.setAppKey(PAY_APP_KEY).setChannelCode(withdraw.getTransferChannelCode()).setUserIp(getClientIP()) // 支付应用
|
||||
.setMerchantTransferId(String.valueOf(withdraw.getId())) // 业务的订单编号
|
||||
.setSubject(withdraw.getSubject()).setPrice(withdraw.getPrice()) // 价格信息
|
||||
.setUserAccount(withdraw.getUserAccount()).setUserName(withdraw.getUserName()); // 收款信息
|
||||
if (ObjectUtil.equal(withdraw.getType(), PayDemoWithdrawTypeEnum.WECHAT.getType())) {
|
||||
// 注意:微信很特殊!提现需要写明用途!!!
|
||||
transferReqDTO.setChannelExtras(PayTransferCreateReqDTO.buildWeiXinChannelExtra1000(
|
||||
"测试活动", "测试奖励"));
|
||||
}
|
||||
PayTransferCreateRespDTO transferRespDTO = payTransferApi.createTransfer(transferReqDTO);
|
||||
|
||||
// 2.2 更新转账单到 demo 示例提现单,并将状态更新为转账中
|
||||
demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(),
|
||||
new PayDemoWithdrawDO().setPayTransferId(transferRespDTO.getId()));
|
||||
return transferRespDTO.getId();
|
||||
}
|
||||
|
||||
private PayDemoWithdrawDO validateDemoWithdrawCanTransfer(Long id) {
|
||||
// 校验存在
|
||||
PayDemoWithdrawDO withdraw = demoTransferMapper.selectById(id);
|
||||
if (withdraw == null) {
|
||||
throw exception(DEMO_WITHDRAW_NOT_FOUND);
|
||||
}
|
||||
// 校验状态,只有等待中或转账失败的订单,才能发起转账
|
||||
if (!PayDemoWithdrawStatusEnum.isWaiting(withdraw.getStatus())
|
||||
&& !PayDemoWithdrawStatusEnum.isClosed(withdraw.getStatus())) {
|
||||
throw exception(DEMO_WITHDRAW_TRANSFER_FAIL_STATUS_NOT_WAITING_OR_CLOSED);
|
||||
}
|
||||
return withdraw;
|
||||
}
|
||||
|
||||
private String getTransferChannelCode(Integer type) {
|
||||
if (ObjectUtil.equal(type, PayDemoWithdrawTypeEnum.ALIPAY.getType())) {
|
||||
return PayChannelEnum.ALIPAY_PC.getCode();
|
||||
}
|
||||
if (ObjectUtil.equal(type, PayDemoWithdrawTypeEnum.WECHAT.getType())) {
|
||||
return PayChannelEnum.WX_LITE.getCode();
|
||||
}
|
||||
if (ObjectUtil.equal(type, PayDemoWithdrawTypeEnum.WALLET.getType())) {
|
||||
return PayChannelEnum.WALLET.getCode();
|
||||
}
|
||||
throw new IllegalArgumentException("未知提现方式:" + type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PayDemoWithdrawDO> getDemoWithdrawPage(PageParam pageVO) {
|
||||
return demoTransferMapper.selectPage(pageVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDemoWithdrawTransferred(Long id, Long payTransferId) {
|
||||
// 1.1 校验转账单是否存在
|
||||
PayDemoWithdrawDO withdraw = demoTransferMapper.selectById(id);
|
||||
if (withdraw == null) {
|
||||
log.error("[updateDemoWithdrawStatus][withdraw({}) payOrder({}) 不存在提现单,请进行处理!]", id, payTransferId);
|
||||
throw exception(DEMO_WITHDRAW_NOT_FOUND);
|
||||
}
|
||||
// 1.2 校验转账单已成结束(成功或失败)
|
||||
if (PayDemoWithdrawStatusEnum.isSuccess(withdraw.getStatus())
|
||||
|| PayDemoWithdrawStatusEnum.isClosed(withdraw.getStatus())) {
|
||||
// 特殊:转账单编号相同,直接返回,说明重复回调
|
||||
if (ObjectUtil.equal(withdraw.getPayTransferId(), payTransferId)) {
|
||||
log.warn("[updateDemoWithdrawStatus][withdraw({}) 已结束,且转账单编号相同({}),直接返回]", withdraw, payTransferId);
|
||||
return;
|
||||
}
|
||||
// 异常:转账单编号不同,说明转账单编号错误
|
||||
log.error("[updateDemoWithdrawStatus][withdraw({}) 转账单不匹配({}),请进行处理!]", withdraw, payTransferId);
|
||||
throw exception(DEMO_WITHDRAW_UPDATE_STATUS_FAIL_PAY_TRANSFER_ID_ERROR);
|
||||
}
|
||||
|
||||
// 2. 校验提现单的合法性
|
||||
PayTransferRespDTO payTransfer = validateDemoTransferStatusCanUpdate(withdraw, payTransferId);
|
||||
|
||||
// 3. 更新示例订单状态
|
||||
Integer newStatus = PayTransferStatusEnum.isSuccess(payTransfer.getStatus()) ? PayDemoWithdrawStatusEnum.SUCCESS.getStatus() :
|
||||
PayTransferStatusEnum.isClosed(payTransfer.getStatus()) ? PayDemoWithdrawStatusEnum.CLOSED.getStatus() : null;
|
||||
Assert.notNull(newStatus, "转账单状态({}) 不合法", payTransfer.getStatus());
|
||||
demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(),
|
||||
new PayDemoWithdrawDO().setStatus(newStatus).setTransferTime(payTransfer.getSuccessTime())
|
||||
.setTransferErrorMsg(payTransfer.getChannelErrorMsg()));
|
||||
}
|
||||
|
||||
private PayTransferRespDTO validateDemoTransferStatusCanUpdate(PayDemoWithdrawDO withdraw, Long payTransferId) {
|
||||
// 1. 校验转账单是否存在
|
||||
PayTransferRespDTO payTransfer = payTransferApi.getTransfer(payTransferId);
|
||||
if (payTransfer == null) {
|
||||
log.error("[validateDemoTransferStatusCanUpdate][withdraw({}) payTransfer({}) 不存在,请进行处理!]", withdraw.getId(), payTransferId);
|
||||
throw exception(PAY_TRANSFER_NOT_FOUND);
|
||||
}
|
||||
|
||||
// 2.1 校验转账单已成功
|
||||
if (!PayTransferStatusEnum.isSuccessOrClosed(payTransfer.getStatus())) {
|
||||
log.error("[validateDemoTransferStatusCanUpdate][withdraw({}) payTransfer({}) 未结束,请进行处理!payTransfer 数据是:{}]",
|
||||
withdraw.getId(), payTransferId, JsonUtils.toJsonString(payTransfer));
|
||||
throw exception(DEMO_WITHDRAW_UPDATE_STATUS_FAIL_PAY_TRANSFER_STATUS_NOT_SUCCESS_OR_CLOSED);
|
||||
}
|
||||
// 2.2 校验转账金额一致
|
||||
if (ObjectUtil.notEqual(payTransfer.getPrice(), withdraw.getPrice())) {
|
||||
log.error("[validateDemoTransferStatusCanUpdate][withdraw({}) payTransfer({}) 转账金额不匹配,请进行处理!withdraw 数据是:{},payTransfer 数据是:{}]",
|
||||
withdraw.getId(), payTransferId, JsonUtils.toJsonString(withdraw), JsonUtils.toJsonString(payTransfer));
|
||||
throw exception(DEMO_WITHDRAW_UPDATE_STATUS_FAIL_PAY_PRICE_NOT_MATCH);
|
||||
}
|
||||
// 2.3 校验转账订单匹配(二次)
|
||||
if (ObjectUtil.notEqual(payTransfer.getMerchantTransferId(), withdraw.getId().toString())) {
|
||||
log.error("[validateDemoTransferStatusCanUpdate][withdraw({}) 转账单不匹配({}),请进行处理!payTransfer 数据是:{}]",
|
||||
withdraw.getId(), payTransferId, JsonUtils.toJsonString(payTransfer));
|
||||
throw exception(DEMO_WITHDRAW_UPDATE_STATUS_FAIL_PAY_MERCHANT_EXISTS);
|
||||
}
|
||||
// 2.4 校验转账渠道一致
|
||||
if (ObjectUtil.notEqual(payTransfer.getChannelCode(), withdraw.getTransferChannelCode())) {
|
||||
log.error("[validateDemoTransferStatusCanUpdate][withdraw({}) payTransfer({}) 转账渠道不匹配,请进行处理!withdraw 数据是:{},payTransfer 数据是:{}]",
|
||||
withdraw.getId(), payTransferId, JsonUtils.toJsonString(withdraw), JsonUtils.toJsonString(payTransfer));
|
||||
throw exception(DEMO_WITHDRAW_UPDATE_STATUS_FAIL_PAY_CHANNEL_NOT_MATCH);
|
||||
}
|
||||
return payTransfer;
|
||||
}
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package cn.iocoder.yudao.module.report.framework.jmreport.core.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jeecg.modules.drag.service.IOnlDragExternalService;
|
||||
import org.jeecg.modules.drag.vo.DragDictModel;
|
||||
import org.jeecg.modules.drag.vo.DragLogDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* {@link IOnlDragExternalService} 实现类,提供积木仪表盘的查询等功能
|
||||
*
|
||||
* 实现可参考:
|
||||
* 1. <a href="https://github.com/jeecgboot/jimureport/blob/master/jimureport-example/src/main/java/com/jeecg/modules/jmreport/extend/JimuDragExternalServiceImpl.java">jimureport-example</a>
|
||||
* 2. <a href="https://gitee.com/jeecg/JeecgBoot/blob/master/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/config/jimureport/JimuDragExternalServiceImpl.java">JeecgBoot 集成</a>
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class JmOnlDragExternalServiceImpl implements IOnlDragExternalService {
|
||||
|
||||
// ========== DictItem 相关 ==========
|
||||
|
||||
@Override
|
||||
public Map<String, List<DragDictModel>> getManyDictItems(List<String> codeList, List<JSONObject> tableDictList) {
|
||||
return IOnlDragExternalService.super.getManyDictItems(codeList, tableDictList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DragDictModel> getDictItems(String dictCode) {
|
||||
return IOnlDragExternalService.super.getDictItems(dictCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DragDictModel> getTableDictItems(String dictTable, String dictText, String dictCode) {
|
||||
return IOnlDragExternalService.super.getTableDictItems(dictTable, dictText, dictCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DragDictModel> getCategoryTreeDictItems(List<String> ids) {
|
||||
return IOnlDragExternalService.super.getCategoryTreeDictItems(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DragDictModel> getUserDictItems(List<String> ids) {
|
||||
return IOnlDragExternalService.super.getUserDictItems(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DragDictModel> getDeptsDictItems(List<String> ids) {
|
||||
return IOnlDragExternalService.super.getDeptsDictItems(ids);
|
||||
}
|
||||
|
||||
// ========== Log 相关 ==========
|
||||
|
||||
@Override
|
||||
public void addLog(DragLogDTO dto) {
|
||||
IOnlDragExternalService.super.addLog(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLog(String logMsg, int logType, int operateType) {
|
||||
IOnlDragExternalService.super.addLog(logMsg, logType, operateType);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user