50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
/*
|
|
* @Descripttion:
|
|
* @version:
|
|
* @Author: kangkang
|
|
* @Date: 2020-10-16 14:44:02
|
|
* @LastEditors: kangkang
|
|
* @LastEditTime: 2020-11-18 19:34:22
|
|
*/
|
|
|
|
namespace app\manager\model;
|
|
|
|
use fastphp\base\Model;
|
|
|
|
class UserScore extends Model
|
|
{
|
|
protected $table = 'user_score';
|
|
|
|
/**
|
|
* @description: 获取用户所有的消费记录
|
|
* @param {*}
|
|
* @return {*}
|
|
*/
|
|
public function getUserCost($user_id, $index)
|
|
{
|
|
$where = [];
|
|
$wheres = [];
|
|
switch($index){
|
|
case 2:
|
|
$last_month = date("Y-m-01 H:i:s", strtotime("-1 month"));
|
|
$new_month = date("Y-m-t H:i:s", strtotime("-1 month"));
|
|
$where['UpdateTime'] = ['<',$new_month];
|
|
$wheres['UpdateTime'] = ['>',$last_month];
|
|
break;
|
|
case 3:
|
|
$last_month = date("Y-m-01 H:i:s", time());
|
|
$new_month = date("Y-m-d H:i:s", time());
|
|
$where['UpdateTime'] = ['<',$new_month];
|
|
$wheres['UpdateTime'] = ['>',$last_month];
|
|
break;
|
|
}
|
|
return $this->field('ScoreTypeName,ScoreValue,RestAmount1,RestAmount2,UpdateTime')
|
|
->where(['UserId' => $user_id])
|
|
->where($where)
|
|
->where($wheres)
|
|
->order('Id desc')
|
|
->fetchAll();
|
|
}
|
|
}
|