From beb76ea959ccaf0575bc27ee993b5d5d829fed36 Mon Sep 17 00:00:00 2001 From: fengjundan <1436525664@qq.com> Date: Tue, 3 Aug 2021 10:51:56 +0800 Subject: [PATCH] =?UTF-8?q?1=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=94=80=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../general/controller/XhpcSmsController.java | 8 ++-- .../general/service/XhpcSmsServiceImpl.java | 6 +-- .../controller/XhpcRefundAuditController.java | 16 ++++--- .../controller/XhpcAppUserController.java | 5 +-- .../user/service/IXhpcAppUserUserService.java | 6 +-- .../service/impl/XhpcAppUserServiceImpl.java | 43 ++++++++++++------- 6 files changed, 51 insertions(+), 33 deletions(-) diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java index d3bd6489..c311c022 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java @@ -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); } } diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java index 398f267e..3ad939bc 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java @@ -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()); diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java index d091ecf4..c3763ebd 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java @@ -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 map = iXhpcRefundOrderService.addRefundOrder(userId); - if (StringUtils.isNull(map)) { + public AjaxResult cancelExamine(@RequestBody Map map) { + String userId = StringUtils.valueOf(map); + if (StringUtils.isEmpty(userId)) { + return AjaxResult.error(HttpStatus.NOT_NULL, "用户id不能为空"); + } + Map 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(); diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java index 3de1405f..43313bd2 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java @@ -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); } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java index 584f724e..9d542665 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java @@ -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); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java index dc6a2c76..98d3247c 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java @@ -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(); } }