Commit ab849450 authored by xiongjunyi's avatar xiongjunyi

Initial commit

parents
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.miya</groupId>
<artifactId>manning</artifactId>
<version>1.0-SNAPSHOT</version>
<name>manning</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<aspectj.version>1.8.10</aspectj.version>
</properties>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus ReleaseRepository</name>
<url>http://10.8.0.128:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus SnapshotsRepository</name>
<url>http://10.8.0.128:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.13</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-full</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>ch.ethz.ganymed</groupId>
<artifactId>ganymed-ssh2</artifactId>
<version>build210</version>
</dependency>
<!--spring依赖-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>
<!--aspectj依赖-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>
<!--spring事务依赖-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.2</version>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- allure测试报表 -->
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-testng-adaptor</artifactId>
<version>1.3.6</version>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>2.12.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
package com.miya.manning.enums;
public enum DataRefTypeEnum {
Type_Object(0,"对象类型"),
Type_List(1,"数组类型"),
Type_Integer(2,"整数类型"),
Type_normal(3,"普通类型"),
Type_bool(4,"布尔类型");
private int typeId;
private String desc;
DataRefTypeEnum(int typeId, String desc) {
this.typeId = typeId;
this.desc = desc;
}
public int getTypeId() {
return typeId;
}
public void setTypeId(int typeId) {
this.typeId = typeId;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package com.miya.manning.enums;
public enum ScriptType {
JAVA_SCRIPT("Java","java脚本"),
SSH_SCRIPT("SSH","ssh脚本");
private String type;
private String desc;
ScriptType(String type, String desc) {
this.type = type;
this.desc = desc;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package com.miya.manning.framework.request;
import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.request
* @ClassName: HTTPDelete
* @Description: java类作用描述
* @Author: 唐奇良
* @CreateDate: 2019/1/21 下午5:59
* @UpdateUser: 更新者
* @UpdateDate: 2019/1/21 下午5:59
*/
public class HTTPDelete {
public static String httpDelete(String url, JSONObject jsonParam){
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
MyHttpDelete myhttpdelete = new MyHttpDelete(url);
StringEntity entity = new StringEntity(jsonParam.toString(), "utf-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
myhttpdelete.setEntity(entity);
CloseableHttpResponse httpResponse = null;
String result = null;
try {
httpResponse = closeableHttpClient.execute(myhttpdelete);
HttpEntity httpEntity = httpResponse.getEntity();
result = EntityUtils.toString(httpEntity, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
}
package com.miya.manning.framework.request;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.testng.collections.CollectionUtils;
import java.io.*;
import java.net.URI;
import java.util.*;
import java.util.Map.Entry;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.request
* @ClassName: HTTPGet
* @Description: java类作用描述
* @Author: 唐奇良
* @CreateDate: 2019/1/21 下午5:33
* @UpdateUser: 更新者
* @UpdateDate: 2019/1/21 下午5:33
*/
public class HTTPGet {
public static String httpGet(String url) {
return httpGet(url, null);
}
/*public static String httpGet(String url, String headerContent) {
HttpClient hc = new DefaultHttpClient();
HttpGet hg = new HttpGet(url);
if (StringUtils.isNotBlank(headerContent)) {
hg.addHeader("authorization", headerContent);
}
try {
HttpResponse response = hc.execute(hg);
HttpEntity entity = response.getEntity();
String result = null;
if (entity != null) {
result = EntityUtils.toString(entity, "UTF-8");
}
return result;
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
hc.getConnectionManager().shutdown();
return null;
}*/
public static String get(String url,Map<String,String> headerMap,Map<String, String> paramMap) throws ClientProtocolException, IOException {
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet();
Iterator headerIterator = headerMap.entrySet().iterator(); //循环增加header
while (headerIterator.hasNext()) {
Entry<String, String> elem = (Entry<String, String>) headerIterator.next();
httpGet.addHeader(elem.getKey(), elem.getValue());
}
if (CollectionUtils.hasElements(paramMap)){
List<NameValuePair> formparams = setHttpParams(paramMap);
String param = URLEncodedUtils.format(formparams, "UTF-8");
httpGet.setURI(URI.create(url + "?" + param));
}else{
httpGet.setURI(URI.create(url));
}
HttpResponse response = httpClient.execute(httpGet);
String httpEntityContent = getHttpEntityContent(response);
httpGet.abort();
return httpEntityContent;
}
private static List<NameValuePair> setHttpParams(Map<String, String> paramMap) {
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
Set<Entry<String, String>> set = paramMap.entrySet();
for (Entry<String, String> entry : set) {
formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
return formparams;
}
private static String getHttpEntityContent(HttpResponse response) throws IOException, UnsupportedEncodingException {
//通过HttpResponse 的getEntity()方法获取返回信息
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream is = entity.getContent();
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String line = br.readLine();
StringBuilder sb = new StringBuilder();
while (line != null) {
sb.append(line + "\n");
line = br.readLine();
}
br.close();
is.close();
return sb.toString();
}
return "";
}
public static String httpGet(String url, Map<String, String> httpHeaderMap) {
HttpClient hc = new DefaultHttpClient();
HttpGet hg = new HttpGet(url);
//添加HTTPHeader
Iterator headerIterator = httpHeaderMap.entrySet().iterator(); //循环增加header
while (headerIterator.hasNext()) {
Entry<String, String> elem = (Entry<String, String>) headerIterator.next();
hg.addHeader(elem.getKey(), elem.getValue());
}
//hg.addHeader("authorization", "bearer 65008152-6d0c-484c-8b25-c21e119190af");
//hg.addHeader("Customer-Id", "121");
try {
HttpResponse response = hc.execute(hg);
HttpEntity entity = response.getEntity();
String result = null;
if(entity != null) {
result = EntityUtils.toString(entity,"UTF-8");
}
return result;
}
catch(ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
hc.getConnectionManager().shutdown();
return null;
}
}
This diff is collapsed.
package com.miya.manning.framework.request;
import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.request
* @ClassName: HTTPPut
* @Description: java类作用描述
* @Author: 唐奇良
* @CreateDate: 2019/1/21 下午5:41
* @UpdateUser: 更新者
* @UpdateDate: 2019/1/21 下午5:41
*/
public class HTTPPut {
public static String httpPut(String url, JSONObject jsonParam) throws IOException {
HttpClient client = HttpClientBuilder.create().build();
HttpPut put = new HttpPut(url);
put.setHeader("Content-Type","application/json");
put.addHeader("Accept", "application/json");
StringEntity params =new StringEntity(jsonParam.toString(), "utf-8");
put.setEntity(params);
HttpResponse response = client.execute(put);
HttpEntity httpEntity = response.getEntity();
String result = EntityUtils.toString(httpEntity, "UTF-8");
return result;
}
public static String httpPut(String url, Map<String,String> httpHeaderMap) throws IOException {
HttpClient client = HttpClientBuilder.create().build();
HttpPut put = new HttpPut(url);
Iterator headerIterator = httpHeaderMap.entrySet().iterator(); //循环增加header
while (headerIterator.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>) headerIterator.next();
put.addHeader(elem.getKey(), elem.getValue());
}
HttpResponse response = client.execute(put);
HttpEntity httpEntity = response.getEntity();
String result = EntityUtils.toString(httpEntity, "UTF-8");
return result;
}
}
\ No newline at end of file
package com.miya.manning.framework.request;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import java.net.URI;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.request
* @ClassName: MyHttpDelete
* @Description: HttpClient自带的HttpDelete方法是不支持上传body的,所以重写delete方法
* @Author: 唐奇良
* @CreateDate: 2019/1/21 下午7:05
* @UpdateUser: 更新者
* @UpdateDate: 2019/1/21 下午7:05
*/
public class MyHttpDelete extends HttpEntityEnclosingRequestBase {
public static final String METHOD_NAME = "DELETE";
public String getMethod() {
return METHOD_NAME;
}
public MyHttpDelete(final String uri) {
super();
setURI(URI.create(uri));
}
public MyHttpDelete(final URI uri) {
super();
setURI(uri);
}
public MyHttpDelete() {
super();
}
}
package com.miya.manning.framework.response;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.response
* @ClassName: SaasResponse
* @Description: java类作用描述
* @Author: 梁振振
* @CreateDate: 2020/8/21 下午4:56
* @UpdateUser:
* @UpdateDate:
*/
public class SaasResponse {
private String code;
private String msg;
private Object data;
public SaasResponse() {}
public JsonObject getJsonObjData() {
try {
Gson gs = new Gson();
JsonObject responseData = new JsonParser().parse(gs.toJson(this.data)).getAsJsonObject();
return responseData;
}catch (Exception e) {
return null;
}
}
public JsonArray getJsonArrData() {
try {
Gson gs = new Gson();
JsonArray responseData = new JsonParser().parse(gs.toJson(this.data)).getAsJsonArray();
return responseData;
}catch (Exception e) {
return null;
}
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
package com.miya.manning.framework.saas;
import com.miya.interfacetest.huihua.framework.util.GPSUtil;
import com.miya.interfacetest.huihua.framework.util.PropertiesHandle;
import com.miya.interfacetest.huihua.framework.util.StringUtil;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: Store
* @Description: 门店类
* @Author: 梁振振
* @CreateDate: 2020/8/11 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class Store {
private int id;
private int merchantId;
private String latitude;
private String longitude;
private String name;
private String provinceId;
private String cityId;
private String regionId;
private String address;
private double saasDistance;
public Store(int id) {
this.id = id;
this.setStoreInfoWithStoreId(id);
}
public void setStoreInfoWithStoreId(int id) {
MysqlUtil sqlUtil = new MysqlUtil();
ResultSet storeQuery = sqlUtil.ExecuteSelectSQL("select * from store where id = " + id);
try {
storeQuery.next();
this.merchantId = storeQuery.getInt("merchant_id");
this.latitude = storeQuery.getString("lat");
this.longitude = storeQuery.getString("lng");
this.name = storeQuery.getString("name");
this.provinceId = storeQuery.getString("province_id");
this.cityId = storeQuery.getString("city_id");
this.regionId = storeQuery.getString("region_id");
this.address = storeQuery.getString("address");
this.saasDistance = this.getSaasDistance();
} catch (SQLException e) {
e.printStackTrace();
}
}
public double getSaasDistance () {
String currentLng = PropertiesHandle.readValue(StringUtil.SAAS_PARAM_FILE_PATH, "current_hangzhou_longitude");
String currentLat = PropertiesHandle.readValue(StringUtil.SAAS_PARAM_FILE_PATH, "current_hangzhou_latitude");
return GPSUtil.GetSaasDistance(currentLng, currentLat, this.longitude, this.latitude);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getProvinceId() {
return provinceId;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public String getCityId() {
return cityId;
}
public void setCityId(String cityId) {
this.cityId = cityId;
}
public String getRegionId() {
return regionId;
}
public void setRegionId(String regionId) {
this.regionId = regionId;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public void setSaasDistance(double saasDistance) {
this.saasDistance = saasDistance;
}
}
This diff is collapsed.
package com.miya.manning.framework.saas.coupon;
import com.miya.interfacetest.huihua.framework.saas.User;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: Coupon
* @Description: 优惠券类
* @Author: 梁振振
* @CreateDate: 2020/8/11 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class Coupon {
private String couponId;
private int userId;
private int status;
private Date writeOffTime;
private Date createTime;
private int couponBatchId;
public Coupon(String couponId) throws SQLException {
this.couponId = couponId;
this.setCouponInfoWithCouponId(couponId);
}
public void setCouponInfoWithCouponId(String couponId) throws SQLException {
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet couponQuery = mysqlUtil.ExecuteSelectSQL("select * from card_search where coupon_id = \"" + couponId + "\"");
couponQuery.next();
this.status = couponQuery.getInt("status");
this.writeOffTime = couponQuery.getTimestamp("write_off_time");
this.createTime = couponQuery.getTimestamp("create_time");
this.userId = couponQuery.getInt("userid");
this.couponBatchId = couponQuery.getInt("card_id");
}
public User getUser() throws SQLException {
return new User(String.valueOf(this.userId));
}
public CouponBatch getCouponBatch () throws SQLException {
return new CouponBatch(this.couponBatchId);
}
/* public CouponHongbaoActivity getFirstHongbaoActivity () throws SQLException {
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet hongbaoQuery = mysqlUtil.ExecuteSelectSQL("select a.id from card_activity a left join card_red_packet_record r on a.id = r.activity_id " +
" where a.rule_coupon_id in (select card_id from card_search where coupon_id = \"" + this.getCouponId() + "\")" +
" order by r.gmt_create desc");
hongbaoQuery.next();
return new CouponHongbaoActivity(hongbaoQuery.getInt("id"));
}*/
public CouponHongbao getFirstHongbao () throws SQLException {
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet hongbaoQuery = mysqlUtil.ExecuteSelectSQL("select r.id from card_activity a left join card_red_packet_record r on a.id = r.activity_id " +
" where a.rule_coupon_id in (select card_id from card_search where coupon_id = \"" + this.getCouponId() + "\")" +
" order by r.gmt_create desc");
hongbaoQuery.next();
return new CouponHongbao(hongbaoQuery.getInt("id"));
}
public String getCouponId() {
return couponId;
}
public void setCouponId(String couponId) {
this.couponId = couponId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Date getWriteOffTime() {
return writeOffTime;
}
public void setWriteOffTime(Date writeOffTime) {
this.writeOffTime = writeOffTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public int getCouponBatchId() {
return couponBatchId;
}
public void setCouponBatchId(int couponBatchId) {
this.couponBatchId = couponBatchId;
}
}
package com.miya.manning.framework.saas.coupon;
import com.miya.interfacetest.huihua.framework.saas.Store;
import com.miya.interfacetest.huihua.framework.util.ComparatorUtil;
import com.miya.interfacetest.huihua.framework.util.PropertiesHandle;
import com.miya.interfacetest.huihua.framework.util.StringUtil;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: CouponBatch
* @Description: 优惠券批次类
* @Author: 梁振振
* @CreateDate: 2020/8/11 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class CouponBatch {
private int id;
private int merchantId;
private String title;
private String type;
private String description;
private Date beginTime;
private Date endTime;
private String userRules;
private int giftable;
private String btnStatus;
private int num;
public CouponBatch(int id) {
this.id = id;
this.setCouponInfoWithCouponId(id);
this.setBtnStatus();
}
public void setCouponInfoWithCouponId(int id){
MysqlUtil sqlUtil = new MysqlUtil();
ResultSet couponQuery = sqlUtil.ExecuteSelectSQL("select * from card_ticket where id = " + id);
try {
couponQuery.next();
this.merchantId = couponQuery.getInt("merchant_id");
this.title = couponQuery.getString("card_title");
this.type = couponQuery.getString("card_type");
this.description = couponQuery.getString("description");
this.beginTime = couponQuery.getTimestamp("begin_timestamp");
this.endTime = couponQuery.getTimestamp("end_timestamp");
this.userRules = couponQuery.getString("use_rules");
this.giftable = couponQuery.getInt("is_support_given");
} catch (SQLException e) {
e.printStackTrace();
}
}
public List<Store> getStoreList() {
List<Store> storeList = new ArrayList<>();
MysqlUtil sqlUtil = new MysqlUtil();
ResultSet storeQuery = sqlUtil.ExecuteSelectSQL("select * from card_ticket_store_map where card_id = " + this.id);
try {
while (storeQuery.next()){
storeList.add(new Store(storeQuery.getInt("store_id")));
}
Collections.sort(storeList, ComparatorUtil.storeSaasDistanceComparator);
return storeList;
} catch (SQLException e) {
e.printStackTrace();
return storeList;
}
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public String getUserRules() {
return userRules;
}
public void setUserRules(String userRules) {
this.userRules = userRules;
}
public int getGiftable() {
return giftable;
}
public void setGiftable(int giftable) {
this.giftable = giftable;
}
public String getBtnStatus() {
return btnStatus;
}
private void setBtnStatus() {
this.btnStatus = PropertiesHandle.readSpecialValue(StringUtil.COUPON_PARAM_FILE_PATH, String.valueOf(this.id));
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
package com.miya.manning.framework.saas.coupon;
import com.miya.interfacetest.huihua.framework.saas.User;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: CouponHongbao
* @Description: 红包类
* @Author: 梁振振
* @CreateDate:
* @UpdateUser:
* @UpdateDate:
*/
public class CouponHongbao {
private int id;
private int merchantId;
private int activityId;
private int userId;
private String userPhone;
private String activityTitle;
private String hongbaoGroupId;
private Date shareExpiryTime;
private Date receiveExpiryTime;
private int hongbaoCouponNum;
public CouponHongbao(int id) throws SQLException {
this.id = id;
this.setCouponHongbaoWithId(id);
}
public void setCouponHongbaoWithId(int id) throws SQLException {
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet couponHongbaoQuery = mysqlUtil.ExecuteSelectSQL("select * from card_red_packet_record where id = " + id);
couponHongbaoQuery.next();
this.merchantId = couponHongbaoQuery.getInt("merchant_id");
this.activityId = couponHongbaoQuery.getInt("activity_id");
this.userId = couponHongbaoQuery.getInt("user_id");
this.userPhone = couponHongbaoQuery.getString("phone");
this.activityTitle = couponHongbaoQuery.getString("activity_title");
this.hongbaoGroupId = couponHongbaoQuery.getString("red_packet_group_id");
this.shareExpiryTime = couponHongbaoQuery.getTimestamp("share_end_date");
this.receiveExpiryTime = couponHongbaoQuery.getTimestamp("receive_end_time");
this.hongbaoCouponNum = couponHongbaoQuery.getInt("coupon_total_count");
}
public CouponHongbaoActivity getHongbaoActivity() throws SQLException {
return new CouponHongbaoActivity(this.activityId);
}
public Coupon getReceivedCoupon(User user) throws SQLException {
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet couponQuery = mysqlUtil.ExecuteSelectSQL("select * from card_red_packet_search_map " +
"where red_packet_id = " + this.id + " and share_user_id = " + this.userId + " and receive_user_id = " + user.getUserId());
couponQuery.next();
return new Coupon(couponQuery.getString("coupon_id"));
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public int getActivityId() {
return activityId;
}
public void setActivityId(int activityId) {
this.activityId = activityId;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserPhone() {
return userPhone;
}
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}
public String getActivityTitle() {
return activityTitle;
}
public void setActivityTitle(String activityTitle) {
this.activityTitle = activityTitle;
}
public String getHongbaoGroupId() {
return hongbaoGroupId;
}
public void setHongbaoGroupId(String hongbaoGroupId) {
this.hongbaoGroupId = hongbaoGroupId;
}
public Date getShareExpiryTime() {
return shareExpiryTime;
}
public void setShareExpiryTime(Date shareExpiryTime) {
this.shareExpiryTime = shareExpiryTime;
}
public Date getReceiveExpiryTime() {
return receiveExpiryTime;
}
public void setReceiveExpiryTime(Date receiveExpiryTime) {
this.receiveExpiryTime = receiveExpiryTime;
}
public int getHongbaoCouponNum() {
return hongbaoCouponNum;
}
public void setHongbaoCouponNum(int hongbaoCouponNum) {
this.hongbaoCouponNum = hongbaoCouponNum;
}
}
package com.miya.manning.framework.saas.coupon;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: CouponHongbaoActivity
* @Description: 分享红包活动类
* @Author: 梁振振
* @CreateDate:
* @UpdateUser:
* @UpdateDate:
*/
public class CouponHongbaoActivity {
private int id;
private int merchantId;
private String activityTitle;
private String hongbaoGroupId;
private int shareExpiryHours;
private int receiveExpiryHours;
private String verifiedCouponTitle;
private int verifiedCouponId;
private int couponType;
private String shareTitle;
private String activityRules;
private int status;
public CouponHongbaoActivity(int id) throws SQLException {
this.id = id;
this.setCouponHongbaoActivityWithId(id);
}
public void setCouponHongbaoActivityWithId(int id) throws SQLException {
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet couponHongbaoQuery = mysqlUtil.ExecuteSelectSQL("select * from card_activity where id = " + id);
couponHongbaoQuery.next();
this.merchantId = couponHongbaoQuery.getInt("merchant_id");
this.activityTitle = couponHongbaoQuery.getString("activity_title");
this.hongbaoGroupId = couponHongbaoQuery.getString("red_packet_group_id");
this.shareExpiryHours = couponHongbaoQuery.getInt("share_failure_hours");
this.receiveExpiryHours = couponHongbaoQuery.getInt("receive_failure_hours");
this.couponType = couponHongbaoQuery.getInt("card_type");
this.status = couponHongbaoQuery.getInt("status");
this.verifiedCouponTitle = couponHongbaoQuery.getString("rule_coupon_name");
this.verifiedCouponId = couponHongbaoQuery.getInt("rule_coupon_id");
this.shareTitle = couponHongbaoQuery.getString("share_title");
this.activityRules = couponHongbaoQuery.getString("activity_rule");
}
public List<CouponBatch> getHongbaoCouponList() throws SQLException {
List<CouponBatch> hongbaoCouponList = new ArrayList<>();
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet hongbaoCouponListQuery = mysqlUtil.ExecuteSelectSQL("select * from card_red_packet where group_id = \"" + this.hongbaoGroupId + "\"");
while (hongbaoCouponListQuery.next()){
hongbaoCouponList.add(new CouponBatch(hongbaoCouponListQuery.getInt("coupon_id")));
}
return hongbaoCouponList;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public String getActivityTitle() {
return activityTitle;
}
public void setActivityTitle(String activityTitle) {
this.activityTitle = activityTitle;
}
public String getHongbaoGroupId() {
return hongbaoGroupId;
}
public void setHongbaoGroupId(String hongbaoGroupId) {
this.hongbaoGroupId = hongbaoGroupId;
}
public int getShareExpiryHours() {
return shareExpiryHours;
}
public void setShareExpiryHours(int shareExpiryHours) {
this.shareExpiryHours = shareExpiryHours;
}
public int getReceiveExpiryHours() {
return receiveExpiryHours;
}
public void setReceiveExpiryHours(int receiveExpiryHours) {
this.receiveExpiryHours = receiveExpiryHours;
}
public String getVerifiedCouponTitle() {
return verifiedCouponTitle;
}
public void setVerifiedCouponTitle(String verifiedCouponTitle) {
this.verifiedCouponTitle = verifiedCouponTitle;
}
public int getVerifiedCouponId() {
return verifiedCouponId;
}
public void setVerifiedCouponId(int verifiedCouponId) {
this.verifiedCouponId = verifiedCouponId;
}
public int getCouponType() {
return couponType;
}
public void setCouponType(int couponType) {
this.couponType = couponType;
}
public String getShareTitle() {
return shareTitle;
}
public void setShareTitle(String shareTitle) {
this.shareTitle = shareTitle;
}
public String getActivityRules() {
return activityRules;
}
public void setActivityRules(String activityRules) {
this.activityRules = activityRules;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
package com.miya.manning.framework.saas.coupon;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: CouponMarket
* @Description: 券商城类
* @Author: 梁振振
* @CreateDate: 2020/8/11 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class CouponMarket {
private int merchantId;
private List<CouponPacket> couponPacketList;
public CouponMarket(int merchantId) {
this.merchantId = merchantId;
this.setCouponMarketInfoWithMerchantId();
}
public void setCouponMarketInfoWithMerchantId() {
this.couponPacketList = new ArrayList<>();
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet couponMarketQuery = mysqlUtil.ExecuteSelectSQL("select * from card_packet where merchant_id = " + this.merchantId + " and status = 1 order by sort is NULL, sort, create_time desc");
try {
while (couponMarketQuery.next()){
couponPacketList.add(new CouponPacket(couponMarketQuery.getInt("id")));
}
}catch (SQLException e) {
e.printStackTrace();
}
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public List<CouponPacket> getCouponPacketList() {
return couponPacketList;
}
public void setCouponPacketList(List<CouponPacket> couponPacketList) {
this.couponPacketList = couponPacketList;
}
}
package com.miya.manning.framework.saas.coupon;
import com.miya.interfacetest.huihua.framework.util.PropertiesHandle;
import com.miya.interfacetest.huihua.framework.util.StringUtil;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: CouponPacket
* @Description: 券包类
* @Author: 梁振振
* @CreateDate: 2020/8/11 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class CouponPacket {
private int id;
private int merchantId;
private String couponPacketName;
private double price;
private double linePirce;
private Date startTime;
private Date endTime;
private int status;
private String userDesc;
private int type;
private int stock;
private int dayLimit;
private int personLimit;
private int soldNum;
private String buyBtnStatus;
private int couponNum;
public CouponPacket(int id) throws SQLException {
this.id = id;
this.setCouponPacketInfoWithId(id);
this.setBuyBtnStatus();
this.setCouponNum();
}
public void setCouponPacketInfoWithId (int id) throws SQLException {
MysqlUtil sqlUtil = new MysqlUtil();
ResultSet couponPacketQuery = sqlUtil.ExecuteSelectSQL("select * from card_packet where id = " + id);
couponPacketQuery.next();
this.merchantId = couponPacketQuery.getInt("merchant_id");
this.couponPacketName = couponPacketQuery.getString("card_packet_name");
this.price = (double)couponPacketQuery.getInt("card_packet_price")/100;
this.linePirce = (double)couponPacketQuery.getInt("marking_price")/100;
this.startTime = couponPacketQuery.getTimestamp("start_time");
this.endTime = couponPacketQuery.getTimestamp("end_time");
this.status = couponPacketQuery.getInt("status");
this.userDesc = couponPacketQuery.getString("use_desc");
this.type = couponPacketQuery.getInt("card_packet_type");
this.stock = couponPacketQuery.getInt("stock");
this.dayLimit = couponPacketQuery.getInt("day_purchase_limit");
this.personLimit = couponPacketQuery.getInt("person_purchase_limit");
this.soldNum = couponPacketQuery.getInt("sale_stock");
}
private void setBuyBtnStatus() {
this.buyBtnStatus = PropertiesHandle.readSpecialValue(StringUtil.COUPON_PACKET_PARAM_FILE_PATH, String.valueOf(this.id));
}
public List<CouponBatch> getCouponBatchList() throws SQLException {
List<CouponBatch> queryedCouponBatchList = new ArrayList<CouponBatch>();
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet couponMapQuery = mysqlUtil.ExecuteSelectSQL("select card_id, num from card_packet_map where card_packet_id = " + this.id + " order by card_id desc");
while (couponMapQuery.next()){
CouponBatch couponBatch = new CouponBatch(couponMapQuery.getInt("card_id"));
couponBatch.setNum(couponMapQuery.getInt("num"));
queryedCouponBatchList.add(couponBatch);
}
return queryedCouponBatchList;
}
private void setCouponNum() throws SQLException {
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet couponMapQuery = mysqlUtil.ExecuteSelectSQL("select sum(num) as total_num from card_packet_map where card_packet_id = " + this.id);
couponMapQuery.next();
this.couponNum = couponMapQuery.getInt("total_num");
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public String getCouponPacketName() {
return couponPacketName;
}
public void setCouponPacketName(String couponPacketName) {
this.couponPacketName = couponPacketName;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public double getLinePirce() {
return linePirce;
}
public void setLinePirce(double linePirce) {
this.linePirce = linePirce;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getUserDesc() {
return userDesc;
}
public void setUserDesc(String userDesc) {
this.userDesc = userDesc;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
public int getDayLimit() {
return dayLimit;
}
public void setDayLimit(int dayLimit) {
this.dayLimit = dayLimit;
}
public int getPersonLimit() {
return personLimit;
}
public void setPersonLimit(int personLimit) {
this.personLimit = personLimit;
}
public int getSoldNum() {
return soldNum;
}
public void setSoldNum(int soldNum) {
this.soldNum = soldNum;
}
public String getBuyBtnStatus() {
return buyBtnStatus;
}
public void setBuyBtnStatus(String buyBtnStatus) {
this.buyBtnStatus = buyBtnStatus;
}
public int getCouponNum() {
return couponNum;
}
public void setCouponNum(int couponNum) {
this.couponNum = couponNum;
}
}
package com.miya.manning.framework.saas.giftcard;
import com.miya.interfacetest.huihua.framework.saas.User;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: GiftCard
* @Description: 礼品卡类
* @Author: 梁振振
* @CreateDate: 2020/9/7 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class GiftCard {
private int id;
private int merchantId;
private int userId;
private int cardId;
private String cardNo;
private int balance;
private int sourceType;
private int status;
private Date writeOffTime;
private String fromUserName;
private int givingBalance;
private Date receiveTime;
public GiftCard(int id) {
this.id = id;
this.setGiftCardInfo();
}
public GiftCard(String cardNo) {
this.cardNo = cardNo;
this.setGiftCardInfo();
}
public void setGiftCardInfo () {
MysqlUtil mysqlUtil = new MysqlUtil();
String sql = "";
if (this.id > 0) {
sql = "select * from hh_giftcard_user where id = " + this.id;
} else if (!this.cardNo.isEmpty()) {
sql = "select * from hh_giftcard_user where card_no = \"" + this.cardNo + "\"";
}
ResultSet giftCardQuery = mysqlUtil.ExecuteSelectSQL(sql);
try {
giftCardQuery.next();
this.id = giftCardQuery.getInt("id");
this.merchantId = giftCardQuery.getInt("merchant_id");
this.userId = giftCardQuery.getInt("user_id");
this.cardId = giftCardQuery.getInt("card_id");
this.cardNo = giftCardQuery.getString("card_no");
this.balance = giftCardQuery.getInt("balance");
this.sourceType = giftCardQuery.getInt("source_type");
this.status = giftCardQuery.getInt("status");
this.writeOffTime = giftCardQuery.getTimestamp("write_off_time");
ResultSet givingInfoQuery = mysqlUtil.ExecuteSelectSQL("select * from (SELECT * FROM `hh_giftcard_giving_info` where card_no = \"" +
this.cardNo +"\" order by receive_time desc) a group by card_no ");
if (givingInfoQuery.next()){
this.fromUserName = new User(givingInfoQuery.getInt("from_user_id")).getUserPhone();
this.givingBalance = givingInfoQuery.getInt("balance");
this.receiveTime = givingInfoQuery.getTimestamp("receive_time");
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public GiftCardBatch getGiftCardBatch () {
return new GiftCardBatch(this.cardId);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj != null && obj instanceof GiftCard) {
GiftCard giftCard = (GiftCard) obj;
return this.cardNo.equals(giftCard.cardNo);
} else {
return false;
}
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public int getCardId() {
return cardId;
}
public void setCardId(int cardId) {
this.cardId = cardId;
}
public String getCardNo() {
return cardNo;
}
public void setCardNo(String cardNo) {
this.cardNo = cardNo;
}
public int getBalance() {
return balance;
}
public void setBalance(int balance) {
this.balance = balance;
}
public int getSourceType() {
return sourceType;
}
public void setSourceType(int sourceType) {
this.sourceType = sourceType;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Date getWriteOffTime() {
return writeOffTime;
}
public void setWriteOffTime(Date writeOffTime) {
this.writeOffTime = writeOffTime;
}
public String getFromUserName() {
return fromUserName;
}
public void setFromUserName(String fromUserName) {
this.fromUserName = fromUserName;
}
public int getGivingBalance() {
return givingBalance;
}
public void setGivingBalance(int givingBalance) {
this.givingBalance = givingBalance;
}
public Date getReceiveTime() {
return receiveTime;
}
public void setReceiveTime(Date receiveTime) {
this.receiveTime = receiveTime;
}
}
package com.miya.manning.framework.saas.giftcard;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: GiftCardBatch
* @Description: 礼品卡批次类
* @Author: 梁振振
* @CreateDate: 2020/9/7 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class GiftCardBatch {
private int id;
private int merchantId;
private String stockId;
private String title;
private String description;
private int price;
private int value;
private Date startTime;
private Date endTime;
private int stock;
private String userRules;
private int status;
public GiftCardBatch(int id) {
this.id = id;
this.setGiftCardInfo();
}
public GiftCardBatch(String stockId) {
this.stockId = stockId;
this.setGiftCardInfo();
}
public void setGiftCardInfo () {
MysqlUtil mysqlUtil = new MysqlUtil();
String sql = "";
if (this.id > 0) {
sql = "select * from hh_giftcard_info where id = " + this.id;
} else if (!this.stockId.isEmpty()) {
sql = "select * from hh_giftcard_info where card_stock_id = \"" + this.stockId + "\"";
}
ResultSet giftCardQuery = mysqlUtil.ExecuteSelectSQL(sql);
try {
giftCardQuery.next();
this.id = giftCardQuery.getInt("id");
this.merchantId = giftCardQuery.getInt("merchant_id");
this.stockId = giftCardQuery.getString("card_stock_id");
this.title = giftCardQuery.getString("card_title");
this.description = giftCardQuery.getString("card_description");
this.price = giftCardQuery.getInt("card_price");
this.value = giftCardQuery.getInt("card_denomination");
this.startTime = giftCardQuery.getTimestamp("card_starttime");
this.endTime = giftCardQuery.getTimestamp("card_endtime");
this.stock = giftCardQuery.getInt("card_stock");
this.userRules = giftCardQuery.getString("card_use_desc");
this.status = giftCardQuery.getInt("status");
} catch (SQLException e) {
e.printStackTrace();
}
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public String getStockId() {
return stockId;
}
public void setStockId(String stockId) {
this.stockId = stockId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
public String getUserRules() {
return userRules;
}
public void setUserRules(String userRules) {
this.userRules = userRules;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
package com.miya.manning.framework.saas.giftcard;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: GiftCardCategory
* @Description: 礼品卡类别类
* @Author: 梁振振
* @CreateDate: 2020/9/7 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class GiftCardCategory {
private int id;
private int merchantId;
private String title;
private List<GiftCardBatch> giftCardBatchList;
public GiftCardCategory(int merchantId) {
this.merchantId = merchantId;
this.setNoCategoryCategory();
}
public GiftCardCategory(int id, int merchantId) {
this.id = id;
this.merchantId = merchantId;
this.setGiftCardCategoryWithId();
}
public void setGiftCardCategoryWithId () {
this.giftCardBatchList = new ArrayList<>();
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet categoryQuery = mysqlUtil.ExecuteSelectSQL("select * from hh_giftcard_category where id = " + this.id);
ResultSet giftCardListQuery = mysqlUtil.ExecuteSelectSQL("select m.* from hh_category_info_map m left join hh_giftcard_info g on g.id = m.card_id " +
" where g.status = 1 and m.category_id = " + this.id + " order by g.sort is NULL, g.sort, g.create_time desc");
try {
categoryQuery.next();
this.title = categoryQuery.getString("name");
while (giftCardListQuery.next()){
this.giftCardBatchList.add(new GiftCardBatch(giftCardListQuery.getInt("card_id")));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public void setNoCategoryCategory () {
this.giftCardBatchList = new ArrayList<>();
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet giftCardListQuery = mysqlUtil.ExecuteSelectSQL("select * from hh_giftcard_info where id not in " +
"(select card_id from hh_category_info_map where category_id in " +
"(select id from hh_giftcard_category where show_status = 1 )) and merchant_id = "+
this.merchantId + " and status = 1 order by sort is NULL, sort, create_time desc");
try {
while (giftCardListQuery.next()){
this.giftCardBatchList.add(new GiftCardBatch(giftCardListQuery.getInt("id")));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<GiftCardBatch> getGiftCardBatchList() {
return giftCardBatchList;
}
public void setGiftCardBatchList(List<GiftCardBatch> giftCardBatchList) {
this.giftCardBatchList = giftCardBatchList;
}
}
package com.miya.manning.framework.saas.giftcard;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: GiftCardMarket
* @Description: 礼品卡商城类
* @Author: 梁振振
* @CreateDate: 2020/9/7 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class GiftCardMarket {
private int merchantId;
private GiftCardCategory noCategoryCategory;
private List<GiftCardCategory> categoryList;
public GiftCardMarket(int merchantId) {
this.merchantId = merchantId;
this.setGiftCardMarketWithMerchant();
}
public void setGiftCardMarketWithMerchant () {
this.noCategoryCategory = new GiftCardCategory(this.merchantId);
this.categoryList = new ArrayList<>();
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet categoryListQuery = mysqlUtil.ExecuteSelectSQL("select * from hh_giftcard_category where show_status = 1 and merchant_id = " + this.merchantId +
" and id not in (select c.category_id from (select sum(status) as valid, m.category_id " +
"from hh_giftcard_info g left join hh_category_info_map m on g.id = m.card_id GROUP BY m.category_id) c where c.valid = 0) order by sort IS NULL,sort, create_time desc");
try {
while (categoryListQuery.next()) {
this.categoryList.add(new GiftCardCategory(categoryListQuery.getInt("id"), this.merchantId));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public int getMerchantId() {
return merchantId;
}
public void setMerchantId(int merchantId) {
this.merchantId = merchantId;
}
public GiftCardCategory getNoCategoryCategory() {
return noCategoryCategory;
}
public void setNoCategoryCategory(GiftCardCategory noCategoryCategory) {
this.noCategoryCategory = noCategoryCategory;
}
public List<GiftCardCategory> getCategoryList() {
return categoryList;
}
public void setCategoryList(List<GiftCardCategory> categoryList) {
this.categoryList = categoryList;
}
}
package com.miya.manning.framework.saas.order;
import java.sql.SQLException;
public class CouponMarketOrder extends Order {
//quan
private int sendCouponStatus;
private int couponRefundable;
public CouponMarketOrder(int id) throws SQLException {
super(id);
}
public CouponMarketOrder(String orderNo) throws SQLException {
super(orderNo);
}
}
package com.miya.manning.framework.saas.order;
import java.sql.SQLException;
public class DaojiaOrder extends Order {
//daojia
private int storeId;
private double packPrice;
private double totalWeght;
private String consigneePhone;
private int deliveryType;
private String notes;
private int businessSource;
private int activityId;
private String sellerNotes;
private int refundGoodsCount;
public DaojiaOrder(int id) throws SQLException {
super(id);
}
}
package com.miya.manning.framework.saas.order;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
public class GiftCardOrder extends Order{
private String cardNo;
public GiftCardOrder(String orderNo) {
super(orderNo);
this.setGiftCardOrderInfo();
}
public void setGiftCardOrderInfo () {
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet orderQuery = mysqlUtil.ExecuteSelectSQL("select * from hh_order_gifcard_map where order_id = " + this.getId());
try {
orderQuery.next();
this.cardNo = orderQuery.getString("card_no");
} catch (SQLException e) {
e.printStackTrace();
}
}
public String getCardNo() {
return cardNo;
}
public void setCardNo(String cardNo) {
this.cardNo = cardNo;
}
}
package com.miya.manning.framework.saas.order;
import com.miya.interfacetest.huihua.framework.saas.User;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.saas
* @ClassName: Order
* @Description: 订单类
* @Author: 梁振振
* @CreateDate: 2020/9/1 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class Order {
//common
private int id;
private String orderNo;
private int totalOrderPirce;
private int totalPayPrice;
private int platformDiscount;
private int merchantDiscount;
private int businessType;
private int goodsNum;
private User user;
private int orderStatus;
private int paymentStatus;
private int refundStatus;
private int paymentType;
private Date cancelTime;
private int cancelType;
private String cancelReason;
private int refundableAmount;
private Date createTime;
public Order(int id){
this.id = id;
this.setOrderInfoWithId(id);
}
public Order(String orderNo){
this.orderNo = orderNo;
this.setOrderInfoWithOrderNo(orderNo);
}
public void setOrderInfoWithId(int id){
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet orderQuery = mysqlUtil.ExecuteSelectSQL("select * from center_order where id = " + id);
try{
orderQuery.next();
this.orderNo = orderQuery.getString("order_no");
this.totalOrderPirce = orderQuery.getInt("total_order_price");
this.totalPayPrice = orderQuery.getInt("total_pay_price");
this.platformDiscount = orderQuery.getInt("platform_discount_amount");
this.merchantDiscount = orderQuery.getInt("merchant_discount_amount");
this.businessType = orderQuery.getInt("business_type");
this.goodsNum = orderQuery.getInt("goods_num");
this.user = new User(orderQuery.getString("order_user_id"));
this.orderStatus = orderQuery.getInt("order_status");
this.paymentStatus = orderQuery.getInt("payment_status");
this.refundStatus = orderQuery.getInt("refund_status");
this.paymentType = orderQuery.getInt("payment_type");
this.cancelTime = orderQuery.getTimestamp("cancel_time");
this.cancelType = orderQuery.getInt("cancel_type");
this.cancelReason = orderQuery.getString("cancel_reason");
this.refundableAmount = orderQuery.getInt("refundable_amount");
this.createTime = orderQuery.getTimestamp("create_time");
}catch (SQLException e) {
e.printStackTrace();
}
}
public void setOrderInfoWithOrderNo(String orderNo){
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet orderQuery = mysqlUtil.ExecuteSelectSQL("select * from center_order where order_no = \"" + orderNo + "\"");
try {
orderQuery.next();
this.id = orderQuery.getInt("id");
this.totalOrderPirce = orderQuery.getInt("total_order_price");
this.totalPayPrice = orderQuery.getInt("total_pay_price");
this.platformDiscount = orderQuery.getInt("platform_discount_amount");
this.merchantDiscount = orderQuery.getInt("merchant_discount_amount");
this.businessType = orderQuery.getInt("business_type");
this.goodsNum = orderQuery.getInt("goods_num");
this.user = new User(orderQuery.getString("order_user_id"));
this.orderStatus = orderQuery.getInt("order_status");
this.paymentStatus = orderQuery.getInt("payment_status");
this.refundStatus = orderQuery.getInt("refund_status");
this.paymentType = orderQuery.getInt("payment_type");
this.cancelTime = orderQuery.getTimestamp("cancel_time");
this.cancelType = orderQuery.getInt("cancel_type");
this.cancelReason = orderQuery.getString("cancel_reason");
this.refundableAmount = orderQuery.getInt("refundable_amount");
this.createTime = orderQuery.getTimestamp("create_time");
} catch (SQLException e) {
e.printStackTrace();
}
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public int getTotalOrderPirce() {
return totalOrderPirce;
}
public void setTotalOrderPirce(int totalOrderPirce) {
this.totalOrderPirce = totalOrderPirce;
}
public int getTotalPayPrice() {
return totalPayPrice;
}
public void setTotalPayPrice(int totalPayPrice) {
this.totalPayPrice = totalPayPrice;
}
public int getPlatformDiscount() {
return platformDiscount;
}
public void setPlatformDiscount(int platformDiscount) {
this.platformDiscount = platformDiscount;
}
public int getMerchantDiscount() {
return merchantDiscount;
}
public void setMerchantDiscount(int merchantDiscount) {
this.merchantDiscount = merchantDiscount;
}
public int getBusinessType() {
return businessType;
}
public void setBusinessType(int businessType) {
this.businessType = businessType;
}
public int getGoodsNum() {
return goodsNum;
}
public void setGoodsNum(int goodsNum) {
this.goodsNum = goodsNum;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public int getOrderStatus() {
return orderStatus;
}
public void setOrderStatus(int orderStatus) {
this.orderStatus = orderStatus;
}
public int getPaymentStatus() {
return paymentStatus;
}
public void setPaymentStatus(int paymentStatus) {
this.paymentStatus = paymentStatus;
}
public int getRefundStatus() {
return refundStatus;
}
public void setRefundStatus(int refundStatus) {
this.refundStatus = refundStatus;
}
public int getPaymentType() {
return paymentType;
}
public void setPaymentType(int paymentType) {
this.paymentType = paymentType;
}
public Date getCancelTime() {
return cancelTime;
}
public void setCancelTime(Date cancelTime) {
this.cancelTime = cancelTime;
}
public int getCancelType() {
return cancelType;
}
public void setCancelType(int cancelType) {
this.cancelType = cancelType;
}
public String getCancelReason() {
return cancelReason;
}
public void setCancelReason(String cancelReason) {
this.cancelReason = cancelReason;
}
public int getRefundableAmount() {
return refundableAmount;
}
public void setRefundableAmount(int refundableAmount) {
this.refundableAmount = refundableAmount;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
package com.miya.manning.framework.saas.order;
import java.sql.SQLException;
public class PointsMarketOrder extends Order {
private int totalPoints;
public PointsMarketOrder(int id) throws SQLException {
super(id);
}
}
package com.miya.manning.framework.saas.requestmessage;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.miya.interfacetest.huihua.framework.util.DateUtil;
import com.miya.interfacetest.huihua.framework.util.dbutil.MysqlUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class CouponVerificationMsg {
private String cashierNo;
private String couponDeductionNo;
private List<JsonObject> goodsItems;
private String merchantNo;
private String merchantOrderId;
private int orderAmount;
private String posDeviceNo;
private String posTradeNo;
private String storeNo;
public CouponVerificationMsg(String couponDeductionNo) {
this.couponDeductionNo = couponDeductionNo;
this.cashierNo = "17012";
this.merchantNo = "1305561201";
this.merchantOrderId = "999001"+DateUtil.format(new Date(), "yyyyMMddHHmmssSSS");
this.posDeviceNo = "0009";
this.posTradeNo = this.merchantOrderId;
//this.storeNo = "3003";
this.setStoreNo();
this.setGoodsItemsAndAmount();
}
public void setStoreNo() {
MysqlUtil mysqlUtil = new MysqlUtil();
ResultSet storeQuery = mysqlUtil.ExecuteSelectSQL("select * from card_ticket_store_map where card_id = " +
"(select card_id from card_search where coupon_id = \""+ this.couponDeductionNo.substring(1) +"\")");
try {
storeQuery.next();
this.storeNo = storeQuery.getString("store_id");
} catch (SQLException e) {
this.storeNo = "3003";
e.printStackTrace();
}
}
public void setGoodsItemsAndAmount() {
try{
Gson gs = new Gson();
goodsItems = new ArrayList<>();
GoodsItem goodsItem1 = new GoodsItem("商品1", "6954767425645", 2000, 1);
GoodsItem goodsItem2 = new GoodsItem("商品2", "11006028", 800, 1);
GoodsItem goodsItem3 = new GoodsItem("商品3", "1234", 100, 2);
this.goodsItems.add(new JsonParser().parse(gs.toJson(goodsItem1, GoodsItem.class)).getAsJsonObject());
this.goodsItems.add(new JsonParser().parse(gs.toJson(goodsItem2, GoodsItem.class)).getAsJsonObject());
this.goodsItems.add(new JsonParser().parse(gs.toJson(goodsItem3, GoodsItem.class)).getAsJsonObject());
this.orderAmount = goodsItem1.getPrice()*goodsItem1.getQuantity()
+ goodsItem2.getPrice()*goodsItem2.getQuantity()
+ goodsItem3.getPrice()*goodsItem3.getQuantity();
}catch (Exception e) {
e.printStackTrace();
}
}
public JsonObject getCouponVerificationMsg() {
//CouponVerificationMsg couponVerificationMsg = new CouponVerificationMsg(this.couponDeductionNo);
Gson gs = new Gson();
return new JsonParser().parse(gs.toJson(this, CouponVerificationMsg.class)).getAsJsonObject();
}
public String getCashierNo() {
return cashierNo;
}
public void setCashierNo(String cashierNo) {
this.cashierNo = cashierNo;
}
public String getCouponDeductionNo() {
return couponDeductionNo;
}
public void setCouponDeductionNo(String couponDeductionNo) {
this.couponDeductionNo = couponDeductionNo;
}
public List<JsonObject> getGoodsItems() {
return goodsItems;
}
public void setGoodsItems(List<JsonObject> goodsItems) {
this.goodsItems = goodsItems;
}
public String getMerchantNo() {
return merchantNo;
}
public void setMerchantNo(String merchantNo) {
this.merchantNo = merchantNo;
}
public String getMerchantOrderId() {
return merchantOrderId;
}
public void setMerchantOrderId(String merchantOrderId) {
this.merchantOrderId = merchantOrderId;
}
public int getOrderAmount() {
return orderAmount;
}
public void setOrderAmount(int orderAmount) {
this.orderAmount = orderAmount;
}
public String getPosDeviceNo() {
return posDeviceNo;
}
public void setPosDeviceNo(String posDeviceNo) {
this.posDeviceNo = posDeviceNo;
}
public String getPosTradeNo() {
return posTradeNo;
}
public void setPosTradeNo(String posTradeNo) {
this.posTradeNo = posTradeNo;
}
public String getStoreNo() {
return storeNo;
}
public void setStoreNo(String storeNo) {
this.storeNo = storeNo;
}
}
class GoodsItem {
private String goodsName;
private String goodsNo;
private int price;
private int quantity;
public GoodsItem(String goodsName, String goodsNo, int price, int quantity) {
this.goodsName = goodsName;
this.goodsNo = goodsNo;
this.price = price;
this.quantity = quantity;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getGoodsNo() {
return goodsNo;
}
public void setGoodsNo(String goodsNo) {
this.goodsNo = goodsNo;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
package com.miya.manning.framework.saas.requestmessage;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.miya.interfacetest.huihua.framework.saas.User;
import com.miya.interfacetest.huihua.framework.util.PropertiesHandle;
import com.miya.interfacetest.huihua.framework.util.StringUtil;
public class LoginMsg {
private String jsCode;
private String openIdOrUserId;
private String from;
private String clientId;
private int appPublishType;
public LoginMsg(User user) {
this.jsCode = PropertiesHandle.readValue(StringUtil.SAAS_PARAM_FILE_PATH, "js_code");
this.openIdOrUserId = user.getUserOpenId();
this.from = PropertiesHandle.readValue(StringUtil.SAAS_PARAM_FILE_PATH, "merchant");
this.clientId = PropertiesHandle.readValue(StringUtil.SAAS_PARAM_FILE_PATH, "clientid_wechat");
this.appPublishType = 0;
}
public JsonObject getJsonMsg() {
Gson gs = new Gson();
return new JsonParser().parse(gs.toJson(this, LoginMsg.class)).getAsJsonObject();
}
public String getJsCode() {
return jsCode;
}
public void setJsCode(String jsCode) {
this.jsCode = jsCode;
}
public String getOpenIdOrUserId() {
return openIdOrUserId;
}
public void setOpenIdOrUserId(String openIdOrUserId) {
this.openIdOrUserId = openIdOrUserId;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public int getAppPublishType() {
return appPublishType;
}
public void setAppPublishType(int appPublishType) {
this.appPublishType = appPublishType;
}
}
package com.miya.manning.framework.saas.requestmessage;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.miya.interfacetest.huihua.framework.saas.giftcard.GiftCardBatch;
import com.miya.interfacetest.huihua.framework.util.PropertiesHandle;
import com.miya.interfacetest.huihua.framework.util.StringUtil;
public class OrderSubmitMsg {
private String businessType;
private JsonObject data;
public OrderSubmitMsg(String businessType) {
this.businessType = businessType;
}
public JsonObject getCouponMarketOrderMsg(String cardPacketId) {
Gson gs = new Gson();
CouponMarketData couponMarketData = new CouponMarketData(cardPacketId);
this.data = new JsonParser().parse(gs.toJson(couponMarketData, CouponMarketData.class)).getAsJsonObject();
return new JsonParser().parse(gs.toJson(this, OrderSubmitMsg.class)).getAsJsonObject();
}
public JsonObject getGiftCardOrderMsg(String cardStockId) {
Gson gs = new Gson();
GiftCardMarketData giftCardMarketData = new GiftCardMarketData(cardStockId);
this.data = new JsonParser().parse(gs.toJson(giftCardMarketData, GiftCardMarketData.class)).getAsJsonObject();
return new JsonParser().parse(gs.toJson(this, OrderSubmitMsg.class)).getAsJsonObject();
}
public String getBusinessType() {
return businessType;
}
public void setBusinessType(String businessType) {
this.businessType = businessType;
}
public JsonObject getData() {
return data;
}
public void setData(JsonObject data) {
this.data = data;
}
}
class CouponMarketData {
private String cardPacketId;
public CouponMarketData(String cardPacketId) {
this.cardPacketId = cardPacketId;
}
public String getCardPacketId() {
return cardPacketId;
}
public void setCardPacketId(String cardPacketId) {
this.cardPacketId = cardPacketId;
}
}
class GiftCardMarketData {
private String cardStockId;
private String merchant;
private int price;
private int quantity;
public GiftCardMarketData (String cardStockId) {
GiftCardBatch giftCardBatch = new GiftCardBatch(cardStockId);
this.price = giftCardBatch.getPrice();
this.cardStockId = cardStockId;
this.merchant = PropertiesHandle.readValue(StringUtil.SAAS_PARAM_FILE_PATH, "merchant");
this.quantity = 1;
}
public String getCardStockId() {
return cardStockId;
}
public void setCardStockId(String cardStockId) {
this.cardStockId = cardStockId;
}
public String getMerchant() {
return merchant;
}
public void setMerchant(String merchant) {
this.merchant = merchant;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
\ No newline at end of file
package com.miya.manning.framework.saas.requestmessage;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.miya.interfacetest.huihua.framework.saas.order.Order;
import com.miya.interfacetest.huihua.framework.util.PropertiesHandle;
import com.miya.interfacetest.huihua.framework.util.StringUtil;
import java.util.Date;
public class PaySuccessMsg {
private int merchantDiscountAmount;
private String openId;
private String orderNo;
private long paymentTime;
private int platformDiscountAmount;
private String pmtChannel;
private String totalFee;
private String tradeNo;
private int userPayPrice;
public PaySuccessMsg() { }
public JsonObject getJsonMsg(String orderNo) {
Order order = new Order(orderNo);
this.orderNo = orderNo;
this.tradeNo = orderNo;
this.merchantDiscountAmount = 0;
this.openId = PropertiesHandle.readValue(StringUtil.SAAS_PARAM_FILE_PATH, "order_open_id");
this.paymentTime = new Date().getTime();
this.platformDiscountAmount = 0;
this.pmtChannel = "0";
this.totalFee = String.valueOf(order.getTotalOrderPirce());
this.userPayPrice = order.getTotalPayPrice();
Gson gs = new Gson();
return new JsonParser().parse(gs.toJson(this, PaySuccessMsg.class)).getAsJsonObject();
}
public int getMerchantDiscountAmount() {
return merchantDiscountAmount;
}
public void setMerchantDiscountAmount(int merchantDiscountAmount) {
this.merchantDiscountAmount = merchantDiscountAmount;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public long getPaymentTime() {
return paymentTime;
}
public void setPaymentTime(long paymentTime) {
this.paymentTime = paymentTime;
}
public int getPlatformDiscountAmount() {
return platformDiscountAmount;
}
public void setPlatformDiscountAmount(int platformDiscountAmount) {
this.platformDiscountAmount = platformDiscountAmount;
}
public String getPmtChannel() {
return pmtChannel;
}
public void setPmtChannel(String pmtChannel) {
this.pmtChannel = pmtChannel;
}
public String getTotalFee() {
return totalFee;
}
public void setTotalFee(String totalFee) {
this.totalFee = totalFee;
}
public String getTradeNo() {
return tradeNo;
}
public void setTradeNo(String tradeNo) {
this.tradeNo = tradeNo;
}
public int getUserPayPrice() {
return userPayPrice;
}
public void setUserPayPrice(int userPayPrice) {
this.userPayPrice = userPayPrice;
}
}
package com.miya.manning.framework.util;
import com.miya.interfacetest.huihua.framework.saas.Store;
import java.util.Comparator;
public class ComparatorUtil {
public static Comparator<Store> storeSaasDistanceComparator = new Comparator<Store>() {
@Override
public int compare(Store s1, Store s2) {
if (s1.getSaasDistance() != s2.getSaasDistance()) {
return new Double(s1.getSaasDistance()).intValue()-new Double(s2.getSaasDistance()).intValue();
} else {
if (s1.getId() != s2.getId()) {
return s1.getId() - s2.getId();
}else {
return 0;
}
}
}
};
}
package com.miya.manning.framework.util;
import org.apache.commons.lang.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateUtil {
/**
* 日期格式 年 如2009
*/
public static final String DATEFORMATYEAR = "yyyy";
/**
* 日期格式 年 月 如 2009-02
*/
public static final String DATEFORMATMONTH = "yyyy-MM";
/**
* 日期格式 年 月 日 如2009-02-26
*/
public static final String DATEFORMATDAY = "yyyy-MM-dd";
/**
* 日期格式 年 月 日 时 如2009-02-26 15
*/
public static final String DATEFORMATHOUR = "yyyy-MM-dd HH";
/**
* 日期格式 年 月 日 时 分 如2009-02-26 15:40
*/
public static final String DATEFORMATMINUTE = "yyyy-MM-dd HH:mm";
/**
* 日期格式年 月 日 时 分 秒 如 2009-02-26 15:40:00
*/
public static final String DATEFORMATSECOND = "yyyy-MM-dd HH:mm:ss";
/**
* 日期格式年 月 日 时 分 秒 毫秒 如2009-02-26 15:40:00 110
*/
public static final String DATEFORMATMILLISECOND = "yyyy-MM-dd HH:mm:ss SSS";
/**
* 获取当前系统时间
*
* @return
*/
public static Date getSysDate() {
Calendar calender = Calendar.getInstance();
return calender.getTime();
}
/**
* 按年月日格式,把String转换成Date 如果String为空或者null,返回null
* @param dateString
* @return
* @throws ParseException
*/
public static Date string2Date(String dateString) throws ParseException {
Date dateTime = null;
if (!StringUtils.isEmpty(dateString)) { //如果string时间参数不是空
final SimpleDateFormat df = new SimpleDateFormat(DATEFORMATDAY); //年月日时间格式化
Date date = null;
date = df.parse(dateString); //String转换Date
dateTime = new Date(date.getTime());
}
return dateTime;
}
/**
* 按年月日时分秒格式,把String转换成Date 如果String为空或者null,返回null
* @param dateString
* @return
* @throws ParseException
*/
public static Date string2DateTime(String dateString) throws ParseException {
Date dateTime = null;
if (!StringUtils.isEmpty(dateString)) { //如果string时间参数不是空
final SimpleDateFormat df = new SimpleDateFormat(DATEFORMATSECOND); //年月日时间格式化
Date date = null;
date = df.parse(dateString); //String转换Date
dateTime = new Date(date.getTime());
}
return dateTime;
}
/**
* 按指定的格式,把string转换成Date 如string为空或null,返回null
*
* @param string
* @param format
* @return
* @throws ParseException
*/
public static Date parase(String string, String format) throws ParseException {
if (StringUtils.isEmpty(string)) {
return null;
}
return new SimpleDateFormat(format).parse(string);
}
/**
* 按指定的格式,把Date转换成String 如date为null,返回null
*
* @param date
* Date参数
* @param format
* 日期格式
* @return String
*/
public static String format(Date date, String format) {
if (date == null) {
return null;
}
return new SimpleDateFormat(format).format(date);
}
}
This diff is collapsed.
package com.miya.manning.framework.util;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.util
* @ClassName: GPSUtil
* @Description: 定位距离计算工具类
* @Author: 梁振振
* @CreateDate: 2020/8/11 下午18:02
* @UpdateUser:
* @UpdateDate:
*/
public class GPSUtil {
private static final double EARTH_RADIUS = 6371000;// 赤道半径(单位m)
/**
* 转化为弧度(rad)
*/
private static double rad(double d) {
return d * Math.PI / 180.0;
}
/**
* 基于googleMap中的算法得到两经纬度之间的距离,计算精度与谷歌地图的距离精度差不多,相差范围在0.2米以下(单位m)
*
* @param lon1 第一点的精度
* @param lat1 第一点的纬度
* @param lon2 第二点的精度
* @param lat2 第二点的纬度
* @return 返回的距离,单位m
*/
public static double GetDistance(double lon1, double lat1, double lon2, double lat2) {
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lon1) - rad(lon2);
double s = 2 * Math.asin(Math.sqrt(
Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * EARTH_RADIUS;
// s = Math.round(s * 10000) / 10000;
return s;
}
public static double GetDistance(Object o_lon1, Object o_lat1, Object o_lon2, Object o_lat2) {
double lon1 = Double.valueOf(o_lon1.toString());
double lat1 = Double.valueOf(o_lat1.toString());
double lon2 = Double.valueOf(o_lon2.toString());
double lat2 = Double.valueOf(o_lat2.toString());
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lon1) - rad(lon2);
double s = 2 * Math.asin(Math.sqrt(
Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * EARTH_RADIUS;
// s = Math.round(s * 10000) / 10000;
return s;
}
/*
* @description: saas距离,距离小于1km,显示XXm,不保留小数; 距离大于1km,显示XX.Xkm, 保留一位小数
* @param distance: 传入的距离单位为米
* @return:单位:米 如果大于1000,则十位数和个位数为0
* */
public static double GetSaasDistance(double distance) {
if (distance >= 1000) {
//如果距离大于1000m,则saas会显示km为单位的距离,保留一位小数,即返回结果为XX00.0m
return (Math.round(distance/100) * 0.1d) * 1000;
} else {
//如果距离小于1000m,则saas会显示m为单位的距离,不保留小数,即返回结果为XXX.0m
return Math.round(distance);
}
}
public static double GetSaasDistance(Object o_lon1, Object o_lat1, Object o_lon2, Object o_lat2){
return GetSaasDistance(GetDistance(o_lon1, o_lat1, o_lon2, o_lat2));
}
}
package com.miya.manning.framework.util;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.huihua.framework.util
* @ClassName: 以http header中的参数作为键值对生成map,作为HTTPGet方法的入参
* @Description: java类作用描述
* @Author: 唐奇良
* @CreateDate: 2019/4/8 下午10:28
* @UpdateUser: 梁振振
* @UpdateDate: 2020/8/7 上午10:28
*/
@Component(value = "HttpHeaderBuilt")
public class HttpHeaderBuilt {
private static String hhFrom = PropertiesHandle.readValue(StringUtil.HTML_HEADER_FILE_PATH, "HH-FROM");
private static String hhApp = PropertiesHandle.readValue(StringUtil.HTML_HEADER_FILE_PATH, "HH-APP");
private static String contentType = PropertiesHandle.readValue(StringUtil.HTML_HEADER_FILE_PATH, "Content-Type");
private static String hhCi = PropertiesHandle.readValue(StringUtil.HTML_HEADER_FILE_PATH, "HH-CI");
private static String merchantId = PropertiesHandle.readValue(StringUtil.HTML_HEADER_FILE_PATH, "merchant_id");
private static String couponVerifyType=PropertiesHandle.readValue(StringUtil.HTML_HEADER_FILE_PATH, "coupon_verify_type");
private static String couponVerifyAuth = PropertiesHandle.readValue(StringUtil.HTML_HEADER_FILE_PATH, "coupon_verify_auth");
public static HashMap httpHeaderBuilt() {
HashMap headerMap = new HashMap<String, String>();
headerMap.put("HH-FROM", hhFrom);
headerMap.put("HH-APP", hhApp);
headerMap.put("HH-CI", hhCi);
headerMap.put("Content-Type", contentType);
return headerMap;
}
public static HashMap httpHeaderBuiltEWithAuth(String userToken) throws SQLException {
HashMap headerMap = new HashMap<String, String>();
headerMap.put("HH-FROM", hhFrom);
headerMap.put("HH-APP", hhApp);
headerMap.put("HH-CI", hhCi);
headerMap.put("Content-Type", contentType);
headerMap.put("Authorization", "bearer " + userToken);
return headerMap;
}
public static HashMap httpHeaderBuiltCouponVerify() {
HashMap headerMap = new HashMap<String, String>();
headerMap.put("Content-Type", contentType);
headerMap.put("userInfo", "{\"merchant_id\":"+ merchantId +"}");
headerMap.put("type", couponVerifyType);
headerMap.put("Authorization", couponVerifyAuth);
return headerMap;
}
public static Map<String,String> httpHeadBuiltHuihuaSaasB(Map<String,String> res_map){
Map<String,String> httpheadermap = new HashMap<>();
httpheadermap.put("content-type","application/json");
httpheadermap.put("authorization", res_map.containsKey("varg_data_0_token")? res_map.get("varg_data_0_token") : "");
httpheadermap.put("type", "unioncenter");
return httpheadermap;
}
public static Map<String,String> httpHeadBuiltHuihuaSaasC(Map<String,String> string_var_map){
Map<String,String> httpheadermap = new HashMap<>();
httpheadermap.put("hh-app","wx5e87437bdd346c77");
httpheadermap.put("hh-from","cocaCola");
httpheadermap.put("hh-version","v1.3.7");
httpheadermap.put("apppublishtype","1");
httpheadermap.put("hh-ci","saas-wechat-app");
httpheadermap.put("content-type","application/json");
httpheadermap.put("access_token", string_var_map.containsKey("varg_access_token")? string_var_map.get("varg_access_token") : "");
httpheadermap.put("authorization", string_var_map.containsKey("varg_access_token")? "bearer " + string_var_map.get("varg_access_token") : "");
httpheadermap.put("ONE-ID", "1408936455002181661");
return httpheadermap;
}
}
package com.miya.manning.framework.util;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import java.util.*;
public class JsonTransfer {
private static String start_with = "varg_";
public static JSONObject ToJsonObject(String req){
return JSONObject.fromObject(req);
}
public static JSONArray ToJsonArray(String req){
return JSONArray.fromObject(req);
}
public static boolean AnalysisJson(String response, Map map ,String orgin ,int num){
if(response.indexOf(":") == -1){
//value中没有:表示该json不需要继续解析了
return true;
}
JSONObject fromObject = JSONObject.fromObject(response);
Iterator it = fromObject.keys();
while(it.hasNext()){
String key = it.next().toString();
String value = fromObject.get(key).toString();
if(value.startsWith("[{") && value.indexOf("[{") != -1){
//表明该value中包含jsonarray类型的数据
//去除[号
String jsons = value.substring(1, value.lastIndexOf("]"));
jsons = ArrayInObject(jsons);
jsons = jsons.replaceAll("\\}\\s?,\\s?\\{", "}|{");//替换成{}|{}格式,方便分割
String[] split = jsons.split("\\|");
for(int i = 0 ; i<split.length ;i++){
String orgin1 = orgin + "_" + num + "_" + key;
String sub = split[i];
//System.out.println(sub);
sub = sub.replaceAll("\\+", "}");//外层分割好后,再把-替换回}
AnalysisJson(sub,map,orgin1,i);
}
}else if (value.indexOf("{") != -1){
//表明该value中包含jsonobject类型的数据
String orgin1 = orgin+"_" + num + "_" +key ;
AnalysisJson(value, map, orgin1,num);
}else{
//普通的value
map.put(orgin + "_" + num + "_" + key ,value);
}
}
return false;
}
public static boolean AnalysisJson(String response, Map<String,String> map ){
if(response.indexOf(":") == -1){
//value中没有:表示该json不需要继续解析了
return true;
}
JSONObject fromObject = JSONObject.fromObject(response);
Iterator it = fromObject.keys();
while(it.hasNext()){
String key = it.next().toString();
String value = fromObject.get(key).toString();
if(value.startsWith("[{") && value.indexOf("[{") != -1){
String jsons = value.substring(1, value.lastIndexOf("]"));
/*此处有问题,如果jsonarray中嵌套了jsonarray并且内部有多个对象,会有截断*/
jsons = ArrayInObject(jsons);
jsons = jsons.replaceAll("\\}\\s?,\\s?\\{", "}|{");//替换成{}|{}格式,方便分割
String[] split = jsons.split("\\|");
for(int i = 0 ; i<split.length ;i++){
String orgin = start_with+key;
String sub = split[i];
//System.out.println(sub);
sub = sub.replaceAll("\\+", "}");//外层分割好后,再把-替换回}
AnalysisJson(sub,map,orgin,i);
}
//表明该value中包含jsonarray类型的数据
}else if (value.indexOf("{") != -1){
//表明该value中包含jsonobject类型的数据
String orgin = start_with+key;
AnalysisJson(value, map, orgin,0);
}else{
//普通的value
map.put(start_with+key,value);
}
}
return false;
}
/***
*
* @param jsonobject_str jsonarray中提取出来的jsonobject字符串,可能包含多个对象{},{}
* @return jsonobject中嵌套的jsonarray,将}替换成+返回
*/
public static String ArrayInObject(String jsonobject_str){
Map<Character, Character> pairs = new HashMap<Character, Character>() {{
put(')', '(');
put(']', '[');
put('}', '{');
}};
List<Integer> need_replace_index = new ArrayList<>();
Deque<Character> stack = new LinkedList<>();
StringBuffer sb = new StringBuffer();
if(jsonobject_str.contains("[")){
int first_index = jsonobject_str.indexOf("[");
for(int i = first_index;i<jsonobject_str.length();i++){//从[开始的地方进行压栈,栈顶如果有'{',且下一个压栈的字符是'}'时,说明array中的一个object结束了,需要把这个位置记下来,后续需要替换成+
// 最后格式为{[{+,{+]},{[{+,{+]} ,外层是匹配},{替换为}|{后用|分割,方便内层array的对象和外层的分隔符区分开
char ch = jsonobject_str.charAt(i);
if(pairs.containsKey(ch)){
if( !stack.isEmpty() && stack.peek() == pairs.get(ch)){
stack.pop();
if(ch!=']'){//弹栈时,如果是array的结束符']',则不需要记录下标位置,因为只有数组中对象的}需要和外层进行区分
need_replace_index.add(i);
}
}
}if ((stack.isEmpty() && ch =='[') || (!stack.isEmpty() &&( ch == '{' || ch =='['))) {//过滤其他字符,只针对代表array和object的起始字符和结束字符
//正常的嵌套格式,例如{[{obj1},{obj2}]},{[{obj3},{obj4}]},只有栈为空的时候遇到[会压栈,表示内部开始有嵌套数组了;或者栈内已经有数据了,再次遇到{,表示当前数组中的对象开始解析到了;再次遇到[表示又嵌套了一层新的数组
//这些都需要进行压栈
stack.push(ch);
}
}
if(!need_replace_index.isEmpty()){
for(int j = 0 ; j< jsonobject_str.length() ; j++){
if(need_replace_index.contains(j)){
sb.append('+');
}
else{
sb.append(jsonobject_str.charAt(j));
}
}
}
return sb.toString();
}
return jsonobject_str;
}
}
package com.miya.manning.framework.util;
import java.util.HashMap;
import java.util.Map;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.util
* @ClassName: ParamsBuilt
* @Description: 此函数的作用是构建一个包含公共参数的的params格式文件
* @Author: 唐奇良
* @CreateDate: 2019/1/22 下午2:57
* @UpdateUser: 更新者
* @UpdateDate: 2019/1/22 下午2:57
*/
public class ParamsBuilt {
private static String region_id = PropertiesHandle.readValue("region_id");
private static String uuid = PropertiesHandle.readValue("uuid");
private static String udid = PropertiesHandle.readValue("udid");
private static String android_iOS = PropertiesHandle.readValue("android_iOS");
private static String version = PropertiesHandle.readValue("version");
private static String time = PropertiesHandle.readValue("time");
private static String security = PropertiesHandle.readValue("security");
public static Map<String, String> params_built() {
Map<String, String> params = new HashMap<String, String>();
params.put("region_id", region_id);
params.put("uuid", uuid);
params.put("udid", udid);
params.put("android_iOS", android_iOS);
params.put("version", version);
params.put("time", time);
params.put("security", security);
return params;
}
public static String params_replace(String params, Map<String, Integer> int_var_map, Map<String, String> string_var_map ) {
if(params != null){
if (int_var_map.size() != 0) {
for (Map.Entry<String, Integer> entry : int_var_map.entrySet()) {
params = params.replaceAll(entry.getKey(), String.valueOf(entry.getValue()));
}
}
if (string_var_map.size() != 0) {
for (Map.Entry<String, String> entry : string_var_map.entrySet()) {
params = params.replaceAll(entry.getKey(), entry.getValue());
}
}
}
return params;
}
/***
*
* @param params 待替换的参数
* @param int_var_map int变量集
* @param string_var_map string变量集
* @param res_map 响应变量集
* @return
*/
public static String params_replace(String params, Map<String, Integer> int_var_map, Map<String, String> string_var_map ,Map<String,String> res_map ) {
if(params != null){
if (int_var_map.size() != 0) {
for (Map.Entry<String, Integer> entry : int_var_map.entrySet()) {
params = params.replaceAll(entry.getKey(), String.valueOf(entry.getValue()));
}
}
if (string_var_map.size() != 0) {
for (Map.Entry<String, String> entry : string_var_map.entrySet()) {
params = params.replaceAll(entry.getKey(), entry.getValue());
}
}
if(res_map.size() != 0){
//get请求参数
if(params.contains("=")){
String[] subs = params.split("&");
for(String str: subs){
String[] sub = str.split("=");
if(sub.length>1){//防止get请求中有参数是空
//去除掉参数中的引号
String after = sub[1].replaceAll("\"", "");
if(res_map.containsKey(after)){
params = params.replaceAll(after,res_map.get(after));
}
}
}
}
//post请求参数
if(params.contains(":")){
String[] subs = params.split(",");
for(String str : subs){
String[] sub = str.split(":");
if(sub.length>1){
String after = sub[sub.length-1].replaceAll("\"", "");
after = after.replaceAll("}", "");
//array里的最后一个对象还会带],也需要去掉
after = after.replaceAll("]", "");
if(res_map.containsKey(after)){
params = params.replaceAll(after, res_map.get(after));
}
}
}
}
}
}
return params;
}
public static String sql_replace(String sql, Map<String, Integer> int_var_map, Map<String, String> string_var_map ,Map<String,String> res_map ) {
if(sql != null){
if (int_var_map.size() != 0) {
for (Map.Entry<String, Integer> entry : int_var_map.entrySet()) {
sql = sql.replaceAll(entry.getKey(), String.valueOf(entry.getValue()));
}
}
if (string_var_map.size() != 0) {
for (Map.Entry<String, String> entry : string_var_map.entrySet()) {
sql = sql.replaceAll(entry.getKey(), entry.getValue());
}
}
if(res_map.size() != 0){
//
String[] subs = sql.split(" ");
for(String str: subs){
String after = str.replaceAll("\"", "");
if(res_map.containsKey(after)){
sql = sql.replaceAll(after,res_map.get(after));
}
}
}
}
return sql;
}
public static void main(String[] args) {
System.out.println(params_built());
}
}
package com.miya.manning.framework.util;
import java.io.*;
import java.util.Properties;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.util
* @ClassName: PropertiesHandle
* @Description: java类作用描述
* @Author: 唐奇良
* @CreateDate: 2019/1/22 下午2:53
* @UpdateUser: 更新者
* @UpdateDate: 2019/1/22 下午2:53
*/
public class PropertiesHandle {
public static String readValue(String key) {
Properties props = new Properties();
try {
//InputStream in = new BufferedInputStream(new FileInputStream("/Users/Ryan/Git/MY/Test/MY_INTERFACE_TEST/src/main/resources/config.properties"));
InputStream in = new BufferedInputStream(new FileInputStream("src/main/resources/config.properties"));
//InputStream in = new BufferedInputStream(new FileInputStream("config.properties"));
props.load(in);
String value = props.getProperty(key);
return value;
}
catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static String readValue(String filename, String key) {
Properties props = new Properties();
try {
InputStream in = new BufferedInputStream(new FileInputStream(filename));
props.load(in);
String value = props.getProperty(key);
return value;
}
catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static String readSpecialValue(String fileName, String key) {
Properties props = new Properties();
try {
InputStreamReader in = new InputStreamReader(new FileInputStream(fileName), "UTF-8");
props.load(in);
String value = props.getProperty(key);
return value;
}
catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static String readTempValue(String key) {
Properties props = new Properties();
try {
InputStreamReader in = new InputStreamReader(new FileInputStream(StringUtil.TEMP_PARAM_FILE_PATH), "UTF-8");
props.load(in);
String value = props.getProperty(key);
return value;
}
catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static void writeValue(String fileName, String key, String value) {
Properties props = new Properties();
try {
InputStreamReader in = new InputStreamReader(new FileInputStream(fileName), "UTF-8");
props.load(in);
if (props.containsKey(key)){
props.replace(key, value);
}else{
props.setProperty(key, value);
}
clearFile(fileName);
FileOutputStream oFile = new FileOutputStream(fileName, true);
props.store(oFile, "Add properties: " + key);
oFile.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
try {
FileOutputStream oFile = new FileOutputStream(fileName, true);
props.setProperty(key, value);
props.store(oFile, "Add properties: " + key);
oFile.close();
}catch (Exception e1){
e1.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void writeTempValue(String key, String value) {
try {
writeValue(StringUtil.TEMP_PARAM_FILE_PATH, key, value);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void deleteValue(String fileName, String key) {
Properties props = new Properties();
try{
InputStreamReader in = new InputStreamReader(new FileInputStream(fileName), "UTF-8");
props.load(in);
props.remove(key);
FileOutputStream oFile = new FileOutputStream(fileName);
props.store(oFile, "Delete properties: " + key);
oFile.close();
}catch (Exception e) {
e.printStackTrace();
}
}
public static void clearFile(String fileName) {
Properties props = new Properties();
try{
props.clear();
FileOutputStream oFile = new FileOutputStream(fileName);
props.store(oFile, "clear");
oFile.close();
}catch (Exception e) {
e.printStackTrace();
}
}
}
package com.miya.manning.framework.util;
import com.miya.manning.framework.request.HTTPGet;
import com.miya.manning.framework.request.HTTPPost;
import com.miya.manning.framework.request.HTTPPut;
import com.miya.manning.vo.TestCase;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.log4j.Logger;
import java.util.Map;
public class RequestUtil {
/***
*
* @param testCase 用例对象
* @param new_params 替换变量后的请求参数
* @param url 请求地址
* @param httpheadermap 请求头
* @param logger 日志实例
* @param builder
* @return 应答信息
* @throws Exception
*/
public static String doRequest(TestCase testCase , String new_params , StringBuffer url, Map<String,String> httpheadermap , Logger logger , StringBuilder builder ) throws Exception{
if("get".equals(testCase.getMethod_type())){
if(new_params != null ){
url.append(new_params);
}
String new_url = url.toString();
logger.info("url为:" + new_url);
String result = HTTPGet.httpGet(new_url, httpheadermap);
builder.append(result);
logger.info("收到的应答为:" + result);
}else if("post".equals(testCase.getMethod_type())){
logger.info(url.toString());
if(new_params.startsWith("[")){
JSONArray Req = JsonTransfer.ToJsonArray(new_params);
System.out.println(Req);
String result = HTTPPost.httpPost(url.toString(),Req,httpheadermap);
builder.append(result);
logger.info(result);
}
else if (new_params.startsWith("{")){
JSONObject Req = JsonTransfer.ToJsonObject(new_params);
System.out.println(Req);
String result = HTTPPost.httpPost(url.toString(),Req,httpheadermap);
builder.append(result);
logger.info(result);
}
}
else if("put".equals(testCase.getMethod_type())){
if(new_params != null ){
url.append(new_params);
}
String new_url = url.toString();
logger.info("url为:" + new_url);
String result = HTTPPut.httpPut(new_url, httpheadermap);
builder.append(result);
logger.info("收到的应答为:" + result);
}
return builder.toString();
}
}
package com.miya.manning.framework.util;
import com.miya.manning.enums.ScriptType;
import com.miya.manning.vo.*;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.lang.reflect.Method;
import java.util.List;
import java.util.stream.Collectors;
public class ScriptUtil {
private static final Logger log = Logger.getLogger(ScriptUtil.class);
public static void ExcuteScript(List<Script> scriptList , TestCase testCase ) throws Exception {
ExcuteableScript script = null;
ApplicationContext ac = new ClassPathXmlApplicationContext("ApplicationContext.xml");
ScriptFactory scriptFactory = (ScriptFactory) ac.getBean("ScriptFactory");
List<Script> list_script =scriptList.stream().filter(x -> x.getScript_name().equals(testCase.getScript_name())).collect(Collectors.toList());
if(list_script.size() == 0) {
throw new Exception("没有匹配到脚本!");
}if(list_script.size() >1 ){
throw new Exception("匹配到多个同名脚本!");
}else{
Class<?> clz = Class.forName("com.miya.interfacetest.huihua.vo.ScriptFactory");
Script sc = list_script.get(0);
Method method = clz.getDeclaredMethod("create" + sc.getSrcipt_type() + "Script",String.class);
if(ScriptType.JAVA_SCRIPT.getType().equals(sc.getSrcipt_type())){
script = (JavaScript) method.invoke(scriptFactory,sc.getScript_param());
log.info("开始执行脚本:" + sc.getScript_name());
script.excute(sc.getScript_param());
}
if(ScriptType.SSH_SCRIPT.getType().equals(sc.getSrcipt_type())){
script = (SSHScript) method.invoke(scriptFactory,sc.getScript_param());
log.info("开始执行脚本:" + sc.getScript_name());
script.excute(sc.getScript_param());
}
}
}
}
package com.miya.manning.framework.util;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.util
* @ClassName: StringUtil
* @Description: 地址选择工具类
* @Author: 唐奇良
* @CreateDate: 2019/1/22 上午10:48
* @UpdateUser: 更新者
* @UpdateDate: 2019/1/22 上午10:48
*/
public class StringUtil {
public static final String DB_CONFIG_FILE_PATH = "src/main/resources/db.properties";
public static final String REDIS_FILE_PATH = "src/main/resources/redis.properties";
public static final String CONFIG_FILE_PATH = "src/main/resources/config.properties";
public static final String HTML_HEADER_FILE_PATH = "src/main/resources/htmlHeader.properties";
public static final String SAAS_PARAM_FILE_PATH = "CommonParameters/SaasParameters.properties";
public static final String COUPON_PARAM_FILE_PATH="CommonParameters/CouponParameters.properties";
public static final String COUPON_PACKET_PARAM_FILE_PATH="CommonParameters/CouponPacketParameters.properties";
public static final String TEMP_PARAM_FILE_PATH="CommonParameters/TempParameters.properties";
}
package com.miya.manning.framework.util;
/**
* 首字母大写
*/
public class UpperUtil {
public static String Upper(String str){
char[] cs=str.toCharArray();
cs[0]-=32;
return String.valueOf(cs);
}
}
package com.miya.manning.framework.util;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.util
* @ClassName: UrlAdd
* @Description: java类作用描述
* @Author: 唐奇良
* @CreateDate: 2019/1/22 下午6:38
* @UpdateUser: 更新者
* @UpdateDate: 2019/1/22 下午6:38
*/
public class UrlAdd {
private static String region_id=PropertiesHandle.readValue("region_id");
private static String uuid=PropertiesHandle.readValue("uuid");
private static String udid=PropertiesHandle.readValue("udid");
private static String android_iOS=PropertiesHandle.readValue("android_iOS");
private static String version=PropertiesHandle.readValue("version");
private static String time=PropertiesHandle.readValue("time");
private static String security=PropertiesHandle.readValue("security");
private static String bdread=PropertiesHandle.readValue("bdread");
private static String kongread=PropertiesHandle.readValue("kongread");
//private static String themeID=PropertiesHandle.readValue("themeID");//
//private static String uid=PropertiesHandle.readValue("uid");
public static String UrlAdd_themeID(String themeID){
//String url="?deviceType="+deviceType+"&systemVersion="+systemVersion+"&appVersion="+appVersion+"&clientIP="+clientIP+"&deviceNumber="+deviceNumber+"&token="+token+"&sessionId="+sessionId+"&shopId="+shopId;
//String url="?bdread="+bdread;//非网关
// String url="?bdread="+bdread+"&kongread="+kongread;//网关//
String themeIDurl="?themeID="+themeID;
return themeIDurl;
}
public static String UrlAdd_CardID(String cardID){
String cardIDurl="?cardID="+cardID;
return cardIDurl;
}
public static String UrlAdd_CardInstructions(String cardId,String cardCode,String type){
String CardInstructionsurl="?cardId="+cardId+"&cardCode="+cardCode+"&type="+type;
return CardInstructionsurl;
}
public static String UrlAdd_themesubjectid(String themesubjectid){
String themesubjecturl="?id="+themesubjectid;
return themesubjecturl;
}
public static String UrlAdd_type(String type){
String UrlAdd_type="?type="+type;
return UrlAdd_type;
}
public static String UrlAdd_json(){
//String url="?deviceType="+deviceType+"&systemVersion="+systemVersion+"&appVersion="+appVersion+"&clientIP="+clientIP+"&deviceNumber="+deviceNumber+"&token="+token+"&sessionId="+sessionId+"&shopId="+shopId;
String url="?bdread="+bdread+"&region_id="+region_id+"&uuid="+uuid+"&udid="+udid+"&android_iOS="+android_iOS+"&version="+version+"&time="+time+"&security="+security;
return url;
}
}
package com.miya.manning.framework.util.encryptutil;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @ProjectName: MY_INTERFACE_TEST
* @Package: com.miya.interfacetest.framework.util.encryptutil
* @ClassName: MDSUtil
* @Description: java类作用描述
* @Author: 唐奇良
* @CreateDate: 2019/1/22 下午6:46
* @UpdateUser: 更新者
* @UpdateDate: 2019/1/22 下午6:46
*/
public class MD5Util {
public static String MD5(String s) {
char hexDigits[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
try {
byte[] btInput = s.getBytes();
// 获得MD5摘要算法的 MessageDigest 对象
MessageDigest mdInst = MessageDigest.getInstance("MD5");
// 使用指定的字节更新摘要
mdInst.update(btInput);
// 获得密文
byte[] md = mdInst.digest();
// 把密文转换成十六进制的字符串形式
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
System.out.println(MD5Util.MD5(df.format(new Date())));
System.out.println(MD5Util.MD5("加密"));
}
}
\ No newline at end of file
package com.miya.manning.vo;
public interface ExcuteableScript {
void excute(String params);
}
package com.miya.manning.vo;
import org.apache.log4j.Logger;
public class JavaScript implements ExcuteableScript{
private static final Logger log = Logger.getLogger(JavaScript.class);
private String params;
public JavaScript(){};
public JavaScript(String params) {
this.params = params;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
@Override
public void excute(String params) {
//执行java脚本
try {
log.info("即将等待" + params + "s");
Thread.sleep((long) (Double.parseDouble(params)*1000));
log.info("等待结束");
} catch (Exception e) {
log.error("执行等待脚本失败!");
e.printStackTrace();
}
}
}
This diff is collapsed.
This diff is collapsed.
package com.miya.manning.vo;
import org.springframework.stereotype.Component;
@Component(value = "ScriptFactory")
public class ScriptFactory {
public ScriptFactory(){};
public JavaScript createJavaScript(String params){
return new JavaScript(params);
}
public SSHScript createSSHScript(String params){
return new SSHScript(params);
}
}
This diff is collapsed.
#
saasTestHost=https://applets-dev.miyapay.com/
ssh_ip=47.97.19.30
ssh_port=40022
ssh_username=poslzk
ssh_password=miya@lizhikui
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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