Commit b856df631efa9beb71761b2b8519aef8f86b0d8e
1 parent
087602d3ed
Exists in
master
and in
6 other branches
优惠券 打印显示人数增加
Showing 1 changed file with 40 additions and 1 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CouponServiceImpl.java
View file @
b856df6
| 1 | 1 | package com.lyms.platform.permission.service.impl; |
| 2 | 2 | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 3 | 4 | import com.lyms.platform.biz.service.GenSequenceIdService; |
| 4 | 5 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 5 | 6 | import com.lyms.platform.common.result.RespBuilder; |
| 6 | 7 | import com.lyms.platform.common.result.ResponseCode; |
| 7 | 8 | import com.lyms.platform.common.utils.DateUtil; |
| 8 | 9 | import com.lyms.platform.common.utils.HttpClientUtil; |
| 10 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 9 | 11 | import com.lyms.platform.common.utils.PropertiesUtil; |
| 10 | 12 | import com.lyms.platform.permission.dao.master.CouponMapper; |
| 11 | 13 | import com.lyms.platform.permission.model.CouponInfo; |
| ... | ... | @@ -132,6 +134,27 @@ |
| 132 | 134 | /** 记录为已经发放过优惠券 */ |
| 133 | 135 | mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patientId)), Update.update("isSendCoupon", true), Patients.class); |
| 134 | 136 | |
| 137 | + /** 如果配置了医院打印人数 mongo人数自增1 */ | |
| 138 | + PlantformConfigModel model = mongoTemplate.findOne(Query.query(Criteria.where("key").is(hospitalId)), PlantformConfigModel.class); | |
| 139 | + if(model != null) { | |
| 140 | + String value = model.getValue(); | |
| 141 | + Map<Integer, Integer> map = new HashMap<>(); | |
| 142 | + Integer year = DateUtil.getCurrentYear(); | |
| 143 | + if(StringUtils.isNotEmpty(value)) { | |
| 144 | + map = JSON.parseObject(value, Map.class); | |
| 145 | + Integer code = map.get(year); | |
| 146 | + if(code != null) { | |
| 147 | + map.put(year, ++code); | |
| 148 | + } else { | |
| 149 | + map.put(year, 1); | |
| 150 | + } | |
| 151 | + } else { | |
| 152 | + map.put(year, 1); | |
| 153 | + } | |
| 154 | + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(model.getId())), | |
| 155 | + Update.update("value", JSON.toJSONString(map)), PlantformConfigModel.class); | |
| 156 | + } | |
| 157 | + | |
| 135 | 158 | return RespBuilder.buildSuccess(); |
| 136 | 159 | } |
| 137 | 160 | |
| ... | ... | @@ -557,6 +580,20 @@ |
| 557 | 580 | |
| 558 | 581 | @Override |
| 559 | 582 | public BaseObjectResponse findList(String userId, String hospitalId, String url,Integer type) { |
| 583 | + Integer year = DateUtil.getCurrentYear(); | |
| 584 | + String peopleNum = null; | |
| 585 | + PlantformConfigModel model = mongoTemplate.findOne(Query.query(Criteria.where("key").is(hospitalId)), PlantformConfigModel.class); | |
| 586 | + if(model != null) { | |
| 587 | + String value = model.getValue(); | |
| 588 | + if(StringUtils.isNotEmpty(value)) { | |
| 589 | + Map<Integer, Integer> map = JSON.parseObject(value, Map.class); | |
| 590 | + Integer code = map.get(year); | |
| 591 | + if(code != null) { | |
| 592 | + peopleNum = String.valueOf(year).substring(2) + "-" + code; | |
| 593 | + } | |
| 594 | + } | |
| 595 | + } | |
| 596 | + | |
| 560 | 597 | Map<String, Object> param = new HashMap<>(); |
| 561 | 598 | param.put("userId", userId); |
| 562 | 599 | param.put("hospitalId", hospitalId); |
| 563 | 600 | |
| ... | ... | @@ -565,8 +602,10 @@ |
| 565 | 602 | restMap.put("topName", couponMapper.findTopName(hospitalId)); |
| 566 | 603 | List<Map<String, Object>> couponInfos = couponMapper.findInfo(param); |
| 567 | 604 | for (Map<String,Object> map : couponInfos) { |
| 568 | -// map.put("url", PropertiesUtil.getInstance().getDefault("or.code.url", map.get("sequence_id").toString())); | |
| 569 | 605 | map.put("url", findUrl(map.get("sequence_id").toString(),type)); |
| 606 | + if(StringUtils.isNotEmpty(peopleNum)) { | |
| 607 | + map.put("peopleNum", peopleNum); | |
| 608 | + } | |
| 570 | 609 | } |
| 571 | 610 | restMap.put("couponInfos", couponInfos); |
| 572 | 611 | return RespBuilder.buildSuccess(restMap); |