Commit d3e0bb7e by Java-聂换换

商户进件

parent 2fedb02f
......@@ -655,6 +655,20 @@
<version>4.5</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>2.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alipay.sdk/alipay-sdk-java -->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
<build>
......
package com.thinkgem.jeesite.common.constant;
import com.thinkgem.jeesite.common.config.Global;
import java.text.SimpleDateFormat;
/**
......@@ -52,6 +54,14 @@ public class ComCode {
public static final String DLB_CREATE_URL = "/v1/customer/order/pay/create";// 创建支付订单的接口
/**
* 微信相关
*/
public static final String WEIXIN_MERCHANT_ID = Global.getConfig("weixin.merchant.id");// 店铺编号(需要用户提供)
public static final String WEIXIN_APPID = Global.getConfig("weixin.appid");
public static final String WEIXIN_APPSECRET = Global.getConfig("weixin.appid");
public static final String WEIXIN_UNIFIEDPAY_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
/**
* 时间相关参数
......
......@@ -6,6 +6,8 @@ import com.thinkgem.jeesite.modules.commonError.MyException;
import com.thinkgem.jeesite.modules.pay.entity.OrderEntity;
import com.thinkgem.jeesite.modules.pay.juhezhong.dto.PayBackDto;
import com.thinkgem.jeesite.modules.pay.service.PayApiService;
import com.thinkgem.jeesite.modules.sys.entity.Dict;
import com.thinkgem.jeesite.modules.sys.service.DictService;
import com.thinkgem.jeesite.modules.user.bean.JuHeZhongPayRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
......@@ -18,10 +20,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.*;
/**
* 支付相关
......@@ -32,6 +31,9 @@ public class PayApiController {
@Autowired
private PayApiService payService;
@Autowired
private DictService dictService;
/**
* 快捷支付
*
......@@ -43,9 +45,16 @@ public class PayApiController {
Response resp = new Response();
try {
PayBackDto payBackDto = payService.quickPay(request);
resp.setStatus(ComCode.STATUS_CODE_2000);
resp.setMessage(ComCode.STATUS_CODE_2000_DESC);
resp.setData(payBackDto);
if(payBackDto.getUrl()!=null && !"".equals(payBackDto.getUrl())){
resp.setStatus(ComCode.STATUS_CODE_2000);
resp.setMessage(ComCode.STATUS_CODE_2000_DESC);
resp.setData(payBackDto);
}else{
resp.setStatus(ComCode.STATUS_CODE_9998);
resp.setMessage(payBackDto.getMessage());
resp.setData(payBackDto);
}
} catch (MyException e){
resp.setStatus(ComCode.STATUS_CODE_9998);
resp.setMessage(ComCode.STATUS_CODE_9998_DESC);
......@@ -174,4 +183,13 @@ public class PayApiController {
}
@RequestMapping("/getDict")
public Response getDict(Dict dict){
Response response = new Response();
List<Dict> list = dictService.findList(dict);
response.setStatus(ComCode.STATUS_CODE_2000);
response.setData(list);
return response;
}
}
......@@ -7,6 +7,7 @@ package com.thinkgem.jeesite.modules.pay.juhezhong.dto;
*/
public class PayBackDto {
private String url; // 支付url
private String message;
public String getUrl() {
return url;
......@@ -15,4 +16,12 @@ public class PayBackDto {
public void setUrl(String url) {
this.url = url;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
......@@ -2,6 +2,7 @@ package com.thinkgem.jeesite.modules.pay.juhezhong.service;
import com.alibaba.fastjson.JSONObject;
import com.thinkgem.jeesite.common.constant.ComCode;
import com.thinkgem.jeesite.common.utils.IdGen;
import com.thinkgem.jeesite.modules.pay.juhezhong.dto.CommonDto;
import com.thinkgem.jeesite.modules.pay.juhezhong.dto.MerchantDto;
import com.thinkgem.jeesite.modules.pay.juhezhong.dto.MerchantsEntering;
......@@ -66,31 +67,83 @@ public class JuHeZhongPayIntegralService {
// System.out.println(jsonObject.toJSONString());
JuHeZhongPayIntegralService juHeZhongPayIntegralService = new JuHeZhongPayIntegralService();
// JSONObject dto = new JSONObject();
//
// dto.put("orderId", MakeOrderNum.makeOrderNum());//标识请求唯一(非订单号)
// dto.put("serviceType", 1);//服务类型
// dto.put("merchantId", ComCode.INTEGRAL_MERCHANT_ID);//商户号
// dto.put("subMerchantName", "libo");//对公的就按照营业执照的注册名称进行商户名的报备进件,个体户的需要突出省,市,区一级营业范围,如:“XX市+XX区+法人名称+营业范围”--例“北京市朝阳区洪新阳饭店”而且一个身份证不要重复入很多个做银联二维码交易的商户 原则上一个身份证下只有一个做银联二维码交易的户,23:00—7:00,这段时间,银联二维码可以交易,不结算
//
// dto.put("accName", "李波");//开户名称
// dto.put("accNo", "6222621210006388191");//开户账号
// dto.put("accType",1); //1=个人账户 0=企业账户1=个人账户
//
// dto.put("bankName", "交通银行");//开户银行名(支行全称)
// dto.put("bankCode", "301290000007");//联行号
// dto.put("mobile","13821934497");
// dto.put("idNo","53250219850831031X");//身份证号
// dto.put("settleType","795934");//费率类型 795934
// dto.put("address","天津市河西区");//地址
// dto.put("merchantKey", ComCode.INTEGRAL_MERCHANT_KEY);//商户key
// dto.put("timestamp", System.currentTimeMillis());//时间戳
//
// JSONObject jsonObject = juHeZhongPayIntegralService.quickPayHandle(dto);
//
// String signBefore = SignUtils.signBefore(jsonObject);
// String sign = SignUtils.sign(signBefore, ComCode.INTEGRAL_MERCHANT_SECRET);
//B105004538
JSONObject dto = new JSONObject();
dto.put("orderId", MakeOrderNum.makeOrderNum());//标识请求唯一(非订单号)
dto.put("serviceType", 1);//服务类型
dto.put("merchantId", ComCode.INTEGRAL_MERCHANT_ID);//商户号
dto.put("subMerchantName", "niehh");//对公的就按照营业执照的注册名称进行商户名的报备进件,个体户的需要突出省,市,区一级营业范围,如:“XX市+XX区+法人名称+营业范围”--例“北京市朝阳区洪新阳饭店”而且一个身份证不要重复入很多个做银联二维码交易的商户 原则上一个身份证下只有一个做银联二维码交易的户,23:00—7:00,这段时间,银联二维码可以交易,不结算
dto.put("accName", "聂换换");//开户名称
dto.put("accNo", "6217000180000770507");//开户账号
dto.put("accType",1); //1=个人账户 0=企业账户1=个人账户
dto.put("bankName", "建设银行");//开户银行名(支行全称)
dto.put("bankCode", "105100000017");//联行号
dto.put("mobile","13722537737");
dto.put("idNo","130434199212214429");//身份证号
dto.put("settleType","795934");//费率类型 795934
dto.put("address","天津市河西区");//地址
dto.put("serviceType", 10);// 服务类型
dto.put("merchantId",ComCode.INTEGRAL_MERCHANT_ID);//商户号
dto.put("orderId", IdGen.randomBase62(64));//订单号
// 李波的交通银行卡subMchId 403196720
dto.put("subMchId", "403196720");//由系统分配的商户号
dto.put("merchantKey", ComCode.INTEGRAL_MERCHANT_KEY);//商户key
dto.put("timestamp", System.currentTimeMillis());//时间戳
JSONObject jsonObject = juHeZhongPayIntegralService.quickPayHandle(dto);
String signBefore = SignUtils.signBefore(jsonObject);
String sign = SignUtils.sign(signBefore, ComCode.INTEGRAL_MERCHANT_SECRET);
//B105004538
// JSONObject dto = new JSONObject();
//
// dto.put("serviceType", 4);// 服务类型
// dto.put("orderId", IdGen.randomBase62(64));//订单号
// dto.put("amount", 5000);//交易金额
// dto.put("merchantId",ComCode.INTEGRAL_MERCHANT_ID);//商户号
// dto.put("subMchId", "403196720");//由系统分配的商户号
// dto.put("accNo", "6225571645517950");//开卡 唯一标识
//// dto.put("accNo", "6210210010501799229");//开卡 唯一标识
// dto.put("mobile","13821934497");
//
// dto.put("productName", "收款");//标题
// dto.put("notifyUrl", "http://pay.hezhongpay.com");//支付完成 异步通知结果
// dto.put("frontUrl", "http://www.baidu.com");//返回商户页面
// dto.put("merchantKey", ComCode.INTEGRAL_MERCHANT_KEY);//商户key
// dto.put("timestamp", System.currentTimeMillis());//时间戳
// System.out.println(dto.toJSONString());
// JSONObject jsonObject = juHeZhongPayIntegralService.quickPayHandle(dto);
// JSONObject dto = new JSONObject();
//
// dto.put("serviceType", 4);// 服务类型
// dto.put("orderId", IdGen.randomBase62(64));//订单号
// dto.put("amount", 5000);//交易金额
// dto.put("merchantId",ComCode.INTEGRAL_MERCHANT_ID);//商户号
// dto.put("subMchId", "403192069");//由系统分配的商户号
// dto.put("accNo", "6225767500540075");//开卡 唯一标识
//// dto.put("accNo", "6210210010501799229");//开卡 唯一标识
// dto.put("mobile","13722537737");
//
// dto.put("productName", "收款");//标题
// dto.put("notifyUrl", "http://pay.hezhongpay.com");//支付完成 异步通知结果
// dto.put("frontUrl", "http://www.baidu.com");//返回商户页面
// dto.put("merchantKey", ComCode.INTEGRAL_MERCHANT_KEY);//商户key
// dto.put("timestamp", System.currentTimeMillis());//时间戳
// System.out.println(dto.toJSONString());
// JSONObject jsonObject = juHeZhongPayIntegralService.quickPayHandle(dto);
System.out.println(jsonObject.toJSONString());
}
......
package com.thinkgem.jeesite.modules.pay.juhezhong.utils;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.*;
/**
* 将Map转换为Obj的工具类
......@@ -73,4 +70,34 @@ public class Bean2Map {
}
}
public static SortedMap Entity2SortedMap(Object thisObj) {
SortedMap map = new TreeMap();
Class c;
try {
c = Class.forName(thisObj.getClass().getName());
Method[] m = c.getMethods();
for (int i = 0; i < m.length; i++) {
String method = m[i].getName();
if (method.startsWith("get")) {
try {
Object value = m[i].invoke(thisObj);
if (value != null) {
String key = method.substring(3);
if (key.toLowerCase().equals("class".toLowerCase())) {
continue;
}
key = key.substring(0, 1).toLowerCase()
+ key.substring(1);
map.put(key, value);
}
} catch (Exception e) {
System.out.println("error:" + method);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
}
......@@ -133,4 +133,6 @@ public abstract class MD5Utils {
return false;
}
}
}
......@@ -16,6 +16,7 @@ import com.thinkgem.jeesite.modules.pay.juhezhong.dto.ApiQuickPayDto;
import com.thinkgem.jeesite.modules.pay.juhezhong.dto.MerchantDto;
import com.thinkgem.jeesite.modules.pay.juhezhong.dto.PayBackDto;
import com.thinkgem.jeesite.modules.pay.juhezhong.dto.QuickDto;
import com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayIntegralService;
import com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayService;
import com.thinkgem.jeesite.modules.user.bean.JuHeZhongPayRequest;
import com.thinkgem.jeesite.modules.user.bean.UserRequest;
......@@ -45,6 +46,9 @@ public class PayApiService {
@Autowired
private JuHeZhongPayService juHeZhongPayService;
@Autowired
private JuHeZhongPayIntegralService juHeZhongPayIntegralService;
@Transactional(readOnly = false)
public PayBackDto quickPay(JuHeZhongPayRequest request) throws MyException, Exception {
// 1. 根据入参获取用户详情信息,包括支付卡片信息
......@@ -72,7 +76,22 @@ public class PayApiService {
payDao.saveBenefitInfo(benefitEntity);
}
// 4. JuHeZhong支付
PayBackDto payBackDto = quickPayJuHeZhongPay(userEntity, orderEntity, request);
PayBackDto payBackDto = new PayBackDto();
// 获取支付卡号
CardEntity cardEntityPay = userService.getCardInfo(request);
if("quick_no_integral".equals(request.getPayChannel())){
payBackDto = quickPayJuHeZhongPay(userEntity, orderEntity, request,cardEntityPay);
}else if("quick_integral".equals(request.getPayChannel())){
if(!"C".equals(cardEntityPay.getCardType())){
payBackDto.setMessage("只能用信用卡支付");
}else if(cardEntityPay.getSupportPayChannel()==null || !cardEntityPay.getSupportPayChannel().contains("quick_integral,")){
payBackDto.setMessage("不支持"+cardEntityPay.getBankName());
}else{
payBackDto = this.quickPayJuHeZhongIntegralPay(userEntity, orderEntity, request,cardEntityPay);
}
}
return payBackDto;
}
......@@ -82,13 +101,13 @@ public class PayApiService {
*/
/**
* JuHeZhong快捷支付
* JuHeZhong 无积分快捷支付
*
* @param userEntity
* @param request
* @throws Exception
*/
public PayBackDto quickPayJuHeZhongPay(UserEntity userEntity, OrderEntity orderEntity, JuHeZhongPayRequest request) throws Exception {
public PayBackDto quickPayJuHeZhongPay(UserEntity userEntity, OrderEntity orderEntity, JuHeZhongPayRequest request,CardEntity cardEntity) throws Exception {
// 快捷支付
// ApiQuickPayDto quickPayDto = new ApiQuickPayDto();
// quickPayDto.setMerchantId(ComCode.MERCHANT_ID);
......@@ -120,7 +139,6 @@ public class PayApiService {
quickDto.setAmount(Long.parseLong(request.getAmount())*100);
// 获取支付卡号
CardEntity cardEntity = userService.getCardInfo(request);
quickDto.setBankNo(cardEntity.getCardNo()); // 支付卡号
quickDto.setSettleBankName(userEntity.getUserDetail().getCard().getBelongBank());
......@@ -133,7 +151,7 @@ public class PayApiService {
RateEntity rateEntity = new RateEntity();
rateEntity.setUserLevel(userEntity.getLevel());
rateEntity.setPayMethod("quick");
rateEntity.setPayMethod("quick_no_integral");
rateEntity = userService.getRateByLevel(rateEntity);
if(rateEntity!=null){
double userFee = Long.parseLong(request.getAmount())*100*Double.valueOf(rateEntity.getRate());
......@@ -162,6 +180,47 @@ public class PayApiService {
return payBackDto;
}
/**
* JuHeZhong积分快捷支付
*
* @param userEntity
* @param request
* @throws Exception
*/
public PayBackDto quickPayJuHeZhongIntegralPay(UserEntity userEntity, OrderEntity orderEntity, JuHeZhongPayRequest request,CardEntity cardEntity) throws Exception {
JSONObject dto = new JSONObject();
dto.put("serviceType", 4);// 服务类型
dto.put("orderId", orderEntity.getPayCode());//订单号
dto.put("amount", Long.parseLong(request.getAmount())*100);//交易金额
dto.put("merchantId",ComCode.INTEGRAL_MERCHANT_ID);//商户号
dto.put("subMchId", userEntity.getUserDetail().getCard().getSubMerchantId());//由系统分配的商户号
dto.put("accNo", cardEntity.getCardNo());//开卡 唯一标识
// dto.put("accNo", "6210210010501799229");//开卡 唯一标识
dto.put("mobile",cardEntity.getCardMobile());
dto.put("productName", "收款");//标题
dto.put("notifyUrl", Global.getConfig("project.access.url")+"/api/pay/notifyPay");//支付完成 异步通知结果
dto.put("frontUrl", Global.getConfig("project.access.url")+"/api/pay/notifyPay");//返回商户页面
dto.put("merchantKey", ComCode.INTEGRAL_MERCHANT_KEY);//商户key
dto.put("timestamp", System.currentTimeMillis());//时间戳
System.out.println(dto.toJSONString());
JSONObject jsonObject = juHeZhongPayIntegralService.quickPayHandle(dto);
System.out.println(jsonObject.toString());
PayBackDto payBackDto = new PayBackDto();
if (!"0000".equals(jsonObject.getString("code"))) {
throw new MyException(jsonObject.getString("msg"));
}else{
payBackDto.setUrl(jsonObject.getString("url"));
}
return payBackDto;
}
public Map<String, String> getUserBenefit(UserEntity userEntity, JuHeZhongPayRequest request) {
Map<String, String> userBenefit = new HashMap<>();
String[] pathIds = (userEntity.getRecommendedPath() + userEntity.getId() + ",").split(",");
......
......@@ -9,6 +9,8 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.thinkgem.jeesite.common.baseBean.Response;
import com.thinkgem.jeesite.common.constant.ComCode;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -120,4 +122,9 @@ public class DictController extends BaseController {
return dictService.findList(dict);
}
}
......@@ -6,7 +6,7 @@ public class JuHeZhongPayRequest extends Request {
private String amount; // 金额
private String cardCode; // 支付卡code
private String subject; // 商品名称
private String payChannel; // 渠道 目前合众支付接口仅传入quick
private String payChannel; // 渠道 目前合众支付接口仅传入quick_no_integral quick_integral
public String getAmount() {
return amount;
......
......@@ -35,6 +35,8 @@ public class CardEntity extends BaseEntity implements Serializable {
private String bankShort; // 银行缩写
private String bankUrl; // 银行logo
private String supportPayChannel;
public CardEntity() {
}
......@@ -211,4 +213,12 @@ public class CardEntity extends BaseEntity implements Serializable {
public void setBankUrl(String bankUrl) {
this.bankUrl = bankUrl;
}
public String getSupportPayChannel() {
return supportPayChannel;
}
public void setSupportPayChannel(String supportPayChannel) {
this.supportPayChannel = supportPayChannel;
}
}
......@@ -228,6 +228,7 @@ public class UserApiService {
String status = "0"; // 新增卡片审核状态均为未审核
// String subMerchantId = null;//registJuHeZhongPay(request, type);
String subMerchantId = quickPayHandleJuhezhong(request,type);
submitPayTest(subMerchantId);
// 更新银行卡详情
CardEntity cardStatusEntity = new CardEntity(request.getSubMerchantCode(), "N");
userDao.updateCardStatus(cardStatusEntity);
......@@ -358,7 +359,7 @@ public class UserApiService {
dto.put("bankCode", request.getBelongBank());//联行号
dto.put("mobile",request.getMobile());
dto.put("idNo",request.getIdCard());//身份证号
dto.put("settleType","795934");//费率类型 795934
dto.put("settleType","177631");//费率类型 795934
dto.put("address",request.getCardPlace());//地址
dto.put("merchantKey", ComCode.INTEGRAL_MERCHANT_KEY);//商户key
dto.put("timestamp", System.currentTimeMillis());//时间戳
......@@ -371,6 +372,25 @@ public class UserApiService {
}
public void submitPayTest(String subMchId) throws Exception {
JSONObject dto = new JSONObject();
dto.put("serviceType", 4);// 服务类型
dto.put("merchantId",ComCode.INTEGRAL_MERCHANT_ID);//商户号
dto.put("orderId", IdGen.randomBase62(64));//订单号
dto.put("subMchId", subMchId);//由系统分配的商户号
dto.put("merchantKey", ComCode.INTEGRAL_MERCHANT_KEY);//商户key
dto.put("timestamp", System.currentTimeMillis());//时间戳
JSONObject jsonObject = juHeZhongPayIntegralService.quickPayHandle(dto);
System.out.println(jsonObject.toJSONString());
if(!"0000".equals(jsonObject.get("code"))){
throw new MyException();
}
}
/**
* 修改JuHeZhong支付用户费率
*
......
......@@ -258,6 +258,7 @@
yc.belong_bank AS belongBank,
yb.bank_name AS bankName,
yb.bank_short AS bankShort,
yb.support_pay_channel AS supportPayChannel,
yc.card_bank AS cardBank,
yc.card_place AS cardPlace,
yc.is_debit AS isDebit,
......
......@@ -113,4 +113,14 @@ pay.y = 0
## 短信相关
message.username = 710047
message.password = HY1034ZY
message.url = http://122.144.179.5:7891/mt
\ No newline at end of file
message.url = http://122.144.179.5:7891/mt
## 微信支付相关
weixin.merchant.id = 1489100872
weixin.appid = wx6a278e46e075d9f6
weixin.appsecret = libo13821934497libo1382193449700
alipay.appid = 2018041002530242
\ No newline at end of file
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