# Conflicts: # hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java # hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.javamaster
parent
d752345fb2
commit
ba05c0d457
File diff suppressed because one or more lines are too long
@ -0,0 +1,114 @@ |
|||||||
|
package com.hai.config; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hai.common.utils.HttpsUtils; |
||||||
|
import com.hai.common.utils.WxUtils; |
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @serviceName .java |
||||||
|
* @author Sum1Dream |
||||||
|
* @version 1.0.0 |
||||||
|
* @Description // 中石油卡券
|
||||||
|
* @createTime 18:33 2023/11/13 |
||||||
|
**/ |
||||||
|
@Configuration |
||||||
|
public class PetroCouponConfig { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getCouponList |
||||||
|
* @Description // 获取卡券列表
|
||||||
|
* @Date 11:50 2024/4/7 |
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public static JSONObject getCouponList() throws Exception { |
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
|
||||||
|
paramMap.put("method" , "api.coupon.reserve"); |
||||||
|
paramMap.put("merchant" ,CommonSysConst.getSysConfig().getSphMerchant()); |
||||||
|
paramMap.put("sign", WxUtils.generateSignSph(paramMap , CommonSysConst.getSysConfig().getSphSecret())); |
||||||
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getSphPostUrl() , paramSort(paramMap), new HashMap<>()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getCoupon |
||||||
|
* @Description // 获取电子券
|
||||||
|
* @Date 17:19 2024/4/7 |
||||||
|
|
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public static JSONObject getCoupon(String orderNo , String mobile, String reqCode) throws Exception { |
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
|
||||||
|
paramMap.put("method" , "api.coupon.once"); |
||||||
|
paramMap.put("batchId" , orderNo); |
||||||
|
paramMap.put("mobile" , mobile); |
||||||
|
paramMap.put("reqCode" , reqCode); |
||||||
|
paramMap.put("merchant" ,CommonSysConst.getSysConfig().getSphMerchant()); |
||||||
|
paramMap.put("sign", WxUtils.generateSignSph(paramMap , CommonSysConst.getSysConfig().getSphSecret())); |
||||||
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getSphPostUrl() , paramSort(paramMap), new HashMap<>()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getCouponQuery |
||||||
|
* @Description // 查询电子券信息
|
||||||
|
* @Date 17:25 2024/4/7 |
||||||
|
* @Param couponCode |
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public static JSONObject getCouponQuery(String couponCode ) throws Exception { |
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
|
||||||
|
paramMap.put("method" , "api.coupon.query"); |
||||||
|
paramMap.put("couponCode" , couponCode); |
||||||
|
paramMap.put("merchant" ,CommonSysConst.getSysConfig().getSphMerchant()); |
||||||
|
paramMap.put("sign", WxUtils.generateSignSph(paramMap , CommonSysConst.getSysConfig().getSphSecret())); |
||||||
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getSphPostUrl() , paramSort(paramMap), new HashMap<>()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getCouponDestroy |
||||||
|
* @Description // 作废电子券
|
||||||
|
* @Date 17:26 2024/4/7 |
||||||
|
* @Param couponCode |
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public static JSONObject getCouponDestroy(String couponCode ) throws Exception { |
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
|
||||||
|
paramMap.put("method" , "api.coupon.destroy"); |
||||||
|
paramMap.put("couponCode" , couponCode); |
||||||
|
paramMap.put("merchant" ,CommonSysConst.getSysConfig().getSphMerchant()); |
||||||
|
paramMap.put("sign", WxUtils.generateSignSph(paramMap , CommonSysConst.getSysConfig().getSphSecret())); |
||||||
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getSphPostUrl() , paramSort(paramMap), new HashMap<>()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static String paramSort(final Map<String, Object> param) { |
||||||
|
Set<String> keySet = param.keySet(); |
||||||
|
String[] keyArray = keySet.toArray(new String[keySet.size()]); |
||||||
|
StringBuilder sb = new StringBuilder(); |
||||||
|
for (String k : keyArray) { |
||||||
|
if (StringUtils.isBlank(sb.toString())) { |
||||||
|
sb.append(k).append("=").append(param.get(k)); |
||||||
|
} else { |
||||||
|
sb.append("&").append(k).append("=").append(param.get(k)); |
||||||
|
} |
||||||
|
} |
||||||
|
return sb.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue