Commit 96b56a2c750e5302603371057d352765b4d9d3a0
1 parent
4a4a16b680
Exists in
master
and in
1 other branch
处理优惠券统计多惨成问题
Showing 3 changed files with 34 additions and 0 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
View file @
96b56a2
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
96b56a2
... | ... | @@ -646,5 +646,20 @@ |
646 | 646 | </if> |
647 | 647 | ) a |
648 | 648 | </select> |
649 | + | |
650 | + | |
651 | + <select id="findMulitPatientCount" parameterType="list"> | |
652 | + select sum(a.mulit_patient_count) as count from ( | |
653 | + select (count(1) - 1) as mulit_patient_count, a.user_id as count from ( | |
654 | + select a.ymd, a.user_id from ( | |
655 | + select DATE_FORMAT(create_date, '%Y-%m-%d') as ymd, user_id from coupon_info | |
656 | + where user_id in | |
657 | + <foreach collection="userIds" open="(" close=")" separator="," item="uid"> | |
658 | + #{uid} | |
659 | + </foreach> | |
660 | + ) a group by a.ymd, a.user_id | |
661 | + ) a group by a.user_id | |
662 | + ) a | |
663 | + </select> | |
649 | 664 | </mapper> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
96b56a2
... | ... | @@ -902,6 +902,23 @@ |
902 | 902 | couponReportMap.add(m); |
903 | 903 | } |
904 | 904 | // return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap, "reportModel", reportModel); |
905 | + | |
906 | + for (Map<String, Object> map : couponReport) { | |
907 | + List<String> sendUserIds = (List<String>) map.get("sendUserIds"); | |
908 | + List<String> usedUserIds = (List<String>) map.get("usedUserIds"); | |
909 | + int addSendcount = couponMapper.findMulitPatientCount(sendUserIds); /** 查询需要添加人数的总数, 例如A发了两次优惠券 那么这里返回需要加的值为1 */ | |
910 | + int addUsedcount = couponMapper.findMulitPatientCount(usedUserIds); /** 查询需要添加人数的总数, 例如A发了两次优惠券 那么这里返回需要加的值为1 */ | |
911 | + map.put("coupon_send_count", ((Integer) map.get("coupon_send_count")) + addSendcount); | |
912 | + map.put("coupon_used_count", ((Integer) map.get("coupon_used_count")) + addUsedcount); | |
913 | + | |
914 | + for (int i = 0; i < addSendcount; i++) { | |
915 | + sendUserIds.add(UUID.randomUUID().toString()); | |
916 | + } | |
917 | + for (int i = 0; i < addUsedcount; i++) { | |
918 | + usedUserIds.add(UUID.randomUUID().toString()); | |
919 | + } | |
920 | + } | |
921 | + | |
905 | 922 | return RespBuilder.buildSuccess("couponReport", couponReport, "couponReportMap", couponReportMap, "reportModel", reportModal); |
906 | 923 | } |
907 | 924 |