| @@ -65,6 +65,26 @@ public class WxCouponPasswordController extends BaseController { | |||||
| return getCouponOrderByPassword(password, formId,payCheck,payPassword, memberId,EnumPayWay.PAY_WAY_NOT_UNPAY_PASSWD,EnumPayVersion.NO_VERSION); | return getCouponOrderByPassword(password, formId,payCheck,payPassword, memberId,EnumPayWay.PAY_WAY_NOT_UNPAY_PASSWD,EnumPayVersion.NO_VERSION); | ||||
| } | } | ||||
| private WxCouponPassword getWxCouponPasswordQuery(String password) { | |||||
| WxCouponPassword couponPasswordQ = new WxCouponPassword(); | |||||
| couponPasswordQ.updateTenantInfo(getTenantInfo()); | |||||
| boolean isCardId = false; | |||||
| if (password.length() > 10) { | |||||
| isCardId = true; | |||||
| } | |||||
| if (isCardId) { | |||||
| try { | |||||
| Long cardId = Long.parseLong(password); | |||||
| couponPasswordQ.setId(cardId); | |||||
| }catch (Exception e) { | |||||
| return null; | |||||
| } | |||||
| }else { | |||||
| couponPasswordQ.setPassword(password); | |||||
| } | |||||
| return couponPasswordQ; | |||||
| } | |||||
| private ResultData getCouponOrderByPassword(String password,String formId,String payCheck,String payPassword,Long memberId,EnumPayWay payWay,EnumPayVersion payVersion) { | private ResultData getCouponOrderByPassword(String password,String formId,String payCheck,String payPassword,Long memberId,EnumPayWay payWay,EnumPayVersion payVersion) { | ||||
| password = StringUtils.trimToNull(password); | password = StringUtils.trimToNull(password); | ||||
| payPassword = StringUtils.trimToNull(payPassword); | payPassword = StringUtils.trimToNull(payPassword); | ||||
| @@ -89,23 +109,10 @@ public class WxCouponPasswordController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| boolean isCardId = false; | |||||
| if (password.length() > 10) { | |||||
| isCardId = true; | |||||
| } | |||||
| // 1. 根据password获取领取的couponId | // 1. 根据password获取领取的couponId | ||||
| WxCouponPassword couponPasswordQ = new WxCouponPassword(); | |||||
| couponPasswordQ.updateTenantInfo(getTenantInfo()); | |||||
| if (isCardId) { | |||||
| try { | |||||
| Long cardId = Long.parseLong(password); | |||||
| couponPasswordQ.setId(cardId); | |||||
| }catch (Exception e) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "password参数非法"); | |||||
| } | |||||
| }else { | |||||
| couponPasswordQ.setPassword(password); | |||||
| WxCouponPassword couponPasswordQ = getWxCouponPasswordQuery(password); | |||||
| if (null == couponPasswordQ) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "卡号或者卡密错误"); | |||||
| } | } | ||||
| couponPasswordQ.setExpireDate(new Date()); | couponPasswordQ.setExpireDate(new Date()); | ||||
| WxCouponPassword couponPassword = couponPasswordService.getByObj(couponPasswordQ); | WxCouponPassword couponPassword = couponPasswordService.getByObj(couponPasswordQ); | ||||
| @@ -209,18 +216,22 @@ public class WxCouponPasswordController extends BaseController { | |||||
| @ApiImplicitParam(name = "cardId", value = "券ID", dataType = "String", paramType = "query", required = true) | @ApiImplicitParam(name = "cardId", value = "券ID", dataType = "String", paramType = "query", required = true) | ||||
| }) | }) | ||||
| public ResultData getCardDetail(String cardId) { | public ResultData getCardDetail(String cardId) { | ||||
| cardId = StringUtils.trimToNull(cardId); | |||||
| if (StringUtils.isBlank(cardId) || cardId.equalsIgnoreCase(Constant.UNDEFINED)) { | if (StringUtils.isBlank(cardId) || cardId.equalsIgnoreCase(Constant.UNDEFINED)) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"参数错误."); | |||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"卡号或者卡密错误."); | |||||
| } | } | ||||
| cardId = StringUtils.trimToNull(cardId); | |||||
| WxCouponPassword couponPasswordQ = getWxCouponPasswordQuery(cardId); | |||||
| if (null == couponPasswordQ) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "卡号或者卡密错误"); | |||||
| } | |||||
| WxCouponPassword password = null; | WxCouponPassword password = null; | ||||
| try { | try { | ||||
| password = couponPasswordService.getById(Long.parseLong(cardId)); | |||||
| password = couponPasswordService.getByObj(couponPasswordQ); | |||||
| if (null == password) { | if (null == password) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"参数错误."); | |||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"卡号或者卡密错误."); | |||||
| } | } | ||||
| }catch(Exception e) { | }catch(Exception e) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"参数错误."); | |||||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"卡号或者卡密错误."); | |||||
| } | } | ||||
| WxCoupon coupon = couponService.getById(password.getCouponId(),password.getTenantId()); | WxCoupon coupon = couponService.getById(password.getCouponId(),password.getTenantId()); | ||||
| if (coupon == null) { | if (coupon == null) { | ||||