mirror of https://gitee.com/karson/fastadmin.git
commit
7edc152cf5
|
|
@ -116,12 +116,12 @@
|
||||||
<input id="c-in_stock" class="form-control" name="row[in_stock]" type="number" value="0">
|
<input id="c-in_stock" class="form-control" name="row[in_stock]" type="number" value="0">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<!--<div class="form-group">-->
|
||||||
<label for="c-category_id" class="control-label col-xs-12 col-sm-2">{:__('Category_id')}:</label>
|
<!--<label for="c-category_id" class="control-label col-xs-12 col-sm-2">{:__('Category_id')}:</label>-->
|
||||||
<div class="col-xs-12 col-sm-8">
|
<!--<div class="col-xs-12 col-sm-8">-->
|
||||||
<input id="c-category_id" data-rule="required" data-source="category/selectpage" data-params='{"custom[type]":"product_tickets"}' class="form-control selectpage" name="row[category_id]" type="text" value="">
|
<!--<input id="c-category_id" data-rule="required" data-source="category/selectpage" data-params='{"custom[type]":"product_tickets"}' class="form-control selectpage" name="row[category_id]" type="text" value="">-->
|
||||||
</div>
|
<!--</div>-->
|
||||||
</div>
|
<!--</div>-->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="c-status" class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
<label for="c-status" class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace app\api\controller;
|
namespace app\api\controller;
|
||||||
|
|
||||||
use app\common\controller\Api;
|
use app\common\controller\Api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -21,51 +22,62 @@ class Order extends Api
|
||||||
parent::_initialize();
|
parent::_initialize();
|
||||||
$this->model = model('Order');
|
$this->model = model('Order');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入订单
|
* 插入订单
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
if (request()->isPost())
|
// if (request()->isPost())
|
||||||
{
|
// {
|
||||||
//$params = $this->request->post("row/a");
|
//$params = $this->request->post("row/a");
|
||||||
$params = input('post.');
|
// $params = input('post.');
|
||||||
if ($params)
|
|
||||||
{
|
$params = array(
|
||||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill)
|
'order_num' => time(),
|
||||||
{
|
'user_id' => '1',
|
||||||
$params[$this->dataLimitField] = $this->auth->id;
|
'travel_start_time' => '2018-01-04',
|
||||||
}
|
'travel_end_time' => '2018-01-09',
|
||||||
try
|
'product_name' => '产品名',
|
||||||
{
|
'order_start_time' => 'order_start_time',
|
||||||
//是否采用模型验证
|
'reconciliation_time' => '2018-01-09 12:33:44',
|
||||||
if ($this->modelValidate)
|
'ota_name' => 'aasd',
|
||||||
{
|
);
|
||||||
$name = basename(str_replace('\\', '/', get_class($this->model)));
|
|
||||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate;
|
// print_r($params);
|
||||||
$this->model->validate($validate);
|
// exit();
|
||||||
}
|
if ($params) {
|
||||||
$result = $this->model->allowField(true)->save($params);
|
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||||
if ($result !== false)
|
$params[$this->dataLimitField] = $this->auth->id;
|
||||||
{
|
}
|
||||||
$this->success('','',json(),[]);
|
try {
|
||||||
}
|
//是否采用模型验证
|
||||||
else
|
if ($this->modelValidate) {
|
||||||
{
|
$name = basename(str_replace('\\', '/', get_class($this->model)));
|
||||||
$this->error($this->getError());
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate;
|
||||||
}
|
$this->model->validate($validate);
|
||||||
}
|
}
|
||||||
catch (\think\exception\PDOException $e)
|
// $result = $this->model->save($params);
|
||||||
{
|
$result = $this->model->allowField(true)->save($params);
|
||||||
$this->error($e->getMessage());
|
if ($result !== false) {
|
||||||
}
|
// success里调用了strtolower
|
||||||
|
// $this->success('', '', json(), []);
|
||||||
|
return json('添加成功', 200, [], '');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$this->error($this->getError());
|
||||||
|
}
|
||||||
|
} catch (\think\exception\PDOException $e) {
|
||||||
|
$this->error($e->getMessage());
|
||||||
}
|
}
|
||||||
$this->error(__('Parameter %s can not be empty', ''));
|
|
||||||
}
|
}
|
||||||
|
$this->error(__('Parameter %s can not be empty', ''));
|
||||||
|
// }
|
||||||
//return $this->view->fetch();
|
//return $this->view->fetch();
|
||||||
return json('',200,[],'');
|
// return json('', 200, [], '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
//设置过滤方法
|
//设置过滤方法
|
||||||
|
|
@ -73,8 +85,7 @@ class Order extends Api
|
||||||
// if ($this->request->isAjax())
|
// if ($this->request->isAjax())
|
||||||
// {
|
// {
|
||||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||||
if ($this->request->request('pkey_name'))
|
if ($this->request->request('pkey_name')) {
|
||||||
{
|
|
||||||
return $this->selectpage();
|
return $this->selectpage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,26 +115,20 @@ class Order extends Api
|
||||||
*/
|
*/
|
||||||
public function del($ids = "")
|
public function del($ids = "")
|
||||||
{
|
{
|
||||||
if ($ids)
|
if ($ids) {
|
||||||
{
|
|
||||||
$pk = $this->model->getPk();
|
$pk = $this->model->getPk();
|
||||||
$adminIds = $this->getDataLimitAdminIds();
|
$adminIds = $this->getDataLimitAdminIds();
|
||||||
if (is_array($adminIds))
|
if (is_array($adminIds)) {
|
||||||
{
|
|
||||||
$count = $this->model->where($this->dataLimitField, 'in', $adminIds);
|
$count = $this->model->where($this->dataLimitField, 'in', $adminIds);
|
||||||
}
|
}
|
||||||
$list = $this->model->where($pk, 'in', $ids)->select();
|
$list = $this->model->where($pk, 'in', $ids)->select();
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($list as $k => $v)
|
foreach ($list as $k => $v) {
|
||||||
{
|
|
||||||
$count += $v->delete();
|
$count += $v->delete();
|
||||||
}
|
}
|
||||||
if ($count)
|
if ($count) {
|
||||||
{
|
$this->success('操作成功', '', json(), []);
|
||||||
$this->success('操作成功','',json(),[]);
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error(__('No rows were deleted'));
|
$this->error(__('No rows were deleted'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
class Order extends Model
|
||||||
|
{
|
||||||
|
// 表名
|
||||||
|
protected $name = 'order';
|
||||||
|
|
||||||
|
// 自动写入时间戳字段
|
||||||
|
protected $autoWriteTimestamp = false;
|
||||||
|
|
||||||
|
// 定义时间戳字段名
|
||||||
|
protected $createTime = false;
|
||||||
|
protected $updateTime = false;
|
||||||
|
|
||||||
|
// 追加属性
|
||||||
|
protected $append = [
|
||||||
|
'order_status_text',
|
||||||
|
'comment_status_text',
|
||||||
|
'order_start_time_text'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getOrderStatusList()
|
||||||
|
{
|
||||||
|
return ['0' => __('Order_status 0'),'1' => __('Order_status 1')];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCommentStatusList()
|
||||||
|
{
|
||||||
|
return ['0' => __('Comment_status 0'),'1' => __('Comment_status 1')];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getOrderStatusTextAttr($value, $data)
|
||||||
|
{
|
||||||
|
$value = $value ? $value : $data['order_status'];
|
||||||
|
$list = $this->getOrderStatusList();
|
||||||
|
return isset($list[$value]) ? $list[$value] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getCommentStatusTextAttr($value, $data)
|
||||||
|
{
|
||||||
|
$value = $value ? $value : $data['comment_status'];
|
||||||
|
$list = $this->getCommentStatusList();
|
||||||
|
return isset($list[$value]) ? $list[$value] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getOrderStartTimeTextAttr($value, $data)
|
||||||
|
{
|
||||||
|
$value = $value ? $value : $data['order_start_time'];
|
||||||
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setOrderStartTimeAttr($value)
|
||||||
|
{
|
||||||
|
return $value && !is_numeric($value) ? strtotime($value) : $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue