| | |
| | | package com.yeshi.makemoney.app.controller.admin.money; |
| | | |
| | | import com.google.gson.*; |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.yeshi.makemoney.app.aop.AdminApiFilter; |
| | | import com.yeshi.makemoney.app.dto.money.ExtractConfig; |
| | | import com.yeshi.makemoney.app.entity.config.SystemConfig; |
| | | import com.yeshi.makemoney.app.entity.config.SystemConfigKey; |
| | | import com.yeshi.makemoney.app.entity.money.ExtractPayType; |
| | | import com.yeshi.makemoney.app.exception.money.ExtractException; |
| | | import com.yeshi.makemoney.app.exception.money.UserMoneyBalanceException; |
| | | import com.yeshi.makemoney.app.service.inter.AdminUserService; |
| | | import com.yeshi.makemoney.app.service.inter.config.SystemConfigService; |
| | | import com.yeshi.makemoney.app.service.inter.user.UserInfoService; |
| | | import com.yeshi.makemoney.app.service.manager.VerifyCodeManager; |
| | | import com.yeshi.makemoney.app.vo.AcceptAdminData; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | |
| | | import com.yeshi.makemoney.app.entity.money.Extract; |
| | | import com.yeshi.makemoney.app.service.inter.money.ExtractService; |
| | | import com.yeshi.makemoney.app.service.query.money.ExtractQuery; |
| | | import org.yeshi.utils.exception.MailSendException; |
| | | import org.yeshi.utils.mail.EmailApiUtil; |
| | | import org.yeshi.utils.mail.EmailInfo; |
| | | |
| | | @Controller |
| | | @RequestMapping("admin/api/money/extract") |
| | | public class ExtractAdminController { |
| | | |
| | | private final String SESSION_KEY_EXTRACT_EMAIL_VERIFIED = "admin-do-extract"; |
| | | |
| | | |
| | | @Resource |
| | | private ExtractService extractService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private AdminUserService adminUserService; |
| | | |
| | | @Resource |
| | | private VerifyCodeManager verifyCodeManager; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("get") |
| | | public String get(Long id, HttpSession session, String callback) { |
| | | public String get(Long id) { |
| | | Extract entity = extractService.get(id); |
| | | if (entity != null) { |
| | | return JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(entity)); |
| | | |
| | | entity.setUser(userInfoService.get(entity.getUser().getId())); |
| | | return JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(entity)); |
| | | } else { |
| | | return JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("ID不存在")); |
| | | |
| | | return JsonUtil.loadFalseResult("ID不存在"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return java.lang.String |
| | | * @author hxh |
| | | * @description 发送提现的邮箱验证码 |
| | | * @date 14:14 2022/5/9 |
| | | * @param: extractConfig |
| | | * @param: acceptAdminData |
| | | **/ |
| | | @ResponseBody |
| | | @RequestMapping("sendExtractEmail") |
| | | public String sendExtractEmail(AcceptAdminData acceptAdminData) { |
| | | if (acceptAdminData.getAdminUser() == null) { |
| | | return JsonUtil.loadFalseResult("管理员信息为空"); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(acceptAdminData.getAdminUser().getEmail())) { |
| | | return JsonUtil.loadFalseResult("管理员邮件地址为空"); |
| | | } |
| | | |
| | | String emailSender = systemConfigService.getValueCache(acceptAdminData.getSystem(), SystemConfigKey.emailSender); |
| | | |
| | | if (StringUtil.isNullOrEmpty(emailSender)) { |
| | | return JsonUtil.loadFalseResult("系统尚未配置邮件发送账号信息"); |
| | | } |
| | | String[] sts = emailSender.split(","); |
| | | if (sts.length != 2) { |
| | | return JsonUtil.loadFalseResult("邮件发送账号信息格式有误"); |
| | | } |
| | | |
| | | String code = StringUtil.getVerifyCode(); |
| | | EmailInfo emailInfo = new EmailInfo(); |
| | | emailInfo.setFromEmail(sts[0]); |
| | | emailInfo.setFormEmailPwd(sts[1]); |
| | | emailInfo.setApp(systemConfigService.getValueCache(acceptAdminData.getSystem(), SystemConfigKey.androidPushAppCode)); |
| | | emailInfo.setTitle("提现审核验证码:" + code); |
| | | emailInfo.setContent("提现审核验证码:" + code + ",5分钟内有效,请尽快验证。"); |
| | | emailInfo.setToEmail(acceptAdminData.getAdminUser().getEmail()); |
| | | try { |
| | | EmailApiUtil.sendEmail(emailInfo); |
| | | verifyCodeManager.sendEmailCodeSuccess(emailInfo.getToEmail(), code); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (MailSendException e) { |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("verifyExtractEmail") |
| | | public String verifyExtractEmail(String code, AcceptAdminData acceptAdminData, HttpSession session) { |
| | | if (acceptAdminData.getAdminUser() == null) { |
| | | return JsonUtil.loadFalseResult("管理员信息为空"); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(acceptAdminData.getAdminUser().getEmail())) { |
| | | return JsonUtil.loadFalseResult("管理员邮件地址为空"); |
| | | } |
| | | |
| | | boolean isRight = verifyCodeManager.isEMailCodeRight(acceptAdminData.getAdminUser().getEmail(), code); |
| | | if (isRight) { |
| | | session.setAttribute(SESSION_KEY_EXTRACT_EMAIL_VERIFIED, true); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } else { |
| | | return JsonUtil.loadFalseResult("验证码错误"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return java.lang.String |
| | | * @author hxh |
| | | * @description 通过提现 |
| | | * @date 15:04 2022/5/9 |
| | | * @param: id |
| | | * @param: acceptAdminData |
| | | **/ |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("passExtract") |
| | | public String passExtract(Long id, AcceptAdminData acceptAdminData, HttpSession session) { |
| | | |
| | | if (!isVerifiedEmailCode(session)) { |
| | | return JsonUtil.loadFalseResult(50002, "邮箱未验证"); |
| | | } |
| | | |
| | | try { |
| | | extractService.passExtract(id, acceptAdminData.getAdminUser().getAccount()); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (ExtractException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("rejectExtract") |
| | | public String rejectExtract(Long id, String reason, AcceptAdminData acceptAdminData, HttpSession session) { |
| | | if (!isVerifiedEmailCode(session)) { |
| | | return JsonUtil.loadFalseResult(50002, "邮箱未验证"); |
| | | } |
| | | try { |
| | | extractService.rejectExtract(id, reason, acceptAdminData.getAdminUser().getAccount()); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (ExtractException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } catch (UserMoneyBalanceException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } catch (ParamsException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return boolean |
| | | * @author hxh |
| | | * @description 是否已经验证了邮件验证码 |
| | | * @date 15:02 2022/5/9 |
| | | * @param: session |
| | | **/ |
| | | private boolean isVerifiedEmailCode(HttpSession session) { |
| | | Boolean verified = (Boolean) session.getAttribute(SESSION_KEY_EXTRACT_EMAIL_VERIFIED); |
| | | if (verified != null && verified) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | } |