From fc48ab492872a2e0ebb03d3664625e28dc950403 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 10 Dec 2022 17:06:34 +0800 Subject: [PATCH] =?UTF-8?q?trade=EF=BC=9A=E5=89=8D=E7=AB=AF=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=AE=A1=E7=90=86=EF=BC=8C=E8=81=94=E8=B0=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ip/core/utils/AreaUtilsTest.java | 6 +- .../admin/order/vo/TradeOrderPageReqVO.java | 36 +++++ .../dal/mysql/order/TradeOrderMapper.java | 14 +- .../service/order/TradeOrderServiceImpl.java | 24 ++- .../module/member/api/user/MemberUserApi.java | 8 + .../member/api/user/MemberUserApiImpl.java | 5 + .../service/user/MemberUserService.java | 1 - .../service/order/PayOrderServiceTest.java | 4 +- .../service/refund/PayRefundServiceTest.java | 8 +- yudao-ui-admin/src/utils/dict.js | 2 + .../src/views/mall/trade/afterSale/index.vue | 4 +- .../src/views/mall/trade/order/index.vue | 146 +++++++++++------- 12 files changed, 183 insertions(+), 75 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java index 535032631..8f5646b33 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java @@ -28,9 +28,9 @@ public class AreaUtilsTest { @Test public void testFormat() { - assertEquals(AreaUtils.format(110105L), "北京 北京市 朝阳区"); - assertEquals(AreaUtils.format(1L), "中国"); - assertEquals(AreaUtils.format(2L), "蒙古"); + assertEquals(AreaUtils.format(110105), "北京 北京市 朝阳区"); + assertEquals(AreaUtils.format(1), "中国"); + assertEquals(AreaUtils.format(2), "蒙古"); } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java index 35f2b6f43..4295d8c3d 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java @@ -2,17 +2,53 @@ package cn.iocoder.yudao.module.trade.controller.admin.order.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.validation.InEnum; +import cn.iocoder.yudao.framework.common.validation.Mobile; import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @ApiModel("管理后台 - 交易订单的分页 Request VO") @Data public class TradeOrderPageReqVO extends PageParam { + @ApiModelProperty(value = "订单号", example = "88888888", notes = "模糊匹配") + private String no; + + @ApiModelProperty(value = "用户编号", example = "1024") + private Long userId; + + @ApiModelProperty(value = "用户昵称", example = "小王", notes = "模糊匹配") + private String userNickname; + + @ApiModelProperty(value = "用户手机号", example = "小王", notes = "精准匹配") + @Mobile + private String userMobile; + + @ApiModelProperty(value = "收件人名称", example = "小红", notes = "模糊匹配") + private String receiverName; + + @ApiModelProperty(value = "收件人手机", example = "1560", notes = "模糊匹配") + @Mobile + private String receiverMobile; + + @ApiModelProperty(value = "订单类型", example = "1", notes = "参见 TradeOrderTypeEnum 枚举") + private Integer type; + @ApiModelProperty(value = "订单状态", example = "1", notes = "参见 TradeOrderStatusEnum 枚举") @InEnum(value = TradeOrderStatusEnum.class, message = "订单状态必须是 {value}") private Integer status; + @ApiModelProperty(value = "支付渠道", example = "wx_lite") + private String payChannelCode; + + @ApiModelProperty(value = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java index e533e2d6c..e256a2ee1 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java @@ -8,6 +8,8 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.ibatis.annotations.Mapper; +import java.util.Set; + @Mapper public interface TradeOrderMapper extends BaseMapperX { @@ -20,9 +22,17 @@ public interface TradeOrderMapper extends BaseMapperX { return selectOne(TradeOrderDO::getId, id, TradeOrderDO::getUserId, userId); } - default PageResult selectPage(TradeOrderPageReqVO reqVO) { + default PageResult selectPage(TradeOrderPageReqVO reqVO, Set userIds) { return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus())); + .likeIfPresent(TradeOrderDO::getNo, reqVO.getNo()) + .eqIfPresent(TradeOrderDO::getUserId, reqVO.getUserId()) + .inIfPresent(TradeOrderDO::getUserId, userIds) + .likeIfPresent(TradeOrderDO::getReceiverName, reqVO.getReceiverName()) + .likeIfPresent(TradeOrderDO::getReceiverMobile, reqVO.getReceiverMobile()) + .eqIfPresent(TradeOrderDO::getType, reqVO.getType()) + .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) + .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) + .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime())); } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java index 7eed7aa90..3eef12043 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.trade.service.order; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -11,6 +12,8 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.module.member.api.address.AddressApi; import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; @@ -77,6 +80,8 @@ public class TradeOrderServiceImpl implements TradeOrderService { private AddressApi addressApi; @Resource private CouponApi couponApi; + @Resource + private MemberUserApi memberUserApi; @Resource private TradeOrderProperties tradeOrderProperties; @@ -420,7 +425,24 @@ public class TradeOrderServiceImpl implements TradeOrderService { @Override public PageResult getOrderPage(TradeOrderPageReqVO reqVO) { - return tradeOrderMapper.selectPage(reqVO); + // 获得 userId 相关的查询 + Set userIds = new HashSet<>(); + if (StrUtil.isNotEmpty(reqVO.getUserMobile())) { + MemberUserRespDTO user = memberUserApi.getUserByMobile(reqVO.getUserMobile()); + if (user == null) { // 没查询到用户,说明肯定也没他的订单 + return new PageResult<>(); + } + userIds.add(user.getId()); + } + if (StrUtil.isNotEmpty(reqVO.getUserNickname())) { + List users = memberUserApi.getUserListByNickname(reqVO.getUserNickname()); + if (CollUtil.isEmpty(users)) { // 没查询到用户,说明肯定也没他的订单 + return new PageResult<>(); + } + userIds.addAll(convertSet(users, MemberUserRespDTO::getId)); + } + // 分页查询 + return tradeOrderMapper.selectPage(reqVO, userIds); } // =================== Order Item =================== diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java index 2af5446d2..6cbb781bf 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java +++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java @@ -49,4 +49,12 @@ public interface MemberUserApi { */ List getUserListByNickname(String nickname); + /** + * 基于手机号,精准匹配用户 + * + * @param mobile 手机号 + * @return 用户信息 + */ + MemberUserRespDTO getUserByMobile(String mobile); + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java index 3239d8931..37aee217e 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java @@ -39,4 +39,9 @@ public class MemberUserApiImpl implements MemberUserApi { return UserConvert.INSTANCE.convertList2(userService.getUserListByNickname(nickname)); } + @Override + public MemberUserRespDTO getUserByMobile(String mobile) { + return UserConvert.INSTANCE.convert2(userService.getUserByMobile(mobile)); + } + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java index da3b4fd4a..b0a2edc79 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java @@ -31,7 +31,6 @@ public interface MemberUserService { */ List getUserListByNickname(String nickname); - /** * 基于手机号创建用户。 * 如果用户已经存在,则直接进行返回 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java index 8cb3efa7a..774ec3ade 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java @@ -76,7 +76,7 @@ public class PayOrderServiceTest extends BaseDbUnitTest { o.setBody("斌斌子送给灿灿子的炸弹猫"); o.setNotifyUrl("https://hc.com/lbh"); o.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus()); - o.setAmount(10000L); + o.setAmount(10000); o.setChannelFeeRate(0.01); o.setChannelFeeAmount(1L); o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); @@ -148,7 +148,7 @@ public class PayOrderServiceTest extends BaseDbUnitTest { o.setBody("斌斌子送给灿灿子的炸弹猫"); o.setNotifyUrl("https://hc.com/lbh"); o.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus()); - o.setAmount(10000L); + o.setAmount(10000); o.setChannelFeeRate(0.01); o.setChannelFeeAmount(1L); o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java index 3815e1620..da42e7cf2 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java @@ -67,8 +67,8 @@ public class PayRefundServiceTest extends BaseDbUnitTest { o.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus()); o.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()); o.setType(PayRefundTypeEnum.SOME.getStatus()); - o.setPayAmount(100L); - o.setRefundAmount(500L); + o.setPayAmount(100); + o.setRefundAmount(500); o.setReason("就是想退款了,你有意见吗"); o.setUserIp("127.0.0.1"); o.setChannelOrderNo("CH0000001"); @@ -136,8 +136,8 @@ public class PayRefundServiceTest extends BaseDbUnitTest { o.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus()); o.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()); o.setType(PayRefundTypeEnum.SOME.getStatus()); - o.setPayAmount(100L); - o.setRefundAmount(500L); + o.setPayAmount(100); + o.setRefundAmount(500); o.setReason("就是想退款了,你有意见吗"); o.setUserIp("127.0.0.1"); o.setChannelOrderNo("CH0000001"); diff --git a/yudao-ui-admin/src/utils/dict.js b/yudao-ui-admin/src/utils/dict.js index 9c5661824..2dc3e119e 100644 --- a/yudao-ui-admin/src/utils/dict.js +++ b/yudao-ui-admin/src/utils/dict.js @@ -65,6 +65,8 @@ export const DICT_TYPE = { TRADE_AFTER_SALE_STATUS: 'trade_after_sale_status', // 售后 - 状态 TRADE_AFTER_SALE_WAY: 'trade_after_sale_way', // 售后 - 方式 TRADE_AFTER_SALE_TYPE: 'trade_after_sale_type', // 售后 - 类型 + TRADE_ORDER_TYPE: 'trade_order_type', // 订单 - 类型 + TRADE_ORDER_STATUS: 'trade_order_status', // 订单 - 状态 // ========== MALL - PROMOTION 模块 ========== PROMOTION_DISCOUNT_TYPE: 'promotion_discount_type', // 优惠类型 diff --git a/yudao-ui-admin/src/views/mall/trade/afterSale/index.vue b/yudao-ui-admin/src/views/mall/trade/afterSale/index.vue index adc3bb396..5eda5bc6a 100644 --- a/yudao-ui-admin/src/views/mall/trade/afterSale/index.vue +++ b/yudao-ui-admin/src/views/mall/trade/afterSale/index.vue @@ -46,7 +46,7 @@ - + @@ -100,7 +100,7 @@