From 09f309f1d155c6de1ac10a0841ee7a7dcfd8f397 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 20 Aug 2019 16:45:30 +0800 Subject: [PATCH] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:POS=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/iformall/utils/PosUtil.java | 604 +++++++++++++++++- .../iformall/controller/PosController.java | 30 +- .../iformall/service/impl/PosServiceImpl.java | 1 - 3 files changed, 611 insertions(+), 24 deletions(-) diff --git a/mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java b/mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java index f09d380d3..ec225129c 100755 --- a/mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java +++ b/mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -24,14 +25,42 @@ import java.util.Map; public class PosUtil { 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 reqKey = "ZiGFLC4@3c5sTLZT"; private static final String resKey = "ugPAM7wd&%p6I0W8"; // 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 String doPost(String url, Map paramMap) { @@ -70,13 +99,16 @@ public class PosUtil { /** - * 1. 商户用户登录检查 + * 1. 商户POS用户/B端用户登录检查 * @param baseUrl * @param devId * @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 { Map paramMap = new HashMap<>(); paramMap.put(WxPayConstant.DEV_ID, devId); @@ -85,7 +117,136 @@ public class PosUtil { paramMap.put(WxPayConstant.PASSWORD, password); 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 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 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 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 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) { throw new MallinkException(ErrorCode.POS_CMD_FAIL); } @@ -95,9 +256,435 @@ public class PosUtil { 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 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 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 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 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 couponOrderIdList, + String posOrderId, String posAmount) throws MallinkException { + Map 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 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) { + 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(); - 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 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) { System.out.println(resStr); JSONObject retObj = JSON.parseObject(resStr); @@ -108,5 +695,6 @@ public class PosUtil { System.out.println("verify sign ok"); } } + */ } } diff --git a/mallinkPosApi/src/main/java/com/iformall/controller/PosController.java b/mallinkPosApi/src/main/java/com/iformall/controller/PosController.java index 41041c4d9..ea8a23d55 100644 --- a/mallinkPosApi/src/main/java/com/iformall/controller/PosController.java +++ b/mallinkPosApi/src/main/java/com/iformall/controller/PosController.java @@ -70,8 +70,8 @@ public class PosController extends BaseController { @ApiOperation(value = "获取会员折扣/优惠券/消费卡是否启用", notes = "{" + "\"dev_id\":\"string(必填)\"," + - "\"tenant_id\":\"string(必填)\"," + - "\"nonce_str\":\"string(必填)\"}") + "\"nonce_str\":\"string(必填)\"," + + "\"tenant_id\":\"string(必填)\"}") @PostMapping("/getPosMemConfig") @SystemControllerLog(description = "获取会员折扣/优惠券/消费卡是否启用") public Map getMemStatus(@RequestBody Map params) { @@ -102,8 +102,8 @@ public class PosController extends BaseController { @ApiOperation(value = "获取注册二维码及小票二维码规则", notes = "{" + "\"dev_id\":\"string(必填)\"," + - "\"tenant_id\":\"string(必填)\"," + - "\"nonce_str\":\"string(必填)\"}") + "\"nonce_str\":\"string(必填)\"," + + "\"tenant_id\":\"string(必填)\"}") @PostMapping("/getQrCode") @SystemControllerLog(description = "获取注册二维码及小票二维码规则") public Map getQrCode(@RequestBody Map params) { @@ -173,11 +173,11 @@ public class PosController extends BaseController { @ApiOperation(value = "券核销检查", notes = "{" + "\"dev_id\":\"string(必填)\"," + + "\"nonce_str\":\"string(必填)\"," + "\"tenant_id\":\"string(必填)\"," + "\"merchant_id\":\"string(必填)\"," + "\"bu_user_id\":\"string(必填)\"," + "\"coupon_order_id\":\"string(必填)\"," + - "\"nonce_str\":\"string(必填)\"," + "\"verify_type\":\"independent, pay(必填)\"," + "\"pos_order_id\":\"string(选填)\"," + "\"pos_amount\":\"单位(分)(选填)\"}") @@ -212,11 +212,11 @@ public class PosController extends BaseController { @ApiOperation(value = "券预核销", notes = "{" + "\"dev_id\":\"string(必填)\"," + + "\"nonce_str\":\"string(必填)\"," + "\"tenant_id\":\"string(必填)\"," + "\"merchant_id\":\"string(必填)\"," + "\"bu_user_id\":\"string(必填)\"," + "\"coupon_order_id\":\"string(必填)\"," + - "\"nonce_str\":\"string(必填)\"," + "\"pos_order_id\":\"string(必填)\"," + "\"pos_amount\":\"string(必填)\"}") @PostMapping("/couponOrderPreVerify") @@ -287,12 +287,12 @@ public class PosController extends BaseController { @ApiOperation(value = "券独立核销", notes = "{" + "\"dev_id\":\"string(必填)\"," + + "\"nonce_str\":\"string(必填)\"," + "\"tenant_id\":\"string(必填)\"," + "\"merchant_id\":\"string(必填)\"," + "\"bu_user_id\":\"string(必填)\"," + - "\"coupon_order_id\":\"string(必填)\" +" + - "\"nonce_str\":\"string(必填)\" +" + - "\"pos_order_id\":\"string(必填)\" }") + "\"coupon_order_id\":\"string(必填)\"," + + "\"pos_order_id\":\"string(必填)\"}") @PostMapping("/couponOrderIndependentVerify") @SystemControllerLog(description = "券独立核销") public Map couponOrderIndependentVerify(@RequestBody Map params) { @@ -345,12 +345,13 @@ public class PosController extends BaseController { @ApiOperation(value = "券交易核销-单个优惠券接口", notes = "{" + "\"dev_id\":\"string(必填)\"," + + "\"nonce_str\":\"string(必填)\"," + "\"tenant_id\":\"string(必填)\"," + "\"merchant_id\":\"string(必填)\"," + "\"bu_user_id\":\"string(必填)\"," + - "\"coupon_order_id\":\"string(必填)\" +" + - "\"nonce_str\":\"string(必填)\" +" + - "\"pos_order_id\":\"string(必填)\" }") + "\"coupon_order_id\":\"string(必填)\"," + + "\"pos_order_id\":\"string(必填)\"," + + "\"pos_amount\":\"string(单位:分)(必填)\"}") @PostMapping("/couponOrderPayVerifyOne") @SystemControllerLog(description = "券交易核销-单个优惠券接口") public Map couponOrderPayVerify(@RequestBody Map params) { @@ -455,13 +456,12 @@ public class PosController extends BaseController { @ApiOperation(value = "券核销取消", notes = "{" + "\"dev_id\":\"string(必填)\"," + + "\"nonce_str\":\"string(必填)\"," + "\"tenant_id\":\"string(必填)\"," + "\"merchant_id\":\"string(必填)\"," + "\"bu_user_id\":\"string(必填)\"," + "\"coupon_order_id\":\"string(必填)\"" + - "\"nonce_str\":\"string(必填)\"" + - "\"pos_order_id\":\"string(必填)\"" + - "\"force\":\"string(选填true/false)\" }") + "\"pos_order_id\":\"string(必填)\"}") @PostMapping("/couponOrderVerifyCancel") @SystemControllerLog(description = "券核销取消") public Map couponOrderIndependentVerifyCancel(@RequestBody Map params) { diff --git a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java index 1ad54af44..cd2e9be77 100644 --- a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java +++ b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java @@ -334,7 +334,6 @@ public class PosServiceImpl implements PosService { retMap.put(WxPayConstant.MEM_PHONE, user.getPhone()); retMap.put(WxPayConstant.ORG_AMOUNT, posAmountStr); retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(remainAmount)); - return retMap; }