Commit e38fce6f6ac9184a65ac4db7365de779d5e0e975
1 parent
4b40078f5b
Exists in
master
and in
6 other branches
update code
Showing 3 changed files with 56 additions and 2 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java
View file @
e38fce6
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
View file @
e38fce6
| ... | ... | @@ -357,6 +357,58 @@ |
| 357 | 357 | return RespBuilder.buildSuccess(patientsInfo); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | + | |
| 361 | + | |
| 362 | + @Override | |
| 363 | + public BaseObjectResponse validateUse(String code, Integer type, String hospitalId) { | |
| 364 | + Map<String, Object> param = new HashMap<>(); | |
| 365 | + param.put("code", code); | |
| 366 | + param.put("type", type); | |
| 367 | + List<CouponInfo> couponInfos = couponMapper.findList(param); | |
| 368 | + if(CollectionUtils.isEmpty(couponInfos)) | |
| 369 | + return RespBuilder.buildErro(ResponseCode.COUPON_NOT_FOUND); | |
| 370 | + if(couponInfos.size() > 1) | |
| 371 | + return RespBuilder.buildErro(ResponseCode.COUPON_NOT_UNIQUE); | |
| 372 | + | |
| 373 | + CouponInfo couponInfo = couponInfos.get(0); | |
| 374 | + Map<String, Object> patientsInfo = getPatientsInfo(couponInfo.getUserId()); | |
| 375 | + | |
| 376 | + if(couponInfo.getStatus() == 3) { | |
| 377 | + return RespBuilder.buildErro(ResponseCode.COUPON_IS_INVALID, patientsInfo); | |
| 378 | + } | |
| 379 | + if(couponInfo.getStatus() == -1) { | |
| 380 | + return RespBuilder.buildErro(ResponseCode.COUPON_IS_DISABLED, patientsInfo); | |
| 381 | + } | |
| 382 | + if(couponInfo.getStatus() == 2) { | |
| 383 | + return RespBuilder.buildErro(ResponseCode.COUPON_IS_USERD, patientsInfo); | |
| 384 | + } | |
| 385 | + | |
| 386 | + Map<String, Object> data = couponMapper.findValidateParam(param); | |
| 387 | + if(MapUtils.isEmpty(data)) { | |
| 388 | + return RespBuilder.buildErro(ResponseCode.COUPON_NOT_AVAILABLE, patientsInfo); | |
| 389 | + } | |
| 390 | + | |
| 391 | + | |
| 392 | + /** 验证区域 */ | |
| 393 | + if(!validateArea(data.get("area_type").toString(), couponInfo.getCreateHospitalId(), hospitalId)) { | |
| 394 | + return RespBuilder.buildErro(ResponseCode.COUPON_AREA_NO_USE, patientsInfo); | |
| 395 | + } | |
| 396 | + | |
| 397 | + //验证优惠劵是否临时使用了 该功能属于秦皇岛区域 | |
| 398 | + if (couponInfo.getTempStatus() != null && couponInfo.getTempStatus() == 1) | |
| 399 | + { | |
| 400 | + //验证临时使用的医院是不是当前登陆的医院 | |
| 401 | + if (StringUtils.isNotEmpty(couponInfo.getTempHospitalId()) && !couponInfo.getTempHospitalId().equals(hospitalId)) | |
| 402 | + { | |
| 403 | + return RespBuilder.buildErro(ResponseCode.COUPON_IS_USED); | |
| 404 | + } | |
| 405 | + } | |
| 406 | + | |
| 407 | + | |
| 408 | + return RespBuilder.buildSuccess(patientsInfo); | |
| 409 | + } | |
| 410 | + | |
| 411 | + | |
| 360 | 412 | @Override |
| 361 | 413 | public Map<String, Object> getPatientsInfo(String userId) { |
| 362 | 414 | Map<String, Object> restMap = new HashMap<>(); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponPrintController.java
View file @
e38fce6
| ... | ... | @@ -137,7 +137,7 @@ |
| 137 | 137 | |
| 138 | 138 | Object type = couponInfo.get("type"); |
| 139 | 139 | //验证优惠劵是否可以使用 |
| 140 | - BaseObjectResponse objectResponse = couponService.validate(code, Integer.parseInt(type.toString()), hospitalId); | |
| 140 | + BaseObjectResponse objectResponse = couponService.validateUse(code, Integer.parseInt(type.toString()), hospitalId); | |
| 141 | 141 | if (objectResponse.getErrorcode() != ResponseCode.SUCCESS.getCode()) |
| 142 | 142 | { |
| 143 | 143 | return objectResponse; |
| ... | ... | @@ -207,7 +207,7 @@ |
| 207 | 207 | |
| 208 | 208 | Object type = couponInfo.get("type"); |
| 209 | 209 | //验证优惠劵是否可以使用 |
| 210 | - BaseObjectResponse objectResponse = couponService.validate(code,Integer.parseInt(type.toString()),hospitalId); | |
| 210 | + BaseObjectResponse objectResponse = couponService.validateUse(code,Integer.parseInt(type.toString()),hospitalId); | |
| 211 | 211 | if (objectResponse.getErrorcode() != ResponseCode.SUCCESS.getCode()) |
| 212 | 212 | { |
| 213 | 213 | return objectResponse; |