<?php
/**
*------Create thems Model------
*------SCWPHP  Version 1.0.0------
*------Dev Model Jions------
*------Create Time 2019-04-15 16:05:26------
*/
namespace App\Commons\Model;

use \System\Model;

class Money_prize extends Model {

    // 对象表
    protected $table = 'money_prize';
    public $timestamps = false;

    /**
     * 中奖记录
     *
     * @access public
     * @param mixed $prizeRecordWhere 查询条件
     * @param mixed $prizeRecordBetween 查询条件区间
     * @param mixed $begin 起始查询位置
     * @param mixed $pageSize 分页大小
     * @param mixed $orderBy 排序字段
     * @return array JsonString
     */
    public function prizeRecord($prizeRecordWhere, $prizeRecordBetween, $begin, $pageSize, $orderBy = 'money_time') {
        $result = $this
            //-> join('article','money_prize.info_identity','=','article.identity')
            -> where($prizeRecordWhere)
            -> whereBetween('money_time', $prizeRecordBetween)
            -> offset($begin)
            -> limit($pageSize)
            -> orderBy($orderBy)
            -> get();

        return $result;
    }

    /**
     * 中奖记录总数
     *
     * @access public
     * @param mixed $prizeRecordWhere 查询条件
     * @param mixed $prizeRecordBetween 查询条件区间
     * @return array JsonString
     */
    public function prizeRecordTotal($prizeRecordWhere, $prizeRecordBetween) {
        $result = $this
            -> where($prizeRecordWhere)
            -> whereBetween('money_time', $prizeRecordBetween)
            -> count();

        return $result;
    }
}
