Commit d67492df by lihui.wang

向第三方 发送请求

parent adbef38a
......@@ -136,6 +136,25 @@
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>
<!-- sdk依赖的日志jar -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<!--支付宝sdk编译文件jar-->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<!--<build>-->
......
package com.freemud.pay.job.entity.dto;
package com.freemud.pay.job.config;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* All rights Reserved, Designed By www.freemud.cn
......@@ -11,19 +18,27 @@ package com.freemud.pay.job.entity.dto;
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class CommonRequest {
@Profile("default")
@Component
@PropertySource("classpath:alipay.properties")
@ConfigurationProperties(prefix="alipay")
public class AliPayConfig {
private String serverUrl;
private String appId;
private String method;
private String privateKey;
private String format;
private String charset;
private String alipayPublicKey;
private String signType;
private String sign;
private String timestamp;
/**
* 调用的接口版本,固定为1.0
*/
private String version;
private String appAuthToken;
public String getServerUrl() {
return serverUrl;
}
public void setServerUrl(String serverUrl) {
this.serverUrl = serverUrl;
}
public String getAppId() {
return appId;
......@@ -33,12 +48,12 @@ public class CommonRequest {
this.appId = appId;
}
public String getMethod() {
return method;
public String getPrivateKey() {
return privateKey;
}
public void setMethod(String method) {
this.method = method;
public void setPrivateKey(String privateKey) {
this.privateKey = privateKey;
}
public String getFormat() {
......@@ -57,43 +72,19 @@ public class CommonRequest {
this.charset = charset;
}
public String getSignType() {
return signType;
}
public void setSignType(String signType) {
this.signType = signType;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
public String getAlipayPublicKey() {
return alipayPublicKey;
}
public String getVersion() {
return version;
public void setAlipayPublicKey(String alipayPublicKey) {
this.alipayPublicKey = alipayPublicKey;
}
public void setVersion(String version) {
this.version = version;
}
public String getAppAuthToken() {
return appAuthToken;
public String getSignType() {
return signType;
}
public void setAppAuthToken(String appAuthToken) {
this.appAuthToken = appAuthToken;
public void setSignType(String signType) {
this.signType = signType;
}
}
\ No newline at end of file
......@@ -26,6 +26,140 @@ public class PayMessageDM extends BaseModel implements Serializable {
private Long payMessageActiveId;
private String store_id;
private Double amount;
private String operator_Id;
private String station_Id;
private Double mCoupon;
private Double pCoupon;
private String platformTradeNumber;
private String platform;
private String subUserId;
private String unifyId;
private String trans_Id;
private String remark;
private String payCode;
public String getStore_id() {
return store_id;
}
public void setStore_id(String store_id) {
this.store_id = store_id;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public String getOperator_Id() {
return operator_Id;
}
public void setOperator_Id(String operator_Id) {
this.operator_Id = operator_Id;
}
public String getStation_Id() {
return station_Id;
}
public void setStation_Id(String station_Id) {
this.station_Id = station_Id;
}
public Double getmCoupon() {
return mCoupon;
}
public void setmCoupon(Double mCoupon) {
this.mCoupon = mCoupon;
}
public Double getpCoupon() {
return pCoupon;
}
public void setpCoupon(Double pCoupon) {
this.pCoupon = pCoupon;
}
public String getPlatformTradeNumber() {
return platformTradeNumber;
}
public void setPlatformTradeNumber(String platformTradeNumber) {
this.platformTradeNumber = platformTradeNumber;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getSubUserId() {
return subUserId;
}
public void setSubUserId(String subUserId) {
this.subUserId = subUserId;
}
public String getUnifyId() {
return unifyId;
}
public void setUnifyId(String unifyId) {
this.unifyId = unifyId;
}
public String getTrans_Id() {
return trans_Id;
}
public void setTrans_Id(String trans_Id) {
this.trans_Id = trans_Id;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getPayCode() {
return payCode;
}
public void setPayCode(String payCode) {
this.payCode = payCode;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
private static final long serialVersionUID = 1L;
public Long getId() {
......
......@@ -24,4 +24,6 @@ public interface PayMessageDMMapper extends IBaseDao<PayMessageDM>{
List<PayMessageDM> getPayMessages(Map<String, Object> paramsMap);
int updateMessageStatus(Integer status,Long id);
int updateMessageTryTimes(Integer trytimes,Long id);
}
\ No newline at end of file
package com.freemud.pay.job.entity.vo.response;
package com.freemud.pay.job.dao.repository;
import com.freemud.pay.job.dao.dbModel.ActiveDM;
/**
* All rights Reserved, Designed By www.freemud.cn
......@@ -11,5 +13,6 @@ package com.freemud.pay.job.entity.vo.response;
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class AResponse {
public interface IActiveRepository extends IBaseRepository{
ActiveDM selectByPrimaryKey(Integer activeid);
}
\ No newline at end of file
......@@ -19,4 +19,5 @@ import java.util.Map;
public interface IPayMessageRepository extends IBaseRepository{
List<PayMessageDM> getPayMessages(Map<String, Object> paramsMap);
int updateMessageStatus(Integer status,Long id);
int updateMessageTryTimes(Integer trytimes,Long id);
}
package com.freemud.pay.job.entity.dto;
package com.freemud.pay.job.dao.repository;
import com.freemud.pay.job.dao.dbModel.StoreDM;
import java.util.Map;
/**
* All rights Reserved, Designed By www.freemud.cn
......@@ -11,23 +15,6 @@ package com.freemud.pay.job.entity.dto;
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class AliFuWuChuangSingleMessageResponse {
private String code;
private String msg;
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 interface IStoreRepository extends IBaseRepository{
StoreDM selectByStoreIdAndPartnerId(Map<String, Object> paramsMap);
}
\ No newline at end of file
package com.freemud.pay.job.dao.repository.Impl;
import com.freemud.pay.job.dao.IBaseDao;
import com.freemud.pay.job.dao.dbModel.ActiveDM;
import com.freemud.pay.job.dao.mapper.ActiveDMMapper;
import com.freemud.pay.job.dao.repository.IActiveRepository;
import org.springframework.beans.factory.annotation.Autowired;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title:
* @Package com.freemud.pay
* @Description:
* @author: lihui.wang
* @date:
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class ActiveRepositoryImpl extends BaseRepositoryImpl implements IActiveRepository {
@Autowired
ActiveDMMapper activeDMMapper;
@Override
protected IBaseDao getDao() {
return activeDMMapper;
}
@Override
public ActiveDM selectByPrimaryKey(Integer activeid) {
return activeDMMapper.selectByPrimaryKey(activeid);
}
}
\ No newline at end of file
......@@ -43,4 +43,9 @@ public class PayMessageRepositoryImpl extends BaseRepositoryImpl implements IPay
public int updateMessageStatus(Integer status,Long id) {
return payMessageMapper.updateMessageStatus(status,id);
}
@Override
public int updateMessageTryTimes(Integer trytimes, Long id) {
return payMessageMapper.updateMessageTryTimes(trytimes,id);
}
}
\ No newline at end of file
package com.freemud.pay.job.dao.repository.Impl;
import com.freemud.pay.job.dao.IBaseDao;
import com.freemud.pay.job.dao.dbModel.StoreDM;
import com.freemud.pay.job.dao.mapper.StoreDMMapper;
import com.freemud.pay.job.dao.repository.IStoreRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;
import java.util.Map;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title:
* @Package com.freemud.pay
* @Description:
* @author: lihui.wang
* @date:
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Primary
@Repository
public class StoreRepositoryImpl extends BaseRepositoryImpl implements IStoreRepository {
@Autowired
StoreDMMapper storeDMMapper;
@Override
protected IBaseDao getDao() {
return storeDMMapper;
}
@Override
public StoreDM selectByStoreIdAndPartnerId(Map<String, Object> paramsMap) {
return storeDMMapper.selectByStoreIdAndPartnerId(paramsMap);
}
}
\ No newline at end of file
package com.freemud.pay.job.entity.dto;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title:
* @Package com.freemud.pay
* @Description:
* @author: lihui.wang
* @date:
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class CommonResponse {
private String code;
private String msg;
private String subCode;
private String subMsg;
private String sign;
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 String getSubCode() {
return subCode;
}
public void setSubCode(String subCode) {
this.subCode = subCode;
}
public String getSubMsg() {
return subMsg;
}
public void setSubMsg(String subMsg) {
this.subMsg = subMsg;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
}
\ No newline at end of file
package com.freemud.pay.job.entity.dto;
package com.freemud.pay.job.service;
import com.freemud.pay.job.dao.dbModel.ActiveDM;
/**
* All rights Reserved, Designed By www.freemud.cn
......@@ -11,14 +13,6 @@ package com.freemud.pay.job.entity.dto;
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class AliFuWuChuangSingleMessageRequest extends CommonRequest{
private String bizContent;
public String getBizContent() {
return bizContent;
}
public void setBizContent(String bizContent) {
this.bizContent = bizContent;
}
}
\ No newline at end of file
public interface IActiveService {
ActiveDM selectByPrimaryKey(Integer activeid);
}
......@@ -14,6 +14,6 @@ import com.freemud.pay.job.entity.BaseParam;
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public interface PayMessageActiveService {
public interface IPayMessageActiveService {
PayMessageActiveDM getPayMessageActiveDM(long activeId, BaseParam baseParam);
}
......@@ -21,4 +21,5 @@ public interface IPayMessageService {
void pushMessage(BaseParam baseRequest);
int updateMessageStatus(Integer status,Long id);
List<PayMessageDM> getPayMessages(BaseParam baseParam);
int updateMessageTryTimes(Integer trytimes,Long id);
}
......@@ -13,6 +13,6 @@ import com.freemud.pay.job.dao.dbModel.PayPlatformAccountDM;
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public interface PayPlatformAccountService {
public interface IPayPlatformAccountService {
PayPlatformAccountDM getPayPlatformAccount(Integer partnerId);
}
package com.freemud.pay.job.service;
import com.freemud.pay.job.dao.dbModel.StoreDM;
import java.util.Map;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title:
* @Package com.freemud.pay
* @Description:
* @author: lihui.wang
* @date:
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public interface IStoreService {
StoreDM selectByStoreIdAndPartnerId(Integer partnerid,String storeidPartner);
}
package com.freemud.pay.job.service.impl;
import com.freemud.pay.job.dao.dbModel.ActiveDM;
import com.freemud.pay.job.dao.repository.IActiveRepository;
import com.freemud.pay.job.service.IActiveService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title:
* @Package com.freemud.pay
* @Description:
* @author: lihui.wang
* @date:
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class ActiveServiceImpl implements IActiveService {
@Autowired
IActiveRepository iActiveRepository;
@Override
public ActiveDM selectByPrimaryKey(Integer activeid) {
return iActiveRepository.selectByPrimaryKey(activeid);
}
}
\ No newline at end of file
package com.freemud.pay.job.service.impl;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayMobilePublicMessageSingleSendRequest;
import com.alipay.api.response.AlipayMobilePublicMessageSingleSendResponse;
import com.freemud.pay.job.config.AliPayConfig;
import com.freemud.pay.job.dao.dbModel.ActiveDM;
import com.freemud.pay.job.dao.dbModel.PayPlatformAccountDM;
import com.freemud.pay.job.dao.dbModel.StoreDM;
import com.freemud.pay.job.entity.PayMessage;
import com.freemud.pay.job.service.IMessageProcessor;
import com.freemud.pay.job.service.PayPlatformAccountService;
import com.freemud.pay.job.service.*;
import com.freemud.pay.job.service.util.InterrprentUtil;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.*;
import java.text.SimpleDateFormat;
/**
* All rights Reserved, Designed By www.freemud.cn
*
......@@ -20,89 +30,58 @@ import org.springframework.beans.factory.annotation.Autowired;
public class AliFuWuChuangSingleMessageSender implements IMessageProcessor {
@Autowired
PayPlatformAccountService payPlatformAccountService;
IPayPlatformAccountService IPayPlatformAccountService;
@Autowired
IPayMessageService iPayMessageService;
@Autowired
IStoreService iStoreService;
@Autowired
IActiveService iActiveService;
@Autowired
private AliPayConfig config;
@Autowired
private InterrprentUtil interrprentUtil;
@Override
public Boolean Process(PayMessage payMessage) {
PayPlatformAccountDM payPlatformAccountDM = payPlatformAccountService.getPayPlatformAccount(payMessage.getPayMessage().getPartnerid());
PayPlatformAccountDM payPlatformAccountDM = IPayPlatformAccountService.getPayPlatformAccount(payMessage.getPayMessage().getPartnerid());
if (payPlatformAccountDM == null){
payMessage.setNoRetry(true);
return false;
}
try {
AlipayClient alipayClient = new DefaultAlipayClient(config.getServerUrl(),payPlatformAccountDM.getPlatformappid(),payPlatformAccountDM.getCerfile());
AlipayMobilePublicMessageSingleSendRequest request = new AlipayMobilePublicMessageSingleSendRequest();
request.setBizContent(interrprentUtil.Interrprent(payMessage));
AlipayMobilePublicMessageSingleSendResponse response = alipayClient.execute(request);
if (response.getCode() == "200"){
return true;
}
else if (response.getCode() == "12007") //未关注
{
iPayMessageService.updateMessageStatus(3,payMessage.getPayMessage().getId());
}
else
{
return false;
}
}catch (Exception e){
return false;
}
// try
// {
//
// Logger.Info("process:" + context.Message.Id);
// var url = ConfigurationManager.AppSettings["alipay_gateway"];
// var req = new AlipayMobilePublicMessageSingleSendRequest();
// req.BizContent = TemplateHelper.Interprent(context);
// // Logger.Info("account.PlatformAppId:" + account.PlatformAppId + ",account.PlatformAppId:" + account.CerFile);
// var client = new DefaultAopClient(url, account.PlatformAppId, account.CerFile);
// Stopwatch stopwatch = new Stopwatch();
// stopwatch.Start();
// var rsp = client.Execute(req, null, account.AuthCode);
// stopwatch.Stop();
// string timeCost = "timecost:" + stopwatch.ElapsedMilliseconds;
// if (rsp.Code == "200")
// {
// Logger.Info(timeCost+" \tsend:" + req.BizContent + "\tget response:" + rsp.Body);
// return true;
// }
// else if (rsp.Code == "12007")//未关注
// {
// Logger.Warn(timeCost + " \tsend:" + JsonUtility.ToJson(req) + "\tget response:" + rsp.Body);
// new Repository().UpdateMessageStatus(context.Message.Id, context.BussinessType, context.DBPartition);
// return false;
// }
// else
// {
// Logger.Warn(timeCost + " \tsend:" + JsonUtility.ToJson(req) + "\tget response:" + rsp.Body);
// return false;
// }
// }
// catch (Exception ex)
// {
// Logger.Warn(string.Format("failed process #{0},exception:{1}", context.Message.Id, ex));
// return false;
// }
return null;
}
// public MeddyIdResponse getMeddyId(String json, String url){
// RestTemplate restTemplate = new RestTemplate();
// HttpHeaders headers = new HttpHeaders();
// //一定要设置好ContentType为utf8否则会乱码
// MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
// headers.setContentType(type);
// headers.add("Accept", MediaType.APPLICATION_JSON.toString());
//
// HttpEntity<String> formEntity = new HttpEntity<String>(json, headers);
// String meddyIdResponseString = restTemplate.postForObject(url, formEntity, String.class);
// MeddyIdResponse meddyIdResponse = JSONObject.parseObject(meddyIdResponseString,MeddyIdResponse.class);
// return meddyIdResponse;
// }
}
\ No newline at end of file
......@@ -3,8 +3,7 @@ package com.freemud.pay.job.service.impl;
import com.freemud.pay.job.dao.dbModel.PayMessageActiveDM;
import com.freemud.pay.job.dao.repository.IPayMessageActiveRepository;
import com.freemud.pay.job.entity.BaseParam;
import com.freemud.pay.job.service.PayMessageActiveService;
import com.freemud.pay.job.service.PayPlatformAccountService;
import com.freemud.pay.job.service.IPayMessageActiveService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
......@@ -21,7 +20,7 @@ import java.util.Map;
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class PayMessageActiveServiceImpl implements PayMessageActiveService{
public class IPayMessageActiveServiceImpl implements IPayMessageActiveService {
@Autowired
IPayMessageActiveRepository iPayMessageActiveRepository;
......
package com.freemud.pay.job.service.impl;
import com.freemud.pay.job.dao.dbModel.PayMessageActiveDM;
import com.freemud.pay.job.dao.dbModel.PayPlatformAccountDM;
import com.freemud.pay.job.dao.repository.PayPlatformAccountRepository;
import com.freemud.pay.job.entity.BaseParam;
import com.freemud.pay.job.service.PayPlatformAccountService;
import com.freemud.pay.job.service.IPayPlatformAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* All rights Reserved, Designed By www.freemud.cn
*
......@@ -23,7 +18,7 @@ import java.util.Map;
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Service
public class PayPlatformAccountServiceImpl implements PayPlatformAccountService {
public class IPayPlatformAccountServiceImpl implements IPayPlatformAccountService {
@Autowired
PayPlatformAccountRepository payPlatformAccountRepository;
......
......@@ -9,7 +9,7 @@ import com.freemud.pay.job.entity.PayMessage;
import com.freemud.pay.job.service.IMessageProcessor;
import com.freemud.pay.job.service.IPayMessageService;
import com.freemud.pay.job.service.MessageProcessorFactory;
import com.freemud.pay.job.service.PayMessageActiveService;
import com.freemud.pay.job.service.IPayMessageActiveService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -36,7 +36,7 @@ public class PayMessageServiceImpl implements IPayMessageService {
IPayMessageRepository iPayMessageRepository;
@Autowired
PayMessageActiveService payMessageActiveService;
IPayMessageActiveService IPayMessageActiveService;
@Override
public void pushMessage(BaseParam baseParam) {
......@@ -62,7 +62,7 @@ public class PayMessageServiceImpl implements IPayMessageService {
markMessageAsNoProcess(message);
return;
}
PayMessageActiveDM active = payMessageActiveService.getPayMessageActiveDM(message.getPayMessageActiveId(),baseParam);
PayMessageActiveDM active = IPayMessageActiveService.getPayMessageActiveDM(message.getPayMessageActiveId(),baseParam);
if (active == null
|| StringUtils.isEmpty(active.getAction()))
{
......@@ -123,11 +123,15 @@ public class PayMessageServiceImpl implements IPayMessageService {
@Override
public List<PayMessageDM> getPayMessages(BaseParam baseParam){
//db linkserver
Map<String, Object> paramsMap = new HashMap<String, Object>();
paramsMap.put("linkServer",baseParam.getLinkServer());
return iPayMessageRepository.getPayMessages(paramsMap);
}
@Override
public int updateMessageTryTimes(Integer trytimes, Long id) {
return iPayMessageRepository.updateMessageTryTimes(trytimes,id);
}
}
\ No newline at end of file
package com.freemud.pay.job.service.impl;
import com.freemud.pay.job.dao.dbModel.StoreDM;
import com.freemud.pay.job.dao.repository.IStoreRepository;
import com.freemud.pay.job.service.IStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
import java.util.Map;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title:
* @Package com.freemud.pay
* @Description:
* @author: lihui.wang
* @date:
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class StoreServiceImpl implements IStoreService {
@Autowired
IStoreRepository iStoreRepository;
@Override
public StoreDM selectByStoreIdAndPartnerId(Integer partnerid, String storeidPartner) {
Map<String, Object> paramsMap = new HashMap<String, Object>();
paramsMap.put("partnerid",partnerid);
paramsMap.put("storeidPartner",storeidPartner);
return iStoreRepository.selectByStoreIdAndPartnerId(paramsMap);
}
}
\ No newline at end of file
package com.freemud.pay.job.service.util;
import com.freemud.pay.job.dao.dbModel.ActiveDM;
import com.freemud.pay.job.dao.dbModel.StoreDM;
import com.freemud.pay.job.entity.PayMessage;
import com.freemud.pay.job.service.IActiveService;
import com.freemud.pay.job.service.IStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.*;
import java.text.SimpleDateFormat;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title:
* @Package com.freemud.pay
* @Description:
* @author: lihui.wang
* @date:
* @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class InterrprentUtil {
@Autowired
IStoreService iStoreService;
@Autowired
IActiveService iActiveService;
public String Interrprent(PayMessage context)
{
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
SimpleDateFormat dateformat1 = new SimpleDateFormat("MM月dd日");
SimpleDateFormat dateformat2 = new SimpleDateFormat("yyyy年MM月dd日");
StoreDM storeDM = iStoreService.selectByStoreIdAndPartnerId(context.getPayMessage().getPartnerid(),context.getPayMessage().getStore_id());
String templateContent=readToFile("templates"+"\\"+context.getPayMessageActive().getTemplateid()+".txt");
templateContent= templateContent.replace("#id#", context.getPayMessage().getId().toString())
.replace("#toUserId#", context.getPayMessage().getUserid())
.replace("#fmId#", context.getPayMessage().getFmid())
.replace("#shortDate#", dateformat1.format(context.getPayMessage().getCreatedate()))
.replace("#createDate#", dateformat.format(context.getPayMessage().getCreatedate()))
.replace("#platfromTranNo#", context.getPayMessage().getPlatformTradeNumber())
.replace("#amount#", context.getPayMessage().getAmount().toString())
.replace("#mcoupon#", context.getPayMessage().getmCoupon().toString())
.replace("#pcoupon#", context.getPayMessage().getpCoupon().toString())
.replace("#actualPay#", String.valueOf(context.getPayMessage().getAmount() -
context.getPayMessage().getpCoupon() -
context.getPayMessage().getpCoupon()))
.replace("#discount#", String.valueOf(context.getPayMessage().getmCoupon() + context.getPayMessage().getpCoupon()))
.replace("#storeName#", storeDM.getStorename())
.replace("#templateId#", context.getPayMessageActive().getTemplateid())
.replace("#wxMsgActiveId#", context.getPayMessageActive().getWxmsgactiveid());
if (context.getPayMessageActive().getCouponactiveid() > 0)
{
/**
* todo code 解密没有
*/
String code = context.getPayMessage().getCode().isEmpty()?"":context.getPayMessage().getCode().trim();
// string.IsNullOrWhiteSpace()
// ? string.Empty
// : new ZhuiHu.Encryption.EncryptionUtility().Decode(context.getPayMessage().Code.Trim());
ActiveDM couponInfo = iActiveService.selectByPrimaryKey(context.getPayMessageActive().getCouponactiveid());
templateContent = templateContent.replace("#code#", code)
.replace("#validFrom#", dateformat2.format(couponInfo.getStartdate()))
.replace("#validEnd#", dateformat2.format(couponInfo.getEnddate()));
}
return templateContent;
}
public String readToFile(String fileName) {
String encoding = "UTF-8";
File file = new File(fileName);
Long filelength = file.length();
byte[] filecontent = new byte[filelength.intValue()];
try {
FileInputStream in = new FileInputStream(file);
in.read(filecontent);
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
return new String(filecontent, encoding);
} catch (UnsupportedEncodingException e) {
System.err.println("The OS does not support " + encoding);
e.printStackTrace();
return null;
}
}
}
\ No newline at end of file
alipay.serverUrl=https://openapi.alipay.com/gateway.do
alipay.appId=
alipay.privateKey=
alipay.format=json
alipay.charset=utf-8
alipay.alipayPublicKey=
alipay.signType=RSA2
\ No newline at end of file
......@@ -70,11 +70,13 @@
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!--<table tableName="Store" domainObjectName="StoreDM" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<!--<table tableName="pay" domainObjectName="PayDM" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<!--<table tableName="Pay_Message" domainObjectName="PayMessageDM" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<!--<table tableName="Pay_Message_Active" domainObjectName="PayMessageActiveDM" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<!--<table tableName="Partner" domainObjectName="PartnerDM" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<table tableName="Pay_PlatformAccount" domainObjectName="PayPlatformAccountDM" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>
<!--<table tableName="Pay_PlatformAccount" domainObjectName="PayPlatformAccountDM" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<table tableName="Active" domainObjectName="ActiveDM" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>
<!--<table tableName="partner" domainObjectName="Partner" ></table>
......
......@@ -196,4 +196,7 @@
<update id="updateMessageStatus">
update top(1) [Freemud_ThirdParty].[dbo].[Pay_Message] set status=#{status} ,TryTimes=TryTimes+1 where id=#{id}
</update>
<update id="updateMessageTryTimes">
update top(1) [Freemud_ThirdParty].[dbo].[Pay_Message] set TryTimes=#{TryTimes} where id=#{id}
</update>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment