作者 shenhailong

充值水费 返回二维码

@@ -24,6 +24,36 @@ @@ -24,6 +24,36 @@
24 </properties> 24 </properties>
25 25
26 <dependencies> 26 <dependencies>
  27 +
  28 + <!--水电缴费支付需要包-->
  29 + <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
  30 + <dependency>
  31 + <groupId>org.apache.httpcomponents</groupId>
  32 + <artifactId>httpclient</artifactId>
  33 + <version>4.5.12</version>
  34 + </dependency>
  35 +
  36 + <!-- https://mvnrepository.com/artifact/org.json/json -->
  37 + <dependency>
  38 + <groupId>org.json</groupId>
  39 + <artifactId>json</artifactId>
  40 + <version>20190722</version>
  41 + </dependency>
  42 +
  43 + <dependency>
  44 + <groupId>commons-httpclient</groupId>
  45 + <artifactId>commons-httpclient</artifactId>
  46 + <version>3.1</version>
  47 + </dependency>
  48 +
  49 + <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
  50 + <dependency>
  51 + <groupId>com.google.code.gson</groupId>
  52 + <artifactId>gson</artifactId>
  53 + <version>2.8.6</version>
  54 + </dependency>
  55 +
  56 +
27 <dependency> 57 <dependency>
28 <groupId>org.springframework.boot</groupId> 58 <groupId>org.springframework.boot</groupId>
29 <artifactId>spring-boot-starter-thymeleaf</artifactId> 59 <artifactId>spring-boot-starter-thymeleaf</artifactId>
@@ -66,4 +66,5 @@ public class PayOrderController { @@ -66,4 +66,5 @@ public class PayOrderController {
66 } 66 }
67 return mgs==1? new ResultJson("200","订单信息移出成功"):new ResultJson("500","订单信息删除失败"); 67 return mgs==1? new ResultJson("200","订单信息移出成功"):new ResultJson("500","订单信息删除失败");
68 } 68 }
  69 +
69 } 70 }
  1 +package com.sunyo.energy.location.controller;
  2 +
  3 +import com.sunyo.energy.location.controller.response.ResultJson;
  4 +import com.sunyo.energy.location.dao.PayResponseMapper;
  5 +import com.sunyo.energy.location.model.PayResponse;
  6 +import io.swagger.annotations.ApiOperation;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Controller;
  9 +import org.springframework.web.bind.annotation.RequestBody;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RequestParam;
  12 +import org.springframework.web.bind.annotation.ResponseBody;
  13 +
  14 +import java.math.BigDecimal;
  15 +import java.util.Date;
  16 +import java.util.UUID;
  17 +
  18 +@Controller
  19 +@RequestMapping("/payCode")
  20 +public class PayRseponeController {
  21 +
  22 +
  23 + @Autowired
  24 + private PayResponseMapper payResponseMapperl;
  25 +
  26 + /**
  27 + * 接受字段
  28 + * @param POSID 商户柜台代码
  29 + * @param BRANCHID 分行代码
  30 + * @param ORDERID 定单号
  31 + * @param PAYMENT 付款金额
  32 + * @param CURCODE 币种
  33 + * @param REMARK1 备注一
  34 + * @param REMARK2 备注二
  35 + * @param ACC_TYPE 账户类型
  36 + * @param SUCCESS 成功标志
  37 + * @param TYPE 接口类型
  38 + * @param REFERER Referer信息
  39 + * @param CLIENTIP 客户端IP
  40 + * @param ACCDATE 系统记账日期
  41 + * @param USRMSG 支付账户信息
  42 + * @param USRINFO 客户加密信息
  43 + * @param PAYTYPE 支付方式
  44 + * @param SIGN 数字签名
  45 + */
  46 + @RequestMapping(value = "/payRseponse")
  47 + @ApiOperation(value = "支付回执是否成功")
  48 + @ResponseBody
  49 + public ResultJson payCodeRsepone(@RequestParam(value = "POSID", required = false) String POSID,
  50 + @RequestParam(value = "BRANCHID", required = false) String BRANCHID,
  51 + @RequestParam(value = "ORDERID", required = false) String ORDERID,
  52 + @RequestParam(value = "PAYMENT", required = false) String PAYMENT,
  53 + @RequestParam(value = "CURCODE", required = false) String CURCODE,
  54 + @RequestParam(value = "REMARK1", required = false) String REMARK1,
  55 + @RequestParam(value = "REMARK2", required = false) String REMARK2,
  56 + @RequestParam(value = "ACC_TYPE", required = false) String ACC_TYPE,
  57 + @RequestParam(value = "SUCCESS", required = false) String SUCCESS,
  58 + @RequestParam(value = "TYPE", required = false) String TYPE,
  59 + @RequestParam(value = "REFERER", required = false) String REFERER,
  60 + @RequestParam(value = "CLIENTIP", required = false) String CLIENTIP,
  61 + @RequestParam(value = "ACCDATE", required = false) String ACCDATE,
  62 + @RequestParam(value = "USRMSG", required = false) String USRMSG,
  63 + @RequestParam(value = "USRINFO", required = false) String USRINFO,
  64 + @RequestParam(value = "PAYTYPE", required = false) String PAYTYPE,
  65 + @RequestParam(value = "SIGN", required = false) String SIGN){
  66 +
  67 + PayResponse payResponse = new PayResponse();
  68 + payResponse.setId(UUID.randomUUID().toString());
  69 + payResponse.setPosid(POSID);
  70 + payResponse.setBranchid(BRANCHID);
  71 + payResponse.setOrderid(ORDERID);
  72 + payResponse.setPayment(new BigDecimal(PAYMENT));
  73 + payResponse.setCurcode(CURCODE);
  74 + payResponse.setRemark1(REMARK1);
  75 + payResponse.setRemark2(REMARK2);
  76 + payResponse.setAccType(ACC_TYPE);
  77 + payResponse.setSuccess(SUCCESS);
  78 + payResponse.setType(TYPE);
  79 + payResponse.setReferer(REFERER);
  80 + payResponse.setClientip(CLIENTIP);
  81 + payResponse.setAccdate(new Date());
  82 + payResponse.setUsrmsg(USRMSG);
  83 + payResponse.setUsrinfo(USRINFO);
  84 + payResponse.setPaytype(PAYTYPE);
  85 + payResponse.setSign(SIGN);
  86 + int msg = 0;
  87 + int i = payResponseMapperl.insertSelective(payResponse);
  88 + if (i>0){
  89 + msg=1;
  90 + }
  91 + return i==1? new ResultJson("200","支付回执信息接受成功"):new ResultJson("500","支付回执信息接受失败");
  92 + }
  93 +
  94 +}
@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
16 import org.springframework.web.bind.annotation.RequestParam; 16 import org.springframework.web.bind.annotation.RequestParam;
17 import org.springframework.web.bind.annotation.RestController; 17 import org.springframework.web.bind.annotation.RestController;
18 18
  19 +import java.io.UnsupportedEncodingException;
19 import java.util.List; 20 import java.util.List;
20 21
21 @Api(description = "用户支付管理") 22 @Api(description = "用户支付管理")
@@ -46,4 +47,15 @@ public class UserPayController { @@ -46,4 +47,15 @@ public class UserPayController {
46 return waterMeterService.payWater(payFees, wmId, userId, realName); 47 return waterMeterService.payWater(payFees, wmId, userId, realName);
47 } 48 }
48 49
  50 + @ApiOperation(value = "请求返回二维码")
  51 + @PostMapping("/qrCode")
  52 + public ResultJson qrCode(@RequestParam(value = "payFees", required = false) String payFees,
  53 + @RequestParam(value = "wmId", required = false) String wmId,
  54 + @RequestParam(value = "userId", required = false) String userId,
  55 + @RequestParam(value = "realName", required = false) String realName) throws UnsupportedEncodingException {
  56 +
  57 + ResultJson resultJson = waterMeterService.qrCode(payFees, wmId, userId, realName);
  58 + return resultJson;
  59 + }
  60 +
49 } 61 }
  1 +package com.sunyo.energy.location.dao;
  2 +
  3 +import com.sunyo.energy.location.model.PayResponse;
  4 +
  5 +public interface PayResponseMapper {
  6 + int deleteByPrimaryKey(String id);
  7 +
  8 + int insert(PayResponse record);
  9 +
  10 + int insertSelective(PayResponse record);
  11 +
  12 + PayResponse selectByPrimaryKey(String id);
  13 +
  14 + int updateByPrimaryKeySelective(PayResponse record);
  15 +
  16 + int updateByPrimaryKey(PayResponse record);
  17 +}
  1 +package com.sunyo.energy.location.demopay;
  2 +
  3 +
  4 +import java.io.IOException;
  5 +import java.util.Iterator;
  6 +import java.util.Map;
  7 +
  8 +import org.apache.commons.httpclient.HttpClient;
  9 +import org.apache.commons.httpclient.HttpException;
  10 +import org.apache.commons.httpclient.HttpStatus;
  11 +import org.apache.commons.httpclient.NameValuePair;
  12 +import org.apache.commons.httpclient.methods.GetMethod;
  13 +import org.apache.commons.httpclient.methods.PostMethod;
  14 +import org.apache.commons.httpclient.params.HttpMethodParams;
  15 +import org.apache.commons.logging.Log;
  16 +import org.apache.commons.logging.LogFactory;
  17 +
  18 +public class HttpClientUtil {
  19 +
  20 +
  21 + public static String httpReader(String url, String code){
  22 + System.out.println("GetPage:"+url);
  23 +
  24 + HttpClient client = new HttpClient();
  25 + GetMethod method = new GetMethod(url);
  26 + String result = null;
  27 + try {
  28 + client.executeMethod(method);
  29 + int status = method.getStatusCode();
  30 + if (status == HttpStatus.SC_OK) {
  31 + result = method.getResponseBodyAsString();
  32 + } else {
  33 + System.out.println("Method failed: " + method.getStatusLine());
  34 + }
  35 + } catch (HttpException e) {
  36 + // �����������쳣��������Э�鲻�Ի��߷��ص�����������
  37 + System.out.println("Please check your provided http address!");
  38 + e.printStackTrace();
  39 + } catch (IOException e) {
  40 + // ���������쳣
  41 + System.out.println("���������쳣��");
  42 + e.printStackTrace();
  43 + } finally{
  44 + // �ͷ�����
  45 + if(method!=null)method.releaseConnection();
  46 + method = null;
  47 + client = null;
  48 + }
  49 + return result;
  50 + }
  51 +
  52 + public static String httpGet(String url,String code) {
  53 + System.out.println("GetPage:"+url);
  54 + String content = null;
  55 + HttpClient httpClient = new HttpClient();
  56 + //����header
  57 + httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT,"Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2");
  58 + GetMethod method = new GetMethod(url);
  59 + try {
  60 + int statusCode = httpClient.executeMethod(method);
  61 + System.out.println("httpClientUtils::statusCode="+statusCode);
  62 + System.out.println(method.getStatusLine());
  63 + content = new String(method.getResponseBody(), code);
  64 +
  65 + } catch (Exception e) {
  66 + System.out.println("time out");
  67 + e.printStackTrace();
  68 + } finally {
  69 + if(method!=null)method.releaseConnection();
  70 + method = null;
  71 + httpClient = null;
  72 + }
  73 + return content;
  74 + }
  75 +
  76 + public static String httpPost(String url, Map paramMap, String code) {
  77 + System.out.println("GetPage:"+url);
  78 + String content = null;
  79 + if (url == null || url.trim().length() == 0 || paramMap == null
  80 + || paramMap.isEmpty())
  81 + return null;
  82 + HttpClient httpClient = new HttpClient();
  83 + //����header
  84 + httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT,"Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2");//
  85 +
  86 + //��������
  87 + //httpClient.getHostConfiguration().setProxy("128.128.176.74", 808);
  88 +
  89 + PostMethod method = new PostMethod(url);
  90 + Iterator it = paramMap.keySet().iterator();
  91 +
  92 +
  93 + while (it.hasNext()) {
  94 + String key = it.next() + "";
  95 + Object o = paramMap.get(key);
  96 + if (o != null && o instanceof String) {
  97 + method.addParameter(new NameValuePair(key, o.toString()));
  98 + }
  99 + if (o != null && o instanceof String[]) {
  100 + String[] s = (String[]) o;
  101 + if (s != null)
  102 + for (int i = 0; i < s.length; i++) {
  103 + method.addParameter(new NameValuePair(key, s[i]));
  104 + }
  105 + }
  106 + }
  107 + try {
  108 +
  109 + int statusCode = httpClient.executeMethod(method);
  110 +
  111 + System.out.println("httpClientUtils::statusCode="+statusCode);
  112 +
  113 + System.out.println(method.getStatusLine());
  114 + content = new String(method.getResponseBody(), code);
  115 +
  116 + } catch (Exception e) {
  117 + System.out.println("time out");
  118 + e.printStackTrace();
  119 + } finally {
  120 + if(method!=null)method.releaseConnection();
  121 + method = null;
  122 + httpClient = null;
  123 + }
  124 + return content;
  125 +
  126 + }
  127 +
  128 + public static String httpPost(String url, Map paramMap) {
  129 + //���룺UTF-8
  130 + return HttpClientUtil.httpPost(url, paramMap, "UTF-8");
  131 + }
  132 +}
  1 +package com.sunyo.energy.location.demopay;
  2 +
  3 +import java.io.*;
  4 +import java.security.*;
  5 +
  6 +public class MD5
  7 +
  8 +{
  9 +
  10 + public static String md5Str(String str)
  11 + {
  12 + if (str == null)return "";
  13 + return md5Str(str, 0);
  14 + }
  15 +
  16 +
  17 + /**
  18 + * ������ϢժҪ��
  19 + * @param data ����ժҪ�����ݡ�
  20 + * @param offset ����ƫ�Ƶ�ַ��
  21 + * @param length ���ݳ��ȡ�
  22 + * @return ժҪ�����(16�ֽ�)
  23 + */
  24 + public static String md5Str(String str, int offset)
  25 + {
  26 + try
  27 + {
  28 + MessageDigest md5 = MessageDigest.getInstance("MD5");
  29 + byte[] b = str.getBytes("UTF8");
  30 + md5.update(b, offset, b.length);
  31 + return byteArrayToHexString(md5.digest());
  32 + }
  33 + catch (NoSuchAlgorithmException ex)
  34 + {
  35 + ex.printStackTrace();
  36 + return null;
  37 + }
  38 + catch (UnsupportedEncodingException ex)
  39 + {
  40 + ex.printStackTrace();
  41 + return null;
  42 + }
  43 + }
  44 +
  45 + /**
  46 + *
  47 + * @param b byte[]
  48 + * @return String
  49 + */
  50 + public static String byteArrayToHexString(byte[] b)
  51 + {
  52 + String result = "";
  53 + for (int i = 0; i < b.length; i++)
  54 + {
  55 + result += byteToHexString(b[i]);
  56 + }
  57 + return result;
  58 + }
  59 +
  60 + private static String[] hexDigits =
  61 + {
  62 + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b",
  63 + "c", "d", "e", "f"};
  64 +
  65 + /**
  66 + * ���ֽ�ת��Ϊ��Ӧ��16��������
  67 + * @param b byte
  68 + * @return String
  69 + */
  70 + public static String byteToHexString(byte b)
  71 + {
  72 + int n = b;
  73 + if (n < 0)
  74 + {
  75 + n = 256 + n;
  76 + }
  77 + int d1 = n / 16;
  78 + int d2 = n % 16;
  79 + return hexDigits[d1] + hexDigits[d2];
  80 + }
  81 +
  82 + public static void main(String[] args)
  83 + {
  84 + System.out.println(byteToHexString((byte)-99));
  85 + String str =
  86 + "eeeeeeeeeeeeeewrw213123122222222222222222222222213123213213213erwer";
  87 + String ened = MD5.md5Str(str);
  88 + System.out.println(ened.length());
  89 + System.out.println(ened);
  90 + }
  91 +}
  92 +
  1 +package com.sunyo.energy.location.demopay;
  2 +
  3 +import java.io.UnsupportedEncodingException;
  4 +import java.net.URLDecoder;
  5 +import java.util.HashMap;
  6 +import java.util.Map;
  7 +
  8 +import com.google.gson.Gson;
  9 +import com.google.gson.JsonArray;
  10 +import com.google.gson.JsonObject;
  11 +import com.sunyo.energy.location.model.WaterMeter;
  12 +import net.sf.json.JSONObject;
  13 +import net.sf.json.util.JSONUtils;
  14 +import springfox.documentation.spring.web.json.Json;
  15 +
  16 +public class QrDemo {
  17 +
  18 +
  19 + public static String orUrl(String orderId, String payMent) throws UnsupportedEncodingException {
  20 + String bankURL="https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain";
  21 +
  22 + String MERCHANTID = "105001453995827";
  23 + String POSID = "031575220";
  24 + String BRANCHID = "410000000";
  25 +// String ORDERID = "1050014539958271238454321";
  26 +// String PAYMENT= "0.01";
  27 + String CURCODE="01";
  28 + String TXCODE = "530550";
  29 + String REMARK1 = "";
  30 + String REMARK2 = "";
  31 + String RETURNTYPE="3";
  32 + String TIMEOUT = "";
  33 + String PUB32TR2= "8578d1cd9340dba556126a71020111";
  34 +
  35 + StringBuffer tmp = new StringBuffer(); //ÑéÇ©×Ö¶Î
  36 + tmp.append("MERCHANTID=");
  37 + tmp.append(MERCHANTID);
  38 + tmp.append("&POSID=");
  39 + tmp.append(POSID);
  40 + tmp.append("&BRANCHID=");
  41 + tmp.append(BRANCHID);
  42 + tmp.append("&ORDERID=");
  43 + tmp.append(orderId);
  44 + tmp.append("&PAYMENT=");
  45 + tmp.append(payMent);
  46 + tmp.append("&CURCODE=");
  47 + tmp.append(CURCODE);
  48 + tmp.append("&TXCODE=");
  49 + tmp.append(TXCODE);
  50 + tmp.append("&REMARK1=");
  51 + tmp.append(REMARK1);
  52 + tmp.append("&REMARK2=");
  53 + tmp.append(REMARK2);
  54 + tmp.append("&RETURNTYPE=");
  55 + tmp.append(RETURNTYPE);
  56 + tmp.append("&TIMEOUT=");
  57 + tmp.append(TIMEOUT);
  58 + tmp.append("&PUB=");
  59 + tmp.append(PUB32TR2);
  60 +
  61 + Map map = new HashMap();
  62 + map.put("CCB_IBSVersion","V6"); //±ØÊäÏî
  63 + map.put("MERCHANTID",MERCHANTID);
  64 + map.put("BRANCHID",BRANCHID);
  65 + map.put("POSID",POSID);
  66 + map.put("ORDERID",orderId);
  67 + map.put("PAYMENT",payMent);
  68 + map.put("CURCODE",CURCODE);
  69 + map.put("TXCODE",TXCODE);
  70 + map.put("REMARK1",REMARK1);
  71 + map.put("REMARK2",REMARK2);
  72 + map.put("RETURNTYPE",RETURNTYPE);
  73 + map.put("TIMEOUT",TIMEOUT);
  74 + map.put("MAC",MD5.md5Str(tmp.toString()));
  75 +
  76 + String ret = HttpClientUtil.httpPost(bankURL, map);
  77 +
  78 + Gson gson = new Gson();
  79 + QrURLDemo qrurl = (QrURLDemo) gson.fromJson(ret, QrURLDemo.class);
  80 + String rets = HttpClientUtil.httpGet(qrurl.getPAYURL(), "UTF-8");
  81 + JSONObject jsonObject = JSONObject.fromObject(rets);
  82 + String qrurl1 = URLDecoder.decode(jsonObject.get("QRURL").toString(), "UTF-8");
  83 + return qrurl1;
  84 + }
  85 +}
  1 +package com.sunyo.energy.location.demopay;
  2 +
  3 +public class QrORURLDemo {
  4 +
  5 + private String SUCCESS;
  6 + private String ORYURL;
  7 +
  8 + public String getSUCCESS() {
  9 + return SUCCESS;
  10 + }
  11 + public void setSUCCESS(String success) {
  12 + SUCCESS = success;
  13 + }
  14 +
  15 + public String getORYURL() {
  16 + return ORYURL;
  17 + }
  18 +
  19 + public void setORYURL(String ORYURL) {
  20 + this.ORYURL = ORYURL;
  21 + }
  22 +}
  1 +package com.sunyo.energy.location.demopay;
  2 +
  3 +public class QrURLDemo {
  4 +
  5 + private String SUCCESS;
  6 + private String PAYURL;
  7 +
  8 + public String getSUCCESS() {
  9 + return SUCCESS;
  10 + }
  11 + public void setSUCCESS(String success) {
  12 + SUCCESS = success;
  13 + }
  14 + public String getPAYURL() {
  15 + return PAYURL;
  16 + }
  17 + public void setPAYURL(String payurl) {
  18 + PAYURL = payurl;
  19 + }
  20 +}
  1 +package com.sunyo.energy.location.model;
  2 +
  3 +import java.math.BigDecimal;
  4 +import java.util.Date;
  5 +
  6 +public class PayResponse {
  7 + private String id;
  8 +
  9 + private String posid;
  10 +
  11 + private String branchid;
  12 +
  13 + private String orderid;
  14 +
  15 + private BigDecimal payment;
  16 +
  17 + private String curcode;
  18 +
  19 + private String remark1;
  20 +
  21 + private String remark2;
  22 +
  23 + private String accType;
  24 +
  25 + private String success;
  26 +
  27 + private String type;
  28 +
  29 + private String referer;
  30 +
  31 + private String clientip;
  32 +
  33 + private Date accdate;
  34 +
  35 + private String usrmsg;
  36 +
  37 + private String usrinfo;
  38 +
  39 + private String paytype;
  40 +
  41 + private String sign;
  42 +
  43 + public String getId() {
  44 + return id;
  45 + }
  46 +
  47 + public void setId(String id) {
  48 + this.id = id == null ? null : id.trim();
  49 + }
  50 +
  51 + public String getPosid() {
  52 + return posid;
  53 + }
  54 +
  55 + public void setPosid(String posid) {
  56 + this.posid = posid == null ? null : posid.trim();
  57 + }
  58 +
  59 + public String getBranchid() {
  60 + return branchid;
  61 + }
  62 +
  63 + public void setBranchid(String branchid) {
  64 + this.branchid = branchid == null ? null : branchid.trim();
  65 + }
  66 +
  67 + public String getOrderid() {
  68 + return orderid;
  69 + }
  70 +
  71 + public void setOrderid(String orderid) {
  72 + this.orderid = orderid == null ? null : orderid.trim();
  73 + }
  74 +
  75 + public BigDecimal getPayment() {
  76 + return payment;
  77 + }
  78 +
  79 + public void setPayment(BigDecimal payment) {
  80 + this.payment = payment;
  81 + }
  82 +
  83 + public String getCurcode() {
  84 + return curcode;
  85 + }
  86 +
  87 + public void setCurcode(String curcode) {
  88 + this.curcode = curcode == null ? null : curcode.trim();
  89 + }
  90 +
  91 + public String getRemark1() {
  92 + return remark1;
  93 + }
  94 +
  95 + public void setRemark1(String remark1) {
  96 + this.remark1 = remark1 == null ? null : remark1.trim();
  97 + }
  98 +
  99 + public String getRemark2() {
  100 + return remark2;
  101 + }
  102 +
  103 + public void setRemark2(String remark2) {
  104 + this.remark2 = remark2 == null ? null : remark2.trim();
  105 + }
  106 +
  107 + public String getAccType() {
  108 + return accType;
  109 + }
  110 +
  111 + public void setAccType(String accType) {
  112 + this.accType = accType == null ? null : accType.trim();
  113 + }
  114 +
  115 + public String getSuccess() {
  116 + return success;
  117 + }
  118 +
  119 + public void setSuccess(String success) {
  120 + this.success = success == null ? null : success.trim();
  121 + }
  122 +
  123 + public String getType() {
  124 + return type;
  125 + }
  126 +
  127 + public void setType(String type) {
  128 + this.type = type == null ? null : type.trim();
  129 + }
  130 +
  131 + public String getReferer() {
  132 + return referer;
  133 + }
  134 +
  135 + public void setReferer(String referer) {
  136 + this.referer = referer == null ? null : referer.trim();
  137 + }
  138 +
  139 + public String getClientip() {
  140 + return clientip;
  141 + }
  142 +
  143 + public void setClientip(String clientip) {
  144 + this.clientip = clientip == null ? null : clientip.trim();
  145 + }
  146 +
  147 + public Date getAccdate() {
  148 + return accdate;
  149 + }
  150 +
  151 + public void setAccdate(Date accdate) {
  152 + this.accdate = accdate;
  153 + }
  154 +
  155 + public String getUsrmsg() {
  156 + return usrmsg;
  157 + }
  158 +
  159 + public void setUsrmsg(String usrmsg) {
  160 + this.usrmsg = usrmsg == null ? null : usrmsg.trim();
  161 + }
  162 +
  163 + public String getUsrinfo() {
  164 + return usrinfo;
  165 + }
  166 +
  167 + public void setUsrinfo(String usrinfo) {
  168 + this.usrinfo = usrinfo == null ? null : usrinfo.trim();
  169 + }
  170 +
  171 + public String getPaytype() {
  172 + return paytype;
  173 + }
  174 +
  175 + public void setPaytype(String paytype) {
  176 + this.paytype = paytype == null ? null : paytype.trim();
  177 + }
  178 +
  179 + public String getSign() {
  180 + return sign;
  181 + }
  182 +
  183 + public void setSign(String sign) {
  184 + this.sign = sign == null ? null : sign.trim();
  185 + }
  186 +}
@@ -4,6 +4,8 @@ package com.sunyo.energy.location.service; @@ -4,6 +4,8 @@ package com.sunyo.energy.location.service;
4 import com.sunyo.energy.location.controller.response.ResultJson; 4 import com.sunyo.energy.location.controller.response.ResultJson;
5 import com.sunyo.energy.location.model.WaterMeter; 5 import com.sunyo.energy.location.model.WaterMeter;
6 6
  7 +import java.io.UnsupportedEncodingException;
  8 +
7 public interface WaterMeterService { 9 public interface WaterMeterService {
8 10
9 int realTime(); 11 int realTime();
@@ -14,5 +16,8 @@ public interface WaterMeterService { @@ -14,5 +16,8 @@ public interface WaterMeterService {
14 16
15 ResultJson waterMeterAll(String wmId); 17 ResultJson waterMeterAll(String wmId);
16 18
  19 + // 请求返回二维码
  20 + ResultJson qrCode(String payFees, String wmId, String userId, String realName) throws UnsupportedEncodingException;
  21 +
17 22
18 } 23 }
@@ -8,6 +8,7 @@ import com.sunyo.energy.location.controller.response.ResultJson; @@ -8,6 +8,7 @@ import com.sunyo.energy.location.controller.response.ResultJson;
8 import com.sunyo.energy.location.dao.LocationMapper; 8 import com.sunyo.energy.location.dao.LocationMapper;
9 import com.sunyo.energy.location.dao.PayRecordsMapper; 9 import com.sunyo.energy.location.dao.PayRecordsMapper;
10 import com.sunyo.energy.location.dao.WaterMeterMapper; 10 import com.sunyo.energy.location.dao.WaterMeterMapper;
  11 +import com.sunyo.energy.location.demopay.QrDemo;
11 import com.sunyo.energy.location.model.PayRecords; 12 import com.sunyo.energy.location.model.PayRecords;
12 import com.sunyo.energy.location.model.WaterMeter; 13 import com.sunyo.energy.location.model.WaterMeter;
13 import com.sunyo.energy.location.service.WaterMeterService; 14 import com.sunyo.energy.location.service.WaterMeterService;
@@ -20,6 +21,7 @@ import org.springframework.scheduling.annotation.Scheduled; @@ -20,6 +21,7 @@ import org.springframework.scheduling.annotation.Scheduled;
20 import org.springframework.stereotype.Service; 21 import org.springframework.stereotype.Service;
21 22
22 import javax.servlet.http.HttpSession; 23 import javax.servlet.http.HttpSession;
  24 +import java.io.UnsupportedEncodingException;
23 import java.math.BigDecimal; 25 import java.math.BigDecimal;
24 import java.util.Date; 26 import java.util.Date;
25 import java.util.HashMap; 27 import java.util.HashMap;
@@ -168,6 +170,27 @@ public class WaterMeterServiceImp implements WaterMeterService { @@ -168,6 +170,27 @@ public class WaterMeterServiceImp implements WaterMeterService {
168 } 170 }
169 } 171 }
170 172
  173 + // 请求返回二维码
  174 + @Override
  175 + public ResultJson qrCode(String payFees, String wmId, String userId, String realName) throws UnsupportedEncodingException {
  176 + ResultJson<Object> resultJson = new ResultJson<>();
  177 + // 成功生成水费订单
  178 + PayRecords payRecords = payRecords(payFees, wmId, userId, realName);
  179 + // 请求返回二维码lujing
  180 + String s = QrDemo.orUrl(payRecords.getOrdernumber(), payFees);
  181 +
  182 + int i = payRecordsMapper.insertSelective(payRecords);
  183 + if(i>0){
  184 + resultJson.setCode("200");
  185 +
  186 + }
  187 + if (!"".equals(s)){
  188 + resultJson.setData(s);
  189 + }
  190 +
  191 + return resultJson;
  192 + }
  193 +
171 /** 194 /**
172 * 总水量 换算 195 * 总水量 换算
173 * @param payFees 196 * @param payFees
@@ -208,7 +231,7 @@ public class WaterMeterServiceImp implements WaterMeterService { @@ -208,7 +231,7 @@ public class WaterMeterServiceImp implements WaterMeterService {
208 PayRecords payRecords = new PayRecords(); 231 PayRecords payRecords = new PayRecords();
209 payRecords.setOrdernumber(AllUtils.getOrderIdByTime()); 232 payRecords.setOrdernumber(AllUtils.getOrderIdByTime());
210 payRecords.setPayfees(Long.valueOf(payFees)); 233 payRecords.setPayfees(Long.valueOf(payFees));
211 - payRecords.setPaystatus(true); 234 + payRecords.setPaystatus(false);
212 payRecords.setPaytype(false); 235 payRecords.setPaytype(false);
213 payRecords.setReamke1("0"); 236 payRecords.setReamke1("0");
214 payRecords.setPayuserid(Integer.valueOf(userId)); 237 payRecords.setPayuserid(Integer.valueOf(userId));
@@ -46,14 +46,14 @@ public class AllUtils { @@ -46,14 +46,14 @@ public class AllUtils {
46 46
47 // 订单号生成 时间加随机数 47 // 订单号生成 时间加随机数
48 public static String getOrderIdByTime() { 48 public static String getOrderIdByTime() {
49 - SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");  
50 - String newDate=sdf.format(new Date()); 49 + // 商户码
  50 + String merchantId ="105001453995827";
51 String result=""; 51 String result="";
52 Random random=new Random(); 52 Random random=new Random();
53 for(int i=0;i<3;i++){ 53 for(int i=0;i<3;i++){
54 result+=random.nextInt(10); 54 result+=random.nextInt(10);
55 } 55 }
56 - return newDate+result; 56 + return merchantId+result;
57 } 57 }
58 58
59 59
1 ${AnsiColor.YELLOW} 1 ${AnsiColor.YELLOW}
2 - #####################################################  
3 - # #  
4 - # _oo0oo_ #  
5 - # o8888888o #  
6 - # 88" . "88 #  
7 - # (| -_- |) #  
8 - # 0\ = /0 #  
9 - # ___/`---'\___ #  
10 - # .' \\| |# '. #  
11 - # / \\||| : |||# \ #  
12 - # / _||||| -:- |||||- \ #  
13 - # | | \\\ - #/ | | #  
14 - # | \_| ''\---/'' |_/ | #  
15 - # \ .-\__ '-' ___/-. / #  
16 - # ___'. .' /--.--\ `. .'___ #  
17 - # ."" '< `.___\_<|>_/___.' >' "". #  
18 - # | | : `- \`.;`\ _ /`;.`/ - ` : | | #  
19 - # \ \ `_. \_ __\ /__ _/ .-` / / #  
20 - # =====`-.____`.___ \_____/___.-`___.-'===== #  
21 - # `=---=' #  
22 - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #  
23 - # #  
24 - # 佛祖保佑 永不宕机 永无Bug #  
25 - # #  
26 - #####################################################  
27 2
28 .::::. 3 .::::.
29 .::::::::. 4 .::::::::.
@@ -43,7 +18,6 @@ ${AnsiColor.YELLOW} @@ -43,7 +18,6 @@ ${AnsiColor.YELLOW}
43 ...::: ::::::::::::' ``::. 18 ...::: ::::::::::::' ``::.
44 ```` ':. ':::::::::' ::::.. 19 ```` ':. ':::::::::' ::::..
45 '.:::::' ':'````.. 20 '.:::::' ':'````..
46 - 不存在的 你看我美吗  
47 21
48 ================================================== 22 ==================================================
49 Application Info:${application.title} 23 Application Info:${application.title}
@@ -45,6 +45,6 @@ @@ -45,6 +45,6 @@
45 <property name="enableSubPackages" value="true"/> 45 <property name="enableSubPackages" value="true"/>
46 </javaClientGenerator> 46 </javaClientGenerator>
47 <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名--> 47 <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
48 - <table tableName="pay_records" domainObjectName="PayRecords" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="true"></table> 48 + <table tableName="pay_response" domainObjectName="PayResponse" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="true"></table>
49 </context> 49 </context>
50 </generatorConfiguration> 50 </generatorConfiguration>
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.sunyo.energy.location.dao.PayResponseMapper" >
  4 + <resultMap id="BaseResultMap" type="com.sunyo.energy.location.model.PayResponse" >
  5 + <id column="ID" property="id" jdbcType="VARCHAR" />
  6 + <result column="POSID" property="posid" jdbcType="VARCHAR" />
  7 + <result column="BRANCHID" property="branchid" jdbcType="VARCHAR" />
  8 + <result column="ORDERID" property="orderid" jdbcType="VARCHAR" />
  9 + <result column="PAYMENT" property="payment" jdbcType="DECIMAL" />
  10 + <result column="CURCODE" property="curcode" jdbcType="VARCHAR" />
  11 + <result column="REMARK1" property="remark1" jdbcType="VARCHAR" />
  12 + <result column="REMARK2" property="remark2" jdbcType="VARCHAR" />
  13 + <result column="ACC_TYPE" property="accType" jdbcType="VARCHAR" />
  14 + <result column="SUCCESS" property="success" jdbcType="VARCHAR" />
  15 + <result column="TYPE" property="type" jdbcType="VARCHAR" />
  16 + <result column="REFERER" property="referer" jdbcType="VARCHAR" />
  17 + <result column="CLIENTIP" property="clientip" jdbcType="VARCHAR" />
  18 + <result column="ACCDATE" property="accdate" jdbcType="TIMESTAMP" />
  19 + <result column="USRMSG" property="usrmsg" jdbcType="VARCHAR" />
  20 + <result column="USRINFO" property="usrinfo" jdbcType="VARCHAR" />
  21 + <result column="PAYTYPE" property="paytype" jdbcType="VARCHAR" />
  22 + <result column="SIGN" property="sign" jdbcType="VARCHAR" />
  23 + </resultMap>
  24 + <sql id="Base_Column_List" >
  25 + ID, POSID, BRANCHID, ORDERID, PAYMENT, CURCODE, REMARK1, REMARK2, ACC_TYPE, SUCCESS,
  26 + TYPE, REFERER, CLIENTIP, ACCDATE, USRMSG, USRINFO, PAYTYPE, SIGN
  27 + </sql>
  28 + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  29 + select
  30 + <include refid="Base_Column_List" />
  31 + from pay_response
  32 + where ID = #{id,jdbcType=VARCHAR}
  33 + </select>
  34 + <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  35 + delete from pay_response
  36 + where ID = #{id,jdbcType=VARCHAR}
  37 + </delete>
  38 + <insert id="insert" parameterType="com.sunyo.energy.location.model.PayResponse" >
  39 + insert into pay_response (ID, POSID, BRANCHID,
  40 + ORDERID, PAYMENT, CURCODE,
  41 + REMARK1, REMARK2, ACC_TYPE,
  42 + SUCCESS, TYPE, REFERER,
  43 + CLIENTIP, ACCDATE, USRMSG,
  44 + USRINFO, PAYTYPE, SIGN
  45 + )
  46 + values (#{id,jdbcType=VARCHAR}, #{posid,jdbcType=VARCHAR}, #{branchid,jdbcType=VARCHAR},
  47 + #{orderid,jdbcType=VARCHAR}, #{payment,jdbcType=DECIMAL}, #{curcode,jdbcType=VARCHAR},
  48 + #{remark1,jdbcType=VARCHAR}, #{remark2,jdbcType=VARCHAR}, #{accType,jdbcType=VARCHAR},
  49 + #{success,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{referer,jdbcType=VARCHAR},
  50 + #{clientip,jdbcType=VARCHAR}, #{accdate,jdbcType=TIMESTAMP}, #{usrmsg,jdbcType=VARCHAR},
  51 + #{usrinfo,jdbcType=VARCHAR}, #{paytype,jdbcType=VARCHAR}, #{sign,jdbcType=VARCHAR}
  52 + )
  53 + </insert>
  54 + <insert id="insertSelective" parameterType="com.sunyo.energy.location.model.PayResponse" >
  55 + insert into pay_response
  56 + <trim prefix="(" suffix=")" suffixOverrides="," >
  57 + <if test="id != null" >
  58 + ID,
  59 + </if>
  60 + <if test="posid != null" >
  61 + POSID,
  62 + </if>
  63 + <if test="branchid != null" >
  64 + BRANCHID,
  65 + </if>
  66 + <if test="orderid != null" >
  67 + ORDERID,
  68 + </if>
  69 + <if test="payment != null" >
  70 + PAYMENT,
  71 + </if>
  72 + <if test="curcode != null" >
  73 + CURCODE,
  74 + </if>
  75 + <if test="remark1 != null" >
  76 + REMARK1,
  77 + </if>
  78 + <if test="remark2 != null" >
  79 + REMARK2,
  80 + </if>
  81 + <if test="accType != null" >
  82 + ACC_TYPE,
  83 + </if>
  84 + <if test="success != null" >
  85 + SUCCESS,
  86 + </if>
  87 + <if test="type != null" >
  88 + TYPE,
  89 + </if>
  90 + <if test="referer != null" >
  91 + REFERER,
  92 + </if>
  93 + <if test="clientip != null" >
  94 + CLIENTIP,
  95 + </if>
  96 + <if test="accdate != null" >
  97 + ACCDATE,
  98 + </if>
  99 + <if test="usrmsg != null" >
  100 + USRMSG,
  101 + </if>
  102 + <if test="usrinfo != null" >
  103 + USRINFO,
  104 + </if>
  105 + <if test="paytype != null" >
  106 + PAYTYPE,
  107 + </if>
  108 + <if test="sign != null" >
  109 + SIGN,
  110 + </if>
  111 + </trim>
  112 + <trim prefix="values (" suffix=")" suffixOverrides="," >
  113 + <if test="id != null" >
  114 + #{id,jdbcType=VARCHAR},
  115 + </if>
  116 + <if test="posid != null" >
  117 + #{posid,jdbcType=VARCHAR},
  118 + </if>
  119 + <if test="branchid != null" >
  120 + #{branchid,jdbcType=VARCHAR},
  121 + </if>
  122 + <if test="orderid != null" >
  123 + #{orderid,jdbcType=VARCHAR},
  124 + </if>
  125 + <if test="payment != null" >
  126 + #{payment,jdbcType=DECIMAL},
  127 + </if>
  128 + <if test="curcode != null" >
  129 + #{curcode,jdbcType=VARCHAR},
  130 + </if>
  131 + <if test="remark1 != null" >
  132 + #{remark1,jdbcType=VARCHAR},
  133 + </if>
  134 + <if test="remark2 != null" >
  135 + #{remark2,jdbcType=VARCHAR},
  136 + </if>
  137 + <if test="accType != null" >
  138 + #{accType,jdbcType=VARCHAR},
  139 + </if>
  140 + <if test="success != null" >
  141 + #{success,jdbcType=VARCHAR},
  142 + </if>
  143 + <if test="type != null" >
  144 + #{type,jdbcType=VARCHAR},
  145 + </if>
  146 + <if test="referer != null" >
  147 + #{referer,jdbcType=VARCHAR},
  148 + </if>
  149 + <if test="clientip != null" >
  150 + #{clientip,jdbcType=VARCHAR},
  151 + </if>
  152 + <if test="accdate != null" >
  153 + #{accdate,jdbcType=TIMESTAMP},
  154 + </if>
  155 + <if test="usrmsg != null" >
  156 + #{usrmsg,jdbcType=VARCHAR},
  157 + </if>
  158 + <if test="usrinfo != null" >
  159 + #{usrinfo,jdbcType=VARCHAR},
  160 + </if>
  161 + <if test="paytype != null" >
  162 + #{paytype,jdbcType=VARCHAR},
  163 + </if>
  164 + <if test="sign != null" >
  165 + #{sign,jdbcType=VARCHAR},
  166 + </if>
  167 + </trim>
  168 + </insert>
  169 + <update id="updateByPrimaryKeySelective" parameterType="com.sunyo.energy.location.model.PayResponse" >
  170 + update pay_response
  171 + <set >
  172 + <if test="posid != null" >
  173 + POSID = #{posid,jdbcType=VARCHAR},
  174 + </if>
  175 + <if test="branchid != null" >
  176 + BRANCHID = #{branchid,jdbcType=VARCHAR},
  177 + </if>
  178 + <if test="orderid != null" >
  179 + ORDERID = #{orderid,jdbcType=VARCHAR},
  180 + </if>
  181 + <if test="payment != null" >
  182 + PAYMENT = #{payment,jdbcType=DECIMAL},
  183 + </if>
  184 + <if test="curcode != null" >
  185 + CURCODE = #{curcode,jdbcType=VARCHAR},
  186 + </if>
  187 + <if test="remark1 != null" >
  188 + REMARK1 = #{remark1,jdbcType=VARCHAR},
  189 + </if>
  190 + <if test="remark2 != null" >
  191 + REMARK2 = #{remark2,jdbcType=VARCHAR},
  192 + </if>
  193 + <if test="accType != null" >
  194 + ACC_TYPE = #{accType,jdbcType=VARCHAR},
  195 + </if>
  196 + <if test="success != null" >
  197 + SUCCESS = #{success,jdbcType=VARCHAR},
  198 + </if>
  199 + <if test="type != null" >
  200 + TYPE = #{type,jdbcType=VARCHAR},
  201 + </if>
  202 + <if test="referer != null" >
  203 + REFERER = #{referer,jdbcType=VARCHAR},
  204 + </if>
  205 + <if test="clientip != null" >
  206 + CLIENTIP = #{clientip,jdbcType=VARCHAR},
  207 + </if>
  208 + <if test="accdate != null" >
  209 + ACCDATE = #{accdate,jdbcType=TIMESTAMP},
  210 + </if>
  211 + <if test="usrmsg != null" >
  212 + USRMSG = #{usrmsg,jdbcType=VARCHAR},
  213 + </if>
  214 + <if test="usrinfo != null" >
  215 + USRINFO = #{usrinfo,jdbcType=VARCHAR},
  216 + </if>
  217 + <if test="paytype != null" >
  218 + PAYTYPE = #{paytype,jdbcType=VARCHAR},
  219 + </if>
  220 + <if test="sign != null" >
  221 + SIGN = #{sign,jdbcType=VARCHAR},
  222 + </if>
  223 + </set>
  224 + where ID = #{id,jdbcType=VARCHAR}
  225 + </update>
  226 + <update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.PayResponse" >
  227 + update pay_response
  228 + set POSID = #{posid,jdbcType=VARCHAR},
  229 + BRANCHID = #{branchid,jdbcType=VARCHAR},
  230 + ORDERID = #{orderid,jdbcType=VARCHAR},
  231 + PAYMENT = #{payment,jdbcType=DECIMAL},
  232 + CURCODE = #{curcode,jdbcType=VARCHAR},
  233 + REMARK1 = #{remark1,jdbcType=VARCHAR},
  234 + REMARK2 = #{remark2,jdbcType=VARCHAR},
  235 + ACC_TYPE = #{accType,jdbcType=VARCHAR},
  236 + SUCCESS = #{success,jdbcType=VARCHAR},
  237 + TYPE = #{type,jdbcType=VARCHAR},
  238 + REFERER = #{referer,jdbcType=VARCHAR},
  239 + CLIENTIP = #{clientip,jdbcType=VARCHAR},
  240 + ACCDATE = #{accdate,jdbcType=TIMESTAMP},
  241 + USRMSG = #{usrmsg,jdbcType=VARCHAR},
  242 + USRINFO = #{usrinfo,jdbcType=VARCHAR},
  243 + PAYTYPE = #{paytype,jdbcType=VARCHAR},
  244 + SIGN = #{sign,jdbcType=VARCHAR}
  245 + where ID = #{id,jdbcType=VARCHAR}
  246 + </update>
  247 +</mapper>
1 -package com.sunyo.customer.order;  
2 -  
3 -import org.junit.Test;  
4 -import org.junit.runner.RunWith;  
5 -import org.springframework.boot.test.context.SpringBootTest;  
6 -import org.springframework.test.context.junit4.SpringRunner;  
7 -  
8 -@RunWith(SpringRunner.class)  
9 -@SpringBootTest  
10 -public class OrderApplicationTests {  
11 -  
12 - @Test  
13 - public void contextLoads() {  
14 - }  
15 -  
16 -}