| @@ -157,28 +157,6 @@ public class PosController extends BaseController { | |||
| return buildReturnMap(retObj, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||
| } | |||
| /* | |||
| private void doActionAfterVerify(Map<String, String> params, Map<String, String> retMap) { | |||
| String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID | |||
| String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID | |||
| String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券ID | |||
| Long buUserId, couponOrderId; | |||
| try { | |||
| buUserId = Long.valueOf(buUserIdStr); | |||
| couponOrderId = Long.valueOf(couponOrderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| String errCode = retMap.get(WxPayConstant.RESULT_CODE); | |||
| if(StringUtils.isBlank(errCode)||errCode.equals(WxPayConstant.RESULT_SUCCESS)) { | |||
| // 无异常信息,核销成功 | |||
| couponOrderService.sendInsideCouponVerifyMsg(tenantId, couponOrderId, buUserId); | |||
| } | |||
| } | |||
| */ | |||
| @ApiOperation(value = "券核销取消", notes = "{" + | |||
| "\"dev_id\":\"string(必填)\"," + | |||
| "\"nonce_str\":\"string(必填)\"," + | |||
| @@ -289,6 +267,7 @@ public class PosController extends BaseController { | |||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",500, e.getMessage()); | |||
| } | |||
| } | |||
| */ | |||
| @ApiOperation(value = "POS订单同步", notes = "支付成功/支付取消后订单同步") | |||
| @PostMapping("/posOrderSync") | |||
| @@ -296,6 +275,7 @@ public class PosController extends BaseController { | |||
| public Map<String, String> posOrderSync(@RequestBody Map<String, String> params) { | |||
| logger.info(params.toString()); | |||
| JSONObject payContent = new JSONObject(); | |||
| JSONObject retObj = new JSONObject(); | |||
| // 1. check sign | |||
| Map<String, String> retMap = checkSign(params, payContent); | |||
| @@ -307,15 +287,16 @@ public class PosController extends BaseController { | |||
| logger.info(WxPayConstant.RES_KEY + ": " + resKey); | |||
| try { | |||
| retMap = posService.posOrderSync(params); | |||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||
| retObj = posService.posOrderSync(params); | |||
| } catch (MallinkException e) { | |||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||
| return buildReturnMap(retObj, resKey, WxPayConstant.RET_SUCCESS, "", e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| return buildReturnMap(retMap, resKey, WxPayConstant.RET_SUCCESS, "", 500, e.getMessage()); | |||
| return buildReturnMap(retObj, resKey, WxPayConstant.RET_SUCCESS, "", 500, e.getMessage()); | |||
| } | |||
| } | |||
| return buildReturnMap(retObj, resKey, WxPayConstant.RET_SUCCESS, "",null); | |||
| } | |||
| /* | |||
| private Map<String, String> couponOrderPayVerify(@RequestBody Map<String, String> params) { | |||
| JSONObject payContent = new JSONObject(); | |||
| @@ -60,7 +60,7 @@ public interface PosService { | |||
| * @return | |||
| * @throws MallinkException | |||
| */ | |||
| //Map<String, String> posOrderSync(Map<String, String> params) throws MallinkException; | |||
| JSONObject posOrderSync(Map<String, String> params) throws MallinkException; | |||
| /** | |||
| * 消费卡POS支付 | |||
| @@ -2078,16 +2078,17 @@ public class PosServiceImpl implements PosService { | |||
| return retMap; | |||
| } | |||
| //@Override | |||
| @Override | |||
| @Transactional(rollbackFor = Exception.class) | |||
| public Map<String, String> posOrderSync(Map<String, String> params) throws MallinkException { | |||
| Map<String, String> retMap = new HashMap<>(); | |||
| public JSONObject posOrderSync(Map<String, String> params) throws MallinkException { | |||
| JSONObject retMap = new JSONObject(); | |||
| String tenantId = params.get(WxPayConstant.NEU_TENANT_ID); // 租户ID | |||
| String merchantIdStr = params.get(WxPayConstant.NEU_MERCHANT_ID); // 商户ID | |||
| String buUserIdStr = params.get(WxPayConstant.NEU_BU_USER_ID); // POS操作员ID | |||
| String cuUserIdStr = params.get(WxPayConstant.NEU_MEM_ID); // 富茂系统会员ID | |||
| String sceneTypeStr = params.get(WxPayConstant.NEU_ORDER_SCENE_TYPE); // 场景类型 | |||
| String cuPhoneStr = params.get(WxPayConstant.NEU_MEM_PHONE); // 富茂系统会员手机号 | |||
| String sceneTypeStr = params.get(WxPayConstant.NEU_ORDER_SCENE_TYPE); // 场景类型 | |||
| String posOrderIdStr = params.get(WxPayConstant.NEU_ORDER_ID); // POS订单ID | |||
| String posOrderTimeStr = params.get(WxPayConstant.NEU_ORDER_TIME); // POS订单时间 | |||
| String posAmountStr = params.get(WxPayConstant.NEU_ORDER_AMOUNT); // POS订单总额 | |||
| @@ -2129,13 +2130,13 @@ public class PosServiceImpl implements PosService { | |||
| Long merchantId, buUserId, posOrderId, memId; | |||
| Long posAmount = 0L; | |||
| Integer sceneType; | |||
| Integer iSceneType; | |||
| Date orderTime = null; | |||
| try { | |||
| merchantId = Long.valueOf(merchantIdStr); | |||
| buUserId = Long.valueOf(buUserIdStr); | |||
| memId = Long.valueOf(cuUserIdStr); | |||
| sceneType = Integer.valueOf(sceneTypeStr); | |||
| iSceneType = Integer.valueOf(sceneTypeStr); | |||
| posOrderId = Long.valueOf(posOrderIdStr); | |||
| posAmount = Long.valueOf(posAmountStr); | |||
| } catch (NumberFormatException e) { | |||
| @@ -2184,8 +2185,10 @@ public class PosServiceImpl implements PosService { | |||
| WxPayOrder payOrder = payOrderFromMemDiscount(merchantBUser, order, memId, neuPayOrderId, neuPaymentAmount, neuPosPayOrderTime); | |||
| } else if (neuPayOrderType.equals(String.valueOf(EnumNeuPosPamentType.MEM_COUPON.getCode()))) { | |||
| // 优惠券 | |||
| WxPayOrder payOrder = payOrderFromCouponVerify(merchantBUser, order, memId, sceneType, | |||
| WxPayOrder payOrder = payOrderFromCouponVerify(merchantBUser, order, memId, iSceneType, | |||
| neuPayOrderId, neuPaymentAmount, neuPosPayOrderTime, neuPayThirdNo); | |||
| Long couponOrderId = Long.valueOf(neuPayThirdNo); | |||
| couponOrderService.sendInsideCouponVerifyMsg(tenantId, couponOrderId, merchantBUser.getId()); | |||
| } else if (neuPayOrderType.equals(String.valueOf(EnumNeuPosPamentType.MEM_CARD.getCode()))) { | |||
| // 预付卡, 不能退 | |||
| WxPayOrder payOrder = payOrderFromCard(merchantBUser, order, memId, neuPayOrderId, neuPaymentAmount, neuPosPayOrderTime, neuPayThirdNo); | |||
| @@ -283,9 +283,9 @@ public class PosAppTest { | |||
| public void verifySyncTest() throws Exception { | |||
| String memId = "321178010928119808"; | |||
| String memPhone = "13910154397"; | |||
| String sceneType = "2"; // 核销 | |||
| String sceneType = "0"; // 核销 | |||
| String posOrderId = "1"; | |||
| String posAmount = "20000"; | |||
| String posAmount = "1000"; | |||
| String posPayOrderId = "1"; | |||
| String posPaymentType = "4"; | |||
| String posPaymentTypeDes = "优惠券"; | |||
| @@ -377,40 +377,6 @@ public class PosAppTest { | |||
| doCardPayPreCancel(cardId, cardSpendId, posOrderId); | |||
| } | |||
| private void doCheckCouponOrder(String couponOrderId, String sceneType, String posOrderId, String posAmount) throws Exception { | |||
| 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.COUPON_ORDER_ID, couponOrderId); | |||
| reqObj.put(WxPayConstant.SCENE_TYPE, sceneType); | |||
| reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | |||
| reqObj.put(WxPayConstant.ORDER_AMOUNT, posAmount); | |||
| boolean resSigned = sendAndRes("/checkCouponOrder", reqObj); | |||
| Assert.assertEquals(resSigned, true); | |||
| } | |||
| private void doCouponOrderVerify(String couponOrderId, String posOrderId) throws Exception { | |||
| 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.COUPON_ORDER_ID, couponOrderId); | |||
| reqObj.put(WxPayConstant.POS_ORDER_ID, posOrderId); | |||
| boolean resSigned = sendAndRes("/couponOrderVerify", reqObj); | |||
| Assert.assertEquals(resSigned, true); | |||
| } | |||
| private void doCouponOrderVerifyCancel(String couponOrderId, String posOrderId) throws Exception { | |||
| } | |||
| private void doPreVerify(String couponOrderId, String posOrderId, String posAmount) throws Exception { | |||
| Map<String, String> reqObj = new HashMap<>(); | |||
| reqObj.put(WxPayConstant.NONCE_STR, "1"); | |||
| @@ -133,7 +133,7 @@ public class WxPayConstant { | |||
| public final static String NEU_ORDER_TIME = "OrderTimeOfPlatform"; // 平台订单创建时间, 格式:4位年2位月2位日2位24小时制时2位分2位秒3位毫秒 | |||
| public final static String NEU_ORDER_AMOUNT = "OrderAmount"; // 订单价格 | |||
| public final static String NEU_ORDER_CREATE_SN = "OrderCreateSN"; // 创建订单的POS SN号 | |||
| public final static String NEU_ORDER_SCENE_TYPE = "SceneType"; // 订单场景 1:订单支付 2:核销 | |||
| public final static String NEU_ORDER_SCENE_TYPE = "BusinessType"; // 订单场景 // 0:核销 1:支付 | |||
| public final static String NEU_ORDER_STATUS = "OrderStatus"; // 必要,订单状态: 0有效,1取消,根据订单状态处理优惠券;有效:优惠券从预核销处理为核销; | |||
| public final static String NEU_PAY_DETAIL = "PaymentDetail"; | |||
| public final static String NEU_PAY_DETAIL_LIST = "PaymentDetailList"; | |||