__('Money'), 'score' => __('Score')]; } public function getTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['type']) ? $data['type'] : ''); $list = $this->getTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function sumByMassagerAndThisMonth($m_id) { $sum = $this->query(" SELECT SUM( `CHANGE` ) AS tp_sum FROM `ma_massager_bill` WHERE ( DATE_FORMAT( FROM_UNIXTIME( createtime ), '%Y-%m' ) = date_format( now(), '%Y-%m' ) ) AND `massager_id` = {$m_id} AND `currency_type` = 'score' LIMIT 1 "); return fixed2Float($sum[0]["tp_sum"]); } function fetchBill($m_id, $currency_type, $change_types, $page = 1, $size = 10) { $query = $this->where([ "massager_id" => $m_id, "currency_type" => $currency_type ]); if (!in_array("*", $change_types)) { $query->where("change_type", "in", $change_types); } return $query->order("createtime", "desc") ->page($page) ->paginate($size); } }