SmsInfoVo.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. package com.xunmei.sms.vo;
  2. import com.dc.eai.data.CompositeData;
  3. import com.dc.eai.data.Field;
  4. import com.dc.eai.data.FieldAttr;
  5. import com.dc.eai.data.FieldType;
  6. import lombok.Data;
  7. import org.slf4j.Logger;
  8. import org.slf4j.LoggerFactory;
  9. /**
  10. * @author wubiyu[2024/03/18]
  11. */
  12. @Data
  13. public class SmsInfoVo {
  14. private static Logger logger = LoggerFactory.getLogger(SmsInfoVo.class);
  15. /**
  16. * 交易类型
  17. */
  18. private String tranType;
  19. /**
  20. * 机构号
  21. */
  22. private String branchId;
  23. /**
  24. * 消费者系统流水号
  25. */
  26. private String consumerSeqNo;
  27. /**
  28. * 客户号
  29. */
  30. private String custNo;
  31. /**
  32. * 客户姓名
  33. */
  34. private String custName;
  35. /**
  36. * 性别
  37. */
  38. private String sex;
  39. /**
  40. * 手机号
  41. */
  42. private String mobile;
  43. /**
  44. * 帐号
  45. */
  46. private String acctNo;
  47. /**
  48. * 发生日期 格式:yyyy-MM-dd
  49. */
  50. private String occurDate;
  51. /**
  52. * 发生时间:格式:Hh:mm:ss
  53. */
  54. private String occurTime;
  55. /**
  56. * 交易金额1
  57. */
  58. private String tranAmt1;
  59. /**
  60. * 交易金额1
  61. */
  62. private String tranAmt2;
  63. /**
  64. * 交易金额1
  65. */
  66. private String tranAmt3;
  67. /**
  68. * 支出/存入位1
  69. */
  70. private String payoutStoreBit1;
  71. /**
  72. * 支出/存入位2
  73. */
  74. private String payoutStoreBit2;
  75. /**
  76. * 支出/存入位1
  77. */
  78. private String payoutStoreBit3;
  79. /**
  80. * 交易摘要
  81. */
  82. private String tranRemark;
  83. /**
  84. * 帐户状态
  85. */
  86. private String acctStatus;
  87. /**
  88. * 渠道类型
  89. */
  90. private String channelType;
  91. /**
  92. * 备用1
  93. */
  94. private String bak1;
  95. /**
  96. * 备用2
  97. */
  98. private String bak2;
  99. /**
  100. * 备用3
  101. */
  102. private String bak3;
  103. public static CompositeData convertTo(SmsInfoVo source) {
  104. try {
  105. /***********************************************************************
  106. * *********构造请求数据,定义相关结构体*******
  107. **********************************************************************/
  108. CompositeData reqData = new CompositeData();
  109. CompositeData sysData = new CompositeData();
  110. CompositeData appData = new CompositeData();
  111. CompositeData body = new CompositeData();
  112. reqData.addStruct("SYS_HEAD", sysData);
  113. reqData.addStruct("APP_HEAD", appData);
  114. reqData.addStruct("BODY", body);
  115. /***********************************************************************
  116. * ********* 系统头 ******************
  117. **********************************************************************/
  118. if (source.getConsumerSeqNo() != null) {
  119. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 15, 0));
  120. field.setValue(source.getConsumerSeqNo());
  121. sysData.addField("CONSUMER_SEQ_NO", field);
  122. }
  123. /***********************************************************************
  124. * ********** 应用头 ***************
  125. **********************************************************************/
  126. if (source.getBranchId() != null) {
  127. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 9, 0));
  128. field.setValue(source.getBranchId());
  129. appData.addField("BRANCH_ID", field);
  130. }
  131. // 应用头其他需要上送的数据。。。
  132. /***********************************************************************
  133. * ************* 报文体 ************ 服务代码为11003000002,场景为07定义的输入数据
  134. **********************************************************************/
  135. if (source.getTranType() != null) {
  136. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 6, 0));
  137. field.setValue(source.getTranType());
  138. body.addField("TRAN_TYPE", field);
  139. }
  140. if (source.getCustNo() != null) {
  141. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 22, 0));
  142. field.setValue(source.getCustNo());
  143. body.addField("CUST_NO", field);
  144. }
  145. if (source.getCustName() != null) {
  146. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 50, 0));
  147. field.setValue(source.getCustNo());
  148. body.addField("CUST_NAME", field);
  149. }
  150. if (source.getSex() != null) {
  151. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 2, 0));
  152. field.setValue(source.getSex());
  153. body.addField("SEX", field);
  154. }
  155. if (source.getMobile() != null) {
  156. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 20, 0));
  157. field.setValue(source.getMobile());
  158. body.addField("MOBILE", field);
  159. }
  160. if (source.getAcctNo() != null) {
  161. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 32, 0));
  162. field.setValue(source.getAcctNo());
  163. body.addField("ACCT_NO", field);
  164. }
  165. if (source.getOccurDate() != null) {
  166. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 10, 0));
  167. field.setValue(source.getOccurDate());
  168. body.addField("OCCUR_DATE", field);
  169. }
  170. if (source.getOccurTime() != null) {
  171. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 10, 0));
  172. field.setValue(source.getOccurTime());
  173. body.addField("OCCUR_TIME", field);
  174. }
  175. if (source.getTranAmt1() != null) {
  176. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 17, 0));
  177. field.setValue(source.getTranAmt1());
  178. body.addField("TRAN_AMT1", field);
  179. }
  180. if (source.getTranAmt2() != null) {
  181. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 17, 0));
  182. field.setValue(source.getTranAmt2());
  183. body.addField("TRAN_AMT2", field);
  184. }
  185. if (source.getTranAmt3() != null) {
  186. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 17, 0));
  187. field.setValue(source.getTranAmt3());
  188. body.addField("TRAN_AMT3", field);
  189. }
  190. if (source.getPayoutStoreBit1() != null) {
  191. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 1, 0));
  192. field.setValue(source.getPayoutStoreBit1());
  193. body.addField("PAYOUT_STORE_BIT1", field);
  194. }
  195. if (source.getPayoutStoreBit2() != null) {
  196. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 1, 0));
  197. field.setValue(source.getPayoutStoreBit2());
  198. body.addField("PAYOUT_STORE_BIT2", field);
  199. }
  200. if (source.getPayoutStoreBit3() != null) {
  201. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 1, 0));
  202. field.setValue(source.getPayoutStoreBit3());
  203. body.addField("PAYOUT_STORE_BIT3", field);
  204. }
  205. if (source.getTranRemark() != null) {
  206. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 30, 0));
  207. field.setValue(source.getTranRemark());
  208. body.addField("TRAN_REMARK", field);
  209. }
  210. if (source.getAcctStatus() != null) {
  211. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 100, 0));
  212. field.setValue(source.getAcctStatus());
  213. body.addField("ACCT_STATUS", field);
  214. }
  215. if (source.getChannelType() != null) {
  216. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 2, 0));
  217. field.setValue(source.getChannelType());
  218. body.addField("CHANNEL_TYPE", field);
  219. }
  220. if (source.getBak1() != null) {
  221. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 50, 0));
  222. field.setValue(source.getBak1());
  223. body.addField("BAK1", field);
  224. }
  225. if (source.getBak2() != null) {
  226. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 50, 0));
  227. field.setValue(source.getBak2());
  228. body.addField("BAK2", field);
  229. }
  230. if (source.getBak3() != null) {
  231. Field field = new Field(new FieldAttr(FieldType.FIELD_STRING, 50, 0));
  232. field.setValue(source.getBak3());
  233. body.addField("BAK3", field);
  234. }
  235. return reqData;
  236. } catch (Exception ex) {
  237. logger.error("【发送短信】转换数据异常", ex);
  238. return null;
  239. }
  240. }
  241. }