Commit 4682eaf2b4d7d47a01ccfe6d1bc942182fa260a6

Authored by liquanyu
1 parent 7be6dec4ea

update

Showing 3 changed files with 76 additions and 3 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java View file @ 4682eaf
... ... @@ -18,6 +18,7 @@
18 18 BaseObjectResponse distErrorData();
19 19  
20 20 BaseObjectResponse validate(String code, Integer type, String hospitalId);
  21 + BaseObjectResponse validate1(String code, Integer type, String hospitalId);
21 22  
22 23 BaseObjectResponse findList(String userId, String hospitalId, String url,Integer type);
23 24  
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java View file @ 4682eaf
... ... @@ -436,9 +436,9 @@
436 436 if (couponInfo.getStatus() == -1) {
437 437 return RespBuilder.buildErro(ResponseCode.COUPON_IS_DISABLED, patientsInfo);
438 438 }
439   -// if (couponInfo.getStatus() == 2) {
440   -// return RespBuilder.buildErro(ResponseCode.COUPON_IS_USERD, patientsInfo);
441   -// }
  439 + if (couponInfo.getStatus() == 2) {
  440 + return RespBuilder.buildErro(ResponseCode.COUPON_IS_USERD, patientsInfo);
  441 + }
442 442  
443 443 Map<String, Object> data = couponMapper.findValidateParam(param);
444 444 if (MapUtils.isEmpty(data)) {
... ... @@ -469,6 +469,64 @@
469 469 return RespBuilder.buildSuccess(patientsInfo);
470 470 }
471 471  
  472 +
  473 +
  474 + @Override
  475 + public BaseObjectResponse validate1(String code, Integer type, String hospitalId) {
  476 + Map<String, Object> param = new HashMap<>();
  477 + param.put("code", code);
  478 + param.put("type", type);
  479 + List<CouponInfo> couponInfos = couponMapper.findList(param);
  480 + if (CollectionUtils.isEmpty(couponInfos))
  481 + return RespBuilder.buildErro(ResponseCode.COUPON_NOT_FOUND);
  482 + if (couponInfos.size() > 1)
  483 + return RespBuilder.buildErro(ResponseCode.COUPON_NOT_UNIQUE);
  484 +
  485 + CouponInfo couponInfo = couponInfos.get(0);
  486 + Map<String, Object> patientsInfo = getPatientsInfo(couponInfo.getUserId());
  487 +
  488 + if (couponInfo.getStatus() == 3) {
  489 + return RespBuilder.buildErro(ResponseCode.COUPON_IS_INVALID, patientsInfo);
  490 + }
  491 + if (couponInfo.getStatus() == -1) {
  492 + return RespBuilder.buildErro(ResponseCode.COUPON_IS_DISABLED, patientsInfo);
  493 + }
  494 + if (couponInfo.getStatus() == 2) {
  495 + patientsInfo.put("status",2);
  496 + }
  497 + else
  498 + {
  499 + patientsInfo.put("status",1);
  500 + }
  501 +
  502 + Map<String, Object> data = couponMapper.findValidateParam(param);
  503 + if (MapUtils.isEmpty(data)) {
  504 + return RespBuilder.buildErro(ResponseCode.COUPON_NOT_AVAILABLE, patientsInfo);
  505 + }
  506 +
  507 + PersonModel person = mongoTemplate.findById(couponInfo.getUserId(), PersonModel.class);
  508 +
  509 + /** 验证时间 */
  510 + if (!validateDate(couponInfo.getUserId(), Integer.parseInt(data.get("actual_start").toString()), Integer.parseInt(data.get("actual_end").toString()), Integer.parseInt(data.get("unit_type").toString()),
  511 + data.get("create_hospital_id").toString(), Integer.parseInt(data.get("type").toString()), 2, person.getType()))
  512 + return RespBuilder.buildErro(ResponseCode.COUPON_TIME_OUT, patientsInfo);
  513 +
  514 + /** 验证区域 */
  515 + if (!validateArea(data.get("area_type").toString(), couponInfo.getCreateHospitalId(), hospitalId)) {
  516 + return RespBuilder.buildErro(ResponseCode.COUPON_AREA_NO_USE, patientsInfo);
  517 + }
  518 +
  519 +// //验证优惠劵是否临时使用了 该功能属于秦皇岛区域
  520 +// if (couponInfo.getTempStatus() != null && couponInfo.getTempStatus() == 1) {
  521 +// //验证临时使用的医院是不是当前登陆的医院
  522 +// if (StringUtils.isNotEmpty(couponInfo.getTempHospitalId()) && !couponInfo.getTempHospitalId().equals(hospitalId)) {
  523 +// return RespBuilder.buildErro(ResponseCode.COUPON_IS_USED);
  524 +// }
  525 +// }
  526 +
  527 +
  528 + return RespBuilder.buildSuccess(patientsInfo);
  529 + }
472 530  
473 531 @Override
474 532 public BaseObjectResponse validateUse(String code, Integer type, String hospitalId) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java View file @ 4682eaf
... ... @@ -115,6 +115,20 @@
115 115  
116 116  
117 117  
  118 + @RequestMapping(method = RequestMethod.GET, value = "/validate1/{code}/{type}")
  119 + @ResponseBody
  120 + @TokenRequired
  121 + public BaseObjectResponse validate1(@PathVariable String code, @PathVariable Integer type, String userId, HttpServletRequest request) {
  122 + if(StringUtils.isNotEmpty(userId)) {
  123 + if(!couponService.validateUser(userId, code)) { /** 优惠券不属于本人 */
  124 + return RespBuilder.buildErro(ResponseCode.COUPON_IS_NOT_SELF);
  125 + }
  126 + }
  127 + return couponService.validate1(code, type, autoMatchFacade.getHospitalId(getUserId(request)));
  128 + }
  129 +
  130 +
  131 +
118 132 /**
119 133 * 获取当前登陆医生所属医院的所有人员
120 134 * @param request