|
|
|
@ -2,6 +2,9 @@ |
|
|
|
namespace app\controller; |
|
|
|
|
|
|
|
use app\BaseController; |
|
|
|
use app\model\AwardsRecords; |
|
|
|
use app\model\User as UserModel; |
|
|
|
use think\facade\Request; |
|
|
|
|
|
|
|
class Index extends BaseController |
|
|
|
{ |
|
|
|
@ -14,4 +17,37 @@ class Index extends BaseController |
|
|
|
{ |
|
|
|
return 'hello,' . $name; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取首页中间记录 |
|
|
|
* @return array |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
*/ |
|
|
|
public function awardRecords() |
|
|
|
{ |
|
|
|
|
|
|
|
$data = Request::param(); |
|
|
|
|
|
|
|
$limit = $data['limit'] ?: 10; |
|
|
|
|
|
|
|
$records = new AwardsRecords(); |
|
|
|
|
|
|
|
$list = $records->field('user_id,awards_amount')->order('create_time desc')->paginate($limit); |
|
|
|
|
|
|
|
$data = $list->toArray()['data']; |
|
|
|
|
|
|
|
foreach ($data as &$item) { |
|
|
|
$item['user_id'] .= "XX"; |
|
|
|
$user = UserModel::field('phone')->find($item['user_id']); |
|
|
|
$item['phone'] = format_phone_number($user['phone']); |
|
|
|
$item['awards_amount'] = number_format($item['awards_amount']); |
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderSuccess('数据返回成功',[ |
|
|
|
'list' => $data, |
|
|
|
'total' => $list->total() |
|
|
|
]); |
|
|
|
} |
|
|
|
} |
|
|
|
|