Commit e54cdd53 by lihui.wang

向第三方 发送请求

parent 79243b8f
......@@ -161,6 +161,20 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!--<scope>compile</scope> --> <!-- 不打包的时候用,打包的时候注释 -->
<scope>provided</scope> <!-- // 打包的时候用,不打包的时候注释 -->
</dependency>
</dependencies>
......@@ -189,7 +203,23 @@
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>com.freemud.pay.job.PushMessageApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
......
package com.freemud.pay.job;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.apache.http.impl.client.CloseableHttpClient;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
//import org.apache.http.ssl.SSLContextBuilder;
@Configurable
public class ConfigBean {
@Bean(name="sdkRestTemplate")
public RestTemplate restTemplate() {
CloseableHttpClient httpClient;
RestTemplate restTemplate = null;
try {
httpClient = HttpClientUtils.acceptsUntrustedCertsHttpClient();
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(
httpClient);
restTemplate = new RestTemplate(clientHttpRequestFactory);
} catch (KeyManagementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (KeyStoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return restTemplate;
}
/**
* ObjectMapper源码注释建议单例化,因为创建成本比较高
* 如果config不同可以使用ObjectMapper中的writer()或者reader()
* 方法创建出非常轻量化的fluent的ObjectWrite或者ObjectReader来进行自定义配置
* 原文请看{@link ObjectMapper}
* */
@Bean(name="soapMapper")
public ObjectMapper soapMapper(){
final XmlMapper mapper = new XmlMapper();
//大驼峰命名
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
//关闭未知属性报错,以免对方升级接口添加字段导致我们挂掉
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
//针对没有的PropertyName的情况不会创建一个空的标签
mapper.setDefaultUseWrapper(false);
return mapper;
}
}
package com.freemud.pay.job;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.TrustStrategy;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
/**
* Created by Administrator on 2015/6/8.
*/
public class HttpClientUtils {
public static CloseableHttpClient acceptsUntrustedCertsHttpClient() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
HttpClientBuilder b = HttpClientBuilder.create();
// setup a Trust Strategy that allows all certificates.
//
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
return true;
}
}).build();
b.setSSLContext(sslContext);
// don't check Hostnames, either.
// -- use SSLConnectionSocketFactory.getDefaultHostnameVerifier(), if you don't want to weaken
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
// here's the special part:
// -- need to create an SSL Socket Factory, to use our weakened "trust strategy";
// -- and create a Registry, to register it.
//
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
Registry<ConnectionSocketFactory> socketFactoryRegistry= RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslSocketFactory)
.build();
// now, we create connection-manager using our Registry.
// -- allows multi-threaded use
PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager( socketFactoryRegistry);
connMgr.setMaxTotal(350);
connMgr.setDefaultMaxPerRoute(300);
b.setConnectionManager( connMgr);
// finally, build the HttpClient;
// -- done!
CloseableHttpClient client = b.build();
return client;
}
}
\ No newline at end of file
package com.freemud.pay.job.dao.dbModel;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
public class PayPlatformAccountDM extends BaseModel {
private Integer id;
private Integer partnerid;
private String platform;
private String platformpartnerid;
private String platformappkey;
private String platformsellerid;
private String platformselleremail;
private String platformsubject;
private String createuser;
private Date createdate;
private String signchar;
private String cerfile;
private String cerpassword;
private String platformsubaccountid;
private Boolean enable;
private String platformappid;
private String password;
private String agentid;
private String authcode;
private String memo;
private String feetype;
public static long getSerialVersionUID() {
return serialVersionUID;
}
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getPartnerid() {
return partnerid;
}
public void setPartnerid(Integer partnerid) {
this.partnerid = partnerid;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform == null ? null : platform.trim();
}
public String getPlatformpartnerid() {
return platformpartnerid;
}
public void setPlatformpartnerid(String platformpartnerid) {
this.platformpartnerid = platformpartnerid == null ? null : platformpartnerid.trim();
}
public String getPlatformappkey() {
return platformappkey;
}
public void setPlatformappkey(String platformappkey) {
this.platformappkey = platformappkey == null ? null : platformappkey.trim();
}
public String getPlatformsellerid() {
return platformsellerid;
}
public void setPlatformsellerid(String platformsellerid) {
this.platformsellerid = platformsellerid == null ? null : platformsellerid.trim();
}
public String getPlatformselleremail() {
return platformselleremail;
}
public void setPlatformselleremail(String platformselleremail) {
this.platformselleremail = platformselleremail == null ? null : platformselleremail.trim();
}
public String getPlatformsubject() {
return platformsubject;
}
public void setPlatformsubject(String platformsubject) {
this.platformsubject = platformsubject == null ? null : platformsubject.trim();
}
public String getCreateuser() {
return createuser;
}
public void setCreateuser(String createuser) {
this.createuser = createuser == null ? null : createuser.trim();
}
public Date getCreatedate() {
return createdate;
}
public void setCreatedate(Date createdate) {
this.createdate = createdate;
}
public String getSignchar() {
return signchar;
}
public void setSignchar(String signchar) {
this.signchar = signchar == null ? null : signchar.trim();
}
public String getCerfile() {
return cerfile;
}
public void setCerfile(String cerfile) {
this.cerfile = cerfile == null ? null : cerfile.trim();
}
public String getCerpassword() {
return cerpassword;
}
public void setCerpassword(String cerpassword) {
this.cerpassword = cerpassword == null ? null : cerpassword.trim();
}
public String getPlatformsubaccountid() {
return platformsubaccountid;
}
public void setPlatformsubaccountid(String platformsubaccountid) {
this.platformsubaccountid = platformsubaccountid == null ? null : platformsubaccountid.trim();
}
public Boolean getEnable() {
return enable;
}
public void setEnable(Boolean enable) {
this.enable = enable;
}
public String getPlatformappid() {
return platformappid;
}
public void setPlatformappid(String platformappid) {
this.platformappid = platformappid == null ? null : platformappid.trim();
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
}
public String getAgentid() {
return agentid;
}
public void setAgentid(String agentid) {
this.agentid = agentid == null ? null : agentid.trim();
}
public String getAuthcode() {
return authcode;
}
public void setAuthcode(String authcode) {
this.authcode = authcode == null ? null : authcode.trim();
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo == null ? null : memo.trim();
}
public String getFeetype() {
return feetype;
}
public void setFeetype(String feetype) {
this.feetype = feetype == null ? null : feetype.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", partnerid=").append(partnerid);
sb.append(", platform=").append(platform);
sb.append(", platformpartnerid=").append(platformpartnerid);
sb.append(", platformappkey=").append(platformappkey);
sb.append(", platformsellerid=").append(platformsellerid);
sb.append(", platformselleremail=").append(platformselleremail);
sb.append(", platformsubject=").append(platformsubject);
sb.append(", createuser=").append(createuser);
sb.append(", createdate=").append(createdate);
sb.append(", signchar=").append(signchar);
sb.append(", cerfile=").append(cerfile);
sb.append(", cerpassword=").append(cerpassword);
sb.append(", platformsubaccountid=").append(platformsubaccountid);
sb.append(", enable=").append(enable);
sb.append(", platformappid=").append(platformappid);
sb.append(", password=").append(password);
sb.append(", agentid=").append(agentid);
sb.append(", authcode=").append(authcode);
sb.append(", memo=").append(memo);
sb.append(", feetype=").append(feetype);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
package com.freemud.pay.job.dao.mapper;
import com.freemud.pay.job.dao.IBaseDao;
import com.freemud.pay.job.dao.dbModel.ActiveDM;
public interface ActiveDMMapper extends IBaseDao<ActiveDM> {
}
\ No newline at end of file
package com.freemud.pay.job.dao.mapper;
import com.freemud.pay.job.dao.IBaseDao;
import com.freemud.pay.job.dao.dbModel.PayPlatformAccountDM;
import java.util.List;
public interface PayPlatformAccountDMMapper extends IBaseDao<PayPlatformAccountDM> {
List<PayPlatformAccountDM> selectByPartnerId(Integer partnerId);
}
\ No newline at end of file
package com.freemud.pay.job.dao.mapper;
import com.freemud.pay.job.dao.IBaseDao;
import com.freemud.pay.job.dao.dbModel.StoreDM;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import java.util.Map;
public interface StoreDMMapper extends IBaseDao<StoreDM> {
StoreDM selectByStoreIdAndPartnerId(Map<String, Object> paramsMap);
}
\ No newline at end of file
......@@ -15,7 +15,6 @@ public class BaseParam {
private String dbPartition;
private String linkServer;
public String getDbPartition() {
return dbPartition;
}
......
......@@ -20,7 +20,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.List;
/**
......@@ -57,9 +59,6 @@ public class AliFuWuChuangSingleMessageSender implements IMessageProcessor {
@Autowired
private InterrprentUtil interrprentUtil;
@Autowired
private EncryptionHelper encryptionHelper;
@Override
public Boolean Process(PayMessage payMessage) {
......
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.freemud.pay.job.ConfigBean
......@@ -7,7 +7,8 @@ logging.config=classpath:logback.xml
### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
#xxl.job.admin.addresses=http://115.159.142.32:9080/xxl-job-admin/
xxl.job.admin.addresses=http://localhost:8080/xxl-job-admin/
#xxl.job.admin.addresses=http://localhost:8080/xxl-job-admin/
xxl.job.admin.addresses=http://115.159.142.32:9080/xxl-job-admin/
### xxl-job executor address
xxl.job.executor.appname=push-message-test
xxl.job.executor.ip=
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.freemud.pay.job.dao.mapper.ActiveDMMapper">
<resultMap id="BaseResultMap" type="com.freemud.pay.job.dao.dbModel.ActiveDM">
<id column="ActiveId" jdbcType="INTEGER" property="activeid" />
<result column="EBCode" jdbcType="VARCHAR" property="ebcode" />
<result column="Type" jdbcType="INTEGER" property="type" />
<result column="PartnerID" jdbcType="INTEGER" property="partnerid" />
<result column="PlatformItemId" jdbcType="VARCHAR" property="platformitemid" />
<result column="State" jdbcType="INTEGER" property="state" />
<result column="CreateUser" jdbcType="NVARCHAR" property="createuser" />
<result column="CreateDate" jdbcType="TIMESTAMP" property="createdate" />
<result column="LastEditUser" jdbcType="NVARCHAR" property="lastedituser" />
<result column="LastEditDate" jdbcType="TIMESTAMP" property="lasteditdate" />
<result column="ActiveCode" jdbcType="VARCHAR" property="activecode" />
<result column="ActiveName" jdbcType="NVARCHAR" property="activename" />
<result column="ActiveDesc" jdbcType="NVARCHAR" property="activedesc" />
<result column="StartDate" jdbcType="TIMESTAMP" property="startdate" />
<result column="EndDate" jdbcType="TIMESTAMP" property="enddate" />
<result column="ShouldRedeemAll" jdbcType="BIT" property="shouldredeemall" />
<result column="PromotionType" jdbcType="NVARCHAR" property="promotiontype" />
<result column="Exclusive" jdbcType="BIT" property="exclusive" />
<result column="MinAmount" jdbcType="DECIMAL" property="minamount" />
<result column="MaxRedeemTimes" jdbcType="INTEGER" property="maxredeemtimes" />
<result column="MaxSendOut" jdbcType="INTEGER" property="maxsendout" />
<result column="Cost" jdbcType="DECIMAL" property="cost" />
<result column="BusinessID" jdbcType="INTEGER" property="businessid" />
<result column="PercentDiscount" jdbcType="DECIMAL" property="percentdiscount" />
<result column="MaxDiscount" jdbcType="INTEGER" property="maxdiscount" />
<result column="CompanyId" jdbcType="INTEGER" property="companyid" />
<result column="OriginalPrice" jdbcType="DECIMAL" property="originalprice" />
<result column="SalePrice" jdbcType="DECIMAL" property="saleprice" />
<result column="TimeLimit" jdbcType="INTEGER" property="timelimit" />
<result column="DailyRedeemTimes" jdbcType="INTEGER" property="dailyredeemtimes" />
<result column="StationEnable" jdbcType="BIT" property="stationenable" />
<result column="RedeemChannel" jdbcType="VARCHAR" property="redeemchannel" />
</resultMap>
<sql id="Base_Column_List">
ActiveId, EBCode, Type, PartnerID, PlatformItemId, State, CreateUser, CreateDate,
LastEditUser, LastEditDate, ActiveCode, ActiveName, ActiveDesc, StartDate, EndDate,
ShouldRedeemAll, PromotionType, Exclusive, MinAmount, MaxRedeemTimes, MaxSendOut,
Cost, BusinessID, PercentDiscount, MaxDiscount, CompanyId, OriginalPrice, SalePrice,
TimeLimit, DailyRedeemTimes, StationEnable, RedeemChannel
</sql>
</mapper>
\ No newline at end of file
......@@ -43,7 +43,13 @@
p.Code AS PayCode
FROM [Freemud_ThirdParty].[dbo].[Pay_Message] a WITH ( NOLOCK )
INNER JOIN ${linkServer}zhuihu.dbo.Pay p WITH ( NOLOCK ) ON a.FMId = p.ZhuiHuOrderId
INNER JOIN zhuihu.dbo.[Partner] part WITH(NOLOCK) ON part.ID=a.PartnerId WHERE Pay_Message_Active_ID=100008333 AND Status=0
INNER JOIN zhuihu.dbo.[Partner] part WITH(NOLOCK) ON part.ID=a.PartnerId
WHERE a.Status IN ( -1, 0 )
AND a.TryTimes < 3
-- AND a.LastEditDate> DATEADD(MINUTE,-30, GETDATE())
AND a.LastEditDate < GETDATE()
AND a.PartnerId = 1205
ORDER BY a.LastEditDate
]]>
</select>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.freemud.pay.job.dao.mapper.PayPlatformAccountDMMapper">
<resultMap id="BaseResultMap" type="com.freemud.pay.job.dao.dbModel.PayPlatformAccountDM">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="PartnerId" jdbcType="INTEGER" property="partnerid" />
<result column="Platform" jdbcType="VARCHAR" property="platform" />
<result column="PlatformPartnerId" jdbcType="VARCHAR" property="platformpartnerid" />
<result column="PlatformAppKey" jdbcType="VARCHAR" property="platformappkey" />
<result column="PlatformSellerId" jdbcType="VARCHAR" property="platformsellerid" />
<result column="PlatformSellerEmail" jdbcType="VARCHAR" property="platformselleremail" />
<result column="PlatformSubject" jdbcType="NVARCHAR" property="platformsubject" />
<result column="CreateUser" jdbcType="VARCHAR" property="createuser" />
<result column="CreateDate" jdbcType="TIMESTAMP" property="createdate" />
<result column="SignChar" jdbcType="VARCHAR" property="signchar" />
<result column="CerFile" jdbcType="VARCHAR" property="cerfile" />
<result column="CerPassword" jdbcType="VARCHAR" property="cerpassword" />
<result column="PlatformSubAccountId" jdbcType="VARCHAR" property="platformsubaccountid" />
<result column="Enable" jdbcType="BIT" property="enable" />
<result column="PlatformAppId" jdbcType="VARCHAR" property="platformappid" />
<result column="Password" jdbcType="VARCHAR" property="password" />
<result column="AgentId" jdbcType="VARCHAR" property="agentid" />
<result column="AuthCode" jdbcType="VARCHAR" property="authcode" />
<result column="Memo" jdbcType="NVARCHAR" property="memo" />
<result column="FeeType" jdbcType="NVARCHAR" property="feetype" />
</resultMap>
<sql id="Base_Column_List">
ID, PartnerId, Platform, PlatformPartnerId, PlatformAppKey, PlatformSellerId, PlatformSellerEmail,
PlatformSubject, CreateUser, CreateDate, SignChar, CerFile, CerPassword, PlatformSubAccountId,
Enable, PlatformAppId, Password, AgentId, AuthCode, Memo, FeeType
</sql>
<select id="selectByPartnerId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from zhuihu.dbo.Pay_PlatformAccount
with(nolock)
where Partnerid = #{partnerid,jdbcType=INTEGER} AND Enable=1
</select>
</mapper>
\ No newline at end of file
......@@ -6,7 +6,7 @@ logging.config=classpath:logback.xml
### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
xxl.job.admin.addresses=http://115.159.142.32:9080/xxl-job-admin/
xxl.job.admin.addresses=http://localhost:8080/xxl-job-admin
### xxl-job executor address
xxl.job.executor.appname=xxl-job-executor-sample
......
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