Commit e8164668 by Java-张振楠

①增加公共变量

②增加消息中心实体属性
③增加juhezhong支付的用户注册功能、修改费率功能
④修改部分已完成接口的出入参数
parent 39b0e491
......@@ -55,6 +55,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<downloadSources>true</downloadSources>
<!-- tools class -->
<httpclient.version>4.5</httpclient.version>
</properties>
<!-- 设定主仓库,按设定顺序进行查找。 -->
......@@ -628,7 +630,12 @@
</exclusion>
</exclusions>
</dependency> -->
<!-- tools class -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
</dependencies>
<build>
......
......@@ -10,6 +10,22 @@ public class ComCode {
* 加密串
*/
public static final String signCode = "Y0UKA@2018";
/**
* juhezhong相关参数
*/
public static final String HOST = "http://pay.hezhongpay.com"; // 请求地址
public static final String MERCHANT_ID = "100532502195879"; // 商户号
public static final String MERCHANT_KEY = "670993bf-dd22-4464-9d81-69595d36b794"; // 商户key
public static final String MERCHANT_SECRET = "289ada73-27db-49e0-b2ad-3ae1613a665a"; // 商户sescet
public static final String MERCHANT_REG_URL = "/api/quick/merchant/apply"; // 注册商户
public static final String ORDER_QUERY_URL = "/order/query"; // 查询订单
public static final String SETTLE_UPDATE_URL = "/api/quick/settle/card/update"; // 修改结算卡信息
public static final String MERCHANT_INFO_URL = "/api/quick/merchant/info"; // 查询商户费率
public static final String RATE_UPDATE_URL = "/api/quick/merchant/update/rate"; // 修改商户费率
public static final String QUICK_PAY_URL = "/api/quick/pre/pay"; // 快捷支付
public static final String EXTRA_RATE = "200";
/**
* 时间相关参数
*/
......@@ -18,6 +34,7 @@ public class ComCode {
public static final long minutes = 60;
public static final long hours = 24;
public static final SimpleDateFormat YYYYMMDD_HHMMSS = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/**
* 系统公共
*/
......@@ -57,4 +74,10 @@ public class ComCode {
public static final String STATUS_CODE_4009_DESC = "验证码已过期";
public static final String STATUS_CODE_4010 = "4010";
public static final String STATUS_CODE_4010_DESC = "验证码场景错误";
/**
* 卡片相关
*/
public static final String STATUS_CODE_5001 = "5001";
public static final String STATUS_CODE_5001_DESC = "卡片注册异常";
}
package com.thinkgem.jeesite.modules.commonError;
public class MyException extends Exception {
public MyException() {
}
public MyException(String s) {
super(s);
}
}
......@@ -22,6 +22,10 @@ public class ArticleEntity extends BaseEntity implements Serializable {
private String is_flow; // 是否滚动通知
@JsonIgnore
private String is_tip; // 是否弹窗通知
@JsonIgnore
private String scope; // 推送范围
@JsonIgnore
private String send_date; // 发送时间
private String content; // 内容
public String getTitle() {
......@@ -96,6 +100,22 @@ public class ArticleEntity extends BaseEntity implements Serializable {
this.is_tip = is_tip;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getSend_date() {
return send_date;
}
public void setSend_date(String send_date) {
this.send_date = send_date;
}
public String getContent() {
return content;
}
......
package com.thinkgem.jeesite.modules.pay.juhezhong.dto;
/**
* 快捷支付
*/
public class ApiQuickPayDto extends MerchantDto {
private String name;//商户展示名称
private String body;//商品名称
private String url;//快捷返回地址
private String notifyUrl;//通知地址
private String frontUrl;//前台地址
private Long amount;//金额 统一用分
private Integer type;//交易类型
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getNotifyUrl() {
return notifyUrl;
}
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
public String getFrontUrl() {
return frontUrl;
}
public void setFrontUrl(String frontUrl) {
this.frontUrl = frontUrl;
}
public Long getAmount() {
return amount;
}
public void setAmount(Long amount) {
this.amount = amount;
}
}
package com.thinkgem.jeesite.modules.pay.juhezhong.dto;
/**
* 平台交易公共属性
*/
public class CommonDto implements java.io.Serializable {
private String orderId;//平台订单号
private String merchantId;//商户id
private String merchantKey;//商户密钥
private Long timestamp;//时间戳
private Long amount;//金额 统一用分
private String sign;//签名
private String notifyUrl ;//通知地址
private String frontUrl ;//前台地址
private String productName;//商品名称
private Integer type;//交易类型
private Integer settleType;//结算类型
private String url;//多功能
private String msg;//响应消息
private String code;//响应码
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getFrontUrl() {
return frontUrl;
}
public void setFrontUrl(String frontUrl) {
this.frontUrl = frontUrl;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getSettleType() {
return settleType;
}
public void setSettleType(Integer settleType) {
this.settleType = settleType;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getNotifyUrl() {
return notifyUrl;
}
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
public Long getAmount() {
return amount;
}
public void setAmount(Long amount) {
this.amount = amount;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public String getMerchantId() {
return merchantId;
}
public void setMerchantId(String merchantId) {
this.merchantId = merchantId;
}
public String getMerchantKey() {
return merchantKey;
}
public void setMerchantKey(String merchantKey) {
this.merchantKey = merchantKey;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
}
package com.thinkgem.jeesite.modules.pay.juhezhong.dto;
import java.math.BigDecimal;
/**
* 小微商户开通
*/
public class MerchantDto extends TranstionDto {
private String subMchId;//子商户号
private String idType;//证件类型
private String accName;//持卡人姓名
private String accNo;//卡号
private String accProvince;//开通省份
private String accCity;//开通城市
private String mobile;//预留手机号
private String idNo;//证件号码
private BigDecimal settleRate;//结算费率
private BigDecimal extraRate;//T0费率
private Integer accType;//账户类型
private String bankCode;
public String getBankCode() {
return bankCode;
}
public void setBankCode(String bankCode) {
this.bankCode = bankCode;
}
public String getAccProvince() {
return accProvince;
}
public void setAccProvince(String accProvince) {
this.accProvince = accProvince;
}
public String getAccCity() {
return accCity;
}
public void setAccCity(String accCity) {
this.accCity = accCity;
}
public String getSubMchId() {
return subMchId;
}
public void setSubMchId(String subMchId) {
this.subMchId = subMchId;
}
public String getIdType() {
return idType;
}
public void setIdType(String idType) {
this.idType = idType;
}
public String getAccName() {
return accName;
}
public void setAccName(String accName) {
this.accName = accName;
}
public String getAccNo() {
return accNo;
}
public void setAccNo(String accNo) {
this.accNo = accNo;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public BigDecimal getSettleRate() {
return settleRate;
}
public void setSettleRate(BigDecimal settleRate) {
this.settleRate = settleRate;
}
public BigDecimal getExtraRate() {
return extraRate;
}
public void setExtraRate(BigDecimal extraRate) {
this.extraRate = extraRate;
}
public Integer getAccType() {
return accType;
}
public void setAccType(Integer accType) {
this.accType = accType;
}
}
package com.thinkgem.jeesite.modules.pay.juhezhong.dto;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class TranstionDto implements java.io.Serializable {
private String msg;//响应消息
private String code;//响应码
private String sign;//签名
private String orderId;//平台订单号
private String merchantKey;//商户密钥
private Long timestamp;//时间戳
private String merchantId;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public String getMerchantKey() {
return merchantKey;
}
public void setMerchantKey(String merchantKey) {
this.merchantKey = merchantKey;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getMerchantId() {
return merchantId;
}
public void setMerchantId(String merchantId) {
this.merchantId = merchantId;
}
}
package com.thinkgem.jeesite.modules.pay.juhezhong.service;
import com.alibaba.fastjson.JSONObject;
import com.thinkgem.jeesite.common.constant.ComCode;
import com.thinkgem.jeesite.modules.pay.juhezhong.dto.MerchantDto;
import com.thinkgem.jeesite.modules.pay.juhezhong.utils.Bean2Map;
import com.thinkgem.jeesite.modules.pay.juhezhong.utils.HttpUtil;
import com.thinkgem.jeesite.modules.pay.juhezhong.utils.SignUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
/**
* 首页通知
*/
@Service
@Transactional(readOnly = true)
public class JuHeZhongPayService {
public JSONObject register(MerchantDto dto) throws Exception {
Map<String, Object> params = Bean2Map.Entity2Map(dto);
String signBefore = SignUtils.signBefore(params);
String sign = SignUtils.sign(signBefore, ComCode.MERCHANT_SECRET);
params.put("sign", sign);
String respStr = HttpUtil.post(ComCode.HOST + ComCode.MERCHANT_REG_URL, params);
return JSONObject.parseObject(respStr);
}
public JSONObject updateSettle(MerchantDto dto) throws Exception {
Map<String, Object> params = Bean2Map.Entity2Map(dto);
String signBefore = SignUtils.signBefore(params);
String sign = SignUtils.sign(signBefore, ComCode.MERCHANT_SECRET);
params.put("sign", sign);
String respStr = HttpUtil.post(ComCode.HOST + ComCode.RATE_UPDATE_URL, params);
return JSONObject.parseObject(respStr);
}
}
package com.thinkgem.jeesite.modules.pay.juhezhong.utils;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* 将Map转换为Obj的工具类
*/
public class Bean2Map {
public static void Map2Entity(Map map, Object thisObj) {
Set set = map.keySet();
Iterator iterator = set.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
Object val = map.get(obj);
setObjMethod(obj, val, thisObj);
}
}
public static Map Entity2Map(Object thisObj) {
Map map = new HashMap();
Class c;
try {
c = Class.forName(thisObj.getClass().getName());
Method[] m = c.getMethods();
for (int i = 0; i < m.length; i++) {
String method = m[i].getName();
if (method.startsWith("get")) {
try {
Object value = m[i].invoke(thisObj);
if (value != null) {
String key = method.substring(3);
if (key.toLowerCase().equals("class".toLowerCase())) {
continue;
}
key = key.substring(0, 1).toLowerCase()
+ key.substring(1);
map.put(key, value);
}
} catch (Exception e) {
System.out.println("error:" + method);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
private static void setObjMethod(Object method, Object value, Object thisObj) {
Class c;
try {
c = Class.forName(thisObj.getClass().getName());
String met = (String) method;
met = met.trim();
if (!met.substring(0, 1).equals(met.substring(0, 1).toUpperCase())) {
met = met.substring(0, 1).toUpperCase() + met.substring(1);
}
if (!String.valueOf(method).startsWith("set")) {
met = "set" + met;
}
Class types[] = new Class[1];
types[0] = Class.forName("java.lang.String");
Method m = c.getMethod(met, types);
m.invoke(thisObj, value);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.thinkgem.jeesite.modules.pay.juhezhong.utils;
import java.nio.charset.Charset;
/**
* <p>Created with IntelliJ IDEA. </p>
* <p>User: Stony </p>
* <p>Date: 2016/5/17 </p>
* <p>Time: 10:21 </p>
* <p>Version: 1.0 </p>
*/
public abstract class CharsetUtil {
/**
* UTF-8: eight-bit UCS Transformation Format.
*/
public static final Charset UTF_8 = Charset.forName("UTF-8");
/**
* US-ASCII: seven-bit ASCII, the Basic Latin block of the Unicode character set (ISO646-US).
*/
public static final Charset US_ASCII = Charset.forName("US-ASCII");
}
package com.thinkgem.jeesite.modules.pay.juhezhong.utils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EntityUtils;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/***
* httpUtil
*
* @author
*/
public class HttpUtil {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(HttpUtil.class);
private static PoolingClientConnectionManager conMgr = null;
static {
HttpParams params = new BasicHttpParams();
Integer CONNECTION_TIMEOUT = 2 * 1000; //设置请求超时2秒钟 根据业务调整
Integer SO_TIMEOUT = 2 * 1000; //设置等待数据超时时间2秒钟 根据业务调整
Long CONN_MANAGER_TIMEOUT = 500L; //该值就是连接不够用的时候等待超时时间,一定要设置,而且不能太大
params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, CONNECTION_TIMEOUT);
params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, SO_TIMEOUT);
params.setLongParameter(ClientPNames.CONN_MANAGER_TIMEOUT, CONN_MANAGER_TIMEOUT);
params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, true);
conMgr = new PoolingClientConnectionManager();
conMgr.setMaxTotal(2000);
conMgr.setDefaultMaxPerRoute(conMgr.getMaxTotal());
}
public static String get(String url, String param) {
DefaultHttpClient httpClient = new DefaultHttpClient(conMgr);
// httpClient.setParams(params);
httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
HttpResponse httpResponse = null;
// 发送get请求
try {
// 用get方法发送http请求
HttpGet get = new HttpGet(url + URLEncoder.encode(param, "UTF-8"));
get.setHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/51.0.2704.79 Chrome/51.0.2704.79 Safari/537.36");
System.out.println("执行get请求, uri: " + get.getURI());
httpResponse = httpClient.execute(get);
// response实体
HttpEntity entity = httpResponse.getEntity();
if (null != entity) {
String response = EntityUtils.toString(entity);
int statusCode = httpResponse.getStatusLine().getStatusCode();
if (statusCode == HttpStatus.SC_OK) {
// 成功
return response;
} else {
return null;
}
}
} catch (IOException e) {
e.printStackTrace();
System.out.println("httpclient请求失败");
return null;
} finally {
if (httpResponse != null) {
try {
EntityUtils.consume(httpResponse.getEntity()); //会自动释放连接
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
public static String post(String url, List<NameValuePair> nvps) throws Exception {
// HttpClient httpclient = new DefaultHttpClient(); 已经过期采用新的类
CloseableHttpClient httpclient = HttpClients.createDefault();
String str = "";
try {
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
CloseableHttpResponse response = httpclient.execute(httpPost);
try {
HttpEntity entity = response.getEntity();
str = EntityUtils.toString(entity);
log.info("httpclient调用状态:" + response.getStatusLine());
log.info("httpclient调用结果{}", str);
// return EntityUtils.toString(response.getEntity());
return str;
} finally {
response.close();
}
} finally {
httpclient.close();
}
}
public static String post(String url, Map<String,Object> params) throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpResponse response=null;
String str = "";
try {
HttpPost httpPost = new HttpPost(url);
//设置参数
List<NameValuePair> list = new ArrayList<NameValuePair>();
for(String key : params.keySet()){
list.add(new BasicNameValuePair(key,""+params.get(key)));
}
if(list.size() > 0){
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list);
httpPost.setEntity(new UrlEncodedFormEntity(list, "utf-8"));
}
response = httpclient.execute(httpPost);
str = EntityUtils.toString(response.getEntity(), "UTF-8");
return str;
} finally {
if(response!=null){
response.close();
}
httpclient.close();
}
}
public static String postRaw(String url, String json) throws Exception {
// HttpClient httpclient = new DefaultHttpClient(); 已经过期采用新的类
CloseableHttpClient httpclient = HttpClients.createDefault();
String str = "";
try {
HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(json);// json传递
httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/json");
CloseableHttpResponse response = httpclient.execute(httpPost);
try {
HttpEntity entity = response.getEntity();
str = EntityUtils.toString(entity);
log.info("httpclient调用状态:" + response.getStatusLine());
log.info("httpclient调用结果{}", str);
// return EntityUtils.toString(response.getEntity());
return str;
} finally {
response.close();
}
} finally {
httpclient.close();
}
}
public static String get(String url) throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
HttpGet httpget = new HttpGet(url);
// httpget.addHeader(new BasicHeader("", ""));
// httpget.addHeader("", "");
String str = "";
CloseableHttpResponse response = httpclient.execute(httpget);
try {
// 获取状态行
HttpEntity entity = response.getEntity();
str = EntityUtils.toString(entity);
log.info("httpclient调用状态:" + response.getStatusLine());
log.info("httpclient调用结果{}", str);
return str;
} finally {
response.close();
}
} finally {
httpclient.close();
}
}
public static void main(String[] args) {
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
try {
get("http://localhost:8080/website/index");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package com.thinkgem.jeesite.modules.pay.juhezhong.utils;
import java.security.MessageDigest;
public abstract class MD5Utils {
private static byte[] getBytes(String text) {
return text.getBytes(CharsetUtil.UTF_8);
}
/**
* 返回MD5 加密字符串
*
* @param text
* @return
* @throws Exception
*/
public static String md5(String text) throws Exception {
return md5(getBytes(text));
}
public static byte[] md5ToByte(String text) throws Exception {
return md5ToByte(getBytes(text));
}
public static byte[] md5ToByte(byte[] bytes) throws Exception {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(bytes);
return messageDigest.digest();
}
/**
* 返回MD5 加密字符串
*
* @param bytes
* @return
* @throws Exception
*/
public static String md5(byte[] bytes) throws Exception {
byte[] use = md5ToByte(bytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < use.length; i++) {
if ((use[i] & 0xff) < 0x10) {
sb.append("0");
}
sb.append(Long.toString(use[i] & 0xff, 16));
}
return sb.toString();
}
/**
* MD5方法
*
* @param text
* @return 大写
* @throws Exception
*/
public static String md5UpperCase(String text) throws Exception {
byte[] bytes = getBytes(text);
return md5(bytes).toUpperCase();
}
/**
* MD5方法
*
* @param text 明文
* @param salt 盐
* @return 密文
* @throws Exception
*/
public static String md5UpperCase(String text, String salt) throws Exception {
byte[] bytes = getBytes((text + salt));
return md5(bytes).toUpperCase();
}
/**
* MD5方法
*
* @param text
* @return 小写
* @throws Exception
*/
public static String md5LowerCase(String text) throws Exception {
byte[] bytes = getBytes(text);
return md5(bytes).toLowerCase();
}
/**
* MD5方法
*
* @param text 明文
* @param salt 盐
* @return 密文
* @throws Exception
*/
public static String md5LowerCase(String text, String salt) throws Exception {
byte[] bytes = getBytes((text + salt));
return md5(bytes).toLowerCase();
}
/**
* MD5验证方法
*
* @param text 明文
* @param salt 盐
* @param md5 密文
* @return true/false
* @throws Exception
*/
public static boolean verify(String text, String salt, String md5) throws Exception {
String md5Text = md5UpperCase(text, salt);
if (md5Text.equalsIgnoreCase(md5)) {
return true;
} else {
return false;
}
}
/**
* MD5验证
*
* @param text
* @param md5
* @return
* @throws Exception
*/
public static boolean verify(String text, String md5) throws Exception {
String md5Text = md5UpperCase(text);
if (md5Text.equalsIgnoreCase(md5)) {
return true;
} else {
return false;
}
}
}
package com.thinkgem.jeesite.modules.pay.juhezhong.utils;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
/**
* 签名工具类
*/
public abstract class SignUtils {
public static String sign(String signBefore, String merchantSescrt) throws Exception {
return MD5Utils.md5LowerCase(signBefore, merchantSescrt);
}
public static String signBefore(Map<String, Object> body) {
StringBuffer sign = new StringBuffer();
Set<String> keySet = new TreeSet<String>();
for (String key : body.keySet()) {
keySet.add(key);
}
for (String key : keySet) {
if (!"sign".equals(key) && body.get(key) != null) {
sign.append("&" + key + "=" + body.get(key));
}
}
if (sign != null && !("".equals(sign))) {
sign.delete(0, 1);
}
return sign.toString();
}
}
package com.thinkgem.jeesite.modules.pay.utils;
import com.thinkgem.jeesite.common.baseBean.BaseEntity;
import java.io.Serializable;
public class RateEntity extends BaseEntity implements Serializable {
private String userLevel; // 用户等级
private String payMethod; // 支付方式
private String rate; // 费率
private String balance; // 结算
private String singleLimit; // 单笔限额
private String dayLimit; // 当天额度
public RateEntity() {
}
public RateEntity(String userLevel, String payMethod) {
this.userLevel = userLevel;
this.payMethod = payMethod;
}
public String getUserLevel() {
return userLevel;
}
public void setUserLevel(String userLevel) {
this.userLevel = userLevel;
}
public String getPayMethod() {
return payMethod;
}
public void setPayMethod(String payMethod) {
this.payMethod = payMethod;
}
public String getRate() {
return rate;
}
public void setRate(String rate) {
this.rate = rate;
}
public String getBalance() {
return balance;
}
public void setBalance(String balance) {
this.balance = balance;
}
public String getSingleLimit() {
return singleLimit;
}
public void setSingleLimit(String singleLimit) {
this.singleLimit = singleLimit;
}
public String getDayLimit() {
return dayLimit;
}
public void setDayLimit(String dayLimit) {
this.dayLimit = dayLimit;
}
}
......@@ -3,6 +3,7 @@ package com.thinkgem.jeesite.modules.user.api;
import com.thinkgem.jeesite.common.baseBean.Response;
import com.thinkgem.jeesite.common.constant.ComCode;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.commonError.MyException;
import com.thinkgem.jeesite.modules.user.bean.IdentityCodeRequest;
import com.thinkgem.jeesite.modules.user.bean.UserRequest;
import com.thinkgem.jeesite.modules.user.entity.IdentityCodeEntity;
......@@ -336,6 +337,10 @@ public class UserApiController {
userService.addNewCard(request);
resp.setStatus(ComCode.STATUS_CODE_2000);
resp.setMessage(ComCode.STATUS_CODE_2000_DESC);
} catch (MyException e) {
resp.setStatus(ComCode.STATUS_CODE_5001);
resp.setMessage(ComCode.STATUS_CODE_5001_DESC);
resp.setError(e.getMessage());
} catch (Exception e) {
resp.setStatus(ComCode.STATUS_CODE_9998);
resp.setMessage(ComCode.STATUS_CODE_9998_DESC);
......@@ -409,7 +414,7 @@ public class UserApiController {
|| StringUtils.isBlank(request.getFunction()) || StringUtils.isBlank(request.getIdentityCode())
|| StringUtils.isBlank(request.getRealName()) || StringUtils.isBlank(request.getIdCard()) || StringUtils.isBlank(request.getIdCardPlace())
|| StringUtils.isBlank(request.getCardNo()) || StringUtils.isBlank(request.getCardMobile()) || StringUtils.isBlank(request.getBelongBank()) || StringUtils.isBlank(request.getCardPlace()) || StringUtils.isBlank(request.getCardBank())
|| StringUtils.isBlank(request.getIdCardFront()) || StringUtils.isBlank(request.getIdCardBack()) || StringUtils.isBlank(request.getIdCardHold()) || StringUtils.isBlank(request.getDebitCard())) {
|| StringUtils.isBlank(request.getIdCardFront()) || StringUtils.isBlank(request.getIdCardBack()) || StringUtils.isBlank(request.getIdCardHold()) || StringUtils.isBlank(request.getDebitCard()) || StringUtils.isBlank(request.getCardSrc())) {
resp.setStatus(ComCode.STATUS_CODE_4001);
resp.setMessage(ComCode.STATUS_CODE_4001_DESC);
return resp;
......@@ -439,4 +444,54 @@ public class UserApiController {
}
return resp;
}
/**
* 获取省市
*
* @param request
* @return
*/
@PostMapping("/provinceCity")
public Response getProvinceCity(UserRequest request) {
Response resp = new Response();
try {
// 判断业务入参是否为空
if (StringUtils.isBlank(request.getType()) || StringUtils.isBlank(request.getPid())) {
resp.setStatus(ComCode.STATUS_CODE_4001);
resp.setMessage(ComCode.STATUS_CODE_4001_DESC);
return resp;
}
resp.setData(userService.getProvinceCity(request));
resp.setStatus(ComCode.STATUS_CODE_2000);
resp.setMessage(ComCode.STATUS_CODE_2000_DESC);
} catch (Exception e) {
resp.setStatus(ComCode.STATUS_CODE_9998);
resp.setMessage(ComCode.STATUS_CODE_9998_DESC);
resp.setError(e.getMessage());
}
return resp;
}
/**
* 获取所属银行及联行号
*
* @param request
* @return
*/
@PostMapping("/belongBank")
public Response getBelongBank(UserRequest request) {
Response resp = new Response();
try {
resp.setData(userService.getBelongBank(request));
resp.setStatus(ComCode.STATUS_CODE_2000);
resp.setMessage(ComCode.STATUS_CODE_2000_DESC);
} catch (Exception e) {
resp.setStatus(ComCode.STATUS_CODE_9998);
resp.setMessage(ComCode.STATUS_CODE_9998_DESC);
resp.setError(e.getMessage());
}
return resp;
}
}
......@@ -18,6 +18,8 @@ public class UserRequest extends Request {
private String belongBank; // 所属银行
private String cardBank; // 开户支行
private String cardPlace; // 开户地址
private String province; // 省
private String city; // 市
private String feedback; // 反馈意见
private String realName; // 真实姓名
private String idCard; // 身份证号
......@@ -26,6 +28,9 @@ public class UserRequest extends Request {
private String idCardBack; // 身份证反面
private String idCardHold; // 手持身份证
private String debitCard; // 结算卡正面
private String cardSrc; // 银行卡正面
private String type; // 省市类型 P省 C市
private String pid; // 父级id
public String getMobile() {
return mobile;
......@@ -131,6 +136,22 @@ public class UserRequest extends Request {
this.cardPlace = cardPlace;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getFeedback() {
return feedback;
}
......@@ -194,4 +215,28 @@ public class UserRequest extends Request {
public void setDebitCard(String debitCard) {
this.debitCard = debitCard;
}
public String getCardSrc() {
return cardSrc;
}
public void setCardSrc(String cardSrc) {
this.cardSrc = cardSrc;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
}
......@@ -2,6 +2,7 @@ package com.thinkgem.jeesite.modules.user.dao;
import com.thinkgem.jeesite.common.baseBean.Request;
import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
import com.thinkgem.jeesite.modules.pay.utils.RateEntity;
import com.thinkgem.jeesite.modules.user.bean.UserRequest;
import com.thinkgem.jeesite.modules.user.entity.*;
......@@ -26,7 +27,7 @@ public interface UserApiDao {
UserEntity getUserInfoByPassword(UserRequest request);
UserDetailEntity getUserDetailByCode(UserEntity code);
UserDetailEntity getUserDetailByCode(UserEntity userEntity);
CardEntity getCardInfoByCode(UserEntity userEntity);
......@@ -34,6 +35,8 @@ public interface UserApiDao {
void removeCards(UserRequest request);
void updateCardStatus(CardEntity cardStatusEntity);
void addNewCard(CardEntity cardEntity);
void addFeedback(FeedbackEntity feedbackEntity);
......@@ -42,5 +45,25 @@ public interface UserApiDao {
void saveUserDetail(UserDetailEntity userDetailEntity);
void updateUserDetail(UserDetailEntity userDetailEntity);
void updateUserInfo(UserEntity userEntity);
RateEntity getRateByLevel(RateEntity rateEntityParam);
List<UserEntity> getUserInfoBySameRecommend(UserEntity queryUserRecommendEntity);
UserEntity getUserInfoById(String userId);
void updateUserLevel(UserEntity recommendedUser);
List<CardEntity> getRecommendCardsInfo(UserEntity recommendedUser);
List<ProvinceCityEntity> getProvince(UserRequest request);
List<ProvinceCityEntity> getCity(UserRequest request);
List<BelongBankEntity> getBelongBank(UserRequest request);
}
package com.thinkgem.jeesite.modules.user.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thinkgem.jeesite.common.baseBean.BaseEntity;
import java.io.Serializable;
public class BelongBankEntity extends BaseEntity implements Serializable {
private String bankCode; // 联行号
private String bankName; // 银行名称
@JsonIgnore
private String bankShort; // 银行缩写
@JsonIgnore
private String delFlag; // 删除标记
public String getBankCode() {
return bankCode;
}
public void setBankCode(String bankCode) {
this.bankCode = bankCode;
}
public String getBankName() {
return bankName;
}
public void setBankName(String bankName) {
this.bankName = bankName;
}
public String getBankShort() {
return bankShort;
}
public void setBankShort(String bankShort) {
this.bankShort = bankShort;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
}
......@@ -20,12 +20,30 @@ public class CardEntity extends BaseEntity implements Serializable {
@JsonIgnore
private String cardPlace; // 开户地点
private String isDebit; // 是否是结算卡 Y是 N否
private String subMerchantId; // 子商户号
private String cardSrc; // 图片路径
@JsonIgnore
private String type; // 账户类型 1对私 2对公
private String status; // 卡片审核状态 0未审核 1已审核 2未通过
private String province; // 省
private String city; // 市
@JsonIgnore
private String delFlag; // 删除标记 0未删除 1已删除
private String bankName; // 银行名称
@JsonIgnore
private String bankShort; // 银行缩写
private String bankUrl; // 银行logo
public CardEntity() {
}
public CardEntity(String code, String userCode, String cardType, String cardNo, String cardMobile, String belongBank, String cardBank, String cardPlace, String isDebit) {
public CardEntity(String userCode, String isDebit) {
this.userCode = userCode;
this.isDebit = isDebit;
}
public CardEntity(String code, String userCode, String cardType, String cardNo, String cardMobile, String belongBank, String cardBank, String cardPlace, String isDebit, String subMerchantId, String cardSrc, String type, String status, String province, String city) {
this.setCode(code);
this.userCode = userCode;
this.cardType = cardType;
......@@ -36,6 +54,12 @@ public class CardEntity extends BaseEntity implements Serializable {
this.cardPlace = cardPlace;
this.isDebit = isDebit;
this.delFlag = "0";
this.subMerchantId = subMerchantId;
this.cardSrc = cardSrc;
this.type = type;
this.status = status;
this.province = province;
this.city = city;
this.setCreatedUser("sys");
this.setModifiedUser("sys");
}
......@@ -104,6 +128,54 @@ public class CardEntity extends BaseEntity implements Serializable {
this.isDebit = isDebit;
}
public String getSubMerchantId() {
return subMerchantId;
}
public void setSubMerchantId(String subMerchantId) {
this.subMerchantId = subMerchantId;
}
public String getCardSrc() {
return cardSrc;
}
public void setCardSrc(String cardSrc) {
this.cardSrc = cardSrc;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getDelFlag() {
return delFlag;
}
......@@ -111,4 +183,28 @@ public class CardEntity extends BaseEntity implements Serializable {
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getBankName() {
return bankName;
}
public void setBankName(String bankName) {
this.bankName = bankName;
}
public String getBankShort() {
return bankShort;
}
public void setBankShort(String bankShort) {
this.bankShort = bankShort;
}
public String getBankUrl() {
return bankUrl;
}
public void setBankUrl(String bankUrl) {
this.bankUrl = bankUrl;
}
}
package com.thinkgem.jeesite.modules.user.entity;
public class ProvinceCityEntity {
private String id;
private String code;
private String name;
private String pid;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
}
......@@ -27,6 +27,10 @@ public class UserEntity extends BaseEntity implements Serializable {
public UserEntity() {
}
public UserEntity(String code) {
this.setCode(code);
}
public UserEntity(String code, String subMerchantId, String mobile, String password, String recommendedMobile, String recommendedPath, String belongTo) {
this.setCode(code);
this.nickname = "E_" + mobile;
......
......@@ -14,6 +14,8 @@
a.hits,
a.is_flow,
a.is_tip,
a.scope,
a.send_date,
a.create_date AS created,
a.create_by AS createdUser,
a.update_date AS modified,
......@@ -23,6 +25,15 @@
WHERE
a.is_flow = 'N'
AND a.is_tip = 'N'
AND a.scope LIKE CONCAT('%',(
SELECT
yu. LEVEL
FROM
youka_users yu
WHERE
yu. CODE = #{subMerchantCode}
),'%')
<![CDATA[AND a.send_date <= now()]]>
ORDER BY
a.create_date DESC,
a.weight DESC
......@@ -41,6 +52,8 @@
a.hits,
a.is_flow,
a.is_tip,
a.scope,
a.send_date,
a.create_date AS created,
a.create_by AS createdUser,
a.update_date AS modified,
......@@ -51,6 +64,15 @@
LEFT JOIN cms_article_data b ON a.id = b.id
WHERE
a.id = #{articleId}
AND a.scope LIKE CONCAT('%',(
SELECT
yu. LEVEL
FROM
youka_users yu
WHERE
yu. CODE = #{subMerchantCode}
),'%')
<![CDATA[AND a.send_date <= now()]]>
ORDER BY
a.create_date DESC,
a.weight DESC
......
......@@ -178,6 +178,7 @@
youka_user_details yud
WHERE
yud.user_code = #{code}
LIMIT 1
</select>
<select id="getCardInfoByCode" resultType="com.thinkgem.jeesite.modules.user.entity.CardEntity">
......@@ -192,6 +193,12 @@
yc.card_bank AS cardBank,
yc.card_place AS cardPlace,
yc.is_debit AS isDebit,
yc.sub_merchant_id AS subMerchantId,
yc.card_src AS cardSrc,
yc.type,
yc.status,
yc.province,
yc.city,
yc.create_date AS created,
yc.create_by AS createdUser,
yc.update_date AS modified,
......@@ -202,6 +209,7 @@
WHERE
yc.user_code = #{code}
AND yc.is_debit = 'Y'
AND yc.del_flag = '0'
</select>
<select id="getCardsInfo" resultType="com.thinkgem.jeesite.modules.user.entity.CardEntity">
......@@ -213,9 +221,17 @@
yc.card_no AS cardNo,
yc.card_mobile AS cardMobile,
yc.belong_bank AS belongBank,
yb.bank_name AS bankName,
yb.bank_short AS bankShort,
yc.card_bank AS cardBank,
yc.card_place AS cardPlace,
yc.is_debit AS isDebit,
yc.sub_merchant_id AS subMerchantId,
yc.card_src AS cardSrc,
yc.type,
yc.status,
yc.province,
yc.city,
yc.create_date AS created,
yc.create_by AS createdUser,
yc.update_date AS modified,
......@@ -223,6 +239,7 @@
yc.del_flag AS delFlag
FROM
youka_cards yc
LEFT JOIN youka_bank yb ON yc.belong_bank = yb.bank_code
WHERE
yc.user_code = #{subMerchantCode}
AND yc.card_type = #{cardType}
......@@ -240,6 +257,15 @@
</foreach>
</update>
<update id="updateCardStatus">
UPDATE
youka_cards
SET
is_debit = #{isDebit}
WHERE
user_code = #{userCode}
</update>
<insert id="addNewCard">
INSERT INTO youka_cards (
code,
......@@ -251,12 +277,18 @@
card_bank,
card_place,
is_debit,
sub_merchant_id,
card_src,
type,
status,
province,
city,
create_by,
update_by,
del_flag
)
VALUES
(#{code}, #{userCode}, #{cardType}, #{cardNo}, #{cardMobile}, #{belongBank}, #{cardBank}, #{cardPlace}, #{isDebit}, #{createdUser}, #{modifiedUser}, #{delFlag})
(#{code}, #{userCode}, #{cardType}, #{cardNo}, #{cardMobile}, #{belongBank}, #{cardBank}, #{cardPlace}, #{isDebit}, #{subMerchantId}, #{cardSrc}, #{type}, #{status}, #{province}, #{city}, #{createdUser}, #{modifiedUser}, #{delFlag})
</insert>
<insert id="addFeedback">
......@@ -279,7 +311,7 @@
yau.create_date AS created,
yau.create_by AS createdUser,
yau.update_date AS modified,
yau.update_by AS modifiedUse
yau.update_by AS modifiedUser
FROM
youka_about_us yau
ORDER BYd
......@@ -299,12 +331,30 @@
id_card_hold,
debit_card,
create_by,
update_by
update_by,
update_date = CURRENT_TIMESTAMP
)
VALUES
(#{code}, #{userCode}, #{realName}, #{idCard}, #{idCardPlace}, #{idCardFront}, #{idCardBack}, #{idCardHold}, #{debitCard}, #{createdUser}, #{modifiedUser})
</insert>
<update id="updateUserDetail">
UPDATE
youka_user_details
SET
real_name = #{realName},
id_card = #{idCard},
id_card_place = #{idCardPlace},
id_card_front = #{idCardFront},
id_card_back = #{idCardBack},
id_card_hold = #{idCardHold},
debit_card = #{debitCard},
create_by = #{createdUser},
update_by = #{modifiedUser}
WHERE
user_code = #{userCode}
</update>
<update id="updateUserInfo">
UPDATE youka_users
SET code = #{code}
......@@ -313,4 +363,156 @@
</if>
WHERE code = #{code}
</update>
<select id="getRateByLevel" resultType="com.thinkgem.jeesite.modules.pay.utils.RateEntity">
SELECT
yr.id,
yr.code,
yr.user_level AS userLevel,
yr.pay_method AS payMethod,
yr.rate,
yr.balance,
yr.single_limit AS singleLimit,
yr.day_limit AS dayLimit,
yr.create_date AS created,
yr.create_by AS createdUser,
yr.update_date AS modified,
yr.update_by AS modifiedUser
FROM
youka_rate yr
WHERE
yr.user_level = #{userLevel}
AND yr.pay_method = #{payMethod}
</select>
<select id="getUserInfoBySameRecommend" resultType="com.thinkgem.jeesite.modules.user.entity.UserEntity">
SELECT
yu.id,
yu.code,
yu.nickname,
yu.sub_merchant_id AS subMerchantId,
yu.level,
yu.mobile,
yu.password,
yu.avatar,
yu.recommended_mobile AS recommendedMobile,
yu.recommended_path AS recommendedPath,
yu.belong_to AS belongTo,
yu.status,
yu.create_date AS created,
yu.create_by AS createdUser,
yu.update_date AS modified,
yu.update_by AS modifiedUser
FROM
youka_users yu
WHERE
yu.recommended_path = (SELECT yu1.recommended_path FROM youka_users yu1 WHERE yu1.code = #{code})
AND yu.status != 0
</select>
<select id="getUserInfoById" resultType="com.thinkgem.jeesite.modules.user.entity.UserEntity">
SELECT
yu.id,
yu.code,
yu.nickname,
yu.sub_merchant_id AS subMerchantId,
yu.level,
yu.mobile,
yu.password,
yu.avatar,
yu.recommended_mobile AS recommendedMobile,
yu.recommended_path AS recommendedPath,
yu.belong_to AS belongTo,
yu.status,
yu.create_date AS created,
yu.create_by AS createdUser,
yu.update_date AS modified,
yu.update_by AS modifiedUser
FROM
youka_users yu
WHERE
id = #{id}
</select>
<update id="updateUserLevel">
UPDATE
youka_users
SET
level = #{level}
WHERE
code = #{code}
AND level = 'E'
</update>
<select id="getRecommendCardsInfo" resultType="com.thinkgem.jeesite.modules.user.entity.CardEntity">
SELECT
yc.id,
yc.code,
yc.user_code AS userCode,
yc.card_type AS cardType,
yc.card_no AS cardNo,
yc.card_mobile AS cardMobile,
yc.belong_bank AS belongBank,
yc.card_bank AS cardBank,
yc.card_place AS cardPlace,
yc.is_debit AS isDebit,
yc.sub_merchant_id AS subMerchantId,
yc.card_src AS cardSrc,
yc.type,
yc.status,
yc.province,
yc.city,
yc.create_date AS created,
yc.create_by AS createdUser,
yc.update_date AS modified,
yc.update_by AS modifiedUser,
yc.del_flag AS delFlag
FROM
youka_cards yc
WHERE
yc.user_code = #{code}
AND yc.del_flag = '0'
</select>
<select id="getProvince" resultType="com.thinkgem.jeesite.modules.user.entity.ProvinceCityEntity">
SELECT
id,
province_code AS code,
province AS name,
country_id AS pid
FROM
region_provinces
WHERE
country_id = #{pid}
</select>
<select id="getCity" resultType="com.thinkgem.jeesite.modules.user.entity.ProvinceCityEntity">
SELECT
id,
city_code AS code,
city AS name,
province_id AS pid
FROM
region_cities
WHERE
province_id = #{pid}
</select>
<select id="getBelongBank" resultType="com.thinkgem.jeesite.modules.user.entity.BelongBankEntity">
SELECT
yb.id,
yb.code,
yb.bank_code AS bankCode,
yb.bank_name AS bankName,
yb.bank_short AS bankShort,
yb.create_date AS created,
yb.create_by AS createdUser,
yb.update_date AS modified,
yb.update_by AS modifiedUser,
yb.del_flag AS delFlag
FROM
youka_bank yb
WHERE
del_flag = '0'
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment