You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

266 lines
10 KiB

package com.example.web.mapper;
import com.example.web.annotation.DataSource;
import com.example.web.dto.ManagerAuthInfo;
import com.example.web.dto.UserProductCartDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.time.LocalDateTime;
import java.util.List;
@Mapper
@DataSource("wechat")
public interface SupplyUsersMapper {
// 获取用户基本信息
UserProductCartDTO getUserBasicInfo(@Param("userId") String userId);
// 获取卖家的产品信息
List<UserProductCartDTO.ProductInfo> getSellerProducts(@Param("sellerId") String sellerId);
/**
* 获取所有用户的基本信息
*/
List<UserProductCartDTO> getAllUserBasicInfo();
// 新增根据手机号查询用户的方法
UserProductCartDTO selectByPhone(@Param("phoneNumber") String phoneNumber);
// 新增:根据用户ID精确查询用户
UserProductCartDTO selectByUserId(@Param("userId") String userId);
// 新增:更新公海需求信息
int updateProduct(
@Param("sellerId") String sellerId,
@Param("productId") String productId,
@Param("product") UserProductCartDTO.ProductInfo product
);
/**
* 根据手机号更新用户信息
*/
int updateByPhone(UserProductCartDTO user);
/**
* 更新卖家产品信息
*/
int updateProductBySellerId(
@Param("sellerId") String sellerId,
@Param("productName") String productName,
@Param("variety") String variety,
@Param("specification") String specification,
@Param("quantity") Integer quantity,
@Param("grossWeight") String grossWeight,
@Param("yolk") String yolk
);
/**
* 更新用户联系人信息 - 更新第一个联系人(向后兼容)
*/
int updateContactsByUserId(
@Param("userId") String userId,
@Param("wechat") String wechat,
@Param("account") String account,
@Param("accountNumber") String accountNumber,
@Param("bank") String bank,
@Param("address") String address
);
/**
* 获取用户联系人信息 - 获取第一个联系人(向后兼容)
*/
List<UserProductCartDTO.UsersContacts> getUserContacts(@Param("userId") String userId);
/**
* 更新或插入联系人信息
*/
int updateOrInsertContact(
@Param("userId") String userId,
@Param("contactId") String contactId,
@Param("wechat") String wechat,
@Param("account") String account,
@Param("accountNumber") String accountNumber,
@Param("bank") String bank,
@Param("address") String address
);
/**
* 采购端:更新或插入产品信息(类似购物车的updateOrInsertCartItem)
*/
int updateOrInsertProduct(
@Param("sellerId") String sellerId,
@Param("productId") String productId,
@Param("productName") String productName,
@Param("variety") String variety,
@Param("specification") String specification,
@Param("quantity") Integer quantity,
@Param("grossWeight") String grossWeight,
@Param("yolk") String yolk,
@Param("price") String price
);
/**
* 更新特定联系人信息 - 一对多逻辑新增
*/
int updateSpecificContact(
@Param("userId") String userId,
@Param("contactId") String contactId,
@Param("wechat") String wechat,
@Param("account") String account,
@Param("accountNumber") String accountNumber,
@Param("bank") String bank,
@Param("address") String address
);
/**
* 采购端:更新特定产品信息 - 一对多逻辑新增
*/
int updateSpecificProduct(
@Param("sellerId") String sellerId,
@Param("productId") String productId,
@Param("productName") String productName,
@Param("variety") String variety,
@Param("specification") String specification,
@Param("quantity") Integer quantity,
@Param("grossWeight") String grossWeight,
@Param("yolk") String yolk
);
/**
* 获取用户所有联系人 - 一对多逻辑新增
*/
List<ContactInfo> getUserAllContacts(@Param("userId") String userId);
/**
* 采购端:获取用户所有产品信息 - 一对多逻辑新增
*/
List<ProductInfo> getUserAllProducts(@Param("sellerId") String sellerId);
// 联系人信息内部类 - 用于一对多查询
class ContactInfo {
private String contactId;
private String userId;
private String wechat;
private String account;
private String accountNumber;
private String bank;
private String address;
public String getContactId() { return contactId; }
public void setContactId(String contactId) { this.contactId = contactId; }
public String getUserId() { return userId; }
public void setUserId(String userId) { this.userId = userId; }
public String getWechat() { return wechat; }
public void setWechat(String wechat) { this.wechat = wechat; }
public String getAccount() { return account; }
public void setAccount(String account) { this.account = account; }
public String getAccountNumber() { return accountNumber; }
public void setAccountNumber(String accountNumber) { this.accountNumber = accountNumber; }
public String getBank() { return bank; }
public void setBank(String bank) { this.bank = bank; }
public String getAddress() { return address; }
public void setAddress(String address) { this.address = address; }
}
// 产品信息内部类 - 用于一对多查询
class ProductInfo {
private String productId;
private String userId;
private String productName;
private String variety;
private String specification;
private Integer quantity;
private String grossWeight;
private String yolk;
public String getProductId() { return productId; }
public void setProductId(String productId) { this.productId = productId; }
public String getUserId() { return userId; }
public void setUserId(String userId) { this.userId = userId; }
public String getProductName() { return productName; }
public void setProductName(String productName) { this.productName = productName; }
public String getVariety() { return variety; }
public void setVariety(String variety) { this.variety = variety; }
public String getSpecification() { return specification; }
public void setSpecification(String specification) { this.specification = specification; }
public Integer getQuantity() { return quantity; }
public void setQuantity(Integer quantity) { this.quantity = quantity; }
public String getGrossWeight() { return grossWeight; }
public void setGrossWeight(String grossWeight) { this.grossWeight = grossWeight; }
public String getYolk() { return yolk; }
public void setYolk(String yolk) { this.yolk = yolk; }
}
/**
* 根据产品ID精确更新产品信息
*/
int updateProductByProductId(
@Param("productId") String productId,
@Param("productName") String productName,
@Param("variety") String variety,
@Param("specification") String specification,
@Param("quantity") Integer quantity,
@Param("grossWeight") String grossWeight,
@Param("yolk") String yolk
);
// 在 SupplyUsersMapper.java 中添加以下方法
/**
* 查询超过指定时间的未分级客户
*/
List<UserProductCartDTO> findUnclassifiedCustomersOlderThan(LocalDateTime thresholdTime);
/**
* 查询超过指定时间的组织公海池客户
*/
List<UserProductCartDTO> findOrganizationSeaPoolsCustomersOlderThan(LocalDateTime thresholdTime);
/**
* 更新客户等级
*/
@Update("UPDATE users SET level = #{level}, updated_at = #{updateTime} WHERE user_id = #{userId}")
boolean updateCustomerLevel(@Param("userId") String userId,
@Param("level") String level,
@Param("updateTime") LocalDateTime updateTime);
// 🔥 新增:查询最近回流的客户
List<UserProductCartDTO> findRecentlyRecycledCustomers(@Param("sinceTime") LocalDateTime sinceTime);
// 新增:直接查询有权限的客户列表(支持分页)
List<UserProductCartDTO> getAuthorizedCustomers(@Param("authInfo") ManagerAuthInfo authInfo, @Param("limit") int limit, @Param("offset") int offset);
/**
* 根据认证信息获取有权限的用户ID列表
*/
List<String> getAuthorizedUserIds(@Param("authInfo") ManagerAuthInfo authInfo);
// 获取授权客户总数
int getAuthorizedCustomersCount(@Param("authInfo") ManagerAuthInfo authInfo);
/**
* 根据手机号和权限查询用户
*/
UserProductCartDTO selectByPhoneWithAuth(@Param("phoneNumber") String phoneNumber,
@Param("authInfo") ManagerAuthInfo authInfo);
// 🔥 新增:批量查询用户联系人信息
List<UsersMapper.ContactInfo> getUserContactsByUserIds(@Param("userIds") List<String> userIds);
// 🔥 新增:批量查询用户产品信息
List<UserProductCartDTO.ProductInfo> getSellerProductsByUserIds(@Param("userIds") List<String> userIds);
// 🔥 新增:批量查询用户基本信息
List<UserProductCartDTO> getUserBasicInfoByUserIds(@Param("userIds") List<String> userIds);
// 查询跟进信息
@Select("SELECT followup FROM users WHERE phoneNumber = #{phoneNumber}")
String getFollowUpByPhone(@Param("phoneNumber") String phoneNumber);
// 更新跟进信息
@Update("UPDATE users SET followup = #{followup} WHERE phoneNumber = #{phoneNumber}")
int updateFollowUpByPhone(@Param("phoneNumber") String phoneNumber, @Param("followup") String followup);
}