| | |
| | | private String name; |
| | | private String paymentType; |
| | | |
| | | private String beanRefund; |
| | | |
| | | |
| | | private Date createTime; |
| | | |
| | |
| | | public void setStatusCd(String statusCd) { |
| | | this.statusCd = statusCd; |
| | | } |
| | | |
| | | public String getBeanRefund() { |
| | | return beanRefund; |
| | | } |
| | | |
| | | public void setBeanRefund(String beanRefund) { |
| | | this.beanRefund = beanRefund; |
| | | } |
| | | } |
| | |
| | | private String beanJsapi; |
| | | private String beanQrcode; |
| | | private String beanNative; |
| | | |
| | | private String beanRefund; |
| | | private List<PaymentPoolValueDto> values; |
| | | |
| | | private List<PaymentPoolConfigDto> configs; |
| | |
| | | public void setBeanNative(String beanNative) { |
| | | this.beanNative = beanNative; |
| | | } |
| | | |
| | | public String getBeanRefund() { |
| | | return beanRefund; |
| | | } |
| | | |
| | | public void setBeanRefund(String beanRefund) { |
| | | this.beanRefund = beanRefund; |
| | | } |
| | | } |
| | |
| | | private String payName; |
| | | private String transactionId; |
| | | |
| | | private String paymentPoolId; |
| | | |
| | | |
| | | private Date createTime; |
| | | |
| | |
| | | public void setStatusCd(String statusCd) { |
| | | this.statusCd = statusCd; |
| | | } |
| | | |
| | | public String getPaymentPoolId() { |
| | | return paymentPoolId; |
| | | } |
| | | |
| | | public void setPaymentPoolId(String paymentPoolId) { |
| | | this.paymentPoolId = paymentPoolId; |
| | | } |
| | | } |
| | |
| | | return JSONObject.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteDateUseDateFormat); |
| | | } |
| | | |
| | | public static ResultVo ok(){ |
| | | return new ResultVo(ResultVo.CODE_OK,ResultVo.MSG_OK); |
| | | } |
| | | |
| | | /** |
| | | * 创建ResponseEntity对象 |
| | |
| | | <mapper namespace="paymentAdaptV1ServiceDaoImpl"> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 保存支付厂家信息 add by wuxw 2018-07-03 --> |
| | | <insert id="savePaymentAdaptInfo" parameterType="Map"> |
| | | insert into payment_adapt( |
| | | adapt_id,bean_jsapi,bean_qrcode,bean_native,name,payment_type |
| | | ) values ( |
| | | #{adaptId},#{beanJsapi},#{beanQrcode},#{beanNative},#{name},#{paymentType} |
| | | ) |
| | | adapt_id,bean_jsapi,bean_qrcode,bean_native,name,payment_type,bean_refund |
| | | ) values ( |
| | | #{adaptId},#{beanJsapi},#{beanQrcode},#{beanNative},#{name},#{paymentType},#{beanRefund} |
| | | ) |
| | | </insert> |
| | | |
| | | |
| | | |
| | | <!-- 查询支付厂家信息 add by wuxw 2018-07-03 --> |
| | | <select id="getPaymentAdaptInfo" parameterType="Map" resultType="Map"> |
| | | select t.adapt_id,t.adapt_id adaptId,t.bean_jsapi,t.bean_jsapi beanJsapi,t.bean_qrcode,t.bean_qrcode beanQrcode,t.bean_native,t.bean_native beanNative,t.name,t.status_cd,t.status_cd statusCd,t.payment_type,t.payment_type paymentType |
| | | from payment_adapt t |
| | | where 1 =1 |
| | | <if test="adaptId !=null and adaptId != ''"> |
| | | and t.adapt_id= #{adaptId} |
| | | </if> |
| | | <if test="beanJsapi !=null and beanJsapi != ''"> |
| | | and t.bean_jsapi= #{beanJsapi} |
| | | </if> |
| | | <if test="beanQrcode !=null and beanQrcode != ''"> |
| | | and t.bean_qrcode= #{beanQrcode} |
| | | </if> |
| | | <if test="beanNative !=null and beanNative != ''"> |
| | | and t.bean_native= #{beanNative} |
| | | </if> |
| | | <if test="name !=null and name != ''"> |
| | | and t.name= #{name} |
| | | </if> |
| | | <if test="statusCd !=null and statusCd != ''"> |
| | | and t.status_cd= #{statusCd} |
| | | </if> |
| | | <if test="paymentType !=null and paymentType != ''"> |
| | | and t.payment_type= #{paymentType} |
| | | </if> |
| | | order by t.create_time desc |
| | | <if test="page != -1 and page != null "> |
| | | limit #{page}, #{row} |
| | | </if> |
| | | select t.adapt_id,t.adapt_id adaptId,t.bean_jsapi,t.bean_jsapi beanJsapi,t.bean_qrcode,t.bean_qrcode |
| | | beanQrcode,t.bean_native,t.bean_native beanNative,t.name,t.status_cd,t.status_cd |
| | | statusCd,t.payment_type,t.payment_type paymentType,t.bean_refund beanRefund |
| | | from payment_adapt t |
| | | where 1 =1 |
| | | <if test="adaptId !=null and adaptId != ''"> |
| | | and t.adapt_id= #{adaptId} |
| | | </if> |
| | | <if test="beanJsapi !=null and beanJsapi != ''"> |
| | | and t.bean_jsapi= #{beanJsapi} |
| | | </if> |
| | | <if test="beanQrcode !=null and beanQrcode != ''"> |
| | | and t.bean_qrcode= #{beanQrcode} |
| | | </if> |
| | | <if test="beanNative !=null and beanNative != ''"> |
| | | and t.bean_native= #{beanNative} |
| | | </if> |
| | | <if test="name !=null and name != ''"> |
| | | and t.name= #{name} |
| | | </if> |
| | | <if test="statusCd !=null and statusCd != ''"> |
| | | and t.status_cd= #{statusCd} |
| | | </if> |
| | | <if test="paymentType !=null and paymentType != ''"> |
| | | and t.payment_type= #{paymentType} |
| | | </if> |
| | | order by t.create_time desc |
| | | <if test="page != -1 and page != null "> |
| | | limit #{page}, #{row} |
| | | </if> |
| | | |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 修改支付厂家信息 add by wuxw 2018-07-03 --> |
| | | <update id="updatePaymentAdaptInfo" parameterType="Map"> |
| | | update payment_adapt t set t.status_cd = #{statusCd} |
| | | <if test="newBId != null and newBId != ''"> |
| | | ,t.b_id = #{newBId} |
| | | </if> |
| | | <if test="beanJsapi !=null and beanJsapi != ''"> |
| | | , t.bean_jsapi= #{beanJsapi} |
| | | </if> |
| | | <if test="beanQrcode !=null and beanQrcode != ''"> |
| | | , t.bean_qrcode= #{beanQrcode} |
| | | </if> |
| | | <if test="beanNative !=null and beanNative != ''"> |
| | | , t.bean_native= #{beanNative} |
| | | </if> |
| | | <if test="name !=null and name != ''"> |
| | | , t.name= #{name} |
| | | </if> |
| | | <if test="paymentType !=null and paymentType != ''"> |
| | | , t.payment_type= #{paymentType} |
| | | </if> |
| | | where 1=1 <if test="adaptId !=null and adaptId != ''"> |
| | | and t.adapt_id= #{adaptId} |
| | | </if> |
| | | update payment_adapt t set t.status_cd = #{statusCd} |
| | | <if test="newBId != null and newBId != ''"> |
| | | ,t.b_id = #{newBId} |
| | | </if> |
| | | <if test="beanJsapi !=null and beanJsapi != ''"> |
| | | , t.bean_jsapi= #{beanJsapi} |
| | | </if> |
| | | <if test="beanQrcode !=null and beanQrcode != ''"> |
| | | , t.bean_qrcode= #{beanQrcode} |
| | | </if> |
| | | <if test="beanNative !=null and beanNative != ''"> |
| | | , t.bean_native= #{beanNative} |
| | | </if> |
| | | <if test="beanNative !=null and beanNative != ''"> |
| | | , t.bean_refund= #{beanRefund} |
| | | </if> |
| | | <if test="name !=null and name != ''"> |
| | | , t.name= #{name} |
| | | </if> |
| | | <if test="paymentType !=null and paymentType != ''"> |
| | | , t.payment_type= #{paymentType} |
| | | </if> |
| | | where 1=1 |
| | | <if test="adaptId !=null and adaptId != ''"> |
| | | and t.adapt_id= #{adaptId} |
| | | </if> |
| | | |
| | | </update> |
| | | |
| | | <!-- 查询支付厂家数量 add by wuxw 2018-07-03 --> |
| | | <select id="queryPaymentAdaptsCount" parameterType="Map" resultType="Map"> |
| | | select count(1) count |
| | | from payment_adapt t |
| | | where 1 =1 |
| | | <if test="adaptId !=null and adaptId != ''"> |
| | | and t.adapt_id= #{adaptId} |
| | | </if> |
| | | <if test="beanJsapi !=null and beanJsapi != ''"> |
| | | and t.bean_jsapi= #{beanJsapi} |
| | | </if> |
| | | <if test="beanQrcode !=null and beanQrcode != ''"> |
| | | and t.bean_qrcode= #{beanQrcode} |
| | | </if> |
| | | <if test="beanNative !=null and beanNative != ''"> |
| | | and t.bean_native= #{beanNative} |
| | | </if> |
| | | <if test="name !=null and name != ''"> |
| | | and t.name= #{name} |
| | | </if> |
| | | <if test="statusCd !=null and statusCd != ''"> |
| | | and t.status_cd= #{statusCd} |
| | | </if> |
| | | <if test="paymentType !=null and paymentType != ''"> |
| | | and t.payment_type= #{paymentType} |
| | | </if> |
| | | <select id="queryPaymentAdaptsCount" parameterType="Map" resultType="Map"> |
| | | select count(1) count |
| | | from payment_adapt t |
| | | where 1 =1 |
| | | <if test="adaptId !=null and adaptId != ''"> |
| | | and t.adapt_id= #{adaptId} |
| | | </if> |
| | | <if test="beanJsapi !=null and beanJsapi != ''"> |
| | | and t.bean_jsapi= #{beanJsapi} |
| | | </if> |
| | | <if test="beanQrcode !=null and beanQrcode != ''"> |
| | | and t.bean_qrcode= #{beanQrcode} |
| | | </if> |
| | | <if test="beanNative !=null and beanNative != ''"> |
| | | and t.bean_native= #{beanNative} |
| | | </if> |
| | | <if test="name !=null and name != ''"> |
| | | and t.name= #{name} |
| | | </if> |
| | | <if test="statusCd !=null and statusCd != ''"> |
| | | and t.status_cd= #{statusCd} |
| | | </if> |
| | | <if test="paymentType !=null and paymentType != ''"> |
| | | and t.payment_type= #{paymentType} |
| | | </if> |
| | | |
| | | |
| | | </select> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | select t.cert_path,t.cert_path certPath,t.status_cd,t.status_cd |
| | | statusCd,t.remark,t.state,t.community_id,t.community_id communityId,t.payment_name,t.payment_name |
| | | paymentName,t.pp_id,t.pp_id ppId,t.payment_type,t.payment_type paymentType,t.create_time createTime, |
| | | t.pay_type payType, pa.name paymentTypeName,pa.bean_jsapi beanJsapi,pa.bean_qrcode beanQrcode,pa.bean_native beanNative |
| | | t.pay_type payType, pa.name paymentTypeName,pa.bean_jsapi beanJsapi,pa.bean_qrcode beanQrcode,pa.bean_native beanNative, |
| | | pa.bean_refund beanRefund |
| | | from payment_pool t |
| | | left join payment_adapt pa on t.payment_type = pa.payment_type and pa.status_cd = '0' |
| | | where 1 =1 |
| New file |
| | |
| | | /* |
| | | * Copyright 2017-2020 吴学文 and java110 team. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.java110.intf.acct; |
| | | |
| | | import com.java110.config.feign.FeignConfiguration; |
| | | import com.java110.dto.payment.NotifyPaymentOrderDto; |
| | | import com.java110.dto.wechat.OnlinePayDto; |
| | | import com.java110.vo.ResultVo; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | |
| | | |
| | | /** |
| | | * 类表述: 服务之前调用的接口类,不对外提供接口能力 只用于接口建调用 |
| | | * add by 吴学文 at 2021-12-21 13:05:25 mail: 928255095@qq.com |
| | | * open source address: https://gitee.com/wuxw7/MicroCommunity |
| | | * 官网:http://www.homecommunity.cn |
| | | * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下 |
| | | * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行 |
| | | */ |
| | | @FeignClient(name = "acct-service", configuration = {FeignConfiguration.class}) |
| | | @RequestMapping("/returnMoneyV1Api") |
| | | public interface IReturnMoneyV1InnerServiceSMO { |
| | | |
| | | /** |
| | | * 退费 |
| | | * |
| | | * @param onlinePayDto 数据对象分享 |
| | | * @return 小区下的小区楼记录数 |
| | | */ |
| | | @RequestMapping(value = "/returnMoney", method = RequestMethod.POST) |
| | | ResultVo returnMoney(@RequestBody OnlinePayDto onlinePayDto); |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.acct.payment; |
| | | |
| | | import com.java110.dto.paymentPool.PaymentPoolDto; |
| | | import com.java110.dto.wechat.OnlinePayDto; |
| | | import com.java110.vo.ResultVo; |
| | | |
| | | public interface IRefundMoneyAdapt { |
| | | |
| | | /** |
| | | * 退款处理 |
| | | * @param onlinePayDto |
| | | * @param paymentPoolDto |
| | | * @return |
| | | */ |
| | | ResultVo refund(OnlinePayDto onlinePayDto, PaymentPoolDto paymentPoolDto) throws Exception; |
| | | } |
| New file |
| | |
| | | package com.java110.acct.payment.adapt.bbgpay; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.acct.payment.IRefundMoneyAdapt; |
| | | import com.java110.core.client.FtpUploadTemplate; |
| | | import com.java110.core.client.OssUploadTemplate; |
| | | import com.java110.core.factory.CommunitySettingFactory; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.factory.PlutusFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.paymentPool.PaymentPoolDto; |
| | | import com.java110.dto.paymentPoolValue.PaymentPoolValueDto; |
| | | import com.java110.dto.wechat.OnlinePayDto; |
| | | import com.java110.intf.acct.IOnlinePayRefundV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IOnlinePayV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IPaymentPoolValueV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IReturnPayFeeInnerServiceSMO; |
| | | import com.java110.intf.order.IOrderInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWechatV1InnerServiceSMO; |
| | | import com.java110.utils.util.PayUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.bouncycastle.util.encoders.Base64; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service("bbgRefundMoney") |
| | | public class BbgRefundMoneyAdapt implements IRefundMoneyAdapt { |
| | | |
| | | |
| | | private static String VERSION = "1.0"; |
| | | |
| | | private static String SIGN_TYPE = "RSA2";// 加密算法:SM4、RSA2 |
| | | |
| | | private static String refundUrl = "https://mbank.bankofbbg.com/www/corepaycer/Refund";// 退款地址 |
| | | |
| | | @Autowired |
| | | private IPaymentPoolValueV1InnerServiceSMO paymentPoolValueV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IReturnPayFeeInnerServiceSMO returnPayFeeInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOrderInnerServiceSMO orderInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOnlinePayV1InnerServiceSMO onlinePayV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ISmallWechatV1InnerServiceSMO smallWechatV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private RestTemplate outRestTemplate; |
| | | |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(BbgRefundMoneyAdapt.class); |
| | | |
| | | @Autowired |
| | | private FtpUploadTemplate ftpUploadTemplate; |
| | | |
| | | @Autowired |
| | | private OssUploadTemplate ossUploadTemplate; |
| | | |
| | | @Autowired |
| | | private IOnlinePayRefundV1InnerServiceSMO onlinePayRefundV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public ResultVo refund(OnlinePayDto onlinePayDto, PaymentPoolDto paymentPoolDto) throws Exception { |
| | | |
| | | PaymentPoolValueDto paymentPoolValueDto = new PaymentPoolValueDto(); |
| | | paymentPoolValueDto.setPpId(paymentPoolDto.getPpId()); |
| | | List<PaymentPoolValueDto> paymentPoolValueDtos = paymentPoolValueV1InnerServiceSMOImpl.queryPaymentPoolValues(paymentPoolValueDto); |
| | | |
| | | if (paymentPoolValueDtos == null || paymentPoolValueDtos.isEmpty()) { |
| | | throw new IllegalArgumentException("配置错误,未配置参数"); |
| | | } |
| | | |
| | | |
| | | String mchtNo_SM4 = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "mchtNo_SM4"); |
| | | String tranNo = GenerateCodeFactory.getGeneratorId("11"); |
| | | |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("version", VERSION);// 版本号 1.0 |
| | | params.put("mcht_no", mchtNo_SM4);// 收款商户编号 |
| | | params.put("tran_no", tranNo);// 商户流水 |
| | | params.put("org_tran_no", onlinePayDto.getOrderId());// 原平台流水 |
| | | params.put("device_ip", "172.0.0.1");// 设备发起交易IP |
| | | params.put("amt", onlinePayDto.getRefundFee());// 交易金额 |
| | | params.put("ware_name", onlinePayDto.getPayName());// 摘要备注 |
| | | |
| | | // 对准备加签参数排序 |
| | | String decryParams = EncryptDecryptFactory.execute(paymentPoolValueDtos, refundUrl, params); |
| | | |
| | | JSONObject paramOut = JSONObject.parseObject(decryParams); |
| | | if ( !"SUCCESS".equals(paramOut.getString("status")) || !"SUCCESS".equals(paramOut.getString("deal_status"))) { |
| | | return new ResultVo(ResultVo.CODE_ERROR, "退款失败" + paramOut.getString("return_message")); |
| | | } |
| | | if ( !"0000".equals(paramOut.getString("return_code")) && !"0001".equals(paramOut.getString("return_code"))) { |
| | | return new ResultVo(ResultVo.CODE_ERROR, "退款失败" + paramOut.getString("return_message")); |
| | | } |
| | | if("0001".equals(paramOut.getString("return_code"))){ |
| | | return new ResultVo(ResultVo.CODE_OK, paramOut.getString("return_message")); |
| | | |
| | | } |
| | | return new ResultVo(ResultVo.CODE_OK, "退款完成"); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.acct.payment.adapt.chinaUms; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.acct.payment.IRefundMoneyAdapt; |
| | | import com.java110.core.client.FtpUploadTemplate; |
| | | import com.java110.core.client.OssUploadTemplate; |
| | | import com.java110.core.factory.PlutusFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.paymentPool.PaymentPoolDto; |
| | | import com.java110.dto.paymentPoolValue.PaymentPoolValueDto; |
| | | import com.java110.dto.wechat.OnlinePayDto; |
| | | import com.java110.intf.acct.IOnlinePayRefundV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IOnlinePayV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IPaymentPoolValueV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IReturnPayFeeInnerServiceSMO; |
| | | import com.java110.intf.order.IOrderInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWechatV1InnerServiceSMO; |
| | | import com.java110.utils.util.PayUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.bouncycastle.util.encoders.Base64; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service("chinaUmsRefundMoney") |
| | | public class ChinaUmsRefundMoneyAdapt implements IRefundMoneyAdapt { |
| | | |
| | | |
| | | //微信支付 |
| | | public static final String DOMAIN_WECHAT_PAY = "WECHAT_PAY"; |
| | | |
| | | // 微信服务商支付开关 |
| | | public static final String WECHAT_SERVICE_PAY_SWITCH = "WECHAT_SERVICE_PAY_SWITCH"; |
| | | |
| | | //开关ON打开 |
| | | public static final String WECHAT_SERVICE_PAY_SWITCH_ON = "ON"; |
| | | |
| | | private static final String WECHAT_SERVICE_APP_ID = "SERVICE_APP_ID"; |
| | | |
| | | private static final String WECHAT_SERVICE_MCH_ID = "SERVICE_MCH_ID"; |
| | | |
| | | @Autowired |
| | | private IPaymentPoolValueV1InnerServiceSMO paymentPoolValueV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IReturnPayFeeInnerServiceSMO returnPayFeeInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOrderInnerServiceSMO orderInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOnlinePayV1InnerServiceSMO onlinePayV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ISmallWechatV1InnerServiceSMO smallWechatV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private RestTemplate outRestTemplate; |
| | | |
| | | public static final String wechatReturnUrl = "https://api.plutuspay.com/open/v2/refund"; |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(ChinaUmsRefundMoneyAdapt.class); |
| | | |
| | | @Autowired |
| | | private FtpUploadTemplate ftpUploadTemplate; |
| | | |
| | | @Autowired |
| | | private OssUploadTemplate ossUploadTemplate; |
| | | |
| | | @Autowired |
| | | private IOnlinePayRefundV1InnerServiceSMO onlinePayRefundV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public ResultVo refund(OnlinePayDto onlinePayDto, PaymentPoolDto paymentPoolDto) throws Exception { |
| | | |
| | | PaymentPoolValueDto paymentPoolValueDto = new PaymentPoolValueDto(); |
| | | paymentPoolValueDto.setPpId(paymentPoolDto.getPpId()); |
| | | List<PaymentPoolValueDto> paymentPoolValueDtos = paymentPoolValueV1InnerServiceSMOImpl.queryPaymentPoolValues(paymentPoolValueDto); |
| | | |
| | | if (paymentPoolValueDtos == null || paymentPoolValueDtos.isEmpty()) { |
| | | throw new IllegalArgumentException("配置错误,未配置参数"); |
| | | } |
| | | |
| | | |
| | | String mchId = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_MCHID"); |
| | | String key = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_KEY"); |
| | | String privateKey = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_PRIVATE_KEY"); |
| | | String devId = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_DEV_ID"); |
| | | String publicKey = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_PUBLIC_KEY"); |
| | | |
| | | JSONObject parameters = new JSONObject(); |
| | | parameters.put("sn", mchId);//商户号 |
| | | parameters.put("outTradeId", onlinePayDto.getOrderId());//商户号 |
| | | parameters.put("outRefundId", onlinePayDto.getPayId());//我们自己设定的退款申请号,约束为UK |
| | | parameters.put("refundAmount", PayUtil.moneyToIntegerStr(Double.parseDouble(onlinePayDto.getTotalFee())));//订单金额 单位为分!!!这里稍微注意一下 |
| | | |
| | | |
| | | String param = PlutusFactory.Encryption(parameters.toJSONString(), privateKey, key, devId); |
| | | System.out.println(param); |
| | | |
| | | String str = PlutusFactory.post(wechatReturnUrl, param); |
| | | System.out.println(str); |
| | | |
| | | JSONObject json = JSON.parseObject(str); |
| | | |
| | | String signature = json.getString("signature"); |
| | | String content = json.getString("content"); |
| | | |
| | | |
| | | //验签 |
| | | Boolean verify = PlutusFactory.verify256(content, Base64.decode(signature), publicKey); |
| | | //验签成功 |
| | | if (!verify) { |
| | | throw new IllegalArgumentException("支付失败签名失败"); |
| | | } |
| | | //解密 |
| | | byte[] bb = PlutusFactory.decrypt(Base64.decode(content), key); |
| | | //服务器返回内容 |
| | | String paramOut = new String(bb); |
| | | System.out.println(paramOut); |
| | | |
| | | JSONObject paramObj = JSONObject.parseObject(paramOut); |
| | | |
| | | if (paramObj.getIntValue("status") != 2) { |
| | | return new ResultVo(ResultVo.CODE_ERROR, paramObj.getString("remark")); |
| | | } else { |
| | | return new ResultVo(ResultVo.CODE_OK, "退款完成"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.acct.payment.adapt.easypay; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.acct.payment.IRefundMoneyAdapt; |
| | | import com.java110.acct.payment.adapt.bbgpay.EncryptDecryptFactory; |
| | | import com.java110.acct.payment.adapt.easypay.utils.HttpConnectUtils; |
| | | import com.java110.core.client.FtpUploadTemplate; |
| | | import com.java110.core.client.OssUploadTemplate; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.paymentPool.PaymentPoolDto; |
| | | import com.java110.dto.paymentPoolValue.PaymentPoolValueDto; |
| | | import com.java110.dto.wechat.OnlinePayDto; |
| | | import com.java110.intf.acct.IOnlinePayRefundV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IOnlinePayV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IPaymentPoolValueV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IReturnPayFeeInnerServiceSMO; |
| | | import com.java110.intf.order.IOrderInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWechatV1InnerServiceSMO; |
| | | import com.java110.utils.util.PayUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service("easyRefundMoney") |
| | | public class EasyRefundMoneyAdapt implements IRefundMoneyAdapt { |
| | | |
| | | |
| | | @Autowired |
| | | private IPaymentPoolValueV1InnerServiceSMO paymentPoolValueV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IReturnPayFeeInnerServiceSMO returnPayFeeInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOrderInnerServiceSMO orderInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOnlinePayV1InnerServiceSMO onlinePayV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ISmallWechatV1InnerServiceSMO smallWechatV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private RestTemplate outRestTemplate; |
| | | |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(EasyRefundMoneyAdapt.class); |
| | | |
| | | @Autowired |
| | | private FtpUploadTemplate ftpUploadTemplate; |
| | | |
| | | @Autowired |
| | | private OssUploadTemplate ossUploadTemplate; |
| | | |
| | | @Autowired |
| | | private IOnlinePayRefundV1InnerServiceSMO onlinePayRefundV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public ResultVo refund(OnlinePayDto onlinePayDto, PaymentPoolDto paymentPoolDto) throws Exception { |
| | | |
| | | PaymentPoolValueDto paymentPoolValueDto = new PaymentPoolValueDto(); |
| | | paymentPoolValueDto.setPpId(paymentPoolDto.getPpId()); |
| | | List<PaymentPoolValueDto> paymentPoolValueDtos = paymentPoolValueV1InnerServiceSMOImpl.queryPaymentPoolValues(paymentPoolValueDto); |
| | | |
| | | if (paymentPoolValueDtos == null || paymentPoolValueDtos.isEmpty()) { |
| | | throw new IllegalArgumentException("配置错误,未配置参数"); |
| | | } |
| | | |
| | | String ORGID = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "ORGID"); // 客户编号 |
| | | String ORGMERCODE = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "ORGMERCODE"); |
| | | String ORGTERMNO = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "ORGTERMNO"); |
| | | String EASYPAY_PUBLIC_KEY = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "EASYPAY_PUBLIC_KEY"); |
| | | String MER_RSA_PRIVATE_KEY = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "MER_RSA_PRIVATE_KEY"); |
| | | |
| | | JSONObject paramIn = new JSONObject(); |
| | | paramIn.put("orgId", ORGID); |
| | | paramIn.put("orgMercode", ORGMERCODE); |
| | | paramIn.put("orgTermno", ORGTERMNO); |
| | | paramIn.put("signType", BasePay.SIGN_TYPE_RSA256); |
| | | paramIn.put("orgTrace", GenerateCodeFactory.getGeneratorId("10")); |
| | | |
| | | JSONObject bizData = new JSONObject(); |
| | | bizData.put("oriOrgTrace", onlinePayDto.getOrderId()); |
| | | bizData.put("transAmt", PayUtil.moneyToIntegerStr(Double.parseDouble(onlinePayDto.getRefundFee()))); |
| | | |
| | | paramIn.put("bizData", bizData); |
| | | String sign = BasePay.sign(paramIn, MER_RSA_PRIVATE_KEY); |
| | | paramIn.put("sign", sign); |
| | | |
| | | String requestStr = paramIn.toJSONString(); |
| | | |
| | | String response = null; |
| | | try { |
| | | response = HttpConnectUtils.sendHttpSRequest(BasePay.BASE_URL + "/ledger/mposrefund", requestStr, "JSON", null); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | System.out.println("\n响应报文:" + response); |
| | | BasePay.checkSign(response, EASYPAY_PUBLIC_KEY); |
| | | |
| | | JSONObject paramOut = JSONObject.parseObject(response); |
| | | if (!"000000".equals(paramOut.getString("sysRetCode"))) { |
| | | return new ResultVo(ResultVo.CODE_ERROR, "退款失败" + paramOut.getString("sysRetMsg")); |
| | | } |
| | | |
| | | JSONObject resData = paramOut.getJSONObject("bizData"); |
| | | |
| | | if (!"00".equals(resData.getString("tradeRetCode"))) { |
| | | return new ResultVo(ResultVo.CODE_ERROR, "退款失败" + paramOut.getString("tradeRetMsg")); |
| | | |
| | | } |
| | | return new ResultVo(ResultVo.CODE_OK, "退款完成"); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.acct.payment.adapt.plutus; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.acct.payment.IRefundMoneyAdapt; |
| | | import com.java110.core.client.FtpUploadTemplate; |
| | | import com.java110.core.client.OssUploadTemplate; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.factory.PlutusFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.file.FileDto; |
| | | import com.java110.dto.onlinePayRefund.OnlinePayRefundDto; |
| | | import com.java110.dto.paymentPool.PaymentPoolDto; |
| | | import com.java110.dto.paymentPoolValue.PaymentPoolValueDto; |
| | | import com.java110.dto.wechat.OnlinePayDto; |
| | | import com.java110.intf.acct.IOnlinePayRefundV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IOnlinePayV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IPaymentPoolValueV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IReturnPayFeeInnerServiceSMO; |
| | | import com.java110.intf.order.IOrderInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWechatV1InnerServiceSMO; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.MappingConstant; |
| | | import com.java110.utils.util.OSSUtil; |
| | | import com.java110.utils.util.PayUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.ssl.SSLContexts; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.bouncycastle.util.encoders.Base64; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.security.KeyStore; |
| | | import java.util.*; |
| | | |
| | | @Service("plutusRefundMoney") |
| | | public class PlutusRefundMoneyAdapt implements IRefundMoneyAdapt { |
| | | |
| | | |
| | | //微信支付 |
| | | public static final String DOMAIN_WECHAT_PAY = "WECHAT_PAY"; |
| | | |
| | | // 微信服务商支付开关 |
| | | public static final String WECHAT_SERVICE_PAY_SWITCH = "WECHAT_SERVICE_PAY_SWITCH"; |
| | | |
| | | //开关ON打开 |
| | | public static final String WECHAT_SERVICE_PAY_SWITCH_ON = "ON"; |
| | | |
| | | private static final String WECHAT_SERVICE_APP_ID = "SERVICE_APP_ID"; |
| | | |
| | | private static final String WECHAT_SERVICE_MCH_ID = "SERVICE_MCH_ID"; |
| | | |
| | | @Autowired |
| | | private IPaymentPoolValueV1InnerServiceSMO paymentPoolValueV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IReturnPayFeeInnerServiceSMO returnPayFeeInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOrderInnerServiceSMO orderInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOnlinePayV1InnerServiceSMO onlinePayV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ISmallWechatV1InnerServiceSMO smallWechatV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private RestTemplate outRestTemplate; |
| | | |
| | | public static final String wechatReturnUrl = "https://api.plutuspay.com/open/v2/refund"; |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(PlutusRefundMoneyAdapt.class); |
| | | |
| | | @Autowired |
| | | private FtpUploadTemplate ftpUploadTemplate; |
| | | |
| | | @Autowired |
| | | private OssUploadTemplate ossUploadTemplate; |
| | | |
| | | @Autowired |
| | | private IOnlinePayRefundV1InnerServiceSMO onlinePayRefundV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public ResultVo refund(OnlinePayDto onlinePayDto, PaymentPoolDto paymentPoolDto) throws Exception { |
| | | |
| | | PaymentPoolValueDto paymentPoolValueDto = new PaymentPoolValueDto(); |
| | | paymentPoolValueDto.setPpId(paymentPoolDto.getPpId()); |
| | | List<PaymentPoolValueDto> paymentPoolValueDtos = paymentPoolValueV1InnerServiceSMOImpl.queryPaymentPoolValues(paymentPoolValueDto); |
| | | |
| | | if (paymentPoolValueDtos == null || paymentPoolValueDtos.isEmpty()) { |
| | | throw new IllegalArgumentException("配置错误,未配置参数"); |
| | | } |
| | | |
| | | |
| | | String mchId = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_MCHID"); |
| | | String key = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_KEY"); |
| | | String privateKey = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_PRIVATE_KEY"); |
| | | String devId = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_DEV_ID"); |
| | | String publicKey = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "PLUTUS_PUBLIC_KEY"); |
| | | |
| | | JSONObject parameters = new JSONObject(); |
| | | parameters.put("sn", mchId);//商户号 |
| | | parameters.put("outTradeId", onlinePayDto.getOrderId());//商户号 |
| | | parameters.put("outRefundId", onlinePayDto.getPayId());//我们自己设定的退款申请号,约束为UK |
| | | parameters.put("refundAmount", PayUtil.moneyToIntegerStr(Double.parseDouble(onlinePayDto.getTotalFee())));//订单金额 单位为分!!!这里稍微注意一下 |
| | | |
| | | |
| | | String param = PlutusFactory.Encryption(parameters.toJSONString(), privateKey, key, devId); |
| | | System.out.println(param); |
| | | |
| | | String str = PlutusFactory.post(wechatReturnUrl, param); |
| | | System.out.println(str); |
| | | |
| | | JSONObject json = JSON.parseObject(str); |
| | | |
| | | String signature = json.getString("signature"); |
| | | String content = json.getString("content"); |
| | | |
| | | |
| | | //验签 |
| | | Boolean verify = PlutusFactory.verify256(content, org.bouncycastle.util.encoders.Base64.decode(signature), publicKey); |
| | | //验签成功 |
| | | if (!verify) { |
| | | throw new IllegalArgumentException("支付失败签名失败"); |
| | | } |
| | | //解密 |
| | | byte[] bb = PlutusFactory.decrypt(Base64.decode(content), key); |
| | | //服务器返回内容 |
| | | String paramOut = new String(bb); |
| | | System.out.println(paramOut); |
| | | |
| | | JSONObject paramObj = JSONObject.parseObject(paramOut); |
| | | |
| | | if (paramObj.getIntValue("status") != 2) { |
| | | return new ResultVo(ResultVo.CODE_ERROR, paramObj.getString("remark")); |
| | | } else { |
| | | return new ResultVo(ResultVo.CODE_OK, "退款完成"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.acct.payment.adapt.wechat; |
| | | |
| | | import com.java110.acct.payment.IRefundMoneyAdapt; |
| | | import com.java110.core.client.FtpUploadTemplate; |
| | | import com.java110.core.client.OssUploadTemplate; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.file.FileDto; |
| | | import com.java110.dto.onlinePayRefund.OnlinePayRefundDto; |
| | | import com.java110.dto.paymentPool.PaymentPoolDto; |
| | | import com.java110.dto.paymentPoolValue.PaymentPoolValueDto; |
| | | import com.java110.dto.wechat.OnlinePayDto; |
| | | import com.java110.dto.wechat.SmallWeChatDto; |
| | | import com.java110.intf.acct.IOnlinePayRefundV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IOnlinePayV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IPaymentPoolValueV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IReturnPayFeeInnerServiceSMO; |
| | | import com.java110.intf.order.IOrderInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWechatV1InnerServiceSMO; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.MappingConstant; |
| | | import com.java110.utils.util.OSSUtil; |
| | | import com.java110.utils.util.PayUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.ssl.SSLContexts; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.security.KeyStore; |
| | | import java.util.*; |
| | | |
| | | @Service("wechatRefundMoney") |
| | | public class WechatRefundMoneyAdapt implements IRefundMoneyAdapt { |
| | | |
| | | |
| | | //微信支付 |
| | | public static final String DOMAIN_WECHAT_PAY = "WECHAT_PAY"; |
| | | |
| | | // 微信服务商支付开关 |
| | | public static final String WECHAT_SERVICE_PAY_SWITCH = "WECHAT_SERVICE_PAY_SWITCH"; |
| | | |
| | | //开关ON打开 |
| | | public static final String WECHAT_SERVICE_PAY_SWITCH_ON = "ON"; |
| | | |
| | | private static final String WECHAT_SERVICE_APP_ID = "SERVICE_APP_ID"; |
| | | |
| | | private static final String WECHAT_SERVICE_MCH_ID = "SERVICE_MCH_ID"; |
| | | |
| | | @Autowired |
| | | private IPaymentPoolValueV1InnerServiceSMO paymentPoolValueV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IReturnPayFeeInnerServiceSMO returnPayFeeInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOrderInnerServiceSMO orderInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOnlinePayV1InnerServiceSMO onlinePayV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ISmallWechatV1InnerServiceSMO smallWechatV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private RestTemplate outRestTemplate; |
| | | |
| | | public static final String wechatReturnUrl = "https://api.mch.weixin.qq.com/secapi/pay/refund"; |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(WechatRefundMoneyAdapt.class); |
| | | |
| | | @Autowired |
| | | private FtpUploadTemplate ftpUploadTemplate; |
| | | |
| | | @Autowired |
| | | private OssUploadTemplate ossUploadTemplate; |
| | | |
| | | @Autowired |
| | | private IOnlinePayRefundV1InnerServiceSMO onlinePayRefundV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public ResultVo refund(OnlinePayDto onlinePayDto, PaymentPoolDto paymentPoolDto) throws Exception { |
| | | |
| | | PaymentPoolValueDto paymentPoolValueDto = new PaymentPoolValueDto(); |
| | | paymentPoolValueDto.setPpId(paymentPoolDto.getPpId()); |
| | | List<PaymentPoolValueDto> paymentPoolValueDtos = paymentPoolValueV1InnerServiceSMOImpl.queryPaymentPoolValues(paymentPoolValueDto); |
| | | |
| | | if (paymentPoolValueDtos == null || paymentPoolValueDtos.isEmpty()) { |
| | | throw new IllegalArgumentException("配置错误,未配置参数"); |
| | | } |
| | | |
| | | String mchId = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "WECHAT_MCHID"); |
| | | String key = PaymentPoolValueDto.getValue(paymentPoolValueDtos, "WECHAT_KEY"); |
| | | String certData = paymentPoolDto.getCertPath(); |
| | | |
| | | System.out.println("------------------------------证书地址:" + certData); |
| | | |
| | | SortedMap<String, String> parameters = new TreeMap<String, String>(); |
| | | String paySwitch = MappingCache.getValue(DOMAIN_WECHAT_PAY, WECHAT_SERVICE_PAY_SWITCH); |
| | | parameters.put("appid", onlinePayDto.getAppId());//appid |
| | | parameters.put("mch_id", mchId);//商户号 |
| | | if (WECHAT_SERVICE_PAY_SWITCH_ON.equals(paySwitch)) { |
| | | key = MappingCache.getValue(DOMAIN_WECHAT_PAY, WECHAT_SERVICE_MCH_ID); |
| | | parameters.put("mch_id", MappingCache.getValue(MappingConstant.WECHAT_STORE_DOMAIN, "mchId"));//商户号 |
| | | parameters.put("sub_mch_id", mchId);//商户号 |
| | | } |
| | | |
| | | // todo 查询退费明细 |
| | | OnlinePayRefundDto onlinePayRefundDto = new OnlinePayRefundDto(); |
| | | onlinePayRefundDto.setPayId(onlinePayDto.getPayId()); |
| | | onlinePayRefundDto.setState(OnlinePayDto.STATE_WT); |
| | | List<OnlinePayRefundDto> onlinePayRefundDtos = onlinePayRefundV1InnerServiceSMOImpl.queryOnlinePayRefunds(onlinePayRefundDto); |
| | | String tranNo = GenerateCodeFactory.getGeneratorId("11"); |
| | | if (onlinePayRefundDtos != null && onlinePayRefundDtos.size() > 0) { |
| | | tranNo = onlinePayRefundDtos.get(0).getRefundId(); |
| | | } |
| | | |
| | | |
| | | parameters.put("nonce_str", PayUtil.makeUUID(32));//随机数 |
| | | parameters.put("out_trade_no", onlinePayDto.getOrderId());//商户订单号 |
| | | parameters.put("out_refund_no", tranNo);//我们自己设定的退款申请号,约束为UK |
| | | parameters.put("total_fee", PayUtil.moneyToIntegerStr(Double.parseDouble(onlinePayDto.getTotalFee())));//订单金额 单位为分!!!这里稍微注意一下 |
| | | parameters.put("refund_fee", PayUtil.moneyToIntegerStr(Double.parseDouble(onlinePayDto.getRefundFee())));//退款金额 单位为分!!! |
| | | parameters.put("sign", PayUtil.createSign(parameters, key)); |
| | | String xmlData = PayUtil.mapToXml(parameters); |
| | | KeyStore keyStore = KeyStore.getInstance("PKCS12"); |
| | | ByteArrayInputStream inputStream = new ByteArrayInputStream(getPkcs12(certData)); |
| | | try { |
| | | //这里写密码..默认是你的MCHID |
| | | keyStore.load(inputStream, mchId.toCharArray()); |
| | | } finally { |
| | | inputStream.close(); |
| | | } |
| | | SSLContext sslcontext = SSLContexts.custom() |
| | | //这里也是写密码的 |
| | | .loadKeyMaterial(keyStore, parameters.get("mch_id").toCharArray()) |
| | | .build(); |
| | | SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( |
| | | sslcontext, |
| | | SSLConnectionSocketFactory.getDefaultHostnameVerifier()); |
| | | CloseableHttpClient httpclient = HttpClients.custom() |
| | | .setSSLSocketFactory(sslsf) |
| | | .build(); |
| | | String jsonStr = ""; |
| | | try { |
| | | HttpPost httpost = new HttpPost(wechatReturnUrl); |
| | | httpost.setEntity(new StringEntity(xmlData, "UTF-8")); |
| | | CloseableHttpResponse response = httpclient.execute(httpost); |
| | | try { |
| | | HttpEntity entity = response.getEntity(); |
| | | //接受到返回信息 |
| | | jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); |
| | | EntityUtils.consume(entity); |
| | | } finally { |
| | | response.close(); |
| | | } |
| | | } finally { |
| | | httpclient.close(); |
| | | } |
| | | Map<String, String> resMap = PayUtil.xmlStrToMap(jsonStr); |
| | | if ("SUCCESS".equals(resMap.get("return_code")) && "SUCCESS".equals(resMap.get("result_code"))) { |
| | | return new ResultVo(ResultVo.CODE_OK, "退款完成"); |
| | | } else { |
| | | return new ResultVo(ResultVo.CODE_ERROR, resMap.get("return_msg")); |
| | | } |
| | | |
| | | } |
| | | |
| | | private byte[] getPkcs12(String fileName) { |
| | | List<FileDto> fileDtos = new ArrayList<>(); |
| | | byte[] context = null; |
| | | String ftpPath = "hc/"; |
| | | String ossSwitch = MappingCache.getValue(MappingConstant.FILE_DOMAIN, OSSUtil.OSS_SWITCH); |
| | | if (StringUtil.isEmpty(ossSwitch) || !OSSUtil.OSS_SWITCH_OSS.equals(ossSwitch)) { |
| | | String ftpServer = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_SERVER); |
| | | int ftpPort = Integer.parseInt(MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_PORT)); |
| | | String ftpUserName = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERNAME); |
| | | String ftpUserPassword = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERPASSWORD); |
| | | context = ftpUploadTemplate.downFileByte(ftpPath, fileName, ftpServer, |
| | | ftpPort, ftpUserName, |
| | | ftpUserPassword); |
| | | } else { |
| | | context = ossUploadTemplate.downFileByte(ftpPath, fileName, "", |
| | | 0, "", |
| | | ""); |
| | | } |
| | | return context; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2017-2020 吴学文 and java110 team. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.java110.acct.smo.impl; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.acct.payment.IPaymentBusiness; |
| | | import com.java110.acct.payment.IPaymentFactoryAdapt; |
| | | import com.java110.acct.payment.IRefundMoneyAdapt; |
| | | import com.java110.core.base.smo.BaseServiceSMO; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.payment.NotifyPaymentOrderDto; |
| | | import com.java110.dto.payment.PaymentOrderDto; |
| | | import com.java110.dto.paymentPool.PaymentPoolDto; |
| | | import com.java110.dto.wechat.OnlinePayDto; |
| | | import com.java110.intf.acct.INotifyPaymentV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IPaymentPoolV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IReturnMoneyV1InnerServiceSMO; |
| | | import com.java110.utils.cache.CommonCache; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.WechatConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 类表述: 服务之前调用的接口实现类,不对外提供接口能力 只用于接口建调用 |
| | | * add by 吴学文 at 2021-12-21 13:05:25 mail: 928255095@qq.com |
| | | * open source address: https://gitee.com/wuxw7/MicroCommunity |
| | | * 官网:http://www.homecommunity.cn |
| | | * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下 |
| | | * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行 |
| | | */ |
| | | @RestController |
| | | public class ReturnMoneyV1InnerServiceSMOImpl extends BaseServiceSMO implements IReturnMoneyV1InnerServiceSMO { |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(ReturnMoneyV1InnerServiceSMOImpl.class); |
| | | |
| | | private static final String DEFAULT_PAYMENT_NOTIFY_ADAPT = "wechatPaymentFactory";// 默认微信通用支付 |
| | | |
| | | protected static final String DEFAULT_NATIVE_QRCODE_PAYMENT_ADAPT = "wechatNativeQrcodePaymentFactory";// 默认微信通用支付 |
| | | @Autowired |
| | | private IPaymentPoolV1InnerServiceSMO paymentPoolV1InnerServiceSMOImpl; |
| | | |
| | | |
| | | @Override |
| | | public ResultVo returnMoney(@RequestBody OnlinePayDto onlinePayDto) { |
| | | |
| | | |
| | | PaymentPoolDto paymentPoolDto = new PaymentPoolDto(); |
| | | paymentPoolDto.setPpId(onlinePayDto.getPaymentPoolId()); |
| | | List<PaymentPoolDto> paymentPoolDtos = paymentPoolV1InnerServiceSMOImpl.queryPaymentPools(paymentPoolDto); |
| | | |
| | | Assert.listOnlyOne(paymentPoolDtos, "支付厂家不存在"); |
| | | |
| | | if (StringUtil.isEmpty(paymentPoolDtos.get(0).getBeanRefund())) { |
| | | throw new IllegalArgumentException("厂家不支持退款"); |
| | | } |
| | | |
| | | IRefundMoneyAdapt refundMoneyAdapt = ApplicationContextFactory.getBean(paymentPoolDtos.get(0).getBeanRefund(), IRefundMoneyAdapt.class); |
| | | if (refundMoneyAdapt == null) { |
| | | throw new IllegalArgumentException("厂家退款适配器配置错误" + paymentPoolDtos.get(0).getBeanRefund()); |
| | | } |
| | | |
| | | ResultVo resultVo = null; |
| | | try { |
| | | resultVo = refundMoneyAdapt.refund(onlinePayDto, paymentPoolDto); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | resultVo = new ResultVo(ResultVo.CODE_ERROR, e.getLocalizedMessage()); |
| | | } |
| | | return resultVo; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.java110.dto.system.Business; |
| | | import com.java110.intf.acct.IOnlinePayRefundV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IOnlinePayV1InnerServiceSMO; |
| | | import com.java110.intf.acct.IReturnMoneyV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IReturnPayFeeInnerServiceSMO; |
| | | import com.java110.intf.order.IOrderInnerServiceSMO; |
| | | import com.java110.intf.store.ISmallWechatV1InnerServiceSMO; |
| | |
| | | import com.java110.utils.util.OSSUtil; |
| | | import com.java110.utils.util.PayUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpPost; |
| | |
| | | @Autowired |
| | | private IOnlinePayRefundV1InnerServiceSMO onlinePayRefundV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IReturnMoneyV1InnerServiceSMO returnMoneyV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void execute(Business business, List<Business> businesses) { |
| | | JSONObject data = business.getData(); |
| | | OnlinePayPo oaWorkflowDataPo = BeanConvertUtil.covertBean(data, OnlinePayPo.class); |
| | | OnlinePayPo onlinePayPo = BeanConvertUtil.covertBean(data, OnlinePayPo.class); |
| | | try { |
| | | doPayFeeMoney(oaWorkflowDataPo); |
| | | doPayFeeMoney(onlinePayPo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | /** |
| | | * 通知退款 |
| | | * |
| | | * @param oaWorkflowDataPo |
| | | * @param onlinePayPo |
| | | */ |
| | | public void doPayFeeMoney(OnlinePayPo oaWorkflowDataPo) throws Exception { |
| | | public void doPayFeeMoney(OnlinePayPo onlinePayPo) throws Exception { |
| | | //查询小区信息 |
| | | OnlinePayDto onlinePayDto = new OnlinePayDto(); |
| | | onlinePayDto.setPayId(oaWorkflowDataPo.getPayId()); |
| | | onlinePayDto.setPayId(onlinePayPo.getPayId()); |
| | | onlinePayDto.setState(OnlinePayDto.STATE_WT); |
| | | List<OnlinePayDto> onlinePayDtos = onlinePayV1InnerServiceSMOImpl.queryOnlinePays(onlinePayDto); |
| | | if (onlinePayDtos == null || onlinePayDtos.size() < 1) { |
| | | return; |
| | | } |
| | | // todo 如果物业系统退款 |
| | | if (!StringUtil.isEmpty(onlinePayDtos.get(0).getPaymentPoolId())) { |
| | | ResultVo resultVo = returnMoneyV1InnerServiceSMOImpl.returnMoney(onlinePayDtos.get(0)); |
| | | if (resultVo.getCode() == ResultVo.CODE_OK) { |
| | | doUpdateOnlinePay(onlinePayDtos.get(0).getPayId(), OnlinePayDto.STATE_CT, "退款完成"); |
| | | } else { |
| | | doUpdateOnlinePay(onlinePayDtos.get(0).getPayId(), OnlinePayDto.STATE_FT, resultVo.getMsg()); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | //todo 商城还是走这里 |
| | | String payPassword = ""; |
| | | String certData = ""; |
| | | String mchPassword = ""; |
| | |
| | | payPassword = smallWeChatDtos.get(0).getPayPassword(); |
| | | certData = smallWeChatDtos.get(0).getCertPath(); |
| | | mchPassword = smallWeChatDtos.get(0).getMchId(); |
| | | if(StringUtil.isEmpty(certData)){ |
| | | if (StringUtil.isEmpty(certData)) { |
| | | certData = MappingCache.getRemark(MappingConstant.WECHAT_STORE_DOMAIN, "cert"); |
| | | } |
| | | } |
| | | |
| | | System.out.println("------------------------------证书地址:"+certData); |
| | | System.out.println("------------------------------证书地址:" + certData); |
| | | |
| | | SortedMap<String, String> parameters = new TreeMap<String, String>(); |
| | | String paySwitch = MappingCache.getValue(DOMAIN_WECHAT_PAY, WECHAT_SERVICE_PAY_SWITCH); |
| | |
| | | onlinePayRefundDto.setState(OnlinePayDto.STATE_WT); |
| | | List<OnlinePayRefundDto> onlinePayRefundDtos = onlinePayRefundV1InnerServiceSMOImpl.queryOnlinePayRefunds(onlinePayRefundDto); |
| | | String tranNo = GenerateCodeFactory.getGeneratorId("11"); |
| | | if(onlinePayRefundDtos != null && onlinePayRefundDtos.size() >0){ |
| | | if (onlinePayRefundDtos != null && onlinePayRefundDtos.size() > 0) { |
| | | tranNo = onlinePayRefundDtos.get(0).getRefundId(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | private void doUpdateOnlinePay(String payId, String state, String message) { |
| | | OnlinePayPo onlinePayPo = new OnlinePayPo(); |
| | | onlinePayPo.setMessage(message.length() > 1000 ? message.substring(0, 1000) : message); |
| | |
| | | onlinePayRefundDto.setState(OnlinePayDto.STATE_WT); |
| | | List<OnlinePayRefundDto> onlinePayRefundDtos = onlinePayRefundV1InnerServiceSMOImpl.queryOnlinePayRefunds(onlinePayRefundDto); |
| | | |
| | | if(onlinePayRefundDtos == null || onlinePayRefundDtos.size() < 1){ |
| | | if (onlinePayRefundDtos == null || onlinePayRefundDtos.size() < 1) { |
| | | return; |
| | | } |
| | | |