Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
纵之格
ShopXO
提交
c3f5f6c0
ShopXO
项目概览
纵之格
/
ShopXO
通知
394
Star
16
Fork
11
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c3f5f6c0
编写于
4月 14, 2022
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增系统类型
上级
72074df3
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
159 addition
and
56 deletion
+159
-56
app/admin/form/User.php
app/admin/form/User.php
+25
-0
app/admin/view/default/user/save_info.html
app/admin/view/default/user/save_info.html
+4
-0
app/service/AppMiniUserService.php
app/service/AppMiniUserService.php
+39
-12
app/service/OrderSplitService.php
app/service/OrderSplitService.php
+26
-4
app/service/PluginsService.php
app/service/PluginsService.php
+26
-7
app/service/SafetyService.php
app/service/SafetyService.php
+11
-11
app/service/UserService.php
app/service/UserService.php
+25
-22
public/core.php
public/core.php
+3
-0
未找到文件。
app/admin/form/User.php
浏览文件 @
c3f5f6c0
...
@@ -68,6 +68,18 @@ class User
...
@@ -68,6 +68,18 @@ class User
'where_type'
=>
'='
,
'where_type'
=>
'='
,
],
],
],
],
[
'label'
=>
'系统类型'
,
'view_type'
=>
'field'
,
'view_key'
=>
'system_type'
,
'is_sort'
=>
1
,
'search_config'
=>
[
'form_type'
=>
'select'
,
'where_type'
=>
'in'
,
'data'
=>
$this
->
UserSystemTypeList
(),
'is_multiple'
=>
1
,
],
],
[
[
'label'
=>
'头像'
,
'label'
=>
'头像'
,
'view_type'
=>
'module'
,
'view_type'
=>
'module'
,
...
@@ -269,5 +281,18 @@ class User
...
@@ -269,5 +281,18 @@ class User
}
}
return
$value
;
return
$value
;
}
}
/**
* 用户系统类型列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-04-14
* @desc description
*/
public
function
UserSystemTypeList
()
{
return
Db
::
name
(
'User'
)
->
group
(
'system_type'
)
->
column
(
'system_type'
,
'system_type'
);
}
}
}
?>
?>
\ No newline at end of file
app/admin/view/default/user/save_info.html
浏览文件 @
c3f5f6c0
...
@@ -9,6 +9,10 @@
...
@@ -9,6 +9,10 @@
<span
class=
"am-text-default"
>
用户{{if empty($data['id'])}}添加{{else /}}编辑{{/if}}
</span>
<span
class=
"am-text-default"
>
用户{{if empty($data['id'])}}添加{{else /}}编辑{{/if}}
</span>
<a
href=
"{{:MyUrl('admin/user/index', $params)}}"
class=
"am-fr am-text-sm am-margin-top-sm am-icon-mail-reply"
>
返回
</a>
<a
href=
"{{:MyUrl('admin/user/index', $params)}}"
class=
"am-fr am-text-sm am-margin-top-sm am-icon-mail-reply"
>
返回
</a>
</legend>
</legend>
<div
class=
"am-form-group"
>
<label>
系统类型
</label>
<input
type=
"text"
name=
"system_type"
class=
"am-radius"
placeholder=
"系统类型"
data-validation-message=
"系统类型 2~60 个字符"
value=
"{{if empty($data['system_type'])}}default{{else /}}{{$data.system_type}}{{/if}}"
/>
</div>
<div
class=
"am-form-group"
>
<div
class=
"am-form-group"
>
<label>
用户名
</label>
<label>
用户名
</label>
<input
type=
"text"
name=
"username"
class=
"am-radius"
placeholder=
"用户名"
data-validation-message=
"用户名 2~30 个字符"
{{
if
!
empty
($
data
)}}
value=
"{{$data.username}}"
{{/
if
}}
/>
<input
type=
"text"
name=
"username"
class=
"am-radius"
placeholder=
"用户名"
data-validation-message=
"用户名 2~30 个字符"
{{
if
!
empty
($
data
)}}
value=
"{{$data.username}}"
{{/
if
}}
/>
...
...
app/service/AppMiniUserService.php
浏览文件 @
c3f5f6c0
...
@@ -21,6 +21,33 @@ use app\service\UserService;
...
@@ -21,6 +21,33 @@ use app\service\UserService;
*/
*/
class
AppMiniUserService
class
AppMiniUserService
{
{
/**
* 读取站点配置信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-13
* @desc description
* @param [string] $key [索引名称]
* @return [mixed] [配置信息值,没找到返回null]
*/
public
static
function
AppMiniConfig
(
$key
)
{
// 获取配置
$value
=
MyC
(
$key
);
// 小程序配置信息读取钩子
$hook_name
=
'plugins_service_appmini_config_value'
;
MyEventTrigger
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
true
,
'key'
=>
$key
,
'value'
=>
&
$value
,
]);
return
$value
;
}
/**
/**
* 支付宝用户授权
* 支付宝用户授权
* @author Devil
* @author Devil
...
@@ -36,7 +63,7 @@ class AppMiniUserService
...
@@ -36,7 +63,7 @@ class AppMiniUserService
if
(
!
empty
(
$params
[
'authcode'
]))
if
(
!
empty
(
$params
[
'authcode'
]))
{
{
// 授权
// 授权
$result
=
(
new
\
base\Alipay
())
->
GetAuthSessionKey
(
MyC
(
'common_app_mini_alipay_appid'
),
$params
[
'authcode'
]);
$result
=
(
new
\
base\Alipay
())
->
GetAuthSessionKey
(
self
::
AppMiniConfig
(
'common_app_mini_alipay_appid'
),
$params
[
'authcode'
]);
if
(
$result
[
'status'
]
==
0
)
if
(
$result
[
'status'
]
==
0
)
{
{
// 先从数据库获取用户信息
// 先从数据库获取用户信息
...
@@ -130,7 +157,7 @@ class AppMiniUserService
...
@@ -130,7 +157,7 @@ class AppMiniUserService
public
static
function
WeixinUserAuth
(
$params
=
[])
public
static
function
WeixinUserAuth
(
$params
=
[])
{
{
// 授权
// 授权
$result
=
(
new
\
base\Wechat
(
MyC
(
'common_app_mini_weixin_appid'
),
MyC
(
'common_app_mini_weixin_appsecret'
)))
->
GetAuthSessionKey
(
$params
);
$result
=
(
new
\
base\Wechat
(
self
::
AppMiniConfig
(
'common_app_mini_weixin_appid'
),
self
::
AppMiniConfig
(
'common_app_mini_weixin_appsecret'
)))
->
GetAuthSessionKey
(
$params
);
if
(
$result
[
'status'
]
==
0
)
if
(
$result
[
'status'
]
==
0
)
{
{
// unionid
// unionid
...
@@ -243,9 +270,9 @@ class AppMiniUserService
...
@@ -243,9 +270,9 @@ class AppMiniUserService
public
static
function
BaiduUserAuth
(
$params
=
[])
public
static
function
BaiduUserAuth
(
$params
=
[])
{
{
$config
=
[
$config
=
[
'appid'
=>
MyC
(
'common_app_mini_baidu_appid'
),
'appid'
=>
self
::
AppMiniConfig
(
'common_app_mini_baidu_appid'
),
'key'
=>
MyC
(
'common_app_mini_baidu_appkey'
),
'key'
=>
self
::
AppMiniConfig
(
'common_app_mini_baidu_appkey'
),
'secret'
=>
MyC
(
'common_app_mini_baidu_appsecret'
),
'secret'
=>
self
::
AppMiniConfig
(
'common_app_mini_baidu_appsecret'
),
];
];
$result
=
(
new
\
base\Baidu
(
$config
))
->
GetAuthSessionKey
(
$params
);
$result
=
(
new
\
base\Baidu
(
$config
))
->
GetAuthSessionKey
(
$params
);
if
(
$result
[
'status'
]
==
0
)
if
(
$result
[
'status'
]
==
0
)
...
@@ -320,9 +347,9 @@ class AppMiniUserService
...
@@ -320,9 +347,9 @@ class AppMiniUserService
if
(
$ret
===
true
)
if
(
$ret
===
true
)
{
{
$config
=
[
$config
=
[
'appid'
=>
MyC
(
'common_app_mini_baidu_appid'
),
'appid'
=>
self
::
AppMiniConfig
(
'common_app_mini_baidu_appid'
),
'key'
=>
MyC
(
'common_app_mini_baidu_appkey'
),
'key'
=>
self
::
AppMiniConfig
(
'common_app_mini_baidu_appkey'
),
'secret'
=>
MyC
(
'common_app_mini_baidu_appsecret'
),
'secret'
=>
self
::
AppMiniConfig
(
'common_app_mini_baidu_appsecret'
),
];
];
$result
=
(
new
\
base\Baidu
(
$config
))
->
DecryptData
(
$auth_data
[
'encrypted_data'
],
$auth_data
[
'iv'
],
$params
[
'openid'
]);
$result
=
(
new
\
base\Baidu
(
$config
))
->
DecryptData
(
$auth_data
[
'encrypted_data'
],
$auth_data
[
'iv'
],
$params
[
'openid'
]);
...
@@ -366,8 +393,8 @@ class AppMiniUserService
...
@@ -366,8 +393,8 @@ class AppMiniUserService
public
static
function
ToutiaoUserAuth
(
$params
=
[])
public
static
function
ToutiaoUserAuth
(
$params
=
[])
{
{
$config
=
[
$config
=
[
'appid'
=>
MyC
(
'common_app_mini_toutiao_appid'
),
'appid'
=>
self
::
AppMiniConfig
(
'common_app_mini_toutiao_appid'
),
'secret'
=>
MyC
(
'common_app_mini_toutiao_appsecret'
),
'secret'
=>
self
::
AppMiniConfig
(
'common_app_mini_toutiao_appsecret'
),
];
];
$result
=
(
new
\
base\Toutiao
(
$config
))
->
GetAuthSessionKey
(
$params
);
$result
=
(
new
\
base\Toutiao
(
$config
))
->
GetAuthSessionKey
(
$params
);
if
(
$result
[
'status'
]
==
0
)
if
(
$result
[
'status'
]
==
0
)
...
@@ -460,7 +487,7 @@ class AppMiniUserService
...
@@ -460,7 +487,7 @@ class AppMiniUserService
if
(
!
empty
(
$params
[
'authcode'
]))
if
(
!
empty
(
$params
[
'authcode'
]))
{
{
// 授权
// 授权
$result
=
(
new
\
base\QQ
(
MyC
(
'common_app_mini_qq_appid'
),
MyC
(
'common_app_mini_qq_appsecret'
)))
->
GetAuthSessionKey
(
$params
[
'authcode'
]);
$result
=
(
new
\
base\QQ
(
self
::
AppMiniConfig
(
'common_app_mini_qq_appid'
),
self
::
AppMiniConfig
(
'common_app_mini_qq_appsecret'
)))
->
GetAuthSessionKey
(
$params
[
'authcode'
]);
if
(
$result
[
'status'
]
==
0
)
if
(
$result
[
'status'
]
==
0
)
{
{
// 先从数据库获取用户信息
// 先从数据库获取用户信息
...
@@ -535,7 +562,7 @@ class AppMiniUserService
...
@@ -535,7 +562,7 @@ class AppMiniUserService
$ret
=
ParamsChecked
(
$auth_data
,
$p
);
$ret
=
ParamsChecked
(
$auth_data
,
$p
);
if
(
$ret
===
true
)
if
(
$ret
===
true
)
{
{
$result
=
(
new
\
base\QQ
(
MyC
(
'common_app_mini_qq_appid'
),
MyC
(
'common_app_mini_qq_appsecret'
)))
->
DecryptData
(
$auth_data
[
'encrypted_data'
],
$auth_data
[
'iv'
],
$params
[
'openid'
]);
$result
=
(
new
\
base\QQ
(
self
::
AppMiniConfig
(
'common_app_mini_qq_appid'
),
self
::
AppMiniConfig
(
'common_app_mini_qq_appsecret'
)))
->
DecryptData
(
$auth_data
[
'encrypted_data'
],
$auth_data
[
'iv'
],
$params
[
'openid'
]);
if
(
is_array
(
$result
))
if
(
is_array
(
$result
))
{
{
$result
[
'nickname'
]
=
isset
(
$result
[
'nickName'
])
?
$result
[
'nickName'
]
:
''
;
$result
[
'nickname'
]
=
isset
(
$result
[
'nickName'
])
?
$result
[
'nickName'
]
:
''
;
...
...
app/service/OrderSplitService.php
浏览文件 @
c3f5f6c0
...
@@ -54,7 +54,7 @@ class OrderSplitService
...
@@ -54,7 +54,7 @@ class OrderSplitService
}
}
// 商品仓库集合
// 商品仓库集合
$warehouse_goods
=
self
::
GoodsWarehouseAggregate
(
$params
[
'goods'
]
);
$warehouse_goods
=
self
::
GoodsWarehouseAggregate
(
$params
);
// 分组商品基础处理
// 分组商品基础处理
$data
=
self
::
GroupGoodsBaseHandle
(
$warehouse_goods
,
$params
);
$data
=
self
::
GroupGoodsBaseHandle
(
$warehouse_goods
,
$params
);
...
@@ -233,16 +233,16 @@ class OrderSplitService
...
@@ -233,16 +233,16 @@ class OrderSplitService
* @version 1.0.0
* @version 1.0.0
* @date 2020-07-18
* @date 2020-07-18
* @desc description
* @desc description
* @param [array] $
data [商品数据
]
* @param [array] $
params [输入参数
]
*/
*/
public
static
function
GoodsWarehouseAggregate
(
$
data
)
public
static
function
GoodsWarehouseAggregate
(
$
params
)
{
{
// 默认仓库
// 默认仓库
$warehouse_default
=
[];
$warehouse_default
=
[];
// 数据分组
// 数据分组
$result
=
[];
$result
=
[];
foreach
(
$
data
as
$v
)
foreach
(
$
params
[
'goods'
]
as
$v
)
{
{
// 不存在规格则使用默认
// 不存在规格则使用默认
$spec
=
empty
(
$v
[
'spec'
])
?
[[
'type'
=>
'默认规格'
,
'value'
=>
'default'
]]
:
$v
[
'spec'
];
$spec
=
empty
(
$v
[
'spec'
])
?
[[
'type'
=>
'默认规格'
,
'value'
=>
'default'
]]
:
$v
[
'spec'
];
...
@@ -259,6 +259,17 @@ class OrderSplitService
...
@@ -259,6 +259,17 @@ class OrderSplitService
$field
=
'distinct w.id,w.name,w.alias,w.lng,w.lat,w.province,w.city,w.county,w.address,wgs.inventory,w.is_default,w.level'
;
$field
=
'distinct w.id,w.name,w.alias,w.lng,w.lat,w.province,w.city,w.county,w.address,wgs.inventory,w.is_default,w.level'
;
$warehouse
=
Db
::
name
(
'WarehouseGoodsSpec'
)
->
alias
(
'wgs'
)
->
join
(
'warehouse_goods wg'
,
'wgs.warehouse_id=wg.warehouse_id'
)
->
join
(
'warehouse w'
,
'wg.warehouse_id=w.id'
)
->
where
(
$where
)
->
field
(
$field
)
->
order
(
'w.level desc,w.is_default desc,wgs.inventory desc'
)
->
select
()
->
toArray
();
$warehouse
=
Db
::
name
(
'WarehouseGoodsSpec'
)
->
alias
(
'wgs'
)
->
join
(
'warehouse_goods wg'
,
'wgs.warehouse_id=wg.warehouse_id'
)
->
join
(
'warehouse w'
,
'wg.warehouse_id=w.id'
)
->
where
(
$where
)
->
field
(
$field
)
->
order
(
'w.level desc,w.is_default desc,wgs.inventory desc'
)
->
select
()
->
toArray
();
// 商品仓库分配仓库组合钩子
$hook_name
=
'plugins_service_buy_group_goods_warehouse_handle'
;
MyEventTrigger
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
true
,
'params'
=>
$params
,
'spec'
=>
$spec
,
'where'
=>
$where
,
'data'
=>
&
$warehouse
,
]);
// 商品仓库分组
// 商品仓库分组
if
(
!
empty
(
$warehouse
))
if
(
!
empty
(
$warehouse
))
{
{
...
@@ -304,6 +315,17 @@ class OrderSplitService
...
@@ -304,6 +315,17 @@ class OrderSplitService
{
{
$warehouse_default
=
Db
::
name
(
'Warehouse'
)
->
where
([
'is_default'
=>
1
,
'is_enable'
=>
1
,
'is_delete_time'
=>
0
])
->
field
(
'id,name,alias,lng,lat,province,city,county,address'
)
->
find
();
$warehouse_default
=
Db
::
name
(
'Warehouse'
)
->
where
([
'is_default'
=>
1
,
'is_enable'
=>
1
,
'is_delete_time'
=>
0
])
->
field
(
'id,name,alias,lng,lat,province,city,county,address'
)
->
find
();
}
}
// 商品仓库分配默认仓库组合钩子
$hook_name
=
'plugins_service_buy_group_goods_default_warehouse_handle'
;
MyEventTrigger
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
true
,
'params'
=>
$params
,
'data'
=>
&
$warehouse_default
,
]);
// 存在默认仓库则继续分配
if
(
!
empty
(
$warehouse_default
))
if
(
!
empty
(
$warehouse_default
))
{
{
if
(
!
array_key_exists
(
$warehouse_default
[
'id'
],
$result
))
if
(
!
array_key_exists
(
$warehouse_default
[
'id'
],
$result
))
...
...
app/service/PluginsService.php
浏览文件 @
c3f5f6c0
...
@@ -426,13 +426,7 @@ class PluginsService
...
@@ -426,13 +426,7 @@ class PluginsService
// 移除私有字段及数据
// 移除私有字段及数据
if
(
!
empty
(
$v
[
'data'
])
&&
is_array
(
$v
[
'data'
])
&&
!
empty
(
$private_field
)
&&
is_array
(
$private_field
))
if
(
!
empty
(
$v
[
'data'
])
&&
is_array
(
$v
[
'data'
])
&&
!
empty
(
$private_field
)
&&
is_array
(
$private_field
))
{
{
foreach
(
$private_field
as
$pv
)
$v
[
'data'
]
=
self
::
ConfigPrivateFieldsHandle
(
$v
[
'data'
],
$private_field
);
{
if
(
array_key_exists
(
$pv
,
$v
[
'data'
]))
{
unset
(
$v
[
'data'
][
$pv
]);
}
}
}
}
}
}
...
@@ -447,6 +441,31 @@ class PluginsService
...
@@ -447,6 +441,31 @@ class PluginsService
return
$data
;
return
$data
;
}
}
/**
* 插件配置隐私字段处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-04-13
* @desc description
* @param [array] $config [配置数据]
* @param [array] $fields [字段列表]
*/
public
static
function
ConfigPrivateFieldsHandle
(
$config
,
$fields
)
{
if
(
!
empty
(
$config
)
&&
is_array
(
$config
)
&&
!
empty
(
$fields
)
&&
is_array
(
$fields
))
{
foreach
(
$fields
as
$pv
)
{
if
(
array_key_exists
(
$pv
,
$config
))
{
unset
(
$config
[
$pv
]);
}
}
}
return
$config
;
}
/**
/**
* 插件更新信息
* 插件更新信息
* @author Devil
* @author Devil
...
...
app/service/SafetyService.php
浏览文件 @
c3f5f6c0
...
@@ -65,7 +65,7 @@ class SafetyService
...
@@ -65,7 +65,7 @@ class SafetyService
}
}
// 获取用户账户信息
// 获取用户账户信息
$user
=
Db
::
name
(
'User'
)
->
field
(
'id,pwd,salt,username,mobile,email'
)
->
find
(
$params
[
'user'
][
'id'
]
);
$user
=
UserService
::
UserInfo
(
'id'
,
intval
(
$params
[
'user'
][
'id'
]),
'id,pwd,salt,username,mobile,email'
);
// 原密码校验
// 原密码校验
if
(
LoginPwdEncryption
(
$params
[
'my_pwd'
],
$user
[
'salt'
])
!=
$user
[
'pwd'
])
if
(
LoginPwdEncryption
(
$params
[
'my_pwd'
],
$user
[
'salt'
])
!=
$user
[
'pwd'
])
...
@@ -103,11 +103,11 @@ class SafetyService
...
@@ -103,11 +103,11 @@ class SafetyService
public
static
function
UserLoginPwdUpdate
(
$accounts
,
$user_id
,
$pwd
)
public
static
function
UserLoginPwdUpdate
(
$accounts
,
$user_id
,
$pwd
)
{
{
$salt
=
GetNumberCode
(
6
);
$salt
=
GetNumberCode
(
6
);
$data
=
array
(
$data
=
[
'pwd'
=>
LoginPwdEncryption
(
trim
(
$pwd
),
$salt
),
'pwd'
=>
LoginPwdEncryption
(
trim
(
$pwd
),
$salt
),
'salt'
=>
$salt
,
'salt'
=>
$salt
,
'upd_time'
=>
time
(),
'upd_time'
=>
time
(),
)
;
]
;
if
(
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$user_id
])
->
update
(
$data
)
!==
false
)
if
(
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$user_id
])
->
update
(
$data
)
!==
false
)
{
{
// 用户登录密码修改钩子
// 用户登录密码修改钩子
...
@@ -117,7 +117,7 @@ class SafetyService
...
@@ -117,7 +117,7 @@ class SafetyService
'is_backend'
=>
true
,
'is_backend'
=>
true
,
'params'
=>
[
'accounts'
=>
$accounts
,
'pwd'
=>
$pwd
],
'params'
=>
[
'accounts'
=>
$accounts
,
'pwd'
=>
$pwd
],
'user_id'
=>
$user_id
,
'user_id'
=>
$user_id
,
'user'
=>
Db
::
name
(
'User'
)
->
field
(
'id,username,nickname,mobile,email,gender,avatar,province,city,birthday'
)
->
where
([
'id'
=>
$user_id
])
->
find
(
),
'user'
=>
UserService
::
UserInfo
(
'id'
,
$user_id
,
'id,username,nickname,mobile,email,gender,avatar,province,city,birthday'
),
]));
]));
if
(
isset
(
$ret
[
'code'
])
&&
$ret
[
'code'
]
!=
0
)
if
(
isset
(
$ret
[
'code'
])
&&
$ret
[
'code'
]
!=
0
)
{
{
...
@@ -141,7 +141,7 @@ class SafetyService
...
@@ -141,7 +141,7 @@ class SafetyService
private
static
function
IsExistAccounts
(
$accounts
,
$type
)
private
static
function
IsExistAccounts
(
$accounts
,
$type
)
{
{
$field
=
(
$type
==
'sms'
)
?
'mobile'
:
'email'
;
$field
=
(
$type
==
'sms'
)
?
'mobile'
:
'email'
;
$user
=
Db
::
name
(
'User'
)
->
where
([
$field
=>
$accounts
])
->
field
(
'id'
)
->
find
(
);
$user
=
UserService
::
UserInfo
(
$field
,
$accounts
,
'id'
);
if
(
!
empty
(
$user
))
if
(
!
empty
(
$user
))
{
{
$msg
=
(
$type
==
'sms'
)
?
'手机号码已存在'
:
'电子邮箱已存在'
;
$msg
=
(
$type
==
'sms'
)
?
'手机号码已存在'
:
'电子邮箱已存在'
;
...
@@ -393,7 +393,7 @@ class SafetyService
...
@@ -393,7 +393,7 @@ class SafetyService
{
{
return
$ret
;
return
$ret
;
}
else
{
}
else
{
$user
=
Db
::
name
(
'User'
)
->
field
(
'id,username,nickname,mobile,email,gender,avatar,province,city,birthday'
)
->
where
([
'id'
=>
$params
[
'user'
][
'id'
]])
->
find
(
);
$user
=
UserService
::
UserInfo
(
'id'
,
intval
(
$params
[
'user'
][
'id'
]),
'id,username,nickname,mobile,email,gender,avatar,province,city,birthday'
);
}
}
// 验证码校验
// 验证码校验
...
@@ -426,7 +426,7 @@ class SafetyService
...
@@ -426,7 +426,7 @@ class SafetyService
'upd_time'
=>
time
(),
'upd_time'
=>
time
(),
);
);
// 更新数据库
// 更新数据库
if
(
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$params
[
'user'
][
'id'
]
])
->
update
(
$data
)
!==
false
)
if
(
Db
::
name
(
'User'
)
->
where
([
'id'
=>
intval
(
$params
[
'user'
][
'id'
])
])
->
update
(
$data
)
!==
false
)
{
{
// 更新用户session数据
// 更新用户session数据
UserService
::
UserLoginRecord
(
$params
[
'user'
][
'id'
]);
UserService
::
UserLoginRecord
(
$params
[
'user'
][
'id'
]);
...
@@ -444,7 +444,7 @@ class SafetyService
...
@@ -444,7 +444,7 @@ class SafetyService
'is_backend'
=>
true
,
'is_backend'
=>
true
,
'params'
=>
[
'accounts'
=>
$user
[
$field
],
'new_accounts'
=>
$params
[
'accounts'
],
'field'
=>
$field
],
'params'
=>
[
'accounts'
=>
$user
[
$field
],
'new_accounts'
=>
$params
[
'accounts'
],
'field'
=>
$field
],
'user_id'
=>
$user
[
'id'
],
'user_id'
=>
$user
[
'id'
],
'user'
=>
Db
::
name
(
'User'
)
->
field
(
'id,username,nickname,mobile,email,gender,avatar,province,city,birthday'
)
->
where
([
'id'
=>
$user
[
'id'
]])
->
find
(
),
'user'
=>
UserService
::
UserInfo
(
'id'
,
$user
[
'id'
],
'id,username,nickname,mobile,email,gender,avatar,province,city,birthday'
),
]));
]));
if
(
isset
(
$ret
[
'code'
])
&&
$ret
[
'code'
]
!=
0
)
if
(
isset
(
$ret
[
'code'
])
&&
$ret
[
'code'
]
!=
0
)
{
{
...
...
app/service/UserService.php
浏览文件 @
c3f5f6c0
...
@@ -356,6 +356,7 @@ class UserService
...
@@ -356,6 +356,7 @@ class UserService
// 更新数据
// 更新数据
$data
=
[
$data
=
[
'system_type'
=>
empty
(
$params
[
'system_type'
])
?
'default'
:
$params
[
'system_type'
],
'username'
=>
isset
(
$params
[
'username'
])
?
$params
[
'username'
]
:
''
,
'username'
=>
isset
(
$params
[
'username'
])
?
$params
[
'username'
]
:
''
,
'nickname'
=>
isset
(
$params
[
'nickname'
])
?
$params
[
'nickname'
]
:
''
,
'nickname'
=>
isset
(
$params
[
'nickname'
])
?
$params
[
'nickname'
]
:
''
,
'mobile'
=>
isset
(
$params
[
'mobile'
])
?
$params
[
'mobile'
]
:
''
,
'mobile'
=>
isset
(
$params
[
'mobile'
])
?
$params
[
'mobile'
]
:
''
,
...
@@ -402,7 +403,7 @@ class UserService
...
@@ -402,7 +403,7 @@ class UserService
if
(
!
empty
(
$params
[
'id'
]))
if
(
!
empty
(
$params
[
'id'
]))
{
{
// 获取用户信息
// 获取用户信息
$user
=
Db
::
name
(
'User'
)
->
field
(
'id,integral'
)
->
find
(
$params
[
'id'
]
);
$user
=
self
::
UserInfo
(
'id'
,
intval
(
$params
[
'id'
]),
'id,integral'
);
if
(
empty
(
$user
))
if
(
empty
(
$user
))
{
{
return
DataReturn
(
'用户信息不存在'
,
-
10
);
return
DataReturn
(
'用户信息不存在'
,
-
10
);
...
@@ -532,7 +533,7 @@ class UserService
...
@@ -532,7 +533,7 @@ class UserService
{
{
if
(
!
empty
(
$user_id
))
if
(
!
empty
(
$user_id
))
{
{
$user
=
Db
::
name
(
'User'
)
->
find
(
$user_id
);
$user
=
self
::
UserInfo
(
'id'
,
$user_id
);
if
(
!
empty
(
$user
))
if
(
!
empty
(
$user
))
{
{
// 用户数据处理
// 用户数据处理
...
@@ -855,8 +856,7 @@ class UserService
...
@@ -855,8 +856,7 @@ class UserService
}
}
// 获取用户账户信息
// 获取用户账户信息
$where
=
[
$ac
[
'data'
]
=>
$params
[
'accounts'
],
'is_delete_time'
=>
0
];
$user
=
self
::
UserInfo
(
$ac
[
'data'
],
$params
[
'accounts'
]);
$user
=
Db
::
name
(
'User'
)
->
where
(
$where
)
->
find
();
if
(
empty
(
$user
))
if
(
empty
(
$user
))
{
{
return
DataReturn
(
'帐号不存在'
,
-
3
);
return
DataReturn
(
'帐号不存在'
,
-
3
);
...
@@ -958,7 +958,7 @@ class UserService
...
@@ -958,7 +958,7 @@ class UserService
$body_html
=
[];
$body_html
=
[];
// 用户登录后钩子
// 用户登录后钩子
$user
=
Db
::
name
(
'User'
)
->
field
(
'id,username,nickname,mobile,email,gender,avatar,province,city,birthday'
)
->
where
([
'id'
=>
$user_id
])
->
find
(
);
$user
=
self
::
UserInfo
(
'id'
,
$user_id
,
'id,system_type,username,nickname,mobile,email,gender,avatar,province,city,birthday'
);
$hook_name
=
'plugins_service_user_login_end'
;
$hook_name
=
'plugins_service_user_login_end'
;
$ret
=
EventReturnHandle
(
MyEventTrigger
(
$hook_name
,
[
$ret
=
EventReturnHandle
(
MyEventTrigger
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'hook_name'
=>
$hook_name
,
...
@@ -1218,8 +1218,8 @@ class UserService
...
@@ -1218,8 +1218,8 @@ class UserService
*/
*/
private
static
function
IsExistAccounts
(
$accounts
,
$field
=
'mobile'
)
private
static
function
IsExistAccounts
(
$accounts
,
$field
=
'mobile'
)
{
{
$
id
=
Db
::
name
(
'User'
)
->
where
(
array
(
$field
=>
$accounts
))
->
value
(
'id'
);
$
temp
=
self
::
UserInfo
(
$field
,
$accounts
,
'id'
);
return
!
empty
(
$
id
);
return
!
empty
(
$
temp
);
}
}
/**
/**
...
@@ -1707,7 +1707,7 @@ class UserService
...
@@ -1707,7 +1707,7 @@ class UserService
}
}
// 获取用户信息
// 获取用户信息
$user
=
Db
::
name
(
'User'
)
->
where
([
$ret
[
'data'
]
=>
$params
[
'accounts'
]])
->
find
(
);
$user
=
self
::
UserInfo
(
$ret
[
'data'
],
$params
[
'accounts'
]
);
if
(
empty
(
$user
))
if
(
empty
(
$user
))
{
{
return
DataReturn
(
'用户信息不存在'
,
-
12
);
return
DataReturn
(
'用户信息不存在'
,
-
12
);
...
@@ -1776,7 +1776,7 @@ class UserService
...
@@ -1776,7 +1776,7 @@ class UserService
'gender'
=>
intval
(
$params
[
'gender'
]),
'gender'
=>
intval
(
$params
[
'gender'
]),
'upd_time'
=>
time
(),
'upd_time'
=>
time
(),
];
];
if
(
Db
::
name
(
'User'
)
->
where
(
array
(
'id'
=>
$params
[
'user'
][
'id'
])
)
->
update
(
$data
))
if
(
Db
::
name
(
'User'
)
->
where
(
[
'id'
=>
$params
[
'user'
][
'id'
]]
)
->
update
(
$data
))
{
{
// 更新用户session数据
// 更新用户session数据
self
::
UserLoginRecord
(
$params
[
'user'
][
'id'
]);
self
::
UserLoginRecord
(
$params
[
'user'
][
'id'
]);
...
@@ -2149,7 +2149,12 @@ class UserService
...
@@ -2149,7 +2149,12 @@ class UserService
return
''
;
return
''
;
}
}
return
Db
::
name
(
'User'
)
->
where
([
$where_field
=>
$where_value
,
'is_delete_time'
=>
0
])
->
field
(
$field
)
->
find
();
$where
=
[
[
'system_type'
,
'='
,
SYSTEM_TYPE
],
[
$where_field
,
'='
,
$where_value
],
[
'is_delete_time'
,
'='
,
0
],
];
return
Db
::
name
(
'User'
)
->
where
(
$where
)
->
field
(
$field
)
->
find
();
}
}
/**
/**
...
@@ -2167,13 +2172,13 @@ class UserService
...
@@ -2167,13 +2172,13 @@ class UserService
// 账号是否存在,以用户名 手机 邮箱 作为唯一
// 账号是否存在,以用户名 手机 邮箱 作为唯一
if
(
!
empty
(
$data
[
'username'
]))
if
(
!
empty
(
$data
[
'username'
]))
{
{
$temp
=
Db
::
name
(
'User'
)
->
where
([
'username'
=>
$data
[
'username'
],
'is_delete_time'
=>
0
])
->
find
(
);
$temp
=
self
::
UserInfo
(
'username'
,
$data
[
'username'
]
);
}
else
if
(
!
empty
(
$data
[
'mobile'
]))
}
else
if
(
!
empty
(
$data
[
'mobile'
]))
{
{
$temp
=
Db
::
name
(
'User'
)
->
where
([
'mobile'
=>
$data
[
'mobile'
],
'is_delete_time'
=>
0
])
->
find
(
);
$temp
=
self
::
UserInfo
(
'mobile'
,
$data
[
'mobile'
]
);
}
else
if
(
!
empty
(
$data
[
'email'
]))
}
else
if
(
!
empty
(
$data
[
'email'
]))
{
{
$temp
=
Db
::
name
(
'User'
)
->
where
([
'email'
=>
$data
[
'email'
],
'is_delete_time'
=>
0
])
->
find
(
);
$temp
=
self
::
UserInfo
(
'email'
,
$data
[
'email'
]
);
}
}
if
(
!
empty
(
$temp
))
if
(
!
empty
(
$temp
))
{
{
...
@@ -2217,7 +2222,7 @@ class UserService
...
@@ -2217,7 +2222,7 @@ class UserService
$body_html
=
[];
$body_html
=
[];
// 注册成功后钩子
// 注册成功后钩子
$user
=
Db
::
name
(
'User'
)
->
field
(
'id,username,nickname,mobile,email,gender,avatar,province,city,birthday'
)
->
where
([
'id'
=>
$user_id
])
->
find
(
);
$user
=
self
::
UserInfo
(
'id'
,
$user_id
,
'id,username,nickname,mobile,email,gender,avatar,province,city,birthday'
);
$hook_name
=
'plugins_service_user_register_end'
;
$hook_name
=
'plugins_service_user_register_end'
;
$ret
=
EventReturnHandle
(
MyEventTrigger
(
$hook_name
,
[
$ret
=
EventReturnHandle
(
MyEventTrigger
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'hook_name'
=>
$hook_name
,
...
@@ -2255,6 +2260,10 @@ class UserService
...
@@ -2255,6 +2260,10 @@ class UserService
*/
*/
public
static
function
UserBaseHandle
(
$data
,
$params
)
public
static
function
UserBaseHandle
(
$data
,
$params
)
{
{
// 系统类型
$data
[
'system_type'
]
=
SYSTEM_TYPE
;
// 基础参数处理
if
(
!
empty
(
$params
)
&&
is_array
(
$params
))
if
(
!
empty
(
$params
)
&&
is_array
(
$params
))
{
{
// 是否存在基信息
// 是否存在基信息
...
@@ -2380,10 +2389,7 @@ class UserService
...
@@ -2380,10 +2389,7 @@ class UserService
$is_appmini
=
array_key_exists
(
APPLICATION_CLIENT_TYPE
,
MyConst
(
'common_appmini_type'
));
$is_appmini
=
array_key_exists
(
APPLICATION_CLIENT_TYPE
,
MyConst
(
'common_appmini_type'
));
// 手机号码获取用户信息
// 手机号码获取用户信息
$mobile_user
=
Db
::
name
(
'User'
)
->
where
([
$mobile_user
=
self
::
UserInfo
(
'mobile'
,
$data
[
'mobile'
]);
[
'mobile'
,
'='
,
$data
[
'mobile'
]],
[
'is_delete_time'
,
'='
,
0
],
])
->
find
();
// 额外信息
// 额外信息
if
(
empty
(
$mobile_user
))
if
(
empty
(
$mobile_user
))
...
@@ -2424,10 +2430,7 @@ class UserService
...
@@ -2424,10 +2430,7 @@ class UserService
$data
[
$accounts_field
]
=
$params
[
$accounts_field
];
$data
[
$accounts_field
]
=
$params
[
$accounts_field
];
// 小程序请求获取用户信息
// 小程序请求获取用户信息
$current_user
=
Db
::
name
(
'User'
)
->
where
([
$current_user
=
self
::
UserInfo
(
$accounts_field
,
$params
[
$accounts_field
]);
[
$accounts_field
,
'='
,
$params
[
$accounts_field
]],
[
'is_delete_time'
,
'='
,
0
],
])
->
find
();
}
else
{
}
else
{
// 当前登录用户
// 当前登录用户
$current_user
=
self
::
LoginUserInfo
();
$current_user
=
self
::
LoginUserInfo
();
...
...
public/core.php
浏览文件 @
c3f5f6c0
...
@@ -82,6 +82,9 @@ define('ROOT', substr(ROOT_PATH, 0, -7));
...
@@ -82,6 +82,9 @@ define('ROOT', substr(ROOT_PATH, 0, -7));
// 定义应用目录
// 定义应用目录
define
(
'APP_PATH'
,
ROOT
.
'app'
.
DS
);
define
(
'APP_PATH'
,
ROOT
.
'app'
.
DS
);
// 系统类型 [default] 默认default、可根据终端区分系统类型
define
(
'SYSTEM_TYPE'
,
empty
(
$_REQUEST
[
'system_type'
])
?
'default'
:
trim
(
$_REQUEST
[
'system_type'
]));
// 请求应用 [web, app] 默认web(ios|android|小程序 均为app)
// 请求应用 [web, app] 默认web(ios|android|小程序 均为app)
define
(
'APPLICATION'
,
empty
(
$_REQUEST
[
'application'
])
?
'web'
:
trim
(
$_REQUEST
[
'application'
]));
define
(
'APPLICATION'
,
empty
(
$_REQUEST
[
'application'
])
?
'web'
:
trim
(
$_REQUEST
[
'application'
]));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录