| @@ -95,64 +95,64 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| List<WxMall> wxmallist = wxMallMapper.findList(wxMall);*/ | List<WxMall> wxmallist = wxMallMapper.findList(wxMall);*/ | ||||
| //3、从短信配置中查询密钥 bid 等信息 | //3、从短信配置中查询密钥 bid 等信息 | ||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if (wxMsgConfigs.size() == 0) new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| wxMsgValidationcodeModel.setTenantId(wxMsgConfig.getTenantId()); | |||||
| wxMsgValidationcodeModel.setType(EnumMsgModel.VALIDATION_CODE.getCode()); | |||||
| wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | |||||
| wxMsgValidationcode.setSignature(wxMsgValidationcodeModel.getSignature()); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| // WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| // wxMsgConfig.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| // List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| // if (wxMsgConfigs.size() == 0) new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); | |||||
| // wxMsgConfig = wxMsgConfigs.get(0); | |||||
| // | |||||
| // WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| // wxMsgValidationcodeModel.setTenantId(wxMsgConfig.getTenantId()); | |||||
| // wxMsgValidationcodeModel.setType(EnumMsgModel.VALIDATION_CODE.getCode()); | |||||
| // wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | |||||
| // wxMsgValidationcode.setSignature(wxMsgValidationcodeModel.getSignature()); | |||||
| // | |||||
| // String secret = wxMsgConfig.getSecret(); | |||||
| // String bid = wxMsgConfig.getBid(); | |||||
| // String publickey = wxMsgConfig.getPublickey(); | |||||
| // //验证码 | // //验证码 | ||||
| int code = (int) ((Math.random() * 9 + 1) * 100000); | int code = (int) ((Math.random() * 9 + 1) * 100000); | ||||
| String phone = wxMsgValidationcode.getPhone(); | |||||
| String signature = wxMsgValidationcode.getSignature(); | |||||
| //内容 | |||||
| String msg = wxMsgValidationcodeModel.getContent().replace("{s6}", String.valueOf(code)); | |||||
| wxMsgValidationcode.setCode(String.valueOf(code)); | |||||
| wxMsgValidationcode.setMsg(msg); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| Integer modelId = wxMsgValidationcodeModel.getModelId(); | |||||
| // String phone = wxMsgValidationcode.getPhone(); | |||||
| // String signature = wxMsgValidationcode.getSignature(); | |||||
| // //内容 | |||||
| // String msg = wxMsgValidationcodeModel.getContent().replace("{s6}", String.valueOf(code)); | |||||
| // wxMsgValidationcode.setCode(String.valueOf(code)); | |||||
| // wxMsgValidationcode.setMsg(msg); | |||||
| // String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| // Integer modelId = wxMsgValidationcodeModel.getModelId(); | |||||
| //给发起人发送驳回消息 | //给发起人发送驳回消息 | ||||
| // Map<String,String> msgReplaceMap = new HashedMap(); | |||||
| // msgReplaceMap.put("s6",String.valueOf(code)); | |||||
| // WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| // wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| // wxMsgRecord.setModelType(EnumMsgModel.VALIDATION_CODE.getCode()); | |||||
| // wxMsgRecord.setReceiver(wxMsgValidationcode.getPhone()); | |||||
| // wxMsgRecord.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| // wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||||
| // mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| // return new ResultData(Result.SUCCESS,"发送成功"); | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.YES.getCode().toString(), modelId); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| String batchNo = jsonObjectResult.get("data").toString(); | |||||
| if (ret.equals("1")) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxMsgValidationcode.setId(idWorker.nextId()); | |||||
| long currentTime = System.currentTimeMillis() ; | |||||
| Date createtime=new Date(currentTime); | |||||
| Integer minutes = wxMsgValidationcodeModel.getMinutes(); | |||||
| currentTime +=minutes*60*1000; | |||||
| Date expiredate=new Date(currentTime); | |||||
| wxMsgValidationcode.setExpiretime(expiredate); | |||||
| wxMsgValidationcode.setCreatetime(createtime); | |||||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | |||||
| addMsgCallback(wxMsgValidationcode,batchNo); | |||||
| return new ResultData(Result.SUCCESS,"发送成功"); | |||||
| } | |||||
| return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); | |||||
| Map<String,String> msgReplaceMap = new HashedMap(); | |||||
| msgReplaceMap.put("s6",String.valueOf(code)); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.VALIDATION_CODE.getCode()); | |||||
| wxMsgRecord.setReceiver(wxMsgValidationcode.getPhone()); | |||||
| wxMsgRecord.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| return new ResultData(Result.SUCCESS,"发送成功"); | |||||
| // String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.YES.getCode().toString(), modelId); | |||||
| // JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| // String ret = jsonObjectResult.get("ret").toString(); | |||||
| // String batchNo = jsonObjectResult.get("data").toString(); | |||||
| // if (ret.equals("1")) { | |||||
| // final IdWorker idWorker = IdWorker.get(); | |||||
| // wxMsgValidationcode.setId(idWorker.nextId()); | |||||
| // long currentTime = System.currentTimeMillis() ; | |||||
| // Date createtime=new Date(currentTime); | |||||
| // Integer minutes = wxMsgValidationcodeModel.getMinutes(); | |||||
| // currentTime +=minutes*60*1000; | |||||
| // Date expiredate=new Date(currentTime); | |||||
| // wxMsgValidationcode.setExpiretime(expiredate); | |||||
| // wxMsgValidationcode.setCreatetime(createtime); | |||||
| // wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | |||||
| // addMsgCallback(wxMsgValidationcode,batchNo); | |||||
| // return new ResultData(Result.SUCCESS,"发送成功"); | |||||
| // } | |||||
| // return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); | |||||
| } | } | ||||
| @Override | @Override | ||||