parent
b5bcaabcc3
commit
b8ae8a903e
@ -0,0 +1,78 @@ |
||||
package com.hfkj.channel.hsg; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.channel.hsg.config.HsgConfig; |
||||
import com.hfkj.channel.hsg.type.RebateProductTypeEnum; |
||||
import com.hfkj.channel.weixin.utils.WxUtils; |
||||
import com.hfkj.channel.weixin.utils.sdk.WXPayConstants; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.HttpsUtils; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: HsgService |
||||
* @author: HuRui |
||||
* @date: 2023/4/27 |
||||
**/ |
||||
public class HsgIntegralService { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HsgIntegralService.class); |
||||
|
||||
/** |
||||
* 返利 |
||||
* @param productType |
||||
* @param phone |
||||
* @param orderNo |
||||
* @param orderId |
||||
* @param price |
||||
* @param storeName |
||||
* @param createTime |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static Boolean rebate(RebateProductTypeEnum productType, |
||||
String phone, |
||||
String orderNo, |
||||
Long orderId, |
||||
BigDecimal price, |
||||
String storeName, |
||||
Date createTime) { |
||||
|
||||
try { |
||||
Map<String , Object> mapPost = new HashMap<>(); |
||||
mapPost.put("apiKey" , HsgConfig.apiKey); |
||||
mapPost.put("merchId" , HsgConfig.merchId); |
||||
mapPost.put("productType" , productType.getNumber()); // 101 普通支付 102 商家活动差价返利
|
||||
mapPost.put("orderNo" , orderNo); |
||||
mapPost.put("phone" , phone); |
||||
mapPost.put("orderId" , orderId); |
||||
mapPost.put("price" , price); |
||||
mapPost.put("title" , storeName); |
||||
mapPost.put("createTime" , createTime); |
||||
mapPost.put("sign" , WxUtils.generateSignApi(mapPost, MapUtils.getString(mapPost, "apiKey"), WXPayConstants.SignType.MD5)); |
||||
JSONObject response = HttpsUtils.doPost(HsgConfig.hsgDomainName+"v1/orderRebate/rebate", mapPost, new HashMap<>()); |
||||
System.out.println(response); |
||||
if (response == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时"); |
||||
} |
||||
if (!response.getString("return_code").equals("000000")) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getString("return_msg")); |
||||
} |
||||
return true; |
||||
} catch (Exception e) { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,17 @@ |
||||
package com.hfkj.channel.hsg.config; |
||||
|
||||
import com.hfkj.config.CommonSysConst; |
||||
|
||||
/** |
||||
* @className: HsgConfig |
||||
* @author: HuRui |
||||
* @date: 2023/4/27 |
||||
**/ |
||||
public class HsgConfig { |
||||
|
||||
public final static String apiKey = "0C7897EA3BD96156A5881618FF2FF645"; |
||||
|
||||
public final static String merchId = "20230258302"; |
||||
public final static String hsgDomainName = CommonSysConst.getSysConfig().getHsg_domain_name(); |
||||
|
||||
} |
@ -0,0 +1,35 @@ |
||||
package com.hfkj.channel.hsg.type; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public enum RebateProductTypeEnum { |
||||
type1(101, "普通支付"), |
||||
type2(102, "商家活动差价返利"), |
||||
; |
||||
|
||||
private Integer number; |
||||
|
||||
private String name; |
||||
|
||||
RebateProductTypeEnum(int number, String name) { |
||||
this.number = number; |
||||
this.name = name; |
||||
} |
||||
|
||||
public Integer getNumber() { |
||||
return number; |
||||
} |
||||
|
||||
public void setNumber(Integer number) { |
||||
this.number = number; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
Loading…
Reference in new issue