Compare commits

...

3 Commits

Author SHA1 Message Date
c03678bd93 feat(mobile): 添加景区账号注册功能
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
- 新增注册接口和相关请求/响应对象
- 实现手机号格式验证、密码非空验证
- 检查手机号是否已注册
- 创建新账号并设置初始状态
- 返回注册结果及提示信息
2025-08-28 15:07:45 +08:00
ce7e055ada feat(scenic-account): 添加景区账号激活/停用功能并优化登录验证
- 新增激活/停用景区账号的接口和相关逻辑
- 在登录时增加账号激活状态的验证
- 更新数据库表结构,添加 isActive 字段
- 优化 MyBatis 映射文件,支持新功能
2025-08-28 11:12:37 +08:00
e694aac928 refactor(pricing): 修正凭证打印服务中的 URL 链接参数
- 在生成 URL链接时,添加了 scenicId
2025-08-26 10:37:30 +08:00
13 changed files with 137 additions and 6 deletions

View File

@@ -5,6 +5,8 @@ import com.ycwl.basic.constant.BaseContextHandler;
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginOldRespVO;
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginReq;
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginRespVO;
import com.ycwl.basic.model.mobile.scenic.account.ScenicRegisterReq;
import com.ycwl.basic.model.mobile.scenic.account.ScenicRegisterRespVO;
import com.ycwl.basic.model.mobile.weChat.DTO.WeChatUserInfoDTO;
import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
@@ -63,6 +65,13 @@ public class AppScenicAccountController {
return ApiResponse.success(vo);
}
// 注册
@PostMapping("/register")
@IgnoreToken
public ApiResponse<ScenicRegisterRespVO> register(@RequestBody ScenicRegisterReq scenicRegisterReq) {
return scenicService.register(scenicRegisterReq);
}
@GetMapping("/myScenicList")
public ApiResponse<List<ScenicRespVO>> myScenicList() {
List<ScenicRespVO> list;

View File

@@ -39,6 +39,13 @@ public class ScenicAccountController {
return result > 0 ? ApiResponse.success("更新成功") : ApiResponse.fail("更新失败");
}
// 激活/停用景区账号
@PostMapping("/updateActiveStatus/{id}")
public ApiResponse updateActiveStatus(@PathVariable Long id) {
int result = service.updateActiveStatus(id);
return result > 0 ? ApiResponse.success("操作成功") : ApiResponse.fail("操作失败");
}
// 更新景区账号
@PostMapping("/update")
public ApiResponse updateScenicAccount(@RequestBody ScenicAccountEntity entity) {

View File

@@ -14,6 +14,7 @@ public interface ScenicAccountMapper {
int update(ScenicAccountEntity scenicAccount);
int deleteById(Long id);
int updateStatus(Long id);
int updateActiveStatus(Long id);
int deleteByScenicId(Long scenicId);
ScenicAccountEntity findAccountById(String id);

View File

@@ -0,0 +1,14 @@
package com.ycwl.basic.model.mobile.scenic.account;
import lombok.Data;
/**
* 景区账号注册请求
* @Author:longbinbin
* @Date:2024/12/28 10:00
*/
@Data
public class ScenicRegisterReq {
private String phone;
private String password;
}

View File

@@ -0,0 +1,17 @@
package com.ycwl.basic.model.mobile.scenic.account;
import lombok.Data;
/**
* 景区账号注册响应
* @Author:longbinbin
* @Date:2024/12/28 10:00
*/
@Data
public class ScenicRegisterRespVO {
private Long id;
private String account;
private String phone;
private Integer isActive;
private String message;
}

View File

@@ -17,6 +17,7 @@ public class ScenicAccountEntity {
private String account;
private String password;
private Integer status;
private Integer isActive;
private Date createTime;
private Date updateTime;
}

View File

@@ -213,7 +213,8 @@ public class VoucherPrintServiceImpl implements VoucherPrintService {
private void printTicket(VoucherPrintRecord record) throws Exception {
FaceEntity face = faceRepository.getFace(record.getFaceId());
MpConfigEntity scenicMpConfig = scenicRepository.getScenicMpConfig(face.getScenicId());
String urlLink = WxMpUtil.generateUrlLink(scenicMpConfig.getAppId(), scenicMpConfig.getAppSecret(), "pages/videoSynthesis/index", "code=" + record.getVoucherCode() + "&faceId=" + face.getId());
String urlLink = WxMpUtil.generateUrlLink(scenicMpConfig.getAppId(), scenicMpConfig.getAppSecret(), "pages/videoSynthesis/index", "code=" + record.getVoucherCode() + "&scenicId=" + face.getScenicId() + "&faceId=" + face.getId());
urlLink = urlLink + "?cq=T"+record.getVoucherCode();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
SimpleDateFormat sdf2 = new SimpleDateFormat("MM月dd日");
log.info(" 调用打印机打印小票,记录ID: {}, 券码: {}", record.getId(), record.getVoucherCode());

View File

@@ -6,6 +6,8 @@ import com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO;
import com.ycwl.basic.model.mobile.scenic.ScenicIndexVO;
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginReq;
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginRespVO;
import com.ycwl.basic.model.mobile.scenic.account.ScenicRegisterReq;
import com.ycwl.basic.model.mobile.scenic.account.ScenicRegisterRespVO;
import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
@@ -26,6 +28,8 @@ public interface AppScenicService {
ApiResponse<ScenicLoginRespVO> login(ScenicLoginReq scenicLoginReq) throws Exception;
ApiResponse<ScenicRegisterRespVO> register(ScenicRegisterReq scenicRegisterReq);
List<ScenicAppVO> scenicListByLnLa(ScenicIndexVO scenicIndexVO);
ApiResponse<List<DeviceRespVO>> getDevices(Long scenicId);

View File

@@ -11,6 +11,8 @@ import com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO;
import com.ycwl.basic.model.mobile.scenic.ScenicIndexVO;
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginReq;
import com.ycwl.basic.model.mobile.scenic.account.ScenicLoginRespVO;
import com.ycwl.basic.model.mobile.scenic.account.ScenicRegisterReq;
import com.ycwl.basic.model.mobile.scenic.account.ScenicRegisterRespVO;
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
@@ -90,6 +92,9 @@ public class AppScenicServiceImpl implements AppScenicService {
if (scenicAccount.getStatus() == 0) {
return ApiResponse.fail("账号已被禁用");
}
if (scenicAccount.getIsActive() == null || scenicAccount.getIsActive() != 1) {
return ApiResponse.fail("账号未激活");
}
if (!scenicAccount.getPassword().equals(scenicLoginReq.getPassword())) {
return ApiResponse.fail("密码错误");
}
@@ -113,6 +118,57 @@ public class AppScenicServiceImpl implements AppScenicService {
return ApiResponse.success(scenicLoginRespVO);
}
@Override
public ApiResponse<ScenicRegisterRespVO> register(ScenicRegisterReq scenicRegisterReq) {
// 验证手机号格式
if (scenicRegisterReq.getPhone() == null || !scenicRegisterReq.getPhone().matches("^1[3-9]\\d{9}$")) {
return ApiResponse.fail("手机号格式不正确");
}
// 验证密码不能为空
if (scenicRegisterReq.getPassword() == null || scenicRegisterReq.getPassword().trim().isEmpty()) {
return ApiResponse.fail("密码不能为空");
}
// 检查手机号是否已存在
try {
ScenicAccountEntity existingAccount = scenicAccountService.getScenicAccountByAccount(scenicRegisterReq.getPhone());
if (existingAccount != null) {
return ApiResponse.fail("该手机号已注册");
}
} catch (Exception e) {
// 如果抛出异常说明账号不存在,可以继续注册
}
// 创建新账号
ScenicAccountEntity newAccount = new ScenicAccountEntity();
newAccount.setAccount(scenicRegisterReq.getPhone());
newAccount.setPhone(scenicRegisterReq.getPhone());
newAccount.setPassword(scenicRegisterReq.getPassword());
newAccount.setIsActive(0); // 未激活状态
newAccount.setStatus(1); // 正常状态
newAccount.setCreateTime(new Date());
newAccount.setUpdateTime(new Date());
try {
int result = scenicAccountService.addScenicAccount(newAccount);
if (result > 0) {
ScenicRegisterRespVO response = new ScenicRegisterRespVO();
response.setId(newAccount.getId());
response.setAccount(newAccount.getAccount());
response.setPhone(newAccount.getPhone());
response.setIsActive(newAccount.getIsActive());
response.setMessage("注册成功,请等待后台激活");
return ApiResponse.success(response);
} else {
return ApiResponse.fail("注册失败");
}
} catch (Exception e) {
log.error("注册失败", e);
return ApiResponse.fail("注册失败:" + e.getMessage());
}
}
@Override
public List<ScenicAppVO> scenicListByLnLa(ScenicIndexVO scenicIndexVO) {
List<ScenicAppVO> scenicAppVOS = scenicMapper.scenicListByLnLa(scenicIndexVO);

View File

@@ -17,5 +17,7 @@ public interface ScenicAccountService {
int updateStatus(Long id);
int updateActiveStatus(Long id);
ScenicAccountEntity getScenicAccountByAccount(String account);
}

View File

@@ -72,6 +72,11 @@ public class ScenicAccountServiceImpl implements ScenicAccountService {
return mapper.updateStatus(id);
}
@Override
public int updateActiveStatus(Long id) {
return mapper.updateActiveStatus(id);
}
@Override
public ScenicAccountEntity getScenicAccountByAccount(String account) {
ScenicAccountEntity accountEntity = mapper.getByAccount(account);

View File

@@ -141,6 +141,6 @@ public class WxMpUtil {
}
public static void main(String[] args) throws Exception {
generateWXAQRCode("wxe7ff26af70bfc37c", "5252fbbc68513bc77b7cc0052b9f9695", "trial", "pages/home/index?scenicId=3978838215909052416", "dhg_t.jpg");
generateWXAQRCode("wxe7ff26af70bfc37c", "5252fbbc68513bc77b7cc0052b9f9695", "trial", "pages/home/index?scenicId=3930324797233434624&morphId=22", "zt_p_t.jpg");
}
}

View File

@@ -2,8 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ycwl.basic.mapper.ScenicAccountMapper">
<insert id="add">
insert into scenic_account(id, is_super, name, phone, account, password, create_time, update_time)
values (#{id}, #{isSuper}, #{name}, #{phone}, #{account}, #{password}, now(), now())
insert into scenic_account(id, is_super, name, phone, account, password, is_active, create_time, update_time)
values (#{id}, #{isSuper}, #{name}, #{phone}, #{account}, #{password}, #{isActive}, now(), now())
</insert>
<insert id="addAccountScenicRelation">
insert into account_scenic(account_id, scenic_id, is_admin)
@@ -24,6 +24,9 @@
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="isActive != null">
is_active = #{isActive},
</if>
update_time = now()
</set>
where id = #{id}
@@ -39,6 +42,17 @@
END)
where id = #{id}
</update>
<update id="updateActiveStatus">
update scenic_account
set is_active = (CASE
WHEN is_active = 1 THEN
0
WHEN is_active = 0 THEN
1
ELSE 1
END)
where id = #{id}
</update>
<delete id="deleteById">
delete from scenic_account where id = #{id}
</delete>
@@ -53,12 +67,12 @@
</delete>
<select id="getSuperAccountOfScenic"
resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
select a.id, b.scenic_id, b.is_admin as isSuper, a.name, a.phone, a.account, a.password, a.create_time, a.update_time
select a.id, b.scenic_id, b.is_admin as isSuper, a.name, a.phone, a.account, a.password, a.status, a.is_active, a.create_time, a.update_time
from scenic_account a left join account_scenic b on a.id = b.account_id
where b.scenic_id = #{scenicId} and b.is_admin = 1
</select>
<select id="getByAccount" resultType="com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity">
select id, scenic_id, is_super, name, phone, account, password, status,create_time, update_time
select id, scenic_id, is_super, name, phone, account, password, status, is_active, create_time, update_time
from scenic_account
where account = #{account}
</select>