| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | 
							- <?php
 
- /**
 
-  * DayPayModel.php UTF-8
 
-  *
 
-  *
 
-  * @date    : 2017/12/18 11:41
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : liguanglong <lgl@huosdk.com>
 
-  * @version : HUOSDK 8.0
 
-  */
 
- namespace huo\model\data;
 
- use huo\model\user\UserModel;
 
- class DayAgentModel extends DayBaseModel {
 
-     protected $table = 'dw_day_agent';
 
-     public $map  = [];
 
-     public function agent() {
 
-         return $this->belongsTo('huo\model\user\UserModel', 'agent_id', 'id')
 
-                     ->field('id,user_login,user_nicename,role_id,parent_id');
 
-     }
 
-     public function mpagent() {
 
-         return $this->belongsTo(UserModel::className(), 'agent_id', 'id')->setEagerlyType(0);
 
-     }
 
-     /**
 
-      * 根据日期获取
 
-      *
 
-      * @param string $field      字段,包括别名
 
-      * @param string $start_date 开始日期
 
-      * @param string $end_date   结束日期
 
-      *
 
-      * @param string $alias      别名
 
-      *
 
-      * @return array
 
-      */
 
-     public function getByDate($field, $start_date, $end_date, $alias = null) {
 
-         $alias or $alias = $field;
 
-         $_map = $this->map;
 
-         $_rows = $this->where($_map)->whereBetween('date', [$start_date, $end_date])
 
-                       ->field("date, $field")
 
-                       ->select()->toArray();
 
-         $_data = [];
 
-         foreach ($_rows as $_row) {
 
-             $_data[$_row['date']] = $_row[$alias];
 
-         }
 
-         $result = [];
 
-         for ($_i = strtotime($start_date); $_i <= strtotime($end_date); $_i += 24 * 3600) {
 
-             $_key = date('Y-m-d', $_i);
 
-             $result[date('m-d', $_i)] = isset($_data[$_key]) ? doubleval($_data[$_key]) : 0;
 
-         }
 
-         return $result;
 
-     }
 
- }
 
 
  |