Commit c0f1f14e authored by jiaorz's avatar jiaorz

修改冲突

parent 73e7d1b2
......@@ -12,17 +12,23 @@ import com.alipay.api.request.*;
import com.alipay.api.response.*;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.HTTPSUtils;
import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.UUIDUtils;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.constant.PayWay;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.OrderPay;
import com.xxfc.platform.universal.mapper.OrderPayMapper;
import com.xxfc.platform.universal.utils.SignUtils;
import com.xxfc.platform.universal.vo.FundPayVo;
import com.xxfc.platform.universal.vo.OrderPayVo;
import com.xxfc.platform.universal.weixin.api.WXPay;
import com.xxfc.platform.universal.weixin.api.*;
import com.xxfc.platform.universal.constant.WxResponseProperties;
import com.xxfc.platform.universal.weixin.util.HTTPUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
......@@ -34,10 +40,7 @@ import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.xxfc.platform.universal.constant.DictionaryKey.PAY_DEMOTION;
import static com.xxfc.platform.universal.constant.DictionaryKey.UNIVERSAL_PAY;
......@@ -51,7 +54,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.UNIVERSAL_PAY;
*/
@Service
@Slf4j
public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay>{
@Autowired
DictionaryBiz dictionaryBiz;
......@@ -68,6 +71,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
@Value("${wx.appSercet}")
private String wy_secret;
private static final String SUCCESS = "SUCCESS";
public JSONObject preparepay(OrderPayVo orderPayVo) {
......@@ -107,16 +111,16 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
String sellerAccount = null;
if (type == 2 && payWay == 1) {
sellerAccount = SystemConfig.APP_PARTNER;
jsParam = WXPay.webPay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount(),null);
jsParam = WXPay.webPay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount(), null);
} else if (type == 1 && payWay == 1) {
sellerAccount = SystemConfig.APP_PARTNER;
jsParam = WXPay.apppay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), 0);
} else if (type == 1 && payWay == 2) {
sellerAccount = SystemConfig.ALIPAY_PID;
jsParam = generateAliPayment(orderPayVo, notifyUrl);
}else if (type == 3 && payWay == 1){
} else if (type == 3 && payWay == 1) {
sellerAccount = SystemConfig.APP_PARTNER;
jsParam = WXPay.webPay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount(),wy_appid);
jsParam = WXPay.webPay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount(), wy_appid);
}
log.info("报名费回调路径jsParam:" + jsParam);
if (!StringUtils.isBlank(jsParam)) {
......@@ -302,6 +306,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
"utf-8", SystemConfig.ALIPAY_PUBLIC_KEY, AlipayConstants.SIGN_TYPE_RSA2);
return alipayClient;
}
//balance 余额
//moneyFund 余额宝
//coupon 红包
......@@ -370,6 +375,142 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
}
}
/**
* 转账功能 微信 | 支付宝
*
* @param fundPayVo
* @return
* @throws Exception
*/
public String fundTrans(FundPayVo fundPayVo) throws BaseException {
String cono = OrderUtil.GetOrderNumber("");
fundPayVo.setOutBizNo(cono);
if (fundPayVo.getType() == PayWay.WX_PAY.getCode()) {
//微信
fundPayVo.setCheckName("NO_CHECK");
return wxpayfundTrans(fundPayVo);
}
if (fundPayVo.getType() == PayWay.ALI_PAY.getCode()) {
//支付宝
return alipayfundTrans(getAlipayClient(), fundPayVo);
}
throw new BaseException("提现方式不对");
}
/**
* 支付宝转账功能 单笔最小转账0.1 最大小数点位数前支持13位,实际限额和签约一致
*
* @param alipayClient
* @throws AlipayApiException
*/
public String alipayfundTrans(AlipayClient alipayClient, FundPayVo fundPayVo){
AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest();
request.setBizContent("{" +
"\"out_biz_no\":\"" + fundPayVo.getOutBizNo() + "\"," +
"\"payee_type\":\"ALIPAY_USERID\"," +
"\"payee_account\":\"" + fundPayVo.getPayeeAccount() + "\"," +
"\"amount\":\"" + fundPayVo.getAmount() + "\"," +
"\"payer_show_name\":\"" + fundPayVo.getPayerShowName() + "\"," +
"\"remark\":\"" + fundPayVo.getRemark() + "\"" +
" }");
AlipayFundTransToaccountTransferResponse response = null;
try {
response = alipayClient.execute(request);
} catch (AlipayApiException e) {
throw new BaseException("支付宝转账api调用错误",e);
}
if (response.isSuccess()) {
return fundPayVo.getOutBizNo();
} else {
throw new BaseException(response.getSubMsg(),response.getSubCode());
}
}
public String wxpayfundTrans(FundPayVo fundPayVo) {
Map<String, String> map = WXSuppToUserPay.WeiXinTiXian(fundPayVo.getAmount(),fundPayVo.getOutBizNo(),fundPayVo.getCheckName(), fundPayVo.getAmount(), fundPayVo.getRemark(), fundPayVo.getCreatIp());
if (SUCCESS.equals(map.get(WxResponseProperties.RETURN_CODE)) && SUCCESS.equals(map.get(WxResponseProperties.RESULT_CODE))) {
return map.get(WxResponseProperties.PARTNER_TRADE_NO);
}
throw new BaseException(map.get(WxResponseProperties.ERR_CODE_DES),map.get(WxResponseProperties.ERROR_CODE));
}
/**
* 支付宝授权获取用户信息
* @param code
* @return
* @throws AlipayApiException
*/
public String getAlipayToken(String code) throws AlipayApiException{
AlipayClient alipayClient = getAlipayClient();
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setGrantType("authorization_code");
request.setCode(code);
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
if(response.isSuccess()){
log.info("获取用户token调用成功,获取用户信息 {}", response.getBody());
if(response.getAccessToken() != null) {
AlipayUserInfoShareRequest alipayUserInfoShareRequest = new AlipayUserInfoShareRequest();
AlipayUserInfoShareResponse alipayUserInfoShareResponse = alipayClient.execute(alipayUserInfoShareRequest,response.getAccessToken());
if(alipayUserInfoShareResponse.isSuccess()){
log.info("获取用户支付宝信息调用成功, {}", alipayUserInfoShareResponse.getBody());
return alipayUserInfoShareResponse.getBody();
} else {
log.info("获取用户支付宝信息调用失败, {}", alipayUserInfoShareResponse.getBody());
}
}
} else {
log.info("获取用户token调用失败, {}", response.getBody());
}
return response.getBody();
}
public String generateAliPayInfo(String apiName, String appName) {
//apiname=com.alipay.account.auth&app_id=xxxxx&app_name=mc&auth_type=AUTHACCOUNT&biz_type=openservice&method=alipay.open.auth.sdk.code.get&pid=xxxxx&product_id=APP_FAST_LOGIN&scope=kuaijie&sign_type=RSA2&target_id=20141225xxxx&sign=fMcp4GtiM6rxSIeFnJCVePJKV43eXrUP86CQgiLhDHH2u%2FdN75eEvmywc2ulkm7qKRetkU9fbVZtJIqFdMJcJ9Yp%2BJI%2FF%2FpESafFR6rB2fRjiQQLGXvxmDGVMjPSxHxVtIqpZy5FDoKUSjQ2%2FILDKpu3%2F%2BtAtm2jRw1rUoMhgt0%3D
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("apiname=");
stringBuilder.append(apiName);
stringBuilder.append("&app_id=");
stringBuilder.append(SystemConfig.ALIPAY_APPID);
stringBuilder.append("&app_name=");
stringBuilder.append(appName);
stringBuilder.append("&auth_type=AUTHACCOUNT");
stringBuilder.append("&biz_type=openservice");
stringBuilder.append("&method=alipay.open.auth.sdk.code.get");
stringBuilder.append("&pid=");
stringBuilder.append(SystemConfig.ALIPAY_PID);
stringBuilder.append("&product_id=APP_FAST_LOGIN");
stringBuilder.append("&scope=kuaijie");
stringBuilder.append("&sign_type=RSA2");
stringBuilder.append("&target_id=");
stringBuilder.append(UUIDUtils.generateShortUuid());
String sign = SignUtils.sign(stringBuilder.toString(), SystemConfig.ALIPAY_PRIVATE_KEY, true);
stringBuilder.append("&sign=");
stringBuilder.append(sign);
return stringBuilder.toString();
}
public String alipayUserAuth() throws AlipayApiException {
AlipayClient alipayClient = getAlipayClient();
AlipayUserInfoAuthRequest request = new AlipayUserInfoAuthRequest();
request.setBizContent("{" +
" \"scopes\":[" +
" \"auth_base\"" +
" ]," +
"\"state\":\"init\"," +
"\"is_mobile\":\"true\"" +
" }");
AlipayUserInfoAuthResponse response = alipayClient.execute(request);
if(response.isSuccess()){
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
return response.getBody();
}
//解冻预授权
public void fundAuthOrderUnFreeze(AlipayClient alipayClient) throws AlipayApiException {
AlipayFundAuthOrderUnfreezeRequest request = new AlipayFundAuthOrderUnfreezeRequest();
......@@ -456,7 +597,8 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
* outRequestNo 退款请求标示 用于分批退款,每笔退款标示不一样,同样标示不会重复退款
* @return
*/
public boolean alipayOrderRefund(String outTradeNo, String tradNo, Integer refundAmount, String refundReason, String outRequestNo) {
public boolean alipayOrderRefund(String outTradeNo, String tradNo, Integer refundAmount, String
refundReason, String outRequestNo) {
AlipayClient alipayClient = getAlipayClient();
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
BigDecimal realAmount = new BigDecimal(refundAmount.toString()).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_UP);
......@@ -464,7 +606,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
"\"out_trade_no\":\"" + outTradeNo + "\"," +
"\"trade_no\":\"" + tradNo + "\"," +
"\"refund_amount\":" + realAmount + "," +
"\"refund_reason\":\""+ refundReason + "\"," +
"\"refund_reason\":\"" + refundReason + "\"," +
"\"out_request_no\":\"" + outRequestNo + "\"" +
" }");
try {
......@@ -485,6 +627,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
public static void main(String[] args) {
OrderPayBiz orderPayBiz = new OrderPayBiz();
orderPayBiz.alipayOrderRefund("20190806134440000001","2019080622001421530542309594", 3, "xxxx", "");
FundPayVo fundPayVo = new FundPayVo();
fundPayVo.setRemark("转账");
fundPayVo.setOutBizNo("12345678");
fundPayVo.setAmount("0.1");
fundPayVo.setPayeeAccount("2088212169302286");
AlipayClient alipayClient = orderPayBiz.getAlipayClient();
System.out.println(orderPayBiz.alipayfundTrans(alipayClient, fundPayVo));
}
}
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