| @@ -93,13 +93,13 @@ public class PosController extends BaseController { | |||||
| String memIdStr = params.get(WxPayConstant.MEM_ID); // 会员ID | String memIdStr = params.get(WxPayConstant.MEM_ID); // 会员ID | ||||
| String memPhoneStr = params.get(WxPayConstant.MEM_PHONE); // 会员手机 | String memPhoneStr = params.get(WxPayConstant.MEM_PHONE); // 会员手机 | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单金额(单位:分) | |||||
| if (StringUtils.isBlank(posOrderIdStr)) { | if (StringUtils.isBlank(posOrderIdStr)) { | ||||
| return errParam(WxPayConstant.POS_ORDER_ID); | return errParam(WxPayConstant.POS_ORDER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| return errParam(WxPayConstant.POS_AMOUNT); | |||||
| return errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| if (StringUtils.isBlank(memIdStr) && StringUtils.isBlank(memPhoneStr)) { | if (StringUtils.isBlank(memIdStr) && StringUtils.isBlank(memPhoneStr)) { | ||||
| @@ -116,7 +116,7 @@ public class PosController extends BaseController { | |||||
| WxMerchantBUser user = getUser(); | WxMerchantBUser user = getUser(); | ||||
| String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID | String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额 | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单金额 | |||||
| if (StringUtils.isBlank(couponOrderIdStr)) { | if (StringUtils.isBlank(couponOrderIdStr)) { | ||||
| return errParam(WxPayConstant.COUPON_ORDER_ID); | return errParam(WxPayConstant.COUPON_ORDER_ID); | ||||
| @@ -125,7 +125,7 @@ public class PosController extends BaseController { | |||||
| return errParam(WxPayConstant.POS_ORDER_ID); | return errParam(WxPayConstant.POS_ORDER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| return errParam(WxPayConstant.POS_AMOUNT); | |||||
| return errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| String verifyType = WxPayConstant.SCENE_PAY; | String verifyType = WxPayConstant.SCENE_PAY; | ||||
| return posService.checkCouponOrderForPayVerify(user, verifyType, couponOrderIdStr, posOrderIdStr, posAmountStr); | return posService.checkCouponOrderForPayVerify(user, verifyType, couponOrderIdStr, posOrderIdStr, posAmountStr); | ||||
| @@ -138,7 +138,7 @@ public class PosController extends BaseController { | |||||
| String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID | String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID | ||||
| String deductAmountStr = params.get(WxPayConstant.DEDUCT_AMOUNT); // 扣减金额 | String deductAmountStr = params.get(WxPayConstant.DEDUCT_AMOUNT); // 扣减金额 | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单金额(单位:分) | |||||
| if (StringUtils.isBlank(couponOrderIdStr)) { | if (StringUtils.isBlank(couponOrderIdStr)) { | ||||
| return errParam(WxPayConstant.COUPON_ORDER_ID); | return errParam(WxPayConstant.COUPON_ORDER_ID); | ||||
| @@ -150,7 +150,7 @@ public class PosController extends BaseController { | |||||
| return errParam(WxPayConstant.POS_ORDER_ID); | return errParam(WxPayConstant.POS_ORDER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| return errParam(WxPayConstant.POS_AMOUNT); | |||||
| return errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| return posService.couponOrderPreVerify(user, couponOrderIdStr, deductAmountStr, posOrderIdStr, posAmountStr); | return posService.couponOrderPreVerify(user, couponOrderIdStr, deductAmountStr, posOrderIdStr, posAmountStr); | ||||
| } | } | ||||
| @@ -177,7 +177,7 @@ public class PosController extends BaseController { | |||||
| WxMerchantBUser user = getUser(); | WxMerchantBUser user = getUser(); | ||||
| String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID | String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单金额(单位:分) | |||||
| if (StringUtils.isBlank(couponOrderIdStr)) { | if (StringUtils.isBlank(couponOrderIdStr)) { | ||||
| return errParam(WxPayConstant.COUPON_ORDER_ID); | return errParam(WxPayConstant.COUPON_ORDER_ID); | ||||
| @@ -186,7 +186,7 @@ public class PosController extends BaseController { | |||||
| return errParam(WxPayConstant.POS_ORDER_ID); | return errParam(WxPayConstant.POS_ORDER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| return errParam(WxPayConstant.POS_AMOUNT); | |||||
| return errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| return posService.couponOrderPreVerifyCancel(user, couponOrderIdStr, posOrderIdStr, posAmountStr); | return posService.couponOrderPreVerifyCancel(user, couponOrderIdStr, posOrderIdStr, posAmountStr); | ||||
| } | } | ||||
| @@ -377,7 +377,7 @@ public class PosBrunService { | |||||
| return new ResultData(JSON.toJSONString(retObj)); | return new ResultData(JSON.toJSONString(retObj)); | ||||
| } else { | } else { | ||||
| logger.error(resStr); | logger.error(resStr); | ||||
| return new ResultData(Result.ERROR, retObj.getString(WxPayConstant.ERR_CODE_DES)); | |||||
| return new ResultData(Result.ERROR, retObj.getString(WxPayConstant.RESULT_DATA)); | |||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -233,7 +233,7 @@ public class PosUtil { | |||||
| paramMap.put(WxPayConstant.MEM_PHONE, memPhone); | paramMap.put(WxPayConstant.MEM_PHONE, memPhone); | ||||
| } | } | ||||
| paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| paramMap.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | ||||
| String respStr = doPost(baseUrl + URL_CheckMem, paramMap); | String respStr = doPost(baseUrl + URL_CheckMem, paramMap); | ||||
| @@ -275,7 +275,7 @@ public class PosUtil { | |||||
| paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| } | } | ||||
| if (StringUtils.isNotBlank(posAmount)) { | if (StringUtils.isNotBlank(posAmount)) { | ||||
| paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| paramMap.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| } | } | ||||
| paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | ||||
| @@ -313,7 +313,7 @@ public class PosUtil { | |||||
| paramMap.put(WxPayConstant.BUSER_ID, buUserId); | paramMap.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | ||||
| paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| paramMap.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | ||||
| String respStr = doPost(baseUrl + URL_CouponOrderPreVerify, paramMap); | String respStr = doPost(baseUrl + URL_CouponOrderPreVerify, paramMap); | ||||
| @@ -350,7 +350,7 @@ public class PosUtil { | |||||
| paramMap.put(WxPayConstant.BUSER_ID, buUserId); | paramMap.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | ||||
| paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| paramMap.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | ||||
| String respStr = doPost(baseUrl + URL_CouponOrderPreVerifyCancel, paramMap); | String respStr = doPost(baseUrl + URL_CouponOrderPreVerifyCancel, paramMap); | ||||
| @@ -422,7 +422,7 @@ public class PosUtil { | |||||
| paramMap.put(WxPayConstant.BUSER_ID, buUserId); | paramMap.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | ||||
| paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| paramMap.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | ||||
| String respStr = doPost(baseUrl + URL_CouponOrderPayVerifyOne, paramMap); | String respStr = doPost(baseUrl + URL_CouponOrderPayVerifyOne, paramMap); | ||||
| @@ -457,9 +457,9 @@ public class PosUtil { | |||||
| paramMap.put(WxPayConstant.TENANT_ID, tenantId); | paramMap.put(WxPayConstant.TENANT_ID, tenantId); | ||||
| paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); | paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); | ||||
| paramMap.put(WxPayConstant.BUSER_ID, buUserId); | paramMap.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| paramMap.put(WxPayConstant.SELECTED_COUPON_ORDER_LIST, JSON.toJSONString(couponOrderIdList)); | |||||
| paramMap.put(WxPayConstant.COUPON_ORDER_LIST, JSON.toJSONString(couponOrderIdList)); | |||||
| paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| paramMap.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | ||||
| String respStr = doPost(baseUrl + URL_CouponOrderPayVerifyList, paramMap); | String respStr = doPost(baseUrl + URL_CouponOrderPayVerifyList, paramMap); | ||||
| @@ -72,189 +72,28 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.checkUserPassword(params); | retMap = posService.checkUserPassword(params); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), | |||||
| e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", WxPayConstant.RET_FAIL, | |||||
| 500, | |||||
| e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", 500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @ApiOperation(value = "获取会员折扣/优惠券/消费卡是否启用, 同时返回注册二维码及小票二维码规则", notes = "request: \n{" + | |||||
| "\"dev_id\":\"string(必填)\"," + | |||||
| "\"nonce_str\":\"string(必填)\"," + | |||||
| "\"tenant_id\":\"string(必填)\"}\n" + | |||||
| "\"response: \n{" + | |||||
| "\"return_code\":\"SUCCESS\",\"return_msg\":\"\",\"result_code\":\"SUCCESS\"," + | |||||
| "\"tenant_id\":\"456\",\"mall_name\":\"富茂中心\"," + | |||||
| "\"qrcode_url\":\"https://s3.cn-northwest-1.amazonaws.com.cn/iformall-net/456/formall_c.png\"," + | |||||
| "\"pos_qrcode_rule\":\"https://ctest.malls.iformall.com/order/(二维码规则: url + POS订单ID)\"," + | |||||
| "\"discount\":\"false(是否支持会员折扣,false:禁用,true:可用)\"," + | |||||
| "\"coupon\":\"0(会员优惠券是否开启,0-禁用,1-单选可用,2-多选可用)\",\"coupon_desc\":\"禁用(会员优惠券是否开启描述)\"," + | |||||
| "\"card\":\"false(是否支持卡支付,false:禁用,true:可用)\"" + | |||||
| "\"nonce_str\":\"eea09381622540868d22dee631054b30\"," + | |||||
| "\"sign\":\"0EADC3B7D4B77D0AC923C095B6172955D462366FB4BF142467B4935FA7833A91\"}") | |||||
| @PostMapping("/getPosMemConfig") | |||||
| @SystemControllerLog(description = "获取会员折扣/优惠券/消费卡是否启用") | |||||
| public Map<String, String> getMemStatus(@RequestBody Map<String, String> params) { | |||||
| JSONObject payContent = new JSONObject(); | |||||
| // 1. check sign | |||||
| Map<String, String> retMap = checkSign(params, payContent); | |||||
| if (retMap != null) { | |||||
| // 签名相关异常返回 | |||||
| return retMap; | |||||
| } | |||||
| String resKey = payContent.getString(WxPayConstant.RES_KEY); | |||||
| logger.info(WxPayConstant.RES_KEY + ": " + resKey); | |||||
| try { | |||||
| retMap = posService.getPosMemConfig(params); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", WxPayConstant.RET_SUCCESS, null); | |||||
| } catch (MallinkException e) { | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), | |||||
| e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", WxPayConstant.RET_FAIL, | |||||
| 500, | |||||
| e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation(value = "获取注册二维码及小票二维码规则", notes = "request: \n{" + | |||||
| "\"dev_id\":\"string(必填)\"," + | |||||
| "\"nonce_str\":\"string(必填)\"," + | |||||
| "\"tenant_id\":\"string(必填)\"}\n" + | |||||
| "\"response: \n{" + | |||||
| "\"return_code\":\"SUCCESS\",\"return_msg\":\"\",\"result_code\":\"SUCCESS\"," + | |||||
| "\"tenant_id\":\"456\",\"mall_name\":\"富茂中心\"," + | |||||
| "\"qrcode_url\":\"https://s3.cn-northwest-1.amazonaws.com.cn/iformall-net/456/formall_c.png\"," + | |||||
| "\"pos_qrcode_rule\":\"https://ctest.malls.iformall.com/order/(二维码规则: url + POS订单ID)\"," + | |||||
| "\"nonce_str\":\"5604985305904f35bc9eeeda94346f8d\"," + | |||||
| "\"sign\":\"5760C5989C3DD2F99CB3506EDBA0FB84A77BC60313F65206EB774A203108AA82\"}") | |||||
| @PostMapping("/getQrCode") | |||||
| @SystemControllerLog(description = "获取注册二维码及小票二维码规则") | |||||
| public Map<String, String> getQrCode(@RequestBody Map<String, String> params) { | |||||
| JSONObject payContent = new JSONObject(); | |||||
| // 1. check sign | |||||
| Map<String, String> retMap = checkSign(params, payContent); | |||||
| if (retMap != null) { | |||||
| // 签名相关异常返回 | |||||
| return retMap; | |||||
| } | |||||
| String resKey = payContent.getString(WxPayConstant.RES_KEY); | |||||
| logger.info(WxPayConstant.RES_KEY + ": " + resKey); | |||||
| try { | |||||
| retMap = posService.doGetQrCode(params); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", WxPayConstant.RET_SUCCESS, null); | |||||
| } catch (MallinkException e) { | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), | |||||
| e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", WxPayConstant.RET_FAIL, | |||||
| 500, | |||||
| e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation(value = "会员识别", notes = "request: \n{" + | |||||
| @ApiOperation(value = "查询及试算接口", notes = "{" + | |||||
| "\"dev_id\":\"string(必填)\"," + | "\"dev_id\":\"string(必填)\"," + | ||||
| "\"nonce_str\":\"string(必填)\"," + | "\"nonce_str\":\"string(必填)\"," + | ||||
| "\"tenant_id\":\"string(必填)\"," + | "\"tenant_id\":\"string(必填)\"," + | ||||
| "\"merchant_id\":\"string(必填)\"," + | "\"merchant_id\":\"string(必填)\"," + | ||||
| "\"order_operator_id\":\"string(必填)\"," + | |||||
| "\"mem_id\":\"string(选填)\"," + | "\"mem_id\":\"string(选填)\"," + | ||||
| "\"mem_phone\":\"string(选填)\"," + | |||||
| "\"pos_order_id\":\"string(必填)\"," + | |||||
| "\"pos_amount\":\"string(单位:分)(必填)\"}") | |||||
| @PostMapping("/checkMem") | |||||
| @SystemControllerLog(description = "会员识别") | |||||
| public Map<String, String> checkMem(@RequestBody Map<String, String> params) { | |||||
| JSONObject payContent = new JSONObject(); | |||||
| // 1. check sign | |||||
| Map<String, String> retMap = checkSign(params, payContent); | |||||
| if (retMap != null) { | |||||
| // 签名相关异常返回 | |||||
| return retMap; | |||||
| } | |||||
| String resKey = payContent.getString(WxPayConstant.RES_KEY); | |||||
| logger.info(WxPayConstant.RES_KEY + ": " + resKey); | |||||
| try { | |||||
| retMap = posService.checkMember(params); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| } catch (MallinkException e) { | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation(value = "券检查是否可用-场景(核销/支付)", notes = "{" + | |||||
| "\"dev_id\":\"string(必填)\"," + | |||||
| "\"nonce_str\":\"string(必填)\"," + | |||||
| "\"tenant_id\":\"string(必填)\"," + | |||||
| "\"merchant_id\":\"string(必填)\"," + | |||||
| "\"bu_user_id\":\"string(必填)\"," + | |||||
| "\"coupon_order_id\":\"string(必填)\"," + | |||||
| "\"scene_type\":\"string(1支付2:核销)(必填)\"," + | |||||
| "\"pos_order_id\":\"string(选填)\"," + | |||||
| "\"pos_amount\":\"string单位(分)(选填)\"}") | |||||
| @PostMapping("/checkCouponOrder") | |||||
| @SystemControllerLog(description = "券检查是否可用-场景(核销/支付)") | |||||
| public Map<String, String> checkCouponOrder(@RequestBody Map<String, String> params) { | |||||
| JSONObject payContent = new JSONObject(); | |||||
| // 1. check sign | |||||
| Map<String, String> retMap = checkSign(params, payContent); | |||||
| if (retMap != null) { | |||||
| // 签名相关异常返回 | |||||
| return retMap; | |||||
| } | |||||
| String resKey = payContent.getString(WxPayConstant.RES_KEY); | |||||
| logger.info(WxPayConstant.RES_KEY + ": " + resKey); | |||||
| try { | |||||
| retMap = posService.couponOrderVerifyDo(params, EnumPosActionType.CHECK); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| } catch (MallinkException e) { | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation(value = "支付计算接口", notes = "{" + | |||||
| "\"dev_id\":\"string(必填)\"," + | |||||
| "\"nonce_str\":\"string(必填)\"," + | |||||
| "\"tenant_id\":\"string(必填)\"," + | |||||
| "\"merchant_id\":\"string(必填)\"," + | |||||
| "\"bu_user_id\":\"string(必填)\"," + | |||||
| "\"mem_id\":\"string(选填)\"," + | |||||
| "\"mem_phone\":\"string(选填)\"," + | |||||
| "\"sel_co_list\":\"json array[券包ID list](必填),例[\"1\",\"2\",\"3\"]\"" + | |||||
| "\"pos_order_id\":\"string(选填)\"," + | |||||
| "\"pos_amount\":\"string单位(分)(必填)\"}") | |||||
| @PostMapping("/calcMem") | |||||
| "\"mem_phone_number\":\"string(选填)\"," + | |||||
| "\"business_type\":\"string(0:核销1支付(必填)\"," + | |||||
| "\"order_amount\":\"string单位(分)(必填)\"," + | |||||
| "\"order_amount_left\":\"string单位(分)(必填)\"," + | |||||
| "\"order_create_sn\":\"string单位(分)(必填)\"," + | |||||
| "\"coupon_list\":\"json array[券包ID list](必填),例[\"1\",\"2\",\"3\"]\"}") | |||||
| @PostMapping("/queryAndCalc") | |||||
| @SystemControllerLog(description = "支付计算接口") | @SystemControllerLog(description = "支付计算接口") | ||||
| public Map<String, String> calcForMem(@RequestBody Map<String, String> params) { | public Map<String, String> calcForMem(@RequestBody Map<String, String> params) { | ||||
| JSONObject payContent = new JSONObject(); | JSONObject payContent = new JSONObject(); | ||||
| @@ -269,17 +108,12 @@ public class PosController extends BaseController { | |||||
| logger.info(WxPayConstant.RES_KEY + ": " + resKey); | logger.info(WxPayConstant.RES_KEY + ": " + resKey); | ||||
| try { | try { | ||||
| retMap = posService.calcMem(params); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| retMap = posService.queryAndCalcMem(params); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", 500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -308,16 +142,11 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.couponOrderVerifyDo(params, EnumPosActionType.VERIFY_INDEPENT); | retMap = posService.couponOrderVerifyDo(params, EnumPosActionType.VERIFY_INDEPENT); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", 500, e.getMessage()); | |||||
| } | } | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } | } | ||||
| private void doActionAfterVerify(Map<String, String> params, Map<String, String> retMap) { | private void doActionAfterVerify(Map<String, String> params, Map<String, String> retMap) { | ||||
| @@ -333,8 +162,8 @@ public class PosController extends BaseController { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), e.getMessage()); | throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), e.getMessage()); | ||||
| } | } | ||||
| String errCode = retMap.get(WxPayConstant.ERR_CODE); | |||||
| if(StringUtils.isBlank(errCode)) { | |||||
| String errCode = retMap.get(WxPayConstant.RESULT_CODE); | |||||
| if(StringUtils.isBlank(errCode)||errCode.equals(WxPayConstant.RESULT_SUCCESS)) { | |||||
| // 无异常信息,核销成功 | // 无异常信息,核销成功 | ||||
| couponOrderService.sendInsideCouponVerifyMsg(tenantId, couponOrderId, buUserId); | couponOrderService.sendInsideCouponVerifyMsg(tenantId, couponOrderId, buUserId); | ||||
| } | } | ||||
| @@ -364,16 +193,11 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.couponOrderVerifyCancel(params, EnumPosActionType.VERIFY_CANCEL); | retMap = posService.couponOrderVerifyCancel(params, EnumPosActionType.VERIFY_CANCEL); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -402,16 +226,11 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.couponOrderVerifyDo(params, EnumPosActionType.PAY_VERIFY_PRE); | retMap = posService.couponOrderVerifyDo(params, EnumPosActionType.PAY_VERIFY_PRE); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -439,16 +258,11 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.couponOrderVerifyCancel(params, EnumPosActionType.PAY_VERIFY_PRE_CANCEL); | retMap = posService.couponOrderVerifyCancel(params, EnumPosActionType.PAY_VERIFY_PRE_CANCEL); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -470,16 +284,11 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.posOrderSync(params); | retMap = posService.posOrderSync(params); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", 500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -498,18 +307,13 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.couponOrderVerifyDo(params, EnumPosActionType.VERIFY_PAY); | retMap = posService.couponOrderVerifyDo(params, EnumPosActionType.VERIFY_PAY); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage()); | |||||
| } | } | ||||
| doActionAfterVerify(params, retMap); | doActionAfterVerify(params, retMap); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } | } | ||||
| private Map<String, String> couponOrderPayVerifyList(@RequestBody Map<String, String> params) { | private Map<String, String> couponOrderPayVerifyList(@RequestBody Map<String, String> params) { | ||||
| @@ -527,13 +331,9 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.couponOrderVerifyListDo(params, EnumPosActionType.VERIFY_PAY); | retMap = posService.couponOrderVerifyListDo(params, EnumPosActionType.VERIFY_PAY); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage()); | |||||
| } | } | ||||
| String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID | String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID | ||||
| @@ -544,9 +344,7 @@ public class PosController extends BaseController { | |||||
| buUserId = Long.valueOf(buUserIdStr); | buUserId = Long.valueOf(buUserIdStr); | ||||
| } catch (NumberFormatException e) { | } catch (NumberFormatException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||||
| } | } | ||||
| JSONArray couponArr = JSON.parseArray(arrString); | JSONArray couponArr = JSON.parseArray(arrString); | ||||
| @@ -557,9 +355,7 @@ public class PosController extends BaseController { | |||||
| couponOrderId = Long.valueOf(id); | couponOrderId = Long.valueOf(id); | ||||
| } catch (NumberFormatException e) { | } catch (NumberFormatException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||||
| } | } | ||||
| String errCode = retMap.get(WxPayConstant.VERIFY); | String errCode = retMap.get(WxPayConstant.VERIFY); | ||||
| if(errCode.equalsIgnoreCase(WxPayConstant.TRUE)) { | if(errCode.equalsIgnoreCase(WxPayConstant.TRUE)) { | ||||
| @@ -568,8 +364,7 @@ public class PosController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } | } | ||||
| @ApiOperation(value = "消费卡预支付", notes = "{" + | @ApiOperation(value = "消费卡预支付", notes = "{" + | ||||
| @@ -597,16 +392,11 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.cardPayPre(params); | retMap = posService.cardPayPre(params); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", 500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -636,16 +426,11 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.cardPayPreCancel(params); | retMap = posService.cardPayPreCancel(params); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -663,16 +448,11 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.cardPay(params); | retMap = posService.cardPay(params); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", 500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -690,16 +470,11 @@ public class PosController extends BaseController { | |||||
| try { | try { | ||||
| retMap = posService.cardPayCancel(params); | retMap = posService.cardPayCancel(params); | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_SUCCESS, null); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| e.getErrorCode(), e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", | |||||
| WxPayConstant.RET_FAIL, | |||||
| 500, e.getMessage()); | |||||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", 500, e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -708,69 +483,65 @@ public class PosController extends BaseController { | |||||
| * 构造返回map,无签名, 有错误 | * 构造返回map,无签名, 有错误 | ||||
| * @param retCode | * @param retCode | ||||
| * @param retMsg | * @param retMsg | ||||
| * @param resCode | |||||
| * @param errCode | * @param errCode | ||||
| * @param errMsg | * @param errMsg | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| private Map<String, String> buildReturnMap(String retCode, String retMsg, String resCode, Integer errCode, String errMsg) { | |||||
| private Map<String, String> buildReturnMap(String retCode, String retMsg, Integer errCode, String errMsg) { | |||||
| Map<String, String> retMap = new HashMap<>(); | Map<String, String> retMap = new HashMap<>(); | ||||
| retMap.put(WxPayConstant.RETURN_CODE, retCode); | retMap.put(WxPayConstant.RETURN_CODE, retCode); | ||||
| retMap.put(WxPayConstant.RETURN_MSG, retMsg); | retMap.put(WxPayConstant.RETURN_MSG, retMsg); | ||||
| retMap.put(WxPayConstant.RESULT_CODE, resCode); | |||||
| retMap.put(WxPayConstant.ERR_CODE, "" + errCode); | |||||
| retMap.put(WxPayConstant.ERR_CODE_DES, errMsg); | |||||
| retMap.put(WxPayConstant.TIMESTAMP, neuDateFormat.format(new Date())); | |||||
| retMap.put(WxPayConstant.RESULT_CODE, "" + errCode); | |||||
| retMap.put(WxPayConstant.RESULT_MSG, errMsg); | |||||
| return retMap; | return retMap; | ||||
| } | } | ||||
| /** | /** | ||||
| * 构造返回map,带签名, 有错误 | * 构造返回map,带签名, 有错误 | ||||
| * @param retMap | |||||
| * @param dataMap | |||||
| * @param resKey | * @param resKey | ||||
| * @param retCode | * @param retCode | ||||
| * @param retMsg | * @param retMsg | ||||
| * @param resCode | |||||
| * @param err | * @param err | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| private Map<String, String> buildReturnMap(Map<String, String> retMap, String resKey, String retCode, String retMsg, String resCode, ErrorCode err) { | |||||
| if(retMap == null) { | |||||
| retMap = new HashMap<>(); | |||||
| } | |||||
| private Map<String, String> buildReturnMap(Map<String, String> dataMap, String resKey, String retCode, String retMsg, ErrorCode err) { | |||||
| Map<String, String> retMap = new HashMap<>(); | |||||
| retMap.put(WxPayConstant.RETURN_CODE, retCode); | retMap.put(WxPayConstant.RETURN_CODE, retCode); | ||||
| retMap.put(WxPayConstant.RETURN_MSG, retMsg); | retMap.put(WxPayConstant.RETURN_MSG, retMsg); | ||||
| retMap.put(WxPayConstant.RESULT_CODE, resCode); | |||||
| retMap.put(WxPayConstant.TIMESTAMP, neuDateFormat.format(new Date())); | |||||
| if (err != null) { | if (err != null) { | ||||
| retMap.put(WxPayConstant.ERR_CODE, "" + err.getCode()); | |||||
| retMap.put(WxPayConstant.ERR_CODE_DES, err.getMessage()); | |||||
| retMap.put(WxPayConstant.RESULT_CODE, "" + err.getCode()); | |||||
| retMap.put(WxPayConstant.RESULT_MSG, err.getMessage()); | |||||
| } else { | |||||
| retMap.put(WxPayConstant.RESULT_CODE, "0"); | |||||
| retMap.put(WxPayConstant.RESULT_MSG, ""); | |||||
| } | |||||
| if (dataMap != null) { | |||||
| retMap.put(WxPayConstant.RESULT_DATA, JSON.toJSONString(dataMap)); | |||||
| } | } | ||||
| return WxPayment.buildSignAfterParasMapForHMAC(retMap, resKey); | return WxPayment.buildSignAfterParasMapForHMAC(retMap, resKey); | ||||
| } | } | ||||
| /** | /** | ||||
| * 构造返回map,带签名, 有错误 | * 构造返回map,带签名, 有错误 | ||||
| * @param retMap | |||||
| * @param dataMap | |||||
| * @param resKey | * @param resKey | ||||
| * @param retCode | * @param retCode | ||||
| * @param retMsg | * @param retMsg | ||||
| * @param resCode | |||||
| * @param errCode | * @param errCode | ||||
| * @param errMsg | * @param errMsg | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| private Map<String, String> buildReturnMap(Map<String, String> retMap, String resKey, String retCode, String retMsg, String resCode, Integer errCode, String errMsg) { | |||||
| private Map<String, String> buildReturnMap(Map<String, String> dataMap, String resKey, String retCode, String retMsg, Integer errCode, String errMsg) { | |||||
| Map<String, String> retMap = new HashMap<>(); | |||||
| if(retMap == null) { | if(retMap == null) { | ||||
| retMap = new HashMap<>(); | retMap = new HashMap<>(); | ||||
| } | } | ||||
| retMap.put(WxPayConstant.RETURN_CODE, retCode); | retMap.put(WxPayConstant.RETURN_CODE, retCode); | ||||
| retMap.put(WxPayConstant.RETURN_MSG, retMsg); | retMap.put(WxPayConstant.RETURN_MSG, retMsg); | ||||
| retMap.put(WxPayConstant.RESULT_CODE, resCode); | |||||
| retMap.put(WxPayConstant.ERR_CODE, "" + errCode); | |||||
| retMap.put(WxPayConstant.ERR_CODE_DES, errMsg); | |||||
| retMap.put(WxPayConstant.TIMESTAMP, neuDateFormat.format(new Date())); | |||||
| retMap.put(WxPayConstant.RESULT_CODE, "" + errCode); | |||||
| retMap.put(WxPayConstant.RESULT_MSG, errMsg); | |||||
| retMap.put(WxPayConstant.RESULT_DATA, JSON.toJSONString(dataMap)); | |||||
| return WxPayment.buildSignAfterParasMapForHMAC(retMap, resKey); | return WxPayment.buildSignAfterParasMapForHMAC(retMap, resKey); | ||||
| } | } | ||||
| @@ -787,39 +558,39 @@ public class PosController extends BaseController { | |||||
| String sign = params.get(WxPayConstant.SIGN); // 签名 | String sign = params.get(WxPayConstant.SIGN); // 签名 | ||||
| if (StringUtils.isBlank(devId)) { | if (StringUtils.isBlank(devId)) { | ||||
| String errorMessage = String.format("request params[%s] error.", WxPayConstant.DEV_ID); | String errorMessage = String.format("request params[%s] error.", WxPayConstant.DEV_ID); | ||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", WxPayConstant.RET_FAIL, ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errorMessage); | |||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errorMessage); | |||||
| } | } | ||||
| if (StringUtils.isBlank(sign)) { | if (StringUtils.isBlank(sign)) { | ||||
| String errorMessage = String.format("request params[%s] error.", WxPayConstant.SIGN); | String errorMessage = String.format("request params[%s] error.", WxPayConstant.SIGN); | ||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", WxPayConstant.RET_FAIL, ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errorMessage); | |||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errorMessage); | |||||
| } | } | ||||
| // 查询开发者信息 | // 查询开发者信息 | ||||
| ThDevInfo devInfo = thDevInfoService.getByDevId(devId); | ThDevInfo devInfo = thDevInfoService.getByDevId(devId); | ||||
| if (devInfo == null) { | if (devInfo == null) { | ||||
| String errorMessage = String.format("Can't found devInfo[%s=%s] record in db.", WxPayConstant.DEV_ID, devId); | String errorMessage = String.format("Can't found devInfo[%s=%s] record in db.", WxPayConstant.DEV_ID, devId); | ||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", WxPayConstant.RET_FAIL, ErrorCode.DEV_ID_NOT_FOUND.getCode(), errorMessage); | |||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", ErrorCode.DEV_ID_NOT_FOUND.getCode(), errorMessage); | |||||
| } | } | ||||
| if (devInfo.getState().equals(EnumEnableType.Disable.getCode())) { | if (devInfo.getState().equals(EnumEnableType.Disable.getCode())) { | ||||
| String errorMessage = String.format("devInfo not available [%s=%s] record in db.", WxPayConstant.DEV_ID, devId); | String errorMessage = String.format("devInfo not available [%s=%s] record in db.", WxPayConstant.DEV_ID, devId); | ||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", WxPayConstant.RET_FAIL, ErrorCode.DEV_ID_IS_DISABLED.getCode(), errorMessage); | |||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", ErrorCode.DEV_ID_IS_DISABLED.getCode(), errorMessage); | |||||
| } | } | ||||
| if (StringUtils.isBlank(devInfo.getReqKey())) { | if (StringUtils.isBlank(devInfo.getReqKey())) { | ||||
| String errorMessage = String.format("%s is null[%s=%s] record in db.", WxPayConstant.REQ_KEY, WxPayConstant.DEV_ID, devId); | String errorMessage = String.format("%s is null[%s=%s] record in db.", WxPayConstant.REQ_KEY, WxPayConstant.DEV_ID, devId); | ||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", WxPayConstant.RET_FAIL, ErrorCode.DEV_ID_REQ_KEY_IS_NULL.getCode(), errorMessage); | |||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", ErrorCode.DEV_ID_REQ_KEY_IS_NULL.getCode(), errorMessage); | |||||
| } | } | ||||
| if (StringUtils.isBlank(devInfo.getResKey())) { | if (StringUtils.isBlank(devInfo.getResKey())) { | ||||
| String errorMessage = String.format("%s is null[%s=%s] record in db.", WxPayConstant.RES_KEY, WxPayConstant.DEV_ID, devId); | String errorMessage = String.format("%s is null[%s=%s] record in db.", WxPayConstant.RES_KEY, WxPayConstant.DEV_ID, devId); | ||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", WxPayConstant.RET_FAIL, ErrorCode.DEV_ID_RES_KEY_IS_NULL.getCode(), errorMessage); | |||||
| return buildReturnMap(WxPayConstant.RET_FAIL, "参数错误", ErrorCode.DEV_ID_RES_KEY_IS_NULL.getCode(), errorMessage); | |||||
| } | } | ||||
| payContent.put(WxPayConstant.RES_KEY, devInfo.getResKey()); | payContent.put(WxPayConstant.RES_KEY, devInfo.getResKey()); | ||||
| boolean signVerified = WxPayment.verifyNotifyHMAC(params, devInfo.getReqKey()); | boolean signVerified = WxPayment.verifyNotifyHMAC(params, devInfo.getReqKey()); | ||||
| if (!signVerified) { | if (!signVerified) { | ||||
| String errorMessage = "签名错误"; | |||||
| String errorMessage = ErrorCode.DEV_ID_SIGN_ERR.getMessage(); | |||||
| logger.error(errorMessage + ": " + params.toString()); | logger.error(errorMessage + ": " + params.toString()); | ||||
| return buildReturnMap(WxPayConstant.RET_FAIL, errorMessage, WxPayConstant.RET_FAIL, ErrorCode.DEV_ID_RES_KEY_IS_NULL.getCode(), errorMessage); | |||||
| return buildReturnMap(WxPayConstant.RET_FAIL, errorMessage, ErrorCode.DEV_ID_SIGN_ERR.getCode(), errorMessage + ": " + params.toString()); | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.enums.EnumPosActionType; | import com.iformall.enums.EnumPosActionType; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| @@ -39,7 +40,7 @@ public interface PosService { | |||||
| * @param params | * @param params | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| Map<String, String> calcMem(Map<String, String> params) throws MallinkException; | |||||
| Map<String, String> queryAndCalcMem(Map<String, String> params) throws MallinkException; | |||||
| /** | /** | ||||
| * 核销动作(check, pre_verify, verify) | * 核销动作(check, pre_verify, verify) | ||||
| @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.PromotionCalc; | |||||
| import com.iformall.domain.vo.WxCouponOrderCVo; | import com.iformall.domain.vo.WxCouponOrderCVo; | ||||
| import com.iformall.domain.vo.WxLevelMerchantCVo; | import com.iformall.domain.vo.WxLevelMerchantCVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| @@ -23,10 +24,7 @@ import org.springframework.web.bind.annotation.RequestBody; | |||||
| import java.text.ParseException; | import java.text.ParseException; | ||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.util.*; | |||||
| @Service | @Service | ||||
| @AllArgsConstructor | @AllArgsConstructor | ||||
| @@ -119,10 +117,10 @@ public class PosServiceImpl implements PosService { | |||||
| retMap.put(WxPayConstant.REG_QRCODE_URL, mall.getImgQrcodeWeapp()); | retMap.put(WxPayConstant.REG_QRCODE_URL, mall.getImgQrcodeWeapp()); | ||||
| retMap.put(WxPayConstant.POS_QRCODE_RULE, mall.getPosQrcodeRule()); | retMap.put(WxPayConstant.POS_QRCODE_RULE, mall.getPosQrcodeRule()); | ||||
| retMap.put(WxPayConstant.MEM_DISCOUNT, String.valueOf(config.getDiscount().equals(EnumPosEnableType.Enable.getCode()))); | |||||
| retMap.put(WxPayConstant.MEM_COUPON, String.valueOf(config.getCoupon())); | |||||
| retMap.put(WxPayConstant.MEM_COUPON_DES, EnumPosCouponEnableType.getEnum(config.getCoupon()).getMessage()); | |||||
| retMap.put(WxPayConstant.MEM_CARD, String.valueOf(config.getCard().equals(EnumPosEnableType.Enable.getCode()))); | |||||
| retMap.put(WxPayConstant.DISCOUNT, String.valueOf(config.getDiscount().equals(EnumPosEnableType.Enable.getCode()))); | |||||
| retMap.put(WxPayConstant.COUPON, String.valueOf(config.getCoupon())); | |||||
| retMap.put(WxPayConstant.COUPON_DES, EnumPosCouponEnableType.getEnum(config.getCoupon()).getMessage()); | |||||
| retMap.put(WxPayConstant.CARD, String.valueOf(config.getCard().equals(EnumPosEnableType.Enable.getCode()))); | |||||
| return retMap; | return retMap; | ||||
| } else { | } else { | ||||
| logger.error(ErrorCode.PASSWORD_ERROR.getMessage()); | logger.error(ErrorCode.PASSWORD_ERROR.getMessage()); | ||||
| @@ -163,10 +161,10 @@ public class PosServiceImpl implements PosService { | |||||
| retMap.put(WxPayConstant.REG_QRCODE_URL, mall.getImgQrcodeWeapp()); | retMap.put(WxPayConstant.REG_QRCODE_URL, mall.getImgQrcodeWeapp()); | ||||
| retMap.put(WxPayConstant.POS_QRCODE_RULE, mall.getPosQrcodeRule()); | retMap.put(WxPayConstant.POS_QRCODE_RULE, mall.getPosQrcodeRule()); | ||||
| retMap.put(WxPayConstant.MEM_DISCOUNT, String.valueOf(config.getDiscount().equals(EnumPosEnableType.Enable.getCode()))); | |||||
| retMap.put(WxPayConstant.MEM_COUPON, String.valueOf(config.getCoupon())); | |||||
| retMap.put(WxPayConstant.MEM_COUPON_DES, EnumPosCouponEnableType.getEnum(config.getCoupon()).getMessage()); | |||||
| retMap.put(WxPayConstant.MEM_CARD, String.valueOf(config.getCard().equals(EnumPosEnableType.Enable.getCode()))); | |||||
| retMap.put(WxPayConstant.DISCOUNT, String.valueOf(config.getDiscount().equals(EnumPosEnableType.Enable.getCode()))); | |||||
| retMap.put(WxPayConstant.COUPON, String.valueOf(config.getCoupon())); | |||||
| retMap.put(WxPayConstant.COUPON_DES, EnumPosCouponEnableType.getEnum(config.getCoupon()).getMessage()); | |||||
| retMap.put(WxPayConstant.CARD, String.valueOf(config.getCard().equals(EnumPosEnableType.Enable.getCode()))); | |||||
| return retMap; | return retMap; | ||||
| } | } | ||||
| @@ -211,7 +209,7 @@ public class PosServiceImpl implements PosService { | |||||
| String memIdStr = params.get(WxPayConstant.MEM_ID); // 会员ID | String memIdStr = params.get(WxPayConstant.MEM_ID); // 会员ID | ||||
| String memPhoneStr = params.get(WxPayConstant.MEM_PHONE); // 会员手机 | String memPhoneStr = params.get(WxPayConstant.MEM_PHONE); // 会员手机 | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单金额(单位:分) | |||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| errParam(WxPayConstant.TENANT_ID); | errParam(WxPayConstant.TENANT_ID); | ||||
| @@ -230,7 +228,7 @@ public class PosServiceImpl implements PosService { | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | errParam(WxPayConstant.POS_ORDER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| // 1. 商户ID, B端用户ID | // 1. 商户ID, B端用户ID | ||||
| @@ -261,24 +259,13 @@ public class PosServiceImpl implements PosService { | |||||
| logger.error(ErrorCode.USER_NOT_MEMBER.getMessage()); | logger.error(ErrorCode.USER_NOT_MEMBER.getMessage()); | ||||
| throw new MallinkException(ErrorCode.USER_NOT_MEMBER); | throw new MallinkException(ErrorCode.USER_NOT_MEMBER); | ||||
| } | } | ||||
| /* | |||||
| // 5. 会员level及折扣 | // 5. 会员level及折扣 | ||||
| Integer discount = 100; | |||||
| if (config.getDiscount().equals(EnumEnableType.Enable.getCode())) { | |||||
| discount = getMemLevelDiscount(retMap, tenantId, user, merchantId); | |||||
| } else { | |||||
| retMap.put(WxPayConstant.MEM_DISCOUNT_RATE, discount.toString()); | |||||
| } | |||||
| Double remainAmountD = posAmount * 1.0D * discount / 100; | |||||
| Long remainAmount = Math.round(remainAmountD); | |||||
| Long discountAmount = posAmount - remainAmount; | |||||
| JSONObject discountObj = new JSONObject(); | |||||
| posAmount = getMemLevelDiscount(discountObj, config.getDiscount(), tenantId, user, merchantId, posAmount.intValue()); | |||||
| retMap.put(WxPayConstant.MEM_ID, user.getId().toString()); | retMap.put(WxPayConstant.MEM_ID, user.getId().toString()); | ||||
| retMap.put(WxPayConstant.MEM_PHONE, user.getPhone()); | retMap.put(WxPayConstant.MEM_PHONE, user.getPhone()); | ||||
| retMap.put(WxPayConstant.ORG_AMOUNT, posAmountStr); | |||||
| retMap.put(WxPayConstant.DISCOUNT_AMOUNT, String.valueOf(discountAmount)); | |||||
| retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(remainAmount)); | |||||
| // 6. 优惠券列表 | // 6. 优惠券列表 | ||||
| if (config.getCoupon().equals(EnumEnableType.Enable.getCode())) { | if (config.getCoupon().equals(EnumEnableType.Enable.getCode())) { | ||||
| @@ -310,133 +297,334 @@ public class PosServiceImpl implements PosService { | |||||
| } else { | } else { | ||||
| retMap.put(WxPayConstant.AVAIL_CO_LIST, "[]"); | retMap.put(WxPayConstant.AVAIL_CO_LIST, "[]"); | ||||
| } | } | ||||
| */ | |||||
| return retMap; | return retMap; | ||||
| } | } | ||||
| @Override | @Override | ||||
| @Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
| public Map<String, String> calcMem(Map<String, String> params) throws MallinkException { | |||||
| Map<String, String> retMap = new HashMap<>(); | |||||
| public Map<String, String> queryAndCalcMem(Map<String, String> params) throws MallinkException { | |||||
| Map<String, String> dataMap = new HashMap<>(); | |||||
| String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID | String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID | ||||
| String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | ||||
| String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | ||||
| String memIdStr = params.get(WxPayConstant.MEM_ID); // 会员ID | |||||
| String memPhoneStr = params.get(WxPayConstant.MEM_PHONE); // 会员手机 | |||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) | |||||
| String selCoListStr = params.get(WxPayConstant.SELECTED_COUPON_ORDER_LIST); // 选中的优惠券列表 | |||||
| String sceneTypeStr = params.get(WxPayConstant.SCENE_TYPE); // 交易场景 | |||||
| String orderCreateSN = params.get(WxPayConstant.ORDER_CREATE_SN); // POS SN号 | |||||
| String coListStr = params.get(WxPayConstant.COUPON_ORDER_LIST); // 优惠券列表 | |||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| errParam(WxPayConstant.TENANT_ID); | errParam(WxPayConstant.TENANT_ID); | ||||
| } else { | |||||
| dataMap.put(WxPayConstant.TENANT_ID, tenantId); | |||||
| } | |||||
| if (StringUtils.isBlank(merchantIdStr)) { | |||||
| errParam(WxPayConstant.MERCHANT_ID); | |||||
| } else { | |||||
| dataMap.put(WxPayConstant.MERCHANT_ID, merchantIdStr); | |||||
| } | |||||
| if (StringUtils.isBlank(buUserIdStr)) { | |||||
| errParam(WxPayConstant.BUSER_ID); | |||||
| } else { | |||||
| dataMap.put(WxPayConstant.BUSER_ID, buUserIdStr); | |||||
| } | |||||
| if (StringUtils.isBlank(sceneTypeStr)) { | |||||
| errParam(WxPayConstant.SCENE_TYPE); | |||||
| } else { | |||||
| dataMap.put(WxPayConstant.SCENE_TYPE, sceneTypeStr); | |||||
| } | |||||
| if (StringUtils.isBlank(orderCreateSN)) { | |||||
| errParam(WxPayConstant.ORDER_CREATE_SN); | |||||
| } else { | |||||
| dataMap.put(WxPayConstant.ORDER_CREATE_SN, orderCreateSN); | |||||
| } | } | ||||
| Integer iSceneType; | |||||
| try { | |||||
| iSceneType = Integer.valueOf(sceneTypeStr); | |||||
| } catch (NumberFormatException e) { | |||||
| logger.error(e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||||
| } | |||||
| // 1. POS 支持 配置 | |||||
| PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | ||||
| if (config == null) { | if (config == null) { | ||||
| logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); | logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); | ||||
| throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); | throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); | ||||
| } | } | ||||
| if (StringUtils.isBlank(merchantIdStr)) { | |||||
| errParam(WxPayConstant.MERCHANT_ID); | |||||
| } | |||||
| if (StringUtils.isBlank(posAmountStr)) { | |||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| } | |||||
| if (StringUtils.isBlank(selCoListStr)) { | |||||
| errParam(WxPayConstant.SELECTED_COUPON_ORDER_LIST); | |||||
| } | |||||
| if (StringUtils.isBlank(memIdStr) && StringUtils.isBlank(memPhoneStr)) { | |||||
| errParam2(WxPayConstant.MEM_ID, WxPayConstant.MEM_PHONE); | |||||
| } | |||||
| // 1. 商户ID, B端用户ID | |||||
| Long merchantId, buUserId, posOrderId; | |||||
| Long posAmount = 0L; | |||||
| // 2. 商户ID, B端用户ID | |||||
| Long merchantId, buUserId; | |||||
| try { | try { | ||||
| merchantId = Long.valueOf(merchantIdStr); | merchantId = Long.valueOf(merchantIdStr); | ||||
| buUserId = Long.valueOf(buUserIdStr); | buUserId = Long.valueOf(buUserIdStr); | ||||
| posAmount = Long.valueOf(posAmountStr); | |||||
| } catch (NumberFormatException e) { | } catch (NumberFormatException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR); | throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR); | ||||
| } | } | ||||
| // 2. check merchant | |||||
| // 3. check merchant | |||||
| WxMerchant merchant = checkAndGetMerchant(merchantId); | WxMerchant merchant = checkAndGetMerchant(merchantId); | ||||
| // 3. check buUser | |||||
| // 4. check buUser | |||||
| WxMerchantBUser buUser = checkAndGetMerchantUser(buUserId, merchantId); | WxMerchantBUser buUser = checkAndGetMerchantUser(buUserId, merchantId); | ||||
| // 4. 获取会员信息 | |||||
| WxCUser user = getMemUser(tenantId, memIdStr, memPhoneStr); | |||||
| if (user == null) { | |||||
| logger.error(ErrorCode.USER_NOT_MEMBER.getMessage()); | |||||
| throw new MallinkException(ErrorCode.USER_NOT_MEMBER); | |||||
| } | |||||
| // 5. 获取折扣率 | |||||
| Integer discount = 100; | |||||
| if (config.getDiscount().equals(EnumEnableType.Enable.getCode())) { | |||||
| discount = getMemLevelDiscount(retMap, tenantId, user, merchantId); | |||||
| } else { | |||||
| retMap.put(WxPayConstant.MEM_DISCOUNT_RATE, discount.toString()); | |||||
| } | |||||
| // 6. 计算折扣及剩余支付金额(四舍五入) | |||||
| Double remainAmountD = posAmount * 1.0D * discount / 100; | |||||
| Long remainAmount = Math.round(remainAmountD); | |||||
| Long discountAmount = posAmount - remainAmount; | |||||
| retMap.put(WxPayConstant.MEM_ID, user.getId().toString()); | |||||
| retMap.put(WxPayConstant.MEM_PHONE, user.getPhone()); | |||||
| retMap.put(WxPayConstant.ORG_AMOUNT, posAmountStr); | |||||
| retMap.put(WxPayConstant.DISCOUNT_AMOUNT, String.valueOf(discountAmount)); | |||||
| // 7. 计算券抵扣及剩余支付金额(四舍五入) | |||||
| JSONArray selCoArr = JSONObject.parseArray(selCoListStr); | |||||
| if (selCoArr.size() <= 0) { | |||||
| errParam(WxPayConstant.SELECTED_COUPON_ORDER_LIST); | |||||
| } | |||||
| JSONArray coRetArr = new JSONArray(); | |||||
| for(int i=0;i<selCoArr.size();i++) { | |||||
| String couponOrderIdStr = selCoArr.getString(i); | |||||
| EnumPosSceneType sceneType = EnumPosSceneType.getEnum(iSceneType); | |||||
| JSONObject promotionData = new JSONObject(); | |||||
| JSONObject promotionInfo = new JSONObject(); | |||||
| JSONObject promotionPayment = new JSONObject(); | |||||
| PromotionCalc promotionCalc = new PromotionCalc(); | |||||
| if (sceneType.equals(EnumPosSceneType.VERIFY)) { | |||||
| if (config.getCoupon().equals(EnumPosCouponEnableType.Disable.getCode())) { | |||||
| logger.error(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE.getMessage()); | |||||
| throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | |||||
| } | |||||
| JSONObject promotionCoupon = new JSONObject(); | |||||
| JSONArray couponList = new JSONArray(); | |||||
| if (StringUtils.isBlank(coListStr)) { | |||||
| errParam(WxPayConstant.COUPON_ORDER_LIST); | |||||
| } | |||||
| JSONArray couponOrderArr = JSON.parseArray(coListStr); | |||||
| if (couponOrderArr.size() > 1) { | |||||
| String errMessage = "核销只能使用一张券"; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.VERIFY_ERROR.getCode(), errMessage); | |||||
| } | |||||
| String couponOrderIdStr = couponOrderArr.getString(0); | |||||
| if (couponOrderIdStr != null) { | if (couponOrderIdStr != null) { | ||||
| try { | try { | ||||
| Map<String, String> oneRetMap = calcOneCouponVerify(merchantId, posAmount, couponOrderIdStr); | |||||
| coRetArr.add(oneRetMap); | |||||
| posAmount = Long.valueOf(oneRetMap.get(WxPayConstant.REMAIN_AMOUNT)); | |||||
| if (posAmount.equals(0L)) { | |||||
| break; | |||||
| } | |||||
| JSONObject couponPromoMap = calcOneCouponVerify(promotionCalc, couponOrderIdStr, merchantId); | |||||
| couponList.add(couponPromoMap); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | throw new MallinkException(e.getErrorCode(), e.getMessage()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new MallinkException(500, e.getMessage()); | throw new MallinkException(500, e.getMessage()); | ||||
| } | } | ||||
| } | } | ||||
| promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | |||||
| // 券优惠总信息 | |||||
| promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | |||||
| promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | |||||
| } else if(sceneType.equals(EnumPosSceneType.PAY)) { | |||||
| JSONObject promotionCoupon = new JSONObject(); | |||||
| JSONArray couponList = new JSONArray(); | |||||
| String memIdStr = params.get(WxPayConstant.MEM_ID); // 会员ID | |||||
| String memPhoneStr = params.get(WxPayConstant.MEM_PHONE); // 会员手机 | |||||
| String orderAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单金额(单位:分) | |||||
| String orderAmountLeftStr = params.get(WxPayConstant.ORDER_AMOUNT_LEFT); // POS订单金额(单位:分) | |||||
| if (StringUtils.isBlank(orderAmountStr)) { | |||||
| errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } else { | |||||
| dataMap.put(WxPayConstant.ORDER_AMOUNT, orderAmountStr); | |||||
| } | |||||
| if (StringUtils.isBlank(orderAmountLeftStr)) { | |||||
| errParam(WxPayConstant.ORDER_AMOUNT_LEFT); | |||||
| } else { | |||||
| dataMap.put(WxPayConstant.ORDER_AMOUNT_LEFT, orderAmountLeftStr); | |||||
| } | |||||
| if (StringUtils.isBlank(memIdStr) && StringUtils.isBlank(memPhoneStr)) { | |||||
| errParam2(WxPayConstant.MEM_ID, WxPayConstant.MEM_PHONE); | |||||
| } | |||||
| // 10. 获取会员信息 | |||||
| WxCUser user = getMemUser(tenantId, memIdStr, memPhoneStr); | |||||
| if (user == null) { | |||||
| logger.error(ErrorCode.USER_NOT_MEMBER.getMessage()); | |||||
| throw new MallinkException(ErrorCode.USER_NOT_MEMBER); | |||||
| } | |||||
| if (user != null) { | |||||
| dataMap.put(WxPayConstant.MEM_ID, user.getId().toString()); | |||||
| dataMap.put(WxPayConstant.MEM_PHONE, user.getPhone()); | |||||
| } | |||||
| // 11. 订单金额 | |||||
| Integer orderAmount, orderAmountLeft; | |||||
| try { | |||||
| orderAmount = Integer.valueOf(orderAmountStr); | |||||
| orderAmountLeft = Integer.valueOf(orderAmountLeftStr); | |||||
| } catch (NumberFormatException e) { | |||||
| logger.error(e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||||
| } | |||||
| promotionCalc.setOrderAmount(orderAmount); | |||||
| promotionCalc.setOrderAmountLeft(orderAmountLeft); | |||||
| promotionCalc.setPromotionAmount(0); | |||||
| promotionCalc.setAmountLeftAfterPay(orderAmountLeft); | |||||
| // 12. 会员折扣 | |||||
| JSONObject discountObj = getMemLevelDiscount(promotionCalc, config.getDiscount(), tenantId, user, merchantId); | |||||
| promotionInfo.put(WxPayConstant.MEMBER_DISCOUNT, discountObj); | |||||
| // 14. 获取用户可用券列表 | |||||
| if (!config.getCoupon().equals(EnumPosCouponEnableType.Disable.getCode())) { | |||||
| Map<String, Object> coQ = new HashMap<>(); | |||||
| coQ.put("tenantId", tenantId); | |||||
| coQ.put("cUserId", user.getId()); | |||||
| coQ.put("merchantId", merchantId); | |||||
| List<WxCouponOrderCVo> avaCoList = couponOrderMapper.findAvailCouponOrder(coQ); | |||||
| JSONArray selCoArr = JSONObject.parseArray(coListStr); | |||||
| if (config.getCoupon().equals(EnumPosCouponEnableType.SingleEnable.getCode())) { | |||||
| if (selCoArr.size() > 1) { | |||||
| String errMessage = "支付只能使用一张券"; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.POS_COUPON_PAY_ERROR.getCode(), errMessage); | |||||
| } | |||||
| for (int i = 0; i < avaCoList.size(); i++) { | |||||
| WxCouponOrderCVo couponOrderCVo = avaCoList.get(i); | |||||
| boolean selCoupon = isSelCoupon(selCoArr, couponOrderCVo.getId()); | |||||
| try { | |||||
| JSONObject couponObj = calcOneCouponPay(promotionCalc, couponOrderCVo, selCoupon); | |||||
| couponList.add(couponObj); | |||||
| } catch (MallinkException e) { | |||||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(500, e.getMessage()); | |||||
| } | |||||
| } | |||||
| } else if (config.getCoupon().equals(EnumPosCouponEnableType.MultiEnable.getCode())) { | |||||
| for (int i = 0; i < avaCoList.size(); i++) { | |||||
| WxCouponOrderCVo couponOrderCVo = avaCoList.get(i); | |||||
| boolean selCoupon = isSelCoupon(selCoArr, couponOrderCVo.getId()); | |||||
| try { | |||||
| JSONObject couponObj = calcOneCouponPay(promotionCalc, couponOrderCVo, selCoupon); | |||||
| couponList.add(couponObj); | |||||
| } catch (MallinkException e) { | |||||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| throw new MallinkException(500, e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | |||||
| // 券优惠总信息 | |||||
| promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | |||||
| promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | |||||
| } | |||||
| // 构造支付信息 | |||||
| promotionPayment.put(WxPayConstant.ORDER_AMOUNT, promotionCalc.getOrderAmount()); | |||||
| promotionPayment.put(WxPayConstant.ORDER_AMOUNT_LEFT, promotionCalc.getOrderAmountLeft()); | |||||
| promotionPayment.put(WxPayConstant.PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | |||||
| promotionPayment.put(WxPayConstant.AMOUNT_LEFT_AFTER_PAY, promotionCalc.getAmountLeftAfterPay()); | |||||
| promotionData.put(WxPayConstant.PAYMENT_PREDICTION, promotionPayment); | |||||
| promotionData.put(WxPayConstant.PROMOTION_INFO, promotionInfo); | |||||
| dataMap.put(WxPayConstant.PROMOTION_DATA, JSON.toJSONString(promotionData)); | |||||
| return dataMap; | |||||
| } | |||||
| private boolean isSelCoupon(JSONArray selCoArr, Long couponOrderId) { | |||||
| boolean selCoupon = false; | |||||
| for (int j=0;j<selCoArr.size();j++) { | |||||
| String selCouponOrderStr = selCoArr.getString(j); | |||||
| if (couponOrderId.toString().equals(selCouponOrderStr)) { | |||||
| selCoupon = true; | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| retMap.put(WxPayConstant.MEM_COUPONS, coRetArr.toJSONString()); | |||||
| retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(posAmount)); | |||||
| return retMap; | |||||
| return selCoupon; | |||||
| } | } | ||||
| private Map<String, String> calcOneCouponVerify(Long merchantId, Long posAmount, String couponOrderIdStr) { | |||||
| Map<String, String> retMap = new HashMap<>(); | |||||
| /** | |||||
| * 券核销计算 | |||||
| * @param promotionCalc | |||||
| * @param merchantId | |||||
| * @param couponOrderIdStr | |||||
| * @return | |||||
| */ | |||||
| private JSONObject calcOneCouponVerify(PromotionCalc promotionCalc, String couponOrderIdStr, Long merchantId) { | |||||
| JSONObject retObj = new JSONObject(); | |||||
| Date now = new Date(); | |||||
| // 1. 获取券包信息 | // 1. 获取券包信息 | ||||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(couponOrderIdStr); | |||||
| if (couponOrderCVo == null) { | |||||
| logger.error(ErrorCode.COUPON_ORDER_IS_NULL.getMessage() + ": " + couponOrderIdStr); | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||||
| WxCouponOrderCVo couponOrderCVo = checkAndGetCouponOrder(couponOrderIdStr, merchantId, now); | |||||
| // 2. 检查券类型 核销可用(4, 6, 8, 9) | |||||
| EnumCouponType couponType = EnumCouponType.getEnum(couponOrderCVo.getCouponType()); | |||||
| if (!(couponType.getCode().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || | |||||
| couponType.getCode().equals(EnumCouponType.COUPON_LIPIN.getCode()) || | |||||
| couponType.getCode().equals(EnumCouponType.COUPON_PRESS.getCode()) || | |||||
| couponType.getCode().equals(EnumCouponType.COUPON_GROUP.getCode())) | |||||
| ) { | |||||
| logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage()); | |||||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); | |||||
| } | } | ||||
| // 2. 检查券类型 | |||||
| if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || | |||||
| couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN.getCode()) || | |||||
| couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_DAIJIN.getCode()) | |||||
| )) { | |||||
| retObj.put(WxPayConstant.COUPON_ID, couponOrderIdStr); | |||||
| retObj.put(WxPayConstant.IS_SELECTED, EnumPosSelect.SELECTED.getCode()); | |||||
| retObj.put(WxPayConstant.TITLE, couponOrderCVo.getTitle()); | |||||
| retObj.put(WxPayConstant.COUPON_TYPE, couponType.getMessage()); | |||||
| retObj.put(WxPayConstant.COVER_IMG, couponOrderCVo.getCoverImg()); | |||||
| retObj.put(WxPayConstant.PRICE, couponOrderCVo.getPrice()); | |||||
| retObj.put(WxPayConstant.SALE_PRICE, couponOrderCVo.getSalePrice()); | |||||
| retObj.put(WxPayConstant.COUPON_DES, String.format("过期时间: %s", mydateFormat.format(couponOrderCVo.getExpiredTime()))); | |||||
| promotionCalc.setOrderAmount(couponOrderCVo.getPrice()); | |||||
| promotionCalc.setOrderAmountLeft(couponOrderCVo.getPrice()); | |||||
| promotionCalc.setPromotionAmount(couponOrderCVo.getPrice()); | |||||
| promotionCalc.setAmountLeftAfterPay(0); | |||||
| return retObj; | |||||
| } | |||||
| /** | |||||
| * 券支付计算 | |||||
| * @param promotionCalc | |||||
| * @return | |||||
| */ | |||||
| private JSONObject calcOneCouponPay(PromotionCalc promotionCalc, WxCouponOrderCVo couponOrderCVo, boolean couponSelected) { | |||||
| JSONObject retObj = new JSONObject(); | |||||
| Date now = new Date(); | |||||
| // 2. 检查券类型 支付可用(1, 2, 6), | |||||
| EnumCouponType couponType = EnumCouponType.getEnum(couponOrderCVo.getCouponType()); | |||||
| if (!(couponType.getCode().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || | |||||
| couponType.getCode().equals(EnumCouponType.COUPON_MANJIAN.getCode()) || | |||||
| couponType.getCode().equals(EnumCouponType.COUPON_DAIJIN.getCode()))) { | |||||
| logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage()); | logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage()); | ||||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); | throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); | ||||
| } | } | ||||
| // 3. 券包状态检查 | |||||
| // 3. 满减券检查使用金额 | |||||
| if (couponType.equals(EnumCouponType.COUPON_MANJIAN)) { | |||||
| if (promotionCalc.getOrderAmount() < couponOrderCVo.getUsePrice()) { | |||||
| logger.error(ErrorCode.VERIFY_MANJIAN_USER_PRICE_NOT_TOUCH.getMessage()); | |||||
| throw new MallinkException(ErrorCode.VERIFY_MANJIAN_USER_PRICE_NOT_TOUCH); | |||||
| } | |||||
| } | |||||
| // 4. 生成优惠券抵扣信息 | |||||
| retObj.put(WxPayConstant.COUPON_ID, couponOrderCVo.getId().toString()); | |||||
| retObj.put(WxPayConstant.TITLE, couponOrderCVo.getTitle()); | |||||
| retObj.put(WxPayConstant.COUPON_TYPE, couponType.getMessage()); | |||||
| retObj.put(WxPayConstant.COVER_IMG, couponOrderCVo.getCoverImg()); | |||||
| retObj.put(WxPayConstant.PRICE, couponOrderCVo.getPrice()); | |||||
| retObj.put(WxPayConstant.SALE_PRICE, couponOrderCVo.getSalePrice()); | |||||
| if (couponType.equals(EnumCouponType.COUPON_MANJIAN)) { | |||||
| retObj.put(WxPayConstant.USE_PRICE, couponOrderCVo.getSalePrice()); | |||||
| String des = String.format("%s-满%s元可用,可抵%s元, 过期时间: %s", | |||||
| couponType.getMessage(), couponOrderCVo.getUsePriceStr(), couponOrderCVo.getPriceStr(), | |||||
| mydateFormat.format(couponOrderCVo.getExpiredTime())); | |||||
| retObj.put(WxPayConstant.COUPON_DES, des); | |||||
| } else { | |||||
| String des = String.format("%s-可抵%s元, 过期时间: %s", | |||||
| couponType.getMessage(), couponOrderCVo.getPriceStr(), | |||||
| mydateFormat.format(couponOrderCVo.getExpiredTime())); | |||||
| retObj.put(WxPayConstant.COUPON_DES, des); | |||||
| } | |||||
| if (couponSelected) { | |||||
| retObj.put(WxPayConstant.IS_SELECTED, String.valueOf(EnumPosSelect.SELECTED.getCode())); | |||||
| Integer remainAmount = promotionCalc.getAmountLeftAfterPay() - couponOrderCVo.getPrice(); | |||||
| if (remainAmount < 0) { | |||||
| remainAmount = 0; | |||||
| } | |||||
| Integer discountAmount = promotionCalc.getAmountLeftAfterPay() - remainAmount; | |||||
| promotionCalc.setPromotionAmount(discountAmount); | |||||
| promotionCalc.setAmountLeftAfterPay(remainAmount); | |||||
| } | |||||
| return retObj; | |||||
| } | |||||
| private WxCouponOrderCVo checkAndGetCouponOrder(String couponOrderIdStr, Long merchantId, Date currDate) { | |||||
| // 1, 获取券包信息 | |||||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(couponOrderIdStr); | |||||
| if (couponOrderCVo == null) { | |||||
| logger.error(ErrorCode.COUPON_ORDER_IS_NULL.getMessage() + ": " + couponOrderIdStr); | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||||
| } | |||||
| // 2. 券包状态检查 | |||||
| if (couponOrderCVo.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { | if (couponOrderCVo.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { | ||||
| logger.error("已过期: couponOrder-" + couponOrderIdStr); | logger.error("已过期: couponOrder-" + couponOrderIdStr); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | ||||
| @@ -449,28 +637,26 @@ public class PosServiceImpl implements PosService { | |||||
| logger.error("已经核销过的券: couponOrder-" + couponOrderIdStr); | logger.error("已经核销过的券: couponOrder-" + couponOrderIdStr); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); | ||||
| } | } | ||||
| Date now = new Date(); | |||||
| // 4. 检查有效期 | |||||
| // 3. 检查有效期 | |||||
| if (couponOrderCVo.getValidStartDate() != null && couponOrderCVo.getValidEndDate() != null) { | if (couponOrderCVo.getValidStartDate() != null && couponOrderCVo.getValidEndDate() != null) { | ||||
| if (couponOrderCVo.getValidStartDate().getTime() > now.getTime()) { | |||||
| if (couponOrderCVo.getValidStartDate().getTime() > currDate.getTime()) { | |||||
| logger.error("此券有效期未开始:" + couponOrderIdStr); | logger.error("此券有效期未开始:" + couponOrderIdStr); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | ||||
| } | } | ||||
| if (couponOrderCVo.getValidEndDate().getTime() < now.getTime()) { | |||||
| if (couponOrderCVo.getValidEndDate().getTime() < currDate.getTime()) { | |||||
| logger.error("此券有效期已结束:" + couponOrderIdStr); | logger.error("此券有效期已结束:" + couponOrderIdStr); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | ||||
| } | } | ||||
| } | } | ||||
| // 5 券已过期 | |||||
| if (couponOrderCVo.getExpiredTime().before(now)) { | |||||
| // 4 券已过期 | |||||
| if (couponOrderCVo.getExpiredTime().before(currDate)) { | |||||
| logger.error("此券已过期:" + couponOrderIdStr); | logger.error("此券已过期:" + couponOrderIdStr); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | ||||
| } | } | ||||
| Long couponOrderId = couponOrderCVo.getId(); | Long couponOrderId = couponOrderCVo.getId(); | ||||
| // 6. 检查适用门店 | |||||
| // 5. 检查适用门店 | |||||
| WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | ||||
| wxCouponMerchant.setProductId(couponOrderCVo.getCouponId()); | wxCouponMerchant.setProductId(couponOrderCVo.getCouponId()); | ||||
| wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| @@ -479,17 +665,7 @@ public class PosServiceImpl implements PosService { | |||||
| logger.error("券: coupon-" + couponOrderCVo.getCouponId() + "核销: couponMerchantId-" + merchantId + " 门店不适用"); | logger.error("券: coupon-" + couponOrderCVo.getCouponId() + "核销: couponMerchantId-" + merchantId + " 门店不适用"); | ||||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); | throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); | ||||
| } | } | ||||
| Long remainAmount = posAmount - couponOrderCVo.getPrice(); | |||||
| if (remainAmount < 0L) { | |||||
| remainAmount = 0L; | |||||
| } | |||||
| Long discountAmount = posAmount - remainAmount; | |||||
| retMap.put(WxPayConstant.ID, couponOrderIdStr); | |||||
| retMap.put(WxPayConstant.PRICE, String.valueOf(couponOrderCVo.getPrice())); | |||||
| retMap.put(WxPayConstant.DEDUCT_AMOUNT, String.valueOf(discountAmount)); | |||||
| retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(remainAmount)); | |||||
| return retMap; | |||||
| return couponOrderCVo; | |||||
| } | } | ||||
| private WxCUser getMemUser(String tenantId, String memIdStr, String memPhoneStr) { | private WxCUser getMemUser(String tenantId, String memIdStr, String memPhoneStr) { | ||||
| @@ -514,35 +690,64 @@ public class PosServiceImpl implements PosService { | |||||
| return user; | return user; | ||||
| } | } | ||||
| private Integer getMemLevelDiscount(Map<String, String> retMap, String tenantId, WxCUser user, Long merchantId) { | |||||
| /** | |||||
| * 会员折扣 | |||||
| * @param promotionCalc | |||||
| * @param discountConfig | |||||
| * @param tenantId | |||||
| * @param user | |||||
| * @param merchantId | |||||
| * @return | |||||
| */ | |||||
| private JSONObject getMemLevelDiscount(PromotionCalc promotionCalc, Integer discountConfig, String tenantId, WxCUser user, Long merchantId) { | |||||
| JSONObject discountObj = new JSONObject(); | |||||
| Integer discount = 100; | Integer discount = 100; | ||||
| String level = WxLevelConfigService.DEFAULT_LEVEL; | |||||
| // Level, 折扣 | |||||
| List<WxLevelConfig> levelList = levelConfigService.getByTenantId(tenantId); | |||||
| Long levelId = 0L; | |||||
| for (WxLevelConfig levelConfig : levelList) { | |||||
| if (user.getScore() >= levelConfig.getPoints()) { | |||||
| if (levelConfig.getDiscountEnable().equals(EnumLevelConfigDiscountStatus.ENABLE.getCode())) | |||||
| levelId = levelConfig.getId(); | |||||
| level = levelConfig.getLevel(); | |||||
| if (discountConfig.equals(EnumEnableType.Enable.getCode())) { | |||||
| String level = WxLevelConfigService.DEFAULT_LEVEL; | |||||
| // 1. 会员级别Level | |||||
| List<WxLevelConfig> levelList = levelConfigService.getByTenantId(tenantId); | |||||
| Long levelId = 0L; | |||||
| for (WxLevelConfig levelConfig : levelList) { | |||||
| if (user.getScore() >= levelConfig.getPoints()) { | |||||
| if (levelConfig.getDiscountEnable().equals(EnumLevelConfigDiscountStatus.ENABLE.getCode())) | |||||
| levelId = levelConfig.getId(); | |||||
| level = levelConfig.getLevel(); | |||||
| } | |||||
| } | } | ||||
| } | |||||
| WxLevelMerchant levelMerchant = new WxLevelMerchant(); | |||||
| levelMerchant.setTenantId(tenantId); | |||||
| levelMerchant.setLevelId(levelId); | |||||
| levelMerchant.setMerchantId(merchantId); | |||||
| List<WxLevelMerchantCVo> levelMerchantList = levelConfigService.findListCVo(levelMerchant); | |||||
| if (levelMerchantList.size() >= 1) { | |||||
| WxLevelMerchantCVo levelMerchantCVo = levelMerchantList.get(0); | |||||
| if (levelMerchantCVo != null) { | |||||
| discount = levelMerchantCVo.getDiscount(); | |||||
| // 2. 会员级别对应折扣discount | |||||
| WxLevelMerchant levelMerchant = new WxLevelMerchant(); | |||||
| levelMerchant.setTenantId(tenantId); | |||||
| levelMerchant.setLevelId(levelId); | |||||
| levelMerchant.setMerchantId(merchantId); | |||||
| List<WxLevelMerchantCVo> levelMerchantList = levelConfigService.findListCVo(levelMerchant); | |||||
| if (levelMerchantList.size() >= 1) { | |||||
| WxLevelMerchantCVo levelMerchantCVo = levelMerchantList.get(0); | |||||
| if (levelMerchantCVo != null) { | |||||
| discount = levelMerchantCVo.getDiscount(); | |||||
| } | |||||
| } | } | ||||
| } | |||||
| retMap.put(WxPayConstant.MEM_LEVEL, level); | |||||
| retMap.put(WxPayConstant.MEM_DISCOUNT_RATE, discount.toString()); | |||||
| return discount; | |||||
| discountObj.put(WxPayConstant.LEVEL, level); | |||||
| discountObj.put(WxPayConstant.DISCOUNT_DES, level); | |||||
| discountObj.put(WxPayConstant.DISCOUNT, discount); | |||||
| } else { | |||||
| discountObj.put(WxPayConstant.DISCOUNT, discount); | |||||
| discountObj.put(WxPayConstant.DISCOUNT_DES, "不支持会员折扣"); | |||||
| } | |||||
| // 13. 计算折扣及剩余支付金额(四舍五入) | |||||
| Double remainAmountD = promotionCalc.getAmountLeftAfterPay() * 1.0D * discount / 100; | |||||
| Integer remainAmount = Long.valueOf(Math.round(remainAmountD)).intValue(); | |||||
| Integer discountAmount = promotionCalc.getAmountLeftAfterPay() - remainAmount; | |||||
| discountObj.put(WxPayConstant.ORDER_AMOUNT, promotionCalc.getOrderAmount()); | |||||
| discountObj.put(WxPayConstant.ORDER_AMOUNT_LEFT, promotionCalc.getOrderAmountLeft()); | |||||
| discountObj.put(WxPayConstant.DISCOUNT_AMOUNT, String.valueOf(discountAmount)); | |||||
| discountObj.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(remainAmount)); | |||||
| promotionCalc.setPromotionAmount(discountAmount); | |||||
| promotionCalc.setAmountLeftAfterPay(remainAmount); | |||||
| return discountObj; | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -556,7 +761,7 @@ public class PosServiceImpl implements PosService { | |||||
| String sceneTypeStr = params.get(WxPayConstant.SCENE_TYPE); // 场景类型 | String sceneTypeStr = params.get(WxPayConstant.SCENE_TYPE); // 场景类型 | ||||
| String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券ID | String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券ID | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单总额(单位:分) | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单总额(单位:分) | |||||
| Integer sceneType = null; | Integer sceneType = null; | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| @@ -605,7 +810,7 @@ public class PosServiceImpl implements PosService { | |||||
| if (actionType.equals(EnumPosActionType.PAY_VERIFY_PRE) || | if (actionType.equals(EnumPosActionType.PAY_VERIFY_PRE) || | ||||
| actionType.equals(EnumPosActionType.VERIFY_PAY)) { | actionType.equals(EnumPosActionType.VERIFY_PAY)) { | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| } | } | ||||
| @@ -659,8 +864,8 @@ public class PosServiceImpl implements PosService { | |||||
| String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | ||||
| String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单总额(单位:分) | |||||
| String selCoListStr = params.get(WxPayConstant.SELECTED_COUPON_ORDER_LIST); // 选中的优惠券列表 | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单总额(单位:分) | |||||
| String selCoListStr = params.get(WxPayConstant.COUPON_ORDER_LIST); // 选中的优惠券列表 | |||||
| Integer sceneType = EnumPosSceneType.PAY.getCode(); // 此接口只有支付使用 | Integer sceneType = EnumPosSceneType.PAY.getCode(); // 此接口只有支付使用 | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| @@ -682,14 +887,14 @@ public class PosServiceImpl implements PosService { | |||||
| errParam(WxPayConstant.BUSER_ID); | errParam(WxPayConstant.BUSER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(selCoListStr)) { | if (StringUtils.isBlank(selCoListStr)) { | ||||
| errParam(WxPayConstant.SELECTED_COUPON_ORDER_LIST); | |||||
| errParam(WxPayConstant.COUPON_ORDER_LIST); | |||||
| } | } | ||||
| if (actionType.equals(EnumPosActionType.PAY_VERIFY_PRE) || actionType.equals(EnumPosActionType.VERIFY_INDEPENT)) { | if (actionType.equals(EnumPosActionType.PAY_VERIFY_PRE) || actionType.equals(EnumPosActionType.VERIFY_INDEPENT)) { | ||||
| if (StringUtils.isBlank(posOrderIdStr)) { | if (StringUtils.isBlank(posOrderIdStr)) { | ||||
| errParam(WxPayConstant.POS_ORDER_ID); | errParam(WxPayConstant.POS_ORDER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1416,7 +1621,7 @@ public class PosServiceImpl implements PosService { | |||||
| String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | ||||
| String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单总额(单位:分) | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单总额(单位:分) | |||||
| String cardIdStr = params.get(WxPayConstant.CARD_ID); // 消费卡ID | String cardIdStr = params.get(WxPayConstant.CARD_ID); // 消费卡ID | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| @@ -1441,7 +1646,7 @@ public class PosServiceImpl implements PosService { | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | errParam(WxPayConstant.POS_ORDER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| if (StringUtils.isBlank(cardIdStr)) { | if (StringUtils.isBlank(cardIdStr)) { | ||||
| errParam(WxPayConstant.CARD_ID); | errParam(WxPayConstant.CARD_ID); | ||||
| @@ -1539,7 +1744,7 @@ public class PosServiceImpl implements PosService { | |||||
| String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | ||||
| String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单总额(单位:分) | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单总额(单位:分) | |||||
| String cardIdStr = params.get(WxPayConstant.CARD_ID); // 消费卡ID | String cardIdStr = params.get(WxPayConstant.CARD_ID); // 消费卡ID | ||||
| String cardSpendIdStr = params.get(WxPayConstant.CARD_SPEND_ID); // 消费卡花费ID | String cardSpendIdStr = params.get(WxPayConstant.CARD_SPEND_ID); // 消费卡花费ID | ||||
| @@ -1565,7 +1770,7 @@ public class PosServiceImpl implements PosService { | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | errParam(WxPayConstant.POS_ORDER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| if (StringUtils.isBlank(cardIdStr)) { | if (StringUtils.isBlank(cardIdStr)) { | ||||
| errParam(WxPayConstant.CARD_ID); | errParam(WxPayConstant.CARD_ID); | ||||
| @@ -1654,7 +1859,7 @@ public class PosServiceImpl implements PosService { | |||||
| String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID | ||||
| String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | ||||
| String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID | ||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单总额(单位:分) | |||||
| String posAmountStr = params.get(WxPayConstant.ORDER_AMOUNT); // POS订单总额(单位:分) | |||||
| String cardIdStr = params.get(WxPayConstant.CARD_ID); // 消费卡ID | String cardIdStr = params.get(WxPayConstant.CARD_ID); // 消费卡ID | ||||
| String cardSpendIdStr = params.get(WxPayConstant.CARD_SPEND_ID); // 消费卡花费ID | String cardSpendIdStr = params.get(WxPayConstant.CARD_SPEND_ID); // 消费卡花费ID | ||||
| @@ -1680,7 +1885,7 @@ public class PosServiceImpl implements PosService { | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | errParam(WxPayConstant.POS_ORDER_ID); | ||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| errParam(WxPayConstant.ORDER_AMOUNT); | |||||
| } | } | ||||
| if (StringUtils.isBlank(cardIdStr)) { | if (StringUtils.isBlank(cardIdStr)) { | ||||
| errParam(WxPayConstant.CARD_ID); | errParam(WxPayConstant.CARD_ID); | ||||
| @@ -2160,6 +2365,17 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | ||||
| } | } | ||||
| /** | |||||
| * 输入参数错误 | |||||
| * @param paramStr | |||||
| * @throws MallinkException | |||||
| */ | |||||
| private void errParamCast(String paramStr, String valStr) throws MallinkException { | |||||
| String errMessage = String.format("request params[%s] error: %s", paramStr, valStr); | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), errMessage); | |||||
| } | |||||
| /** | /** | ||||
| * POS订单添加 | * POS订单添加 | ||||
| * @return | * @return | ||||
| @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import com.iformall.PosApplication; | import com.iformall.PosApplication; | ||||
| import com.iformall.enums.EnumPosSceneType; | |||||
| import com.iformall.pay.WxPayConstant; | import com.iformall.pay.WxPayConstant; | ||||
| import com.iformall.pay.WxPayment; | import com.iformall.pay.WxPayment; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -156,32 +157,75 @@ public class PosAppTest { | |||||
| reqObj.put(WxPayConstant.MEM_PHONE, phone); | reqObj.put(WxPayConstant.MEM_PHONE, phone); | ||||
| } | } | ||||
| reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| boolean resSigned = sendAndRes("/checkMem", reqObj); | boolean resSigned = sendAndRes("/checkMem", reqObj); | ||||
| Assert.assertEquals(resSigned, true); | Assert.assertEquals(resSigned, true); | ||||
| } | } | ||||
| @Test | @Test | ||||
| public void checkCalcTest() throws Exception { | |||||
| public void checkVerifyCalcTest() throws Exception { | |||||
| String selCoList = "[\"321872988134408192\"]"; | |||||
| String sceneType = String.valueOf(EnumPosSceneType.VERIFY.getCode()); | |||||
| Map<String, String> reqObj = new HashMap<>(); | |||||
| reqObj.put(WxPayConstant.NONCE_STR, "1"); | |||||
| reqObj.put(WxPayConstant.DEV_ID, devId); | |||||
| reqObj.put(WxPayConstant.TENANT_ID, tenantId); | |||||
| reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | |||||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | |||||
| reqObj.put(WxPayConstant.SCENE_TYPE, sceneType); | |||||
| reqObj.put(WxPayConstant.ORDER_CREATE_SN, posSN); | |||||
| reqObj.put(WxPayConstant.COUPON_ORDER_LIST, selCoList); | |||||
| boolean resSigned = sendAndRes("/queryAndCalc", reqObj); | |||||
| Assert.assertEquals(resSigned, true); | |||||
| } | |||||
| @Test | |||||
| public void checkPayCalcTest() throws Exception { | |||||
| String memId = "321178010928119808"; | String memId = "321178010928119808"; | ||||
| String phone = "13910154397"; | String phone = "13910154397"; | ||||
| String posAmount = "20000"; | |||||
| String selCoList = "[\"321877927162249216\"]"; | |||||
| String orderAmount = "2000"; | |||||
| String orderAmountLeft = "2000"; | |||||
| String selCoList = "[]"; | |||||
| String sceneType = String.valueOf(EnumPosSceneType.PAY.getCode()); | |||||
| Map<String, String> reqObj = new HashMap<>(); | Map<String, String> reqObj = new HashMap<>(); | ||||
| reqObj.put(WxPayConstant.NONCE_STR, "1"); | reqObj.put(WxPayConstant.NONCE_STR, "1"); | ||||
| reqObj.put(WxPayConstant.DEV_ID, devId); | reqObj.put(WxPayConstant.DEV_ID, devId); | ||||
| reqObj.put(WxPayConstant.TENANT_ID, tenantId); | reqObj.put(WxPayConstant.TENANT_ID, tenantId); | ||||
| reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | ||||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | reqObj.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| if (StringUtils.isNotBlank(memId)) { | |||||
| reqObj.put(WxPayConstant.MEM_ID, memId); | |||||
| } | |||||
| if (StringUtils.isNotBlank(phone)) { | |||||
| reqObj.put(WxPayConstant.MEM_PHONE, phone); | |||||
| } | |||||
| reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| reqObj.put(WxPayConstant.SELECTED_COUPON_ORDER_LIST, selCoList); | |||||
| boolean resSigned = sendAndRes("/calcMem", reqObj); | |||||
| reqObj.put(WxPayConstant.MEM_ID, memId); | |||||
| reqObj.put(WxPayConstant.MEM_PHONE, phone); | |||||
| reqObj.put(WxPayConstant.SCENE_TYPE, sceneType); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT, orderAmount); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT_LEFT, orderAmountLeft); | |||||
| reqObj.put(WxPayConstant.ORDER_CREATE_SN, posSN); | |||||
| reqObj.put(WxPayConstant.COUPON_ORDER_LIST, selCoList); | |||||
| boolean resSigned = sendAndRes("/queryAndCalc", reqObj); | |||||
| Assert.assertEquals(resSigned, true); | |||||
| } | |||||
| @Test | |||||
| public void checkPayCalc1Test() throws Exception { | |||||
| String memId = "321178010928119808"; | |||||
| String phone = "13910154397"; | |||||
| String orderAmount = "20000"; | |||||
| String orderAmountLeft = "20000"; | |||||
| String selCoList = "[\"321878185355214848\"]"; | |||||
| String sceneType = String.valueOf(EnumPosSceneType.PAY.getCode()); | |||||
| Map<String, String> reqObj = new HashMap<>(); | |||||
| reqObj.put(WxPayConstant.NONCE_STR, "1"); | |||||
| reqObj.put(WxPayConstant.DEV_ID, devId); | |||||
| reqObj.put(WxPayConstant.TENANT_ID, tenantId); | |||||
| reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | |||||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | |||||
| reqObj.put(WxPayConstant.MEM_ID, memId); | |||||
| reqObj.put(WxPayConstant.MEM_PHONE, phone); | |||||
| reqObj.put(WxPayConstant.SCENE_TYPE, sceneType); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT, orderAmount); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT_LEFT, orderAmountLeft); | |||||
| reqObj.put(WxPayConstant.ORDER_CREATE_SN, posSN); | |||||
| reqObj.put(WxPayConstant.COUPON_ORDER_LIST, selCoList); | |||||
| boolean resSigned = sendAndRes("/queryAndCalc", reqObj); | |||||
| Assert.assertEquals(resSigned, true); | Assert.assertEquals(resSigned, true); | ||||
| } | } | ||||
| @@ -327,7 +371,7 @@ public class PosAppTest { | |||||
| reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | ||||
| reqObj.put(WxPayConstant.SCENE_TYPE, sceneType); | reqObj.put(WxPayConstant.SCENE_TYPE, sceneType); | ||||
| reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| boolean resSigned = sendAndRes("/checkCouponOrder", reqObj); | boolean resSigned = sendAndRes("/checkCouponOrder", reqObj); | ||||
| Assert.assertEquals(resSigned, true); | Assert.assertEquals(resSigned, true); | ||||
| } | } | ||||
| @@ -367,7 +411,7 @@ public class PosAppTest { | |||||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | reqObj.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | ||||
| reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| boolean resSigned = sendAndRes("/couponOrderPreVerify", reqObj); | boolean resSigned = sendAndRes("/couponOrderPreVerify", reqObj); | ||||
| Assert.assertEquals(resSigned, true); | Assert.assertEquals(resSigned, true); | ||||
| } | } | ||||
| @@ -395,7 +439,7 @@ public class PosAppTest { | |||||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | reqObj.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | reqObj.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | ||||
| reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| boolean resSigned = sendAndRes("/couponOrderPayVerifyOne", reqObj); | boolean resSigned = sendAndRes("/couponOrderPayVerifyOne", reqObj); | ||||
| Assert.assertEquals(resSigned, true); | Assert.assertEquals(resSigned, true); | ||||
| } | } | ||||
| @@ -407,9 +451,9 @@ public class PosAppTest { | |||||
| reqObj.put(WxPayConstant.TENANT_ID, tenantId); | reqObj.put(WxPayConstant.TENANT_ID, tenantId); | ||||
| reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | ||||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | reqObj.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| reqObj.put(WxPayConstant.SELECTED_COUPON_ORDER_LIST, couponOrderIdList); | |||||
| reqObj.put(WxPayConstant.COUPON_ORDER_LIST, couponOrderIdList); | |||||
| reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| boolean resSigned = sendAndRes("/couponOrderPayVerifyList", reqObj); | boolean resSigned = sendAndRes("/couponOrderPayVerifyList", reqObj); | ||||
| Assert.assertEquals(resSigned, true); | Assert.assertEquals(resSigned, true); | ||||
| } | } | ||||
| @@ -422,7 +466,7 @@ public class PosAppTest { | |||||
| reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | ||||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | reqObj.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | ||||
| reqObj.put(WxPayConstant.POS_AMOUNT, posAmount); | |||||
| reqObj.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||||
| reqObj.put(WxPayConstant.CARD_ID, cardId); | reqObj.put(WxPayConstant.CARD_ID, cardId); | ||||
| boolean resSigned = sendAndRes("/cardPayPre", reqObj); | boolean resSigned = sendAndRes("/cardPayPre", reqObj); | ||||
| Assert.assertEquals(resSigned, true); | Assert.assertEquals(resSigned, true); | ||||
| @@ -244,7 +244,8 @@ public enum ErrorCode{ | |||||
| POS_CONFIG_MEM_COUPON_DISABLE(11102, "POS会员优惠券未启用"), | POS_CONFIG_MEM_COUPON_DISABLE(11102, "POS会员优惠券未启用"), | ||||
| POS_COUPON_ORDER_NOT_VERIFY(11103, "此券未核销"), | POS_COUPON_ORDER_NOT_VERIFY(11103, "此券未核销"), | ||||
| POS_COUPON_ORDER_VERIFY_NOT_CANCEL(11104, "此券核销无法取消"), | POS_COUPON_ORDER_VERIFY_NOT_CANCEL(11104, "此券核销无法取消"), | ||||
| POS_CAR_PAY_NOT_CANCEL(11105, "卡支付无法取消"), | |||||
| POS_COUPON_PAY_ERROR(11105, "POS券包支付异常"), | |||||
| POS_CAR_PAY_NOT_CANCEL(11106, "卡支付无法取消"), | |||||
| POS_CMD_FAIL(11200, "POS命令错误"), | POS_CMD_FAIL(11200, "POS命令错误"), | ||||
| @@ -0,0 +1,17 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import com.iformall.domain.po.BaseEntity; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class PromotionCalc extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="订单总金额",name="orderAmount") | |||||
| Integer orderAmount; | |||||
| @io.swagger.annotations.ApiModelProperty(value="订单剩余金额",name="orderAmountLeft") | |||||
| Integer orderAmountLeft; | |||||
| @io.swagger.annotations.ApiModelProperty(value="优惠金额",name="promotionAmount") | |||||
| Integer promotionAmount; | |||||
| @io.swagger.annotations.ApiModelProperty(value="优惠后剩余金额",name="amountLeftAfterPay") | |||||
| Integer amountLeftAfterPay; | |||||
| } | |||||
| @@ -8,6 +8,7 @@ import lombok.ToString; | |||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import javax.persistence.Transient; | import javax.persistence.Transient; | ||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -82,4 +83,34 @@ public class WxCouponOrderCVo extends WxCouponOrder { | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户列表",name="merchantVoList") | @io.swagger.annotations.ApiModelProperty(value="商户列表",name="merchantVoList") | ||||
| private List<WxMerchantVo> merchantVoList; | private List<WxMerchantVo> merchantVoList; | ||||
| @Transient | |||||
| private String salePriceStr; | |||||
| @Transient | |||||
| private String usePriceStr; | |||||
| @Transient | |||||
| private String priceStr; | |||||
| public String getSalePriceStr() { | |||||
| if(salePrice!=null) { | |||||
| salePriceStr = new BigDecimal(salePrice).divide(new BigDecimal(100)).toString(); | |||||
| } | |||||
| return salePriceStr; | |||||
| } | |||||
| public String getUsePriceStr() { | |||||
| if(usePrice!=null) { | |||||
| usePriceStr = new BigDecimal(usePrice).divide(new BigDecimal(100)).toString(); | |||||
| } | |||||
| return usePriceStr; | |||||
| } | |||||
| public String getPriceStr() { | |||||
| if(price!=null) { | |||||
| priceStr = new BigDecimal(price).divide(new BigDecimal(100)).toString(); | |||||
| } | |||||
| return priceStr; | |||||
| } | |||||
| } | } | ||||
| @@ -7,8 +7,8 @@ package com.iformall.enums; | |||||
| public enum EnumPosSceneType { | public enum EnumPosSceneType { | ||||
| PAY(1,"支付"), | |||||
| VERIFY(2,"核销") | |||||
| VERIFY(0,"核销"), | |||||
| PAY(1,"支付") | |||||
| ; | ; | ||||
| public static EnumPosSceneType getEnum(Integer code) { | public static EnumPosSceneType getEnum(Integer code) { | ||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumPosSelect { | |||||
| // 0:不使用 1:使用 | |||||
| NOT_SEL(0, "不使用"), | |||||
| SELECTED(1, "使用") | |||||
| ; | |||||
| public static EnumPosSelect getEnum(Integer code) { | |||||
| for (EnumPosSelect value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumPosSelect(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -74,5 +74,5 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||||
| /// POS接口 | /// POS接口 | ||||
| List<Map> findAvailCouponOrder(Map<String,Object> params); | |||||
| List<WxCouponOrderCVo> findAvailCouponOrder(Map<String,Object> params); | |||||
| } | } | ||||
| @@ -6,13 +6,15 @@ public class WxPayConstant { | |||||
| public final static String RET_SUCCESS = "SUCCESS"; | public final static String RET_SUCCESS = "SUCCESS"; | ||||
| public final static String RET_FAIL = "FAIL"; | public final static String RET_FAIL = "FAIL"; | ||||
| public final static String RESULT_SUCCESS = "0"; | |||||
| public final static String RETURN_CODE = "return_code"; | public final static String RETURN_CODE = "return_code"; | ||||
| public final static String RETURN_MSG = "return_msg"; | public final static String RETURN_MSG = "return_msg"; | ||||
| public final static String RESULT_CODE = "result_code"; | public final static String RESULT_CODE = "result_code"; | ||||
| public final static String RESULT_MSG = "result_msg"; | |||||
| public final static String RESULT_DATA = "result_data"; | |||||
| public final static String TIMESTAMP = "timestamp"; | public final static String TIMESTAMP = "timestamp"; | ||||
| public final static String ERR_CODE = "err_code"; | |||||
| public final static String ERR_CODE_DES = "err_code_des"; | |||||
| public final static String NONCE_STR = "nonce_str"; | public final static String NONCE_STR = "nonce_str"; | ||||
| public final static String DEV_ID = "dev_id"; | public final static String DEV_ID = "dev_id"; | ||||
| public final static String SIGN = "sign"; | public final static String SIGN = "sign"; | ||||
| @@ -24,24 +26,31 @@ public class WxPayConstant { | |||||
| public final static String MERCHANT_ID = "merchant_id"; | public final static String MERCHANT_ID = "merchant_id"; | ||||
| public final static String MERCHANT_NAME = "merchant_name"; | public final static String MERCHANT_NAME = "merchant_name"; | ||||
| public final static String MERCHANT_IMG = "merchant_img"; | public final static String MERCHANT_IMG = "merchant_img"; | ||||
| public final static String BUSER_ID = "bu_user_id"; | |||||
| public final static String BUSER_ID = "order_operation_id"; | |||||
| public final static String COUPON_ORDER_ID = "coupon_order_id"; | public final static String COUPON_ORDER_ID = "coupon_order_id"; | ||||
| public final static String SELECTED_COUPON_ORDER_LIST = "sel_co_list"; | |||||
| public final static String COUPON_ORDER_LIST = "coupon_list"; | |||||
| public final static String POS_ORDER_ID = "pos_order_id"; | public final static String POS_ORDER_ID = "pos_order_id"; | ||||
| public final static String POS_AMOUNT = "pos_amount"; | |||||
| public final static String ORDER_CREATE_SN = "order_create_sn"; | |||||
| public final static String ORDER_AMOUNT = "order_amount"; | |||||
| public final static String ORDER_AMOUNT_LEFT = "order_amount_left"; | |||||
| public final static String MEM_ID = "mem_id"; | public final static String MEM_ID = "mem_id"; | ||||
| public final static String MEM_PHONE = "mem_phone"; | |||||
| public final static String MEM_PHONE = "mem_phone_number"; | |||||
| public final static String CARD_ID = "card_id"; | public final static String CARD_ID = "card_id"; | ||||
| public final static String CARD_SPEND_ID = "card_spend_id"; | public final static String CARD_SPEND_ID = "card_spend_id"; | ||||
| public final static String PHONE = "phone"; | public final static String PHONE = "phone"; | ||||
| public final static String PASSWORD = "password"; | public final static String PASSWORD = "password"; | ||||
| public final static String PROMOTION_AMOUNT = "promotion_amount"; | |||||
| public final static String AMOUNT_LEFT_AFTER_PAY = "amount_left_after_pay"; | |||||
| public final static String TITLE = "title"; | public final static String TITLE = "title"; | ||||
| public final static String COVER_IMG = "cover_img"; | public final static String COVER_IMG = "cover_img"; | ||||
| public final static String EXPIRE_TIME = "expire_time"; | public final static String EXPIRE_TIME = "expire_time"; | ||||
| public final static String VALID_START_DATE = "valid_start_date"; | public final static String VALID_START_DATE = "valid_start_date"; | ||||
| public final static String VALID_END_DATE = "valid_end_date"; | public final static String VALID_END_DATE = "valid_end_date"; | ||||
| public final static String PRICE = "price"; | public final static String PRICE = "price"; | ||||
| public final static String SALE_PRICE = "sale_price"; | |||||
| public final static String USE_PRICE = "use_price"; | |||||
| public final static String STATUS = "status"; | public final static String STATUS = "status"; | ||||
| public final static String STATUS_DES = "status_des"; | public final static String STATUS_DES = "status_des"; | ||||
| @@ -62,15 +71,26 @@ public class WxPayConstant { | |||||
| public final static String POS_QRCODE_RULE = "pos_qrcode_rule"; | public final static String POS_QRCODE_RULE = "pos_qrcode_rule"; | ||||
| public final static String MEM_DISCOUNT = "discount"; | |||||
| public final static String MEM_DISCOUNT_RATE = "discount_rate"; | |||||
| public final static String MEM_COUPON = "coupon"; | |||||
| public final static String DISCOUNT = "discount"; | |||||
| public final static String DISCOUNT_DES = "discount_description"; | |||||
| public final static String DISCOUNT_RATE = "discount_rate"; | |||||
| public final static String COUPON = "coupon"; | |||||
| public final static String MEM_COUPONS = "coupons"; | public final static String MEM_COUPONS = "coupons"; | ||||
| public final static String MEM_COUPON_DES = "coupon_des"; | |||||
| public final static String MEM_CARD = "card"; | |||||
| public final static String MEM_LEVEL = "level"; | |||||
| public final static String COUPON_DES = "coupon_description"; | |||||
| public final static String CARD = "card"; | |||||
| public final static String LEVEL = "level"; | |||||
| public final static String AVAIL_CO_LIST = "avail_co_list"; | public final static String AVAIL_CO_LIST = "avail_co_list"; | ||||
| public final static String ID = "id"; | public final static String ID = "id"; | ||||
| public final static String COUPON_ID = "coupon_id"; | |||||
| public final static String COUPON_TYPE = "coupon_type"; | |||||
| public final static String IS_SELECTED = "is_selected"; | |||||
| public final static String COUPON_PROMOTION_AMOUNT = "coupon_promotion_amount"; | |||||
| public final static String MEMBER_DISCOUNT = "member_discount"; | |||||
| public final static String PROMOTION_INFO = "promotion_info"; | |||||
| public final static String PROMOTION_DATA = "promotion_data"; | |||||
| public final static String PAYMENT_PREDICTION = "payment_prediction"; | |||||
| public final static String DEDUCT_AMOUNT = "deduct_amount"; | public final static String DEDUCT_AMOUNT = "deduct_amount"; | ||||
| public final static String REMAIN_AMOUNT = "remain_amount"; | public final static String REMAIN_AMOUNT = "remain_amount"; | ||||
| @@ -80,7 +100,7 @@ public class WxPayConstant { | |||||
| public final static String CREDIT = "credit"; | public final static String CREDIT = "credit"; | ||||
| public final static String REAL_AMOUNT = "real_amount"; | public final static String REAL_AMOUNT = "real_amount"; | ||||
| public final static String SALE_PRICE = "sale_price"; | |||||
| public final static String SALE_FEE = "sale_fee"; | public final static String SALE_FEE = "sale_fee"; | ||||
| public final static String ORG_AMOUNT = "org_amount"; | public final static String ORG_AMOUNT = "org_amount"; | ||||
| @@ -189,11 +189,4 @@ public interface WxCouponOrderService { | |||||
| ResultData queryCardStatus(WxCouponOrder wxCouponOrder); | ResultData queryCardStatus(WxCouponOrder wxCouponOrder); | ||||
| void exportData(WxCouponOrderBVo wxCouponOrder, HttpServletRequest request, HttpServletResponse response); | void exportData(WxCouponOrderBVo wxCouponOrder, HttpServletRequest request, HttpServletResponse response); | ||||
| /** | |||||
| * POS相关接口 | |||||
| */ | |||||
| List<Map> findAvailCouponOrder(Map<String, Object> params); | |||||
| } | } | ||||
| @@ -981,9 +981,4 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| wxCardTransferInfoMapper.insertSelective(wxCardTransferInfo); | wxCardTransferInfoMapper.insertSelective(wxCardTransferInfo); | ||||
| } | } | ||||
| @Override | |||||
| public List<Map> findAvailCouponOrder(Map<String, Object> params) { | |||||
| return wxCouponOrderMapper.findAvailCouponOrder(params); | |||||
| } | |||||
| } | } | ||||
| @@ -876,6 +876,34 @@ | |||||
| and co.id = #{id} | and co.id = #{id} | ||||
| </select> | </select> | ||||
| <select id="findAvailCouponOrder" parameterType="java.util.Map" resultMap="CVoResultMap"> | |||||
| select <include refid="allCUserCouponOrderListColumns" /> | |||||
| from wx_coupon_order co | |||||
| left join wx_coupon_merchant cm on cm.product_id = co.coupon_id | |||||
| left join wx_coupon c on c.id = co.coupon_id | |||||
| left join wx_coupon_action_log cal on cal.coupon_order_id = co.id | |||||
| where co.tenant_id = #{tenantId} and co.c_user_id = #{cUserId} | |||||
| and co.coupon_order_status = 0 | |||||
| and cm.merchant_id = #{merchantId} | |||||
| and co.expired_time > now() | |||||
| and c.type in (1, 2, 6) | |||||
| union | |||||
| select <include refid="allCUserCouponOrderListColumns" /> | |||||
| from wx_coupon_order co | |||||
| left join wx_coupon_merchant cm on cm.product_id = co.coupon_id | |||||
| left join wx_coupon c on c.id = co.coupon_id | |||||
| left join wx_coupon_action_log cal on cal.coupon_order_id = co.id | |||||
| left join pos_coupon_order_verify pco on pco.coupon_order_id = co.id | |||||
| where co.tenant_id = #{tenantId} and co.c_user_id = #{cUserId} | |||||
| and co.coupon_order_status = 100 | |||||
| and cm.merchant_id = #{merchantId} | |||||
| and co.expired_time > now() | |||||
| <if test="posOrderId != null"> | |||||
| and pco.pos_order_id = #{posOrderId} | |||||
| </if> | |||||
| and c.type in (1, 2, 6) | |||||
| </select> | |||||
| <sql id="allCUserCouponOrderCarListColumns"> | <sql id="allCUserCouponOrderCarListColumns"> | ||||
| co.id,co.coupon_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type, | co.id,co.coupon_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type, | ||||
| c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit, | c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit, | ||||
| @@ -1049,42 +1077,4 @@ | |||||
| and co.id = #{id} | and co.id = #{id} | ||||
| </select> | </select> | ||||
| <select id="findAvailCouponOrder" parameterType="java.util.Map" resultType="hashmap"> | |||||
| select co.id, c.title, c.type, co.create_date, co.expired_time, c.price, | |||||
| if((co.coupon_price > 0 or (c.subsidy_type>0 and c.subsidy_num >0)), 'NO', 'YES') as cancellable | |||||
| from wx_coupon_order co | |||||
| left join wx_coupon_merchant cm on cm.product_id = co.coupon_id | |||||
| left join wx_coupon c on c.id = co.coupon_id | |||||
| where co.tenant_id = #{tenantId} and co.c_user_id = #{cUserId} | |||||
| and co.coupon_order_status = 0 | |||||
| and cm.merchant_id = #{merchantId} | |||||
| and co.expired_time > now() | |||||
| <if test="posPayVerify != null"> | |||||
| and c.type in (1, 2, 6) | |||||
| </if> | |||||
| <if test="posIndepVerify != null"> | |||||
| and c.type in (4, 6, 8, 9) | |||||
| </if> | |||||
| union | |||||
| select co.id, c.title, c.type, co.create_date, co.expired_time, c.price, | |||||
| if((co.coupon_price > 0 or (c.subsidy_type>0 and c.subsidy_num >0)), 'NO', 'YES') as cancellable | |||||
| from wx_coupon_order co | |||||
| left join wx_coupon_merchant cm on cm.product_id = co.coupon_id | |||||
| left join wx_coupon c on c.id = co.coupon_id | |||||
| left join pos_coupon_order_verify pco on pco.coupon_order_id = co.id | |||||
| where co.tenant_id = #{tenantId} and co.c_user_id = #{cUserId} | |||||
| and co.coupon_order_status = 100 | |||||
| and cm.merchant_id = #{merchantId} | |||||
| and co.expired_time > now() | |||||
| and pco.pos_order_id = #{posOrderId} | |||||
| <if test="posPayVerify != null"> | |||||
| and c.type in (1, 2, 6) | |||||
| </if> | |||||
| <if test="posIndepVerify != null"> | |||||
| and c.type in (4, 6, 8, 9) | |||||
| </if> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||