SelfCarInterServiceImpl.java 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. package com.jkcredit.invoice.credit.custInterface;
  2. import cn.com.taiji.sdk.model.comm.protocol.tts.trade.service.CardTradeModel;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.jkcredit.invoice.common.DataResult;
  6. import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
  7. import com.jkcredit.invoice.model.entity.customer.CustomerRec;
  8. import com.jkcredit.invoice.service.customer.CustomerRecService;
  9. import com.jkcredit.invoice.service.lowerService.SelfCarServiceL;
  10. import com.jkcredit.invoice.service.lowerService.vo.*;
  11. import com.jkcredit.invoice.util.DateUtil;
  12. import com.jkcredit.invoice.util.LogFileName;
  13. import com.jkcredit.invoice.util.LoggerUtil;
  14. import com.jkcredit.invoice.util.RespR;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.slf4j.Logger;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.stereotype.Service;
  19. import java.util.ArrayList;
  20. import java.util.List;
  21. @Service("selfCarInterService")
  22. public class SelfCarInterServiceImpl implements SelfCarInterService {
  23. Logger QUERY_LOG = LoggerUtil.logger(LogFileName.QUERY_LOG);
  24. @Autowired
  25. SelfCarServiceL selfCarService;
  26. @Autowired
  27. CustomerRecService customerRecMapper;
  28. /**
  29. * 自有车 用户卡列表查询接口
  30. * @param appKey
  31. * @param api
  32. * @param data
  33. * @return
  34. */
  35. @Override
  36. public DataResult customerETCQuery(String appKey, String api, String data,String requestid) {
  37. long costtimestart = System.currentTimeMillis();
  38. DataResult result = new DataResult();
  39. result.setData(3);
  40. result.setCode(200);
  41. result.setRequestid(requestid);
  42. result.setMsg("无法认证");
  43. try {
  44. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerETCQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
  45. JSONObject jsonObject = JSONObject.parseObject(data);
  46. String companyNum = jsonObject.getString("companyNum");//企业编号 必输
  47. String cardId = jsonObject.getString("cardId");//卡号 非必输
  48. String plateNum = jsonObject.getString("plateNum");//车牌号 非必输
  49. Integer plateColor = jsonObject.getInteger("plateColor");//车牌颜色 非必输
  50. if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(companyNum)){
  51. result.setData(3);
  52. result.setMsg("请输入必输项!");
  53. return result;
  54. }
  55. CustomerRec customerRec = new CustomerRec();
  56. customerRec.setCustomerName(appKey);
  57. customerRec.setCompanyNum(companyNum);
  58. customerRec.setInterType(0);
  59. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec);
  60. if (null == customerRec1){
  61. result.setCode(200);
  62. result.setMsg("该企业编号在平台中不存在,请联系管理员核实!");
  63. return result;
  64. }
  65. EtcQueryVo etcQueryVo = new EtcQueryVo();
  66. etcQueryVo.setCustomerName(appKey);//客户名称
  67. etcQueryVo.setCompanyName(customerRec1.getCompanyName());//企业名称
  68. etcQueryVo.setPlateNum(plateNum);//车牌号 非必输
  69. etcQueryVo.setCardId(cardId);//卡号 非必输
  70. etcQueryVo.setPlateColor(plateColor);//车牌颜色 非必输
  71. RespR rs = selfCarService.getEtcInfo(etcQueryVo);
  72. long costtimeend = System.currentTimeMillis();
  73. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerETCQuery-] result is "
  74. + rs.toString() + ", request is " + data + " ,costtime="
  75. + (costtimeend - costtimestart));
  76. if(null != rs && rs.getCode() == 0){
  77. result.setData(1);
  78. result.setCode(200);
  79. result.setMsg(rs.getData().toString());
  80. return result;
  81. } else {
  82. if(rs!=null && rs.getCode()==2){
  83. result.setData(2);
  84. result.setCode(200);
  85. result.setMsg("未查得");
  86. return result;
  87. }
  88. result.setData(3);
  89. result.setCode(200);
  90. result.setMsg(rs.getMsg());
  91. return result;
  92. }
  93. } catch (Exception e) {
  94. QUERY_LOG.error("[-SelfCarInterServiceImpl.customerETCQuery-] get httpclient exception is "
  95. + e + ", request is " + data);
  96. }
  97. return result;
  98. }
  99. /**
  100. * 自有车 卡信息查询接口
  101. * @param appKey
  102. * @param api
  103. * @param data
  104. * @return
  105. */
  106. @Override
  107. public DataResult customerQueryEtcInfo(String appKey, String api, String data,String requestid) {
  108. long costtimestart = System.currentTimeMillis();
  109. DataResult result = new DataResult();
  110. result.setData(3);
  111. result.setCode(200);
  112. result.setRequestid(requestid);
  113. result.setMsg("无法认证");
  114. try {
  115. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerQueryEtcInfo-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
  116. JSONObject jsonObject = JSONObject.parseObject(data);
  117. String companyNum = jsonObject.getString("companyNum");//企业编号 必输
  118. JSONArray vehicleList = jsonObject.getJSONArray("vehicleList");//车牌的json字符串 必输
  119. //JSONObject jb = vehicleList.getJSONObject(0);
  120. // String plateNum = jb.getString("plateNum");//车牌号
  121. //Integer plateColor = jb.getInteger("plateColor");//车牌颜色
  122. if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(companyNum)
  123. || null == vehicleList
  124. ){
  125. result.setCode(200);
  126. result.setMsg("必传参数有为空情况,请核实后再试");
  127. return result;
  128. }
  129. CustomerRec customerRec = new CustomerRec();
  130. customerRec.setCustomerName(appKey);
  131. customerRec.setCompanyNum(companyNum);
  132. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec);
  133. if (null == customerRec1){
  134. result.setMsg("该企业编号在平台中不存在,请联系管理员核实!");
  135. return result;
  136. }
  137. EtcBindVo etcQueryVo = new EtcBindVo();
  138. etcQueryVo.setCustomerName(appKey);//客户名称
  139. etcQueryVo.setCompanyName(customerRec1.getCompanyName());//企业名称
  140. List<CarVo> cards = new ArrayList<CarVo>();
  141. for(int i=0;i<vehicleList.size();i++) {
  142. JSONObject jb = vehicleList.getJSONObject(i);
  143. String plateNum = jb.getString("plateNum");//车牌号
  144. Integer plateColor = jb.getInteger("plateColor");//车牌颜色
  145. if(null == jb || StringUtils.isEmpty(plateNum)
  146. || null == plateColor
  147. ){
  148. result.setMsg("参数格式错误");
  149. return result;
  150. }
  151. CarVo carVo = new CarVo();
  152. carVo.setNum(plateNum);
  153. carVo.setColor(plateColor);
  154. cards.add(carVo);
  155. }
  156. etcQueryVo.setCards(cards);
  157. RespR rs = selfCarService.queryEtcInfo(etcQueryVo);
  158. long costtimeend = System.currentTimeMillis();
  159. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerQueryEtcInfo-] result is "
  160. + rs.toString() + ", request is " + data + " ,costtime="
  161. + (costtimeend - costtimestart));
  162. if(null != rs && rs.getCode() == 0){
  163. result.setData(1);
  164. result.setCode(200);
  165. result.setMsg(rs.getData().toString());
  166. return result;
  167. } else {
  168. result.setData(3);
  169. result.setCode(200);
  170. result.setMsg(rs.getMsg());
  171. if("未查得".equals(rs.getMsg())){
  172. result.setData(2);
  173. }
  174. return result;
  175. }
  176. } catch (Exception e) {
  177. QUERY_LOG.error("[-SelfCarInterServiceImpl.customerQueryEtcInfo-] get httpclient exception is "
  178. + e + ", request is " + data);
  179. }
  180. return result;
  181. }
  182. /**
  183. * 自有车下发短信通知接口
  184. * @param appKey
  185. * @param api
  186. * @param data
  187. * @return
  188. */
  189. @Override
  190. public DataResult customerETCRec(String appKey, String api, String data,String requestid) {
  191. long costtimestart = System.currentTimeMillis();
  192. DataResult result = new DataResult();
  193. result.setData(3);
  194. result.setCode(200);
  195. result.setRequestid(requestid);
  196. result.setMsg("无法认证");
  197. try {
  198. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerETCRec-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
  199. JSONObject jsonObject = JSONObject.parseObject(data);
  200. String companyNum = jsonObject.getString("companyNum");//企业编号 必输
  201. String mobile = jsonObject.getString("mobile");//企业预留手机号 必输
  202. JSONArray cardIdList = jsonObject.getJSONArray("cardIdList");//ETC卡编号列表 必输
  203. //JSONObject jb = cardIdList.getJSONObject(0);
  204. // String cardId = jb.getString("cardId");//用户卡Id
  205. if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(companyNum)
  206. || StringUtils.isEmpty(mobile)
  207. || null == cardIdList
  208. ){
  209. result.setCode(200);
  210. result.setMsg("必传参数有为空情况,请核实后再试");
  211. return result;
  212. }
  213. CustomerRec customerRec = new CustomerRec();
  214. customerRec.setCustomerName(appKey);
  215. customerRec.setCompanyNum(companyNum);
  216. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec);
  217. if (null == customerRec1){
  218. result.setCode(200);
  219. result.setMsg("该企业编号在平台中不存在,请联系管理员核实!");
  220. return result;
  221. }
  222. EtcBindVo etcQueryVo = new EtcBindVo();
  223. etcQueryVo.setCustomerName(appKey);//客户名称
  224. etcQueryVo.setCompanyName(customerRec1.getCompanyName());//企业名称
  225. etcQueryVo.setMobile(mobile);//企业预留手机号
  226. List<CarVo> cards = new ArrayList<CarVo>();
  227. for(int i=0;i<cardIdList.size();i++) {
  228. JSONObject jb = cardIdList.getJSONObject(i);
  229. String cardId = jb.getString("cardId");//用户卡Id
  230. if(null == jb || StringUtils.isEmpty(cardId)
  231. ){
  232. result.setCode(200);
  233. result.setMsg("用户卡为空!");
  234. return result;
  235. }
  236. CarVo carVo = new CarVo();
  237. carVo.setEtcNum(cardId);
  238. cards.add(carVo);
  239. }
  240. etcQueryVo.setCards(cards);
  241. RespR rs = selfCarService.customerEtcRec(etcQueryVo);
  242. long costtimeend = System.currentTimeMillis();
  243. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerETCRec-] result is "
  244. + rs.toString() + ", request is " + data + " ,costtime="
  245. + (costtimeend - costtimestart));
  246. if(null != rs && rs.getCode() == 0){
  247. result.setData(1);
  248. result.setCode(200);
  249. result.setMsg(rs.getData().toString());
  250. return result;
  251. } else {
  252. result.setData(3);
  253. result.setCode(200);
  254. result.setMsg(rs.getMsg());
  255. return result;
  256. }
  257. } catch (Exception e) {
  258. QUERY_LOG.error("[-SelfCarInterServiceImpl.customerETCRec-] get httpclient exception is "
  259. + e + ", request is " + data);
  260. }
  261. return result;
  262. }
  263. /**
  264. * 自有车 卡绑定接口 渠道调用此接口,上传用户收到的短信验证码
  265. * @param appKey
  266. * @param api
  267. * @param data
  268. * @return
  269. */
  270. @Override
  271. public DataResult customerETCRecValid(String appKey, String api, String data,String requestid) {
  272. long costtimestart = System.currentTimeMillis();
  273. DataResult result = new DataResult();
  274. result.setData(3);
  275. result.setCode(200);
  276. result.setRequestid(requestid);
  277. result.setMsg("无法认证");
  278. try {
  279. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerETCRecValid-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
  280. JSONObject jsonObject = JSONObject.parseObject(data);
  281. String companyNum = jsonObject.getString("companyNum");//企业编号 必输
  282. String mobile = jsonObject.getString("mobile");//企业预留手机号 必输
  283. String validCode = jsonObject.getString("validCode");//验证码 必输
  284. if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(companyNum)
  285. || StringUtils.isEmpty(mobile)
  286. || StringUtils.isEmpty(validCode)
  287. ){
  288. result.setCode(200);
  289. result.setMsg("必传参数有为空情况,请核实后再试");
  290. return result;
  291. }
  292. CustomerRec customerRec = new CustomerRec();
  293. customerRec.setCustomerName(appKey);
  294. customerRec.setCompanyNum(companyNum);
  295. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec);
  296. if (null == customerRec1){
  297. result.setCode(200);
  298. result.setMsg("该企业编号在平台中不存在,请联系管理员核实!");
  299. return result;
  300. }
  301. EtcValidVo etcValidVo = new EtcValidVo();
  302. etcValidVo.setCustomerName(appKey);
  303. etcValidVo.setCompanyName(customerRec1.getCompanyName());
  304. etcValidVo.setValidCode(validCode);
  305. etcValidVo.setMobile(mobile);
  306. etcValidVo.setInterType(0);//接口
  307. RespR rs = selfCarService.customerEtcRecValid(etcValidVo);
  308. long costtimeend = System.currentTimeMillis();
  309. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerETCRecValid-] result is "
  310. + rs.toString() + ", request is " + data + " ,costtime="
  311. + (costtimeend - costtimestart));
  312. if(null != rs && rs.getCode() == 0){
  313. result.setData(1);
  314. result.setCode(200);
  315. result.setMsg(rs.getData().toString());
  316. return result;
  317. } else {
  318. result.setData(3);
  319. result.setCode(200);
  320. result.setMsg(rs.getMsg());
  321. return result;
  322. }
  323. } catch (Exception e) {
  324. QUERY_LOG.error("[-SelfCarInterServiceImpl.customerETCRecValid-] get httpclient exception is "
  325. + e + ", request is " + data);
  326. }
  327. return result;
  328. }
  329. /**
  330. * 自有车 交易查询接口 渠道通过此接口可以查询单张卡连续90天内的交易(待开票、开票中、已开票)
  331. * @param appKey
  332. * @param api
  333. * @param data
  334. * @return
  335. */
  336. @Override
  337. public DataResult getTradeList(String appKey, String api, String data,String requestid) {
  338. long costtimestart = System.currentTimeMillis();
  339. DataResult result = new DataResult();
  340. result.setData(3);
  341. result.setCode(200);
  342. result.setRequestid(requestid);
  343. result.setMsg("无法认证");
  344. try {
  345. QUERY_LOG.info("[-SelfCarInterServiceImpl.getTradeList-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
  346. JSONObject jsonObject = JSONObject.parseObject(data);
  347. String companyNum = jsonObject.getString("companyNum");//企业编号 必输
  348. String cardId = jsonObject.getString("cardId");//卡号 必输
  349. Integer tradeStatus = jsonObject.getInteger("tradeStatus");//交易状态 必输
  350. String startExTime = jsonObject.getString("startExTime");//开始时间 必输
  351. String endExTime = jsonObject.getString("endExTime");//结束时间 必输
  352. if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(companyNum)
  353. || StringUtils.isEmpty(cardId)
  354. || null == tradeStatus
  355. || StringUtils.isEmpty(startExTime)
  356. || StringUtils.isEmpty(endExTime)
  357. ){
  358. result.setCode(200);
  359. result.setMsg("必传参数有为空情况,请核实后再试");
  360. return result;
  361. }
  362. CustomerRec customerRec = new CustomerRec();
  363. customerRec.setCustomerName(appKey);
  364. customerRec.setCompanyNum(companyNum);
  365. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec);
  366. if (null == customerRec1){
  367. result.setCode(200);
  368. result.setMsg("该企业编号在平台中不存在,请联系管理员核实!");
  369. return result;
  370. }
  371. TradeRequestVo tradeRequestVo = new TradeRequestVo();
  372. tradeRequestVo.setCustomerName(appKey);
  373. tradeRequestVo.setCompanyName(customerRec1.getCompanyName());
  374. tradeRequestVo.setStartTime(DateUtil.getDistanceHoursFormat(startExTime));
  375. tradeRequestVo.setEndTime(DateUtil.getDistanceHoursFormat(endExTime));
  376. tradeRequestVo.setEtcId(cardId);
  377. tradeRequestVo.setTradeStatus(tradeStatus);
  378. tradeRequestVo.setInterType(0);//0 接口
  379. if(tradeRequestVo.getTradeStatus() ==null){
  380. tradeRequestVo.setTradeStatus(1);
  381. RespR<List<CardTradeModel>> respRbefore = selfCarService.getTradeList(tradeRequestVo);
  382. tradeRequestVo.setTradeStatus(2);
  383. RespR<List<CardTradeModel>> respRUnder = selfCarService.getTradeList(tradeRequestVo);
  384. tradeRequestVo.setTradeStatus(3);
  385. RespR<List<CardTradeModel>> respRAfter = selfCarService.getTradeList(tradeRequestVo);
  386. //合并展示
  387. List<CardTradeModel> cardTradeModels = new ArrayList<>();
  388. if(respRbefore.getCode() == 0){
  389. cardTradeModels.addAll(respRbefore.getData());
  390. }
  391. if(respRUnder.getCode() == 0){
  392. cardTradeModels.addAll(respRUnder.getData());
  393. }
  394. if(respRAfter.getCode() == 0){
  395. cardTradeModels.addAll(respRAfter.getData());
  396. }
  397. result.setData(1);
  398. result.setCode(200);
  399. result.setMsg(cardTradeModels.toString());
  400. return result;
  401. }
  402. RespR rs = selfCarService.getTradeList(tradeRequestVo);
  403. long costtimeend = System.currentTimeMillis();
  404. QUERY_LOG.info("[-SelfCarInterServiceImpl.getTradeList-] result is "
  405. + rs.toString() + ", request is " + data + " ,costtime="
  406. + (costtimeend - costtimestart));
  407. if(null != rs && rs.getCode() == 0){
  408. result.setData(1);
  409. result.setCode(200);
  410. result.setMsg(rs.getData().toString());
  411. return result;
  412. } else {
  413. result.setData(3);
  414. if("未查得".equals(result.getMsg())){
  415. result.setData(2);
  416. }
  417. result.setCode(200);
  418. result.setMsg(rs.getMsg());
  419. return result;
  420. }
  421. } catch (Exception e) {
  422. QUERY_LOG.error("[-SelfCarInterServiceImpl.getTradeList-] get httpclient exception is "
  423. + e + ", request is " + data);
  424. }
  425. return result;
  426. }
  427. /**
  428. * 自有车 交易查询接口 渠道通过此接口可以查询单张卡连续90天内的交易(待开票、开票中、已开票)
  429. * @param appKey
  430. * @param api
  431. * @param data
  432. * @return
  433. */
  434. @Override
  435. public DataResult applInvoice(String appKey, String api, String data,String requestid) {
  436. long costtimestart = System.currentTimeMillis();
  437. DataResult result = new DataResult();
  438. result.setData(3);
  439. result.setCode(200);
  440. result.setRequestid(requestid);
  441. result.setMsg("无法认证");
  442. try {
  443. QUERY_LOG.info("[-SelfCarInterServiceImpl.applInvoice-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
  444. JSONObject jsonObject = JSONObject.parseObject(data);
  445. String companyNum = jsonObject.getString("companyNum");//企业编号 必输
  446. String cardId = jsonObject.getString("cardId");//卡号 必输
  447. JSONArray tradeIdModel = jsonObject.getJSONArray("tradeIdModel");//交易ID集合 必输
  448. /*String startExTime = jsonObject.getString("startExTime");//开始时间 必输
  449. String endExTime = jsonObject.getString("endExTime");//结束时间 必输*/
  450. if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(companyNum)
  451. || StringUtils.isEmpty(cardId)
  452. || null == tradeIdModel
  453. ){
  454. result.setCode(200);
  455. result.setMsg("必传参数有为空情况,请核实后再试");
  456. return result;
  457. }
  458. CustomerRec customerRec = new CustomerRec();
  459. customerRec.setCustomerName(appKey);
  460. customerRec.setCompanyNum(companyNum);
  461. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec);
  462. if (null == customerRec1 ){
  463. result.setCode(200);
  464. result.setMsg("该企业编号在平台中不存在,请联系管理员核实!");
  465. return result;
  466. }
  467. InvoiceApplVo invoiceApplVo = new InvoiceApplVo();
  468. invoiceApplVo.setCustomerName(appKey);
  469. invoiceApplVo.setCompanyName(customerRec1.getCompanyName());
  470. invoiceApplVo.setCardId(cardId);
  471. invoiceApplVo.setInterType(0);//接口
  472. List<String> tradeIds = new ArrayList<String>();
  473. for(int i=0;i<tradeIdModel.size();i++) {
  474. JSONObject jb = tradeIdModel.getJSONObject(i);
  475. String tradeId = jb.getString("tradeId");//交易ID
  476. if(null == jb || StringUtils.isEmpty(tradeId)
  477. ){
  478. return result;
  479. }
  480. tradeIds.add(tradeId);
  481. }
  482. invoiceApplVo.setTradeIds(tradeIds);
  483. RespR rs = selfCarService.applInvoice(invoiceApplVo);
  484. long costtimeend = System.currentTimeMillis();
  485. QUERY_LOG.info("[-SelfCarInterServiceImpl.applInvoice-] result is "
  486. + rs.toString() + ", request is " + data + " ,costtime="
  487. + (costtimeend - costtimestart));
  488. if(null != rs && rs.getCode() == 0){
  489. result.setData(1);
  490. result.setCode(200);
  491. result.setMsg(rs.getData().toString());
  492. return result;
  493. } else {
  494. result.setData(3);
  495. result.setCode(200);
  496. result.setMsg(rs.getMsg());
  497. return result;
  498. }
  499. } catch (Exception e) {
  500. QUERY_LOG.error("[-SelfCarInterServiceImpl.applInvoice-] get httpclient exception is "
  501. + e + ", request is " + data);
  502. }
  503. return result;
  504. }
  505. /**
  506. * 自有车 已开发票查询接口 渠道通过此接口可以根据该公司绑定的单张卡查询此卡在某个月开具的发票
  507. * @param appKey
  508. * @param api
  509. * @param data
  510. * @return
  511. */
  512. @Override
  513. public DataResult getSelfCarInvoicesByTime(String appKey, String api, String data,String requestid) {
  514. long costtimestart = System.currentTimeMillis();
  515. DataResult result = new DataResult();
  516. result.setData(3);
  517. result.setCode(200);
  518. result.setRequestid(requestid);
  519. result.setMsg("无法认证");
  520. try {
  521. QUERY_LOG.info("[-SelfCarInterServiceImpl.getSelfCarInvoicesByTime-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
  522. JSONObject jsonObject = JSONObject.parseObject(data);
  523. String companyNum = jsonObject.getString("companyNum");//企业编号 必输
  524. String cardId = jsonObject.getString("cardId");//卡号 必输
  525. String startInvoiceMakeTime = jsonObject.getString("startInvoiceMakeTime");//开始时间 必输
  526. String endInvoiceMakeTime = jsonObject.getString("endInvoiceMakeTime");//结束时间 必输
  527. if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(companyNum)
  528. || StringUtils.isEmpty(cardId)
  529. || StringUtils.isEmpty(startInvoiceMakeTime)
  530. || StringUtils.isEmpty(endInvoiceMakeTime)
  531. ){
  532. result.setCode(200);
  533. result.setMsg("必传参数有为空情况,请核实后再试");
  534. return result;
  535. }
  536. CustomerRec customerRec = new CustomerRec();
  537. customerRec.setCustomerName(appKey);
  538. customerRec.setCompanyNum(companyNum);
  539. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec);
  540. if (null == customerRec1){
  541. result.setCode(200);
  542. result.setMsg("该企业编号在平台中不存在,请联系管理员核实!");
  543. return result;
  544. }
  545. SelfCarDueQueryVo selfCarDueQueryVo = new SelfCarDueQueryVo();
  546. selfCarDueQueryVo.setCustomername(appKey);
  547. selfCarDueQueryVo.setCompanyName(customerRec1.getCompanyName());
  548. selfCarDueQueryVo.setCardId(cardId);
  549. selfCarDueQueryVo.setStartTime(startInvoiceMakeTime);
  550. selfCarDueQueryVo.setEndTime(endInvoiceMakeTime);
  551. RespR rs = selfCarService.getSelfCarInvoicesByTime(selfCarDueQueryVo);
  552. long costtimeend = System.currentTimeMillis();
  553. QUERY_LOG.info("[-SelfCarInterServiceImpl.getSelfCarInvoicesByTime-] result is "
  554. + rs.toString() + ", request is " + data + " ,costtime="
  555. + (costtimeend - costtimestart));
  556. if(null != rs && rs.getCode() == 0){
  557. result.setData(1);
  558. result.setCode(200);
  559. result.setMsg(rs.getMsg());
  560. return result;
  561. } else {
  562. result.setData(3);
  563. if("未查得".equals(rs.getMsg())){
  564. result.setData(3);
  565. }
  566. result.setCode(200);
  567. result.setMsg(rs.getMsg());
  568. return result;
  569. }
  570. } catch (Exception e) {
  571. QUERY_LOG.error("[-SelfCarInterServiceImpl.getSelfCarInvoicesByTime-] get httpclient exception is "
  572. + e + ", request is " + data);
  573. }
  574. return result;
  575. }
  576. /**
  577. * 自有车 发票下载 渠道通过此接口可以下载某公司某个月份开具的发票。
  578. * @param appKey
  579. * @param api
  580. * @param data
  581. * @return
  582. */
  583. @Override
  584. public DataResult getSelfCarInvoicePackage(String appKey, String api, String data,String requestid) {
  585. long costtimestart = System.currentTimeMillis();
  586. DataResult result = new DataResult();
  587. result.setData(3);
  588. result.setCode(200);
  589. result.setRequestid(requestid);
  590. result.setMsg("无法认证");
  591. try {
  592. QUERY_LOG.info("[-SelfCarInterServiceImpl.getSelfCarInvoicePackage-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
  593. JSONObject jsonObject = JSONObject.parseObject(data);
  594. String companyNum = jsonObject.getString("companyNum");//企业编号 必输
  595. String makeMonth = jsonObject.getString("makeMonth");//发票开具月份 必输
  596. if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(companyNum)
  597. || StringUtils.isEmpty(makeMonth)
  598. ){
  599. result.setCode(200);
  600. result.setMsg("必传参数有为空情况,请核实后再试");
  601. return result;
  602. }
  603. CustomerRec customerRec = new CustomerRec();
  604. customerRec.setCustomerName(appKey);
  605. customerRec.setCompanyNum(companyNum);
  606. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec);
  607. if (null == customerRec1){
  608. result.setCode(200);
  609. result.setMsg("该企业编号在平台中不存在,请联系管理员核实!");
  610. return result;
  611. }
  612. InvoicePackageVo invoicePackageVo = new InvoicePackageVo();
  613. invoicePackageVo.setCustomerName(appKey);
  614. invoicePackageVo.setCompanyName(customerRec1.getCompanyName());
  615. invoicePackageVo.setMonth(makeMonth);
  616. RespR rs = selfCarService.getInvoicePackge(invoicePackageVo);
  617. long costtimeend = System.currentTimeMillis();
  618. QUERY_LOG.info("[-SelfCarInterServiceImpl.getSelfCarInvoicePackage-] result is "
  619. + rs.toString() + ", request is " + data + " ,costtime="
  620. + (costtimeend - costtimestart));
  621. if(null != rs && rs.getCode() == 0){
  622. result.setData(1);
  623. result.setCode(200);
  624. result.setMsg(rs.getData().toString());
  625. return result;
  626. } else {
  627. result.setData(3);
  628. result.setCode(200);
  629. result.setMsg(rs.getMsg());
  630. return result;
  631. }
  632. } catch (Exception e) {
  633. QUERY_LOG.error("[-SelfCarInterServiceImpl.getSelfCarInvoicePackage-] get httpclient exception is "
  634. + e + ", request is " + data);
  635. }
  636. return result;
  637. }
  638. /**
  639. * 自有车 卡解绑接口
  640. * @param appKey
  641. * @param api
  642. * @param data
  643. * @return
  644. */
  645. @Override
  646. public DataResult customerCarUnRec(String appKey, String api, String data,String requestid) {
  647. long costtimestart = System.currentTimeMillis();
  648. DataResult result = new DataResult();
  649. result.setData(3);
  650. result.setCode(200);
  651. result.setRequestid(requestid);
  652. result.setMsg("无法认证");
  653. try {
  654. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerCarUnRec-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data+ " ,requestid=" +requestid);
  655. JSONObject jsonObject = JSONObject.parseObject(data);
  656. String companyNum = jsonObject.getString("companyNum");//企业编号 必输
  657. String cardId = jsonObject.getString("cardId");//Etc卡号 必输
  658. if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(companyNum)
  659. || StringUtils.isEmpty(cardId)
  660. ){
  661. return result;
  662. }
  663. CustomerRec customerRec = new CustomerRec();
  664. customerRec.setCustomerName(appKey);
  665. customerRec.setCompanyNum(companyNum);
  666. CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec);
  667. if (null == customerRec1){
  668. result.setMsg("该企业编号未注册企业!");
  669. return result;
  670. }
  671. List<CustomerCarRec> customerCarRecList = new ArrayList<CustomerCarRec>();
  672. CustomerCarRec customerCarRec = new CustomerCarRec();
  673. customerCarRec.setCustomerName(appKey);
  674. customerCarRec.setCompanyName(customerRec1.getCompanyName());
  675. customerCarRec.setEtcNum(cardId);
  676. customerCarRecList.add(customerCarRec);
  677. RespR rs = selfCarService.customerCarUnRec(customerCarRecList);
  678. long costtimeend = System.currentTimeMillis();
  679. QUERY_LOG.info("[-SelfCarInterServiceImpl.customerCarUnRec-] result is "
  680. + rs.toString() + ", request is " + data + " ,costtime="
  681. + (costtimeend - costtimestart));
  682. if(null != rs && rs.getCode() == 0){
  683. result.setData(1);
  684. result.setCode(200);
  685. result.setMsg(rs.getData().toString());
  686. return result;
  687. } else {
  688. result.setData(3);
  689. result.setCode(200);
  690. result.setMsg(rs.getMsg());
  691. return result;
  692. }
  693. } catch (Exception e) {
  694. QUERY_LOG.error("[-SelfCarInterServiceImpl.customerCarUnRec-] get httpclient exception is "
  695. + e + ", request is " + data);
  696. }
  697. return result;
  698. }
  699. }