1修改注销用户接口

This commit is contained in:
fengjundan 2021-08-03 10:51:56 +08:00
parent 8ebc320e25
commit beb76ea959
6 changed files with 51 additions and 33 deletions

View File

@ -2,10 +2,12 @@ package com.xhpc.general.controller;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.security.annotation.PreAuthorize;
import com.xhpc.general.service.IXhpcSmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author yuyang
@ -24,7 +26,7 @@ public class XhpcSmsController extends BaseController {
@GetMapping(value = "/getLogonPhoneCode")
public AjaxResult getLogonPhoneCode(@RequestParam("phone") String phone)
{
return AjaxResult.success(xhpcSmsService.getLogonPhoneCode(phone));
return xhpcSmsService.getLogonPhoneCode(phone);
}
}

View File

@ -2,6 +2,7 @@ package com.xhpc.general.service;
import com.alibaba.fastjson.JSONObject;
import com.xhpc.common.core.utils.HttpUtils;
import com.xhpc.common.core.utils.StringUtils;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.general.domain.XhpcSms;
@ -10,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Random;
@ -57,11 +57,11 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService{
//添加短信记录
XhpcSms xhpcSms =new XhpcSms();
try {
Long random = getRandom();
String random = StringUtils.valueOf(getRandom());
String conten ="【小华充电】您的验证码是:"+random+"有效期为5分钟。如非本人操作可不用理会。";
String req = HttpUtils.postFormData(URL, null, assembleSmsReq(phone,conten));
JSONObject json = JSONObject.parseObject(req);
xhpcSms.setCode(random+"");
xhpcSms.setCode(random);
xhpcSms.setPhone(phone);
xhpcSms.setContent(conten);
xhpcSms.setCreateTime(new Date());

View File

@ -107,17 +107,21 @@ public class XhpcRefundAuditController extends BaseController {
/**
* 退款审核
*
* @param userId
* @param map
* @return
*/
@PostMapping("/cancelExamine")
@ApiOperation(value = "退款审核")
public AjaxResult cancelExamine(@RequestParam Long userId) {
Map<String, Object> map = iXhpcRefundOrderService.addRefundOrder(userId);
if (StringUtils.isNull(map)) {
public AjaxResult cancelExamine(@RequestBody Map<String, Object> map) {
String userId = StringUtils.valueOf(map);
if (StringUtils.isEmpty(userId)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "用户id不能为空");
}
Map<String, Object> refundOrder = iXhpcRefundOrderService.addRefundOrder(Long.parseLong(userId));
if (StringUtils.isNull(refundOrder)) {
return AjaxResult.error(HttpStatus.DATA_ERROR, "退款订单不存在");
}
String refundOrderId = StringUtils.valueOf(map.get("refundOrderId"));
String refundOrderId = StringUtils.valueOf(refundOrder.get("refundOrderId"));
XhpcRefundOrder xhpcRefundOrder = new XhpcRefundOrder();
xhpcRefundOrder.setRefundOrderId(Long.parseLong(refundOrderId));
xhpcRefundOrder.setStatus(StatusConstants.REFUND_ORDER_STATUS_CANCEL);
@ -127,7 +131,7 @@ public class XhpcRefundAuditController extends BaseController {
return AjaxResult.error();
}
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setAppUserId(userId);
xhpcAppUser.setAppUserId(Long.parseLong(userId));
xhpcAppUser.setIsRefundApplication(0);
xhpcUserAccountStatementMapper.updateAppUserRefundApplication(xhpcAppUser);
return AjaxResult.success();

View File

@ -237,8 +237,7 @@ public class XhpcAppUserController extends BaseController {
*/
@ApiOperation("注销账号")
@PostMapping("/logout")
public AjaxResult logout(@RequestParam Long appUserId) {
iXhpcAppUserUserService.logout(appUserId);
return AjaxResult.success();
public R<?> logout(String phone, String code) {
return iXhpcAppUserUserService.logout(phone, code);
}
}

View File

@ -90,9 +90,9 @@ public interface IXhpcAppUserUserService {
/**
* 注销账号
*
* @param appUserId C端用户id
* @param phone
* @param code
* @return
*/
public void logout(Long appUserId);
public R<?> logout(String phone, String code);
}

View File

@ -113,15 +113,13 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
if (StringUtils.isEmpty(code)) {
return R.fail(HttpStatus.NOT_NULL, "验证码不能为空");
}
/*String verifyKey = Constants.CAPTCHA_CODE_KEY + phone;
String captcha = redisService.getCacheObject(verifyKey);
redisService.deleteObject(verifyKey);
String captcha = redisService.getCacheObject(phone);
redisService.deleteObject(phone);
if (!code.equalsIgnoreCase(captcha))
{
R.fail(HttpStatus.ERROR_STATUS,"openid不能为空");
}*/
R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
}
XhpcAppUser info = xhpcAppUserMapper.getAppUserByPhone(phone);
if (StringUtils.isNotNull(info)) {
return R.fail(HttpStatus.ALREADY_EXISTING, "账号已存在");
@ -152,14 +150,12 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
if (StringUtils.isEmpty(openid)) {
return R.fail(HttpStatus.NOT_NULL, "openid不能为空");
}
/*String verifyKey = Constants.CAPTCHA_CODE_KEY + phone;
String captcha = redisService.getCacheObject(verifyKey);
redisService.deleteObject(verifyKey);
String captcha = redisService.getCacheObject(phone);
redisService.deleteObject(phone);
if (!code.equalsIgnoreCase(captcha))
{
R.fail(HttpStatus.ERROR_STATUS,"openid不能为空");
}*/
R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
}
return appLogin(phone, type, openid);
}
@ -279,12 +275,29 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
/**
* 注销账号
*
* @param appUserId
* @param phone
* @param code
* @return
*/
@Override
@Transactional
public void logout(Long appUserId) {
xhpcAppUserMapper.deleteById(appUserId);
public R<?> logout(String phone, String code) {
if (StringUtils.isEmpty(code)) {
return R.fail(HttpStatus.NOT_NULL, "验证码不能为空");
}
if (StringUtils.isEmpty(phone)) {
return R.fail(HttpStatus.NOT_NULL, "手机号不能为空");
}
redisService.deleteObject(phone);
String captcha = redisService.getCacheObject(phone);
if (!code.equalsIgnoreCase(captcha)) {
return R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
}
XhpcAppUser xhpcAppUser = xhpcAppUserMapper.getAppUserByPhone(phone);
if (StringUtils.isNull(xhpcAppUser)) {
return R.fail(HttpStatus.ERROR_STATUS, "用户不存在");
}
xhpcAppUserMapper.deleteById(xhpcAppUser.getAppUserId());
return R.fail();
}
}