Commit b4e2312e authored by rlgy's avatar rlgy

账单

parent cba9dc0a
......@@ -49,15 +49,24 @@ class BillController extends BaseController
if (empty($from)) {
return ['code' => -1, 'message' => '数据不存在'];
}
$condition = [
['from' => $from],
];
$condition = ['AND'];
if (!empty($coinname)) {
$condition[] = ['coinname' => $coinname];
$condition[] = "`coinname`='$coinname'";
}
if (!empty($chain)) {
$condition[] = ['chain' => $chain];
$condition[] = "`chain`='$chain'";
}
return Bill::getList($page, $limit, $condition);
if (!empty($condition)) {
$condition[] = ['OR', "`from`='$from'", "`to`='$from'"];
} else {
$condition = ['OR', ['from' => $from], ['to' => $from]];
}
$result = Bill::getList2($page, $limit, $condition);
foreach ($result['data'] as $key => $item) {
if ($item['from'] != $from) {
$result['data'][$key]['type'] = 1;
}
}
return $result;
}
}
\ No newline at end of file
......@@ -25,4 +25,23 @@ class BaseActiveRecord extends \yii\db\ActiveRecord
}
return $data;
}
public static function getList2($page = 1, $limit = 10, $condition = [])
{
$query = self::find();
if (!empty($condition)) {
$query = $query->where($condition);
}
$count = $query->count();
$data = $query->offset(($page - 1) * 10)->limit($limit)->asArray()->all();
$sql = $query->createCommand()->getSql();
$data = ['count' => $count, 'data' => $data];
if ($count > 0) {
$data['code'] = 0;
} else {
$data['code'] = 1;
$data['msg'] = '数据为空';
}
return $data;
}
}
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