You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.2 KiB

<?php
namespace app\money\controller\admin;
use app\mall\model\MallOrder;
use app\money\model\MoneyCard;
use app\money\model\MoneyConfig;
use app\money\model\MoneyOrder;
use think\App;
use think\facade\View;
class Money extends Base
{
/**
* 余额设置
* @return string|\think\response\Json
*/
public function config()
{
$money_config_model = new MoneyConfig();
if (request()->isPost()) {
$data = input('post.');
$data['uid'] = UID;
$res = $money_config_model->dataUpdate($data);
if (!$res) {
return sendErrorMessage();
}
return sendSuccessMessage();
} else {
$data = $money_config_model->getOneData(['uid' => UID]);
View::assign('data', $data);
return View::fetch();
}
}
/**
* 充值卡额列表
* @return string
*/
public function card()
{
$where = [
'uid' => UID
];
$money_card_model = new MoneyCard();
$dataList = $money_card_model->getAllData($where, '*', 'sort desc');
View::assign('dataList', $dataList);
return View::fetch();
}
/**
* 添加充值卡
* @return string
*/
public function cardadd()
{
$money_card_model = new MoneyCard();
if (request()->isPost()) {
$data = input('post.');
$data['uid'] = UID;
$res = $money_card_model->dataUpdate($data);
if (!$res) {
return sendErrorMessage();
}
return sendSuccessMessage();
} else {
$id = input('param.id', 0);
$data = $money_card_model->getOneData(['id' => $id]);
View::assign('data', $data);
return View::fetch('cardadd');
}
}
/**
* 充值卡修改
* @return array|mixed|string
*/
public function cardUpdate()
{
return $this->cardadd();
}
/**
* 充值订单列表
* @return string
*/
public function order()
{
$search = input('get.');
autoSearch(['time', 'keyword', 'is_pay'], $search);
View::assign('search', $search);
$where = [
['uid','=', UID],
];
if ($search['time']) {
$time = explode('-', $search['time']);
$where[] = ['create_time', 'between time', [$time[0], $time[1]]];
}
if ($search['keyword'] !== null && $search['keyword'] !== '') {
$where[] = ['order_number','like', '%' . $search['keyword'] . '%'];
}
if ($search['is_pay'] !== '' && $search['is_pay'] !== null) {
$where[] = ['is_pay','=',$search['is_pay']];
}
$money_order_model = new MoneyOrder();
$dataList = $money_order_model
->with('userInfo')
->where($where)
->order('id desc')
->paginate(['page' => array_key_exists("page", $search) ? (string)$search['page'] : "1", 'list_rows' => 10, 'query' => $search], false)
->each(function ($item) {
return $item;
});
View::assign('dataList', $dataList);
return View::fetch();
}
}