Prechádzať zdrojové kódy

feat(customer): 添加客户联系人手机号去重和软删除查询功能

- 在CustomerContactMapper中添加selectOneByPhoneIgnoreDelete方法用于查询忽略软删除的手机号记录
- 更新CustomerContactServiceImpl实现手机号重复检查逻辑,已删除记录可复用userId,有效记录禁止重复添加
- 修改查询逻辑确保只返回未删除的联系人记录
- 移除联系人删除时的用户同步删除,支持后续复用原有用户

feat(order): 增加订单回款状态管理和发货物流查询功能

- 在OrderMain实体中添加returnedStatus和contactId字段
- 实现changeReturnedStatusByIds批量修改回款状态接口
- 添加MiniOrderController中的发货订单查询和物流跟踪接口
- 增加订单流程节点查询功能
- 在订单创建时自动关联联系人ID

feat(mall): 新增小程序底部导航配置查询接口

- 创建MiniNavigationConfigController提供getCurrent配置查询
- 实现导航配置服务层接口支持前端获取当前导航设置
hurx 3 týždňov pred
rodič
commit
4142bfea61
14 zmenil súbory, kde vykonal 201 pridanie a 19 odobranie
  1. 2 0
      ruoyi-api/ruoyi-api-system/src/main/java/org/dromara/system/api/domain/bo/RemoteUserBo.java
  2. 2 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/CustomerContactVo.java
  3. 6 2
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/mapper/CustomerContactMapper.java
  4. 21 6
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerContactServiceImpl.java
  5. 4 0
      ruoyi-modules/ruoyi-customer/src/main/resources/mapper/customer/CustomerContactMapper.xml
  6. 35 0
      ruoyi-modules/ruoyi-mall/src/main/java/org/dromara/mall/controller/mini/MiniNavigationConfigController.java
  7. 17 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/OrderMainController.java
  8. 41 5
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/mini/MiniOrderController.java
  9. 8 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/OrderMain.java
  10. 8 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/bo/OrderMainBo.java
  11. 11 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/dto/ChangeReturnedStatusRequestDto.java
  12. 8 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderMainVo.java
  13. 3 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/IOrderMainService.java
  14. 35 6
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderMainServiceImpl.java

+ 2 - 0
ruoyi-api/ruoyi-api-system/src/main/java/org/dromara/system/api/domain/bo/RemoteUserBo.java

@@ -130,6 +130,8 @@ public class RemoteUserBo implements Serializable {
      */
     private String platformCode;
 
+    private String delFlag;
+
     public RemoteUserBo(Long userId) {
         this.userId = userId;
     }

+ 2 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/CustomerContactVo.java

@@ -157,4 +157,6 @@ public class CustomerContactVo implements Serializable {
     private String platformCode;
 
     private Date createTime;
+
+    private String delFlag;
 }

+ 6 - 2
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/mapper/CustomerContactMapper.java

@@ -1,10 +1,9 @@
 package org.dromara.customer.mapper;
 
 import org.apache.ibatis.annotations.Param;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 import org.dromara.customer.domain.CustomerContact;
-import org.dromara.customer.domain.CustomerInvoiceInfo;
 import org.dromara.customer.domain.vo.CustomerContactVo;
-import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 
 import java.util.List;
 
@@ -18,5 +17,10 @@ public interface CustomerContactMapper extends BaseMapperPlus<CustomerContact, C
 
     void deleteByCustomerId(@Param("customerId") Long customerId);
 
+    /**
+     * 自定义查询:忽略逻辑删除,查询手机号对应的所有记录(含已删除)
+     */
+    CustomerContact selectOneByPhoneIgnoreDelete(@Param("phone") String phone);
+
     List<CustomerContact> selectListByCustomerId(@Param("customerId") Long customerId);
 }

+ 21 - 6
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerContactServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
+import org.dromara.common.core.context.PlatformContext;
 import org.dromara.common.core.enums.SysPlatformYesNo;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
@@ -71,7 +72,7 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
 
     @Override
     public CustomerContactVo selectCustomerContactByCustomerIdAndUserId(Long customerId, Long userId) {
-        return baseMapper.selectVoOne(new LambdaQueryWrapper<CustomerContact>().eq(CustomerContact::getCustomerId, customerId).eq(CustomerContact::getUserId, userId).last("limit 1"));
+        return baseMapper.selectVoOne(new LambdaQueryWrapper<CustomerContact>().eq(CustomerContact::getCustomerId, customerId).eq(CustomerContact::getUserId, userId).eq(CustomerContact::getDelFlag, '0').last("limit 1"));
     }
 
     /**
@@ -202,7 +203,6 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
                 throw new RuntimeException("客户编号为空,数据异常 (ID: " + bo.getCustomerId() + ")");
             }
         }
-
         // 1. 准备创建系统用户的数据
         RemoteUserBo remoteUserBo = new RemoteUserBo();
         remoteUserBo.setNickName(bo.getContactName());
@@ -214,8 +214,23 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
         remoteUserBo.setUserSonType("3");
         remoteUserBo.setTenantId(LoginHelper.getTenantId());
         remoteUserBo.setRoleIds(new Long[]{bo.getRoleId()});
-        // 2. 调用远程服务创建用户
-        Long userId = remoteUserService.addUser(remoteUserBo);
+        Long userId = null;
+        // 使用自定义方法查询
+        CustomerContact customerContact = baseMapper.selectOneByPhoneIgnoreDelete(bo.getPhone());
+
+        if (customerContact != null) {
+            // 如果查到了数据
+            if ("1".equals(customerContact.getDelFlag())) {
+                // 情况 A:数据已删除 -> 复用原有的 userId
+                userId = customerContact.getUserId();
+            } else {
+                // 情况 B:数据未删除 -> 报错,禁止重复
+                throw new ServiceException("该手机号已存在有效联系人,请勿重复添加");
+            }
+        } else {
+            // 情况 C:完全没数据 -> 创建新用户
+            userId = remoteUserService.addUser(remoteUserBo);
+        }
 
         if (userId == null) {
             throw new ServiceException("创建系统用户失败:" + userId);
@@ -335,7 +350,7 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
             return false;
         }
 
-        // 5. 提取 userId 列表
+        /*// 5. 提取 userId 列表
         List<Long> userIds = contactList.stream()
             .map(CustomerContact::getUserId)
             .filter(Objects::nonNull) // 过滤掉 userId 为 null 的情况
@@ -351,7 +366,7 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
                 log.error("删除远程用户 {} 失败", uid, e);
                 throw new ServiceException("依赖服务异常,删除中止"); // 抛出异常触发回滚
             }
-        }
+        }*/  //联系人删除时不删除用户  后续可能会复用之前的 用户
         // 7. 执行本地数据库删除
         int rows = baseMapper.deleteByIds(ids); // 确保 MP 版本支持或自定义 XML
 

+ 4 - 0
ruoyi-modules/ruoyi-customer/src/main/resources/mapper/customer/CustomerContactMapper.xml

@@ -14,4 +14,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE customer_id = #{customerId}
         ORDER BY id
     </select>
+
+    <select id="selectOneByPhoneIgnoreDelete" resultType="org.dromara.customer.domain.CustomerContact">
+        SELECT * FROM customer_contact WHERE phone = #{phone} ORDER BY create_time desc LIMIT 1
+    </select>
 </mapper>

+ 35 - 0
ruoyi-modules/ruoyi-mall/src/main/java/org/dromara/mall/controller/mini/MiniNavigationConfigController.java

@@ -0,0 +1,35 @@
+package org.dromara.mall.controller.mini;
+
+import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.domain.R;
+import org.dromara.common.web.core.BaseController;
+import org.dromara.mall.domain.vo.MNavigationConfigVo;
+import org.dromara.mall.service.IMNavigationConfigService;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * mini底部导航栏
+ * 前端访问路由地址为:/mall/miniNavigationConfig
+ *
+ * @author LionLi
+ * @date 2026-05-06
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/miniNavigationConfig")
+public class MiniNavigationConfigController extends BaseController {
+
+    private final IMNavigationConfigService navigationConfigService;
+
+    /**
+     * 获取当前导航配置
+     */
+    @GetMapping("/current")
+    public R<MNavigationConfigVo> getCurrent() {
+        return R.ok(navigationConfigService.getCurrentConfig());
+    }
+}

+ 17 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/OrderMainController.java

@@ -21,6 +21,7 @@ import org.dromara.common.tenant.helper.PlatformHelper;
 import org.dromara.common.web.core.BaseController;
 import org.dromara.order.domain.bo.OrderMainBo;
 import org.dromara.order.domain.bo.OrderProductBo;
+import org.dromara.order.domain.dto.ChangeReturnedStatusRequestDto;
 import org.dromara.order.domain.vo.OrderMainVo;
 import org.dromara.order.domain.vo.OrderProductVo;
 import org.dromara.order.domain.vo.OrderStatusStats;
@@ -225,4 +226,20 @@ public class OrderMainController extends BaseController {
     public R<Void> changePayStatus(@RequestBody OrderMainBo bo) {
         return toAjax(orderMainService.updatePayStatus(bo));
     }
+
+    /**
+     * 修改订单回款状态
+     *
+     */
+    @Log(title = "订单主信息", businessType = BusinessType.UPDATE)
+    @PutMapping("changeReturnedStatus") //
+    public R<Void> changeReturnedStatus(@RequestBody ChangeReturnedStatusRequestDto request) {
+
+        // 从请求对象中获取参数
+        Long[] ids = request.getIds();
+        String returnedStatus = request.getReturnedStatus();
+
+        // 调用服务层方法
+        return toAjax(orderMainService.changeReturnedStatusByIds(List.of(ids), returnedStatus));
+    }
 }

+ 41 - 5
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/mini/MiniOrderController.java

@@ -1,5 +1,6 @@
 package org.dromara.order.controller.mini;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import jakarta.validation.constraints.NotNull;
 import lombok.RequiredArgsConstructor;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -16,16 +17,17 @@ import org.dromara.common.web.core.BaseController;
 import org.dromara.customer.api.RemoteCustomerContactService;
 import org.dromara.customer.api.RemoteCustomerService;
 import org.dromara.customer.api.domain.CustomerApiVo;
+import org.dromara.order.domain.OrderCustomerFlowNodeLink;
+import org.dromara.order.domain.bo.OrderDeliverBo;
 import org.dromara.order.domain.bo.OrderMainBo;
 import org.dromara.order.domain.bo.OrderProductBo;
 import org.dromara.order.domain.bo.PcSubmitOrderBo;
 import org.dromara.order.domain.dto.OrderPayDto;
+import org.dromara.order.domain.vo.OrderDeliverVo;
 import org.dromara.order.domain.vo.OrderMainVo;
 import org.dromara.order.domain.vo.OrderProductVo;
-import org.dromara.order.service.IOrderCustomerFlowLinkService;
-import org.dromara.order.service.IOrderCustomerFlowNodeLinkService;
-import org.dromara.order.service.IOrderCustomerFlowService;
-import org.dromara.order.service.IOrderMainService;
+import org.dromara.order.service.*;
+import org.dromara.order.utils.kd100.domain.TrackVO;
 import org.dromara.product.api.RemoteProductService;
 import org.dromara.product.api.RemoteProductShoppingCartService;
 import org.dromara.product.api.domain.ProductVo;
@@ -77,6 +79,8 @@ public class MiniOrderController extends BaseController {
 
     private final IOrderMainService orderMainService;
 
+    private final IOrderDeliverService orderDeliverService;
+
 
     private final IOrderCustomerFlowNodeLinkService orderCustomerFlowNodeLinkService;
 
@@ -182,7 +186,7 @@ public class MiniOrderController extends BaseController {
 
         // 强制设置企业ID
         bo.setCustomerId(customerId);
-        bo.setOrderStatuses(OrderStatus.CANCEL.getCode());
+        bo.setOrderStatus(OrderStatus.CANCEL.getCode());
 
         return toAjax(orderMainService.updateStatus(bo));
     }
@@ -344,6 +348,9 @@ public class MiniOrderController extends BaseController {
         return R.ok(orderPayResult);
     }
 
+    /**
+     * 确认订单
+     */
     @GetMapping("/batchConfirmation")
     public R<Void> batchConfirmation(@RequestParam("orderIds") List<Long> orderIds) {
         if (orderIds == null || orderIds.isEmpty()) {
@@ -372,4 +379,33 @@ public class MiniOrderController extends BaseController {
         Set<Long> uniqueOrderIds = new HashSet<>(orderIds);
         return toAjax(orderMainService.batchConfirmation(uniqueOrderIds));
     }
+
+
+    /**
+     * 根据订单id查询发货订单
+     */
+    @GetMapping("/selectOrderDeliverByOrderId")
+    public TableDataInfo<OrderDeliverVo> selectOrderDeliverList(OrderDeliverBo bo) {
+        return orderDeliverService.selectOrderDeliverByOrderId(bo.getOrderId());
+    }
+
+    /**
+     * 查询订单物流信息列表
+     */
+    @GetMapping("/queryTrack")
+    public TrackVO queryTrack(OrderDeliverBo bo) {
+        return orderDeliverService.queryTrack(bo);
+    }
+
+    /**
+     * 查询当前订单的流程节点列表
+     */
+    @GetMapping("/getOrderFlowNodes/{orderId}")
+    public R<List<OrderCustomerFlowNodeLink>> getOrderFlowNodes(@PathVariable("orderId") Long orderId) {
+        return R.ok(orderCustomerFlowNodeLinkService.list(
+            Wrappers.lambdaQuery(OrderCustomerFlowNodeLink.class)
+                .eq(OrderCustomerFlowNodeLink::getOrderId, orderId)
+                .orderByAsc(OrderCustomerFlowNodeLink::getSort)
+        ));
+    }
 }

+ 8 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/OrderMain.java

@@ -304,4 +304,12 @@ public class OrderMain extends TenantEntity {
      */
     private Integer evaluationStatus;
 
+    /*回款状态0未汇款 部分回款 2 全部回款*/
+    private String returnedStatus;
+
+    /**
+     * 联系人ID
+     */
+    private Long contactId;
+
 }

+ 8 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/bo/OrderMainBo.java

@@ -308,6 +308,14 @@ public class OrderMainBo extends BaseEntity {
      */
     private Integer evaluationStatus;
 
+    /*回款状态0未汇款 部分回款 2 全部回款*/
+    private String returnedStatus;
+
+    /**
+     * 联系人ID
+     */
+    private Long contactId;
+
     List<OrderProductBo> orderProductBos;
 
 

+ 11 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/dto/ChangeReturnedStatusRequestDto.java

@@ -0,0 +1,11 @@
+package org.dromara.order.domain.dto;
+
+import lombok.Data;
+
+@Data
+public class ChangeReturnedStatusRequestDto {
+
+    private Long[] ids;
+
+    private String returnedStatus;
+}

+ 8 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderMainVo.java

@@ -439,4 +439,12 @@ public class OrderMainVo implements Serializable {
      */
     private String projectOrderNo;
 
+    /*回款状态0未汇款 部分回款 2 全部回款*/
+    private String returnedStatus;
+
+    /**
+     * 联系人ID
+     */
+    private Long contactId;
+
 }

+ 3 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/IOrderMainService.java

@@ -127,4 +127,7 @@ public interface IOrderMainService extends IService<OrderMain> {
 
     /*根据id查询订单编号*/
     Map<Long, String> selectOrderNoByIds(Set<Long> ids);
+
+    Boolean changeReturnedStatusByIds(List<Long> ids, String returnedStatus);
+
 }

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

@@ -11,7 +11,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
-import org.dromara.common.core.enums.*;
+import org.dromara.common.core.enums.AssigneeTypeConstants;
+import org.dromara.common.core.enums.OrderPayType;
+import org.dromara.common.core.enums.OrderStatus;
+import org.dromara.common.core.enums.SysPlatformYesNo;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.exception.api.ZhongcheException;
 import org.dromara.common.core.utils.MapstructUtils;
@@ -20,11 +23,9 @@ import org.dromara.common.core.utils.StringUtils;
 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.customer.api.RemoteCustomerSalesService;
-import org.dromara.customer.api.RemoteCustomerService;
-import org.dromara.customer.api.RemotePartnerInfoService;
-import org.dromara.customer.api.RemoteSupplierInfoService;
+import org.dromara.customer.api.*;
 import org.dromara.customer.api.domain.dto.CustomerInfoDTO;
+import org.dromara.customer.api.domain.vo.RemoteCustomerContactVo;
 import org.dromara.customer.api.domain.vo.RemoteCustomerSalesVo;
 import org.dromara.external.api.zhongche.RemoteZhongChePullService;
 import org.dromara.external.api.zhongche.domain.bo.OrderConfirmBo;
@@ -101,6 +102,9 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
     //客户订单流程
     private final IOrderCustomerFlowService orderCustomerFlowService;
 
+    @DubboReference
+    private RemoteCustomerContactService remoteCustomerContactService;
+
     @DubboReference
     private RemoteProductShoppingCartService remoteProductShoppingCartService;
 
@@ -578,7 +582,11 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
     @Transactional(rollbackFor = Exception.class)
     public Long insertOrder(PcSubmitOrderBo bo, OrderMainBo mainBo) {
         CustomerInfoDTO customerInfoDTO = remoteCustomerService.selectCustomerInfoById(mainBo.getCustomerId());
-        RemoteCustomerSalesVo remoteCustomerSalesVo = remoteCustomerSalesService.selectCustomerSalesInfoByCustomerId(mainBo.getCustomerId());
+
+        RemoteCustomerContactVo remoteCustomerContactVo = remoteCustomerContactService.selectCustomerContactByCustomerIdAndUserId(mainBo.getCustomerId(), mainBo.getUserId());
+        if (ObjectUtils.isNotEmpty(remoteCustomerContactVo)) {
+            mainBo.setContactId(remoteCustomerContactVo.getId());
+        }
 
         LoginUser userInfo = remoteUserService.getUserInfo(mainBo.getUserId(), "000000");
         if (ObjectUtils.isNotEmpty(userInfo)) {
@@ -1193,4 +1201,25 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
         }
         return resultMap;
     }
+
+    @Override
+    public Boolean changeReturnedStatusByIds(List<Long> ids, String returnedStatus) {
+        if (ids == null || ids.isEmpty()) {
+            return false;
+        }
+        try {
+            if (ids != null && !ids.isEmpty()) {
+                for (Long id : ids) {
+                    OrderMain update = new OrderMain();
+                    update.setId(id);
+                    update.setReturnedStatus(returnedStatus);
+                    baseMapper.updateById(update);
+                }
+            }
+        } catch (Exception e) {
+            log.error("修改回款状态失败", e);
+            return false;
+        }
+        return true;
+    }
 }