添加优惠码,工作机
This commit is contained in:
parent
72523df3fa
commit
7690b1e40f
38
application/admin/controller/Coupons.php
Normal file
38
application/admin/controller/Coupons.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 优惠码规则表,用于存储所有优惠码及其规则信息
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Coupons extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* Coupons模型对象
|
||||
* @var \app\admin\model\Coupons
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\Coupons;
|
||||
$this->view->assign("discountTypeList", $this->model->getDiscountTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ class Order extends Backend
|
|||
*/
|
||||
protected $model = null;
|
||||
protected $sources = null;
|
||||
protected $items = null;
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
|
@ -53,8 +54,44 @@ class Order extends Backend
|
|||
// Tree::instance()->init($sources);
|
||||
// $data = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
|
||||
// dd($data);
|
||||
|
||||
$items = Db::name('item')
|
||||
->where('status',1)
|
||||
->field(['id','title','key_word','pid'])
|
||||
->order('pid','asc')
|
||||
->order('sort','desc')
|
||||
->select();
|
||||
|
||||
$phones = Db::name('phones')
|
||||
->where('assigned_user',$this->auth->id)
|
||||
->field(['id','model','phone_number'])
|
||||
->select();
|
||||
|
||||
$this->items = $items;
|
||||
$filtered = array_filter($items, function($item) {
|
||||
return $item['pid'] == 0;
|
||||
});
|
||||
|
||||
$pid_map = array_column($filtered,null,'id');
|
||||
$res_items = [];
|
||||
foreach ($items as $item){
|
||||
if ($item['pid'] != 0 && isset($pid_map[$item['pid']])){
|
||||
$res_items [] = [
|
||||
...$item,'ptitle' => $pid_map[$item['pid']]['title']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$coupons = Db::name('coupons')
|
||||
->where('status','active')
|
||||
->field(['id','code','description'])
|
||||
->select();
|
||||
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("sources", $res);
|
||||
$this->view->assign("coupons", $coupons);
|
||||
$this->view->assign("items", $res_items);
|
||||
$this->view->assign("phones", $phones);
|
||||
//$this->view->assign("collectList", $this->model->getCollectList());
|
||||
//$this->view->assign("dispatchTypeList", $this->model->getDispatchTypeList());
|
||||
}
|
||||
|
|
@ -81,10 +118,15 @@ class Order extends Backend
|
|||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->field(['id','order_no','customer','tel','status','area_id','address',
|
||||
->field(['id','order_no','user_id','customer','tel','status','area_id','address',
|
||||
'source','source_shop','source_uid','source','item_title','item_id',
|
||||
'detail','remark','images','create_time','update_time'])
|
||||
->where($where)
|
||||
->with(['user' => function($q){
|
||||
$q->field('id,nickname');
|
||||
},'area' => function($q){
|
||||
$q->field('id,area_code,merge_name');
|
||||
}])
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
|
|
@ -116,8 +158,11 @@ class Order extends Backend
|
|||
}
|
||||
|
||||
$sources = $this->sources;
|
||||
$items = $this->items;
|
||||
$sources = array_column($sources,'title','id');
|
||||
$items = array_column($items,'title','id');
|
||||
$params['source_shop'] = $sources[$params['source']] ?? null;
|
||||
$params['item_title'] = $items[$params['item_id']] ?? null;
|
||||
$params['user_id'] = $this->auth->id;
|
||||
$params['status'] = 10;
|
||||
$params['order_no'] = $this->generateOrderNumber();
|
||||
|
|
@ -163,6 +208,7 @@ class Order extends Backend
|
|||
$data['update_time'] = date('Y-m-d H:i:s');
|
||||
$sources = $this->sources;
|
||||
$sources = array_column($sources,'title','id');
|
||||
// $data['user_id'] = $this->auth->id;
|
||||
$data['source_shop'] = $sources[$data['source']] ?? null;
|
||||
// 更新订单信息
|
||||
$order->save($data);
|
||||
|
|
|
|||
160
application/admin/controller/Phones.php
Normal file
160
application/admin/controller/Phones.php
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Phones extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* Phones模型对象
|
||||
* @var \app\admin\model\Phones
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\Phones;
|
||||
|
||||
$users = Db::name('admin')
|
||||
// ->where('status',1)
|
||||
->field(['id','nickname'])
|
||||
->select();
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("users", $users);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
//如果发送的来源是 Selectpage,则转发到 Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->with(['user' => function($q){
|
||||
$q->field('id,nickname');
|
||||
}])
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
return json($result);
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$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()->validate($validate);
|
||||
}
|
||||
if ($params['assigned_user'] != 0){
|
||||
$params['status'] = 'assigned';
|
||||
$params['assigned_date'] = date('Y-m-d H:i:s');
|
||||
}else{
|
||||
$params['status'] = 'available';
|
||||
$params['assigned_date'] = null;
|
||||
}
|
||||
|
||||
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException|PDOException|Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result === false) {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
public function edit($ids = null)
|
||||
{
|
||||
if (!$ids) {
|
||||
if (request()->isPost()){
|
||||
$ids = input('id');
|
||||
if (!$ids){
|
||||
$this->error('缺少订单ID');
|
||||
}
|
||||
}else{
|
||||
$this->error('缺少订单ID');
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前ID对应的订单信息
|
||||
$order = $this->model->get($ids);
|
||||
if (!$order) {
|
||||
$this->error('订单不存在');
|
||||
}
|
||||
|
||||
// 判断是否为POST请求,进行更新操作
|
||||
if (request()->isPost()) {
|
||||
// 获取表单提交的数据
|
||||
$data = input('post.row/a');
|
||||
|
||||
if ($data['assigned_user'] != 0){
|
||||
$data['status'] = 'assigned';
|
||||
$data['assigned_date'] = date('Y-m-d H:i:s');
|
||||
}else{
|
||||
$data['status'] = 'available';
|
||||
$data['assigned_date'] = null;
|
||||
}
|
||||
// 更新订单信息
|
||||
$order->save($data);
|
||||
|
||||
// 返回成功信息
|
||||
$this->success('更新成功', 'index');
|
||||
}
|
||||
// 将订单数据传递到视图
|
||||
$this->assign('row', $order);
|
||||
|
||||
// 渲染编辑页面
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
20
application/admin/lang/zh-cn/coupons.php
Normal file
20
application/admin/lang/zh-cn/coupons.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'Id' => '优惠码唯一标识',
|
||||
'Code' => '优惠码名称',
|
||||
'Description' => '优惠码描述',
|
||||
'Discount_type' => '折扣类型',
|
||||
'Min_order' => '最低消费金额',
|
||||
'Max_discount' => '最大优惠金额',
|
||||
'Status' => '状态',
|
||||
'Threshold' => '优惠门槛',
|
||||
'Discount_value' => '优惠金额',
|
||||
'Created_at' => '创建时间',
|
||||
'Updated_at' => '更新时间',
|
||||
'Percentage' => '百分比优惠',
|
||||
|
||||
'Fixed' => '固定优惠',
|
||||
'Active' => '可用',
|
||||
'Inactive' => '禁用',
|
||||
];
|
||||
|
|
@ -57,5 +57,6 @@ return [
|
|||
'Payment_time' => '付款时间',
|
||||
'Finishe_time' => '完成时间',
|
||||
'Dispatch_time' => '派单时间',
|
||||
'Delete_time' => '删除时间'
|
||||
'Delete_time' => '删除时间',
|
||||
'Coupons' => '优惠',
|
||||
];
|
||||
|
|
|
|||
10
application/admin/lang/zh-cn/phones.php
Normal file
10
application/admin/lang/zh-cn/phones.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'Phone_number' => '手机号码',
|
||||
'Model' => '型号',
|
||||
'Assigned_user' => '使用者',
|
||||
'Assigned_date' => '使用时期',
|
||||
'Available' => '空闲',
|
||||
'Assigned' => '已分配',
|
||||
];
|
||||
63
application/admin/model/Coupons.php
Normal file
63
application/admin/model/Coupons.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Coupons extends Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'coupons';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = false;
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'discount_type_text',
|
||||
'status_text'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getDiscountTypeList()
|
||||
{
|
||||
return ['fixed' => __('Fixed'), 'percentage' => __('Percentage')];
|
||||
}
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['active' => __('Active'), 'inactive' => __('Inactive')];
|
||||
}
|
||||
|
||||
|
||||
public function getDiscountTypeTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['discount_type'] ?? '');
|
||||
$list = $this->getDiscountTypeList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['status'] ?? '');
|
||||
$list = $this->getStatusList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -99,7 +99,11 @@ class Order extends Model
|
|||
}
|
||||
|
||||
|
||||
public function admin(){
|
||||
return $this->belongsTo(Admin::class,'audit_admin_id',);
|
||||
public function user(){
|
||||
return $this->belongsTo(Admin::class,'user_id',);
|
||||
}
|
||||
|
||||
public function area(){
|
||||
return $this->belongsTo(Area::class,'area_id','area_code');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
47
application/admin/model/Phones.php
Normal file
47
application/admin/model/Phones.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Phones extends Model
|
||||
{
|
||||
|
||||
// 表名
|
||||
protected $name = 'phones';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = false;
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['available' => __('Available'), 'assigned' => __('Assigned')];
|
||||
}
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['status'] ?? '');
|
||||
$list = $this->getStatusList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function user(){
|
||||
return $this->belongsTo(Admin::class,'assigned_user');
|
||||
}
|
||||
}
|
||||
27
application/admin/validate/Coupons.php
Normal file
27
application/admin/validate/Coupons.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Coupons extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
||||
27
application/admin/validate/Phones.php
Normal file
27
application/admin/validate/Phones.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Phones extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
||||
81
application/admin/view/coupons/add.html
Normal file
81
application/admin/view/coupons/add.html
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<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">{:__('Code')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-code" data-rule="required" class="form-control" name="row[code]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Description')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-description" class="form-control" name="row[description]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Discount_type')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
||||
<select id="c-discount_type" data-rule="required" class="form-control selectpicker" name="row[discount_type]">
|
||||
{foreach name="discountTypeList" item="vo"}
|
||||
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Min_order')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-min_order" class="form-control" step="0.01" name="row[min_order]" type="number" value="0.00">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Max_discount')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-max_discount" class="form-control" step="0.01" name="row[max_discount]" type="number" value="0.00">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="active"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Threshold')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-threshold" data-rule="required" class="form-control" step="0.01" name="row[threshold]" type="number">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Discount_value')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-discount_value" data-rule="required" class="form-control" step="0.01" name="row[discount_value]" type="number">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Created_at')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-created_at" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[created_at]" 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">{:__('Updated_at')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-updated_at" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[updated_at]" type="text" value="{:date('Y-m-d H:i:s')}">
|
||||
</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-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
81
application/admin/view/coupons/edit.html
Normal file
81
application/admin/view/coupons/edit.html
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<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">{:__('Code')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-code" data-rule="required" class="form-control" name="row[code]" type="text" value="{$row.code|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Description')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-description" class="form-control" name="row[description]" type="text" value="{$row.description|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Discount_type')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
||||
<select id="c-discount_type" data-rule="required" class="form-control selectpicker" name="row[discount_type]">
|
||||
{foreach name="discountTypeList" item="vo"}
|
||||
<option value="{$key}" {in name="key" value="$row.discount_type"}selected{/in}>{$vo}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Min_order')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-min_order" class="form-control" step="0.01" name="row[min_order]" type="number" value="{$row.min_order|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Max_discount')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-max_discount" class="form-control" step="0.01" name="row[max_discount]" type="number" value="{$row.max_discount|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Threshold')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-threshold" data-rule="required" class="form-control" step="0.01" name="row[threshold]" type="number" value="{$row.threshold|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Discount_value')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-discount_value" data-rule="required" class="form-control" step="0.01" name="row[discount_value]" type="number" value="{$row.discount_value|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Created_at')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-created_at" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[created_at]" type="text" value="{:$row.created_at?datetime($row.created_at):''}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Updated_at')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-updated_at" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[updated_at]" type="text" value="{:$row.updated_at?datetime($row.updated_at):''}">
|
||||
</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-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
46
application/admin/view/coupons/index.html
Normal file
46
application/admin/view/coupons/index.html
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<div class="panel panel-default panel-intro">
|
||||
|
||||
<div class="panel-heading">
|
||||
{:build_heading(null,FALSE)}
|
||||
<ul class="nav nav-tabs" data-field="status">
|
||||
<li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
|
||||
{foreach name="statusList" item="vo"}
|
||||
<li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<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('coupons/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('coupons/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('coupons/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
|
||||
|
||||
<div class="dropdown btn-group {:$auth->check('coupons/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">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
data-operate-edit="{:$auth->check('coupons/edit')}"
|
||||
data-operate-del="{:$auth->check('coupons/del')}"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -51,19 +51,41 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Coupons')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-coupon" data-live-search="true" title="请选择" data-rule="required" name="row[coupon_id]" class="form-control selectpicker show-tick">
|
||||
<option selected value="0">不使用优惠</option>
|
||||
{foreach $coupons as $item}
|
||||
<option data-subtext="{$item['description']}" value="{$item['id']}">{$item['code']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Item_title')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-service_title" data-rule="required" class="form-control" name="row[item_title]" type="text" value="">
|
||||
|
||||
<!-- 选项下拉框 -->
|
||||
<ul id="service-list" class="dropdown-menu" style="display: none;"></ul>
|
||||
|
||||
<!-- 存储选择的 area_code -->
|
||||
<input type="hidden" id="selected-service_id" name="row[item_id]">
|
||||
<select id="citem" data-live-search="true" title="请选择" data-rule="required" name="row[item_id]" class="form-control selectpicker show-tick">
|
||||
{foreach $items as $item}
|
||||
<option data-subtext="{$item['key_word']}" value="{$item['id']}">{$item['title']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Work_tel_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="Work_tel_id" data-live-search="true" title="请选择" data-rule="required" name="row[item_id]" class="form-control selectpicker show-tick">
|
||||
{foreach $phones as $item}
|
||||
<option data-subtext="{$item['phone_number']}" value="{$item['id']}">{$item['model']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Detail')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
<label class="control-label col-xs-12 col-sm-3">{:__('Source')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-source" data-live-search="true" data-value="{$row.source}" data-rule="required" name="row[source]" class="form-control selectpicker">
|
||||
{foreach $sources as $item}
|
||||
{foreach $users as $item}
|
||||
<option data-subtext="{$item['ptitle']}" {if $item['id'] == $row.source} selected {/if} value="{$item['id']}">{$item['title']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
|
|
|
|||
32
application/admin/view/phones/add.html
Normal file
32
application/admin/view/phones/add.html
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<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">{:__('Phone_number')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-phone_number" data-rule="required" class="form-control" name="row[phone_number]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Model')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-model" data-rule="required" class="form-control" name="row[model]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Assigned_user')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="citem" data-live-search="true" title="请选择" data-rule="required" name="row[assigned_user]" class="form-control selectpicker show-tick">
|
||||
<option value="0">不分配</option>
|
||||
{foreach $users as $item}
|
||||
<option value="{$item['id']}">{$item['nickname']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</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-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
32
application/admin/view/phones/edit.html
Normal file
32
application/admin/view/phones/edit.html
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<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">{:__('Phone_number')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-phone_number" data-rule="required" class="form-control" name="row[phone_number]" type="text" value="{$row.phone_number|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Model')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-model" data-rule="required" class="form-control" name="row[model]" type="text" value="{$row.model|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Assigned_user')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="citem" data-live-search="true" title="请选择" data-rule="required" name="row[assigned_user]" class="form-control selectpicker show-tick">
|
||||
<option value="0">不分配</option>
|
||||
{foreach $users as $item}
|
||||
<option {if $item['id'] == $row.assigned_user} selected {/if} value="{$item['id']}">{$item['nickname']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</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-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
46
application/admin/view/phones/index.html
Normal file
46
application/admin/view/phones/index.html
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<div class="panel panel-default panel-intro">
|
||||
|
||||
<div class="panel-heading">
|
||||
{:build_heading(null,FALSE)}
|
||||
<ul class="nav nav-tabs" data-field="status">
|
||||
<li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
|
||||
{foreach name="statusList" item="vo"}
|
||||
<li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<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('phones/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('phones/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('phones/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
|
||||
|
||||
<div class="dropdown btn-group {:$auth->check('phones/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">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
data-operate-edit="{:$auth->check('phones/edit')}"
|
||||
data-operate-del="{:$auth->check('phones/del')}"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
62
public/assets/js/backend/coupons.js
Normal file
62
public/assets/js/backend/coupons.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'coupons/index' + location.search,
|
||||
add_url: 'coupons/add',
|
||||
edit_url: 'coupons/edit',
|
||||
del_url: 'coupons/del',
|
||||
multi_url: 'coupons/multi',
|
||||
import_url: 'coupons/import',
|
||||
table: 'coupons',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'code', title: __('Code'), operate: 'LIKE'},
|
||||
{field: 'description', title: __('Description'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'discount_type', title: __('Discount_type'), searchList: {"fixed":__('Fixed'),"percentage":__('Percentage')}, formatter: Table.api.formatter.normal},
|
||||
{field: 'min_order', title: __('Min_order'), operate:'BETWEEN'},
|
||||
{field: 'max_discount', title: __('Max_discount'), operate:'BETWEEN'},
|
||||
{field: 'status', title: __('Status'), searchList: {"active":__('Active'),"inactive":__('Inactive')}, formatter: Table.api.formatter.status},
|
||||
{field: 'threshold', title: __('Threshold'), operate:'BETWEEN'},
|
||||
{field: 'discount_value', title: __('Discount_value'), operate:'BETWEEN'},
|
||||
{field: 'created_at', title: __('Created_at')},
|
||||
{field: 'updated_at', title: __('Updated_at')},
|
||||
{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;
|
||||
});
|
||||
|
|
@ -28,6 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'user.nickname', title: '录单员'},
|
||||
{field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
|
||||
{field: 'customer', title: __('Customer'), operate: 'LIKE'},
|
||||
{field: 'tel', title: __('Tel'), operate: 'LIKE'},
|
||||
|
|
@ -46,7 +47,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
},
|
||||
formatter: Table.api.formatter.status
|
||||
},
|
||||
{field: 'area_id', title: __('Area_id')},
|
||||
{field: 'area.merge_name', title: __('Area_id')},
|
||||
{
|
||||
field: 'address',
|
||||
title: __('Address'),
|
||||
|
|
|
|||
55
public/assets/js/backend/phones.js
Normal file
55
public/assets/js/backend/phones.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'phones/index' + location.search,
|
||||
add_url: 'phones/add',
|
||||
edit_url: 'phones/edit',
|
||||
del_url: 'phones/del',
|
||||
multi_url: 'phones/multi',
|
||||
import_url: 'phones/import',
|
||||
table: 'phones',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'phone_number', title: __('Phone_number'), operate: 'LIKE'},
|
||||
{field: 'model', title: __('Model'), operate: 'LIKE'},
|
||||
{field: 'user.nickname', title: __('Assigned_user')},
|
||||
{field: 'assigned_date', title: __('Assigned_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
{field: 'status', title: __('Status'), searchList: {"available":__('Available'),"assigned":__('Assigned')}, formatter: Table.api.formatter.status},
|
||||
{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;
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user