Explorar o código

Merge branch 'dev' of wangzhinan/wlyy2.0 into dev

huangwenjie %!s(int64=6) %!d(string=hai) anos
pai
achega
1e437bf20d

+ 12 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/CreditsDetailDO.java

@ -90,6 +90,9 @@ public class CreditsDetailDO extends UuidIdentityEntityWithOperator implements S
    @Transient
    private Integer mark;//1活动劵,2积分
    @Transient
    private ExchangeGoodsDO exchangeGoodsDO;//兑换商品
    @Column(name = "saas_id")
@ -315,4 +318,13 @@ public class CreditsDetailDO extends UuidIdentityEntityWithOperator implements S
    public void setMark(Integer mark) {
        this.mark = mark;
    }
    @Transient
    public ExchangeGoodsDO getExchangeGoodsDO() {
        return exchangeGoodsDO;
    }
    public void setExchangeGoodsDO(ExchangeGoodsDO exchangeGoodsDO) {
        this.exchangeGoodsDO = exchangeGoodsDO;
    }
}

+ 172 - 33
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityService.java

@ -536,6 +536,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
                "ORDER BY " +
                " btpd.total DESC)btpd1 ORDER BY btpd1.create_time LIMIT " + (page-1)*size+","+size;
        List<TaskPatientDetailDO> patientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
        long count=0L;
        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS){
            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime());
            String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " +
@ -547,16 +548,20 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
            }
            taskPatientDetailDO.setExchangeGoodsDO(exchangeGoodsDOS);
            taskPatientDetailDO.setTimeSeparated(timeSeparated);
            if (!taskPatientDetailDO.getPatientId().equals(patient)){
                count+=1;
            }
        }
        //活动劵排行
        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 " +
        String sqlCoupon  ="SELECT btpd1.patientId, btpd1.couponTotal, 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)btpd1 WHERE btpd1.LIMIT " + (page-1)*size+","+size;
                " btpd.couponTotal DESC )btpd1 ORDER BY btpd1.create_time DESC LIMIT " + (page-1)*size+","+size;
        List<TaskPatientDetailDO> patientDetailDOS1 = jdbcTemplate.query(sqlCoupon,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
        long count2 = 0l;
        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS1){
            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime());
            String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " +
@ -566,27 +571,32 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
                TaskGoodsDO taskGoodsDO = taskGoodsDao.selectById(exchangeGoodsDO.getActivityGoodsId());
                exchangeGoodsDO.setTaskGoodsDO(taskGoodsDO);
            }
            if (taskPatientDetailDO.getPatientId().equals(taskPatientDetailDO.getPatientId())){
                count2+=1;
            }
            taskPatientDetailDO.setExchangeGoodsDO(exchangeGoodsDOS);
            taskPatientDetailDO.setTimeSeparated(timeSeparated);
        }
        //活动总积分排名
        String rankingSql1 = "SELECT count(1)+1 AS total FROM (SELECT " +
        /*String rankingSql1 = "SELECT count(1)+1 AS total FROM (SELECT " +
                " SUM(total) AS sum , " +
                " patient_id, " +
                " activity_id " +
                "FROM " +
                " 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);
@ -596,12 +606,13 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
                " SUM(total) AS sum , " +
                " patient_id, " +
                " activity_id " +
                "FROM " +
                " 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.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" ;
                "FROM  wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND  s.activity_id='"+activityId+"')" +
                " limit "+countTotal+",1" ;
        List<Map<String,Object>> rstotal9 = jdbcTemplate.queryForList(rankingSql9);
        Integer total = 0;
        if(rstotal9!=null&&rstotal9.size()>0){
@ -618,21 +629,24 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
        //总活动劵的排名
        String rankingSql2 = "SELECT count(1)+1 AS total FROM (SELECT " +
        /*String rankingSql2 = "SELECT count(1)+1 AS total FROM (SELECT " +
                " SUM(coupon_total) AS sum , " +
                " patient_id, " +
                " activity_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+"')" ;
                "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){
@ -642,13 +656,14 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
        String rankingSql10 = "SELECT btpd1.sum as total FROM (SELECT " +
                " SUM(coupon_total) AS sum , " +
                " patient_id, " +
                " activity_id " +
                " activity_id "+
                "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.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" ;
                "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;
        if(totalSql10!=null&&totalSql10.size()>0){
@ -662,47 +677,164 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
            total3 = Integer.parseInt(totalSql11.get(0).get("total").toString());
        }
        //活动劵
        //街道
        String rankingSql3  ="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)btpd1 WHERE  btpd1.patientId IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.street = '"+street+"')"+" ORDER BY btpd1.create_time ";
        List<TaskPatientDetailDO> patientDetailDOS2 = jdbcTemplate.query(rankingSql3,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
        long count3=0L;
        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS2){
            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime());
            String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " +
                    "and activity_goods_id in(select id from wlyy_health_bank_activity_goods where activity_id ='"+activityId+"')";
            List<ExchangeGoodsDO> exchangeGoodsDOS = jdbcTemplate.query(goodsSql,new BeanPropertyRowMapper<>(ExchangeGoodsDO.class));
            for (ExchangeGoodsDO exchangeGoodsDO :exchangeGoodsDOS){
                TaskGoodsDO taskGoodsDO = taskGoodsDao.selectById(exchangeGoodsDO.getActivityGoodsId());
                exchangeGoodsDO.setTaskGoodsDO(taskGoodsDO);
            }
            taskPatientDetailDO.setExchangeGoodsDO(exchangeGoodsDOS);
            taskPatientDetailDO.setTimeSeparated(timeSeparated);
            if (!taskPatientDetailDO.getPatientId().equals(patient)){
                count3+=1;
            }
        }
        //区排名
        String rankingSql4  ="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)btpd1 WHERE  btpd1.patientId IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.town = '"+town+"')"+" ORDER BY btpd1.create_time ";
        List<TaskPatientDetailDO> patientDetailDOS3 = jdbcTemplate.query(rankingSql4,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
        long count4=0L;
        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS3){
            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime());
            String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " +
                    "and activity_goods_id in(select id from wlyy_health_bank_activity_goods where activity_id ='"+activityId+"')";
            List<ExchangeGoodsDO> exchangeGoodsDOS = jdbcTemplate.query(goodsSql,new BeanPropertyRowMapper<>(ExchangeGoodsDO.class));
            for (ExchangeGoodsDO exchangeGoodsDO :exchangeGoodsDOS){
                TaskGoodsDO taskGoodsDO = taskGoodsDao.selectById(exchangeGoodsDO.getActivityGoodsId());
                exchangeGoodsDO.setTaskGoodsDO(taskGoodsDO);
            }
            taskPatientDetailDO.setExchangeGoodsDO(exchangeGoodsDOS);
            taskPatientDetailDO.setTimeSeparated(timeSeparated);
            if (!taskPatientDetailDO.getPatientId().equals(patient)){
                count4+=1;
            }
        }
        //活动劵排名
        //街道
        String rankingSql5  ="SELECT btpd1.patientId, btpd1.couponTotal, 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 )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 = 0l;
        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()+"' " +
                    "and activity_goods_id in(select id from wlyy_health_bank_activity_goods where activity_id ='"+activityId+"')";
            List<ExchangeGoodsDO> exchangeGoodsDOS = jdbcTemplate.query(goodsSql,new BeanPropertyRowMapper<>(ExchangeGoodsDO.class));
            for (ExchangeGoodsDO exchangeGoodsDO :exchangeGoodsDOS){
                TaskGoodsDO taskGoodsDO = taskGoodsDao.selectById(exchangeGoodsDO.getActivityGoodsId());
                exchangeGoodsDO.setTaskGoodsDO(taskGoodsDO);
            }
            if (taskPatientDetailDO.getPatientId().equals(taskPatientDetailDO.getPatientId())){
                count5+=1;
            }
            taskPatientDetailDO.setExchangeGoodsDO(exchangeGoodsDOS);
            taskPatientDetailDO.setTimeSeparated(timeSeparated);
        }
        //区排名
        String rankingSql6  ="SELECT btpd1.patientId, btpd1.couponTotal, 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 )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 = 0l;
        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()+"' " +
                    "and activity_goods_id in(select id from wlyy_health_bank_activity_goods where activity_id ='"+activityId+"')";
            List<ExchangeGoodsDO> exchangeGoodsDOS = jdbcTemplate.query(goodsSql,new BeanPropertyRowMapper<>(ExchangeGoodsDO.class));
            for (ExchangeGoodsDO exchangeGoodsDO :exchangeGoodsDOS){
                TaskGoodsDO taskGoodsDO = taskGoodsDao.selectById(exchangeGoodsDO.getActivityGoodsId());
                exchangeGoodsDO.setTaskGoodsDO(taskGoodsDO);
            }
            if (taskPatientDetailDO.getPatientId().equals(taskPatientDetailDO.getPatientId())){
                count6+=1;
            }
            taskPatientDetailDO.setExchangeGoodsDO(exchangeGoodsDOS);
            taskPatientDetailDO.setTimeSeparated(timeSeparated);
        }
        //街道排名
        String rankingSql3 = "SELECT count(1)+1 AS total FROM (SELECT " +
       /* String rankingSql3 = "SELECT count(1)+1 AS total FROM (SELECT " +
                " SUM(btpd.coupon_total) AS sum , " +
                " btpd.patient_id, " +
                " btpd.activity_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 " +
       /* String rankingSql4 = "SELECT count(1)+1 AS total FROM (SELECT " +
                " SUM(btpd.coupon_total) AS sum , " +
                " btpd.patient_id, " +
                " btpd.activity_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 " +
        /*String rankingSql5 = "SELECT count(1)+1 AS total FROM (SELECT " +
                " SUM(btpd.total) AS sum , " +
                " btpd.patient_id, " +
                " btpd.activity_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;
@ -713,31 +845,36 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
        String rankingSql6 = "SELECT count(1)+1 AS total FROM (SELECT " +
                " SUM(btpd.total) AS sum , " +
                " btpd.patient_id, " +
                " btpd.activity_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.total) AS sum , " +
                " btpd.patient_id, " +
                " btpd.activity_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 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+"')"+
                " 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>> rstotal7 = jdbcTemplate.queryForList(rankingSql7);
        Long count7 = 0L;
@ -749,12 +886,15 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
        String rankingSql8 = "SELECT count(1)+1 AS total FROM (SELECT " +
                " SUM(btpd.total) AS sum , " +
                " btpd.patient_id, " +
                " btpd.activity_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 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+"')" +
                " 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>> rstotal8 = jdbcTemplate.queryForList(rankingSql8);
        Long count8 = 0L;
@ -812,13 +952,12 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
            count6= (Long) rstotal6.get(0).get("total");
        }*/
        ActivityRuleDO activityRuleDO = activityRuleDao.selectByActivityId(activityId);
        JSONObject object = JSONObject.parseObject(activityRuleDO.getValue1());
        Integer type = object.getInteger("type");
        if (type == 2){
            jsonObject.put("activityTownCouponRanking",count4);//活动劵全区排名
            jsonObject.put("activityStreetCouponRanking",count3);//活动劵街道排名
            jsonObject.put("activityTownCouponRanking",count6);//活动劵全区排名
            jsonObject.put("activityStreetCouponRanking",count5);//活动劵街道排名
            jsonObject.put("activityCouponRanking",count2);//活动劵的排名
            jsonObject.put("couponTotal",taskPatientDetailDO1.getCouponTotal());//本人活动劵总数
            jsonObject.put("couponRanking",patientDetailDOS1);//活动劵人数排名
@ -830,9 +969,9 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
            }
        }else if (type ==1){
            jsonObject.put("IntegrateRanking",patientDetailDOS);
            jsonObject.put("activityStreetIntegrateRanking",count5);//积分街道排名
            jsonObject.put("activityStreetIntegrateRanking",count3);//积分街道排名
            jsonObject.put("total",taskPatientDetailDO1.getTotal());//本人总积分
            jsonObject.put("activityTownIntegrateRanking",count6);//积分全区排名
            jsonObject.put("activityTownIntegrateRanking",count4);//积分全区排名
            jsonObject.put("activityRanking",count);//积分排名
            jsonObject.put("signRanking",count8);//积分团队排名
            if (count==1){

+ 9 - 2
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/CreditsDetailService.java

@ -59,6 +59,10 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
    private ActiveRecordService activeRecordService;
    @Autowired
    private ActivityRuleDao activityRuleDao;
    @Autowired
    private ExchangeGoodsDao exchangeGoodsDao;
    @Autowired
    private TaskGoodsDao taskGoodsDao;
   /**
     *  find creditsLogInfo
@ -73,6 +77,11 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
            if (creditsDetailDO1.getTradeType() != null && creditsDetailDO1.getTradeType().equalsIgnoreCase("ACTIVITY_TASK")){
                TaskDO taskDO = taskDao.findOne(creditsDetailDO1.getTransactionId());
                creditsDetailDO1.setTaskDO(taskDO);
            }else if (creditsDetailDO1.getTradeType()!=null&&creditsDetailDO1.getTradeType().equals("EXCHANGE_GOODS")){
                ExchangeGoodsDO exchangeGoodsDO =exchangeGoodsDao.findOne(creditsDetailDO1.getTransactionId());
                TaskGoodsDO taskGoodsDO = taskGoodsDao.selectById(exchangeGoodsDO.getActivityGoodsId());
                exchangeGoodsDO.setTaskGoodsDO(taskGoodsDO);
                creditsDetailDO1.setExchangeGoodsDO(exchangeGoodsDO);
            }
        }
        String sqlcount = new ISqlUtils().getSql(creditsDetailDO,0,0,"count");
@ -787,7 +796,6 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                    List<AccountDO> accountDOS = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                    creditsDetailDO.setAccountId(accountDOS.get(0).getId());
                }
                TaskDO taskDO = taskDao.findOne(creditsDetailDO.getTransactionId());
                String sql1 = "select *  from wlyy_health_bank_task_patient_detail where "+
                        " patient_idcard = '"+creditsDetailDO.getIdCard()+"' AND union_id = '"+creditsDetailDO.getUnionId()+"' AND task_id = '"+creditsDetailDO.getTransactionId()+"'";
                List<TaskPatientDetailDO> taskPatientDetailDOList = jdbcTemplate.query(sql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
@ -812,7 +820,6 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                        int integrate = jsonObject.getInteger("integrate");
                        if (creditsDetailDOS != null && creditsDetailDOS.size() != 0){
                            CreditsDetailDO creditsDetailDO1 = creditsDetailDOS.get(0);
                            TaskRuleDO taskRuleDO = taskRuleDao.findOne(taskDO.getRuleCode());
                            if (creditsDetailDO.getStepNumber()>0 && creditsDetailDO.getStepNumber()<=step){
                                int integrate1=creditsDetailDO1.getIntegrate();
                                creditsDetailDO1.setIntegrate(creditsDetailDO.getIntegrate());

+ 6 - 4
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ExchangeGoodsService.java

@ -70,19 +70,19 @@ public class ExchangeGoodsService extends BaseJpaService<ExchangeGoodsDO,Exchang
               taskPatientDetailDO.setCouponTotal(taskPatientDetailDO.getCouponTotal() - exchangeGoodsDO.getCoupon());
           }
       }
       if (exchangeGoodsDO.getCoupon() == null){
       /*if (exchangeGoodsDO.getCoupon() == null){
           if (accountDO.getTotal() == null ){
               throw new Exception("积分余额不足!");
           }else {
               accountDO.setTotal(accountDO.getTotal()-exchangeGoodsDO.getIntegrate());
           }
       }else if (exchangeGoodsDO.getIntegrate() == null){
           if (accountDO.getTotal() == null){
           if (accountDO.getCouponTotal() == null){
               throw new Exception("活动劵余额不足!");
           }else {
               accountDO.setCouponTotal(accountDO.getCouponTotal()-exchangeGoodsDO.getCoupon());
           }
       }
       }*/
       exchangeGoodsDO.setCreateTime(new Date());
       exchangeGoodsDO.setUpdateTime(new Date());
       exchangeGoodsDO.setSaasId("dev");
@ -102,9 +102,11 @@ public class ExchangeGoodsService extends BaseJpaService<ExchangeGoodsDO,Exchang
       creditsDetailDO.setHospitalName(exchangeGoodsDO.getHospitalName());
       creditsDetailDO.setTransactionId(exchangeGoodsDO.getId());
       creditsDetailDO.setPatientId(exchangeGoodsDO.getPatientId());
       creditsDetailDO.setCreateTime(new Date());
       creditsDetailDO.setUpdateTime(new Date());
       credittsLogDetailDao.save(creditsDetailDO);
       taskPatientDetailDao.save(taskPatientDetailDO);
       accountDao.save(accountDO);
       /*accountDao.save(accountDO);*/
       return envelop;
    }