|
@ -0,0 +1,217 @@
|
|
|
/*
|
|
|
package com.yihu.jw.Pay;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.yihu.wlyy.entity.health.ShopPayLog;
|
|
|
import com.yihu.wlyy.repository.dict.SystemDictDao;
|
|
|
import com.yihu.wlyy.repository.health.ShopPayLogDao;
|
|
|
import com.ylzinfo.onepay.sdk.HisOnepayClient;
|
|
|
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
|
|
|
import com.ylzinfo.onepay.sdk.domain.ext.*;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.PrintWriter;
|
|
|
import java.io.StringWriter;
|
|
|
import java.util.Map;
|
|
|
|
|
|
*/
|
|
|
/**
|
|
|
* Created by wangzhinan on 2020/1/13.
|
|
|
*//*
|
|
|
|
|
|
@Service
|
|
|
public class OnePayShopService {
|
|
|
@Autowired
|
|
|
private PayLogService logService;
|
|
|
@Value("${onepay1.onepay_url}")
|
|
|
private String onepayUrl;
|
|
|
@Value("${onepay1.appId}")
|
|
|
private String appId;
|
|
|
@Value("${onepay1.appSecret}")
|
|
|
private String appSecret;
|
|
|
@Value("${wlyy.url}")
|
|
|
private String wlyyUrl;
|
|
|
@Autowired
|
|
|
private SystemDictDao systemDictDao;
|
|
|
@Autowired
|
|
|
private ShopPayLogDao shopPayLogDao;
|
|
|
*/
|
|
|
/**
|
|
|
* 支付
|
|
|
*
|
|
|
* @param operatorId 操作员编码
|
|
|
* @param operatorName 操作员姓名
|
|
|
* @param cardType 卡类型
|
|
|
* @param accountType 账户类型
|
|
|
* @param cardNo 卡号
|
|
|
* @param idNo 身份证号
|
|
|
* @param depositType 充值方式 WX_PUB
|
|
|
* @param amount 充值金额
|
|
|
* @param outChargeNo 商户充值业务流水号
|
|
|
* @param userName 用户姓名
|
|
|
* @param openId 微信公共号支付需入参openId
|
|
|
* @return
|
|
|
*//*
|
|
|
|
|
|
public String recharge(String operatorId,String operatorName,String cardType,String accountType,String cardNo,String idNo,String depositType,String amount,String outChargeNo,String openId,String userName){
|
|
|
Boolean isSuccess = true;
|
|
|
String jsonObject = null;
|
|
|
RechargeParams param = new RechargeParams();
|
|
|
String error = null;
|
|
|
try {
|
|
|
HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret,"MD5","AES");
|
|
|
param.setOperatorId(operatorId);
|
|
|
param.setOperatorName(operatorName);
|
|
|
param.setCardType(cardType);
|
|
|
param.setAccountType(accountType);
|
|
|
param.setCardNo(cardNo);
|
|
|
param.setIdNo(idNo);
|
|
|
param.setDepositType(depositType);
|
|
|
param.setAmount(amount);
|
|
|
param.setOutChargeNo(outChargeNo);
|
|
|
param.setUserName(userName);
|
|
|
Map<String, String> extra = new HashedMap();
|
|
|
extra.put("openId",openId);
|
|
|
*/
|
|
|
/* String value = systemDictDao.findByDictNameAndCode("RETURN_URL","RETURN_URL");
|
|
|
extra.put("returnUrl",value);*//*
|
|
|
|
|
|
extra.put("notifyUrl", wlyyUrl+"/third/order/receiveNotify");
|
|
|
param.setExtra(extra);
|
|
|
ResponseParams<RechargeResult> respnse = onepayClient.recharge(param);
|
|
|
if (respnse.getRespCode().equals("000000")){
|
|
|
jsonObject = JSON.toJSONString(respnse);
|
|
|
}else {
|
|
|
isSuccess = false;
|
|
|
jsonObject = JSON.toJSONString(respnse);
|
|
|
error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
|
|
|
}
|
|
|
if (respnse!=null){
|
|
|
ShopPayLog payLog =shopPayLogDao.selectByCode(respnse.getParam().getOutChargeNo());
|
|
|
payLog.setTradeNo(respnse.getParam().getTraceNo());
|
|
|
shopPayLogDao.save(payLog);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
isSuccess = false;
|
|
|
StringWriter sw = new StringWriter();
|
|
|
PrintWriter pw = new PrintWriter(sw);
|
|
|
e.printStackTrace(pw);
|
|
|
error = sw.toString();
|
|
|
}
|
|
|
|
|
|
logService.saveHttpLog(isSuccess, "hop.trade.recharge", "商城充值", "POST", null,JSON.toJSONString(param), jsonObject, error,logService.shoppatType);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
*/
|
|
|
/**
|
|
|
*
|
|
|
* 退款
|
|
|
*
|
|
|
* @param operatorId 操作者id
|
|
|
* @param operatorName 操作者名字
|
|
|
* @param cardType 卡类型
|
|
|
* @param accountType 账号类型
|
|
|
* @param cardNo 卡号
|
|
|
* @param idNo 身份证号
|
|
|
* @param amount 退款金额
|
|
|
* @param outChargeNo 原充值订单号
|
|
|
* @param userName 用户名字
|
|
|
* @param withdrawMode 退款方式 0 现金退回1 原路退回2 银企转账3 医保自费退回
|
|
|
* @param traceNo 平台交易跟踪号
|
|
|
* @param outRefundNo 退款订单号
|
|
|
* @return
|
|
|
*//*
|
|
|
|
|
|
public String refund(String operatorId,String operatorName,String cardType,String accountType,String cardNo,String idNo,String amount,String outChargeNo,String userName,String withdrawMode,String traceNo,String outRefundNo,String hisCustId){
|
|
|
Boolean isSuccess = true;
|
|
|
String jsonObject = null;
|
|
|
RefundParams param = new RefundParams();
|
|
|
String error = null;
|
|
|
try {
|
|
|
ShopPayLog shopPayLog = shopPayLogDao.selectByCode(outChargeNo);
|
|
|
HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret,"MD5","AES");
|
|
|
param.setOperatorId(operatorId);
|
|
|
param.setOperatorName(operatorName);
|
|
|
param.setOutChargeNo(outChargeNo);
|
|
|
param.setCardType(cardType);
|
|
|
param.setCardNo(cardNo);
|
|
|
param.setAccountType(accountType);
|
|
|
param.setAmount(amount);
|
|
|
param.setWithdrawMode(withdrawMode);
|
|
|
param.setOutChargeNo(outChargeNo);
|
|
|
param.setTraceNo(shopPayLog.getTradeNo());
|
|
|
param.setOutRefundNo(outRefundNo);
|
|
|
param.setHisCustId(hisCustId);
|
|
|
param.setIdNo(idNo);
|
|
|
param.setUserName(userName);
|
|
|
ResponseParams<RefundResult> respnse = onepayClient.refund(param);
|
|
|
if (respnse.getRespCode().equals("000000")){
|
|
|
jsonObject = JSON.toJSONString(respnse);
|
|
|
shopPayLog.setOutRefundNo(respnse.getParam().getOutRefundNo());
|
|
|
shopPayLog.setRefundNo(respnse.getParam().getOutRefundNo());
|
|
|
shopPayLog.setRefundAmount(amount);
|
|
|
shopPayLogDao.save(shopPayLog);
|
|
|
}else {
|
|
|
jsonObject = JSON.toJSONString(respnse);
|
|
|
isSuccess = false;
|
|
|
error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
isSuccess = false;
|
|
|
StringWriter sw = new StringWriter();
|
|
|
PrintWriter pw = new PrintWriter(sw);
|
|
|
e.printStackTrace(pw);
|
|
|
error = sw.toString();
|
|
|
}
|
|
|
logService.saveHttpLog(isSuccess, "hop.trade.refund", "商城退款", "POST", null,JSON.toJSONString(param), jsonObject, error, logService.shoppatType);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
|
|
|
*/
|
|
|
/**
|
|
|
* 查询余额
|
|
|
*
|
|
|
* @param operatorId
|
|
|
* @param operatorName
|
|
|
* @param termNo
|
|
|
* @param tradeType
|
|
|
* @param outTradeNo
|
|
|
* @param traceNo
|
|
|
* @return
|
|
|
*//*
|
|
|
|
|
|
public String tradeQuery(String operatorId,String operatorName,String termNo,String tradeType,String outTradeNo,String traceNo){
|
|
|
Boolean isSuccess = true;
|
|
|
String jsonObject = null;
|
|
|
TradeQueryParams param = new TradeQueryParams();
|
|
|
String error = null;
|
|
|
try {
|
|
|
HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret,"MD5","AES");
|
|
|
param.setOperatorId(operatorId);
|
|
|
param.setOperatorName(operatorName);
|
|
|
param.setTradeType(tradeType);
|
|
|
param.setOutTradeNo(outTradeNo);
|
|
|
param.setTraceNo(traceNo);
|
|
|
ResponseParams<TradeQueryResult> respnse = onepayClient.tradeQuery(param);
|
|
|
if (respnse.getRespCode().equals("000000")){
|
|
|
jsonObject = JSON.toJSONString(respnse);
|
|
|
}else {
|
|
|
isSuccess = false;
|
|
|
jsonObject = JSON.toJSONString(respnse);
|
|
|
error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
isSuccess = false;
|
|
|
StringWriter sw = new StringWriter();
|
|
|
PrintWriter pw = new PrintWriter(sw);
|
|
|
e.printStackTrace(pw);
|
|
|
error = sw.toString();
|
|
|
}
|
|
|
logService.saveHttpLog(isSuccess, "hop.trade.query", "商城充值查询", "POST", null,JSON.toJSONString(param), jsonObject, error,logService.shoppatType);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
}*/
|