|
@ -113,6 +113,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
activityRuleDO.setActivityId(activityDO.getId());
|
|
|
activityRuleDO.setSaasId("dev");
|
|
|
activityRuleDO.setValue1(value1);
|
|
|
|
|
|
activityRuleDO.setValue2(value2);
|
|
|
activityRuleDO.setValue3(value3);
|
|
|
activityRuleDO.setDelFlag(1);
|
|
@ -525,13 +526,13 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
TaskPatientDetailDO taskPatientDetailDO1 = taskPatientDetailDao.selectByActivityIdAndPatientId(activityId,patient);
|
|
|
//积分排行
|
|
|
String sql ="SELECT btpd.patient_id AS patientId,btpd.total,btpd.update_time AS updateTime FROM ( SELECT sum(btpd.total) AS total, btpd.patient_id,btpd.update_time " +
|
|
|
String sql ="SELECT btpd1.patientId, btpd1.total, btpd1.create_time AS updateTime FROM (SELECT btpd.patient_id AS patientId,btpd.total,btpd.create_time AS create_time FROM ( SELECT sum(btpd.total) AS total, btpd.patient_id,btpd.create_time " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail btpd " +
|
|
|
"WHERE btpd.activity_id = '"+activityId +
|
|
|
"' GROUP BY btpd.patient_id " +
|
|
|
" ) btpd " +
|
|
|
"ORDER BY " +
|
|
|
" btpd.total DESC LIMIT " + (page-1)*size+","+size;
|
|
|
" btpd.total DESC)btpd1 ORDER BY btpd1.create_time LIMIT " + (page-1)*size+","+size;
|
|
|
List<TaskPatientDetailDO> patientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
|
|
|
for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS){
|
|
|
String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime());
|
|
@ -546,13 +547,13 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
taskPatientDetailDO.setTimeSeparated(timeSeparated);
|
|
|
}
|
|
|
//活动劵排行
|
|
|
String sqlCoupon ="SELECT btpd.patient_id AS patientId,btpd.couponTotal,btpd.update_time AS updateTime FROM ( SELECT sum(btpd.coupon_total) AS couponTotal, btpd.patient_id,btpd.update_time " +
|
|
|
String sqlCoupon ="SELECT btpd1.patientId, btpd1.total, btpd1.create_time AS updateTime FROM (SELECT btpd.patient_id AS patientId,btpd.couponTotal,btpd.create_time AS create_time FROM ( SELECT sum(btpd.coupon_total) AS couponTotal, btpd.patient_id,btpd.create_time " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail btpd " +
|
|
|
"WHERE btpd.activity_id = '"+activityId +
|
|
|
"' GROUP BY btpd.patient_id " +
|
|
|
" ) btpd " +
|
|
|
"ORDER BY " +
|
|
|
" btpd.couponTotal DESC LIMIT " + (page-1)*size+","+size;
|
|
|
" btpd.couponTotal DESC)btpd1 WHERE btpd1.LIMIT " + (page-1)*size+","+size;
|
|
|
List<TaskPatientDetailDO> patientDetailDOS1 = jdbcTemplate.query(sqlCoupon,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
|
|
|
for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS1){
|
|
|
String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime());
|
|
@ -572,10 +573,11 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" patient_id, " +
|
|
|
" activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
" wlyy_health_bank_task_patient_detail htpd " +
|
|
|
" where htpd.activity_id ='"+activityId+"' AND htpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' AND btpd1.sum >= (SELECT SUM(s.total) as total " +
|
|
|
" btpd1.sum >= (SELECT SUM(s.total) as total " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"')" ;
|
|
|
List<Map<String,Object>> rstotal1 = jdbcTemplate.queryForList(rankingSql1);
|
|
|
Long count = 0L;
|
|
@ -593,8 +595,8 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" patient_id, " +
|
|
|
" activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd where btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' AND btpd1.sum >= (SELECT SUM(s.total) as total " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"') limit "+countTotal+",1" ;
|
|
@ -619,10 +621,10 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" patient_id, " +
|
|
|
" activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
" wlyy_health_bank_task_patient_detail htpd WHERE htpd.activity_id ='"+activityId+"' AND htpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
" btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"')" ;
|
|
|
List<Map<String,Object>> rstotal2 = jdbcTemplate.queryForList(rankingSql2);
|
|
|
Long count2 = 0L;
|
|
@ -640,10 +642,10 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" patient_id, " +
|
|
|
" activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd WHERE btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' AND btpd1.sum >= (SELECT SUM(s.total) as total " +
|
|
|
" btpd1.sum >= (SELECT SUM(s.total) as total " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"') limit "+countTotal1+",1" ;
|
|
|
List<Map<String,Object>> totalSql10 = jdbcTemplate.queryForList(rankingSql10);
|
|
|
Integer total2 = 0;
|
|
@ -664,10 +666,9 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" btpd.patient_id, " +
|
|
|
" btpd.activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' and btpd1.patient_id IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.street = '"+street+"') AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd WHERE btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE btpd1.patient_id IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.street = '"+street+"') AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"')" ;
|
|
|
List<Map<String,Object>> rstotal3 = jdbcTemplate.queryForList(rankingSql3);
|
|
|
Long count3 = 0L;
|
|
@ -680,10 +681,9 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" btpd.patient_id, " +
|
|
|
" btpd.activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' and btpd1.patient_id IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.town = '"+town+"') AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd WHERE btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE btpd1.patient_id IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.town = '"+town+"') AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"')" ;
|
|
|
List<Map<String,Object>> rstotal4 = jdbcTemplate.queryForList(rankingSql4);
|
|
|
Long count4 = 0L;
|
|
@ -698,10 +698,9 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" btpd.patient_id, " +
|
|
|
" btpd.activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' and btpd1.patient_id IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.street = '"+street+"') AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd WHERE btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE btpd1.patient_id IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.street = '"+street+"') AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"')" ;
|
|
|
List<Map<String,Object>> rstotal5 = jdbcTemplate.queryForList(rankingSql5);
|
|
|
Long count5 = 0L;
|
|
@ -714,8 +713,8 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" btpd.patient_id, " +
|
|
|
" btpd.activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd WHERE btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' and btpd1.patient_id IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.town = '"+town+"') AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"')" ;
|
|
@ -733,10 +732,9 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" btpd.patient_id, " +
|
|
|
" btpd.activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' and btpd1.patient_id IN(SELECT sf.patient FROM wlyy.wlyy_sign_family sf WHERE sf.status=1 " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd WHERE btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE btpd1.patient_id IN(SELECT sf.patient FROM wlyy.wlyy_sign_family sf WHERE sf.status=1 " +
|
|
|
"AND sf.admin_team_code=(SELECT sf.admin_team_code FROM wlyy.wlyy_sign_family sf WHERE sf.status=1 AND sf.patient='"+patient+"') ) AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"')" ;
|
|
|
List<Map<String,Object>> rstotal7 = jdbcTemplate.queryForList(rankingSql7);
|
|
@ -751,10 +749,9 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
" btpd.patient_id, " +
|
|
|
" btpd.activity_id " +
|
|
|
"FROM " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd " +
|
|
|
"GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE " +
|
|
|
" btpd1.activity_id = '"+activityDO.getId()+"' and btpd1.patient_id IN(SELECT sf.patient FROM wlyy.wlyy_sign_family sf WHERE sf.status=1 " +
|
|
|
" wlyy_health_bank_task_patient_detail btpd WHERE btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
|
|
|
"' GROUP BY patient_id )btpd1 " +
|
|
|
"WHERE btpd1.patient_id IN(SELECT sf.patient FROM wlyy.wlyy_sign_family sf WHERE sf.status=1 " +
|
|
|
"AND sf.admin_team_code=(SELECT sf.admin_team_code FROM wlyy.wlyy_sign_family sf WHERE sf.status=1 AND sf.patient='"+patient+"') ) AND btpd1.sum >= (SELECT SUM(s.coupon_total) as couponTotal " +
|
|
|
"FROM wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND s.activity_id='"+activityId+"')" ;
|
|
|
List<Map<String,Object>> rstotal8 = jdbcTemplate.queryForList(rankingSql8);
|
|
@ -824,7 +821,11 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
jsonObject.put("couponTotal",taskPatientDetailDO1.getCouponTotal());//本人活动劵总数
|
|
|
jsonObject.put("couponRanking",patientDetailDOS1);//活动劵人数排名
|
|
|
jsonObject.put("signCouponRanking",count7);//活动劵团队排名
|
|
|
jsonObject.put("differTotal",total2-total3);//相距前一个差多少活动劵
|
|
|
if (count2 ==1){
|
|
|
jsonObject.put("differTotal",0);
|
|
|
}else {
|
|
|
jsonObject.put("differTotal",total2-total3);//相距前一个差多少活动劵
|
|
|
}
|
|
|
}else if (type ==1){
|
|
|
jsonObject.put("IntegrateRanking",patientDetailDOS);
|
|
|
jsonObject.put("activityStreetIntegrateRanking",count5);//积分街道排名
|
|
@ -832,7 +833,11 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
|
|
|
jsonObject.put("activityTownIntegrateRanking",count6);//积分全区排名
|
|
|
jsonObject.put("activityRanking",count);//积分排名
|
|
|
jsonObject.put("signRanking",count8);//积分团队排名
|
|
|
jsonObject.put("differTotal",total-total1);//相距前一个差多少积分
|
|
|
if (count==1){
|
|
|
jsonObject.put("differTotal",0);//相距前一个差多少积分
|
|
|
}else {
|
|
|
jsonObject.put("differTotal",total-total1);//相距前一个差多少积分
|
|
|
}
|
|
|
}
|
|
|
jsonObject.put("type",type);//积分还是活动劵
|
|
|
envelop.setObj(jsonObject);
|