Commit ab6e26fe7ed1407afad2fa24675b69f68867aec4

Authored by liquanyu
1 parent 477e3891ca

产检券

Showing 2 changed files with 103 additions and 4 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java View file @ ab6e26f
... ... @@ -2,6 +2,7 @@
2 2  
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.lyms.platform.biz.SequenceConstant;
  5 +import com.lyms.platform.biz.dal.IPatientDao;
5 6 import com.lyms.platform.biz.service.GenSequenceIdService;
6 7 import com.lyms.platform.common.result.BaseObjectResponse;
7 8 import com.lyms.platform.common.result.RespBuilder;
... ... @@ -51,6 +52,9 @@
51 52 /** 2 = 儿童 */
52 53 private static final String CHILDREN = "2";
53 54  
  55 + @Autowired
  56 + private IPatientDao iPatientDao;
  57 +
54 58 /** 3_{?} = 产妇 */
55 59 /** 产妇没有分娩记录且没有出院小结 */
56 60 private static final String MATERNAL_NCHILDBIRTH_NHOSPITAL = "3_1";
... ... @@ -62,7 +66,7 @@
62 66 /** 建档 */
63 67 private static final String PUT_ON_RECORD = "4";
64 68  
65   -@Autowired
  69 + @Autowired
66 70 private WeixinQrcodeConfigService weixinQrcodeConfigService;
67 71 @Autowired
68 72 private CouponMapper couponMapper;
69 73  
... ... @@ -119,8 +123,92 @@
119 123 Map<String, Object> param = new HashMap<>();
120 124 param.put("types", types);
121 125 param.put("hospitalId", hospitalId);
  126 +
  127 + Integer start = null;
  128 + if (person.getType() == 1 || person.getType() == 3)
  129 + {
  130 + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("id").is(patientId)), Patients.class);
  131 + if (patients != null && patients.getType() == 3)
  132 + {
  133 + Date fmDate = patients.getFmDate();
  134 + if (fmDate != null)
  135 + {
  136 + start = DateUtil.getDays(fmDate,new Date());
  137 + }
  138 + }
  139 + else if (patients != null && patients.getType() == 1)
  140 + {
  141 + start = DateUtil.getWeek(patients.getLastMenses(),new Date());
  142 + }
  143 + }
  144 + else if (person.getType() == 2)
  145 + {
  146 + BabyModel babyModel = mongoTemplate.findOne(Query.query(Criteria.where("id").is(patientId)), BabyModel.class);
  147 + if (babyModel != null && babyModel.getBirth() != null)
  148 + {
  149 + start = DateUtil.getMonth(babyModel.getBirth(), new Date());
  150 +
  151 + }
  152 + }
  153 +
122 154 List<Map<String,Object>> temps = couponMapper.findTemp(param);
123   - if(CollectionUtils.isEmpty(temps)) {
  155 +
  156 + List<Map<String,Object>> list = new ArrayList<>();
  157 + //滦平县妇幼保健院
  158 + if ("2100001377".equals(hospitalId))
  159 + {
  160 + if (CollectionUtils.isNotEmpty(temps))
  161 + {
  162 + for (Map<String,Object> map : temps)
  163 + {
  164 + Integer type = Integer.parseInt(map.get("type").toString());
  165 + if (person.getType() == 1)
  166 + {
  167 + if (type != 2)
  168 + {
  169 + list.add(map);
  170 + }
  171 + }
  172 + else if (person.getType() == 3)
  173 + {
  174 + if (type != 6)
  175 + {
  176 + list.add(map);
  177 + }
  178 + }
  179 + }
  180 +
  181 + for (Map<String,Object> map : temps)
  182 + {
  183 + if (person.getType() == 1)
  184 + {
  185 + Integer type = Integer.parseInt(map.get("type").toString());
  186 + Integer showStart = Integer.parseInt(map.get("show_start").toString());
  187 + if (type == 2 && showStart >= start)
  188 + {
  189 + list.add(map);
  190 + }
  191 + }
  192 + else if (person.getType() == 3)
  193 + {
  194 + Integer type = Integer.parseInt(map.get("type").toString());
  195 + Integer showStart = Integer.parseInt(map.get("show_start").toString());
  196 + if (type == 6 && showStart >= start)
  197 + {
  198 + list.add(map);
  199 + }
  200 + }
  201 + }
  202 + }
  203 +
  204 + }
  205 + else
  206 + {
  207 + list.addAll(temps);
  208 + }
  209 +
  210 +
  211 + if(CollectionUtils.isEmpty(list)) {
124 212 return RespBuilder.buildErro(ResponseCode.COUPON_TEMP_NOT_FOUND);
125 213 }
126 214  
... ... @@ -129,7 +217,7 @@
129 217 return RespBuilder.buildErro(ResponseCode.OUPON_HOSPITAL_NOT_BOUND_AREA);
130 218 }
131 219  
132   - sendCoupon(temps, hospitalId, createUserId, userId, person.getType(), areaCode);
  220 + sendCoupon(list, hospitalId, createUserId, userId, person.getType(), areaCode);
133 221  
134 222 /** 记录为已经发放过优惠券 */
135 223 mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patientId)), Update.update("isSendCoupon", true), Patients.class);
... ... @@ -685,6 +773,17 @@
685 773 map.put("url", findUrl(map.get("sequence_id").toString(),type));
686 774 if(StringUtils.isNotEmpty(peopleNum)) {
687 775 map.put("peopleNum", peopleNum);
  776 + }
  777 + map.put("days",0);
  778 + //滦平县妇幼保健院2100001377
  779 + //滦平县妇幼保健院首次产检券 孕0-12周 改为 孕0-12周+6天
  780 + if ("2100001377".equals(hospitalId))
  781 + {
  782 + Integer show_end = Integer.parseInt(String.valueOf(map.get("show_end")));
  783 + if (show_end == 12)
  784 + {
  785 + map.put("days",6);
  786 + }
688 787 }
689 788 }
690 789 restMap.put("couponInfos", couponInfos);
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml View file @ ab6e26f
... ... @@ -59,7 +59,7 @@
59 59 </insert>
60 60  
61 61 <select id="findTemp" parameterType="map" resultType="map">
62   - select b.id, b.id as coupon_template_id, b.actual_start, b.actual_end, b.unit_type, c.send_type, c.type from
  62 + select b.id, b.id as coupon_template_id, b.actual_start, b.actual_end, b.unit_type,b.show_start, c.send_type, c.type from
63 63 hospital_coupon_template_group a, coupon_template b, coupon_type c
64 64 where a.hospital_id = #{hospitalId} and a.coupon_template_group_id = b.group_id and b.type_id = c.id and c.type in
65 65 <foreach collection="types" open="(" close=")" separator="," item="type">