|
|
@@ -1,7 +1,6 @@
|
|
|
package shop.alien.store.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import io.swagger.annotations.*;
|
|
|
@@ -15,13 +14,12 @@ import shop.alien.entity.store.vo.StoreInfoVo;
|
|
|
import shop.alien.entity.store.vo.StoreUserVo;
|
|
|
import shop.alien.mapper.StoreImgMapper;
|
|
|
import shop.alien.mapper.StoreUserMapper;
|
|
|
+import shop.alien.store.config.BaseRedisService;
|
|
|
import shop.alien.store.service.StoreInfoService;
|
|
|
import shop.alien.store.service.StoreUserService;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* 门店用户 前端控制器
|
|
|
@@ -39,31 +37,14 @@ import java.util.Optional;
|
|
|
public class StoreUserController {
|
|
|
|
|
|
private final StoreUserService storeUserService;
|
|
|
+
|
|
|
private final StoreUserMapper storeUserMapper;
|
|
|
+
|
|
|
private final StoreInfoService storeInfoService;
|
|
|
+
|
|
|
private final StoreImgMapper storeImgMapper;
|
|
|
|
|
|
- @ApiOperation("门店用户登录")
|
|
|
- @ApiOperationSupport(order = 1)
|
|
|
- @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "password", value = "密码", dataType = "String", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "isPassword", value = "是否密码登录", dataType = "Boolean", paramType = "query", required = true)})
|
|
|
- @GetMapping("/login")
|
|
|
- public R<StoreUserVo> login(String phone, String password,
|
|
|
- @RequestParam(defaultValue = "true", required = false) Boolean isPassword) {
|
|
|
- log.info("StoreUserController.login?phone={}&password={}&isPassword={}", phone, password, isPassword);
|
|
|
- StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>()
|
|
|
- .eq(StoreUser::getPhone, phone));
|
|
|
- if (null == storeUser) {
|
|
|
- return R.fail("当前账号不存在,请先去注册账号!");
|
|
|
- }
|
|
|
- if (storeUser.getStatus() == 1) {
|
|
|
- return R.fail("账号被禁用");
|
|
|
- }
|
|
|
- return Optional.ofNullable(storeUser).
|
|
|
- map(user -> isPassword ? checkPassword(user, password) : storeUserService.createToKen(user)).
|
|
|
- orElseGet(() -> R.fail("手机号不存在"));
|
|
|
- }
|
|
|
+ private final BaseRedisService baseRedisService;
|
|
|
|
|
|
/**
|
|
|
* 校验商户端账号是否禁用
|
|
|
@@ -76,46 +57,52 @@ public class StoreUserController {
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "accountId", value = "账号id", dataType = "Integer", paramType = "query", required = true)})
|
|
|
@GetMapping("/checkAccount")
|
|
|
private R<StoreUserVo> checkAccount(Integer accountId) {
|
|
|
- return storeUserService.getById(accountId).getStatus() != 1 ? R.success("账号正常")
|
|
|
- : R.fail("账号禁用");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * checkPwd
|
|
|
- *
|
|
|
- * @param user
|
|
|
- * @param password
|
|
|
- * @return
|
|
|
- */
|
|
|
- private R<StoreUserVo> checkPassword(StoreUser user, String password) {
|
|
|
- return Objects.equals(password, user.getPassword())
|
|
|
- ? storeUserService.createToKen(user)
|
|
|
- : R.fail("密码错误");
|
|
|
+ return storeUserService.getById(accountId).getStatus() != 1 ? R.success("账号正常") : R.fail("账号禁用");
|
|
|
}
|
|
|
|
|
|
@ApiOperation("修改密码/忘记密码/更换绑定手机号")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
- @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "newPhone", value = "新手机号", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "oldPassword", value = "旧密码", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "newPassword", value = "新密码", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "confirmNewPassword", value = "新密码确认", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "verificationCode", value = "验证码", dataType = "String", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "type", value = "类型:0:忘记密码,1:修改密码,2:更换绑定手机号", dataType = "Integer", paramType = "query", required = true)})
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "newPhone", value = "新手机号", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "oldPassword", value = "旧密码", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "newPassword", value = "新密码", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "confirmNewPassword", value = "新密码确认", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "verificationCode", value = "验证码", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "type", value = "类型:0:忘记密码,1:修改密码,2:更换绑定手机号", dataType = "Integer", paramType = "query", required = true)})
|
|
|
@GetMapping("/updatePassword")
|
|
|
- public R<String> updatePassword(String phone,String newPhone, String oldPassword, String newPassword, String confirmNewPassword,String verificationCode, Integer type) {
|
|
|
- log.info("StoreUserController.updatePassword?phone={}&newPhone&oldPassword={}&newPassword={}&confirmNewPassword={}&verificationCode={}&type={}", phone, newPhone, oldPassword, newPassword, confirmNewPassword, verificationCode, type);
|
|
|
- return storeUserService.forgetOrModifyPassword(phone, newPhone, oldPassword, newPassword, confirmNewPassword, verificationCode, type);
|
|
|
+ public R<String> updatePassword(String phone, String newPhone, String oldPassword, String newPassword, String confirmNewPassword, String verificationCode, Integer type) {
|
|
|
+ log.info("StoreUserController.updatePassword?phone={}&newPhone={}&oldPassword={}&newPassword={}&confirmNewPassword={}&verificationCode={}&type={}", phone, newPhone, oldPassword, newPassword, confirmNewPassword, verificationCode, type);
|
|
|
+ // 2025-11-04 验证码-商家端修改密码/忘记密码/更换绑定手机号
|
|
|
+ String businessType = "";
|
|
|
+ switch (type) {
|
|
|
+ case 0:
|
|
|
+ businessType = "forget_password";
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ businessType = "modify_password";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ businessType = "modify_phone";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ String cacheCode = baseRedisService.getString("verification_store_" + businessType + "_" + phone);
|
|
|
+ if (null == cacheCode) {
|
|
|
+ return R.fail("当验证码过期或未发送");
|
|
|
+ }
|
|
|
+ if (!cacheCode.trim().equals(verificationCode.trim())) {
|
|
|
+ return R.fail("验证码错误");
|
|
|
+ }
|
|
|
+ return storeUserService.forgetOrModifyPassword(phone, newPhone, oldPassword, newPassword, confirmNewPassword, verificationCode, type);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("更换绑定手机号效验原密码或验证码")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
- @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "oldPassword", value = "旧密码", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "verificationCode", value = "验证码", dataType = "String", paramType = "query")})
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "oldPassword", value = "旧密码", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "verificationCode", value = "验证码", dataType = "String", paramType = "query")})
|
|
|
@GetMapping("/changePhoneVerification")
|
|
|
public R<Map<String, String>> changePhoneVerification(String phone, String oldPassword, String verificationCode) {
|
|
|
- log.info("StoreUserController.changePhoneVerification?phone={}&oldPassword={}&verificationCode={}", phone, oldPassword, verificationCode);
|
|
|
+ log.info("StoreUserController.changePhoneVerification?phone={}&oldPassword={}&verificationCode={}", phone, oldPassword, verificationCode);
|
|
|
+ // 2025-11-04 验证码-商家端更换绑定手机号效验原密码或验证码
|
|
|
+ String cacheCode = baseRedisService.getString("verification_store_modify_phone_" + phone);
|
|
|
+ if (null == cacheCode) {
|
|
|
+ return R.fail("当验证码过期或未发送");
|
|
|
+ }
|
|
|
+ if (!cacheCode.trim().equals(verificationCode.trim())) {
|
|
|
+ return R.fail("验证码错误");
|
|
|
+ }
|
|
|
try {
|
|
|
return R.data(storeUserService.changePhoneVerification(phone, oldPassword, verificationCode));
|
|
|
} catch (Exception e) {
|
|
|
@@ -160,10 +147,7 @@ public class StoreUserController {
|
|
|
|
|
|
@ApiOperation("修改用户状态")
|
|
|
@ApiOperationSupport(order = 6)
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "type", value = "修改类型 (pass:密码状态改为1, face:人脸状态改为2)", dataType = "String", paramType = "query", required = true)
|
|
|
- })
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "type", value = "修改类型 (pass:密码状态改为1, face:人脸状态改为2)", dataType = "String", paramType = "query", required = true)})
|
|
|
@GetMapping("/updateUserStatus")
|
|
|
public R<StoreUser> updateUserStatus(String phone, String type) {
|
|
|
log.info("StoreUserController.updateUserStatus?phone={}&type={}", phone, type);
|
|
|
@@ -180,9 +164,7 @@ public class StoreUserController {
|
|
|
log.info("StoreUserController.setStoreUserInfo?storeInfo={}", storeInfo);
|
|
|
|
|
|
// 查询店铺图片信息
|
|
|
- LambdaQueryWrapper<StoreImg> queryWrapper = new LambdaQueryWrapper<StoreImg>()
|
|
|
- .eq(StoreImg::getImgType, 10)
|
|
|
- .eq(StoreImg::getStoreId, storeInfo.getId());
|
|
|
+ LambdaQueryWrapper<StoreImg> queryWrapper = new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 10).eq(StoreImg::getStoreId, storeInfo.getId());
|
|
|
StoreImg storeImg = storeImgMapper.selectOne(queryWrapper);
|
|
|
|
|
|
// 如果查询到店铺图片信息,则更新图片 URL
|
|
|
@@ -224,19 +206,8 @@ public class StoreUserController {
|
|
|
@ApiOperation("web端查询用户列表")
|
|
|
@ApiOperationSupport(order = 7)
|
|
|
@GetMapping("/getStoreUserList")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "pageSize", value = "页容", dataType = "int", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "storeName", value = "门店名称", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "storeContact", value = "门店联系人", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "storePhone", value = "门店电话", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "storeType", value = "门店类型", dataType = "String", paramType = "query")
|
|
|
- })
|
|
|
- public R<IPage<StoreUserVo>> getStoreUserList(@RequestParam(defaultValue = "1") int pageNum,
|
|
|
- @RequestParam(defaultValue = "10") int pageSize,
|
|
|
- @RequestParam(required = false) String id,
|
|
|
- @RequestParam(required = false) String phone,
|
|
|
- @RequestParam(required = false) Integer status) {
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), @ApiImplicitParam(name = "pageSize", value = "页容", dataType = "int", paramType = "query", required = true), @ApiImplicitParam(name = "storeName", value = "门店名称", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "storeContact", value = "门店联系人", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "storePhone", value = "门店电话", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "storeType", value = "门店类型", dataType = "String", paramType = "query")})
|
|
|
+ public R<IPage<StoreUserVo>> getStoreUserList(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(required = false) String id, @RequestParam(required = false) String phone, @RequestParam(required = false) Integer status) {
|
|
|
log.info("StoreInfoController.getStoreUserList?pageNum={},pageSize={},id={},phone={},status={}", pageNum, pageSize, id, phone, status);
|
|
|
R<IPage<StoreUserVo>> storeUserVoR = storeUserService.getStoreUserList(pageNum, pageSize, id, phone, status);
|
|
|
return storeUserVoR;
|
|
|
@@ -304,15 +275,9 @@ public class StoreUserController {
|
|
|
@ApiOperation(value = "web端导出商家端账号相关信息")
|
|
|
@ApiOperationSupport(order = 6)
|
|
|
@GetMapping("/exportExcel")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "id", value = "用户id", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "phone", value = "联系电话", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "status", value = "状态", dataType = "String", paramType = "query"),
|
|
|
- })
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "用户id", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "phone", value = "联系电话", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "status", value = "状态", dataType = "String", paramType = "query"),})
|
|
|
@ResponseBody
|
|
|
- public R exportExcel(@RequestParam(value = "id", required = false) String id
|
|
|
- , @RequestParam(value = "phone", required = false) String phone
|
|
|
- , @RequestParam(value = "status", required = false) String status) throws IOException {
|
|
|
+ public R exportExcel(@RequestParam(value = "id", required = false) String id, @RequestParam(value = "phone", required = false) String phone, @RequestParam(value = "status", required = false) String status) throws IOException {
|
|
|
log.info("StoreInfoController.exportExcel");
|
|
|
String excelPath = storeUserService.exportExcel(id, phone, status);
|
|
|
return R.data(excelPath);
|
|
|
@@ -328,10 +293,18 @@ public class StoreUserController {
|
|
|
*/
|
|
|
@ApiOperation("门店用户注册")
|
|
|
@ApiOperationSupport(order = 7)
|
|
|
- @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "password", value = "密码", dataType = "String", paramType = "query", required = true)})
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "password", value = "密码", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "code", value = "验证码", dataType = "String", paramType = "query", required = true)})
|
|
|
@GetMapping("/register")
|
|
|
- public R<Boolean> register(String phone, String password) {
|
|
|
+ public R<Boolean> register(@RequestParam("phone") String phone, @RequestParam("password") String password, @RequestParam("code") String code) {
|
|
|
+ log.info("StoreUserController.register?phone={}&password={}&code={}", phone, password, code);
|
|
|
+ // 2025-11-04 验证码-商家端注册
|
|
|
+ String cacheCode = baseRedisService.getString("verification_store_register_" + phone);
|
|
|
+ if (null == cacheCode) {
|
|
|
+ return R.fail("当验证码过期或未发送");
|
|
|
+ }
|
|
|
+ if (!cacheCode.trim().equals(code.trim())) {
|
|
|
+ return R.fail("验证码错误");
|
|
|
+ }
|
|
|
log.info("StoreUserController.register?phone={}&password={}", phone, password);
|
|
|
return storeUserService.register(phone, password);
|
|
|
}
|
|
|
@@ -376,7 +349,7 @@ public class StoreUserController {
|
|
|
@PostMapping("/storeCancelAccountVerification")
|
|
|
public R<Map<String, String>> storeCancelAccountVerification(@RequestBody StoreUserVo storeUserVo) {
|
|
|
log.info("StoreUserController.storeCancelAccountVerification?storeUserVo={}", storeUserVo);
|
|
|
- return R.data(storeUserService.storeCancelAccountVerification(storeUserVo));
|
|
|
+ return R.data(storeUserService.storeCancelAccountVerification(storeUserVo));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -386,6 +359,14 @@ public class StoreUserController {
|
|
|
@PostMapping("/storeCancelAccount")
|
|
|
public R<StoreUserVo> storeCancelAccount(@RequestBody StoreUserVo storeUserVo) {
|
|
|
log.info("StoreUserController.storeCancelAccount?storeUserVo={}", storeUserVo);
|
|
|
+ // 2025-11-04 验证码-商家端注册
|
|
|
+ String cacheCode = baseRedisService.getString("verification_store_cancel_account_" + storeUserVo.getPhone());
|
|
|
+ if (null == cacheCode) {
|
|
|
+ return R.fail("当验证码过期或未发送");
|
|
|
+ }
|
|
|
+ if (!cacheCode.trim().equals(storeUserVo.getVerificationCode().trim())) {
|
|
|
+ return R.fail("验证码错误");
|
|
|
+ }
|
|
|
try {
|
|
|
storeUserService.storeCancelAccount(storeUserVo);
|
|
|
} catch (Exception e) {
|
|
|
@@ -421,9 +402,9 @@ public class StoreUserController {
|
|
|
*/
|
|
|
@ApiOperation("是否有支付密码")
|
|
|
@GetMapping("/havePayPassword")
|
|
|
- public R<Boolean> havePayPassword(@RequestParam String storeUserId,@RequestParam(required = false) String password){
|
|
|
- log.info("StoreUserController.havePayPassword?storeUserId={},password={}",storeUserId,password);
|
|
|
- return storeUserService.havePayPassword(storeUserId,password);
|
|
|
+ public R<Boolean> havePayPassword(@RequestParam String storeUserId, @RequestParam(required = false) String password) {
|
|
|
+ log.info("StoreUserController.havePayPassword?storeUserId={},password={}", storeUserId, password);
|
|
|
+ return storeUserService.havePayPassword(storeUserId, password);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -434,8 +415,8 @@ public class StoreUserController {
|
|
|
public R<Integer> addAlipayAccount(@RequestBody StoreUserVo storeUserVo) {
|
|
|
log.info("StoreUserController.addAlipayAccount?storeUserVo={}", storeUserVo);
|
|
|
LambdaUpdateWrapper<StoreUser> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- lambdaUpdateWrapper.set(StoreUser :: getAlipayAccount, storeUserVo.getAlipayAccount());
|
|
|
- lambdaUpdateWrapper.eq(StoreUser :: getId, storeUserVo.getId());
|
|
|
- return R.data(storeUserMapper.update(null,lambdaUpdateWrapper));
|
|
|
+ lambdaUpdateWrapper.set(StoreUser::getAlipayAccount, storeUserVo.getAlipayAccount());
|
|
|
+ lambdaUpdateWrapper.eq(StoreUser::getId, storeUserVo.getId());
|
|
|
+ return R.data(storeUserMapper.update(null, lambdaUpdateWrapper));
|
|
|
}
|
|
|
}
|