|  | @ -5,11 +5,9 @@ package com.yihu.jw.service;/**
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.google.common.base.Joiner;
 | 
	
		
			
				|  |  | import com.netflix.discovery.util.StringUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.dao.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.health.bank.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.util.AesEncryptUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.rm.health.bank.HealthBankMapping;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.DateUtils;
 | 
	
	
		
			
				|  | @ -22,7 +20,6 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.transaction.RollbackException;
 | 
	
		
			
				|  |  | import javax.transaction.Transactional;
 | 
	
		
			
				|  |  | import java.text.ParseException;
 | 
	
		
			
				|  |  | import java.text.SimpleDateFormat;
 | 
	
	
		
			
				|  | @ -276,8 +273,11 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             activityDO1.setTotal(count);
 | 
	
		
			
				|  |  |             String taskSql1 = "select * from wlyy_health_bank_task_patient_detail btpd where activity_id = '"+activityDO1.getId()
 | 
	
		
			
				|  |  |                     +"' and (patient_idcard = '"+activityDO.getPatientIdcard()+"' OR union_id = '"+activityDO.getUnionId()+"')";
 | 
	
		
			
				|  |  |                     +"' and (patient_idcard = '"+ AesEncryptUtils.encrypt(activityDO.getPatientIdcard())+"' OR union_id = '"+activityDO.getUnionId()+"')";
 | 
	
		
			
				|  |  |             List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
 | 
	
		
			
				|  |  |             for (TaskPatientDetailDO taskPatientDetailDO : taskPatientDetailDOS){
 | 
	
		
			
				|  |  |                 taskPatientDetailDO.setPatientIdcard(AesEncryptUtils.decrypt(taskPatientDetailDO.getPatientIdcard()));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             activityDO1.setTaskPatientDetailDOS(taskPatientDetailDOS);
 | 
	
		
			
				|  |  |             String tasksql = "select * from wlyy_health_bank_task where transaction_id = '"+activityDO1.getId()+"'";
 | 
	
		
			
				|  |  |             List<TaskDO> taskDOList = jdbcTemplate.query(tasksql,new BeanPropertyRowMapper(TaskDO.class));
 | 
	
	
		
			
				|  | @ -407,7 +407,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |                 " SELECT task_id FROM " +
 | 
	
		
			
				|  |  |                 "wlyy_health_bank_task_patient_detail" +
 | 
	
		
			
				|  |  |                 " WHERE " +
 | 
	
		
			
				|  |  |                 " patient_idcard = '"+activityDO.getPatientIdcard()+"' "+ condition+")" +
 | 
	
		
			
				|  |  |                 " patient_idcard = '"+ AesEncryptUtils.encrypt(activityDO.getPatientIdcard()) +"' "+ condition+")" +
 | 
	
		
			
				|  |  |                 " ) AND del_flag =1 " +condition1+" order by create_time DESC "+
 | 
	
		
			
				|  |  |                 " LIMIT "+(page-1)*size +","+size;
 | 
	
		
			
				|  |  |         List<ActivityDO> activityDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ActivityDO.class));
 | 
	
	
		
			
				|  | @ -423,7 +423,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |                     " wlyy_health_bank_task_patient_detail " +
 | 
	
		
			
				|  |  |                     "GROUP BY patient_openid,patient_idcard,union_id)btpd1 " +
 | 
	
		
			
				|  |  |                     "WHERE " +
 | 
	
		
			
				|  |  |                     " btpd1.activity_id = '"+activityDO1.getId() +"' AND patient_openid = '"+activityDO.getOpenId()+ "' AND patient_idcard = '"+activityDO.getPatientIdcard()+"' "+condition;
 | 
	
		
			
				|  |  |                     " btpd1.activity_id = '"+activityDO1.getId() +"' AND patient_openid = '"+activityDO.getOpenId()+ "' AND patient_idcard = '"+AesEncryptUtils.encrypt(activityDO.getPatientIdcard())+"' "+condition;
 | 
	
		
			
				|  |  |             List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(activitySql);
 | 
	
		
			
				|  |  |             Long count = 0L;
 | 
	
		
			
				|  |  |             if(rstotal!=null&&rstotal.size()>0){
 | 
	
	
		
			
				|  | @ -478,7 +478,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |                 " SELECT task_id FROM " +
 | 
	
		
			
				|  |  |                 "wlyy_health_bank_task_patient_detail" +
 | 
	
		
			
				|  |  |                 " WHERE " +
 | 
	
		
			
				|  |  |                 " patient_openid = '"+activityDO.getOpenId()+ "' AND patient_idcard = '"+activityDO.getPatientIdcard()+"'"+condition+ ")" +
 | 
	
		
			
				|  |  |                 " patient_openid = '"+activityDO.getOpenId()+ "' AND patient_idcard = '"+AesEncryptUtils.encrypt(activityDO.getPatientIdcard())+"'"+condition+ ")" +
 | 
	
		
			
				|  |  |                 " ) "+condition1;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
 | 
	
		
			
				|  |  |         Long count = 0L;
 | 
	
	
		
			
				|  | @ -733,7 +733,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |                 "ORDER BY " +
 | 
	
		
			
				|  |  |                 " btpd.couponTotal DESC,btpd.create_time ASC LIMIT " + (page-1)*size+","+size;
 | 
	
		
			
				|  |  |         List<TaskPatientDetailDO> patientDetailDOS1 = jdbcTemplate.query(sqlCoupon,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
 | 
	
		
			
				|  |  |         long count2 = 1l;
 | 
	
		
			
				|  |  |         long count2 = 1L;
 | 
	
		
			
				|  |  |         int i=0;
 | 
	
		
			
				|  |  |         for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS1){
 | 
	
		
			
				|  |  |             String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime());
 | 
	
	
		
			
				|  | @ -751,26 +751,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |             taskPatientDetailDO.setExchangeGoodsDO(exchangeGoodsDOS);
 | 
	
		
			
				|  |  |             taskPatientDetailDO.setTimeSeparated(timeSeparated);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //活动总积分排名
 | 
	
		
			
				|  |  |         /*String rankingSql1 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(total) AS sum , " +
 | 
	
		
			
				|  |  |                 " patient_id, " +
 | 
	
		
			
				|  |  |                 " activity_id, " +
 | 
	
		
			
				|  |  |                 " create_time "+
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_health_bank_task_patient_detail htpd " +
 | 
	
		
			
				|  |  |                 " where htpd.activity_id ='"+activityId+"' AND htpd.patient_id !='"+patient+
 | 
	
		
			
				|  |  |                 "' GROUP BY patient_id )btpd1 " +
 | 
	
		
			
				|  |  |                 "WHERE " +
 | 
	
		
			
				|  |  |                 " 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+"') " +
 | 
	
		
			
				|  |  |                 " AND btpd1.create_time >=(SELECT s.create_time " +
 | 
	
		
			
				|  |  |                 "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;
 | 
	
		
			
				|  |  |         if(rstotal1!=null&&rstotal1.size()>0){
 | 
	
		
			
				|  |  |             count = (Long) rstotal1.get(0).get("total");
 | 
	
		
			
				|  |  |         }*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long countTotal = 0L;
 | 
	
		
			
				|  |  |         if ((count-2)>=0){
 | 
	
		
			
				|  |  |             countTotal = (count-2);
 | 
	
	
		
			
				|  | @ -801,28 +782,6 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |             total1 = Integer.parseInt( rstotal10.get(0).get("total").toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //总活动劵的排名
 | 
	
		
			
				|  |  |         /*String rankingSql2 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(coupon_total) AS sum , " +
 | 
	
		
			
				|  |  |                 " patient_id, " +
 | 
	
		
			
				|  |  |                 " activity_id," +
 | 
	
		
			
				|  |  |                 " create_time " +
 | 
	
		
			
				|  |  |                 "FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_health_bank_task_patient_detail htpd WHERE htpd.activity_id ='"+activityId+"' AND htpd.patient_id !='"+patient+
 | 
	
		
			
				|  |  |                 "' GROUP BY patient_id )btpd1 " +
 | 
	
		
			
				|  |  |                 "WHERE " +
 | 
	
		
			
				|  |  |                 "   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+"')"+
 | 
	
		
			
				|  |  |                 " AND btpd1.create_time >=(SELECT s.create_time " +
 | 
	
		
			
				|  |  |                 "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;
 | 
	
		
			
				|  |  |         if(rstotal2!=null&&rstotal2.size()>0){
 | 
	
		
			
				|  |  |             count2 = (Long) rstotal2.get(0).get("total");
 | 
	
		
			
				|  |  |         }*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long countTotal1 = 0L;
 | 
	
		
			
				|  |  |         if ((count2-2)>=0){
 | 
	
		
			
				|  |  |             countTotal1=(count2-2);
 | 
	
	
		
			
				|  | @ -930,7 +889,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |                 "ORDER BY " +
 | 
	
		
			
				|  |  |                 " btpd.couponTotal DESC )btpd1 WHERE  btpd1.patientId IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.street = '"+street+"') ORDER BY btpd1.create_time ";
 | 
	
		
			
				|  |  |         List<TaskPatientDetailDO> patientDetailDOS4 = jdbcTemplate.query(rankingSql5,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
 | 
	
		
			
				|  |  |         long count5 = 1l;
 | 
	
		
			
				|  |  |         long count5 = 1L;
 | 
	
		
			
				|  |  |         for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS4){
 | 
	
		
			
				|  |  |             String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime());
 | 
	
		
			
				|  |  |             String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " +
 | 
	
	
		
			
				|  | @ -955,7 +914,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |                 "ORDER BY " +
 | 
	
		
			
				|  |  |                 " btpd.couponTotal DESC )btpd1 WHERE  btpd1.patientId IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.town = '"+town+"') ORDER BY btpd1.create_time ";
 | 
	
		
			
				|  |  |         List<TaskPatientDetailDO> patientDetailDOS5 = jdbcTemplate.query(rankingSql6,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
 | 
	
		
			
				|  |  |         long count6 = 1l;
 | 
	
		
			
				|  |  |         long count6 = 1L;
 | 
	
		
			
				|  |  |         for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS5){
 | 
	
		
			
				|  |  |             String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime());
 | 
	
		
			
				|  |  |             String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " +
 | 
	
	
		
			
				|  | @ -991,85 +950,6 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |             count11 =  new Double((Double) maps1.get(0).get("rank")).longValue();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //街道排名
 | 
	
		
			
				|  |  |        /* String rankingSql3 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(btpd.coupon_total) AS sum , " +
 | 
	
		
			
				|  |  |                 " btpd.patient_id, " +
 | 
	
		
			
				|  |  |                 " btpd.activity_id," +
 | 
	
		
			
				|  |  |                 " create_time " +
 | 
	
		
			
				|  |  |                 "FROM " +
 | 
	
		
			
				|  |  |                 " 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+"')"+
 | 
	
		
			
				|  |  |                 " AND btpd1.create_time >=(SELECT s.create_time " +
 | 
	
		
			
				|  |  |                 "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;
 | 
	
		
			
				|  |  |         if(rstotal3!=null&&rstotal3.size()>0){
 | 
	
		
			
				|  |  |             count3 = (Long) rstotal3.get(0).get("total");
 | 
	
		
			
				|  |  |         }*/
 | 
	
		
			
				|  |  |         //区排名
 | 
	
		
			
				|  |  |        /* String rankingSql4 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(btpd.coupon_total) AS sum , " +
 | 
	
		
			
				|  |  |                 " btpd.patient_id, " +
 | 
	
		
			
				|  |  |                 " btpd.activity_id," +
 | 
	
		
			
				|  |  |                 " create_time  " +
 | 
	
		
			
				|  |  |                 "FROM " +
 | 
	
		
			
				|  |  |                 " 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+"')"+
 | 
	
		
			
				|  |  |                 " AND btpd1.create_time >=(SELECT s.create_time " +
 | 
	
		
			
				|  |  |                 "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;
 | 
	
		
			
				|  |  |         if(rstotal4!=null&&rstotal4.size()>0){
 | 
	
		
			
				|  |  |             count4= (Long) rstotal4.get(0).get("total");
 | 
	
		
			
				|  |  |         }*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //积分
 | 
	
		
			
				|  |  |         //街道排名
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         /*String rankingSql5 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(btpd.total) AS sum , " +
 | 
	
		
			
				|  |  |                 " btpd.patient_id, " +
 | 
	
		
			
				|  |  |                 " btpd.activity_id," +
 | 
	
		
			
				|  |  |                 " create_time  " +
 | 
	
		
			
				|  |  |                 "FROM " +
 | 
	
		
			
				|  |  |                 " 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+"')"+
 | 
	
		
			
				|  |  |                 " AND btpd1.create_time >=(SELECT s.create_time " +
 | 
	
		
			
				|  |  |                 "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;
 | 
	
		
			
				|  |  |         if(rstotal5!=null&&rstotal5.size()>0){
 | 
	
		
			
				|  |  |             count5 = (Long) rstotal5.get(0).get("total");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //区排名
 | 
	
		
			
				|  |  |         String rankingSql6 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(btpd.total) AS sum , " +
 | 
	
		
			
				|  |  |                 " btpd.patient_id, " +
 | 
	
		
			
				|  |  |                 " btpd.activity_id," +
 | 
	
		
			
				|  |  |                 " create_time " +
 | 
	
		
			
				|  |  |                 "FROM " +
 | 
	
		
			
				|  |  |                 " 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+"')"
 | 
	
		
			
				|  |  |                 + " AND btpd1.create_time >=(SELECT s.create_time " +
 | 
	
		
			
				|  |  |                 "FROM  wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND  s.activity_id='"+activityId+"')" ;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> rstotal6 = jdbcTemplate.queryForList(rankingSql6);
 | 
	
		
			
				|  |  |         Long count6 = 0L;
 | 
	
		
			
				|  |  |         if(rstotal6!=null&&rstotal6.size()>0){
 | 
	
		
			
				|  |  |             count6= (Long) rstotal6.get(0).get("total");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | */
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //活动劵团队排名
 | 
	
		
			
				|  |  |         String rankingSql7 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(btpd.coupon_total) AS sum , " +
 | 
	
	
		
			
				|  | @ -1110,56 +990,6 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |             count8 = (Long) rstotal8.get(0).get("total");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |       /*  //活动劵
 | 
	
		
			
				|  |  |         String rankingSql4 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(coupon_total) AS sum , " +
 | 
	
		
			
				|  |  |                 " patient_id, " +
 | 
	
		
			
				|  |  |                 " activity_id " +
 | 
	
		
			
				|  |  |                 "FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_health_bank_task_patient_detail " +
 | 
	
		
			
				|  |  |                 "GROUP BY patient_id )btpd1 " +
 | 
	
		
			
				|  |  |                 "WHERE " +
 | 
	
		
			
				|  |  |                 " btpd1.activity_id = '"+activityDO.getId()+"'"+buffer+" 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;
 | 
	
		
			
				|  |  |         if(rstotal4!=null&&rstotal4.size()>0){
 | 
	
		
			
				|  |  |             count4= (Long) rstotal4.get(0).get("total");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //积分
 | 
	
		
			
				|  |  |         String rankingSql5 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(total) AS sum , " +
 | 
	
		
			
				|  |  |                 " patient_id, " +
 | 
	
		
			
				|  |  |                 " activity_id " +
 | 
	
		
			
				|  |  |                 "FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_health_bank_task_patient_detail " +
 | 
	
		
			
				|  |  |                 "GROUP BY patient_id )btpd1 " +
 | 
	
		
			
				|  |  |                 "WHERE " +
 | 
	
		
			
				|  |  |                 " btpd1.activity_id = '"+activityDO.getId()+"'"+buffer+" 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+"')" ;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> rstotal5 = jdbcTemplate.queryForList(rankingSql5);
 | 
	
		
			
				|  |  |         Long count5 = 0L;
 | 
	
		
			
				|  |  |         if(rstotal5!=null&&rstotal5.size()>0){
 | 
	
		
			
				|  |  |             count5 = (Long) rstotal5.get(0).get("total");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String rankingSql6 = "SELECT count(1)+1 AS total FROM (SELECT " +
 | 
	
		
			
				|  |  |                 " SUM(total) AS sum , " +
 | 
	
		
			
				|  |  |                 " patient_id, " +
 | 
	
		
			
				|  |  |                 " activity_id " +
 | 
	
		
			
				|  |  |                 "FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_health_bank_task_patient_detail " +
 | 
	
		
			
				|  |  |                 "GROUP BY patient_id )btpd1 " +
 | 
	
		
			
				|  |  |                 "WHERE " +
 | 
	
		
			
				|  |  |                 " btpd1.activity_id = '"+activityDO.getId()+"'"+buffer+" 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+"')" ;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> rstotal6 = jdbcTemplate.queryForList(rankingSql6);
 | 
	
		
			
				|  |  |         Long count6 = 0L;
 | 
	
		
			
				|  |  |         if(rstotal6!=null&&rstotal6.size()>0){
 | 
	
		
			
				|  |  |             count6= (Long) rstotal6.get(0).get("total");
 | 
	
		
			
				|  |  |         }*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         ActivityRuleDO activityRuleDO = activityRuleDao.selectByActivityId(activityId);
 | 
	
		
			
				|  |  |         JSONObject object = JSONObject.parseObject(activityRuleDO.getValue1());
 | 
	
		
			
				|  |  |         Integer type = object.getInteger("type");
 | 
	
	
		
			
				|  | @ -1236,8 +1066,6 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |         stringBuffer.append(" order by create_time desc");
 | 
	
		
			
				|  |  |         String sql = "SELECT * FROM wlyy_health_bank.wlyy_health_bank_activity  WHERE 1=1 AND del_flag=1 "+stringBuffer.toString()+" LIMIT "+(page-1)*size+","+size;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<ActivityDO> activityDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ActivityDO.class));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sqlcount = "SELECT COUNT(1)  AS total  FROM wlyy_health_bank.wlyy_health_bank_activity  WHERE 1=1 AND del_flag=1 "+stringBuffer.toString();
 | 
	
	
		
			
				|  | @ -1292,7 +1120,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop<ActivityDO,ActivityDO> selectByUnionId(String unionId,String patient,String idCard,Integer page,Integer size){
 | 
	
		
			
				|  |  |         String sql ="select hba.* from wlyy_health_bank_activity hba right join wlyy_health_bank_task_patient_detail htpd on htpd.activity_id=hba.id " +
 | 
	
		
			
				|  |  |                 "AND htpd.union_id='"+unionId+"' AND  htpd.patient_id ='"+patient+"' and htpd.patient_idcard ='"+idCard+"' " +
 | 
	
		
			
				|  |  |                 "AND htpd.union_id='"+unionId+"' AND  htpd.patient_id ='"+patient+"' and htpd.patient_idcard ='"+ AesEncryptUtils.encrypt(idCard)+"' " +
 | 
	
		
			
				|  |  |                 "where hba.del_flag=1 and hba.type='竞走' order by hba.create_time desc LIMIT " + (page-1)*size+","+size;
 | 
	
		
			
				|  |  |         List<ActivityDO> activityDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ActivityDO.class));
 | 
	
		
			
				|  |  |         for (ActivityDO activityDO:activityDOList){
 | 
	
	
		
			
				|  | @ -1361,7 +1189,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<ActivityDO> selectNowByUnionId(String unionId,String patient,String idCard){
 | 
	
		
			
				|  |  |         String sql ="select hba.* from wlyy_health_bank_activity hba right join wlyy_health_bank_task_patient_detail htpd on htpd.activity_id=hba.id " +
 | 
	
		
			
				|  |  |                 "AND htpd.union_id='"+unionId+"' AND  htpd.patient_id ='"+patient+"' and htpd.patient_idcard ='"+idCard+"' " +
 | 
	
		
			
				|  |  |                 "AND htpd.union_id='"+unionId+"' AND  htpd.patient_id ='"+patient+"' and htpd.patient_idcard ='"+AesEncryptUtils.encrypt(idCard) +"' " +
 | 
	
		
			
				|  |  |                 "where hba.del_flag=1 and hba.type='竞走' order by hba.create_time desc " ;
 | 
	
		
			
				|  |  |         List<ActivityDO> activityDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ActivityDO.class));
 | 
	
		
			
				|  |  |         List<ActivityDO> activityDOS = new ArrayList<>();
 |