| @@ -1,8 +1,7 @@ | |||||
| package com.simple.config; | package com.simple.config; | ||||
| import java.util.LinkedHashMap; | |||||
| import java.util.Map; | |||||
| import com.simple.service.MallPermissionService; | |||||
| import com.simple.shiro.MyShiroRealm; | |||||
| import org.apache.shiro.authc.credential.HashedCredentialsMatcher; | import org.apache.shiro.authc.credential.HashedCredentialsMatcher; | ||||
| import org.apache.shiro.mgt.SecurityManager; | import org.apache.shiro.mgt.SecurityManager; | ||||
| import org.apache.shiro.spring.LifecycleBeanPostProcessor; | import org.apache.shiro.spring.LifecycleBeanPostProcessor; | ||||
| @@ -19,8 +18,8 @@ import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.context.annotation.Bean; | import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.Configuration; | import org.springframework.context.annotation.Configuration; | ||||
| import com.simple.service.MallPermissionService; | |||||
| import com.simple.shiro.MyShiroRealm; | |||||
| import java.util.LinkedHashMap; | |||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * Created by yangqj on 2017/4/23. | * Created by yangqj on 2017/4/23. | ||||
| @@ -109,6 +108,7 @@ public class ShiroConfig { | |||||
| filterChainDefinitionMap.put("/v2/**","anon"); | filterChainDefinitionMap.put("/v2/**","anon"); | ||||
| filterChainDefinitionMap.put("/swagger-resources/**","anon"); | filterChainDefinitionMap.put("/swagger-resources/**","anon"); | ||||
| filterChainDefinitionMap.put("/webjars/**","anon"); | filterChainDefinitionMap.put("/webjars/**","anon"); | ||||
| filterChainDefinitionMap.put("/wxMsgCallback/**","anon"); | |||||
| filterChainDefinitionMap.put("/**", "authc"); | filterChainDefinitionMap.put("/**", "authc"); | ||||
| // filterChainDefinitionMap.put("/**", "anon"); | // filterChainDefinitionMap.put("/**", "anon"); | ||||
| @@ -13,7 +13,12 @@ import com.simple.domain.po.WxMsgCallback; | |||||
| import com.simple.service.WxMsgCallbackService; | import com.simple.service.WxMsgCallbackService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxMsgCallback") | @RequestMapping("wxMsgCallback") | ||||
| @@ -65,7 +70,15 @@ public class WxMsgCallbackController extends BaseController | |||||
| public ResultData findById(Long id) { | public ResultData findById(Long id) { | ||||
| return new ResultData(Result.SUCCESS,"查询成功",wxMsgCallbackService.getById(id)); | return new ResultData(Result.SUCCESS,"查询成功",wxMsgCallbackService.getById(id)); | ||||
| } | } | ||||
| @RequestMapping(value = "/receivemsg/{bid}") | |||||
| public void receivemsg(@PathVariable String bid, @RequestParam Map<String,String> param) { | |||||
| //解析param数据插入数据库中 | |||||
| String item = param.get("item"); | |||||
| String sign = param.get("sign"); | |||||
| wxMsgCallbackService.saveOrUpdate(bid,item,sign); | |||||
| } | |||||
| } | } | ||||
| @@ -71,25 +71,19 @@ public class WxMsgController extends BaseController | |||||
| public void receivemsg(@PathVariable String bid,@RequestParam Map<String,String> param) { | public void receivemsg(@PathVariable String bid,@RequestParam Map<String,String> param) { | ||||
| //解析param数据插入数据库中 | //解析param数据插入数据库中 | ||||
| } | |||||
| @RequestMapping("/sendmsgbyexcel") | |||||
| public ResultData sendmsgbyexcel(@RequestParam("file") MultipartFile file,@RequestBody WxMsg wxMsg) throws Exception { | |||||
| @GetMapping("/sendmsgbyexcel") | |||||
| public ResultData sendmsgbyexcel(@RequestParam("file") MultipartFile file,@ModelAttribute WxMsg wxMsg) throws Exception { | |||||
| if (file.isEmpty()) { | if (file.isEmpty()) { | ||||
| return new ResultData(Result.SUCCESS,"上传文件不能为空"); | return new ResultData(Result.SUCCESS,"上传文件不能为空"); | ||||
| } | } | ||||
| //wxMsgService.sendmsgbyexcel(file,wxMsg); | |||||
| return new ResultData(); | |||||
| return wxMsgService.sendmsgbyexcel(file,wxMsg); | |||||
| } | } | ||||
| @RequestMapping("/sendmsgbylabel") | |||||
| public ResultData sendmsgbylabel(@RequestBody WxMsg wxMsg) throws Exception { | |||||
| @GetMapping("/sendmsgbylabel") | |||||
| public ResultData sendmsgbylabel(@ModelAttribute WxMsg wxMsg) throws Exception { | |||||
| //wxMsgService.sendmsgbylabel(wxMsg); | |||||
| return new ResultData(); | |||||
| return wxMsgService.sendmsgbylabel(wxMsg); | |||||
| } | } | ||||
| @@ -37,15 +37,14 @@ public class WxMsgModelController extends BaseController | |||||
| public ResultData add(@RequestBody WxMsgModel wxMsgModel) { | public ResultData add(@RequestBody WxMsgModel wxMsgModel) { | ||||
| //Assert.notNull(wxMsgModel.getName(), "角色名不能为空"); | //Assert.notNull(wxMsgModel.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| //return wxMsgModelService.saveOrUpdate(wxMsgModel); | |||||
| return new ResultData(); | |||||
| return wxMsgModelService.saveOrUpdate(wxMsgModel); | |||||
| } | } | ||||
| @ApiOperation("根据id更新接口") | @ApiOperation("根据id更新接口") | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxMsgModel wxMsgModel) { | public ResultData update(@RequestBody WxMsgModel wxMsgModel) { | ||||
| wxMsgModelService.saveOrUpdate(wxMsgModel); | |||||
| return new ResultData(); | |||||
| return wxMsgModelService.saveOrUpdate(wxMsgModel); | |||||
| } | } | ||||
| @ApiOperation("根据id删除接口") | @ApiOperation("根据id删除接口") | ||||
| @@ -36,13 +36,8 @@ public interface WxMsgCallbackService { | |||||
| * | * | ||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | |||||
| void deleteById(String id); | |||||
| void saveOrUpdate(String bid, String item, String sign); | |||||
| } | } | ||||
| @@ -2,6 +2,7 @@ package com.simple.service; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMsgModel; | import com.simple.domain.po.WxMsgModel; | ||||
| public interface WxMsgModelService { | public interface WxMsgModelService { | ||||
| @@ -29,7 +30,7 @@ public interface WxMsgModelService { | |||||
| * | * | ||||
| * @param record | * @param record | ||||
| */ | */ | ||||
| void saveOrUpdate(WxMsgModel record); | |||||
| ResultData saveOrUpdate(WxMsgModel record); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -2,7 +2,9 @@ package com.simple.service; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMsg; | import com.simple.domain.po.WxMsg; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| public interface WxMsgService { | public interface WxMsgService { | ||||
| @@ -29,7 +31,7 @@ public interface WxMsgService { | |||||
| * | * | ||||
| * @param record | * @param record | ||||
| */ | */ | ||||
| void saveOrUpdate(WxMsg record); | |||||
| ResultData saveOrUpdate(WxMsg record); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -37,12 +39,9 @@ public interface WxMsgService { | |||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| ResultData sendmsgbyexcel(MultipartFile file, WxMsg wxMsg); | |||||
| ResultData sendmsgbylabel(WxMsg wxMsg); | |||||
| } | } | ||||
| @@ -1,14 +1,19 @@ | |||||
| package com.simple.service.impl; | package com.simple.service.impl; | ||||
| import java.util.*; | |||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxMsgCallback; | import com.simple.domain.po.WxMsgCallback; | ||||
| import com.simple.domain.po.WxMsgConfig; | |||||
| import com.simple.mapper.WxMsgCallbackMapper; | import com.simple.mapper.WxMsgCallbackMapper; | ||||
| import com.simple.mapper.WxMsgConfigMapper; | |||||
| import com.simple.service.WxMsgCallbackService; | import com.simple.service.WxMsgCallbackService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.simple.common.IdWorker; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import java.util.UUID; | |||||
| @Service | @Service | ||||
| public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | ||||
| @@ -16,6 +21,8 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| @Autowired | @Autowired | ||||
| WxMsgCallbackMapper wxMsgCallbackMapper; | WxMsgCallbackMapper wxMsgCallbackMapper; | ||||
| @Autowired | |||||
| WxMsgConfigMapper wxMsgConfigMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMsgCallback> listAsPage(WxMsgCallback record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMsgCallback> listAsPage(WxMsgCallback record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -30,9 +37,7 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxMsgCallback record) { | public void saveOrUpdate(WxMsgCallback record) { | ||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| IdWorker idWorker = new IdWorker(0, 0); | |||||
| record.setId(idWorker.nextId()); | |||||
| record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| wxMsgCallbackMapper.insertSelective(record); | wxMsgCallbackMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| wxMsgCallbackMapper.updateByPrimaryKeySelective(record); | wxMsgCallbackMapper.updateByPrimaryKeySelective(record); | ||||
| @@ -43,12 +48,26 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxMsgCallbackMapper.deleteByPrimaryKey(id); | wxMsgCallbackMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public void saveOrUpdate(String bid, String item, String sign) { | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setBid(bid); | |||||
| String tenantid=null; | |||||
| List<WxMsgConfig> list = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if(list.size()==1){ | |||||
| tenantid=list.get(0).getTenantId(); | |||||
| } | |||||
| List<WxMsgCallback> wxMsgCallbacks = JSONArray.parseArray(item, WxMsgCallback.class); | |||||
| for(WxMsgCallback wxMsgCallback:wxMsgCallbacks){ | |||||
| wxMsgCallback.setTenantId(tenantid); | |||||
| wxMsgCallback.setSign(sign); | |||||
| wxMsgCallback.setCreatetime(new Date()); | |||||
| wxMsgCallbackMapper.insertSelective(wxMsgCallback); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -1,14 +1,24 @@ | |||||
| package com.simple.service.impl; | package com.simple.service.impl; | ||||
| import java.util.*; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.IdWorker; | |||||
| import com.simple.common.Result; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMsgConfig; | |||||
| import com.simple.domain.po.WxMsgModel; | import com.simple.domain.po.WxMsgModel; | ||||
| import com.simple.mapper.WxMsgConfigMapper; | |||||
| import com.simple.mapper.WxMsgModelMapper; | import com.simple.mapper.WxMsgModelMapper; | ||||
| import com.simple.service.WxMsgModelService; | import com.simple.service.WxMsgModelService; | ||||
| import com.simple.utils.AesUtil; | |||||
| import com.simple.utils.HMACSHA256; | |||||
| import com.simple.utils.HttpUtil; | |||||
| import com.simple.utils.RsaUtil; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.simple.common.IdWorker; | |||||
| import java.util.*; | |||||
| @Service | @Service | ||||
| public class WxMsgModelServiceImpl implements WxMsgModelService { | public class WxMsgModelServiceImpl implements WxMsgModelService { | ||||
| @@ -16,6 +26,8 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| @Autowired | @Autowired | ||||
| WxMsgModelMapper wxMsgModelMapper; | WxMsgModelMapper wxMsgModelMapper; | ||||
| @Autowired | |||||
| WxMsgConfigMapper wxMsgConfigMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMsgModel> listAsPage(WxMsgModel record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMsgModel> listAsPage(WxMsgModel record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -28,15 +40,78 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxMsgModel record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| IdWorker idWorker = new IdWorker(0, 0); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxMsgModelMapper.insertSelective(record); | |||||
| } else { | |||||
| wxMsgModelMapper.updateByPrimaryKeySelective(record); | |||||
| public ResultData saveOrUpdate(WxMsgModel wxMsgModel) { | |||||
| //从短信配置中查询密钥 bid 等信息 | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId("1"); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if(wxMsgConfigs.size()==0)return new ResultData(Result.SUCCESS, "您还未接入短信运营商,请联系平台管理员"); | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String signature = wxMsgModel.getSignature(); | |||||
| String content = wxMsgModel.getContent(); | |||||
| //查看用户最新数据是否存在 | |||||
| List<WxMsgModel> wxMsgModels = wxMsgModelMapper.findList(wxMsgModel); | |||||
| if (wxMsgModel.getId() == null && wxMsgModels.size() == 1) { | |||||
| return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); | |||||
| } | |||||
| if (wxMsgModel.getId() != null && wxMsgModels.size() == 1) { | |||||
| WxMsgModel wxmsgmodel = wxMsgModels.get(0); | |||||
| if(wxmsgmodel.getContent().equals(wxMsgModel.getContent()) && wxmsgmodel.getSignature().equals(wxMsgModel.getSignature())) { | |||||
| return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); | |||||
| } | |||||
| } | |||||
| //请求api数据排序 | |||||
| TreeMap<String, String> message = new TreeMap<>(); | |||||
| message.put("bid", bid); | |||||
| message.put("signature", signature); | |||||
| message.put("content", content); | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| Set<Map.Entry<String, String>> entries = message.entrySet(); | |||||
| for (Map.Entry<String, String> entry : entries) { | |||||
| sb.append(entry.getKey()).append("=").append(entry.getValue()); | |||||
| } | |||||
| sb.append("&secret=").append(secret); | |||||
| String sign = HMACSHA256.sha256_HMAC(sb.toString(), secret); | |||||
| message.put("sign", sign.toUpperCase()); | |||||
| String str32 = "198b02e8fd704e96198b02e8fd704e96"; | |||||
| String iv = "198b02e8fd704e96"; | |||||
| Map<String, String> params = new HashMap<>(); | |||||
| params.put("iv", iv); | |||||
| params.put("bid", bid); | |||||
| try { | |||||
| String data = AesUtil.AESEncode(str32, JSONObject.toJSONString(message), iv); | |||||
| String sc = RsaUtil.RSAEncode(str32.getBytes(), wxMsgConfig.getPublickey()); | |||||
| params.put("data", data); | |||||
| params.put("sc", sc); | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | |||||
| String result = HttpUtil.doPost(requestUrl, params); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| if (ret.equals("1") || ret.equals("-6")) { | |||||
| if (wxMsgModel.getId() == null) { | |||||
| IdWorker idWorker = new IdWorker(0, 0); | |||||
| wxMsgModel.setId(idWorker.nextId()); | |||||
| wxMsgModel.setCreatetime(new Date()); | |||||
| wxMsgModelMapper.insertSelective(wxMsgModel); | |||||
| } else { | |||||
| wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "创建模板成功"); | |||||
| }else if (ret == "-4") { | |||||
| return new ResultData(Result.SUCCESS, "短信签名或内容错误"); | |||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "创建模板失败"); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -1,14 +1,25 @@ | |||||
| package com.simple.service.impl; | package com.simple.service.impl; | ||||
| import java.util.*; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.IdWorker; | |||||
| import com.simple.common.Result; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMsg; | import com.simple.domain.po.WxMsg; | ||||
| import com.simple.domain.po.WxMsgConfig; | |||||
| import com.simple.mapper.WxMsgConfigMapper; | |||||
| import com.simple.mapper.WxMsgMapper; | import com.simple.mapper.WxMsgMapper; | ||||
| import com.simple.service.WxMsgService; | import com.simple.service.WxMsgService; | ||||
| import com.simple.utils.AesUtil; | |||||
| import com.simple.utils.HMACSHA256; | |||||
| import com.simple.utils.HttpUtil; | |||||
| import com.simple.utils.RsaUtil; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.simple.common.IdWorker; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import java.util.*; | |||||
| @Service | @Service | ||||
| public class WxMsgServiceImpl implements WxMsgService { | public class WxMsgServiceImpl implements WxMsgService { | ||||
| @@ -16,6 +27,8 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| @Autowired | @Autowired | ||||
| WxMsgMapper wxMsgMapper; | WxMsgMapper wxMsgMapper; | ||||
| @Autowired | |||||
| WxMsgConfigMapper wxMsgConfigMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMsg> listAsPage(WxMsg record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMsg> listAsPage(WxMsg record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -28,27 +41,90 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxMsg record) { | |||||
| if (record.getId() == null) { | |||||
| public ResultData saveOrUpdate(WxMsg record) { | |||||
| //从短信配置中查询密钥 bid 等信息 | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId("1"); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if(wxMsgConfigs.size()==0)return new ResultData(Result.SUCCESS, "您还未接入短信运营商,请联系平台管理员"); | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| String phone="13810135185"; | |||||
| String signature="123"; | |||||
| String msg="测试"; | |||||
| String notifyUrl="http://8d8fe61b.ngrok.io/wxMsgCallback/receivemsg/"+bid; | |||||
| TreeMap<String, String> message = new TreeMap<>(); | |||||
| message.put("bid",bid); | |||||
| message.put("phone",phone); | |||||
| message.put("signature",signature); | |||||
| message.put("msg",msg); | |||||
| message.put("notify_url",notifyUrl); | |||||
| StringBuilder sb=new StringBuilder(); | |||||
| Set<Map.Entry<String, String>> entries = message.entrySet(); | |||||
| for(Map.Entry<String, String> entry:entries){ | |||||
| sb.append(entry.getKey()).append("=").append(entry.getValue()); | |||||
| } | |||||
| sb.append("&secret=").append(secret); | |||||
| String sign = HMACSHA256.sha256_HMAC(sb.toString(), secret); | |||||
| message.put("sign",sign.toUpperCase()); | |||||
| String str32="198b02e8fd704e96198b02e8fd704e96"; | |||||
| String iv="198b02e8fd704e96"; | |||||
| Map<String,String> params=new HashMap<>(); | |||||
| params.put("iv",iv); | |||||
| params.put("bid",bid); | |||||
| try { | |||||
| String data = AesUtil.AESEncode(str32, JSONObject.toJSONString(message), iv); | |||||
| String sc = RsaUtil.RSAEncode(str32.getBytes(),publickey); | |||||
| params.put("data",data); | |||||
| params.put("sc",sc); | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| String requestUrl="https://webapp.wiwide.com/apisms/send"; | |||||
| String result = HttpUtil.doPost(requestUrl, params); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret=jsonObjectResult.get("ret").toString(); | |||||
| if(ret.equals("1")){ | |||||
| System.out.println("发送成功"); | |||||
| }else{ | |||||
| System.out.println("发送失败"); | |||||
| } | |||||
| /* if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | ||||
| IdWorker idWorker = new IdWorker(0, 0); | IdWorker idWorker = new IdWorker(0, 0); | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| wxMsgMapper.insertSelective(record); | wxMsgMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| wxMsgMapper.updateByPrimaryKeySelective(record); | wxMsgMapper.updateByPrimaryKeySelective(record); | ||||
| } | |||||
| }*/ | |||||
| return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态"); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxMsgMapper.deleteByPrimaryKey(id); | wxMsgMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public ResultData sendmsgbyexcel(MultipartFile file, WxMsg wxMsg) { | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public ResultData sendmsgbylabel(WxMsg wxMsg) { | |||||
| return null; | |||||
| } | |||||
| } | } | ||||