Commit ac4ec827e7ec1279ba4e982324dcf697bbd875cf

Authored by litao
1 parent 1e4d7d2d6c

优惠券时间对比规则更改

Showing 5 changed files with 45 additions and 37 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/model/CouponInfo.java View file @ ac4ec82
... ... @@ -56,6 +56,11 @@
56 56 private Integer status;
57 57  
58 58 /**
  59 + * 使用时的id,比如建档id、儿保id,通过type判断是什么id
  60 + */
  61 + private String usedId;
  62 +
  63 + /**
59 64 * 使用优惠券时操作人的id
60 65 */
61 66 private String operatorUseId;
... ... @@ -142,6 +147,14 @@
142 147  
143 148 public void setOperatorUseId(String operatorUseId) {
144 149 this.operatorUseId = operatorUseId;
  150 + }
  151 +
  152 + public String getUsedId() {
  153 + return usedId;
  154 + }
  155 +
  156 + public void setUsedId(String usedId) {
  157 + this.usedId = usedId;
145 158 }
146 159 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java View file @ ac4ec82
... ... @@ -116,7 +116,7 @@
116 116 if(CollectionUtils.isEmpty(temps)) {
117 117 return RespBuilder.buildErro(ResponseCode.COUPON_TEMP_NOT_FOUND);
118 118 }
119   - sendCoupon(temps, hospitalId, createUserId, userId);
  119 + sendCoupon(temps, hospitalId, createUserId, userId, person.getType());
120 120 return RespBuilder.buildSuccess();
121 121 }
122 122  
... ... @@ -128,7 +128,7 @@
128 128 return CollectionUtils.isNotEmpty(list);
129 129 }
130 130  
131   - private void sendCoupon(List<Map<String, Object>> temps, String hospitalId, Integer createUserId, String userId) {
  131 + private void sendCoupon(List<Map<String, Object>> temps, String hospitalId, Integer createUserId, String userId, Integer personType) {
132 132 for (Map<String, Object> temp : temps) {
133 133 Object sendType = temp.get("send_type");
134 134 if(sendType != null) {/** 1=全部发放 2=按有效时间发放 */
135 135  
... ... @@ -146,18 +146,22 @@
146 146 Object type = temp.get("type");
147 147 if(type != null && typeMap.get(PUT_ON_RECORD).contains(Integer.parseInt(type.toString()))) {
148 148 couponInfo.setStatus(2);
149   - Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), Patients.class);
150   - if(patients == null) { /** 不是孕妇就是儿童 */
  149 +
  150 + /** 1=孕妇 2=儿童 3=产妇 */
  151 + if(1 == personType || 3 == personType) {
  152 + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), Patients.class);
  153 + if(patients != null){
  154 + couponInfo.setUseDate(patients.getBookbuildingDate());
  155 + couponInfo.setOperatorUseId(patients.getBookbuildingDoctor());
  156 + couponInfo.setUsedHospitalId(patients.getHospitalId());
  157 + }
  158 + } else {
151 159 BabyModel baby = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), BabyModel.class);
152 160 if(baby != null) {
153 161 couponInfo.setUseDate(baby.getBuildDate());
154 162 couponInfo.setOperatorUseId(baby.getBuildDoctor());
155 163 couponInfo.setUsedHospitalId(baby.getHospitalId());
156 164 }
157   - } else if(patients != null){
158   - couponInfo.setUseDate(patients.getBookbuildingDate());
159   - couponInfo.setOperatorUseId(patients.getBookbuildingDoctor());
160   - couponInfo.setUsedHospitalId(patients.getHospitalId());
161 165 }
162 166 }
163 167  
... ... @@ -169,7 +173,7 @@
169 173 Object unitType = temp.get("unit_type");
170 174 if(actualStart != null && actualEnd != null && unitType != null && type != null) {
171 175 if(validateDate(userId, Integer.parseInt(actualStart.toString()), Integer.parseInt(actualEnd.toString()),
172   - Integer.parseInt(unitType.toString()), hospitalId, Integer.parseInt(type.toString()), 1)) {
  176 + Integer.parseInt(unitType.toString()), hospitalId, Integer.parseInt(type.toString()), 1, personType)) {
173 177 couponMapper.save(couponInfo);
174 178 }
175 179 }
176 180  
... ... @@ -245,9 +249,11 @@
245 249 return RespBuilder.buildErro(ResponseCode.COUPON_NOT_AVAILABLE, patientsInfo);
246 250 }
247 251  
  252 + PersonModel person = mongoTemplate.findById(couponInfo.getId(), PersonModel.class);
  253 +
248 254 /** 验证时间 */
249 255 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()),
250   - data.get("create_hospital_id").toString(), Integer.parseInt(data.get("type").toString()), 2))
  256 + data.get("create_hospital_id").toString(), Integer.parseInt(data.get("type").toString()), 2, person.getType()))
251 257 return RespBuilder.buildErro(ResponseCode.COUPON_TIME_OUT, patientsInfo);
252 258  
253 259 /** 验证区域 */
254 260  
255 261  
256 262  
257 263  
258 264  
... ... @@ -356,39 +362,30 @@
356 362 * @param hospitalId 医院id
357 363 * @param couponType 产检券类型 1=孕妇 2=产妇 3=儿童
358 364 * @param validateType 验证类型 1=创建 2=使用
  365 + * @param personType 1=孕妇 2=儿童 3=产妇
359 366 * @return
360 367 */
361   - private boolean validateDate(String userId, Integer start, Integer end, Integer unitType, String hospitalId, Integer couponType, Integer validateType) {
  368 + private boolean validateDate(String userId, Integer start, Integer end, Integer unitType, String hospitalId, Integer couponType, Integer validateType, Integer personType) {
362 369 Date midDate = null;
363 370 Date startDate = null;
364 371 Date endDate = null;
365   - List<Patients> patients = null;
366   - if(typeMap.get(PREGNANT_WOMAN).contains(couponType)) {/** 孕妇: 根据末次月经对比 midDate = 末次月经时间 */
367   - patients = mongoTemplate.find(Query.query(Criteria.where("pid").is(userId)), Patients.class);
368   - if(CollectionUtils.isEmpty(patients)) {
369   - BabyModel baby = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), BabyModel.class);
370   - if(baby != null) {/** 孕妇没查到就查儿童 */
371   - midDate = baby.getBirth();
372   - } else {
373   - logger.info("未找到pid: " + userId + ", hospitalId: " + hospitalId + ", type: 1 的信息");
374   - return false;
375   - }
376   - }
377   - midDate = patients.get(0).getFmDate();
378   - } else {/** 产妇或者儿童:根据分娩时间对比 midDate = 分娩时间 */
379   - patients = mongoTemplate.find(Query.query(Criteria.where("type").is(3).and("hospitalId").is(hospitalId).and("pid").is(userId))
380   - .with(new Sort(Sort.Direction.DESC, "fmDate")), Patients.class);
381 372  
382   - if(CollectionUtils.isEmpty(patients)) {
383   - logger.info("未找到pid: " + userId + ", hospitalId: " + hospitalId + ", type: 3 的孕妇信息");
  373 + if(personType == 2) { /** 儿童根据生日对比 */
  374 + BabyModel baby = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), BabyModel.class);
  375 + midDate = baby.getBirth();
  376 + } else {
  377 + Patients patient = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), Patients.class);
  378 + if(personType == 1) { /** 孕妇根据末次月经对比 */
  379 + midDate = patient.getLastMenses();
  380 + } else if(personType == 3) { /** 产妇根据分娩时间对比 */
  381 + midDate = patient.getFmDate();
  382 + } else {
384 383 return false;
385 384 }
386   - midDate = patients.get(0).getFmDate();
387 385 }
388 386  
389 387 if(midDate != null) {
390 388 if(unitType == 1) { /** 孕周: startDate = lastMenses + start*7、 endDate = lastMenses + end*7 + 6*/
391   - midDate = patients.get(0).getLastMenses();
392 389 startDate = DateUtils.addDays(midDate, start * 7);
393 390 endDate = DateUtils.addDays(midDate, end * 7 + 6);
394 391 } else if(unitType == 2) { /** 天数 stratDate = 孕妇:fmDate/儿童:birth + start、 endDate = lastMenses + end */
... ... @@ -403,7 +400,7 @@
403 400 return true;
404 401 }
405 402 } else if(validateType == 1) {
406   - return DateUtil.isLtOrEq(new Date(), startDate);
  403 + return DateUtil.isLtOrEq(new Date(), endDate);
407 404 }
408 405 }
409 406 return false;
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml View file @ ac4ec82
... ... @@ -14,9 +14,8 @@
14 14 <result column="used_hospital_id" property="usedHospitalId"/>
15 15 <result column="status" property="status"/>
16 16 <result column="operator_use_id" property="operatorUseId"/>
  17 + <result column="used_id" property="usedId"/>
17 18 </resultMap>
18   -
19   -
20 19  
21 20 <sql id="columnList">
22 21 sequence_id,create_date,use_date, operator_use_id, user_id,create_user_id,coupon_template_id,create_hospital_id,used_hospital_id,status
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CouponController.java View file @ ac4ec82
... ... @@ -46,7 +46,6 @@
46 46 public BaseObjectResponse create(String userId, String hospitalId, HttpServletRequest request) {
47 47 LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
48 48 return couponService.create(userId, hospitalId, loginState.getId());
49   -// return couponService.create(userId, hospitalId, 200);
50 49 }
51 50  
52 51 /**
... ... @@ -76,7 +75,7 @@
76 75 * @param request
77 76 * @return
78 77 */
79   - @RequestMapping(method = RequestMethod.PUT, value = "/use/{code}/{hospitalId}")
  78 + @RequestMapping(method = RequestMethod.PUT, value = "/test")
80 79 @TokenRequired
81 80 @ResponseBody
82 81 public BaseObjectResponse testUse(@PathVariable String code, @PathVariable String hospitalId, HttpServletRequest request) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ ac4ec82
... ... @@ -308,7 +308,7 @@
308 308 ticket.setCreated(new Date());
309 309 ticket.setId(areaCode.getAreaCode() + ticketPid + i);
310 310 ticket.setPid(p.getPid());
311   - patientCheckTicketService.addTicket(ticket);
  311 +// patientCheckTicketService.addTicket(ticket);
312 312 }
313 313 }
314 314 }