5 files modified
1 files added
New file |
| | |
| | | package cc.mrbird.febs.common.utils; |
| | | |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.core.util.XmlUtil; |
| | | import cn.hutool.http.HttpUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2020-07-14 |
| | | **/ |
| | | @Slf4j |
| | | public class Sms106Send { |
| | | |
| | | private static final String URL = "http://www.qf106.com/sms.aspx"; |
| | | private static final String ID = "16859"; |
| | | private static final String ACCOUNT = "gcsm"; |
| | | private static final String PASSWORD = "a123456"; |
| | | |
| | | |
| | | /** |
| | | * @param phone 手机号 |
| | | * @param code 验证码 |
| | | * @param time 失效时间 |
| | | * @return |
| | | */ |
| | | public static boolean sendVerifyCode(String phone, String code, int time) { |
| | | String msg = "您的验证码是{},请在{}分钟内输入,请勿泄露给他人,如非本人操作,请及时修改密码。"; |
| | | String content = StrUtil.format(msg, code, time); |
| | | return request(phone, content, "验证码"); |
| | | } |
| | | |
| | | private static boolean request(String phone, String content, String tagName) { |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | param.put("userid", ID); |
| | | param.put("account", ACCOUNT); |
| | | param.put("password", PASSWORD); |
| | | param.put("mobile", phone); |
| | | param.put("content", content); |
| | | param.put("sendTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN)); |
| | | param.put("action", "send"); |
| | | param.put("checkcontent", 0); |
| | | param.put("taskName", tagName); |
| | | param.put("countnumber", 1); |
| | | param.put("mobilenumber", 1); |
| | | param.put("telephonenumber", 0); |
| | | |
| | | String response = HttpUtil.post(URL, param); |
| | | log.info("短信发送:{}, {}", tagName, response); |
| | | if ("Success".equals(XmlUtil.xmlToMap(response).get("returnstatus"))) { |
| | | return true; |
| | | } else { |
| | | throw new FebsException((String) XmlUtil.xmlToMap(response).get("message")); |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(sendVerifyCode("15773002834", "123456", 2)); |
| | | } |
| | | } |
| | |
| | | @ApiParam(name = "type", value = "类型1-手机号", required = true) @RequestParam("type") String type) { |
| | | log.info("#账号:{}, 类型:{}#", account, type); |
| | | |
| | | Integer code = 123456; |
| | | // Integer code = (int) ((Math.random() * 9 + 1) * 100000); |
| | | // Integer code = 123456; |
| | | Integer code = (int) ((Math.random() * 9 + 1) * 100000); |
| | | if (StrUtil.isNotBlank(redisUtils.getString(AppContants.VERIFY_CODE_PREFIX + account))) { |
| | | throw new FebsException("验证码已发送"); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | boolean flag = redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120); |
| | | map.put("code", flag); |
| | | return new FebsResponse().success().message("验证码发送成功"); |
| | | |
| | | // // 发送手机验证码 |
| | | // if (AppContants.ACCOUNT_TYPE_MOBILE.equals(type)) { |
| | | // boolean result = ZzSmsSend.sendVerifyCode(account, code.toString(), 2); |
| | | // if (result) { |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // boolean flag = redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120); |
| | | // map.put("code", flag); |
| | | // return new FebsResponse().success().message("验证码发送成功"); |
| | | // } |
| | | // // 发送邮件验证码 |
| | | // } else if (AppContants.ACCOUNT_TYPE_EMAIL.equals(type)) { |
| | | // boolean flag = SubMailSend.sendMail(account, code.toString()); |
| | | // if (flag) { |
| | | // redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120); |
| | | // return new FebsResponse().success().message("验证码发送成功"); |
| | | // } else { |
| | | // return new FebsResponse().fail().message("验证码发送失败"); |
| | | // } |
| | | // } else { |
| | | // log.info("未定义账号类型"); |
| | | // throw new FebsException("未定义账号类型"); |
| | | // } |
| | | // return new FebsResponse().fail().message("验证码发送失败"); |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // boolean flag = redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120); |
| | | // map.put("code", flag); |
| | | // return new FebsResponse().success().message("验证码发送成功"); |
| | | |
| | | // 发送手机验证码 |
| | | if (AppContants.ACCOUNT_TYPE_MOBILE.equals(type)) { |
| | | boolean result = Sms106Send.sendVerifyCode(account, code.toString(), 2); |
| | | if (result) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | boolean flag = redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120); |
| | | map.put("code", flag); |
| | | return new FebsResponse().success().message("验证码发送成功"); |
| | | } |
| | | // 发送邮件验证码 |
| | | } else if (AppContants.ACCOUNT_TYPE_EMAIL.equals(type)) { |
| | | boolean flag = SubMailSend.sendMail(account, code.toString()); |
| | | if (flag) { |
| | | redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120); |
| | | return new FebsResponse().success().message("验证码发送成功"); |
| | | } else { |
| | | return new FebsResponse().fail().message("验证码发送失败"); |
| | | } |
| | | } else { |
| | | log.info("未定义账号类型"); |
| | | throw new FebsException("未定义账号类型"); |
| | | } |
| | | return new FebsResponse().fail().message("验证码发送失败"); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | BigDecimal selectSumAmountByPayMethodAndSomeStatue(@Param("payMethod")String name, @Param("statues") List<Long> values); |
| | | |
| | | List<MallOrderInfo> selectScoreOrderListInDate(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("goodsId") Long goodsId); |
| | | List<MallOrderInfo> selectScoreOrderListInDate(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("goodsId") Long goodsId,@Param("memberId") Long memberId); |
| | | } |
| | |
| | | } |
| | | |
| | | String account = registerDto.getAccount(); |
| | | // if (!"admin".equals(registerDto.getRegistType())) { |
| | | // String code = registerDto.getCode(); |
| | | // boolean flags = commonService.verifyCode(account, code); |
| | | // if (!flags) { |
| | | // throw new FebsException("验证码错误"); |
| | | // } |
| | | // } |
| | | if (!"admin".equals(registerDto.getRegistType())) { |
| | | String code = registerDto.getCode(); |
| | | boolean flags = commonService.verifyCode(account, code); |
| | | if (!flags) { |
| | | throw new FebsException("验证码错误"); |
| | | } |
| | | } |
| | | |
| | | mallMember = new MallMember(); |
| | | mallMember.setPassword(SecureUtil.md5(registerDto.getPassword())); |
| | |
| | | |
| | | if (mallGoods.getRulesTimes() != null && mallGoods.getRulesCnt() != null) { |
| | | DateTime startDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -mallGoods.getRulesTimes()); |
| | | List<MallOrderInfo> orderInfos = this.baseMapper.selectScoreOrderListInDate(DateUtil.beginOfDay(startDate), DateUtil.endOfDay(new Date()), mallGoods.getId()); |
| | | List<MallOrderInfo> orderInfos = this.baseMapper.selectScoreOrderListInDate(DateUtil.beginOfDay(startDate), DateUtil.endOfDay(new Date()), mallGoods.getId(), member.getId()); |
| | | if (CollUtil.isNotEmpty(orderInfos) && orderInfos.size() >= mallGoods.getRulesCnt()) { |
| | | throw new FebsException("超出领取最大限制"); |
| | | } |
| | |
| | | where orderInfo.order_time >= #{startDate} |
| | | and orderInfo.order_time <= #{endDate} |
| | | and orderInfo.status in (2,3,4,5) |
| | | and orderInfo.member_id=#{memberId} |
| | | </select> |
| | | </mapper> |