Commit 7f670f99 authored by twj's avatar twj

twj

parent 9c9f3f59
......@@ -26,6 +26,7 @@ class Site extends Backend
parent::_initialize();
$this->model = new \app\admin\model\device\Site;
$this->Chargegroupmodel = new \app\admin\model\device\Chargegroup();
$this->Chargedevicemodel = new \app\admin\model\device\Chargedevice();
$this->view->assign("statusList", $this->model->getStatusList());
}
......@@ -95,11 +96,11 @@ class Site extends Backend
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
$group_name = $this->Chargegroupmodel->where(['id' =>$params['group_id']])->value('group_name');
$group_name = $this->Chargegroupmodel->where(['id' => $params['group_id']])->value('group_name');
$params['area_name'] = $group_name;
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
} catch (ValidateException | PDOException | Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
......@@ -145,11 +146,11 @@ class Site extends Backend
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$group_name = $this->Chargegroupmodel->where(['id' =>$params['group_id']])->value('group_name');
$group_name = $this->Chargegroupmodel->where(['id' => $params['group_id']])->value('group_name');
$params['area_name'] = $group_name;
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
} catch (ValidateException | PDOException | Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
......@@ -158,6 +159,56 @@ class Site extends Backend
}
$this->success();
}
/**
* 授权设备
*
* @return string
* @throws \think\Exception
*/
public function authorizedevice()
{
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);
}
//判断设备数量够不够
$deviceAmount = $this->Chargedevicemodel->where(['user_id' => 0, 'authorizestatus' => 1, 'group_id' => $params['group_id']])->count('1');
if ($params['amount'] > $deviceAmount) {
Db::rollback();
$this->error("当前选择小区可授权设备不足!只剩" . $deviceAmount);
}
$site = $this->model->where(['agent_user_id' => $params['agent_user_id'], 'group_id' => $params['group_id']])->find();
$update_arr['user_id'] = $params['agent_user_id'];
$update_arr['authorizestatus'] = 2;
$update_arr['authorizetime'] = strtotime(date('Y-m-d'))+86400;
$update_arr['site_id'] = $site['id'];
$this->Chargedevicemodel->where(['user_id' => 0, 'authorizestatus' => 1, 'group_id' => $params['group_id']])->limit($params['amount'])->update($update_arr);
Db::commit();
$this->success('操作成功');
} catch (ValidateException | PDOException | Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
}
<!--
* @Author: taowj 965042433@qq.com
* @Date: 2023-06-27 17:16:00
* @LastEditors: taowj 965042433@qq.com
* @LastEditTime: 2023-06-27 17:20:43
* @FilePath: \introducer\application\admin\view\device\site\authorisedevice.html
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<form id="authorisedevice-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">{:__('Agent_user_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-agent_user_id" data-rule="required" data-source="users/users/index" data-search-field="id,realname" data-primary-key="id" data-field="realname" data-format-item="{id} - {realname}" class="form-control selectpage" name="row[agent_user_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('选择所在站点')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-group_id" data-rule="required" data-source="device/chargegroup/index" data-field="group_name" data-primary-key="id" class="form-control selectpage" data-format-item="{id} - {group_name} - {old_id}" name="row[group_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('输入设备数量')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-amount" data-rule="required" class="form-control" name="row[amount]" type="number">
</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>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
<!--
* @Author: taowj 965042433@qq.com
* @Date: 2022-11-08 16:21:34
* @LastEditors: taowj 965042433@qq.com
* @LastEditTime: 2023-06-27 19:58:44
* @FilePath: \introducer\application\admin\view\device\site\index.html
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<div class="panel panel-default panel-intro">
<div class="panel-heading">
......@@ -20,7 +28,9 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('device/site/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('device/site/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('device/site/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a data-url="device/site/authorizedevice" id='authorizedevice' class="btn btn-info" data-title="{:__('批量授权设备')}" ><i class="fa"></i> {:__('批量授权设备')}</a>
<div class="dropdown btn-group {:$auth->check('device/site/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>
......
......@@ -3,7 +3,7 @@
* @Author: taowj 965042433@qq.com
* @Date: 2023-06-06 16:07:57
* @LastEditors: taowj 965042433@qq.com
* @LastEditTime: 2023-06-08 10:02:59
* @LastEditTime: 2023-06-08 15:15:08
* @FilePath: \introducer\application\api\controller\Commission.php
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -192,7 +192,7 @@ class Commission extends Api
$pAgentInfo = AgentModel::where(['agent_user_id' => $userInfo['pid'], 'status' => 1])->find();
if ($pAgentInfo) {
//获取分佣比例
$commissionRate = Config::get('recharge_commission_rate');
$commissionRate = Config::get('site.recharge_commission_rate');
//获取团长资金情况
$puserInfo = UsersModel::where(['id' => $userInfo['pid']])->find();
//判断团长身份等级
......@@ -336,7 +336,7 @@ class Commission extends Api
$pAgentInfo = AgentModel::where(['agent_user_id' => $userInfo['pid'], 'status' => 1])->find();
if ($pAgentInfo) {
//获取分佣比例
$commissionRate = Config::get('shop_commission_rate');
$commissionRate = Config::get('site.shop_commission_rate');
//获取团长资金情况
$puserInfo = UsersModel::where(['id' => $userInfo['pid']])->find();
//判断团长身份等级
......
<?php
/*
* @Author: taowj 965042433@qq.com
* @Date: 2023-06-08 13:49:07
* @LastEditors: taowj 965042433@qq.com
* @LastEditTime: 2023-06-08 15:14:01
* @FilePath: \introducer\application\extra\site.php
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
return array (
return array(
'name' => '引充者充电桩',
'beian' => '',
'cdnurl' => '',
'version' => '1.0.5',
'timezone' => 'Asia/Shanghai',
'forbiddenip' => '',
'languages' =>
array (
'languages' =>
array(
'backend' => 'zh-cn',
'frontend' => 'zh-cn',
),
'fixedpage' => 'dashboard',
'categorytype' =>
array (
'categorytype' =>
array(
'default' => 'Default',
'page' => 'Page',
'article' => 'Article',
'test' => 'Test',
),
'configgroup' =>
array (
'configgroup' =>
array(
'basic' => 'Basic',
'email' => 'Email',
'dictionary' => 'Dictionary',
......@@ -35,11 +43,23 @@ return array (
'mail_smtp_pass' => 'password',
'mail_verify_type' => '2',
'mail_from' => '10000@qq.com',
'attachmentcategory' =>
array (
'attachmentcategory' =>
array(
'category1' => 'Category1',
'category2' => 'Category2',
'custom' => 'Custom',
),
'recharge_gift_pack' => '100',
//充值分佣比例
'recharge_commission_rate' => [
'city' => 0.02,
'area' => 0.03,
'maker' => 0.05,
],
//商城分佣比例
'shop_commission_rate' => [
'city' => 0.02,
'area' => 0.03,
'maker' => 0.05,
]
);
......@@ -11,6 +11,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
del_url: 'device/site/del',
multi_url: 'device/site/multi',
import_url: 'device/site/import',
authorizedevice_url: 'device/site/authorizedevice',
table: 'site',
}
});
......@@ -24,32 +25,43 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'agent_user_id', title: __('Agent_user_id'),
formatter: function (value,row,index) {
if(row.users){
var html="id:"+row.agent_user_id + "<br/> 昵称:" + row.users.nickname;
html = row.realname?html+"<br/> 姓名:" + row.realname:html;
html = row.users.mobile?html+"<br/> 电话:" + row.users.mobile:html;
{ checkbox: true },
{ field: 'id', title: __('Id') },
{
field: 'agent_user_id', title: __('Agent_user_id'),
formatter: function (value, row, index) {
if (row.users) {
var html = "id:" + row.agent_user_id + "<br/> 昵称:" + row.users.nickname;
html = row.users.realname ? html + "<br/> 姓名:" + row.users.realname : html;
html = row.users.mobile ? html + "<br/> 电话:" + row.users.mobile : html;
return html;
} else {
return "id:" + row.agent_user_id;
}
}},
{field: 'area.MergerName', title: __('所属区域')},
}
},
{ field: 'area.MergerName', title: __('所属区域') },
// {field: 'province_id', title: __('Province_id')},
// {field: 'city_id', title: __('City_id')},
// {field: 'area_id', title: __('Area_id')},
{field: 'area_name', title: __('Area_name'), operate: 'LIKE'},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{ field: 'area_name', title: __('Area_name'), operate: 'LIKE' },
{ field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
{ field: 'status', title: __('Status'), searchList: { "1": __('Status 1'), "2": __('Status 2') }, formatter: Table.api.formatter.status },
{ field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate }
]
]
});
// 绑定用户
$('#authorizedevice').click(function () {
var url = $(this).attr('data-url');
var title = $(this).attr('title');
Fast.api.open("device/site/authorizedevice", '批量设备授权', {
callback: function (value) {
console.log(value);
}
});
})
// 为表格绑定事件
Table.api.bindevent(table);
},
......@@ -59,6 +71,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
edit: function () {
Controller.api.bindevent();
},
authorizedevice: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment