AppUserInfoController.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. package com.platform.yijia.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.google.gson.Gson;
  4. import com.platform.yijia.param.request.AppUserInfoRequest;
  5. import com.platform.yijia.pojo.AppUserInfo;
  6. import com.platform.yijia.pojo.CustomerElectronicCard;
  7. import com.platform.yijia.pojo.CustomerPoints;
  8. import com.platform.yijia.service.*;
  9. import com.platform.yijia.utils.CodeMsg;
  10. import com.platform.yijia.utils.ResultData;
  11. import com.platform.yijia.utils.redis.RedisCacheUtil;
  12. import com.platform.yijia.utils.weixinapp.AesDecryptUtil;
  13. import com.platform.yijia.utils.weixinapp.WeiXinUserUtil;
  14. import org.apache.commons.codec.digest.DigestUtils;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.stereotype.Controller;
  20. import org.springframework.transaction.annotation.Transactional;
  21. import org.springframework.web.bind.annotation.*;
  22. import javax.annotation.Resource;
  23. import java.math.BigDecimal;
  24. import java.security.MessageDigest;
  25. import java.security.NoSuchAlgorithmException;
  26. import java.util.Date;
  27. import java.util.HashMap;
  28. import java.util.List;
  29. import java.util.Map;
  30. import java.util.concurrent.TimeUnit;
  31. @Controller
  32. @RequestMapping("/demo")
  33. public class AppUserInfoController {
  34. private static Logger logger =(Logger) LoggerFactory.getLogger(AppUserInfoController.class);
  35. @Autowired
  36. private PayOrderService payOrderService;
  37. @Autowired
  38. private AppUserInfoService appUserInfoService;
  39. @Resource
  40. private StationService stationService;
  41. @Resource
  42. private CustomerPointsService customerPointsService;
  43. @Resource
  44. private RedisCacheUtil redisCacheUtil;
  45. @Resource
  46. private ElectronicMembershipCardService electronicMembershipCardService;
  47. // String appId = "wxe1135cd390b38a54"; //微信小程序appID
  48. // String appSecret = "0532c7d9ae876c4ad636df0b1e3b9ddb"; //微信小程序密钥
  49. /*
  50. * 微信小程序根据code获取用户openId和sessionKey
  51. * @param code
  52. * @param stationId
  53. * @return
  54. */
  55. @ResponseBody
  56. @RequestMapping(value = "/getSessionKeyAndOpenID")
  57. public Map<String, Object> getSessionKeyAndOpenID(@RequestParam("code") String code, @RequestParam("stationId") Integer stationId){
  58. logger.info("微信小程序获取用户openId和sessionKey入参code和stationId: "+code +"-----" +stationId);
  59. String appId = ""; //微信小程序appID
  60. String appSecret = ""; //微信小程序密钥
  61. if(stationId !=null){
  62. Map<String, String> map = stationService.getStationAppIdAndAppSecret(stationId);
  63. appId = map.get("appId"); //微信小程序appID
  64. appSecret = map.get("appSecret"); //微信小程序密钥
  65. }
  66. //获取session_key 和 openid
  67. return WeiXinUserUtil.getUserSessionKeyAndOpenID(appId, appSecret, code);
  68. }
  69. /*
  70. * 解密 encryptedData
  71. * @param sessionKey
  72. * @param encryptedData
  73. * @param iv
  74. * @return
  75. */
  76. @ResponseBody
  77. @RequestMapping(value = "/decryptEncryptedData", method = RequestMethod.POST, consumes = "application/json")
  78. public String decryptEncryptedData(@RequestBody JSONObject jsonObject){
  79. logger.info("解密获取手机号前台传入参数:" +jsonObject.toString());
  80. return AesDecryptUtil.decryptEncryptedData(jsonObject.get("encryptedData").toString(), jsonObject.get("sessionKey").toString(), jsonObject.get("iv").toString(), "UTF-8").toString();
  81. }
  82. /*
  83. * JS-SDK使用权限签名算法
  84. * @param noncestr 随机字符串
  85. * @param timestamp 时间戳
  86. * @param url 页面访问路径
  87. * @param stationId 油站ID
  88. * @return
  89. */
  90. @RequestMapping(value = "/getSignature", method = RequestMethod.GET)
  91. @ResponseBody
  92. public String getSignature(@RequestParam String noncestr, String timestamp, String url, Integer stationId){
  93. Gson gson =new Gson();
  94. //返回结果集
  95. ResultData resultData = null;
  96. logger.info("JS-SDK使用权限签名算法前台传来参数: "+"油站ID:"+stationId+"; noncestr: " +noncestr+"; timestamp: " +timestamp + "; url: "+url);
  97. Map<String, String> m = stationService.getStationAppIdAndAppSecret(stationId);
  98. String gzhAppId ="";
  99. String gzhAppSecret ="";
  100. String accessToken ="";
  101. if(m !=null && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
  102. gzhAppId = m.get("gzhAppId");
  103. gzhAppSecret = m.get("gzhAppSecret");
  104. accessToken = this.getTokenByRedisCache(gzhAppId, gzhAppSecret);
  105. //当前用户登录的公众号redis缓存中的jsapi_ticket
  106. String appIdTicket =gzhAppId + "-ticket";
  107. String jsapiTicket ="";
  108. if(redisCacheUtil.hasKey(appIdTicket)){
  109. jsapiTicket = redisCacheUtil.getCacheObject(appIdTicket);
  110. }else {
  111. //获取jsapi_ticket
  112. net.sf.json.JSONObject gzhJsapiTicket = WeiXinUserUtil.getGzhJsapiTicket(accessToken);
  113. if(gzhJsapiTicket.containsKey("ticket")){
  114. redisCacheUtil.setCacheObject(appIdTicket, gzhJsapiTicket.get("ticket"));
  115. redisCacheUtil.expire(appIdTicket, 7200, TimeUnit.SECONDS);
  116. jsapiTicket = gzhJsapiTicket.get("ticket").toString();
  117. }
  118. }
  119. String string1 = "jsapi_ticket="+jsapiTicket + "&noncestr=" +noncestr +"&timestamp=" +timestamp +"&url=" +url;
  120. logger.info("签名参数拼接:"+ string1);
  121. //sha1加密
  122. String signature = DigestUtils.sha1Hex(string1);
  123. //String signature = this.sha1(string1);
  124. resultData = ResultData.success(signature);
  125. }
  126. return gson.toJson(resultData);
  127. }
  128. /*
  129. * 判断使用小程序支付的用户是否关注公众号
  130. * @param unionId
  131. * @param stationId
  132. * @return
  133. */
  134. @RequestMapping(value = "/whetherFollowGzh", method = RequestMethod.GET)
  135. @ResponseBody
  136. public String whetherFollowGzh(@RequestParam String unionId, Integer stationId){
  137. Gson gson =new Gson();
  138. //返回结果集
  139. ResultData resultData = null;
  140. if (unionId !=null){
  141. Map<String, String> param = new HashMap<>();
  142. param.put("unionId", unionId);
  143. param.put("userType", "1");
  144. param.put("stationId", stationId.toString());
  145. String openId = appUserInfoService.whetherFollowGzh(param);
  146. if(openId !=null){
  147. Map<String, String> m = stationService.getStationAppIdAndAppSecret(stationId);
  148. String gzhAppId ="";
  149. String gzhAppSecret ="";
  150. String accessToken ="";
  151. if(m !=null && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
  152. gzhAppId = m.get("gzhAppId");
  153. gzhAppSecret = m.get("gzhAppSecret");
  154. accessToken = this.getTokenByRedisCache(gzhAppId, gzhAppSecret);
  155. net.sf.json.JSONObject unionIdInfo = WeiXinUserUtil.getUnionIdInfo(accessToken, openId);
  156. logger.info("用户公众号信息:" + unionIdInfo);
  157. if(unionIdInfo.containsKey("subscribe") && unionIdInfo.get("subscribe").equals(1)){
  158. resultData = ResultData.success(CodeMsg.SUCCESS);
  159. }else {
  160. resultData = ResultData.error(CodeMsg.NO_FollowGzh);
  161. }
  162. }else {
  163. resultData = ResultData.error(CodeMsg.SEARCH_APPID_FAIL);
  164. }
  165. }else {
  166. resultData = ResultData.error(CodeMsg.USERGZHINFO_EXSIST);
  167. }
  168. }
  169. return gson.toJson(resultData);
  170. }
  171. /*
  172. * 获取公众号授权后的信息
  173. * @param code
  174. * @param stationId
  175. * @return
  176. */
  177. @RequestMapping(value = "/getGzhAuthorizeInfo", method = RequestMethod.GET)
  178. @ResponseBody
  179. public String getGzhAuthorizeInfo(@RequestParam String code, Integer stationId){
  180. logger.info("获取公众号授权后的信息前端传递参数:code:"+ code );
  181. logger.info("获取公众号授权后的信息前端传递参数:stationId:" +stationId);
  182. Gson gson =new Gson();
  183. //返回结果集
  184. ResultData resultData = null;
  185. if(code != null && stationId !=null){
  186. String gzhAppId ="";
  187. String gzhAppSecret ="";
  188. Map<String, String> m = stationService.getStationAppIdAndAppSecret(stationId);
  189. if(m !=null && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
  190. gzhAppId = m.get("gzhAppId");
  191. gzhAppSecret = m.get("gzhAppSecret");
  192. net.sf.json.JSONObject gzhAuthorizeInfo = WeiXinUserUtil.getGzhAuthorizeInfo(gzhAppId, gzhAppSecret, code);
  193. logger.info("授权获取到信息:" + gzhAuthorizeInfo.toString());
  194. resultData = ResultData.success(gzhAuthorizeInfo);
  195. }else {
  196. resultData = ResultData.error(CodeMsg.REQUEST_FAIL);
  197. }
  198. }else {
  199. resultData = ResultData.error(CodeMsg.REQUEST_FAIL);
  200. }
  201. return gson.toJson(resultData);
  202. }
  203. /*
  204. * 测试用来
  205. * 获取公众号授权后的信息测试
  206. * @param code
  207. * @param stationId
  208. * @return
  209. */
  210. @RequestMapping(value = "/getGzhAuthorizeInfoNew", method = RequestMethod.GET)
  211. @ResponseBody
  212. public String getGzhAuthorizeInfoNew(@RequestParam String code, Integer stationId){
  213. logger.info("获取公众号授权后的信息前端传递参数:code:"+ code );
  214. logger.info("获取公众号授权后的信息前端传递参数:stationId:" +stationId);
  215. Gson gson =new Gson();
  216. //返回结果集
  217. ResultData resultData = null;
  218. if(code != null && stationId !=null){
  219. String gzhAppId ="";
  220. String gzhAppSecret ="";
  221. Map<String, String> m = stationService.getStationAppIdAndAppSecret(stationId);
  222. if(m !=null && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
  223. gzhAppId = m.get("gzhAppId");
  224. gzhAppSecret = m.get("gzhAppSecret");
  225. net.sf.json.JSONObject gzhAuthorizeInfo = WeiXinUserUtil.getGzhAuthorizeInfo(gzhAppId, gzhAppSecret, code);
  226. logger.info("授权获取到信息:" + gzhAuthorizeInfo.toString());
  227. if(gzhAuthorizeInfo.containsKey("openid")){
  228. String openId = gzhAuthorizeInfo.get("openid").toString();
  229. String accessToken = this.getTokenByRedisCache(gzhAppId, gzhAppSecret);
  230. net.sf.json.JSONObject unionIdInfo = null;
  231. unionIdInfo= WeiXinUserUtil.getUnionIdInfo(accessToken, openId);
  232. if(unionIdInfo.containsKey("errcode")){
  233. //删除原来key
  234. redisCacheUtil.deleteObject(gzhAppId);
  235. String token = WeiXinUserUtil.getToken(gzhAppId, gzhAppSecret).getAccessToken();
  236. redisCacheUtil.setCacheObject(gzhAppId, token);
  237. redisCacheUtil.expire(gzhAppId, 7200, TimeUnit.SECONDS);
  238. unionIdInfo= WeiXinUserUtil.getUnionIdInfo(token, openId);
  239. }
  240. AppUserInfo appUserInfo = new AppUserInfo();
  241. if(unionIdInfo.containsKey("openid")){
  242. appUserInfo.setBlogOpenid(unionIdInfo.get("openid").toString());
  243. }
  244. if(unionIdInfo.containsKey("nickname")){
  245. appUserInfo.setBlogNickName(unionIdInfo.get("nickname").toString());
  246. }
  247. if(unionIdInfo.containsKey("sex")){
  248. appUserInfo.setSexFlag(unionIdInfo.get("sex").toString());
  249. }
  250. if(unionIdInfo.containsKey("headimgurl")){
  251. appUserInfo.setBlogProfilePhoto(unionIdInfo.get("headimgurl").toString());
  252. }
  253. if(unionIdInfo.containsKey("unionid")){
  254. appUserInfo.setUnionId(unionIdInfo.get("unionid").toString());
  255. }
  256. appUserInfo.setUserType("1");
  257. Map<String, Object> params = new HashMap<>();
  258. params.put("openId", openId); //注册用户openId
  259. params.put("userType", appUserInfo.getUserType()); //用户类型
  260. //判断该用户是否已存在
  261. int count = appUserInfoService.isExistAppUser(params);
  262. if(count > 0){
  263. appUserInfoService.updateAppUserInfo(appUserInfo);
  264. }else {
  265. appUserInfoService.AddAppUserInfo(appUserInfo);
  266. }
  267. resultData = ResultData.success(unionIdInfo);
  268. }
  269. }else {
  270. resultData = ResultData.error(CodeMsg.REQUEST_FAIL);
  271. }
  272. }else {
  273. resultData = ResultData.error(CodeMsg.REQUEST_FAIL);
  274. }
  275. return gson.toJson(resultData);
  276. }
  277. /*
  278. * 获取公众号信息
  279. * @param openId
  280. * @param stationId
  281. * @return
  282. */
  283. @RequestMapping(value = "/getGzhUserInfo", method = RequestMethod.GET)
  284. @ResponseBody
  285. public String getGzhUserInfo(@RequestParam String openId, Integer stationId){
  286. Gson gson =new Gson();
  287. //返回结果集
  288. ResultData resultData = null;
  289. if(openId !=null && stationId !=null){
  290. String gzhAppId ="";
  291. String gzhAppSecret ="";
  292. String accessToken ="";
  293. Map<String, String> m = stationService.getStationAppIdAndAppSecret(stationId);
  294. if(m !=null && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){
  295. gzhAppId = m.get("gzhAppId");
  296. gzhAppSecret = m.get("gzhAppSecret");
  297. accessToken = this.getTokenByRedisCache(gzhAppId, gzhAppSecret);
  298. net.sf.json.JSONObject unionIdInfo = null;
  299. unionIdInfo= WeiXinUserUtil.getUnionIdInfo(accessToken, openId);
  300. if(unionIdInfo.containsKey("errcode")){
  301. //删除原来key
  302. redisCacheUtil.deleteObject(gzhAppId);
  303. String token = WeiXinUserUtil.getToken(gzhAppId, gzhAppSecret).getAccessToken();
  304. redisCacheUtil.setCacheObject(gzhAppId, token);
  305. redisCacheUtil.expire(gzhAppId, 7200, TimeUnit.SECONDS);
  306. unionIdInfo= WeiXinUserUtil.getUnionIdInfo(token, openId);
  307. }
  308. resultData=ResultData.success(unionIdInfo);
  309. }
  310. }else {
  311. resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
  312. }
  313. return gson.toJson(resultData);
  314. }
  315. /*
  316. * 从Redis缓存中获取 tokenCache
  317. * @param appId
  318. * @param appSecret
  319. * @return
  320. */
  321. public String getTokenByRedisCache(String appId, String appSecret){
  322. logger.info("appId参数: "+ appId+" ;appSecret参数: " +appSecret);
  323. if(!redisCacheUtil.hasKey(appId) || redisCacheUtil.getCacheObject(appId) ==null || redisCacheUtil.getCacheObject(appId).equals("")){
  324. String token = WeiXinUserUtil.getToken(appId, appSecret).getAccessToken();
  325. redisCacheUtil.setCacheObject(appId, token);
  326. redisCacheUtil.expire(appId, 7200, TimeUnit.SECONDS);
  327. logger.info("Redis缓存中token信息: " + token);
  328. return token;
  329. }else {
  330. return redisCacheUtil.getCacheObject(appId);
  331. }
  332. }
  333. /*
  334. * 添加用户信息
  335. * @param request
  336. * @return
  337. */
  338. @RequestMapping(value = "/addAppUserInfo", method = RequestMethod.POST)
  339. @ResponseBody
  340. @Transactional
  341. public String addAppUserInfo(@RequestBody AppUserInfoRequest request){
  342. Gson gson =new Gson();
  343. ResultData resultData=null;
  344. try{
  345. logger.info("前端传入参数:" +request.toString());
  346. AppUserInfo appUserInfo =new AppUserInfo();
  347. CustomerPoints customerPoints = new CustomerPoints();
  348. CustomerElectronicCard customerElectronicCard = new CustomerElectronicCard(); //客户电子卡
  349. String openId = ""; //此参数用于查询该用户是否已注册过
  350. if(request.getUserType()!=null){
  351. //1-微信公众号
  352. if(request.getUserType().equals("1") &&StringUtils.isNotBlank(request.getOpenId())){
  353. appUserInfo.setUserType(request.getUserType());
  354. appUserInfo.setBlogToken(request.getBlogToken());
  355. openId = request.getOpenId();
  356. appUserInfo.setBlogOpenid(openId);
  357. customerPoints.setBlogOpenId(openId);
  358. customerElectronicCard.setBlogOpenid(openId);
  359. //2-微信小程序
  360. }else if(request.getUserType().equals("2") &&StringUtils.isNotBlank(request.getOpenId())){
  361. appUserInfo.setUserType(request.getUserType());
  362. appUserInfo.setMinaToken(request.getMinaToken());
  363. openId = request.getOpenId();
  364. appUserInfo.setMinaOpenid(openId);
  365. customerPoints.setMinaOpenId(openId);
  366. customerElectronicCard.setMinaOpenid(openId);
  367. }
  368. }
  369. if(StringUtils.isNotBlank(request.getBlogNickName())){
  370. appUserInfo.setBlogNickName(request.getBlogNickName());
  371. customerPoints.setCustomerName(request.getBlogNickName());
  372. customerElectronicCard.setCustomerName(request.getBlogNickName());
  373. }
  374. if(StringUtils.isNotBlank(request.getMobilePhone())){
  375. appUserInfo.setMobilePhone(request.getMobilePhone());
  376. customerPoints.setMobilePhone(request.getMobilePhone());
  377. customerElectronicCard.setMobilePhone(request.getMobilePhone());
  378. }
  379. if(StringUtils.isNotBlank(request.getBlogProfilePhoto())){
  380. appUserInfo.setBlogProfilePhoto(request.getBlogProfilePhoto());
  381. }
  382. if(StringUtils.isNotBlank(request.getUnionId())){
  383. appUserInfo.setUnionId(request.getUnionId());
  384. customerPoints.setUnionId(request.getUnionId());
  385. customerElectronicCard.setUnionId(request.getUnionId());
  386. }
  387. appUserInfo.setStationId(request.getStationId());
  388. appUserInfo.setRegisteDate(new Date());
  389. appUserInfo.setUpdateDate(new Date());
  390. customerPoints.setCreateTime(new Date());
  391. customerPoints.setUnionId(request.getUnionId());
  392. customerPoints.setPoints(0);
  393. customerPoints.setConsumptionPoints(0);
  394. customerPoints.setAccumulatePoints(0);
  395. customerPoints.setInvalidPoints(0);
  396. customerPoints.setStationId(request.getStationId());
  397. customerPoints.setStationName(request.getStationName());
  398. customerElectronicCard.setCreateTime(new Date());
  399. customerElectronicCard.setStationId(request.getStationId());
  400. customerElectronicCard.setStationName(request.getStationName());
  401. if(StringUtils.isNotBlank(request.getSexFlag())){
  402. appUserInfo.setSexFlag(request.getSexFlag());
  403. }
  404. logger.info("插入数据库用户信息参数:"+appUserInfo.toString());
  405. Map<String, Object> params = new HashMap<>();
  406. params.put("openId", openId); //注册用户openId
  407. params.put("userType", request.getUserType()); //用户类型
  408. //判断该用户是否已存在
  409. int count = appUserInfoService.isExistAppUser(params);
  410. if(count > 0){
  411. appUserInfoService.updateAppUserInfo(appUserInfo);
  412. this.upDateCustomerPointsInfo(customerPoints, request);
  413. this.upDateCustomerElectronicCard(customerElectronicCard, request);
  414. resultData = ResultData.error(CodeMsg.SUCCESS);
  415. }else {
  416. appUserInfoService.AddAppUserInfo(appUserInfo);
  417. this.upDateCustomerPointsInfo(customerPoints, request);
  418. this.upDateCustomerElectronicCard(customerElectronicCard, request);
  419. resultData = ResultData.success(CodeMsg.SUCCESS);
  420. }
  421. }catch (Exception e){
  422. resultData = ResultData.error(CodeMsg.INSERT_FAIL);
  423. e.printStackTrace();
  424. }
  425. return gson.toJson(resultData);
  426. }
  427. //客户积分表信息操作
  428. public void upDateCustomerPointsInfo(CustomerPoints customerPoints, AppUserInfoRequest request){
  429. boolean boo = customerPointsService.isExistCustomerPointsInfo(customerPoints);
  430. if(!boo){
  431. customerPointsService.insertCustomerPointsInfo(customerPoints);
  432. }else {
  433. //此处用于:如果客户积分信息存在可能会出现小程序ID或者公众号ID没有的情况
  434. CustomerPoints c = new CustomerPoints();
  435. c.setUnionId(customerPoints.getUnionId());
  436. if(request.getUserType().equals("1")){
  437. c.setBlogOpenId(customerPoints.getBlogOpenId());
  438. }else if(request.getUserType().equals("2")){
  439. c.setMinaOpenId(customerPoints.getMinaOpenId());
  440. }
  441. c.setStationId(request.getStationId());
  442. c.setStationName(request.getStationName());
  443. c.setMobilePhone(request.getMobilePhone());
  444. c.setStationId(request.getStationId());
  445. c.setCustomerName(request.getBlogNickName());
  446. c.setStationName(request.getStationName());
  447. customerPointsService.updateCustomerPointsInfo(c);
  448. }
  449. }
  450. //客户电子会员卡表操作
  451. public void upDateCustomerElectronicCard(CustomerElectronicCard customerElectronicCard, AppUserInfoRequest request){
  452. List<CustomerElectronicCard> electronicCardList = electronicMembershipCardService.getElectronicCardList(customerElectronicCard);
  453. if(electronicCardList !=null && electronicCardList.size() ==2){
  454. electronicMembershipCardService.updateElectronicCardInfoByUnionId(customerElectronicCard);
  455. }else {
  456. //当前时间戳
  457. String currentTime = String.valueOf(System.currentTimeMillis());
  458. String customerNo = request.getStationId() + currentTime;
  459. customerElectronicCard.setCustomerNo(customerNo);
  460. customerElectronicCard.setAmt(new BigDecimal(0));
  461. customerElectronicCard.setCardOilsType("1");
  462. electronicMembershipCardService.insetElectronicCard(customerElectronicCard);
  463. customerElectronicCard.setCardOilsType("2");
  464. String currentTime1 = String.valueOf(System.currentTimeMillis());
  465. String customerNo1 = request.getStationId() + currentTime1;
  466. customerElectronicCard.setCustomerNo(customerNo1);
  467. electronicMembershipCardService.insetElectronicCard(customerElectronicCard);
  468. }
  469. }
  470. }