提交 783fdbee authored 作者: caiwenxin's avatar caiwenxin

初始化开发分支

上级 2ec9bc74
...@@ -16,3 +16,5 @@ composer.lock ...@@ -16,3 +16,5 @@ composer.lock
.svn .svn
.vscode .vscode
node_modules node_modules
application/database.php
public/nginx.htaccess
...@@ -18,6 +18,8 @@ class TtCode extends Backend ...@@ -18,6 +18,8 @@ class TtCode extends Backend
*/ */
protected $model = null; protected $model = null;
protected $noNeedRight = ['admin_user'];
public function _initialize() public function _initialize()
{ {
parent::_initialize(); parent::_initialize();
...@@ -36,5 +38,46 @@ class TtCode extends Backend ...@@ -36,5 +38,46 @@ class TtCode extends Backend
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/ */
/**
* 查看
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $key => $value) {
$list[$key]['user_id'] = \app\admin\model\User::where('id',$value['user_id'])->value('nickname');
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
/**
* 搜索下拉框
*/
public function admin_user()
{
$user = \app\admin\model\User::select();
$user = collection($user)->toArray();
foreach ($user as $key => $value) {
$user[$key]['name'] = $value['nickname'];
}
return $user;
}
} }
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 订单管理
*
* @icon fa fa-circle-o
*/
class TtEx extends Backend
{
/**
* TtEx模型对象
* @var \app\admin\model\TtEx
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\TtEx;
}
public function import()
{
parent::importOrder();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
...@@ -3,7 +3,15 @@ ...@@ -3,7 +3,15 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\common\controller\Backend; use app\common\controller\Backend;
use app\admin\library\Auth;
use Exception;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
/** /**
* 平级奖励 * 平级奖励
* *
...@@ -36,5 +44,86 @@ class TtLevelReward extends Backend ...@@ -36,5 +44,86 @@ class TtLevelReward extends Backend
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/ */
/**
* 查看
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $key => $value) {
$list[$key]['group_id'] = \app\admin\model\UserGroup::where('id',$value['group_id'])->value('name');
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
/**
* 编辑
*/
public function edit($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
}
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException(true)->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("row", $row);
$this->view->assign('group_id', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker','disabled']));
return $this->view->fetch();
}
} }
<?php
return [
'Order_id' => '订单id',
'Enddate' => '订单完结时间',
'Create_time' => '订单创建时间',
'Pay_time' => '订单支付时间',
'Refund_time' => '退款申请时间',
'Channel_id' => '一级渠道id',
'Channel_name' => '一级渠道名称',
'Code_id' => '推广者id',
'Real_money' => '卖家实收金额',
'Shop_id' => '商品id',
'Shop_name' => '商品名称',
'Shop_price' => '商品价格',
'Shop_quantity' => '商品数量',
'Class_three_name' => '下单日商品叶子类目名称',
'Class_two_name' => '下单日商品一级类目名称',
'Class_name' => '商品行业大组名称',
'Name' => '名称'
];
...@@ -479,4 +479,140 @@ trait Backend ...@@ -479,4 +479,140 @@ trait Backend
$this->success(); $this->success();
} }
/**
* 导入订单
*/
protected function importOrder()
{
$file = $this->request->request('file');
if (!$file) {
$this->error(__('Parameter %s can not be empty', 'file'));
}
$filePath = ROOT_PATH . DS . 'public' . DS . $file;
if (!is_file($filePath)) {
$this->error(__('No results were found'));
}
//实例化reader
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
if (!in_array($ext, ['csv', 'xls', 'xlsx'])) {
$this->error(__('Unknown data format'));
}
if ($ext === 'csv') {
$file = fopen($filePath, 'r');
$filePath = tempnam(sys_get_temp_dir(), 'import_csv');
$fp = fopen($filePath, "w");
$n = 0;
while ($line = fgets($file)) {
$line = rtrim($line, "\n\r\0");
$encoding = mb_detect_encoding($line, ['utf-8', 'gbk', 'latin1', 'big5']);
if ($encoding != 'utf-8') {
$line = mb_convert_encoding($line, 'utf-8', $encoding);
}
if ($n == 0 || preg_match('/^".*"$/', $line)) {
fwrite($fp, $line . "\n");
} else {
fwrite($fp, '"' . str_replace(['"', ','], ['""', '","'], $line) . "\"\n");
}
$n++;
}
fclose($file) || fclose($fp);
$reader = new Csv();
} elseif ($ext === 'xls') {
$reader = new Xls();
} else {
$reader = new Xlsx();
}
//导入文件首行类型,默认是注释,如果需要使用字段名称请使用name
$importHeadType = isset($this->importHeadType) ? $this->importHeadType : 'comment';
$table = $this->model->getQuery()->getTable();
$database = \think\Config::get('database.database');
$fieldArr = [];
$list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]);
foreach ($list as $k => $v) {
if ($importHeadType == 'comment') {
$fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME'];
} else {
$fieldArr[$v['COLUMN_NAME']] = $v['COLUMN_NAME'];
}
}
//加载文件
$insert = [];
try {
if (!$PHPExcel = $reader->load($filePath)) {
$this->error(__('Unknown data format'));
}
$currentSheet = $PHPExcel->getSheet(0); //读取文件中的第一个工作表
$allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
$maxColumnNumber = Coordinate::columnIndexFromString($allColumn);
$fields = [];
for ($currentRow = 1; $currentRow <= 1; $currentRow++) {
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
$fields[] = $val;
}
}
for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
$values = [];
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
if($currentColumn == 1){
$val = decimalNotation($val);
}
$values[] = is_null($val) ? '' : $val;
}
$row = [];
$temp = array_combine($fields, $values);
foreach ($temp as $k => $v) {
if (isset($fieldArr[$k]) && $k !== '') {
$row[$fieldArr[$k]] = $v;
}
}
if ($row) {
$insert[] = $row;
}
}
} catch (Exception $exception) {
$this->error($exception->getMessage());
}
if (!$insert) {
$this->error(__('No rows were updated'));
}
try {
//是否包含admin_id字段
$has_admin_id = false;
foreach ($fieldArr as $name => $key) {
if ($key == 'admin_id') {
$has_admin_id = true;
break;
}
}
if ($has_admin_id) {
$auth = Auth::instance();
foreach ($insert as &$val) {
if (!isset($val['admin_id']) || empty($val['admin_id'])) {
$val['admin_id'] = $auth->isLogin() ? $auth->id : 0;
}
}
}
$this->model->saveAll($insert);
} catch (PDOException $exception) {
$msg = $exception->getMessage();
if (preg_match("/.+Integrity constraint violation: 1062 Duplicate entry '(.+)' for key '(.+)'/is", $msg, $matches)) {
$msg = "导入失败,包含【{$matches[1]}】的记录已存在";
};
$this->error($msg);
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->success();
}
} }
<?php
namespace app\admin\model;
use think\Model;
class TtEx extends Model
{
// 表名
protected $name = 'tt_ex';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'create_time_text',
'pay_time_text',
'refund_time_text'
];
public function getCreateTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getPayTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getRefundTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['refund_time']) ? $data['refund_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setCreateTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
protected function setPayTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
protected function setRefundTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
}
<?php
namespace app\admin\validate;
use think\Validate;
class TtEx extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<div class="widget-body no-padding"> <div class="widget-body no-padding">
<div id="toolbar" class="toolbar"> <div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('tt_code/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> <!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('tt_code/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('tt_code/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('tt_code/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('tt_code/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('tt_code/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('tt_code/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a> <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('tt_code/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li> <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li> <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul> </ul>
</div> </div> -->
</div> </div>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="widget-body no-padding"> <div class="widget-body no-padding">
<div id="toolbar" class="toolbar"> <div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('tt_distribution/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> <!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('tt_distribution/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('tt_distribution/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('tt_distribution/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('tt_distribution/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('tt_distribution/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('tt_distribution/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a> <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('tt_distribution/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li> <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li> <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul> </ul>
</div> </div> -->
</div> </div>
......
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Order_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-order_id" data-rule="required" data-source="order/index" class="form-control selectpage" name="row[order_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Enddate')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-enddate" class="form-control" name="row[enddate]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-create_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Pay_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-pay_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[pay_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Refund_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-refund_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[refund_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Channel_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-channel_id" data-rule="required" data-source="channel/index" class="form-control selectpage" name="row[channel_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Channel_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-channel_name" class="form-control" name="row[channel_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Code_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-code_id" data-rule="required" data-source="code/index" class="form-control selectpage" name="row[code_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Real_money')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-real_money" class="form-control" name="row[real_money]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shop_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shop_id" data-rule="required" data-source="shop/index" class="form-control selectpage" name="row[shop_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shop_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shop_name" class="form-control" name="row[shop_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shop_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shop_price" class="form-control" name="row[shop_price]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shop_quantity')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shop_quantity" class="form-control" name="row[shop_quantity]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Class_three_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-class_three_name" class="form-control" name="row[class_three_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Class_two_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-class_two_name" class="form-control" name="row[class_two_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Class_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-class_name" class="form-control" name="row[class_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text" value="">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Order_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-order_id" data-rule="required" data-source="order/index" class="form-control selectpage" name="row[order_id]" type="text" value="{$row.order_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Enddate')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-enddate" class="form-control" name="row[enddate]" type="text" value="{$row.enddate|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-create_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:$row.create_time?datetime($row.create_time):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Pay_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-pay_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[pay_time]" type="text" value="{:$row.pay_time?datetime($row.pay_time):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Refund_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-refund_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[refund_time]" type="text" value="{:$row.refund_time?datetime($row.refund_time):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Channel_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-channel_id" data-rule="required" data-source="channel/index" class="form-control selectpage" name="row[channel_id]" type="text" value="{$row.channel_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Channel_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-channel_name" class="form-control" name="row[channel_name]" type="text" value="{$row.channel_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Code_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-code_id" data-rule="required" data-source="code/index" class="form-control selectpage" name="row[code_id]" type="text" value="{$row.code_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Real_money')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-real_money" class="form-control" name="row[real_money]" type="text" value="{$row.real_money|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shop_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shop_id" data-rule="required" data-source="shop/index" class="form-control selectpage" name="row[shop_id]" type="text" value="{$row.shop_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shop_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shop_name" class="form-control" name="row[shop_name]" type="text" value="{$row.shop_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shop_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shop_price" class="form-control" name="row[shop_price]" type="text" value="{$row.shop_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shop_quantity')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shop_quantity" class="form-control" name="row[shop_quantity]" type="text" value="{$row.shop_quantity|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Class_three_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-class_three_name" class="form-control" name="row[class_three_name]" type="text" value="{$row.class_three_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Class_two_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-class_two_name" class="form-control" name="row[class_two_name]" type="text" value="{$row.class_two_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Class_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-class_name" class="form-control" name="row[class_name]" type="text" value="{$row.class_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('tt_ex/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('tt_ex/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('tt_ex/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('tt_ex/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<div class="dropdown btn-group {:$auth->check('tt_ex/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('tt_ex/edit')}"
data-operate-del="{:$auth->check('tt_ex/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Group_id')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Group_id')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input id="c-group_id" data-rule="required" data-source="group/index" class="form-control selectpage" name="row[group_id]" type="text" value="{$row.group_id|htmlentities}"> {$group_id}
<!-- <input id="c-group_id" data-rule="required" data-source="group/index" class="form-control selectpage" name="row[group_id]" type="text" value="{$row.group_id|htmlentities}"> -->
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="widget-body no-padding"> <div class="widget-body no-padding">
<div id="toolbar" class="toolbar"> <div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('tt_level_reward/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> <!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('tt_level_reward/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('tt_level_reward/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('tt_level_reward/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('tt_level_reward/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('tt_level_reward/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('tt_level_reward/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a> <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('tt_level_reward/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li> <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li> <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul> </ul>
</div> </div> -->
</div> </div>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\api\controller; namespace app\api\controller;
use app\common\controller\Api; use app\common\controller\Api;
use app\common\model\User;
/** /**
* 首页接口 * 首页接口
...@@ -20,4 +21,6 @@ class Index extends Api ...@@ -20,4 +21,6 @@ class Index extends Api
{ {
$this->success('请求成功'); $this->success('请求成功');
} }
} }
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
namespace app\api\controller; namespace app\api\controller;
use app\admin\model\TtCode;
use app\common\controller\Api; use app\common\controller\Api;
use app\common\library\Ems; use app\common\library\Ems;
use app\common\library\Sms; use app\common\library\Sms;
use fast\Random; use fast\Random;
use think\Validate; use think\Validate;
/** /**
* 会员接口 * 会员接口
*/ */
...@@ -37,15 +37,27 @@ class User extends Api ...@@ -37,15 +37,27 @@ class User extends Api
*/ */
public function login() public function login()
{ {
$account = $this->request->request('account'); $account = $this->request->request('username');
$password = $this->request->request('password'); $password = $this->request->request('password');
if (!$account || !$password) { if (!$account || !$password) {
$this->error(__('Invalid parameters')); $this->error(__('Invalid parameters'));
} }
$ret = $this->auth->login($account, $password); $ret = $this->auth->login($account, $password,\app\common\model\User::TYPE_TT);
if ($ret) { if ($ret) {
$data = ['userinfo' => $this->auth->getUserinfo()]; $data = ['userinfo' => $this->auth->getUserinfo()];
//检查并处理押金
$res = \app\common\model\User::depositChange($data['userinfo']['id']);
switch ($res['code']){
case 1:
$this->success(__('Logged in successful'), $data); $this->success(__('Logged in successful'), $data);
break;
case 2:
$this->error('登录失败,账户异常');
break;
default:
$this->error('系统异常');
break;
}
} else { } else {
$this->error($this->auth->getError()); $this->error($this->auth->getError());
} }
...@@ -105,6 +117,7 @@ class User extends Api ...@@ -105,6 +117,7 @@ class User extends Api
$email = $this->request->request('email'); $email = $this->request->request('email');
$mobile = $this->request->request('mobile'); $mobile = $this->request->request('mobile');
$code = $this->request->request('code'); $code = $this->request->request('code');
$code_tt = $this->request->request('code_tt');
if (!$username || !$password) { if (!$username || !$password) {
$this->error(__('Invalid parameters')); $this->error(__('Invalid parameters'));
} }
...@@ -118,8 +131,13 @@ class User extends Api ...@@ -118,8 +131,13 @@ class User extends Api
if (!$ret) { if (!$ret) {
$this->error(__('Captcha is incorrect')); $this->error(__('Captcha is incorrect'));
} }
$ret = $this->auth->register($username, $password, $email, $mobile, []); $ttCodeInfo = TtCode::where('code',$code_tt)->where('parent_id','>',0)->where('status',0)->find();
if ($ret) { if(empty($ttCodeInfo)){
$this->error('无效的站长码');
}
$ret = $this->auth->register($username, $password, $email, $mobile, [],[],$ttCodeInfo['parent_id'],\app\common\model\User::TYPE_TT);
$resMoney = \app\common\model\User::money(10,$ttCodeInfo['parent_id'],'拉新注册');
if ($ret && $resMoney){
$data = ['userinfo' => $this->auth->getUserinfo()]; $data = ['userinfo' => $this->auth->getUserinfo()];
$this->success(__('Sign up successful'), $data); $this->success(__('Sign up successful'), $data);
} else { } else {
...@@ -323,4 +341,6 @@ class User extends Api ...@@ -323,4 +341,6 @@ class User extends Api
$this->error($this->auth->getError()); $this->error($this->auth->getError());
} }
} }
} }
...@@ -478,3 +478,20 @@ if (!function_exists('check_ip_allowed')) { ...@@ -478,3 +478,20 @@ if (!function_exists('check_ip_allowed')) {
} }
} }
} }
if (!function_exists('decimalNotation')){
/*还原科学计数*/
function decimalNotation($num)
{
$parts = explode('E', $num);
if (count($parts) != 2) {
return $num;
}
$exp = abs(end($parts)) + 3;
$decimal = number_format($num, $exp, '.', '');
$decimal = rtrim($decimal, '0');
return rtrim($decimal, '.');
}
}
\ No newline at end of file
...@@ -131,23 +131,23 @@ class Auth ...@@ -131,23 +131,23 @@ class Auth
* @param array $extend 扩展参数 * @param array $extend 扩展参数
* @return boolean * @return boolean
*/ */
public function register($username, $password, $email = '', $mobile = '',$popularizeId = '', $extend = []) public function register($username, $password, $email = '', $mobile = '',$popularizeId = '', $extend = [],$parent_id='',$type=User::TYPE_YNS)
{ {
// 检测用户名、昵称、邮箱、手机号是否存在 // 检测用户名、昵称、邮箱、手机号是否存在
if (User::getByUsername($username)) { if (User::getByUsername($username)) {
$this->setError('Username already exist'); $this->setError(__('Username already exist'));
return false; return false;
} }
if (User::getByNickname($username)) { if (User::getByNickname($username)) {
$this->setError('Nickname already exist'); $this->setError(__('Nickname already exist'));
return false; return false;
} }
if ($email && User::getByEmail($email)) { if ($email && User::getByEmail($email)) {
$this->setError('Email already exist'); $this->setError(__('Email already exist'));
return false; return false;
} }
if ($mobile && User::getByMobile($mobile)) { if ($mobile && User::getByMobile($mobile)) {
$this->setError('Mobile already exist'); $this->setError(__('Moile already existb'));
return false; return false;
} }
...@@ -163,6 +163,8 @@ class Auth ...@@ -163,6 +163,8 @@ class Auth
'level' => 1, 'level' => 1,
'score' => 0, 'score' => 0,
'avatar' => '', 'avatar' => '',
'parent_id'=>$parent_id,
'type' =>$type
]; ];
$params = array_merge($data, [ $params = array_merge($data, [
'nickname' => preg_match("/^1[3-9]{1}\d{9}$/",$username) ? substr_replace($username,'****',3,4) : $username, 'nickname' => preg_match("/^1[3-9]{1}\d{9}$/",$username) ? substr_replace($username,'****',3,4) : $username,
...@@ -172,7 +174,9 @@ class Auth ...@@ -172,7 +174,9 @@ class Auth
'logintime' => $time, 'logintime' => $time,
'loginip' => $ip, 'loginip' => $ip,
'prevtime' => $time, 'prevtime' => $time,
'status' => 'normal' 'status' => 'normal',
'parent_id' => $parent_id,
'type' => $type
]); ]);
$params['password'] = $this->getEncryptPassword($password, $params['salt']); $params['password'] = $this->getEncryptPassword($password, $params['salt']);
$params = array_merge($params, $extend); $params = array_merge($params, $extend);
...@@ -209,10 +213,10 @@ class Auth ...@@ -209,10 +213,10 @@ class Auth
* @param string $password 密码 * @param string $password 密码
* @return boolean * @return boolean
*/ */
public function login($account, $password) public function login($account, $password,$type=1)
{ {
$field = Validate::is($account, 'email') ? 'email' : (Validate::regex($account, '/^1\d{10}$/') ? 'mobile' : 'username'); $field = Validate::is($account, 'email') ? 'email' : (Validate::regex($account, '/^1\d{10}$/') ? 'mobile' : 'username');
$user = User::get([$field => $account]); $user = User::get([$field => $account,'type'=>$type]);
if (!$user) { if (!$user) {
$this->setError('Account is incorrect'); $this->setError('Account is incorrect');
return false; return false;
......
<?php
namespace app\common\model;
use think\Model;
/**
* 平级分销
*/
class TtCode Extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $updateTime = false;
// 追加属性
protected $append = [
];
/**
* 修改邀请码状态
* @param $user_id
* @param $parent_id
* @param $code
* @return TtCode
*/
public static function updateCode($user_id,$parent_id,$code)
{
return self::where('code',$code)->update(['status'=>1,'user_id'=>$user_id,'parent_id'=>$parent_id]);
}
}
<?php
namespace app\common\model;
use think\Model;
/**
* 三级分销
*/
class TtDistribution Extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $updateTime = false;
// 追加属性
protected $append = [
];
}
<?php
namespace app\common\model;
use think\Model;
/**
* 平级分销
*/
class TtLevelReward Extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $updateTime = false;
// 追加属性
protected $append = [
];
/**
* 获取平级奖励价格
* @param $group_id 角色ID
* @return bool|float|mixed|string|null
*/
public static function getPrice($group_id)
{
return self::where('group_id',$group_id)->value('price');
}
}
...@@ -183,7 +183,7 @@ class User extends Frontend ...@@ -183,7 +183,7 @@ class User extends Frontend
$this->error(__($validate->getError()), null, ['token' => $this->request->token()]); $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
return false; return false;
} }
if ($this->auth->login($account, $password)) { if ($this->auth->login($account, $password,\app\common\model\User::TYPE_YNS)) {
$this->success(__('Logged in successful'), $url ? $url : url('index/order')); $this->success(__('Logged in successful'), $url ? $url : url('index/order'));
} else { } else {
$this->error($this->auth->getError(), null, ['token' => $this->request->token()]); $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
......
...@@ -22,15 +22,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -22,15 +22,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
url: $.fn.bootstrapTable.defaults.extend.index_url, url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id', pk: 'id',
sortName: 'id', sortName: 'id',
// 搜索按钮框展开
searchFormVisible: true,
// 隐藏搜索按钮
showSearch: false,
//隐藏搜索框
search:false,
//隐藏切换按钮
showToggle: false,
//隐藏列按钮
showColumns: false,
//隐藏导出按钮
showExport: false,
columns: [ columns: [
[ [
{checkbox: true}, // {checkbox: true},
{field: 'id', title: __('Id')}, {field: 'id', title: __('Id'), operate:false},
{field: 'code', title: __('Code')}, {field: 'code', title: __('Code'), operate:'LIKE'},
{field: 'user_id', title: __('User_id')}, {field: 'user_id', title: __('User_id'), searchList: $.getJSON('tt_code/admin_user')},
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status}, {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
] ]
] ]
}); });
......
...@@ -6,9 +6,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -6,9 +6,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
Table.api.init({ Table.api.init({
extend: { extend: {
index_url: 'tt_distribution/index' + location.search, index_url: 'tt_distribution/index' + location.search,
add_url: 'tt_distribution/add', // add_url: 'tt_distribution/add',
edit_url: 'tt_distribution/edit', edit_url: 'tt_distribution/edit',
del_url: 'tt_distribution/del', // del_url: 'tt_distribution/del',
multi_url: 'tt_distribution/multi', multi_url: 'tt_distribution/multi',
import_url: 'tt_distribution/import', import_url: 'tt_distribution/import',
table: 'tt_distribution', table: 'tt_distribution',
...@@ -22,13 +22,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -22,13 +22,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
url: $.fn.bootstrapTable.defaults.extend.index_url, url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id', pk: 'id',
sortName: 'id', sortName: 'id',
// 隐藏搜索按钮
showSearch: false,
//隐藏搜索框
search:false,
//隐藏切换按钮
showToggle: false,
//隐藏列按钮
showColumns: false,
//隐藏导出按钮
showExport: false,
columns: [ columns: [
[ [
{checkbox: true}, // {checkbox: true},
{field: 'id', title: __('Id')}, // {field: 'id', title: __('Id')},
{field: 'primary_distribution', title: __('Primary_distribution')}, {field: 'primary_distribution', title: __('Primary_distribution'), formatter: Controller.api.formatter.percent},
{field: 'secondary_distribution', title: __('Secondary_distribution')}, {field: 'secondary_distribution', title: __('Secondary_distribution'), formatter: Controller.api.formatter.percent},
{field: 'third_distribution', title: __('Third_distribution')}, {field: 'third_distribution', title: __('Third_distribution'), formatter: Controller.api.formatter.percent},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
] ]
] ]
...@@ -46,6 +56,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -46,6 +56,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
api: { api: {
bindevent: function () { bindevent: function () {
Form.api.bindevent($("form[role=form]")); Form.api.bindevent($("form[role=form]"));
},
formatter: {
percent:function(value, row) {
return '<span>'+value+'%</span>';
}
} }
} }
}; };
......
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'tt_ex/index' + location.search,
add_url: 'tt_ex/add',
edit_url: 'tt_ex/edit',
del_url: 'tt_ex/del',
multi_url: 'tt_ex/multi',
import_url: 'tt_ex/import',
table: 'tt_ex',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'order_id', title: __('Order_id')},
{field: 'enddate', title: __('Enddate')},
{field: 'create_time', title: __('Create_time')},
{field: 'pay_time', title: __('Pay_time')},
{field: 'refund_time', title: __('Refund_time')},
{field: 'channel_id', title: __('Channel_id')},
{field: 'channel_name', title: __('Channel_name')},
{field: 'code_id', title: __('Code_id')},
{field: 'real_money', title: __('Real_money')},
{field: 'shop_id', title: __('Shop_id')},
{field: 'shop_name', title: __('Shop_name')},
{field: 'shop_price', title: __('Shop_price')},
{field: 'shop_quantity', title: __('Shop_quantity')},
{field: 'class_three_name', title: __('Class_three_name')},
{field: 'class_two_name', title: __('Class_two_name')},
{field: 'class_name', title: __('Class_name')},
{field: 'name', title: __('Name')},
// {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
...@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
index_url: 'tt_level_reward/index' + location.search, index_url: 'tt_level_reward/index' + location.search,
add_url: 'tt_level_reward/add', add_url: 'tt_level_reward/add',
edit_url: 'tt_level_reward/edit', edit_url: 'tt_level_reward/edit',
del_url: 'tt_level_reward/del', // del_url: 'tt_level_reward/del',
multi_url: 'tt_level_reward/multi', multi_url: 'tt_level_reward/multi',
import_url: 'tt_level_reward/import', import_url: 'tt_level_reward/import',
table: 'tt_level_reward', table: 'tt_level_reward',
...@@ -22,12 +22,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -22,12 +22,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
url: $.fn.bootstrapTable.defaults.extend.index_url, url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id', pk: 'id',
sortName: 'id', sortName: 'id',
// 隐藏搜索按钮
showSearch: false,
//隐藏搜索框
search:false,
//隐藏切换按钮
showToggle: false,
//隐藏列按钮
showColumns: false,
//隐藏导出按钮
showExport: false,
columns: [ columns: [
[ [
{checkbox: true}, // {checkbox: true},
{field: 'id', title: __('Id')}, // {field: 'id', title: __('Id')},
{field: 'group_id', title: __('Group_id')}, {field: 'group_id', title: __('Group_id')},
{field: 'price', title: __('Price'), operate:'BETWEEN'}, {field: 'price', title: __('Price'), operate:'BETWEEN',formatter: Controller.api.formatter.company},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
] ]
] ]
...@@ -45,6 +55,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -45,6 +55,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
api: { api: {
bindevent: function () { bindevent: function () {
Form.api.bindevent($("form[role=form]")); Form.api.bindevent($("form[role=form]"));
},
formatter: {
company:function(value, row) {
return '<span>'+value+'元/单</span>';
}
} }
} }
}; };
......
File added
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论