| | |
| | | private final static String SING_NAME = "橙桔天下科技"; |
| | | |
| | | |
| | | public void sendSms(int type, String phone, Orders orders, String receiveName, String businessPhone, BigDecimal distance, IdentityInfo identityInfo,CategoryMapper categoryMapper){ |
| | | Constants.smsContent smsContent = Constants.smsContent.getSmsContent(type); |
| | | Map<String,Object> tempParam = new HashMap<>(); |
| | | if(smsContent.getName().indexOf("time1")>=Constants.ZERO){ |
| | | tempParam.put("time1", DateUtil.formatDate(orders.getStartDate(),"MM-dd")); |
| | | } |
| | | if(smsContent.getName().indexOf("time2")>=Constants.ZERO){ |
| | | tempParam.put("time2", DateUtil.formatDate(orders.getEndDate(),"MM-dd")); |
| | | } |
| | | if(smsContent.getName().indexOf("name")>=Constants.ZERO){ |
| | | tempParam.put("name", receiveName); |
| | | } |
| | | if(smsContent.getName().indexOf("money")>=Constants.ZERO){ |
| | | tempParam.put("money", new BigDecimal(orders.getReceiveAccount().toString()).divide(new BigDecimal("100"),2,BigDecimal.ROUND_HALF_UP)+"元"); |
| | | } |
| | | if(smsContent.getName().indexOf("distance")>=Constants.ZERO){ |
| | | tempParam.put("distance", distance +"km"); |
| | | } |
| | | //认证短信 特殊处理 |
| | | if(Constants.equalsInteger(smsContent.getKey(),Constants.smsContent.authentication.getKey())){ |
| | | //认证类型 |
| | | if(smsContent.getName().indexOf("authentication")>=Constants.ZERO){ |
| | | tempParam.put("authentication", Constants.equalsInteger(identityInfo.getAuthType(),Constants.ZERO)?"个人":identityInfo.getCompanyName()); |
| | | public void businessSendSms(int type, String phone, Orders orders, BigDecimal distance, |
| | | IdentityInfo identityInfo,CategoryMapper categoryMapper){ |
| | | try{ |
| | | Constants.smsContent smsContent = Constants.smsContent.getSmsContent(type); |
| | | Map<String,Object> tempParam = new HashMap<>(); |
| | | if(smsContent.getName().indexOf("time1")>=Constants.ZERO){ |
| | | tempParam.put("time1", DateUtil.formatDate(orders.getStartDate(),"MM-dd")); |
| | | } |
| | | if(smsContent.getName().indexOf("order")>=Constants.ZERO){ |
| | | tempParam.put("order", Constants.orderType.getName(identityInfo.getType()).replace("单","")); |
| | | if(smsContent.getName().indexOf("time2")>=Constants.ZERO){ |
| | | tempParam.put("time2", DateUtil.formatDate(orders.getEndDate(),"MM-dd")); |
| | | } |
| | | if(smsContent.getName().indexOf("status")>=Constants.ZERO){ |
| | | tempParam.put("status", Constants.equalsInteger(identityInfo.getAuditStatus(),Constants.TWO)?"已通过":"未通过"); |
| | | if(smsContent.getName().indexOf("money")>=Constants.ZERO){ |
| | | tempParam.put("money", new BigDecimal(orders.getReceiveAccount().toString()).divide(new BigDecimal("100"),2,BigDecimal.ROUND_HALF_UP)+"元"); |
| | | } |
| | | }else{ |
| | | if(smsContent.getName().indexOf("order")>=Constants.ZERO){ |
| | | String order = ""; |
| | | //查询订单的类型信息 |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | order = Constants.workType.getName(orders.getWorkType()); |
| | | Category category = categoryMapper.selectById(orders.getCategoryId()); |
| | | if(Objects.nonNull(category)){ |
| | | order = category.getName() + order; |
| | | } |
| | | }else if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | order = "运输"; |
| | | Category category = categoryMapper.selectById(orders.getTransportTypeId()); |
| | | if(Objects.nonNull(category)){ |
| | | order = category.getName() + order; |
| | | } |
| | | }else{ |
| | | List<CateringDTO> cateringDTOList = JSONArray.parseArray(orders.getWayInfo(),CateringDTO.class); |
| | | if(CollectionUtils.isNotEmpty(cateringDTOList)){ |
| | | for (CateringDTO cateringDTO:cateringDTOList) { |
| | | if(StringUtils.isBlank(order)){ |
| | | order = cateringDTO.getName(); |
| | | }else{ |
| | | order = order + "/" +cateringDTO.getName(); |
| | | if(smsContent.getName().indexOf("distance")>=Constants.ZERO){ |
| | | tempParam.put("distance", distance +"km"); |
| | | } |
| | | //认证短信 特殊处理 |
| | | if(Constants.equalsInteger(smsContent.getKey(),Constants.smsContent.authentication.getKey())){ |
| | | //认证类型 |
| | | if(smsContent.getName().indexOf("authentication")>=Constants.ZERO){ |
| | | tempParam.put("authentication", Constants.equalsInteger(identityInfo.getAuthType(),Constants.ZERO)?"个人":identityInfo.getCompanyName()); |
| | | } |
| | | if(smsContent.getName().indexOf("order")>=Constants.ZERO){ |
| | | tempParam.put("oeder", Constants.orderType.getName(identityInfo.getType()).replace("单","")); |
| | | } |
| | | if(smsContent.getName().indexOf("status")>=Constants.ZERO){ |
| | | tempParam.put("status", Constants.equalsInteger(identityInfo.getAuditStatus(),Constants.TWO)?"已通过":"未通过"); |
| | | } |
| | | }else{ |
| | | if(smsContent.getName().indexOf("order")>=Constants.ZERO){ |
| | | String order = ""; |
| | | //查询订单的类型信息 |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | order = Constants.workType.getName(orders.getWorkType()); |
| | | Category category = categoryMapper.selectById(orders.getCategoryId()); |
| | | if(Objects.nonNull(category)){ |
| | | order = category.getName() + order; |
| | | } |
| | | }else if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | order = "运输"; |
| | | Category category = categoryMapper.selectById(orders.getTransportTypeId()); |
| | | if(Objects.nonNull(category)){ |
| | | order = category.getName() + order; |
| | | } |
| | | }else{ |
| | | List<CateringDTO> cateringDTOList = JSONArray.parseArray(orders.getWayInfo(),CateringDTO.class); |
| | | if(CollectionUtils.isNotEmpty(cateringDTOList)){ |
| | | for (CateringDTO cateringDTO:cateringDTOList) { |
| | | if(StringUtils.isBlank(order)){ |
| | | order = cateringDTO.getName(); |
| | | }else{ |
| | | order = order + "/" +cateringDTO.getName(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | tempParam.put("order",order); |
| | | } |
| | | tempParam.put("order",order); |
| | | } |
| | | if(smsContent.getName().indexOf("distance")>=Constants.ZERO){ |
| | | tempParam.put("distance", distance +"km"); |
| | | } |
| | | AliSmsService.sendSms(phone,smsContent.getCode(), JSONObject.toJSONString(tempParam)); |
| | | }catch (Exception e){ |
| | | log.error("短信发送失败~"); |
| | | } |
| | | |
| | | if(smsContent.getName().indexOf("authentication")>=Constants.ZERO){ |
| | | tempParam.put("distance", distance +"km"); |
| | | } |
| | | AliSmsService.sendSms(phone,smsContent.getCode(), JSONObject.toJSONString(tempParam)); |
| | | } |
| | | |
| | | |
| | |
| | | //请求失败这里会抛ClientException异常 |
| | | SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request); |
| | | if (sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) { |
| | | // logger.info(phone + "-" + templateCode + "-" + templateParam + " >>> " + JSON.toJSONString(sendSmsResponse)); |
| | | log.info("短信发送内容:"+phone + "-" + templateCode + "-" + templateParam + " >>> " + JSON.toJSONString(sendSmsResponse)); |
| | | return true; |
| | | } else { |
| | | // logger.error(phone + "-" + templateCode + "-" + templateParam + " >>> " + JSON.toJSONString(sendSmsResponse)); |
| | | log.error("短信发送内容:"+phone + "-" + templateCode + "-" + templateParam + " >>> " + JSON.toJSONString(sendSmsResponse)); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |