| @@ -272,7 +272,7 @@ public class WxBillController extends BaseController { | |||||
| } | } | ||||
| try { | try { | ||||
| Object result = payBillServiceFactory.getPayAdapterService(wxPayAccountBill.getPayChannel()) | Object result = payBillServiceFactory.getPayAdapterService(wxPayAccountBill.getPayChannel()) | ||||
| .createPay(wxPayAccountBill,this.getLoginBUser(),billdetail,Double.parseDouble(payMoney), paramMap); | |||||
| .createPay(wxPayAccountBill,this.getLoginBUser(),this.getCUser(),billdetail,Double.parseDouble(payMoney), paramMap); | |||||
| if (null == result) { | if (null == result) { | ||||
| return new ResultData(Result.ERROR,"账单支付错误,请联系管理员"); | return new ResultData(Result.ERROR,"账单支付错误,请联系管理员"); | ||||
| } | } | ||||
| @@ -4,7 +4,8 @@ package com.iformall.enums; | |||||
| */ | */ | ||||
| public enum EnumBillPayChannel { | public enum EnumBillPayChannel { | ||||
| WX_MINI_PROGRAM(1, "微信小程序支付"), | WX_MINI_PROGRAM(1, "微信小程序支付"), | ||||
| BANK_JIANSHE_MA(2, "建设银行收款码"); | |||||
| BANK_JIANSHE_MA(2, "建设银行收款码"), | |||||
| BANK_JIANSHE_WX_MINIPROGRAM(3, "建设银行小程序收款"); | |||||
| public static EnumBillPayChannel getEnum(Integer code) { | public static EnumBillPayChannel getEnum(Integer code) { | ||||
| for (EnumBillPayChannel value : values()) { | for (EnumBillPayChannel value : values()) { | ||||
| @@ -2,6 +2,7 @@ package com.iformall.service.payBill; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| import com.iformall.domain.po.CUser; | |||||
| import com.iformall.domain.po.WxAllBill; | import com.iformall.domain.po.WxAllBill; | ||||
| import com.iformall.domain.po.WxBillPayWay; | import com.iformall.domain.po.WxBillPayWay; | ||||
| import com.iformall.domain.po.WxMerchantBUser; | import com.iformall.domain.po.WxMerchantBUser; | ||||
| @@ -10,7 +11,7 @@ import com.iformall.domain.po.WxPayAccountBill; | |||||
| public interface PayBillAdapterService { | public interface PayBillAdapterService { | ||||
| //发起支付,有可能是码,小程序支付,或者其他支付 | //发起支付,有可能是码,小程序支付,或者其他支付 | ||||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,WxAllBill billdetail,Double money,Map<String,String> params) throws Exception; | |||||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,CUser bOpenUser,WxAllBill billdetail,Double money,Map<String,String> params) throws Exception; | |||||
| //支付通知处理 | //支付通知处理 | ||||
| public void paidCallBack(String tenantId,WxBillPayWay payWay,Map paramMap); | public void paidCallBack(String tenantId,WxBillPayWay payWay,Map paramMap); | ||||
| @@ -4,6 +4,7 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.enums.EnumBillPayChannel; | import com.iformall.enums.EnumBillPayChannel; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.payBill.impl.jianhang.JianHangMaServiceImpl; | import com.iformall.service.payBill.impl.jianhang.JianHangMaServiceImpl; | ||||
| import com.iformall.service.payBill.impl.jianhang.JianHangWxMiniProgramServiceImpl; | |||||
| import com.iformall.service.payBill.impl.wx.WxMiniProgramServiceImpl; | import com.iformall.service.payBill.impl.wx.WxMiniProgramServiceImpl; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -23,6 +24,8 @@ public class PayBillServiceFactory { | |||||
| JianHangMaServiceImpl jianHangMaService; | JianHangMaServiceImpl jianHangMaService; | ||||
| @Autowired | @Autowired | ||||
| WxMiniProgramServiceImpl wxMiniProgramService; | WxMiniProgramServiceImpl wxMiniProgramService; | ||||
| @Autowired | |||||
| JianHangWxMiniProgramServiceImpl jianHangWxMiniProgrameServiceImpl; | |||||
| private Map<String,PayBillAdapterService> getServiceMap() { | private Map<String,PayBillAdapterService> getServiceMap() { | ||||
| @@ -30,6 +33,7 @@ public class PayBillServiceFactory { | |||||
| serviceMap = new ConcurrentHashMap<String,PayBillAdapterService>(); | serviceMap = new ConcurrentHashMap<String,PayBillAdapterService>(); | ||||
| serviceMap.put(EnumBillPayChannel.BANK_JIANSHE_MA.getCode()+"", jianHangMaService); | serviceMap.put(EnumBillPayChannel.BANK_JIANSHE_MA.getCode()+"", jianHangMaService); | ||||
| serviceMap.put(EnumBillPayChannel.WX_MINI_PROGRAM.getCode()+"", wxMiniProgramService); | serviceMap.put(EnumBillPayChannel.WX_MINI_PROGRAM.getCode()+"", wxMiniProgramService); | ||||
| serviceMap.put(EnumBillPayChannel.BANK_JIANSHE_WX_MINIPROGRAM.getCode()+"", jianHangWxMiniProgrameServiceImpl); | |||||
| } | } | ||||
| return serviceMap; | return serviceMap; | ||||
| } | } | ||||
| @@ -13,8 +13,10 @@ import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.po.CUser; | |||||
| import com.iformall.domain.po.WxAllBill; | import com.iformall.domain.po.WxAllBill; | ||||
| import com.iformall.domain.po.WxBillPayWay; | import com.iformall.domain.po.WxBillPayWay; | ||||
| import com.iformall.domain.po.WxBuser; | |||||
| import com.iformall.domain.po.WxMerchantBUser; | import com.iformall.domain.po.WxMerchantBUser; | ||||
| import com.iformall.domain.po.WxPayAccountBill; | import com.iformall.domain.po.WxPayAccountBill; | ||||
| import com.iformall.enums.EnumBillAllType; | import com.iformall.enums.EnumBillAllType; | ||||
| @@ -40,7 +42,7 @@ public class JianHangMaServiceImpl extends PayBillBaseService implements PayBill | |||||
| //建行动态二维码接口 | //建行动态二维码接口 | ||||
| @Override | @Override | ||||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,WxAllBill billdetail,Double money,Map<String, String> params) throws Exception { | |||||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,CUser bOpenUser,WxAllBill billdetail,Double money,Map<String, String> params) throws Exception { | |||||
| return QrDemo.getMa(wxPayAccountBill, buser, billdetail, money); | return QrDemo.getMa(wxPayAccountBill, buser, billdetail, money); | ||||
| } | } | ||||
| @@ -0,0 +1,70 @@ | |||||
| package com.iformall.service.payBill.impl.jianhang; | |||||
| import java.io.UnsupportedEncodingException; | |||||
| import java.net.URLDecoder; | |||||
| import java.net.URLEncoder; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| import org.apache.commons.codec.digest.DigestUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.CUser; | |||||
| import com.iformall.domain.po.WxAllBill; | |||||
| import com.iformall.domain.po.WxBillPayWay; | |||||
| import com.iformall.domain.po.WxBuser; | |||||
| import com.iformall.domain.po.WxMerchantBUser; | |||||
| import com.iformall.domain.po.WxPayAccountBill; | |||||
| import com.iformall.enums.EnumBillAllType; | |||||
| import com.iformall.mapper.WxBuserMapper; | |||||
| import com.iformall.service.payBill.PayBillAdapterService; | |||||
| import com.iformall.service.payBill.impl.PayBillBaseService; | |||||
| import com.iformall.utils.DateUtils; | |||||
| import com.iformall.utils.HttpUtil; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| /** | |||||
| * 建行收款码支付 | |||||
| * | |||||
| * 需银行配置回调地址 | |||||
| * | |||||
| * @author Administrator | |||||
| * | |||||
| */ | |||||
| @Slf4j | |||||
| @Service | |||||
| public class JianHangWxMiniProgramServiceImpl extends PayBillBaseService implements PayBillAdapterService { | |||||
| private static final String url = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; | |||||
| @Autowired | |||||
| WxBuserMapper wxBuserMapper; | |||||
| //建行微信支付接口 | |||||
| @Override | |||||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,CUser bOpenUser,WxAllBill billdetail,Double money,Map<String, String> params) throws Exception { | |||||
| return MiniProgramDemo.getMa(wxPayAccountBill,bOpenUser, buser, billdetail, money); | |||||
| } | |||||
| @Override | |||||
| public void paidCallBack(String tenantId,WxBillPayWay payWay, Map paramMap) { | |||||
| String success = (String) paramMap.get("SUCCESS"); | |||||
| if ("Y".equals(success.toUpperCase())) { | |||||
| String money = (String) paramMap.get("PAYMENT"); | |||||
| String remark1 = (String) paramMap.get("REMARK1"); | |||||
| String[] remark1_args = remark1.split("_"); | |||||
| Integer billType = Integer.parseInt(remark1_args[0]); | |||||
| Long billId = Long.parseLong(remark1_args[1]); | |||||
| Long merchantBUserId = Long.parseLong((String)paramMap.get("REMARK2")); | |||||
| String orderId = (String) paramMap.get("ORDERID"); | |||||
| this.updateBillPaid(tenantId, merchantBUserId, EnumBillAllType.getEnum(billType), billId, | |||||
| money, payWay, "商户单号"+orderId); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,106 @@ | |||||
| package com.iformall.service.payBill.impl.jianhang; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| import com.google.gson.Gson; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.CUser; | |||||
| import com.iformall.domain.po.WxAllBill; | |||||
| import com.iformall.domain.po.WxMerchantBUser; | |||||
| import com.iformall.domain.po.WxPayAccountBill; | |||||
| import com.iformall.utils.DateUtils; | |||||
| import com.iformall.utils.HttpUtil; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| @Slf4j | |||||
| public class MiniProgramDemo { | |||||
| private static final String bankURL="https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; | |||||
| public static String getMa(WxPayAccountBill wxPayAccountBill,CUser bOpenIdUser,WxMerchantBUser buser,WxAllBill billdetail,Double money) throws Exception { | |||||
| String MERCHANTID = wxPayAccountBill.getPayConfigString("MERCHANTID"); | |||||
| String POSID = wxPayAccountBill.getPayConfigString("POSID"); | |||||
| String BRANCHID = wxPayAccountBill.getPayConfigString("BRANCHID"); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| String ORDERID = billdetail.getBillType()+"_"+idWorker.nextId(); | |||||
| String PAYMENT= money.toString(); | |||||
| String CURCODE="01"; | |||||
| String TXCODE = "530590"; | |||||
| String REMARK1 = billdetail.getBillType()+"_"+billdetail.getId(); | |||||
| String REMARK2 = String.valueOf(buser.getId()); | |||||
| String MAC = "1"; | |||||
| String GATEWAY="0"; | |||||
| String TRADE_TYPE="MINIPRO";//JSAPI-- 公 众 号 支 付 、MINIPRO--小程序 | |||||
| String SUB_APPID=bOpenIdUser.getAppId(); | |||||
| String SUB_OPENID=bOpenIdUser.getOpenId(); | |||||
| String TIMEOUT = DateUtils.date2String(DateUtils.getSecondsTimeAfter(10*60, new Date()), DateUtils.DATE_PATTERN_ALL_NOSPACE); | |||||
| String PUB32TR2= wxPayAccountBill.getPayConfigString("PUB_30"); | |||||
| StringBuffer tmp = new StringBuffer(); //��ǩ�ֶ� | |||||
| tmp.append("MERCHANTID="); | |||||
| tmp.append(MERCHANTID); | |||||
| tmp.append("&POSID="); | |||||
| tmp.append(POSID); | |||||
| tmp.append("&BRANCHID="); | |||||
| tmp.append(BRANCHID); | |||||
| tmp.append("&ORDERID="); | |||||
| tmp.append(ORDERID); | |||||
| tmp.append("&PAYMENT="); | |||||
| tmp.append(PAYMENT); | |||||
| tmp.append("&CURCODE="); | |||||
| tmp.append(CURCODE); | |||||
| tmp.append("&TXCODE="); | |||||
| tmp.append(TXCODE); | |||||
| tmp.append("&REMARK1="); | |||||
| tmp.append(REMARK1); | |||||
| tmp.append("&REMARK2="); | |||||
| tmp.append(REMARK2); | |||||
| tmp.append("&MAC="); | |||||
| tmp.append(MAC); | |||||
| tmp.append("&GATEWAY="); | |||||
| tmp.append(GATEWAY); | |||||
| tmp.append("&TRADE_TYPE="); | |||||
| tmp.append(TRADE_TYPE); | |||||
| tmp.append("&SUB_APPID="); | |||||
| tmp.append(SUB_APPID); | |||||
| tmp.append("&SUB_OPENID="); | |||||
| tmp.append(SUB_OPENID); | |||||
| tmp.append("&TIMEOUT="); | |||||
| tmp.append(TIMEOUT); | |||||
| tmp.append("&PUB="); | |||||
| tmp.append(PUB32TR2); | |||||
| Map map = new HashMap(); | |||||
| map.put("CCB_IBSVersion","V6"); //������ | |||||
| map.put("MERCHANTID",MERCHANTID); | |||||
| map.put("BRANCHID",BRANCHID); | |||||
| map.put("POSID",POSID); | |||||
| map.put("ORDERID",ORDERID); | |||||
| map.put("PAYMENT",PAYMENT); | |||||
| map.put("CURCODE",CURCODE); | |||||
| map.put("TXCODE",TXCODE); | |||||
| map.put("REMARK1",REMARK1); | |||||
| map.put("REMARK2",REMARK2); | |||||
| map.put("MAC",MAC); | |||||
| map.put("GATEWAY",GATEWAY); | |||||
| map.put("TRADE_TYPE",TRADE_TYPE); | |||||
| map.put("SUB_APPID",SUB_APPID); | |||||
| map.put("SUB_OPENID",SUB_OPENID); | |||||
| map.put("TIMEOUT",TIMEOUT); | |||||
| map.put("MAC",MD5.md5Str(tmp.toString())); | |||||
| String ret = HttpUtil.doPost(bankURL, map); //�����ά���������Ӵ� | |||||
| Gson gson = new Gson(); | |||||
| QrURLDemo qrurl = (QrURLDemo) gson.fromJson(ret, QrURLDemo.class); | |||||
| log.info("jianhang payUrl:"+qrurl.getPAYURL()); | |||||
| //ret = HttpUtil.httpGet(qrurl.getPAYURL(), "UTF-8"); //��ȡ��ά�봮 | |||||
| ret = HttpUtil.doGet(qrurl.getPAYURL()); | |||||
| log.info(" jianhang ret :"+ret); | |||||
| String result = HttpUtil.doPost(ret,null); | |||||
| log.info("jianhang request miniprograme:"+ret+"[result]"+result); | |||||
| return result; | |||||
| } | |||||
| } | |||||
| @@ -18,7 +18,7 @@ import lombok.extern.slf4j.Slf4j; | |||||
| @Slf4j | @Slf4j | ||||
| public class QrDemo { | public class QrDemo { | ||||
| private static final String bankURL="https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain"; | |||||
| private static final String bankURL="https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; | |||||
| public static String getMa(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,WxAllBill billdetail,Double money) throws Exception { | public static String getMa(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,WxAllBill billdetail,Double money) throws Exception { | ||||
| String MERCHANTID = wxPayAccountBill.getPayConfigString("MERCHANTID"); | String MERCHANTID = wxPayAccountBill.getPayConfigString("MERCHANTID"); | ||||
| @@ -13,8 +13,10 @@ import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.CUser; | |||||
| import com.iformall.domain.po.WxAllBill; | import com.iformall.domain.po.WxAllBill; | ||||
| import com.iformall.domain.po.WxBillPayWay; | import com.iformall.domain.po.WxBillPayWay; | ||||
| import com.iformall.domain.po.WxBuser; | |||||
| import com.iformall.domain.po.WxMerchantBUser; | import com.iformall.domain.po.WxMerchantBUser; | ||||
| import com.iformall.domain.po.WxPayAccount; | import com.iformall.domain.po.WxPayAccount; | ||||
| import com.iformall.domain.po.WxPayAccountBill; | import com.iformall.domain.po.WxPayAccountBill; | ||||
| @@ -42,7 +44,7 @@ public class WxMiniProgramServiceImpl extends PayBillBaseService implements PayB | |||||
| WxPayAccountService wxPayAccountService; | WxPayAccountService wxPayAccountService; | ||||
| @Override | @Override | ||||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,WxAllBill billdetail,Double money,Map<String, String> params) throws Exception{ | |||||
| public Object createPay(WxPayAccountBill wxPayAccountBill,WxMerchantBUser buser,CUser bOpenUser,WxAllBill billdetail,Double money,Map<String, String> params) throws Exception{ | |||||
| String openId = params.get("openId"); | String openId = params.get("openId"); | ||||
| if (StringUtils.isBlank(openId)) { | if (StringUtils.isBlank(openId)) { | ||||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND.getCode(),"参数openId为空"); | throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND.getCode(),"参数openId为空"); | ||||