// +---------------------------------------------------------------------- declare (strict_types = 1); namespace app\store\model; use app\common\model\StoreDailySalesSt as StoreStModel; /** * 门店销售数据每日统计模型 * Class ShopsDailySalesSt * @package app\common\model */ class StoreDailySalesSt extends StoreStModel { /** * 商城销售额按天统计 * @param $from * @param $to * @return StoreDailySalesSt[]|array|\think\Collection * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function listAMonthSt($from,$to){ return self::where('st_time','between',[$from,$to]) ->field('sale_volume,order_count,st_time,st_month,right(st_month,2) as int_month,right(st_time,2) as st_day') ->order('st_time asc')->select(); } /** * 商城销售额按月统计 * @param $from * @param $to * @return mixed */ public function listTwoMonthSt($from,$to){ return self::where('st_time','between',[$from,$to]) ->field('sum(sale_volume) as sale_volume,right(st_month,2) as int_month,left(st_month,4) as st_year') ->group('st_month') ->order('st_month asc')->select(); } }