Przeglądaj źródła

feat(order): 添加订单产品分类名称和客户审核状态验证功能

- 在CustomerInfoDTO中新增status字段用于存储客户审核状态
- 将OrderMainServiceImpl中的订单号查询从精确匹配改为模糊匹配
- 在OrderProduct相关类中添加categoryName字段以支持产品分类信息
- 更新OrderProductMapper.xml映射文件以包含分类名称查询
- 在PasswordAuthStrategy中添加客户审核状态验证逻辑
- 集成SequenceUtils和DuplicateKeyException等工具类
- 扩展PcOrderController中的产品信息设置功能
- 实现RemoteCustomerService中的selectCustomerInfoById方法
- 优化代码中的空值检查和字符串比较操作
hurx 1 miesiąc temu
rodzic
commit
9c9052fef2

+ 4 - 2
ruoyi-api/ruoyi-api-customer/src/main/java/org/dromara/customer/api/RemoteCustomerService.java

@@ -24,11 +24,13 @@ public interface RemoteCustomerService {
      */
     Long selectCustomerIdByUserId(Long userId);
 
+    CustomerInfoDTO selectCustomerInfoById(Long customerId);
+
     /**
      * 新增收货人
      */
-    CustomerInfoDTO addReceiver(String name , String email);
+    CustomerInfoDTO addReceiver(String name, String email);
 
-    CustomerAddressDTO addReceiverAddress(String provinceId, String cityId, String countyId, String address , String mobile);
+    CustomerAddressDTO addReceiverAddress(String provinceId, String cityId, String countyId, String address, String mobile);
 
 }

+ 7 - 0
ruoyi-api/ruoyi-api-customer/src/main/java/org/dromara/customer/api/domain/dto/CustomerInfoDTO.java

@@ -13,4 +13,11 @@ public class CustomerInfoDTO implements Serializable {
     private Long id;
 
     private String customerName;
+
+    /**
+     * 状态(0已审核 待审核)
+     */
+    private String status;
+
+
 }

+ 9 - 3
ruoyi-auth/src/main/java/org/dromara/auth/service/impl/PasswordAuthStrategy.java

@@ -17,6 +17,7 @@ import org.dromara.common.core.constant.Constants;
 import org.dromara.common.core.constant.GlobalConstants;
 import org.dromara.common.core.constant.SystemConstants;
 import org.dromara.common.core.enums.LoginType;
+import org.dromara.common.core.enums.SysPlatformYesNo;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.exception.user.CaptchaException;
 import org.dromara.common.core.exception.user.CaptchaExpireException;
@@ -28,6 +29,7 @@ import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.common.tenant.helper.TenantHelper;
 import org.dromara.customer.api.RemoteCustomerService;
+import org.dromara.customer.api.domain.dto.CustomerInfoDTO;
 import org.dromara.system.api.RemoteClientService;
 import org.dromara.system.api.RemoteUserService;
 import org.dromara.system.api.domain.vo.RemoteClientVo;
@@ -128,9 +130,13 @@ public class PasswordAuthStrategy implements IAuthStrategy {
         });
         //获取客户信息
         Long customerId = remoteCustomerService.selectCustomerIdByUserId(loginUser.getUserId());
-        if (Objects.isNull(customerId)){
+        if (Objects.isNull(customerId)) {
             throw new ServiceException("不存在该账号");
         }
+        CustomerInfoDTO customerInfoDTO = remoteCustomerService.selectCustomerInfoById(customerId);
+        if (null != customerInfoDTO && "0".equals(customerInfoDTO.getStatus())) {
+            throw new ServiceException("该企业当前未审核,请审核后再登录");
+        }
         loginUser.setClientKey(client.getClientKey());
         loginUser.setDeviceType(client.getDeviceType());
         loginUser.setCustomerId(customerId);
@@ -181,13 +187,13 @@ public class PasswordAuthStrategy implements IAuthStrategy {
             loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !BCrypt.checkpw(password, user.getPassword()));
             return user;
         });
-        if(ObjectUtil.isEmpty(loginUser)){
+        if (ObjectUtil.isEmpty(loginUser)) {
             loginVo.setCode(5004);
             loginVo.setMsg("用户名或密码错误");
             return loginVo;
         }
         RemoteClientVo client = remoteClientService.queryByClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
-        if(ObjectUtil.isEmpty(client)){
+        if (ObjectUtil.isEmpty(client)) {
             return null;
         }
         loginUser.setClientKey(client.getClientKey());

+ 8 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/dubbo/RemoteCustomerServiceImpl.java

@@ -1,6 +1,8 @@
 package org.dromara.customer.dubbo;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -81,6 +83,12 @@ public class RemoteCustomerServiceImpl implements RemoteCustomerService {
         return null;
     }
 
+    @Override
+    public CustomerInfoDTO selectCustomerInfoById(Long customerId) {
+        CustomerInfo customerInfo = customerInfoService.getById(customerId);
+        return BeanUtil.toBean(customerInfo, CustomerInfoDTO.class);
+    }
+
     @Override
     public CustomerInfoDTO addReceiver(String name, String email) {
         CustomerInfo customerInfo = new CustomerInfo();

+ 11 - 1
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/pc/PcOrderController.java

@@ -8,10 +8,12 @@ import org.apache.dubbo.config.annotation.DubboReference;
 import org.dromara.common.core.domain.R;
 import org.dromara.common.core.enums.OrderSourceEnum;
 import org.dromara.common.core.enums.OrderStatus;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.log.annotation.Log;
 import org.dromara.common.log.enums.BusinessType;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.redis.utils.SequenceUtils;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.common.web.core.BaseController;
 import org.dromara.customer.api.RemoteCustomerService;
@@ -30,10 +32,12 @@ import org.dromara.product.api.RemoteProductService;
 import org.dromara.product.api.RemoteProductShoppingCartService;
 import org.dromara.product.api.domain.ProductVo;
 import org.dromara.product.api.domain.RemoteProductShoppingCartVo;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
+import java.time.Duration;
 import java.time.LocalDate;
 import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
@@ -345,8 +349,14 @@ public class PcOrderController extends BaseController {
                     orderProductBo.setProductName(productVo.getItemName());
                     orderProductBo.setProductUnitId(Long.valueOf(productVo.getUnitId()));
                     orderProductBo.setProductUnit(productVo.getUnitName());
-                    orderProductBo.setProductImage(productVo.getProductImageUrl());
+                    orderProductBo.setProductImage(productVo.getProductImage());
                     orderProductBo.setOrderPrice(productVo.getMemberPrice());
+                    orderProductBo.setMarketPrice(productVo.getMarketPrice());
+                    orderProductBo.setTaxRate(productVo.getTaxRate());
+                    orderProductBo.setCategoryName(productVo.getCategoryName());
+                    orderProductBo.setPurchasingPrice(productVo.getPurchasingPrice());
+                    orderProductBo.setMinOrderQuantity(productVo.getMinOrderQuantity());
+                    orderProductBo.setMinSellingPrice(productVo.getMinSellingPrice());
                     orderProductBo.setOrderQuantity(quantity);
                     orderProductBo.setSubtotal(productVo.getMemberPrice().multiply(BigDecimal.valueOf(quantity)));
                     return orderProductBo;

+ 2 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/OrderProduct.java

@@ -84,6 +84,8 @@ public class OrderProduct extends TenantEntity {
      */
     private String productImage;
 
+    private String categoryName;
+
     /**
      * 平台价格(元)
      */

+ 2 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/bo/OrderProductBo.java

@@ -83,6 +83,8 @@ public class OrderProductBo extends BaseEntity {
      */
     private String productImage;
 
+    private String categoryName;
+
     /**
      * 平台价格(元)
      */

+ 2 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderProductVo.java

@@ -65,6 +65,8 @@ public class OrderProductVo implements Serializable {
     @ExcelProperty(value = "发货单编号")
     private String shipmentNo;
 
+    private String categoryName;
+
     /**
      * 产品ID
      */

+ 1 - 1
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderMainServiceImpl.java

@@ -217,7 +217,7 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
         Map<String, Object> params = bo.getParams();
         LambdaQueryWrapper<OrderMain> lqw = Wrappers.lambdaQuery();
         lqw.orderByDesc(OrderMain::getId);
-        lqw.eq(StringUtils.isNotBlank(bo.getOrderNo()), OrderMain::getOrderNo, bo.getOrderNo());
+        lqw.like(StringUtils.isNotBlank(bo.getOrderNo()), OrderMain::getOrderNo, bo.getOrderNo());
         lqw.eq(StringUtils.isNotBlank(bo.getCustomerCode()), OrderMain::getCustomerCode, bo.getCustomerCode());
         lqw.eq(StringUtils.isNotBlank(bo.getShipmentNo()), OrderMain::getShipmentNo, bo.getShipmentNo());
         lqw.eq(StringUtils.isNotBlank(bo.getSubOrderNo()), OrderMain::getSubOrderNo, bo.getSubOrderNo());

+ 1 - 0
ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderProductMapper.xml

@@ -14,6 +14,7 @@
                op.product_name                                       AS productName,
                op.product_unit                                       AS productUnit,
                op.product_image                                      AS productImage,
+               op.category_name                                      AS categoryName,
                op.platform_price                                     AS platformPrice,
                op.min_order_quantity                                 AS minOrderQuantity,
                op.order_price                                        AS orderPrice,