84 lines
2.6 KiB
PHP
84 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\common\controller\Backend;
|
|
use app\common\library\DatabaseRoute;
|
|
use think\facade\Db;
|
|
|
|
class UserPrizeExchange extends Backend
|
|
{
|
|
protected array $noNeedLogin = ['*'];
|
|
protected array $noNeedPermission = ['statisticsIncomeMoney', 'statisticsCashMoney'];
|
|
|
|
|
|
public function page()
|
|
{
|
|
$params = $this->request->param();
|
|
$this->successWithData(DatabaseRoute::paginateDb('user_prize_exchange', function ($query) use ($params) {
|
|
if (!empty($params['foreignId'])) {
|
|
$query->where('foreign_id', $params['foreignId']);
|
|
}
|
|
if (!empty($params['foreignType'])) {
|
|
$query->where('foreign_type', $params['foreignType']);
|
|
}
|
|
if (!empty($params['userId'])) {
|
|
$query->where('user_id', $params['userId']);
|
|
}
|
|
if (!empty($params['userName'])) {
|
|
$query->where('user_name', 'like', "%". $params['userName']."%");
|
|
}
|
|
if (!empty($params['prizeName'])) {
|
|
$query->where('prize_name', 'like', "%" . $params['prizeName'] . "%");
|
|
}
|
|
if (!empty($params['status'])) {
|
|
$query->where('status', $params['status']);
|
|
}
|
|
if (!empty($params['phone'])) {
|
|
$query->where('phone', 'like', "%". $params['phone'] ."%");
|
|
}
|
|
if (!empty($params['remark'])) {
|
|
$query->where('remark', 'like', "%" . $params['remark'] . "%");
|
|
}
|
|
|
|
if (!empty($params['beginDate'])) {
|
|
$query->where('create_time', '>=', $params['beginDate'] . ' 00:00:00');
|
|
}
|
|
if (!empty($params['endDate'])) {
|
|
$query->where('create_time', '<=', $params['endDate'] . ' 23:59:59');
|
|
}
|
|
$query->order('id', false);
|
|
}));
|
|
}
|
|
|
|
public function deliver()
|
|
{
|
|
$params = $this->request->post();
|
|
if (empty($params['id'])) {
|
|
$this->error('兑奖id不能为空');
|
|
}
|
|
|
|
$info = Db::name('user_prize_exchange')->where([
|
|
'id' => $params['id']
|
|
])->find();
|
|
if (!$info) {
|
|
$this->error('兑奖订单不存在');
|
|
}
|
|
|
|
Db::name('user_prize_exchange')->where([
|
|
'id' => $params['id']
|
|
])->update([
|
|
'status' => 1,
|
|
'address' => $params['address'] ?? '',
|
|
'remark' => $params['remark'] ?? '',
|
|
'update_time' => getNormalDate()
|
|
]);
|
|
|
|
$this->success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} |