修复无手机号客户创建失败
This commit is contained in:
+8
-4
@@ -55,6 +55,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/manager")
|
||||
@@ -179,12 +180,15 @@ public class AdminManagerController {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requireShopContext(currentUser, "请先选择店铺后再新增客户");
|
||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
String phone = dto.getPhone().trim();
|
||||
String phone = dto.getPhone() == null ? "" : dto.getPhone().trim();
|
||||
String account = phone.isEmpty()
|
||||
? "customer" + UUID.randomUUID().toString().replace("-", "")
|
||||
: phone;
|
||||
UserDTO userDTO = new UserDTO();
|
||||
userDTO.setNickname(dto.getNickname().trim());
|
||||
userDTO.setPhone(phone);
|
||||
userDTO.setContactPhone(phone);
|
||||
userDTO.setAccount(phone);
|
||||
userDTO.setPhone(phone.isEmpty() ? null : phone);
|
||||
userDTO.setContactPhone(phone.isEmpty() ? null : phone);
|
||||
userDTO.setAccount(account);
|
||||
userDTO.setType(0);
|
||||
userDTO.setShopId(shopId);
|
||||
userDTO.setShopIds(List.of(shopId));
|
||||
|
||||
-1
@@ -11,7 +11,6 @@ public class ManagerCustomerCreateDTO {
|
||||
@NotBlank(message = "客户姓名不能为空")
|
||||
private String nickname;
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
||||
private String phone;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user