From 8a51bd9ed75fcd1a709b987c880acd6ea6f761b6 Mon Sep 17 00:00:00 2001 From: zc Date: Fri, 6 Feb 2026 15:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/renren/controller/CardController.java | 974 +++++++++--------- .../src/main/resources/logback-spring.xml | 56 +- 2 files changed, 526 insertions(+), 504 deletions(-) diff --git a/renren-api/src/main/java/io/renren/controller/CardController.java b/renren-api/src/main/java/io/renren/controller/CardController.java index 244eb78..377497c 100644 --- a/renren-api/src/main/java/io/renren/controller/CardController.java +++ b/renren-api/src/main/java/io/renren/controller/CardController.java @@ -611,160 +611,161 @@ public class CardController { return; } - @RequestMapping(value = "real",method = RequestMethod.POST) + @RequestMapping(value = "real", method = RequestMethod.POST) @ApiOperation("实时接口") - public JSONObject real(@RequestBody JSONObject json){ - JSONObject result=new JSONObject(); - Gson gson = new Gson(); - System.out.println("实时接口========="+json); + public JSONObject real(@RequestBody JSONObject json) { + JSONObject result = new JSONObject(); + System.out.println("实时接口=========" + json); //如果有记录时则要处理记录后再应答,保存后的id回传给设备,方便设备对记录作标志 cardpwd FFFFFFFFFFFF - String api=json.get("api")+""; - if("infoquery".equals(api)){ + String api = json.getString("api"); + //判断是否是人员查询接口 + if ("infoquery".equals(api)) { //判断人员查询是否成功 - JSONObject params= JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); - String code="0"; + JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); + String code = "0"; String accountId = ""; - String name= ""; - String gh= ""; - String deptName= ""; - String isLock= ""; - double money=0; - if(params!=null){ - Long id= Long.parseLong(params.get("pay_code")+""); - SysPeople people=peopleService.selectSysPeopleById(id); - if(people!=null){ - accountId=people.getId()+""; - code="0"; - money=(people.getCzje()+people.getBtje()); - name=people.getName(); - gh=people.getGh(); - deptName=people.getBranch().getName(); - isLock=people.getIsLock(); - }else{ - code="1"; + String name = ""; + String gh = ""; + String deptName = ""; + String isLock = ""; + double money = 0; + if (params != null) { + Long id = Long.parseLong(params.get("pay_code") + ""); + SysPeople people = peopleService.selectSysPeopleById(id); + if (people != null) { + accountId = people.getId() + ""; + code = "0"; + money = (people.getCzje() + people.getBtje()); + name = people.getName(); + gh = people.getGh(); + deptName = people.getBranch().getName(); + isLock = people.getIsLock(); + } else { + code = "1"; } - }else{ - code="1"; + } else { + code = "1"; } - String transactionId=json.get("transaction_id")+""; - result.put("api","infoquery"); - result.put("query_code","0"); - result.put("interval","10000"); - result.put("result_code",code); - Long time=new Date().getTime()/1000; - String noncestr= UUID.randomUUID().toString(); - result.put("time",time); - String sign= EncodeByMD5(time+noncestr+"FFFFFFFFFFFF"); - result.put("sign",sign); - result.put("transaction_id",transactionId); - result.put("result_msg",""); - result.put("noncestr",noncestr); - JSONArray results=new JSONArray(); - JSONObject results1=new JSONObject(); - results1.put("account_id",accountId); - results1.put("consume",""); - results1.put("balance",money); - results1.put("emp_id",gh); - results1.put("depart_name",deptName); - results1.put("sign",EncodeByMD5(accountId+"100000"+time+noncestr+"FFFFFFFFFFFF")); + String transactionId = json.get("transaction_id") + ""; + result.put("api", "infoquery"); + result.put("query_code", "0"); + result.put("interval", "10000"); + result.put("result_code", code); + Long time = new Date().getTime() / 1000; + String noncestr = UUID.randomUUID().toString(); + result.put("time", time); + String sign = EncodeByMD5(time + noncestr + "FFFFFFFFFFFF"); + result.put("sign", sign); + result.put("transaction_id", transactionId); + result.put("result_msg", ""); + result.put("noncestr", noncestr); + JSONArray results = new JSONArray(); + JSONObject results1 = new JSONObject(); + results1.put("account_id", accountId); + results1.put("consume", ""); + results1.put("balance", money); + results1.put("emp_id", gh); + results1.put("depart_name", deptName); + results1.put("sign", EncodeByMD5(accountId + "100000" + time + noncestr + "FFFFFFFFFFFF")); results.add(results1); - result.put("result",results); - result.put("tts",name+"当前余额"+money+"元"); - JSONArray msg=new JSONArray(); - if ("0".equals(code)){ - if("1".equals(isLock)){ - JSONObject obj=new JSONObject(); - obj.put("line","查询成功"); - JSONObject obj1=new JSONObject(); - obj1.put("line","账号挂失,请解挂"); + result.put("result", results); + result.put("tts", name + "当前余额" + money + "元"); + JSONArray msg = new JSONArray(); + if ("0".equals(code)) { + if ("1".equals(isLock)) { + JSONObject obj = new JSONObject(); + obj.put("line", "查询成功"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "账号挂失,请解挂"); msg.add(obj); msg.add(obj1); - result.put("tts","账号挂失,请解挂"); - result.put("result_code","1"); - }else{ - JSONObject obj=new JSONObject(); - obj.put("line","查询成功"); - JSONObject obj1=new JSONObject(); - obj1.put("line","当前余额:"+money); + result.put("tts", "账号挂失,请解挂"); + result.put("result_code", "1"); + } else { + JSONObject obj = new JSONObject(); + obj.put("line", "查询成功"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "当前余额:" + money); msg.add(obj); msg.add(obj1); } - }else{ - JSONObject obj=new JSONObject(); - obj.put("line","查询失败"); - JSONObject obj1=new JSONObject(); - obj1.put("line","人事资料未找到"); + } else { + JSONObject obj = new JSONObject(); + obj.put("line", "查询失败"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "人事资料未找到"); msg.add(obj); msg.add(obj1); - result.put("tts","查询失败"); + result.put("tts", "查询失败"); } - result.put("msg",msg); - return result; + result.put("msg", msg); + return result; } - if("posonline".equals(api)){ + //判断是否是无点餐接口 + if ("posonline".equals(api)) { //无点餐时上传 - JSONObject params= JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); - String devId=json.get("dev_id")+""; - SysPeople people=new SysPeople(); + JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); + String devId = json.getString("dev_id"); + SysPeople people = new SysPeople(); //总金额 - Long amount= Long.parseLong(params.get("amount")+"");//交易金额 - String code="0"; - double money=0; - if(StringUtils.isNotEmpty(params.get("pay_code")+"")){ - Long id= Long.parseLong(params.get("pay_code")+""); - people=peopleService.selectSysPeopleById(id); - if("2".equals(people.getType())){ - amount=100L; + Long amount = Long.parseLong(params.get("amount") + "");//交易金额 + String code = "0"; + double money = 0; + if (StringUtils.isNotEmpty(params.get("pay_code") + "")) { + Long id = Long.parseLong(params.get("pay_code") + ""); + people = peopleService.selectSysPeopleById(id); + if ("2".equals(people.getType())) { + amount = 100L; } - money=(people.getCzje()+people.getBtje())*100; - if (money>=amount){ - code="0"; - }else { - code="1"; + money = (people.getCzje() + people.getBtje()) * 100; + if (money >= amount) { + code = "0"; + } else { + code = "1"; } - }else{ - code="2"; - SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + } else { + code = "2"; + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); try { - Date date=sdf1.parse(sdf2.format(new Date())+" 10:00:00"); - if(date.getTime()>new Date().getTime()){ - amount=500L; - }else{ - amount=1500L; + Date date = sdf1.parse(sdf2.format(new Date()) + " 10:00:00"); + if (date.getTime() > new Date().getTime()) { + amount = 500L; + } else { + amount = 1500L; } } catch (ParseException e) { throw new RuntimeException(e); } } - String accountId=people.getId()+""; - String transactionId=json.get("transaction_id")+""; + String accountId = people.getId() + ""; + String transactionId = json.get("transaction_id") + ""; //服务器应答 - result.put("api","posonline"); - result.put("interval","10000"); - String noncestr= UUID.randomUUID().toString(); - result.put("noncestr",noncestr); - Long time=new Date().getTime()/1000; - result.put("time",time); - String sign= EncodeByMD5(time+noncestr+"FFFFFFFFFFFF"); - result.put("sign",sign); - result.put("transaction_id",transactionId); - result.put("result_code",code); - result.put("result_msg",""); - JSONArray results=new JSONArray(); - JSONObject results1=new JSONObject(); - results1.put("account_id",accountId); - results1.put("emp_id",people.getGh()); - results1.put("emp_fname",people.getName()); - results1.put("consume_money",params.get("amount")); - results1.put("discount_money","0"); - results1.put("balance",money); - result.put("trade_id",params.get("trade_id")); - results1.put("sign",EncodeByMD5(accountId+money+time+noncestr+"FFFFFFFFFFFF")); + result.put("api", "posonline"); + result.put("interval", "10000"); + String noncestr = UUID.randomUUID().toString(); + result.put("noncestr", noncestr); + Long time = new Date().getTime() / 1000; + result.put("time", time); + String sign = EncodeByMD5(time + noncestr + "FFFFFFFFFFFF"); + result.put("sign", sign); + result.put("transaction_id", transactionId); + result.put("result_code", code); + result.put("result_msg", ""); + JSONArray results = new JSONArray(); + JSONObject results1 = new JSONObject(); + results1.put("account_id", accountId); + results1.put("emp_id", people.getGh()); + results1.put("emp_fname", people.getName()); + results1.put("consume_money", params.get("amount")); + results1.put("discount_money", "0"); + results1.put("balance", money); + result.put("trade_id", params.get("trade_id")); + results1.put("sign", EncodeByMD5(accountId + money + time + noncestr + "FFFFFFFFFFFF")); results.add(results1); - result.put("result",results); + result.put("result", results); DecimalFormat df = new DecimalFormat("0.00"); - JSONArray msg=new JSONArray(); + JSONArray msg = new JSONArray(); /* //判断是否是同一订单,若是同一订单就不扣钱 ConsumeRecord consumeRecords=consumeRecordService.selectConsumeRecordByOutTradeId(params.get("trade_id")+""); if(consumeRecords!=null){ @@ -798,120 +799,120 @@ public class CardController { result.put("result_code", "1"); return result; }*/ - if("3".equals(people.getType())){ + if ("3".equals(people.getType())) { - }else if("2".equals(people.getType())){ + } else if ("2".equals(people.getType())) { - }else{ - SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); - Date startDate=new Date(Long.parseLong(params.get("sign_time")+"")); - String timeType=""; - try { - Date date1=sdf1.parse(sdf2.format(startDate)+" 14:00:00"); - Date date2=sdf1.parse(sdf2.format(startDate)+" 16:00:00"); - if(date1.getTime()>startDate.getTime()){ - timeType="2"; - }else if(date2.getTime() startDate.getTime()) { + timeType = "2"; + } else if (date2.getTime() < startDate.getTime()) { + timeType = "3"; + } else { + timeType = "4"; + } + } catch (ParseException e) { + throw new RuntimeException(e); + } + Map paramMap = new HashMap<>(); + paramMap.put("recordDateTime", sdf1.format(startDate)); + paramMap.put("code", people.getId());//认证人员员工号 + paramMap.put("consumeInterval", timeType); + //请求当天的消费信息 + JSONObject jsons1 = queryPeopleDay(paramMap); + if (!"0".equals(jsons1.get("code") + "")) { + result.put("tts", jsons1.get("msg") + ""); + JSONObject obj = new JSONObject(); + obj.put("line", jsons1.get("msg") + ""); + msg.add(obj); + result.put("msg", msg); + result.put("result_code", "1"); + return result; } - } catch (ParseException e) { - throw new RuntimeException(e); - } - Map paramMap =new HashMap<>(); - paramMap.put("recordDateTime",sdf1.format(startDate)); - paramMap.put("code",people.getId());//认证人员员工号 - paramMap.put("consumeInterval",timeType); - //请求当天的消费信息 - JSONObject jsons1=queryPeopleDay(paramMap); - if(!"0".equals(jsons1.get("code")+"")){ - result.put("tts",jsons1.get("msg")+""); - JSONObject obj = new JSONObject(); - obj.put("line",jsons1.get("msg")+""); - msg.add(obj); - result.put("msg",msg); - result.put("result_code","1"); - return result; - } } } - System.out.println("result1==="+result); + System.out.println("result1===" + result); //保存消费记录 - ConsumeRecord consumeRecord =new ConsumeRecord(); + ConsumeRecord consumeRecord = new ConsumeRecord(); consumeRecord.setEmpId(people.getGh()); - if("null".equals(accountId)){ + if ("null".equals(accountId)) { consumeRecord.setAccountId(null); - }else{ + } else { consumeRecord.setAccountId(accountId); } - consumeRecord.setConsumeMode(params.get("consume_mode")+""); - consumeRecord.setConsumeMoney(Double.parseDouble(amount+"")/100+""); - consumeRecord.setOutTradeId(params.get("trade_id")+""); - consumeRecord.setStartTime(params.get("sign_time")+""); - consumeRecord.setEndTime(new Date().getTime()+""); + consumeRecord.setConsumeMode(params.get("consume_mode") + ""); + consumeRecord.setConsumeMoney(Double.parseDouble(amount + "") / 100 + ""); + consumeRecord.setOutTradeId(params.get("trade_id") + ""); + consumeRecord.setStartTime(params.get("sign_time") + ""); + consumeRecord.setEndTime(new Date().getTime() + ""); consumeRecord.setResultCode("0"); - consumeRecord.setPayMode(params.get("pay_mode")+""); + consumeRecord.setPayMode(params.get("pay_mode") + ""); consumeRecord.setOrderType("0"); consumeRecord.setWalletConsumeMode("0"); consumeRecord.setDevId(devId); - Date startDate=new Date(Long.parseLong(params.get("sign_time")+"")); + Date startDate = new Date(Long.parseLong(params.get("sign_time") + "")); consumeRecord.setStartDate(startDate); consumeRecord.setEndDate(new Date()); - if ("0".equals(code)){ - double amounts=Double.parseDouble(amount+"")/100; + if ("0".equals(code)) { + double amounts = Double.parseDouble(amount + "") / 100; //result.put("tts","消费"+df.format(amounts)+"元"); - result.put("tts","谢谢"); - JSONObject obj=new JSONObject(); - obj.put("line","姓名:"+people.getName()); + result.put("tts", "谢谢"); + JSONObject obj = new JSONObject(); + obj.put("line", "姓名:" + people.getName()); msg.add(obj); - JSONObject obj1=new JSONObject(); - obj1.put("line","消费:"+df.format(amounts)+"元"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "消费:" + df.format(amounts) + "元"); msg.add(obj1); - JSONObject obj2=new JSONObject(); - obj2.put("line","余:"+df.format((money-amount)/100)+"元"); + JSONObject obj2 = new JSONObject(); + obj2.put("line", "余:" + df.format((money - amount) / 100) + "元"); msg.add(obj2); - consumeRecord.setDiscountMoney(df.format((money-amount)/100)); - if(people.getBtje()*100>=amount){ - Double btje =(people.getBtje()*100-amount)/100; + consumeRecord.setDiscountMoney(df.format((money - amount) / 100)); + if (people.getBtje() * 100 >= amount) { + Double btje = (people.getBtje() * 100 - amount) / 100; people.setBtje(Double.valueOf(df.format(btje))); - }else{ + } else { people.setBtje((double) 0); - Double czje = (money-amount)/100; - consumeRecord.setWalletConsumeMode(df.format(people.getCzje()-czje)); + Double czje = (money - amount) / 100; + consumeRecord.setWalletConsumeMode(df.format(people.getCzje() - czje)); people.setCzje(Double.valueOf(df.format(czje))); } peopleService.updateSysPeople(people); - }else if ("2".equals(code)){ + } else if ("2".equals(code)) { //支付宝(暂时接入支付宝支付)/微信支付 - String qrCode =params.get("qr_code")+""; - if(this.codevale(qrCode)){ + String qrCode = params.get("qr_code") + ""; + if (this.codevale(qrCode)) { consumeRecord.setConsumeResult("0"); consumeRecord.setPayMode("3"); consumeRecord.setRemark("支付宝支付"); try { AlipayConfig alipayConfig = new AlipayConfig();// 支付宝配置 - if(alipayConfig.isIsable()){ - double amounts=Double.parseDouble(amount+"")/100; - result.put("tts","消费"+df.format(amounts)+"元"); + if (alipayConfig.isIsable()) { + double amounts = Double.parseDouble(amount + "") / 100; + result.put("tts", "消费" + df.format(amounts) + "元"); result.put("result_code", "0"); //result.put("tts","谢谢"); - JSONObject obj=new JSONObject(); - obj.put("line","消费"+df.format(amounts)+"元"); - JSONObject obj1=new JSONObject(); - obj1.put("line","支付宝支付"); + JSONObject obj = new JSONObject(); + obj.put("line", "消费" + df.format(amounts) + "元"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "支付宝支付"); msg.add(obj); msg.add(obj1); - sendZfb(params.get("trade_id")+"",qrCode,amounts); - }else{ - double amounts=Double.parseDouble(amount+"")/100; - result.put("tts","消费"+df.format(amounts)+"元失败,请联系管理员"); + sendZfb(params.get("trade_id") + "", qrCode, amounts); + } else { + double amounts = Double.parseDouble(amount + "") / 100; + result.put("tts", "消费" + df.format(amounts) + "元失败,请联系管理员"); result.put("result_code", "1"); - JSONObject obj=new JSONObject(); - obj.put("line","消费"+df.format(amounts)+"元失败,请联系管理员"); - JSONObject obj1=new JSONObject(); - obj1.put("line","支付宝支付"); + JSONObject obj = new JSONObject(); + obj.put("line", "消费" + df.format(amounts) + "元失败,请联系管理员"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "支付宝支付"); msg.add(obj); msg.add(obj1); consumeRecord.setConsumeResult("1"); @@ -919,31 +920,31 @@ public class CardController { } catch (AlipayApiException e) { throw new RuntimeException(e); } - }else{ + } else { consumeRecord.setConsumeResult("0"); consumeRecord.setPayMode("4"); consumeRecord.setRemark("微信支付"); try { WxPayConfig wxPayConfig = new WxPayConfig();//微信配置 - if(wxPayConfig.isIsable()) { - double amounts=Double.parseDouble(amount+"")/100; - result.put("tts","消费"+df.format(amounts)+"元"); + if (wxPayConfig.isIsable()) { + double amounts = Double.parseDouble(amount + "") / 100; + result.put("tts", "消费" + df.format(amounts) + "元"); result.put("result_code", "0"); // result.put("tts","谢谢"); - JSONObject obj=new JSONObject(); - obj.put("line","消费"+df.format(amounts)+"元"); - JSONObject obj1=new JSONObject(); - obj1.put("line","微信支付"); + JSONObject obj = new JSONObject(); + obj.put("line", "消费" + df.format(amounts) + "元"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "微信支付"); msg.add(obj); msg.add(obj1); sendWeixin(params.get("trade_id") + "", qrCode, Integer.parseInt(amount + ""), consumeRecord); - }else{ - double amounts=Double.parseDouble(amount+"")/100; - result.put("tts","消费"+df.format(amounts)+"元失败,请联系管理员"); - JSONObject obj=new JSONObject(); - obj.put("line","消费"+df.format(amounts)+"元失败,请联系管理员"); - JSONObject obj1=new JSONObject(); - obj1.put("line","微信支付"); + } else { + double amounts = Double.parseDouble(amount + "") / 100; + result.put("tts", "消费" + df.format(amounts) + "元失败,请联系管理员"); + JSONObject obj = new JSONObject(); + obj.put("line", "消费" + df.format(amounts) + "元失败,请联系管理员"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "微信支付"); msg.add(obj); msg.add(obj1); consumeRecord.setConsumeResult("1"); @@ -952,37 +953,36 @@ public class CardController { throw new RuntimeException(e); } } - } - else{ - result.put("tts","余次不足"); - JSONObject obj=new JSONObject(); - obj.put("line","余次不足" ); - JSONObject obj1=new JSONObject(); - obj1.put("line","当前余次:"+df.format(money/100)); + } else { + result.put("tts", "余次不足"); + JSONObject obj = new JSONObject(); + obj.put("line", "余次不足"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "当前余次:" + df.format(money / 100)); msg.add(obj); msg.add(obj1); consumeRecord.setConsumeResult("1"); consumeRecord.setRemark("余额不足"); } - consumeRecord.setDevId(json.get("dev_id")+""); - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - List consumeTimeIntervals=consumeTimeIntervalService.selectConsumeTimeIntervalList(new ConsumeTimeInterval()); - for(ConsumeTimeInterval cti:consumeTimeIntervals ){ + consumeRecord.setDevId(json.get("dev_id") + ""); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + List consumeTimeIntervals = consumeTimeIntervalService.selectConsumeTimeIntervalList(new ConsumeTimeInterval()); + for (ConsumeTimeInterval cti : consumeTimeIntervals) { try { - Date start=sdf1.parse(sdf.format(new Date())+" "+cti.getStartTime()); - Date end=sdf1.parse(sdf.format(new Date())+" "+cti.getEndTime()); - if("3".equals(cti.getTmrtype())){ + Date start = sdf1.parse(sdf.format(new Date()) + " " + cti.getStartTime()); + Date end = sdf1.parse(sdf.format(new Date()) + " " + cti.getEndTime()); + if ("3".equals(cti.getTmrtype())) { Calendar calendar = new GregorianCalendar(); calendar.setTime(end); calendar.add(Calendar.DATE, 1); end = calendar.getTime(); - if(start.getTime()new Date().getTime()){ + if (start.getTime() < new Date().getTime() && end.getTime() > new Date().getTime()) { consumeRecord.setTimeId(cti.getId()); break; } - }else { - if(start.getTime()new Date().getTime()){ + } else { + if (start.getTime() < new Date().getTime() && end.getTime() > new Date().getTime()) { consumeRecord.setTimeId(cti.getId()); break; } @@ -992,243 +992,243 @@ public class CardController { } } - if(!"2".equals(consumeRecord.getOrderType())){//排除更正 + if (!"2".equals(consumeRecord.getOrderType())) {//排除更正 consumeRecordService.insertConsumeRecord(consumeRecord); } - result.put("msg",msg); - System.out.println("系统发送数据===="+result); - return result; + result.put("msg", msg); + System.out.println("系统发送数据====" + result); + return result; } - if("recordquery".equals(api)){//查询记录recordquery应答 - String transactionId=json.get("transaction_id")+""; - String devId=json.get("dev_id")+""; + if ("recordquery".equals(api)) {//查询记录recordquery应答 + String transactionId = json.get("transaction_id") + ""; + String devId = json.get("dev_id") + ""; //服务器应答 - result.put("api","recordquery"); - result.put("interval","10000"); - String noncestr= UUID.randomUUID().toString(); - result.put("noncestr",noncestr); - Long time=new Date().getTime()/1000; - result.put("time",time); - String sign= EncodeByMD5(time+noncestr+"FFFFFFFFFFFF"); - result.put("sign",sign); - result.put("transaction_id",transactionId); - ConsumeRecord consumeRecord= new ConsumeRecord(); + result.put("api", "recordquery"); + result.put("interval", "10000"); + String noncestr = UUID.randomUUID().toString(); + result.put("noncestr", noncestr); + Long time = new Date().getTime() / 1000; + result.put("time", time); + String sign = EncodeByMD5(time + noncestr + "FFFFFFFFFFFF"); + result.put("sign", sign); + result.put("transaction_id", transactionId); + ConsumeRecord consumeRecord = new ConsumeRecord(); consumeRecord.setDevId(devId); List list = consumeRecordService.selectConsumeRecordAllList(consumeRecord); - String code="0"; - if(list.size()>0){ - code="0"; - }else{ - code="1"; + String code = "0"; + if (list.size() > 0) { + code = "0"; + } else { + code = "1"; } - result.put("result_code",code); - result.put("result_msg",""); - result.put("tts","查询成功"); - JSONArray msg=new JSONArray(); - for(ConsumeRecord cr:list){ - JSONObject obj=new JSONObject(); - if("1".equals(cr.getConsumeResult())){ - obj.put("line","姓名:"+cr.getAccountName()+",消费失败:"+cr.getConsumeMoney()+"元 "+cr.getRemark()); - }else{ - obj.put("line","姓名:"+cr.getAccountName()+",消费成功:"+cr.getConsumeMoney()+"元"); + result.put("result_code", code); + result.put("result_msg", ""); + result.put("tts", "查询成功"); + JSONArray msg = new JSONArray(); + for (ConsumeRecord cr : list) { + JSONObject obj = new JSONObject(); + if ("1".equals(cr.getConsumeResult())) { + obj.put("line", "姓名:" + cr.getAccountName() + ",消费失败:" + cr.getConsumeMoney() + "元 " + cr.getRemark()); + } else { + obj.put("line", "姓名:" + cr.getAccountName() + ",消费成功:" + cr.getConsumeMoney() + "元"); } msg.add(obj); } - result.put("msg",msg); + result.put("msg", msg); - return result; + return result; } - if("correctonline".equals(api)){//查询记录recordquery应答 - String transactionId=json.get("transaction_id")+""; - String devId=json.get("dev_id")+""; + if ("correctonline".equals(api)) {//查询记录recordquery应答 + String transactionId = json.get("transaction_id") + ""; + String devId = json.get("dev_id") + ""; //服务器应答 - result.put("api","correctonline"); - result.put("interval","10000"); - String noncestr= UUID.randomUUID().toString(); - result.put("noncestr",noncestr); - Long time=new Date().getTime()/1000; - result.put("time",time); - String sign= EncodeByMD5(time+noncestr+"FFFFFFFFFFFF"); - result.put("sign",sign); - result.put("transaction_id",transactionId); - JSONArray results=new JSONArray(); - JSONObject results1=new JSONObject(); + result.put("api", "correctonline"); + result.put("interval", "10000"); + String noncestr = UUID.randomUUID().toString(); + result.put("noncestr", noncestr); + Long time = new Date().getTime() / 1000; + result.put("time", time); + String sign = EncodeByMD5(time + noncestr + "FFFFFFFFFFFF"); + result.put("sign", sign); + result.put("transaction_id", transactionId); + JSONArray results = new JSONArray(); + JSONObject results1 = new JSONObject(); String accountId = ""; - JSONObject params= JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); - String code="0"; - if(params!=null){ - Long id= Long.parseLong(params.get("pay_code")+""); - SysPeople people=peopleService.selectSysPeopleById(id); - if(people!=null){ - accountId=people.getId()+""; - code="0"; - }else{ - code="1"; + JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); + String code = "0"; + if (params != null) { + Long id = Long.parseLong(params.get("pay_code") + ""); + SysPeople people = peopleService.selectSysPeopleById(id); + if (people != null) { + accountId = people.getId() + ""; + code = "0"; + } else { + code = "1"; } - ConsumeRecord consumeRecord= new ConsumeRecord(); + ConsumeRecord consumeRecord = new ConsumeRecord(); consumeRecord.setDevId(devId); - consumeRecord.setAccountId(params.get("pay_code")+""); + consumeRecord.setAccountId(params.get("pay_code") + ""); List list = consumeRecordService.selectConsumeRecordList(consumeRecord); - Double amount= Double.valueOf(0); - if(list.size()>0){ - ConsumeRecord consumeRecords=list.get(0); - if("1".equals(consumeRecords.getConsumeResult())&&"更正消费".equals(consumeRecords.getRemark())){ - code="2"; - }else{ - amount=Double.parseDouble(consumeRecords.getConsumeMoney()); + Double amount = Double.valueOf(0); + if (list.size() > 0) { + ConsumeRecord consumeRecords = list.get(0); + if ("1".equals(consumeRecords.getConsumeResult()) && "更正消费".equals(consumeRecords.getRemark())) { + code = "2"; + } else { + amount = Double.parseDouble(consumeRecords.getConsumeMoney()); consumeRecords.setConsumeResult("1"); consumeRecords.setRemark("更正消费"); consumeRecordService.updateConsumeRecord(consumeRecords); DecimalFormat df = new DecimalFormat("0.00"); - if("0".equals(consumeRecords.getWalletConsumeMode())){ - people.setBtje(Double.valueOf(df.format(amount+people.getBtje()))); - }else{ - people.setCzje(Double.parseDouble(consumeRecords.getWalletConsumeMode())+people.getCzje()); - if (amount>Double.parseDouble(consumeRecords.getWalletConsumeMode())){ - people.setBtje(Double.valueOf(amount-Double.parseDouble(consumeRecords.getWalletConsumeMode()))); + if ("0".equals(consumeRecords.getWalletConsumeMode())) { + people.setBtje(Double.valueOf(df.format(amount + people.getBtje()))); + } else { + people.setCzje(Double.parseDouble(consumeRecords.getWalletConsumeMode()) + people.getCzje()); + if (amount > Double.parseDouble(consumeRecords.getWalletConsumeMode())) { + people.setBtje(Double.valueOf(amount - Double.parseDouble(consumeRecords.getWalletConsumeMode()))); } } peopleService.updateSysPeople(people); - code="0"; + code = "0"; } - }else{ - code="1"; + } else { + code = "1"; } - result.put("result_msg",""); - result.put("tts","退款"+amount+"元"); - double money=(people.getCzje()+people.getBtje())*100; - results1.put("account_id",accountId); - results1.put("emp_id",people.getGh()); - results1.put("emp_fname",people.getName()); - results1.put("consume_money",amount*100+""); - results1.put("balance",money+amount*100+""); - results1.put("trade_id",params.get("trade_id")); - results1.put("sign",EncodeByMD5(accountId+people.getGh()+people.getName()+amount*100+time+noncestr+"FFFFFFFFFFFF")); + result.put("result_msg", ""); + result.put("tts", "退款" + amount + "元"); + double money = (people.getCzje() + people.getBtje()) * 100; + results1.put("account_id", accountId); + results1.put("emp_id", people.getGh()); + results1.put("emp_fname", people.getName()); + results1.put("consume_money", amount * 100 + ""); + results1.put("balance", money + amount * 100 + ""); + results1.put("trade_id", params.get("trade_id")); + results1.put("sign", EncodeByMD5(accountId + people.getGh() + people.getName() + amount * 100 + time + noncestr + "FFFFFFFFFFFF")); results.add(results1); - result.put("result",results); - }else{ - code="1"; + result.put("result", results); + } else { + code = "1"; } - result.put("result_code",code); - JSONArray msg=new JSONArray(); - if ("0".equals(code)){ - JSONObject obj=new JSONObject(); - obj.put("line","更正成功"); + result.put("result_code", code); + JSONArray msg = new JSONArray(); + if ("0".equals(code)) { + JSONObject obj = new JSONObject(); + obj.put("line", "更正成功"); msg.add(obj); - }else if ("2".equals(code)){ - JSONObject obj=new JSONObject(); - obj.put("line","最近消费记录已更正"); + } else if ("2".equals(code)) { + JSONObject obj = new JSONObject(); + obj.put("line", "最近消费记录已更正"); msg.add(obj); - }else{ - JSONObject obj=new JSONObject(); - obj.put("line","更正失败"); + } else { + JSONObject obj = new JSONObject(); + obj.put("line", "更正失败"); msg.add(obj); } - result.put("msg",msg); - System.out.println("发送的json===="+result); - return result; + result.put("msg", msg); + System.out.println("发送的json====" + result); + return result; } - if("sumonline".equals(api)){//汇总sumonline应答 - String transactionId=json.get("transaction_id")+""; - String devId=json.get("dev_id")+""; + if ("sumonline".equals(api)) {//汇总sumonline应答 + String transactionId = json.get("transaction_id") + ""; + String devId = json.get("dev_id") + ""; //服务器应答 - result.put("api","sumonline"); - result.put("interval","10000"); - String noncestr= UUID.randomUUID().toString(); - result.put("noncestr",noncestr); - Long time=new Date().getTime()/1000; - result.put("time",time); - String sign= EncodeByMD5(time+noncestr+"FFFFFFFFFFFF"); - result.put("sign",sign); - result.put("transaction_id",transactionId); - result.put("result_msg",""); - String code="0"; - result.put("result_code",code); - result.put("tts","消费汇总"); - JSONArray msg=new JSONArray(); - if ("0".equals(code)){ - JSONObject obj1=new JSONObject(); - obj1.put("line","当日汇总"); + result.put("api", "sumonline"); + result.put("interval", "10000"); + String noncestr = UUID.randomUUID().toString(); + result.put("noncestr", noncestr); + Long time = new Date().getTime() / 1000; + result.put("time", time); + String sign = EncodeByMD5(time + noncestr + "FFFFFFFFFFFF"); + result.put("sign", sign); + result.put("transaction_id", transactionId); + result.put("result_msg", ""); + String code = "0"; + result.put("result_code", code); + result.put("tts", "消费汇总"); + JSONArray msg = new JSONArray(); + if ("0".equals(code)) { + JSONObject obj1 = new JSONObject(); + obj1.put("line", "当日汇总"); msg.add(obj1); - List> list=consumeRecordService.selectConsumeRecordSumonline(devId); - for(Map cr:list){ - JSONObject obj=new JSONObject(); - obj.put("line",cr.get("name")+":次数:"+cr.get("num")+"次,消费:"+cr.get("money")+"元"); + List> list = consumeRecordService.selectConsumeRecordSumonline(devId); + for (Map cr : list) { + JSONObject obj = new JSONObject(); + obj.put("line", cr.get("name") + ":次数:" + cr.get("num") + "次,消费:" + cr.get("money") + "元"); msg.add(obj); } - JSONObject obj2=new JSONObject(); - obj2.put("line","当月汇总"); + JSONObject obj2 = new JSONObject(); + obj2.put("line", "当月汇总"); msg.add(obj2); - List> lists=consumeRecordService.selectConsumeRecordSumonlineMonth(devId); - for(Map cr:lists){ - JSONObject obj=new JSONObject(); - obj.put("line",cr.get("name")+":次数:"+cr.get("num")+"次,消费:"+cr.get("money")+"元"); + List> lists = consumeRecordService.selectConsumeRecordSumonlineMonth(devId); + for (Map cr : lists) { + JSONObject obj = new JSONObject(); + obj.put("line", cr.get("name") + ":次数:" + cr.get("num") + "次,消费:" + cr.get("money") + "元"); msg.add(obj); } - }else{ - JSONObject obj=new JSONObject(); - obj.put("line","查询失败"); + } else { + JSONObject obj = new JSONObject(); + obj.put("line", "查询失败"); msg.add(obj); } - result.put("msg",msg); - return result; + result.put("msg", msg); + return result; } - if("rechargeonline".equals(api)){//汇总sumonline应答 - JSONObject params= JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); - Long amount= Long.parseLong(params.get("amount")+"");//交易金额 - String account_id=params.get("pay_code")+""; - String trade_id=params.get("trade_id")+""; + if ("rechargeonline".equals(api)) {//汇总sumonline应答 + JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); + Long amount = Long.parseLong(params.get("amount") + "");//交易金额 + String account_id = params.get("pay_code") + ""; + String trade_id = params.get("trade_id") + ""; - SysPeople people=peopleService.selectSysPeopleById(Long.parseLong(account_id)); - String transactionId=json.get("transaction_id")+""; + SysPeople people = peopleService.selectSysPeopleById(Long.parseLong(account_id)); + String transactionId = json.get("transaction_id") + ""; //服务器应答 - result.put("api","rechargeonline"); - result.put("interval","10000"); - String noncestr= UUID.randomUUID().toString(); - result.put("noncestr",noncestr); - Long time=new Date().getTime()/1000; - result.put("time",time); - String sign= EncodeByMD5(time+noncestr+"FFFFFFFFFFFF"); - result.put("sign",sign); - result.put("transaction_id",transactionId); - result.put("result_msg",""); - String code="0"; - result.put("result_code",code); - double amounts=Double.parseDouble(amount+"")/100; - result.put("tts","充值"+amounts+"元"); - JSONArray msg=new JSONArray(); - if ("0".equals(code)){ - JSONObject obj1=new JSONObject(); - obj1.put("line","姓名:"+people.getName()); + result.put("api", "rechargeonline"); + result.put("interval", "10000"); + String noncestr = UUID.randomUUID().toString(); + result.put("noncestr", noncestr); + Long time = new Date().getTime() / 1000; + result.put("time", time); + String sign = EncodeByMD5(time + noncestr + "FFFFFFFFFFFF"); + result.put("sign", sign); + result.put("transaction_id", transactionId); + result.put("result_msg", ""); + String code = "0"; + result.put("result_code", code); + double amounts = Double.parseDouble(amount + "") / 100; + result.put("tts", "充值" + amounts + "元"); + JSONArray msg = new JSONArray(); + if ("0".equals(code)) { + JSONObject obj1 = new JSONObject(); + obj1.put("line", "姓名:" + people.getName()); msg.add(obj1); - JSONObject obj2=new JSONObject(); - obj2.put("line","充值:"+amounts); + JSONObject obj2 = new JSONObject(); + obj2.put("line", "充值:" + amounts); msg.add(obj2); - JSONObject obj3=new JSONObject(); - obj3.put("line","余:"); + JSONObject obj3 = new JSONObject(); + obj3.put("line", "余:"); msg.add(obj3); DecimalFormat df = new DecimalFormat("0.00"); - Double czje = people.getCzje()+amounts; + Double czje = people.getCzje() + amounts; people.setCzje(Double.valueOf(df.format(czje))); peopleService.updateSysPeople(people); - }else{ - JSONObject obj=new JSONObject(); - obj.put("line","充值失败"); + } else { + JSONObject obj = new JSONObject(); + obj.put("line", "充值失败"); msg.add(obj); } - result.put("msg",msg); - JSONArray result1=new JSONArray(); - JSONObject obj=new JSONObject(); - obj.put("account_id",account_id); - obj.put("emp_id",people.getGh()); - obj.put("emp_fname",people.getName()); - obj.put("consume_money",amount); - obj.put("trade_id",params.get("trade_id")+""); - String sign1= EncodeByMD5(account_id+people.getGh()+people.getName()+amount+trade_id+time+noncestr+"FFFFFFFFFFFF"); - obj.put("sign",sign1); + result.put("msg", msg); + JSONArray result1 = new JSONArray(); + JSONObject obj = new JSONObject(); + obj.put("account_id", account_id); + obj.put("emp_id", people.getGh()); + obj.put("emp_fname", people.getName()); + obj.put("consume_money", amount); + obj.put("trade_id", params.get("trade_id") + ""); + String sign1 = EncodeByMD5(account_id + people.getGh() + people.getName() + amount + trade_id + time + noncestr + "FFFFFFFFFFFF"); + obj.put("sign", sign1); result1.add(obj); - result.put("result",result1); - return result; + result.put("result", result1); + return result; } return result; } @@ -1388,94 +1388,94 @@ public class CardController { return; } - @RequestMapping(value = "realpass",method = RequestMethod.POST) + @RequestMapping(value = "realpass", method = RequestMethod.POST) @ApiOperation("人脸设备实时控制") - public JSONObject realpass(@RequestBody JSONObject json){ - System.out.println("人脸设备实时控制========="+json); - JSONObject result=new JSONObject(); - JSONObject params= JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); - String account_id=params.get("pay_code")+""; - String devId=json.get("dev_id")+""; - SysPeople people=peopleService.selectSysPeopleById(Long.parseLong(account_id)); - SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public JSONObject realpass(@RequestBody JSONObject json) { + System.out.println("人脸设备实时控制=========" + json); + JSONObject result = new JSONObject(); + JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); + String account_id = params.getString("pay_code"); + String devId = json.getString("dev_id"); + SysPeople people = peopleService.selectSysPeopleById(Long.parseLong(account_id)); + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); - Date startDate=new Date(Long.parseLong(params.get("sign_time")+"")); - String timeType=""; - Long timeId=0L; + Date startDate = new Date(params.getLong("sign_time")); + String timeType = ""; + Long timeId = 0L; try { - Date date1=sdf1.parse(sdf2.format(startDate)+" 14:00:00"); - Date date2=sdf1.parse(sdf2.format(startDate)+" 16:00:00"); - if(date1.getTime()>startDate.getTime()){ - timeType="2"; - timeId=187L; - }else if(date2.getTime() startDate.getTime()) { + timeType = "2"; + timeId = 187L; + } else if (date2.getTime() < startDate.getTime()) { + timeType = "3"; + timeId = 188L; + } else { + timeType = "4"; + timeId = 189L; } } catch (ParseException e) { throw new RuntimeException(e); } - Map paramMap =new HashMap<>(); - paramMap.put("recordDateTime",sdf1.format(startDate)); - paramMap.put("code",people.getId());//认证人员员工号 - paramMap.put("consumeInterval",timeType); + Map paramMap = new HashMap<>(); + paramMap.put("recordDateTime", sdf1.format(startDate)); + paramMap.put("code", people.getId());//认证人员员工号 + paramMap.put("consumeInterval", timeType); //请求当天的消费信息 - JSONObject jsons1=queryPeopleDay(paramMap); - if(!"0".equals(jsons1.get("code")+"")){ - result.put("tts",jsons1.get("msg")+""); - result.put("result_code","1"); - Long time=new Date().getTime()/1000; - String noncestr= UUID.randomUUID().toString(); - result.put("noncestr",noncestr); - JSONArray results=new JSONArray(); - JSONObject results1=new JSONObject(); - results1.put("account_id",account_id); - results1.put("emp_id",people.getGh()); - results1.put("emp_fname",people.getName()); - results1.put("card_sn",people.getDoorNo()); + JSONObject jsons1 = queryPeopleDay(paramMap); + if (!"0".equals(jsons1.get("code") + "")) { + result.put("tts", jsons1.get("msg") + ""); + result.put("result_code", "1"); + Long time = new Date().getTime() / 1000; + String noncestr = UUID.randomUUID().toString(); + result.put("noncestr", noncestr); + JSONArray results = new JSONArray(); + JSONObject results1 = new JSONObject(); + results1.put("account_id", account_id); + results1.put("emp_id", people.getGh()); + results1.put("emp_fname", people.getName()); + results1.put("card_sn", people.getDoorNo()); results.add(results1); - result.put("result",results); - result.put("time",time); - String sign= EncodeByMD5(time+noncestr+"FFFFFFFFFFFF"); - result.put("sign",sign); - result.put("result_msg",jsons1.get("msg")+""); + result.put("result", results); + result.put("time", time); + String sign = EncodeByMD5(time + noncestr + "FFFFFFFFFFFF"); + result.put("sign", sign); + result.put("result_msg", jsons1.get("msg") + ""); return result; } - result.put("tts","请通行"); - result.put("result_code",0); - Long time=new Date().getTime()/1000; - String noncestr= UUID.randomUUID().toString(); - result.put("noncestr",noncestr); - JSONArray results=new JSONArray(); - JSONObject results1=new JSONObject(); - results1.put("account_id",account_id); - results1.put("emp_id",people.getGh()); - results1.put("emp_fname",people.getName()); - results1.put("card_sn",people.getDoorNo()); + result.put("tts", "请通行"); + result.put("result_code", 0); + Long time = new Date().getTime() / 1000; + String noncestr = UUID.randomUUID().toString(); + result.put("noncestr", noncestr); + JSONArray results = new JSONArray(); + JSONObject results1 = new JSONObject(); + results1.put("account_id", account_id); + results1.put("emp_id", people.getGh()); + results1.put("emp_fname", people.getName()); + results1.put("card_sn", people.getDoorNo()); results.add(results1); - result.put("result",results); - result.put("time",time); - String sign= EncodeByMD5(time+noncestr+"FFFFFFFFFFFF"); - result.put("sign",sign); - result.put("result_msg","请通行"); + result.put("result", results); + result.put("time", time); + String sign = EncodeByMD5(time + noncestr + "FFFFFFFFFFFF"); + result.put("sign", sign); + result.put("result_msg", "请通行"); //保存消费记录 - ConsumeRecord consumeRecord =new ConsumeRecord(); + ConsumeRecord consumeRecord = new ConsumeRecord(); consumeRecord.setEmpId(people.getGh()); - if("null".equals(account_id)){ + if ("null".equals(account_id)) { consumeRecord.setAccountId(null); - }else{ + } else { consumeRecord.setAccountId(account_id); } - consumeRecord.setConsumeMode(params.get("consume_mode")+""); + consumeRecord.setConsumeMode(params.get("consume_mode") + ""); consumeRecord.setConsumeMoney(""); - consumeRecord.setOutTradeId(params.get("trade_id")+""); - consumeRecord.setStartTime(params.get("sign_time")+""); - consumeRecord.setEndTime(new Date().getTime()+""); + consumeRecord.setOutTradeId(params.get("trade_id") + ""); + consumeRecord.setStartTime(params.get("sign_time") + ""); + consumeRecord.setEndTime(new Date().getTime() + ""); consumeRecord.setResultCode("0"); - consumeRecord.setPayMode(params.get("pay_mode")+""); + consumeRecord.setPayMode(params.get("pay_mode") + ""); consumeRecord.setOrderType("0"); consumeRecord.setWalletConsumeMode("0"); consumeRecord.setDevId(devId); diff --git a/renren-api/src/main/resources/logback-spring.xml b/renren-api/src/main/resources/logback-spring.xml index 5deef21..69e09a2 100644 --- a/renren-api/src/main/resources/logback-spring.xml +++ b/renren-api/src/main/resources/logback-spring.xml @@ -1,21 +1,43 @@ - - - - + + + + + - - - - - - + + + + ${log.pattern} + + - - - - - - + + + ${log.path}/xf.log + + + + ${log.path}/xf.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + - \ No newline at end of file + + + + + + + + + + + + + +