| | |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.properties.XcxProperties; |
| | | import cc.mrbird.febs.common.utils.SpringContextHolder; |
| | | import cc.mrbird.febs.pay.model.BrandWCPayRequestData; |
| | | import cc.mrbird.febs.pay.model.JsApiPayBusiness; |
| | | import cc.mrbird.febs.pay.model.JsApiPayReqData; |
| | | import cc.mrbird.febs.pay.model.JsApiPayResData; |
| | | import cc.mrbird.febs.pay.model.*; |
| | | import cc.mrbird.febs.pay.service.impl.RefundService; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness(); |
| | | String idAddr = getIpAddr(WebUtil.getRequest()); |
| | | |
| | | String mchID = WechatConfigure.WECHARPAY_MCHID; |
| | | String paySecret = WechatConfigure.WECHARPAY_SECRET; |
| | | String appId = WechatConfigure.MINIPROGRAM_APPID; |
| | | String mchID = xcxProperties.getWecharpayMchid(); |
| | | String paySecret = xcxProperties.getWecharpaySecret(); |
| | | String appId = xcxProperties.getXcxAppid(); |
| | | |
| | | JsApiPayReqData jsApiPayReqData = new JsApiPayReqData( |
| | | appId, mchID, paySecret, notifyUrl, desc, |
| | |
| | | * @param opUserID 操作员id,默认为商户号 |
| | | * @return |
| | | */ |
| | | // public boolean comRefund(String outTradeNo, String outRefundNo,int totalFee, |
| | | // int refundFee, String opUserID){ |
| | | // LogUtil.info("#---outTradeNo:{}#---outRefundNo:{}#---totalFee:{}#---refundFee:{}", |
| | | // outTradeNo,outRefundNo,totalFee,refundFee); |
| | | // BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_MCHID, HostInterceptor.getCompanyId()); |
| | | // if(opUserID==null){ |
| | | // opUserID=mchID.getParamValue(); |
| | | // } |
| | | // RefundResData result=null; |
| | | // boolean flag=false; |
| | | // try { |
| | | // JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness(); |
| | | // Long companyId=HostInterceptor.getCompanyId(); |
| | | // BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId); |
| | | // BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId); |
| | | // BusParameterSettings certLocalPath = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_CERTLOCAL_PATH, companyId); |
| | | // |
| | | // RefundReqData refundReqData=new RefundReqData(mchID.getParamValue(),appId.getParamValue(),paySecret.getParamValue(), outTradeNo, outRefundNo, totalFee, refundFee,opUserID); |
| | | // RefundService refundService=new RefundService(); |
| | | // HttpsRequest2 request2= (HttpsRequest2) refundService.getServiceRequest(); |
| | | // request2.setCertLocalPath(certLocalPath.getParamValue()); |
| | | // request2.setMchId(mchID.getParamValue()); |
| | | // |
| | | // result = jsApiPayBusiness.refundComOrder(refundService, refundReqData); |
| | | // LogUtil.info("#退款,企业付款到个人---result:{}",result); |
| | | // //如果返回余额不足时 |
| | | // if (StringUtils.equals(AppConstance.REFUND_FAIL_NOTENOUGH, result.getErr_code())) { |
| | | // LogUtil.info("#退款失败,{}!", "商户余额不足"); |
| | | // throw new GlobleException("退款失败,请联系管理员!"); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // LogUtil.error("#企业付款到个人异常#退款#outTradeNo:{}#opUserID:{}", e, outTradeNo,opUserID); |
| | | // } |
| | | // |
| | | // if (result.getResult_code().equals(WechatConfigure.SUCCESS)) { |
| | | // flag=true; |
| | | // }else{ |
| | | // flag=false; |
| | | // throw new GlobleException(result.getErr_code_des()); |
| | | // } |
| | | // return flag; |
| | | // } |
| | | public boolean comRefund(String outTradeNo, String outRefundNo,int totalFee, |
| | | int refundFee, String opUserID){ |
| | | log.info("#---outTradeNo:{}#---outRefundNo:{}#---totalFee:{}#---refundFee:{}", |
| | | outTradeNo,outRefundNo,totalFee,refundFee); |
| | | |
| | | String mchID = xcxProperties.getWecharpayMchid(); |
| | | if(opUserID==null){ |
| | | opUserID=mchID; |
| | | } |
| | | RefundResData result=null; |
| | | boolean flag=false; |
| | | try { |
| | | JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness(); |
| | | String paySecret = xcxProperties.getWecharpaySecret(); |
| | | String appId = xcxProperties.getXcxAppid(); |
| | | String certLocalPath = xcxProperties.getCertLocalPath(); |
| | | |
| | | RefundReqData refundReqData=new RefundReqData(mchID,appId,paySecret, outTradeNo, outRefundNo, totalFee, refundFee,opUserID); |
| | | RefundService refundService=new RefundService(); |
| | | HttpsRequest2 request2= (HttpsRequest2) refundService.getServiceRequest(); |
| | | request2.setCertLocalPath(certLocalPath); |
| | | request2.setMchId(mchID); |
| | | |
| | | result = jsApiPayBusiness.refundComOrder(refundService, refundReqData); |
| | | log.info("#退款,企业付款到个人---result:{}",result); |
| | | //如果返回余额不足时,商户余额不足时微信返回状态码(退款失败时) |
| | | if (StrUtil.equals("NOTENOUGH", result.getErr_code())) { |
| | | log.info("#退款失败,{}!", "商户余额不足"); |
| | | flag=false; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("#企业付款到个人异常#退款#outTradeNo:{}#opUserID:{}", e, outTradeNo,opUserID); |
| | | flag=false; |
| | | } |
| | | |
| | | if (result.getResult_code().equals("SUCCESS")) { |
| | | flag=true; |
| | | }else{ |
| | | flag=false; |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /**@Description 支付获取远程设备的ip |
| | | @date 2017年6月27日 |