jh-admin/addon/dividemoney/shop/controller/Account.php

140 lines
4.9 KiB
PHP

<?php
namespace addon\dividemoney\shop\controller;
use app\model\web\Config as ConfigModel;
use app\shop\controller\BaseShop;
use addon\dividemoney\model\DividemoneyAccount;
use addon\dividemoney\model\Config;
class Account extends BaseShop
{
public function list()
{
if (request()->isAjax()) {
$model = new DividemoneyAccount();
$page = input('page', 1);
$page_size = input('page_size', 10);
$condition = [];
$condition[] = ['site_id', '=', $this->site_id];
$bonus_type = input('bonus_type', '');
$accids = input('accids', '');
$keyword_search = input('keyword_search', '');
if ($bonus_type) {
$condition[] = ['bonus_type', '=', $bonus_type];
}
if ($accids) {
$condition[] = ['id', 'notin', explode(',', $accids)];
}
if ($keyword_search) {
$condition[] = ['account', 'like', '%' . $keyword_search . '%'];
}
$list = $model->getDividemoneyAccountPageList($condition, $page, $page_size);
return $list;
} else {
$this->forthMenu();
return $this->fetch('account/lists');
}
}
public function add()
{
if (request()->isAjax()) {
$channel_type = input('channel_type', '');
$account = input('account', '');
$model = new DividemoneyAccount();
$data = request()->post();
$data['is_system'] = 0;
if (empty($account)) return error('请填写正确的账户');
switch ($channel_type) {
case 'aliapp':
$res = $model->BingAlipayAccount($this->site_id, $data);
break;
case 'wechat':
$res = $model->BingWechatAccount($this->site_id, $data);
break;
case 'cypay':
$res = $model->BingCyPayAccount($this->site_id, $data);
break;
case 'member':
$res = $model->BingMemberAccount($this->site_id, $data);
break;
}
return $res;
}
$upload_config_model = new ConfigModel();
$upload_config_result = $upload_config_model->getDefaultImg($this->site_id, $this->app_module)['data']['value'];
$this->assign("default_headimg", $upload_config_result['head']);
return $this->fetch('account/add');
}
public function edit()
{
if (request()->isAjax()) {
$channel_type = input('channel_type', '');
$account = input('account', '');
$model = new DividemoneyAccount();
$data = request()->post();
$data['is_system'] = 0;
unset($data['bonus_type']);
if (empty($account)) return error('请填写正确的账户');
switch ($channel_type) {
case 'aliapp':
$res = $model->BingAlipayAccount($this->site_id, $data);
break;
case 'wechat':
$res = $model->BingWechatAccount($this->site_id, $data);
break;
case 'cypay':
$res = $model->BingCyPayAccount($this->site_id, $data);
break;
case 'member':
$res = $model->BingMemberAccount($this->site_id, $data);
break;
}
return $res;
}
$id = input('id', 0);
$model = new DividemoneyAccount();
$info = $model->getDividemoneyAccountInfo([['id', '=', $id]]);
$upload_config_model = new ConfigModel();
$upload_config_result = $upload_config_model->getDefaultImg($this->site_id, $this->app_module)['data']['value'];
$this->assign("default_headimg", $upload_config_result['head']);
$this->assign('info', $info['data']);
$username = '';
if ($info['data']['member_id'] > 0) {
$username = model('member')->getValue(['member_id' => $info['data']['member_id']], 'username');
}
$this->assign('username', $username);
return $this->fetch('account/edit');
}
/***
* 删除
* @return int|void
*/
public function delete()
{
if (request()->isAjax()) {
$id = input('id', 0);
$model = new DividemoneyAccount();
$info = $model->deleteDividemoneyAccount([['id', '=', $id], ['site_id', '=', $this->site_id]]);
return $info;
}
}
public function setiing()
{
$config_model = new Config();
if (request()->isAjax()) {
return $config_model->setConfig(request()->post(), $this->site_id);
}
$info = $config_model->getConfig($this->site_id);
$this->assign('info', $info['data']['value']);
$this->forthMenu();
return $this->fetch('account/setiing');
}
}