Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
introducer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sugar
introducer
Commits
7f670f99
Commit
7f670f99
authored
Jun 27, 2023
by
twj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
twj
parent
9c9f3f59
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
165 additions
and
33 deletions
+165
-33
application/admin/controller/device/Site.php
application/admin/controller/device/Site.php
+56
-5
application/admin/view/device/site/authorizedevice.html
application/admin/view/device/site/authorizedevice.html
+36
-0
application/admin/view/device/site/index.html
application/admin/view/device/site/index.html
+11
-1
application/api/controller/shopro/Commission.php
application/api/controller/shopro/Commission.php
+3
-3
application/extra/site.php
application/extra/site.php
+29
-9
public/assets/js/backend/device/site.js
public/assets/js/backend/device/site.js
+30
-15
No files found.
application/admin/controller/device/Site.php
View file @
7f670f99
...
...
@@ -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
();
}
}
application/admin/view/device/site/authorizedevice.html
0 → 100644
View file @
7f670f99
<!--
* @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>
application/admin/view/device/site/index.html
View file @
7f670f99
<!--
* @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>
...
...
application/api/controller/shopro/Commission.php
View file @
7f670f99
...
...
@@ -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 1
0:02:59
* @LastEditTime: 2023-06-08 1
5: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
(
's
ite.s
hop_commission_rate'
);
//获取团长资金情况
$puserInfo
=
UsersModel
::
where
([
'id'
=>
$userInfo
[
'pid'
]])
->
find
();
//判断团长身份等级
...
...
application/extra/site.php
View file @
7f670f99
<?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
,
]
);
public/assets/js/backend/device/site.js
View file @
7f670f99
...
...
@@ -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]
"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment