use of com.coolfish.weixin.redpack.protocol.RedPackResData in project vip by guangdada.
the class RedPackUtil method redPackSend.
public static RedPackResData redPackSend(int amount, String actName, String remark, String wishing, String openid, String billno, String certLocalPath) {
try {
final RedPackResData rprd = new RedPackResData();
// --------------------------------------------------------------------
// 温馨提示,第一次使用该SDK时请到com.tencent.common.Configure类里面进行配置
// --------------------------------------------------------------------
// certLocalPath /data/apps/weixin/apiclient_cert.p12
WXPay.initSDKConfiguration("JTZM88CKRKSWNUAUUF8HMJ7FJPGIY3NA", "wx71e66431bed0303e", "1229321102", "", certLocalPath, "1229321102");
// Configure.setAppID("wx71e66431bed0303e");
// Configure.setKey("JTZM88CKRKSWNUAUUF8HMJ7FJPGIY3NA");
// Configure.setMchID("1229321102");
PayConfig.setIp(Util.localIp());
PayConfig.setHttpsRequestClassName("com.coolfish.weixin.pay.common.HttpsRequest");
// Configure.setCertLocalPath(certLocalPath);
// Configure.setCertPassword(certPassword);
// --------------------------------------------------------------------
// 温馨提示,统一下单,获得付款地址
// --------------------------------------------------------------------
RedPackSendReqData sendRedPackReqData = new RedPackSendReqData(billno, "酷锐运动", openid, amount, 1, wishing, PayConfig.getIP(), actName, remark);
// 也可以直接调用服务,自己处理error_code
// UnifiedOrderResData
// unifiedOrderResData=WXPay.requestUnifiedOrderService(unifiedOrderReqData);
// System.out.println(unifiedOrderResData);
// 封装好错误的商业服务
WXPay.doRedPackSendBusiness(sendRedPackReqData, new RedPackSendListener() {
public void onXmlError(RedPackResData payResData) {
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
public void onSystemError(RedPackResData payResData) {
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
public void onSignError(RedPackResData payResData) {
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
public void onParamError(RedPackResData payResData) {
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
public void onNoAuth(RedPackResData payResData) {
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
public void onFreqLimit(RedPackResData payResData) {
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
public void onCaError(RedPackResData payResData) {
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
public void onSystemBusinessError(RedPackSendResData redPackResData) {
rprd.setErr_code(redPackResData.getErr_code());
rprd.setErr_code_des(redPackResData.getErr_code_des());
rprd.setResult_code(redPackResData.getResult_code());
rprd.setReturn_code(redPackResData.getReturn_code());
rprd.setReturn_msg(redPackResData.getReturn_msg());
}
public void onSuccess(RedPackSendResData redPackResData) {
rprd.setErr_code(redPackResData.getErr_code());
rprd.setErr_code_des(redPackResData.getErr_code_des());
rprd.setResult_code(redPackResData.getResult_code());
rprd.setReturn_code(redPackResData.getReturn_code());
rprd.setReturn_msg(redPackResData.getReturn_msg());
}
public void onSendNumLimit(RedPackSendResData redPackResData) {
rprd.setErr_code(redPackResData.getErr_code());
rprd.setErr_code_des(redPackResData.getErr_code_des());
rprd.setResult_code(redPackResData.getResult_code());
rprd.setReturn_code(redPackResData.getReturn_code());
rprd.setReturn_msg(redPackResData.getReturn_msg());
}
public void onSendFailed(RedPackSendResData redPackResData) {
rprd.setErr_code(redPackResData.getErr_code());
rprd.setErr_code_des(redPackResData.getErr_code_des());
rprd.setResult_code(redPackResData.getResult_code());
rprd.setReturn_code(redPackResData.getReturn_code());
rprd.setReturn_msg(redPackResData.getReturn_msg());
}
public void onOtherError(RedPackSendResData SendRedPackResData) {
rprd.setErr_code(SendRedPackResData.getErr_code());
rprd.setErr_code_des(SendRedPackResData.getErr_code_des());
rprd.setResult_code(SendRedPackResData.getResult_code());
rprd.setReturn_code(SendRedPackResData.getReturn_code());
rprd.setReturn_msg(SendRedPackResData.getReturn_msg());
}
public void onOpenidError(RedPackSendResData redPackResData) {
rprd.setErr_code(redPackResData.getErr_code());
rprd.setErr_code_des(redPackResData.getErr_code_des());
rprd.setResult_code(redPackResData.getResult_code());
rprd.setReturn_code(redPackResData.getReturn_code());
rprd.setReturn_msg(redPackResData.getReturn_msg());
}
public void onNotenough(RedPackSendResData redPackResData) {
rprd.setErr_code(redPackResData.getErr_code());
rprd.setErr_code_des(redPackResData.getErr_code_des());
rprd.setResult_code(redPackResData.getResult_code());
rprd.setReturn_code(redPackResData.getReturn_code());
rprd.setReturn_msg(redPackResData.getReturn_msg());
}
public void onMoneyLimit(RedPackSendResData redPackResData) {
rprd.setErr_code(redPackResData.getErr_code());
rprd.setErr_code_des(redPackResData.getErr_code_des());
rprd.setResult_code(redPackResData.getResult_code());
rprd.setReturn_code(redPackResData.getReturn_code());
rprd.setReturn_msg(redPackResData.getReturn_msg());
}
public void onIllegalAppid(RedPackSendResData SendRedPackResData) {
rprd.setErr_code(SendRedPackResData.getErr_code());
rprd.setErr_code_des(SendRedPackResData.getErr_code_des());
rprd.setResult_code(SendRedPackResData.getResult_code());
rprd.setReturn_code(SendRedPackResData.getReturn_code());
rprd.setReturn_msg(SendRedPackResData.getReturn_msg());
}
public void onFatalError(RedPackSendResData redPackResData) {
rprd.setErr_code(redPackResData.getErr_code());
rprd.setErr_code_des(redPackResData.getErr_code_des());
rprd.setResult_code(redPackResData.getResult_code());
rprd.setReturn_code(redPackResData.getReturn_code());
rprd.setReturn_msg(redPackResData.getReturn_msg());
}
});
return rprd;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of com.coolfish.weixin.redpack.protocol.RedPackResData in project vip by guangdada.
the class RedpackLogServiceImpl method saveRedPackLog.
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveRedPackLog(int amount, String unionid, String openid, String ip, Long merchantId, Long redpackId, String actName, String remark, String wishing) {
log.info("进入saveRedPackLog>>amount = " + amount);
log.info("进入saveRedPackLog>>unionid = " + unionid);
log.info("进入saveRedPackLog>>openid = " + openid);
log.info("进入saveRedPackLog>>ip = " + ip);
log.info("进入saveRedPackLog>>merchantId = " + merchantId);
log.info("进入saveRedPackLog>>redpackId = " + redpackId);
log.info("进入saveRedPackLog>>actName = " + actName);
log.info("进入saveRedPackLog>>remark = " + remark);
log.info("进入saveRedPackLog>>wishing = " + wishing);
log.info("进入saveRedPackLog>>certPath = " + gunsProperties.getCertPath());
if (!gunsProperties.getRedpackFlag()) {
log.info("发送红包开关没有打开");
return;
}
String billno = "kryhb" + new SimpleDateFormat("yyyyMMddHHmmssSSSS").format(new Date());
RedPackResData rprd = RedPackUtil.redPackSend(amount, actName, remark, wishing, openid, billno, gunsProperties.getCertPath());
// 通信成功则记录发送日志
if (rprd != null && "SUCCESS".equals(rprd.getReturn_code())) {
RedpackLog log = new RedpackLog();
log.setBillno(billno);
log.setIp(ip);
log.setRedpackId(redpackId);
log.setMerchantId(merchantId);
log.setUnionid(unionid);
log.setReason(rprd.getErr_code_des());
log.setSendAmount(amount);
if ("SUCCESS".equals(rprd.getErr_code())) {
log.setSendStatus(RedPackSendStatus.SENDING.getCode());
} else {
log.setSendStatus(RedPackSendStatus.FAILED.getCode());
}
redpackLogMapper.insert(log);
// 修改发放信息
redpackDao.updateSendInfo(amount, redpackId);
}
}
use of com.coolfish.weixin.redpack.protocol.RedPackResData in project vip by guangdada.
the class RedPackUtil method redPackQuery.
public static RedPackQueryResData redPackQuery(String mch_billno, String certLocalPath) {
final RedPackQueryResData rprd = new RedPackQueryResData();
try {
WXPay.initSDKConfiguration("JTZM88CKRKSWNUAUUF8HMJ7FJPGIY3NA", "wx71e66431bed0303e", "1229321102", "", certLocalPath, "1229321102");
PayConfig.setIp(Util.localIp());
PayConfig.setHttpsRequestClassName("com.coolfish.weixin.pay.common.HttpsRequest");
RedPackQueryReqData redPackQueryReqData = new RedPackQueryReqData(mch_billno);
WXPay.doRedPackQueryBusiness(redPackQueryReqData, new RedPackQueryListener() {
@Override
public void onXmlError(RedPackResData payResData) {
// TODO Auto-generated method stub
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
@Override
public void onSystemError(RedPackResData payResData) {
// TODO Auto-generated method stub
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
@Override
public void onSignError(RedPackResData payResData) {
// TODO Auto-generated method stub
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
@Override
public void onParamError(RedPackResData payResData) {
// TODO Auto-generated method stub
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
@Override
public void onNoAuth(RedPackResData payResData) {
// TODO Auto-generated method stub
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
@Override
public void onFreqLimit(RedPackResData payResData) {
// TODO Auto-generated method stub
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
@Override
public void onCaError(RedPackResData payResData) {
// TODO Auto-generated method stub
rprd.setErr_code(payResData.getErr_code());
rprd.setErr_code_des(payResData.getErr_code_des());
rprd.setResult_code(payResData.getResult_code());
rprd.setReturn_code(payResData.getReturn_code());
rprd.setReturn_msg(payResData.getReturn_msg());
}
@Override
public void onSuccess(RedPackQueryResData resData) {
// TODO Auto-generated method stub
rprd.setErr_code(resData.getErr_code());
rprd.setErr_code_des(resData.getErr_code_des());
rprd.setResult_code(resData.getResult_code());
rprd.setReturn_code(resData.getReturn_code());
rprd.setReturn_msg(resData.getReturn_msg());
rprd.setStatus(resData.getStatus());
rprd.setReason(resData.getReason());
rprd.setRefund_time(resData.getRefund_time());
}
@Override
public void onOtherError(RedPackQueryResData resData) {
// TODO Auto-generated method stub
rprd.setErr_code(resData.getErr_code());
rprd.setErr_code_des(resData.getErr_code_des());
rprd.setResult_code(resData.getResult_code());
rprd.setReturn_code(resData.getReturn_code());
rprd.setReturn_msg(resData.getReturn_msg());
rprd.setStatus(resData.getStatus());
rprd.setReason(resData.getReason());
rprd.setRefund_time(resData.getRefund_time());
}
@Override
public void onNotFound(RedPackQueryResData resData) {
// TODO Auto-generated method stub
rprd.setErr_code(resData.getErr_code());
rprd.setErr_code_des(resData.getErr_code_des());
rprd.setResult_code(resData.getResult_code());
rprd.setReturn_code(resData.getReturn_code());
rprd.setReturn_msg(resData.getReturn_msg());
rprd.setStatus(resData.getStatus());
rprd.setReason(resData.getReason());
rprd.setRefund_time(resData.getRefund_time());
}
});
return rprd;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Aggregations