FastMovieAI 二开基线 v1.0 (完整源码)
This commit is contained in:
@@ -0,0 +1,439 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\finance\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\DataboardBuilder;
|
||||
use app\expose\build\builder\databoardBuilder\component\Echarts;
|
||||
use app\expose\build\builder\databoardBuilder\component\Statistic;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use app\expose\enum\Week;
|
||||
use plugin\finance\app\model\PluginFinanceOrders;
|
||||
use plugin\finance\utils\enum\OrdersState;
|
||||
use support\Cache;
|
||||
use support\Request;
|
||||
|
||||
class IndexController extends Basic
|
||||
{
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder();
|
||||
$builder->addAction('操作', [
|
||||
'width' => '200px',
|
||||
'fixed' => 'right'
|
||||
]);
|
||||
$builder->addTableAction('编辑', [
|
||||
'path' => 'Control/update',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
'title' => '编辑《{nickname}》管理员'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addTableAction('删除', [
|
||||
'model' => Action::COMFIRM['value'],
|
||||
'path' => 'Control/delete',
|
||||
'where' => [
|
||||
['is_system', '!=', 1]
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'error',
|
||||
'message' => '确定要删除《{nickname}》管理员吗?',
|
||||
'confirmButtonClass' => 'el-button--danger'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'danger',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addHeader();
|
||||
$builder->addHeaderAction('创建管理员', [
|
||||
'path' => 'Control/create',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'title' => '创建管理员'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'success'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$formBuilder = new FormBuilder();
|
||||
$formBuilder->add('username', '账号', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '账号搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('mobile', '手机号', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '手机号搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '80px'
|
||||
]
|
||||
]);
|
||||
$builder->add('userinfo', '管理员', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'nickname',
|
||||
'avatar' => 'headimg',
|
||||
'info' => 'username',
|
||||
'nicknameTags' => [
|
||||
[
|
||||
'field' => 'new_text',
|
||||
'props' => [
|
||||
'type' => 'danger',
|
||||
'size' => 'small'
|
||||
]
|
||||
],
|
||||
[
|
||||
'field' => 'new_text1',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'role_name',
|
||||
'props' => [
|
||||
'type' => 'success'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('contact', '联系方式', [
|
||||
'props' => [
|
||||
'width' => '280px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'mobile',
|
||||
'label' => '手机号'
|
||||
],
|
||||
[
|
||||
'field' => 'email',
|
||||
'label' => '邮箱'
|
||||
],
|
||||
[
|
||||
'field' => 'wx_openid',
|
||||
'label' => 'OpenID'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('allow_week', '工作日', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => Week::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '240px'
|
||||
]
|
||||
]);
|
||||
$builder->add('allow_work', '工作时间', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => [
|
||||
[
|
||||
'index' => 0,
|
||||
'props' => [
|
||||
'type' => 'success'
|
||||
]
|
||||
],
|
||||
[
|
||||
'index' => 1,
|
||||
'props' => [
|
||||
'type' => 'danger'
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('online_time', '活动', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'online_time',
|
||||
'label' => '在线'
|
||||
],
|
||||
[
|
||||
'field' => 'login_time',
|
||||
'label' => '登录'
|
||||
],
|
||||
[
|
||||
'component' => 'tag',
|
||||
'field' => 'login_ip',
|
||||
'label' => '登录IP',
|
||||
'props' => [
|
||||
'size' => 'small',
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'switch',
|
||||
'api' => 'Control/indexUpdateState',
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$builder = new DataboardBuilder([
|
||||
'gutter' => 6
|
||||
]);
|
||||
|
||||
// 今日支付订单数
|
||||
$today = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->whereDay('create_time')->count();
|
||||
$yesterday = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->whereDay('create_time', 'yesterday')->count();
|
||||
$statistic = new Statistic;
|
||||
$statistic->setLabel('今日支付订单数')
|
||||
->setUnit('笔')
|
||||
->setData([
|
||||
'today' => $today,
|
||||
'yesterday' => $yesterday,
|
||||
'growth_rate' => $yesterday ? round(($today - $yesterday) / $yesterday * 100, 2) : 0
|
||||
])
|
||||
->setClass('p-6');
|
||||
$builder->add($statistic, [
|
||||
'xs' => 24,
|
||||
'sm' => 12,
|
||||
'md' => 6,
|
||||
'lg' => 4,
|
||||
'class' => 'bg-white p-4 rounded-4 shadow-lighter'
|
||||
]);
|
||||
|
||||
// 今日支付金额
|
||||
$today = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->whereDay('create_time')->sum('money');
|
||||
$yesterday = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->whereDay('create_time', 'yesterday')->sum('money');
|
||||
$statistic = new Statistic;
|
||||
$statistic->setLabel('今日支付金额')
|
||||
->setUnit('元')
|
||||
->setData([
|
||||
'today' => $today,
|
||||
'yesterday' => $yesterday,
|
||||
'growth_rate' => $yesterday ? round(($today - $yesterday) / $yesterday * 100, 2) : 0
|
||||
])
|
||||
->setClass('p-6');
|
||||
$builder->add($statistic, [
|
||||
'xs' => 24,
|
||||
'sm' => 12,
|
||||
'md' => 6,
|
||||
'lg' => 4,
|
||||
'class' => 'bg-white p-4 rounded-4 shadow-lighter'
|
||||
]);
|
||||
|
||||
// 总订单数
|
||||
$total = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->count();
|
||||
$lastMonthTotal = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->whereMonth('create_time', '-1 month')->count();
|
||||
$statistic = new Statistic;
|
||||
$statistic->setLabel('总订单数')
|
||||
->setUnit('笔')
|
||||
->setData([
|
||||
'today' => $total,
|
||||
'yesterday' => $lastMonthTotal,
|
||||
'growth_rate' => $lastMonthTotal ? round(($total - $lastMonthTotal) / $lastMonthTotal * 100, 2) : 0
|
||||
])
|
||||
->setClass('p-6');
|
||||
$builder->add($statistic, [
|
||||
'xs' => 24,
|
||||
'sm' => 12,
|
||||
'md' => 6,
|
||||
'lg' => 4,
|
||||
'class' => 'bg-white p-4 rounded-4 shadow-lighter'
|
||||
]);
|
||||
|
||||
// 当月订单数
|
||||
$month = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->whereMonth('create_time')->count();
|
||||
$lastMonth = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->whereMonth('create_time', '-1 month')->count();
|
||||
$statistic = new Statistic;
|
||||
$statistic->setLabel('当月订单数')
|
||||
->setUnit('笔')
|
||||
->setData([
|
||||
'today' => $month,
|
||||
'yesterday' => $lastMonth,
|
||||
'growth_rate' => $lastMonth ? round(($month - $lastMonth) / $lastMonth * 100, 2) : 0
|
||||
])
|
||||
->setClass('p-6');
|
||||
$builder->add($statistic, [
|
||||
'xs' => 24,
|
||||
'sm' => 12,
|
||||
'md' => 6,
|
||||
'lg' => 4,
|
||||
'class' => 'bg-white p-4 rounded-4 shadow-lighter'
|
||||
]);
|
||||
|
||||
// 添加图表
|
||||
$this->echarts($builder, $request);
|
||||
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加图表组件
|
||||
* @param DataboardBuilder $builder
|
||||
* @param Request $request
|
||||
*/
|
||||
private function echarts(DataboardBuilder $builder, Request $request)
|
||||
{
|
||||
$endTime = strtotime('23:59:59', time()) - time();
|
||||
$echarts = new Echarts;
|
||||
$echarts->setClass('bg-white p-4 rounded-4 shadow-lighter vh-65');
|
||||
$EchartsData = Cache::get('finance_echarts_data_' . $request->channels_uid);
|
||||
if (!$EchartsData) {
|
||||
$EchartsData = $this->getEchartsData($request);
|
||||
Cache::set('finance_echarts_data_' . $request->channels_uid, $EchartsData, $endTime);
|
||||
}
|
||||
$echarts->setData($EchartsData);
|
||||
$builder->add($echarts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图表数据
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
private function getEchartsData(Request $request)
|
||||
{
|
||||
$data = [
|
||||
'color' => ['#80FFA5', '#00DDFF', '#37A2FF', '#FF0087', '#FFBF00'],
|
||||
'title' => [
|
||||
'text' => '订单数据可视化'
|
||||
],
|
||||
'tooltip' => [
|
||||
'trigger' => 'axis',
|
||||
'axisPointer' => [
|
||||
'type' => 'cross',
|
||||
'label' => [
|
||||
'backgroundColor' => '#6a7985'
|
||||
]
|
||||
]
|
||||
],
|
||||
'legend' => [
|
||||
'data' => ["订单数", "支付金额"]
|
||||
],
|
||||
'toolbox' => [
|
||||
'show' => false
|
||||
],
|
||||
'grid' => [
|
||||
'left' => '3%',
|
||||
'right' => '4%',
|
||||
'bottom' => '3%',
|
||||
'containLabel' => true
|
||||
],
|
||||
'xAxis' => [
|
||||
[
|
||||
'type' => 'category',
|
||||
'boundaryGap' => false,
|
||||
'data' => []
|
||||
]
|
||||
],
|
||||
'yAxis' => [
|
||||
[
|
||||
'type' => 'value'
|
||||
]
|
||||
],
|
||||
'series' => [
|
||||
[
|
||||
'name' => "订单数",
|
||||
'type' => 'line',
|
||||
'smooth' => true,
|
||||
'data' => []
|
||||
],
|
||||
[
|
||||
'name' => "支付金额",
|
||||
'type' => 'line',
|
||||
'smooth' => true,
|
||||
'data' => []
|
||||
]
|
||||
]
|
||||
];
|
||||
for ($i = 7; $i > 0; $i--) {
|
||||
$date = date('Y-m-d', strtotime("-$i day"));
|
||||
$data['xAxis'][0]['data'][] = $date;
|
||||
$Order = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->whereDay('create_time', $date)->count();
|
||||
if ($Order) {
|
||||
$data['series'][0]['data'][] = $Order;
|
||||
} else {
|
||||
$data['series'][0]['data'][] = 0;
|
||||
}
|
||||
$Payment = PluginFinanceOrders::where(['channels_uid' => $request->channels_uid])->whereIn('state', [OrdersState::PAID['value'], OrdersState::FINISH['value']])->whereDay('create_time', $date)->sum('money');
|
||||
if ($Payment) {
|
||||
$data['series'][1]['data'][] = $Payment;
|
||||
} else {
|
||||
$data['series'][1]['data'][] = 0;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,686 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\finance\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\EventName;
|
||||
use app\expose\enum\PaymentChannels;
|
||||
use app\expose\enum\PaymentCurrency;
|
||||
use app\expose\enum\State;
|
||||
use app\model\PaymentTemplate;
|
||||
use plugin\apps\app\model\PluginAppsPrice;
|
||||
use plugin\apps\app\model\PluginAppsSpecifications;
|
||||
use plugin\apps\utils\enum\PaymentMethod;
|
||||
use plugin\finance\app\model\PluginFinanceOrders;
|
||||
use plugin\finance\app\model\PluginFinanceOrdersLog;
|
||||
use plugin\finance\app\model\PluginFinanceWallet;
|
||||
use plugin\finance\utils\enum\OrdersState;
|
||||
use plugin\finance\utils\enum\OrdersType;
|
||||
use plugin\marketing\app\model\PluginMarketingCoupon;
|
||||
use plugin\marketing\app\model\PluginMarketingCouponCode;
|
||||
use plugin\user\app\model\PluginUser;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use think\facade\Db;
|
||||
use Webman\Event\Event;
|
||||
|
||||
class OrdersController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginFinanceOrders();
|
||||
}
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder();
|
||||
$builder->addAction('操作', [
|
||||
'width' => '160px',
|
||||
'fixed' => 'right'
|
||||
]);
|
||||
$builder->addTableAction('完成', [
|
||||
'model' => Action::COMFIRM['value'],
|
||||
'path' => '/app/finance/control/Orders/finish',
|
||||
'props' => [
|
||||
'title' => '完成《{title}》订单'
|
||||
],
|
||||
'where' => [
|
||||
['state', '=', OrdersState::PAID['value']]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addTableAction('实收', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/finance/control/Orders/real_money',
|
||||
'props' => [
|
||||
'title' => '实收《{title}》订单'
|
||||
],
|
||||
'where' => [
|
||||
['state', '=', OrdersState::WAIT_PAY['value']]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addTableAction('收付', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/finance/control/Orders/receipt_money',
|
||||
'props' => [
|
||||
'title' => '确认已收到《{title}》订单对公转账'
|
||||
],
|
||||
'where' => [
|
||||
['state', '=', OrdersState::WAIT_VERIFIED['value']]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('title', '订单标题', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '订单标题搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('trade_no', '订单号', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '订单号搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('state', '状态', 'select', null, [
|
||||
'options' => OrdersState::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '状态搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('type', '订单类型', 'select', null, [
|
||||
'options' => OrdersType::getOptions(),
|
||||
'props' => [
|
||||
'placeholder' => '订单类型搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('uid', '用户', 'select', null, [
|
||||
'options' => [],
|
||||
'remote' => [
|
||||
'url' => '/app/finance/control/Orders/queryUser',
|
||||
],
|
||||
'props' => [
|
||||
'placeholder' => '用户搜索',
|
||||
'clearable' => true,
|
||||
'filterable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('user_id', '用户ID', 'input', null, [
|
||||
'options' => [],
|
||||
'props' => [
|
||||
'placeholder' => '用户搜索',
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '80px'
|
||||
]
|
||||
]);
|
||||
$builder->add('order', '订单', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'title',
|
||||
'info' => 'trade_no',
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => OrdersState::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('type', '订单类型', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => OrdersType::getOptions()
|
||||
],
|
||||
'props' => [
|
||||
'width' => '140px'
|
||||
]
|
||||
]);
|
||||
$builder->add('statistic', '数据', [
|
||||
'component' => [
|
||||
'name' => 'statistic',
|
||||
'options' => [
|
||||
[
|
||||
'label' => '原价',
|
||||
'value' => 'origin_money'
|
||||
],
|
||||
[
|
||||
'label' => '实付',
|
||||
'value' => 'money'
|
||||
],
|
||||
[
|
||||
'label' => '数量',
|
||||
'value' => 'num'
|
||||
]
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'minWidth' => '380px'
|
||||
]
|
||||
]);
|
||||
$builder->add('coupon', '优惠券', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
],
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '220px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
],
|
||||
[
|
||||
'field' => 'pay_time',
|
||||
'label' => '支付'
|
||||
],
|
||||
[
|
||||
'field' => 'expire_time',
|
||||
'label' => '过期'
|
||||
],
|
||||
[
|
||||
'field' => 'finish_time',
|
||||
'label' => '完成'
|
||||
],
|
||||
[
|
||||
'field' => 'comment_time',
|
||||
'label' => '评价'
|
||||
],
|
||||
[
|
||||
'field' => 'cancel_time',
|
||||
'label' => '取消'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function queryUser(Request $request)
|
||||
{
|
||||
$query = $request->post('query');
|
||||
if (empty($query)) {
|
||||
return $this->resData([]);
|
||||
}
|
||||
$where = [];
|
||||
$where[] = ['nickname|mobile', 'like', "%{$query}%"];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
return $this->resData(PluginUser::options($where));
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
$title = $request->get('title');
|
||||
if ($title) {
|
||||
$where[] = ['title', 'like', "%{$title}%"];
|
||||
}
|
||||
$trade_no = $request->get('trade_no');
|
||||
if ($trade_no) {
|
||||
$where[] = ['trade_no', '=', $trade_no];
|
||||
}
|
||||
$state = $request->get('state');
|
||||
if ($state !== null) {
|
||||
$where[] = ['state', '=', $state];
|
||||
}
|
||||
$type = $request->get('type');
|
||||
if ($type !== null) {
|
||||
$where[] = ['type', '=', $type];
|
||||
}
|
||||
$uid = $request->get('uid');
|
||||
if ($uid) {
|
||||
$where[] = ['uid', '=', $uid];
|
||||
}
|
||||
$user_id = $request->get('user_id');
|
||||
if ($user_id) {
|
||||
$where[] = ['uid', '=', $user_id];
|
||||
}
|
||||
$list = PluginFinanceOrders::where($where)
|
||||
->with(['user' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile,channels_uid');
|
||||
}])
|
||||
->order('id desc')->paginate($limit)->each(function ($item) {});
|
||||
return $this->resData($list);
|
||||
}
|
||||
public function finish(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
try {
|
||||
PluginFinanceOrders::finish(['id' => $id, 'channels_uid' => $request->channels_uid]);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->exception($th);
|
||||
}
|
||||
return $this->success('完成订单成功');
|
||||
}
|
||||
public function real_money(Request $request)
|
||||
{
|
||||
if ($request->method() == 'POST') {
|
||||
$id = $request->post('id');
|
||||
$order = PluginFinanceOrders::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
|
||||
if (!$order) {
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
if ($order->state != OrdersState::WAIT_PAY['value']) {
|
||||
return $this->fail('订单状态不是待支付');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order->state = OrdersState::PAID['value'];
|
||||
$order->pay_type = PaymentChannels::ADMIN['value'];
|
||||
$order->pay_time = date('Y-m-d H:i:s');
|
||||
$order->system_money = $request->post('system_money');
|
||||
$order->money = $order->origin_money - $order->system_money - $order->channels_money - $order->developer_money;
|
||||
$order->save();
|
||||
PluginFinanceOrdersLog::info($order, '管理员操作实收成功');
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
PluginFinanceOrdersLog::fail($order, $th->getMessage());
|
||||
return $this->exception($th);
|
||||
}
|
||||
Event::emit(EventName::ORDERS_PAY['value'], [
|
||||
'data' => $order,
|
||||
'payment_channel' => PaymentChannels::ADMIN['value'],
|
||||
'plugin' => 'finance'
|
||||
]);
|
||||
try {
|
||||
PluginFinanceOrders::finish(['id' => $order->id, 'channels_uid' => $request->channels_uid]);
|
||||
} catch (\Throwable $th) {
|
||||
PluginFinanceOrdersLog::fail($order, $th->getMessage());
|
||||
Log::error("订单完成失败:{$order->trade_no},{$th->getMessage()},{$th->getFile()}:{$th->getLine()}", $th->getTrace());
|
||||
return $this->exception($th);
|
||||
}
|
||||
return $this->success('实收订单成功');
|
||||
}
|
||||
$id = $request->get('id');
|
||||
$order = PluginFinanceOrders::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
|
||||
if (!$order) {
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
if ($order->state != OrdersState::WAIT_PAY['value']) {
|
||||
return $this->fail('订单状态不是待支付');
|
||||
}
|
||||
$Component = new ComponentBuilder;
|
||||
$builder = new FormBuilder(null, null, [
|
||||
'translations' => true,
|
||||
'size' => 'large',
|
||||
]);
|
||||
$builder->add('title', '订单', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 12,
|
||||
'xl' => 12
|
||||
],
|
||||
]);
|
||||
$builder->add('trade_no', '订单号', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 12,
|
||||
'xl' => 12
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'info',
|
||||
'size' => 'small'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '下单时间', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 12,
|
||||
'xl' => 12
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'info',
|
||||
'size' => 'small'
|
||||
]
|
||||
]);
|
||||
$builder->add('expire_time', '过期时间', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 12,
|
||||
'xl' => 12
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'info',
|
||||
'size' => 'small'
|
||||
]
|
||||
]);
|
||||
$builder->add('settle_accounts_time', '结算日期', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
]);
|
||||
$builder->add('num', '数量', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
]);
|
||||
$builder->add('origin_money', '原价', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
]);
|
||||
$builder->add('unit_money', '单价', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
]);
|
||||
$builder->add('money', '应付', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'danger'
|
||||
]
|
||||
]);
|
||||
$maxSystemMoney = $order->money;
|
||||
$builder->add('system_money', '平台优惠金额', 'input-number', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'min' => 0,
|
||||
'max' => $maxSystemMoney,
|
||||
'step' => 0.01,
|
||||
'controls' => false
|
||||
],
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '最大可优惠金额:' . $maxSystemMoney . '元'], ['type' => 'danger', 'size' => 'small'])->builder(),
|
||||
],
|
||||
'children' => [
|
||||
'suffix' => [
|
||||
'component' => 'el-text',
|
||||
'props' => [
|
||||
'size' => 'small'
|
||||
],
|
||||
'children' => [
|
||||
'default' => '元'
|
||||
]
|
||||
],
|
||||
'prefix' => [
|
||||
'component' => 'el-text',
|
||||
'props' => [
|
||||
'size' => 'small'
|
||||
],
|
||||
'children' => [
|
||||
'default' => '¥'
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$formula = 'money - system_money';
|
||||
$builder->add('real_money', '实收金额', 'compute', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '请确认财务已收到款项'], ['type' => 'info', 'size' => 'small'])->builder(),
|
||||
$Component->add('text', ['default' => '实收后订单状态将变为:'], ['type' => 'info', 'size' => 'small'])->add('tag', ['default' => OrdersState::FINISH['label']], ['type' => OrdersState::FINISH['props']['type'], 'size' => 'small'])->builder(),
|
||||
],
|
||||
'props' => [
|
||||
'formula' => $formula,
|
||||
'type' => 'danger',
|
||||
'size' => 'large',
|
||||
'tag' => 'b'
|
||||
]
|
||||
]);
|
||||
$builder->setData($order->toArray());
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function receipt_money(Request $request)
|
||||
{
|
||||
if ($request->method() == 'POST') {
|
||||
$id = $request->post('id');
|
||||
$order = PluginFinanceOrders::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
|
||||
if (!$order) {
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
if ($order->state != OrdersState::WAIT_VERIFIED['value']) {
|
||||
return $this->fail('订单状态不是待验证');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order->state = OrdersState::PAID['value'];
|
||||
$order->pay_type = PaymentChannels::ADMIN['value'];
|
||||
$order->pay_time = date('Y-m-d H:i:s');
|
||||
$order->save();
|
||||
PluginFinanceOrdersLog::info($order, '管理员确认对公转账成功');
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
PluginFinanceOrdersLog::fail($order, $th->getMessage());
|
||||
return $this->exception($th);
|
||||
}
|
||||
Event::emit(EventName::ORDERS_PAY['value'], [
|
||||
'data' => $order,
|
||||
'payment_channel' => PaymentChannels::ADMIN['value'],
|
||||
'plugin' => 'finance'
|
||||
]);
|
||||
try {
|
||||
PluginFinanceOrders::finish(['id' => $order->id, 'channels_uid' => $request->channels_uid]);
|
||||
} catch (\Throwable $th) {
|
||||
PluginFinanceOrdersLog::fail($order, $th->getMessage());
|
||||
Log::error("订单完成失败:{$order->trade_no},{$th->getMessage()},{$th->getFile()}:{$th->getLine()}", $th->getTrace());
|
||||
return $this->exception($th);
|
||||
}
|
||||
return $this->success('确认对公转账成功');
|
||||
}
|
||||
$id = $request->get('id');
|
||||
$order = PluginFinanceOrders::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
|
||||
if (!$order) {
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
if ($order->state != OrdersState::WAIT_VERIFIED['value']) {
|
||||
return $this->fail('订单状态不是待验证');
|
||||
}
|
||||
$Component = new ComponentBuilder;
|
||||
$builder = new FormBuilder(null, null, [
|
||||
'translations' => true,
|
||||
'size' => 'large',
|
||||
]);
|
||||
$builder->add('title', '订单', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 12,
|
||||
'xl' => 12
|
||||
],
|
||||
]);
|
||||
$builder->add('trade_no', '订单号', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 12,
|
||||
'xl' => 12
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'info',
|
||||
'size' => 'small'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '下单时间', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 12,
|
||||
'xl' => 12
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'info',
|
||||
'size' => 'small'
|
||||
]
|
||||
]);
|
||||
$builder->add('expire_time', '过期时间', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 12,
|
||||
'xl' => 12
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'info',
|
||||
'size' => 'small'
|
||||
]
|
||||
]);
|
||||
$builder->add('num', '数量', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
]);
|
||||
$builder->add('origin_money', '原价', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
]);
|
||||
$builder->add('unit_money', '单价', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
]);
|
||||
$builder->add('money', '应付', 'text', null, [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 6
|
||||
],
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '请确认已收到该订单的对公转账款项'], ['type' => 'warning', 'size' => 'small'])->builder(),
|
||||
$Component->add('text', ['default' => '确认后订单状态将变为:'], ['type' => 'info', 'size' => 'small'])->add('tag', ['default' => OrdersState::FINISH['label']], ['type' => OrdersState::FINISH['props']['type'], 'size' => 'small'])->builder(),
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'danger'
|
||||
]
|
||||
]);
|
||||
$builder->setData($order->toArray());
|
||||
return $this->resData($builder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\finance\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ActionBuilder;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use app\expose\helper\Uploads;
|
||||
use plugin\finance\app\model\PluginFinanceWallet;
|
||||
use plugin\finance\expose\helper\Account;
|
||||
use plugin\finance\utils\enum\BillScene;
|
||||
use plugin\finance\utils\enum\PointsBillScene;
|
||||
use plugin\finance\utils\enum\ValidityPeriod;
|
||||
use plugin\user\app\model\PluginUserPoints;
|
||||
use plugin\user\utils\enum\MoneyAction;
|
||||
use support\Request;
|
||||
|
||||
class WalletController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginFinanceWallet;
|
||||
}
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder;
|
||||
$builder->addAction('操作', [
|
||||
'width' => '180px',
|
||||
'fixed' => 'right'
|
||||
]);
|
||||
$builder->addTableAction('余额', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/finance/control/Wallet/recharge',
|
||||
'props' => [
|
||||
'title' => '余额操作《{nickname}》'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addTableAction('积分', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/finance/control/Wallet/rechargePoints',
|
||||
'props' => [
|
||||
'title' => '积分操作《{nickname}》'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'info',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addTableAction('临时积分', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/finance/control/Wallet/rechargeTmpPoints',
|
||||
'props' => [
|
||||
'title' => '临时积分操作《{nickname}》'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
|
||||
$formBuilder->add('uid', 'UID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => 'UID搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('mobile', '手机号', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '手机号搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('nickname', '昵称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '昵称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'nickname',
|
||||
'avatar' => 'headimg',
|
||||
'info' => 'mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '240px'
|
||||
]
|
||||
]);
|
||||
$builder->add('points', '可用积分', [
|
||||
'props' => [
|
||||
'minWidth' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('points_sum', '累计积分', [
|
||||
'props' => [
|
||||
'minWidth' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('points_used', '累计支出积分', [
|
||||
'props' => [
|
||||
'minWidth' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('tmp_points', '临时积分', [
|
||||
'props' => [
|
||||
'minWidth' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('tmp_points_sum', '累计临时积分', [
|
||||
'props' => [
|
||||
'minWidth' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('tmp_points_used', '累计支出临时积分', [
|
||||
'props' => [
|
||||
'minWidth' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('balance', '可用余额', [
|
||||
'props' => [
|
||||
'minWidth' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('balance_sum', '累计余额', [
|
||||
'props' => [
|
||||
'minWidth' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('balance_used', '累计支出余额', [
|
||||
'props' => [
|
||||
'minWidth' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['w.channels_uid', '=', $request->channels_uid];
|
||||
$nickname = $request->get('nickname');
|
||||
if ($nickname) {
|
||||
$where[] = ['u.nickname', 'like', "%{$nickname}%"];
|
||||
}
|
||||
$mobile = $request->get('mobile');
|
||||
if ($mobile) {
|
||||
$where[] = ['u.mobile', '=', $mobile];
|
||||
}
|
||||
$uid = $request->get('uid');
|
||||
if ($uid) {
|
||||
$where[] = ['w.uid', '=', $uid];
|
||||
}
|
||||
$list = PluginFinanceWallet::alias('w')
|
||||
->join('plugin_user u', ' u.id=w.uid ')
|
||||
->field('w.*,u.id,u.nickname,u.headimg,u.mobile')
|
||||
->where($where)
|
||||
->order('w.uid desc')
|
||||
->paginate($limit)
|
||||
->each(function ($item) {
|
||||
$item->headimg = Uploads::url($item->headimg);
|
||||
});
|
||||
return $this->resData($list);
|
||||
}
|
||||
|
||||
|
||||
public function recharge(Request $request)
|
||||
{
|
||||
if ($request->method() == 'POST') {
|
||||
$data = $request->post();
|
||||
Account::updateAccount($data['id'], $request->channels_uid, $data['number'], $data['action'], BillScene::ADMIN['value'], 0, $data['remarks'], $data['is_accumulate'] == 1);
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
$builder = new FormBuilder();
|
||||
|
||||
$builder->add('action', '操作', 'radio', MoneyAction::INCREASE['value'], [
|
||||
'options' => MoneyAction::getOptions()
|
||||
]);
|
||||
$Component = new ComponentBuilder;
|
||||
$builder->add('is_accumulate', '是否计入累计', 'switch', State::NO['value'], [
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '是否计入累计,如退款时,不计入累计'], ['type' => 'info', 'size' => 'small'])->builder()
|
||||
],
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
]);
|
||||
$builder->add('number', '操作数量', 'input-number', 0, [
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'controls' => false,
|
||||
'min' => 1,
|
||||
'step' => 1,
|
||||
'style' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('remarks', '备注', 'input', '', [
|
||||
'required' => true,
|
||||
]);
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
public function rechargePoints(Request $request)
|
||||
{
|
||||
if ($request->method() == 'POST') {
|
||||
$data = $request->post();
|
||||
Account::updatePermanentPoints($data['id'], $request->channels_uid, $data['number'], PointsBillScene::ADMIN['value'], 0, $data['action'], $data['remarks'], $data['is_accumulate']);
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
$builder = new FormBuilder();
|
||||
$builder->add('action', '操作', 'radio', MoneyAction::INCREASE['value'], [
|
||||
'options' => MoneyAction::getOptions()
|
||||
]);
|
||||
|
||||
$Component = new ComponentBuilder;
|
||||
$builder->add('is_accumulate', '是否计入累计', 'switch', State::NO['value'], [
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '是否计入累计,如退款时,不计入累计消费'], ['type' => 'info', 'size' => 'small'])->builder()
|
||||
],
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
|
||||
]
|
||||
]);
|
||||
$builder->add('number', '操作数量', 'input-number', 0, [
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'controls' => false,
|
||||
'min' => 1,
|
||||
'step' => 1,
|
||||
'style' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('remarks', '备注', 'input', '', [
|
||||
'required' => true,
|
||||
]);
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function rechargeTmpPoints(Request $request)
|
||||
{
|
||||
if ($request->method() == 'POST') {
|
||||
$data = $request->post();
|
||||
|
||||
if ($data['action'] == MoneyAction::INCREASE['value']) {
|
||||
Account::incPoints($data['id'], $request->channels_uid, $data['number'], PointsBillScene::ADMIN['value'], 0, $data['remarks'], $data['is_accumulate'], $data['valid_time']);
|
||||
} else {
|
||||
Account::decTemporaryPoints($data['id'], $request->channels_uid, $data['number'], PointsBillScene::ADMIN['value'], 0, $data['action'], $data['remarks'], $data['is_accumulate'], $data['point_id']);
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
$list = PluginUserPoints::field('id as value,points as label, valid_time as tips')
|
||||
->where('channels_uid', $request->channels_uid)
|
||||
->where('uid', $request->get('id'))
|
||||
->where('points', '>', 0)
|
||||
->where('valid_time', '>=', date('Y-m-d H:i:s'))
|
||||
->where('extended_time', '>=', date('Y-m-d H:i:s'))
|
||||
->order('extended_time ASC, valid_time ASC')
|
||||
->select();
|
||||
$list = $list->map(function ($item) {
|
||||
return [
|
||||
'value' => $item['value'],
|
||||
'label' => '剩余积分' . $item['label'],
|
||||
'tips' => '有效期至:' . $item['tips']
|
||||
];
|
||||
});
|
||||
$builder = new FormBuilder();
|
||||
$builder->add('action', '操作', 'radio', MoneyAction::INCREASE['value'], [
|
||||
'options' => MoneyAction::getOptions()
|
||||
]);
|
||||
|
||||
$builder->add('point_id', '选择扣除对象', 'select', null, [
|
||||
'options' => $list,
|
||||
'required' => true,
|
||||
'where' => [
|
||||
['action', '=', MoneyAction::DECREASE['value']]
|
||||
]
|
||||
]);
|
||||
$Component = new ComponentBuilder;
|
||||
$builder->add('is_accumulate', '是否计入累计', 'switch', State::NO['value'], [
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '是否计入累计,如退款时,不计入累计消费'], ['type' => 'info', 'size' => 'small'])->builder()
|
||||
],
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
]);
|
||||
$builder->add('number', '操作数量', 'input-number', 0, [
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'controls' => false,
|
||||
'min' => 1,
|
||||
'step' => 1,
|
||||
'style' => [
|
||||
'width' => '200px'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('valid_time', '有效期', 'date-picker', null, [
|
||||
'required' => true,
|
||||
'where' => [
|
||||
['action', '=', MoneyAction::INCREASE['value']]
|
||||
]
|
||||
]);
|
||||
$builder->add('remarks', '备注', 'input', '', [
|
||||
'required' => true,
|
||||
]);
|
||||
return $this->resData($builder);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user