From 50e47434bbdd0419e8c8113673a2b148e7ce03ef Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 25 Nov 2024 20:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=90=8C=E6=AD=A5=E3=80=91BOOT=20?= =?UTF-8?q?=E5=92=8C=20CLOUD=20=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=88?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=9B=B8=E5=85=B3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProductBrowseHistoryController.java | 3 +- .../vo/ProductBrowseHistoryRespVO.java | 9 +- .../AppProductBrowseHistoryController.java | 3 +- .../vo/AppProductBrowseHistoryRespVO.java | 12 +- .../kefu/KeFuConversationController.java | 20 +++ .../admin/kefu/KeFuMessageController.java | 19 ++- .../kefu/vo/message/KeFuMessageListReqVO.java | 34 +++++ .../kefu/vo/message/KeFuMessagePageReqVO.java | 16 -- .../vo/activity/PointActivityPageReqVO.java | 18 --- .../app/kefu/AppKeFuMessageController.java | 28 +++- .../vo/message/AppKeFuMessagePageReqVO.java | 27 +++- .../app/point/vo/AppPointActivityRespVO.java | 16 -- .../CombinationActivityConvert.java | 5 +- .../dal/mysql/kefu/KeFuMessageMapper.java | 30 ++-- .../dal/mysql/point/PointActivityMapper.java | 6 +- .../CombinationRecordServiceImpl.java | 2 +- .../service/kefu/KeFuConversationService.java | 8 + .../kefu/KeFuConversationServiceImpl.java | 5 + .../service/kefu/KeFuMessageService.java | 9 +- .../service/kefu/KeFuMessageServiceImpl.java | 19 ++- .../trade/enums/ErrorCodeConstants.java | 2 + .../trade/enums/MessageTemplateConstants.java | 3 - .../brokerage/BrokerageWithdrawTypeEnum.java | 13 +- .../admin/base/system/package-info.java | 4 + .../base/system/user/UserSimpleBaseVO.java | 19 +++ .../brokerage/BrokerageRecordController.java | 2 +- .../BrokerageWithdrawController.java | 26 +++- .../vo/record/BrokerageRecordBaseVO.java | 4 +- .../vo/record/BrokerageRecordRespVO.java | 2 +- .../vo/user/BrokerageUserBaseVO.java | 2 +- .../BrokerageUserClearBrokerageUserReqVO.java | 3 +- ...kerageUserUpdateBrokerageEnabledReqVO.java | 3 +- ...BrokerageUserUpdateBrokerageUserReqVO.java | 3 +- .../vo/withdraw/BrokerageWithdrawBaseVO.java | 2 +- .../BrokerageWithdrawRejectReqVO.java | 7 +- .../vo/withdraw/BrokerageWithdrawRespVO.java | 2 +- .../DeliveryPickUpStoreController.java | 30 +++- .../vo/pickup/DeliveryPickUpBindReqVO.java | 24 +++ .../vo/pickup/DeliveryPickUpStoreBaseVO.java | 4 +- .../DeliveryPickUpStoreCreateReqVO.java | 6 +- .../pickup/DeliveryPickUpStorePageReqVO.java | 10 +- .../vo/pickup/DeliveryPickUpStoreRespVO.java | 5 + .../DeliveryPickUpStoreSimpleRespVO.java | 5 + .../DeliveryPickUpStoreUpdateReqVO.java | 3 +- .../admin/order/TradeOrderController.java | 8 +- .../delivery/DeliveryPickUpStoreConvert.java | 5 +- .../delivery/DeliveryPickUpStoreDO.java | 16 +- .../delivery/DeliveryPickUpStoreStaffDO.java | 49 ------ .../brokerage/BrokerageWithdrawMapper.java | 2 +- .../DeliveryPickUpStoreStaffMapper.java | 14 -- .../brokerage/BrokerageRecordService.java | 2 +- .../brokerage/BrokerageRecordServiceImpl.java | 2 +- .../brokerage/BrokerageWithdrawService.java | 15 +- .../BrokerageWithdrawServiceImpl.java | 144 +++++++++++++----- .../delivery/DeliveryPickUpStoreService.java | 19 ++- .../DeliveryPickUpStoreServiceImpl.java | 27 +++- .../order/TradeOrderUpdateService.java | 6 +- .../order/TradeOrderUpdateServiceImpl.java | 20 ++- .../pay/api/transfer/PayTransferApi.java | 9 ++ .../api/transfer/dto/PayTransferRespDTO.java | 31 ++++ .../module/pay/api/wallet/PayWalletApi.java | 23 +++ .../wallet/dto/PayWalletAddBalanceReqDTO.java | 49 ++++++ .../enums/wallet/PayWalletBizTypeEnum.java | 8 +- .../pay/api/transfer/PayTransferApiImpl.java | 9 ++ .../pay/api/wallet/PayWalletApiImpl.java | 39 +++++ .../controller/admin/app/vo/PayAppBaseVO.java | 17 ++- .../admin/notify/PayNotifyController.java | 38 ++++- .../convert/transfer/PayTransferConvert.java | 3 +- .../dal/mysql/transfer/PayTransferMapper.java | 12 +- .../pay/dal/mysql/wallet/PayWalletMapper.java | 14 +- .../framework/pay/config/PayProperties.java | 9 ++ .../framework/pay/core/WalletPayClient.java | 5 + .../service/transfer/PayTransferService.java | 10 ++ .../transfer/PayTransferServiceImpl.java | 30 ++-- .../service/wallet/PayWalletServiceImpl.java | 10 +- .../src/main/resources/application-dev.yaml | 1 + .../src/main/resources/application-local.yaml | 3 +- .../pay/config/YudaoPayAutoConfiguration.java | 1 + .../framework/pay/core/client/PayClient.java | 12 ++ .../pay/core/client/PayClientConfig.java | 1 + .../dto/order/PayOrderUnifiedReqDTO.java | 6 +- .../dto/refund/PayRefundUnifiedReqDTO.java | 7 +- .../transfer/PayTransferUnifiedReqDTO.java | 17 ++- .../WxPayTransferPartnerNotifyV3Result.java | 129 ++++++++++++++++ .../core/client/impl/AbstractPayClient.java | 16 ++ .../core/client/impl/NonePayClientConfig.java | 3 +- .../impl/alipay/AbstractAlipayPayClient.java | 6 + .../impl/alipay/AlipayAppPayClient.java | 2 + .../impl/alipay/AlipayBarPayClient.java | 2 + .../client/impl/alipay/AlipayPcPayClient.java | 2 + .../core/client/impl/mock/MockPayClient.java | 5 + .../impl/weixin/AbstractWxPayClient.java | 83 +++++++++- .../core/enums/channel/PayChannelEnum.java | 2 +- .../bean/transfer/TransferBatchesRequest.java | 118 ++++++++++++++ ...ot.autoconfigure.AutoConfiguration.imports | 2 +- .../admin/user/vo/user/UserPageReqVO.java | 3 + .../dal/mysql/user/AdminUserMapper.java | 3 +- .../service/user/AdminUserServiceImpl.java | 12 +- 98 files changed, 1209 insertions(+), 345 deletions(-) create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessageListReqVO.java delete mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessagePageReqVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/package-info.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/user/UserSimpleBaseVO.java create mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindReqVO.java delete mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java delete mode 100644 yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java create mode 100644 yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferRespDTO.java create mode 100644 yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java create mode 100644 yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletAddBalanceReqDTO.java create mode 100644 yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java create mode 100644 yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/WxPayTransferPartnerNotifyV3Result.java create mode 100644 yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesRequest.java diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java index 0b9e6a13b..38c888bd3 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java @@ -51,7 +51,8 @@ public class ProductBrowseHistoryController { convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId)); return success(BeanUtils.toBean(pageResult, ProductBrowseHistoryRespVO.class, vo -> Optional.ofNullable(spuMap.get(vo.getSpuId())) - .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice())))); + .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice()) + .setSalesCount(spu.getSalesCount()).setStock(spu.getStock())))); } } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java index 012f1602c..30ca93bd7 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java @@ -1,12 +1,9 @@ package cn.iocoder.yudao.module.product.controller.admin.history.vo; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.time.LocalDateTime; - import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; @Schema(description = "管理后台 - 商品浏览记录 Response VO") @@ -31,4 +28,10 @@ public class ProductBrowseHistoryRespVO { @Schema(description = "商品单价", example = "100") private Integer price; + @Schema(description = "商品销量", example = "100") + private Integer salesCount; + + @Schema(description = "库存", example = "100") + private Integer stock; + } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java index 46dfacf2c..89c435cbf 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java @@ -67,7 +67,8 @@ public class AppProductBrowseHistoryController { Map spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId); return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class, vo -> Optional.ofNullable(spuMap.get(vo.getSpuId())) - .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice())))); + .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice()) + .setSalesCount(spu.getSalesCount()).setStock(spu.getStock())))); } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java index 05b528cdb..d7b44f05c 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java @@ -17,13 +17,19 @@ public class AppProductBrowseHistoryRespVO { // ========== 商品相关字段 ========== - @Schema(description = "商品 SPU 名称", example = "赵六") + @Schema(description = "商品 SPU 名称", requiredMode = REQUIRED, example = "赵六") private String spuName; - @Schema(description = "商品封面图", example = "https://domain/pic.png") + @Schema(description = "商品封面图", requiredMode = REQUIRED, example = "https://www.iocoder.cn/pic.png") private String picUrl; - @Schema(description = "商品单价", example = "100") + @Schema(description = "商品单价", requiredMode = REQUIRED, example = "50") private Integer price; + @Schema(description = "商品销量", requiredMode = REQUIRED, example = "60") + private Integer salesCount; + + @Schema(description = "库存", requiredMode = REQUIRED, example = "80") + private Integer stock; + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java index 8d286a36a..dbf24d4f4 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.conversation.KeFuConversationRespVO; import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.conversation.KeFuConversationUpdatePinnedReqVO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuConversationDO; import cn.iocoder.yudao.module.promotion.service.kefu.KeFuConversationService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -34,6 +35,25 @@ public class KeFuConversationController { @Resource private MemberUserApi memberUserApi; + @GetMapping("/get") + @Operation(summary = "获得客服会话") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('promotion:kefu-conversation:query')") + public CommonResult getConversation(@RequestParam("id") Long id) { + KeFuConversationDO conversation = conversationService.getConversation(id); + if (conversation == null) { + return success(null); + } + + // 拼接数据 + KeFuConversationRespVO result = BeanUtils.toBean(conversation, KeFuConversationRespVO.class); + MemberUserRespDTO memberUser = memberUserApi.getUser(conversation.getUserId()).getCheckedData(); + if (memberUser != null) { + result.setUserAvatar(memberUser.getAvatar()).setUserNickname(memberUser.getNickname()); + } + return success(result); + } + @PutMapping("/update-conversation-pinned") @Operation(summary = "置顶/取消置顶客服会话") @PreAuthorize("@ss.hasPermission('promotion:kefu-conversation:update')") diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java index 72ca7b066..1e7acf5d8 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java @@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.promotion.controller.admin.kefu; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageRespVO; import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; @@ -20,6 +19,7 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -56,19 +56,18 @@ public class KeFuMessageController { return success(true); } - @GetMapping("/page") - @Operation(summary = "获得客服消息分页") + @GetMapping("/list") + @Operation(summary = "获得客服消息列表") @PreAuthorize("@ss.hasPermission('promotion:kefu-message:query')") - public CommonResult> getKeFuMessagePage(@Valid KeFuMessagePageReqVO pageReqVO) { + public CommonResult> getKeFuMessageList(@Valid KeFuMessageListReqVO pageReqVO) { // 获得数据 - PageResult pageResult = messageService.getKeFuMessagePage(pageReqVO); + List list = messageService.getKeFuMessageList(pageReqVO); // 拼接数据 - PageResult result = BeanUtils.toBean(pageResult, KeFuMessageRespVO.class); - Map userMap = adminUserApi.getUserMap(convertSet(filterList(result.getList(), + List result = BeanUtils.toBean(list, KeFuMessageRespVO.class); + Map userMap = adminUserApi.getUserMap(convertSet(filterList(result, item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId)); - result.getList().forEach(item-> findAndThen(userMap, item.getSenderId(), - user -> item.setSenderAvatar(user.getAvatar()))); + result.forEach(item -> findAndThen(userMap, item.getSenderId(), user -> item.setSenderAvatar(user.getAvatar()))); return success(result); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessageListReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessageListReqVO.java new file mode 100644 index 000000000..25b8f499c --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessageListReqVO.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 客服消息列表 Request VO") +@Data +public class KeFuMessageListReqVO { + + private static final Integer LIMIT = 10; + + @Schema(description = "会话编号", example = "12580") + @NotNull(message = "会话编号不能为空") + private Long conversationId; + + @Schema(description = "发送时间", example = "2024-03-27 12:00:00") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime createTime; + + @Schema(description = "每次查询条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") + @NotNull(message = "每次查询条数不能为空") + @Min(value = 1, message = "每次查询条数最小值为 1") + @Max(value = 100, message = "每次查询最大值为 100") + private Integer limit = LIMIT; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessagePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessagePageReqVO.java deleted file mode 100644 index 60b918520..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessagePageReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 客服消息分页 Request VO") -@Data -@ToString(callSuper = true) -public class KeFuMessagePageReqVO extends PageParam { - - @Schema(description = "会话编号", example = "12580") - private Long conversationId; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/activity/PointActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/activity/PointActivityPageReqVO.java index 89786c2de..c20404154 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/activity/PointActivityPageReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/activity/PointActivityPageReqVO.java @@ -5,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @Schema(description = "管理后台 - 积分商城活动分页 Request VO") @Data @@ -17,20 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class PointActivityPageReqVO extends PageParam { - @Schema(description = "积分商城活动商品", example = "19509") - private Long spuId; - @Schema(description = "活动状态", example = "2") private Integer status; - @Schema(description = "备注", example = "你说的对") - private String remark; - - @Schema(description = "排序") - private Integer sort; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java index 852a583f7..5c592f6f3 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java @@ -2,13 +2,14 @@ package cn.iocoder.yudao.module.promotion.controller.app.kefu; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageRespVO; import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO; import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; import cn.iocoder.yudao.module.promotion.service.kefu.KeFuMessageService; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -17,7 +18,13 @@ import jakarta.validation.Valid; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.List; +import java.util.Map; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Tag(name = "用户 APP - 客服消息") @@ -29,6 +36,9 @@ public class AppKeFuMessageController { @Resource private KeFuMessageService kefuMessageService; + @Resource + private AdminUserApi adminUserApi; + @PostMapping("/send") @Operation(summary = "发送客服消息") public CommonResult sendKefuMessage(@Valid @RequestBody AppKeFuMessageSendReqVO sendReqVO) { @@ -44,11 +54,17 @@ public class AppKeFuMessageController { return success(true); } - @GetMapping("/page") - @Operation(summary = "获得客服消息分页") - public CommonResult> getKefuMessagePage(@Valid AppKeFuMessagePageReqVO pageReqVO) { - PageResult pageResult = kefuMessageService.getKeFuMessagePage(pageReqVO, getLoginUserId()); - return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class)); + @GetMapping("/list") + @Operation(summary = "获得客服消息列表") + public CommonResult> getKefuMessageList(@Valid AppKeFuMessagePageReqVO pageReqVO) { + List list = kefuMessageService.getKeFuMessageList(pageReqVO, getLoginUserId()); + + // 拼接数据 + List result = BeanUtils.toBean(list, KeFuMessageRespVO.class); + Map userMap = adminUserApi.getUserMap(convertSet(filterList(result, + item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId)); + result.forEach(item -> findAndThen(userMap, item.getSenderId(), user -> item.setSenderAvatar(user.getAvatar()))); + return success(result); } } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessagePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessagePageReqVO.java index 72efbdd62..78b105aea 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessagePageReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessagePageReqVO.java @@ -1,16 +1,33 @@ package cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message; -import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; import lombok.Data; -import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; -@Schema(description = "用户 App - 客服消息分页 Request VO") +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "用户 App - 客服消息 Request VO") @Data -@ToString(callSuper = true) -public class AppKeFuMessagePageReqVO extends PageParam { +public class AppKeFuMessagePageReqVO { + + private static final Integer LIMIT = 10; @Schema(description = "会话编号", example = "12580") private Long conversationId; + @Schema(description = "发送时间", example = "2024-03-27 12:00:00") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime createTime; + + @Schema(description = "每次查询条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") + @NotNull(message = "每次查询条数不能为空") + @Min(value = 1, message = "每次查询条数最小值为 1") + @Max(value = 100, message = "每次查询最大值为 100") + private Integer limit = LIMIT; + } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/vo/AppPointActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/vo/AppPointActivityRespVO.java index 29f4f97c1..ddcc23b9c 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/vo/AppPointActivityRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/vo/AppPointActivityRespVO.java @@ -4,8 +4,6 @@ import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.time.LocalDateTime; - @Schema(description = "用户 App - 积分商城活动 Response VO") @Data public class AppPointActivityRespVO { @@ -30,20 +28,6 @@ public class AppPointActivityRespVO { @ExcelProperty("积分商城活动总库存") private Integer totalStock; - // TODO @puhui999:只返回必要的字段,例如说 remark、sort、createTime 应该是不需要的呢。也可以看看别的也不需要哈。 - - @Schema(description = "备注", example = "你说的对") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("排序") - private Integer sort; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - // ========== 商品字段 ========== @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java index 8f8088060..9ea776232 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java @@ -217,8 +217,7 @@ public interface CombinationActivityConvert { List createRecords = new ArrayList<>(count); for (int i = 0; i < count; i++) { // 基础信息和团长保持一致 - CombinationRecordDO newRecord = BeanUtils.toBean(headRecord, CombinationRecordDO.class) - .setId(null).setHeadId(headRecord.getHeadId()); + CombinationRecordDO newRecord = convert5(headRecord).setHeadId(headRecord.getId()); // 虚拟信息 newRecord.setCount(0) // 会单独更新下,在后续的 Service 逻辑里 .setUserId(0L).setNickname("").setAvatar("").setOrderId(0L); @@ -226,5 +225,7 @@ public interface CombinationActivityConvert { } return createRecords; } + @Mapping(target = "id", ignore = true) + CombinationRecordDO convert5(CombinationRecordDO headRecord); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuMessageMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuMessageMapper.java index f565fd7f0..a7753b395 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuMessageMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuMessageMapper.java @@ -1,10 +1,8 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.kefu; -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.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO; +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; +import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -21,10 +19,20 @@ import java.util.List; @Mapper public interface KeFuMessageMapper extends BaseMapperX { - default PageResult selectPage(KeFuMessagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(KeFuMessageDO::getConversationId, reqVO.getConversationId()) - .orderByDesc(KeFuMessageDO::getCreateTime)); + /** + * 获得消息列表 + * 1. 第一次查询时,不带时间,默认查询最新的十条消息 + * 2. 第二次查询时,带时间,查询历史消息 + * + * @param reqVO 列表请求 + * @return 消息列表 + */ + default List selectList(KeFuMessageListReqVO reqVO) { + return selectList(new QueryWrapperX() + .eqIfPresent("conversation_id", reqVO.getConversationId()) + .ltIfPresent("create_time", reqVO.getCreateTime()) + .orderByDesc("create_time") + .limitN(reqVO.getLimit())); } default List selectListByConversationIdAndUserTypeAndReadStatus(Long conversationId, Integer userType, @@ -40,10 +48,4 @@ public interface KeFuMessageMapper extends BaseMapperX { .in(KeFuMessageDO::getId, ids)); } - default PageResult selectPage(AppKeFuMessagePageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eqIfPresent(KeFuMessageDO::getConversationId, pageReqVO.getConversationId()) - .orderByDesc(KeFuMessageDO::getCreateTime)); - } - } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/point/PointActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/point/PointActivityMapper.java index d724c32ee..e8ce53134 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/point/PointActivityMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/point/PointActivityMapper.java @@ -19,12 +19,8 @@ public interface PointActivityMapper extends BaseMapperX { default PageResult selectPage(PointActivityPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PointActivityDO::getSpuId, reqVO.getSpuId()) .eqIfPresent(PointActivityDO::getStatus, reqVO.getStatus()) - .eqIfPresent(PointActivityDO::getRemark, reqVO.getRemark()) - .eqIfPresent(PointActivityDO::getSort, reqVO.getSort()) - .betweenIfPresent(PointActivityDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PointActivityDO::getId)); + .orderByDesc(PointActivityDO::getSort)); } /** diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java index 08212a78a..dc49d7859 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java @@ -375,7 +375,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { CombinationRecordDO updateRecord = new CombinationRecordDO().setId(item.getId()) .setStatus(status.getStatus()).setEndTime(now); if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 - updateRecord.setUserCount(updateRecord.getUserSize()); + updateRecord.setUserCount(records.size()); } updateRecords.add(updateRecord); }); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationService.java index 2da8d0bc6..d993a2f66 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationService.java @@ -13,6 +13,14 @@ import java.util.List; */ public interface KeFuConversationService { + /** + * 获得客服会话 + * + * @param id 编号 + * @return 客服会话 + */ + KeFuConversationDO getConversation(Long id); + /** * 【管理员】删除客服会话 * diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java index 48aff5b03..a123bb8d0 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java @@ -30,6 +30,11 @@ public class KeFuConversationServiceImpl implements KeFuConversationService { @Resource private KeFuConversationMapper conversationMapper; + @Override + public KeFuConversationDO getConversation(Long id) { + return conversationMapper.selectById(id); + } + @Override public void deleteKefuConversation(Long id) { // 校验存在 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageService.java index 8af4f128e..46e29e747 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageService.java @@ -1,13 +1,14 @@ package cn.iocoder.yudao.module.promotion.service.kefu; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO; import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO; import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; import jakarta.validation.Valid; +import java.util.List; + /** * 客服消息 Service 接口 * @@ -46,7 +47,7 @@ public interface KeFuMessageService { * @param pageReqVO 分页查询 * @return 客服消息分页 */ - PageResult getKeFuMessagePage(KeFuMessagePageReqVO pageReqVO); + List getKeFuMessageList(KeFuMessageListReqVO pageReqVO); /** * 【会员】获得客服消息分页 @@ -55,6 +56,6 @@ public interface KeFuMessageService { * @param userId 用户编号 * @return 客服消息分页 */ - PageResult getKeFuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId); + List getKeFuMessageList(AppKeFuMessagePageReqVO pageReqVO, Long userId); } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java index b47cd9004..5a118856d 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java @@ -2,14 +2,12 @@ package cn.iocoder.yudao.module.promotion.service.kefu; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO; import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO; import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO; @@ -23,6 +21,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; +import java.util.Collections; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -113,9 +112,9 @@ public class KeFuMessageServiceImpl implements KeFuMessageService { // 2.3 发送消息通知会员,管理员已读 -> 会员更新发送的消息状态 KeFuMessageDO keFuMessage = getFirst(filterList(messageList, message -> UserTypeEnum.MEMBER.getValue().equals(message.getSenderType()))); assert keFuMessage != null; // 断言避免警告 - getSelf().sendAsyncMessageToMember(keFuMessage.getSenderId(), KEFU_MESSAGE_ADMIN_READ, StrUtil.EMPTY); + getSelf().sendAsyncMessageToMember(keFuMessage.getSenderId(), KEFU_MESSAGE_ADMIN_READ, conversation.getId()); // 2.4 通知所有管理员消息已读 - getSelf().sendAsyncMessageToAdmin(KEFU_MESSAGE_ADMIN_READ, StrUtil.EMPTY); + getSelf().sendAsyncMessageToAdmin(KEFU_MESSAGE_ADMIN_READ, conversation.getId()); } private void validateReceiverExist(Long receiverId, Integer receiverType) { @@ -138,20 +137,20 @@ public class KeFuMessageServiceImpl implements KeFuMessageService { } @Override - public PageResult getKeFuMessagePage(KeFuMessagePageReqVO pageReqVO) { - return keFuMessageMapper.selectPage(pageReqVO); + public List getKeFuMessageList(KeFuMessageListReqVO pageReqVO) { + return keFuMessageMapper.selectList(pageReqVO); } @Override - public PageResult getKeFuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId) { + public List getKeFuMessageList(AppKeFuMessagePageReqVO pageReqVO, Long userId) { // 1. 获得客服会话 KeFuConversationDO conversation = conversationService.getConversationByUserId(userId); if (conversation == null) { - return PageResult.empty(); + return Collections.emptyList(); } // 2. 设置会话编号 pageReqVO.setConversationId(conversation.getId()); - return keFuMessageMapper.selectPage(pageReqVO); + return keFuMessageMapper.selectList(BeanUtils.toBean(pageReqVO, KeFuMessageListReqVO.class)); } private KeFuMessageServiceImpl getSelf() { diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java index be0ef51ae..936ece33d 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java @@ -36,6 +36,7 @@ public interface ErrorCodeConstants { ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单不是【待发货】状态"); ErrorCode ORDER_CREATE_FAIL_EXIST_UNPAID = new ErrorCode(1_011_000_032, "交易订单创建失败,原因:存在未付款订单"); ErrorCode ORDER_CANCEL_PAID_FAIL = new ErrorCode(1_011_000_033, "交易订单取消支付失败,原因:订单不是【{}】状态"); + ErrorCode ORDER_PICK_UP_FAIL_NOT_VERIFY_USER = new ErrorCode(1_011_000_034, "交易订单自提失败,原因:你没有核销该门店订单的权限"); // ========== After Sale 模块 1-011-000-100 ========== ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在"); @@ -80,6 +81,7 @@ public interface ErrorCodeConstants { // ========== 物流 PICK_UP 模块 1-011-006-000 ========== ErrorCode PICK_UP_STORE_NOT_EXISTS = new ErrorCode(1_011_006_000, "自提门店不存在"); + ErrorCode PICK_UP_STORE_STAFF_NOT_EXISTS = new ErrorCode(1_011_006_000, "自提门店店员不存在"); // ========== 分销用户 模块 1-011-007-000 ========== ErrorCode BROKERAGE_USER_NOT_EXISTS = new ErrorCode(1_011_007_000, "分销用户不存在"); diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java index 56c4c9005..b0752ec55 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java @@ -11,9 +11,6 @@ public interface MessageTemplateConstants { String SMS_ORDER_DELIVERY = "order_delivery"; // 短信模版编号 - String SMS_BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过) - String SMS_BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过) - // ======================= 小程序订阅消息模版 ======================= String WXA_ORDER_DELIVERY = "订单发货通知"; diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java index 46edf010e..cf063516c 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java @@ -17,8 +17,9 @@ public enum BrokerageWithdrawTypeEnum implements IntArrayValuable { WALLET(1, "钱包"), BANK(2, "银行卡"), - WECHAT(3, "微信"), + WECHAT(3, "微信"), // 手动打款 ALIPAY(4, "支付宝"), + WECHAT_API(5, "微信零钱"), // 自动打款,通过微信转账 API ; public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawTypeEnum::getType).toArray(); @@ -37,4 +38,14 @@ public enum BrokerageWithdrawTypeEnum implements IntArrayValuable { return ARRAYS; } + /** + * 是否通过支付平台的 API 打款 + * + * @param type 类型 + * @return 是否 + */ + public static boolean isApi(Integer type) { + return WECHAT_API.getType().equals(type); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/package-info.java new file mode 100644 index 000000000..f1451de5f --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位符,可忽略 + */ +package cn.iocoder.yudao.module.trade.controller.admin.base.system; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/user/UserSimpleBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/user/UserSimpleBaseVO.java new file mode 100644 index 000000000..39fcd66c9 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/system/user/UserSimpleBaseVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.trade.controller.admin.base.system.user; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "用户精简信息 VO") +@Data +public class UserSimpleBaseVO { + + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long id; + + @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + private String nickname; + + @Schema(description = "用户头像", example = "https://www.iocoder.cn/1.png") + private String avatar; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java index bcf46d1df..cbb8a6b22 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java @@ -44,7 +44,7 @@ public class BrokerageRecordController { @Operation(summary = "获得佣金记录") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')") - public CommonResult getBrokerageRecord(@RequestParam("id") Integer id) { + public CommonResult getBrokerageRecord(@RequestParam("id") Long id) { BrokerageRecordDO brokerageRecord = brokerageRecordService.getBrokerageRecord(id); return success(BrokerageRecordConvert.INSTANCE.convert(brokerageRecord)); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java index bb35c0d7f..c8d34ecbd 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.pay.api.notify.dto.PayTransferNotifyReqDTO; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRejectReqVO; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; @@ -14,6 +15,8 @@ import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; 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.security.PermitAll; +import lombok.extern.slf4j.Slf4j; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -24,11 +27,13 @@ import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; @Tag(name = "管理后台 - 佣金提现") @RestController @RequestMapping("/trade/brokerage-withdraw") @Validated +@Slf4j public class BrokerageWithdrawController { @Resource @@ -40,8 +45,9 @@ public class BrokerageWithdrawController { @PutMapping("/approve") @Operation(summary = "通过申请") @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") - public CommonResult approveBrokerageWithdraw(@RequestParam("id") Integer id) { - brokerageWithdrawService.auditBrokerageWithdraw(id, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, ""); + public CommonResult approveBrokerageWithdraw(@RequestParam("id") Long id) { + brokerageWithdrawService.auditBrokerageWithdraw(id, + BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, "", getClientIP()); return success(true); } @@ -49,7 +55,8 @@ public class BrokerageWithdrawController { @Operation(summary = "驳回申请") @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") public CommonResult rejectBrokerageWithdraw(@Valid @RequestBody BrokerageWithdrawRejectReqVO reqVO) { - brokerageWithdrawService.auditBrokerageWithdraw(reqVO.getId(), BrokerageWithdrawStatusEnum.AUDIT_FAIL, reqVO.getAuditReason()); + brokerageWithdrawService.auditBrokerageWithdraw(reqVO.getId(), + BrokerageWithdrawStatusEnum.AUDIT_FAIL, reqVO.getAuditReason(), getClientIP()); return success(true); } @@ -57,7 +64,7 @@ public class BrokerageWithdrawController { @Operation(summary = "获得佣金提现") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") - public CommonResult getBrokerageWithdraw(@RequestParam("id") Integer id) { + public CommonResult getBrokerageWithdraw(@RequestParam("id") Long id) { BrokerageWithdrawDO brokerageWithdraw = brokerageWithdrawService.getBrokerageWithdraw(id); return success(BrokerageWithdrawConvert.INSTANCE.convert(brokerageWithdraw)); } @@ -75,4 +82,15 @@ public class BrokerageWithdrawController { return success(BrokerageWithdrawConvert.INSTANCE.convertPage(pageResult, userMap)); } + // TODO @luchi:update-transferred,url 改成这个。和 update-paid 、update-refunded 保持一致 + @PostMapping("/update-transfer") + @Operation(summary = "更新转账订单为转账成功") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob + @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 + public CommonResult updateBrokerageWithdrawTransferred(@RequestBody PayTransferNotifyReqDTO notifyReqDTO) { + log.info("[updateAfterRefund][notifyReqDTO({})]", notifyReqDTO); + brokerageWithdrawService.updateBrokerageWithdrawTransferred( + Long.parseLong(notifyReqDTO.getMerchantTransferId()), notifyReqDTO.getPayTransferId()); + return success(true); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java index 436a2f20c..b6ebd382c 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java index 224ecf1e5..0012eb9ce 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java @@ -14,7 +14,7 @@ import java.time.LocalDateTime; public class BrokerageRecordRespVO extends BrokerageRecordBaseVO { @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28896") - private Integer id; + private Long id; @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java index e732e3e14..c68812358 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; -import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java index bc1b9254e..8a04ae9a7 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java @@ -1,11 +1,10 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.ToString; -import jakarta.validation.constraints.NotNull; - @Schema(description = "管理后台 - 分销用户 - 清除推广员 Request VO") @Data @ToString(callSuper = true) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java index 10519ad8c..516169948 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java @@ -1,11 +1,10 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.ToString; -import jakarta.validation.constraints.NotNull; - @Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") @Data @ToString(callSuper = true) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java index 825346390..2aba9fde7 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java @@ -1,11 +1,10 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.ToString; -import jakarta.validation.constraints.NotNull; - @Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") @Data @ToString(callSuper = true) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java index 69765a528..1aae0608f 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; -import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java index 7de2b7d7f..ffff2c1de 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java @@ -1,11 +1,10 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.ToString; @Schema(description = "管理后台 - 驳回申请 Request VO") @Data @@ -14,7 +13,7 @@ public class BrokerageWithdrawRejectReqVO { @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") @NotNull(message = "编号不能为空") - private Integer id; + private Long id; @Schema(description = "审核驳回原因", example = "不对") @NotEmpty(message = "审核驳回原因不能为空") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java index de74bb4f6..0abd77e69 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java @@ -14,7 +14,7 @@ import java.time.LocalDateTime; public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO { @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") - private Integer id; + private Long id; @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java index b8d7f1fce..71432ec81 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java @@ -1,8 +1,13 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import cn.iocoder.yudao.module.trade.controller.admin.base.system.user.UserSimpleBaseVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; @@ -10,12 +15,12 @@ import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService 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.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; -import jakarta.validation.Valid; import java.util.Collection; import java.util.List; @@ -30,6 +35,9 @@ public class DeliveryPickUpStoreController { @Resource private DeliveryPickUpStoreService deliveryPickUpStoreService; + @Resource + private AdminUserApi adminUserApi; + @PostMapping("/create") @Operation(summary = "创建自提门店") @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')") @@ -60,10 +68,16 @@ public class DeliveryPickUpStoreController { @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") public CommonResult getDeliveryPickUpStore(@RequestParam("id") Long id) { DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(id); - return success(DeliveryPickUpStoreConvert.INSTANCE.convert(deliveryPickUpStore)); + if (deliveryPickUpStore == null) { + return success(null); + } + List verifyUsers = CollUtil.isNotEmpty(deliveryPickUpStore.getVerifyUserIds()) ? + adminUserApi.getUserList(deliveryPickUpStore.getVerifyUserIds()).getCheckedData() : null; + return success(BeanUtils.toBean(deliveryPickUpStore, DeliveryPickUpStoreRespVO.class) + .setVerifyUsers(BeanUtils.toBean(verifyUsers, UserSimpleBaseVO.class))); } - @GetMapping("/list-all-simple") + @GetMapping("/simple-list") @Operation(summary = "获得自提门店精简信息列表") public CommonResult> getSimpleDeliveryPickUpStoreList() { List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( @@ -88,4 +102,12 @@ public class DeliveryPickUpStoreController { return success(DeliveryPickUpStoreConvert.INSTANCE.convertPage(pageResult)); } + @PostMapping("/bind") + @Operation(summary = "绑定自提店员") + @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')") + public CommonResult bindDeliveryPickUpStore(@Valid @RequestBody DeliveryPickUpBindReqVO bindReqVO) { + deliveryPickUpStoreService.bindDeliveryPickUpStore(bindReqVO); + return success(true); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindReqVO.java new file mode 100644 index 000000000..7ee808977 --- /dev/null +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpBindReqVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.ToString; + +import java.util.List; + +@Schema(description = "管理后台 - 自提门店绑定核销人 Request VO") +@Data +@ToString(callSuper = true) +public class DeliveryPickUpBindReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + @NotNull(message = "编号不能为空") + private Long id; + + @Schema(description = "绑定用户编号组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + @NotEmpty(message = "绑定用户编号组数不能未空") + private List verifyUserIds; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java index 79995ceb4..bf2ae31e4 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java @@ -5,10 +5,10 @@ import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.framework.common.validation.Mobile; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import lombok.Data; + import java.time.LocalTime; /** diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java index 6dda8399f..713f9f03e 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; -import lombok.*; -import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; @Schema(description = "管理后台 - 自提门店创建 Request VO") @Data diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java index ee3ce2e49..423001d70 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java @@ -1,12 +1,14 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import lombok.*; - -import io.swagger.v3.oas.annotations.media.Schema; import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.validation.InEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import org.springframework.format.annotation.DateTimeFormat; + import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java index 5b5bd0d0c..fdf39a46d 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; +import cn.iocoder.yudao.module.trade.controller.admin.base.system.user.UserSimpleBaseVO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import java.time.LocalDateTime; +import java.util.List; @Schema(description = "管理后台 - 自提门店 Response VO") @Data @@ -19,4 +21,7 @@ public class DeliveryPickUpStoreRespVO extends DeliveryPickUpStoreBaseVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; + @Schema(description = "核销用户数组", requiredMode = Schema.RequiredMode.REQUIRED) + private List verifyUsers; + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java index c12fc9fc3..ac688f3f8 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java @@ -5,6 +5,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + @Schema(description = "管理后台 - 自提门店精简信息 Response VO") @Data @NoArgsConstructor @@ -29,4 +31,7 @@ public class DeliveryPickUpStoreSimpleRespVO { @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") private String detailAddress; + @Schema(description = "绑定用户编号组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") + private List verifyUserIds; + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java index e0774f6d9..03f9e320a 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java @@ -1,12 +1,11 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import jakarta.validation.constraints.NotNull; - @Schema(description = "管理后台 - 自提门店更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java index 16bb81582..79afa7046 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java @@ -10,19 +10,18 @@ import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderLogService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; 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 lombok.extern.slf4j.Slf4j; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; import java.util.List; import java.util.Map; import java.util.Objects; @@ -31,6 +30,7 @@ import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; @Tag(name = "管理后台 - 交易订单") @RestController @@ -144,7 +144,7 @@ public class TradeOrderController { @Parameter(name = "id", description = "交易订单编号") @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") public CommonResult pickUpOrderById(@RequestParam("id") Long id) { - tradeOrderUpdateService.pickUpOrderByAdmin(id); + tradeOrderUpdateService.pickUpOrderByAdmin(getLoginUserId(), id); return success(true); } @@ -153,7 +153,7 @@ public class TradeOrderController { @Parameter(name = "pickUpVerifyCode", description = "自提核销码") @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") public CommonResult pickUpOrderByVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { - tradeOrderUpdateService.pickUpOrderByAdmin(pickUpVerifyCode); + tradeOrderUpdateService.pickUpOrderByAdmin(getLoginUserId(), pickUpVerifyCode); return success(true); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java index 1d5b360a5..05d8a8f01 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java @@ -26,8 +26,6 @@ public interface DeliveryPickUpStoreConvert { DeliveryPickUpStoreDO convert(DeliveryPickUpStoreUpdateReqVO bean); - DeliveryPickUpStoreRespVO convert(DeliveryPickUpStoreDO bean); - List convertList(List list); PageResult convertPage(PageResult page); @@ -43,14 +41,13 @@ public interface DeliveryPickUpStoreConvert { default List convertList(List list, Double latitude, Double longitude) { - List voList = CollectionUtils.convertList(list, store -> { + return CollectionUtils.convertList(list, store -> { AppDeliveryPickUpStoreRespVO storeVO = convert03(store); if (latitude != null && longitude != null) { storeVO.setDistance(NumberUtils.getDistance(latitude, longitude, storeVO.getLatitude(), storeVO.getLongitude())); } return storeVO; }); - return voList; } @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") AppDeliveryPickUpStoreRespVO convert03(DeliveryPickUpStoreDO bean); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java index 21ff99374..93fe74f2a 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java @@ -2,19 +2,23 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.time.LocalTime; +import java.util.List; /** * 自提门店 DO * * @author jason */ -@TableName(value ="trade_delivery_pick_up_store") +@TableName(value ="trade_delivery_pick_up_store", autoResultMap = true) @KeySequence("trade_delivery_pick_up_store_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data public class DeliveryPickUpStoreDO extends BaseDO { @@ -74,6 +78,16 @@ public class DeliveryPickUpStoreDO extends BaseDO { */ private Double longitude; + /** + * 核销员工用户编号数组 + * + * 订单自提核销时,只有对应门店的店员才能核销 + * + * 关联 {@link AdminUserRespDTO#getId()} 管理员编号 + */ + @TableField(typeHandler = LongListTypeHandler.class) + private List verifyUserIds; + /** * 门店状态 * diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java deleted file mode 100644 index 4c03a8e5d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -// TODO @芋艿:后续再详细 review 一轮 -// TODO @芋艿:可能改成 DeliveryPickUpStoreUserDO -/** - * 自提门店店员 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_pick_up_store_staff") -@KeySequence("trade_delivery_pick_up_store_staff_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryPickUpStoreStaffDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 自提门店编号 - * - * 关联 {@link DeliveryPickUpStoreDO#getId()} - */ - private Long storeId; - - /** - * 管理员用户id - * - * 关联 {AdminUserDO#getId()} - */ - private Long adminUserId; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java index 9e2cf68ad..dc2b00916 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java @@ -35,7 +35,7 @@ public interface BrokerageWithdrawMapper extends BaseMapperX() .eq(BrokerageWithdrawDO::getId, id) .eq(BrokerageWithdrawDO::getStatus, status)); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java deleted file mode 100644 index 06cc14e26..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface DeliveryPickUpStoreStaffMapper extends BaseMapperX { - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java index c0580cb8c..b9a3261cb 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java @@ -32,7 +32,7 @@ public interface BrokerageRecordService { * @param id 编号 * @return 佣金记录 */ - BrokerageRecordDO getBrokerageRecord(Integer id); + BrokerageRecordDO getBrokerageRecord(Long id); /** * 获得佣金记录分页 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java index fa53a5586..7d75a6df5 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java @@ -64,7 +64,7 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { private ProductSkuApi productSkuApi; @Override - public BrokerageRecordDO getBrokerageRecord(Integer id) { + public BrokerageRecordDO getBrokerageRecord(Long id) { return brokerageRecordMapper.selectById(id); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java index 04ea9c49b..386b4c610 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java @@ -27,8 +27,9 @@ public interface BrokerageWithdrawService { * @param id 佣金编号 * @param status 审核状态 * @param auditReason 驳回原因 + * @param userIp 操作 IP */ - void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason); + void auditBrokerageWithdraw(Long id, BrokerageWithdrawStatusEnum status, String auditReason, String userIp); /** * 获得佣金提现 @@ -36,7 +37,7 @@ public interface BrokerageWithdrawService { * @param id 编号 * @return 佣金提现 */ - BrokerageWithdrawDO getBrokerageWithdraw(Integer id); + BrokerageWithdrawDO getBrokerageWithdraw(Long id); /** * 获得佣金提现分页 @@ -55,6 +56,16 @@ public interface BrokerageWithdrawService { */ Long createBrokerageWithdraw(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO); + /** + * 【API】更新佣金提现的转账结果 + * + * 目前用于支付回调,标记提现转账结果 + * + * @param id 提现编号 + * @param payTransferId 转账订单编号 + */ + void updateBrokerageWithdrawTransferred(Long id, Long payTransferId); + /** * 按照 userId,汇总每个用户的提现 * diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java index 063296ace..ccac4eb44 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java @@ -1,27 +1,37 @@ package cn.iocoder.yudao.module.trade.service.brokerage; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; +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.PayTransferRespDTO; +import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletAddBalanceReqDTO; +import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; +import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum; +import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; +import cn.iocoder.yudao.module.system.api.social.SocialUserApi; +import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; +import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageWithdrawMapper; -import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; +import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; import jakarta.annotation.Resource; import jakarta.validation.Validator; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; @@ -30,9 +40,9 @@ import java.time.LocalDateTime; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Map; 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.trade.enums.ErrorCodeConstants.*; /** @@ -42,6 +52,7 @@ import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; */ @Service @Validated +@Slf4j public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { @Resource @@ -54,13 +65,22 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { @Resource private NotifyMessageSendApi notifyMessageSendApi; + @Resource + private PayTransferApi payTransferApi; + @Resource + private SocialUserApi socialUserApi; + @Resource + private PayWalletApi payWalletApi; @Resource private Validator validator; + @Resource + private TradeOrderProperties tradeOrderProperties; + @Override @Transactional(rollbackFor = Exception.class) - public void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason) { + public void auditBrokerageWithdraw(Long id, BrokerageWithdrawStatusEnum status, String auditReason, String userIp) { // 1.1 校验存在 BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id); // 1.2 校验状态为审核中 @@ -68,41 +88,67 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); } - // 2. 更新 + // 2. 更新状态 int rows = brokerageWithdrawMapper.updateByIdAndStatus(id, BrokerageWithdrawStatusEnum.AUDITING.getStatus(), new BrokerageWithdrawDO().setStatus(status.getStatus()).setAuditReason(auditReason).setAuditTime(LocalDateTime.now())); if (rows == 0) { throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); } - String templateCode; + // 3.1 审批通过的后续处理 if (BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.equals(status)) { - templateCode = MessageTemplateConstants.SMS_BROKERAGE_WITHDRAW_AUDIT_APPROVE; - // 3.1 通过时佣金转余额 - if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(withdraw.getType())) { - // todo 疯狂: - } - // TODO 疯狂:调用转账接口 + auditBrokerageWithdrawSuccess(withdraw); + // 3.2 审批不通过的后续处理 } else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) { - templateCode = MessageTemplateConstants.SMS_BROKERAGE_WITHDRAW_AUDIT_REJECT; - // 3.2 驳回时需要退还用户佣金 brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT, String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle()); } else { throw new IllegalArgumentException("不支持的提现状态:" + status); } - - // 4. 通知用户 - Map templateParams = MapUtil.builder() - .put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime())) - .put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice())) - .put("reason", auditReason) - .build(); - notifyMessageSendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO() - .setUserId(withdraw.getUserId()).setTemplateCode(templateCode).setTemplateParams(templateParams)).checkError(); } - private BrokerageWithdrawDO validateBrokerageWithdrawExists(Integer id) { + private void auditBrokerageWithdrawSuccess(BrokerageWithdrawDO withdraw) { + // 1.1 钱包 + if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(withdraw.getType())) { + payWalletApi.addWalletBalance(new PayWalletAddBalanceReqDTO() + .setUserId(withdraw.getUserId()).setUserType(UserTypeEnum.MEMBER.getValue()) + .setBizType(PayWalletBizTypeEnum.BROKERAGE_WITHDRAW.getType()).setBizId(withdraw.getId().toString()) + .setPrice(withdraw.getPrice())).checkError(); + // 1.2 微信 API + } else if (BrokerageWithdrawTypeEnum.WECHAT_API.getType().equals(withdraw.getType())) { + // TODO @luchi:这里,要加个转账单号的记录;另外,调用 API 转账,是立马成功,还是有延迟的哈? + Long payTransferId = createPayTransfer(withdraw); + // 1.3 剩余类型,都是手动打款,所以不处理 + } else { + // TODO 可优化:未来可以考虑,接入支付宝、银联等 API 转账,实现自动打款 + log.info("[auditBrokerageWithdrawSuccess][withdraw({}) 类型({}) 手动打款,无需处理]", withdraw.getId(), withdraw.getType()); + } + + // 2. 非支付 API,则直接体现成功 + if (!BrokerageWithdrawTypeEnum.isApi(withdraw.getType())) { + brokerageWithdrawMapper.updateByIdAndStatus(withdraw.getId(), BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.getStatus(), + new BrokerageWithdrawDO().setStatus(BrokerageWithdrawStatusEnum.WITHDRAW_SUCCESS.getStatus())); + } + } + + private Long createPayTransfer(BrokerageWithdrawDO withdraw) { + // 1.1 获取微信 openid + SocialUserRespDTO socialUser = socialUserApi.getSocialUserByUserId( + UserTypeEnum.MEMBER.getValue(), withdraw.getUserId(), SocialTypeEnum.WECHAT_MINI_APP.getType()).getCheckedData(); + // TODO @luchi:这里,需要校验非空。如果空的话,要有业务异常哈; + // 1.2 构建请求 + PayTransferCreateReqDTO payTransferCreateReqDTO = new PayTransferCreateReqDTO() + .setAppKey(tradeOrderProperties.getPayAppKey()) + .setChannelCode("wx_lite").setType(PayTransferTypeEnum.WX_BALANCE.getType()) + .setMerchantTransferId(withdraw.getId().toString()) + .setPrice(withdraw.getPrice()) + .setSubject("佣金提现") + .setOpenid(socialUser.getOpenid()).setUserIp(getClientIP()); + // 2. 发起请求 + return payTransferApi.createTransfer(payTransferCreateReqDTO).getCheckedData(); + } + + private BrokerageWithdrawDO validateBrokerageWithdrawExists(Long id) { BrokerageWithdrawDO withdraw = brokerageWithdrawMapper.selectById(id); if (withdraw == null) { throw exception(BROKERAGE_WITHDRAW_NOT_EXISTS); @@ -111,7 +157,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { } @Override - public BrokerageWithdrawDO getBrokerageWithdraw(Integer id) { + public BrokerageWithdrawDO getBrokerageWithdraw(Long id) { return brokerageWithdrawMapper.selectById(id); } @@ -141,15 +187,6 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { return withdraw.getId(); } - @Override - public List getWithdrawSummaryListByUserId(Collection userIds, - BrokerageWithdrawStatusEnum status) { - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, status.getStatus()); - } - /** * 计算提现手续费 * @@ -157,7 +194,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { * @param percent 手续费百分比 * @return 提现手续费 */ - Integer calculateFeePrice(Integer withdrawPrice, Integer percent) { + private Integer calculateFeePrice(Integer withdrawPrice, Integer percent) { Integer feePrice = 0; if (percent != null && percent > 0) { feePrice = MoneyUtils.calculateRatePrice(withdrawPrice, Double.valueOf(percent)); @@ -171,11 +208,42 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { * @param withdrawPrice 提现金额 * @return 分销配置 */ - TradeConfigDO validateWithdrawPrice(Integer withdrawPrice) { + private TradeConfigDO validateWithdrawPrice(Integer withdrawPrice) { TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); if (tradeConfig.getBrokerageWithdrawMinPrice() != null && withdrawPrice < tradeConfig.getBrokerageWithdrawMinPrice()) { throw exception(BROKERAGE_WITHDRAW_MIN_PRICE, MoneyUtils.fenToYuanStr(tradeConfig.getBrokerageWithdrawMinPrice())); } return tradeConfig; } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateBrokerageWithdrawTransferred(Long id, Long payTransferId) { + BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id); + PayTransferRespDTO transfer = payTransferApi.getTransfer(payTransferId).getCheckedData(); + // TODO @luchi:建议参考支付那,即使成功的情况下,也要各种校验;金额是否匹配、转账单号是否匹配、是否重复调用; + if (PayTransferStatusEnum.isSuccess(transfer.getStatus())) { + withdraw.setStatus(BrokerageWithdrawStatusEnum.WITHDRAW_SUCCESS.getStatus()); + // TODO @luchi:发送站内信 + } else if (PayTransferStatusEnum.isPendingStatus(transfer.getStatus())) { + // TODO @luchi:这里,是不是不用更新哈? + withdraw.setStatus(BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.getStatus()); + } else { + withdraw.setStatus(BrokerageWithdrawStatusEnum.WITHDRAW_FAIL.getStatus()); + // 3.2 驳回时需要退还用户佣金 + brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT, + String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle()); + } + brokerageWithdrawMapper.updateById(withdraw); + } + + @Override + public List getWithdrawSummaryListByUserId(Collection userIds, + BrokerageWithdrawStatusEnum status) { + if (CollUtil.isEmpty(userIds)) { + return Collections.emptyList(); + } + return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, status.getStatus()); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java index 300b24d0e..f8681e758 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java @@ -1,12 +1,13 @@ package cn.iocoder.yudao.module.trade.service.delivery; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpBindReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; - import jakarta.validation.Valid; + import java.util.Collection; import java.util.List; @@ -55,6 +56,14 @@ public interface DeliveryPickUpStoreService { */ List getDeliveryPickUpStoreList(Collection ids); + /** + * 获得指定状态的自提门店列表 + * + * @param status 状态 + * @return 自提门店列表 + */ + List getDeliveryPickUpStoreListByStatus(Integer status); + /** * 获得自提门店分页 * @@ -64,10 +73,10 @@ public interface DeliveryPickUpStoreService { PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO); /** - * 获得指定状态的自提门店列表 + * 绑定自提店员 * - * @param status 状态 - * @return 自提门店列表 + * @param bindReqVO 绑定数据 */ - List getDeliveryPickUpStoreListByStatus(Integer status); + void bindDeliveryPickUpStore(DeliveryPickUpBindReqVO bindReqVO); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java index 278235f65..66e0bfb35 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java @@ -1,16 +1,19 @@ package cn.iocoder.yudao.module.trade.service.delivery; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpBindReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper; +import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import jakarta.annotation.Resource; import java.util.Collection; import java.util.List; @@ -29,6 +32,9 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic @Resource private DeliveryPickUpStoreMapper deliveryPickUpStoreMapper; + @Resource + private AdminUserApi adminUserApi; + @Override public Long createDeliveryPickUpStore(DeliveryPickUpStoreCreateReqVO createReqVO) { // 插入 @@ -56,7 +62,8 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic } private void validateDeliveryPickUpStoreExists(Long id) { - if (deliveryPickUpStoreMapper.selectById(id) == null) { + DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreMapper.selectById(id); + if (deliveryPickUpStore == null) { throw exception(PICK_UP_STORE_NOT_EXISTS); } } @@ -71,14 +78,26 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic return deliveryPickUpStoreMapper.selectBatchIds(ids); } + @Override + public List getDeliveryPickUpStoreListByStatus(Integer status) { + return deliveryPickUpStoreMapper.selectListByStatus(status); + } + @Override public PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO) { return deliveryPickUpStoreMapper.selectPage(pageReqVO); } @Override - public List getDeliveryPickUpStoreListByStatus(Integer status) { - return deliveryPickUpStoreMapper.selectListByStatus(status); + public void bindDeliveryPickUpStore(DeliveryPickUpBindReqVO bindReqVO) { + // 1.1 校验门店存在 + validateDeliveryPickUpStoreExists(bindReqVO.getId()); + // 1.2 校验用户存在 + adminUserApi.validateUserList(bindReqVO.getVerifyUserIds()).checkError(); + + // 2. 更新 + DeliveryPickUpStoreDO updateObj = BeanUtils.toBean(bindReqVO, DeliveryPickUpStoreDO.class); + deliveryPickUpStoreMapper.updateById(updateObj); } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java index 55a696e2a..59ad63acf 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java @@ -129,16 +129,18 @@ public interface TradeOrderUpdateService { /** * 【管理员】核销订单 * + * @param userId 管理员编号 * @param id 订单编号 */ - void pickUpOrderByAdmin(Long id); + void pickUpOrderByAdmin(Long userId, Long id); /** * 【管理员】核销订单 * + * @param userId 管理员编号 * @param pickUpVerifyCode 自提核销码 */ - void pickUpOrderByAdmin(String pickUpVerifyCode); + void pickUpOrderByAdmin(Long userId, String pickUpVerifyCode); /** * 【管理员】根据自提核销码,查询订单 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index f87f67ac7..2c042ae0b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java @@ -36,6 +36,7 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderI import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; @@ -48,6 +49,7 @@ import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrder import cn.iocoder.yudao.module.trade.framework.order.core.utils.TradeOrderLogUtils; import cn.iocoder.yudao.module.trade.service.cart.CartService; import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; +import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; import cn.iocoder.yudao.module.trade.service.message.TradeMessageService; import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; import cn.iocoder.yudao.module.trade.service.order.handler.TradeOrderHandler; @@ -104,6 +106,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { private DeliveryExpressService deliveryExpressService; @Resource private TradeMessageService tradeMessageService; + @Resource + private DeliveryPickUpStoreService pickUpStoreService; @Resource private PayOrderApi payOrderApi; @@ -718,14 +722,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Override @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) - public void pickUpOrderByAdmin(Long id) { - getSelf().pickUpOrder(tradeOrderMapper.selectById(id)); + public void pickUpOrderByAdmin(Long userId, Long id) { + getSelf().pickUpOrder(userId, tradeOrderMapper.selectById(id)); } @Override @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) - public void pickUpOrderByAdmin(String pickUpVerifyCode) { - getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); + public void pickUpOrderByAdmin(Long userId, String pickUpVerifyCode) { + getSelf().pickUpOrder(userId, tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); } @Override @@ -734,13 +738,19 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { } @Transactional(rollbackFor = Exception.class) - public void pickUpOrder(TradeOrderDO order) { + public void pickUpOrder(Long userId, TradeOrderDO order) { if (order == null) { throw exception(ORDER_NOT_FOUND); } if (ObjUtil.notEqual(DeliveryTypeEnum.PICK_UP.getType(), order.getDeliveryType())) { throw exception(ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP); } + DeliveryPickUpStoreDO deliveryPickUpStore = pickUpStoreService.getDeliveryPickUpStore(order.getPickUpStoreId()); + if (deliveryPickUpStore == null + || !CollUtil.contains(deliveryPickUpStore.getVerifyUserIds(), userId)) { + throw exception(ORDER_PICK_UP_FAIL_NOT_VERIFY_USER); + } + receiveOrder0(order); } diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java index 9660bce1a..b109b0c16 100644 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java @@ -2,14 +2,18 @@ package cn.iocoder.yudao.module.pay.api.transfer; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; +import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO; import cn.iocoder.yudao.module.pay.enums.ApiConstants; 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.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import jakarta.validation.Valid; +import org.springframework.web.bind.annotation.RequestParam; @FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = @Tag(name = "RPC 服务 - 转账单") @@ -21,4 +25,9 @@ public interface PayTransferApi { @Operation(summary = "创建转账单") CommonResult createTransfer(@Valid @RequestBody PayTransferCreateReqDTO reqDTO); + @GetMapping(PREFIX + "/get") + @Operation(summary = "获得转账单") + @Parameter(name = "id", description = "转账单编号", required = true, example = "1024") + CommonResult getTransfer(@RequestParam("id") Long id); + } diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferRespDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferRespDTO.java new file mode 100644 index 000000000..d287dcc83 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferRespDTO.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.pay.api.transfer.dto; + +import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; +import lombok.Data; + +@Data +public class PayTransferRespDTO { + + /** + * 编号 + */ + private Long id; + + /** + * 转账单号 + */ + private String no; + + /** + * 转账金额,单位:分 + */ + private Integer price; + + /** + * 转账状态 + * + * 枚举 {@link PayTransferStatusEnum} + */ + private Integer status; + +} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java new file mode 100644 index 000000000..222b07c84 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.pay.api.wallet; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletAddBalanceReqDTO; +import cn.iocoder.yudao.module.pay.enums.ApiConstants; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = +@Tag(name = "RPC 服务 - 钱包") +public interface PayWalletApi { + + String PREFIX = ApiConstants.PREFIX + "/wallet"; + + @PostMapping(PREFIX + "/add-balance") + @Operation(summary = "添加钱包余额") + CommonResult addWalletBalance(@Valid @RequestBody PayWalletAddBalanceReqDTO reqDTO); + +} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletAddBalanceReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletAddBalanceReqDTO.java new file mode 100644 index 000000000..264649d2a --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletAddBalanceReqDTO.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.pay.api.wallet.dto; + +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * 钱包余额增加 Request DTO + * + * @author 芋道源码 + */ +@Data +public class PayWalletAddBalanceReqDTO { + + /** + * 用户编号 + * + * 关联 MemberUserDO 的 id 属性,或者 AdminUserDO 的 id 属性 + */ + @NotNull(message = "用户编号不能为空") + private Long userId; + /** + * 用户类型 + * + * 关联 {@link UserTypeEnum} + */ + @NotNull(message = "用户类型不能为空") + private Integer userType; + + /** + * 关联业务分类 + */ + @NotNull(message = "关联业务分类不能为空") + private Integer bizType; + /** + * 关联业务编号 + */ + @NotNull(message = "关联业务编号不能为空") + private String bizId; + + /** + * 交易金额,单位分 + * + * 正值表示余额增加,负值表示余额减少 + */ + @NotNull(message = "交易金额不能为空") + private Integer price; + +} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java index b5702ebbc..0060579e9 100644 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java @@ -19,7 +19,8 @@ public enum PayWalletBizTypeEnum implements IntArrayValuable { RECHARGE_REFUND(2, "充值退款"), PAYMENT(3, "支付"), PAYMENT_REFUND(4, "支付退款"), - UPDATE_BALANCE(5, "更新余额"); + UPDATE_BALANCE(5, "更新余额"), + BROKERAGE_WITHDRAW(6, "分佣提现"); /** * 业务分类 @@ -36,4 +37,9 @@ public enum PayWalletBizTypeEnum implements IntArrayValuable { public int[] array() { return ARRAYS; } + + public static PayWalletBizTypeEnum valueOf(Integer type) { + return Arrays.stream(values()).filter(item -> item.getType().equals(type)).findFirst().orElse(null); + } + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java index 20363e4f2..c3d820195 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java @@ -1,7 +1,10 @@ package cn.iocoder.yudao.module.pay.api.transfer; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; +import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO; +import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RestController; @@ -27,4 +30,10 @@ public class PayTransferApiImpl implements PayTransferApi { return success(payTransferService.createTransfer(reqDTO)); } + @Override + public CommonResult getTransfer(Long id) { + PayTransferDO transfer = payTransferService.getTransfer(id); + return success(BeanUtils.toBean(transfer, PayTransferRespDTO.class)); + } + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java new file mode 100644 index 000000000..8ac9a725f --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.pay.api.wallet; + +import cn.hutool.core.lang.Assert; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletAddBalanceReqDTO; +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; +import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; +import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RestController; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.*; + +/** + * 钱包 API 实现类 + * + * @author jason + */ +@RestController // 提供 RESTful API 接口,给 Feign 调用 +@Validated +public class PayWalletApiImpl implements PayWalletApi { + + @Resource + private PayWalletService payWalletService; + + @Override + public CommonResult addWalletBalance(PayWalletAddBalanceReqDTO reqDTO) { + // 创建或获取钱包 + PayWalletDO wallet = payWalletService.getOrCreateWallet(reqDTO.getUserId(), reqDTO.getUserType()); + Assert.notNull(wallet, "钱包({}/{})不存在", reqDTO.getUserId(), reqDTO.getUserType()); + + // 增加余额 + PayWalletBizTypeEnum bizType = PayWalletBizTypeEnum.valueOf(reqDTO.getBizType()); + payWalletService.addWalletBalance(wallet.getId(), reqDTO.getBizId(), bizType, reqDTO.getPrice()); + return success(true); + } + +} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java index 723870bf5..f636972f2 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java @@ -1,17 +1,16 @@ package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.validation.InEnum; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import lombok.Data; +import lombok.*; import org.hibernate.validator.constraints.URL; +import jakarta.validation.constraints.*; + /** -* 支付应用信息 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ + * 支付应用信息 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ @Data public class PayAppBaseVO { @@ -41,4 +40,8 @@ public class PayAppBaseVO { @URL(message = "退款结果的回调地址必须为 URL 格式") private String refundNotifyUrl; + @Schema(description = "转账结果的回调地址", example = "http://127.0.0.1:48080/transfer-callback") + @URL(message = "转账结果的回调地址必须为 URL 格式") + private String transferNotifyUrl; + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java index 700232a19..1139a8247 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.pay.core.client.PayClient; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO; import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskRespVO; @@ -18,17 +19,18 @@ import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; import cn.iocoder.yudao.module.pay.service.order.PayOrderService; import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; +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 jakarta.annotation.Resource; -import jakarta.annotation.security.PermitAll; -import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import jakarta.annotation.Resource; +import jakarta.annotation.security.PermitAll; +import jakarta.validation.Valid; import java.util.List; import java.util.Map; @@ -49,6 +51,8 @@ public class PayNotifyController { @Resource private PayRefundService refundService; @Resource + private PayTransferService payTransferService; + @Resource private PayNotifyService notifyService; @Resource private PayAppService appService; @@ -65,7 +69,7 @@ public class PayNotifyController { // 1. 校验支付渠道是否存在 PayClient payClient = channelService.getPayClient(channelId); if (payClient == null) { - log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId); + log.error("[notifyOrder][渠道编号({}) 找不到对应的支付客户端]", channelId); throw exception(CHANNEL_NOT_FOUND); } @@ -79,13 +83,13 @@ public class PayNotifyController { @Operation(summary = "支付渠道的统一【退款】回调") @PermitAll public String notifyRefund(@PathVariable("channelId") Long channelId, - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { + @RequestParam(required = false) Map params, + @RequestBody(required = false) String body) { log.info("[notifyRefund][channelId({}) 回调数据({}/{})]", channelId, params, body); // 1. 校验支付渠道是否存在 PayClient payClient = channelService.getPayClient(channelId); if (payClient == null) { - log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId); + log.error("[notifyRefund][渠道编号({}) 找不到对应的支付客户端]", channelId); throw exception(CHANNEL_NOT_FOUND); } @@ -95,6 +99,26 @@ public class PayNotifyController { return "success"; } + @PostMapping(value = "/transfer/{channelId}") + @Operation(summary = "支付渠道的统一【转账】回调") + @PermitAll + public String notifyTransfer(@PathVariable("channelId") Long channelId, + @RequestParam(required = false) Map params, + @RequestBody(required = false) String body) { + log.info("[notifyTransfer][channelId({}) 回调数据({}/{})]", channelId, params, body); + // 1. 校验支付渠道是否存在 + PayClient payClient = channelService.getPayClient(channelId); + if (payClient == null) { + log.error("[notifyTransfer][渠道编号({}) 找不到对应的支付客户端]", channelId); + throw exception(CHANNEL_NOT_FOUND); + } + + // 2. 解析通知数据 + PayTransferRespDTO notify = payClient.parseTransferNotify(params, body); + payTransferService.notifyTransfer(channelId, notify); + return "success"; + } + @GetMapping("/get-detail") @Operation(summary = "获得回调通知的明细") @Parameter(name = "id", description = "编号", required = true, example = "1024") diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java index 4e79548d0..7f6b59cc8 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java @@ -24,7 +24,8 @@ public interface PayTransferConvert { PayTransferCreateReqDTO convert(PayDemoTransferCreateReqVO vo); - PayTransferRespVO convert(PayTransferDO bean); + PayTransferRespVO convert(PayTransferDO bean); PageResult convertPage(PageResult pageResult); + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java index af4f6debf..57be1a818 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java @@ -23,10 +23,6 @@ public interface PayTransferMapper extends BaseMapperX { PayTransferDO::getMerchantTransferId, merchantTransferId); } - default PayTransferDO selectByNo(String no){ - return selectOne(PayTransferDO::getNo, no); - } - default PageResult selectPage(PayTransferPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(PayTransferDO::getNo, reqVO.getNo()) @@ -41,9 +37,15 @@ public interface PayTransferMapper extends BaseMapperX { .orderByDesc(PayTransferDO::getId)); } - default List selectListByStatus(Integer status){ + default List selectListByStatus(Integer status) { return selectList(PayTransferDO::getStatus, status); } + + default PayTransferDO selectByAppIdAndNo(Long appId, String no) { + return selectOne(PayTransferDO::getAppId, appId, + PayTransferDO::getNo, no); + } + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java index 4bbaff8b5..19a76cd6e 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java @@ -68,6 +68,19 @@ public interface PayWalletMapper extends BaseMapperX { return update(null, lambdaUpdateWrapper); } + /** + * 增加余额的时候,更新钱包 + * + * @param id 钱包 id + * @param price 钱包金额 + */ + default void updateWhenAdd(Long id, Integer price) { + LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() + .setSql(" balance = balance + " + price) + .eq(PayWalletDO::getId, id); + update(null, lambdaUpdateWrapper); + } + /** * 冻结钱包部分余额 * @@ -114,7 +127,6 @@ public interface PayWalletMapper extends BaseMapperX { return update(null, lambdaUpdateWrapper); } - } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java index d124bbfc5..84905a532 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java @@ -39,6 +39,15 @@ public class PayProperties { @URL(message = "支付回调地址的格式必须是 URL") private String refundNotifyUrl; + /** + * 转账回调地址 + * + * 实际上,对应的 PayNotifyController 的 notifyTransfer 方法的 URL + * + * 回调顺序:支付渠道(支付宝支付、微信支付) => yudao-module-pay 的 transferNotifyUrl 地址 => 业务的 PayAppDO.transferNotifyUrl 地址 + */ + private String transferNotifyUrl; + /** * 支付订单 no 的前缀 */ diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java index c7be35f1a..63fc92ba3 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java @@ -177,6 +177,11 @@ public class WalletPayClient extends AbstractPayClient { throw new IllegalStateException(String.format("支付退款单[%s] 状态不正确", outRefundNo)); } + @Override + protected PayTransferRespDTO doParseTransferNotify(Map params, String body) throws Throwable { + throw new UnsupportedOperationException("未实现"); + } + @Override public PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { throw new UnsupportedOperationException("待实现"); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java index 37c921b1b..f671c753a 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.pay.service.transfer; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferCreateReqVO; import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO; @@ -53,4 +54,13 @@ public interface PayTransferService { * @return 同步到状态的转账数量,包括转账成功、转账失败、转账中的 */ int syncTransfer(); + + /** + * 渠道的转账通知 + * + * @param channelId 渠道编号 + * @param notify 通知 + */ + void notifyTransfer(Long channelId, PayTransferRespDTO notify); + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java index 5ace5ab4b..1825b3a45 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java @@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.pay.dal.mysql.transfer.PayTransferMapper; import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; +import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; import cn.iocoder.yudao.module.pay.service.app.PayAppService; import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; @@ -50,6 +51,9 @@ public class PayTransferServiceImpl implements PayTransferService { private static final String TRANSFER_NO_PREFIX = "T"; + @Resource + private PayProperties payProperties; + @Resource private PayTransferMapper transferMapper; @Resource @@ -96,13 +100,15 @@ public class PayTransferServiceImpl implements PayTransferService { transfer = INSTANCE.convert(reqDTO) .setChannelId(channel.getId()) .setNo(no).setStatus(WAITING.getStatus()) - .setNotifyUrl(payApp.getTransferNotifyUrl()); + .setNotifyUrl(payApp.getTransferNotifyUrl()) + .setAppId(channel.getAppId()); transferMapper.insert(transfer); } try { // 3. 调用三方渠道发起转账 PayTransferUnifiedReqDTO transferUnifiedReq = INSTANCE.convert2(transfer) .setOutTransferNo(transfer.getNo()); + transferUnifiedReq.setNotifyUrl(genChannelTransferNotifyUrl(channel)); PayTransferRespDTO unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq); // 4. 通知转账结果 getSelf().notifyTransfer(channel, unifiedTransferResp); @@ -116,6 +122,16 @@ public class PayTransferServiceImpl implements PayTransferService { return transfer.getId(); } + /** + * 根据支付渠道的编码,生成支付渠道的回调地址 + * + * @param channel 支付渠道 + * @return 支付渠道的回调地址 配置地址 + "/" + channel id + */ + private String genChannelTransferNotifyUrl(PayChannelDO channel) { + return payProperties.getTransferNotifyUrl() + "/" + channel.getId(); + } + private PayTransferDO validateTransferCanCreate(PayTransferCreateReqDTO dto, Long appId) { PayTransferDO transfer = transferMapper.selectByAppIdAndMerchantTransferId(appId, dto.getMerchantTransferId()); if (transfer != null) { @@ -154,7 +170,7 @@ public class PayTransferServiceImpl implements PayTransferService { private void notifyTransferInProgress(PayChannelDO channel, PayTransferRespDTO notify) { // 1.校验 - PayTransferDO transfer = transferMapper.selectByNo(notify.getOutTransferNo()); + PayTransferDO transfer = transferMapper.selectByAppIdAndNo(channel.getAppId(), notify.getOutTransferNo()); if (transfer == null) { throw exception(PAY_TRANSFER_NOT_FOUND); } @@ -172,16 +188,12 @@ public class PayTransferServiceImpl implements PayTransferService { throw exception(PAY_TRANSFER_STATUS_IS_NOT_WAITING); } log.info("[notifyTransferInProgress][transfer({}) 更新为转账进行中状态]", transfer.getId()); - - // 3. 插入转账通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.TRANSFER.getType(), - transfer.getId()); } private void notifyTransferSuccess(PayChannelDO channel, PayTransferRespDTO notify) { // 1.校验 - PayTransferDO transfer = transferMapper.selectByNo(notify.getOutTransferNo()); + PayTransferDO transfer = transferMapper.selectByAppIdAndNo(channel.getAppId(), notify.getOutTransferNo()); if (transfer == null) { throw exception(PAY_TRANSFER_NOT_FOUND); } @@ -210,7 +222,7 @@ public class PayTransferServiceImpl implements PayTransferService { private void notifyTransferClosed(PayChannelDO channel, PayTransferRespDTO notify) { // 1.校验 - PayTransferDO transfer = transferMapper.selectByNo(notify.getOutTransferNo()); + PayTransferDO transfer = transferMapper.selectByAppIdAndNo(channel.getAppId(), notify.getOutTransferNo()); if (transfer == null) { throw exception(PAY_TRANSFER_NOT_FOUND); } @@ -283,7 +295,7 @@ public class PayTransferServiceImpl implements PayTransferService { } } - private void notifyTransfer(Long channelId, PayTransferRespDTO notify) { + public void notifyTransfer(Long channelId, PayTransferRespDTO notify) { // 校验渠道是否有效 PayChannelDO channel = channelService.validPayChannel(channelId); // 通知转账结果给对应的业务 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java index cc9d570a2..30afb437d 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java @@ -187,7 +187,7 @@ public class PayWalletServiceImpl implements PayWalletService { // 2. 加锁,更新钱包余额(目的:避免钱包流水的并发更新时,余额变化不连贯) return lockRedisDAO.lock(walletId, UPDATE_TIMEOUT_MILLIS, () -> { - // 2. 更新钱包金额 + // 3. 更新钱包金额 switch (bizType) { case PAYMENT_REFUND: { // 退款更新 walletMapper.updateWhenConsumptionRefund(payWallet.getId(), price); @@ -198,15 +198,15 @@ public class PayWalletServiceImpl implements PayWalletService { break; } case UPDATE_BALANCE: // 更新余额 - walletMapper.updateWhenRecharge(payWallet.getId(), price); + case BROKERAGE_WITHDRAW: // 分佣提现 + walletMapper.updateWhenAdd(payWallet.getId(), price); break; default: { - // TODO 其它类型待实现 - throw new UnsupportedOperationException("待实现"); + throw new UnsupportedOperationException("待实现:" + bizType); } } - // 3. 生成钱包流水 + // 4. 生成钱包流水 WalletTransactionCreateReqBO transactionCreateReqBO = new WalletTransactionCreateReqBO() .setWalletId(payWallet.getId()).setPrice(price).setBalance(payWallet.getBalance() + price) .setBizId(bizId).setBizType(bizType.getType()).setTitle(bizType.getDescription()); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml index e45ceb23c..17c1e1521 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml @@ -109,4 +109,5 @@ yudao: pay: order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址 refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址 + transfer-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/transfer # 支付渠道的【转账】回调地址 demo: true # 关闭演示模式 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml index a7f41d5ff..0160ebfa0 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml @@ -137,4 +137,5 @@ yudao: enable: false pay: order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址 - refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址 \ No newline at end of file + refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址 + transfer-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/transfer # 支付渠道的【转账】回调地址 \ No newline at end of file diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java index a9a98953c..e57f4ac70 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.pay.config; import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.framework.pay.core.client.impl.PayClientFactoryImpl; import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; /** diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java index 86e3566b2..816b6fef7 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java @@ -79,6 +79,8 @@ public interface PayClient { */ PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo); + // ============ 转账相关 ========== + /** * 调用渠道,进行转账 * @@ -95,4 +97,14 @@ public interface PayClient { * @return 转账信息 */ PayTransferRespDTO getTransfer(String outTradeNo, PayTransferTypeEnum type); + + /** + * 解析 transfer 回调数据 + * + * @param params HTTP 回调接口 content type 为 application/x-www-form-urlencoded 的所有参数 + * @param body HTTP 回调接口的 request body + * @return 转账信息 + */ + PayTransferRespDTO parseTransferNotify(Map params, String body); + } diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java index 52b75c89c..beb3b4165 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.framework.pay.core.client; import com.fasterxml.jackson.annotation.JsonTypeInfo; + import jakarta.validation.Validator; /** diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java index da8469496..15be7a757 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java @@ -1,13 +1,13 @@ package cn.iocoder.yudao.framework.pay.core.client.dto.order; import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import jakarta.validation.constraints.DecimalMin; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import lombok.Data; import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.URL; +import jakarta.validation.constraints.DecimalMin; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; import java.util.Map; diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java index 06efe895f..3101633b8 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java @@ -1,8 +1,5 @@ package cn.iocoder.yudao.framework.pay.core.client.dto.refund; -import jakarta.validation.constraints.DecimalMin; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -10,6 +7,10 @@ import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import org.hibernate.validator.constraints.URL; +import jakarta.validation.constraints.DecimalMin; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; + /** * 统一 退款 Request DTO * diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java index b945912dc..509223f60 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java @@ -2,17 +2,18 @@ package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; -import lombok.Data; -import org.hibernate.validator.constraints.Length; +import org.hibernate.validator.constraints.URL; import java.util.Map; -import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.Alipay; -import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.WxPay; +import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.*; /** * 统一转账 Request DTO @@ -76,4 +77,12 @@ public class PayTransferUnifiedReqDTO { * 支付渠道的额外参数 */ private Map channelExtras; + + /** + * 转账结果的 notify 回调地址 + */ + @NotEmpty(message = "转账结果的回调地址不能为空") + @URL(message = "转账结果的 notify 回调地址必须是 URL 格式") + private String notifyUrl; + } diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/WxPayTransferPartnerNotifyV3Result.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/WxPayTransferPartnerNotifyV3Result.java new file mode 100644 index 000000000..a25cc1569 --- /dev/null +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/WxPayTransferPartnerNotifyV3Result.java @@ -0,0 +1,129 @@ +package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; + +import com.github.binarywang.wxpay.bean.notify.OriginNotifyResponse; +import com.github.binarywang.wxpay.bean.notify.WxPayBaseNotifyV3Result; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +// TODO @luchi:这个可以复用 wxjava 里的类么? +@NoArgsConstructor +public class WxPayTransferPartnerNotifyV3Result implements Serializable, WxPayBaseNotifyV3Result { + + private static final long serialVersionUID = -1L; + + /** + * 源数据 + */ + private OriginNotifyResponse rawData; + + /** + * 解密后的数据 + */ + private TransferNotifyResult result; + + @Override + public void setRawData(OriginNotifyResponse rawData) { + this.rawData = rawData; + } + + @Override + public void setResult(TransferNotifyResult data) { + this.result = data; + } + + public TransferNotifyResult getResult() { + return result; + } + + public OriginNotifyResponse getRawData() { + return rawData; + } + + @Data + @NoArgsConstructor + public static class TransferNotifyResult implements Serializable { + private static final long serialVersionUID = 1L; + + /*********************** 公共字段 ******************** + + /** + * 商家批次单号 + */ + @SerializedName(value = "out_batch_no") + protected String outBatchNo; + + /** + * 微信批次单号 + */ + @SerializedName(value = "batch_id") + protected String batchId; + + /** + * 批次状态 + */ + @SerializedName(value = "batch_status") + protected String batchStatus; + + /** + * 批次总笔数 + */ + @SerializedName(value = "total_num") + protected Integer totalNum; + + /** + * 批次总金额 + */ + @SerializedName(value = "total_amount") + protected Integer totalAmount; + + /** + * 批次更新时间 + */ + @SerializedName(value = "update_time") + private String updateTime; + + /*********************** FINISHED ******************** + + /** + * 转账成功金额 + */ + @SerializedName(value = "success_amount") + protected Integer successAmount; + + /** + * 转账成功笔数 + */ + @SerializedName(value = "success_num") + protected Integer successNum; + + /** + * 转账失败金额 + */ + @SerializedName(value = "fail_amount") + protected Integer failAmount; + + /** + * 转账失败笔数 + */ + @SerializedName(value = "fail_num") + protected Integer failNum; + + /*********************** CLOSED ******************** + + /** + * 商户号 + */ + @SerializedName(value = "mchid") + protected String mchId; + + /** + * 批次关闭原因 + */ + @SerializedName(value = "close_reason") + protected String closeReason; + + } +} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java index 82d68b58f..5c4750402 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java @@ -219,6 +219,22 @@ public abstract class AbstractPayClient implemen } } + @Override + public final PayTransferRespDTO parseTransferNotify(Map params, String body) { + try { + return doParseTransferNotify(params, body); + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 + throw ex; + } catch (Throwable ex) { + log.error("[doParseTransferNotify][客户端({}) params({}) body({}) 解析失败]", + getId(), params, body, ex); + throw buildPayException(ex); + } + } + + protected abstract PayTransferRespDTO doParseTransferNotify(Map params, String body) + throws Throwable; + @Override public final PayTransferRespDTO getTransfer(String outTradeNo, PayTransferTypeEnum type) { try { diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java index 4f35cae90..80581f304 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java @@ -1,9 +1,10 @@ package cn.iocoder.yudao.framework.pay.core.client.impl; import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import jakarta.validation.Validator; import lombok.Data; +import jakarta.validation.Validator; + /** * 无需任何配置 PayClientConfig 实现类 * diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java index 4dcf23675..b3075eb03 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java @@ -325,6 +325,12 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient params, String body) throws Throwable { + throw new UnsupportedOperationException("未实现"); + } + // ========== 各种工具方法 ========== protected String formatAmount(Integer amount) { diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java index 4e5a37e9d..c990e7be6 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; import com.alipay.api.AlipayApiException; @@ -56,4 +57,5 @@ public class AlipayAppPayClient extends AbstractAlipayPayClient { return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), reqDTO.getOutTradeNo(), response); } + } diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java index 1f90d6b58..8bd341357 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java @@ -5,6 +5,7 @@ import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; import com.alipay.api.AlipayApiException; @@ -82,4 +83,5 @@ public class AlipayBarPayClient extends AbstractAlipayPayClient { return PayOrderRespDTO.waitingOf(displayMode, "", reqDTO.getOutTradeNo(), response); } + } diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java index 6dbd19bef..39cd78d54 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.http.Method; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; import com.alipay.api.AlipayApiException; @@ -66,4 +67,5 @@ public class AlipayPcPayClient extends AbstractAlipayPayClient { return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), reqDTO.getOutTradeNo(), response); } + } diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java index 1ad1ad713..34b1d5db6 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java @@ -57,6 +57,11 @@ public class MockPayClient extends AbstractPayClient { outRefundNo, MOCK_RESP_SUCCESS_DATA); } + @Override + protected PayTransferRespDTO doParseTransferNotify(Map params, String body) throws Throwable { + throw new UnsupportedOperationException("未实现"); + } + @Override protected PayRefundRespDTO doParseRefundNotify(Map params, String body) { throw new UnsupportedOperationException("模拟支付无退款回调"); diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java index ee6621eb6..7f4cc584a 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java @@ -14,6 +14,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.WxPayTransferPartnerNotifyV3Result; import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; @@ -23,6 +24,10 @@ import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; +import com.github.binarywang.wxpay.bean.transfer.QueryTransferBatchesRequest; +import com.github.binarywang.wxpay.bean.transfer.QueryTransferBatchesResult; +import com.github.binarywang.wxpay.bean.transfer.TransferBatchesRequest; +import com.github.binarywang.wxpay.bean.transfer.TransferBatchesResult; import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; @@ -31,6 +36,8 @@ import lombok.extern.slf4j.Slf4j; import java.time.LocalDateTime; import java.time.ZoneId; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Objects; @@ -349,6 +356,33 @@ public abstract class AbstractWxPayClient extends AbstractPayClient params, String body) throws WxPayException { + switch (config.getApiVersion()) { + case API_VERSION_V3: + return parseTransferNotifyV3(body); + case API_VERSION_V2: + throw new UnsupportedOperationException("V2 版本暂不支持,建议使用 V3 版本"); + default: + throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); + } + } + + private PayTransferRespDTO parseTransferNotifyV3(String body) throws WxPayException { + // 1. 解析回调 + // TODO @luchi:这个可以复用 wxjava 里的类么? + WxPayTransferPartnerNotifyV3Result response = client.baseParseOrderNotifyV3Result(body, null, WxPayTransferPartnerNotifyV3Result.class, WxPayTransferPartnerNotifyV3Result.TransferNotifyResult.class); + WxPayTransferPartnerNotifyV3Result.TransferNotifyResult result = response.getResult(); + // 2. 构建结果 + if (Objects.equals("FINISHED", result.getBatchStatus())) { + if (result.getFailNum() <= 0) { + return PayTransferRespDTO.successOf(result.getBatchId(), parseDateV3(result.getUpdateTime()), + result.getOutBatchNo(), response); + } + } + return PayTransferRespDTO.closedOf(result.getBatchStatus(), result.getCloseReason(), result.getOutBatchNo(), response); + } + @Override protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException { try { @@ -427,13 +461,54 @@ public abstract class AbstractWxPayClient extends AbstractPayClient transferDetailList = Collections.singletonList( + TransferBatchesRequest.TransferDetail.newBuilder() + .outDetailNo(reqDTO.getOutTransferNo()) + .transferAmount(reqDTO.getPrice()) + .transferRemark(reqDTO.getSubject()) + .openid(reqDTO.getOpenid()) + .build()); + // TODO @luchi:能不能我们搞个 TransferBatchesRequestX extends TransferBatchesRequest,这样更简洁一点。 + TransferBatchesRequest transferBatches = TransferBatchesRequest.newBuilder() + .appid(this.config.getAppId()) + .outBatchNo(reqDTO.getOutTransferNo()) + .batchName(reqDTO.getSubject()) + .batchRemark(reqDTO.getSubject()) + .totalAmount(reqDTO.getPrice()) + .totalNum(transferDetailList.size()) + .transferDetailList(transferDetailList).build() + .setNotifyUrl(reqDTO.getNotifyUrl()); + // 2.1 执行请求 + TransferBatchesResult transferBatchesResult = client.getTransferService().transferBatches(transferBatches); + // 2.2 创建返回结果 + return PayTransferRespDTO.dealingOf(transferBatchesResult.getBatchId(), reqDTO.getOutTransferNo(), transferBatchesResult); } @Override - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) { - throw new UnsupportedOperationException("待实现"); + protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) throws WxPayException { + QueryTransferBatchesRequest request = QueryTransferBatchesRequest.newBuilder() + .outBatchNo(outTradeNo).needQueryDetail(true).offset(0).limit(20).detailStatus("ALL") + .build(); + QueryTransferBatchesResult response = client.getTransferService().transferBatchesOutBatchNo(request); + QueryTransferBatchesResult.TransferBatch transferBatch = response.getTransferBatch(); + if (Objects.equals("FINISHED", transferBatch.getBatchStatus())) { + // 明细中全部成功则成功,任一失败则失败 + if (response.getTransferDetailList().stream().allMatch(detail -> Objects.equals("SUCCESS", detail.getDetailStatus()))) { + return PayTransferRespDTO.successOf(transferBatch.getBatchId(), parseDateV3(transferBatch.getUpdateTime()), + transferBatch.getOutBatchNo(), response); + } + if (response.getTransferDetailList().stream().anyMatch(detail -> Objects.equals("FAIL", detail.getDetailStatus()))) { + return PayTransferRespDTO.closedOf(transferBatch.getBatchStatus(), transferBatch.getCloseReason(), + transferBatch.getOutBatchNo(), response); + } + } + if (Objects.equals("CLOSED", transferBatch.getBatchStatus())) { + return PayTransferRespDTO.closedOf(transferBatch.getBatchStatus(), transferBatch.getCloseReason(), + transferBatch.getOutBatchNo(), response); + } + return PayTransferRespDTO.dealingOf(transferBatch.getBatchId(), transferBatch.getOutBatchNo(), response); } // ========== 各种工具方法 ========== diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java index 24f51bbb0..925fb45f0 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.framework.pay.core.enums.channel; import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; +import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; import lombok.AllArgsConstructor; diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesRequest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesRequest.java new file mode 100644 index 000000000..72296daa8 --- /dev/null +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/com/github/binarywang/wxpay/bean/transfer/TransferBatchesRequest.java @@ -0,0 +1,118 @@ +package com.github.binarywang.wxpay.bean.transfer; + +import com.github.binarywang.wxpay.v3.SpecEncrypt; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 发起商家转账API参数 + * + * @author zhongjun + * created on 2022/6/17 + **/ +@Data +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor +public class TransferBatchesRequest implements Serializable { + private static final long serialVersionUID = -2175582517588397426L; + + /** + * 直连商户的appid + */ + @SerializedName("appid") + private String appid; + + /** + * 商家批次单号 + */ + @SerializedName("out_batch_no") + private String outBatchNo; + + /** + * 批次名称 + */ + @SerializedName("batch_name") + private String batchName; + + /** + * 批次备注 + */ + @SerializedName("batch_remark") + private String batchRemark; + + /** + * 转账总金额 + */ + @SerializedName("total_amount") + private Integer totalAmount; + + /** + * 转账总笔数 + */ + @SerializedName("total_num") + private Integer totalNum; + + /** + * 转账明细列表 + */ + @SpecEncrypt + @SerializedName("transfer_detail_list") + private List transferDetailList; + + /** + * 转账场景ID + */ + @SerializedName("transfer_scene_id") + private String transferSceneId; + + /** + * 通知地址 说明:异步接收微信支付结果通知的回调地址,通知url必须为公网可访问的url,必须为https,不能携带参数。 + */ + @SerializedName("notify_url") + private String notifyUrl; + + @Data + @Builder(builderMethodName = "newBuilder") + @AllArgsConstructor + @NoArgsConstructor + public static class TransferDetail { + + /** + * 商家明细单号 + */ + @SerializedName("out_detail_no") + private String outDetailNo; + + /** + * 转账金额 + */ + @SerializedName("transfer_amount") + private Integer transferAmount; + + /** + * 转账备注 + */ + @SerializedName("transfer_remark") + private String transferRemark; + + /** + * 用户在直连商户应用下的用户标示 + */ + @SerializedName("openid") + private String openid; + + /** + * 收款用户姓名 + */ + @SpecEncrypt + @SerializedName("user_name") + private String userName; + } +} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 6fd198210..f2a8bf146 100644 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1 @@ -cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration +cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java index 525cb11c4..7dadb513b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java @@ -35,4 +35,7 @@ public class UserPageReqVO extends PageParam { @Schema(description = "部门编号,同时筛选子部门", example = "1024") private Long deptId; + @Schema(description = "角色编号", example = "1024") + private Long roleId; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index 75bf3fa47..c0c9be8e4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -25,13 +25,14 @@ public interface AdminUserMapper extends BaseMapperX { return selectOne(AdminUserDO::getMobile, mobile); } - default PageResult selectPage(UserPageReqVO reqVO, Collection deptIds) { + default PageResult selectPage(UserPageReqVO reqVO, Collection deptIds, Collection userIds) { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername()) .likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile()) .eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus()) .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime()) .inIfPresent(AdminUserDO::getDeptId, deptIds) + .inIfPresent(AdminUserDO::getId, userIds) .orderByDesc(AdminUserDO::getId)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index 9d96e941f..ef06d3c29 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -46,8 +46,7 @@ import java.time.LocalDateTime; import java.util.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*; @@ -272,7 +271,12 @@ public class AdminUserServiceImpl implements AdminUserService { @Override public PageResult getUserPage(UserPageReqVO reqVO) { - return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId())); + // 如果有角色编号,查询角色对应的用户编号 + Set userIds = reqVO.getRoleId() != null ? + permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId())) : null; + + // 分页查询 + return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds); } @Override @@ -349,7 +353,7 @@ public class AdminUserServiceImpl implements AdminUserService { } private AdminUserDO validateUserForCreateOrUpdate(Long id, String username, String mobile, String email, - Long deptId, Set postIds) { + Long deptId, Set postIds) { // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确 return DataPermissionUtils.executeIgnore(() -> { // 校验用户存在