SelfCarInterServiceImpl.java 37 KB

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