Commit 8b98d13d8bac263ea2f3627e759a972c47b28f9b
Merge branch 'feature/mall_product' of https://gitee.com/zhijiantianya/ruoyi-vue-pro
Showing
175 changed files
with
4991 additions
and
1094 deletions
Too many changes.
To preserve performance only 100 of 175 files are displayed.
pom.xml
| ... | ... | @@ -16,11 +16,11 @@ |
| 16 | 16 | <module>yudao-module-member</module> |
| 17 | 17 | <module>yudao-module-system</module> |
| 18 | 18 | <module>yudao-module-infra</module> |
| 19 | -<!-- <module>yudao-module-pay</module>--> | |
| 20 | -<!-- <module>yudao-module-bpm</module>--> | |
| 21 | -<!-- <module>yudao-module-report</module>--> | |
| 22 | -<!-- <module>yudao-module-mp</module>--> | |
| 23 | -<!-- <module>yudao-module-mall</module>--> | |
| 19 | + <module>yudao-module-pay</module> | |
| 20 | + <module>yudao-module-bpm</module> | |
| 21 | + <module>yudao-module-report</module> | |
| 22 | + <module>yudao-module-mp</module> | |
| 23 | + <module>yudao-module-mall</module> | |
| 24 | 24 | <!-- 示例项目 --> |
| 25 | 25 | <module>yudao-example</module> |
| 26 | 26 | </modules> | ... | ... |
sql/mysql/pay_wallet.sql
0 → 100644
| 1 | +-- ---------------------------- | |
| 2 | +-- 支付-钱包表 | |
| 3 | +-- ---------------------------- | |
| 4 | +DROP TABLE IF EXISTS `pay_wallet`; | |
| 5 | +CREATE TABLE `pay_wallet` | |
| 6 | +( | |
| 7 | + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', | |
| 8 | + `user_id` bigint NOT NULL COMMENT '用户 id', | |
| 9 | + `user_type` tinyint NOT NULL DEFAULT 0 COMMENT '用户类型', | |
| 10 | + `balance` int NOT NULL DEFAULT 0 COMMENT '余额, 单位分', | |
| 11 | + `total_expense` bigint NOT NULL DEFAULT 0 COMMENT '累计支出, 单位分', | |
| 12 | + `total_recharge` bigint NOT NULL DEFAULT 0 COMMENT '累计充值, 单位分', | |
| 13 | + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 14 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 15 | + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 16 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 17 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 18 | + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 19 | + PRIMARY KEY (`id`) USING BTREE | |
| 20 | +) ENGINE=InnoDB COMMENT='支付钱包表'; | |
| 21 | + | |
| 22 | +-- ---------------------------- | |
| 23 | +-- 支付- 钱包余额明细表 | |
| 24 | +-- ---------------------------- | |
| 25 | +DROP TABLE IF EXISTS `pay_wallet_transaction`; | |
| 26 | +CREATE TABLE `pay_wallet_transaction` | |
| 27 | +( | |
| 28 | + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', | |
| 29 | + `wallet_id` bigint NOT NULL COMMENT '会员钱包 id', | |
| 30 | + `biz_type` tinyint NOT NULL COMMENT '关联类型', | |
| 31 | + `biz_id` bigint NOT NULL COMMENT '关联业务编号', | |
| 32 | + `no` varchar(64) NOT NULL COMMENT '流水号', | |
| 33 | + `description` varchar(255) COMMENT '操作说明', | |
| 34 | + `amount` int NOT NULL COMMENT '交易金额, 单位分', | |
| 35 | + `balance` int NOT NULL COMMENT '余额, 单位分', | |
| 36 | + `transaction_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '交易时间', | |
| 37 | + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 38 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 39 | + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 40 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 41 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 42 | + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 43 | + PRIMARY KEY (`id`) USING BTREE | |
| 44 | +) ENGINE=InnoDB COMMENT='支付钱包余额明细表'; | |
| 0 | 45 | \ No newline at end of file | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java
| ... | ... | @@ -27,6 +27,7 @@ import com.alipay.api.request.AlipayTradeRefundRequest; |
| 27 | 27 | import com.alipay.api.response.AlipayTradeFastpayRefundQueryResponse; |
| 28 | 28 | import com.alipay.api.response.AlipayTradeQueryResponse; |
| 29 | 29 | import com.alipay.api.response.AlipayTradeRefundResponse; |
| 30 | +import lombok.Getter; | |
| 30 | 31 | import lombok.SneakyThrows; |
| 31 | 32 | import lombok.extern.slf4j.Slf4j; |
| 32 | 33 | |
| ... | ... | @@ -47,6 +48,7 @@ import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER; |
| 47 | 48 | @Slf4j |
| 48 | 49 | public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPayClientConfig> { |
| 49 | 50 | |
| 51 | + @Getter // 仅用于单测场景 | |
| 50 | 52 | protected DefaultAlipayClient client; |
| 51 | 53 | |
| 52 | 54 | public AbstractAlipayPayClient(Long channelId, String channelCode, AlipayPayClientConfig config) { | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java
| ... | ... | @@ -13,6 +13,8 @@ import com.alipay.api.request.AlipayTradePayRequest; |
| 13 | 13 | import com.alipay.api.response.AlipayTradePayResponse; |
| 14 | 14 | import lombok.extern.slf4j.Slf4j; |
| 15 | 15 | |
| 16 | +import java.time.LocalDateTime; | |
| 17 | + | |
| 16 | 18 | import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; |
| 17 | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; |
| 18 | 20 | |
| ... | ... | @@ -63,8 +65,10 @@ public class AlipayBarPayClient extends AbstractAlipayPayClient { |
| 63 | 65 | return buildClosedPayOrderRespDTO(reqDTO, response); |
| 64 | 66 | } |
| 65 | 67 | if ("10000".equals(response.getCode())) { // 免密支付 |
| 66 | - return PayOrderRespDTO.successOf(response.getTradeNo(), response.getBuyerUserId(), LocalDateTimeUtil.of(response.getGmtPayment()), | |
| 67 | - response.getOutTradeNo(), response); | |
| 68 | + LocalDateTime successTime = LocalDateTimeUtil.of(response.getGmtPayment()); | |
| 69 | + return PayOrderRespDTO.successOf(response.getTradeNo(), response.getBuyerUserId(), successTime, | |
| 70 | + response.getOutTradeNo(), response) | |
| 71 | + .setDisplayMode(displayMode).setDisplayContent(""); | |
| 68 | 72 | } |
| 69 | 73 | // 大额支付,需要用户输入密码,所以返回 waiting。此时,前端一般会进行轮询 |
| 70 | 74 | return PayOrderRespDTO.waitingOf(displayMode, "", | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; | |
| 2 | + | |
| 3 | +import cn.hutool.core.date.LocalDateTimeUtil; | |
| 4 | +import cn.hutool.core.util.RandomUtil; | |
| 5 | +import cn.iocoder.yudao.framework.common.exception.ServiceException; | |
| 6 | +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | |
| 7 | +import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | |
| 8 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; | |
| 9 | +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; | |
| 10 | +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; | |
| 11 | +import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; | |
| 12 | +import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; | |
| 13 | +import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; | |
| 14 | +import com.alipay.api.AlipayApiException; | |
| 15 | +import com.alipay.api.DefaultAlipayClient; | |
| 16 | +import com.alipay.api.DefaultSigner; | |
| 17 | +import com.alipay.api.domain.AlipayTradeRefundModel; | |
| 18 | +import com.alipay.api.request.AlipayTradeRefundRequest; | |
| 19 | +import com.alipay.api.response.AlipayTradeRefundResponse; | |
| 20 | +import lombok.Setter; | |
| 21 | +import org.junit.jupiter.api.BeforeEach; | |
| 22 | +import org.junit.jupiter.api.DisplayName; | |
| 23 | +import org.junit.jupiter.api.Test; | |
| 24 | +import org.mockito.ArgumentMatcher; | |
| 25 | +import org.mockito.Mock; | |
| 26 | + | |
| 27 | +import javax.validation.ConstraintViolationException; | |
| 28 | +import java.util.Date; | |
| 29 | + | |
| 30 | +import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY; | |
| 31 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 32 | +import static org.junit.jupiter.api.Assertions.*; | |
| 33 | +import static org.mockito.ArgumentMatchers.argThat; | |
| 34 | +import static org.mockito.Mockito.when; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * 支付宝 Client 的测试基类 | |
| 38 | + * | |
| 39 | + * @author jason | |
| 40 | + */ | |
| 41 | +public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest { | |
| 42 | + | |
| 43 | + protected AlipayPayClientConfig config = randomPojo(AlipayPayClientConfig.class, o -> { | |
| 44 | + o.setServerUrl(randomURL()); | |
| 45 | + o.setPrivateKey(randomString()); | |
| 46 | + o.setMode(MODE_PUBLIC_KEY); | |
| 47 | + o.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); | |
| 48 | + o.setAppCertContent(""); | |
| 49 | + o.setAlipayPublicCertContent(""); | |
| 50 | + o.setRootCertContent(""); | |
| 51 | + }); | |
| 52 | + | |
| 53 | + @Mock | |
| 54 | + protected DefaultAlipayClient defaultAlipayClient; | |
| 55 | + | |
| 56 | + @Setter | |
| 57 | + private AbstractAlipayPayClient client; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 子类需要实现该方法. 设置 client 的具体实现 | |
| 61 | + */ | |
| 62 | + @BeforeEach | |
| 63 | + public abstract void setUp(); | |
| 64 | + | |
| 65 | + @Test | |
| 66 | + @DisplayName("支付宝 Client 初始化") | |
| 67 | + public void testDoInit() { | |
| 68 | + // 调用 | |
| 69 | + client.doInit(); | |
| 70 | + // 断言 | |
| 71 | + DefaultAlipayClient realClient = client.getClient(); | |
| 72 | + assertNotSame(defaultAlipayClient, realClient); | |
| 73 | + assertInstanceOf(DefaultSigner.class, realClient.getSigner()); | |
| 74 | + assertEquals(config.getPrivateKey(), ((DefaultSigner) realClient.getSigner()).getPrivateKey()); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Test | |
| 78 | + @DisplayName("支付宝 Client 统一退款:成功") | |
| 79 | + public void testUnifiedRefund_success() throws AlipayApiException { | |
| 80 | + // mock 方法 | |
| 81 | + String notifyUrl = randomURL(); | |
| 82 | + Date refundTime = randomDate(); | |
| 83 | + String outRefundNo = randomString(); | |
| 84 | + String outTradeNo = randomString(); | |
| 85 | + Integer refundAmount = randomInteger(); | |
| 86 | + AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { | |
| 87 | + o.setSubCode(""); | |
| 88 | + o.setGmtRefundPay(refundTime); | |
| 89 | + }); | |
| 90 | + when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeRefundRequest>) request -> { | |
| 91 | + assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); | |
| 92 | + AlipayTradeRefundModel bizModel = (AlipayTradeRefundModel) request.getBizModel(); | |
| 93 | + assertEquals(outRefundNo, bizModel.getOutRequestNo()); | |
| 94 | + assertEquals(outTradeNo, bizModel.getOutTradeNo()); | |
| 95 | + assertEquals(String.valueOf(refundAmount / 100.0), bizModel.getRefundAmount()); | |
| 96 | + return true; | |
| 97 | + }))).thenReturn(response); | |
| 98 | + // 准备请求参数 | |
| 99 | + PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { | |
| 100 | + o.setOutRefundNo(outRefundNo); | |
| 101 | + o.setOutTradeNo(outTradeNo); | |
| 102 | + o.setNotifyUrl(notifyUrl); | |
| 103 | + o.setRefundPrice(refundAmount); | |
| 104 | + }); | |
| 105 | + | |
| 106 | + // 调用 | |
| 107 | + PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); | |
| 108 | + // 断言 | |
| 109 | + assertEquals(PayRefundStatusRespEnum.SUCCESS.getStatus(), resp.getStatus()); | |
| 110 | + assertEquals(outRefundNo, resp.getOutRefundNo()); | |
| 111 | + assertNull(resp.getChannelRefundNo()); | |
| 112 | + assertEquals(LocalDateTimeUtil.of(refundTime), resp.getSuccessTime()); | |
| 113 | + assertSame(response, resp.getRawData()); | |
| 114 | + assertNull(resp.getChannelErrorCode()); | |
| 115 | + assertNull(resp.getChannelErrorMsg()); | |
| 116 | + } | |
| 117 | + | |
| 118 | + @Test | |
| 119 | + @DisplayName("支付宝 Client 统一退款:渠道返回失败") | |
| 120 | + public void test_unified_refund_channel_failed() throws AlipayApiException { | |
| 121 | + // mock 方法 | |
| 122 | + String notifyUrl = randomURL(); | |
| 123 | + String subCode = randomString(); | |
| 124 | + String subMsg = randomString(); | |
| 125 | + AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { | |
| 126 | + o.setSubCode(subCode); | |
| 127 | + o.setSubMsg(subMsg); | |
| 128 | + }); | |
| 129 | + when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeRefundRequest>) request -> { | |
| 130 | + assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); | |
| 131 | + return true; | |
| 132 | + }))).thenReturn(response); | |
| 133 | + // 准备请求参数 | |
| 134 | + String outRefundNo = randomString(); | |
| 135 | + String outTradeNo = randomString(); | |
| 136 | + PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { | |
| 137 | + o.setOutRefundNo(outRefundNo); | |
| 138 | + o.setOutTradeNo(outTradeNo); | |
| 139 | + o.setNotifyUrl(notifyUrl); | |
| 140 | + }); | |
| 141 | + | |
| 142 | + // 调用 | |
| 143 | + PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); | |
| 144 | + // 断言 | |
| 145 | + assertEquals(PayRefundStatusRespEnum.FAILURE.getStatus(), resp.getStatus()); | |
| 146 | + assertEquals(outRefundNo, resp.getOutRefundNo()); | |
| 147 | + assertNull(resp.getChannelRefundNo()); | |
| 148 | + assertNull(resp.getSuccessTime()); | |
| 149 | + assertSame(response, resp.getRawData()); | |
| 150 | + assertEquals(subCode, resp.getChannelErrorCode()); | |
| 151 | + assertEquals(subMsg, resp.getChannelErrorMsg()); | |
| 152 | + } | |
| 153 | + | |
| 154 | + @Test | |
| 155 | + @DisplayName("支付宝 Client 统一退款:参数校验不通过") | |
| 156 | + public void testUnifiedRefund_paramInvalidate() { | |
| 157 | + // 准备请求参数 | |
| 158 | + String notifyUrl = randomURL(); | |
| 159 | + PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { | |
| 160 | + o.setOutTradeNo(""); | |
| 161 | + o.setNotifyUrl(notifyUrl); | |
| 162 | + }); | |
| 163 | + | |
| 164 | + // 调用,并断言 | |
| 165 | + assertThrows(ConstraintViolationException.class, () -> client.unifiedRefund(refundReqDTO)); | |
| 166 | + } | |
| 167 | + | |
| 168 | + @Test | |
| 169 | + @DisplayName("支付宝 Client 统一退款:抛出业务异常") | |
| 170 | + public void testUnifiedRefund_throwServiceException() throws AlipayApiException { | |
| 171 | + // mock | |
| 172 | + when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeRefundRequest>) request -> true))) | |
| 173 | + .thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); | |
| 174 | + // 准备请求参数 | |
| 175 | + String notifyUrl = randomURL(); | |
| 176 | + PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl)); | |
| 177 | + | |
| 178 | + // 调用,并断言 | |
| 179 | + assertThrows(ServiceException.class, () -> client.unifiedRefund(refundReqDTO)); | |
| 180 | + } | |
| 181 | + | |
| 182 | + @Test | |
| 183 | + @DisplayName("支付宝 Client 统一退款:抛出系统异常") | |
| 184 | + public void testUnifiedRefund_throwPayException() throws AlipayApiException { | |
| 185 | + // mock | |
| 186 | + when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeRefundRequest>) request -> true))) | |
| 187 | + .thenThrow(new RuntimeException("系统异常")); | |
| 188 | + // 准备请求参数 | |
| 189 | + String notifyUrl = randomURL(); | |
| 190 | + PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl)); | |
| 191 | + | |
| 192 | + // 调用,并断言 | |
| 193 | + assertThrows(PayException.class, () -> client.unifiedRefund(refundReqDTO)); | |
| 194 | + } | |
| 195 | + | |
| 196 | + @Test | |
| 197 | + @DisplayName("支付宝 Client 统一下单:参数校验不通过") | |
| 198 | + public void testUnifiedOrder_paramInvalidate() { | |
| 199 | + // 准备请求参数 | |
| 200 | + String outTradeNo = randomString(); | |
| 201 | + String notifyUrl = randomURL(); | |
| 202 | + PayOrderUnifiedReqDTO reqDTO = randomPojo(PayOrderUnifiedReqDTO.class, o -> { | |
| 203 | + o.setOutTradeNo(outTradeNo); | |
| 204 | + o.setNotifyUrl(notifyUrl); | |
| 205 | + }); | |
| 206 | + | |
| 207 | + // 调用,并断言 | |
| 208 | + assertThrows(ConstraintViolationException.class, () -> client.unifiedOrder(reqDTO)); | |
| 209 | + } | |
| 210 | + | |
| 211 | + protected PayOrderUnifiedReqDTO buildOrderUnifiedReqDTO(String notifyUrl, String outTradeNo, Integer price) { | |
| 212 | + return randomPojo(PayOrderUnifiedReqDTO.class, o -> { | |
| 213 | + o.setOutTradeNo(outTradeNo); | |
| 214 | + o.setNotifyUrl(notifyUrl); | |
| 215 | + o.setPrice(price); | |
| 216 | + o.setSubject(RandomUtil.randomString(32)); | |
| 217 | + o.setBody(RandomUtil.randomString(32)); | |
| 218 | + }); | |
| 219 | + } | |
| 220 | + | |
| 221 | +} | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; | |
| 2 | + | |
| 3 | +import cn.hutool.core.date.LocalDateTimeUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.exception.ServiceException; | |
| 5 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; | |
| 6 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; | |
| 7 | +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; | |
| 8 | +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; | |
| 9 | +import com.alipay.api.AlipayApiException; | |
| 10 | +import com.alipay.api.domain.AlipayTradePayModel; | |
| 11 | +import com.alipay.api.request.AlipayTradePayRequest; | |
| 12 | +import com.alipay.api.response.AlipayTradePayResponse; | |
| 13 | +import org.junit.jupiter.api.BeforeEach; | |
| 14 | +import org.junit.jupiter.api.DisplayName; | |
| 15 | +import org.junit.jupiter.api.Test; | |
| 16 | +import org.mockito.ArgumentMatcher; | |
| 17 | +import org.mockito.InjectMocks; | |
| 18 | + | |
| 19 | +import java.util.Date; | |
| 20 | +import java.util.HashMap; | |
| 21 | +import java.util.Map; | |
| 22 | + | |
| 23 | +import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; | |
| 24 | +import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; | |
| 25 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 26 | +import static org.junit.jupiter.api.Assertions.*; | |
| 27 | +import static org.mockito.ArgumentMatchers.argThat; | |
| 28 | +import static org.mockito.Mockito.when; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * {@link AlipayBarPayClient} 单元测试 | |
| 32 | + * | |
| 33 | + * @author jason | |
| 34 | + */ | |
| 35 | +public class AlipayBarPayClientTest extends AbstractAlipayClientTest { | |
| 36 | + | |
| 37 | + @InjectMocks | |
| 38 | + private AlipayBarPayClient client = new AlipayBarPayClient(randomLongId(), config); | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + @BeforeEach | |
| 42 | + public void setUp() { | |
| 43 | + setClient(client); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Test | |
| 47 | + @DisplayName("支付宝条码支付:非免密码支付下单成功") | |
| 48 | + public void testUnifiedOrder_success() throws AlipayApiException { | |
| 49 | + // mock 方法 | |
| 50 | + String outTradeNo = randomString(); | |
| 51 | + String notifyUrl = randomURL(); | |
| 52 | + Integer price = randomInteger(); | |
| 53 | + String authCode = randomString(); | |
| 54 | + AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> o.setSubCode("")); | |
| 55 | + when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradePayRequest>) request -> { | |
| 56 | + assertInstanceOf(AlipayTradePayModel.class, request.getBizModel()); | |
| 57 | + assertEquals(notifyUrl, request.getNotifyUrl()); | |
| 58 | + AlipayTradePayModel model = (AlipayTradePayModel) request.getBizModel(); | |
| 59 | + assertEquals(outTradeNo, model.getOutTradeNo()); | |
| 60 | + assertEquals(String.valueOf(price / 100.0), model.getTotalAmount()); | |
| 61 | + assertEquals(authCode, model.getAuthCode()); | |
| 62 | + return true; | |
| 63 | + }))).thenReturn(response); | |
| 64 | + // 准备请求参数 | |
| 65 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); | |
| 66 | + Map<String, String> extraParam = new HashMap<>(); | |
| 67 | + extraParam.put("auth_code", authCode); | |
| 68 | + reqDTO.setChannelExtras(extraParam); | |
| 69 | + | |
| 70 | + // 调用方法 | |
| 71 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | |
| 72 | + // 断言 | |
| 73 | + assertEquals(WAITING.getStatus(), resp.getStatus()); | |
| 74 | + assertEquals(outTradeNo, resp.getOutTradeNo()); | |
| 75 | + assertNull(resp.getChannelOrderNo()); | |
| 76 | + assertNull(resp.getChannelUserId()); | |
| 77 | + assertNull(resp.getSuccessTime()); | |
| 78 | + assertEquals(PayOrderDisplayModeEnum.BAR_CODE.getMode(), resp.getDisplayMode()); | |
| 79 | + assertEquals("", resp.getDisplayContent()); | |
| 80 | + assertSame(response, resp.getRawData()); | |
| 81 | + assertNull(resp.getChannelErrorCode()); | |
| 82 | + assertNull(resp.getChannelErrorMsg()); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @Test | |
| 86 | + @DisplayName("支付宝条码支付:免密码支付下单成功") | |
| 87 | + public void testUnifiedOrder_code10000Success() throws AlipayApiException { | |
| 88 | + // mock 方法 | |
| 89 | + String outTradeNo = randomString(); | |
| 90 | + String channelNo = randomString(); | |
| 91 | + String channelUserId = randomString(); | |
| 92 | + Date payTime = randomDate(); | |
| 93 | + AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> { | |
| 94 | + o.setSubCode(""); | |
| 95 | + o.setCode("10000"); | |
| 96 | + o.setOutTradeNo(outTradeNo); | |
| 97 | + o.setTradeNo(channelNo); | |
| 98 | + o.setBuyerUserId(channelUserId); | |
| 99 | + o.setGmtPayment(payTime); | |
| 100 | + }); | |
| 101 | + when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradePayRequest>) request -> true))) | |
| 102 | + .thenReturn(response); | |
| 103 | + // 准备请求参数 | |
| 104 | + String authCode = randomString(); | |
| 105 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); | |
| 106 | + Map<String, String> extraParam = new HashMap<>(); | |
| 107 | + extraParam.put("auth_code", authCode); | |
| 108 | + reqDTO.setChannelExtras(extraParam); | |
| 109 | + | |
| 110 | + // 下单请求 | |
| 111 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | |
| 112 | + // 断言 | |
| 113 | + assertEquals(PayOrderStatusRespEnum.SUCCESS.getStatus(), resp.getStatus()); | |
| 114 | + assertEquals(outTradeNo, resp.getOutTradeNo()); | |
| 115 | + assertEquals(channelNo, resp.getChannelOrderNo()); | |
| 116 | + assertEquals(channelUserId, resp.getChannelUserId()); | |
| 117 | + assertEquals(LocalDateTimeUtil.of(payTime), resp.getSuccessTime()); | |
| 118 | + assertEquals(PayOrderDisplayModeEnum.BAR_CODE.getMode(), resp.getDisplayMode()); | |
| 119 | + assertEquals("", resp.getDisplayContent()); | |
| 120 | + assertSame(response, resp.getRawData()); | |
| 121 | + assertNull(resp.getChannelErrorCode()); | |
| 122 | + assertNull(resp.getChannelErrorMsg()); | |
| 123 | + } | |
| 124 | + | |
| 125 | + @Test | |
| 126 | + @DisplayName("支付宝条码支付:没有传条码") | |
| 127 | + public void testUnifiedOrder_emptyAuthCode() { | |
| 128 | + // 准备参数 | |
| 129 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | |
| 130 | + | |
| 131 | + // 调用,并断言 | |
| 132 | + assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); | |
| 133 | + } | |
| 134 | + | |
| 135 | + @Test | |
| 136 | + @DisplayName("支付宝条码支付:渠道返回失败") | |
| 137 | + public void test_unified_order_channel_failed() throws AlipayApiException { | |
| 138 | + // mock 方法 | |
| 139 | + String subCode = randomString(); | |
| 140 | + String subMsg = randomString(); | |
| 141 | + AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> { | |
| 142 | + o.setSubCode(subCode); | |
| 143 | + o.setSubMsg(subMsg); | |
| 144 | + }); | |
| 145 | + when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradePayRequest>) request -> true))) | |
| 146 | + .thenReturn(response); | |
| 147 | + // 准备请求参数 | |
| 148 | + String authCode = randomString(); | |
| 149 | + String outTradeNo = randomString(); | |
| 150 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); | |
| 151 | + Map<String, String> extraParam = new HashMap<>(); | |
| 152 | + extraParam.put("auth_code", authCode); | |
| 153 | + reqDTO.setChannelExtras(extraParam); | |
| 154 | + | |
| 155 | + // 调用方法 | |
| 156 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | |
| 157 | + // 断言 | |
| 158 | + assertEquals(CLOSED.getStatus(), resp.getStatus()); | |
| 159 | + assertEquals(outTradeNo, resp.getOutTradeNo()); | |
| 160 | + assertNull(resp.getChannelOrderNo()); | |
| 161 | + assertNull(resp.getChannelUserId()); | |
| 162 | + assertNull(resp.getSuccessTime()); | |
| 163 | + assertNull(resp.getDisplayMode()); | |
| 164 | + assertNull(resp.getDisplayContent()); | |
| 165 | + assertSame(response, resp.getRawData()); | |
| 166 | + assertEquals(subCode, resp.getChannelErrorCode()); | |
| 167 | + assertEquals(subMsg, resp.getChannelErrorMsg()); | |
| 168 | + } | |
| 169 | + | |
| 170 | +} | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; | |
| 2 | + | |
| 3 | +import cn.hutool.http.Method; | |
| 4 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; | |
| 5 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; | |
| 6 | +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; | |
| 7 | +import com.alipay.api.AlipayApiException; | |
| 8 | +import com.alipay.api.request.AlipayTradePagePayRequest; | |
| 9 | +import com.alipay.api.response.AlipayTradePagePayResponse; | |
| 10 | +import org.junit.jupiter.api.BeforeEach; | |
| 11 | +import org.junit.jupiter.api.DisplayName; | |
| 12 | +import org.junit.jupiter.api.Test; | |
| 13 | +import org.mockito.ArgumentMatcher; | |
| 14 | +import org.mockito.InjectMocks; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; | |
| 17 | +import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 19 | +import static org.junit.jupiter.api.Assertions.*; | |
| 20 | +import static org.junit.jupiter.api.Assertions.assertNull; | |
| 21 | +import static org.mockito.ArgumentMatchers.argThat; | |
| 22 | +import static org.mockito.ArgumentMatchers.eq; | |
| 23 | +import static org.mockito.Mockito.when; | |
| 24 | + | |
| 25 | +/** | |
| 26 | + * {@link AlipayPcPayClient} 单元测试 | |
| 27 | + * | |
| 28 | + * @author jason | |
| 29 | + */ | |
| 30 | +public class AlipayPcPayClientTest extends AbstractAlipayClientTest { | |
| 31 | + | |
| 32 | + @InjectMocks | |
| 33 | + private AlipayPcPayClient client = new AlipayPcPayClient(randomLongId(), config); | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + @BeforeEach | |
| 37 | + public void setUp() { | |
| 38 | + setClient(client); | |
| 39 | + } | |
| 40 | + | |
| 41 | + @Test | |
| 42 | + @DisplayName("支付宝 PC 网站支付:URL Display Mode 下单成功") | |
| 43 | + public void testUnifiedOrder_urlSuccess() throws AlipayApiException { | |
| 44 | + // mock 方法 | |
| 45 | + String notifyUrl = randomURL(); | |
| 46 | + AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> o.setSubCode("")); | |
| 47 | + when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher<AlipayTradePagePayRequest>) request -> true), | |
| 48 | + eq(Method.GET.name()))).thenReturn(response); | |
| 49 | + // 准备请求参数 | |
| 50 | + String outTradeNo = randomString(); | |
| 51 | + Integer price = randomInteger(); | |
| 52 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); | |
| 53 | + reqDTO.setDisplayMode(null); | |
| 54 | + | |
| 55 | + // 调用 | |
| 56 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | |
| 57 | + // 断言 | |
| 58 | + assertEquals(WAITING.getStatus(), resp.getStatus()); | |
| 59 | + assertEquals(outTradeNo, resp.getOutTradeNo()); | |
| 60 | + assertNull(resp.getChannelOrderNo()); | |
| 61 | + assertNull(resp.getChannelUserId()); | |
| 62 | + assertNull(resp.getSuccessTime()); | |
| 63 | + assertEquals(PayOrderDisplayModeEnum.URL.getMode(), resp.getDisplayMode()); | |
| 64 | + assertEquals(response.getBody(), resp.getDisplayContent()); | |
| 65 | + assertSame(response, resp.getRawData()); | |
| 66 | + assertNull(resp.getChannelErrorCode()); | |
| 67 | + assertNull(resp.getChannelErrorMsg()); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @Test | |
| 71 | + @DisplayName("支付宝 PC 网站支付:Form Display Mode 下单成功") | |
| 72 | + public void testUnifiedOrder_formSuccess() throws AlipayApiException { | |
| 73 | + // mock | |
| 74 | + String notifyUrl = randomURL(); | |
| 75 | + AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> o.setSubCode("")); | |
| 76 | + when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher<AlipayTradePagePayRequest>) request -> true), | |
| 77 | + eq(Method.POST.name()))).thenReturn(response); | |
| 78 | + // 准备请求参数 | |
| 79 | + String outTradeNo = randomString(); | |
| 80 | + Integer price = randomInteger(); | |
| 81 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); | |
| 82 | + reqDTO.setDisplayMode(PayOrderDisplayModeEnum.FORM.getMode()); | |
| 83 | + | |
| 84 | + // 调用 | |
| 85 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | |
| 86 | + // 断言 | |
| 87 | + assertEquals(WAITING.getStatus(), resp.getStatus()); | |
| 88 | + assertEquals(outTradeNo, resp.getOutTradeNo()); | |
| 89 | + assertNull(resp.getChannelOrderNo()); | |
| 90 | + assertNull(resp.getChannelUserId()); | |
| 91 | + assertNull(resp.getSuccessTime()); | |
| 92 | + assertEquals(PayOrderDisplayModeEnum.FORM.getMode(), resp.getDisplayMode()); | |
| 93 | + assertEquals(response.getBody(), resp.getDisplayContent()); | |
| 94 | + assertSame(response, resp.getRawData()); | |
| 95 | + assertNull(resp.getChannelErrorCode()); | |
| 96 | + assertNull(resp.getChannelErrorMsg()); | |
| 97 | + } | |
| 98 | + | |
| 99 | + @Test | |
| 100 | + @DisplayName("支付宝 PC 网站支付:渠道返回失败") | |
| 101 | + public void testUnifiedOrder_channelFailed() throws AlipayApiException { | |
| 102 | + // mock | |
| 103 | + String subCode = randomString(); | |
| 104 | + String subMsg = randomString(); | |
| 105 | + AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> { | |
| 106 | + o.setSubCode(subCode); | |
| 107 | + o.setSubMsg(subMsg); | |
| 108 | + }); | |
| 109 | + when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher<AlipayTradePagePayRequest>) request -> true), | |
| 110 | + eq(Method.GET.name()))).thenReturn(response); | |
| 111 | + // 准备请求参数 | |
| 112 | + String outTradeNo = randomString(); | |
| 113 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); | |
| 114 | + reqDTO.setDisplayMode(PayOrderDisplayModeEnum.URL.getMode()); | |
| 115 | + | |
| 116 | + // 调用 | |
| 117 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | |
| 118 | + // 断言 | |
| 119 | + assertEquals(CLOSED.getStatus(), resp.getStatus()); | |
| 120 | + assertEquals(outTradeNo, resp.getOutTradeNo()); | |
| 121 | + assertNull(resp.getChannelOrderNo()); | |
| 122 | + assertNull(resp.getChannelUserId()); | |
| 123 | + assertNull(resp.getSuccessTime()); | |
| 124 | + assertNull(resp.getDisplayMode()); | |
| 125 | + assertNull(resp.getDisplayContent()); | |
| 126 | + assertSame(response, resp.getRawData()); | |
| 127 | + assertEquals(subCode, resp.getChannelErrorCode()); | |
| 128 | + assertEquals(subMsg, resp.getChannelErrorMsg()); | |
| 129 | + } | |
| 130 | + | |
| 131 | +} | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java
| 1 | 1 | package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.date.LocalDateTimeUtil; | |
| 4 | -import cn.hutool.core.util.RandomUtil; | |
| 5 | -import cn.hutool.core.util.ReflectUtil; | |
| 6 | 3 | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| 7 | 4 | import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; |
| 8 | 5 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| 9 | 6 | import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; |
| 10 | 7 | import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; |
| 11 | -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; | |
| 12 | -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; | |
| 13 | 8 | import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; |
| 14 | 9 | import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; |
| 15 | -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; | |
| 16 | -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; | |
| 17 | 10 | import com.alipay.api.AlipayApiException; |
| 18 | -import com.alipay.api.DefaultAlipayClient; | |
| 19 | -import com.alipay.api.domain.AlipayTradeRefundModel; | |
| 20 | 11 | import com.alipay.api.request.AlipayTradePrecreateRequest; |
| 21 | -import com.alipay.api.request.AlipayTradeRefundRequest; | |
| 22 | 12 | import com.alipay.api.response.AlipayTradePrecreateResponse; |
| 23 | -import com.alipay.api.response.AlipayTradeRefundResponse; | |
| 13 | +import org.junit.jupiter.api.BeforeEach; | |
| 24 | 14 | import org.junit.jupiter.api.DisplayName; |
| 25 | 15 | import org.junit.jupiter.api.Test; |
| 26 | 16 | import org.mockito.ArgumentMatcher; |
| 27 | 17 | import org.mockito.InjectMocks; |
| 28 | -import org.mockito.Mock; | |
| 29 | 18 | |
| 30 | -import javax.validation.ConstraintViolationException; | |
| 31 | -import java.util.Date; | |
| 32 | - | |
| 33 | -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY; | |
| 34 | 19 | import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; |
| 35 | 20 | import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; |
| 36 | 21 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; |
| 37 | 22 | import static org.junit.jupiter.api.Assertions.*; |
| 38 | 23 | import static org.mockito.ArgumentMatchers.argThat; |
| 39 | 24 | import static org.mockito.Mockito.when; |
| 25 | + | |
| 40 | 26 | /** |
| 41 | 27 | * {@link AlipayQrPayClient} 单元测试 |
| 42 | 28 | * |
| 43 | 29 | * @author jason |
| 44 | 30 | */ |
| 45 | -public class AlipayQrPayClientTest extends BaseMockitoUnitTest { | |
| 46 | - | |
| 47 | - private final AlipayPayClientConfig config = randomPojo(AlipayPayClientConfig.class, t -> { | |
| 48 | - t.setServerUrl(randomURL()); | |
| 49 | - t.setMode(MODE_PUBLIC_KEY); | |
| 50 | - t.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); | |
| 51 | - t.setAppCertContent(""); | |
| 52 | - t.setAlipayPublicCertContent(""); | |
| 53 | - t.setRootCertContent(""); | |
| 54 | - }); | |
| 31 | +public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | |
| 55 | 32 | |
| 56 | 33 | @InjectMocks |
| 57 | - AlipayQrPayClient client = new AlipayQrPayClient(randomLongId(), config); | |
| 34 | + private AlipayQrPayClient client = new AlipayQrPayClient(randomLongId(), config); | |
| 58 | 35 | |
| 59 | - @Mock | |
| 60 | - private DefaultAlipayClient defaultAlipayClient; | |
| 61 | - | |
| 62 | - @Test | |
| 63 | - public void test_do_init() { | |
| 64 | - client.doInit(); | |
| 65 | - assertNotSame(defaultAlipayClient, ReflectUtil.getFieldValue(client, "defaultAlipayClient")); | |
| 36 | + @BeforeEach | |
| 37 | + public void setUp() { | |
| 38 | + setClient(client); | |
| 66 | 39 | } |
| 67 | 40 | |
| 68 | 41 | @Test |
| 69 | - @DisplayName("支付包扫描支付下单成功") | |
| 42 | + @DisplayName("支付宝扫描支付下单成功") | |
| 70 | 43 | public void test_unified_order_success() throws AlipayApiException { |
| 71 | 44 | // 准备返回对象 |
| 72 | 45 | String notifyUrl = randomURL(); |
| 73 | 46 | String qrCode = randomString(); |
| 47 | + Integer price = randomInteger(); | |
| 74 | 48 | AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { |
| 75 | 49 | o.setQrCode(qrCode); |
| 76 | 50 | o.setSubCode(""); |
| ... | ... | @@ -82,7 +56,7 @@ public class AlipayQrPayClientTest extends BaseMockitoUnitTest { |
| 82 | 56 | }))).thenReturn(response); |
| 83 | 57 | // 准备请求参数 |
| 84 | 58 | String outTradeNo = randomString(); |
| 85 | - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo); | |
| 59 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); | |
| 86 | 60 | |
| 87 | 61 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 88 | 62 | // 断言 |
| ... | ... | @@ -94,11 +68,12 @@ public class AlipayQrPayClientTest extends BaseMockitoUnitTest { |
| 94 | 68 | } |
| 95 | 69 | |
| 96 | 70 | @Test |
| 97 | - @DisplayName("支付包扫描支付,渠道返回失败") | |
| 71 | + @DisplayName("支付宝扫描支付,渠道返回失败") | |
| 98 | 72 | public void test_unified_order_channel_failed() throws AlipayApiException { |
| 99 | 73 | String notifyUrl = randomURL(); |
| 100 | 74 | String subCode = randomString(); |
| 101 | 75 | String subMsg = randomString(); |
| 76 | + Integer price = randomInteger(); | |
| 102 | 77 | AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { |
| 103 | 78 | o.setSubCode(subCode); |
| 104 | 79 | o.setSubMsg(subMsg); |
| ... | ... | @@ -110,7 +85,7 @@ public class AlipayQrPayClientTest extends BaseMockitoUnitTest { |
| 110 | 85 | }))).thenReturn(response); |
| 111 | 86 | // 准备请求参数 |
| 112 | 87 | String outTradeNo = randomString(); |
| 113 | - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo); | |
| 88 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); | |
| 114 | 89 | |
| 115 | 90 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 116 | 91 | // 断言 |
| ... | ... | @@ -121,174 +96,38 @@ public class AlipayQrPayClientTest extends BaseMockitoUnitTest { |
| 121 | 96 | } |
| 122 | 97 | |
| 123 | 98 | @Test |
| 124 | - @DisplayName("支付包扫描支付,抛出系统异常") | |
| 99 | + @DisplayName("支付宝扫描支付, 抛出系统异常") | |
| 125 | 100 | public void test_unified_order_throw_pay_exception() throws AlipayApiException { |
| 126 | 101 | // 准备请求参数 |
| 127 | 102 | String outTradeNo = randomString(); |
| 128 | 103 | String notifyUrl = randomURL(); |
| 104 | + Integer price = randomInteger(); | |
| 129 | 105 | // mock |
| 130 | 106 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradePrecreateRequest>) request -> { |
| 131 | 107 | assertEquals(notifyUrl, request.getNotifyUrl()); |
| 132 | 108 | return true; |
| 133 | 109 | }))).thenThrow(new RuntimeException("系统异常")); |
| 134 | 110 | // 准备请求参数 |
| 135 | - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo); | |
| 111 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo,price); | |
| 136 | 112 | // 断言 |
| 137 | 113 | assertThrows(PayException.class, () -> client.unifiedOrder(reqDTO)); |
| 138 | 114 | } |
| 139 | 115 | |
| 140 | 116 | @Test |
| 141 | - @DisplayName("支付包扫描支付,抛出业务异常") | |
| 117 | + @DisplayName("支付宝 Client 统一下单,抛出业务异常") | |
| 142 | 118 | public void test_unified_order_throw_service_exception() throws AlipayApiException { |
| 143 | 119 | // 准备请求参数 |
| 144 | 120 | String outTradeNo = randomString(); |
| 145 | 121 | String notifyUrl = randomURL(); |
| 122 | + Integer price = randomInteger(); | |
| 146 | 123 | // mock |
| 147 | 124 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradePrecreateRequest>) request -> { |
| 148 | 125 | assertEquals(notifyUrl, request.getNotifyUrl()); |
| 149 | 126 | return true; |
| 150 | 127 | }))).thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); |
| 151 | 128 | // 准备请求参数 |
| 152 | - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo); | |
| 129 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); | |
| 153 | 130 | // 断言 |
| 154 | 131 | assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); |
| 155 | 132 | } |
| 156 | - | |
| 157 | - @Test | |
| 158 | - @DisplayName("支付包扫描支付,参数校验不通过") | |
| 159 | - public void test_unified_order_param_validate() { | |
| 160 | - // 准备请求参数 | |
| 161 | - String outTradeNo = randomString(); | |
| 162 | - String notifyUrl = randomURL(); | |
| 163 | - PayOrderUnifiedReqDTO reqDTO = randomPojo(PayOrderUnifiedReqDTO.class, o -> { | |
| 164 | - o.setOutTradeNo(outTradeNo); | |
| 165 | - o.setNotifyUrl(notifyUrl); | |
| 166 | - }); | |
| 167 | - // 断言 | |
| 168 | - assertThrows(ConstraintViolationException.class, () -> client.unifiedOrder(reqDTO)); | |
| 169 | - } | |
| 170 | - | |
| 171 | - private PayOrderUnifiedReqDTO buildOrderUnifiedReqDTO(String notifyUrl, String outTradeNo) { | |
| 172 | - return randomPojo(PayOrderUnifiedReqDTO.class, o -> { | |
| 173 | - o.setOutTradeNo(outTradeNo); | |
| 174 | - o.setNotifyUrl(notifyUrl); | |
| 175 | - o.setSubject(RandomUtil.randomString(32)); | |
| 176 | - o.setBody(RandomUtil.randomString(32)); | |
| 177 | - }); | |
| 178 | - } | |
| 179 | - | |
| 180 | - @Test | |
| 181 | - @DisplayName("支付包扫描退款成功") | |
| 182 | - public void test_unified_refund_success() throws AlipayApiException { | |
| 183 | - // 准备返回对象 | |
| 184 | - String notifyUrl = randomURL(); | |
| 185 | - Date refundTime = randomDate(); | |
| 186 | - String outRefundNo = randomString(); | |
| 187 | - String outTradeNo = randomString(); | |
| 188 | - Integer refundAmount = randomInteger(); | |
| 189 | - AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { | |
| 190 | - o.setSubCode(""); | |
| 191 | - o.setGmtRefundPay(refundTime); | |
| 192 | - }); | |
| 193 | - // mock | |
| 194 | - when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeRefundRequest>) request -> { | |
| 195 | - assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); | |
| 196 | - AlipayTradeRefundModel bizModel = (AlipayTradeRefundModel) request.getBizModel(); | |
| 197 | - assertEquals(outRefundNo, bizModel.getOutRequestNo()); | |
| 198 | - assertEquals(outTradeNo, bizModel.getOutTradeNo()); | |
| 199 | - assertEquals(String.valueOf(refundAmount / 100.0), bizModel.getRefundAmount()); | |
| 200 | - return true; | |
| 201 | - }))).thenReturn(response); | |
| 202 | - // 准备请求参数 | |
| 203 | - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { | |
| 204 | - o.setOutRefundNo(outRefundNo); | |
| 205 | - o.setOutTradeNo(outTradeNo); | |
| 206 | - o.setNotifyUrl(notifyUrl); | |
| 207 | - o.setRefundPrice(refundAmount); | |
| 208 | - }); | |
| 209 | - PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); | |
| 210 | - // 断言 | |
| 211 | - assertEquals(PayRefundStatusRespEnum.SUCCESS.getStatus(), resp.getStatus()); | |
| 212 | - assertNull(resp.getChannelRefundNo()); | |
| 213 | - assertEquals(LocalDateTimeUtil.of(refundTime), resp.getSuccessTime()); | |
| 214 | - assertEquals(outRefundNo, resp.getOutRefundNo()); | |
| 215 | - assertSame(response, resp.getRawData()); | |
| 216 | - } | |
| 217 | - | |
| 218 | - @Test | |
| 219 | - @DisplayName("支付包扫描退款,渠道返回失败") | |
| 220 | - public void test_unified_refund_channel_failed() throws AlipayApiException { | |
| 221 | - // 准备返回对象 | |
| 222 | - String notifyUrl = randomURL(); | |
| 223 | - String subCode = randomString(); | |
| 224 | - String subMsg = randomString(); | |
| 225 | - AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { | |
| 226 | - o.setSubCode(subCode); | |
| 227 | - o.setSubMsg(subMsg); | |
| 228 | - }); | |
| 229 | - // mock | |
| 230 | - when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeRefundRequest>) request -> { | |
| 231 | - assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); | |
| 232 | - return true; | |
| 233 | - }))).thenReturn(response); | |
| 234 | - // 准备请求参数 | |
| 235 | - String outRefundNo = randomString(); | |
| 236 | - String outTradeNo = randomString(); | |
| 237 | - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { | |
| 238 | - o.setOutRefundNo(outRefundNo); | |
| 239 | - o.setOutTradeNo(outTradeNo); | |
| 240 | - o.setNotifyUrl(notifyUrl); | |
| 241 | - }); | |
| 242 | - PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); | |
| 243 | - // 断言 | |
| 244 | - assertEquals(PayRefundStatusRespEnum.FAILURE.getStatus(), resp.getStatus()); | |
| 245 | - assertNull(resp.getChannelRefundNo()); | |
| 246 | - assertEquals(subCode, resp.getChannelErrorCode()); | |
| 247 | - assertEquals(subMsg, resp.getChannelErrorMsg()); | |
| 248 | - assertNull(resp.getSuccessTime()); | |
| 249 | - assertEquals(outRefundNo, resp.getOutRefundNo()); | |
| 250 | - assertSame(response, resp.getRawData()); | |
| 251 | - } | |
| 252 | - | |
| 253 | - @Test | |
| 254 | - @DisplayName("支付包扫描退款,参数校验不通过") | |
| 255 | - public void test_unified_refund_param_validate() { | |
| 256 | - // 准备请求参数 | |
| 257 | - String notifyUrl = randomURL(); | |
| 258 | - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { | |
| 259 | - o.setOutTradeNo(""); | |
| 260 | - o.setNotifyUrl(notifyUrl); | |
| 261 | - }); | |
| 262 | - // 断言 | |
| 263 | - assertThrows(ConstraintViolationException.class, () -> client.unifiedRefund(refundReqDTO)); | |
| 264 | - } | |
| 265 | - | |
| 266 | - @Test | |
| 267 | - @DisplayName("支付包扫描退款,抛出业务异常") | |
| 268 | - public void test_unified_refund_throw_service_exception() throws AlipayApiException { | |
| 269 | - // mock | |
| 270 | - when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeRefundRequest>) request -> true))) | |
| 271 | - .thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); | |
| 272 | - // 准备请求参数 | |
| 273 | - String notifyUrl = randomURL(); | |
| 274 | - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { | |
| 275 | - o.setNotifyUrl(notifyUrl); | |
| 276 | - }); | |
| 277 | - // 断言 | |
| 278 | - assertThrows(ServiceException.class, () -> client.unifiedRefund(refundReqDTO)); | |
| 279 | - } | |
| 280 | - @Test | |
| 281 | - @DisplayName("支付包扫描退款,抛出系统异常") | |
| 282 | - public void test_unified_refund_throw_pay_exception() throws AlipayApiException { | |
| 283 | - // mock | |
| 284 | - when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeRefundRequest>) request -> true))) | |
| 285 | - .thenThrow(new RuntimeException("系统异常")); | |
| 286 | - // 准备请求参数 | |
| 287 | - String notifyUrl = randomURL(); | |
| 288 | - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { | |
| 289 | - o.setNotifyUrl(notifyUrl); | |
| 290 | - }); | |
| 291 | - // 断言 | |
| 292 | - assertThrows(PayException.class, () -> client.unifiedRefund(refundReqDTO)); | |
| 293 | - } | |
| 294 | 133 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; | |
| 2 | + | |
| 3 | +import cn.hutool.http.Method; | |
| 4 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; | |
| 5 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; | |
| 6 | +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; | |
| 7 | +import com.alipay.api.AlipayApiException; | |
| 8 | +import com.alipay.api.domain.AlipayTradeWapPayModel; | |
| 9 | +import com.alipay.api.request.AlipayTradeWapPayRequest; | |
| 10 | +import com.alipay.api.response.AlipayTradeWapPayResponse; | |
| 11 | +import org.junit.jupiter.api.BeforeEach; | |
| 12 | +import org.junit.jupiter.api.DisplayName; | |
| 13 | +import org.junit.jupiter.api.Test; | |
| 14 | +import org.mockito.ArgumentMatcher; | |
| 15 | +import org.mockito.InjectMocks; | |
| 16 | + | |
| 17 | +import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; | |
| 18 | +import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; | |
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 20 | +import static org.junit.jupiter.api.Assertions.*; | |
| 21 | +import static org.junit.jupiter.api.Assertions.assertEquals; | |
| 22 | +import static org.mockito.ArgumentMatchers.argThat; | |
| 23 | +import static org.mockito.ArgumentMatchers.eq; | |
| 24 | +import static org.mockito.Mockito.when; | |
| 25 | + | |
| 26 | +/** | |
| 27 | + * {@link AlipayWapPayClient} 单元测试 | |
| 28 | + * | |
| 29 | + * @author jason | |
| 30 | + */ | |
| 31 | +public class AlipayWapPayClientTest extends AbstractAlipayClientTest { | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 支付宝 H5 支付 Client | |
| 35 | + */ | |
| 36 | + @InjectMocks | |
| 37 | + private AlipayWapPayClient client = new AlipayWapPayClient(randomLongId(), config); | |
| 38 | + | |
| 39 | + @BeforeEach | |
| 40 | + public void setUp() { | |
| 41 | + setClient(client); | |
| 42 | + } | |
| 43 | + | |
| 44 | + @Test | |
| 45 | + @DisplayName("支付宝 H5 支付下单成功") | |
| 46 | + public void test_unified_order_success() throws AlipayApiException { | |
| 47 | + // 准备响应对象 | |
| 48 | + String h5Body = randomString(); | |
| 49 | + Integer price = randomInteger(); | |
| 50 | + AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { | |
| 51 | + o.setSubCode(""); | |
| 52 | + o.setBody(h5Body); | |
| 53 | + }); | |
| 54 | + String notifyUrl = randomURL(); | |
| 55 | + // mock | |
| 56 | + when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher<AlipayTradeWapPayRequest>) request -> { | |
| 57 | + assertInstanceOf(AlipayTradeWapPayModel.class, request.getBizModel()); | |
| 58 | + AlipayTradeWapPayModel bizModel = (AlipayTradeWapPayModel) request.getBizModel(); | |
| 59 | + assertEquals(String.valueOf(price / 100.0), bizModel.getTotalAmount()); | |
| 60 | + assertEquals(notifyUrl, request.getNotifyUrl()); | |
| 61 | + return true; | |
| 62 | + }), eq(Method.GET.name()))).thenReturn(response); | |
| 63 | + | |
| 64 | + String outTradeNo = randomString(); | |
| 65 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); | |
| 66 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | |
| 67 | + assertEquals(WAITING.getStatus(), resp.getStatus()); | |
| 68 | + assertEquals(PayOrderDisplayModeEnum.URL.getMode(), resp.getDisplayMode()); | |
| 69 | + assertEquals(outTradeNo, resp.getOutTradeNo()); | |
| 70 | + assertEquals(h5Body, resp.getDisplayContent()); | |
| 71 | + assertSame(response, resp.getRawData()); | |
| 72 | + } | |
| 73 | + | |
| 74 | + @Test | |
| 75 | + @DisplayName("支付宝 H5 支付,渠道返回失败") | |
| 76 | + public void test_unified_order_channel_failed() throws AlipayApiException { | |
| 77 | + // 准备响应对象 | |
| 78 | + String subCode = randomString(); | |
| 79 | + String subMsg = randomString(); | |
| 80 | + AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { | |
| 81 | + o.setSubCode(subCode); | |
| 82 | + o.setSubMsg(subMsg); | |
| 83 | + }); | |
| 84 | + // mock | |
| 85 | + when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher<AlipayTradeWapPayRequest>) request -> true), | |
| 86 | + eq(Method.GET.name()))).thenReturn(response); | |
| 87 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | |
| 88 | + | |
| 89 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | |
| 90 | + // 断言 | |
| 91 | + assertEquals(CLOSED.getStatus(), resp.getStatus()); | |
| 92 | + assertEquals(subCode, resp.getChannelErrorCode()); | |
| 93 | + assertEquals(subMsg, resp.getChannelErrorMsg()); | |
| 94 | + assertSame(response, resp.getRawData()); | |
| 95 | + } | |
| 96 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java
| ... | ... | @@ -51,7 +51,7 @@ public class ProductCommentController { |
| 51 | 51 | return success(true); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - @PutMapping("/create") | |
| 54 | + @PostMapping("/create") | |
| 55 | 55 | @Operation(summary = "添加自评") |
| 56 | 56 | @PreAuthorize("@ss.hasPermission('product:comment:update')") |
| 57 | 57 | public CommonResult<Boolean> createComment(@Valid @RequestBody ProductCommentCreateReqVO createReqVO) { | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java
| ... | ... | @@ -11,11 +11,9 @@ import java.util.List; |
| 11 | 11 | public class ProductCommentBaseVO { |
| 12 | 12 | |
| 13 | 13 | @Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "16868") |
| 14 | - @NotNull(message = "评价人不能为空") | |
| 15 | 14 | private Long userId; |
| 16 | 15 | |
| 17 | 16 | @Schema(description = "评价订单项", requiredMode = Schema.RequiredMode.REQUIRED, example = "19292") |
| 18 | - @NotNull(message = "评价订单项不能为空") | |
| 19 | 17 | private Long orderItemId; |
| 20 | 18 | |
| 21 | 19 | @Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小姑凉") | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.product.controller.admin.comment.vo; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; | |
| 3 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 5 | import lombok.Data; |
| 5 | 6 | import lombok.EqualsAndHashCode; |
| ... | ... | @@ -7,6 +8,7 @@ import lombok.ToString; |
| 7 | 8 | |
| 8 | 9 | import javax.validation.constraints.NotNull; |
| 9 | 10 | import java.time.LocalDateTime; |
| 11 | +import java.util.List; | |
| 10 | 12 | |
| 11 | 13 | @Schema(description = "管理后台 - 商品评价 Response VO") |
| 12 | 14 | @Data |
| ... | ... | @@ -23,10 +25,10 @@ public class ProductCommentRespVO extends ProductCommentBaseVO { |
| 23 | 25 | @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428") |
| 24 | 26 | private Long orderId; |
| 25 | 27 | |
| 26 | - @Schema(description = "是否可见:[true:显示 false:隐藏]", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 28 | + @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 27 | 29 | private Boolean visible; |
| 28 | 30 | |
| 29 | - @Schema(description = "商家是否回复:[1:回复 0:未回复]", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 31 | + @Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 30 | 32 | private Boolean replyStatus; |
| 31 | 33 | |
| 32 | 34 | @Schema(description = "回复管理员编号", example = "9527") |
| ... | ... | @@ -52,4 +54,10 @@ public class ProductCommentRespVO extends ProductCommentBaseVO { |
| 52 | 54 | @NotNull(message = "商品 SPU 名称不能为空") |
| 53 | 55 | private String spuName; |
| 54 | 56 | |
| 57 | + @Schema(description = "商品 SKU 图片地址", example = "https://www.iocoder.cn/yudao.jpg") | |
| 58 | + private String skuPicUrl; | |
| 59 | + | |
| 60 | + @Schema(description = "商品 SKU 规格值数组") | |
| 61 | + private List<ProductSkuBaseVO.Property> skuProperties; | |
| 62 | + | |
| 55 | 63 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java
| 1 | 1 | package cn.iocoder.yudao.module.product.controller.admin.sku; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.CollUtil; | |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 6 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuOptionRespVO; | |
| 7 | -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | |
| 8 | -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 9 | -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | |
| 10 | -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | |
| 11 | -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; | |
| 12 | -import io.swagger.v3.oas.annotations.Operation; | |
| 13 | 3 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 14 | 4 | import org.springframework.validation.annotation.Validated; |
| 15 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 16 | 5 | import org.springframework.web.bind.annotation.RequestMapping; |
| 17 | 6 | import org.springframework.web.bind.annotation.RestController; |
| 18 | 7 | |
| 19 | -import javax.annotation.Resource; | |
| 20 | -import java.util.Collections; | |
| 21 | -import java.util.List; | |
| 22 | -import java.util.Map; | |
| 23 | - | |
| 24 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 25 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 26 | - | |
| 27 | -@Tag(name = "管理后台 - 商品 sku") | |
| 8 | +@Tag(name = "管理后台 - 商品 SKU") | |
| 28 | 9 | @RestController |
| 29 | 10 | @RequestMapping("/product/sku") |
| 30 | 11 | @Validated |
| 31 | 12 | public class ProductSkuController { |
| 32 | 13 | |
| 33 | - @Resource | |
| 34 | - private ProductSkuService productSkuService; | |
| 35 | - @Resource | |
| 36 | - private ProductSpuService productSpuService; | |
| 37 | - | |
| 38 | - @GetMapping("/get-option-list") | |
| 39 | - @Operation(summary = "获得商品 SKU 选项的列表") | |
| 40 | -// @PreAuthorize("@ss.hasPermission('product:sku:query')") | |
| 41 | - public CommonResult<List<ProductSkuOptionRespVO>> getSkuOptionList() { | |
| 42 | - // 获得 SKU 列表 | |
| 43 | - List<ProductSkuDO> skus = productSkuService.getSkuList(); | |
| 44 | - if (CollUtil.isEmpty(skus)) { | |
| 45 | - return success(Collections.emptyList()); | |
| 46 | - } | |
| 47 | - | |
| 48 | - // 获得对应的 SPU 映射 | |
| 49 | - Map<Long, ProductSpuDO> spuMap = productSpuService.getSpuMap(convertSet(skus, ProductSkuDO::getSpuId)); | |
| 50 | - // 转换为返回结果 | |
| 51 | - List<ProductSkuOptionRespVO> skuVOs = ProductSkuConvert.INSTANCE.convertList05(skus); | |
| 52 | - skuVOs.forEach(sku -> MapUtils.findAndThen(spuMap, sku.getSpuId(), | |
| 53 | - spu -> sku.setSpuId(spu.getId()).setSpuName(spu.getName()))); | |
| 54 | - return success(skuVOs); | |
| 55 | - } | |
| 56 | - | |
| 57 | 14 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 6 | -@Schema(description = "管理后台 - 商品 SKU 选项 Response VO") // 用于前端 SELECT 选项 | |
| 7 | -@Data | |
| 8 | -public class ProductSkuOptionRespVO { | |
| 9 | - | |
| 10 | - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 11 | - private Long id; | |
| 12 | - | |
| 13 | - @Schema(description = "商品 SKU 名字", example = "红色") | |
| 14 | - private String name; | |
| 15 | - | |
| 16 | - @Schema(description = "销售价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 17 | - private String price; | |
| 18 | - | |
| 19 | - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 20 | - private Integer stock; | |
| 21 | - | |
| 22 | - // ========== 商品 SPU 信息 ========== | |
| 23 | - | |
| 24 | - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 25 | - private Long spuId; | |
| 26 | - | |
| 27 | - @Schema(description = "商品 SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "iPhone 11") | |
| 28 | - private String spuName; | |
| 29 | - | |
| 30 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.product.convert.comment; |
| 3 | 3 | import cn.hutool.core.util.ObjectUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 6 | -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 7 | 6 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 8 | 7 | import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; |
| 9 | 8 | import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; |
| ... | ... | @@ -24,6 +23,8 @@ import java.math.RoundingMode; |
| 24 | 23 | import java.util.List; |
| 25 | 24 | import java.util.Map; |
| 26 | 25 | |
| 26 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | |
| 27 | + | |
| 27 | 28 | /** |
| 28 | 29 | * 商品评价 Convert |
| 29 | 30 | * |
| ... | ... | @@ -60,7 +61,7 @@ public interface ProductCommentConvert { |
| 60 | 61 | item.setUserNickname(ProductCommentDO.NICKNAME_ANONYMOUS); |
| 61 | 62 | } |
| 62 | 63 | // 设置 SKU 规格值 |
| 63 | - MapUtils.findAndThen(skuMap, item.getSkuId(), | |
| 64 | + findAndThen(skuMap, item.getSkuId(), | |
| 64 | 65 | sku -> item.setSkuProperties(convertList01(sku.getProperties()))); |
| 65 | 66 | }); |
| 66 | 67 | return page; |
| ... | ... | @@ -87,7 +88,7 @@ public interface ProductCommentConvert { |
| 87 | 88 | |
| 88 | 89 | @Mapping(target = "scores", |
| 89 | 90 | expression = "java(convertScores(createReqDTO.getDescriptionScores(), createReqDTO.getBenefitScores()))") |
| 90 | - default ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO, ProductSpuDO spuDO, MemberUserRespDTO user) { | |
| 91 | + default ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO, ProductSpuDO spuDO, ProductSkuDO skuDO, MemberUserRespDTO user) { | |
| 91 | 92 | ProductCommentDO commentDO = convert(createReqDTO); |
| 92 | 93 | if (user != null) { |
| 93 | 94 | commentDO.setUserId(user.getId()); |
| ... | ... | @@ -98,9 +99,15 @@ public interface ProductCommentConvert { |
| 98 | 99 | commentDO.setSpuId(spuDO.getId()); |
| 99 | 100 | commentDO.setSpuName(spuDO.getName()); |
| 100 | 101 | } |
| 102 | + if (skuDO != null) { | |
| 103 | + commentDO.setSkuPicUrl(skuDO.getPicUrl()); | |
| 104 | + commentDO.setSkuProperties(skuDO.getProperties()); | |
| 105 | + } | |
| 101 | 106 | return commentDO; |
| 102 | 107 | } |
| 103 | 108 | |
| 109 | + @Mapping(target = "visible", constant = "true") | |
| 110 | + @Mapping(target = "replyStatus", constant = "false") | |
| 104 | 111 | @Mapping(target = "userId", constant = "0L") |
| 105 | 112 | @Mapping(target = "orderId", constant = "0L") |
| 106 | 113 | @Mapping(target = "orderItemId", constant = "0L") |
| ... | ... | @@ -111,4 +118,15 @@ public interface ProductCommentConvert { |
| 111 | 118 | |
| 112 | 119 | List<AppProductCommentRespVO> convertList02(List<ProductCommentDO> list); |
| 113 | 120 | |
| 121 | + default ProductCommentDO convert(ProductCommentCreateReqVO createReq, ProductSpuDO spu, ProductSkuDO sku) { | |
| 122 | + ProductCommentDO commentDO = convert(createReq); | |
| 123 | + if (spu != null) { | |
| 124 | + commentDO.setSpuId(spu.getId()).setSpuName(spu.getName()); | |
| 125 | + } | |
| 126 | + if (sku != null) { | |
| 127 | + commentDO.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties()); | |
| 128 | + } | |
| 129 | + return commentDO; | |
| 130 | + } | |
| 131 | + | |
| 114 | 132 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java
| ... | ... | @@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil; |
| 5 | 5 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 6 | 6 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 7 | 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 8 | -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuOptionRespVO; | |
| 9 | 8 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; |
| 10 | 9 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 11 | 10 | import org.mapstruct.Mapper; |
| ... | ... | @@ -44,8 +43,6 @@ public interface ProductSkuConvert { |
| 44 | 43 | |
| 45 | 44 | List<ProductSkuRespDTO> convertList04(List<ProductSkuDO> list); |
| 46 | 45 | |
| 47 | - List<ProductSkuOptionRespVO> convertList05(List<ProductSkuDO> skus); | |
| 48 | - | |
| 49 | 46 | /** |
| 50 | 47 | * 获得 SPU 的库存变化 Map |
| 51 | 48 | * | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java
| ... | ... | @@ -73,11 +73,14 @@ public class ProductCommentDO extends BaseDO { |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * 商品 SPU 编号 |
| 76 | + * | |
| 76 | 77 | * 关联 {@link ProductSpuDO#getId()} |
| 77 | 78 | */ |
| 78 | 79 | private Long spuId; |
| 79 | 80 | /** |
| 80 | 81 | * 商品 SPU 名称 |
| 82 | + * | |
| 83 | + * 关联 {@link ProductSpuDO#getName()} | |
| 81 | 84 | */ |
| 82 | 85 | private String spuName; |
| 83 | 86 | /** |
| ... | ... | @@ -86,6 +89,19 @@ public class ProductCommentDO extends BaseDO { |
| 86 | 89 | * 关联 {@link ProductSkuDO#getId()} |
| 87 | 90 | */ |
| 88 | 91 | private Long skuId; |
| 92 | + /** | |
| 93 | + * 商品 SKU 图片地址 | |
| 94 | + * | |
| 95 | + * 关联 {@link ProductSkuDO#getPicUrl()} | |
| 96 | + */ | |
| 97 | + private String skuPicUrl; | |
| 98 | + /** | |
| 99 | + * 属性数组,JSON 格式 | |
| 100 | + * | |
| 101 | + * 关联 {@link ProductSkuDO#getProperties()} | |
| 102 | + */ | |
| 103 | + @TableField(typeHandler = ProductSkuDO.PropertyTypeHandler.class) | |
| 104 | + private List<ProductSkuDO.Property> skuProperties; | |
| 89 | 105 | |
| 90 | 106 | /** |
| 91 | 107 | * 是否可见 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.product.dal.mysql.comment; |
| 2 | 2 | |
| 3 | - | |
| 4 | 3 | import cn.hutool.core.util.ObjectUtil; |
| 5 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 6 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| ... | ... | @@ -20,6 +19,7 @@ public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> { |
| 20 | 19 | .eqIfPresent(ProductCommentDO::getOrderId, reqVO.getOrderId()) |
| 21 | 20 | .eqIfPresent(ProductCommentDO::getSpuId, reqVO.getSpuId()) |
| 22 | 21 | .eqIfPresent(ProductCommentDO::getScores, reqVO.getScores()) |
| 22 | + .eqIfPresent(ProductCommentDO::getReplyStatus, reqVO.getReplyStatus()) | |
| 23 | 23 | .betweenIfPresent(ProductCommentDO::getCreateTime, reqVO.getCreateTime()) |
| 24 | 24 | .likeIfPresent(ProductCommentDO::getSpuName, reqVO.getSpuName()) |
| 25 | 25 | .orderByDesc(ProductCommentDO::getId)); |
| ... | ... | @@ -53,11 +53,10 @@ public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> { |
| 53 | 53 | return selectPage(reqVO, queryWrapper); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - default ProductCommentDO selectByUserIdAndOrderItemIdAndSpuId(Long userId, Long orderItemId, Long skuId) { | |
| 56 | + default ProductCommentDO selectByUserIdAndOrderItemId(Long userId, Long orderItemId) { | |
| 57 | 57 | return selectOne(new LambdaQueryWrapperX<ProductCommentDO>() |
| 58 | 58 | .eq(ProductCommentDO::getUserId, userId) |
| 59 | - .eq(ProductCommentDO::getOrderItemId, orderItemId) | |
| 60 | - .eq(ProductCommentDO::getSpuId, skuId)); | |
| 59 | + .eq(ProductCommentDO::getOrderItemId, orderItemId)); | |
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | default Long selectCountBySpuId(Long spuId, Boolean visible, Integer type) { | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java
| ... | ... | @@ -25,12 +25,21 @@ import java.util.List; |
| 25 | 25 | public interface ProductCommentService { |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * 获得商品评价分页 | |
| 28 | + * 创建商品评论 | |
| 29 | + * 后台管理员创建评论使用 | |
| 29 | 30 | * |
| 30 | - * @param pageReqVO 分页查询 | |
| 31 | - * @return 商品评价分页 | |
| 31 | + * @param createReqVO 商品评价创建 Request VO 对象 | |
| 32 | 32 | */ |
| 33 | - PageResult<ProductCommentDO> getCommentPage(ProductCommentPageReqVO pageReqVO); | |
| 33 | + void createComment(ProductCommentCreateReqVO createReqVO); | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 创建评论 | |
| 37 | + * 创建商品评论 APP 端创建商品评论使用 | |
| 38 | + * | |
| 39 | + * @param createReqDTO 创建请求 dto | |
| 40 | + * @return 返回评论 id | |
| 41 | + */ | |
| 42 | + Long createComment(ProductCommentCreateReqDTO createReqDTO); | |
| 34 | 43 | |
| 35 | 44 | /** |
| 36 | 45 | * 修改评论是否可见 |
| ... | ... | @@ -43,35 +52,26 @@ public interface ProductCommentService { |
| 43 | 52 | * 商家回复 |
| 44 | 53 | * |
| 45 | 54 | * @param replyVO 商家回复 |
| 46 | - * @param loginUserId 管理后台商家登陆人 ID | |
| 55 | + * @param userId 管理后台商家登陆人 ID | |
| 47 | 56 | */ |
| 48 | - void replyComment(ProductCommentReplyReqVO replyVO, Long loginUserId); | |
| 57 | + void replyComment(ProductCommentReplyReqVO replyVO, Long userId); | |
| 49 | 58 | |
| 50 | 59 | /** |
| 51 | - * 获得商品评价分页 | |
| 60 | + * 【管理员】获得商品评价分页 | |
| 52 | 61 | * |
| 53 | - * @param pageVO 分页查询 | |
| 54 | - * @param visible 是否可见 | |
| 62 | + * @param pageReqVO 分页查询 | |
| 55 | 63 | * @return 商品评价分页 |
| 56 | 64 | */ |
| 57 | - PageResult<ProductCommentDO> getCommentPage(AppCommentPageReqVO pageVO, Boolean visible); | |
| 65 | + PageResult<ProductCommentDO> getCommentPage(ProductCommentPageReqVO pageReqVO); | |
| 58 | 66 | |
| 59 | 67 | /** |
| 60 | - * 创建商品评论 | |
| 61 | - * 后台管理员创建评论使用 | |
| 68 | + * 【会员】获得商品评价分页 | |
| 62 | 69 | * |
| 63 | - * @param createReqVO 商品评价创建 Request VO 对象 | |
| 64 | - */ | |
| 65 | - void createComment(ProductCommentCreateReqVO createReqVO); | |
| 66 | - | |
| 67 | - /** | |
| 68 | - * 创建评论 | |
| 69 | - * 创建商品评论 APP 端创建商品评论使用 | |
| 70 | - * | |
| 71 | - * @param createReqDTO 创建请求 dto | |
| 72 | - * @return 返回评论 id | |
| 70 | + * @param pageVO 分页查询 | |
| 71 | + * @param visible 是否可见 | |
| 72 | + * @return 商品评价分页 | |
| 73 | 73 | */ |
| 74 | - Long createComment(ProductCommentCreateReqDTO createReqDTO); | |
| 74 | + PageResult<ProductCommentDO> getCommentPage(AppCommentPageReqVO pageVO, Boolean visible); | |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * 获得商品的评价统计 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java
| ... | ... | @@ -20,7 +20,6 @@ import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 20 | 20 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 21 | 21 | import org.springframework.context.annotation.Lazy; |
| 22 | 22 | import org.springframework.stereotype.Service; |
| 23 | -import org.springframework.transaction.annotation.Transactional; | |
| 24 | 23 | import org.springframework.validation.annotation.Validated; |
| 25 | 24 | |
| 26 | 25 | import javax.annotation.Resource; |
| ... | ... | @@ -53,69 +52,55 @@ public class ProductCommentServiceImpl implements ProductCommentService { |
| 53 | 52 | private MemberUserApi memberUserApi; |
| 54 | 53 | |
| 55 | 54 | @Override |
| 56 | - @Transactional(rollbackFor = Exception.class) | |
| 57 | - public void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO) { | |
| 58 | - // 校验评论是否存在 | |
| 59 | - ProductCommentDO productCommentDO = validateCommentExists(updateReqVO.getId()); | |
| 60 | - productCommentDO.setVisible(updateReqVO.getVisible()); | |
| 61 | - | |
| 62 | - // 更新可见状态 | |
| 63 | - productCommentMapper.updateById(productCommentDO); | |
| 64 | - } | |
| 65 | - | |
| 66 | - @Override | |
| 67 | - @Transactional(rollbackFor = Exception.class) | |
| 68 | - public void replyComment(ProductCommentReplyReqVO replyVO, Long loginUserId) { | |
| 69 | - // 校验评论是否存在 | |
| 70 | - ProductCommentDO productCommentDO = validateCommentExists(replyVO.getId()); | |
| 71 | - productCommentDO.setReplyTime(LocalDateTime.now()); | |
| 72 | - productCommentDO.setReplyUserId(loginUserId); | |
| 73 | - productCommentDO.setReplyStatus(Boolean.TRUE); | |
| 74 | - productCommentDO.setReplyContent(replyVO.getReplyContent()); | |
| 75 | - | |
| 76 | - // 回复评论 | |
| 77 | - productCommentMapper.updateById(productCommentDO); | |
| 78 | - } | |
| 79 | - | |
| 80 | - @Override | |
| 81 | - @Transactional(rollbackFor = Exception.class) | |
| 82 | 55 | public void createComment(ProductCommentCreateReqVO createReqVO) { |
| 83 | - // 校验评论 | |
| 84 | - validateComment(createReqVO.getSkuId(), createReqVO.getUserId(), createReqVO.getOrderItemId()); | |
| 56 | + // 校验 SKU | |
| 57 | + ProductSkuDO skuDO = validateSku(createReqVO.getSkuId()); | |
| 58 | + // 校验 SPU | |
| 59 | + ProductSpuDO spuDO = validateSpu(skuDO.getSpuId()); | |
| 85 | 60 | |
| 86 | - ProductCommentDO commentDO = ProductCommentConvert.INSTANCE.convert(createReqVO); | |
| 87 | - productCommentMapper.insert(commentDO); | |
| 61 | + // 创建评论 | |
| 62 | + ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqVO, spuDO, skuDO); | |
| 63 | + productCommentMapper.insert(comment); | |
| 88 | 64 | } |
| 89 | 65 | |
| 90 | 66 | @Override |
| 91 | - @Transactional(rollbackFor = Exception.class) | |
| 92 | 67 | public Long createComment(ProductCommentCreateReqDTO createReqDTO) { |
| 93 | - // 通过 sku ID 拿到 spu 相关信息 | |
| 94 | - ProductSkuDO sku = productSkuService.getSku(createReqDTO.getSkuId()); | |
| 95 | - if (sku == null) { | |
| 96 | - throw exception(SKU_NOT_EXISTS); | |
| 97 | - } | |
| 98 | - // 校验 spu 如果存在返回详情 | |
| 99 | - ProductSpuDO spuDO = validateSpu(sku.getSpuId()); | |
| 68 | + // 校验 SKU | |
| 69 | + ProductSkuDO skuDO = validateSku(createReqDTO.getSkuId()); | |
| 70 | + // 校验 SPU | |
| 71 | + ProductSpuDO spuDO = validateSpu(skuDO.getSpuId()); | |
| 100 | 72 | // 校验评论 |
| 101 | - validateComment(spuDO.getId(), createReqDTO.getUserId(), createReqDTO.getOrderId()); | |
| 73 | + validateCommentExists(createReqDTO.getUserId(), createReqDTO.getOrderId()); | |
| 102 | 74 | // 获取用户详细信息 |
| 103 | 75 | MemberUserRespDTO user = memberUserApi.getUser(createReqDTO.getUserId()); |
| 104 | 76 | |
| 105 | 77 | // 创建评论 |
| 106 | - ProductCommentDO commentDO = ProductCommentConvert.INSTANCE.convert(createReqDTO, spuDO, user); | |
| 107 | - productCommentMapper.insert(commentDO); | |
| 108 | - return commentDO.getId(); | |
| 78 | + ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqDTO, spuDO, skuDO, user); | |
| 79 | + productCommentMapper.insert(comment); | |
| 80 | + return comment.getId(); | |
| 109 | 81 | } |
| 110 | 82 | |
| 111 | - private void validateComment(Long skuId, Long userId, Long orderItemId) { | |
| 112 | - // 判断当前订单的当前商品用户是否评价过 | |
| 113 | - ProductCommentDO exist = productCommentMapper.selectByUserIdAndOrderItemIdAndSpuId(userId, orderItemId, skuId); | |
| 114 | - if (null != exist) { | |
| 83 | + /** | |
| 84 | + * 判断当前订单的当前商品用户是否评价过 | |
| 85 | + * | |
| 86 | + * @param userId 用户编号 | |
| 87 | + * @param orderItemId 订单项编号 | |
| 88 | + */ | |
| 89 | + private void validateCommentExists(Long userId, Long orderItemId) { | |
| 90 | + ProductCommentDO exist = productCommentMapper.selectByUserIdAndOrderItemId(userId, orderItemId); | |
| 91 | + if (exist != null) { | |
| 115 | 92 | throw exception(COMMENT_ORDER_EXISTS); |
| 116 | 93 | } |
| 117 | 94 | } |
| 118 | 95 | |
| 96 | + private ProductSkuDO validateSku(Long skuId) { | |
| 97 | + ProductSkuDO sku = productSkuService.getSku(skuId); | |
| 98 | + if (sku == null) { | |
| 99 | + throw exception(SKU_NOT_EXISTS); | |
| 100 | + } | |
| 101 | + return sku; | |
| 102 | + } | |
| 103 | + | |
| 119 | 104 | private ProductSpuDO validateSpu(Long spuId) { |
| 120 | 105 | ProductSpuDO spu = productSpuService.getSpu(spuId); |
| 121 | 106 | if (null == spu) { |
| ... | ... | @@ -124,6 +109,26 @@ public class ProductCommentServiceImpl implements ProductCommentService { |
| 124 | 109 | return spu; |
| 125 | 110 | } |
| 126 | 111 | |
| 112 | + @Override | |
| 113 | + public void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO) { | |
| 114 | + // 校验评论是否存在 | |
| 115 | + validateCommentExists(updateReqVO.getId()); | |
| 116 | + | |
| 117 | + // 更新可见状态 | |
| 118 | + productCommentMapper.updateById(new ProductCommentDO().setId(updateReqVO.getId()) | |
| 119 | + .setVisible(true)); | |
| 120 | + } | |
| 121 | + | |
| 122 | + @Override | |
| 123 | + public void replyComment(ProductCommentReplyReqVO replyVO, Long userId) { | |
| 124 | + // 校验评论是否存在 | |
| 125 | + validateCommentExists(replyVO.getId()); | |
| 126 | + // 回复评论 | |
| 127 | + productCommentMapper.updateById(new ProductCommentDO().setId(replyVO.getId()) | |
| 128 | + .setReplyTime(LocalDateTime.now()).setReplyUserId(userId) | |
| 129 | + .setReplyStatus(Boolean.TRUE).setReplyContent(replyVO.getReplyContent())); | |
| 130 | + } | |
| 131 | + | |
| 127 | 132 | private ProductCommentDO validateCommentExists(Long id) { |
| 128 | 133 | ProductCommentDO productComment = productCommentMapper.selectById(id); |
| 129 | 134 | if (productComment == null) { | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.product.service.sku; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.collection.ListUtil; | |
| 4 | 5 | import cn.hutool.core.util.ObjectUtil; |
| 5 | 6 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 6 | 7 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; |
| ... | ... | @@ -74,6 +75,9 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 74 | 75 | |
| 75 | 76 | @Override |
| 76 | 77 | public List<ProductSkuDO> getSkuList(Collection<Long> ids) { |
| 78 | + if (CollUtil.isEmpty(ids)) { | |
| 79 | + return ListUtil.empty(); | |
| 80 | + } | |
| 77 | 81 | return productSkuMapper.selectBatchIds(ids); |
| 78 | 82 | } |
| 79 | 83 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityBaseVO.java
| ... | ... | @@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 18 | 18 | @Data |
| 19 | 19 | public class BargainActivityBaseVO { |
| 20 | 20 | |
| 21 | - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "越拼越省钱") | |
| 21 | + @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "砍得越多省得越多,是兄弟就来砍我") | |
| 22 | 22 | @NotNull(message = "砍价名称不能为空") |
| 23 | 23 | private String name; |
| 24 | 24 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.controller.admin.delivery; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | 7 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | 8 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; |
| 8 | -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; | |
| 9 | 9 | import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; |
| 10 | 10 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; |
| 11 | 11 | import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; |
| ... | ... | @@ -67,6 +67,13 @@ public class DeliveryExpressController { |
| 67 | 67 | return success(DeliveryExpressConvert.INSTANCE.convert(deliveryExpress)); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | + @GetMapping("/list-all-simple") | |
| 71 | + @Operation(summary = "获取快递公司精简信息列表", description = "主要用于前端的下拉选项") | |
| 72 | + public CommonResult<List<DeliveryExpressSimpleRespVO>> getSimpleDeliveryExpressList() { | |
| 73 | + List<DeliveryExpressDO> list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); | |
| 74 | + return success(DeliveryExpressConvert.INSTANCE.convertList1(list)); | |
| 75 | + } | |
| 76 | + | |
| 70 | 77 | @GetMapping("/page") |
| 71 | 78 | @Operation(summary = "获得快递公司分页") |
| 72 | 79 | @PreAuthorize("@ss.hasPermission('trade:delivery:express:query')") | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.controller.admin.delivery; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 6 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 7 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; |
| 8 | 7 | import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; |
| 9 | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| ... | ... | @@ -16,14 +15,11 @@ import org.springframework.validation.annotation.Validated; |
| 16 | 15 | import org.springframework.web.bind.annotation.*; |
| 17 | 16 | |
| 18 | 17 | import javax.annotation.Resource; |
| 19 | -import javax.servlet.http.HttpServletResponse; | |
| 20 | 18 | import javax.validation.Valid; |
| 21 | -import java.io.IOException; | |
| 22 | 19 | import java.util.Collection; |
| 23 | 20 | import java.util.List; |
| 24 | 21 | |
| 25 | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 26 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 27 | 23 | |
| 28 | 24 | @Tag(name = "管理后台 - 自提门店") |
| 29 | 25 | @RestController |
| ... | ... | @@ -67,6 +63,13 @@ public class DeliveryPickUpStoreController { |
| 67 | 63 | return success(DeliveryPickUpStoreConvert.INSTANCE.convert(deliveryPickUpStore)); |
| 68 | 64 | } |
| 69 | 65 | |
| 66 | + @GetMapping("/list-all-simple") | |
| 67 | + @Operation(summary = "获取快递公司精简信息列表") | |
| 68 | + public CommonResult<List<DeliveryPickUpStoreSimpleRespVO>> getSimpleDeliveryPickUpStoreList() { | |
| 69 | + List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(CommonStatusEnum.ENABLE.getStatus()); | |
| 70 | + return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); | |
| 71 | + } | |
| 72 | + | |
| 70 | 73 | @GetMapping("/list") |
| 71 | 74 | @Operation(summary = "获得自提门店列表") |
| 72 | 75 | @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") |
| ... | ... | @@ -84,16 +87,4 @@ public class DeliveryPickUpStoreController { |
| 84 | 87 | return success(DeliveryPickUpStoreConvert.INSTANCE.convertPage(pageResult)); |
| 85 | 88 | } |
| 86 | 89 | |
| 87 | - // TODO @jason:导出去掉好列;简化下,一般用不到哈。 | |
| 88 | - @GetMapping("/export-excel") | |
| 89 | - @Operation(summary = "导出自提门店 Excel") | |
| 90 | - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:export')") | |
| 91 | - @OperateLog(type = EXPORT) | |
| 92 | - public void exportDeliveryPickUpStoreExcel(@Valid DeliveryPickUpStoreExportReqVO exportReqVO, | |
| 93 | - HttpServletResponse response) throws IOException { | |
| 94 | - List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreList(exportReqVO); | |
| 95 | - // 导出 Excel | |
| 96 | - List<DeliveryPickUpStoreExcelVO> datas = DeliveryPickUpStoreConvert.INSTANCE.convertList02(list); | |
| 97 | - ExcelUtils.write(response, "自提门店.xls", "数据", DeliveryPickUpStoreExcelVO.class, datas); | |
| 98 | - } | |
| 99 | 90 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; | |
| 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 | + | |
| 10 | +@Schema(description = "管理后台 - 快递公司精简信息 Response VO") | |
| 11 | +@Data | |
| 12 | +@NoArgsConstructor | |
| 13 | +@AllArgsConstructor | |
| 14 | +public class DeliveryExpressSimpleRespVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") | |
| 17 | + @NotNull(message = "编号不能为空") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | + @Schema(description = "快递公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "顺丰速运") | |
| 21 | + @NotNull(message = "快递公司名称不能为空") | |
| 22 | + private String name; | |
| 23 | + | |
| 24 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; | |
| 6 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 7 | -import lombok.Data; | |
| 8 | - | |
| 9 | -import java.time.LocalDateTime; | |
| 10 | - | |
| 11 | -@Data | |
| 12 | -public class DeliveryPickUpStoreExcelVO { | |
| 13 | - | |
| 14 | - @ExcelProperty("编号") | |
| 15 | - private Long id; | |
| 16 | - | |
| 17 | - @ExcelProperty("门店名称") | |
| 18 | - private String name; | |
| 19 | - | |
| 20 | - @ExcelProperty("门店简介") | |
| 21 | - private String introduction; | |
| 22 | - | |
| 23 | - @ExcelProperty("门店手机") | |
| 24 | - private String phone; | |
| 25 | - | |
| 26 | - @ExcelProperty("门店所在区域") | |
| 27 | - private String areaName; | |
| 28 | - | |
| 29 | - @ExcelProperty("门店详细地址") | |
| 30 | - private String detailAddress; | |
| 31 | - | |
| 32 | - @ExcelProperty("门店logo") | |
| 33 | - private String logo; | |
| 34 | - | |
| 35 | - // TODO @jason:是不是可以加个 convert? | |
| 36 | - /** | |
| 37 | - * easy-excel 好像暂时不支持 LocalTime. 转成string | |
| 38 | - */ | |
| 39 | - @ExcelProperty("营业开始时间") | |
| 40 | - private String openingTime; | |
| 41 | - | |
| 42 | - @ExcelProperty("营业结束时间") | |
| 43 | - private String closingTime; | |
| 44 | - | |
| 45 | - @ExcelProperty("纬度") | |
| 46 | - private String latitude; | |
| 47 | - | |
| 48 | - @ExcelProperty("经度") | |
| 49 | - private String longitude; | |
| 50 | - | |
| 51 | - @ExcelProperty(value = "状态", converter = DictConvert.class) | |
| 52 | - @DictFormat(DictTypeConstants.COMMON_STATUS) | |
| 53 | - private Integer status; | |
| 54 | - | |
| 55 | - @ExcelProperty("创建时间") | |
| 56 | - private LocalDateTime createTime; | |
| 57 | - | |
| 58 | -} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.NoArgsConstructor; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 自提门店精简信息 Response VO") | |
| 9 | +@Data | |
| 10 | +@NoArgsConstructor | |
| 11 | +@AllArgsConstructor | |
| 12 | +public class DeliveryPickUpStoreSimpleRespVO { | |
| 13 | + | |
| 14 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") | |
| 15 | + private Long id; | |
| 16 | + | |
| 17 | + @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | |
| 18 | + private String name; | |
| 19 | + | |
| 20 | + @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") | |
| 21 | + private String phone; | |
| 22 | + | |
| 23 | + @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") | |
| 24 | + private Integer areaId; | |
| 25 | + | |
| 26 | + // TODO @puhui999:要把 areaName 也返回哈 | |
| 27 | + | |
| 28 | + @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") | |
| 29 | + private String detailAddress; | |
| 30 | + | |
| 31 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java
| ... | ... | @@ -5,10 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 7 | 7 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 8 | -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; | |
| 9 | -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDetailRespVO; | |
| 10 | -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; | |
| 11 | -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; | |
| 12 | 9 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 13 | 10 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 14 | 11 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| ... | ... | @@ -79,12 +76,56 @@ public class TradeOrderController { |
| 79 | 76 | return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, user)); |
| 80 | 77 | } |
| 81 | 78 | |
| 79 | + @GetMapping("/get-express-track-list") | |
| 80 | + @Operation(summary = "获得交易订单的物流轨迹") | |
| 81 | + @Parameter(name = "id", description = "交易订单编号") | |
| 82 | + @PreAuthorize("@ss.hasPermission('trade:order:query')") | |
| 83 | + public CommonResult<List<?>> getOrderExpressTrackList(@RequestParam("id") Long id) { | |
| 84 | + return success(TradeOrderConvert.INSTANCE.convertList02( | |
| 85 | + tradeOrderQueryService.getExpressTrackList(id, getLoginUserId()))); | |
| 86 | + } | |
| 87 | + | |
| 88 | + // TODO @puhui999:put 请求哈 | |
| 82 | 89 | @PostMapping("/delivery") |
| 83 | - @Operation(summary = "发货订单") | |
| 84 | - @PreAuthorize("@ss.hasPermission('trade:order:delivery')") | |
| 90 | + @Operation(summary = "订单发货") | |
| 91 | + @PreAuthorize("@ss.hasPermission('trade:order:update')") | |
| 85 | 92 | public CommonResult<Boolean> deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) { |
| 86 | - tradeOrderUpdateService.deliveryOrder(getLoginUserId(), deliveryReqVO); | |
| 93 | + tradeOrderUpdateService.deliveryOrder(deliveryReqVO); | |
| 87 | 94 | return success(true); |
| 88 | 95 | } |
| 89 | 96 | |
| 97 | + // TODO @puhui999:put 请求哈,update-remark; | |
| 98 | + @PostMapping("/remark") | |
| 99 | + @Operation(summary = "订单备注") | |
| 100 | + @PreAuthorize("@ss.hasPermission('trade:order:update')") | |
| 101 | + public CommonResult<Boolean> updateOrderRemark(@RequestBody TradeOrderRemarkReqVO reqVO) { | |
| 102 | + tradeOrderUpdateService.updateOrderRemark(reqVO); | |
| 103 | + return success(true); | |
| 104 | + } | |
| 105 | + | |
| 106 | + // TODO @puhui999:put 请求哈,update-price; | |
| 107 | + @PostMapping("/adjust-price") | |
| 108 | + @Operation(summary = "订单调价") | |
| 109 | + @PreAuthorize("@ss.hasPermission('trade:order:update')") | |
| 110 | + public CommonResult<Boolean> updateOrderPrice(@RequestBody TradeOrderUpdatePriceReqVO reqVO) { | |
| 111 | + tradeOrderUpdateService.updateOrderPrice(reqVO); | |
| 112 | + return success(true); | |
| 113 | + } | |
| 114 | + | |
| 115 | + // TODO @puhui999:put 请求哈,update-address; | |
| 116 | + @PostMapping("/adjust-address") | |
| 117 | + @Operation(summary = "修改订单收货地址") | |
| 118 | + @PreAuthorize("@ss.hasPermission('trade:order:update')") | |
| 119 | + public CommonResult<Boolean> updateOrderAddress(@RequestBody TradeOrderUpdateAddressReqVO reqVO) { | |
| 120 | + tradeOrderUpdateService.updateOrderAddress(reqVO); | |
| 121 | + return success(true); | |
| 122 | + } | |
| 123 | + | |
| 124 | + // TODO @puhui999 订单物流详情 | |
| 125 | + // TODO @puhui999 【前台】订单取消 | |
| 126 | + // TODO @puhui999 【后台】订单取消 | |
| 127 | + // TODO @puhui999 【前台】订单核销 | |
| 128 | + // TODO @puhui999 【前台】订单删除 | |
| 129 | + // TODO @puhui999 【后台】订单统计 | |
| 130 | + | |
| 90 | 131 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java
| ... | ... | @@ -6,9 +6,9 @@ import lombok.Data; |
| 6 | 6 | import java.time.LocalDateTime; |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | -* 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | -*/ | |
| 9 | + * 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | + */ | |
| 12 | 12 | @Data |
| 13 | 13 | public class TradeOrderBaseVO { |
| 14 | 14 | |
| ... | ... | @@ -87,6 +87,12 @@ public class TradeOrderBaseVO { |
| 87 | 87 | |
| 88 | 88 | // ========== 收件 + 物流基本信息 ========== |
| 89 | 89 | |
| 90 | + @Schema(description = "配送方式", example = "10") | |
| 91 | + private Integer deliveryType; | |
| 92 | + | |
| 93 | + @Schema(description = "自提门店", example = "10") | |
| 94 | + private Long pickUpStoreId; | |
| 95 | + | |
| 90 | 96 | @Schema(description = "配送模板编号", example = "1024") |
| 91 | 97 | private Long deliveryTemplateId; |
| 92 | 98 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.controller.admin.order.vo; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; | |
| 5 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 4 | import lombok.Data; |
| 7 | 5 | |
| 8 | -import javax.validation.constraints.NotEmpty; | |
| 9 | 6 | import javax.validation.constraints.NotNull; |
| 10 | 7 | |
| 11 | 8 | @Schema(description = "管理后台 - 订单发货 Request VO") |
| ... | ... | @@ -16,18 +13,11 @@ public class TradeOrderDeliveryReqVO { |
| 16 | 13 | @NotNull(message = "订单编号不能为空") |
| 17 | 14 | private Long id; |
| 18 | 15 | |
| 19 | - // TODO @puhui999:可以去掉 type;如果无需发货,则 logisticsId 传递 0;logisticsNo 传递空串 | |
| 20 | - @Schema(description = "发货类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 21 | - @InEnum(DeliveryTypeEnum.class) | |
| 22 | - @NotNull(message = "发货类型不能为空") | |
| 23 | - private Integer type; | |
| 24 | - | |
| 25 | 16 | @Schema(description = "发货物流公司编号", example = "1") |
| 26 | 17 | @NotNull(message = "发货物流公司不能为空") |
| 27 | 18 | private Long logisticsId; |
| 28 | 19 | |
| 29 | 20 | @Schema(description = "发货物流单号", example = "SF123456789") |
| 30 | - @NotEmpty(message = "发货物流单号不能为空") | |
| 31 | 21 | private String logisticsNo; |
| 32 | 22 | |
| 33 | 23 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java
| ... | ... | @@ -10,6 +10,7 @@ import lombok.Data; |
| 10 | 10 | import org.springframework.format.annotation.DateTimeFormat; |
| 11 | 11 | |
| 12 | 12 | import java.time.LocalDateTime; |
| 13 | +import java.util.List; | |
| 13 | 14 | |
| 14 | 15 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 15 | 16 | |
| ... | ... | @@ -30,6 +31,12 @@ public class TradeOrderPageReqVO extends PageParam { |
| 30 | 31 | @Mobile |
| 31 | 32 | private String userMobile; |
| 32 | 33 | |
| 34 | + @Schema(description = "发货物流公司编号", example = "1") | |
| 35 | + private Long logisticsId; | |
| 36 | + | |
| 37 | + @Schema(description = "自提门店编号", example = "[1,2]") | |
| 38 | + private List<Long> pickUpStoreIds; | |
| 39 | + | |
| 33 | 40 | @Schema(description = "收件人名称", example = "小红") |
| 34 | 41 | private String receiverName; |
| 35 | 42 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.order.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotEmpty; | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - 订单备注 Request VO") | |
| 10 | +@Data | |
| 11 | +public class TradeOrderRemarkReqVO { | |
| 12 | + | |
| 13 | + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + @NotNull(message = "订单编号不能为空") | |
| 15 | + private Long id; | |
| 16 | + | |
| 17 | + @Schema(description = "商家备注", example = "你猜一下") | |
| 18 | + @NotEmpty(message = "订单备注不能为空") | |
| 19 | + private String remark; | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.order.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotEmpty; | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - 订单修改地址 Request VO") | |
| 10 | +@Data | |
| 11 | +public class TradeOrderUpdateAddressReqVO { | |
| 12 | + | |
| 13 | + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 14 | + @NotNull(message = "订单编号不能为空") | |
| 15 | + private Long id; | |
| 16 | + | |
| 17 | + @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "z张三") | |
| 18 | + @NotEmpty(message = "收件人名称不能为空") | |
| 19 | + private String receiverName; | |
| 20 | + | |
| 21 | + @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "19988188888") | |
| 22 | + @NotEmpty(message = "收件人手机不能为空") | |
| 23 | + private String receiverMobile; | |
| 24 | + | |
| 25 | + @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7310") | |
| 26 | + @NotNull(message = "收件人地区编号不能为空") | |
| 27 | + private Integer receiverAreaId; | |
| 28 | + | |
| 29 | + @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "昆明市五华区xxx小区xxx") | |
| 30 | + @NotEmpty(message = "收件人详细地址不能为空") | |
| 31 | + private String receiverDetailAddress; | |
| 32 | + | |
| 33 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.order.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 订单改价 Request VO") | |
| 9 | +@Data | |
| 10 | +public class TradeOrderUpdatePriceReqVO { | |
| 11 | + | |
| 12 | + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 13 | + @NotNull(message = "订单编号不能为空") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @Schema(description = "订单调价,单位:分。正数,加价;负数,减价", requiredMode = Schema.RequiredMode.REQUIRED, example = "-100") | |
| 17 | + @NotNull(message = "订单调价价格不能为空") | |
| 18 | + private Integer adjustPrice; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java
| ... | ... | @@ -31,7 +31,7 @@ public class AppDeliverExpressController { |
| 31 | 31 | @GetMapping("/list") |
| 32 | 32 | @Operation(summary = "获得快递公司列表") |
| 33 | 33 | public CommonResult<List<AppDeliveryExpressRespVO>> getDeliveryExpressList() { |
| 34 | - List<DeliveryExpressDO> list = deliveryExpressService.getDeliveryExpressList(CommonStatusEnum.ENABLE.getStatus()); | |
| 34 | + List<DeliveryExpressDO> list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); | |
| 35 | 35 | list.sort(Comparator.comparing(DeliveryExpressDO::getSort)); |
| 36 | 36 | return success(DeliveryExpressConvert.INSTANCE.convertList03(list)); |
| 37 | 37 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.convert.delivery; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; | |
| 4 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExcelVO; |
| 6 | 7 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressRespVO; |
| ... | ... | @@ -29,6 +30,8 @@ public interface DeliveryExpressConvert { |
| 29 | 30 | |
| 30 | 31 | List<DeliveryExpressExcelVO> convertList02(List<DeliveryExpressDO> list); |
| 31 | 32 | |
| 33 | + List<DeliveryExpressSimpleRespVO> convertList1(List<DeliveryExpressDO> list); | |
| 34 | + | |
| 32 | 35 | List<AppDeliveryExpressRespVO> convertList03(List<DeliveryExpressDO> list); |
| 33 | 36 | |
| 34 | 37 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.convert.delivery; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | - | |
| 7 | 4 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 8 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; |
| 9 | -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreExcelVO; | |
| 10 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreRespVO; |
| 7 | +import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreSimpleRespVO; | |
| 11 | 8 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; |
| 12 | 9 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| 13 | 10 | import org.mapstruct.Mapper; |
| 14 | -import org.mapstruct.Mapping; | |
| 15 | 11 | import org.mapstruct.Named; |
| 16 | 12 | import org.mapstruct.factory.Mappers; |
| 17 | 13 | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 18 | 16 | @Mapper |
| 19 | 17 | public interface DeliveryPickUpStoreConvert { |
| 20 | 18 | |
| ... | ... | @@ -30,14 +28,10 @@ public interface DeliveryPickUpStoreConvert { |
| 30 | 28 | |
| 31 | 29 | PageResult<DeliveryPickUpStoreRespVO> convertPage(PageResult<DeliveryPickUpStoreDO> page); |
| 32 | 30 | |
| 33 | - List<DeliveryPickUpStoreExcelVO> convertList02(List<DeliveryPickUpStoreDO> list); | |
| 34 | - | |
| 35 | - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToName") | |
| 36 | - DeliveryPickUpStoreExcelVO convert2(DeliveryPickUpStoreDO bean); | |
| 37 | - | |
| 38 | 31 | @Named("convertAreaIdToName") |
| 39 | 32 | default String convertAreaIdToName(Integer areaId) { |
| 40 | 33 | return AreaUtils.format(areaId); |
| 41 | 34 | } |
| 42 | 35 | |
| 36 | + List<DeliveryPickUpStoreSimpleRespVO> convertList1(List<DeliveryPickUpStoreDO> list); | |
| 43 | 37 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
| ... | ... | @@ -17,8 +17,7 @@ import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCr |
| 17 | 17 | import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; |
| 18 | 18 | import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; |
| 19 | 19 | import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; |
| 20 | -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDetailRespVO; | |
| 21 | -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; | |
| 20 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; | |
| 22 | 21 | import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; |
| 23 | 22 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; |
| 24 | 23 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; |
| ... | ... | @@ -278,4 +277,10 @@ public interface TradeOrderConvert { |
| 278 | 277 | |
| 279 | 278 | List<AppOrderExpressTrackRespDTO> convertList02(List<ExpressTrackRespDTO> list); |
| 280 | 279 | |
| 280 | + TradeOrderDO convert(TradeOrderUpdateAddressReqVO reqVO); | |
| 281 | + | |
| 282 | + TradeOrderDO convert(TradeOrderUpdatePriceReqVO reqVO); | |
| 283 | + | |
| 284 | + TradeOrderDO convert(TradeOrderRemarkReqVO reqVO); | |
| 285 | + | |
| 281 | 286 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.trade.dal.mysql.delivery; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreExportReqVO; | |
| 7 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| 9 | 8 | import org.apache.ibatis.annotations.Mapper; |
| ... | ... | @@ -23,15 +22,10 @@ public interface DeliveryPickUpStoreMapper extends BaseMapperX<DeliveryPickUpSto |
| 23 | 22 | .orderByDesc(DeliveryPickUpStoreDO::getId)); |
| 24 | 23 | } |
| 25 | 24 | |
| 26 | - default List<DeliveryPickUpStoreDO> selectList(DeliveryPickUpStoreExportReqVO reqVO) { | |
| 27 | - return selectList(new LambdaQueryWrapperX<DeliveryPickUpStoreDO>() | |
| 28 | - .likeIfPresent(DeliveryPickUpStoreDO::getName, reqVO.getName()) | |
| 29 | - .eqIfPresent(DeliveryPickUpStoreDO::getPhone, reqVO.getPhone()) | |
| 30 | - .eqIfPresent(DeliveryPickUpStoreDO::getAreaId, reqVO.getAreaId()) | |
| 31 | - .eqIfPresent(DeliveryPickUpStoreDO::getStatus, reqVO.getStatus()) | |
| 32 | - .betweenIfPresent(DeliveryPickUpStoreDO::getCreateTime, reqVO.getCreateTime()) | |
| 33 | - .orderByDesc(DeliveryPickUpStoreDO::getId)); | |
| 25 | + default List<DeliveryPickUpStoreDO> selectListByStatus(Integer status) { | |
| 26 | + return selectList(DeliveryPickUpStoreDO::getStatus, status); | |
| 34 | 27 | } |
| 28 | + | |
| 35 | 29 | } |
| 36 | 30 | |
| 37 | 31 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java
| ... | ... | @@ -34,6 +34,8 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { |
| 34 | 34 | .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) |
| 35 | 35 | .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) |
| 36 | 36 | .eqIfPresent(TradeOrderDO::getTerminal,reqVO.getTerminal()) |
| 37 | + .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) | |
| 38 | + .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) | |
| 37 | 39 | .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime())); |
| 38 | 40 | } |
| 39 | 41 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java
| ... | ... | @@ -64,11 +64,10 @@ public interface DeliveryExpressService { |
| 64 | 64 | List<DeliveryExpressDO> getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO); |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | - * 获得快递公司列表 | |
| 67 | + * 获取指定状态的快递公司列表 | |
| 68 | 68 | * |
| 69 | 69 | * @param status 状态 |
| 70 | 70 | * @return 快递公司列表 |
| 71 | 71 | */ |
| 72 | - List<DeliveryExpressDO> getDeliveryExpressList(Integer status); | |
| 73 | - | |
| 72 | + List<DeliveryExpressDO> getDeliveryExpressListByStatus(Integer status); | |
| 74 | 73 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java
| ... | ... | @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; |
| 12 | 12 | import org.springframework.validation.annotation.Validated; |
| 13 | 13 | |
| 14 | 14 | import javax.annotation.Resource; |
| 15 | +import java.util.Collection; | |
| 15 | 16 | import java.util.List; |
| 16 | 17 | |
| 17 | 18 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -95,7 +96,7 @@ public class DeliveryExpressServiceImpl implements DeliveryExpressService { |
| 95 | 96 | } |
| 96 | 97 | |
| 97 | 98 | @Override |
| 98 | - public List<DeliveryExpressDO> getDeliveryExpressList(Integer status) { | |
| 99 | + public List<DeliveryExpressDO> getDeliveryExpressListByStatus(Integer status) { | |
| 99 | 100 | return deliveryExpressMapper.selectListByStatus(status); |
| 100 | 101 | } |
| 101 | 102 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.delivery; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | -import javax.validation.*; | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 4 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; |
| 7 | -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreExportReqVO; | |
| 8 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; |
| 9 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; |
| 10 | 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| 11 | 8 | |
| 9 | +import javax.validation.Valid; | |
| 10 | +import java.util.Collection; | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 12 | 13 | /** |
| 13 | 14 | * 自提门店 Service 接口 |
| 14 | 15 | * |
| ... | ... | @@ -63,10 +64,10 @@ public interface DeliveryPickUpStoreService { |
| 63 | 64 | PageResult<DeliveryPickUpStoreDO> getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO); |
| 64 | 65 | |
| 65 | 66 | /** |
| 66 | - * 获得自提门店列表, 用于 Excel 导出 | |
| 67 | + * 获得指定状态的自提门店列表 | |
| 67 | 68 | * |
| 68 | - * @param exportReqVO 查询条件 | |
| 69 | + * @param status 状态 | |
| 69 | 70 | * @return 自提门店列表 |
| 70 | 71 | */ |
| 71 | - List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreList(DeliveryPickUpStoreExportReqVO exportReqVO); | |
| 72 | + List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status); | |
| 72 | 73 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java
| ... | ... | @@ -2,21 +2,20 @@ package cn.iocoder.yudao.module.trade.service.delivery; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; |
| 5 | -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreExportReqVO; | |
| 6 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; |
| 7 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; |
| 9 | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; |
| 10 | 9 | import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper; |
| 11 | 10 | import org.springframework.stereotype.Service; |
| 12 | -import javax.annotation.Resource; | |
| 13 | 11 | import org.springframework.validation.annotation.Validated; |
| 14 | 12 | |
| 15 | -import java.util.*; | |
| 16 | - | |
| 13 | +import javax.annotation.Resource; | |
| 14 | +import java.util.Collection; | |
| 15 | +import java.util.List; | |
| 17 | 16 | |
| 18 | 17 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 19 | -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; | |
| 18 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS; | |
| 20 | 19 | |
| 21 | 20 | /** |
| 22 | 21 | * 自提门店 Service 实现类 |
| ... | ... | @@ -78,7 +77,8 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic |
| 78 | 77 | } |
| 79 | 78 | |
| 80 | 79 | @Override |
| 81 | - public List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreList(DeliveryPickUpStoreExportReqVO exportReqVO) { | |
| 82 | - return deliveryPickUpStoreMapper.selectList(exportReqVO); | |
| 80 | + public List<DeliveryPickUpStoreDO> getDeliveryPickUpStoreListByStatus(Integer status) { | |
| 81 | + return deliveryPickUpStoreMapper.selectListByStatus(status); | |
| 83 | 82 | } |
| 83 | + | |
| 84 | 84 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.order; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; | |
| 4 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; | |
| 3 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; |
| 6 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; | |
| 4 | 7 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; |
| 5 | 8 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; |
| 6 | 9 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; |
| ... | ... | @@ -20,7 +23,7 @@ public interface TradeOrderUpdateService { |
| 20 | 23 | /** |
| 21 | 24 | * 获得订单结算信息 |
| 22 | 25 | * |
| 23 | - * @param userId 登录用户 | |
| 26 | + * @param userId 登录用户 | |
| 24 | 27 | * @param settlementReqVO 订单结算请求 |
| 25 | 28 | * @return 订单结算结果 |
| 26 | 29 | */ |
| ... | ... | @@ -29,8 +32,8 @@ public interface TradeOrderUpdateService { |
| 29 | 32 | /** |
| 30 | 33 | * 【会员】创建交易订单 |
| 31 | 34 | * |
| 32 | - * @param userId 登录用户 | |
| 33 | - * @param userIp 用户 IP 地址 | |
| 35 | + * @param userId 登录用户 | |
| 36 | + * @param userIp 用户 IP 地址 | |
| 34 | 37 | * @param createReqVO 创建交易订单请求模型 |
| 35 | 38 | * @return 交易订单的 |
| 36 | 39 | */ |
| ... | ... | @@ -39,7 +42,7 @@ public interface TradeOrderUpdateService { |
| 39 | 42 | /** |
| 40 | 43 | * 更新交易订单已支付 |
| 41 | 44 | * |
| 42 | - * @param id 交易订单编号 | |
| 45 | + * @param id 交易订单编号 | |
| 43 | 46 | * @param payOrderId 支付订单编号 |
| 44 | 47 | */ |
| 45 | 48 | void updateOrderPaid(Long id, Long payOrderId); |
| ... | ... | @@ -47,10 +50,9 @@ public interface TradeOrderUpdateService { |
| 47 | 50 | /** |
| 48 | 51 | * 【管理员】发货交易订单 |
| 49 | 52 | * |
| 50 | - * @param userId 管理员编号 | |
| 51 | 53 | * @param deliveryReqVO 发货请求 |
| 52 | 54 | */ |
| 53 | - void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO); | |
| 55 | + void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO); | |
| 54 | 56 | |
| 55 | 57 | /** |
| 56 | 58 | * 【会员】收货交易订单 |
| ... | ... | @@ -60,12 +62,33 @@ public interface TradeOrderUpdateService { |
| 60 | 62 | */ |
| 61 | 63 | void receiveOrder(Long userId, Long id); |
| 62 | 64 | |
| 65 | + /** | |
| 66 | + * 【管理员】交易订单备注 | |
| 67 | + * | |
| 68 | + * @param reqVO 请求 | |
| 69 | + */ | |
| 70 | + void updateOrderRemark(TradeOrderRemarkReqVO reqVO); | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 【管理员】调整价格 | |
| 74 | + * | |
| 75 | + * @param reqVO 请求 | |
| 76 | + */ | |
| 77 | + void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO); | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * 【管理员】调整地址 | |
| 81 | + * | |
| 82 | + * @param reqVO 请求 | |
| 83 | + */ | |
| 84 | + void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO); | |
| 85 | + | |
| 63 | 86 | // =================== Order Item =================== |
| 64 | 87 | |
| 65 | 88 | /** |
| 66 | 89 | * 更新交易订单项的售后状态 |
| 67 | 90 | * |
| 68 | - * @param id 交易订单项编号 | |
| 91 | + * @param id 交易订单项编号 | |
| 69 | 92 | * @param oldAfterSaleStatus 当前售后状态;如果不符,更新后会抛出异常 |
| 70 | 93 | * @param newAfterSaleStatus 目标售后状态 |
| 71 | 94 | */ |
| ... | ... | @@ -76,11 +99,11 @@ public interface TradeOrderUpdateService { |
| 76 | 99 | /** |
| 77 | 100 | * 更新交易订单项的售后状态 |
| 78 | 101 | * |
| 79 | - * @param id 交易订单项编号 | |
| 102 | + * @param id 交易订单项编号 | |
| 80 | 103 | * @param oldAfterSaleStatus 当前售后状态;如果不符,更新后会抛出异常 |
| 81 | 104 | * @param newAfterSaleStatus 目标售后状态 |
| 82 | - * @param afterSaleId 售后单编号;当订单项发起售后时,必须传递该字段 | |
| 83 | - * @param refundPrice 退款金额;当订单项退款成功时,必须传递该值 | |
| 105 | + * @param afterSaleId 售后单编号;当订单项发起售后时,必须传递该字段 | |
| 106 | + * @param refundPrice 退款金额;当订单项退款成功时,必须传递该值 | |
| 84 | 107 | */ |
| 85 | 108 | void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, |
| 86 | 109 | Long afterSaleId, Integer refundPrice); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| ... | ... | @@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert; |
| 5 | 5 | import cn.hutool.core.util.IdUtil; |
| 6 | 6 | import cn.hutool.core.util.ObjectUtil; |
| 7 | 7 | import cn.hutool.core.util.StrUtil; |
| 8 | +import cn.hutool.extra.spring.SpringUtil; | |
| 8 | 9 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 9 | 10 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 10 | 11 | import cn.iocoder.yudao.framework.common.enums.TerminalEnum; |
| ... | ... | @@ -12,8 +13,12 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 12 | 13 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 13 | 14 | import cn.iocoder.yudao.module.member.api.address.AddressApi; |
| 14 | 15 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; |
| 16 | +import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; | |
| 17 | +import cn.iocoder.yudao.module.member.api.point.MemberPointApi; | |
| 15 | 18 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 16 | 19 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 20 | +import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; | |
| 21 | +import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; | |
| 17 | 22 | import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; |
| 18 | 23 | import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; |
| 19 | 24 | import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; |
| ... | ... | @@ -30,6 +35,9 @@ import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; |
| 30 | 35 | import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; |
| 31 | 36 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 32 | 37 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; |
| 38 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; | |
| 39 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; | |
| 40 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; | |
| 33 | 41 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; |
| 34 | 42 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; |
| 35 | 43 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; |
| ... | ... | @@ -53,6 +61,8 @@ import cn.iocoder.yudao.module.trade.service.price.TradePriceService; |
| 53 | 61 | import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; |
| 54 | 62 | import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; |
| 55 | 63 | import lombok.extern.slf4j.Slf4j; |
| 64 | +import org.jetbrains.annotations.NotNull; | |
| 65 | +import org.springframework.scheduling.annotation.Async; | |
| 56 | 66 | import org.springframework.stereotype.Service; |
| 57 | 67 | import org.springframework.transaction.annotation.Transactional; |
| 58 | 68 | |
| ... | ... | @@ -64,6 +74,7 @@ import java.util.Objects; |
| 64 | 74 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 65 | 75 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 66 | 76 | import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.ORDER_NOT_FOUND; |
| 77 | +import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.ORDER_UPDATE_PRICE_FAIL_PAID; | |
| 67 | 78 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; |
| 68 | 79 | |
| 69 | 80 | /** |
| ... | ... | @@ -96,9 +107,15 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 96 | 107 | private AddressApi addressApi; |
| 97 | 108 | @Resource |
| 98 | 109 | private CouponApi couponApi; |
| 110 | + | |
| 99 | 111 | @Resource |
| 100 | 112 | private MemberUserApi memberUserApi; |
| 101 | 113 | @Resource |
| 114 | + private MemberLevelApi memberLevelApi; | |
| 115 | + @Resource | |
| 116 | + private MemberPointApi memberPointApi; | |
| 117 | + | |
| 118 | + @Resource | |
| 102 | 119 | private ProductCommentApi productCommentApi; |
| 103 | 120 | @Resource |
| 104 | 121 | private TradeMessageService tradeMessageService; |
| ... | ... | @@ -331,6 +348,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 331 | 348 | // TODO 芋艿:发送站内信 |
| 332 | 349 | |
| 333 | 350 | // TODO 芋艿:OrderLog |
| 351 | + | |
| 352 | + // 增加用户积分 | |
| 353 | + getSelf().addUserPointAsync(order.getUserId(), order.getPayPrice(), order.getId()); | |
| 354 | + // 增加用户经验 | |
| 355 | + getSelf().addUserExperienceAsync(order.getUserId(), order.getPayPrice(), order.getId()); | |
| 334 | 356 | } |
| 335 | 357 | |
| 336 | 358 | /** |
| ... | ... | @@ -345,10 +367,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 345 | 367 | */ |
| 346 | 368 | private KeyValue<TradeOrderDO, PayOrderRespDTO> validateOrderPayable(Long id, Long payOrderId) { |
| 347 | 369 | // 校验订单是否存在 |
| 348 | - TradeOrderDO order = tradeOrderMapper.selectById(id); | |
| 349 | - if (order == null) { | |
| 350 | - throw exception(ORDER_NOT_FOUND); | |
| 351 | - } | |
| 370 | + TradeOrderDO order = validateOrderExists(id); | |
| 352 | 371 | // 校验订单未支付 |
| 353 | 372 | if (!TradeOrderStatusEnum.isUnpaid(order.getStatus()) || order.getPayStatus()) { |
| 354 | 373 | log.error("[validateOrderPaid][order({}) 不处于待支付状态,请进行处理!order 数据是:{}]", |
| ... | ... | @@ -391,14 +410,16 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 391 | 410 | |
| 392 | 411 | @Override |
| 393 | 412 | @Transactional(rollbackFor = Exception.class) |
| 394 | - public void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO) { | |
| 413 | + public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) { | |
| 395 | 414 | // TODO @puhui999:只有选择快递的,才可以发货 |
| 396 | 415 | // 1.1 校验并获得交易订单(可发货) |
| 397 | 416 | TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); |
| 398 | - TradeOrderDO updateOrderObj = new TradeOrderDO(); | |
| 417 | + | |
| 418 | + // TODO @puhui999:下面不修改 deliveryType,直接校验 deliveryType 是否为快递,是快递才可以发货;先做严格的方式哈。 | |
| 399 | 419 | // 判断发货类型 |
| 420 | + TradeOrderDO updateOrderObj = new TradeOrderDO(); | |
| 400 | 421 | // 2.1 快递发货 |
| 401 | - if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) { | |
| 422 | + if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), 0L)) { | |
| 402 | 423 | // 校验快递公司 |
| 403 | 424 | DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId()); |
| 404 | 425 | if (deliveryExpress == null) { |
| ... | ... | @@ -408,27 +429,24 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 408 | 429 | throw exception(EXPRESS_STATUS_NOT_ENABLE); |
| 409 | 430 | } |
| 410 | 431 | updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode()); |
| 432 | + } else { | |
| 433 | + // 2.2 无需发货 | |
| 434 | + updateOrderObj.setLogisticsId(0L).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode()); | |
| 411 | 435 | } |
| 412 | - // TODO @puhui999:无需发货时,更新 logisticsId 为 0; | |
| 413 | - // 2.2 无需发货 | |
| 414 | - if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) { | |
| 415 | - updateOrderObj.setLogisticsId(null).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode()); | |
| 416 | - } | |
| 417 | - | |
| 418 | 436 | // 更新 TradeOrderDO 状态为已发货,等待收货 |
| 419 | 437 | updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now()); |
| 420 | 438 | int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj); |
| 421 | 439 | if (updateCount == 0) { |
| 422 | 440 | throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); |
| 423 | 441 | } |
| 442 | + | |
| 424 | 443 | // TODO 芋艿:发送订单变化的消息 |
| 425 | 444 | |
| 426 | 445 | // 发送站内信 |
| 427 | 446 | tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO().setOrderId(order.getId()) |
| 428 | - .setUserId(userId).setMessage(null)); | |
| 447 | + .setUserId(order.getUserId()).setMessage(null)); | |
| 429 | 448 | |
| 430 | 449 | // TODO 芋艿:OrderLog |
| 431 | - // TODO 设计:lili:是不是发货后,才支持售后? | |
| 432 | 450 | } |
| 433 | 451 | |
| 434 | 452 | /** |
| ... | ... | @@ -440,12 +458,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 440 | 458 | * @return 交易订单 |
| 441 | 459 | */ |
| 442 | 460 | private TradeOrderDO validateOrderDeliverable(Long id) { |
| 443 | - // 校验订单是否存在 | |
| 444 | - TradeOrderDO order = tradeOrderMapper.selectById(id); | |
| 445 | - if (order == null) { | |
| 446 | - throw exception(ORDER_NOT_FOUND); | |
| 447 | - } | |
| 461 | + TradeOrderDO order = validateOrderExists(id); | |
| 448 | 462 | // 校验订单是否是待发货状态 |
| 463 | + // TODO @puhui999:已经发货,可以重新发货,修改信息; | |
| 449 | 464 | if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) { |
| 450 | 465 | throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); |
| 451 | 466 | } |
| ... | ... | @@ -456,6 +471,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 456 | 471 | // 订单类型:拼团 |
| 457 | 472 | if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { |
| 458 | 473 | // 校验订单拼团是否成功 |
| 474 | + // TODO @puhui999:是不是取反? | |
| 459 | 475 | if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { |
| 460 | 476 | throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); |
| 461 | 477 | } |
| ... | ... | @@ -463,6 +479,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 463 | 479 | // 订单类类型:砍价 |
| 464 | 480 | if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) { |
| 465 | 481 | // 校验订单砍价是否成功 |
| 482 | + // TODO @puhui999:是不是取反? | |
| 466 | 483 | if (bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) { |
| 467 | 484 | throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS); |
| 468 | 485 | } |
| ... | ... | @@ -470,6 +487,16 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 470 | 487 | return order; |
| 471 | 488 | } |
| 472 | 489 | |
| 490 | + @NotNull | |
| 491 | + private TradeOrderDO validateOrderExists(Long id) { | |
| 492 | + // 校验订单是否存在 | |
| 493 | + TradeOrderDO order = tradeOrderMapper.selectById(id); | |
| 494 | + if (order == null) { | |
| 495 | + throw exception(ORDER_NOT_FOUND); | |
| 496 | + } | |
| 497 | + return order; | |
| 498 | + } | |
| 499 | + | |
| 473 | 500 | @Override |
| 474 | 501 | @Transactional(rollbackFor = Exception.class) |
| 475 | 502 | public void receiveOrder(Long userId, Long id) { |
| ... | ... | @@ -489,6 +516,43 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 489 | 516 | // TODO 芋艿:lili 发送商品被购买完成的数据 |
| 490 | 517 | } |
| 491 | 518 | |
| 519 | + @Override | |
| 520 | + public void updateOrderRemark(TradeOrderRemarkReqVO reqVO) { | |
| 521 | + // 校验并获得交易订单 | |
| 522 | + validateOrderExists(reqVO.getId()); | |
| 523 | + | |
| 524 | + // 更新 | |
| 525 | + TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(reqVO); | |
| 526 | + tradeOrderMapper.updateById(order); | |
| 527 | + } | |
| 528 | + | |
| 529 | + @Override | |
| 530 | + public void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO) { | |
| 531 | + // 校验交易订单 | |
| 532 | + TradeOrderDO order = validateOrderExists(reqVO.getId()); | |
| 533 | + if (order.getPayStatus()) { | |
| 534 | + throw exception(ORDER_UPDATE_PRICE_FAIL_PAID); | |
| 535 | + } | |
| 536 | + | |
| 537 | + // 更新 | |
| 538 | + // TODO @puhui999:TradeOrderItemDO 需要做 adjustPrice 的分摊;另外,支付订单那的价格,需要 update 下; | |
| 539 | + TradeOrderDO update = TradeOrderConvert.INSTANCE.convert(reqVO); | |
| 540 | + update.setPayPrice(update.getPayPrice() + update.getAdjustPrice()); | |
| 541 | + tradeOrderMapper.updateById(update); | |
| 542 | + } | |
| 543 | + | |
| 544 | + @Override | |
| 545 | + public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) { | |
| 546 | + // 校验交易订单 | |
| 547 | + validateOrderExists(reqVO.getId()); | |
| 548 | + // TODO 是否需要校验订单是否发货 | |
| 549 | + // TODO 发货后是否支持修改收货地址 | |
| 550 | + | |
| 551 | + // 更新 | |
| 552 | + TradeOrderDO update = TradeOrderConvert.INSTANCE.convert(reqVO); | |
| 553 | + tradeOrderMapper.updateById(update); | |
| 554 | + } | |
| 555 | + | |
| 492 | 556 | /** |
| 493 | 557 | * 校验交易订单满足可售货的条件 |
| 494 | 558 | * |
| ... | ... | @@ -555,6 +619,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 555 | 619 | } |
| 556 | 620 | |
| 557 | 621 | // TODO 芋艿:未来如果有分佣,需要更新相关分佣订单为已失效 |
| 622 | + | |
| 623 | + // 扣减用户积分 | |
| 624 | + getSelf().reduceUserPointAsync(order.getUserId(), orderRefundPrice, afterSaleId); | |
| 625 | + // 扣减用户经验 | |
| 626 | + getSelf().reduceUserExperienceAsync(order.getUserId(), orderRefundPrice, afterSaleId); | |
| 558 | 627 | } |
| 559 | 628 | |
| 560 | 629 | @Override |
| ... | ... | @@ -602,4 +671,37 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 602 | 671 | TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus())); |
| 603 | 672 | } |
| 604 | 673 | |
| 674 | + @Async | |
| 675 | + protected void addUserExperienceAsync(Long userId, Integer payPrice, Long orderId) { | |
| 676 | + int bizType = MemberExperienceBizTypeEnum.ORDER.getType(); | |
| 677 | + memberLevelApi.addExperience(userId, payPrice, bizType, String.valueOf(orderId)); | |
| 678 | + } | |
| 679 | + | |
| 680 | + @Async | |
| 681 | + protected void reduceUserExperienceAsync(Long userId, Integer refundPrice, Long afterSaleId) { | |
| 682 | + int bizType = MemberExperienceBizTypeEnum.REFUND.getType(); | |
| 683 | + memberLevelApi.addExperience(userId, -refundPrice, bizType, String.valueOf(afterSaleId)); | |
| 684 | + } | |
| 685 | + | |
| 686 | + @Async | |
| 687 | + protected void addUserPointAsync(Long userId, Integer payPrice, Long orderId) { | |
| 688 | + int bizType = MemberPointBizTypeEnum.ORDER_BUY.getType(); | |
| 689 | + memberPointApi.addPoint(userId, payPrice, bizType, String.valueOf(orderId)); | |
| 690 | + } | |
| 691 | + | |
| 692 | + @Async | |
| 693 | + protected void reduceUserPointAsync(Long userId, Integer refundPrice, Long afterSaleId) { | |
| 694 | + int bizType = MemberPointBizTypeEnum.ORDER_CANCEL.getType(); | |
| 695 | + memberPointApi.addPoint(userId, -refundPrice, bizType, String.valueOf(afterSaleId)); | |
| 696 | + } | |
| 697 | + | |
| 698 | + /** | |
| 699 | + * 获得自身的代理对象,解决 AOP 生效问题 | |
| 700 | + * | |
| 701 | + * @return 自己 | |
| 702 | + */ | |
| 703 | + private TradeOrderUpdateServiceImpl getSelf() { | |
| 704 | + return SpringUtil.getBean(getClass()); | |
| 705 | + } | |
| 706 | + | |
| 605 | 707 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java
| ... | ... | @@ -56,6 +56,7 @@ public class TradeAfterSaleServiceTest extends BaseDbUnitTest { |
| 56 | 56 | private TradeOrderUpdateService tradeOrderUpdateService; |
| 57 | 57 | @Resource |
| 58 | 58 | private TradeOrderQueryService tradeOrderQueryService; |
| 59 | + | |
| 59 | 60 | @MockBean |
| 60 | 61 | private PayRefundApi payRefundApi; |
| 61 | 62 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java
| ... | ... | @@ -23,7 +23,10 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 23 | 23 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| 24 | 24 | import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; |
| 25 | 25 | import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; |
| 26 | -import cn.iocoder.yudao.module.trade.enums.order.*; | |
| 26 | +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; | |
| 27 | +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum; | |
| 28 | +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; | |
| 29 | +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; | |
| 27 | 30 | import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderConfig; |
| 28 | 31 | import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; |
| 29 | 32 | import org.junit.jupiter.api.BeforeEach; |
| ... | ... | @@ -38,7 +41,6 @@ import java.util.List; |
| 38 | 41 | |
| 39 | 42 | import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; |
| 40 | 43 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 41 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 42 | 44 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 43 | 45 | import static java.util.Collections.singletonList; |
| 44 | 46 | import static org.junit.jupiter.api.Assertions.*; |
| ... | ... | @@ -282,7 +284,7 @@ public class TradeOrderUpdateServiceTest extends BaseDbUnitTest { |
| 282 | 284 | // mock 方法(支付单) |
| 283 | 285 | |
| 284 | 286 | // 调用 |
| 285 | - tradeOrderUpdateService.deliveryOrder(randomLongId(), deliveryReqVO); | |
| 287 | + tradeOrderUpdateService.deliveryOrder(deliveryReqVO); | |
| 286 | 288 | // 断言 |
| 287 | 289 | TradeOrderDO dbOrder = tradeOrderMapper.selectById(1L); |
| 288 | 290 | assertEquals(dbOrder.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus()); | ... | ... |
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.api.level; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 会员等级 API 接口 | |
| 7 | + * | |
| 8 | + * @author owen | |
| 9 | + */ | |
| 10 | +public interface MemberLevelApi { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * 增加会员经验 | |
| 14 | + * | |
| 15 | + * @param userId 会员ID | |
| 16 | + * @param experience 经验 | |
| 17 | + * @param bizType 业务类型 {@link MemberExperienceBizTypeEnum} | |
| 18 | + * @param bizId 业务编号 | |
| 19 | + */ | |
| 20 | + void addExperience(Long userId, Integer experience, Integer bizType, String bizId); | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApi.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.api.point; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 用户积分的 API 接口 | |
| 7 | + * | |
| 8 | + * @author owen | |
| 9 | + */ | |
| 10 | +public interface MemberPointApi { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * 增加用户积分 | |
| 14 | + * | |
| 15 | + * @param userId 用户编号 | |
| 16 | + * @param point 积分 | |
| 17 | + * @param bizType 业务类型 {@link MemberPointBizTypeEnum} | |
| 18 | + * @param bizId 业务编号 | |
| 19 | + */ | |
| 20 | + void addPoint(Long userId, Integer point, Integer bizType, String bizId); | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/DictTypeConstants.java
0 → 100644
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java
| ... | ... | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Member 错误码枚举类 |
| 7 | - * | |
| 7 | + * <p> | |
| 8 | 8 | * member 系统,使用 1-004-000-000 段 |
| 9 | 9 | */ |
| 10 | 10 | public interface ErrorCodeConstants { |
| ... | ... | @@ -24,13 +24,15 @@ public interface ErrorCodeConstants { |
| 24 | 24 | // ========== 用户收件地址 1004004000 ========== |
| 25 | 25 | ErrorCode ADDRESS_NOT_EXISTS = new ErrorCode(1004004000, "用户收件地址不存在"); |
| 26 | 26 | |
| 27 | - //========== 会员标签 1004006000 ========== | |
| 28 | - ErrorCode TAG_NOT_EXISTS = new ErrorCode(1004006000, "会员标签不存在"); | |
| 29 | - ErrorCode TAG_NAME_EXISTS = new ErrorCode(1004006001, "会员标签已经存在"); | |
| 27 | + //========== 用户标签 1004006000 ========== | |
| 28 | + ErrorCode TAG_NOT_EXISTS = new ErrorCode(1004006000, "用户标签不存在"); | |
| 29 | + ErrorCode TAG_NAME_EXISTS = new ErrorCode(1004006001, "用户标签已经存在"); | |
| 30 | + ErrorCode TAG_HAS_USER = new ErrorCode(1004006002, "用户标签下存在用户,无法删除"); | |
| 30 | 31 | |
| 31 | 32 | //========== 积分配置 1004007000 ========== |
| 32 | 33 | |
| 33 | 34 | //========== 积分记录 1004008000 ========== |
| 35 | + ErrorCode POINT_RECORD_BIZ_NOT_SUPPORT = new ErrorCode(1004008000, "用户积分记录业务类型不支持"); | |
| 34 | 36 | |
| 35 | 37 | //========== 签到配置 1004009000 ========== |
| 36 | 38 | ErrorCode SIGN_IN_CONFIG_NOT_EXISTS = new ErrorCode(1004009000, "签到天数规则不存在"); |
| ... | ... | @@ -38,4 +40,19 @@ public interface ErrorCodeConstants { |
| 38 | 40 | |
| 39 | 41 | //========== 签到配置 1004010000 ========== |
| 40 | 42 | |
| 43 | + | |
| 44 | + //========== 用户等级 1004011000 ========== | |
| 45 | + ErrorCode LEVEL_NOT_EXISTS = new ErrorCode(1004011000, "用户等级不存在"); | |
| 46 | + ErrorCode LEVEL_NAME_EXISTS = new ErrorCode(1004011001, "用户等级名称[{}]已被使用"); | |
| 47 | + ErrorCode LEVEL_VALUE_EXISTS = new ErrorCode(1004011002, "用户等级值[{}]已被[{}]使用"); | |
| 48 | + ErrorCode LEVEL_EXPERIENCE_MIN = new ErrorCode(1004011003, "升级经验必须大于上一个等级[{}]设置的升级经验[{}]"); | |
| 49 | + ErrorCode LEVEL_EXPERIENCE_MAX = new ErrorCode(1004011004, "升级经验必须小于下一个等级[{}]设置的升级经验[{}]"); | |
| 50 | + ErrorCode LEVEL_HAS_USER = new ErrorCode(1004011005, "用户等级下存在用户,无法删除"); | |
| 51 | + | |
| 52 | + ErrorCode EXPERIENCE_BIZ_NOT_SUPPORT = new ErrorCode(1004011201, "用户经验业务类型不支持"); | |
| 53 | + | |
| 54 | + //========== 用户分组 1004012000 ========== | |
| 55 | + ErrorCode GROUP_NOT_EXISTS = new ErrorCode(1004012000, "用户分组不存在"); | |
| 56 | + ErrorCode GROUP_HAS_USER = new ErrorCode(1004012001, "用户分组下存在用户,无法删除"); | |
| 57 | + | |
| 41 | 58 | } | ... | ... |
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/MemberExperienceBizTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.enums; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.EnumUtil; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Getter; | |
| 6 | + | |
| 7 | +import java.util.Objects; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 会员经验 - 业务类型 | |
| 11 | + * | |
| 12 | + * @author owen | |
| 13 | + */ | |
| 14 | +@Getter | |
| 15 | +@AllArgsConstructor | |
| 16 | +public enum MemberExperienceBizTypeEnum { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 管理员调整、邀请新用户、下单、退单、签到、抽奖 | |
| 20 | + */ | |
| 21 | + ADMIN(0, "管理员调整", "管理员调整获得 {} 经验", true), | |
| 22 | + INVITE_REGISTER(1, "邀新奖励", "邀请好友获得 {} 经验", true), | |
| 23 | + ORDER(2, "下单奖励", "下单获得 {} 经验", true), | |
| 24 | + REFUND(3, "退单扣除", "退单获得 {} 经验", false), | |
| 25 | + SIGN_IN(4, "签到奖励", "签到获得 {} 经验", true), | |
| 26 | + LOTTERY(5, "抽奖奖励", "抽奖获得 {} 经验", true), | |
| 27 | + ; | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 业务类型 | |
| 31 | + */ | |
| 32 | + private final int type; | |
| 33 | + /** | |
| 34 | + * 标题 | |
| 35 | + */ | |
| 36 | + private final String title; | |
| 37 | + /** | |
| 38 | + * 描述 | |
| 39 | + */ | |
| 40 | + private final String description; | |
| 41 | + /** | |
| 42 | + * 是否为扣减积分 | |
| 43 | + */ | |
| 44 | + private final boolean add; | |
| 45 | + | |
| 46 | + public static MemberExperienceBizTypeEnum getByType(Integer type) { | |
| 47 | + return EnumUtil.getBy(MemberExperienceBizTypeEnum.class, | |
| 48 | + e -> Objects.equals(type, e.getType())); | |
| 49 | + } | |
| 50 | +} | ... | ... |
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/point/MemberPointBizTypeEnum.java
| 1 | 1 | package cn.iocoder.yudao.module.member.enums.point; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.EnumUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; |
| 4 | 5 | import lombok.AllArgsConstructor; |
| 5 | 6 | import lombok.Getter; |
| 6 | 7 | |
| 8 | +import java.util.Objects; | |
| 9 | + | |
| 7 | 10 | /** |
| 8 | 11 | * 会员积分的业务类型枚举 |
| 9 | 12 | * |
| ... | ... | @@ -13,9 +16,9 @@ import lombok.Getter; |
| 13 | 16 | @Getter |
| 14 | 17 | public enum MemberPointBizTypeEnum implements IntArrayValuable { |
| 15 | 18 | |
| 16 | - SIGN(1, "签到"), | |
| 17 | - ORDER_BUY(10, "订单消费"), | |
| 18 | - ORDER_CANCEL(11, "订单取消"); // 退回积分 | |
| 19 | + SIGN(1, "签到", "签到获得 {} 积分", true), | |
| 20 | + ORDER_BUY(10, "订单消费", "下单获得 {} 积分", true), | |
| 21 | + ORDER_CANCEL(11, "订单取消", "退单获得 {} 积分", false); // 退回积分 | |
| 19 | 22 | |
| 20 | 23 | /** |
| 21 | 24 | * 类型 |
| ... | ... | @@ -25,10 +28,23 @@ public enum MemberPointBizTypeEnum implements IntArrayValuable { |
| 25 | 28 | * 名字 |
| 26 | 29 | */ |
| 27 | 30 | private final String name; |
| 31 | + /** | |
| 32 | + * 描述 | |
| 33 | + */ | |
| 34 | + private final String description; | |
| 35 | + /** | |
| 36 | + * 是否为扣减积分 | |
| 37 | + */ | |
| 38 | + private final boolean add; | |
| 28 | 39 | |
| 29 | 40 | @Override |
| 30 | 41 | public int[] array() { |
| 31 | 42 | return new int[0]; |
| 32 | 43 | } |
| 33 | 44 | |
| 45 | + public static MemberPointBizTypeEnum getByType(Integer type) { | |
| 46 | + return EnumUtil.getBy(MemberPointBizTypeEnum.class, | |
| 47 | + e -> Objects.equals(type, e.getType())); | |
| 48 | + } | |
| 49 | + | |
| 34 | 50 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.api.level; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; | |
| 4 | +import cn.iocoder.yudao.module.member.service.level.MemberLevelService; | |
| 5 | +import org.springframework.stereotype.Service; | |
| 6 | +import org.springframework.validation.annotation.Validated; | |
| 7 | + | |
| 8 | +import javax.annotation.Resource; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 11 | +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE_BIZ_NOT_SUPPORT; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 会员等级 API 实现类 | |
| 15 | + * | |
| 16 | + * @author owen | |
| 17 | + */ | |
| 18 | +@Service | |
| 19 | +@Validated | |
| 20 | +public class MemberLevelApiImpl implements MemberLevelApi { | |
| 21 | + | |
| 22 | + @Resource | |
| 23 | + private MemberLevelService memberLevelService; | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public void addExperience(Long userId, Integer experience, Integer bizType, String bizId) { | |
| 27 | + MemberExperienceBizTypeEnum bizTypeEnum = MemberExperienceBizTypeEnum.getByType(bizType); | |
| 28 | + if (bizTypeEnum == null) { | |
| 29 | + throw exception(EXPERIENCE_BIZ_NOT_SUPPORT); | |
| 30 | + } | |
| 31 | + memberLevelService.addExperience(userId, experience, bizTypeEnum, bizId); | |
| 32 | + } | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApiImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.api.point; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; | |
| 4 | +import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; | |
| 5 | +import org.springframework.stereotype.Service; | |
| 6 | +import org.springframework.validation.annotation.Validated; | |
| 7 | + | |
| 8 | +import javax.annotation.Resource; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 11 | +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.POINT_RECORD_BIZ_NOT_SUPPORT; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 用户积分的 API 实现类 | |
| 15 | + * | |
| 16 | + * @author owen | |
| 17 | + */ | |
| 18 | +@Service | |
| 19 | +@Validated | |
| 20 | +public class MemberPointApiImpl implements MemberPointApi { | |
| 21 | + | |
| 22 | + @Resource | |
| 23 | + private MemberPointRecordService memberPointRecordService; | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public void addPoint(Long userId, Integer point, Integer bizType, String bizId) { | |
| 27 | + MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType); | |
| 28 | + if (bizTypeEnum == null) { | |
| 29 | + throw exception(POINT_RECORD_BIZ_NOT_SUPPORT); | |
| 30 | + } | |
| 31 | + memberPointRecordService.createPointRecord(userId, point, bizTypeEnum, bizId); | |
| 32 | + } | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java
| 1 | 1 | package cn.iocoder.yudao.module.member.controller.admin.address; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressRespVO; | |
| 5 | +import cn.iocoder.yudao.module.member.convert.address.AddressConvert; | |
| 3 | 6 | import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; |
| 4 | -import org.springframework.web.bind.annotation.*; | |
| 5 | -import javax.annotation.Resource; | |
| 6 | -import org.springframework.validation.annotation.Validated; | |
| 7 | -import org.springframework.security.access.prepost.PreAuthorize; | |
| 8 | -import io.swagger.v3.oas.annotations.tags.Tag; | |
| 9 | -import io.swagger.v3.oas.annotations.Parameter; | |
| 7 | +import cn.iocoder.yudao.module.member.service.address.AddressService; | |
| 10 | 8 | import io.swagger.v3.oas.annotations.Operation; |
| 9 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 10 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 11 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 15 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 16 | +import org.springframework.web.bind.annotation.RestController; | |
| 11 | 17 | |
| 12 | -import javax.validation.constraints.*; | |
| 13 | -import javax.validation.*; | |
| 14 | -import javax.servlet.http.*; | |
| 15 | -import java.util.*; | |
| 16 | -import java.io.IOException; | |
| 18 | +import javax.annotation.Resource; | |
| 19 | +import java.util.List; | |
| 17 | 20 | |
| 18 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 19 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 20 | 21 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 21 | 22 | |
| 22 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 23 | - | |
| 24 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 25 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | |
| 26 | - | |
| 27 | -import cn.iocoder.yudao.module.member.controller.admin.address.vo.*; | |
| 28 | -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; | |
| 29 | -import cn.iocoder.yudao.module.member.service.address.AddressService; | |
| 30 | - | |
| 31 | 23 | @Tag(name = "管理后台 - 用户收件地址") |
| 32 | 24 | @RestController |
| 33 | 25 | @RequestMapping("/member/address") |
| ... | ... | @@ -37,66 +29,13 @@ public class AddressController { |
| 37 | 29 | @Resource |
| 38 | 30 | private AddressService addressService; |
| 39 | 31 | |
| 40 | - @PostMapping("/create") | |
| 41 | - @Operation(summary = "创建用户收件地址") | |
| 42 | - @PreAuthorize("@ss.hasPermission('member:address:create')") | |
| 43 | - public CommonResult<Long> createAddress(@Valid @RequestBody AddressCreateReqVO createReqVO) { | |
| 44 | - return success(addressService.createAddress(createReqVO)); | |
| 45 | - } | |
| 46 | - | |
| 47 | - @PutMapping("/update") | |
| 48 | - @Operation(summary = "更新用户收件地址") | |
| 49 | - @PreAuthorize("@ss.hasPermission('member:address:update')") | |
| 50 | - public CommonResult<Boolean> updateAddress(@Valid @RequestBody AddressUpdateReqVO updateReqVO) { | |
| 51 | - addressService.updateAddress(updateReqVO); | |
| 52 | - return success(true); | |
| 53 | - } | |
| 54 | - | |
| 55 | - @DeleteMapping("/delete") | |
| 56 | - @Operation(summary = "删除用户收件地址") | |
| 57 | - @Parameter(name = "id", description = "编号", required = true) | |
| 58 | - @PreAuthorize("@ss.hasPermission('member:address:delete')") | |
| 59 | - public CommonResult<Boolean> deleteAddress(@RequestParam("id") Long id) { | |
| 60 | - addressService.deleteAddress(id); | |
| 61 | - return success(true); | |
| 62 | - } | |
| 63 | - | |
| 64 | - @GetMapping("/get") | |
| 65 | - @Operation(summary = "获得用户收件地址") | |
| 66 | - @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 67 | - @PreAuthorize("@ss.hasPermission('member:address:query')") | |
| 68 | - public CommonResult<AddressRespVO> getAddress(@RequestParam("id") Long id) { | |
| 69 | - MemberAddressDO address = addressService.getAddress(id); | |
| 70 | - return success(AddressConvert.INSTANCE.convert2(address)); | |
| 71 | - } | |
| 72 | - | |
| 73 | 32 | @GetMapping("/list") |
| 74 | 33 | @Operation(summary = "获得用户收件地址列表") |
| 75 | - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | |
| 76 | - @PreAuthorize("@ss.hasPermission('member:address:query')") | |
| 77 | - public CommonResult<List<AddressRespVO>> getAddressList(@RequestParam("ids") Collection<Long> ids) { | |
| 78 | - List<MemberAddressDO> list = addressService.getAddressList(ids); | |
| 34 | + @Parameter(name = "userId", description = "用户编号", required = true) | |
| 35 | + @PreAuthorize("@ss.hasPermission('member:user:query')") | |
| 36 | + public CommonResult<List<AddressRespVO>> getAddressList(@RequestParam("userId") Long userId) { | |
| 37 | + List<MemberAddressDO> list = addressService.getAddressList(userId); | |
| 79 | 38 | return success(AddressConvert.INSTANCE.convertList2(list)); |
| 80 | 39 | } |
| 81 | 40 | |
| 82 | - @GetMapping("/page") | |
| 83 | - @Operation(summary = "获得用户收件地址分页") | |
| 84 | - @PreAuthorize("@ss.hasPermission('member:address:query')") | |
| 85 | - public CommonResult<PageResult<AddressRespVO>> getAddressPage(@Valid AddressPageReqVO pageVO) { | |
| 86 | - PageResult<MemberAddressDO> pageResult = addressService.getAddressPage(pageVO); | |
| 87 | - return success(AddressConvert.INSTANCE.convertPage(pageResult)); | |
| 88 | - } | |
| 89 | - | |
| 90 | - @GetMapping("/export-excel") | |
| 91 | - @Operation(summary = "导出用户收件地址 Excel") | |
| 92 | - @PreAuthorize("@ss.hasPermission('member:address:export')") | |
| 93 | - @OperateLog(type = EXPORT) | |
| 94 | - public void exportAddressExcel(@Valid AddressExportReqVO exportReqVO, | |
| 95 | - HttpServletResponse response) throws IOException { | |
| 96 | - List<MemberAddressDO> list = addressService.getAddressList(exportReqVO); | |
| 97 | - // 导出 Excel | |
| 98 | - List<AddressExcelVO> datas = AddressConvert.INSTANCE.convertList02(list); | |
| 99 | - ExcelUtils.write(response, "用户收件地址.xls", "数据", AddressExcelVO.class, datas); | |
| 100 | - } | |
| 101 | - | |
| 102 | 41 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.member.controller.admin.address.vo; | |
| 2 | - | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | -import javax.validation.constraints.*; | |
| 7 | - | |
| 8 | -@Schema(description = "管理后台 - 用户收件地址创建 Request VO") | |
| 9 | -@Data | |
| 10 | -@EqualsAndHashCode(callSuper = true) | |
| 11 | -@ToString(callSuper = true) | |
| 12 | -public class AddressCreateReqVO extends AddressBaseVO { | |
| 13 | - | |
| 14 | -} |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.member.controller.admin.address.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.*; | |
| 5 | -import java.util.*; | |
| 6 | -import java.time.LocalDateTime; | |
| 7 | -import java.time.LocalDateTime; | |
| 8 | - | |
| 9 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * 用户收件地址 Excel VO | |
| 13 | - * | |
| 14 | - * @author 绮梦 | |
| 15 | - */ | |
| 16 | -@Data | |
| 17 | -public class AddressExcelVO { | |
| 18 | - | |
| 19 | - @ExcelProperty("收件地址编号") | |
| 20 | - private Long id; | |
| 21 | - | |
| 22 | - @ExcelProperty("收件人名称") | |
| 23 | - private String name; | |
| 24 | - | |
| 25 | - @ExcelProperty("手机号") | |
| 26 | - private String mobile; | |
| 27 | - | |
| 28 | - @ExcelProperty("地区编码") | |
| 29 | - private Long areaId; | |
| 30 | - | |
| 31 | - @ExcelProperty("收件详细地址") | |
| 32 | - private String detailAddress; | |
| 33 | - | |
| 34 | - @ExcelProperty("是否默认") | |
| 35 | - private Boolean defaultStatus; | |
| 36 | - | |
| 37 | - @ExcelProperty("创建时间") | |
| 38 | - private LocalDateTime createTime; | |
| 39 | - | |
| 40 | -} |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.member.controller.admin.address.vo; | |
| 2 | - | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | -import java.time.LocalDateTime; | |
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | - | |
| 10 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | - | |
| 12 | -@Schema(description = "管理后台 - 用户收件地址 Excel 导出 Request VO,参数和 AddressPageReqVO 是一致的") | |
| 13 | -@Data | |
| 14 | -public class AddressExportReqVO { | |
| 15 | - | |
| 16 | - @Schema(description = "用户编号", example = "20369") | |
| 17 | - private Long userId; | |
| 18 | - | |
| 19 | - @Schema(description = "收件人名称", example = "张三") | |
| 20 | - private String name; | |
| 21 | - | |
| 22 | - @Schema(description = "手机号") | |
| 23 | - private String mobile; | |
| 24 | - | |
| 25 | - @Schema(description = "地区编码", example = "15716") | |
| 26 | - private Long areaId; | |
| 27 | - | |
| 28 | - @Schema(description = "收件详细地址") | |
| 29 | - private String detailAddress; | |
| 30 | - | |
| 31 | - @Schema(description = "是否默认", example = "2") | |
| 32 | - private Boolean defaultStatus; | |
| 33 | - | |
| 34 | - @Schema(description = "创建时间") | |
| 35 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 36 | - private LocalDateTime[] createTime; | |
| 37 | - | |
| 38 | -} |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.member.controller.admin.address.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.*; | |
| 5 | -import java.util.*; | |
| 6 | -import javax.validation.constraints.*; | |
| 7 | - | |
| 8 | -@Schema(description = "管理后台 - 用户收件地址更新 Request VO") | |
| 9 | -@Data | |
| 10 | -@EqualsAndHashCode(callSuper = true) | |
| 11 | -@ToString(callSuper = true) | |
| 12 | -public class AddressUpdateReqVO extends AddressBaseVO { | |
| 13 | - | |
| 14 | - @Schema(description = "收件地址编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7380") | |
| 15 | - @NotNull(message = "收件地址编号不能为空") | |
| 16 | - private Long id; | |
| 17 | - | |
| 18 | -} |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/MemberGroupController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.group; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.member.controller.admin.group.vo.*; | |
| 6 | +import cn.iocoder.yudao.module.member.convert.group.MemberGroupConvert; | |
| 7 | +import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; | |
| 8 | +import cn.iocoder.yudao.module.member.service.group.MemberGroupService; | |
| 9 | +import io.swagger.v3.oas.annotations.Operation; | |
| 10 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 11 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 12 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | +import org.springframework.web.bind.annotation.*; | |
| 15 | + | |
| 16 | +import javax.annotation.Resource; | |
| 17 | +import javax.validation.Valid; | |
| 18 | +import java.util.List; | |
| 19 | + | |
| 20 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 21 | + | |
| 22 | + | |
| 23 | +@Tag(name = "管理后台 - 用户分组") | |
| 24 | +@RestController | |
| 25 | +@RequestMapping("/member/group") | |
| 26 | +@Validated | |
| 27 | +public class MemberGroupController { | |
| 28 | + | |
| 29 | + @Resource | |
| 30 | + private MemberGroupService groupService; | |
| 31 | + | |
| 32 | + @PostMapping("/create") | |
| 33 | + @Operation(summary = "创建用户分组") | |
| 34 | + @PreAuthorize("@ss.hasPermission('member:group:create')") | |
| 35 | + public CommonResult<Long> createGroup(@Valid @RequestBody MemberGroupCreateReqVO createReqVO) { | |
| 36 | + return success(groupService.createGroup(createReqVO)); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @PutMapping("/update") | |
| 40 | + @Operation(summary = "更新用户分组") | |
| 41 | + @PreAuthorize("@ss.hasPermission('member:group:update')") | |
| 42 | + public CommonResult<Boolean> updateGroup(@Valid @RequestBody MemberGroupUpdateReqVO updateReqVO) { | |
| 43 | + groupService.updateGroup(updateReqVO); | |
| 44 | + return success(true); | |
| 45 | + } | |
| 46 | + | |
| 47 | + @DeleteMapping("/delete") | |
| 48 | + @Operation(summary = "删除用户分组") | |
| 49 | + @Parameter(name = "id", description = "编号", required = true) | |
| 50 | + @PreAuthorize("@ss.hasPermission('member:group:delete')") | |
| 51 | + public CommonResult<Boolean> deleteGroup(@RequestParam("id") Long id) { | |
| 52 | + groupService.deleteGroup(id); | |
| 53 | + return success(true); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @GetMapping("/get") | |
| 57 | + @Operation(summary = "获得用户分组") | |
| 58 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 59 | + @PreAuthorize("@ss.hasPermission('member:group:query')") | |
| 60 | + public CommonResult<MemberGroupRespVO> getGroup(@RequestParam("id") Long id) { | |
| 61 | + MemberGroupDO group = groupService.getGroup(id); | |
| 62 | + return success(MemberGroupConvert.INSTANCE.convert(group)); | |
| 63 | + } | |
| 64 | + | |
| 65 | + @GetMapping("/list-all-simple") | |
| 66 | + @Operation(summary = "获取会员分组精简信息列表", description = "只包含被开启的会员分组,主要用于前端的下拉选项") | |
| 67 | + public CommonResult<List<MemberGroupSimpleRespVO>> getSimpleGroupList() { | |
| 68 | + // 获用户列表,只要开启状态的 | |
| 69 | + List<MemberGroupDO> list = groupService.getEnableGroupList(); | |
| 70 | + return success(MemberGroupConvert.INSTANCE.convertSimpleList(list)); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @GetMapping("/page") | |
| 74 | + @Operation(summary = "获得用户分组分页") | |
| 75 | + @PreAuthorize("@ss.hasPermission('member:group:query')") | |
| 76 | + public CommonResult<PageResult<MemberGroupRespVO>> getGroupPage(@Valid MemberGroupPageReqVO pageVO) { | |
| 77 | + PageResult<MemberGroupDO> pageResult = groupService.getGroupPage(pageVO); | |
| 78 | + return success(MemberGroupConvert.INSTANCE.convertPage(pageResult)); | |
| 79 | + } | |
| 80 | + | |
| 81 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.group.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 用户分组 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 12 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +public class MemberGroupBaseVO { | |
| 16 | + | |
| 17 | + @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "购物达人") | |
| 18 | + @NotNull(message = "名称不能为空") | |
| 19 | + private String name; | |
| 20 | + | |
| 21 | + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") | |
| 22 | + private String remark; | |
| 23 | + | |
| 24 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 25 | + @NotNull(message = "状态不能为空") | |
| 26 | + @InEnum(CommonStatusEnum.class) | |
| 27 | + private Integer status; | |
| 28 | + | |
| 29 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.group.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 用户分组创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class MemberGroupCreateReqVO extends MemberGroupBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreExportReqVO.java renamed to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupPageReqVO.java
| 1 | -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; | |
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.group.vo; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 5 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 5 | import lombok.Data; |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 7 | 8 | import org.springframework.format.annotation.DateTimeFormat; |
| 8 | 9 | |
| 9 | 10 | import java.time.LocalDateTime; |
| 10 | 11 | |
| 11 | 12 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 12 | 13 | |
| 13 | -@Schema(description = "管理后台 - 自提门店 Excel 导出 Request VO,参数和 DeliveryPickUpStorePageReqVO 是一致的") | |
| 14 | +@Schema(description = "管理后台 - 用户分组分页 Request VO") | |
| 14 | 15 | @Data |
| 15 | -public class DeliveryPickUpStoreExportReqVO { | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class MemberGroupPageReqVO extends PageParam { | |
| 16 | 19 | |
| 17 | - @Schema(description = "门店名称", example = "李四") | |
| 20 | + @Schema(description = "名称", example = "购物达人") | |
| 18 | 21 | private String name; |
| 19 | 22 | |
| 20 | - @Schema(description = "门店手机") | |
| 21 | - private String phone; | |
| 22 | - | |
| 23 | - @Schema(description = "区域id", example = "18733") | |
| 24 | - private Integer areaId; | |
| 25 | - | |
| 26 | - @Schema(description = "门店状态", example = "1") | |
| 27 | - @InEnum(CommonStatusEnum.class) | |
| 23 | + @Schema(description = "状态", example = "1") | |
| 28 | 24 | private Integer status; |
| 29 | 25 | |
| 30 | 26 | @Schema(description = "创建时间") | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.group.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 用户分组 Response VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class MemberGroupRespVO extends MemberGroupBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20357") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupSimpleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.group.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.ToString; | |
| 6 | + | |
| 7 | +@Schema(description = "管理后台 - 用户分组 Response VO") | |
| 8 | +@Data | |
| 9 | +@ToString(callSuper = true) | |
| 10 | +public class MemberGroupSimpleRespVO { | |
| 11 | + | |
| 12 | + @Schema(description = "编号", example = "6103") | |
| 13 | + private Long id; | |
| 14 | + | |
| 15 | + @Schema(description = "等级名称", example = "芋艿") | |
| 16 | + private String name; | |
| 17 | + | |
| 18 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.group.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 用户分组更新 Request VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class MemberGroupUpdateReqVO extends MemberGroupBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20357") | |
| 17 | + @NotNull(message = "编号不能为空") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceRecordController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordRespVO; | |
| 7 | +import cn.iocoder.yudao.module.member.convert.level.MemberExperienceRecordConvert; | |
| 8 | +import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; | |
| 9 | +import cn.iocoder.yudao.module.member.service.level.MemberExperienceRecordService; | |
| 10 | +import io.swagger.v3.oas.annotations.Operation; | |
| 11 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 12 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 13 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 14 | +import org.springframework.validation.annotation.Validated; | |
| 15 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 16 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 17 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 18 | +import org.springframework.web.bind.annotation.RestController; | |
| 19 | + | |
| 20 | +import javax.annotation.Resource; | |
| 21 | +import javax.validation.Valid; | |
| 22 | + | |
| 23 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 24 | + | |
| 25 | +@Tag(name = "管理后台 - 会员经验记录") | |
| 26 | +@RestController | |
| 27 | +@RequestMapping("/member/experience-record") | |
| 28 | +@Validated | |
| 29 | +public class MemberExperienceRecordController { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private MemberExperienceRecordService experienceLogService; | |
| 33 | + | |
| 34 | + @GetMapping("/get") | |
| 35 | + @Operation(summary = "获得会员经验记录") | |
| 36 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 37 | + @PreAuthorize("@ss.hasPermission('member:experience-record:query')") | |
| 38 | + public CommonResult<MemberExperienceRecordRespVO> getExperienceRecord(@RequestParam("id") Long id) { | |
| 39 | + MemberExperienceRecordDO experienceLog = experienceLogService.getExperienceRecord(id); | |
| 40 | + return success(MemberExperienceRecordConvert.INSTANCE.convert(experienceLog)); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @GetMapping("/page") | |
| 44 | + @Operation(summary = "获得会员经验记录分页") | |
| 45 | + @PreAuthorize("@ss.hasPermission('member:experience-record:query')") | |
| 46 | + public CommonResult<PageResult<MemberExperienceRecordRespVO>> getExperienceRecordPage( | |
| 47 | + @Valid MemberExperienceRecordPageReqVO pageVO) { | |
| 48 | + PageResult<MemberExperienceRecordDO> pageResult = experienceLogService.getExperienceRecordPage(pageVO); | |
| 49 | + return success(MemberExperienceRecordConvert.INSTANCE.convertPage(pageResult)); | |
| 50 | + } | |
| 51 | + | |
| 52 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.*; | |
| 5 | +import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; | |
| 6 | +import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; | |
| 7 | +import cn.iocoder.yudao.module.member.service.level.MemberLevelService; | |
| 8 | +import io.swagger.v3.oas.annotations.Operation; | |
| 9 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 10 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 11 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | +import org.springframework.web.bind.annotation.*; | |
| 14 | + | |
| 15 | +import javax.annotation.Resource; | |
| 16 | +import javax.validation.Valid; | |
| 17 | +import java.util.List; | |
| 18 | + | |
| 19 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 20 | + | |
| 21 | +@Tag(name = "管理后台 - 会员等级") | |
| 22 | +@RestController | |
| 23 | +@RequestMapping("/member/level") | |
| 24 | +@Validated | |
| 25 | +public class MemberLevelController { | |
| 26 | + | |
| 27 | + @Resource | |
| 28 | + private MemberLevelService levelService; | |
| 29 | + | |
| 30 | + @PostMapping("/create") | |
| 31 | + @Operation(summary = "创建会员等级") | |
| 32 | + @PreAuthorize("@ss.hasPermission('member:level:create')") | |
| 33 | + public CommonResult<Long> createLevel(@Valid @RequestBody MemberLevelCreateReqVO createReqVO) { | |
| 34 | + return success(levelService.createLevel(createReqVO)); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @PutMapping("/update") | |
| 38 | + @Operation(summary = "更新会员等级") | |
| 39 | + @PreAuthorize("@ss.hasPermission('member:level:update')") | |
| 40 | + public CommonResult<Boolean> updateLevel(@Valid @RequestBody MemberLevelUpdateReqVO updateReqVO) { | |
| 41 | + levelService.updateLevel(updateReqVO); | |
| 42 | + return success(true); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @DeleteMapping("/delete") | |
| 46 | + @Operation(summary = "删除会员等级") | |
| 47 | + @Parameter(name = "id", description = "编号", required = true) | |
| 48 | + @PreAuthorize("@ss.hasPermission('member:level:delete')") | |
| 49 | + public CommonResult<Boolean> deleteLevel(@RequestParam("id") Long id) { | |
| 50 | + levelService.deleteLevel(id); | |
| 51 | + return success(true); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @GetMapping("/get") | |
| 55 | + @Operation(summary = "获得会员等级") | |
| 56 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 57 | + @PreAuthorize("@ss.hasPermission('member:level:query')") | |
| 58 | + public CommonResult<MemberLevelRespVO> getLevel(@RequestParam("id") Long id) { | |
| 59 | + MemberLevelDO level = levelService.getLevel(id); | |
| 60 | + return success(MemberLevelConvert.INSTANCE.convert(level)); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @GetMapping("/list-all-simple") | |
| 64 | + @Operation(summary = "获取会员等级精简信息列表", description = "只包含被开启的会员等级,主要用于前端的下拉选项") | |
| 65 | + public CommonResult<List<MemberLevelSimpleRespVO>> getSimpleLevelList() { | |
| 66 | + // 获用户列表,只要开启状态的 | |
| 67 | + List<MemberLevelDO> list = levelService.getEnableLevelList(); | |
| 68 | + // 排序后,返回给前端 | |
| 69 | + return success(MemberLevelConvert.INSTANCE.convertSimpleList(list)); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @GetMapping("/list") | |
| 73 | + @Operation(summary = "获得会员等级列表") | |
| 74 | + @PreAuthorize("@ss.hasPermission('member:level:query')") | |
| 75 | + public CommonResult<List<MemberLevelRespVO>> getLevelList(@Valid MemberLevelListReqVO pageVO) { | |
| 76 | + List<MemberLevelDO> result = levelService.getLevelList(pageVO); | |
| 77 | + return success(MemberLevelConvert.INSTANCE.convertList(result)); | |
| 78 | + } | |
| 79 | + | |
| 80 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelRecordController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelRecordPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.member.controller.admin.level.vo.log.MemberLevelRecordRespVO; | |
| 7 | +import cn.iocoder.yudao.module.member.convert.level.MemberLevelRecordConvert; | |
| 8 | +import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; | |
| 9 | +import cn.iocoder.yudao.module.member.service.level.MemberLevelRecordService; | |
| 10 | +import io.swagger.v3.oas.annotations.Operation; | |
| 11 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 12 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 13 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 14 | +import org.springframework.validation.annotation.Validated; | |
| 15 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 16 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 17 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 18 | +import org.springframework.web.bind.annotation.RestController; | |
| 19 | + | |
| 20 | +import javax.annotation.Resource; | |
| 21 | +import javax.validation.Valid; | |
| 22 | + | |
| 23 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 24 | + | |
| 25 | +@Tag(name = "管理后台 - 会员等级记录") | |
| 26 | +@RestController | |
| 27 | +@RequestMapping("/member/level-record") | |
| 28 | +@Validated | |
| 29 | +public class MemberLevelRecordController { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private MemberLevelRecordService levelLogService; | |
| 33 | + | |
| 34 | + @GetMapping("/get") | |
| 35 | + @Operation(summary = "获得会员等级记录") | |
| 36 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 37 | + @PreAuthorize("@ss.hasPermission('member:level-record:query')") | |
| 38 | + public CommonResult<MemberLevelRecordRespVO> getLevelRecord(@RequestParam("id") Long id) { | |
| 39 | + MemberLevelRecordDO levelLog = levelLogService.getLevelRecord(id); | |
| 40 | + return success(MemberLevelRecordConvert.INSTANCE.convert(levelLog)); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @GetMapping("/page") | |
| 44 | + @Operation(summary = "获得会员等级记录分页") | |
| 45 | + @PreAuthorize("@ss.hasPermission('member:level-record:query')") | |
| 46 | + public CommonResult<PageResult<MemberLevelRecordRespVO>> getLevelRecordPage( | |
| 47 | + @Valid MemberLevelRecordPageReqVO pageVO) { | |
| 48 | + PageResult<MemberLevelRecordDO> pageResult = levelLogService.getLevelRecordPage(pageVO); | |
| 49 | + return success(MemberLevelRecordConvert.INSTANCE.convertPage(pageResult)); | |
| 50 | + } | |
| 51 | + | |
| 52 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 会员经验记录 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | + */ | |
| 12 | +@Data | |
| 13 | +public class MemberExperienceRecordBaseVO { | |
| 14 | + | |
| 15 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3638") | |
| 16 | + @NotNull(message = "用户编号不能为空") | |
| 17 | + private Long userId; | |
| 18 | + | |
| 19 | + @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12164") | |
| 20 | + @NotNull(message = "业务编号不能为空") | |
| 21 | + private String bizId; | |
| 22 | + | |
| 23 | + @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 24 | + @NotNull(message = "业务类型不能为空") | |
| 25 | + private Integer bizType; | |
| 26 | + | |
| 27 | + @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "增加经验") | |
| 28 | + @NotNull(message = "标题不能为空") | |
| 29 | + private String title; | |
| 30 | + | |
| 31 | + @Schema(description = "经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 32 | + @NotNull(message = "经验不能为空") | |
| 33 | + private Integer experience; | |
| 34 | + | |
| 35 | + @Schema(description = "变更后的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") | |
| 36 | + @NotNull(message = "变更后的经验不能为空") | |
| 37 | + private Integer totalExperience; | |
| 38 | + | |
| 39 | + @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单增加 100 经验") | |
| 40 | + @NotNull(message = "描述不能为空") | |
| 41 | + private String description; | |
| 42 | + | |
| 43 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - 会员经验记录分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class MemberExperienceRecordPageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "用户编号", example = "3638") | |
| 21 | + private Long userId; | |
| 22 | + | |
| 23 | + @Schema(description = "业务编号", example = "12164") | |
| 24 | + private String bizId; | |
| 25 | + | |
| 26 | + @Schema(description = "业务类型", example = "1") | |
| 27 | + private Integer bizType; | |
| 28 | + | |
| 29 | + @Schema(description = "标题", example = "增加经验") | |
| 30 | + private String title; | |
| 31 | + | |
| 32 | + @Schema(description = "创建时间") | |
| 33 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 34 | + private LocalDateTime[] createTime; | |
| 35 | + | |
| 36 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 会员经验记录 Response VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class MemberExperienceRecordRespVO extends MemberExperienceRecordBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19610") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import lombok.Data; | |
| 7 | +import org.hibernate.validator.constraints.Range; | |
| 8 | +import org.hibernate.validator.constraints.URL; | |
| 9 | + | |
| 10 | +import javax.validation.constraints.NotBlank; | |
| 11 | +import javax.validation.constraints.NotNull; | |
| 12 | +import javax.validation.constraints.Positive; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 会员等级 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 16 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 17 | + */ | |
| 18 | +@Data | |
| 19 | +public class MemberLevelBaseVO { | |
| 20 | + | |
| 21 | + @Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | |
| 22 | + @NotBlank(message = "等级名称不能为空") | |
| 23 | + private String name; | |
| 24 | + | |
| 25 | + @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 26 | + @NotNull(message = "升级经验不能为空") | |
| 27 | + @Positive(message = "升级经验必须大于 0") | |
| 28 | + private Integer experience; | |
| 29 | + | |
| 30 | + @Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 31 | + @NotNull(message = "等级不能为空") | |
| 32 | + @Positive(message = "等级必须大于 0") | |
| 33 | + private Integer level; | |
| 34 | + | |
| 35 | + @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "98") | |
| 36 | + @NotNull(message = "享受折扣不能为空") | |
| 37 | + @Range(min = 0, max = 100, message = "享受折扣的范围为 0-100") | |
| 38 | + private Integer discountPercent; | |
| 39 | + | |
| 40 | + @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") | |
| 41 | + @URL(message = "等级图标必须是 URL 格式") | |
| 42 | + private String icon; | |
| 43 | + | |
| 44 | + @Schema(description = "等级背景图", example = "https://www.iocoder.cn/yudao.jpg") | |
| 45 | + @URL(message = "等级背景图必须是 URL 格式") | |
| 46 | + private String backgroundUrl; | |
| 47 | + | |
| 48 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 49 | + @NotNull(message = "状态不能为空") | |
| 50 | + @InEnum(CommonStatusEnum.class) | |
| 51 | + private Integer status; | |
| 52 | + | |
| 53 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 会员等级创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class MemberLevelCreateReqVO extends MemberLevelBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.ToString; | |
| 6 | + | |
| 7 | +@Schema(description = "管理后台 - 会员等级列表筛选 Request VO") | |
| 8 | +@Data | |
| 9 | +@ToString(callSuper = true) | |
| 10 | +public class MemberLevelListReqVO { | |
| 11 | + | |
| 12 | + @Schema(description = "等级名称", example = "芋艿") | |
| 13 | + private String name; | |
| 14 | + | |
| 15 | + @Schema(description = "状态", example = "1") | |
| 16 | + private Integer status; | |
| 17 | + | |
| 18 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 会员等级 Response VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class MemberLevelRespVO extends MemberLevelBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6103") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.ToString; | |
| 6 | + | |
| 7 | +@Schema(description = "管理后台 - 会员等级 Response VO") | |
| 8 | +@Data | |
| 9 | +@ToString(callSuper = true) | |
| 10 | +public class MemberLevelSimpleRespVO { | |
| 11 | + | |
| 12 | + @Schema(description = "编号", example = "6103") | |
| 13 | + private Long id; | |
| 14 | + | |
| 15 | + @Schema(description = "等级名称", example = "芋艿") | |
| 16 | + private String name; | |
| 17 | + | |
| 18 | + @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") | |
| 19 | + private String icon; | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 会员等级更新 Request VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class MemberLevelUpdateReqVO extends MemberLevelBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6103") | |
| 17 | + @NotNull(message = "编号不能为空") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/log/MemberLevelRecordBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.log; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 会员等级记录 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | + */ | |
| 12 | +@Data | |
| 13 | +public class MemberLevelRecordBaseVO { | |
| 14 | + | |
| 15 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25923") | |
| 16 | + @NotNull(message = "用户编号不能为空") | |
| 17 | + private Long userId; | |
| 18 | + | |
| 19 | + @Schema(description = "等级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25985") | |
| 20 | + @NotNull(message = "等级编号不能为空") | |
| 21 | + private Long levelId; | |
| 22 | + | |
| 23 | + @Schema(description = "会员等级", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 24 | + @NotNull(message = "会员等级不能为空") | |
| 25 | + private Integer level; | |
| 26 | + | |
| 27 | + @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319") | |
| 28 | + @NotNull(message = "享受折扣不能为空") | |
| 29 | + private Integer discountPercent; | |
| 30 | + | |
| 31 | + @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319") | |
| 32 | + @NotNull(message = "升级经验不能为空") | |
| 33 | + private Integer experience; | |
| 34 | + | |
| 35 | + @Schema(description = "会员此时的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319") | |
| 36 | + @NotNull(message = "会员此时的经验不能为空") | |
| 37 | + private Integer userExperience; | |
| 38 | + | |
| 39 | + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "推广需要") | |
| 40 | + @NotNull(message = "备注不能为空") | |
| 41 | + private String remark; | |
| 42 | + | |
| 43 | + @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "升级为金牌会员") | |
| 44 | + @NotNull(message = "描述不能为空") | |
| 45 | + private String description; | |
| 46 | + | |
| 47 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressPageReqVO.java renamed to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/log/MemberLevelRecordPageReqVO.java
| 1 | -package cn.iocoder.yudao.module.member.controller.admin.address.vo; | |
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.log; | |
| 2 | 2 | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 7 | 8 | import org.springframework.format.annotation.DateTimeFormat; |
| 9 | + | |
| 8 | 10 | import java.time.LocalDateTime; |
| 9 | 11 | |
| 10 | 12 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 11 | 13 | |
| 12 | -@Schema(description = "管理后台 - 用户收件地址分页 Request VO") | |
| 14 | +@Schema(description = "管理后台 - 会员等级记录分页 Request VO") | |
| 13 | 15 | @Data |
| 14 | 16 | @EqualsAndHashCode(callSuper = true) |
| 15 | 17 | @ToString(callSuper = true) |
| 16 | -public class AddressPageReqVO extends PageParam { | |
| 18 | +public class MemberLevelRecordPageReqVO extends PageParam { | |
| 17 | 19 | |
| 18 | - @Schema(description = "用户编号", example = "20369") | |
| 20 | + @Schema(description = "用户编号", example = "25923") | |
| 19 | 21 | private Long userId; |
| 20 | 22 | |
| 21 | - @Schema(description = "收件人名称", example = "张三") | |
| 22 | - private String name; | |
| 23 | - | |
| 24 | - @Schema(description = "手机号") | |
| 25 | - private String mobile; | |
| 26 | - | |
| 27 | - @Schema(description = "地区编码", example = "15716") | |
| 28 | - private Long areaId; | |
| 29 | - | |
| 30 | - @Schema(description = "收件详细地址") | |
| 31 | - private String detailAddress; | |
| 32 | - | |
| 33 | - @Schema(description = "是否默认", example = "2") | |
| 34 | - private Boolean defaultStatus; | |
| 23 | + @Schema(description = "等级编号", example = "25985") | |
| 24 | + private Long levelId; | |
| 35 | 25 | |
| 36 | 26 | @Schema(description = "创建时间") |
| 37 | 27 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/log/MemberLevelRecordRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.level.vo.log; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 会员等级记录 Response VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class MemberLevelRecordRespVO extends MemberLevelRecordBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8741") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointConfigController.java
| ... | ... | @@ -29,16 +29,16 @@ public class MemberPointConfigController { |
| 29 | 29 | @PutMapping("/save") |
| 30 | 30 | @Operation(summary = "保存会员积分配置") |
| 31 | 31 | @PreAuthorize("@ss.hasPermission('point:config:save')") |
| 32 | - public CommonResult<Boolean> updateConfig(@Valid @RequestBody MemberPointConfigSaveReqVO saveReqVO) { | |
| 33 | - memberPointConfigService.saveConfig(saveReqVO); | |
| 32 | + public CommonResult<Boolean> savePointConfig(@Valid @RequestBody MemberPointConfigSaveReqVO saveReqVO) { | |
| 33 | + memberPointConfigService.savePointConfig(saveReqVO); | |
| 34 | 34 | return success(true); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | @GetMapping("/get") |
| 38 | 38 | @Operation(summary = "获得会员积分配置") |
| 39 | 39 | @PreAuthorize("@ss.hasPermission('point:config:query')") |
| 40 | - public CommonResult<MemberPointConfigRespVO> getConfig() { | |
| 41 | - MemberPointConfigDO config = memberPointConfigService.getConfig(); | |
| 40 | + public CommonResult<MemberPointConfigRespVO> getPointConfig() { | |
| 41 | + MemberPointConfigDO config = memberPointConfigService.getPointConfig(); | |
| 42 | 42 | return success(MemberPointConfigConvert.INSTANCE.convert(config)); |
| 43 | 43 | } |
| 44 | 44 | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java
| ... | ... | @@ -25,6 +25,7 @@ import java.util.List; |
| 25 | 25 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 26 | 26 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 27 | 27 | |
| 28 | +@Tag(name = "管理后台 - 签到记录") | |
| 28 | 29 | @RestController |
| 29 | 30 | @RequestMapping("/member/point/record") |
| 30 | 31 | @Validated |
| ... | ... | @@ -39,9 +40,9 @@ public class MemberPointRecordController { |
| 39 | 40 | @GetMapping("/page") |
| 40 | 41 | @Operation(summary = "获得用户积分记录分页") |
| 41 | 42 | @PreAuthorize("@ss.hasPermission('point:record:query')") |
| 42 | - public CommonResult<PageResult<MemberPointRecordRespVO>> getRecordPage(@Valid MemberPointRecordPageReqVO pageVO) { | |
| 43 | + public CommonResult<PageResult<MemberPointRecordRespVO>> getPointRecordPage(@Valid MemberPointRecordPageReqVO pageVO) { | |
| 43 | 44 | // 执行分页查询 |
| 44 | - PageResult<MemberPointRecordDO> pageResult = pointRecordService.getRecordPage(pageVO); | |
| 45 | + PageResult<MemberPointRecordDO> pageResult = pointRecordService.getPointRecordPage(pageVO); | |
| 45 | 46 | if (CollectionUtils.isEmpty(pageResult.getList())) { |
| 46 | 47 | return success(PageResult.empty(pageResult.getTotal())); |
| 47 | 48 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java
| ... | ... | @@ -15,7 +15,7 @@ public class MemberPointRecordPageReqVO extends PageParam { |
| 15 | 15 | @Schema(description = "用户昵称", example = "张三") |
| 16 | 16 | private String nickname; |
| 17 | 17 | |
| 18 | - @Schema(description = "用户ID", example = "123") | |
| 18 | + @Schema(description = "用户编号", example = "123") | |
| 19 | 19 | private Long userId; |
| 20 | 20 | |
| 21 | 21 | @Schema(description = "业务类型", example = "1") | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java
| ... | ... | @@ -20,9 +20,10 @@ import java.util.List; |
| 20 | 20 | |
| 21 | 21 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 22 | 22 | |
| 23 | +// TODO 芋艿:url | |
| 23 | 24 | @Tag(name = "管理后台 - 签到规则") |
| 24 | 25 | @RestController |
| 25 | -@RequestMapping("/member/point/sign-in-config") | |
| 26 | +@RequestMapping("/member/sign-in/config") | |
| 26 | 27 | @Validated |
| 27 | 28 | public class MemberSignInConfigController { |
| 28 | 29 | |
| ... | ... | @@ -66,8 +67,8 @@ public class MemberSignInConfigController { |
| 66 | 67 | @Operation(summary = "获得签到规则列表") |
| 67 | 68 | @PreAuthorize("@ss.hasPermission('point:sign-in-config:query')") |
| 68 | 69 | public CommonResult<List<MemberSignInConfigRespVO>> getSignInConfigList() { |
| 69 | - List<MemberSignInConfigDO> pageResult = signInConfigService.getSignInConfigList(); | |
| 70 | - return success(MemberSignInConfigConvert.INSTANCE.convertList(pageResult)); | |
| 70 | + List<MemberSignInConfigDO> list = signInConfigService.getSignInConfigList(); | |
| 71 | + return success(MemberSignInConfigConvert.INSTANCE.convertList(list)); | |
| 71 | 72 | } |
| 72 | 73 | |
| 73 | 74 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java
| ... | ... | @@ -27,7 +27,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. |
| 27 | 27 | |
| 28 | 28 | @Tag(name = "管理后台 - 签到记录") |
| 29 | 29 | @RestController |
| 30 | -@RequestMapping("/member/point/sign-in-record") | |
| 30 | +@RequestMapping("/member/sign-in/record") | |
| 31 | 31 | @Validated |
| 32 | 32 | public class MemberSignInRecordController { |
| 33 | 33 | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordPageReqVO.java
| ... | ... | @@ -23,7 +23,7 @@ public class MemberSignInRecordPageReqVO extends PageParam { |
| 23 | 23 | @Schema(description = "第几天签到", example = "10") |
| 24 | 24 | private Integer day; |
| 25 | 25 | |
| 26 | - @Schema(description = "用户ID", example = "123") | |
| 26 | + @Schema(description = "用户编号", example = "123") | |
| 27 | 27 | private Long userId; |
| 28 | 28 | |
| 29 | 29 | @Schema(description = "签到时间") | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java
| ... | ... | @@ -65,6 +65,15 @@ public class MemberTagController { |
| 65 | 65 | return success(MemberTagConvert.INSTANCE.convert(tag)); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | + @GetMapping("/list-all-simple") | |
| 69 | + @Operation(summary = "获取会员标签精简信息列表", description = "只包含被开启的会员标签,主要用于前端的下拉选项") | |
| 70 | + public CommonResult<List<MemberTagRespVO>> getSimpleTagList() { | |
| 71 | + // 获用户列表,只要开启状态的 | |
| 72 | + List<MemberTagDO> list = tagService.getTagList(); | |
| 73 | + // 排序后,返回给前端 | |
| 74 | + return success(MemberTagConvert.INSTANCE.convertList(list)); | |
| 75 | + } | |
| 76 | + | |
| 68 | 77 | @GetMapping("/list") |
| 69 | 78 | @Operation(summary = "获得会员标签列表") |
| 70 | 79 | @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java
| ... | ... | @@ -5,10 +5,15 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserRespVO; |
| 8 | +import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO; | |
| 8 | 9 | import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; |
| 9 | 10 | import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; |
| 11 | +import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; | |
| 12 | +import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; | |
| 10 | 13 | import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; |
| 11 | 14 | import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; |
| 15 | +import cn.iocoder.yudao.module.member.service.group.MemberGroupService; | |
| 16 | +import cn.iocoder.yudao.module.member.service.level.MemberLevelService; | |
| 12 | 17 | import cn.iocoder.yudao.module.member.service.tag.MemberTagService; |
| 13 | 18 | import cn.iocoder.yudao.module.member.service.user.MemberUserService; |
| 14 | 19 | import io.swagger.v3.oas.annotations.Operation; |
| ... | ... | @@ -27,6 +32,7 @@ import java.util.Set; |
| 27 | 32 | import java.util.stream.Collectors; |
| 28 | 33 | |
| 29 | 34 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 35 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 30 | 36 | |
| 31 | 37 | @Tag(name = "管理后台 - 会员用户") |
| 32 | 38 | @RestController |
| ... | ... | @@ -38,6 +44,10 @@ public class MemberUserController { |
| 38 | 44 | private MemberUserService memberUserService; |
| 39 | 45 | @Resource |
| 40 | 46 | private MemberTagService memberTagService; |
| 47 | + @Resource | |
| 48 | + private MemberLevelService memberLevelService; | |
| 49 | + @Resource | |
| 50 | + private MemberGroupService memberGroupService; | |
| 41 | 51 | |
| 42 | 52 | @PutMapping("/update") |
| 43 | 53 | @Operation(summary = "更新会员用户") |
| ... | ... | @@ -47,6 +57,14 @@ public class MemberUserController { |
| 47 | 57 | return success(true); |
| 48 | 58 | } |
| 49 | 59 | |
| 60 | + @PutMapping("/update-level") | |
| 61 | + @Operation(summary = "更新会员用户等级") | |
| 62 | + @PreAuthorize("@ss.hasPermission('member:user:update-level')") | |
| 63 | + public CommonResult<Boolean> updateUserLevel(@Valid @RequestBody MemberUserUpdateLevelReqVO updateReqVO) { | |
| 64 | + memberLevelService.updateUserLevel(updateReqVO); | |
| 65 | + return success(true); | |
| 66 | + } | |
| 67 | + | |
| 50 | 68 | @GetMapping("/get") |
| 51 | 69 | @Operation(summary = "获得会员用户") |
| 52 | 70 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| ... | ... | @@ -65,14 +83,20 @@ public class MemberUserController { |
| 65 | 83 | return success(PageResult.empty()); |
| 66 | 84 | } |
| 67 | 85 | |
| 68 | - // 处理会员标签返显 | |
| 86 | + // 处理用户标签返显 | |
| 69 | 87 | Set<Long> tagIds = pageResult.getList().stream() |
| 70 | 88 | .map(MemberUserDO::getTagIds) |
| 71 | 89 | .filter(Objects::nonNull) |
| 72 | 90 | .flatMap(Collection::stream) |
| 73 | 91 | .collect(Collectors.toSet()); |
| 74 | 92 | List<MemberTagDO> tags = memberTagService.getTagList(tagIds); |
| 75 | - return success(MemberUserConvert.INSTANCE.convertPage(pageResult, tags)); | |
| 93 | + // 处理用户级别返显 | |
| 94 | + List<MemberLevelDO> levels = memberLevelService.getLevelList( | |
| 95 | + convertSet(pageResult.getList(), MemberUserDO::getLevelId)); | |
| 96 | + // 处理用户分组返显 | |
| 97 | + List<MemberGroupDO> groups = memberGroupService.getGroupList( | |
| 98 | + convertSet(pageResult.getList(), MemberUserDO::getGroupId)); | |
| 99 | + return success(MemberUserConvert.INSTANCE.convertPage(pageResult, tags, levels, groups)); | |
| 76 | 100 | } |
| 77 | 101 | |
| 78 | 102 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java
| ... | ... | @@ -40,10 +40,10 @@ public class MemberUserBaseVO { |
| 40 | 40 | @Schema(description = "用户性别", example = "1") |
| 41 | 41 | private Byte sex; |
| 42 | 42 | |
| 43 | - @Schema(description = "所在地", example = "4371") | |
| 43 | + @Schema(description = "所在地编号", example = "4371") | |
| 44 | 44 | private Long areaId; |
| 45 | 45 | |
| 46 | - @Schema(description = "所在地可视化显示", example = "4371") | |
| 46 | + @Schema(description = "所在地全程", example = "上海上海市普陀区") | |
| 47 | 47 | private String areaName; |
| 48 | 48 | |
| 49 | 49 | @Schema(description = "出生日期", example = "2023-03-12") |
| ... | ... | @@ -56,4 +56,10 @@ public class MemberUserBaseVO { |
| 56 | 56 | @Schema(description = "会员标签", example = "[1, 2]") |
| 57 | 57 | private List<Long> tagIds; |
| 58 | 58 | |
| 59 | + @Schema(description = "会员等级编号", example = "1") | |
| 60 | + private Long levelId; | |
| 61 | + | |
| 62 | + @Schema(description = "用户分组编号", example = "1") | |
| 63 | + private Long groupId; | |
| 64 | + | |
| 59 | 65 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserPageReqVO.java
| ... | ... | @@ -32,7 +32,13 @@ public class MemberUserPageReqVO extends PageParam { |
| 32 | 32 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 33 | 33 | private LocalDateTime[] createTime; |
| 34 | 34 | |
| 35 | - @Schema(description = "会员标签", example = "[1, 2]") | |
| 35 | + @Schema(description = "会员标签编号列表", example = "[1, 2]") | |
| 36 | 36 | private List<Long> tagIds; |
| 37 | 37 | |
| 38 | + @Schema(description = "会员等级编号", example = "1") | |
| 39 | + private Long levelId; | |
| 40 | + | |
| 41 | + @Schema(description = "用户分组编号", example = "1") | |
| 42 | + private Long groupId; | |
| 43 | + | |
| 38 | 44 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserRespVO.java
| ... | ... | @@ -29,10 +29,24 @@ public class MemberUserRespVO extends MemberUserBaseVO { |
| 29 | 29 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 30 | 30 | private LocalDateTime createTime; |
| 31 | 31 | |
| 32 | - | |
| 33 | 32 | // ========== 其它信息 ========== |
| 34 | 33 | |
| 34 | + @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 35 | + private Integer point; | |
| 36 | + | |
| 37 | + @Schema(description = "总积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") | |
| 38 | + private Integer totalPoint; | |
| 39 | + | |
| 35 | 40 | @Schema(description = "会员标签", example = "[红色, 快乐]") |
| 36 | 41 | private List<String> tagNames; |
| 37 | 42 | |
| 43 | + @Schema(description = "会员等级", example = "黄金会员") | |
| 44 | + private String levelName; | |
| 45 | + | |
| 46 | + @Schema(description = "用户分组", example = "购物达人") | |
| 47 | + private String groupName; | |
| 48 | + | |
| 49 | + @Schema(description = "用户经验值", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") | |
| 50 | + private Integer experience; | |
| 51 | + | |
| 38 | 52 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateLevelReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.admin.user.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotBlank; | |
| 9 | +import javax.validation.constraints.NotNull; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - 会员用户 修改等级 Request VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class MemberUserUpdateLevelReqVO extends MemberUserBaseVO { | |
| 16 | + | |
| 17 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788") | |
| 18 | + @NotNull(message = "用户编号不能为空") | |
| 19 | + private Long id; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 取消用户等级时,值为空 | |
| 23 | + */ | |
| 24 | + @Schema(description = "用户等级编号", example = "1") | |
| 25 | + private Long levelId; | |
| 26 | + | |
| 27 | + @Schema(description = "修改原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "推广需要") | |
| 28 | + @NotBlank(message = "修改原因不能为空") | |
| 29 | + private String reason; | |
| 30 | + | |
| 31 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/AppMemberPointRecordController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.app.point; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordRespVO; | |
| 7 | +import cn.iocoder.yudao.module.member.convert.point.MemberPointRecordConvert; | |
| 8 | +import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; | |
| 9 | +import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; | |
| 10 | +import io.swagger.v3.oas.annotations.Operation; | |
| 11 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 15 | +import org.springframework.web.bind.annotation.RestController; | |
| 16 | + | |
| 17 | +import javax.annotation.Resource; | |
| 18 | +import javax.validation.Valid; | |
| 19 | + | |
| 20 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 21 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 22 | + | |
| 23 | +@Tag(name = "用户 App - 签到记录") | |
| 24 | +@RestController | |
| 25 | +@RequestMapping("/member/point/record") | |
| 26 | +@Validated | |
| 27 | +public class AppMemberPointRecordController { | |
| 28 | + | |
| 29 | + @Resource | |
| 30 | + private MemberPointRecordService pointRecordService; | |
| 31 | + | |
| 32 | + @GetMapping("/page") | |
| 33 | + @Operation(summary = "获得用户积分记录分页") | |
| 34 | + public CommonResult<PageResult<AppMemberPointRecordRespVO>> getPointRecordPage(@Valid PageParam pageVO) { | |
| 35 | + PageResult<MemberPointRecordDO> pageResult = pointRecordService.getPointRecordPage(getLoginUserId(), pageVO); | |
| 36 | + return success(MemberPointRecordConvert.INSTANCE.convertPage02(pageResult)); | |
| 37 | + } | |
| 38 | + | |
| 39 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.app.point.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | + | |
| 8 | +@Schema(description = "用户 App - 用户积分记录 Response VO") | |
| 9 | +@Data | |
| 10 | +public class AppMemberPointRecordRespVO { | |
| 11 | + | |
| 12 | + @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31457") | |
| 13 | + private Long id;; | |
| 14 | + | |
| 15 | + @Schema(description = "积分标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") | |
| 16 | + private String title; | |
| 17 | + | |
| 18 | + @Schema(description = "积分描述", example = "你猜") | |
| 19 | + private String description; | |
| 20 | + | |
| 21 | + @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 22 | + private Integer point; | |
| 23 | + | |
| 24 | + @Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 25 | + private LocalDateTime createTime; | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInConfigController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.app.signin; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.module.member.controller.app.signin.vo.config.AppMemberSignInConfigRespVO; | |
| 6 | +import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert; | |
| 7 | +import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; | |
| 8 | +import cn.iocoder.yudao.module.member.service.signin.MemberSignInConfigService; | |
| 9 | +import io.swagger.v3.oas.annotations.Operation; | |
| 10 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 11 | +import org.springframework.validation.annotation.Validated; | |
| 12 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 13 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 14 | +import org.springframework.web.bind.annotation.RestController; | |
| 15 | + | |
| 16 | +import javax.annotation.Resource; | |
| 17 | +import java.util.List; | |
| 18 | + | |
| 19 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 20 | + | |
| 21 | +@Tag(name = "用户 App - 签到规则") | |
| 22 | +@RestController | |
| 23 | +@RequestMapping("/member/sign-in/config") | |
| 24 | +@Validated | |
| 25 | +public class AppMemberSignInConfigController { | |
| 26 | + | |
| 27 | + @Resource | |
| 28 | + private MemberSignInConfigService signInConfigService; | |
| 29 | + | |
| 30 | + @GetMapping("/list") | |
| 31 | + @Operation(summary = "获得签到规则列表") | |
| 32 | + public CommonResult<List<AppMemberSignInConfigRespVO>> getSignInConfigList() { | |
| 33 | + List<MemberSignInConfigDO> pageResult = signInConfigService.getSignInConfigList(CommonStatusEnum.ENABLE.getStatus()); | |
| 34 | + return success(MemberSignInConfigConvert.INSTANCE.convertList02(pageResult)); | |
| 35 | + } | |
| 36 | + | |
| 37 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInRecordController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.app.signin; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordRespVO; | |
| 7 | +import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordSummaryRespVO; | |
| 8 | +import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; | |
| 9 | +import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; | |
| 10 | +import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService; | |
| 11 | +import io.swagger.v3.oas.annotations.Operation; | |
| 12 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 15 | +import org.springframework.web.bind.annotation.PostMapping; | |
| 16 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 17 | +import org.springframework.web.bind.annotation.RestController; | |
| 18 | + | |
| 19 | +import javax.annotation.Resource; | |
| 20 | +import java.time.LocalDateTime; | |
| 21 | + | |
| 22 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 23 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 24 | + | |
| 25 | +@Tag(name = "管理后台 - 签到记录") | |
| 26 | +@RestController | |
| 27 | +@RequestMapping("/member/sign-in/record") | |
| 28 | +@Validated | |
| 29 | +public class AppMemberSignInRecordController { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private MemberSignInRecordService signInRecordService; | |
| 33 | + | |
| 34 | + // TODO 芋艿:临时 mock => UserSignController.getUserInfo | |
| 35 | + @GetMapping("/get-summary") | |
| 36 | + @Operation(summary = "获得个人签到统计") | |
| 37 | + public CommonResult<AppMemberSignInRecordSummaryRespVO> getSignInRecordSummary() { | |
| 38 | + AppMemberSignInRecordSummaryRespVO respVO = new AppMemberSignInRecordSummaryRespVO(); | |
| 39 | + if (false) { | |
| 40 | + respVO.setTotalDay(100); | |
| 41 | + respVO.setContinuousDay(5); | |
| 42 | + respVO.setTodaySignIn(true); | |
| 43 | + } else { | |
| 44 | + respVO.setTotalDay(100); | |
| 45 | + respVO.setContinuousDay(10); | |
| 46 | + respVO.setTodaySignIn(false); | |
| 47 | + } | |
| 48 | + return success(respVO); | |
| 49 | + } | |
| 50 | + | |
| 51 | + // TODO 芋艿:临时 mock => UserSignController.info | |
| 52 | + @PostMapping("/create") | |
| 53 | + @Operation(summary = "签到") | |
| 54 | + public CommonResult<AppMemberSignInRecordRespVO> createSignInRecord() { | |
| 55 | + AppMemberSignInRecordRespVO respVO = new AppMemberSignInRecordRespVO() | |
| 56 | + .setPoint(10) | |
| 57 | + .setDay(10) | |
| 58 | + .setCreateTime(LocalDateTime.now()); | |
| 59 | + return success(respVO); | |
| 60 | + } | |
| 61 | + | |
| 62 | + @GetMapping("/page") | |
| 63 | + @Operation(summary = "获得签到记录分页") | |
| 64 | + public CommonResult<PageResult<AppMemberSignInRecordRespVO>> getSignRecordPage(PageParam pageParam) { | |
| 65 | + PageResult<MemberSignInRecordDO> pageResult = signInRecordService.getSignRecordPage(getLoginUserId(), pageParam); | |
| 66 | + return success(MemberSignInRecordConvert.INSTANCE.convertPage02(pageResult)); | |
| 67 | + } | |
| 68 | + | |
| 69 | +} | ... | ... |