Commit 3e4b1c0552fef432887ef20063be7c8eac2b0d45
Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product
Showing
18 changed files
with
290 additions
and
110 deletions
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java
| 1 | 1 | package cn.iocoder.yudao.framework.pay.core.client; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.pay.core.client.impl.delegate.DelegatePayClient; | |
| 3 | +import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; | |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * 支付客户端的工厂接口 |
| ... | ... | @@ -21,18 +21,8 @@ public interface PayClientFactory { |
| 21 | 21 | * 创建支付客户端 |
| 22 | 22 | * |
| 23 | 23 | * @param channelId 渠道编号 |
| 24 | - * @param channelCode 渠道编码 | |
| 25 | - * @param config 支付配置 | |
| 26 | - */ | |
| 27 | - <Config extends PayClientConfig> void createOrUpdatePayClient(Long channelId, String channelCode, | |
| 28 | - Config config); | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * 新增或更新代理支付客户端 | |
| 32 | - * @param channelId 渠道编号 | |
| 33 | - * @param delegatePayClient 代理支付客户端 | |
| 24 | + * @param client 支付客户端 | |
| 34 | 25 | * @param <Config> 支付配置 |
| 35 | 26 | */ |
| 36 | - <Config extends PayClientConfig> void addOrUpdateDelegatePayClient(Long channelId, DelegatePayClient<Config> delegatePayClient); | |
| 37 | - | |
| 27 | + <Config extends PayClientConfig> void addOrUpdatePayClient(Long channelId, AbstractPayClient<Config> client); | |
| 38 | 28 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java
| ... | ... | @@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDT |
| 9 | 9 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; |
| 10 | 10 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; |
| 11 | 11 | import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; |
| 12 | +import lombok.Getter; | |
| 12 | 13 | import lombok.extern.slf4j.Slf4j; |
| 13 | 14 | |
| 14 | 15 | import java.util.Map; |
| ... | ... | @@ -35,6 +36,7 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 35 | 36 | /** |
| 36 | 37 | * 支付配置 |
| 37 | 38 | */ |
| 39 | + @Getter | |
| 38 | 40 | protected Config config; |
| 39 | 41 | |
| 40 | 42 | public AbstractPayClient(Long channelId, String channelCode, Config config) { | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java
| 1 | 1 | package cn.iocoder.yudao.framework.pay.core.client.impl; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.lang.Assert; | |
| 4 | 3 | import cn.iocoder.yudao.framework.pay.core.client.PayClient; |
| 5 | 4 | import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; |
| 6 | 5 | import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; |
| 7 | -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.*; | |
| 8 | -import cn.iocoder.yudao.framework.pay.core.client.impl.delegate.DelegatePayClient; | |
| 9 | -import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClient; | |
| 10 | -import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClientConfig; | |
| 11 | -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.*; | |
| 12 | -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; | |
| 13 | 6 | import lombok.extern.slf4j.Slf4j; |
| 14 | 7 | |
| 15 | 8 | import java.util.concurrent.ConcurrentHashMap; |
| ... | ... | @@ -40,48 +33,12 @@ public class PayClientFactoryImpl implements PayClientFactory { |
| 40 | 33 | |
| 41 | 34 | @Override |
| 42 | 35 | @SuppressWarnings("unchecked") |
| 43 | - public <Config extends PayClientConfig> void createOrUpdatePayClient(Long channelId, String channelCode, | |
| 44 | - Config config) { | |
| 45 | - AbstractPayClient<Config> client = (AbstractPayClient<Config>) clients.get(channelId); | |
| 46 | - if (client == null) { | |
| 47 | - client = this.createPayClient(channelId, channelCode, config); | |
| 36 | + public <Config extends PayClientConfig> void addOrUpdatePayClient(Long channelId, AbstractPayClient<Config> client) { | |
| 37 | + AbstractPayClient<Config> prePayClient = (AbstractPayClient<Config>) clients.putIfAbsent(channelId, client); | |
| 38 | + if (prePayClient == null) { | |
| 48 | 39 | client.init(); |
| 49 | - clients.put(client.getId(), client); | |
| 50 | 40 | } else { |
| 51 | - client.refresh(config); | |
| 41 | + prePayClient.refresh(client.getConfig()); | |
| 52 | 42 | } |
| 53 | 43 | } |
| 54 | - | |
| 55 | - @Override | |
| 56 | - public <Config extends PayClientConfig> void addOrUpdateDelegatePayClient(Long channelId, DelegatePayClient<Config> delegatePayClient) { | |
| 57 | - clients.put(channelId, delegatePayClient); | |
| 58 | - } | |
| 59 | - | |
| 60 | - @SuppressWarnings("unchecked") | |
| 61 | - private <Config extends PayClientConfig> AbstractPayClient<Config> createPayClient( | |
| 62 | - Long channelId, String channelCode, Config config) { | |
| 63 | - PayChannelEnum channelEnum = PayChannelEnum.getByCode(channelCode); | |
| 64 | - Assert.notNull(channelEnum, String.format("支付渠道(%s) 为空", channelEnum)); | |
| 65 | - // 创建客户端 | |
| 66 | - switch (channelEnum) { | |
| 67 | - // 微信支付 | |
| 68 | - case WX_PUB: return (AbstractPayClient<Config>) new WxPubPayClient(channelId, (WxPayClientConfig) config); | |
| 69 | - case WX_LITE: return (AbstractPayClient<Config>) new WxLitePayClient(channelId, (WxPayClientConfig) config); | |
| 70 | - case WX_APP: return (AbstractPayClient<Config>) new WxAppPayClient(channelId, (WxPayClientConfig) config); | |
| 71 | - case WX_BAR: return (AbstractPayClient<Config>) new WxBarPayClient(channelId, (WxPayClientConfig) config); | |
| 72 | - case WX_NATIVE: return (AbstractPayClient<Config>) new WxNativePayClient(channelId, (WxPayClientConfig) config); | |
| 73 | - // 支付宝支付 | |
| 74 | - case ALIPAY_WAP: return (AbstractPayClient<Config>) new AlipayWapPayClient(channelId, (AlipayPayClientConfig) config); | |
| 75 | - case ALIPAY_QR: return (AbstractPayClient<Config>) new AlipayQrPayClient(channelId, (AlipayPayClientConfig) config); | |
| 76 | - case ALIPAY_APP: return (AbstractPayClient<Config>) new AlipayAppPayClient(channelId, (AlipayPayClientConfig) config); | |
| 77 | - case ALIPAY_PC: return (AbstractPayClient<Config>) new AlipayPcPayClient(channelId, (AlipayPayClientConfig) config); | |
| 78 | - case ALIPAY_BAR: return (AbstractPayClient<Config>) new AlipayBarPayClient(channelId, (AlipayPayClientConfig) config); | |
| 79 | - // 其它支付 | |
| 80 | - case MOCK: return (AbstractPayClient<Config>) new MockPayClient(channelId, (MockPayClientConfig) config); | |
| 81 | - } | |
| 82 | - // 创建失败,错误日志 + 抛出异常 | |
| 83 | - log.error("[createPayClient][配置({}) 找不到合适的客户端实现]", config); | |
| 84 | - throw new IllegalArgumentException(String.format("配置(%s) 找不到合适的客户端实现", config)); | |
| 85 | - } | |
| 86 | - | |
| 87 | 44 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java
| ... | ... | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient; |
| 9 | 9 | import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient; |
| 10 | 10 | import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; |
| 11 | 11 | import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPubPayClient; |
| 12 | -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; | |
| 13 | 12 | import org.junit.jupiter.api.Disabled; |
| 14 | 13 | import org.junit.jupiter.api.Test; |
| 15 | 14 | |
| ... | ... | @@ -41,7 +40,8 @@ public class PayClientFactoryImplIntegrationTest { |
| 41 | 40 | config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); |
| 42 | 41 | // 创建客户端 |
| 43 | 42 | Long channelId = RandomUtil.randomLong(); |
| 44 | - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); | |
| 43 | + | |
| 44 | + payClientFactory.addOrUpdatePayClient(channelId, new WxPubPayClient(channelId, config)); | |
| 45 | 45 | PayClient client = payClientFactory.getPayClient(channelId); |
| 46 | 46 | // 发起支付 |
| 47 | 47 | PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); |
| ... | ... | @@ -64,7 +64,7 @@ public class PayClientFactoryImplIntegrationTest { |
| 64 | 64 | config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); |
| 65 | 65 | // 创建客户端 |
| 66 | 66 | Long channelId = RandomUtil.randomLong(); |
| 67 | - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); | |
| 67 | + payClientFactory.addOrUpdatePayClient(channelId, new WxPubPayClient(channelId, config)); | |
| 68 | 68 | PayClient client = payClientFactory.getPayClient(channelId); |
| 69 | 69 | // 发起支付 |
| 70 | 70 | PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); |
| ... | ... | @@ -87,7 +87,7 @@ public class PayClientFactoryImplIntegrationTest { |
| 87 | 87 | config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); |
| 88 | 88 | // 创建客户端 |
| 89 | 89 | Long channelId = RandomUtil.randomLong(); |
| 90 | - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); | |
| 90 | + payClientFactory.addOrUpdatePayClient(channelId, new AlipayQrPayClient(channelId, config)); | |
| 91 | 91 | PayClient client = payClientFactory.getPayClient(channelId); |
| 92 | 92 | // 发起支付 |
| 93 | 93 | PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); |
| ... | ... | @@ -111,7 +111,7 @@ public class PayClientFactoryImplIntegrationTest { |
| 111 | 111 | config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); |
| 112 | 112 | // 创建客户端 |
| 113 | 113 | Long channelId = RandomUtil.randomLong(); |
| 114 | - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); | |
| 114 | + payClientFactory.addOrUpdatePayClient(channelId, new AlipayWapPayClient(channelId, config)); | |
| 115 | 115 | PayClient client = payClientFactory.getPayClient(channelId); |
| 116 | 116 | // 发起支付 |
| 117 | 117 | PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
| ... | ... | @@ -32,6 +32,7 @@ public interface ErrorCodeConstants { |
| 32 | 32 | ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1011000021, "交易订单发货失败,订单已退款或部分退款"); |
| 33 | 33 | ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000022, "交易订单发货失败,拼团未成功"); |
| 34 | 34 | ErrorCode ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000023, "交易订单发货失败,砍价未成功"); |
| 35 | + ErrorCode ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS = new ErrorCode(1011000024, "交易订单发货失败,发货类型不是快递"); | |
| 35 | 36 | |
| 36 | 37 | // ========== After Sale 模块 1011000100 ========== |
| 37 | 38 | ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在"); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
| ... | ... | @@ -7,13 +7,15 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | 7 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 8 | 8 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 9 | 9 | import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; |
| 10 | -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO; | |
| 11 | -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSalePageReqVO; | |
| 12 | -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRefuseReqVO; | |
| 13 | -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRespPageItemVO; | |
| 10 | +import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.*; | |
| 14 | 11 | import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert; |
| 15 | 12 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; |
| 13 | +import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; | |
| 14 | +import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | |
| 15 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogRespDTO; | |
| 16 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService; | |
| 16 | 17 | import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService; |
| 18 | +import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; | |
| 17 | 19 | import io.swagger.v3.oas.annotations.Operation; |
| 18 | 20 | import io.swagger.v3.oas.annotations.Parameter; |
| 19 | 21 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.*; |
| 25 | 27 | import javax.annotation.Resource; |
| 26 | 28 | import javax.annotation.security.PermitAll; |
| 27 | 29 | import javax.validation.Valid; |
| 30 | +import java.util.List; | |
| 28 | 31 | import java.util.Map; |
| 29 | 32 | |
| 30 | 33 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -41,7 +44,10 @@ public class TradeAfterSaleController { |
| 41 | 44 | |
| 42 | 45 | @Resource |
| 43 | 46 | private TradeAfterSaleService afterSaleService; |
| 44 | - | |
| 47 | + @Resource | |
| 48 | + private TradeOrderQueryService tradeOrderQueryService; | |
| 49 | + @Resource | |
| 50 | + private AfterSaleLogService afterSaleLogService; | |
| 45 | 51 | @Resource |
| 46 | 52 | private MemberUserApi memberUserApi; |
| 47 | 53 | |
| ... | ... | @@ -61,6 +67,24 @@ public class TradeAfterSaleController { |
| 61 | 67 | return success(TradeAfterSaleConvert.INSTANCE.convertPage(pageResult, memberUsers)); |
| 62 | 68 | } |
| 63 | 69 | |
| 70 | + @GetMapping("/get-detail") | |
| 71 | + @Operation(summary = "获得售后订单详情") | |
| 72 | + @Parameter(name = "id", description = "售后编号", required = true, example = "1") | |
| 73 | + @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") | |
| 74 | + public CommonResult<TradeAfterSaleDetailRespVO> getOrderDetail(@RequestParam("id") Long id) { | |
| 75 | + // 查询订单 | |
| 76 | + TradeAfterSaleDO afterSale = afterSaleService.getAfterSale(id); | |
| 77 | + // 查询订单 | |
| 78 | + TradeOrderDO order = tradeOrderQueryService.getOrder(afterSale.getOrderId()); | |
| 79 | + // 查询订单项 | |
| 80 | + List<TradeOrderItemDO> orderItems = tradeOrderQueryService.getOrderItemListByOrderId(id); | |
| 81 | + // 拼接数据 | |
| 82 | + MemberUserRespDTO user = memberUserApi.getUser(afterSale.getUserId()); | |
| 83 | + // 获取售后日志 | |
| 84 | + List<TradeAfterSaleLogRespDTO> logs = afterSaleLogService.getLog(afterSale.getId()); | |
| 85 | + return success(TradeAfterSaleConvert.INSTANCE.convert(afterSale, order, orderItems, user, logs)); | |
| 86 | + } | |
| 87 | + | |
| 64 | 88 | @PutMapping("/agree") |
| 65 | 89 | @Operation(summary = "同意售后") |
| 66 | 90 | @Parameter(name = "id", description = "售后编号", required = true, example = "1") |
| ... | ... | @@ -88,7 +112,7 @@ public class TradeAfterSaleController { |
| 88 | 112 | } |
| 89 | 113 | |
| 90 | 114 | @PutMapping("/refuse") |
| 91 | - @Operation(summary = "确认收货") | |
| 115 | + @Operation(summary = "拒绝收货") | |
| 92 | 116 | @Parameter(name = "id", description = "售后编号", required = true, example = "1") |
| 93 | 117 | @PreAuthorize("@ss.hasPermission('trade:after-sale:receive')") |
| 94 | 118 | public CommonResult<Boolean> refuseAfterSale(TradeAfterSaleRefuseReqVO refuseReqVO) { | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleDetailRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.TradeAfterSaleLogRespVO; | |
| 4 | +import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; | |
| 5 | +import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; | |
| 6 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO; | |
| 7 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderItemBaseVO; | |
| 8 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 9 | +import lombok.Data; | |
| 10 | + | |
| 11 | +import javax.validation.constraints.NotNull; | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - 售后订单的详情 Response VO") | |
| 15 | +@Data | |
| 16 | +public class TradeAfterSaleDetailRespVO extends TradeAfterSaleBaseVO { | |
| 17 | + | |
| 18 | + @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 19 | + @NotNull(message = "售后编号不能为空") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 订单项列表 | |
| 24 | + */ | |
| 25 | + private List<Item> items; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 订单基本信息 | |
| 29 | + */ | |
| 30 | + private TradeOrderBaseVO order; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 用户信息 | |
| 34 | + */ | |
| 35 | + private MemberUserRespVO user; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 售后日志 | |
| 39 | + */ | |
| 40 | + private List<TradeAfterSaleLogRespVO> afterSaleLog; | |
| 41 | + | |
| 42 | + @Schema(description = "管理后台 - 交易订单的详情的订单项目") | |
| 43 | + @Data | |
| 44 | + public static class Item extends TradeOrderItemBaseVO { | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 属性数组 | |
| 48 | + */ | |
| 49 | + private List<ProductPropertyValueDetailRespVO> properties; | |
| 50 | + | |
| 51 | + } | |
| 52 | + | |
| 53 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java
| ... | ... | @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.trade.controller.admin.delivery; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 7 | +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | |
| 6 | 8 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; |
| 7 | 9 | import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; |
| 8 | 10 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| ... | ... | @@ -64,10 +66,13 @@ public class DeliveryPickUpStoreController { |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | 68 | @GetMapping("/list-all-simple") |
| 67 | - @Operation(summary = "获取快递公司精简信息列表") | |
| 69 | + @Operation(summary = "获得自提门店精简信息列表") | |
| 68 | 70 | public CommonResult<List<DeliveryPickUpStoreSimpleRespVO>> getSimpleDeliveryPickUpStoreList() { |
| 69 | 71 | List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 70 | - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); | |
| 72 | + return success(CollectionUtils.convertList(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list), item -> { | |
| 73 | + item.setAreaName(AreaUtils.format(item.getAreaId())); | |
| 74 | + return item; | |
| 75 | + })); | |
| 71 | 76 | } |
| 72 | 77 | |
| 73 | 78 | @GetMapping("/list") | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java
| ... | ... | @@ -23,7 +23,8 @@ public class DeliveryPickUpStoreSimpleRespVO { |
| 23 | 23 | @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") |
| 24 | 24 | private Integer areaId; |
| 25 | 25 | |
| 26 | - // TODO @puhui999:要把 areaName 也返回哈 | |
| 26 | + @Schema(description = "区域名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx市") | |
| 27 | + private String areaName; | |
| 27 | 28 | |
| 28 | 29 | @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") |
| 29 | 30 | private String detailAddress; | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java
| ... | ... | @@ -85,8 +85,7 @@ public class TradeOrderController { |
| 85 | 85 | tradeOrderQueryService.getExpressTrackList(id, getLoginUserId()))); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - // TODO @puhui999:put 请求哈 | |
| 89 | - @PostMapping("/delivery") | |
| 88 | + @PutMapping("/delivery") | |
| 90 | 89 | @Operation(summary = "订单发货") |
| 91 | 90 | @PreAuthorize("@ss.hasPermission('trade:order:update')") |
| 92 | 91 | public CommonResult<Boolean> deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) { |
| ... | ... | @@ -94,8 +93,7 @@ public class TradeOrderController { |
| 94 | 93 | return success(true); |
| 95 | 94 | } |
| 96 | 95 | |
| 97 | - // TODO @puhui999:put 请求哈,update-remark; | |
| 98 | - @PostMapping("/remark") | |
| 96 | + @PutMapping("/update-remark") | |
| 99 | 97 | @Operation(summary = "订单备注") |
| 100 | 98 | @PreAuthorize("@ss.hasPermission('trade:order:update')") |
| 101 | 99 | public CommonResult<Boolean> updateOrderRemark(@RequestBody TradeOrderRemarkReqVO reqVO) { |
| ... | ... | @@ -103,8 +101,7 @@ public class TradeOrderController { |
| 103 | 101 | return success(true); |
| 104 | 102 | } |
| 105 | 103 | |
| 106 | - // TODO @puhui999:put 请求哈,update-price; | |
| 107 | - @PostMapping("/adjust-price") | |
| 104 | + @PutMapping("/update-price") | |
| 108 | 105 | @Operation(summary = "订单调价") |
| 109 | 106 | @PreAuthorize("@ss.hasPermission('trade:order:update')") |
| 110 | 107 | public CommonResult<Boolean> updateOrderPrice(@RequestBody TradeOrderUpdatePriceReqVO reqVO) { |
| ... | ... | @@ -112,8 +109,7 @@ public class TradeOrderController { |
| 112 | 109 | return success(true); |
| 113 | 110 | } |
| 114 | 111 | |
| 115 | - // TODO @puhui999:put 请求哈,update-address; | |
| 116 | - @PostMapping("/adjust-address") | |
| 112 | + @PutMapping("/update-address") | |
| 117 | 113 | @Operation(summary = "修改订单收货地址") |
| 118 | 114 | @PreAuthorize("@ss.hasPermission('trade:order:update')") |
| 119 | 115 | public CommonResult<Boolean> updateOrderAddress(@RequestBody TradeOrderUpdateAddressReqVO reqVO) { | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java
| ... | ... | @@ -4,19 +4,26 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 5 | 5 | import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; |
| 6 | 6 | import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; |
| 7 | +import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDetailRespVO; | |
| 7 | 8 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRespPageItemVO; |
| 9 | +import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.TradeAfterSaleLogRespVO; | |
| 8 | 10 | import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; |
| 9 | 11 | import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; |
| 12 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO; | |
| 10 | 13 | import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; |
| 11 | 14 | import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleRespVO; |
| 12 | 15 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; |
| 16 | +import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleLogDO; | |
| 17 | +import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; | |
| 13 | 18 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| 19 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogRespDTO; | |
| 14 | 20 | import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; |
| 15 | 21 | import org.mapstruct.Mapper; |
| 16 | 22 | import org.mapstruct.Mapping; |
| 17 | 23 | import org.mapstruct.Mappings; |
| 18 | 24 | import org.mapstruct.factory.Mappers; |
| 19 | 25 | |
| 26 | +import java.util.List; | |
| 20 | 27 | import java.util.Map; |
| 21 | 28 | |
| 22 | 29 | @Mapper |
| ... | ... | @@ -61,4 +68,22 @@ public interface TradeAfterSaleConvert { |
| 61 | 68 | |
| 62 | 69 | PageResult<AppTradeAfterSaleRespVO> convertPage02(PageResult<TradeAfterSaleDO> page); |
| 63 | 70 | |
| 71 | + List<TradeAfterSaleLogRespDTO> convertList(List<TradeAfterSaleLogDO> list); | |
| 72 | + | |
| 73 | + List<TradeAfterSaleLogRespVO> convertList1(List<TradeAfterSaleLogRespDTO> list); | |
| 74 | + | |
| 75 | + TradeOrderBaseVO convert(TradeOrderDO order); | |
| 76 | + | |
| 77 | + @Mapping(target = "id", source = "afterSale.id") | |
| 78 | + TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, List<TradeOrderItemDO> orderItems, List<TradeAfterSaleLogRespVO> logs); | |
| 79 | + | |
| 80 | + default TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, TradeOrderDO order, List<TradeOrderItemDO> orderItems, | |
| 81 | + MemberUserRespDTO user, List<TradeAfterSaleLogRespDTO> logs) { | |
| 82 | + TradeAfterSaleDetailRespVO respVO = convert(afterSale, orderItems, convertList1(logs)); | |
| 83 | + // 处理用户信息 | |
| 84 | + respVO.setUser(convert(user)); | |
| 85 | + // 处理订单信息 | |
| 86 | + respVO.setOrder(convert(order)); | |
| 87 | + return respVO; | |
| 88 | + } | |
| 64 | 89 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/dto/TradeAfterSaleLogRespDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.NoArgsConstructor; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 贸易售后日志详情 DTO | |
| 13 | + * | |
| 14 | + * @author HUIHUI | |
| 15 | + */ | |
| 16 | +@Data | |
| 17 | +@NoArgsConstructor | |
| 18 | +@AllArgsConstructor | |
| 19 | +public class TradeAfterSaleLogRespDTO { | |
| 20 | + | |
| 21 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20669") | |
| 22 | + private Long id; | |
| 23 | + | |
| 24 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22634") | |
| 25 | + @NotNull(message = "用户编号不能为空") | |
| 26 | + private Long userId; | |
| 27 | + | |
| 28 | + @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 29 | + @NotNull(message = "用户类型不能为空") | |
| 30 | + private Integer userType; | |
| 31 | + | |
| 32 | + @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3023") | |
| 33 | + @NotNull(message = "售后编号不能为空") | |
| 34 | + private Long afterSaleId; | |
| 35 | + | |
| 36 | + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25870") | |
| 37 | + @NotNull(message = "订单编号不能为空") | |
| 38 | + private Long orderId; | |
| 39 | + | |
| 40 | + @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23154") | |
| 41 | + @NotNull(message = "订单项编号不能为空") | |
| 42 | + private Long orderItemId; | |
| 43 | + | |
| 44 | + @Schema(description = "售后状态(之前)", example = "2") | |
| 45 | + private Integer beforeStatus; | |
| 46 | + | |
| 47 | + @Schema(description = "售后状态(之后)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 48 | + @NotNull(message = "售后状态(之后)不能为空") | |
| 49 | + private Integer afterStatus; | |
| 50 | + | |
| 51 | + @Schema(description = "操作明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "维权完成,退款金额:¥37776.00") | |
| 52 | + @NotNull(message = "操作明细不能为空") | |
| 53 | + private String content; | |
| 54 | + | |
| 55 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 56 | + private LocalDateTime createTime; | |
| 57 | + | |
| 58 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/service/AfterSaleLogService.java
| ... | ... | @@ -2,6 +2,9 @@ package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO; |
| 5 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogRespDTO; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 5 | 8 | |
| 6 | 9 | /** |
| 7 | 10 | * 交易售后日志 Service 接口 |
| ... | ... | @@ -20,4 +23,12 @@ public interface AfterSaleLogService { |
| 20 | 23 | */ |
| 21 | 24 | void createLog(TradeAfterSaleLogCreateReqDTO logDTO); |
| 22 | 25 | |
| 26 | + /** | |
| 27 | + * 获取售后日志 | |
| 28 | + * | |
| 29 | + * @param afterSaleId 售后 id | |
| 30 | + * @return 售后日志 | |
| 31 | + */ | |
| 32 | + List<TradeAfterSaleLogRespDTO> getLog(Long afterSaleId); | |
| 33 | + | |
| 23 | 34 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleService.java
| ... | ... | @@ -43,6 +43,14 @@ public interface TradeAfterSaleService { |
| 43 | 43 | TradeAfterSaleDO getAfterSale(Long userId, Long id); |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | + * 【管理员】获得售后单 | |
| 47 | + * | |
| 48 | + * @param id 售后编号 | |
| 49 | + * @return 售后订单 | |
| 50 | + */ | |
| 51 | + TradeAfterSaleDO getAfterSale(Long id); | |
| 52 | + | |
| 53 | + /** | |
| 46 | 54 | * 【会员】创建售后订单 |
| 47 | 55 | * |
| 48 | 56 | * @param userId 会员用户编号 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java
| ... | ... | @@ -26,6 +26,7 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; |
| 26 | 26 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; |
| 27 | 27 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; |
| 28 | 28 | import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO; |
| 29 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogRespDTO; | |
| 29 | 30 | import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService; |
| 30 | 31 | import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; |
| 31 | 32 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; |
| ... | ... | @@ -40,6 +41,7 @@ import org.springframework.validation.annotation.Validated; |
| 40 | 41 | |
| 41 | 42 | import javax.annotation.Resource; |
| 42 | 43 | import java.time.LocalDateTime; |
| 44 | +import java.util.List; | |
| 43 | 45 | |
| 44 | 46 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 45 | 47 | import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; |
| ... | ... | @@ -87,6 +89,15 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa |
| 87 | 89 | } |
| 88 | 90 | |
| 89 | 91 | @Override |
| 92 | + public TradeAfterSaleDO getAfterSale(Long id) { | |
| 93 | + TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); | |
| 94 | + if (afterSale == null) { | |
| 95 | + throw exception(AFTER_SALE_NOT_FOUND); | |
| 96 | + } | |
| 97 | + return afterSale; | |
| 98 | + } | |
| 99 | + | |
| 100 | + @Override | |
| 90 | 101 | @Transactional(rollbackFor = Exception.class) |
| 91 | 102 | public Long createAfterSale(Long userId, AppTradeAfterSaleCreateReqVO createReqVO) { |
| 92 | 103 | // 第一步,前置校验 |
| ... | ... | @@ -439,4 +450,11 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa |
| 439 | 450 | log.error("[createLog][request({}) 日志记录错误]", toJsonString(logDTO), exception); |
| 440 | 451 | } |
| 441 | 452 | } |
| 453 | + | |
| 454 | + @Override | |
| 455 | + public List<TradeAfterSaleLogRespDTO> getLog(Long afterSaleId) { | |
| 456 | + // TODO 不熟悉流程先这么滴 | |
| 457 | + List<TradeAfterSaleLogDO> saleLogDOs = tradeAfterSaleLogMapper.selectList(TradeAfterSaleLogDO::getAfterSaleId, afterSaleId); | |
| 458 | + return TradeAfterSaleConvert.INSTANCE.convertList(saleLogDOs); | |
| 459 | + } | |
| 442 | 460 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| ... | ... | @@ -414,7 +414,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 414 | 414 | // TODO @puhui999:只有选择快递的,才可以发货 |
| 415 | 415 | // 1.1 校验并获得交易订单(可发货) |
| 416 | 416 | TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); |
| 417 | - | |
| 417 | + // 校验 deliveryType 是否为快递,是快递才可以发货 | |
| 418 | + if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getMode())) { | |
| 419 | + throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS); | |
| 420 | + } | |
| 418 | 421 | // TODO @puhui999:下面不修改 deliveryType,直接校验 deliveryType 是否为快递,是快递才可以发货;先做严格的方式哈。 |
| 419 | 422 | // 判断发货类型 |
| 420 | 423 | TradeOrderDO updateOrderObj = new TradeOrderDO(); |
| ... | ... | @@ -428,10 +431,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 428 | 431 | if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { |
| 429 | 432 | throw exception(EXPRESS_STATUS_NOT_ENABLE); |
| 430 | 433 | } |
| 431 | - updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode()); | |
| 434 | + updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); | |
| 432 | 435 | } else { |
| 433 | 436 | // 2.2 无需发货 |
| 434 | - updateOrderObj.setLogisticsId(0L).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode()); | |
| 437 | + updateOrderObj.setLogisticsId(0L).setLogisticsNo(""); | |
| 435 | 438 | } |
| 436 | 439 | // 更新 TradeOrderDO 状态为已发货,等待收货 |
| 437 | 440 | updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now()); |
| ... | ... | @@ -471,16 +474,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 471 | 474 | // 订单类型:拼团 |
| 472 | 475 | if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { |
| 473 | 476 | // 校验订单拼团是否成功 |
| 474 | - // TODO @puhui999:是不是取反? | |
| 475 | - if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { | |
| 477 | + if (!combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { | |
| 476 | 478 | throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); |
| 477 | 479 | } |
| 478 | 480 | } |
| 479 | 481 | // 订单类类型:砍价 |
| 480 | 482 | if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) { |
| 481 | 483 | // 校验订单砍价是否成功 |
| 482 | - // TODO @puhui999:是不是取反? | |
| 483 | - if (bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) { | |
| 484 | + if (!bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) { | |
| 484 | 485 | throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS); |
| 485 | 486 | } |
| 486 | 487 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/wallet/WalletPayClient.java
| ... | ... | @@ -5,8 +5,8 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; |
| 5 | 5 | import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; |
| 6 | 6 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; |
| 7 | 7 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; |
| 8 | +import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; | |
| 8 | 9 | import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; |
| 9 | -import cn.iocoder.yudao.framework.pay.core.client.impl.delegate.DelegatePayClient; | |
| 10 | 10 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 11 | 11 | import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; |
| 12 | 12 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -21,7 +21,7 @@ import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeC |
| 21 | 21 | * @author jason |
| 22 | 22 | */ |
| 23 | 23 | @Slf4j |
| 24 | -public class WalletPayClient extends DelegatePayClient<NonePayClientConfig> { | |
| 24 | +public class WalletPayClient extends AbstractPayClient<NonePayClientConfig> { | |
| 25 | 25 | |
| 26 | 26 | private PayWalletService payWalletService; |
| 27 | 27 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java
| ... | ... | @@ -6,9 +6,14 @@ import cn.hutool.core.util.ObjectUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 9 | -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; | |
| 10 | 9 | import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; |
| 11 | 10 | import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; |
| 11 | +import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; | |
| 12 | +import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; | |
| 13 | +import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.*; | |
| 14 | +import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClient; | |
| 15 | +import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClientConfig; | |
| 16 | +import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.*; | |
| 12 | 17 | import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; |
| 13 | 18 | import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; |
| 14 | 19 | import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; |
| ... | ... | @@ -29,7 +34,6 @@ import javax.annotation.PostConstruct; |
| 29 | 34 | import javax.annotation.Resource; |
| 30 | 35 | import javax.validation.Validator; |
| 31 | 36 | import java.time.LocalDateTime; |
| 32 | -import java.util.ArrayList; | |
| 33 | 37 | import java.util.Collection; |
| 34 | 38 | import java.util.Collections; |
| 35 | 39 | import java.util.List; |
| ... | ... | @@ -81,29 +85,55 @@ public class PayChannelServiceImpl implements PayChannelService { |
| 81 | 85 | log.error("[支付模块 yudao-module-pay - 表结构未导入][参考 https://doc.iocoder.cn/pay/build/ 开启]"); |
| 82 | 86 | } |
| 83 | 87 | log.info("[initLocalCache][缓存支付渠道,数量为:{}]", channels.size()); |
| 84 | - // 钱包 client 需要和其它 client 分开了创建 | |
| 85 | - List<PayChannelDO> walletChannels = new ArrayList<>(); | |
| 86 | - // TODO @jason:有点复杂,看看用 PayClientInitializer 能不能简化 | |
| 87 | - List<PayChannelDO> otherChannels = new ArrayList<>(); | |
| 88 | - channels.forEach(t -> { | |
| 89 | - if (PayChannelEnum.WALLET.getCode().equals(t.getCode())) { | |
| 90 | - walletChannels.add(t); | |
| 91 | - } else { | |
| 92 | - otherChannels.add(t); | |
| 93 | - } | |
| 94 | - }); | |
| 95 | 88 | // 第二步:构建缓存:创建或更新支付 Client |
| 96 | - otherChannels.forEach(payChannel -> payClientFactory.createOrUpdatePayClient(payChannel.getId(), | |
| 97 | - payChannel.getCode(), payChannel.getConfig())); | |
| 89 | + channels.forEach(payChannel ->{ | |
| 90 | + AbstractPayClient<PayClientConfig> payClient = createPayClient(payChannel.getId(), payChannel.getCode(), payChannel.getConfig()); | |
| 91 | + payClientFactory.addOrUpdatePayClient(payChannel.getId(), payClient); | |
| 98 | 92 | |
| 99 | - walletChannels.forEach(payChannel -> { | |
| 100 | - WalletPayClient walletPayClient = new WalletPayClient(payChannel.getId(), payChannel.getCode(), | |
| 101 | - (NonePayClientConfig) payChannel.getConfig(), payWalletService); | |
| 102 | - payClientFactory.addOrUpdateDelegatePayClient(payChannel.getId(), walletPayClient); | |
| 103 | 93 | }); |
| 104 | 94 | this.channelCache = channels; |
| 105 | 95 | }); |
| 106 | 96 | } |
| 97 | + @SuppressWarnings("unchecked") | |
| 98 | + private <Config extends PayClientConfig> AbstractPayClient<Config> createPayClient( | |
| 99 | + Long channelId, String channelCode, Config config) { | |
| 100 | + PayChannelEnum channelEnum = PayChannelEnum.getByCode(channelCode); | |
| 101 | + Assert.notNull(channelEnum, String.format("支付渠道(%s) 为空", channelEnum)); | |
| 102 | + // 创建客户端 | |
| 103 | + switch (channelEnum) { | |
| 104 | + // 微信支付 | |
| 105 | + case WX_PUB: | |
| 106 | + return (AbstractPayClient<Config>) new WxPubPayClient(channelId, (WxPayClientConfig) config); | |
| 107 | + case WX_LITE: | |
| 108 | + return (AbstractPayClient<Config>) new WxLitePayClient(channelId, (WxPayClientConfig) config); | |
| 109 | + case WX_APP: | |
| 110 | + return (AbstractPayClient<Config>) new WxAppPayClient(channelId, (WxPayClientConfig) config); | |
| 111 | + case WX_BAR: | |
| 112 | + return (AbstractPayClient<Config>) new WxBarPayClient(channelId, (WxPayClientConfig) config); | |
| 113 | + case WX_NATIVE: | |
| 114 | + return (AbstractPayClient<Config>) new WxNativePayClient(channelId, (WxPayClientConfig) config); | |
| 115 | + // 支付宝支付 | |
| 116 | + case ALIPAY_WAP: | |
| 117 | + return (AbstractPayClient<Config>) new AlipayWapPayClient(channelId, (AlipayPayClientConfig) config); | |
| 118 | + case ALIPAY_QR: | |
| 119 | + return (AbstractPayClient<Config>) new AlipayQrPayClient(channelId, (AlipayPayClientConfig) config); | |
| 120 | + case ALIPAY_APP: | |
| 121 | + return (AbstractPayClient<Config>) new AlipayAppPayClient(channelId, (AlipayPayClientConfig) config); | |
| 122 | + case ALIPAY_PC: | |
| 123 | + return (AbstractPayClient<Config>) new AlipayPcPayClient(channelId, (AlipayPayClientConfig) config); | |
| 124 | + case ALIPAY_BAR: | |
| 125 | + return (AbstractPayClient<Config>) new AlipayBarPayClient(channelId, (AlipayPayClientConfig) config); | |
| 126 | + // 其它支付 | |
| 127 | + case MOCK: | |
| 128 | + return (AbstractPayClient<Config>) new MockPayClient(channelId, (MockPayClientConfig) config); | |
| 129 | + case WALLET: | |
| 130 | + return (AbstractPayClient<Config>) new WalletPayClient( | |
| 131 | + channelId, channelCode, (NonePayClientConfig) config, payWalletService); | |
| 132 | + } | |
| 133 | + // 创建失败,错误日志 + 抛出异常 | |
| 134 | + log.error("[createPayClient][配置({}) 找不到合适的客户端实现]", config); | |
| 135 | + throw new IllegalArgumentException(String.format("配置(%s) 找不到合适的客户端实现", config)); | |
| 136 | + } | |
| 107 | 137 | |
| 108 | 138 | /** |
| 109 | 139 | * 通过定时任务轮询,刷新缓存 | ... | ... |