Commit 4260239121e6157c2274fe9df4aba9700cbaab93

Authored by yangfei

Merge remote-tracking branch 'origin/master'

Showing 2 changed files

platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java View file @ 4260239
... ... @@ -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,95 @@
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 + Integer type = Integer.parseInt(map.get("type").toString());
  184 +
  185 + if (person.getType() == 1 && type == 2)
  186 + {
  187 + Integer showStart = Integer.parseInt(map.get("show_start").toString());
  188 + Integer showEnd = Integer.parseInt(map.get("show_end").toString());
  189 + if ((showStart <= start && showEnd >= start) || showStart >= start)
  190 + {
  191 + list.add(map);
  192 + }
  193 + }
  194 + else if (person.getType() == 3 && type == 6)
  195 + {
  196 + Integer showStart = Integer.parseInt(map.get("show_start").toString());
  197 + Integer showEnd = Integer.parseInt(map.get("show_end").toString());
  198 + if ((showStart <= start && showEnd >= start) || showStart >= start)
  199 + {
  200 +
  201 + }
  202 + list.add(map);
  203 + }
  204 + }
  205 + }
  206 +
  207 + }
  208 + else
  209 + {
  210 + list.addAll(temps);
  211 + }
  212 +
  213 +
  214 + if(CollectionUtils.isEmpty(list)) {
124 215 return RespBuilder.buildErro(ResponseCode.COUPON_TEMP_NOT_FOUND);
125 216 }
126 217  
... ... @@ -129,7 +220,7 @@
129 220 return RespBuilder.buildErro(ResponseCode.OUPON_HOSPITAL_NOT_BOUND_AREA);
130 221 }
131 222  
132   - sendCoupon(temps, hospitalId, createUserId, userId, person.getType(), areaCode);
  223 + sendCoupon(list, hospitalId, createUserId, userId, person.getType(), areaCode);
133 224  
134 225 /** 记录为已经发放过优惠券 */
135 226 mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patientId)), Update.update("isSendCoupon", true), Patients.class);
... ... @@ -685,6 +776,17 @@
685 776 map.put("url", findUrl(map.get("sequence_id").toString(),type));
686 777 if(StringUtils.isNotEmpty(peopleNum)) {
687 778 map.put("peopleNum", peopleNum);
  779 + }
  780 + map.put("days",0);
  781 + //滦平县妇幼保健院2100001377
  782 + //滦平县妇幼保健院首次产检券 孕0-12周 改为 孕0-12周+6天
  783 + if ("2100001377".equals(hospitalId))
  784 + {
  785 + Integer show_end = Integer.parseInt(String.valueOf(map.get("show_end")));
  786 + if (show_end == 12)
  787 + {
  788 + map.put("days",6);
  789 + }
688 790 }
689 791 }
690 792 restMap.put("couponInfos", couponInfos);
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml View file @ 4260239
... ... @@ -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,b.show_end, 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">