- 手机号/账号全场景一律脱敏:SensitiveFieldPolicy 删除完整值分支与 ADMIN_EDIT,SELF_PROFILE 同样脱敏;convertToVO 全调用点统一脱敏 - 联系信息接口不再返回号码:toContact 置空 phone 并给出 phoneAvailable,补齐 ensureUserCanSeeShop 真实可见范围校验 - 新增 POST /contact-info/dial,按 scene(SHOP_MANAGER/ORDER_ARTIST/PRODUCT_ARTIST/PLATFORM) 一次一取;DialTargetProvider 抽象直连/隐私号,未配置隐私号返回 9001 且不回退真实号;/contact-info/** 按用户限流并记录审计 - 验证码与换绑手机号改为服务端按当前登录用户取号,客户端 phone/oldPhone 参数兼容忽略;前端与小程序同步去掉回传 - 消息发布人昵称兜底改为脱敏账号,避免 account 明文写入 publisher_name - 新增 V5 账号加密与账号哈希、V6 协议文本改为全场景脱敏与单次拨号取号
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拨号取号配置。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "jayucloud-artlist.dial")
|
||||||
|
public class DialProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拨号提供方:direct(直拨真实号码)或 privacy-number(隐私号,未对接时明确报错)。
|
||||||
|
*/
|
||||||
|
private String provider = "direct";
|
||||||
|
}
|
||||||
+6
@@ -47,6 +47,12 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|||||||
* 注意:QueryWrapper/UpdateWrapper 的 set 不会经过这里,删除等场景需显式置空哈希。
|
* 注意:QueryWrapper/UpdateWrapper 的 set 不会经过这里,删除等场景需显式置空哈希。
|
||||||
*/
|
*/
|
||||||
private void fillPhoneHashes(MetaObject metaObject) {
|
private void fillPhoneHashes(MetaObject metaObject) {
|
||||||
|
if (metaObject.hasSetter("accountHash")) {
|
||||||
|
Object account = getFieldValByName("account", metaObject);
|
||||||
|
if (account != null) {
|
||||||
|
setFieldValByName("accountHash", PhoneCrypto.current().index(String.valueOf(account)), metaObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (metaObject.hasSetter("phoneHash")) {
|
if (metaObject.hasSetter("phoneHash")) {
|
||||||
Object phone = getFieldValByName("phone", metaObject);
|
Object phone = getFieldValByName("phone", metaObject);
|
||||||
if (phone != null) {
|
if (phone != null) {
|
||||||
|
|||||||
+10
@@ -28,6 +28,16 @@ public class RateLimitProperties {
|
|||||||
|
|
||||||
private LimitRule orderCreate = new LimitRule(10, 60);
|
private LimitRule orderCreate = new LimitRule(10, 60);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系方式查询:按登录用户维度。
|
||||||
|
*/
|
||||||
|
private LimitRule contactInfoRead = new LimitRule(30, 60);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次拨号取号:按登录用户维度。
|
||||||
|
*/
|
||||||
|
private LimitRule contactDial = new LimitRule(10, 60);
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
/**
|
/**
|
||||||
* Purpose: LimitRule supports RateLimitProperties.java by holding or executing the limit rule business role.
|
* Purpose: LimitRule supports RateLimitProperties.java by holding or executing the limit rule business role.
|
||||||
|
|||||||
+3
-2
@@ -1,4 +1,4 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.content.service.impl;
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.SensitiveFieldPolicy;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -489,7 +489,8 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentDO> im
|
|||||||
private void fillDisplayFields(CommentVO commentVO, CommentDO commentDO) {
|
private void fillDisplayFields(CommentVO commentVO, CommentDO commentDO) {
|
||||||
UserDO user = commentDO.getUserId() == null ? null : userMapper.selectById(commentDO.getUserId());
|
UserDO user = commentDO.getUserId() == null ? null : userMapper.selectById(commentDO.getUserId());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
commentVO.setUserNickname(StringUtils.hasText(user.getNickname()) ? user.getNickname() : user.getAccount());
|
commentVO.setUserNickname(StringUtils.hasText(user.getNickname()) ? user.getNickname()
|
||||||
|
: SensitiveFieldPolicy.account(user.getAccount(), SensitiveFieldPolicy.Scenario.THIRD_PARTY));
|
||||||
}
|
}
|
||||||
ShopDO shop = commentDO.getShopId() == null ? null : shopMapper.selectById(commentDO.getShopId());
|
ShopDO shop = commentDO.getShopId() == null ? null : shopMapper.selectById(commentDO.getShopId());
|
||||||
if (shop != null) {
|
if (shop != null) {
|
||||||
|
|||||||
+5
-3
@@ -1,4 +1,4 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.message.service.impl;
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.SensitiveFieldPolicy;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -212,7 +212,7 @@ public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Ann
|
|||||||
MessageTargetOptionsVO.UserOptionVO vo = new MessageTargetOptionsVO.UserOptionVO();
|
MessageTargetOptionsVO.UserOptionVO vo = new MessageTargetOptionsVO.UserOptionVO();
|
||||||
vo.setId(user.getId());
|
vo.setId(user.getId());
|
||||||
vo.setNickname(user.getNickname());
|
vo.setNickname(user.getNickname());
|
||||||
vo.setAccount(user.getAccount());
|
vo.setAccount(SensitiveFieldPolicy.account(user.getAccount(), SensitiveFieldPolicy.Scenario.ADMIN_LIST));
|
||||||
vo.setShopId(user.getShopId());
|
vo.setShopId(user.getShopId());
|
||||||
vo.setShopName(shopNameMap.get(user.getShopId()));
|
vo.setShopName(shopNameMap.get(user.getShopId()));
|
||||||
vo.setType(user.getType());
|
vo.setType(user.getType());
|
||||||
@@ -498,6 +498,8 @@ public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Ann
|
|||||||
* @return private String result consumed by the caller or returned to the frontend
|
* @return private String result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
private String resolvePublisherName(UserDO currentUser) {
|
private String resolvePublisherName(UserDO currentUser) {
|
||||||
return StringUtils.hasText(currentUser.getNickname()) ? currentUser.getNickname() : currentUser.getAccount();
|
return StringUtils.hasText(currentUser.getNickname())
|
||||||
|
? currentUser.getNickname()
|
||||||
|
: SensitiveFieldPolicy.account(currentUser.getAccount(), SensitiveFieldPolicy.Scenario.THIRD_PARTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.message.service.impl;
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.SensitiveFieldPolicy;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -267,7 +267,7 @@ public class SystemMessageServiceImpl extends ServiceImpl<SystemMessageMapper, S
|
|||||||
MessageTargetOptionsVO.UserOptionVO vo = new MessageTargetOptionsVO.UserOptionVO();
|
MessageTargetOptionsVO.UserOptionVO vo = new MessageTargetOptionsVO.UserOptionVO();
|
||||||
vo.setId(user.getId());
|
vo.setId(user.getId());
|
||||||
vo.setNickname(user.getNickname());
|
vo.setNickname(user.getNickname());
|
||||||
vo.setAccount(user.getAccount());
|
vo.setAccount(SensitiveFieldPolicy.account(user.getAccount(), SensitiveFieldPolicy.Scenario.ADMIN_LIST));
|
||||||
vo.setShopId(user.getShopId());
|
vo.setShopId(user.getShopId());
|
||||||
vo.setShopName(shopNameMap.get(user.getShopId()));
|
vo.setShopName(shopNameMap.get(user.getShopId()));
|
||||||
vo.setType(user.getType());
|
vo.setType(user.getType());
|
||||||
@@ -881,6 +881,6 @@ public class SystemMessageServiceImpl extends ServiceImpl<SystemMessageMapper, S
|
|||||||
if (StringUtils.hasText(currentUser.getNickname())) {
|
if (StringUtils.hasText(currentUser.getNickname())) {
|
||||||
return currentUser.getNickname();
|
return currentUser.getNickname();
|
||||||
}
|
}
|
||||||
return currentUser.getAccount();
|
return SensitiveFieldPolicy.account(currentUser.getAccount(), SensitiveFieldPolicy.Scenario.THIRD_PARTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -48,6 +48,7 @@ import com.xiaowang.jayucloud.artlist.core.modules.artist.support.BookableArtist
|
|||||||
import com.xiaowang.jayucloud.artlist.core.modules.file.support.ObjectStorageUrlSupport;
|
import com.xiaowang.jayucloud.artlist.core.modules.file.support.ObjectStorageUrlSupport;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.support.OrderStateMachine;
|
import com.xiaowang.jayucloud.artlist.core.modules.order.support.OrderStateMachine;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.support.OrderStatus;
|
import com.xiaowang.jayucloud.artlist.core.modules.order.support.OrderStatus;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.SensitiveFieldPolicy;
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.id.TimeOrderedSnowflakeIdGenerator;
|
import com.xiaowang.jayucloud.artlist.core.support.id.TimeOrderedSnowflakeIdGenerator;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.UserShopBindingSupport;
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.UserShopBindingSupport;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistCalendarAppointmentVO;
|
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistCalendarAppointmentVO;
|
||||||
@@ -3733,7 +3734,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
return customer.getNickname();
|
return customer.getNickname();
|
||||||
}
|
}
|
||||||
if (StringUtils.hasText(customer.getAccount())) {
|
if (StringUtils.hasText(customer.getAccount())) {
|
||||||
return customer.getAccount();
|
return SensitiveFieldPolicy.account(customer.getAccount(), SensitiveFieldPolicy.Scenario.THIRD_PARTY);
|
||||||
}
|
}
|
||||||
return "用户";
|
return "用户";
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -6,7 +6,7 @@ import com.xiaowang.jayucloud.artlist.core.modules.security.entity.SecurityAudit
|
|||||||
import com.xiaowang.jayucloud.artlist.core.modules.security.mapper.SecurityAuditLogMapper;
|
import com.xiaowang.jayucloud.artlist.core.modules.security.mapper.SecurityAuditLogMapper;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.security.service.SecurityAuditLogService;
|
import com.xiaowang.jayucloud.artlist.core.modules.security.service.SecurityAuditLogService;
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.security.RequestThrottleService;
|
import com.xiaowang.jayucloud.artlist.core.support.security.RequestThrottleService;
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.privacy.PhoneCrypto;
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.SensitiveFieldPolicy;
|
||||||
import com.xiaowang.jayucloud.artlist.core.common.vo.PageResultVO;
|
import com.xiaowang.jayucloud.artlist.core.common.vo.PageResultVO;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.security.vo.SecurityAuditLogVO;
|
import com.xiaowang.jayucloud.artlist.core.modules.security.vo.SecurityAuditLogVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -29,7 +29,6 @@ public class SecurityAuditLogServiceImpl implements SecurityAuditLogService {
|
|||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||||
*/
|
*/
|
||||||
private final SecurityAuditLogMapper auditLogMapper;
|
private final SecurityAuditLogMapper auditLogMapper;
|
||||||
private final PhoneCrypto phoneCrypto;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +39,7 @@ public class SecurityAuditLogServiceImpl implements SecurityAuditLogService {
|
|||||||
try {
|
try {
|
||||||
SecurityAuditLogDO log = new SecurityAuditLogDO();
|
SecurityAuditLogDO log = new SecurityAuditLogDO();
|
||||||
log.setUserId(userId);
|
log.setUserId(userId);
|
||||||
log.setAccount(limit(phoneCrypto.maskIfMobile(account), 80));
|
log.setAccount(limit(SensitiveFieldPolicy.account(account, SensitiveFieldPolicy.Scenario.LOG), 80));
|
||||||
log.setAction(limit(action, 80));
|
log.setAction(limit(action, 80));
|
||||||
log.setResult(limit(result, 20));
|
log.setResult(limit(result, 20));
|
||||||
log.setReason(limit(reason, 500));
|
log.setReason(limit(reason, 500));
|
||||||
|
|||||||
+67
-4
@@ -1,8 +1,15 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.shop.controller.front;
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.controller.front;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.common.BusinessException;
|
||||||
import com.xiaowang.jayucloud.artlist.core.common.Result;
|
import com.xiaowang.jayucloud.artlist.core.common.Result;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.security.service.SecurityAuditLogService;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.dto.DialRequestDTO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.service.ContactDialService;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.service.ContactInfoService;
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.service.ContactInfoService;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial.DialScene;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.ContactInfoVO;
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.ContactInfoVO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.DialResponseVO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.support.security.RequestThrottleService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -20,6 +27,18 @@ public class ContactInfoController {
|
|||||||
* Variable `contactInfoService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
* Variable `contactInfoService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||||
*/
|
*/
|
||||||
private final ContactInfoService contactInfoService;
|
private final ContactInfoService contactInfoService;
|
||||||
|
/**
|
||||||
|
* Variable `contactDialService`: resolves a one-time dial number after scene authorization.
|
||||||
|
*/
|
||||||
|
private final ContactDialService contactDialService;
|
||||||
|
/**
|
||||||
|
* Variable `requestThrottleService`: per-user throttling for all contact endpoints.
|
||||||
|
*/
|
||||||
|
private final RequestThrottleService requestThrottleService;
|
||||||
|
/**
|
||||||
|
* Variable `securityAuditLogService`: records who dialed which scene and the result, without the number.
|
||||||
|
*/
|
||||||
|
private final SecurityAuditLogService securityAuditLogService;
|
||||||
|
|
||||||
@GetMapping("/shop/{shopId}/manager")
|
@GetMapping("/shop/{shopId}/manager")
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +49,8 @@ public class ContactInfoController {
|
|||||||
* @return Result<ContactInfoVO> result consumed by the caller or returned to the frontend
|
* @return Result<ContactInfoVO> result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
public Result<ContactInfoVO> shopManager(HttpServletRequest request, @PathVariable Long shopId) {
|
public Result<ContactInfoVO> shopManager(HttpServletRequest request, @PathVariable Long shopId) {
|
||||||
Long userId = (Long) request.getAttribute("userId");
|
Long userId = requireLogin(request);
|
||||||
|
requestThrottleService.checkContactInfoRead(request, userId);
|
||||||
return Result.success(contactInfoService.getShopManagerContact(userId, shopId));
|
return Result.success(contactInfoService.getShopManagerContact(userId, shopId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +64,8 @@ public class ContactInfoController {
|
|||||||
* @return Result<ContactInfoVO> result consumed by the caller or returned to the frontend
|
* @return Result<ContactInfoVO> result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
public Result<ContactInfoVO> productArtist(HttpServletRequest request, @PathVariable Long productId, @PathVariable Long artistId) {
|
public Result<ContactInfoVO> productArtist(HttpServletRequest request, @PathVariable Long productId, @PathVariable Long artistId) {
|
||||||
Long userId = (Long) request.getAttribute("userId");
|
Long userId = requireLogin(request);
|
||||||
|
requestThrottleService.checkContactInfoRead(request, userId);
|
||||||
return Result.success(contactInfoService.getProductArtistContact(userId, productId, artistId));
|
return Result.success(contactInfoService.getProductArtistContact(userId, productId, artistId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +75,8 @@ public class ContactInfoController {
|
|||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||||
*/
|
*/
|
||||||
public Result<ContactInfoVO> orderArtist(HttpServletRequest request, @PathVariable Long orderId, @RequestParam(required = false) Long artistId) {
|
public Result<ContactInfoVO> orderArtist(HttpServletRequest request, @PathVariable Long orderId, @RequestParam(required = false) Long artistId) {
|
||||||
Long userId = (Long) request.getAttribute("userId");
|
Long userId = requireLogin(request);
|
||||||
|
requestThrottleService.checkContactInfoRead(request, userId);
|
||||||
return Result.success(contactInfoService.getOrderArtistContact(userId, orderId, artistId));
|
return Result.success(contactInfoService.getOrderArtistContact(userId, orderId, artistId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,9 +84,50 @@ public class ContactInfoController {
|
|||||||
/**
|
/**
|
||||||
* Run business method `platform`.
|
* Run business method `platform`.
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||||
|
* @param request parameter `request` supplied by the caller
|
||||||
* @return Result<ContactInfoVO> result consumed by the caller or returned to the frontend
|
* @return Result<ContactInfoVO> result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
public Result<ContactInfoVO> platform() {
|
public Result<ContactInfoVO> platform(HttpServletRequest request) {
|
||||||
|
Long userId = requireLogin(request);
|
||||||
|
requestThrottleService.checkContactInfoRead(request, userId);
|
||||||
return Result.success(contactInfoService.getPlatformContact());
|
return Result.success(contactInfoService.getPlatformContact());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/dial")
|
||||||
|
/**
|
||||||
|
* 单次拨号取号:按场景校验可见范围后返回一次可用号码,号码不落库、不进日志、不进缓存。
|
||||||
|
*/
|
||||||
|
public Result<DialResponseVO> dial(HttpServletRequest request, @RequestBody DialRequestDTO dialRequestDTO) {
|
||||||
|
Long userId = requireLogin(request);
|
||||||
|
String account = (String) request.getAttribute("account");
|
||||||
|
requestThrottleService.checkContactDial(request, userId);
|
||||||
|
String action = "CONTACT_DIAL_" + safeSceneCode(dialRequestDTO);
|
||||||
|
try {
|
||||||
|
DialResponseVO response = contactDialService.dial(userId, dialRequestDTO);
|
||||||
|
securityAuditLogService.record(userId, account, action, "SUCCESS", null, request);
|
||||||
|
return Result.success(response);
|
||||||
|
} catch (BusinessException exception) {
|
||||||
|
securityAuditLogService.record(userId, account, action, "FAIL", "code=" + exception.getCode(), request);
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long requireLogin(HttpServletRequest request) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
if (userId == null) {
|
||||||
|
throw new BusinessException(403, "请先登录后再获取联系方式");
|
||||||
|
}
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String safeSceneCode(DialRequestDTO dialRequestDTO) {
|
||||||
|
if (dialRequestDTO == null || dialRequestDTO.getScene() == null) {
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return DialScene.fromCode(dialRequestDTO.getScene()).name();
|
||||||
|
} catch (BusinessException exception) {
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次拨号取号请求。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DialRequestDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拨号场景:SHOP_MANAGER / ORDER_ARTIST / PRODUCT_ARTIST / PLATFORM。
|
||||||
|
*/
|
||||||
|
private String scene;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目标标识:SHOP_MANAGER=店铺ID,ORDER_ARTIST=订单ID,PRODUCT_ARTIST=作品ID,PLATFORM 忽略。
|
||||||
|
*/
|
||||||
|
private Long targetId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可选的美甲师ID,仅 PRODUCT_ARTIST 场景使用;不传时取作品可预约美甲师的第一位。
|
||||||
|
*/
|
||||||
|
private Long artistId;
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.service;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.dto.DialRequestDTO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.DialResponseVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次拨号取号服务:按场景校验可见范围后返回一次可用的拨号号码。
|
||||||
|
*/
|
||||||
|
public interface ContactDialService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按场景解析并返回拨号号码;号码不落库、不进日志、不进缓存。
|
||||||
|
*/
|
||||||
|
DialResponseVO dial(Long userId, DialRequestDTO request);
|
||||||
|
}
|
||||||
+200
@@ -0,0 +1,200 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.common.BusinessException;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.config.DialProperties;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderDO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderItemDO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderItemMapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderMapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.product.entity.ProductDO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.product.mapper.ProductMapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.dto.DialRequestDTO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.entity.ShopDO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.mapper.ShopMapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.service.ContactDialService;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.UserShopBindingSupport;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial.DialScene;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial.DialTargetProvider;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.DialResponseVO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.user.entity.UserDO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.user.mapper.UserMapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
/**
|
||||||
|
* 单次拨号取号实现:先按场景校验可见范围,再由配置的提供方生成拨号号码。
|
||||||
|
*/
|
||||||
|
public class ContactDialServiceImpl implements ContactDialService {
|
||||||
|
|
||||||
|
private static final int FORBIDDEN = 403;
|
||||||
|
|
||||||
|
private final UserMapper userMapper;
|
||||||
|
private final ShopMapper shopMapper;
|
||||||
|
private final ProductMapper productMapper;
|
||||||
|
private final OrderMapper orderMapper;
|
||||||
|
private final OrderItemMapper orderItemMapper;
|
||||||
|
private final UserShopBindingSupport userShopBindingSupport;
|
||||||
|
private final DialProperties dialProperties;
|
||||||
|
private final List<DialTargetProvider> dialTargetProviders;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DialResponseVO dial(Long userId, DialRequestDTO request) {
|
||||||
|
if (userId == null) {
|
||||||
|
throw new BusinessException(FORBIDDEN, "请先登录后再获取联系方式");
|
||||||
|
}
|
||||||
|
DialScene scene = DialScene.fromCode(request == null ? null : request.getScene());
|
||||||
|
UserDO caller = userMapper.selectById(userId);
|
||||||
|
if (caller == null || Integer.valueOf(1).equals(caller.getIsDelete())) {
|
||||||
|
throw new BusinessException(FORBIDDEN, "用户不存在或已失效");
|
||||||
|
}
|
||||||
|
|
||||||
|
String rawPhone = switch (scene) {
|
||||||
|
case SHOP_MANAGER -> resolveShopManagerPhone(caller, request.getTargetId());
|
||||||
|
case ORDER_ARTIST -> resolveOrderArtistPhone(caller, request.getTargetId());
|
||||||
|
case PRODUCT_ARTIST -> resolveProductArtistPhone(request.getTargetId(), request.getArtistId());
|
||||||
|
case PLATFORM -> resolvePlatformPhone();
|
||||||
|
};
|
||||||
|
if (!StringUtils.hasText(rawPhone)) {
|
||||||
|
throw new BusinessException(404, "该联系人暂未配置可拨打电话");
|
||||||
|
}
|
||||||
|
|
||||||
|
DialTargetProvider provider = selectProvider();
|
||||||
|
return provider.resolve(rawPhone);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveShopManagerPhone(UserDO caller, Long shopId) {
|
||||||
|
if (shopId == null || shopId <= 0) {
|
||||||
|
throw new BusinessException(400, "店铺ID不能为空");
|
||||||
|
}
|
||||||
|
ensureShopVisible(caller, shopId);
|
||||||
|
UserDO manager = userMapper.selectOne(new LambdaQueryWrapper<UserDO>()
|
||||||
|
.eq(UserDO::getType, 2)
|
||||||
|
.eq(UserDO::getShopId, shopId)
|
||||||
|
.eq(UserDO::getIsDelete, 0)
|
||||||
|
.eq(UserDO::getStatus, 1)
|
||||||
|
.last("LIMIT 1"));
|
||||||
|
return resolveContactPhone(manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveOrderArtistPhone(UserDO caller, Long orderId) {
|
||||||
|
if (orderId == null || orderId <= 0) {
|
||||||
|
throw new BusinessException(400, "订单ID不能为空");
|
||||||
|
}
|
||||||
|
OrderDO order = orderMapper.selectById(orderId);
|
||||||
|
if (order == null
|
||||||
|
|| Integer.valueOf(1).equals(order.getIsDelete())
|
||||||
|
|| !caller.getId().equals(order.getUserId())) {
|
||||||
|
throw new BusinessException(FORBIDDEN, "订单不存在或无权查看");
|
||||||
|
}
|
||||||
|
OrderItemDO item = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
||||||
|
.eq(OrderItemDO::getOrderId, orderId)
|
||||||
|
.eq(OrderItemDO::getIsDelete, 0)
|
||||||
|
.isNotNull(OrderItemDO::getArtistId)
|
||||||
|
.last("LIMIT 1"))
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow(() -> new BusinessException(404, "订单暂无可联系美甲师"));
|
||||||
|
return resolveContactPhone(userMapper.selectById(item.getArtistId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveProductArtistPhone(Long productId, Long artistId) {
|
||||||
|
if (productId == null || productId <= 0) {
|
||||||
|
throw new BusinessException(400, "作品ID不能为空");
|
||||||
|
}
|
||||||
|
ProductDO product = productMapper.selectById(productId);
|
||||||
|
if (product == null || Integer.valueOf(1).equals(product.getIsDelete())) {
|
||||||
|
throw new BusinessException(FORBIDDEN, "作品不存在或不可见");
|
||||||
|
}
|
||||||
|
Long targetArtistId = artistId;
|
||||||
|
if (targetArtistId == null || targetArtistId <= 0) {
|
||||||
|
targetArtistId = firstBookableArtistId(product.getBookableArtists());
|
||||||
|
}
|
||||||
|
if (targetArtistId == null) {
|
||||||
|
throw new BusinessException(404, "该作品暂未配置可联系美甲师");
|
||||||
|
}
|
||||||
|
ensureArtistAllowed(product.getBookableArtists(), targetArtistId);
|
||||||
|
return resolveContactPhone(userMapper.selectById(targetArtistId));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolvePlatformPhone() {
|
||||||
|
UserDO admin = userMapper.selectOne(new LambdaQueryWrapper<UserDO>()
|
||||||
|
.eq(UserDO::getType, 4)
|
||||||
|
.eq(UserDO::getIsDelete, 0)
|
||||||
|
.eq(UserDO::getStatus, 1)
|
||||||
|
.isNotNull(UserDO::getPhone)
|
||||||
|
.last("LIMIT 1"));
|
||||||
|
return resolveContactPhone(admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验当前用户是否可拨打该店铺店长:平台管理员、本店用户、有绑定关系或门店公开可见。
|
||||||
|
*/
|
||||||
|
private void ensureShopVisible(UserDO caller, Long shopId) {
|
||||||
|
if (Integer.valueOf(4).equals(caller.getType())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (shopId.equals(caller.getShopId()) || userShopBindingSupport.hasActiveBinding(caller.getId(), shopId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ShopDO shop = shopMapper.selectById(shopId);
|
||||||
|
if (shop == null || Integer.valueOf(1).equals(shop.getIsDelete())) {
|
||||||
|
throw new BusinessException(FORBIDDEN, "店铺不存在或不可见");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureArtistAllowed(String rawBookableArtists, Long artistId) {
|
||||||
|
if (!StringUtils.hasText(rawBookableArtists)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean allowed = Arrays.stream(rawBookableArtists.split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(StringUtils::hasText)
|
||||||
|
.anyMatch(id -> id.equals(String.valueOf(artistId)));
|
||||||
|
if (!allowed) {
|
||||||
|
throw new BusinessException(FORBIDDEN, "该美甲师不可联系当前作品");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long firstBookableArtistId(String rawBookableArtists) {
|
||||||
|
if (!StringUtils.hasText(rawBookableArtists)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Arrays.stream(rawBookableArtists.split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(StringUtils::hasText)
|
||||||
|
.map(value -> {
|
||||||
|
try {
|
||||||
|
return Long.valueOf(value);
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(java.util.Objects::nonNull)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveContactPhone(UserDO contact) {
|
||||||
|
if (contact == null || Integer.valueOf(1).equals(contact.getIsDelete())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return StringUtils.hasText(contact.getContactPhone()) ? contact.getContactPhone() : contact.getPhone();
|
||||||
|
}
|
||||||
|
|
||||||
|
private DialTargetProvider selectProvider() {
|
||||||
|
String configured = StringUtils.hasText(dialProperties.getProvider())
|
||||||
|
? dialProperties.getProvider().trim()
|
||||||
|
: "direct";
|
||||||
|
return dialTargetProviders.stream()
|
||||||
|
.filter(provider -> provider.name().equalsIgnoreCase(configured))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow(() -> new BusinessException(9002, "拨号号码提供方配置无效"));
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
-8
@@ -1,6 +1,7 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.shop.service.impl;
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.common.BusinessException;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderDO;
|
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderDO;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderItemDO;
|
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderItemDO;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.entity.ProductDO;
|
import com.xiaowang.jayucloud.artlist.core.modules.product.entity.ProductDO;
|
||||||
@@ -8,12 +9,13 @@ import com.xiaowang.jayucloud.artlist.core.modules.user.entity.UserDO;
|
|||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderItemMapper;
|
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderItemMapper;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderMapper;
|
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderMapper;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.mapper.ProductMapper;
|
import com.xiaowang.jayucloud.artlist.core.modules.product.mapper.ProductMapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.entity.ShopDO;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.user.mapper.UserMapper;
|
import com.xiaowang.jayucloud.artlist.core.modules.user.mapper.UserMapper;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.service.ContactInfoService;
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.service.ContactInfoService;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.file.support.ObjectStorageUrlSupport;
|
import com.xiaowang.jayucloud.artlist.core.modules.file.support.ObjectStorageUrlSupport;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.UserShopBindingSupport;
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.UserShopBindingSupport;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.ContactInfoVO;
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.ContactInfoVO;
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.privacy.PhoneCrypto;
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.SensitiveFieldPolicy;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -41,6 +43,10 @@ public class ContactInfoServiceImpl implements ContactInfoService {
|
|||||||
* Variable `orderItemMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
* Variable `orderItemMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||||
*/
|
*/
|
||||||
private final OrderItemMapper orderItemMapper;
|
private final OrderItemMapper orderItemMapper;
|
||||||
|
/**
|
||||||
|
* Variable `shopMapper`: used to verify the target shop is visible before exposing contact actions.
|
||||||
|
*/
|
||||||
|
private final com.xiaowang.jayucloud.artlist.core.modules.shop.mapper.ShopMapper shopMapper;
|
||||||
/**
|
/**
|
||||||
* Variable `userShopBindingSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
* Variable `userShopBindingSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||||
*/
|
*/
|
||||||
@@ -49,7 +55,6 @@ public class ContactInfoServiceImpl implements ContactInfoService {
|
|||||||
* Variable `objectStorageUrlSupport`: converts stored QR image URLs into frontend-safe signed URLs.
|
* Variable `objectStorageUrlSupport`: converts stored QR image URLs into frontend-safe signed URLs.
|
||||||
*/
|
*/
|
||||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||||
private final PhoneCrypto phoneCrypto;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
/**
|
/**
|
||||||
@@ -162,11 +167,23 @@ public class ContactInfoServiceImpl implements ContactInfoService {
|
|||||||
* @return private void result consumed by the caller or returned to the frontend
|
* @return private void result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
private void ensureUserCanSeeShop(Long userId, Long shopId) {
|
private void ensureUserCanSeeShop(Long userId, Long shopId) {
|
||||||
if (userId == null) return;
|
if (userId == null) {
|
||||||
|
throw new BusinessException(403, "请先登录后再获取联系方式");
|
||||||
|
}
|
||||||
UserDO user = userMapper.selectById(userId);
|
UserDO user = userMapper.selectById(userId);
|
||||||
if (user != null && shopId.equals(user.getShopId())) return;
|
if (user == null || Integer.valueOf(1).equals(user.getIsDelete())) {
|
||||||
if (!userShopBindingSupport.hasActiveBinding(userId, shopId)) {
|
throw new BusinessException(403, "用户不存在或已失效");
|
||||||
// 店铺详情是公开入口,未绑定用户仍允许看联系方式。
|
}
|
||||||
|
if (Integer.valueOf(4).equals(user.getType())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (shopId.equals(user.getShopId()) || userShopBindingSupport.hasActiveBinding(userId, shopId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 普通用户仅可查看未删除的门店,与公开店铺详情可见范围一致。
|
||||||
|
ShopDO shop = shopMapper.selectById(shopId);
|
||||||
|
if (shop == null || Integer.valueOf(1).equals(shop.getIsDelete())) {
|
||||||
|
throw new BusinessException(403, "店铺不存在或不可见");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,9 +221,11 @@ public class ContactInfoServiceImpl implements ContactInfoService {
|
|||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
vo.setContactUserId(user.getId());
|
vo.setContactUserId(user.getId());
|
||||||
vo.setContactName(StringUtils.hasText(user.getNickname()) ? user.getNickname() : user.getAccount());
|
vo.setContactName(StringUtils.hasText(user.getNickname()) ? user.getNickname()
|
||||||
|
: SensitiveFieldPolicy.account(user.getAccount(), SensitiveFieldPolicy.Scenario.THIRD_PARTY));
|
||||||
String contactPhone = StringUtils.hasText(user.getContactPhone()) ? user.getContactPhone() : user.getPhone();
|
String contactPhone = StringUtils.hasText(user.getContactPhone()) ? user.getContactPhone() : user.getPhone();
|
||||||
vo.setPhone(phoneCrypto.mask(contactPhone));
|
// 全场景脱敏:联系信息接口不再返回号码,真实号码只通过 /contact-info/dial 单次取号。
|
||||||
|
vo.setPhone(null);
|
||||||
vo.setPhoneAvailable(StringUtils.hasText(contactPhone));
|
vo.setPhoneAvailable(StringUtils.hasText(contactPhone));
|
||||||
vo.setWechatId(user.getWechatId());
|
vo.setWechatId(user.getWechatId());
|
||||||
vo.setWechatAvailable(StringUtils.hasText(user.getWechatId()));
|
vo.setWechatAvailable(StringUtils.hasText(user.getWechatId()));
|
||||||
|
|||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.common.BusinessException;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拨号场景及其入参含义。
|
||||||
|
*/
|
||||||
|
public enum DialScene {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺店长:targetId 为店铺ID。
|
||||||
|
*/
|
||||||
|
SHOP_MANAGER,
|
||||||
|
/**
|
||||||
|
* 订单美甲师:targetId 为订单ID。
|
||||||
|
*/
|
||||||
|
ORDER_ARTIST,
|
||||||
|
/**
|
||||||
|
* 作品美甲师:targetId 为作品ID,可选 artistId 指定美甲师。
|
||||||
|
*/
|
||||||
|
PRODUCT_ARTIST,
|
||||||
|
/**
|
||||||
|
* 平台客服:targetId 忽略。
|
||||||
|
*/
|
||||||
|
PLATFORM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析前端传入的场景值。
|
||||||
|
*/
|
||||||
|
public static DialScene fromCode(String code) {
|
||||||
|
if (!StringUtils.hasText(code)) {
|
||||||
|
throw new BusinessException(400, "拨号场景不能为空");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return DialScene.valueOf(code.trim().toUpperCase());
|
||||||
|
} catch (IllegalArgumentException exception) {
|
||||||
|
throw new BusinessException(400, "不支持的拨号场景");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.DialResponseVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拨号号码提供方:直拨真实号码或隐私号。
|
||||||
|
*/
|
||||||
|
public interface DialTargetProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置值标识,与 jayucloud-artlist.dial.provider 对应。
|
||||||
|
*/
|
||||||
|
String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将已通过授权校验的真实号码转换为拨号响应。
|
||||||
|
*/
|
||||||
|
DialResponseVO resolve(String rawPhone);
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.DialResponseVO;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直拨真实号码的提供方。
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class DirectDialTargetProvider implements DialTargetProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直拨号码的有效提示时长,仅用于前端控制展示,不做服务端缓存。
|
||||||
|
*/
|
||||||
|
private static final int EXPIRES_IN_SECONDS = 300;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "direct";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DialResponseVO resolve(String rawPhone) {
|
||||||
|
DialResponseVO vo = new DialResponseVO();
|
||||||
|
vo.setMode("DIRECT");
|
||||||
|
vo.setDialNumber(rawPhone);
|
||||||
|
vo.setExpiresInSeconds(EXPIRES_IN_SECONDS);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.common.BusinessException;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.DialResponseVO;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐私号提供方占位实现:未对接隐私号平台时明确报错,绝不回退成真实号码。
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class PlaceholderPrivacyNumberProvider implements DialTargetProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐私号未配置的业务码。
|
||||||
|
*/
|
||||||
|
public static final int NOT_CONFIGURED_CODE = 9001;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "privacy-number";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DialResponseVO resolve(String rawPhone) {
|
||||||
|
throw new BusinessException(NOT_CONFIGURED_CODE, "隐私号码服务未配置,暂时无法拨号");
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次拨号取号响应。号码本身不进审计、日志与缓存。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DialResponseVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拨号模式:DIRECT=直拨真实号码,PRIVACY_NUMBER=隐私号码。
|
||||||
|
*/
|
||||||
|
private String mode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拨号号码;PRIVACY_NUMBER 未对接时不会返回真实号码。
|
||||||
|
*/
|
||||||
|
private String dialNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本次号码的有效时长(秒),供前端控制缓存时间。
|
||||||
|
*/
|
||||||
|
private Integer expiresInSeconds;
|
||||||
|
}
|
||||||
+42
-6
@@ -140,6 +140,10 @@ public class UserController {
|
|||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||||
*/
|
*/
|
||||||
private final LegalAgreementService legalAgreementService;
|
private final LegalAgreementService legalAgreementService;
|
||||||
|
/**
|
||||||
|
* Variable `jwtUtil`: resolves the optional logged-in user on endpoints excluded from authentication.
|
||||||
|
*/
|
||||||
|
private final com.xiaowang.jayucloud.artlist.core.utils.JwtUtil jwtUtil;
|
||||||
/**
|
/**
|
||||||
* Purpose: securityAuditLogService supports UserController.java by holding or executing the security audit log service business role.
|
* Purpose: securityAuditLogService supports UserController.java by holding or executing the security audit log service business role.
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||||
@@ -361,7 +365,7 @@ public class UserController {
|
|||||||
String normalizedAccount = AccountValidationUtils.requireValidAccount(account);
|
String normalizedAccount = AccountValidationUtils.requireValidAccount(account);
|
||||||
UserDO userDO = userMapper.selectOne(
|
UserDO userDO = userMapper.selectOne(
|
||||||
com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery(UserDO.class)
|
com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, normalizedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(normalizedAccount))
|
||||||
);
|
);
|
||||||
boolean available = userDO == null || Integer.valueOf(1).equals(userDO.getIsDelete());
|
boolean available = userDO == null || Integer.valueOf(1).equals(userDO.getIsDelete());
|
||||||
String message = available ? "账号可用" : "账号已被注册";
|
String message = available ? "账号可用" : "账号已被注册";
|
||||||
@@ -379,7 +383,7 @@ public class UserController {
|
|||||||
String normalizedAccount = AccountValidationUtils.requireValidAccount(account);
|
String normalizedAccount = AccountValidationUtils.requireValidAccount(account);
|
||||||
UserDO userDO = userMapper.selectOne(
|
UserDO userDO = userMapper.selectOne(
|
||||||
com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery(UserDO.class)
|
com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, normalizedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(normalizedAccount))
|
||||||
.eq(UserDO::getIsDelete, 0)
|
.eq(UserDO::getIsDelete, 0)
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
);
|
);
|
||||||
@@ -552,7 +556,7 @@ public class UserController {
|
|||||||
boolean success = userService.register(registerRequestDTO);
|
boolean success = userService.register(registerRequestDTO);
|
||||||
UserDO userDO = userMapper.selectOne(
|
UserDO userDO = userMapper.selectOne(
|
||||||
com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery(UserDO.class)
|
com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, AccountValidationUtils.requireValidAccount(registerRequestDTO.getAccount()))
|
.eq(UserDO::getAccountHash, phoneCrypto.index(AccountValidationUtils.requireValidAccount(registerRequestDTO.getAccount())))
|
||||||
.eq(UserDO::getIsDelete, 0)
|
.eq(UserDO::getIsDelete, 0)
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
);
|
);
|
||||||
@@ -599,8 +603,9 @@ public class UserController {
|
|||||||
@PostMapping("/send-verification-code")
|
@PostMapping("/send-verification-code")
|
||||||
@OperationGuard(action = "send-verification-code", ttlSeconds = 8, message = "验证码发送处理中,请稍后再试")
|
@OperationGuard(action = "send-verification-code", ttlSeconds = 8, message = "验证码发送处理中,请稍后再试")
|
||||||
public Result<Boolean> sendVerificationCode(HttpServletRequest request, @RequestBody SendVerificationCodeRequestDTO sendVerificationCodeRequestDTO) {
|
public Result<Boolean> sendVerificationCode(HttpServletRequest request, @RequestBody SendVerificationCodeRequestDTO sendVerificationCodeRequestDTO) {
|
||||||
requestThrottleService.checkSendCode(request, sendVerificationCodeRequestDTO.getPhone());
|
String phone = resolveSendCodePhone(request, sendVerificationCodeRequestDTO);
|
||||||
if (!verificationCodeService.canResend(sendVerificationCodeRequestDTO.getPhone())) {
|
requestThrottleService.checkSendCode(request, phone);
|
||||||
|
if (!verificationCodeService.canResend(phone)) {
|
||||||
/**
|
/**
|
||||||
* Run business method `RuntimeException`.
|
* Run business method `RuntimeException`.
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||||
@@ -609,10 +614,41 @@ public class UserController {
|
|||||||
*/
|
*/
|
||||||
throw new RuntimeException("验证码发送过于频繁,请1分钟后再试");
|
throw new RuntimeException("验证码发送过于频繁,请1分钟后再试");
|
||||||
}
|
}
|
||||||
verificationCodeService.sendVerificationCode(sendVerificationCodeRequestDTO.getPhone(), sendVerificationCodeRequestDTO.getSceneCode());
|
verificationCodeService.sendVerificationCode(phone, sendVerificationCodeRequestDTO.getSceneCode());
|
||||||
return Result.success(true);
|
return Result.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码等"发给自己"的验证码场景:号码由服务端按当前登录用户取,客户端传参忽略。
|
||||||
|
*/
|
||||||
|
private String resolveSendCodePhone(HttpServletRequest request, SendVerificationCodeRequestDTO dto) {
|
||||||
|
String sceneCode = dto.getSceneCode();
|
||||||
|
if (!"USER_CHANGE_PASSWORD_SMS_CODE".equals(sceneCode)) {
|
||||||
|
return dto.getPhone();
|
||||||
|
}
|
||||||
|
Long userId = resolveOptionalUserId(request);
|
||||||
|
if (userId == null) {
|
||||||
|
return dto.getPhone();
|
||||||
|
}
|
||||||
|
return userService.getBoundPhone(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long resolveOptionalUserId(HttpServletRequest request) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
if (userId != null) {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
String authorization = request.getHeader("Authorization");
|
||||||
|
if (authorization == null || !authorization.startsWith("Bearer ")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String token = authorization.substring("Bearer ".length()).trim();
|
||||||
|
if (!jwtUtil.validateToken(token) || !jwtUtil.isAccessToken(token)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return jwtUtil.getUserIdFromToken(token);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过手机号验证码重置密码
|
* 通过手机号验证码重置密码
|
||||||
*
|
*
|
||||||
|
|||||||
+9
-2
@@ -12,6 +12,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.common.entity.BaseEntity;
|
import com.xiaowang.jayucloud.artlist.core.common.entity.BaseEntity;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.AccountPhoneTypeHandler;
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.privacy.PhoneEncryptionTypeHandler;
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.PhoneEncryptionTypeHandler;
|
||||||
/**
|
/**
|
||||||
* 系统用户信息表 DO
|
* 系统用户信息表 DO
|
||||||
@@ -45,11 +46,17 @@ public class UserDO extends BaseEntity {
|
|||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户账号(登录用)
|
* 用户账号(登录用,AES-GCM 密文,落库列 account;实体中保持明文,便于业务使用)
|
||||||
*/
|
*/
|
||||||
@TableField("account")
|
@TableField(value = "account", typeHandler = AccountPhoneTypeHandler.class)
|
||||||
private String account;
|
private String account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号哈希(HMAC-SHA256,十六进制小写),所有账号等值查询统一使用
|
||||||
|
*/
|
||||||
|
@TableField("account_hash")
|
||||||
|
private String accountHash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机号(AES-GCM 密文,落库列 phone_cipher;实体中保持明文,便于业务使用)
|
* 手机号(AES-GCM 密文,落库列 phone_cipher;实体中保持明文,便于业务使用)
|
||||||
*/
|
*/
|
||||||
|
|||||||
+5
@@ -394,4 +394,9 @@ public interface UserService extends IService<UserDO> {
|
|||||||
* @return boolean result consumed by the caller or returned to the frontend
|
* @return boolean result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
boolean updatePhone(Long userId, UpdatePhoneRequestDTO updatePhoneDTO);
|
boolean updatePhone(Long userId, UpdatePhoneRequestDTO updatePhoneDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录用户已绑定的手机号(明文,仅用于服务端发码,不返回前端)。
|
||||||
|
*/
|
||||||
|
String getBoundPhone(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
+63
-40
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.xiaowang.jayucloud.artlist.core.config.BrandProperties;
|
import com.xiaowang.jayucloud.artlist.core.config.BrandProperties;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.common.BusinessException;
|
||||||
import com.xiaowang.jayucloud.artlist.core.common.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.common.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.artist.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.auth.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.auth.dto.*;
|
||||||
@@ -49,6 +50,7 @@ import com.xiaowang.jayucloud.artlist.core.modules.file.support.ObjectStorageUrl
|
|||||||
import com.xiaowang.jayucloud.artlist.core.modules.security.support.PermissionCatalog;
|
import com.xiaowang.jayucloud.artlist.core.modules.security.support.PermissionCatalog;
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.security.UserSessionService;
|
import com.xiaowang.jayucloud.artlist.core.support.security.UserSessionService;
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.privacy.PhoneCrypto;
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.PhoneCrypto;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.support.privacy.SensitiveFieldPolicy;
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.id.TimeOrderedSnowflakeIdGenerator;
|
import com.xiaowang.jayucloud.artlist.core.support.id.TimeOrderedSnowflakeIdGenerator;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.security.support.PermissionPolicy;
|
import com.xiaowang.jayucloud.artlist.core.modules.security.support.PermissionPolicy;
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.RequestShopContext;
|
import com.xiaowang.jayucloud.artlist.core.support.RequestShopContext;
|
||||||
@@ -371,7 +373,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
// 检查账号是否已存在
|
// 检查账号是否已存在
|
||||||
UserDO existingUser = userMapper.selectOne(
|
UserDO existingUser = userMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(UserDO.class)
|
Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, validatedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(validatedAccount))
|
||||||
.eq(UserDO::getIsDelete, 0)
|
.eq(UserDO::getIsDelete, 0)
|
||||||
);
|
);
|
||||||
if (existingUser != null) {
|
if (existingUser != null) {
|
||||||
@@ -536,7 +538,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
if (normalizedAccount != null && !normalizedAccount.equals(userDO.getAccount())) {
|
if (normalizedAccount != null && !normalizedAccount.equals(userDO.getAccount())) {
|
||||||
UserDO existingUser = userMapper.selectOne(
|
UserDO existingUser = userMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(UserDO.class)
|
Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, normalizedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(normalizedAccount))
|
||||||
.eq(UserDO::getIsDelete, 0)
|
.eq(UserDO::getIsDelete, 0)
|
||||||
);
|
);
|
||||||
if (existingUser != null) {
|
if (existingUser != null) {
|
||||||
@@ -655,21 +657,34 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
.set(WechatMiniBindingDO::getUpdateTime, LocalDateTime.now())
|
.set(WechatMiniBindingDO::getUpdateTime, LocalDateTime.now())
|
||||||
);
|
);
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
String deletedAccount = buildDeletedAccount(userDO);
|
||||||
return userMapper.update(
|
return userMapper.update(
|
||||||
null,
|
null,
|
||||||
new LambdaUpdateWrapper<UserDO>()
|
buildSoftDeleteUpdate(id,
|
||||||
.eq(UserDO::getId, id)
|
phoneCrypto.encryptAccount(deletedAccount),
|
||||||
.eq(UserDO::getIsDelete, 0)
|
phoneCrypto.index(deletedAccount),
|
||||||
.set(UserDO::getAccount, buildDeletedAccount(userDO))
|
now)
|
||||||
.set(UserDO::getPhone, null)
|
|
||||||
.set(UserDO::getPhoneHash, null)
|
|
||||||
.set(UserDO::getContactPhoneHash, null)
|
|
||||||
.set(UserDO::getStatus, 0)
|
|
||||||
.set(UserDO::getIsDelete, 1)
|
|
||||||
.set(UserDO::getUpdateTime, now)
|
|
||||||
) > 0;
|
) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造账号注销更新条件:账号改为占位值,手机号/联系电话的密文与哈希一并清空,避免数据残留。
|
||||||
|
*/
|
||||||
|
static LambdaUpdateWrapper<UserDO> buildSoftDeleteUpdate(Long id, String encryptedAccount, String accountHash, LocalDateTime now) {
|
||||||
|
return new LambdaUpdateWrapper<UserDO>()
|
||||||
|
.eq(UserDO::getId, id)
|
||||||
|
.eq(UserDO::getIsDelete, 0)
|
||||||
|
.set(UserDO::getAccount, encryptedAccount)
|
||||||
|
.set(UserDO::getAccountHash, accountHash)
|
||||||
|
.set(UserDO::getPhone, null)
|
||||||
|
.set(UserDO::getPhoneHash, null)
|
||||||
|
.set(UserDO::getContactPhone, null)
|
||||||
|
.set(UserDO::getContactPhoneHash, null)
|
||||||
|
.set(UserDO::getStatus, 0)
|
||||||
|
.set(UserDO::getIsDelete, 1)
|
||||||
|
.set(UserDO::getUpdateTime, now);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID获取用户信息
|
* 根据ID获取用户信息
|
||||||
* @param id 用户ID
|
* @param id 用户ID
|
||||||
@@ -687,7 +702,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
* @param userDO parameter `userDO` supplied by the caller
|
* @param userDO parameter `userDO` supplied by the caller
|
||||||
* @return return result consumed by the caller or returned to the frontend
|
* @return return result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
return convertToVO(userDO);
|
return convertToVO(userDO, SensitiveFieldPolicy.Scenario.SELF_PROFILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -701,7 +716,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
.eq(UserDO::getIsDelete, 0)
|
.eq(UserDO::getIsDelete, 0)
|
||||||
);
|
);
|
||||||
return userDOs.stream()
|
return userDOs.stream()
|
||||||
.map(this::convertToVO)
|
.map(user -> convertToVO(user, SensitiveFieldPolicy.Scenario.ADMIN_LIST))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,7 +737,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
.in(UserDO::getId, userIds)
|
.in(UserDO::getId, userIds)
|
||||||
);
|
);
|
||||||
return userDOs.stream()
|
return userDOs.stream()
|
||||||
.map(this::convertToVO)
|
.map(user -> convertToVO(user, SensitiveFieldPolicy.Scenario.ADMIN_LIST))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -739,7 +754,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
.eq(UserDO::getType, type)
|
.eq(UserDO::getType, type)
|
||||||
);
|
);
|
||||||
return userDOs.stream()
|
return userDOs.stream()
|
||||||
.map(this::convertToVO)
|
.map(user -> convertToVO(user, SensitiveFieldPolicy.Scenario.ADMIN_LIST))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,7 +768,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
String normalizedAccount = AccountValidationUtils.requireValidAccount(account);
|
String normalizedAccount = AccountValidationUtils.requireValidAccount(account);
|
||||||
UserDO userDO = userMapper.selectOne(
|
UserDO userDO = userMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(UserDO.class)
|
Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, normalizedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(normalizedAccount))
|
||||||
.eq(UserDO::getIsDelete, 0)
|
.eq(UserDO::getIsDelete, 0)
|
||||||
);
|
);
|
||||||
if (userDO == null || Integer.valueOf(1).equals(userDO.getIsDelete())) {
|
if (userDO == null || Integer.valueOf(1).equals(userDO.getIsDelete())) {
|
||||||
@@ -765,7 +780,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
* @param userDO parameter `userDO` supplied by the caller
|
* @param userDO parameter `userDO` supplied by the caller
|
||||||
* @return return result consumed by the caller or returned to the frontend
|
* @return return result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
return convertToVO(userDO);
|
return convertToVO(userDO, SensitiveFieldPolicy.Scenario.SELF_PROFILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -774,7 +789,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
* @param userDO 用户DO
|
* @param userDO 用户DO
|
||||||
* @return 用户VO
|
* @return 用户VO
|
||||||
*/
|
*/
|
||||||
private UserVO convertToVO(UserDO userDO) {
|
private UserVO convertToVO(UserDO userDO, SensitiveFieldPolicy.Scenario scenario) {
|
||||||
UserVO userVO = new UserVO();
|
UserVO userVO = new UserVO();
|
||||||
userVO.setId(userDO.getId());
|
userVO.setId(userDO.getId());
|
||||||
List<ShopSimpleVO> shopOptions = resolveShopOptions(userDO, true, false);
|
List<ShopSimpleVO> shopOptions = resolveShopOptions(userDO, true, false);
|
||||||
@@ -795,9 +810,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
userVO.setShopIds(shopOptions.stream().map(ShopSimpleVO::getId).collect(Collectors.toList()));
|
userVO.setShopIds(shopOptions.stream().map(ShopSimpleVO::getId).collect(Collectors.toList()));
|
||||||
userVO.setShopNames(shopOptions.stream().map(ShopSimpleVO::getShopName).collect(Collectors.toList()));
|
userVO.setShopNames(shopOptions.stream().map(ShopSimpleVO::getShopName).collect(Collectors.toList()));
|
||||||
userVO.setNickname(userDO.getNickname());
|
userVO.setNickname(userDO.getNickname());
|
||||||
userVO.setAccount(userDO.getAccount());
|
userVO.setAccount(SensitiveFieldPolicy.account(userDO.getAccount(), scenario));
|
||||||
userVO.setPhone(maskPhone(userDO.getPhone()));
|
userVO.setPhone(SensitiveFieldPolicy.phone(userDO.getPhone(), scenario));
|
||||||
userVO.setContactPhone(maskPhone(userDO.getContactPhone()));
|
userVO.setContactPhone(SensitiveFieldPolicy.phone(userDO.getContactPhone(), scenario));
|
||||||
userVO.setBirthday(userDO.getBirthday());
|
userVO.setBirthday(userDO.getBirthday());
|
||||||
userVO.setWechatId(userDO.getWechatId());
|
userVO.setWechatId(userDO.getWechatId());
|
||||||
userVO.setWechatQrCode(resolveAccessibleProfileImage(userDO.getWechatQrCode()));
|
userVO.setWechatQrCode(resolveAccessibleProfileImage(userDO.getWechatQrCode()));
|
||||||
@@ -873,7 +888,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
|
|
||||||
UserDO userDO = userMapper.selectOne(
|
UserDO userDO = userMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(UserDO.class)
|
Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, normalizedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(normalizedAccount))
|
||||||
.eq(UserDO::getIsDelete, 0)
|
.eq(UserDO::getIsDelete, 0)
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
);
|
);
|
||||||
@@ -978,7 +993,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
|
|
||||||
UserDO userDO = userMapper.selectOne(
|
UserDO userDO = userMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(UserDO.class)
|
Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, normalizedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(normalizedAccount))
|
||||||
.eq(UserDO::getIsDelete, 0)
|
.eq(UserDO::getIsDelete, 0)
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
);
|
);
|
||||||
@@ -1026,7 +1041,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
String normalizedAccount = AccountValidationUtils.requireValidAccount(loginRequestDTO.getAccount());
|
String normalizedAccount = AccountValidationUtils.requireValidAccount(loginRequestDTO.getAccount());
|
||||||
UserDO userDO = userMapper.selectOne(
|
UserDO userDO = userMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(UserDO.class)
|
Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, normalizedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(normalizedAccount))
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1243,7 +1258,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
String normalizedAccount = AccountValidationUtils.requireValidAccount(loginRequestDTO.getAccount());
|
String normalizedAccount = AccountValidationUtils.requireValidAccount(loginRequestDTO.getAccount());
|
||||||
UserDO userDO = userMapper.selectOne(
|
UserDO userDO = userMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(UserDO.class)
|
Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, normalizedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(normalizedAccount))
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1452,7 +1467,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
|
|
||||||
UserDO existingUser = userMapper.selectOne(
|
UserDO existingUser = userMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(UserDO.class)
|
Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, validatedAccount)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(validatedAccount))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (existingUser != null) {
|
if (existingUser != null) {
|
||||||
@@ -1545,7 +1560,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
|
|
||||||
UserDO existingUser = userMapper.selectOne(
|
UserDO existingUser = userMapper.selectOne(
|
||||||
Wrappers.lambdaQuery(UserDO.class)
|
Wrappers.lambdaQuery(UserDO.class)
|
||||||
.eq(UserDO::getAccount, phone)
|
.eq(UserDO::getAccountHash, phoneCrypto.index(phone))
|
||||||
.eq(UserDO::getIsDelete, 0)
|
.eq(UserDO::getIsDelete, 0)
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
);
|
);
|
||||||
@@ -1901,8 +1916,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
// 不再过滤普通用户,由前端根据用户角色进行过滤
|
// 不再过滤普通用户,由前端根据用户角色进行过滤
|
||||||
if (StringUtils.hasText(keyword)) {
|
if (StringUtils.hasText(keyword)) {
|
||||||
String keywordPhoneHash = phoneCrypto.isMobilePhone(keyword) ? phoneCrypto.index(keyword) : null;
|
String keywordPhoneHash = phoneCrypto.isMobilePhone(keyword) ? phoneCrypto.index(keyword) : null;
|
||||||
|
String keywordAccountHash = phoneCrypto.index(keyword);
|
||||||
wrapper.and(w -> {
|
wrapper.and(w -> {
|
||||||
w.like(UserDO::getAccount, keyword).or().like(UserDO::getNickname, keyword);
|
// 账号落库为密文,不能模糊检索,统一走 account_hash 精确匹配
|
||||||
|
w.eq(UserDO::getAccountHash, keywordAccountHash).or().like(UserDO::getNickname, keyword);
|
||||||
// 手机号只做精确匹配:密文不可模糊检索,统一走 phone_hash
|
// 手机号只做精确匹配:密文不可模糊检索,统一走 phone_hash
|
||||||
if (keywordPhoneHash != null) {
|
if (keywordPhoneHash != null) {
|
||||||
w.or().eq(UserDO::getPhoneHash, keywordPhoneHash)
|
w.or().eq(UserDO::getPhoneHash, keywordPhoneHash)
|
||||||
@@ -1960,7 +1977,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
Page<UserDO> userPage = userMapper.selectPage(pageParam, wrapper);
|
Page<UserDO> userPage = userMapper.selectPage(pageParam, wrapper);
|
||||||
|
|
||||||
PageResultVO<UserVO> result = new PageResultVO<>();
|
PageResultVO<UserVO> result = new PageResultVO<>();
|
||||||
result.setList(userPage.getRecords().stream().map(this::convertToVO).collect(Collectors.toList()));
|
result.setList(userPage.getRecords().stream().map(user -> convertToVO(user, SensitiveFieldPolicy.Scenario.ADMIN_LIST)).collect(Collectors.toList()));
|
||||||
result.setTotal(userPage.getTotal());
|
result.setTotal(userPage.getTotal());
|
||||||
result.setPage(page);
|
result.setPage(page);
|
||||||
result.setSize(size);
|
result.setSize(size);
|
||||||
@@ -2220,7 +2237,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
* @return boolean result consumed by the caller or returned to the frontend
|
* @return boolean result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
public boolean updatePhone(Long userId, UpdatePhoneRequestDTO updatePhoneDTO) {
|
public boolean updatePhone(Long userId, UpdatePhoneRequestDTO updatePhoneDTO) {
|
||||||
String oldPhone = updatePhoneDTO.getOldPhone();
|
// 原手机号由服务端按当前登录用户读取,客户端传入的 oldPhone 仅为兼容旧协议,不参与校验。
|
||||||
String newPhone = updatePhoneDTO.getNewPhone();
|
String newPhone = updatePhoneDTO.getNewPhone();
|
||||||
String verificationCode = updatePhoneDTO.getVerificationCode();
|
String verificationCode = updatePhoneDTO.getVerificationCode();
|
||||||
|
|
||||||
@@ -2240,14 +2257,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
*/
|
*/
|
||||||
throw new RuntimeException("当前账号未绑定手机号");
|
throw new RuntimeException("当前账号未绑定手机号");
|
||||||
}
|
}
|
||||||
if (!Objects.equals(phoneCrypto.index(userDO.getPhone()), phoneCrypto.index(oldPhone))) {
|
|
||||||
/**
|
|
||||||
* Run business method `RuntimeException`.
|
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
|
||||||
* @return throw new result consumed by the caller or returned to the frontend
|
|
||||||
*/
|
|
||||||
throw new RuntimeException("原手机号不匹配");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run business method `validateVerificationCode`.
|
* Run business method `validateVerificationCode`.
|
||||||
@@ -2272,6 +2281,19 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
return userMapper.updateById(userDO) > 0;
|
return userMapper.updateById(userDO) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/**
|
||||||
|
* 获取当前登录用户已绑定手机号的明文,仅用于服务端发码。
|
||||||
|
*/
|
||||||
|
public String getBoundPhone(Long userId) {
|
||||||
|
UserDO userDO = userMapper.selectById(userId);
|
||||||
|
assertUserAvailable(userDO);
|
||||||
|
if (!StringUtils.hasText(userDO.getPhone())) {
|
||||||
|
throw new BusinessException(400, "当前账号未绑定手机号");
|
||||||
|
}
|
||||||
|
return userDO.getPhone();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
/**
|
/**
|
||||||
* Run business method `resetPasswordByPhone`.
|
* Run business method `resetPasswordByPhone`.
|
||||||
@@ -2489,7 +2511,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
|||||||
* @return private String result consumed by the caller or returned to the frontend
|
* @return private String result consumed by the caller or returned to the frontend
|
||||||
*/
|
*/
|
||||||
private String buildLoginFailKey(String account) {
|
private String buildLoginFailKey(String account) {
|
||||||
return LOGIN_FAIL_KEY_PREFIX + account.trim();
|
String indexedAccount = StringUtils.hasText(account) ? phoneCrypto.index(account) : null;
|
||||||
|
return LOGIN_FAIL_KEY_PREFIX + (indexedAccount == null ? "anonymous" : indexedAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.support.privacy;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.user.entity.UserDO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.user.mapper.UserMapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* V5 迁移之后的账号补写:把 account_hash 为空的历史行(如 V1 种子账号 xiaowang)
|
||||||
|
* 加密 account 并回填 account_hash,之后所有账号查询可统一走哈希等值条件。
|
||||||
|
*
|
||||||
|
* <p>只处理无哈希的行,幂等;已处理行不会重复更新。</p>
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AccountHashBackfillRunner implements ApplicationRunner {
|
||||||
|
|
||||||
|
private final UserMapper userMapper;
|
||||||
|
private final PhoneCrypto phoneCrypto;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) {
|
||||||
|
List<UserDO> candidates = userMapper.selectList(Wrappers.<UserDO>lambdaQuery()
|
||||||
|
.isNull(UserDO::getAccountHash)
|
||||||
|
.isNotNull(UserDO::getAccount));
|
||||||
|
if (candidates.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int updated = 0;
|
||||||
|
for (UserDO user : candidates) {
|
||||||
|
String plainAccount = user.getAccount();
|
||||||
|
if (!StringUtils.hasText(plainAccount)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
userMapper.update(null, new LambdaUpdateWrapper<UserDO>()
|
||||||
|
.eq(UserDO::getId, user.getId())
|
||||||
|
.set(UserDO::getAccount, phoneCrypto.encryptAccount(plainAccount))
|
||||||
|
.set(UserDO::getAccountHash, phoneCrypto.index(plainAccount)));
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
log.info("账号加密回填完成,共处理 {} 条", updated);
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.support.privacy;
|
||||||
|
|
||||||
|
import org.apache.ibatis.type.BaseTypeHandler;
|
||||||
|
import org.apache.ibatis.type.JdbcType;
|
||||||
|
|
||||||
|
import java.sql.CallableStatement;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号 TypeHandler:写库时一律 AES-GCM 加密,读库时仅解密 enc:v1: 前缀的密文。
|
||||||
|
* 与 JC-Salon-Core 的 AccountPhoneTypeHandler 同名同结构。
|
||||||
|
*/
|
||||||
|
public class AccountPhoneTypeHandler extends BaseTypeHandler<String> {
|
||||||
|
@Override
|
||||||
|
public void setNonNullParameter(PreparedStatement ps, int index, String parameter, JdbcType jdbcType) throws SQLException {
|
||||||
|
ps.setString(index, PhoneCrypto.current().encryptAccount(parameter));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||||
|
return PhoneCrypto.current().decryptAccount(rs.getString(columnName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||||
|
return PhoneCrypto.current().decryptAccount(rs.getString(columnIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||||
|
return PhoneCrypto.current().decryptAccount(cs.getString(columnIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-8
@@ -84,6 +84,20 @@ public class PhoneCrypto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号加密:ArtList 允许字母数字自定义账号,因此非空账号一律加密。
|
||||||
|
*/
|
||||||
|
public String encryptAccount(String value) {
|
||||||
|
return encrypt(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号解密:仅对 {@code enc:v1:} 前缀的密文解密,历史明文账号原样返回。
|
||||||
|
*/
|
||||||
|
public String decryptAccount(String value) {
|
||||||
|
return decrypt(value);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEncrypted(String value) {
|
public boolean isEncrypted(String value) {
|
||||||
return value != null && value.startsWith(CIPHER_PREFIX);
|
return value != null && value.startsWith(CIPHER_PREFIX);
|
||||||
}
|
}
|
||||||
@@ -98,13 +112,6 @@ public class PhoneCrypto {
|
|||||||
return isMobilePhone(plain) ? plain.substring(0, 3) + "****" + plain.substring(7) : plain;
|
return isMobilePhone(plain) ? plain.substring(0, 3) + "****" + plain.substring(7) : plain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 非手机号内容原样返回,手机号返回脱敏值;用于审计日志等既有账号字段。
|
|
||||||
*/
|
|
||||||
public String maskIfMobile(String value) {
|
|
||||||
return isMobilePhone(value) ? mask(value) : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String index(String value) {
|
public String index(String value) {
|
||||||
if (!StringUtils.hasText(value)) return null;
|
if (!StringUtils.hasText(value)) return null;
|
||||||
try {
|
try {
|
||||||
@@ -113,7 +120,7 @@ public class PhoneCrypto {
|
|||||||
byte[] digest = mac.doFinal(value.trim().getBytes(StandardCharsets.UTF_8));
|
byte[] digest = mac.doFinal(value.trim().getBytes(StandardCharsets.UTF_8));
|
||||||
return HexFormat.of().formatHex(digest);
|
return HexFormat.of().formatHex(digest);
|
||||||
} catch (GeneralSecurityException exception) {
|
} catch (GeneralSecurityException exception) {
|
||||||
throw new IllegalStateException("手机号索引生成失败", exception);
|
throw new IllegalStateException("敏感字段索引生成失败", exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.support.privacy;
|
||||||
|
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号 / 账号的集中脱敏策略。
|
||||||
|
*
|
||||||
|
* <p>后端始终完整保存明文语义(落库为 AES-GCM 密文),但返回前端、写日志、写审计时一律脱敏:
|
||||||
|
* 不再存在任何"返回完整号码"的场景。需要真实号码时只走 {@code POST /contact-info/dial} 单次取号。</p>
|
||||||
|
*/
|
||||||
|
public final class SensitiveFieldPolicy {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用场景,仅用于表达调用方语义;所有场景的输出均为脱敏值。
|
||||||
|
*/
|
||||||
|
public enum Scenario {
|
||||||
|
SELF_PROFILE,
|
||||||
|
ADMIN_LIST,
|
||||||
|
THIRD_PARTY,
|
||||||
|
DIAL,
|
||||||
|
LOG
|
||||||
|
}
|
||||||
|
|
||||||
|
private SensitiveFieldPolicy() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号按场景返回脱敏值(138****0000)。
|
||||||
|
*/
|
||||||
|
public static String phone(String value, Scenario scenario) {
|
||||||
|
if (!StringUtils.hasText(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
String plain = PhoneCrypto.current().isEncrypted(value) ? PhoneCrypto.current().decrypt(value) : value;
|
||||||
|
return PhoneCrypto.current().mask(plain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号按场景返回脱敏值;手机号形态账号按手机号规则脱敏,其余保留前两位。
|
||||||
|
*/
|
||||||
|
public static String account(String value, Scenario scenario) {
|
||||||
|
if (!StringUtils.hasText(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
String plain = PhoneCrypto.current().isEncrypted(value) ? PhoneCrypto.current().decryptAccount(value) : value;
|
||||||
|
if (PhoneCrypto.current().isMobilePhone(plain)) {
|
||||||
|
return PhoneCrypto.current().mask(plain);
|
||||||
|
}
|
||||||
|
return plain.length() <= 2 ? "***" : plain.substring(0, 2) + "***";
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -191,8 +191,8 @@ public class OperationGuardService {
|
|||||||
readBodyField(request, key)
|
readBodyField(request, key)
|
||||||
);
|
);
|
||||||
if (StringUtils.hasText(value)) {
|
if (StringUtils.hasText(value)) {
|
||||||
// 手机号不落 Redis 键:统一替换为哈希
|
// 手机号/账号不落 Redis 键:统一替换为哈希
|
||||||
return "phone".equals(key) ? phoneCrypto.index(value) : sanitize(value);
|
return ("phone".equals(key) || "account".equals(key)) ? phoneCrypto.index(value) : sanitize(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buildRequestFingerprint(request, request == null ? "-" : request.getRequestURI());
|
return buildRequestFingerprint(request, request == null ? "-" : request.getRequestURI());
|
||||||
|
|||||||
+16
@@ -107,6 +107,22 @@ public class RequestThrottleService {
|
|||||||
assertAllowed(category, request, userId == null ? "" : String.valueOf(userId), rule, message);
|
assertAllowed(category, request, userId == null ? "" : String.valueOf(userId), rule, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系方式查询限流:按登录用户维度。
|
||||||
|
*/
|
||||||
|
public void checkContactInfoRead(HttpServletRequest request, Long userId) {
|
||||||
|
assertAllowed("contact-info-read", request, userId == null ? "" : String.valueOf(userId),
|
||||||
|
rateLimitProperties.getContactInfoRead(), "联系方式查询过于频繁,请稍后再试");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次拨号取号限流:按登录用户维度,避免批量撞取号码。
|
||||||
|
*/
|
||||||
|
public void checkContactDial(HttpServletRequest request, Long userId) {
|
||||||
|
assertAllowed("contact-dial", request, userId == null ? "" : String.valueOf(userId),
|
||||||
|
rateLimitProperties.getContactDial(), "拨号取号过于频繁,请稍后再试");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: recordLoginFailure supports RequestThrottleService.java by holding or executing the record login failure business role.
|
* Purpose: recordLoginFailure supports RequestThrottleService.java by holding or executing the record login failure business role.
|
||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
-- ============================================================
|
||||||
|
-- ArtList V5:账号加密与账号哈希
|
||||||
|
-- 日期:2026-11-04
|
||||||
|
--
|
||||||
|
-- 版本号说明:V3 从未在任何环境执行过;并行分支已先占用 V4
|
||||||
|
-- (V4__隐私政策与用户协议加密脱敏条款修订_20261104.sql),
|
||||||
|
-- 在 out-of-order:false 前提下本文件使用 V5,保证 V1→V2→V4→V5 顺序天然正确。
|
||||||
|
--
|
||||||
|
-- 语义:
|
||||||
|
-- 1. t_user.account 列改为存放 AES-GCM 密文(enc:v1: 前缀),列名与 Salon 保持一致;
|
||||||
|
-- 2. 新增 account_hash(HMAC-SHA256 十六进制),并建立唯一索引 uk_user_account_hash,
|
||||||
|
-- 所有账号等值查询统一走 account_hash;
|
||||||
|
-- 3. 删除依赖明文 account 的唯一索引 uk_account;
|
||||||
|
-- 4. 不做 SQL 数据迁移:历史/种子账号(如 xiaowang)由应用启动时
|
||||||
|
-- AccountHashBackfillRunner 加密并回填 hash。
|
||||||
|
--
|
||||||
|
-- 幂等:information_schema 判存在 + 存储过程,沿用 V2 风格;可安全重放。
|
||||||
|
-- ============================================================
|
||||||
|
|
||||||
|
DROP PROCEDURE IF EXISTS sp_v5_add_column_if_not_exists;
|
||||||
|
DROP PROCEDURE IF EXISTS sp_v5_drop_index_if_exists;
|
||||||
|
DROP PROCEDURE IF EXISTS sp_v5_add_unique_index_if_not_exists;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
|
||||||
|
CREATE PROCEDURE sp_v5_add_column_if_not_exists(
|
||||||
|
IN p_table_name VARCHAR(64),
|
||||||
|
IN p_column_name VARCHAR(64),
|
||||||
|
IN p_definition TEXT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = p_table_name
|
||||||
|
AND COLUMN_NAME = p_column_name
|
||||||
|
) THEN
|
||||||
|
SET @sql = CONCAT(
|
||||||
|
'ALTER TABLE `', p_table_name, '` ADD COLUMN `', p_column_name, '` ',
|
||||||
|
p_definition
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
|
||||||
|
CREATE PROCEDURE sp_v5_drop_index_if_exists(
|
||||||
|
IN p_table_name VARCHAR(64),
|
||||||
|
IN p_index_name VARCHAR(64)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM information_schema.STATISTICS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = p_table_name
|
||||||
|
AND INDEX_NAME = p_index_name
|
||||||
|
) THEN
|
||||||
|
SET @sql = CONCAT(
|
||||||
|
'ALTER TABLE `', p_table_name, '` DROP INDEX `', p_index_name, '`'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
|
||||||
|
CREATE PROCEDURE sp_v5_add_unique_index_if_not_exists(
|
||||||
|
IN p_table_name VARCHAR(64),
|
||||||
|
IN p_index_name VARCHAR(64),
|
||||||
|
IN p_columns TEXT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM information_schema.STATISTICS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = p_table_name
|
||||||
|
AND INDEX_NAME = p_index_name
|
||||||
|
) THEN
|
||||||
|
SET @sql = CONCAT(
|
||||||
|
'ALTER TABLE `', p_table_name, '` ADD UNIQUE INDEX `', p_index_name, '` ',
|
||||||
|
p_columns
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
-- 1. 账号列改为密文容器(与 Salon 对齐:varchar(128) NULL)
|
||||||
|
ALTER TABLE t_user
|
||||||
|
MODIFY COLUMN account varchar(128) NULL COMMENT '账号AES-GCM密文(enc:v1: 前缀)';
|
||||||
|
|
||||||
|
-- 2. 新增账号 HMAC 索引列
|
||||||
|
CALL sp_v5_add_column_if_not_exists(
|
||||||
|
't_user',
|
||||||
|
'account_hash',
|
||||||
|
"char(64) NULL COMMENT '账号HMAC-SHA256索引'"
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 3. 删除依赖明文账号的唯一索引
|
||||||
|
CALL sp_v5_drop_index_if_exists('t_user', 'uk_account');
|
||||||
|
|
||||||
|
-- 4. 新增账号哈希唯一索引(MySQL 唯一索引允许多行 NULL)
|
||||||
|
CALL sp_v5_add_unique_index_if_not_exists(
|
||||||
|
't_user',
|
||||||
|
'uk_user_account_hash',
|
||||||
|
'(account_hash)'
|
||||||
|
);
|
||||||
|
|
||||||
|
DROP PROCEDURE IF EXISTS sp_v5_add_column_if_not_exists;
|
||||||
|
DROP PROCEDURE IF EXISTS sp_v5_drop_index_if_exists;
|
||||||
|
DROP PROCEDURE IF EXISTS sp_v5_add_unique_index_if_not_exists;
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
-- V6:协议文本改为全场景脱敏与单次拨号取号
|
||||||
|
-- 版本:2026.11.04-R2
|
||||||
|
-- 说明:V4 已发布 2026.11.04 版本协议文本;本次仅新增修订版本并停用旧版本,不修改 V1/V2/V4 文件内容。
|
||||||
|
-- 变更点:所有推送前端的号码一律脱敏;电话联系改为按需单次拨号取号,可对接隐私号码且未配置时明确不可用。
|
||||||
|
|
||||||
|
UPDATE t_legal_agreement
|
||||||
|
SET status = 0,
|
||||||
|
update_time = NOW()
|
||||||
|
WHERE agreement_type IN ('USER_TERMS', 'PRIVACY_POLICY')
|
||||||
|
AND is_delete = 0
|
||||||
|
AND status = 1;
|
||||||
|
|
||||||
|
INSERT INTO t_legal_agreement
|
||||||
|
(id, agreement_type, title, version, content, status, effective_time, create_time, update_time, is_delete)
|
||||||
|
VALUES
|
||||||
|
(313931273555138005, 'USER_TERMS', '用户协议', '2026.11.04-R2',
|
||||||
|
'欢迎使用 JayuCloud ArtList。请在使用账号、预约、订单、会员、消息等功能前仔细阅读本协议。继续登录或注册即表示你已理解并同意平台基础服务规则、账号安全要求、订单预约规则和依法合规使用要求。本协议与《隐私政策》共同构成你使用本服务的基础规则。
|
||||||
|
|
||||||
|
一、协议接受与版本
|
||||||
|
你在登录或注册前应完整阅读本协议和《隐私政策》并主动选择同意;不同意时不能完成注册或继续使用。本协议版本为 2026.11.04-R2,自 2026 年 11 月 4 日起生效;协议发生重要变更时,我们会通过小程序提示并重新征得同意。
|
||||||
|
|
||||||
|
二、账号与安全
|
||||||
|
1. 你应使用本人手机号注册和登录,手机号用于身份识别、验证码校验、订单联系和账号找回。
|
||||||
|
2. 手机号与账号按《隐私政策》所述采用 AES-GCM 加密存储,并以 phone_hash/account_hash 不可逆索引支持登录与去重;客户端页面一律展示脱敏号码,需要电话联系时通过单次拨号取号接口按需获取当次可拨号码,该接口可对接隐私号码且不会回退为真实号码。
|
||||||
|
3. 你应妥善保管账号、验证码和登录设备,不得转借、出租、出售账号,不得绕过权限校验访问他人信息。
|
||||||
|
4. 发现账号异常、手机号被冒用或验证码泄露时,应及时修改资料、解绑手机号并联系客服。
|
||||||
|
|
||||||
|
三、预约、订单与会员
|
||||||
|
1. 预约与订单信息应真实、准确;你应确保填写的联系人手机号已获得联系人授权。
|
||||||
|
2. 订单金额、会员余额、优惠券和售后规则以页面展示和门店确认为准;本平台当前不发起在线支付,充值档位仅作展示,实际充值、退款和余额变动由门店按线下流程处理。
|
||||||
|
3. 不得利用订单、优惠券、会员权益进行虚假交易、套现、刷单或欺诈。
|
||||||
|
|
||||||
|
四、用户内容
|
||||||
|
你上传的头像、作品图片、评价等内容应来源合法,不得包含违法、侵权、暴力、色情、欺诈或侵害他人权益的信息。你授予平台为提供服务所必需的展示、存储和处理权限;平台可对违规内容采取删除、屏蔽或限制功能等措施。
|
||||||
|
|
||||||
|
五、个人信息与保密
|
||||||
|
1. 你不得收集、导出、转卖或向无关第三方提供通过平台获取的他人手机号、订单或会员信息。
|
||||||
|
2. 任何客户端页面均不展示完整手机号;需要电话联系时,仅在登录态与可见范围、权限校验通过后通过单次拨号取号接口获取当次可拨号码,平台不向客户端批量返回、缓存或提供长期有效的号码。
|
||||||
|
|
||||||
|
六、账号注销与数据留存
|
||||||
|
1. 你可在小程序设置中申请注销;注销后账号不可登录,系统清除账号手机号密文、联系电话密文及相关哈希索引,将账号标识替换为注销占位,并更新 account_hash。
|
||||||
|
2. 订单、预约、会员余额、售后和交易记录在去除账号身份关联后,于实现目的所必需的最短期限内保存,当前产品目标为五年【待法务/业务确认】。
|
||||||
|
3. 法律法规另有强制留存要求的,按法定期限保存。
|
||||||
|
|
||||||
|
七、未成年人
|
||||||
|
不满 14 周岁的未成年人应在监护人同意和陪同下阅读并使用本服务;未取得监护人同意,不得注册或下单。
|
||||||
|
|
||||||
|
八、服务调整、责任与联系
|
||||||
|
1. 我们会在合理范围内维护服务,并可能因升级、维护或合规要求调整功能;重要调整将提前告知。
|
||||||
|
2. 因你违反本协议、法律法规或侵害他人权益造成的损失,由你依法承担;因不可抗力、网络故障或第三方服务异常造成的服务中断,我们将在合理范围内协助恢复。
|
||||||
|
3. 隐私相关申请可从设置发起或联系在线客服;其他问题请联系运营方公布的客服渠道【待业务确认】。
|
||||||
|
|
||||||
|
本协议为产品说明文本,正式发布前应由运营方根据实际主体、业务和适用法律完成审核。',
|
||||||
|
1, NOW(), NOW(), NOW(), 0),
|
||||||
|
(313931273555138006, 'PRIVACY_POLICY', '隐私政策', '2026.11.04-R2',
|
||||||
|
'JayuCloud ArtList 会在提供登录注册、预约下单、会员余额、消息通知和客户服务时处理必要的手机号、昵称、门店归属、订单与设备信息。本政策说明我们如何处理这些个人信息。
|
||||||
|
|
||||||
|
一、处理的信息及用途
|
||||||
|
1. 登录与账号:你通过微信登录授权获取 OpenID 与 UnionID,用于识别和绑定账号;你主动授权手机号或输入手机号完成注册登录,手机号用于注册登录、验证码校验、订单联系、售后处理和账号找回,不用于营销。
|
||||||
|
2. 账号标识:账号用于身份识别、权限校验和操作归属记录;账号与手机号均使用 AES-GCM 加密存储。
|
||||||
|
3. 资料:昵称、头像仅在你主动补充或更新时处理。
|
||||||
|
4. 业务信息:预约、订单、会员余额与余额变动、优惠券、售后、消息和客服记录,用于履行交易和服务。
|
||||||
|
5. 安全运行:服务端处理网络地址、登录会话、客户端本地生成的随机设备标识和操作审计信息,用于登录安全、风险控制和审计;不采集 IMEI、MAC、通讯录、麦克风或持续定位。
|
||||||
|
6. 内容与图片:你主动上传的头像、作品图片等文件存储于对象存储,用于资料展示和服务履约;本服务当前不接入第三方内容安全审核平台和地图服务,如后续启用将更新本政策并另行告知。
|
||||||
|
|
||||||
|
二、加密存储与检索索引
|
||||||
|
1. 手机号与账号使用 AES-GCM 加密后落库,不以明文存入数据库;密文带版本标识。
|
||||||
|
2. 加密密钥由服务端按环境独立管理,仅授权服务进程读取,不通过接口、日志或客户端对外提供。
|
||||||
|
3. 为支持登录、去重和查询匹配,系统以 HMAC-SHA256 生成 phone_hash/account_hash 不可逆索引;该索引不能反推手机号或账号原文,不对外展示。
|
||||||
|
4. 备份、导出和迁移沿用同等加密要求。
|
||||||
|
|
||||||
|
三、全场景脱敏与单次拨号取号
|
||||||
|
1. 本人资料、管理端列表与编辑、订单、预约、售后、消息、客户服务和后台列表等所有返回客户端的场景,一律展示脱敏号码与脱敏账号;服务端不对客户端返回完整手机号。
|
||||||
|
2. 需要电话联系时,客户端在点击联系入口后调用单次拨号取号接口;服务端按场景校验登录态、订单归属、门店可见范围与权限后,返回当次可拨号码或隐私号码,响应带有效期标识,前端不缓存、不落库、不写入日志。
|
||||||
|
3. 平台可对接隐私号码服务;未配置隐私号码时接口明确返回不可用错误,不会回退为真实号码。
|
||||||
|
4. 日志、审计、消息记录与缓存不得保存完整手机号或完整账号;审计仅记录操作人、时间、场景与结果。
|
||||||
|
|
||||||
|
四、第三方共享
|
||||||
|
我们仅在实现功能所必需时与以下第三方共享必要信息,不将其用于其他目的:
|
||||||
|
1. 微信:微信登录、手机号授权和订阅消息。
|
||||||
|
2. 短信服务商:通过部署环境配置的 MessageHub 短信通道发送验证码、绑定/解绑和必要业务通知。
|
||||||
|
3. 消息通道:通过 MessageHub 等已配置通道推送站内或订阅消息。
|
||||||
|
4. 对象存储与 CDN:存储和分发头像、作品图片等文件,具体服务商按部署环境配置(七牛云、MinIO 或阿里云 OSS)。
|
||||||
|
我们不会出售个人信息,也不会向无关第三方提供完整手机号。上线前,运营方应在微信后台隐私指引中逐项列明实际服务商名称、处理目的和字段范围【待法务/业务确认】。
|
||||||
|
|
||||||
|
五、保存期限与删除
|
||||||
|
1. 账号注销:可在小程序设置中提交注销申请;注销后账号不可登录,系统清除账号手机号密文、联系电话密文及相关哈希索引,将账号标识替换为注销占位,并更新 account_hash。
|
||||||
|
2. 订单、预约、会员余额、售后和交易记录:在去除账号身份关联后,于实现目的所必需的最短期限内保存;当前产品目标为五年【待法务/业务确认】。
|
||||||
|
3. 安全审计日志:按安全审计要求保存,具体期限【待法务/业务确认】。
|
||||||
|
4. 法律法规另有强制留存要求的,按法定期限保存,并在期限届满后删除或匿名化。
|
||||||
|
|
||||||
|
六、你的权利
|
||||||
|
1. 查询与更正:可在个人资料页查看和修改昵称、头像等资料;手机号可在设置中更换,展示值为脱敏值。
|
||||||
|
2. 删除与注销:可在设置中申请注销;也可请求删除非交易必需的资料。
|
||||||
|
3. 撤回同意:可在设置或联系客服撤回授权;撤回后不影响撤回前已进行的处理。
|
||||||
|
4. 投诉与咨询:可联系在线客服或运营方公布的客服渠道【待业务确认】;我们将在收到请求后按适用法律规定的期限响应。
|
||||||
|
5. 请注意:为保障交易安全,订单、余额和售后记录在法定或约定留存期内可能无法立即删除。
|
||||||
|
|
||||||
|
七、未成年人保护
|
||||||
|
不满 14 周岁的未成年人应在监护人同意和陪同下阅读并使用本服务;未取得监护人同意,我们不会处理其个人信息。如发现误收集,将停止处理并删除。
|
||||||
|
|
||||||
|
八、安全措施与安全事件响应
|
||||||
|
我们采取加密存储、访问控制、最小权限、会话撤销、操作审计等措施保护个人信息。发生或可能发生个人信息泄露、篡改、丢失时,我们将立即采取补救措施,并按适用法律要求向你和监管部门告知事件情况、可能影响、已采取措施和自主防范建议;通知方式包括小程序公告、短信或电话【待业务确认】。
|
||||||
|
|
||||||
|
九、跨境传输
|
||||||
|
目前我们不涉及向境外提供个人信息。如未来发生跨境传输,将另行告知处理目的、接收方和联系方式,并依法取得单独同意或完成安全评估、备案等程序。
|
||||||
|
|
||||||
|
十、政策更新与联系
|
||||||
|
本政策版本为 2026.11.04-R2,自 2026 年 11 月 4 日起生效。处理目的、信息类别或第三方范围发生重要变化时,我们会更新版本并通过小程序提示、公告或重新征得同意等方式告知。你可在设置中查看当前版本;其他问题请联系在线客服或运营方公布的客服渠道【待业务确认】。
|
||||||
|
|
||||||
|
本文件是产品说明,不构成法律意见;上线前应由运营方或专业顾问结合实际处理活动审阅。',
|
||||||
|
1, NOW(), NOW(), NOW(), 0)
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
title = VALUES(title),
|
||||||
|
content = VALUES(content),
|
||||||
|
status = VALUES(status),
|
||||||
|
effective_time = VALUES(effective_time),
|
||||||
|
is_delete = 0,
|
||||||
|
update_time = NOW();
|
||||||
+92
@@ -0,0 +1,92 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.controller.front;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.common.BusinessException;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.security.service.SecurityAuditLogService;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.dto.DialRequestDTO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.service.ContactDialService;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.service.ContactInfoService;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.DialResponseVO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.support.security.RequestThrottleService;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class ContactDialControllerTest {
|
||||||
|
@Mock
|
||||||
|
private ContactInfoService contactInfoService;
|
||||||
|
@Mock
|
||||||
|
private ContactDialService contactDialService;
|
||||||
|
@Mock
|
||||||
|
private RequestThrottleService requestThrottleService;
|
||||||
|
@Mock
|
||||||
|
private SecurityAuditLogService securityAuditLogService;
|
||||||
|
|
||||||
|
private ContactInfoController controller;
|
||||||
|
private MockHttpServletRequest request;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
controller = new ContactInfoController(contactInfoService, contactDialService, requestThrottleService,
|
||||||
|
securityAuditLogService);
|
||||||
|
request = new MockHttpServletRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsAnonymousCallerWith403() {
|
||||||
|
DialRequestDTO dialRequestDTO = new DialRequestDTO();
|
||||||
|
dialRequestDTO.setScene("PLATFORM");
|
||||||
|
|
||||||
|
BusinessException exception = assertThrows(BusinessException.class, () ->
|
||||||
|
controller.dial(request, dialRequestDTO));
|
||||||
|
|
||||||
|
assertEquals(403, exception.getCode());
|
||||||
|
verify(contactDialService, never()).dial(any(), any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void successRecordsAuditWithoutNumber() {
|
||||||
|
request.setAttribute("userId", 1L);
|
||||||
|
request.setAttribute("account", "xiaowang");
|
||||||
|
DialRequestDTO dialRequestDTO = new DialRequestDTO();
|
||||||
|
dialRequestDTO.setScene("SHOP_MANAGER");
|
||||||
|
dialRequestDTO.setTargetId(88L);
|
||||||
|
DialResponseVO response = new DialResponseVO();
|
||||||
|
response.setMode("DIRECT");
|
||||||
|
response.setDialNumber("13800000000");
|
||||||
|
response.setExpiresInSeconds(300);
|
||||||
|
when(contactDialService.dial(eq(1L), any())).thenReturn(response);
|
||||||
|
|
||||||
|
controller.dial(request, dialRequestDTO);
|
||||||
|
|
||||||
|
verify(requestThrottleService).checkContactDial(request, 1L);
|
||||||
|
verify(securityAuditLogService).record(eq(1L), eq("xiaowang"), eq("CONTACT_DIAL_SHOP_MANAGER"),
|
||||||
|
eq("SUCCESS"), eq(null), eq(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void throttledRequestDoesNotReachDialService() {
|
||||||
|
request.setAttribute("userId", 1L);
|
||||||
|
DialRequestDTO dialRequestDTO = new DialRequestDTO();
|
||||||
|
dialRequestDTO.setScene("PLATFORM");
|
||||||
|
org.mockito.Mockito.doThrow(new RuntimeException("拨号取号过于频繁,请稍后再试"))
|
||||||
|
.when(requestThrottleService).checkContactDial(request, 1L);
|
||||||
|
|
||||||
|
RuntimeException exception = assertThrows(RuntimeException.class, () ->
|
||||||
|
controller.dial(request, dialRequestDTO));
|
||||||
|
|
||||||
|
assertEquals("拨号取号过于频繁,请稍后再试", exception.getMessage());
|
||||||
|
verify(contactDialService, never()).dial(any(), any());
|
||||||
|
}
|
||||||
|
}
|
||||||
+131
@@ -0,0 +1,131 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.modules.shop.service.impl;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.common.BusinessException;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.config.DialProperties;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderDO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderItemMapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderMapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.product.mapper.ProductMapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.dto.DialRequestDTO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.mapper.ShopMapper;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.UserShopBindingSupport;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial.DialTargetProvider;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial.DirectDialTargetProvider;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.dial.PlaceholderPrivacyNumberProvider;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.shop.vo.DialResponseVO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.user.entity.UserDO;
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.modules.user.mapper.UserMapper;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class ContactDialServiceTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private UserMapper userMapper;
|
||||||
|
@Mock
|
||||||
|
private ShopMapper shopMapper;
|
||||||
|
@Mock
|
||||||
|
private ProductMapper productMapper;
|
||||||
|
@Mock
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
@Mock
|
||||||
|
private OrderItemMapper orderItemMapper;
|
||||||
|
@Mock
|
||||||
|
private UserShopBindingSupport userShopBindingSupport;
|
||||||
|
|
||||||
|
private DialProperties dialProperties;
|
||||||
|
private ContactDialServiceImpl contactDialService;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
dialProperties = new DialProperties();
|
||||||
|
dialProperties.setProvider("direct");
|
||||||
|
DialTargetProvider[] providers = {
|
||||||
|
new DirectDialTargetProvider(),
|
||||||
|
new PlaceholderPrivacyNumberProvider()
|
||||||
|
};
|
||||||
|
contactDialService = new ContactDialServiceImpl(userMapper, shopMapper, productMapper, orderMapper,
|
||||||
|
orderItemMapper, userShopBindingSupport, dialProperties, Arrays.asList(providers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsAnonymousCallerWith403() {
|
||||||
|
BusinessException exception = assertThrows(BusinessException.class, () ->
|
||||||
|
contactDialService.dial(null, platformRequest()));
|
||||||
|
assertEquals(403, exception.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void platformSceneReturnsDirectNumber() {
|
||||||
|
UserDO caller = user(1L, 1);
|
||||||
|
UserDO admin = user(9L, 4);
|
||||||
|
admin.setPhone("13800000000");
|
||||||
|
when(userMapper.selectById(1L)).thenReturn(caller);
|
||||||
|
when(userMapper.selectOne(any())).thenReturn(admin);
|
||||||
|
|
||||||
|
DialResponseVO response = contactDialService.dial(1L, platformRequest());
|
||||||
|
|
||||||
|
assertEquals("DIRECT", response.getMode());
|
||||||
|
assertEquals("13800000000", response.getDialNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void orderArtistRejectsOrderOfOtherUser() {
|
||||||
|
UserDO caller = user(1L, 1);
|
||||||
|
OrderDO order = new OrderDO();
|
||||||
|
order.setId(100L);
|
||||||
|
order.setUserId(2L);
|
||||||
|
order.setIsDelete(0);
|
||||||
|
when(userMapper.selectById(1L)).thenReturn(caller);
|
||||||
|
when(orderMapper.selectById(100L)).thenReturn(order);
|
||||||
|
|
||||||
|
DialRequestDTO request = new DialRequestDTO();
|
||||||
|
request.setScene("ORDER_ARTIST");
|
||||||
|
request.setTargetId(100L);
|
||||||
|
|
||||||
|
BusinessException exception = assertThrows(BusinessException.class, () ->
|
||||||
|
contactDialService.dial(1L, request));
|
||||||
|
assertEquals(403, exception.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void privacyNumberProviderNeverFallsBackToRealNumber() {
|
||||||
|
dialProperties.setProvider("privacy-number");
|
||||||
|
UserDO caller = user(1L, 1);
|
||||||
|
UserDO admin = user(9L, 4);
|
||||||
|
admin.setPhone("13800000000");
|
||||||
|
when(userMapper.selectById(1L)).thenReturn(caller);
|
||||||
|
when(userMapper.selectOne(any())).thenReturn(admin);
|
||||||
|
|
||||||
|
BusinessException exception = assertThrows(BusinessException.class, () ->
|
||||||
|
contactDialService.dial(1L, platformRequest()));
|
||||||
|
|
||||||
|
assertEquals(PlaceholderPrivacyNumberProvider.NOT_CONFIGURED_CODE, exception.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
private DialRequestDTO platformRequest() {
|
||||||
|
DialRequestDTO request = new DialRequestDTO();
|
||||||
|
request.setScene("PLATFORM");
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
private UserDO user(Long id, Integer type) {
|
||||||
|
UserDO user = new UserDO();
|
||||||
|
user.setId(id);
|
||||||
|
user.setType(type);
|
||||||
|
user.setIsDelete(0);
|
||||||
|
user.setStatus(1);
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -65,4 +65,24 @@ class PhoneCryptoTest {
|
|||||||
assertEquals("138****0000", phoneCrypto.mask(phoneCrypto.encrypt("13800000000")));
|
assertEquals("138****0000", phoneCrypto.mask(phoneCrypto.encrypt("13800000000")));
|
||||||
assertEquals("zhangsan", phoneCrypto.mask("zhangsan"));
|
assertEquals("zhangsan", phoneCrypto.mask("zhangsan"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void accountIsAlwaysEncryptedAndDecryptsBack() {
|
||||||
|
String account = "xiaowang";
|
||||||
|
String cipher = phoneCrypto.encryptAccount(account);
|
||||||
|
assertTrue(cipher.startsWith("enc:v1:"));
|
||||||
|
assertEquals(account, phoneCrypto.decryptAccount(cipher));
|
||||||
|
// 数值型自定义账号同样加密,不采用 Salon 的"仅手机号形态加密"条件
|
||||||
|
String digitAccount = "20261104";
|
||||||
|
assertTrue(phoneCrypto.encryptAccount(digitAccount).startsWith("enc:v1:"));
|
||||||
|
assertEquals(digitAccount, phoneCrypto.decryptAccount(phoneCrypto.encryptAccount(digitAccount)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void legacyPlainAccountIsReadableAndHashIsStable() {
|
||||||
|
// V1 种子账号历史上是明文,无 enc:v1: 前缀时原样返回
|
||||||
|
assertEquals("xiaowang", phoneCrypto.decryptAccount("xiaowang"));
|
||||||
|
assertEquals(phoneCrypto.index("xiaowang"), phoneCrypto.index(" xiaowang "));
|
||||||
|
assertEquals(64, phoneCrypto.index("xiaowang").length());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
package com.xiaowang.jayucloud.artlist.core.support.privacy;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.artlist.core.config.PhoneCryptoProperties;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
class SensitiveFieldPolicyTest {
|
||||||
|
|
||||||
|
private static final String ENCRYPTION_KEY = "Y+Y5vAG/yUVDEvEQ3L5IQOO1ZFsbJp6l4wvrNR69mKM=";
|
||||||
|
private static final String INDEX_KEY = "4/wLgcudBE8XNVBjnUle1A2H1L0ePV0rKUbX3VFeAzU=";
|
||||||
|
private static final String PHONE = "13800000000";
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
PhoneCryptoProperties properties = new PhoneCryptoProperties();
|
||||||
|
properties.setEncryptionKey(ENCRYPTION_KEY);
|
||||||
|
properties.setIndexKey(INDEX_KEY);
|
||||||
|
PhoneCrypto crypto = new PhoneCrypto(properties);
|
||||||
|
crypto.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void phoneIsMaskedInEveryScenario() {
|
||||||
|
assertEquals("138****0000", SensitiveFieldPolicy.phone(PHONE, SensitiveFieldPolicy.Scenario.SELF_PROFILE));
|
||||||
|
assertEquals("138****0000", SensitiveFieldPolicy.phone(PHONE, SensitiveFieldPolicy.Scenario.ADMIN_LIST));
|
||||||
|
assertEquals("138****0000", SensitiveFieldPolicy.phone(PHONE, SensitiveFieldPolicy.Scenario.THIRD_PARTY));
|
||||||
|
assertEquals("138****0000", SensitiveFieldPolicy.phone(PHONE, SensitiveFieldPolicy.Scenario.DIAL));
|
||||||
|
assertEquals("138****0000", SensitiveFieldPolicy.phone(PHONE, SensitiveFieldPolicy.Scenario.LOG));
|
||||||
|
assertEquals("138****0000", SensitiveFieldPolicy.phone(PhoneCrypto.current().encrypt(PHONE), SensitiveFieldPolicy.Scenario.DIAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void accountIsMaskedInEveryScenario() {
|
||||||
|
assertEquals("xi***", SensitiveFieldPolicy.account("xiaowang", SensitiveFieldPolicy.Scenario.SELF_PROFILE));
|
||||||
|
assertEquals("xi***", SensitiveFieldPolicy.account("xiaowang", SensitiveFieldPolicy.Scenario.ADMIN_LIST));
|
||||||
|
assertEquals("xi***", SensitiveFieldPolicy.account("xiaowang", SensitiveFieldPolicy.Scenario.THIRD_PARTY));
|
||||||
|
assertEquals("xi***", SensitiveFieldPolicy.account("xiaowang", SensitiveFieldPolicy.Scenario.DIAL));
|
||||||
|
assertEquals("xi***", SensitiveFieldPolicy.account("xiaowang", SensitiveFieldPolicy.Scenario.LOG));
|
||||||
|
assertEquals("138****0000", SensitiveFieldPolicy.account(PHONE, SensitiveFieldPolicy.Scenario.ADMIN_LIST));
|
||||||
|
assertEquals("***", SensitiveFieldPolicy.account("ab", SensitiveFieldPolicy.Scenario.LOG));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void encryptedAccountIsMaskedAfterDecrypt() {
|
||||||
|
assertEquals("xi***", SensitiveFieldPolicy.account(PhoneCrypto.current().encryptAccount("xiaowang"), SensitiveFieldPolicy.Scenario.SELF_PROFILE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void nullAndBlankValuesStayUnchanged() {
|
||||||
|
assertEquals(null, SensitiveFieldPolicy.phone(null, SensitiveFieldPolicy.Scenario.LOG));
|
||||||
|
assertEquals("", SensitiveFieldPolicy.account("", SensitiveFieldPolicy.Scenario.ADMIN_LIST));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -202,7 +202,8 @@ export interface InviteCodeVO {
|
|||||||
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
export interface UpdatePhoneRequest {
|
export interface UpdatePhoneRequest {
|
||||||
oldPhone: string
|
/** 兼容旧协议保留;服务端按当前登录用户取原手机号,不再使用该字段。 */
|
||||||
|
oldPhone?: string
|
||||||
newPhone: string
|
newPhone: string
|
||||||
verificationCode: string
|
verificationCode: string
|
||||||
}
|
}
|
||||||
@@ -319,6 +320,20 @@ export interface ContactInfoVO {
|
|||||||
platformContactText?: string
|
platformContactText?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拨号场景:与后端 /contact-info/dial 的 scene 取值一致。
|
||||||
|
*/
|
||||||
|
export type ContactDialScene = 'SHOP_MANAGER' | 'ORDER_ARTIST' | 'PRODUCT_ARTIST' | 'PLATFORM'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次拨号取号结果;DIRECT 为直拨真实号码,PRIVACY_NUMBER 为隐私号码。
|
||||||
|
*/
|
||||||
|
export interface DialContactResult {
|
||||||
|
mode: 'DIRECT' | 'PRIVACY_NUMBER'
|
||||||
|
dialNumber: string
|
||||||
|
expiresInSeconds: number
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* userApi groups all API calls for this page domain.
|
* userApi groups all API calls for this page domain.
|
||||||
* Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script.
|
* Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script.
|
||||||
@@ -385,7 +400,7 @@ export const userApi = {
|
|||||||
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
||||||
* @param data: { phone: string; sceneCode?: string } caller-supplied value for `data: { phone: string; sceneCode?: string }`
|
* @param data: { phone: string; sceneCode?: string } caller-supplied value for `data: { phone: string; sceneCode?: string }`
|
||||||
*/
|
*/
|
||||||
sendVerificationCode: (data: { phone: string; sceneCode?: string }) => {
|
sendVerificationCode: (data: { phone?: string; sceneCode?: string }) => {
|
||||||
return api.post('/user/send-verification-code', data)
|
return api.post('/user/send-verification-code', data)
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -459,6 +474,10 @@ export const userApi = {
|
|||||||
getPlatformContact: async (): Promise<ContactInfoVO> => {
|
getPlatformContact: async (): Promise<ContactInfoVO> => {
|
||||||
return await api.get<ContactInfoVO>('/contact-info/platform') as unknown as ContactInfoVO
|
return await api.get<ContactInfoVO>('/contact-info/platform') as unknown as ContactInfoVO
|
||||||
},
|
},
|
||||||
|
// 单次拨号取号:号码不缓存到本地,拨号完成后即丢弃。
|
||||||
|
dialContact: async (scene: ContactDialScene, targetId?: IdType, artistId?: IdType): Promise<DialContactResult> => {
|
||||||
|
return await api.post<DialContactResult>('/contact-info/dial', { scene, targetId, artistId }) as unknown as DialContactResult
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* `deactivateAccount` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
* `deactivateAccount` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
|
||||||
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
|
||||||
|
|||||||
@@ -625,8 +625,8 @@ const handleChangePhoneSubmit = async () => {
|
|||||||
changePhoneLoading.value = true
|
changePhoneLoading.value = true
|
||||||
try {
|
try {
|
||||||
await runWithGlobalLoading(async () => {
|
await runWithGlobalLoading(async () => {
|
||||||
|
// 原手机号由服务端按当前登录用户读取,前端不再回传可能已脱敏的号码。
|
||||||
await userApi.updatePhone({
|
await userApi.updatePhone({
|
||||||
oldPhone: userInfo.value.phone!,
|
|
||||||
newPhone: changePhoneForm.newPhone,
|
newPhone: changePhoneForm.newPhone,
|
||||||
verificationCode: changePhoneForm.verificationCode
|
verificationCode: changePhoneForm.verificationCode
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,6 +9,20 @@ import { BRAND_CONFIG } from '@/config/brand'
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const contact = ref<ContactInfoVO | null>(null)
|
const contact = ref<ContactInfoVO | null>(null)
|
||||||
|
const dialing = ref(false)
|
||||||
|
|
||||||
|
/** 平台客服拨号:点击后才单次取号,号码不落页面状态。 */
|
||||||
|
const dialPlatform = async () => {
|
||||||
|
dialing.value = true
|
||||||
|
try {
|
||||||
|
const result = await userApi.dialContact('PLATFORM')
|
||||||
|
window.location.href = `tel:${result.dialNumber}`
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || '获取客服号码失败')
|
||||||
|
} finally {
|
||||||
|
dialing.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loadContact = async () => {
|
const loadContact = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@@ -46,7 +60,9 @@ onMounted(loadContact)
|
|||||||
<section class="section-card">
|
<section class="section-card">
|
||||||
<h3>平台联系信息</h3>
|
<h3>平台联系信息</h3>
|
||||||
<p v-if="contact?.contactName">{{ contact.contactName }} {{ contact.roleLabel || '' }}</p>
|
<p v-if="contact?.contactName">{{ contact.contactName }} {{ contact.roleLabel || '' }}</p>
|
||||||
<p v-if="contact?.phoneAvailable && contact.phone">电话:{{ contact.phone }}</p>
|
<p v-if="contact?.phoneAvailable">
|
||||||
|
<a-button type="primary" size="small" :loading="dialing" @click="dialPlatform">拨打客服电话</a-button>
|
||||||
|
</p>
|
||||||
<p v-if="contact?.wechatAvailable && contact.wechatId">微信:{{ contact.wechatId }}</p>
|
<p v-if="contact?.wechatAvailable && contact.wechatId">微信:{{ contact.wechatId }}</p>
|
||||||
<p v-if="contact?.platformContactText">{{ contact.platformContactText }}</p>
|
<p v-if="contact?.platformContactText">{{ contact.platformContactText }}</p>
|
||||||
<p v-if="!contact">暂无可展示的客服信息,请稍后重试或通过订单详情联系服务人员。</p>
|
<p v-if="!contact">暂无可展示的客服信息,请稍后重试或通过订单详情联系服务人员。</p>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const reviews = ref<OrderArtistReviewVO[]>([])
|
|||||||
const changeRequests = ref<OrderArtistChangeRequestVO[]>([])
|
const changeRequests = ref<OrderArtistChangeRequestVO[]>([])
|
||||||
const afterSales = ref<AfterSaleVO[]>([])
|
const afterSales = ref<AfterSaleVO[]>([])
|
||||||
const contact = ref<ContactInfoVO | null>(null)
|
const contact = ref<ContactInfoVO | null>(null)
|
||||||
|
const dialing = ref(false)
|
||||||
const quoteReply = ref('')
|
const quoteReply = ref('')
|
||||||
const quoteSubmitting = ref(false)
|
const quoteSubmitting = ref(false)
|
||||||
const quoteConfirming = ref(false)
|
const quoteConfirming = ref(false)
|
||||||
@@ -130,6 +131,20 @@ const loadRelated = async () => {
|
|||||||
contact.value = contactInfo
|
contact.value = contactInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 单次取号后立即拨号:不缓存号码,仅使用本次返回的 dialNumber。 */
|
||||||
|
const dialArtist = async () => {
|
||||||
|
if (!orderId.value) return
|
||||||
|
dialing.value = true
|
||||||
|
try {
|
||||||
|
const result = await userApi.dialContact('ORDER_ARTIST', orderId.value)
|
||||||
|
window.location.href = `tel:${result.dialNumber}`
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || '获取拨号号码失败')
|
||||||
|
} finally {
|
||||||
|
dialing.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loadOrder = async () => {
|
const loadOrder = async () => {
|
||||||
if (!orderId.value) {
|
if (!orderId.value) {
|
||||||
order.value = null
|
order.value = null
|
||||||
@@ -334,7 +349,9 @@ onMounted(loadOrder)
|
|||||||
<section v-if="contact" class="section-card">
|
<section v-if="contact" class="section-card">
|
||||||
<h3>联系信息</h3>
|
<h3>联系信息</h3>
|
||||||
<p>{{ contact.contactName || contact.roleLabel || '服务联系人' }}</p>
|
<p>{{ contact.contactName || contact.roleLabel || '服务联系人' }}</p>
|
||||||
<p v-if="contact.phoneAvailable && contact.phone">电话:{{ contact.phone }}</p>
|
<p v-if="contact.phoneAvailable">
|
||||||
|
<a-button size="small" :loading="dialing" @click="dialArtist">拨打美甲师电话</a-button>
|
||||||
|
</p>
|
||||||
<p v-if="contact.wechatAvailable && contact.wechatId">微信:{{ contact.wechatId }}</p>
|
<p v-if="contact.wechatAvailable && contact.wechatId">微信:{{ contact.wechatId }}</p>
|
||||||
<p v-if="contact.platformContactText">{{ contact.platformContactText }}</p>
|
<p v-if="contact.platformContactText">{{ contact.platformContactText }}</p>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ const handleSendVerificationCode = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await runWithGlobalLoading(() => userApi.sendVerificationCode({
|
await runWithGlobalLoading(() => userApi.sendVerificationCode({
|
||||||
phone: userPhone.value,
|
// 号码由服务端按当前登录用户读取,前端只传场景,避免回传已脱敏的展示值。
|
||||||
sceneCode: 'USER_CHANGE_PASSWORD_SMS_CODE'
|
sceneCode: 'USER_CHANGE_PASSWORD_SMS_CODE'
|
||||||
}))
|
}))
|
||||||
message.success('验证码发送成功')
|
message.success('验证码发送成功')
|
||||||
|
|||||||
@@ -373,6 +373,9 @@ const editForm = reactive({
|
|||||||
wechatQrCode: ''
|
wechatQrCode: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 打开编辑弹窗时的联系电话原值,用于判断用户是否真实修改过(未修改则不提交该字段)。 */
|
||||||
|
const originalContactPhone = ref('')
|
||||||
|
|
||||||
/** getDraftKey is a local helper used by this page script. */
|
/** getDraftKey is a local helper used by this page script. */
|
||||||
const getDraftKey = () => buildDraftStorageKey('profile-edit')
|
const getDraftKey = () => buildDraftStorageKey('profile-edit')
|
||||||
|
|
||||||
@@ -596,6 +599,7 @@ const handleEditProfile = () => {
|
|||||||
editForm.avatar = userInfo.value.avatar || ''
|
editForm.avatar = userInfo.value.avatar || ''
|
||||||
editForm.signature = userInfo.value.signature || ''
|
editForm.signature = userInfo.value.signature || ''
|
||||||
editForm.contactPhone = userInfo.value.contactPhone || ''
|
editForm.contactPhone = userInfo.value.contactPhone || ''
|
||||||
|
originalContactPhone.value = editForm.contactPhone
|
||||||
editForm.birthday = userInfo.value.birthday || ''
|
editForm.birthday = userInfo.value.birthday || ''
|
||||||
editForm.wechatId = userInfo.value.wechatId || ''
|
editForm.wechatId = userInfo.value.wechatId || ''
|
||||||
editForm.wechatQrCode = userInfo.value.wechatQrCode || ''
|
editForm.wechatQrCode = userInfo.value.wechatQrCode || ''
|
||||||
@@ -742,15 +746,17 @@ const handleSaveProfile = async () => {
|
|||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
await runWithGlobalLoading(async () => {
|
await runWithGlobalLoading(async () => {
|
||||||
await userApi.updateUserInfo({
|
const payload = {
|
||||||
nickname: editForm.nickname,
|
nickname: editForm.nickname,
|
||||||
avatar: editForm.avatar,
|
avatar: editForm.avatar,
|
||||||
signature: editForm.signature,
|
signature: editForm.signature,
|
||||||
contactPhone: editForm.contactPhone,
|
|
||||||
birthday: editForm.birthday || undefined,
|
birthday: editForm.birthday || undefined,
|
||||||
wechatId: editForm.wechatId,
|
wechatId: editForm.wechatId,
|
||||||
wechatQrCode: editForm.wechatQrCode
|
wechatQrCode: editForm.wechatQrCode,
|
||||||
})
|
// 只有联系电话真实变更时才提交,避免把接口回填值(可能已脱敏)原样写回
|
||||||
|
...(editForm.contactPhone !== originalContactPhone.value ? { contactPhone: editForm.contactPhone } : {})
|
||||||
|
}
|
||||||
|
await userApi.updateUserInfo(payload)
|
||||||
await fetchUserInfo()
|
await fetchUserInfo()
|
||||||
})
|
})
|
||||||
message.success('资料更新成功')
|
message.success('资料更新成功')
|
||||||
|
|||||||
@@ -226,16 +226,12 @@
|
|||||||
<p class="contact-name">{{ contactInfo.contactName || contactInfo.roleLabel || '联系人' }}</p>
|
<p class="contact-name">{{ contactInfo.contactName || contactInfo.roleLabel || '联系人' }}</p>
|
||||||
<div class="contact-row">
|
<div class="contact-row">
|
||||||
<span>联系电话</span>
|
<span>联系电话</span>
|
||||||
<strong>{{ contactInfo.phoneAvailable ? contactInfo.phone : '暂无电话' }}</strong>
|
<strong>{{ contactInfo.phoneAvailable ? '点击下方按钮获取当次号码' : '暂无电话' }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="contact-actions">
|
<div class="contact-actions">
|
||||||
<a-button v-if="contactInfo.phoneAvailable" type="primary" :href="`tel:${contactInfo.phone}`">
|
<a-button v-if="contactInfo.phoneAvailable" type="primary" :loading="dialing" @click="dialManager">
|
||||||
<PhoneOutlined />
|
<PhoneOutlined />
|
||||||
拨号
|
拨打店长电话
|
||||||
</a-button>
|
|
||||||
<a-button v-if="contactInfo.phoneAvailable" @click="copyToClipboard(contactInfo.phone || '', '联系电话')">
|
|
||||||
<CopyOutlined />
|
|
||||||
复制电话
|
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="contact-row">
|
<div class="contact-row">
|
||||||
@@ -372,6 +368,7 @@ const contactOpen = ref(false)
|
|||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
const contactInfo = ref<ContactInfoVO>({})
|
const contactInfo = ref<ContactInfoVO>({})
|
||||||
|
const dialing = ref(false)
|
||||||
/**
|
/**
|
||||||
* Purpose: mapOpen supports ShopDetailView.vue by holding or executing the map open page or API role.
|
* Purpose: mapOpen supports ShopDetailView.vue by holding or executing the map open page or API role.
|
||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -617,11 +614,24 @@ const openWechatContact = async () => {
|
|||||||
window.location.href = 'weixin://'
|
window.location.href = 'weixin://'
|
||||||
}
|
}
|
||||||
|
|
||||||
/** copyContactInfo copies all available contact channels in one action. */
|
/** 单次取号后立即拨号:页面不缓存号码,仅使用本次返回的 dialNumber。 */
|
||||||
|
const dialManager = async () => {
|
||||||
|
if (!shopInfo.value.id) return
|
||||||
|
dialing.value = true
|
||||||
|
try {
|
||||||
|
const result = await userApi.dialContact('SHOP_MANAGER', shopInfo.value.id)
|
||||||
|
window.location.href = `tel:${result.dialNumber}`
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || '获取拨号号码失败')
|
||||||
|
} finally {
|
||||||
|
dialing.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** copyContactInfo copies the WeChat channel only; phone numbers are no longer rendered or cached. */
|
||||||
const copyContactInfo = async () => {
|
const copyContactInfo = async () => {
|
||||||
const lines = [
|
const lines = [
|
||||||
contactInfo.value.contactName || contactInfo.value.roleLabel || '联系人',
|
contactInfo.value.contactName || contactInfo.value.roleLabel || '联系人',
|
||||||
contactInfo.value.phoneAvailable && contactInfo.value.phone ? `电话:${contactInfo.value.phone}` : '',
|
|
||||||
contactInfo.value.wechatAvailable && contactInfo.value.wechatId ? `微信:${contactInfo.value.wechatId}` : ''
|
contactInfo.value.wechatAvailable && contactInfo.value.wechatId ? `微信:${contactInfo.value.wechatId}` : ''
|
||||||
].filter(Boolean)
|
].filter(Boolean)
|
||||||
await copyToClipboard(lines.join('\n'), '联系方式')
|
await copyToClipboard(lines.join('\n'), '联系方式')
|
||||||
|
|||||||
@@ -144,6 +144,18 @@ module.exports = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次拨号取号:号码不缓存,仅用于本次拨号。
|
||||||
|
* scene: SHOP_MANAGER / ORDER_ARTIST / PRODUCT_ARTIST / PLATFORM
|
||||||
|
*/
|
||||||
|
dialContact(scene, targetId, artistId) {
|
||||||
|
return request({
|
||||||
|
url: '/contact-info/dial',
|
||||||
|
method: 'POST',
|
||||||
|
data: { scene, targetId, artistId }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: getShopManagerContact supports user.js by holding or executing the get shop manager contact page or API role.
|
* Purpose: getShopManagerContact supports user.js by holding or executing the get shop manager contact page or API role.
|
||||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台客服拨号:点击后才单次取号,号码不保存。
|
||||||
|
*/
|
||||||
|
async handleDialPlatform() {
|
||||||
|
try {
|
||||||
|
const dial = await userApi.dialContact('PLATFORM')
|
||||||
|
wx.makePhoneCall({ phoneNumber: dial.dialNumber })
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({ title: error.message || '获取客服号码失败', icon: 'none' })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
openRoute(event) {
|
openRoute(event) {
|
||||||
const route = event.currentTarget.dataset.route
|
const route = event.currentTarget.dataset.route
|
||||||
const pureRoute = String(route || '').split('?')[0]
|
const pureRoute = String(route || '').split('?')[0]
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
<text class="section-title">平台联系信息</text>
|
<text class="section-title">平台联系信息</text>
|
||||||
<block wx:if="{{contact}}">
|
<block wx:if="{{contact}}">
|
||||||
<text wx:if="{{contact.contactName}}" class="contact-line">{{contact.contactName}} {{contact.roleLabel || ''}}</text>
|
<text wx:if="{{contact.contactName}}" class="contact-line">{{contact.contactName}} {{contact.roleLabel || ''}}</text>
|
||||||
<text wx:if="{{contact.phoneAvailable && contact.phone}}" class="contact-line">电话:{{contact.phone}}</text>
|
<text wx:if="{{contact.phoneAvailable}}" class="contact-line">
|
||||||
|
<view class="primary-btn" bindtap="handleDialPlatform">拨打客服电话</view>
|
||||||
|
</text>
|
||||||
<text wx:if="{{contact.wechatAvailable && contact.wechatId}}" class="contact-line">微信:{{contact.wechatId}}</text>
|
<text wx:if="{{contact.wechatAvailable && contact.wechatId}}" class="contact-line">微信:{{contact.wechatId}}</text>
|
||||||
<text wx:if="{{contact.platformContactText}}" class="contact-line">{{contact.platformContactText}}</text>
|
<text wx:if="{{contact.platformContactText}}" class="contact-line">{{contact.platformContactText}}</text>
|
||||||
</block>
|
</block>
|
||||||
|
|||||||
@@ -131,6 +131,21 @@ Page({
|
|||||||
navigation.navigate('/pages/after-sales/index', { orderId: this.data.id })
|
navigation.navigate('/pages/after-sales/index', { orderId: this.data.id })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击后才单次取号并拨号,页面不保存号码。
|
||||||
|
*/
|
||||||
|
async handleDialArtist() {
|
||||||
|
if (!this.data.id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const dial = await userApi.dialContact('ORDER_ARTIST', this.data.id)
|
||||||
|
wx.makePhoneCall({ phoneNumber: dial.dialNumber })
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({ title: error.message || '获取拨号号码失败', icon: 'none' })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async handleCancelOrder() {
|
async handleCancelOrder() {
|
||||||
const confirmed = await new Promise(resolve => {
|
const confirmed = await new Promise(resolve => {
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
|
|||||||
@@ -51,7 +51,9 @@
|
|||||||
<view wx:if="{{contact}}" class="page-card contact-card">
|
<view wx:if="{{contact}}" class="page-card contact-card">
|
||||||
<text class="section-title">联系信息</text>
|
<text class="section-title">联系信息</text>
|
||||||
<text class="contact-line">{{contact.contactName || contact.roleLabel || '服务联系人'}}</text>
|
<text class="contact-line">{{contact.contactName || contact.roleLabel || '服务联系人'}}</text>
|
||||||
<text wx:if="{{contact.phoneAvailable && contact.phone}}" class="contact-line">电话:{{contact.phone}}</text>
|
<text wx:if="{{contact.phoneAvailable}}" class="contact-line">
|
||||||
|
<view class="soft-chip" bindtap="handleDialArtist">拨打美甲师电话</view>
|
||||||
|
</text>
|
||||||
<text wx:if="{{contact.wechatAvailable && contact.wechatId}}" class="contact-line">微信:{{contact.wechatId}}</text>
|
<text wx:if="{{contact.wechatAvailable && contact.wechatId}}" class="contact-line">微信:{{contact.wechatId}}</text>
|
||||||
<text wx:if="{{contact.platformContactText}}" class="contact-line">{{contact.platformContactText}}</text>
|
<text wx:if="{{contact.platformContactText}}" class="contact-line">{{contact.platformContactText}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -739,22 +739,9 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
async handleChangePhoneSubmit() {
|
async handleChangePhoneSubmit() {
|
||||||
const userInfo = this.data.userInfo || {}
|
|
||||||
const oldPhone = String(userInfo.phone || '').trim()
|
|
||||||
const newPhone = String(this.data.changePhoneForm.newPhone || '').trim()
|
const newPhone = String(this.data.changePhoneForm.newPhone || '').trim()
|
||||||
const verificationCode = String(this.data.changePhoneForm.verificationCode || '').trim()
|
const verificationCode = String(this.data.changePhoneForm.verificationCode || '').trim()
|
||||||
|
// 原手机号由服务端按当前登录用户取,页面展示的是脱敏值,不再回传。
|
||||||
/**
|
|
||||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
|
||||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
|
||||||
*/
|
|
||||||
if (!oldPhone) {
|
|
||||||
wx.showToast({
|
|
||||||
title: '请先绑定手机号',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!phoneRegex.test(newPhone)) {
|
if (!phoneRegex.test(newPhone)) {
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
@@ -782,7 +769,6 @@ Page({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await runWithLoading(() => userApi.updatePhone({
|
await runWithLoading(() => userApi.updatePhone({
|
||||||
oldPhone,
|
|
||||||
newPhone,
|
newPhone,
|
||||||
verificationCode
|
verificationCode
|
||||||
}))
|
}))
|
||||||
@@ -829,8 +815,8 @@ Page({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// 号码由服务端按当前登录用户读取,前端只传场景。
|
||||||
await runWithLoading(() => authApi.sendVerificationCode({
|
await runWithLoading(() => authApi.sendVerificationCode({
|
||||||
phone,
|
|
||||||
sceneCode: 'USER_CHANGE_PASSWORD_SMS_CODE'
|
sceneCode: 'USER_CHANGE_PASSWORD_SMS_CODE'
|
||||||
}))
|
}))
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
|
|||||||
@@ -180,8 +180,8 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: handleContactManager retrieves and shows the current shop manager contact.
|
* Purpose: handleContactManager 点击后才单次取号并拨号,页面不再保存或展示号码。
|
||||||
* Usage: bind it to the contact button and require login before exposing phone data.
|
* Usage: 绑定到联系按钮,要求登录后由服务端按场景鉴权。
|
||||||
*/
|
*/
|
||||||
async handleContactManager() {
|
async handleContactManager() {
|
||||||
const shopInfo = this.data.shopInfo
|
const shopInfo = this.data.shopInfo
|
||||||
@@ -191,20 +191,9 @@ Page({
|
|||||||
try {
|
try {
|
||||||
const contact = await userApi.getShopManagerContact(shopInfo.id)
|
const contact = await userApi.getShopManagerContact(shopInfo.id)
|
||||||
this.setData({ managerContact: contact })
|
this.setData({ managerContact: contact })
|
||||||
if (contact && contact.phoneAvailable && contact.phone) {
|
if (contact && contact.phoneAvailable) {
|
||||||
wx.showModal({
|
const dial = await userApi.dialContact('SHOP_MANAGER', shopInfo.id)
|
||||||
title: contact.contactName || '店长联系方式',
|
wx.makePhoneCall({ phoneNumber: dial.dialNumber })
|
||||||
content: `${contact.roleLabel || '店长'}:${contact.phone}`,
|
|
||||||
confirmText: '拨打',
|
|
||||||
cancelText: '复制',
|
|
||||||
success: res => {
|
|
||||||
if (res.confirm) {
|
|
||||||
wx.makePhoneCall({ phoneNumber: contact.phone })
|
|
||||||
} else {
|
|
||||||
wx.setClipboardData({ data: contact.phone })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<view class="contact-row">
|
<view class="contact-row">
|
||||||
<view class="primary-btn contact-btn" bindtap="handleContactManager">联系店长</view>
|
<view class="primary-btn contact-btn" bindtap="handleContactManager">联系店长</view>
|
||||||
<view wx:if="{{managerContact}}" class="contact-copy">
|
<view wx:if="{{managerContact}}" class="contact-copy">
|
||||||
{{managerContact.contactName || '店长'}} · {{managerContact.phoneAvailable ? managerContact.phone : (managerContact.platformContactText || '暂无电话')}}
|
{{managerContact.contactName || '店长'}} · {{managerContact.phoneAvailable ? '点击“联系店长”获取当次号码' : (managerContact.platformContactText || '暂无电话')}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ jayucloud-artlist:
|
|||||||
order-create:
|
order-create:
|
||||||
limit: 10
|
limit: 10
|
||||||
window-seconds: 60
|
window-seconds: 60
|
||||||
|
contact-info-read:
|
||||||
|
limit: 30
|
||||||
|
window-seconds: 60
|
||||||
|
contact-dial:
|
||||||
|
limit: 10
|
||||||
|
window-seconds: 60
|
||||||
|
dial:
|
||||||
|
provider: direct
|
||||||
cache:
|
cache:
|
||||||
local-max-size: 2048
|
local-max-size: 2048
|
||||||
product-detail:
|
product-detail:
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ jayucloud-artlist:
|
|||||||
order-create:
|
order-create:
|
||||||
limit: 10
|
limit: 10
|
||||||
window-seconds: 60
|
window-seconds: 60
|
||||||
|
contact-info-read:
|
||||||
|
limit: 30
|
||||||
|
window-seconds: 60
|
||||||
|
contact-dial:
|
||||||
|
limit: 10
|
||||||
|
window-seconds: 60
|
||||||
|
dial:
|
||||||
|
provider: direct
|
||||||
cache:
|
cache:
|
||||||
local-max-size: 2048
|
local-max-size: 2048
|
||||||
product-detail:
|
product-detail:
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ jayucloud-artlist:
|
|||||||
order-create:
|
order-create:
|
||||||
limit: 10
|
limit: 10
|
||||||
window-seconds: 60
|
window-seconds: 60
|
||||||
|
contact-info-read:
|
||||||
|
limit: 30
|
||||||
|
window-seconds: 60
|
||||||
|
contact-dial:
|
||||||
|
limit: 10
|
||||||
|
window-seconds: 60
|
||||||
|
dial:
|
||||||
|
provider: direct
|
||||||
cache:
|
cache:
|
||||||
local-max-size: 2048
|
local-max-size: 2048
|
||||||
product-detail:
|
product-detail:
|
||||||
|
|||||||
Reference in New Issue
Block a user