本文档描述了从 alien-store(app端商户)迁移到 alien-store-platform(web端商户)的根据手机号获取商户用户信息接口。
接口描述:根据商户手机号查询商户用户的完整信息,包括基本信息、账户状态、余额等,如果用户处于注销中状态,会返回注销倒计时。
GET /alienStore/store/user/getUserByPhone?phone=15242687180StoreUserController.getUserByPhone()StoreUserServiceImpl.getUserByPhone()GET /alienStorePlatform/merchantUser/getMerchantByPhone?phone=15242687180MerchantUserController.getMerchantByPhone()MerchantUserServiceImpl.getMerchantByPhone()Query 参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| phone | String | 是 | 商户手机号 |
请求示例:
GET /alienStorePlatform/merchantUser/getMerchantByPhone?phone=15242687180
成功响应(用户存在):
{
"code": 200,
"msg": "success",
"data": {
"id": 123,
"phone": "15242687180",
"name": "张三",
"nickName": "店铺老板",
"headImg": "https://example.com/avatar.jpg",
"accountBlurb": "这是一家优质店铺",
"storeId": 102,
"status": 1,
"money": 10000,
"moneyStr": "100.00",
"payPassword": "******",
"idCard": "410***********1234",
"realName": "张三",
"logoutFlag": 0,
"logoutTime": null,
"logoutReason": null,
"countdown": 0,
"createdTime": "2024-01-01 10:00:00",
"updatedTime": "2025-01-15 14:30:00"
},
"success": true
}
成功响应(用户不存在):
{
"code": 500,
"msg": "手机号不存在",
"data": null,
"success": false
}
成功响应(用户注销中):
{
"code": 200,
"msg": "success",
"data": {
"id": 123,
"phone": "15242687180",
"name": "张三",
"status": -1,
"money": 10000,
"moneyStr": "100.00",
"logoutFlag": 1,
"logoutTime": "2025-01-15 10:00:00",
"logoutReason": "个人原因",
"countdown": 518400000,
"createdTime": "2024-01-01 10:00:00",
"updatedTime": "2025-01-15 10:00:00"
},
"success": true
}
失败响应(查询错误):
{
"code": 500,
"msg": "{错误信息}",
"data": null,
"success": false
}
| 字段名 | 类型 | 说明 |
|---|---|---|
| id | Integer | 商户用户ID |
| phone | String | 手机号 |
| name | String | 真实姓名 |
| nickName | String | 昵称 |
| headImg | String | 头像URL |
| accountBlurb | String | 账户简介 |
| storeId | Integer | 绑定的店铺ID |
| idCard | String | 身份证号 |
| realName | String | 实名 |
| 字段名 | 类型 | 说明 |
|---|---|---|
| status | Integer | 账户状态(-1:注销中, 1:正常, 0:禁用) |
| logoutFlag | Integer | 注销标记(0:正常, 1:已申请注销) |
| logoutTime | DateTime | 注销申请时间 |
| logoutReason | String | 注销原因 |
| countdown | Long | 注销倒计时(毫秒),仅当status=-1时有值 |
| 字段名 | 类型 | 说明 |
|---|---|---|
| money | Integer | 账户余额(单位:分) |
| moneyStr | String | 账户余额(单位:元,格式化后) |
| payPassword | String | 支付密码(脱敏) |
| 字段名 | 类型 | 说明 |
|---|---|---|
| createdTime | DateTime | 创建时间 |
| updatedTime | DateTime | 更新时间 |
LambdaQueryWrapper<StoreUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StoreUser::getPhone, phone);
StoreUser user = storeUserMapper.selectOne(queryWrapper);
store_user 表phone 字段精确匹配if (user == null) {
return new StoreUserVo(); // 返回空对象
}
StoreUserVo 对象id 是否为空,返回"手机号不存在"if (user.getStatus() == -1) {
// 获取注销申请时间
LocalDateTime logoutDateTime = user.getLogoutTime()
.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
// 计算7天后的时间(冷静期结束时间)
LocalDateTime futureDateTime = logoutDateTime.plusDays(7);
// 获取当前时间
LocalDateTime nowDateTime = LocalDateTime.now();
// 计算剩余时间
Duration duration = Duration.between(nowDateTime, futureDateTime);
// 转换为毫秒
long countdownMillis = duration.toMillis();
storeUserVo.setCountdown(countdownMillis);
}
注销倒计时说明:
status = -1(账户注销中)logoutTime(注销申请时间)logoutTime + 7天结束时间 - 当前时间String moneyStr = new BigDecimal(user.getMoney())
.divide(new BigDecimal(100), 2, RoundingMode.DOWN)
.toString();
storeUserVo.setMoneyStr(moneyStr);
money 字段(单位:分,Integer类型)moneyStr 字段(单位:元,String类型)money = 10000 → moneyStr = "100.00"money = 12345 → moneyStr = "123.45"money = 12346 → moneyStr = "123.46"BeanUtils.copyProperties() 复制用户基本信息moneyStr 字段countdown 字段StoreUserVo 对象请求:
GET /alienStorePlatform/merchantUser/getMerchantByPhone?phone=15242687180
用户状态:
status = 1(正常)logoutFlag = 0(未申请注销)响应特点:
countdown 为 0(未计算)moneyStr 为格式化后的金额请求:
GET /alienStorePlatform/merchantUser/getMerchantByPhone?phone=15242687180
用户状态:
status = -1(注销中)logoutFlag = 1(已申请注销)logoutTime = 2025-01-15 10:00:00响应特点:
countdown 为剩余冷静期时间(毫秒)请求:
GET /alienStorePlatform/merchantUser/getMerchantByPhone?phone=99999999999
响应:
{
"code": 500,
"msg": "手机号不存在",
"data": null,
"success": false
}
| 字段名 | 类型 | 说明 |
|---|---|---|
| id | INT | 主键,自增 |
| phone | VARCHAR(11) | 手机号(唯一) |
| name | VARCHAR(50) | 真实姓名 |
| nick_name | VARCHAR(50) | 昵称 |
| head_img | VARCHAR(255) | 头像URL |
| account_blurb | TEXT | 账户简介 |
| store_id | INT | 绑定的店铺ID |
| status | INT | 账户状态(-1:注销中, 0:禁用, 1:正常) |
| money | INT | 账户余额(单位:分) |
| pay_password | VARCHAR(100) | 支付密码(加密) |
| id_card | VARCHAR(18) | 身份证号 |
| real_name | VARCHAR(50) | 实名 |
| logout_flag | INT | 注销标记(0:正常, 1:已申请注销) |
| logout_time | DATETIME | 注销申请时间 |
| logout_reason | VARCHAR(255) | 注销原因 |
| delete_flag | INT | 删除标记(0:未删除, 1:已删除) |
| created_time | DATETIME | 创建时间 |
| updated_time | DATETIME | 更新时间 |
重要索引:
id)uk_phone (phone)alien-store-platform/src/main/java/shop/alien/storeplatform/controller/MerchantUserController.javaalien-store-platform/src/main/java/shop/alien/storeplatform/service/MerchantUserService.javaalien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/MerchantUserServiceImpl.javaalien-entity/src/main/java/shop/alien/entity/store/StoreUser.javaalien-entity/src/main/java/shop/alien/entity/store/vo/StoreUserVo.javaalien-entity/src/main/java/shop/alien/mapper/StoreUserMapper.javacurl -X GET "http://localhost:8080/alienStorePlatform/merchantUser/getMerchantByPhone?phone=15242687180"
期望结果:
status = 1logoutFlag = 0countdown = 0moneyStr 格式正确(如:"100.00")前置条件:
status = -1logoutTime 在过去7天内
curl -X GET "http://localhost:8080/alienStorePlatform/merchantUser/getMerchantByPhone?phone=15242687180"
期望结果:
status = -1logoutFlag = 1countdown > 0(倒计时为正数)logoutTime 和 logoutReason 有值curl -X GET "http://localhost:8080/alienStorePlatform/merchantUser/getMerchantByPhone?phone=99999999999"
期望结果:
{
"code": 500,
"msg": "手机号不存在",
"data": null,
"success": false
}
测试不同金额值的转换:
| 原始值(分) | 期望值(元) |
|---|---|
| 0 | "0.00" |
| 100 | "1.00" |
| 12345 | "123.45" |
| 99999 | "999.99" |
场景:用户在不同时间点查询倒计时
| 注销申请时间 | 查询时间 | 期望倒计时 |
|---|---|---|
| 2025-01-15 10:00:00 | 2025-01-16 10:00:00 | 6天 = 518400000ms |
| 2025-01-15 10:00:00 | 2025-01-22 09:00:00 | 1小时 = 3600000ms |
| 2025-01-15 10:00:00 | 2025-01-22 10:00:00 | 0ms(冷静期结束) |
| 2025-01-15 10:00:00 | 2025-01-23 10:00:00 | 负数(已超期) |
| status 值 | 状态 | 说明 |
|---|---|---|
| -1 | 注销中 | 冷静期内,可撤销注销 |
| 0 | 禁用 | 账户被管理员禁用 |
| 1 | 正常 | 账户正常使用 |
status = -1logoutFlag = 1countdown 倒计时(毫秒)phone(手机号字段)nullif (user == null) {
return new StoreUserVo(); // 返回空对象,不是null
}
null)id 字段判断是否为空LocalDateTime localDateTime = logoutTime
.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
| 功能 | 原接口(alien-store) | 新接口(alien-store-platform) |
|---|---|---|
| 根据手机号查询 | /alienStore/store/user/getUserByPhone |
/alienStorePlatform/merchantUser/getMerchantByPhone |
| 返回类型 | R<StoreUser> |
R<StoreUserVo> |
主要变化:
MerchantUser)StoreUserVo(扩展字段更丰富)| 版本 | 日期 | 说明 | 作者 |
|---|---|---|---|
| 1.0.0 | 2025-01-xx | 初始版本,迁移商户用户查询功能 | ssk |
如有问题,请联系: