Commit 1c09bf27 by caosy

add the miss file

parent d7d7136a
package com.ctrip.fun.golf.api.express;
import java.io.Serializable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ctrip.fun.common.vo.Request;
import com.ctrip.fun.common.vo.Response;
import com.ctrip.fun.common.vo.ResponseStatusEnum;
import com.ctrip.fun.common.vo.basic.ExpressBean;
import com.ctrip.fun.golf.service.express.ExpressService;
/**
* 快递信息请求
*
* @author gaoc
*
*/
@Controller
@RequestMapping("/express")
public class ExpressController {
@Autowired
private ExpressService expressService = null;
@ResponseBody
@RequestMapping(value = "/request", method = RequestMethod.POST)
public Response<Serializable> sendOnce(@RequestBody Request<ExpressBean> request) {
Boolean flag = this.expressService.requestExpress(request.getBody());
Response<Serializable> respose = new Response<Serializable>();
if(flag){
respose.setStatus(ResponseStatusEnum.SUCCESS.getValue());
respose.setMessage(ResponseStatusEnum.SUCCESS.getMsg());
}else{
respose.setStatus(ResponseStatusEnum.FAIL.getValue());
respose.setMessage(ResponseStatusEnum.FAIL.getMsg());
}
return respose;
}
}
package com.ctrip.fun.golf.service.express;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import com.ctrip.fun.common.core.util.EncryptUtil;
import com.ctrip.fun.common.core.util.JsonUtil;
import com.ctrip.fun.common.vo.basic.ExpressBean;
import com.ctrip.fun.golf.service.express.vo.TaskRequest;
import com.ctrip.fun.mall.vo.order.MallExpressNameEnum;
/**
* 用来请求快递信息
*
* @author gaoc
* @version 1.0.0
*/
public class ExpressService {
private static Logger logger = LoggerFactory.getLogger(ExpressService.class);
@Value("${expressUrl}")
private String expressUrl = null;
@Value("${expressKey}")
private String expressKey = null;
@Value("${callbackurl}")
private String callbackurl = null;
@Value("${expressSalt}")
private String expressSalt = null;
@Value("${useSystemProxy}")
private boolean useSystemProxy = false;
private void requestOneExpress(ExpressBean expressBean) throws Exception {
TaskRequest req = new TaskRequest();
req.setCompany(MallExpressNameEnum.valueOf(expressBean.getCompanyNo()).getCode());
// req.setFrom("上海浦东新区");
// req.setTo("广东深圳南山区");
req.setNumber(expressBean.getExpressNo());
req.getParameters().put("callbackurl", callbackurl);
req.getParameters().put("salt", EncryptUtil.getMD5Str(expressSalt + expressBean.getExpressNo()));
req.setKey(expressKey);
// 创建HttpClientBuilder
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
if (useSystemProxy) {
httpClientBuilder.useSystemProperties();
}
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
HttpPost post = new HttpPost(expressUrl);
post.addHeader("content-charset", "application/json;charset=UTF-8");// 在头文件中设置转码
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
formparams.add(new BasicNameValuePair("schema", "json"));
formparams.add(new BasicNameValuePair("param", JsonUtil.writeValueAsString(req)));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams);
post.setEntity(entity);
HttpResponse httpResponse = closeableHttpClient.execute(post);
HttpEntity httpEntity = httpResponse.getEntity();
String result = EntityUtils.toString(httpEntity, "UTF-8");
logger.info("expressNo:" + req.getNumber() + " request Express result=" + result);
post.releaseConnection();
}
/**
* 请求物流信息
*/
public Boolean requestExpress(ExpressBean expressBean) {
Boolean result = true;
try {
this.requestOneExpress(expressBean);
} catch (Exception e) {
logger.error(e.getMessage(), e);
result = false;
}
return result;
}
public static void main(String[] args) throws Exception {
ExpressService e = new ExpressService();
e.callbackurl = "http://mall.iwanoutdoor.com/fun-mall-mobile/express/execute";
e.expressKey = "eezQpjws5509";
e.expressSalt = "123";
e.expressUrl = "http://www.kuaidi100.com/poll";
ExpressBean expressBean = new ExpressBean();
expressBean.setCompanyNo(11);
expressBean.setExpressNo("968434104741");
e.requestOneExpress(expressBean);
}
}
package com.ctrip.fun.golf.service.express.vo;
import java.util.HashMap;
public class TaskRequest {
private String company;
private String number;
private String from;
private String to;
private String key;
private String src;
private HashMap<String, String> parameters = new HashMap<String, String>();
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getSrc() {
return src;
}
public void setSrc(String src) {
this.src = src;
}
public HashMap<String, String> getParameters() {
return parameters;
}
public void setParameters(HashMap<String, String> parameters) {
this.parameters = parameters;
}
}
imageEndpoint=http://7x2w1g.com1.z0.glb.clouddn.com
accessKey=s_FZUyzvhxv10JMRzJOBwy5rObZWYlEwwNC9rVt2
secretKey=flCPDL5VVrWx4n9VnzSr6zN1wN4XZega_3cWPqmH
bucketName=ofrog
corpId=wj5007
corpPwd=5376wh
corpService=1069007205007
corpUrl=http://cloud.hongshutech.com:8080/sms_send2.do
useSystemProxy=false
# timeout
rpcReadTimeout=300000
rpcConnectionTimeout=300000
#weather
weather.appkey=10003
weather.serverPath=http://api.k780.com:88/?app=weather.future&amp;weaid=
weather.sign=sign=b59bc3ef6191eb9f747dd4e83c99f2a4&amp;format=json
weather.imagePath=http://7x2w1g.com1.z0.glb.clouddn.com/
#payment2
payment.createPayOrderPath=http://ws.security.pay.fat103.qa.nt.ctripcorp.com/api-webapp/json/createpayorder
payment.payOrderOperatePath=http://ws.security.pay.fat103.qa.nt.ctripcorp.com/api-webapp/json/payoperation
payment.queryPayStatusPath=http://ws.security.pay.fat103.qa.nt.ctripcorp.com/api-webapp/json/queryPayStatus
payment.serverBaseNotifyPath=http://10.8.55.46:8080/fun-golf-service
#payment.createPayOrderPath=https://payapi.ctrip.com/api-webapp/json/CreatePayOrder
#payment.payOrderOperatePath=https://payapi.ctrip.com/api-webapp/json/payoperation
#payment.queryPayStatusPath=https://payapi.ctrip.com/api-webapp/json/queryPayStatus
#payment.serverBaseNotifyPath=http://localhost:8080/fun-golf-service
#express
expressUrl=http://www.kuaidi100.com/poll
expressKey=eezQpjws5509
callbackurl=https://api.iwanoutdoor.com/fun-golf-mobile/express/change
expressSalt=2dfb8831-5158-4132-bfd0-4418dec995b5
#pingan
PINGAN_URL=https://222.68.184.181:8007
PINGAN_PORT=8007
PINGAN_KEYSTOREPASSWORD=paic1234
PINGAN_TRUSTSTOREPASSWORD=paic1234
PINGAN_ELECTRONIC_URL=http://epcis-ptp-dmzstg1.pingan.com.cn:9080/epcis.ptp.partner.getAhsEPolicyPDFWithCert.do
#connect
proxyHost=10.8.16.106
proxyPort=8080
#umeng
umeng_api_key=57e8b616e0f55afc8e0028e8
umeng_api_secret=10330b5a6e779ed78b2b3aa64bdbe517
android_umeng_appkey=561b6553e0f55a0aa10045cd
android_umeng_appMasterSecret=eo3cnlm1pmhuvy0a26m4syt2vfqmahiy
ios_umeng_appkey=55238b36fd98c5ae680005b6
ios_umeng_appMasterSecret=hnrphs6jqykvbywvegdlmp6uwjoxnkpr
ios_umeng_productionMode=false
#rongyun
rongyun_appkey = tdrvipksrrcm5
rongyun_appsecret = x4368Fr6lZw
\ No newline at end of file
log.base=/opt/logs/tomcat
slf4j.root=<root><level value="INFO" /><appender-ref ref="stdout" /></root><root><level value="DEBUG" /><appender-ref ref="logstash" /></root>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment