diff --git a/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml b/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml index 0e08fb5..b7c967d 100644 --- a/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml +++ b/platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml @@ -584,26 +584,12 @@ select count(1) from ( - select count(distinct(user_id)) as un_used_people, count(1) as un_used_coupon_count, b.province_id, b.city_id, b.area_id, a.create_hospital_id - from coupon_info a, organization b - where a.create_hospital_id = b.id and a.status = 1 and a.create_hospital_id in - - #{hid} - - and user_id in + select a.user_id, b.coupon_order, c.type from coupon_info a, coupon_template b, coupon_type c + where a.coupon_template_id = b.id and b.type_id = c.id and a.status = 1 + and a.user_id in #{uid} - - and b.province_id = #{provinceId} - - - and b.city_id = #{cityId} - - - and b.area_id = #{areaId} - - group by a.create_hospital_id ) a diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java index 769204c..9116fe9 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java @@ -574,18 +574,36 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService hospitalIds.add(hospitalId); List> datas = couponMapper.findHospitalInfoByIds(hospitalIds); List patients = getPatients(hospitalIds, datas, startDate, endDate, provinceId, cityId, areaId, true); - Set userIds = new HashSet<>(); - for (Patients patient : patients) { - userIds.add(patient.getPid()); - } - Map param = CollectionUtils.createMap("hospitalId", hospitalId, "userIds", userIds, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "page", (page - 1) * limit, "limit", limit); - List> restList = couponMapper.findUnUsedInfo(param); - for (Map map : restList) { - map.put("cityName", findName(map.get("city_id"))); - map.put("areaName", findName(map.get("area_id"))); + if(CollectionUtils.isNotEmpty(patients)) { + Set userIds = new HashSet<>(); + for (Patients patient : patients) { + userIds.add(patient.getPid()); + } + List> list = couponMapper.findUnUsedInfo(CollectionUtils.createMap("userIds", userIds, "page", (page - 1) * limit, "limit", limit)); + List> restList = new ArrayList<>(); + for (Map map : list) { + map.put("couponName", (couponReportMap.get(map.get("type") + "_" + map.get("coupon_order"))).toString() + .replaceAll("使用人次", "") + .replaceAll("
", "") + .replaceAll("
", "") + .replaceAll("
", "")); + for (Patients patient : patients) { + if(patient.getPid().equals(map.get("user_id"))) { + map.put("username", patient.getUsername()); + map.put("phone", com.lyms.platform.common.utils.StringUtils.encryPhone(patient.getPhone())); + map.put("cardNo", com.lyms.platform.common.utils.StringUtils.encryCardNo(patient.getCardNo())); + map.put("week", DateUtil.getWeekDesc(patient.getLastMenses(), new Date())); + map.put("doctorName", couponMapper.getUserName(patient.getBookbuildingDoctor())); + map.put("hospitalName", couponMapper.findHospitalNameById(patient.getHospitalId())); + } + } + map.put("checkTime", "2017-02-22"); + restList.add(map); + } + Integer count = couponMapper.findUnUsedInfoCount(CollectionUtils.createMap("userIds", userIds)); + return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); } - Integer count = couponMapper.findUnUsedInfoCount(param); - return RespBuilder.buildSuccess(new PageResult(count, page, limit, restList)); + return RespBuilder.buildSuccess(new PageResult(0, page, limit, null)); } @Override @@ -742,7 +760,7 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService if(startDate != null && endDate != null) { c.and("bookbuildingDate").gte(startDate).lt(DateUtil.addDay(endDate, 1)); } - List patients = mongoTemplate.find(Query.query(c), Patients.class); + List patients = mongoTemplate.find(Query.query(c).with(new Sort(Sort.Direction.DESC, "created")), Patients.class); return patients; }