作者 耿培杰

修改

... ... @@ -73,4 +73,57 @@ class OrderAddress extends Backend
}
return $this->view->fetch();
}
/**
* 编辑
*/
public function edit($ids = null)
{
$orderId = $this->request->param('order_id');
$row = $this->model->where('order_id',$orderId)->find();
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);
return $this->view->fetch();
}
}
... ...
... ... @@ -36,9 +36,10 @@ class OrderAddressInvoice extends Backend
*/
public function edit($ids = null)
{
$row = $this->model->get($ids);
$orderId = $this->request->param('order_id');
$row = $this->model->where('order_id',$orderId)->find();
if (!$row) {
$this->error('此订单不需要开发票','');
$this->error('此订单不需要开发票','','','');
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
... ...
... ... @@ -2,8 +2,9 @@
namespace app\admin\controller;
use app\api\model\UserTicket;
use app\common\controller\Backend;
use think\Db;
/**
* 优惠券管理
*
... ... @@ -24,6 +25,7 @@ class Ticket extends Backend
$this->model = new \app\admin\model\Ticket;
$this->view->assign("settingShareList", $this->model->getSettingShareList());
$this->view->assign("settingMonthList", $this->model->getSettingMonthList());
$this->view->assign("typeList", $this->model->getTypeList());
}
/**
... ... @@ -31,6 +33,168 @@ class Ticket extends Backend
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 添加
*/
public function add()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$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 . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
if ($params['type'] == 2 && empty($params['fill_price'])) $this->error('使用价格不能为空');
$result = $this->model->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 inserted'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
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);
}
if ($params['type'] == 2 && empty($params['fill_price'])) $this->error('使用价格不能为空');
$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);
return $this->view->fetch();
}
/**
* 发放
*/
public function grant()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$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 . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
$userTicketModel = new UserTicket();
$userIds = explode(',',$params['user_ids']);
//默认全部用户
$ticketInfo = $this->model->where('id',$params['ticket_id'])->find();
$data = [];
foreach ($userIds as $k => $userId){
$date = explode('-',date('Y-m-d',strtotime('+ '.$ticketInfo['days'].'day')));
$time = mktime(23,59,00,$date[1],$date[2],$date[0]);
$data[] = [
'user_id' => $userId,
'ticket_id' => $ticketInfo['id'],
'fill_price'=>$ticketInfo['fill_price'],
'ch_name' => $ticketInfo['ch_name'],
'en_name' => $ticketInfo['en_name'],
'price' => $ticketInfo['price'],
'type' => 1, //获取途径:1=后台发放,2=其他
'status' => 1, //状态:1=未使用,2=已使用,3=已过期
'pasttime' => $time //过期时间
];
}
$result = $userTicketModel->saveAll($data);
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 inserted'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
return $this->view->fetch();
}
}
... ...
... ... @@ -17,6 +17,8 @@ return [
'Country.ch_name' => '国家名称',
'Image' => '图片',
'Images' => '轮播',
'Video' => '视频',
'Video_image' => '视频封面',
'Goods_no' => '商品编码',
'Ch_specification' => '中文包装规格',
'En_specification' => '英文包装规格',
... ... @@ -39,6 +41,11 @@ return [
'Group_agency_rebate' => '团购代理返利',
'Group_price' => '团购价格',
'Goods_price' => '普通价格',
'Vip1_price' => '会员价格',
'Staff_price' => '员工价格',
'One_agency_price' => '一级代理价格',
'Two_agency_price' => '二级代理价格',
'Three_agency_price' => '三级代理价格',
'Vip_price' => '会员特价价格',
'Is_vip_price' => '会员特价',
'Is_vip_price 1' => '开启',
... ...
... ... @@ -6,9 +6,13 @@ return [
'En_name' => '英文名称',
'Price' => '优惠价格',
'Days' => '有效天数',
'Fill_price' => '使用价格',
'Setting_share' => '分享获得',
'Setting_share 1' => '是',
'Setting_share 2' => '否',
'Type' => '类型',
'Type 1' => '抵扣券',
'Type 2' => '满减抵扣券',
'Setting_month' => '会员获得',
'Setting_month 1' => '是',
'Setting_month 2' => '否',
... ...
... ... @@ -32,6 +32,8 @@ return [
'Type 1' => '普通用户',
'Type 2' => '会员',
'Type 3' => '员工',
'Type 4' => '代理',
'Type 4' => '一级代理',
'Type 5' => '二级代理',
'Type 6' => '三级代理',
'Leave password blank if dont want to change' => '不修改密码请留空',
];
... ...
... ... @@ -7,11 +7,6 @@ use think\Model;
class Ticket extends Model
{
// 表名
protected $name = 'ticket';
... ... @@ -41,6 +36,10 @@ class Ticket extends Model
return ['1' => __('Setting_month 1'), '2' => __('Setting_month 2')];
}
public function getTypeList()
{
return ['1' => __('Type 1'), '2' => __('Type 2')];
}
public function getSettingShareTextAttr($value, $data)
{
... ...
... ... @@ -63,7 +63,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('En_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-en_name" class="form-control" name="row[en_name]" type="text">
<input id="c-en_name" data-rule="required" class="form-control" name="row[en_name]" type="text">
</div>
</div>
<div class="form-group">
... ... @@ -95,6 +95,34 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Video')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-video" class="form-control" size="50" name="row[video]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-video" class="btn btn-danger plupload" data-input-id="c-video" data-mimetype="mp4,mp3,avi,flv,wmv" data-multiple="false" data-preview-id="p-video"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-video" class="btn btn-primary fachoose" data-input-id="c-video" data-mimetype="mp4,mp3,avi,flv,wmv" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-video"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Video_image')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-video_image" class="form-control" size="50" name="row[video_image]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-video_image" class="btn btn-danger plupload" data-input-id="c-video_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-video_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-video_image" class="btn btn-primary fachoose" data-input-id="c-video_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-video_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-video_image"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Goods_no')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-goods_no" class="form-control" name="row[goods_no]" type="text">
... ... @@ -205,7 +233,37 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Goods_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-goods_price" class="form-control" step="0.01" name="row[goods_price]" type="number">
<input id="c-goods_price" data-rule="required" class="form-control" step="0.01" name="row[goods_price]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Vip1_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-vip1_price" data-rule="required" class="form-control" step="0.01" name="row[vip1_price]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Staff_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-staff_price" data-rule="required" class="form-control" step="0.01" name="row[staff_price]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('One_agency_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-one_agency_price" data-rule="required" class="form-control" step="0.01" name="row[one_agency_price]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Two_agency_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-two_agency_price" data-rule="required" class="form-control" step="0.01" name="row[two_agency_price]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Three_agency_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-three_agency_price" data-rule="required" class="form-control" step="0.01" name="row[three_agency_price]" type="number">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -95,6 +95,35 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Video')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-video" class="form-control" size="50" name="row[video]" type="text" value="{$row.video|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-video" class="btn btn-danger plupload" data-input-id="c-video" data-mimetype="mp4,mp3,avi,flv,wmv" data-multiple="false" data-preview-id="p-video"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-video" class="btn btn-primary fachoose" data-input-id="c-video" data-mimetype="mp4,mp3,avi,flv,wmv" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-video"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Video_image')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-video_image" class="form-control" size="50" name="row[video_image]" type="text" value="{$row.video_image|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-video_image" class="btn btn-danger plupload" data-input-id="c-video_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-video_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-video_image" class="btn btn-primary fachoose" data-input-id="c-video_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-video_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-video_image"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Goods_no')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-goods_no" class="form-control" name="row[goods_no]" type="text" value="{$row.goods_no|htmlentities}">
... ... @@ -205,7 +234,37 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Goods_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-goods_price" class="form-control" step="0.01" name="row[goods_price]" type="number" value="{$row.goods_price|htmlentities}">
<input id="c-goods_price" data-rule="required" class="form-control" step="0.01" name="row[goods_price]" type="number" value="{$row.goods_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Vip1_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-vip1_price" data-rule="required" class="form-control" step="0.01" name="row[vip1_price]" type="number" value="{$row.vip1_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Staff_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-staff_price" data-rule="required" class="form-control" step="0.01" name="row[staff_price]" type="number" value="{$row.staff_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('One_agency_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-one_agency_price" data-rule="required" class="form-control" step="0.01" name="row[one_agency_price]" type="number" value="{$row.one_agency_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Two_agency_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-two_agency_price" data-rule="required" class="form-control" step="0.01" name="row[two_agency_price]" type="number" value="{$row.two_agency_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Three_agency_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-three_agency_price" data-rule="required" class="form-control" step="0.01" name="row[three_agency_price]" type="number" value="{$row.three_agency_price|htmlentities}">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -19,6 +19,24 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group fill_price" style="display: none;">
<label class="control-label col-xs-12 col-sm-2">{:__('Fill_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-fill_price" class="form-control" step="0.01" name="row[fill_price]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Days')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-days" class="form-control" step="0.01" name="row[days]" type="number">
... ...
... ... @@ -19,6 +19,24 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group fill_price" style="display: none;">
<label class="control-label col-xs-12 col-sm-2">{:__('Fill_price')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-fill_price" class="form-control" step="0.01" name="row[fill_price]" type="number" value="{$row.fill_price|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Days')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-days" class="form-control" step="0.01" name="row[days]" type="number" value="{$row.days|htmlentities}">
... ...
... ... @@ -7,6 +7,7 @@
<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-grant {:$auth->check('ticket/grant')?'':'hide'}" title="发放" ><i class="fa fa-plus"></i>发放</a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('ticket/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('ticket/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('ticket/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
... ...
... ... @@ -52,7 +52,7 @@
<div class="form-group">
<label for="content" class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_radios('row[type]', ['1'=>__('Type 1'), '2'=>__('Type 2'), '3'=>__('Type 3'), '4'=>__('Type 4')], $row['type'])}
{:build_radios('row[type]', ['1'=>__('Type 1'), '2'=>__('Type 2'), '3'=>__('Type 3'), '4'=>__('Type 4'), '5'=>__('Type 5'), '6'=>__('Type 6')], $row['type'])}
</div>
</div>
<div class="form-group">
... ...
... ... @@ -69,26 +69,70 @@ function get_rebate($money, $user_type)
/*
* 根据商品状态和用户身份获取最终价格
*/
//function get_price($arr)
//{
// //会员特价
// if (!empty($arr['is_vip_price']) && $arr['is_vip_price'] == 1 && $arr['user_type'] == 2) return $arr['vip_price'];
// //团购价格
// if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 1) return $arr['group_price'];
// if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 2) return get_vip_price_default($arr['group_price']);
// if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 3) return get_staff_price_default($arr['group_price']);
// if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 4) return get_agency_price_default($arr['group_price']);
//
// //代理基础价
// if ($arr['user_type'] == 4) {
// return get_agency_price_default($arr['goods_price']);
// } elseif ($arr['user_type'] == 3) {
// //员工基础价
// return get_staff_price_default($arr['goods_price']);
// } elseif ($arr['user_type'] == 2) {
// //会员基础价
// return get_vip_price_default($arr['goods_price']);
// }
// //原价
// return $arr['goods_price'];
//}
function get_price_not_group($arr)
{
//会员特价
if (!empty($arr['is_vip_price']) && $arr['is_vip_price'] == 1 && $arr['user_type'] == 2) return $arr['vip_price'];
//积分商品
if (!empty($arr['integral'])) return $arr['goods_price'];
//会员价
if ($arr['user_type'] == 2) return $arr['vip1_price'];
//员工价
if ($arr['user_type'] == 3) return $arr['staff_price'];
//一级代理价
if ($arr['user_type'] == 4) return $arr['one_agency_price'];
//二级代理价
if ($arr['user_type'] == 5) return $arr['two_agency_price'];
//三级代理价
if ($arr['user_type'] == 6) return $arr['three_agency_price'];
//原价
return $arr['goods_price'];
}
/*
* 根据商品状态和用户身份获取最终价格
*/
function get_price($arr)
{
//会员特价
if (!empty($arr['is_vip_price']) && $arr['is_vip_price'] == 1 && $arr['user_type'] == 2) return $arr['vip_price'];
//团购价格
if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 1) return $arr['group_price'];
if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 2) return get_vip_price_default($arr['group_price']);
if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 3) return get_staff_price_default($arr['group_price']);
if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 4) return get_agency_price_default($arr['group_price']);
//代理基础价
if ($arr['user_type'] == 4) {
return get_agency_price_default($arr['goods_price']);
} elseif ($arr['user_type'] == 3) {
//员工基础价
return get_staff_price_default($arr['goods_price']);
} elseif ($arr['user_type'] == 2) {
//会员基础价
return get_vip_price_default($arr['goods_price']);
}
//积分商品
if (!empty($arr['integral'])) return $arr['goods_price'];
//团购商品
if (!empty($arr['is_group']) && $arr['is_group'] == 1) return $arr['group_price'];
//会员价
if ($arr['user_type'] == 2) return $arr['vip1_price'];
//员工价
if ($arr['user_type'] == 3) return $arr['staff_price'];
//一级代理价
if ($arr['user_type'] == 4) return $arr['one_agency_price'];
//二级代理价
if ($arr['user_type'] == 5) return $arr['two_agency_price'];
//三级代理价
if ($arr['user_type'] == 6) return $arr['three_agency_price'];
//原价
return $arr['goods_price'];
}
... ... @@ -100,24 +144,49 @@ function get_discount_price($arr)
{
//会员特价
if (!empty($arr['is_vip_price']) && $arr['is_vip_price'] == 1 && $arr['user_type'] == 2) return $arr['goods_price'] - $arr['vip_price'];
//团购价格
if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 2) return $arr['group_price'] - get_vip_price_default($arr['group_price']);
if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 3) return $arr['group_price'] - get_staff_price_default($arr['group_price']);
if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 4) return $arr['group_price'] - get_agency_price_default($arr['group_price']);
//代理基础价折扣
if ($arr['user_type'] == 4) {
return $arr['goods_price'] - get_agency_price_default($arr['goods_price']);
} elseif ($arr['user_type'] == 3) {
//员工基础价折扣
return $arr['goods_price'] - get_staff_price_default($arr['goods_price']);
} elseif ($arr['user_type'] == 2) {
//会员基础价折扣
return $arr['goods_price'] - get_vip_price_default($arr['goods_price']);
}
//积分商品
if (!empty($arr['integral'])) return 0;
//团购商品
if (!empty($arr['is_group'])) return $arr['goods_price'] - $arr['group_price'];
//会员价
if ($arr['user_type'] == 2) return $arr['goods_price'] - $arr['vip1_price'];
//员工价
if ($arr['user_type'] == 3) return $arr['goods_price'] - $arr['staff_price'];
//一级代理价
if ($arr['user_type'] == 4) return $arr['goods_price'] - $arr['one_agency_price'];
//二级代理价
if ($arr['user_type'] == 5) return $arr['goods_price'] - $arr['two_agency_price'];
//三级代理价
if ($arr['user_type'] == 6) return $arr['goods_price'] - $arr['three_agency_price'];
//原价
return 0;
}
/*
* 根据商品状态和用户身份获取折扣价
*/
//function get_discount_price($arr)
//{
// //会员特价
// if (!empty($arr['is_vip_price']) && $arr['is_vip_price'] == 1 && $arr['user_type'] == 2) return $arr['goods_price'] - $arr['vip_price'];
// //团购价格
// if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 2) return $arr['group_price'] - get_vip_price_default($arr['group_price']);
// if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 3) return $arr['group_price'] - get_staff_price_default($arr['group_price']);
// if (!empty($arr['is_group']) && $arr['is_group'] == 1 && $arr['user_type'] == 4) return $arr['group_price'] - get_agency_price_default($arr['group_price']);
// //代理基础价折扣
// if ($arr['user_type'] == 4) {
// return $arr['goods_price'] - get_agency_price_default($arr['goods_price']);
// } elseif ($arr['user_type'] == 3) {
// //员工基础价折扣
// return $arr['goods_price'] - get_staff_price_default($arr['goods_price']);
// } elseif ($arr['user_type'] == 2) {
// //会员基础价折扣
// return $arr['goods_price'] - get_vip_price_default($arr['goods_price']);
// }
// //原价
// return 0;
//}
/**
* 期间日期
* @param $startDate
... ...
... ... @@ -80,6 +80,10 @@ class Car extends Api
$limit = Config::get('paginate.index_rows');
$data = $this->carModel->selectPageData($where,$page,$limit,$this->lang);
foreach ($data['list'] as $k => $v){
$v['user_type'] = $this->user['type'];
$data['list'][$k]['price'] = get_price_not_group($v);
}
$this->success('SUCCESS',$data);
}
... ... @@ -117,7 +121,6 @@ class Car extends Api
$discount_price += get_discount_price($v);
$original_price += $v['goods_price'];
if (!empty($v['integral'])) $data['integral'] += $v['integral'];
}
$data['price'] = round($price,2);
$data['discount_price'] = round($discount_price,2);
... ... @@ -173,10 +176,10 @@ class Car extends Api
if (!$validate->check($data)) {
$this->error($validate->getError());
}
if($data['type'] == 1){
$is_group = Db::name('goods')->where(['id'=>$data['goods_id'],'is_group'=>1])->count();
if ($is_group) $this->error('团购商品不可以加入购物车');
}
// if($data['type'] == 1){
// $is_group = Db::name('goods')->where(['id'=>$data['goods_id'],'is_group'=>1])->count();
// if ($is_group) $this->error('团购商品不可以加入购物车');
// }
$stock_num = Db::name('goods')->where(['id'=>$data['goods_id']])->value('stock_num');
if (!$stock_num) $this->error('库存不足');
... ...
... ... @@ -136,6 +136,10 @@ class Goods extends Api
$where['g.is_recommend'] = 2;
}
$data = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang);
foreach ($data['list'] as $k => $v){
$v['user_type'] = $this->user['type'];
$data['list'][$k]['price'] = get_price_not_group($v);
}
$this->success('请求成功', $data);
}
... ... @@ -230,6 +234,10 @@ class Goods extends Api
$data['category_three'] = $this->categoryModel->selectData(['pid'=>$params['category_two_id']],null,$this->lang);
//获取列表数据
$data['list'] = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang);
foreach ($data['list']['list'] as $k => $v){
$v['user_type'] = $this->user['type'];
$data['list']['list'][$k]['price'] = get_price_not_group($v);
}
$this->success('请求成功', $data);
}
... ... @@ -327,7 +335,10 @@ class Goods extends Api
$data['extend'] = $this->categoryModel->getExtend($where,$this->lang);
//获取列表数据
$data['list'] = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang);
foreach ($data['list']['list'] as $k => $v){
$v['user_type'] = $this->user['type'];
$data['list']['list'][$k]['price'] = get_price_not_group($v);
}
$this->success('请求成功', $data);
}
... ... @@ -391,7 +402,8 @@ class Goods extends Api
$carModel = new \app\api\model\Car;
$data['is_car'] = $carModel->where(['user_id'=>$userId,'goods_id'=>$data['goods_id']])->count();
}
$data['user_type'] = $this->user['type'];
$data['price'] = get_price($data);
$this->success('请求成功', $data);
}
}
... ...
... ... @@ -56,7 +56,10 @@ class GroupGoods extends Api
$where['g.is_group'] = 1;
$data = $this->goodsModel->selectData($where, 5,$this->lang);
foreach ($data as $k => $v){
$v['user_type'] = $this->user['type'];
$data[$k]['price'] = get_price($v);
}
$this->success('请求成功', $data);
}
... ... @@ -93,6 +96,10 @@ class GroupGoods extends Api
$limit = Config::get('paginate.index_rows');
$where['g.is_group'] = 1;
$data = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang);
foreach ($data['list'] as $k => $v){
$v['user_type'] = $this->user['type'];
$data['list'][$k]['price'] = get_price($v);
}
$this->success('请求成功', $data);
}
... ...
... ... @@ -67,6 +67,7 @@ class Member extends Api
* @ApiRoute (/api/member/getUserTicket)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name=status, type=string, required=true, description="状态:1=未使用,2=已使用,3=已过期")
* @ApiParams (name=price, type=string, required=false, description="价格 确认订单页传,用于查询满减优惠价")
* @ApiParams (name=page, type=string, required=true, description="页数")
* @ApiReturn({
"code": 1,
... ... @@ -79,6 +80,7 @@ class Member extends Api
"user_ticket_id": 1, 用户优惠券id
"pasttime": "2017-07-10 18:28", 截至时间
"price": "5.00", 优惠价格
"fill_price": "100", 满减使用价格 有值为满减优惠券,返回空值为抵扣券
"ch_name": "邀请用户", 优惠券中文名称
"en_name": null 优惠券英文名称
}
... ... @@ -92,13 +94,17 @@ class Member extends Api
$userId = $this->getUserId();
$status = $this->request->param('status');
$page = $this->request->param('page');
$price = $this->request->param('price');
$limit = Config::get('paginate.index_rows');
if (empty($status)) $this->error('缺少参数 status!');
$where['user_id'] = $userId;
$where['status'] = $status;
if (!empty($price)){
$where['ut.fill_price'] = null;
}
$data = $model->selectPageData($where, $page, $limit,$this->lang);
$data = $model->selectPageData($where, $page, $limit,$this->lang,$price);
$this->success('SUCCESS', $data);
}
... ...
... ... @@ -135,7 +135,7 @@ class Order extends Api
//判断优惠券是否可用
if (!empty($ticketId)) {
$ticketInfo = $userTicketModel->where(['user_id' => $userId, 'id' => $ticketId, 'status' => 1])->find();
if (!$ticketInfo) $this->error('优惠不存在!');
if (!$ticketInfo) $this->error('优惠不存在!');
}
//获取原价,现价,折扣
... ... @@ -190,6 +190,7 @@ class Order extends Api
//使用优惠券
if (!empty($ticketInfo)) {
if ($data['price'] - $postage < $ticketInfo['fill_price']) $this->error('优惠券不可使用');
$data['price'] = $data['price'] - $ticketInfo['price'];
$data['ticket_discount_price'] = $ticketInfo['price'];
}
... ... @@ -308,7 +309,7 @@ class Order extends Api
//判断优惠券是否可用
if (!empty($param['ticket_user_id'])) {
$ticketInfo = $this->userTicketModel->where(['user_id' => $userId, 'id' => $param['ticket_user_id'], 'status' => 1])->find();
if (!$ticketInfo) $this->error('优惠不存在!');
if (!$ticketInfo) $this->error('优惠不存在!');
}
//获取原价,现价,折扣
... ... @@ -368,6 +369,7 @@ class Order extends Api
//使用优惠券
if (!empty($ticketInfo)) {
if ($data['price'] - $postage < $ticketInfo['fill_price']) $this->error('优惠券不可使用');
$data['price'] = $data['price'] - $ticketInfo['price'];
$data['ticket_discount_price'] = $ticketInfo['price'];
$data['user_ticket_id'] = $ticketInfo['id'];
... ... @@ -543,11 +545,10 @@ class Order extends Api
//判断优惠券是否可用
if (!empty($ticketId)) {
$ticketInfo = $userTicketModel->where(['user_id' => $userId, 'id' => $ticketId, 'status' => 1])->find();
if (!$ticketInfo) $this->error('优惠不存在!');
if (!$ticketInfo) $this->error('优惠不存在!');
}
//获取原价,现价,折扣
$goodsInfo['user_type'] = $this->user['type'];
$data['price'] = round(get_price($goodsInfo), 2); //折扣后价格
$data['discount_price'] = round(get_discount_price($goodsInfo), 2);//折扣金额
$data['original_price'] = $goodsInfo['goods_price'];//原价
... ... @@ -592,6 +593,7 @@ class Order extends Api
//使用优惠券
if (!empty($ticketInfo)) {
if ($data['price'] - $postage < $ticketInfo['fill_price']) $this->error('优惠券不可使用');
$data['price'] = $data['price'] - $ticketInfo['price'];
$data['ticket_discount_price'] = $ticketInfo['price'];
}
... ... @@ -700,11 +702,10 @@ class Order extends Api
//判断优惠券是否可用
if (!empty($param['ticket_user_id'])) {
$ticketInfo = $userTicketModel->where(['user_id' => $userId, 'id' => $param['ticket_user_id'], 'status' => 1])->find();
if (!$ticketInfo) $this->error('优惠不存在!');
if (!$ticketInfo) $this->error('优惠不存在!');
}
//获取原价,现价,折扣
$goodsInfo['user_type'] = $this->user['type'];
$data['price'] = round(get_price($goodsInfo), 2); //折扣后价格
$data['discount_price'] = round(get_discount_price($goodsInfo), 2);//折扣金额
$data['original_price'] = $goodsInfo['goods_price'];//原价
... ... @@ -752,6 +753,7 @@ class Order extends Api
//使用优惠券
if (!empty($ticketInfo)) {
if ($data['price'] - $postage < $ticketInfo['fill_price']) $this->error('优惠券不可使用');
$data['price'] = $data['price'] - $ticketInfo['price'];
$data['ticket_discount_price'] = $ticketInfo['price'];
$data['user_ticket_id'] = $ticketInfo['id'];
... ... @@ -900,10 +902,9 @@ class Order extends Api
$data['price'] = 0; //折扣后价格
$data['discount_price'] = 0; //折扣金额
$data['original_price'] = 0; //原价
$goodsInfo['user_type'] = $this->user['type'];
$data['price'] += round(get_price($goodsInfo), 2);
$data['discount_price'] += round(get_discount_price($goodsInfo), 2);
$data['original_price'] += $goodsInfo['group_price'];
$data['original_price'] += $goodsInfo['goods_price'];
//获取运费
$is_special = $this->areaExtendModel->where(['province_id' => $provinceId])->value('is_special');
... ... @@ -1038,7 +1039,7 @@ class Order extends Api
$goodsInfo['user_type'] = $this->user['type'];
$data['price'] += round(get_price($goodsInfo), 2);
$data['discount_price'] += round(get_discount_price($goodsInfo), 2);
$data['original_price'] += $goodsInfo['group_price'];
$data['original_price'] += $goodsInfo['goods_price'];
//获取运费
$is_special = $this->areaExtendModel->where(['province_id' => $param['province_id']])->value('is_special');
... ...
... ... @@ -25,8 +25,8 @@ class Car extends Model
}
public function selectPageData($where,$page,$limit,$lang){
if ($lang == 'ch') $field = 'c.id car_id,c.createtime,cou.ch_name country_name,c.number,c.type,g.id goods_id,g.ch_name name,g.image,g.goods_price,g.group_price,g.vip_price,g.is_vip_price,g.is_group';
else $field = 'c.id car_id,c.createtime,cou.en_name country_name,c.number,c.type,g.id goods_id,g.en_name name,g.image,g.goods_price,g.group_price,g.vip_price,g.is_vip_price,g.is_group';
if ($lang == 'ch') $field = 'c.id car_id,c.createtime,cou.ch_name country_name,c.number,c.type,g.id goods_id,g.ch_name name,g.image,g.goods_price,g.group_price,g.vip_price,g.is_vip_price,g.vip1_price,g.vip1_price,g.one_agency_price,g.two_agency_price,g.three_agency_price';
else $field = 'c.id car_id,c.createtime,cou.en_name country_name,c.number,c.type,g.id goods_id,g.en_name name,g.image,g.goods_price,g.group_price,g.vip_price,g.is_vip_price,g.vip1_price,g.vip1_price,g.one_agency_price,g.two_agency_price,g.three_agency_price';
$total =$this->alias('c')
->where($where)
... ... @@ -47,7 +47,15 @@ class Car extends Model
$goodsList = $this->alias('c')
->join('fa_goods g','c.goods_id=g.id')
->where(['c.id'=>['in',$goodsId]])
->field('g.id,goods_price*number goods_price,g.vip_price*number vip_price,g.is_vip_price,g.ch_name,g.en_name,g.image,c.number')
->field('g.id,
g.goods_price*number goods_price,
g.vip_price*number vip_price,
g.vip1_price*number vip1_price,
g.staff_price*number staff_price,
g.one_agency_price*number one_agency_price,
g.two_agency_price*number two_agency_price,
g.three_agency_price*number three_agency_price,
g.is_vip_price,g.ch_name,g.en_name,g.image,c.number')
->select();
$integralGoodsId = $this->where($where)->where(['type'=>2])->column('id');
... ...
... ... @@ -120,8 +120,8 @@ class Goods extends Model
{
$where['g.status'] = 1;
if ($lang == 'ch') $field = 'g.id goods_id,g.ch_name name,g.image,g.goods_price,c.ch_name country_name,is_vip_price,group_price,stock_num';
else $field = 'g.id goods_id,g.en_name name,g.image,g.goods_price,c.en_name country_name,is_vip_price,group_price,stock_num';
if ($lang == 'ch') $field = 'g.id goods_id,g.ch_name name,g.image,g.goods_price,is_group,c.ch_name country_name,is_vip_price,group_price,stock_num,g.vip1_price,g.vip1_price,g.one_agency_price,g.two_agency_price,g.three_agency_price';
else $field = 'g.id goods_id,g.en_name name,g.image,g.goods_price,is_group,c.en_name country_name,is_vip_price,group_price,stock_num,g.vip1_price,g.vip1_price,g.one_agency_price,g.two_agency_price,g.three_agency_price';
$data = $this->alias('g')
->join('fa_country c', 'g.country_id=c.id')
... ... @@ -137,8 +137,8 @@ class Goods extends Model
{
$where['g.status'] = 1;
if ($lang == 'ch') $field = 'g.id goods_id,g.ch_name name,g.image,g.goods_price,c.ch_name country_name,is_vip_price,is_group,group_price,vip_price,stock_num';
else $field = 'g.id goods_id,g.en_name name,g.image,g.goods_price,c.en_name country_name,is_vip_price,is_group,group_price,vip_price,stock_num';
if ($lang == 'ch') $field = 'g.id goods_id,g.ch_name name,g.image,g.goods_price,c.ch_name country_name,is_vip_price,is_group,group_price,vip_price,stock_num,g.vip1_price,g.vip1_price,g.one_agency_price,g.two_agency_price,g.three_agency_price';
else $field = 'g.id goods_id,g.en_name name,g.image,g.goods_price,c.en_name country_name,is_vip_price,is_group,group_price,vip_price,stock_num,g.vip1_price,g.vip1_price,g.one_agency_price,g.two_agency_price,g.three_agency_price';
$total = $this->alias('g')
->join('fa_country c', 'g.country_id=c.id')
... ... @@ -165,8 +165,8 @@ class Goods extends Model
{
$where['g.status'] = 1;
if ($lang == 'ch') $field = 'g.id goods_id,g.ch_name name,g.image,g.status,g.goods_price,g.images,g.goods_no,g.ch_specification specification,g.ch_save_where save_where,g.ch_period period,g.ch_content content,g.stock_num,g.sales_actual,g.group_price,g.vip_price,g.is_vip_price,g.is_group,c.ch_name country_name';
else $field = 'g.id goods_id,g.en_name name,g.image,g.status,g.goods_price,g.images,g.goods_no,g.en_specification specification,g.en_save_where save_where,g.en_period period,g.en_content content,g.stock_num,g.sales_actual,g.group_price,g.vip_price,g.is_vip_price,g.is_group,c.en_name country_name';
if ($lang == 'ch') $field = 'g.id goods_id,g.ch_name name,g.image,g.status,g.goods_price,g.images,g.goods_no,g.ch_specification specification,g.ch_save_where save_where,g.ch_period period,g.ch_content content,g.stock_num,g.sales_actual,g.group_price,g.vip_price,g.is_vip_price,g.is_group,c.ch_name country_name,g.vip1_price,g.vip1_price,g.one_agency_price,g.two_agency_price,g.three_agency_price';
else $field = 'g.id goods_id,g.en_name name,g.image,g.status,g.goods_price,g.images,g.goods_no,g.en_specification specification,g.en_save_where save_where,g.en_period period,g.en_content content,g.stock_num,g.sales_actual,g.group_price,g.vip_price,g.is_vip_price,g.is_group,c.en_name country_name,g.vip1_price,g.vip1_price,g.one_agency_price,g.two_agency_price,g.three_agency_price';
$data = $this->alias('g')
->join('fa_country c', 'g.country_id=c.id')
... ...
... ... @@ -21,18 +21,25 @@ class UserTicket extends Model
return date('Y-m-d H:i',$value);
}
public function selectPageData($where,$page,$limit,$lang){
public function selectPageData($where,$page,$limit,$lang,$price = 0){
if ($lang == 'ch') $field = 'ut.id user_ticket_id,ut.pasttime,t.price,t.ch_name name';
else $field = 'ut.id user_ticket_id,ut.pasttime,t.price,t.en_name name';
if ($lang == 'ch') $field = 'ut.id user_ticket_id,ut.pasttime,t.price,ut.fill_price,t.ch_name name';
else $field = 'ut.id user_ticket_id,ut.pasttime,t.price,ut.fill_price,t.en_name name';
$total =$this
->alias('ut')
->where($where)
->whereOr(function ($query) use ($where,$price){
$query->where('user_id', $where['user_id'])->where('ut.fill_price', '<=', $price);
})
->count();
$list = $this->alias('ut')
->join('fa_ticket t','ut.ticket_id=t.id')
->where($where)
->whereOr(function ($query) use ($where,$price){
$query->where('user_id', $where['user_id'])->where('ut.fill_price', '<=', $price);
})
->field($field)
->page($page,$limit)
->select();
... ...
... ... @@ -7452,6 +7452,12 @@
<td>状态:1=未使用,2=已使用,3=已过期</td>
</tr>
<tr>
<td>price</td>
<td>string</td>
<td></td>
<td>价格 确认订单页传,用于查询满减优惠价</td>
</tr>
<tr>
<td>page</td>
<td>string</td>
<td></td>
... ... @@ -7491,6 +7497,10 @@
<input type="string" class="form-control input-sm" id="status" required placeholder="状态:1=未使用,2=已使用,3=已过期" name="status">
</div>
<div class="form-group">
<label class="control-label" for="price">price</label>
<input type="string" class="form-control input-sm" id="price" placeholder="价格 确认订单页传,用于查询满减优惠价" name="price">
</div>
<div class="form-group">
<label class="control-label" for="page">page</label>
<input type="string" class="form-control input-sm" id="page" required placeholder="页数" name="page">
</div>
... ... @@ -7536,6 +7546,7 @@
"user_ticket_id": 1, 用户优惠券id
"pasttime": "2017-07-10 18:28", 截至时间
"price": "5.00", 优惠价格
"fill_price": "100", 满减使用价格 有值为满减优惠券,返回空值为抵扣券
"ch_name": "邀请用户", 优惠券中文名称
"en_name": null 优惠券英文名称
}
... ... @@ -13135,7 +13146,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2020-06-09 17:22:35 </div>
Generated on 2020-06-15 11:03:37 </div>
<div class="col-md-6" align="right">
<a href="./" target="_blank">E-MP market</a>
</div>
... ...
... ... @@ -10,6 +10,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
edit_url: 'ticket/edit',
del_url: 'ticket/del',
multi_url: 'ticket/multi',
grant_url: 'ticket/grant',
table: 'ticket',
}
});
... ... @@ -29,6 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'en_name', title: __('En_name')},
{field: 'price', title: __('Price'), operate:false},
{field: 'days', title: __('Days'), operate:false},
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.label},
{field: 'setting_share', title: __('Setting_share'), searchList: {"1":__('Setting_share 1'),"2":__('Setting_share 2')}, formatter: Table.api.formatter.toggle,yes:1,no:2, operate:false},
{field: 'setting_month', title: __('Setting_month'), searchList: {"1":__('Setting_month 1'),"2":__('Setting_month 2')}, formatter: Table.api.formatter.toggle,yes:1,no:2, operate:false},
{field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
... ... @@ -40,12 +42,43 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 为表格绑定事件
Table.api.bindevent(table);
$(document).on("click",".btn-grant",function(){
Fast.api.open($.fn.bootstrapTable.defaults.extend.grant_url,'发放',{});
});
},
add: function () {
Controller.api.bindevent();
$('#c-type').change(function () {
var type = $('#c-type').val();
if (type === '2'){
$('.fill_price').show();
}else {
$('.fill_price').hide();
$('#c-fill_price').val('');
}
});
},
edit: function () {
Controller.api.bindevent();
var type = $('#c-type').val();
if (type === '2'){
$('.fill_price').show();
}else {
$('.fill_price').hide();
$('#c-fill_price').val('');
}
$('#c-type').change(function () {
var type = $('#c-type').val();
if (type === '2'){
$('.fill_price').show();
}else {
$('.fill_price').hide();
$('#c-fill_price').val('');
}
});
},
grant: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
... ...