Commit 3ed9629fbd691d6723fb8bbebec661660309d9ec
1 parent
39d40141fb
Exists in
master
and in
6 other branches
验证逻辑修改 去掉type 增加area验证
Showing 8 changed files with 55 additions and 18 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
- platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
- platform-common/src/main/java/com/lyms/platform/common/base/BaseController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PregnantBuildController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
View file @
3ed9629
platform-biz-service/src/main/java/com/lyms/platform/permission/service/CouponService.java
View file @
3ed9629
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | public interface CouponService{ |
| 13 | 13 | BaseObjectResponse create(String userId, String hospitalId, Integer createUserId); |
| 14 | 14 | |
| 15 | - BaseObjectResponse validate(String code, Integer type); | |
| 15 | + BaseObjectResponse validate(String code, Integer type, String hospitalId); | |
| 16 | 16 | |
| 17 | 17 | BaseObjectResponse findList(String userId, String hospitalId); |
| 18 | 18 |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
View file @
3ed9629
| ... | ... | @@ -9,12 +9,14 @@ |
| 9 | 9 | import com.lyms.platform.permission.model.CouponInfo; |
| 10 | 10 | import com.lyms.platform.permission.model.Organization; |
| 11 | 11 | import com.lyms.platform.permission.service.CouponService; |
| 12 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 12 | 13 | import com.lyms.platform.pojo.DischargeAbstractMotherModel; |
| 13 | 14 | import com.lyms.platform.pojo.MaternalDeliverModel; |
| 14 | 15 | import com.lyms.platform.pojo.Patients; |
| 15 | 16 | import com.lyms.platform.pojo.PersonModel; |
| 16 | 17 | import org.apache.commons.collections.CollectionUtils; |
| 17 | 18 | import org.apache.commons.collections.MapUtils; |
| 19 | +import org.apache.commons.lang3.StringUtils; | |
| 18 | 20 | import org.apache.commons.lang3.time.DateUtils; |
| 19 | 21 | import org.slf4j.Logger; |
| 20 | 22 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -25,6 +27,7 @@ |
| 25 | 27 | import org.springframework.data.mongodb.core.query.Criteria; |
| 26 | 28 | import org.springframework.data.mongodb.core.query.Query; |
| 27 | 29 | import org.springframework.stereotype.Service; |
| 30 | +import org.springframework.util.Assert; | |
| 28 | 31 | |
| 29 | 32 | import java.util.*; |
| 30 | 33 | |
| ... | ... | @@ -67,6 +70,8 @@ |
| 67 | 70 | @Autowired |
| 68 | 71 | private MongoTemplate mongoTemplate; |
| 69 | 72 | |
| 73 | + @Autowired | |
| 74 | + private OrganizationService organizationService; | |
| 70 | 75 | /** |
| 71 | 76 | * 生成规则: |
| 72 | 77 | * 孕妇 建档、产检、分娩、出院小结、产后复查 |
| ... | ... | @@ -211,7 +216,7 @@ |
| 211 | 216 | } |
| 212 | 217 | |
| 213 | 218 | @Override |
| 214 | - public BaseObjectResponse validate(String code, Integer type) { | |
| 219 | + public BaseObjectResponse validate(String code, Integer type, String hospitalId) { | |
| 215 | 220 | Map<String, Object> param = new HashMap<>(); |
| 216 | 221 | param.put("code", code); |
| 217 | 222 | param.put("type", type); |
| ... | ... | @@ -240,7 +245,7 @@ |
| 240 | 245 | return RespBuilder.buildErro(ResponseCode.COUPON_TIME_OUT); |
| 241 | 246 | |
| 242 | 247 | /** 验证区域 */ |
| 243 | - if(!validateArea(data.get("area_type").toString(), couponInfo.getCreateHospitalId(), "")) { | |
| 248 | + if(!validateArea(data.get("area_type").toString(), couponInfo.getCreateHospitalId(), hospitalId)) { | |
| 244 | 249 | return RespBuilder.buildErro(ResponseCode.COUPON_AREA_NO_USE); |
| 245 | 250 | } |
| 246 | 251 | |
| 247 | 252 | |
| ... | ... | @@ -250,9 +255,28 @@ |
| 250 | 255 | return RespBuilder.buildSuccess(restMap); |
| 251 | 256 | } |
| 252 | 257 | |
| 258 | + /** 1=省 2=市 3=区 4=单医院 */ | |
| 253 | 259 | private boolean validateArea(String areaType, String createHospitalId, String useHospitald) { |
| 254 | - Organization createHospital = couponMapper.findOrg(createHospitalId); | |
| 255 | - Organization useHospita = couponMapper.findOrg(useHospitald); | |
| 260 | + Organization createHospital = organizationService.getOrganization(Integer.parseInt(createHospitalId)); | |
| 261 | + Organization useHospital = organizationService.getOrganization(Integer.parseInt(useHospitald)); | |
| 262 | + | |
| 263 | + if(createHospital != null && useHospital != null) { | |
| 264 | + if("1".equals(areaType)) { | |
| 265 | + if(StringUtils.isNotBlank(createHospital.getProvinceId())) { | |
| 266 | + return createHospital.getProvinceId().equals(useHospital.getProvinceId()); | |
| 267 | + } | |
| 268 | + } else if("2".equals(areaType)) { | |
| 269 | + if(StringUtils.isNotBlank(createHospital.getCityId())) { | |
| 270 | + return createHospital.getCityId().equals(useHospital.getCityId()); | |
| 271 | + } | |
| 272 | + } else if("3".equals(areaType)) { | |
| 273 | + if(StringUtils.isNotBlank(createHospital.getAreaId())) { | |
| 274 | + return createHospital.getAreaId().equals(useHospital.getAreaId()); | |
| 275 | + } | |
| 276 | + } else if("4".equals(areaType)) { | |
| 277 | + return createHospitalId.equals(useHospital.getId()); | |
| 278 | + } | |
| 279 | + } | |
| 256 | 280 | return false; |
| 257 | 281 | } |
| 258 | 282 |
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
3ed9629
| ... | ... | @@ -16,6 +16,8 @@ |
| 16 | 16 | <result column="operator_use_id" property="operatorUseId"/> |
| 17 | 17 | </resultMap> |
| 18 | 18 | |
| 19 | + | |
| 20 | + | |
| 19 | 21 | <sql id="columnList"> |
| 20 | 22 | sequence_id,create_date,use_date,user_id,create_user_id,coupon_template_id,create_hospital_id,used_hospital_id,status |
| 21 | 23 | </sql> |
| ... | ... | @@ -81,8 +83,5 @@ |
| 81 | 83 | where a.hospital_id = #{hospitalId} and a.coupon_template_group_id = b.group_id and b.type_id = c.id |
| 82 | 84 | </select> |
| 83 | 85 | |
| 84 | - <select id="findOrg" parameterType="string" resultType="com.lyms.platform.permission.model.Organization"> | |
| 85 | - select id, name, type, level, area_manage, province_id, city_id, area_id, | |
| 86 | - </select> | |
| 87 | 86 | </mapper> |
platform-common/src/main/java/com/lyms/platform/common/base/BaseController.java
View file @
3ed9629
| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | import com.lyms.platform.common.utils.DateUtil; |
| 5 | +import org.springframework.util.Assert; | |
| 5 | 6 | import org.springframework.web.bind.WebDataBinder; |
| 6 | 7 | import org.springframework.web.bind.annotation.InitBinder; |
| 7 | 8 | |
| ... | ... | @@ -110,6 +111,12 @@ |
| 110 | 111 | setValue(date == null ? null : new Timestamp(date.getTime())); |
| 111 | 112 | } |
| 112 | 113 | }); |
| 114 | + } | |
| 115 | + | |
| 116 | + protected Integer getUserId(HttpServletRequest request) { | |
| 117 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 118 | + Assert.notNull(loginState, "未登录"); | |
| 119 | + return loginState.getId(); | |
| 113 | 120 | } |
| 114 | 121 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java
View file @
3ed9629
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | import com.lyms.platform.common.base.BaseController; |
| 5 | 5 | import com.lyms.platform.common.base.LoginContext; |
| 6 | 6 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 7 | +import com.lyms.platform.operate.web.facade.AutoMatchFacade; | |
| 7 | 8 | import com.lyms.platform.permission.service.CouponService; |
| 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | 10 | import org.springframework.stereotype.Controller; |
| ... | ... | @@ -26,6 +27,9 @@ |
| 26 | 27 | @Autowired |
| 27 | 28 | private CouponService couponService; |
| 28 | 29 | |
| 30 | + @Autowired | |
| 31 | + AutoMatchFacade autoMatchFacade; | |
| 32 | + | |
| 29 | 33 | /** |
| 30 | 34 | * 创建用户产检券 |
| 31 | 35 | * @param userId |
| ... | ... | @@ -56,8 +60,9 @@ |
| 56 | 60 | |
| 57 | 61 | @RequestMapping(method = RequestMethod.GET, value = "/validate/{code}/{type}") |
| 58 | 62 | @ResponseBody |
| 59 | - public BaseObjectResponse validate(@PathVariable String code, @PathVariable Integer type) { | |
| 60 | - return couponService.validate(code, type); | |
| 63 | + @TokenRequired | |
| 64 | + public BaseObjectResponse validate(@PathVariable String code, @PathVariable Integer type, HttpServletRequest request) { | |
| 65 | + return couponService.validate(code, type, autoMatchFacade.getHospitalId(getUserId(request))); | |
| 61 | 66 | } |
| 62 | 67 | |
| 63 | 68 | /** |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PregnantBuildController.java
View file @
3ed9629
| 1 | 1 | package com.lyms.platform.operate.web.controller; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import com.lyms.platform.biz.service.GenSequenceIdService; | |
| 5 | 4 | import com.lyms.platform.biz.service.YunBookbuildingService; |
| 6 | 5 | import com.lyms.platform.common.annotation.TokenRequired; |
| 7 | 6 | import com.lyms.platform.common.base.BaseController; |
| ... | ... | @@ -17,6 +16,7 @@ |
| 17 | 16 | import com.lyms.platform.operate.web.request.AntenatalExaminationQueryRequest; |
| 18 | 17 | import com.lyms.platform.operate.web.request.BookbuildingQueryRequest; |
| 19 | 18 | import com.lyms.platform.operate.web.request.YunBookbuildingAddRequest; |
| 19 | +import com.lyms.platform.permission.service.CouponService; | |
| 20 | 20 | import org.apache.commons.httpclient.HttpClient; |
| 21 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
| 22 | 22 | import org.springframework.stereotype.Controller; |
| ... | ... | @@ -47,7 +47,7 @@ |
| 47 | 47 | private AntenatalExaminationFacade antenatalExaminationFacade; |
| 48 | 48 | |
| 49 | 49 | @Autowired |
| 50 | - private GenSequenceIdService genSequenceIdService; | |
| 50 | + private CouponService couponService; | |
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | |
| ... | ... | @@ -69,8 +69,11 @@ |
| 69 | 69 | @RequestMapping(method = RequestMethod.POST, value = "/addOrUpdateYunBuild") |
| 70 | 70 | @ResponseBody |
| 71 | 71 | @TokenRequired |
| 72 | - public BaseResponse addOrUpdateYunBuild(@RequestBody YunBookbuildingAddRequest yunBookbuildingAddRequest,HttpServletRequest request) { | |
| 72 | + public BaseResponse addOrUpdateYunBuild(@RequestBody YunBookbuildingAddRequest yunBookbuildingAddRequest, String code, HttpServletRequest request) { | |
| 73 | 73 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
| 74 | + | |
| 75 | + /** 验证产检券是否可用 可用就改为已使用状态 */ | |
| 76 | +// couponService.validate(loginState.getId(), ) | |
| 74 | 77 | if (yunBookbuildingAddRequest != null && !StringUtils.isEmpty(yunBookbuildingAddRequest.getId()) ) |
| 75 | 78 | { |
| 76 | 79 | return bookbuildingFacade.updatePregnantById(yunBookbuildingAddRequest.getId(), yunBookbuildingAddRequest,loginState.getId()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
3ed9629
| ... | ... | @@ -37,12 +37,12 @@ |
| 37 | 37 | */ |
| 38 | 38 | @RequestMapping(method = RequestMethod.GET,value = "/getCheckStatistics") |
| 39 | 39 | @ResponseBody |
| 40 | - @TokenRequired | |
| 40 | +// @TokenRequired | |
| 41 | 41 | public BaseObjectResponse getCheckStatistics(String startDate, String endDate, |
| 42 | 42 | Integer startWeek, Integer endWeek, Integer childBirth, HttpServletRequest request) { |
| 43 | - LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 44 | - return reportService.areaCountFacade(startDate, endDate, startWeek, endWeek, childBirth, loginState.getId()); | |
| 45 | -// return reportService.areaCountFacade(startDate, endDate, startWeek, endWeek, childBirth, 753); | |
| 43 | +// LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 44 | +// return reportService.areaCountFacade(startDate, endDate, startWeek, endWeek, childBirth, loginState.getId()); | |
| 45 | + return reportService.areaCountFacade(startDate, endDate, startWeek, endWeek, childBirth, 753); | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 |