| @@ -0,0 +1,41 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumMsgModelStatus { | |||||
| SUCCESS(1, "创建模板成功"), | |||||
| FAIL(0, "创建模板失败"), | |||||
| REPEAT(-6, "模板已存在"), | |||||
| NOT_FOUND(-5, "短信模板不存在"), | |||||
| SINATURE_CONTENT_ERROR(-4, "短信签名或内容错误"), | |||||
| PARAMETERS_ERROR(-3, "参数错误"), | |||||
| MSG_SEND_FAIL(-2, "发送短信失败"), | |||||
| INTERFACE_ERROR(-2, "接口请求错误") | |||||
| ; | |||||
| public static EnumMsgModelStatus getEnum(Integer code) { | |||||
| for (EnumMsgModelStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumMsgModelStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -9,6 +9,8 @@ import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxMsgConfig; | import com.iformall.domain.po.WxMsgConfig; | ||||
| import com.iformall.domain.po.WxMsgModel; | import com.iformall.domain.po.WxMsgModel; | ||||
| import com.iformall.enums.EnumMsgModelStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxMsgConfigMapper; | import com.iformall.mapper.WxMsgConfigMapper; | ||||
| import com.iformall.mapper.WxMsgModelMapper; | import com.iformall.mapper.WxMsgModelMapper; | ||||
| import com.iformall.service.WxMsgModelService; | import com.iformall.service.WxMsgModelService; | ||||
| @@ -99,14 +101,15 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| params.put("data", data); | params.put("data", data); | ||||
| params.put("sc", sc); | params.put("sc", sc); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException("创建模板失败"); | |||||
| logger.info("短信AES/RSA解密失败"); | |||||
| throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | |||||
| } | } | ||||
| String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | ||||
| String result = HttpUtil.doPost(requestUrl, params); | String result = HttpUtil.doPost(requestUrl, params); | ||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | JSONObject jsonObjectResult = JSONObject.parseObject(result); | ||||
| String ret = jsonObjectResult.get("ret").toString(); | String ret = jsonObjectResult.get("ret").toString(); | ||||
| if (ret.equals("1")) { | |||||
| if (ret.equals(EnumMsgModelStatus.SUCCESS.getCode().toString())) { | |||||
| if (wxMsgModel.getId() == null) { | if (wxMsgModel.getId() == null) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsgModel.setId(idWorker.nextId()); | wxMsgModel.setId(idWorker.nextId()); | ||||
| @@ -117,10 +120,13 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| wxMsgModel.setStatus(2);//审核中 | wxMsgModel.setStatus(2);//审核中 | ||||
| wxMsgModelMapper.insertSelective(wxMsgModel); | wxMsgModelMapper.insertSelective(wxMsgModel); | ||||
| } else { | } else { | ||||
| String data = jsonObjectResult.get("data").toString(); | |||||
| wxMsgModel.setModelId(Integer.valueOf(data)); | |||||
| wxMsgModel.setStatus(2);//审核中 | |||||
| wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | ||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "创建模板成功"); | return new ResultData(Result.SUCCESS, "创建模板成功"); | ||||
| } else if (ret.equals("-6")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.REPEAT.getCode().toString())) { | |||||
| if (wxMsgModel.getId() == null) { | if (wxMsgModel.getId() == null) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsgModel.setId(idWorker.nextId()); | wxMsgModel.setId(idWorker.nextId()); | ||||
| @@ -131,15 +137,15 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| } else { | } else { | ||||
| wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | ||||
| } | } | ||||
| } else if (ret.equals("-4")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.SINATURE_CONTENT_ERROR.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | ||||
| } else if (ret.equals("-5")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.NOT_FOUND.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_TEMPLATE_NOT_FOUND.getCode(), "短信模板不存在"); | return new ResultData(ErrorCode.MSG_TEMPLATE_NOT_FOUND.getCode(), "短信模板不存在"); | ||||
| } else if (ret.equals("-3")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.PARAMETERS_ERROR.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_REQUEST_PARAMS_ERROR.getCode(), "参数错误"); | return new ResultData(ErrorCode.MSG_REQUEST_PARAMS_ERROR.getCode(), "参数错误"); | ||||
| } else if (ret.equals("-2")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.MSG_SEND_FAIL.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "发送短信失败"); | return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "发送短信失败"); | ||||
| } else if (ret.equals("-1")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.INTERFACE_ERROR.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(), "接口请求错误"); | return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(), "接口请求错误"); | ||||
| } | } | ||||
| return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | ||||
| @@ -11,8 +11,11 @@ import com.iformall.domain.po.WxCUserBasicInfo; | |||||
| import com.iformall.domain.po.WxMsg; | import com.iformall.domain.po.WxMsg; | ||||
| import com.iformall.domain.po.WxMsgCallback; | import com.iformall.domain.po.WxMsgCallback; | ||||
| import com.iformall.domain.po.WxMsgConfig; | import com.iformall.domain.po.WxMsgConfig; | ||||
| import com.iformall.enums.EnumMsgSend; | |||||
| import com.iformall.enums.EnumMsgSendSetTime; | |||||
| import com.iformall.enums.EnumMsgSendStatus; | import com.iformall.enums.EnumMsgSendStatus; | ||||
| import com.iformall.enums.EnumMsgStatus; | import com.iformall.enums.EnumMsgStatus; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxCUserBasicInfoMapper; | import com.iformall.mapper.WxCUserBasicInfoMapper; | ||||
| import com.iformall.mapper.WxMsgCallbackMapper; | import com.iformall.mapper.WxMsgCallbackMapper; | ||||
| import com.iformall.mapper.WxMsgConfigMapper; | import com.iformall.mapper.WxMsgConfigMapper; | ||||
| @@ -89,7 +92,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| //新增记录 | //新增记录 | ||||
| if (wxMsg.getId() == null) { | if (wxMsg.getId() == null) { | ||||
| //草稿 | //草稿 | ||||
| if (wxMsg.getStatus() == 2) { | |||||
| if (wxMsg.getStatus().equals(EnumMsgStatus.MSG_STATUS_DRAFT.getCode())) { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsg.setId(idWorker.nextId()); | wxMsg.setId(idWorker.nextId()); | ||||
| wxMsg.setCreatetime(new Date()); | wxMsg.setCreatetime(new Date()); | ||||
| @@ -127,7 +130,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| wxMsg.setPhones(sb.deleteCharAt(sb.length()-1).toString()); | wxMsg.setPhones(sb.deleteCharAt(sb.length()-1).toString()); | ||||
| //是否立即发送 | //是否立即发送 | ||||
| if (wxMsg.getIsright() == 1) { | |||||
| if (wxMsg.getIsright().equals(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode())) { | |||||
| wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | ||||
| wxMsg.setSendtime(DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss")); | wxMsg.setSendtime(DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss")); | ||||
| return sendmsg(wxMsg); | return sendmsg(wxMsg); | ||||
| @@ -143,7 +146,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| } else { | } else { | ||||
| //草稿 | //草稿 | ||||
| if (wxMsg.getStatus() == 2) { | |||||
| if (wxMsg.getStatus().equals(EnumMsgStatus.MSG_STATUS_DRAFT.getCode())) { | |||||
| wxMsgMapper.updateByPrimaryKeySelective(wxMsg); | wxMsgMapper.updateByPrimaryKeySelective(wxMsg); | ||||
| return new ResultData(Result.SUCCESS, "已保存到草稿箱"); | return new ResultData(Result.SUCCESS, "已保存到草稿箱"); | ||||
| } | } | ||||
| @@ -177,7 +180,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| wxMsg.setPhones(sb.deleteCharAt(sb.length()-1).toString()); | wxMsg.setPhones(sb.deleteCharAt(sb.length()-1).toString()); | ||||
| //是否立即发送 | //是否立即发送 | ||||
| if (wxMsg.getIsright() == 1) { | |||||
| if (wxMsg.getIsright().equals(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode())) { | |||||
| wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | ||||
| return sendmsg(wxMsg); | return sendmsg(wxMsg); | ||||
| } else { | } else { | ||||
| @@ -272,7 +275,8 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| params.put("data", data); | params.put("data", data); | ||||
| params.put("sc", sc); | params.put("sc", sc); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException("发送短信失败"); | |||||
| logger.info("短信AES/RSA解密失败"); | |||||
| throw new MallinkException(ErrorCode.MSG_SEND_ERROR); | |||||
| } | } | ||||
| String requestUrl = "https://webapp.wiwide.com/apisms/send"; | String requestUrl = "https://webapp.wiwide.com/apisms/send"; | ||||
| @@ -280,7 +284,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | JSONObject jsonObjectResult = JSONObject.parseObject(result); | ||||
| String ret = jsonObjectResult.get("ret").toString(); | String ret = jsonObjectResult.get("ret").toString(); | ||||
| String batchNo = jsonObjectResult.get("data").toString(); | String batchNo = jsonObjectResult.get("data").toString(); | ||||
| if (ret.equals("1")) { | |||||
| if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | |||||
| wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode()); | wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode()); | ||||
| } else { | } else { | ||||
| wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode()); | wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode()); | ||||
| @@ -297,7 +301,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| } | } | ||||
| logger.info("发送短信结束..."); | logger.info("发送短信结束..."); | ||||
| if (ret.equals("1")) { | |||||
| if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | |||||
| addMsgCallback(wxMsg,batchNo); | addMsgCallback(wxMsg,batchNo); | ||||
| return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态",id); | return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态",id); | ||||
| } else { | } else { | ||||
| @@ -9,6 +9,8 @@ import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxMsgConfig; | import com.iformall.domain.po.WxMsgConfig; | ||||
| import com.iformall.domain.po.WxMsgValidationcodeModel; | import com.iformall.domain.po.WxMsgValidationcodeModel; | ||||
| import com.iformall.enums.EnumMsgModelStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxMsgConfigMapper; | import com.iformall.mapper.WxMsgConfigMapper; | ||||
| import com.iformall.mapper.WxMsgValidationcodeModelMapper; | import com.iformall.mapper.WxMsgValidationcodeModelMapper; | ||||
| import com.iformall.service.WxMsgValidationcodeModelService; | import com.iformall.service.WxMsgValidationcodeModelService; | ||||
| @@ -103,14 +105,15 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||||
| params.put("data", data); | params.put("data", data); | ||||
| params.put("sc", sc); | params.put("sc", sc); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException("创建模板失败"); | |||||
| logger.info("短信AES/RSA解密失败"); | |||||
| throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | |||||
| } | } | ||||
| String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | ||||
| String result = HttpUtil.doPost(requestUrl, params); | String result = HttpUtil.doPost(requestUrl, params); | ||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | JSONObject jsonObjectResult = JSONObject.parseObject(result); | ||||
| String ret = jsonObjectResult.get("ret").toString(); | String ret = jsonObjectResult.get("ret").toString(); | ||||
| if (ret.equals("1")) { | |||||
| if (ret.equals(EnumMsgModelStatus.SUCCESS.getCode().toString())) { | |||||
| if (wxMsgModel.getId() == null) { | if (wxMsgModel.getId() == null) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsgModel.setId(idWorker.nextId()); | wxMsgModel.setId(idWorker.nextId()); | ||||
| @@ -121,10 +124,13 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||||
| wxMsgModel.setStatus(2);//审核中 | wxMsgModel.setStatus(2);//审核中 | ||||
| wxMsgValidationcodeModelMapper.insertSelective(wxMsgModel); | wxMsgValidationcodeModelMapper.insertSelective(wxMsgModel); | ||||
| } else { | } else { | ||||
| String data = jsonObjectResult.get("data").toString(); | |||||
| wxMsgModel.setModelId(Integer.valueOf(data)); | |||||
| wxMsgModel.setStatus(2);//审核中 | |||||
| wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | ||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "创建模板成功"); | return new ResultData(Result.SUCCESS, "创建模板成功"); | ||||
| }else if(ret.equals("-6")){ | |||||
| } else if (ret.equals(EnumMsgModelStatus.REPEAT.getCode().toString())) { | |||||
| if (wxMsgModel.getId() == null) { | if (wxMsgModel.getId() == null) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsgModel.setId(idWorker.nextId()); | wxMsgModel.setId(idWorker.nextId()); | ||||
| @@ -135,15 +141,15 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM | |||||
| } else { | } else { | ||||
| wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | ||||
| } | } | ||||
| }else if (ret.equals("-4")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.SINATURE_CONTENT_ERROR.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); | ||||
| }else if (ret.equals("-5")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.NOT_FOUND.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_TEMPLATE_NOT_FOUND.getCode(), "短信模板不存在"); | return new ResultData(ErrorCode.MSG_TEMPLATE_NOT_FOUND.getCode(), "短信模板不存在"); | ||||
| }else if (ret.equals("-3")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.PARAMETERS_ERROR.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_REQUEST_PARAMS_ERROR.getCode(), "参数错误"); | return new ResultData(ErrorCode.MSG_REQUEST_PARAMS_ERROR.getCode(), "参数错误"); | ||||
| }else if (ret.equals("-2")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.MSG_SEND_FAIL.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "发送短信失败"); | return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "发送短信失败"); | ||||
| }else if (ret.equals("-1")) { | |||||
| } else if (ret.equals(EnumMsgModelStatus.INTERFACE_ERROR.getCode().toString())) { | |||||
| return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(), "接口请求错误"); | return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(), "接口请求错误"); | ||||
| } | } | ||||
| return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); | ||||
| @@ -9,6 +9,7 @@ import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.enums.EnumMsgSendStatus; | import com.iformall.enums.EnumMsgSendStatus; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.WxMsgValidationcodeService; | import com.iformall.service.WxMsgValidationcodeService; | ||||
| import com.iformall.utils.AesUtil; | import com.iformall.utils.AesUtil; | ||||
| @@ -153,7 +154,8 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| params.put("data", data); | params.put("data", data); | ||||
| params.put("sc", sc); | params.put("sc", sc); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException("发送验证码失败"); | |||||
| logger.info("短信AES/RSA解密失败"); | |||||
| throw new MallinkException(ErrorCode.MSG_SEND_ERROR); | |||||
| } | } | ||||
| String requestUrl = "https://webapp.wiwide.com/apisms/send"; | String requestUrl = "https://webapp.wiwide.com/apisms/send"; | ||||