|
|
@@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@@ -24,14 +25,42 @@ import java.util.Map; |
|
|
public class PosUtil { |
|
|
public class PosUtil { |
|
|
private static final Logger logger = LoggerFactory.getLogger(PosUtil.class); |
|
|
private static final Logger logger = LoggerFactory.getLogger(PosUtil.class); |
|
|
|
|
|
|
|
|
private static final String domain = "https://pos.youlane.cn/api"; |
|
|
|
|
|
|
|
|
private static final String domain = "http://localhost:4000"; // "https://pos.youlane.cn/api"; |
|
|
private static final String devId = "fmpos"; |
|
|
private static final String devId = "fmpos"; |
|
|
private static final String reqKey = "ZiGFLC4@3c5sTLZT"; |
|
|
private static final String reqKey = "ZiGFLC4@3c5sTLZT"; |
|
|
private static final String resKey = "ugPAM7wd&%p6I0W8"; |
|
|
private static final String resKey = "ugPAM7wd&%p6I0W8"; |
|
|
|
|
|
|
|
|
// url |
|
|
// url |
|
|
private static final String checkUserPassword = "/checkUserPassword"; |
|
|
|
|
|
private static final String getPosMemConfig = "/getPosMemConfig"; |
|
|
|
|
|
|
|
|
private static final String URL_CheckUserPassword = "/checkUserPassword"; |
|
|
|
|
|
private static final String URL_GetPosMemConfig = "/getPosMemConfig"; |
|
|
|
|
|
private static final String URL_GetQrCode = "/getQrCode"; |
|
|
|
|
|
private static final String URL_CheckMem = "/checkMem"; |
|
|
|
|
|
private static final String URL_CheckCouponOrderForVerify = "/checkCouponOrderForVerify"; |
|
|
|
|
|
private static final String URL_CouponOrderPreVerify = "/couponOrderPreVerify"; |
|
|
|
|
|
private static final String URL_CouponOrderPreVerifyCancel = "/couponOrderPreVerifyCancel"; |
|
|
|
|
|
private static final String URL_CouponOrderIndependentVerify = "/couponOrderIndependentVerify"; |
|
|
|
|
|
private static final String URL_CouponOrderPayVerifyOne = "/couponOrderPayVerifyOne"; |
|
|
|
|
|
private static final String URL_CouponOrderPayVerifyList = "/couponOrderPayVerifyList"; |
|
|
|
|
|
private static final String URL_CouponOrderVerifyCancel = "/couponOrderVerifyCancel"; |
|
|
|
|
|
private static final String URL_CheckCardPay = "/checkCardPay"; |
|
|
|
|
|
private static final String URL_CardPayPre = "/cardPayPre"; |
|
|
|
|
|
private static final String URL_CardPayPreCancel = "/cardPayPreCancel"; |
|
|
|
|
|
private static final String URL_CardPay = "/cardPay"; |
|
|
|
|
|
private static final String URL_CardPayCancel = "/cardPayCancel"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
可用的交易券, 支付可用(1, 2, 6), 独立核销可用(4, 6, 8, 9) |
|
|
|
|
|
coupon_order_id, coupon_type, 售价, 面额, cancellable |
|
|
|
|
|
321872988134408192, 4, 0, 2000, NO |
|
|
|
|
|
321877927162249216, 2, 0, 10000, YES |
|
|
|
|
|
321878123232591872, 2, 1, 10000, NO |
|
|
|
|
|
321878185355214848, 1, 0, 10000, NO |
|
|
|
|
|
321878223800205312, 6, 0, 1000, YES |
|
|
|
|
|
321878329906921472, 6, 1, 1000, NO |
|
|
|
|
|
321882224846667776, 8, 1, 1500, NO |
|
|
|
|
|
321883878446825472, 100, 1, 50000, NO |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
private final OkHttpClient client = new OkHttpClient(); |
|
|
private final OkHttpClient client = new OkHttpClient(); |
|
|
private String doPost(String url, Map<String, String> paramMap) { |
|
|
private String doPost(String url, Map<String, String> paramMap) { |
|
|
@@ -70,13 +99,16 @@ public class PosUtil { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 1. 商户用户登录检查 |
|
|
|
|
|
|
|
|
* 1. 商户POS用户/B端用户登录检查 |
|
|
* @param baseUrl |
|
|
* @param baseUrl |
|
|
* @param devId |
|
|
* @param devId |
|
|
* @param reqKey |
|
|
* @param reqKey |
|
|
* @return 车场状态查询响应信息 |
|
|
|
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @param phone |
|
|
|
|
|
* @param password |
|
|
|
|
|
* @return B端用户信息 |
|
|
*/ |
|
|
*/ |
|
|
public String checkUserPassword(String baseUrl, String devId, String reqKey, String resKey, |
|
|
|
|
|
|
|
|
public String checkUserPassword(String baseUrl, String devId, String reqKey, |
|
|
String tenantId, String phone, String password) throws MallinkException { |
|
|
String tenantId, String phone, String password) throws MallinkException { |
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
@@ -85,7 +117,136 @@ public class PosUtil { |
|
|
paramMap.put(WxPayConstant.PASSWORD, password); |
|
|
paramMap.put(WxPayConstant.PASSWORD, password); |
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + checkUserPassword, paramMap); |
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_CheckUserPassword, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 2. 获取会员折扣/优惠券/消费卡是否启用 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @return 会员折扣信息 |
|
|
|
|
|
*/ |
|
|
|
|
|
public String getPosMemConfig(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_GetPosMemConfig, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 3. 获取注册二维码及小票二维码规则 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @return 二维码url及小票二维码规则 |
|
|
|
|
|
*/ |
|
|
|
|
|
public String getQrCode(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_GetQrCode, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 4. 会员识别 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @param merchantId |
|
|
|
|
|
* @param memId |
|
|
|
|
|
* @param memPhone |
|
|
|
|
|
* @param posOrderId |
|
|
|
|
|
* @param posAmount |
|
|
|
|
|
* @return 会员信息+会员折扣+会员可用优惠券列表 |
|
|
|
|
|
*/ |
|
|
|
|
|
public String checkMem(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId, String merchantId, |
|
|
|
|
|
String memId, String memPhone, |
|
|
|
|
|
String posOrderId, String posAmount) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
|
|
if (StringUtils.isNotBlank(memId)) { |
|
|
|
|
|
paramMap.put(WxPayConstant.MEM_ID, memId); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNotBlank(memPhone)) { |
|
|
|
|
|
paramMap.put(WxPayConstant.MEM_PHONE, memPhone); |
|
|
|
|
|
} |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_CheckMem, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 5. 券核销检查 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @param merchantId |
|
|
|
|
|
* @param buUserId |
|
|
|
|
|
* @param couponOrderId |
|
|
|
|
|
* @param verifyType |
|
|
|
|
|
* @param posOrderId |
|
|
|
|
|
* @param posAmount |
|
|
|
|
|
* @return 券是否可核销 |
|
|
|
|
|
*/ |
|
|
|
|
|
public String checkCouponOrderForVerify(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId, String merchantId, String buUserId, |
|
|
|
|
|
String couponOrderId, String verifyType, |
|
|
|
|
|
String posOrderId, String posAmount) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
|
|
paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.VERIFY_TYPE, verifyType); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_CheckCouponOrderForVerify, paramMap); |
|
|
if(respStr == null) { |
|
|
if(respStr == null) { |
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
} |
|
|
} |
|
|
@@ -95,9 +256,435 @@ public class PosUtil { |
|
|
return respStr; |
|
|
return respStr; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 6. 券预核销 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @param merchantId |
|
|
|
|
|
* @param buUserId |
|
|
|
|
|
* @param couponOrderId |
|
|
|
|
|
* @param posOrderId |
|
|
|
|
|
* @param posAmount |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public String couponOrderPreVerify(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId, String merchantId, String buUserId, |
|
|
|
|
|
String couponOrderId, |
|
|
|
|
|
String posOrderId, String posAmount) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
|
|
paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_CouponOrderPreVerify, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 7. 券预核销取消 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @param merchantId |
|
|
|
|
|
* @param buUserId |
|
|
|
|
|
* @param couponOrderId |
|
|
|
|
|
* @param posOrderId |
|
|
|
|
|
* @param posAmount |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public String couponOrderPreVerifyCancel(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId, String merchantId, String buUserId, |
|
|
|
|
|
String couponOrderId, |
|
|
|
|
|
String posOrderId, String posAmount) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
|
|
paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_CouponOrderPreVerifyCancel, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 8. 券独立核销 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @param merchantId |
|
|
|
|
|
* @param buUserId |
|
|
|
|
|
* @param couponOrderId |
|
|
|
|
|
* @param posOrderId |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public String couponOrderIndependentVerify(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId, String merchantId, String buUserId, |
|
|
|
|
|
String couponOrderId, |
|
|
|
|
|
String posOrderId) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
|
|
paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_CouponOrderIndependentVerify, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 9. 券交易核销-单个优惠券接口 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @param merchantId |
|
|
|
|
|
* @param buUserId |
|
|
|
|
|
* @param couponOrderId |
|
|
|
|
|
* @param posOrderId |
|
|
|
|
|
* @param posAmount |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public String couponOrderPayVerifyOne(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId, String merchantId, String buUserId, |
|
|
|
|
|
String couponOrderId, |
|
|
|
|
|
String posOrderId, String posAmount) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
|
|
paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_CouponOrderPayVerifyOne, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 10. 券交易核销-优惠券列表 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @param merchantId |
|
|
|
|
|
* @param buUserId |
|
|
|
|
|
* @param couponOrderIdList |
|
|
|
|
|
* @param posOrderId |
|
|
|
|
|
* @param posAmount |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public String couponOrderPayVerifyList(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId, String merchantId, String buUserId, |
|
|
|
|
|
List<String> couponOrderIdList, |
|
|
|
|
|
String posOrderId, String posAmount) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
|
|
paramMap.put(WxPayConstant.SELECTED_COUPON_ORDER_LIST, JSON.toJSONString(couponOrderIdList)); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_CouponOrderPayVerifyList, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 11. 券核销取消 |
|
|
|
|
|
* @param baseUrl |
|
|
|
|
|
* @param devId |
|
|
|
|
|
* @param reqKey |
|
|
|
|
|
* @param tenantId |
|
|
|
|
|
* @param merchantId |
|
|
|
|
|
* @param buUserId |
|
|
|
|
|
* @param couponOrderId |
|
|
|
|
|
* @param posOrderId |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public String couponOrderVerifyCancel(String baseUrl, String devId, String reqKey, |
|
|
|
|
|
String tenantId, String merchantId, String buUserId, |
|
|
|
|
|
String couponOrderId, |
|
|
|
|
|
String posOrderId) throws MallinkException { |
|
|
|
|
|
Map<String, String> paramMap = new HashMap<>(); |
|
|
|
|
|
paramMap.put(WxPayConstant.DEV_ID, devId); |
|
|
|
|
|
paramMap.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); |
|
|
|
|
|
paramMap.put(WxPayConstant.BUSER_ID, buUserId); |
|
|
|
|
|
paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); |
|
|
|
|
|
paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); |
|
|
|
|
|
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); |
|
|
|
|
|
|
|
|
|
|
|
String respStr = doPost(baseUrl + URL_CouponOrderVerifyCancel, paramMap); |
|
|
|
|
|
if(respStr == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
if(checkRespFailed(respStr)) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.POS_CMD_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
return respStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
public static void main(String[] args) { |
|
|
|
|
|
String tenantId = "456"; |
|
|
|
|
|
String phone = "13120223636"; |
|
|
|
|
|
String password = "drpos345"; |
|
|
|
|
|
String merchantId = "320833942159982592"; |
|
|
|
|
|
String buUserId = "320834180694245376"; |
|
|
|
|
|
String memId = ""; |
|
|
|
|
|
String memPhone = "13910154397"; |
|
|
|
|
|
String posOrderId = "1"; |
|
|
|
|
|
String posAmount = "200"; |
|
|
|
|
|
String couponOrderId = "321877927162249216"; |
|
|
|
|
|
String verifyType = "independent"; |
|
|
PosUtil posUtil = new PosUtil(); |
|
|
PosUtil posUtil = new PosUtil(); |
|
|
String resStr = posUtil.checkUserPassword(domain, devId, reqKey, resKey, "456", "13120223636", "drpos345"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String resStr = posUtil.checkUserPassword(domain, devId, reqKey, tenantId, phone, password); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
/* |
|
|
|
|
|
resStr = posUtil.getPosMemConfig(domain, devId, reqKey, tenantId); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resStr = posUtil.getQrCode(domain, devId, reqKey, tenantId); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resStr = posUtil.checkMem(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, |
|
|
|
|
|
memId, memPhone, |
|
|
|
|
|
posOrderId, posAmount); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
couponOrderId = "321878223800205312"; |
|
|
|
|
|
verifyType = "independent"; |
|
|
|
|
|
resStr = posUtil.checkCouponOrderForVerify(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderId, verifyType, |
|
|
|
|
|
posOrderId, posAmount); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
couponOrderId = "321877927162249216"; |
|
|
|
|
|
resStr = posUtil.couponOrderPreVerify(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderId, |
|
|
|
|
|
posOrderId, posAmount); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
couponOrderId = "321877927162249216"; |
|
|
|
|
|
resStr = posUtil.couponOrderPreVerifyCancel(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderId, |
|
|
|
|
|
posOrderId, posAmount); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
couponOrderId = "321878223800205312"; |
|
|
|
|
|
resStr = posUtil.couponOrderIndependentVerify(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderId, posOrderId); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
couponOrderId = "321878223800205312"; |
|
|
|
|
|
resStr = posUtil.couponOrderPreVerify(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderId, |
|
|
|
|
|
posOrderId, posAmount); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
couponOrderId = "321878223800205312"; |
|
|
|
|
|
resStr = posUtil.couponOrderPayVerifyOne(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderId, |
|
|
|
|
|
posOrderId, posAmount); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
couponOrderId = "321878223800205312"; |
|
|
|
|
|
resStr = posUtil.couponOrderVerifyCancel(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderId, posOrderId); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
couponOrderId = "321878223800205312"; |
|
|
|
|
|
resStr = posUtil.couponOrderPreVerify(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderId, |
|
|
|
|
|
posOrderId, posAmount); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
couponOrderId = "321878223800205312"; |
|
|
|
|
|
List<String> couponOrderIdList = new ArrayList<>(); |
|
|
|
|
|
couponOrderIdList.add(couponOrderId); |
|
|
|
|
|
resStr = posUtil.couponOrderPayVerifyList(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderIdList, |
|
|
|
|
|
posOrderId, posAmount); |
|
|
|
|
|
if (resStr != null) { |
|
|
|
|
|
System.out.println(resStr); |
|
|
|
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
|
|
|
Map options = retObj; |
|
|
|
|
|
if (!WxPayment.verifyNotifyHMAC(options, resKey)) { |
|
|
|
|
|
System.out.println("verify sign error"); |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("verify sign ok"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
couponOrderId = "321878223800205312"; |
|
|
|
|
|
resStr = posUtil.couponOrderVerifyCancel(domain, devId, reqKey, |
|
|
|
|
|
tenantId, merchantId, buUserId, |
|
|
|
|
|
couponOrderId, posOrderId); |
|
|
if (resStr != null) { |
|
|
if (resStr != null) { |
|
|
System.out.println(resStr); |
|
|
System.out.println(resStr); |
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
JSONObject retObj = JSON.parseObject(resStr); |
|
|
@@ -108,5 +695,6 @@ public class PosUtil { |
|
|
System.out.println("verify sign ok"); |
|
|
System.out.println("verify sign ok"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
*/ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |