Commit 56fa35a390a744c7f8068f908d27ca10c34bf09a
1 parent
ba9db040cb
Exists in
master
and in
6 other branches
优惠券统计的时间改为使用时间
Showing 3 changed files with 101 additions and 8 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
View file @
56fa35a
| ... | ... | @@ -134,5 +134,13 @@ | 
| 134 | 134 | Map<String,Object> findHospitalUsedInfo2(Map<String, Object> param); | 
| 135 | 135 | |
| 136 | 136 | Map<String,Object> findHospitalSendInfo2(Map<String, Object> param); | 
| 137 | + | |
| 138 | + List<String> findSendUserIds2(Map<String, Object> param); | |
| 139 | + | |
| 140 | + List<String> findUsedUserIds2(Map<String, Object> param); | |
| 141 | + | |
| 142 | + List<Map<String,Object>> findUsedInfo2(Map<String, Object> param); | |
| 143 | + | |
| 144 | + List<Map<String,Object>> findMulitPatienInfoWithSend(Map<String, Object> param); | |
| 137 | 145 | } | 
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
56fa35a
| ... | ... | @@ -270,6 +270,30 @@ | 
| 270 | 270 | group by b.coupon_order, b.type, a.used_hospital_id | 
| 271 | 271 | </select> | 
| 272 | 272 | |
| 273 | + <select id="findUsedInfo2" parameterType="map" resultType="map"> | |
| 274 | + select count(1) as type_used_count, b.coupon_order, b.type, a.used_hospital_id | |
| 275 | + from coupon_info a, ( | |
| 276 | + select a.id, a.coupon_order, b.type, d.hospital_id | |
| 277 | + from coupon_template a, coupon_type b, hospital_coupon_template_group d | |
| 278 | + where a.group_id = d.coupon_template_group_id and b.id = a.type_id and d.hospital_id in | |
| 279 | + <foreach collection="hospitalId" open="(" close=")" separator="," item="hid"> | |
| 280 | + #{hid} | |
| 281 | + </foreach> | |
| 282 | + and b.type in | |
| 283 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 284 | + #{type} | |
| 285 | + </foreach> | |
| 286 | + ) b | |
| 287 | + where a.used_hospital_id = b.hospital_id and a.coupon_template_id = b.id and a.status = 2 | |
| 288 | + <if test="startDate != null"> | |
| 289 | + and a.create_date >= #{startDate} | |
| 290 | + </if> | |
| 291 | + <if test="endDate != null"> | |
| 292 | + and a.create_date <![CDATA[ < ]]> #{endDate} | |
| 293 | + </if> | |
| 294 | + group by b.coupon_order, b.type, a.used_hospital_id | |
| 295 | + </select> | |
| 296 | + | |
| 273 | 297 | <select id="findUsedUserIds" parameterType="map" resultType="string"> | 
| 274 | 298 | select distinct(b.user_id) | 
| 275 | 299 | from organization a, coupon_info b, coupon_template c, coupon_type d | 
| ... | ... | @@ -288,6 +312,24 @@ | 
| 288 | 312 | </if> | 
| 289 | 313 | </select> | 
| 290 | 314 | |
| 315 | + <select id="findUsedUserIds2" parameterType="map" resultType="string"> | |
| 316 | + select distinct(b.user_id) | |
| 317 | + from organization a, coupon_info b, coupon_template c, coupon_type d | |
| 318 | + where a.id = b.used_hospital_id and b.coupon_template_id = c.id and c.type_id = d.id | |
| 319 | + and a.id = #{hid} | |
| 320 | + and b.status = 2 | |
| 321 | + and d.type in | |
| 322 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 323 | + #{type} | |
| 324 | + </foreach> | |
| 325 | + <if test="startDate != null"> | |
| 326 | + and b.use_date >= #{startDate} | |
| 327 | + </if> | |
| 328 | + <if test="endDate != null"> | |
| 329 | + and b.use_date <![CDATA[ < ]]> #{endDate} | |
| 330 | + </if> | |
| 331 | + </select> | |
| 332 | + | |
| 291 | 333 | <select id="findHospitalUsedInfo" parameterType="map" resultType="map"> | 
| 292 | 334 | select a.id, count(distinct(b.user_id)) as user_used_count, count(1) as coupon_used_count, a.area_id, a.city_id, a.province_id | 
| 293 | 335 | from organization a, coupon_info b, coupon_template c, coupon_type d | 
| ... | ... | @@ -341,6 +383,23 @@ | 
| 341 | 383 | </if> | 
| 342 | 384 | </select> | 
| 343 | 385 | |
| 386 | + <select id="findSendUserIds2" parameterType="map" resultType="string"> | |
| 387 | + select distinct(b.user_id) | |
| 388 | + from organization a, coupon_info b, coupon_template c, coupon_type d | |
| 389 | + where a.id = b.create_hospital_id and b.coupon_template_id = c.id and c.type_id = d.id | |
| 390 | + and a.id = #{hid} | |
| 391 | + and d.type in | |
| 392 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 393 | + #{type} | |
| 394 | + </foreach> | |
| 395 | + <if test="startDate != null"> | |
| 396 | + and b.create_date >= #{startDate} | |
| 397 | + </if> | |
| 398 | + <if test="endDate != null"> | |
| 399 | + and b.create_date <![CDATA[ < ]]> #{endDate} | |
| 400 | + </if> | |
| 401 | + </select> | |
| 402 | + | |
| 344 | 403 | <select id="findHospitalSendInfo" parameterType="map" resultType="map"> | 
| 345 | 404 | select a.id, count(distinct(b.user_id)) as people_send_count, count(1) as coupon_send_count, a.area_id, a.city_id, a.province_id | 
| 346 | 405 | from organization a, coupon_info b, coupon_template c, coupon_type d | 
| 347 | 406 | |
| ... | ... | @@ -368,10 +427,10 @@ | 
| 368 | 427 | #{type} | 
| 369 | 428 | </foreach> | 
| 370 | 429 | <if test="startDate != null"> | 
| 371 | - and b.use_date >= #{startDate} | |
| 430 | + and b.create_date >= #{startDate} | |
| 372 | 431 | </if> | 
| 373 | 432 | <if test="endDate != null"> | 
| 374 | - and b.use_date <![CDATA[ < ]]> #{endDate} | |
| 433 | + and b.create_date <![CDATA[ < ]]> #{endDate} | |
| 375 | 434 | </if> | 
| 376 | 435 | </select> | 
| 377 | 436 | |
| ... | ... | @@ -740,6 +799,32 @@ | 
| 740 | 799 | </foreach> | 
| 741 | 800 | order by a.create_date desc | 
| 742 | 801 | ) a group by a.ymd, a.user_id | 
| 802 | + ) a group by a.user_id | |
| 803 | + </select> | |
| 804 | + | |
| 805 | + <select id="findMulitPatienInfoWithSend" parameterType="map" resultType="map"> | |
| 806 | + select count(1) as count, a.user_id as user_id from ( | |
| 807 | + select a.ymd, a.user_id from ( | |
| 808 | + select DATE_FORMAT(a.create_date, '%Y-%m-%d') as ymd, a.user_id | |
| 809 | + from coupon_info a, coupon_template b, coupon_type c | |
| 810 | + where a.user_id in | |
| 811 | + <foreach collection="userIds" open="(" close=")" separator="," item="uid"> | |
| 812 | + #{uid} | |
| 813 | + </foreach> | |
| 814 | + <if test="startDate != null"> | |
| 815 | + and a.use_date >= #{startDate} | |
| 816 | + </if> | |
| 817 | + <if test="endDate != null"> | |
| 818 | + and a.use_date <![CDATA[ < ]]> #{endDate} | |
| 819 | + </if> | |
| 820 | + and a.coupon_template_id = b.id and b.type_id = c.id | |
| 821 | + and a.${hospitalFlag} = #{hid} | |
| 822 | + and c.type in | |
| 823 | + <foreach collection="couponType" open="(" close=")" separator="," item="type"> | |
| 824 | + #{type} | |
| 825 | + </foreach> | |
| 826 | + order by a.create_date desc | |
| 827 | + ) a group by a.ymd, a.user_id | |
| 743 | 828 | ) a group by a.user_id | 
| 744 | 829 | </select> | 
| 745 | 830 | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
56fa35a
| ... | ... | @@ -2196,8 +2196,8 @@ | 
| 2196 | 2196 | |
| 2197 | 2197 | if(MapUtils.isNotEmpty(tempMap)) { | 
| 2198 | 2198 | /** 方法/使用人数id */ | 
| 2199 | - List<String> sendUserIds = couponMapper.findSendUserIds(param); | |
| 2200 | - List<String> usedUserIds = couponMapper.findUsedUserIds(param); | |
| 2199 | + List<String> sendUserIds = couponMapper.findSendUserIds2(param); | |
| 2200 | + List<String> usedUserIds = couponMapper.findUsedUserIds2(param); | |
| 2201 | 2201 | tempMap.put("sendUserIds", sendUserIds); | 
| 2202 | 2202 | tempMap.put("usedUserIds", usedUserIds); | 
| 2203 | 2203 | couponReport.add(tempMap); | 
| ... | ... | @@ -2207,7 +2207,8 @@ | 
| 2207 | 2207 | |
| 2208 | 2208 | if(CollectionUtils.isNotEmpty(couponReport)) { | 
| 2209 | 2209 | param.put("status", 2); | 
| 2210 | - List<Map<String, Object>> couponUsedTypeInfo = couponMapper.findUsedInfo(param); /** 优惠券使用详情 */ | |
| 2210 | +// List<Map<String, Object>> couponUsedTypeInfo = couponMapper.findUsedInfo(param); /** 优惠券使用详情 */ | |
| 2211 | + List<Map<String, Object>> couponUsedTypeInfo = couponMapper.findUsedInfo2(param); /** 优惠券使用详情 */ | |
| 2211 | 2212 | for (Map<String, Object> m : couponReport) { | 
| 2212 | 2213 | for (Map<String, Object> info : couponUsedTypeInfo) { | 
| 2213 | 2214 | if(m.get("hospitalId").toString().equals(info.get("used_hospital_id"))) { | 
| 2214 | 2215 | |
| ... | ... | @@ -2251,11 +2252,10 @@ | 
| 2251 | 2252 | List<String> sendUserIds2 = new ArrayList<>(); | 
| 2252 | 2253 | param.put("hid", map.get("hospitalId")); | 
| 2253 | 2254 | if(CollectionUtils.isNotEmpty(sendUserIds)) { | 
| 2254 | -// List<Map<String, Object>> mulitPatienInfo = couponMapper.findMulitPatienInfo(sendUserIds); /** 查询需要添加人数的总数, 例如A发了两次优惠券 那么这里返回需要加的值为1 */ | |
| 2255 | 2255 | param.put("userIds", sendUserIds); | 
| 2256 | 2256 | param.put("hospitalFlag", "create_hospital_id"); /** 医院是用create_hospital_id 还是用 used_hospital_id限制*/ | 
| 2257 | - List<Map<String, Object>> mulitPatienInfo = couponMapper.findMulitPatienInfo(param); /** 查询需要添加人数的总数, 例如A发了两次优惠券 那么这里返回需要加的值为1 */ | |
| 2258 | - System.out.println(sendUserIds); | |
| 2257 | +// List<Map<String, Object>> mulitPatienInfo = couponMapper.findMulitPatienInfo(param); /** 查询需要添加人数的总数, 例如A发了两次优惠券 那么这里返回需要加的值为1 */ | |
| 2258 | + List<Map<String, Object>> mulitPatienInfo = couponMapper.findMulitPatienInfoWithSend(param); /** 查询需要添加人数的总数, 例如A发了两次优惠券 那么这里返回需要加的值为1 */ | |
| 2259 | 2259 | for (Map<String, Object> m : mulitPatienInfo) { | 
| 2260 | 2260 | Long count = (Long) m.get("count"); | 
| 2261 | 2261 | sendUserIds2.add((String) m.get("user_id")); |