微信后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
3.6 KiB

/*
* *
* * @Project 微信公众号
* * @Author 张剑峰
* * @Date 2021/1/12 下午10:20
* * @Description
* * @Version v1.0.0
* * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
*
*/
package com.ynxbd.common.dao;
import com.ynxbd.common.bean.Accounts;
import com.ynxbd.common.config.db.DataBase;
import java.util.List;
public class AccountsDao {
public List<Accounts> getAccounts(String begDate, String endDate) {
String sql = "select * from(\n" +
"select CONCAT(date_format(updatetime,'%Y%m%d'), '1') as no, date_format(updatetime,'%Y-%m-%d') as date, " +
"count(*) as 'count' , sum(paymoney) as 'sumMoney', '挂号合计' as description from register " +
"where paystatus = 0 and hisstatus = 0 and updatetime BETWEEN '" + begDate + "' and DATE_ADD('" + endDate + "',INTERVAL 1 DAY)\n" +
"group by date_format(updatetime,'%Y-%m-%d') \n" +
"union all\n" +
"select CONCAT(date_format(updatetime,'%Y%m%d'), '2') as no, date_format(updatetime,'%Y-%m-%d') as date , " +
"count(*) as 'count', sum(paymoney) as 'sumMoney', '预约挂号' as description from register " +
"where paystatus = 0 and hisstatus = 0 and (RegType = 0 or updatetime < regdate) and updatetime BETWEEN '" + begDate + "' and DATE_ADD('" + endDate + "',INTERVAL 1 DAY)\n" +
"group by date_format(updatetime,'%Y-%m-%d')\n" +
"union all\n" +
"select CONCAT(date_format(updatetime,'%Y%m%d'), '3') as no, date_format(updatetime,'%Y-%m-%d') as date, " +
"count(*) as 'count' , sum(paymoney) as 'sumMoney', '现场挂号' as description from register " +
"where paystatus = 0 and hisstatus = 0 and (RegType = 1 or updatetime >= regdate) and updatetime BETWEEN '" + begDate + "' and DATE_ADD('" + endDate + "',INTERVAL 1 DAY)\n" +
"group by date_format(updatetime,'%Y-%m-%d') \n" +
"union all\n" +
"select CONCAT(date_format(updatetime,'%Y%m%d'), '4') as no, date_format(updatetime,'%Y-%m-%d') as date, " +
"count(*) as 'count' , sum(paymoney) as 'sumMoney', '诊间支付合计' as description from pay " +
"where paystatus = 0 and updatetime BETWEEN '" + begDate + "' and DATE_ADD('" + endDate + "',INTERVAL 1 DAY)\n" +
"group by date_format(updatetime,'%Y-%m-%d') \n" +
"union all\n" +
"select CONCAT(date_format(updatetime,'%Y%m%d'), '5') as no, date_format(updatetime,'%Y-%m-%d') as date, " +
"count(*) as 'count' , sum(paymoney) as 'sumMoney', '扫码支付' as description from pay " +
"where paystatus = 0 and payway = 1 and updatetime BETWEEN '" + begDate + "' and DATE_ADD('" + endDate + "',INTERVAL 1 DAY) \n" +
"group by date_format(updatetime,'%Y-%m-%d') \n" +
"union all\n" +
"select CONCAT(date_format(updatetime,'%Y%m%d'), '6') as no, date_format(updatetime,'%Y-%m-%d') as date, " +
"count(*) as 'count' , sum(paymoney) as 'sumMoney', '公众号内支付' as description from pay " +
"where paystatus = 0 and payway = 0 and updatetime BETWEEN '" + begDate + "' and DATE_ADD('" + endDate + "',INTERVAL 1 DAY)\n" +
"group by date_format(updatetime,'%Y-%m-%d') \n" +
") t\n" +
"order by t.date desc, no";
return DataBase.select(sql, Accounts.class);
}
}