|
@@ -1,38 +1,21 @@
|
|
|
package com.minpay.common.pay;
|
|
|
|
|
|
-import java.net.URLEncoder;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.SortedMap;
|
|
|
-import java.util.TreeMap;
|
|
|
-
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-
|
|
|
import com.min.base64.Base64;
|
|
|
import com.min.des.DesUtils;
|
|
|
import com.minpay.common.bean.User;
|
|
|
import com.minpay.common.exception.BusinessCodeException;
|
|
|
+import com.minpay.common.pay.bean.Huilianpay;
|
|
|
import com.minpay.common.service.IAccountService;
|
|
|
+import com.minpay.common.service.IHuilianPayService;
|
|
|
import com.minpay.common.service.IPropertiesService;
|
|
|
import com.minpay.common.service.IPublicService;
|
|
|
+import com.minpay.common.service.impl.HuilianPayServiceImpl;
|
|
|
import com.minpay.common.util.CommonUtil;
|
|
|
import com.minpay.common.util.DateUtil;
|
|
|
import com.minpay.common.util.HttpPostUtil;
|
|
|
import com.minpay.common.util.PayCommonUtil;
|
|
|
-import com.minpay.db.table.mapper.VmDeliveryInfMapper;
|
|
|
-import com.minpay.db.table.mapper.VmEquipmentInfMapper;
|
|
|
-import com.minpay.db.table.mapper.VmOrderDetailsMapper;
|
|
|
-import com.minpay.db.table.mapper.VmOrderInfMapper;
|
|
|
-import com.minpay.db.table.mapper.VmPaymentInfMapper;
|
|
|
-import com.minpay.db.table.model.VmDeliveryInf;
|
|
|
-import com.minpay.db.table.model.VmEquipmentInf;
|
|
|
-import com.minpay.db.table.model.VmOrderDetails;
|
|
|
-import com.minpay.db.table.model.VmOrderDetailsExample;
|
|
|
-import com.minpay.db.table.model.VmOrderInf;
|
|
|
-import com.minpay.db.table.model.VmOrderInfExample;
|
|
|
-import com.minpay.db.table.model.VmPaymentInf;
|
|
|
-import com.minpay.db.table.model.VmPaymentInfExample;
|
|
|
+import com.minpay.db.table.mapper.*;
|
|
|
+import com.minpay.db.table.model.*;
|
|
|
import com.minpay.db.table.own.mapper.DeliveryMapper;
|
|
|
import com.minpay.shouhuo.deliveryaction.DeliveryAction;
|
|
|
import com.minpay.shouhuo.orderdrawaction.OrderDrawAction;
|
|
@@ -47,8 +30,10 @@ import com.startup.minpay.frame.session.MINSession;
|
|
|
import com.startup.minpay.frame.target.MINAction;
|
|
|
import com.startup.minpay.frame.target.MINComponent;
|
|
|
import com.startup.minpay.frame.target.MINParam;
|
|
|
-
|
|
|
import net.sf.json.JSONObject;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 售货机支付通用接口
|
|
@@ -72,7 +57,7 @@ public class ShouhuoPay implements IMINAction{
|
|
|
* 通用支付
|
|
|
* @param payAmt 支付总金额
|
|
|
* @param orderId 支付订单号
|
|
|
- * @param payType 支付类型(00:微信或支付宝支付, 09:钱包支付, 02:固码支付)
|
|
|
+ * @param payType 支付类型(渠道 WX微信 ALI 支付宝)
|
|
|
* @param session
|
|
|
* @param fapRequest
|
|
|
* @return
|
|
@@ -155,7 +140,7 @@ public class ShouhuoPay implements IMINAction{
|
|
|
payMentInf.setFlowno(nowTime.concat(flowno).concat("pt"));
|
|
|
}else if("03".equals(payMentInf.getType())){
|
|
|
payMentInf.setFlowno(nowTime.concat(flowno).concat("dl"));
|
|
|
- }
|
|
|
+ }
|
|
|
payMentInf.setTranflowno(orderId);
|
|
|
payMentInf.setTranmissiondatetime(nowTime);
|
|
|
// 交易状态(0 初始状态,1成功,2失败,3在途,4待审核,5已审核)
|
|
@@ -173,108 +158,57 @@ public class ShouhuoPay implements IMINAction{
|
|
|
Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPaymentInfMapper.class).updateByExampleSelective(paymentInf, paymentExp);
|
|
|
}
|
|
|
}
|
|
|
+ Map<String, Object> resMap = null;
|
|
|
try {
|
|
|
VmPaymentInf paymentInf = new VmPaymentInf();
|
|
|
// 支付通道
|
|
|
String payChannel = Service.lookup(IPublicService.class).getSysParValue(user.getChannel() +"_PERSONALPAY_PAY_CHANNEL");
|
|
|
- // Personalpay支付,并且不是抽奖订单
|
|
|
- // ProType:00正常商品,01抽奖商品,02:充值',
|
|
|
- // payType:并且不是钱包支付00:微信或支付宝支付, 09:钱包支付, 02:固码支付
|
|
|
- if("PEP".equals(payChannel)
|
|
|
- && !"01".equals(ordInf.getProType())
|
|
|
- && !"09".equals(payType)) {
|
|
|
- String appid = Service.lookup(IPublicService.class).getSysParValue(user.getChannel() + "_PERSONALPAY_APP_ID");
|
|
|
- String mchid = Service.lookup(IPublicService.class).getSysParValue(user.getChannel() + "_PERSONALPAY_MCH_ID");
|
|
|
- String appSecret = Service.lookup(IPublicService.class).getSysParValue(user.getChannel() + "_PERSONALPAY_APP_SECRET");
|
|
|
- //正常商品的订单回调前台地址
|
|
|
- String return_url = Service.lookup(IPublicService.class).getSysParValue(user.getChannel() + "_SHOUHUO_RETURN_URL_00");
|
|
|
- if("01".equals(ordInf.getProType())){
|
|
|
- //抽奖的订单回调前台地址
|
|
|
- return_url = Service.lookup(IPublicService.class).getSysParValue(user.getChannel() + "_SHOUHUO_RETURN_URL_01");
|
|
|
- }
|
|
|
- //支付后台回调地址
|
|
|
- String notify_url = Service.lookup(IPublicService.class).getSysParValue(user.getChannel() + "_SHOUHUO_NOTIFY_URL");
|
|
|
- notify_url = notify_url + "/ShouhuoPay/personalPayCallBack";
|
|
|
|
|
|
+ //汇联
|
|
|
+ if("HLZF".equals(payChannel)
|
|
|
+ && !"01".equals(ordInf.getProType())
|
|
|
+ && !"09".equals(payType)) {
|
|
|
VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmEquipmentInfMapper.class).selectByPrimaryKey(ordInf.getEquipmentId());
|
|
|
if(equipmentInf == null) {
|
|
|
throw new MINBusinessException("没有找到此售货机");
|
|
|
}
|
|
|
- //收款账户
|
|
|
- //String perpayId = equipmentInf.getPersonalpayId();
|
|
|
- //创建PersonalPay订单对象
|
|
|
- SortedMap<Object, Object> perPay = new TreeMap<Object, Object>();
|
|
|
- perPay.put("appid", appid);//appId
|
|
|
- String channel = "SQ";
|
|
|
- if(equipmentInf.getCreditChannel().equals("WX")){
|
|
|
- channel = "ON";
|
|
|
- }
|
|
|
- // 01 账户支付、02 预付卡支付、03 网银支付、04快捷支付 91微信支付92支付宝支付 93钱包支付
|
|
|
- String pay = paymenList.get(0).getPaytype();
|
|
|
- if("92".equals(pay)) {
|
|
|
- pay = "AL";
|
|
|
- }
|
|
|
- else {
|
|
|
- pay = "WX";
|
|
|
+ String branchid = equipmentInf.getBranchid();
|
|
|
+ //查询商户开通了那个支付渠道
|
|
|
+ String pay_channel = Service.lookup(IPublicService.class).getSysParValue( "PAY_CHANNEL");
|
|
|
+ //查询机器所属机构
|
|
|
+ VmAccountExample accExp = new VmAccountExample();
|
|
|
+ accExp.createCriteria().andChannelEqualTo(user.getChannel()).andUsridEqualTo(branchid).andTypeEqualTo(pay_channel);
|
|
|
+ List<VmAccount> accList = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmAccountMapper.class).selectByExample(accExp);
|
|
|
+ if(accList.size() != 1 ){
|
|
|
+ throw new MINBusinessException("商户收款账户异常");
|
|
|
}
|
|
|
- // 固码
|
|
|
- if("02".equals(payType)) {
|
|
|
- if("AL".equals(pay)) {
|
|
|
- pay = "AG";
|
|
|
- }
|
|
|
- else {
|
|
|
- pay = "WG";
|
|
|
- }
|
|
|
- }
|
|
|
- perPay.put("channel", pay);//AL:支付宝, WX:微信商户模式,WG:微信固定码,AG:支付宝固定码 默认:AL
|
|
|
- perPay.put("mchid",mchid);//商户号
|
|
|
- //perPay.put("recuser_no", perpayId);//收款人编号
|
|
|
- perPay.put("nonce_str",System.currentTimeMillis() + "");//随机字符串
|
|
|
- perPay.put("signtype","MD5");//加密类型
|
|
|
- perPay.put("amt",String.valueOf(payAmt));//交易金额CommonUtil.objToint(CommonUtil.multiply(payAmt, "100"))
|
|
|
- perPay.put("orderno",orderId);//交易订单号
|
|
|
- perPay.put("goodsname","shouhuojimaihuo");//商品名称
|
|
|
- perPay.put("tradeType","JSAPI");//这个api有,固定的//交易类型
|
|
|
- perPay.put("openid",user.getOpenid());//微信openId
|
|
|
- perPay.put("userType",channel);//XL支付渠道-迅联SQ收钱吧
|
|
|
- perPay.put("notify_url",notify_url);//后台通知地址
|
|
|
- perPay.put("return_url", URLEncoder.encode(return_url.concat("/"+orderId),"UTF-8"));//前台通知地址
|
|
|
- String paySign = PayCommonUtil.createSign("UTF-8", perPay, appSecret);
|
|
|
- perPay.put("return_url", return_url.concat("/"+orderId));//前台通知地址
|
|
|
- perPay.put("sign",paySign);//加密后字符串
|
|
|
- /**
|
|
|
- * 返回值信息
|
|
|
- * code = 0, // 0:正常返回,其他失败
|
|
|
- * orderId = 102323203232, // 商户订单号
|
|
|
- * sysorderId = 20190423092353971219, // 系统平台订单号
|
|
|
- * qrurl = wxp: //f2f1dQahAFcErd2-QFD0GAuiQQE-zv1P65u3, // 付款二维码
|
|
|
- * orderAmt = 0.03, // 实际客户支付交易金额
|
|
|
- * orderThAmt = 0.02, // 第三方发起交易金额
|
|
|
- * qrBase64=data:image/jpeg;base64,iVBORw // 二维码BASE64串,可直接用img标签使用
|
|
|
- */
|
|
|
- //获取请求PersonalPay的路径"http://api.personalpay.net/api/";
|
|
|
- String url = Service.lookup(IPropertiesService.class)
|
|
|
- .getSystemProperties().get(user.getChannel() + "_PERSONALPAY_PAY_ADDRESS").getKey();
|
|
|
- String str = PayCommonUtil.getRequestJSON(perPay);
|
|
|
- String results = HttpPostUtil.sendPostFormachine(url.concat("OrderAction/createOrder"), str);
|
|
|
- //获取转义后响应信息
|
|
|
- JSONObject detail = JSONObject.fromObject(results);
|
|
|
- //获取code,用来判断是否认证成功
|
|
|
- String code = String.valueOf(detail.get("code"));
|
|
|
- if(!"0".equals(code)){
|
|
|
- throw new BusinessCodeException("JINM0115");//操作失败!
|
|
|
+ String accNo = accList.get(0).getNumber();
|
|
|
+
|
|
|
+ //支付后台回调地址
|
|
|
+ String notify_url = Service.lookup(IPublicService.class).getSysParValue(user.getChannel() + "_SHOUHUO_NOTIFY_URL");
|
|
|
+ notify_url = notify_url + "/ShouhuoPay/personalPayCallBack";
|
|
|
+ if("05".equals(pay_channel)){
|
|
|
+ pay_channel = "09";
|
|
|
}
|
|
|
- res.set("qrurl", detail.get("qrurl"));
|
|
|
- res.set("qrBase64", detail.get("qrBase64"));
|
|
|
- paymentInf.setPayChl("PEP");
|
|
|
- // 更新支付渠道
|
|
|
- Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPaymentInfMapper.class).updateByExampleSelective(paymentInf, paymentExp);
|
|
|
+ Huilianpay prePay = new Huilianpay();
|
|
|
+ IHuilianPayService huilianPayService = new HuilianPayServiceImpl();
|
|
|
+ prePay.setChannel(payType);
|
|
|
+ prePay.setNotifyUrl(notify_url);
|
|
|
+ prePay.setOpenId(user.getOpenid());
|
|
|
+ prePay.setOutTradeNo(orderId);
|
|
|
+ prePay.setProviderType(pay_channel);
|
|
|
+ prePay.setTotalAmount(payAmt);
|
|
|
+ prePay.setHlMerchantId(accNo);
|
|
|
+ resMap = huilianPayService.prePay(prePay);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new MINBusinessException("调用支付失败");
|
|
|
}
|
|
|
+
|
|
|
// 抽奖订单
|
|
|
- if("01".equals(ordInf.getProType())) {
|
|
|
+ /*if("01".equals(ordInf.getProType())) {
|
|
|
// 减余额
|
|
|
// 创建用户基本账户
|
|
|
IAccountService accservice = Service.lookup(IAccountService.class);
|
|
@@ -294,8 +228,10 @@ public class ShouhuoPay implements IMINAction{
|
|
|
CommonUtil.multiply(ordInf.getOrderAmt(), "-1"), "41", ordInf.getId(), "购买商品");
|
|
|
//调用真实回调
|
|
|
backEx(ordInf.getId(), "0000000000", "TRADE_SUCCESS", ordInf.getOrderAmt(), "000000", "", "93");
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ res.set("payMap",resMap);
|
|
|
return res;
|
|
|
+
|
|
|
}
|
|
|
/**
|
|
|
* 查询PersonalPay的订单状态
|