Commit 35d2f230 by lihui.wang

成功!

parent bc1b47f1
package com.freemud.pay.job.controller; package com.freemud.pay.job.controller;
import com.alibaba.fastjson.JSON;
import com.freemud.pay.job.dao.dbModel.StoreDM; import com.freemud.pay.job.dao.dbModel.StoreDM;
import com.freemud.pay.job.entity.BaseParam; import com.freemud.pay.job.entity.BaseParam;
import com.freemud.pay.job.entity.Parameter; import com.freemud.pay.job.entity.Parameter;
...@@ -48,6 +49,7 @@ public class ApiController { ...@@ -48,6 +49,7 @@ public class ApiController {
BaseParam baseParam = new BaseParam(); BaseParam baseParam = new BaseParam();
baseParam.setDbPartition("1205"); baseParam.setDbPartition("1205");
baseParam.setLinkServer(""); baseParam.setLinkServer("");
System.out.println(JSON.toJSONString(baseParam));
payMessageService.pushMessage(baseParam); payMessageService.pushMessage(baseParam);
} }
......
package com.freemud.pay.job.service.processorfactory.processimpl; package com.freemud.pay.job.service.processorfactory.processimpl;
import com.alibaba.fastjson.JSON;
import com.alipay.api.AlipayClient; import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient; import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayMobilePublicMessageSingleSendRequest; import com.alipay.api.request.AlipayMobilePublicMessageSingleSendRequest;
...@@ -12,6 +13,7 @@ import com.freemud.pay.job.service.*; ...@@ -12,6 +13,7 @@ import com.freemud.pay.job.service.*;
import com.freemud.pay.job.service.constants.PayPlatformAccountConstans; import com.freemud.pay.job.service.constants.PayPlatformAccountConstans;
import com.freemud.pay.job.service.processorfactory.IMessageProcessor; import com.freemud.pay.job.service.processorfactory.IMessageProcessor;
import com.freemud.pay.job.service.util.EncryptionHelper; import com.freemud.pay.job.service.util.EncryptionHelper;
import com.freemud.pay.job.service.util.FileHelper;
import com.freemud.pay.job.service.util.InterrprentUtil; import com.freemud.pay.job.service.util.InterrprentUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -63,21 +65,7 @@ public class AliFuWuChuangSingleMessageSender implements IMessageProcessor { ...@@ -63,21 +65,7 @@ public class AliFuWuChuangSingleMessageSender implements IMessageProcessor {
logger.info("向第三方发送请求"); logger.info("向第三方发送请求");
System.out.println(payMessage.getPayMessage().getPartnerid()); System.out.println(payMessage.getPayMessage().getPartnerid());
// List<PayPlatformAccountDM> payPlatformAccountDMList = iPayPlatformAccountService.getPayPlatformAccount(payMessage.getPayMessage().getPartnerid());
// PayPlatformAcountKey payPlatformAcountKey = new PayPlatformAcountKey();
// payPlatformAcountKey.setPartnerId(iPayMessageService.selectByPrimaryKey(payMessage.getPayMessage().getId()).getPartnerid());
// payPlatformAcountKey.setPlatform(iPayMessageService.selectByPrimaryKey(payMessage.getPayMessage().getId()).getPlatform());
// payPlatformAcountKey.setStoreId(iPayMessageService.selectByPrimaryKey(payMessage.getPayMessage().getId()).getStore_id());
// payPlatformAccountDMList.stream().forEach(p->{
// if(p.getEnable() == true && p.getPlatform().equalsIgnoreCase(payPlatformAcountKey.getPlatform()) ){
// PayPlatformAccountDM payPlatformAccountDM = payPlatformAccountDMList.get(0);
// if (payPlatformAccountDM != null && payPlatformAccountDM.getPassword() != null){
// payPlatformAccountDM.setPassword(encryptionHelper.Decode(payPlatformAccountDM.getPassword()));
// }
// return payPlatformAccountDM;
// }
//
// });
PayPlatformAccountDM payPlatformAccountDM = iPayPlatformAccountService.getPayPlatformAccount(payMessage, PayPlatformAccountConstans.PLATFORM_ALI_FWC); PayPlatformAccountDM payPlatformAccountDM = iPayPlatformAccountService.getPayPlatformAccount(payMessage, PayPlatformAccountConstans.PLATFORM_ALI_FWC);
System.out.println(payPlatformAccountDM.getId()); System.out.println(payPlatformAccountDM.getId());
...@@ -88,9 +76,10 @@ public class AliFuWuChuangSingleMessageSender implements IMessageProcessor { ...@@ -88,9 +76,10 @@ public class AliFuWuChuangSingleMessageSender implements IMessageProcessor {
} }
logger.info("获取第三方"); logger.info("获取第三方");
try { try {
AlipayClient alipayClient = new DefaultAlipayClient(config.getServerUrl(),payPlatformAccountDM.getPlatformappid(),payPlatformAccountDM.getCerfile()); //String cerfile =payPlatformAccountDM.getCerfile()+".pkcs8.pem";
String cerfile= FileHelper.readToFile(payPlatformAccountDM.getCerfile()+".pkcs8.pem");
System.out.println(config.getServerUrl()+" "+payPlatformAccountDM.getPlatformappid()+" "+payPlatformAccountDM.getCerfile()); AlipayClient alipayClient = new DefaultAlipayClient(config.getServerUrl(),payPlatformAccountDM.getPlatformappid(),cerfile);
logger.info("获取alipayClient成功"); logger.info("获取alipayClient成功");
...@@ -98,10 +87,14 @@ public class AliFuWuChuangSingleMessageSender implements IMessageProcessor { ...@@ -98,10 +87,14 @@ public class AliFuWuChuangSingleMessageSender implements IMessageProcessor {
request.setBizContent(interrprentUtil.Interrprent(payMessage)); request.setBizContent(interrprentUtil.Interrprent(payMessage));
AlipayMobilePublicMessageSingleSendResponse response = alipayClient.execute(request); AlipayMobilePublicMessageSingleSendResponse response = alipayClient.execute(request,null,payPlatformAccountDM.getAuthcode());
logger.info(JSON.toJSONString(request));
logger.info("-----------------");
logger.info(JSON.toJSONString(response));
if (response.getCode() == "200"){ if (response.getCode().equals("200")){
logger.info("消息推送成功"); logger.info("消息推送成功");
return true; return true;
} }
...@@ -113,6 +106,7 @@ public class AliFuWuChuangSingleMessageSender implements IMessageProcessor { ...@@ -113,6 +106,7 @@ public class AliFuWuChuangSingleMessageSender implements IMessageProcessor {
} }
else else
{ {
logger.info(response.getCode());
logger.error("消息推送状态码未知"); logger.error("消息推送状态码未知");
return false; return false;
} }
......
package com.freemud.pay.job.service.util;
import java.io.*;
/**
* 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 FileHelper {
public static 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
...@@ -36,46 +36,46 @@ public class InterrprentUtil { ...@@ -36,46 +36,46 @@ public class InterrprentUtil {
IActiveService iActiveService; IActiveService iActiveService;
public String Interrprent(PayMessage context) public String Interrprent(PayMessage payMessage)
{ {
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm"); SimpleDateFormat dateformat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
SimpleDateFormat dateformat1 = new SimpleDateFormat("MM月dd日"); SimpleDateFormat dateformat1 = new SimpleDateFormat("MM月dd日");
SimpleDateFormat dateformat2 = new SimpleDateFormat("yyyy年MM月dd日"); SimpleDateFormat dateformat2 = new SimpleDateFormat("yyyy年MM月dd日");
StoreDM storeDM = iStoreService.selectByStoreIdAndPartnerId(context.getPayMessage().getPartnerid(),context.getPayMessage().getStore_id()); StoreDM storeDM = iStoreService.selectByStoreIdAndPartnerId(payMessage.getPayMessage().getPartnerid(),payMessage.getPayMessage().getStore_id());
String templateContent=readToFile("templates"+"\\"+context.getPayMessageActive().getTemplateid()+".txt"); String templateContent=FileHelper.readToFile("D:\\templates\\"+payMessage.getPayMessageActive().getTemplateid()+".txt");
templateContent= templateContent.replace("#id#", payMessage.getPayMessage().getId().toString())
templateContent= templateContent.replace("#id#", context.getPayMessage().getId().toString()) // .replace("#toUserId#", payMessage.getPayMessage().getUserid())
.replace("#toUserId#", context.getPayMessage().getUserid()) .replace("#toUserId#", "2088912097512321")
.replace("#fmId#", context.getPayMessage().getFmid()) .replace("#fmId#", payMessage.getPayMessage().getFmid())
.replace("#shortDate#", dateformat1.format(context.getPayMessage().getCreatedate())) .replace("#shortDate#", dateformat1.format(payMessage.getPayMessage().getCreatedate()))
.replace("#createDate#", dateformat.format(context.getPayMessage().getCreatedate())) .replace("#createDate#", dateformat.format(payMessage.getPayMessage().getCreatedate()))
.replace("#platfromTranNo#", context.getPayMessage().getPlatformTradeNumber()) .replace("#platfromTranNo#", payMessage.getPayMessage().getPlatformTradeNumber())
.replace("#amount#", context.getPayMessage().getAmount().toString()) .replace("#amount#", payMessage.getPayMessage().getAmount().toString())
.replace("#mcoupon#", context.getPayMessage().getmCoupon().toString()) .replace("#mcoupon#", payMessage.getPayMessage().getmCoupon().toString())
.replace("#pcoupon#", context.getPayMessage().getpCoupon().toString()) .replace("#pcoupon#", payMessage.getPayMessage().getpCoupon().toString())
.replace("#actualPay#", String.valueOf(context.getPayMessage().getAmount() - .replace("#actualPay#", String.valueOf(payMessage.getPayMessage().getAmount() -
context.getPayMessage().getpCoupon() - payMessage.getPayMessage().getpCoupon() -
context.getPayMessage().getpCoupon())) payMessage.getPayMessage().getpCoupon()))
.replace("#discount#", String.valueOf(context.getPayMessage().getmCoupon() + context.getPayMessage().getpCoupon())) .replace("#discount#", String.valueOf(payMessage.getPayMessage().getmCoupon() + payMessage.getPayMessage().getpCoupon()))
.replace("#storeName#", storeDM.getStorename()) .replace("#storeName#", storeDM.getStorename())
.replace("#templateId#", context.getPayMessageActive().getTemplateid()) .replace("#templateId#", payMessage.getPayMessageActive().getTemplateid())
.replace("#wxMsgActiveId#", context.getPayMessageActive().getWxmsgactiveid()); .replace("#wxMsgActiveId#", payMessage.getPayMessageActive().getWxmsgactiveid()==null?"":payMessage.getPayMessageActive().getWxmsgactiveid());
if (context.getPayMessageActive().getCouponactiveid() > 0) if (payMessage.getPayMessageActive().getCouponactiveid()!=null &&payMessage.getPayMessageActive().getCouponactiveid() > 0)
{ {
/** /**
* 解密 * 解密
*/ */
EncryptionHelper encryptionHelper = new EncryptionHelper(); EncryptionHelper encryptionHelper = new EncryptionHelper();
String code = context.getPayMessage().getCode().isEmpty()?null:encryptionHelper.Decode(context.getPayMessage().getCode().trim()); String code = payMessage.getPayMessage().getCode().isEmpty()?null:encryptionHelper.Decode(payMessage.getPayMessage().getCode().trim());
// string.IsNullOrWhiteSpace() // string.IsNullOrWhiteSpace()
// ? string.Empty // ? string.Empty
// : new ZhuiHu.Encryption.EncryptionUtility().Decode(context.getPayMessage().Code.Trim()); // : new ZhuiHu.Encryption.EncryptionUtility().Decode(context.getPayMessage().Code.Trim());
ActiveDM couponInfo = iActiveService.selectByPrimaryKey(context.getPayMessageActive().getCouponactiveid()); ActiveDM couponInfo = iActiveService.selectByPrimaryKey(payMessage.getPayMessageActive().getCouponactiveid());
templateContent = templateContent.replace("#code#", code) templateContent = templateContent.replace("#code#", code)
.replace("#validFrom#", dateformat2.format(couponInfo.getStartdate())) .replace("#validFrom#", dateformat2.format(couponInfo.getStartdate()))
.replace("#validEnd#", dateformat2.format(couponInfo.getEnddate())); .replace("#validEnd#", dateformat2.format(couponInfo.getEnddate()));
...@@ -86,29 +86,6 @@ public class InterrprentUtil { ...@@ -86,29 +86,6 @@ public class InterrprentUtil {
return templateContent; 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();
logger.error("读取文件失败");
} catch (IOException e) {
e.printStackTrace();
logger.error("读取文件流失败");
}
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
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
p.Code AS PayCode p.Code AS PayCode
FROM [Freemud_ThirdParty].[dbo].[Pay_Message] a WITH ( NOLOCK ) 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 ${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 a.pay_message_active_id='100001433' INNER JOIN zhuihu.dbo.[Partner] part WITH(NOLOCK) ON part.ID=a.PartnerId WHERE Pay_Message_Active_ID=100008333
]]> ]]>
</select> </select>
......
支付消息推送:
paymessage : pay(zhuihuorderid-fmid)
: partner(id-partnerid)
active : id
partner : id
pay : zhuihuOrderId active(partnerID)
paymessageActive : id paymessage(Pay_Message_Active_ID)
payPlatformAccount : partnerId partner(id)
store: : partnerId/storeId_partner pay(store_id)
三表联合查询:
paymessage - pay - partner :联合查询出来 paymessage pay(store)-store-active partner(id)-payplatformAccount(partnerID)
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{
"TplMsgId":"#templateId#",
"OrderId":"#fmId#",
"OpenId":"#toUserId#",
keyword:"#createDate#,#storeName#,¥#actualPay#(总金额:¥#amount#),¥#discount#,#platfromTranNo#"
}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{
"TplMsgId":"#templateId#",
"OrderId":"#fmId#",
"OpenId":"#toUserId#",
keyword:"#createDate#,#storeName#,¥#actualPay#(总金额:¥#amount#),¥#discount#,#platfromTranNo#","id":"#id#",
"WXMsgActiveId":"#wxMsgActiveId#"
}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{
"TplMsgId":"#templateId#",
"OrderId":"#fmId#",
"OpenId":"#toUserId#",
keyword:"#createDate#,#storeName#,¥#actualPay#(总金额:¥#amount#),¥#discount#,#platfromTranNo#"
}
\ No newline at end of file
{
"TplMsgId":"#templateId#",
"OrderId":"#fmId#",
"OpenId":"#toUserId#",
keyword:"#createDate#,#storeName#,¥#actualPay#(总金额:¥#amount#),¥#discount#,#platfromTranNo#",
"WXMsgActiveId":"#wxMsgActiveId#"
}
\ No newline at end of file
{
"TplMsgId":"#templateId#",
"OrderId":"#fmId#",
"OpenId":"#toUserId#",
keyword:"#code#,#validFrom#~#validEnd#"
}
\ No newline at end of file
{
"TplMsgId":"#templateId#",
"OrderId":"#fmId#",
"OpenId":"#toUserId#",
keyword:"#createDate#,#storeName#,¥#actualPay#(总金额:¥#amount#),¥#discount#,#platfromTranNo#"
}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#"}
\ No newline at end of file
{
"TplMsgId":"#templateId#",
"OrderId":"#fmId#",
"OpenId":"#toUserId#",
keyword:"#createDate#,#storeName#,¥#actualPay#(总金额:¥#amount#),¥#discount#,#platfromTranNo#"
}
\ No newline at end of file
{"TplMsgId":"#templateId#", "OrderId":"#fmId#", "OpenId":"#toUserId#","keyword":"#code#,#validFrom#~#validEnd#","id":"#id#","WXMsgActiveId":"#wxMsgActiveId#"}
\ No newline at end of file
{"toUserId":"#toUserId#","template":{"templateId":"e50b9b8c863640debc08f8eca19f69c6","context":{"HeadColor":"#FAC100","url":"http://mcd.fwc.freemud.cn/survey/survey.html?outtradeNo=#fmId#","actionName":"立即查看","title":"立即反馈用餐体验,赢取专属优惠券","first":"目前仅适用于反馈天津,杭州,青岛和四川麦当劳餐厅","ImageUrl":"http://68fj829u.fwc.freemud.cn/suvery/banner.jpg"}}}
\ No newline at end of file
{"toUserId":"#toUserId#","template":{"templateId":"f884cd4b68744e5489d244faf6e88ee8","context":{"HeadColor":"#FAC100","url":"http://mcd.fwc.freemud.cn/survey/survey.html?outtradeNo=#fmId#","actionName":"立即查看","title":"立即反馈用餐体验,赢取专属优惠券","first":"目前仅适用于反馈天津及杭州市内所有麦当劳餐厅","imageUrl":"http://68fj829u.fwc.freemud.cn/suvery/banner.jpg"}}}
\ No newline at end of file
{
"aliOpenId":"#alipayOpenId#",
"appId":"T007",
"operatorId":"1",
"partnerId":"a8bee0dd-09d1-4fa9-a9eb-80cb36d3d611",
"reqType":1008,
"stationId":"#stationId#",
"storeId":"0000",
"t":"#timestamp#",
"thirdPayTransId":"#platfromTranNo#",
"weixinOpenId":"#wechatOpenId#"
}
{"aliOpenId":"#alipayOpenId#","appId":"T007","operatorId":"1","partnerId":"a8bee0dd-09d1-4fa9-a9eb-80cb36d3d611","reqType":1008,"stationId":"#stationId#", "storeId":"#storeId#","t":"#timestamp#", "thirdPayTransId":"#platfromTranNo#"}
\ No newline at end of file
{"appId":"T007","operatorId":"1","partnerId":"a8bee0dd-09d1-4fa9-a9eb-80cb36d3d611","reqType":1008,"stationId":"#stationId#","storeId":"#storeId#","t":"#timestamp#","thirdPayTransId":"#platfromTranNo#","weixinOpenId":"#wechatOpenId#"}
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