Commit 93f34aa9 authored by rlgy's avatar rlgy

文章管理

parent 24b1b79f
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-4
* Time: 上午9:17
*/
namespace backend\controllers;
use backend\models\coin\ArticleForm;
use Yii;
use common\models\pwallet\Article;
use yii\db\Exception;
class SourceController extends BaseController
{
/**
* 显示文章列表
* @return string
*/
public function actionArticle()
{
if (Yii::$app->request->isAjax) {
$request = Yii::$app->request;
$title = $request->get('title', '');
$status = $request->get('status', 'all');
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$condition = [];
if (!empty($title)) {
$condition[] = ['like', 'title', $title];
}
if ($status != 'all') {
$condition[] = ['status' => $status];
}
$results = Article::getList($page, $limit, $condition);
Yii::$app->response->format = 'json';
Yii::$app->response->data = $results;
Yii::$app->response->send();
}
return $this->render('article');
}
/**
* 添加文章
* @return string
*/
public function actionArticleAdd()
{
$model = new ArticleForm();
$model->scenario = 'add';
if (Yii::$app->request->isPost) {
$request = Yii::$app->request;
if ($model->load($request->post()) && $model->validate()) {
$article = new Article();
$res = $article->addOne($request->post());
if ($res === true) {
$this->success('添加成功', '/admin/source/article');
}
}
$errors = $model->errors;
if ($errors) {
foreach ($errors as $k => $v) {
$errors = $v[0];
break;
}
} elseif (isset($res) && $res['code'] != 0) {
$errors = $res['msg'];
}
$this->error($errors, Yii::$app->request->getReferrer());
}
return $this->render('article-add', ['model' => $model]);
}
/**
* 编辑文章
*/
public function actionArticleEdit()
{
$model = new ArticleForm();
$model->scenario = 'edit';
$id = Yii::$app->request->get('id', null);
if ($id) {
$article = Article::findOne(['id' => $id]);
if ($article) {
if (Yii::$app->request->isPost) {
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$res = $article->updateOne(array_merge(Yii::$app->request->post(), ['id' => $id]));
if ($res === true) {
$this->success('修改成功', '/admin/source/article');
}
}
$errors = $model->errors;
if ($errors) {
foreach ($errors as $k => $v) {
$errors = $v[0];
break;
}
} elseif (isset($res) && $res['code'] != 0) {
$errors = $res['msg'];
}
$this->error($errors, Yii::$app->request->getReferrer());
}
return $this->render('article-edit', ['model' => $article]);
}
}
$this->error('文章不存在', Yii::$app->request->getReferrer());
}
/**
* 删除文章
*/
public function actionArticleDel()
{
$id = Yii::$app->request->get('id', null);
if ($id) {
$article = Article::findOne(['id' => $id]);
if ($article) {
try {
$article->delete();
$this->success('删除成功', Yii::$app->request->getReferrer());
} catch (Exception $exception) {
}
}
}
$this->error('删除失败', Yii::$app->request->getReferrer());
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-4
* Time: 上午10:22
*/
namespace backend\models\coin;
use yii\base\Model;
class ArticleForm extends Model
{
public $id;
public $title;
public $url;
public $status;
public function formName()
{
return '';
}
public function rules()
{
return [
[['title', 'url'], 'required', 'on' => 'add'],
[['id', 'title', 'url'], 'required', 'on' => 'edit'],
];
}
public function scenarios()
{
return [
'add' => ['title', 'url', 'status'],
'edit' => ['id', 'title', 'url', 'status'],
];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-4
* Time: 上午10:18
*/
/**
* @var $model backend\models\coin\ArticleForm
*/
?>
<div class="layui-row">
<div class="layui-col-md6">
<form class="layui-form" lay-filter="form1" method="post" action="">
<input type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>" name="_csrf">
<input type="hidden" value="<?= $model->id ?>" name="id">
<div class="layui-form-item">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">标题</label>
<div class="layui-input-block">
<input class="layui-input" type="text" value="<?= $model->title ?>" lay-verify="required"
name="title">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">外链地址</label>
<div class="layui-input-block">
<input class="layui-input" type="text" value="<?= $model->url ?>" lay-verify="required|url"
name="url">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">发布</label>
<div class="layui-input-block">
<select name="status">
<option value="1">发布</option>
<option value="0">暂不发布</option>
</select>
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn" lay-submit>保存</button>
</div>
</form>
</div>
</div>
<script>
var form = layui.form;
form.render(null, 'form1');
</script>
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-4
* Time: 上午10:17
*/
?>
<h4>添加文章</h4>
<?= $this->render('_form-article', ['model' => $model]) ?>
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-4
* Time: 下午2:19
*/
?>
<h4>编辑文章</h4>
<?= $this->render('_form-article', ['model' => $model]) ?>
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-4
* Time: 上午9:19
*/
?>
<h4>文章列表</h4>
<div class="layui-row">
<div class="layui-col-md1">
<a href="/admin/source/article-add">
<button class="layui-btn lauyi-btn-default" id="add">添加文章</button>
</a>
</div>
<div class="layui-col-md11">
<form class="layui-form" lay-filter="form1" method="get" action="">
<div class="layui-inline">
<label class="layui-form-label" style="width: 100px; margin-bottom: 0">文章标题</label>
<div class="layui-input-block">
<input class="layui-input" type="text" value="" name="title" title="文章标题">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 100px; margin-bottom: 0">文章状态</label>
<div class="layui-input-block">
<select name="status" title="文章状态">
<option value="all">所有</option>
<option value="0">未发布</option>
<option value="1">已发布</option>
</select>
</div>
</div>
<div class="layui-inline">
<button class="layui-btn" lay-submit lay-filter="search1">搜索</button>
</div>
</form>
</div>
</div>
<div class="layui-row">
<table class="layui-table" id="table1"></table>
</div>
<script>
var form = layui.form;
form.render(null, 'form1');
var table = layui.table;
table.render({
elem: "#table1",
cols: [[
{field: 'id', title: 'ID'},
{field: 'title', title: '标题'},
{field: 'url', title: '外链地址'},
{field: 'status', title: '状态', templet: '#statusTpl'},
{field: 'create_at', title: '创建时间'},
{field: 'update_at', title: '更新时间'},
{field: 'id', title: '操作', templet: '#operationTpl'}
]],
page: 1,
limit: 10,
url: '/admin/source/article'
});
form.on('submit(search1)', function (data) {
table.reload("table1", {
where: data.field,
page: {curr: 1}
});
return false;
});
</script>
<script type="text/html" id="statusTpl">
{{# if(d.status==1){ }}
已发布
{{# }else{ }}
未发布
{{# } }}
</script>
<script type="text/html" id="operationTpl">
<a href="/admin/source/article-edit?id={{d.id}}" title="编辑">
<button class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe642;</i></button>
</a>
<a href="/admin/source/article-del?id={{d.id}}" title="删除">
<button class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon">&#xe640;</i></button>
</a>
</script>
\ No newline at end of file
<?php
namespace common\models\fxee;
use Yii;
/**
* This is the model class for table "{{%auth}}".
*
* @property string $uid
* @property int $email_statu
* @property int $mobile_statu
* @property int $identity_statu
*/
class Auth extends \common\core\BaseActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%auth}}';
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('db_fxee');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['uid'], 'required'],
[['uid', 'email_statu', 'mobile_statu', 'identity_statu'], 'integer'],
[['uid'], 'unique'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'uid' => Yii::t('fxee', 'Uid'),
'email_statu' => Yii::t('fxee', 'Email Statu'),
'mobile_statu' => Yii::t('fxee', 'Mobile Statu'),
'identity_statu' => Yii::t('fxee', 'Identity Statu'),
];
}
}
<?php
namespace common\models\fxee;
use common\models\parse\Account;
use Yii;
/**
* This is the model class for table "{{%blockchain_bind}}".
*
* @property string $uid
* @property string $publickey
*/
class BlockchainBind extends \common\core\BaseActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'fxee_blockchain_bind';
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->db_fxee;
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['uid', 'publickey'], 'required'],
[['uid'], 'integer'],
[['publickey'], 'string', 'max' => 100],
[['publickey'], 'unique'],
[['uid'], 'unique'],
];
}
/**
* @return mixed
*/
public function getBindInfo()
{
return $this->hasOne(Account::className(), ['pub_key' => 'publickey'])
->select('id, pub_key');
}
/**
* @return mixed
*/
public function getUserid()
{
return $this->hasOne(Account::className(), ['pub_key' => 'publickey'])
->select('id, pub_key');
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'uid' => Yii::t('fxee', 'Uid'),
'publickey' => Yii::t('fxee', 'Publickey'),
];
}
/**
* [获取user_id]
* @author: libingke
* @param $uid
*/
public static function getUseridByUid($uid)
{
if ($uid == null)
return null;
$one = static::find()
->with('userid')
->where(['uid' => $uid])
->asArray()
->one();
return isset($one['userid']['id']) ? $one['userid']['id'] : false;
}
}
<?php
namespace common\models\fxee;
use Yii;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "{{%cash_record}}".
*
* @property string $id
* @property string $uid 用户UID
* @property int $type 记录类型(
0->入账
1->出账
* @property string $name 姓名
* @property string $account 账户
* @property string $amount 金额
* @property string $balance 原余额
* @property string $newbalance 现余额
* @property string $memo 备注
* @property int $statu 状态
* @property int $opuid 操作者UID
* @property int $checkuid 复核员编号
* @property string $way 数据来源
* @property string $fid 来源ID
* @property int $bid 银行卡id
* @property string $sid 区块链可识别标识
* @property string $sign 安全签名
* @property int $isauto 是否自动处理
* @property string $addtime
* @property string $dealtime
*/
class CashRecord extends \common\core\BaseActiveRecord
{
const AUTO_NO = 0;
const AUTO_YES = 1;
const TYPE_IN = 0;
const TYPE_OUT = 1;
const STATUS_WAITING = 0;//等待处理
const STATUS_OK = 1;//已完成
const STATUS_PREPARE = 2;//处理中
const STATUS_CANCEL = 3;//已取消
const STATUS_DB_FAIL = 4;//处理失败[1]
const STATUS_BLOCK_FAIL = 5;//处理失败[2]
const STATUS_CHECK = 6;//待复核
const STATUS_IMPORT = 7;//待出账
const STATUS_BLOCK_WAIT = 8;//待确认状态[区块链]
const WAY_ZFB = 'zfb_sc';
const WAY_WX = 'wx_lyl';
const WAY_WAIT= 'cbc_lyl';
const WAY_BANK= 'bank';
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%cash_record}}';
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('db_fxee');
}
/**
* @return mixed
*/
public function getCoinInfo()
{
return $this->hasOne(CoinRecord::className(), ['id'=>'fid'])->select('id, amount, currency, rate');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['uid', 'amount', 'statu', 'sign'], 'required'],
[['uid', 'type', 'statu', 'opuid', 'checkuid', 'fid', 'bid', 'isauto', 'addtime', 'dealtime'], 'integer'],
[['amount', 'balance', 'newbalance'], 'number'],
[['name', 'way', 'sign'], 'string', 'max' => 50],
[['account'], 'string', 'max' => 200],
[['memo'], 'string', 'max' => 250],
[['sid'], 'string', 'max' => 100],
];
}
/**
* @inheritdoc todo
*/
public function attributeLabels()
{
return [
'id' => Yii::t('fxee', 'ID'),
'uid' => Yii::t('fxee', '用户UID'),
'type' => Yii::t('fxee', '记录类型(0->入账 1->出账)'),
'name' => Yii::t('fxee', '姓名'),
'account' => Yii::t('fxee', '账户'),
'amount' => Yii::t('fxee', '金额'),
'balance' => Yii::t('fxee', '原余额'),
'newbalance' => Yii::t('fxee', '现余额'),
'memo' => Yii::t('fxee', '备注'),
'statu' => Yii::t('fxee', '状态'),
'opuid' => Yii::t('fxee', '操作者UID'),
'checkuid' => Yii::t('fxee', '复核员编号'),
'way' => Yii::t('fxee', '数据来源'),
'fid' => Yii::t('fxee', '来源ID'),
'bid' => Yii::t('fxee', '银行卡id'),
'sid' => Yii::t('fxee', '区块链可识别标识'),
'sign' => Yii::t('fxee', '安全签名'),
'isauto' => Yii::t('fxee', '是否自动处理'),
'addtime' => Yii::t('fxee', 'Addtime'),
'dealtime' => Yii::t('fxee', 'Dealtime'),
];
}
/**
* 获取类型名称
* @param string $type 类型 all代表输出全部 其余实际值即可
* @return array|bool|mixed 输出相应类型名称
*/
public static function getTypeName($type = 'all')
{
$name = false;
$types = array(
'0' => Yii::t('FxeeLabels', 'Cash_type_in'),
'1' => Yii::t('FxeeLabels', 'Cash_type_out'),
);
if ($type == "all") {
$name = $types;
} else {
if (isset($types[$type])) {
$name = $types[$type];
}
}
return $name;
}
/**
* 获取订单状态
* @param string $statu 订单状态值
* @return array|bool|mixed 返回显示状态信息
*/
public static function getStatu($statu)
{
switch ($statu)
{
case 0:
$name = '等待处理';//Yii::t('FxeeLabels', 'Cash_statu_waiting');
break;
case 1:
$name = '已完成';//Yii::t('FxeeLabels', 'Cash_statu_ok');
break;
case 2:
$name = '处理中';//Yii::t('FxeeLabels', 'Cash_statu_ordeing');
break;
case 3:
$name = '已取消';//Yii::t('FxeeLabels', 'Cash_statu_cacel');
break;
case 4:
$name = '处理失败[1]';//Yii::t('FxeeLabels', 'Cash_statu_database_fail');
break;
case 5:
$name = '处理失败[2]';//Yii::t('FxeeLabels', 'Cash_statu_block_fail');
break;
case 6:
$name = '待复核';//Yii::t('FxeeLabels', 'Cash_statu_check');
break;
case 7:
$name = '待出账';//Yii::t('FxeeLabels', 'Cash_statu_import');todo
break;
case 8:
$name = '待确认状态[区块链]';//Yii::t('FxeeLabels', 'Cash_statu_block_waiting');
break;
default:
$name = '(未知)';
}
return $name;
}
/**
* [描述]
* @author: libingke
*/
public static function getStatuList($all = false)
{
$base = [
0 => '等待处理',
6 => '待复核',
7 => '已出账',
2 => '处理中',
1 => '已完成',
3 => '已取消',
4 => '处理失败[1]',
5 => '处理失败[2]',
8 => '待确认状态[区块链]'
];
$data = $all == true ? \common\helpers\ArrayHelper::merge(['' => '全部'], $base) : $base;
return $data;
}
/**
* 获取出入金通道名称
* @author: libingke
* @param $way
* @return string
*/
public static function getWayName($way)
{
switch ($way)
{
case static::WAY_WAIT:
$name = '建行[卢月玲]'; break;
case static::WAY_ZFB:
$name = '支付宝[首仓]'; break;
case static::WAY_WX:
$name = '微信[卢月玲]'; break;
case static::WAY_BANK:
$name = '银行'; break;
default:
$name = '(未知)';
}
return $name;
}
}
<?php
namespace common\models\fxee;
use Yii;
/**
* This is the model class for table "{{%coin_record}}".
*
* @property string $id 主键ID
* @property string $uid 用户UID
* @property int $type 类型 0入 1出
* @property string $amount 金额
* @property string $txfee
* @property string $currency 币种
* @property string $balance 老余额
* @property string $newbalance 新余额
* @property string $aid 出入币对应的记录ID
* @property string $tradeid 交易ID
* @property string $address 地址
* @property string $sid 区块链对应标识
* @property int $statu 状态
* @property string $sign 唯一标识
* @property int $opuid 操作人UID
* @property int $checkuid 初审人id
* @property int $recheckuid 复核人id
* @property string $addtime 添加时间
* @property string $dealtime 处理时间
*/
class CoinRecord extends \common\core\BaseActiveRecord
{
const TYPE_IN = 0;//入
const TYPE_OUT = 1;//出
const STATUS_OK = 1;//完成
const STATUS_CANCEL = 2;//去撤销
const STATUS_CS = 3;//待初审
const STATUS_HANDLE = 4;//处理中
const STATUS_FS = 7;//待复审
const STATUS_6 = 6;
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%coin_record}}';
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('db_fxee');
}
/**
* @return mixed
*/
public function getName()
{
return $this->hasOne(MemberDetail::className(), ['uid'=>'uid'])->select('uid, name');
}
/**
* @return mixed
*/
public function getCashName()
{
return $this->hasOne(CashRecord::className(), ['id'=>'aid'])->select('id, name, way');
}
/**
* @return mixed
*/
public function getInfo()
{
return $this->hasOne(Member::className(), ['id'=>'uid'])->select('id, mobile');
}
/**
* @return mixed
*/
public function getDetails()
{
return $this->hasOne(MemberDetail::className(), ['uid'=>'uid'])
->select('uid, cardtype, cardid, name, country, operatorid');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['uid', 'type', 'amount', 'currency', 'balance', 'newbalance', 'aid', 'sid', 'sign', 'opuid'], 'required'],
[['uid', 'type', 'aid', 'statu', 'opuid', 'checkuid', 'recheckuid', 'addtime', 'dealtime'], 'integer'],
[['amount', 'txfee', 'balance', 'newbalance'], 'number'],
[['currency'], 'string', 'max' => 10],
[['tradeid', 'address'], 'string', 'max' => 100],
[['sid'], 'string', 'max' => 50],
[['sign'], 'string', 'max' => 40],
[['sid'], 'unique'],
[['sign'], 'unique'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('fxee', '主键ID'),
'uid' => Yii::t('fxee', '用户UID'),
'type' => Yii::t('fxee', '类型 0入 1出'),
'amount' => Yii::t('fxee', '金额'),
'txfee' => Yii::t('fxee', 'Txfee'),
'currency' => Yii::t('fxee', '币种'),
'balance' => Yii::t('fxee', '老余额'),
'newbalance' => Yii::t('fxee', '新余额'),
'aid' => Yii::t('fxee', '出入币对应的记录ID'),
'tradeid' => Yii::t('fxee', '交易ID'),
'address' => Yii::t('fxee', '地址'),
'sid' => Yii::t('fxee', '区块链对应标识'),
'statu' => Yii::t('fxee', '状态'),
'sign' => Yii::t('fxee', '唯一标识'),
'opuid' => Yii::t('fxee', '操作人UID'),
'checkuid' => Yii::t('fxee', '初审人id'),
'recheckuid' => Yii::t('fxee', '复核人id'),
'addtime' => Yii::t('fxee', '添加时间'),
'dealtime' => Yii::t('fxee', '处理时间'),
];
}
/**
* [今日提币总数]
* @author: libingke
* @param $currency
* @param $time
* @return int|string
*/
public static function getTodayCount($currency, $time)
{
$stTime = strtotime(date('Ymd', $time));
if ($stTime != false) {
$count = static::find()
->where(['statu' => static::STATUS_OK, 'type' => static::TYPE_OUT, 'currency' => $currency])
->andWhere(['between', 'dealtime', $stTime, $stTime + 86399])
->sum('amount');
$amount = is_numeric($count) ? $count : 0;
} else {
$amount = 0;
}
return $amount;
}
/**
* [获取审核状态]
* @author: libingke
*/
public static function getCoinOutStatus($id)
{
switch ($id)
{
case 0:
$status = '拒绝';break;
case 1:
$status = '通过';break;
case 2:
$status = '已撤销';break;
case 3:
$status = '待初审';break;
case 4:
$status = '处理中';break;
case 7:
$status = '待复核';break;
default:
$status = null;
}
return $status;
}
}
<?php
namespace common\models\fxee;
use Yii;
/**
* This is the model class for table "{{%login_record}}".
*
* @property string $id 记录ID
* @property string $uid 用户UID
* @property string $type 日志类型
* @property string $ip ip信息
* @property string $os
* @property string $browser 浏览器
* @property string $agent
* @property string $sign 识别号
* @property string $addtime 操作时间
*/
class LoginRecord extends \common\core\BaseActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%login_record}}';
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('db_fxee');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['uid', 'type', 'sign'], 'required'],
[['uid', 'addtime'], 'integer'],
[['os', 'browser', 'agent'], 'string'],
[['type'], 'string', 'max' => 25],
[['ip'], 'string', 'max' => 50],
[['sign'], 'string', 'max' => 32],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('fxee', '记录ID'),
'uid' => Yii::t('fxee', '用户UID'),
'type' => Yii::t('fxee', '日志类型'),
'ip' => Yii::t('fxee', 'ip信息'),
'os' => Yii::t('fxee', 'Os'),
'browser' => Yii::t('fxee', '浏览器'),
'agent' => Yii::t('fxee', 'Agent'),
'sign' => Yii::t('fxee', '识别号'),
'addtime' => Yii::t('fxee', '操作时间'),
];
}
}
<?php
namespace common\models\fxee;
use Yii;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "{{%member}}".
*
* @property string $id 用户ID
* @property string $username 用户名
* @property string $group 用户组别
* @property string $email 用户邮箱
* @property int $area 号码区域
* @property string $mobile 手机号码
* @property string $password_hash 用户密码
* @property string $password_reset_token
* @property string $wfrom
* @property int $isinit
* @property string $regip 注册IP
* @property string $addtime 注册时间
*/
class Member extends \common\core\BaseActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%member}}';
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('db_fxee');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'safe'],
[['username', 'password_hash'], 'required'],
[['area', 'isinit', 'addtime'], 'integer'],
[['username', 'email', 'password_hash'], 'string', 'max' => 100],
[['group', 'mobile', 'regip'], 'string', 'max' => 25],
[['password_reset_token', 'wfrom'], 'string', 'max' => 50],
[['email'], 'unique'],
[['area', 'mobile'], 'unique', 'targetAttribute' => ['area', 'mobile']],
];
}
/**
* @return mixed
*/
public function getName()
{
return $this->hasOne(MemberDetail::className(), ['uid'=>'id'])->select('uid, name');
}
/**
* @return mixed
*/
public function getDetails()
{
return $this->hasOne(MemberDetail::className(), ['uid'=>'id'])
->select('uid, cardtype, cardid, name, country, operatorid');
}
/**
* @return mixed
*/
public function getFromId()
{
return $this->hasOne(Relation::className(), ['uid' => 'id'])->select('uid, fromuid');
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('fxee', '用户ID'),
'username' => Yii::t('fxee', '用户名'),
'group' => Yii::t('fxee', '用户组别'),
'email' => Yii::t('fxee', '用户邮箱'),
'area' => Yii::t('fxee', '号码区域'),
'mobile' => Yii::t('fxee', '手机号码'),
'password_hash' => Yii::t('fxee', '用户密码'),
'password_reset_token' => Yii::t('fxee', 'Password Reset Token'),
'wfrom' => Yii::t('fxee', 'Wfrom'),
'isinit' => Yii::t('fxee', 'Isinit'),
'regip' => Yii::t('fxee', '注册IP'),
'addtime' => Yii::t('fxee', '注册时间'),
];
}
/**
* [角色列表]
* @author: libingke
* @return array
*/
public static function getRoles()
{
return [
'admin' => '管理员',
'kf' => '客服',
];
}
/**
* [操作员列表]
* @author: libingke
* @param bool $hasAll
* @return array
*/
public static function getOperatorList($hasAll = false)
{
$data = ['' => '全部'];
$add = [];
$tmp = static::find()->with('name')->select('id')->where(['group' => ['admin', 'kf']])->asArray()->all();
if ($tmp) {
foreach ($tmp as $item) {
$add[$item['id']] = isset($item['name']['name']) ? ( $item['id'] . '(' . $item['name']['name'] . ')' ) : $item['id'];
}
}
$data = $hasAll == true ? ArrayHelper::merge($data, $add) : $add;
return $data;
}
/**
* [自动完成]
* @author: libingke
*/
public static function getSelect2Data()
{
$all = static::find()
->select(["CONCAT(`id`, '-', `mobile`) as t", "id"])
->indexBy('id')
//->orderBy('mobile')
->column();
$all = is_array($all) ? $all : [];
foreach ($all as $k => $v) {
if ($v == null || $v == '')
$all[$k] = $k;
}
return $all;
// $names = static::find()->select('id')->indexBy('id')->column();
//
// $mobiles = static::find()
// ->select('mobile, id')
// ->where(['not', ['mobile' => false]])
// ->indexBy('id')
// ->column();
//
// $result = [
// '手机号' => $mobiles,
// 'UID' => $names,
// ];
// return $result;
}
}
<?php
namespace common\models\fxee;
use Yii;
/**
* This is the model class for table "{{%member_detail}}".
*
* @property string $uid
* @property int $cardtype
* @property string $cardid
* @property string $name
* @property string $country
* @property string $mid
* @property string $matchmid
* @property string $addtime
* @property int $operatorid
*/
class MemberDetail extends \common\core\BaseActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%member_detail}}';
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('db_fxee');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['cardtype', 'addtime', 'operatorid'], 'integer'],
[['cardid', 'name'], 'string', 'max' => 100],
[['country'], 'string', 'max' => 25],
[['mid', 'matchmid'], 'string', 'max' => 50],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'uid' => Yii::t('fxee', 'Uid'),
'cardtype' => Yii::t('fxee', 'Cardtype'),
'cardid' => Yii::t('fxee', 'Cardid'),
'name' => Yii::t('fxee', 'Name'),
'country' => Yii::t('fxee', 'Country'),
'mid' => Yii::t('fxee', 'Mid'),
'matchmid' => Yii::t('fxee', 'Matchmid'),
'addtime' => Yii::t('fxee', 'Addtime'),
'operatorid' => Yii::t('fxee', 'Operatorid'),
];
}
/**
* @param $code
* @return string
*/
public static function getCountryName($code)
{
switch ($code)
{
case 'CN':
$name = '中国';break;
default:
$name = '';
}
return $name;
}
/**
* @param $code
* @return string
*/
public static function getCardTypeName($cardType)
{
switch ($cardType)
{
case 1:
$name = '身份证';break;
default:
$name = '';
}
return $name;
}
}
<?php
namespace common\models\fxee;
use Yii;
/**
* This is the model class for table "{{%myaddress}}".
*
* @property string $uid
* @property string $btc
* @property string $eth
* @property string $etc
* @property string $zec
* @property string $ltc
* @property string $bcc
* @property string $sign
*/
class Myaddress extends \common\core\BaseActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%myaddress}}';
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('db_fxee');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['uid', 'sign'], 'required'],
[['uid'], 'integer'],
[['btc', 'eth', 'etc', 'zec', 'ltc', 'bcc'], 'string', 'max' => 100],
[['sign'], 'string', 'max' => 50],
[['sign'], 'unique'],
[['btc'], 'unique'],
[['eth'], 'unique'],
[['etc'], 'unique'],
[['zec'], 'unique'],
[['ltc'], 'unique'],
[['bcc'], 'unique'],
[['uid'], 'unique'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'uid' => Yii::t('fxee', 'Uid'),
'btc' => Yii::t('fxee', 'Btc'),
'eth' => Yii::t('fxee', 'Eth'),
'etc' => Yii::t('fxee', 'Etc'),
'zec' => Yii::t('fxee', 'Zec'),
'ltc' => Yii::t('fxee', 'Ltc'),
'bcc' => Yii::t('fxee', 'Bcc'),
'sign' => Yii::t('fxee', 'Sign'),
];
}
}
<?php
namespace common\models\fxee;
use Yii;
class Relation extends \common\core\BaseActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%relation}}';
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('db_fxee');
}
/**
* 根据推客获取uid列表
* @param $pid
* @return array
*/
public static function getChildIdList($pid)
{
$data = [];
if (is_numeric($pid)) {
$query = self::find()
->select('uid')
->where(['fromuid' => $pid])
->column();
$data = $query ? : $data;
}
return $data;
}
/**
* 根据推客获取2级uid列表
* @param $pid
* @return array
*/
public static function getGrandChildIdList($pid)
{
$data = [];
if (is_numeric($pid)) {
$query = self::find()
->alias('o')
->select('o.uid uid1,temp.uid uid2')
->leftJoin(self::tableName() . ' as temp','temp.fromuid = o.uid')
->where(['o.fromuid' => $pid])
->asArray()
->all();
$data = $query ? : $data;
}
return $data;
}
}
<?php
namespace common\models\fxee\search;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\fxee\Auth;
/**
* AuthSearch represents the model behind the search form of `\common\models\fxee\Auth`.
*/
class AuthSearch extends Auth
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['uid', 'email_statu', 'mobile_statu', 'identity_statu'], 'integer'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Auth::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'uid' => $this->uid,
'email_statu' => $this->email_statu,
'mobile_statu' => $this->mobile_statu,
'identity_statu' => $this->identity_statu,
]);
return $dataProvider;
}
}
<?php
namespace common\models\fxee\search;
use common\helpers\ArrayHelper;
use common\helpers\CurrencyHelper;
use common\models\fxee\CoinRecord;
use yii\data\ActiveDataProvider;
use yii\base\Model;
class CoinRecordSearch extends CoinRecord
{
public $from_date;
public $to_date;
public $uid2;
private $_tip;//表格页脚小计
/**
* @inheritdoc
*/
public function rules()
{
return [
[['uid'], 'filter', 'filter' => 'trim', 'on' => ['coin-out-operate', 'coin-out-query']],
/* 提币审核 操作列表 */
[['way', 'opuid', 'uid', 'currency', 'from_date', 'to_date'], 'safe', 'on' => 'coin-out-operate'],
/* 提币审核 查询列表 */
[['way', 'opuid', 'checkuid', 'recheckuid', 'uid', 'currency', 'from_date', 'to_date'], 'safe', 'on' => 'coin-out-query'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
return Model::scenarios();
}
/**
* [获取标签内容]
* @author: libingke
* @return mixed
*/
public function getTip()
{
return $this->_tip;
}
/**
* 提币审核 操作列表
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function coinOutListSearch($params)
{
$query = static::find()->with(['name', 'info'])
->where(['not', ['currency' => 'USDT']])
->andWhere([
'type' => static::TYPE_OUT,
'statu' => [static::STATUS_CS, static::STATUS_FS, static::STATUS_6]
]);
$dataProvider = new ActiveDataProvider([
'query' => $query->asArray(),
'sort' => [
'defaultOrder' => [
'addtime' => SORT_DESC,
],
],
'pagination' => [
'pageSize' => 15,
],
]);
if (!$this->load($params) || !$this->validate()) {
return $dataProvider;
}
$query->andFilterWhere([
'uid' => \common\helpers\PublicHelper::getInFilterByUser($this->uid, 'array'),
'currency' => CurrencyHelper::getCurrencyName($this->currency),
]);
if (strtotime($this->from_date) != false)
$query->andFilterWhere(['>=', 'addtime', strtotime($this->from_date)]);
if (strtotime($this->to_date) != false)
$query->andFilterWhere(['<=', 'addtime', strtotime('+1 day', strtotime($this->to_date))]);
return $dataProvider;
}
/**
* 提币审核 查询列表
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function coinOutQuerySearch($params)
{
$query = static::find()->with(['name', 'info'])
->where(['not', ['currency' => 'USDT']])
->andWhere([
'type' => static::TYPE_OUT,
'statu' => [static::STATUS_OK, static::STATUS_CANCEL, static::STATUS_HANDLE]
]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => [
'dealtime' => SORT_DESC,
],
],
'pagination' => [
'pageSize' => 10,
]
]);
if (!$this->load($params) || !$this->validate()) {
$sum = clone $query;
$count = $sum->andWhere(['statu' => static::STATUS_OK])->count();
$this->_tip = is_numeric($count) ? ("累计提币次数:" . ArrayHelper::formatNumber($count, 0)) . ' 次' : '';
return $dataProvider;
}
$currencyName = CurrencyHelper::getCurrencyName($this->currency);
$query->andFilterWhere([
'uid' => \common\helpers\PublicHelper::getInFilterByUser($this->uid, 'array'),
'currency' => $currencyName
]);
if (strtotime($this->from_date) != false)
$query->andFilterWhere(['>=', 'dealtime', strtotime($this->from_date)]);
if (strtotime($this->to_date) != false)
$query->andFilterWhere(['<=', 'dealtime', strtotime('+1 day', strtotime($this->to_date))]);
if ($this->uid) {
$count1 = $query->count();
$this->_tip = is_numeric($count1) ? ("累计提币次数:" . $count1) . ' 次': '';
if ($this->currency) {
$count2 = $query->sum('amount');
$this->_tip .= is_numeric($count2) ? (", 数量({$currencyName}):" . ArrayHelper::formatNumber($count2, 0)) . ' 个' : '';
}
}
$query->andFilterWhere([
'checkuid' => $this->checkuid,
'recheckuid' => $this->recheckuid,
]);
return $dataProvider;
}
}
<?php
namespace common\models\fxee\search;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\fxee\LoginRecord;
/**
* LoginRecordSearch represents the model behind the search form of `\common\models\fxee\LoginRecord`.
*/
class LoginRecordSearch extends LoginRecord
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'uid', 'addtime'], 'integer'],
[['type', 'ip', 'os', 'browser', 'agent', 'sign'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = LoginRecord::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'uid' => $this->uid,
'addtime' => $this->addtime,
]);
$query->andFilterWhere(['like', 'type', $this->type])
->andFilterWhere(['like', 'ip', $this->ip])
->andFilterWhere(['like', 'os', $this->os])
->andFilterWhere(['like', 'browser', $this->browser])
->andFilterWhere(['like', 'agent', $this->agent])
->andFilterWhere(['like', 'sign', $this->sign]);
return $dataProvider;
}
}
<?php
namespace common\models\fxee\search;
use common\models\fxee\Member;
use yii\helpers\ArrayHelper;
/**
* MemberSearch represents the model behind the search form of `\common\models\fxee\Member`.
*/
class MemberSearch extends Member
{
public $from_date;
public $to_date;
public $user_type;//用户类型
public $economy_trader;//经纪商
public $uid;
/**
* @inheritdoc
*/
public function rules()
{
return [];
}
/**
* @inheritdoc
*/
public function scenarios()
{
return [
'info' => ['uid', 'user_type', 'economy_trader', 'wfrom', 'from_date', 'to_date'],
];
}
/**
* [修改内容:范围]
* @return array
*/
public static function getFieldRange($hasAll = false)
{
$base = $hasAll !== false ? ['' => '全部'] : [];
return ArrayHelper::merge($base, [
1 => '手机号',
2 => '邮箱',
3 => '用户类型',
4 => '证件类型',
5 => '证件号',
6 => '代理商',
7 => '姓名'
]);
}
/**
* [用户范围:范围]
* @return array
*/
public static function getUserTypeRange($hasAll = false)
{
$base = $hasAll !== false ? ['' => '全部'] : [];
return ArrayHelper::merge($base, [
1 => '国内用户',
2 => '国际用户',
3 => '未认证用户'
]);
}
/**
* [证件类型:范围]
* @return array
*/
public static function getCredentialsTypeRange($hasAll = false)
{
$base = $hasAll !== false ? ['' => '全部'] : [];
return ArrayHelper::merge($base, [
1 => '身份证',
2 => '护照',
3 => '驾照',
4 => '其它',
]);
}
/**
* [经纪商:范围]
* @return array
*/
public static function getEconomyRange($hasAll = false)
{
$base = $hasAll !== false ? ['' => '全部'] : [];
return ArrayHelper::merge($base, [
]);
}
/**
* [代理商:范围]
* @return array
*/
public static function getAgentRange($hasAll = false)
{
$base = $hasAll !== false ? ['' => '全部'] : [];
return ArrayHelper::merge($base, [
'fx66' => 'fx66',
'fxee' => 'fxee',
'licai' => 'licai',
]);
}
}
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-4
* Time: 上午9:53
*/
namespace common\models\pwallet;
use common\base\Exception;
use common\core\BaseActiveRecord;
use Yii;
class Article extends BaseActiveRecord
{
public static function getDb()
{
return Yii::$app->get('db_pwallet');
}
public static function tableName()
{
return '{{%article}}';
}
/**
* 获取文章列表
* @param int $page
* @param int $limit
* @param array $condition
* @return array
*/
public static function getList($page = 1, $limit = 10, $condition = [])
{
$query = self::find();
foreach ($condition as $item) {
$query = $query->andFilterWhere($item);
}
$count = $query->count();
if ($count) {
$data = $query->offset(($page - 1) * $limit)->limit($limit)->asArray()->all();
return ['code' => 0, 'count' => $count, 'data' => $data];
}
return ['code' => 1, 'msg' => '数据为空'];
}
/**
* 添加文章
* @param $params
* @return bool|array
*/
public function addOne($params)
{
return $this->realWrite($params);
}
/**
* 更新文章
* @param $params
* @return bool|array
*/
public function updateOne($params)
{
return $this->realWrite($params);
}
/**
* 实际操作数据方法
*/
private function realWrite($params)
{
if (!is_array($params)) {
$params = [$params];
}
$params = array_filter($params, function ($value, $key) {
if (ctype_digit($key) || empty($value)) {
return false;
}
return true;
}, ARRAY_FILTER_USE_BOTH);
if (isset($params['id'])) {
$article = self::findOne($params['id']);
if ($article === null) {
return ['code' => 1, 'msg' => '文章不存在'];
}
unset($params['id']);
} else {
$article = $this;
$params = array_merge($params, ['create_at' => date('Y-m-d H:i:s')]);
}
$params = array_merge($params, ['update_at' => date('Y-m-d H:i:s', time())]);
if (!isset($params['status'])) {
$params['status'] = 0;
}
$article->setAttributes($params, false);
try {
return (bool)$article->save();
} catch (Exception $exception) {
return ['code' => $exception->getCode(), 'msg' => $exception->getMessage()];
}
}
}
\ No newline at end of file
......@@ -65,6 +65,9 @@ class Coin extends BaseActiveRecord
});
if (isset($params['id'])) {
$coin = self::findOne(['id' => $params['id']]);
if ($coin === null) {
return ['code' => 1, 'msg' => '币种不存在'];
}
unset($params['id']);
} else {
$coin = self::findOne(['name' => $params['name']]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment