d4089100e4b3a082c365fda22a53f0bce5f7131e.svn-base 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.chinacreator.process.util;
  2. import com.chinacreator.common.support.util.SpringContextUtil;
  3. import com.chinacreator.common.util.URLUtil;
  4. import com.chinacreator.process.bean.VacOrder;
  5. import com.chinacreator.process.dao.DictionaryDao;
  6. import com.google.gson.Gson;
  7. import com.google.gson.GsonBuilder;
  8. /**
  9. * <p>Description: 调用vac工具类</p>
  10. * <p>Copyright: Copyright (c) 2013</p>
  11. * <p>Company: Chinacreator(长沙科创集成)</p>
  12. * <p>creationTime: 2013-4-12</p>
  13. * @author
  14. * @version 1.0
  15. */
  16. public class VacUtil {
  17. /**
  18. * 调用vac接口,vac接口调用地址,由字典表配置
  19. * @param userId 手机号码
  20. * @param spCode sp编码
  21. * @param productId 产品标识
  22. * @param type 1表示包月订购,2表示退订,0:单次订购
  23. * @return
  24. */
  25. public static String vac(String userId,String spCode, String productId,String type) throws Exception{
  26. DictionaryDao dictionaryDao = SpringUtils.getBean(DictionaryDao.class);
  27. String vacUrl = dictionaryDao.getValue("vacUrl");
  28. if(vacUrl.indexOf("?") == -1) {
  29. vacUrl += "?";
  30. } else {
  31. vacUrl += "&";
  32. }
  33. vacUrl += "usermob=" + userId;
  34. vacUrl += "&productid=" + productId;
  35. vacUrl += "&vacid=" + productId;
  36. vacUrl += "&spcode=" + spCode;
  37. vacUrl += "&ordertype=" + type;
  38. vacUrl += "&servicetype=80";
  39. return URLUtil.get(vacUrl);
  40. }
  41. public static VacOrder query(String userid) throws Exception {
  42. DictionaryDao dictionaryDao = SpringContextUtil.getBean(DictionaryDao.class);
  43. String url = dictionaryDao.getValue("vacQuery");
  44. if(url.indexOf("?") == -1) {
  45. url += "?";
  46. } else {
  47. url += "&";
  48. }
  49. url += "userId=" + userid;
  50. String result = URLUtil.get(url);
  51. Gson gson = new GsonBuilder().serializeNulls().create();
  52. VacOrder vacOrder = gson.fromJson(result, VacOrder.class);
  53. return vacOrder;
  54. }
  55. }