|
@@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSON;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.platform.yijia.config.YiJiaRequest;
|
|
import com.platform.yijia.config.YiJiaRequest;
|
|
import com.platform.yijia.param.request.PayInfoRequest;
|
|
import com.platform.yijia.param.request.PayInfoRequest;
|
|
|
|
+import com.platform.yijia.param.request.RechargeBalance;
|
|
|
|
+import com.platform.yijia.pojo.CustomerCardUseRecord;
|
|
|
|
+import com.platform.yijia.pojo.Oil;
|
|
import com.platform.yijia.pojo.PayOrder;
|
|
import com.platform.yijia.pojo.PayOrder;
|
|
import com.platform.yijia.service.*;
|
|
import com.platform.yijia.service.*;
|
|
import com.platform.yijia.utils.CodeMsg;
|
|
import com.platform.yijia.utils.CodeMsg;
|
|
@@ -18,6 +21,7 @@ import com.saobei.open.sdk.model.response.trade.SaobeiJsPayResponse;
|
|
import com.saobei.open.sdk.model.response.trade.SaobeiMiniPayResponse;
|
|
import com.saobei.open.sdk.model.response.trade.SaobeiMiniPayResponse;
|
|
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthMiniPayResponse;
|
|
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthMiniPayResponse;
|
|
import net.sf.json.JSONObject;
|
|
import net.sf.json.JSONObject;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -68,6 +72,11 @@ public class SaoBeiPayController {
|
|
private GzhNewsTemplateService gzhNewsTemplateService;
|
|
private GzhNewsTemplateService gzhNewsTemplateService;
|
|
@Resource
|
|
@Resource
|
|
private CustomerManagerService customerManagerService;
|
|
private CustomerManagerService customerManagerService;
|
|
|
|
+ @Resource
|
|
|
|
+ private ElectronicMembershipCardService electronicMembershipCardService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysDictDataService sysDictDataService;
|
|
|
|
+
|
|
@Value("${yijia.path.global-prefix}")
|
|
@Value("${yijia.path.global-prefix}")
|
|
private String globalPrefix;
|
|
private String globalPrefix;
|
|
@Value("${yijia.domainName}")
|
|
@Value("${yijia.domainName}")
|
|
@@ -97,13 +106,13 @@ public class SaoBeiPayController {
|
|
|
|
|
|
/***
|
|
/***
|
|
* 公众号云闪付拉起支付
|
|
* 公众号云闪付拉起支付
|
|
- * @param payInfoRequest
|
|
|
|
|
|
+ * @param rechargeBalance
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
@RequestMapping(value = {"/yunPayGzh"}, consumes = {"application/json"}, method = {RequestMethod.POST})
|
|
@RequestMapping(value = {"/yunPayGzh"}, consumes = {"application/json"}, method = {RequestMethod.POST})
|
|
@ResponseBody
|
|
@ResponseBody
|
|
- public String yunPayGzh(@RequestBody PayInfoRequest payInfoRequest) throws Exception {
|
|
|
|
|
|
+ public String yunPayGzh(@RequestBody RechargeBalance rechargeBalance) throws Exception {
|
|
//智慧易加
|
|
//智慧易加
|
|
// 商户号码:845104816000034
|
|
// 商户号码:845104816000034
|
|
// 终端号:18241101
|
|
// 终端号:18241101
|
|
@@ -111,78 +120,98 @@ public class SaoBeiPayController {
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
ResultData resultData = null;
|
|
ResultData resultData = null;
|
|
|
|
|
|
- //根据订单号查询订单信息
|
|
|
|
- String ordNo = payInfoRequest.getOrdNo();
|
|
|
|
- PayOrder payOrder=payOrderService.selectOrderInfoByOrdNo(ordNo);
|
|
|
|
- if(payOrder !=null){
|
|
|
|
- if(payOrder.getStatus().equals("0")){
|
|
|
|
- //String stationId = payInfoRequest.getStationId();
|
|
|
|
- Map<String, String> staPayChannelInfo = stationService.getStationAppIdAndAppSecret(Integer.valueOf(payInfoRequest.getStationId()));
|
|
|
|
- if(staPayChannelInfo !=null && staPayChannelInfo.containsKey("merchantNo") && staPayChannelInfo.containsKey("terminalId")
|
|
|
|
|
|
+ if(rechargeBalance !=null && StringUtils.isNotBlank(rechargeBalance.getAmt()) && StringUtils.isNotBlank(rechargeBalance.getOpenId())
|
|
|
|
+ && StringUtils.isNotBlank(rechargeBalance.getUserType()) && rechargeBalance.getStationId() !=null && StringUtils.isNotBlank(rechargeBalance.getOrderNo())){
|
|
|
|
+ String amt = rechargeBalance.getAmt();
|
|
|
|
+ String openId = rechargeBalance.getOpenId(); //公众号的openId
|
|
|
|
+ Integer stationId = rechargeBalance.getStationId();
|
|
|
|
+ String userType = rechargeBalance.getUserType();
|
|
|
|
+ String orderNo = rechargeBalance.getOrderNo();
|
|
|
|
+ CustomerCardUseRecord customerCardUseRecord = new CustomerCardUseRecord();
|
|
|
|
+ customerCardUseRecord.setOrderNo(orderNo);
|
|
|
|
+ CustomerCardUseRecord cardRecordByOrderNo = electronicMembershipCardService.getCardRecordByOrderNo(customerCardUseRecord);
|
|
|
|
+ if(cardRecordByOrderNo !=null ) {
|
|
|
|
+ if (cardRecordByOrderNo.getStatus() != null && cardRecordByOrderNo.getStatus().equals("0")) {
|
|
|
|
+ Map<String, String> staPayChannelInfo = stationService.getStationAppIdAndAppSecret(stationId);
|
|
|
|
+ if(staPayChannelInfo !=null && staPayChannelInfo.containsKey("merchantNo") && staPayChannelInfo.containsKey("terminalId")
|
|
&& staPayChannelInfo.containsKey("yunKey") && staPayChannelInfo.containsKey("gzhAppId")){
|
|
&& staPayChannelInfo.containsKey("yunKey") && staPayChannelInfo.containsKey("gzhAppId")){
|
|
- //创建client
|
|
|
|
- SaobeiApiClient<SaobeiJsPayRequest, SaobeiJsPayResponse> client = new DefaultSaobeiApiClient<>(staPayChannelInfo.get("yunKey"));
|
|
|
|
- //创建requst
|
|
|
|
- SaobeiJsPayRequest requst = new SaobeiJsPayRequest();
|
|
|
|
- requst.setPay_ver("110");
|
|
|
|
- requst.setPay_type("010");
|
|
|
|
- requst.setService_id("012");
|
|
|
|
- requst.setMerchant_no(staPayChannelInfo.get("merchantNo")); //商户号
|
|
|
|
- requst.setTerminal_id(staPayChannelInfo.get("terminalId")); //终端号
|
|
|
|
- requst.setTerminal_trace(payOrder.getOrderNo()); //订单号
|
|
|
|
- requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
|
|
|
|
- //云闪付金额单位为分
|
|
|
|
- BigDecimal totalFee = new BigDecimal(payOrder.getAmt().toString()).multiply(new BigDecimal("100")).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
|
- logger.info("该订单金额:" + payOrder.getAmt().toString()+"; 拉起云闪付上送金额(单位:分):" + totalFee.toString());
|
|
|
|
- requst.setTotal_fee(totalFee.toString());
|
|
|
|
- requst.setSub_appid(staPayChannelInfo.get("gzhAppId"));
|
|
|
|
- requst.setOpen_id(payInfoRequest.getOpenId()); //oJR5R6r4EJhaORFcPap70r_mtFZo //oRwjv4iHjSUgxNxOJOQ_60Ln7cno
|
|
|
|
- String orderBody = payOrder.getOilName() + " - " +payOrder.getStationName();
|
|
|
|
- requst.setOrder_body(orderBody);
|
|
|
|
- String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getYunPayGzhCallback";
|
|
|
|
- //logger.info("回调地址:"+ notifyUrl);
|
|
|
|
- requst.setNotify_url(notifyUrl);
|
|
|
|
- //发送请求
|
|
|
|
- System.out.println("请求报文:"+JSON.toJSONString(requst));
|
|
|
|
- SaobeiJsPayResponse response = client.execute(requst);
|
|
|
|
- System.out.println("返回报文:"+JSON.toJSONString(response));
|
|
|
|
- resultData = ResultData.success(response);
|
|
|
|
|
|
+ logger.info("==============================云闪付 公众号电子卡充值 拉起支付 ** 开始 **============================================");
|
|
|
|
+ //创建client
|
|
|
|
+ SaobeiApiClient<SaobeiJsPayRequest, SaobeiJsPayResponse> client = new DefaultSaobeiApiClient<>(staPayChannelInfo.get("yunKey"));
|
|
|
|
+ //创建requst
|
|
|
|
+ SaobeiJsPayRequest requst = new SaobeiJsPayRequest();
|
|
|
|
+ requst.setPay_ver("110");
|
|
|
|
+ requst.setPay_type("010");
|
|
|
|
+ requst.setService_id("012");
|
|
|
|
+ requst.setMerchant_no(staPayChannelInfo.get("merchantNo")); //商户号
|
|
|
|
+ requst.setTerminal_id(staPayChannelInfo.get("terminalId")); //终端号
|
|
|
|
+ requst.setTerminal_trace(cardRecordByOrderNo.getOrderNo()); //订单号
|
|
|
|
+ requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
|
|
|
|
+
|
|
|
|
+ BigDecimal totalFee = new BigDecimal(cardRecordByOrderNo.getAmt().toString()).multiply(new BigDecimal("100")).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
|
+ logger.info("该订单金额:" + cardRecordByOrderNo.getAmt().toString()+"; 拉起云闪付上送金额(单位:分):" + totalFee.toString());
|
|
|
|
+ requst.setTotal_fee(totalFee.toString());
|
|
|
|
+ requst.setSub_appid(staPayChannelInfo.get("gzhAppId"));
|
|
|
|
+ requst.setOpen_id(openId); //oJR5R6r4EJhaORFcPap70r_mtFZo //oRwjv4iHjSUgxNxOJOQ_60Ln7cno
|
|
|
|
+
|
|
|
|
+ Oil oil = new Oil();
|
|
|
|
+ oil.setOilsType(cardRecordByOrderNo.getCardOilsType());
|
|
|
|
+ if(cardRecordByOrderNo.getCardOilsType().equals("1") || cardRecordByOrderNo.getCardOilsType().equals("2")){
|
|
|
|
+ oil.setDictType("oil");
|
|
|
|
+ }else {
|
|
|
|
+ oil.setDictType("oil_name");
|
|
|
|
+ }
|
|
|
|
+ String cardName =sysDictDataService.selectOilType(oil).getOilName();
|
|
|
|
+ String orderBody = cardName+ "电子卡" + " - " +cardRecordByOrderNo.getStationName();
|
|
|
|
+ requst.setOrder_body(orderBody);
|
|
|
|
+ String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getYunPayGzhCallback";
|
|
|
|
+ logger.info("回调地址:"+ notifyUrl);
|
|
|
|
+ requst.setNotify_url(notifyUrl);
|
|
|
|
+ //发送请求
|
|
|
|
+ System.out.println("请求报文:"+JSON.toJSONString(requst));
|
|
|
|
+ SaobeiJsPayResponse response = client.execute(requst);
|
|
|
|
+ System.out.println("返回报文:"+JSON.toJSONString(response));
|
|
|
|
+ resultData = ResultData.success(response);
|
|
|
|
+ logger.info("==============================云闪付 公众号电子卡 充值 拉起支付 ** 结束 **============================================");
|
|
|
|
+ }else {
|
|
|
|
+ resultData = ResultData.error(CodeMsg.STATION_NULL_INFO);
|
|
|
|
+ }
|
|
}else {
|
|
}else {
|
|
- resultData = ResultData.error(CodeMsg.STATION_NULL_INFO);
|
|
|
|
|
|
+ resultData = ResultData.error(CodeMsg.ALREADY_PAY);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- resultData = ResultData.error(CodeMsg.ALREADY_PAY);
|
|
|
|
|
|
+ resultData=ResultData.error(CodeMsg.YEWU_FAIL,"未查询到订单");
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- resultData = ResultData.error(CodeMsg.NO_ORDER);
|
|
|
|
|
|
+ resultData = ResultData.error(CodeMsg.REQUEST_FAIL);
|
|
}
|
|
}
|
|
return gson.toJson(resultData);
|
|
return gson.toJson(resultData);
|
|
}
|
|
}
|
|
|
|
|
|
- /***
|
|
|
|
- * 公众号扫呗支付回调
|
|
|
|
- * @param jsonObject
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @RequestMapping(value = "/getYunPayGzhCallback", consumes = "application/json", method = RequestMethod.POST)
|
|
|
|
- @ResponseBody
|
|
|
|
- @Transactional
|
|
|
|
- public JSONObject getYunPayGzhCallback(@RequestBody JSONObject jsonObject){
|
|
|
|
- JSONObject result = new JSONObject(); //返回给扫呗状态码
|
|
|
|
- System.out.println("扫呗调用回调接口返回参数:" + jsonObject);
|
|
|
|
- if(jsonObject.containsKey("result_code") && jsonObject.get("result_code").toString().equals("01")){
|
|
|
|
-
|
|
|
|
- //业务逻辑
|
|
|
|
-
|
|
|
|
- //返给扫呗状态码
|
|
|
|
- result.put("return_code", "01");
|
|
|
|
- result.put("return_msg", "success");
|
|
|
|
- }else {
|
|
|
|
- result.put("return_code", "02");
|
|
|
|
- result.put("return_msg", "fail");
|
|
|
|
- }
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
|
|
+// /***
|
|
|
|
+// * 公众号扫呗支付回调
|
|
|
|
+// * @param jsonObject
|
|
|
|
+// * @return
|
|
|
|
+// */
|
|
|
|
+// @RequestMapping(value = "/getYunPayGzhCallback", consumes = "application/json", method = RequestMethod.POST)
|
|
|
|
+// @ResponseBody
|
|
|
|
+// @Transactional
|
|
|
|
+// public JSONObject getYunPayGzhCallback(@RequestBody JSONObject jsonObject){
|
|
|
|
+// JSONObject result = new JSONObject(); //返回给扫呗状态码
|
|
|
|
+// System.out.println("扫呗调用回调接口返回参数:" + jsonObject);
|
|
|
|
+// if(jsonObject.containsKey("result_code") && jsonObject.get("result_code").toString().equals("01")){
|
|
|
|
+//
|
|
|
|
+// //业务逻辑
|
|
|
|
+//
|
|
|
|
+// //返给扫呗状态码
|
|
|
|
+// result.put("return_code", "01");
|
|
|
|
+// result.put("return_msg", "success");
|
|
|
|
+// }else {
|
|
|
|
+// result.put("return_code", "02");
|
|
|
|
+// result.put("return_msg", "fail");
|
|
|
|
+// }
|
|
|
|
+// return result;
|
|
|
|
+// }
|
|
|
|
|
|
/***
|
|
/***
|
|
* 小程序云闪付拉起支付
|
|
* 小程序云闪付拉起支付
|
|
@@ -211,6 +240,7 @@ public class SaoBeiPayController {
|
|
&& staPayChannelInfo.containsKey("yunKey") && staPayChannelInfo.containsKey("appId")) {
|
|
&& staPayChannelInfo.containsKey("yunKey") && staPayChannelInfo.containsKey("appId")) {
|
|
//秘钥
|
|
//秘钥
|
|
String yunKey = staPayChannelInfo.get("yunKey"); //23570b46a955484d92038f6a18d2b9d6
|
|
String yunKey = staPayChannelInfo.get("yunKey"); //23570b46a955484d92038f6a18d2b9d6
|
|
|
|
+ logger.info("==============================云闪付 小程序支付油品 拉起支付 ** 开始 **============================================");
|
|
DefaultSaobeiApiClient defaultSaobeiApiClient = new DefaultSaobeiApiClient(yunKey); //2ef428f4f76c414282e831baea9e4b0e
|
|
DefaultSaobeiApiClient defaultSaobeiApiClient = new DefaultSaobeiApiClient(yunKey); //2ef428f4f76c414282e831baea9e4b0e
|
|
SaobeiMiniPayRequest requst = new SaobeiMiniPayRequest();
|
|
SaobeiMiniPayRequest requst = new SaobeiMiniPayRequest();
|
|
requst.setPay_ver("100");
|
|
requst.setPay_ver("100");
|
|
@@ -240,17 +270,8 @@ public class SaoBeiPayController {
|
|
System.out.println("请求报文:" + JSON.toJSONString(requst));
|
|
System.out.println("请求报文:" + JSON.toJSONString(requst));
|
|
SaobeiMiniPayResponse response = (SaobeiMiniPayResponse) defaultSaobeiApiClient.execute(requst);
|
|
SaobeiMiniPayResponse response = (SaobeiMiniPayResponse) defaultSaobeiApiClient.execute(requst);
|
|
System.out.println("返回报文:" + JSON.toJSONString(response));
|
|
System.out.println("返回报文:" + JSON.toJSONString(response));
|
|
-
|
|
|
|
-// {
|
|
|
|
-// 'timeStamp': timeStamp,
|
|
|
|
-// 'nonceStr': nonceStr,
|
|
|
|
-// 'package': payPackage,
|
|
|
|
-// 'signType': signType,
|
|
|
|
-// 'paySign': paySign,
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
resultData = ResultData.success(response);
|
|
resultData = ResultData.success(response);
|
|
|
|
+ logger.info("==============================云闪付 小程序支付油品 拉起支付 ** 结束 **============================================");
|
|
}else {
|
|
}else {
|
|
resultData = ResultData.error(CodeMsg.STATION_NULL_INFO);
|
|
resultData = ResultData.error(CodeMsg.STATION_NULL_INFO);
|
|
}
|
|
}
|