Commit 4890eb3422ec810dcc0ea86f1cf054ba56a7a335
1 parent
d6747abe0a
Exists in
master
and in
6 other branches
优惠券时间对比规则更改
Showing 1 changed file with 4 additions and 3 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
View file @
4890eb3
| ... | ... | @@ -350,8 +350,9 @@ |
| 350 | 350 | Date midDate = null; |
| 351 | 351 | Date startDate = null; |
| 352 | 352 | Date endDate = null; |
| 353 | + List<Patients> patients = null; | |
| 353 | 354 | if(typeMap.get(PREGNANT_WOMAN).contains(couponType)) {/** 孕妇: 根据末次月经对比 midDate = 末次月经时间 */ |
| 354 | - List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("pid").is(userId)), Patients.class); | |
| 355 | + patients = mongoTemplate.find(Query.query(Criteria.where("pid").is(userId)), Patients.class); | |
| 355 | 356 | if(CollectionUtils.isEmpty(patients)) { |
| 356 | 357 | BabyModel baby = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(userId)), BabyModel.class); |
| 357 | 358 | if(baby != null) {/** 孕妇没查到就查儿童 */ |
| ... | ... | @@ -363,7 +364,7 @@ |
| 363 | 364 | } |
| 364 | 365 | midDate = patients.get(0).getFmDate(); |
| 365 | 366 | } else {/** 产妇或者儿童:根据分娩时间对比 midDate = 分娩时间 */ |
| 366 | - List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("type").is(3).and("hospitalId").is(hospitalId).and("pid").is(userId)) | |
| 367 | + patients = mongoTemplate.find(Query.query(Criteria.where("type").is(3).and("hospitalId").is(hospitalId).and("pid").is(userId)) | |
| 367 | 368 | .with(new Sort(Sort.Direction.DESC, "fmDate")), Patients.class); |
| 368 | 369 | |
| 369 | 370 | if(CollectionUtils.isEmpty(patients)) { |
| ... | ... | @@ -375,6 +376,7 @@ |
| 375 | 376 | |
| 376 | 377 | if(midDate != null) { |
| 377 | 378 | if(unitType == 1) { /** 孕周: startDate = lastMenses + start*7、 endDate = lastMenses + end*7 + 6*/ |
| 379 | + midDate = patients.get(0).getLastMenses(); | |
| 378 | 380 | startDate = DateUtils.addDays(midDate, start * 7); |
| 379 | 381 | endDate = DateUtils.addDays(midDate, end * 7 + 6); |
| 380 | 382 | } else if(unitType == 2) { /** 天数 stratDate = 孕妇:fmDate/儿童:birth + start、 endDate = lastMenses + end */ |
| ... | ... | @@ -384,7 +386,6 @@ |
| 384 | 386 | startDate = DateUtils.addMonths(midDate, start); |
| 385 | 387 | endDate = DateUtils.addMonths(midDate, end + 1); |
| 386 | 388 | } |
| 387 | -// if(DateUtil.isBetween(midDate, startDate, endDate)) { | |
| 388 | 389 | if(DateUtil.isBetween(new Date(), startDate, endDate)) { |
| 389 | 390 | return true; |
| 390 | 391 | } |