Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wds12580
ShopXO
提交
a2157b0c
ShopXO
项目概览
wds12580
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a2157b0c
编写于
12月 23, 2018
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
数据库使用方式
上级
66a5b6a2
变更
26
展开全部
隐藏空白更改
内联
并排
Showing
26 changed file
with
305 addition
and
277 deletion
+305
-277
application/service/AdminPowerService.php
application/service/AdminPowerService.php
+22
-22
application/service/AdminService.php
application/service/AdminService.php
+11
-9
application/service/AnswerService.php
application/service/AnswerService.php
+9
-8
application/service/AppMiniService.php
application/service/AppMiniService.php
+2
-0
application/service/AppNavService.php
application/service/AppNavService.php
+8
-6
application/service/ArticleService.php
application/service/ArticleService.php
+5
-4
application/service/BannerService.php
application/service/BannerService.php
+3
-1
application/service/BrandService.php
application/service/BrandService.php
+19
-18
application/service/BuyService.php
application/service/BuyService.php
+23
-23
application/service/ConfigService.php
application/service/ConfigService.php
+5
-3
application/service/CustomViewService.php
application/service/CustomViewService.php
+8
-7
application/service/ExpressService.php
application/service/ExpressService.php
+4
-2
application/service/GoodsService.php
application/service/GoodsService.php
+67
-67
application/service/IntegralService.php
application/service/IntegralService.php
+10
-10
application/service/LinkService.php
application/service/LinkService.php
+6
-5
application/service/MessageService.php
application/service/MessageService.php
+6
-5
application/service/NavigationService.php
application/service/NavigationService.php
+11
-11
application/service/OrderService.php
application/service/OrderService.php
+27
-27
application/service/RegionService.php
application/service/RegionService.php
+5
-3
application/service/ResourcesService.php
application/service/ResourcesService.php
+5
-3
application/service/SafetyService.php
application/service/SafetyService.php
+5
-4
application/service/ScreeningPriceService.php
application/service/ScreeningPriceService.php
+6
-5
application/service/SearchService.php
application/service/SearchService.php
+6
-6
application/service/SlideService.php
application/service/SlideService.php
+8
-6
application/service/ThemeService.php
application/service/ThemeService.php
+2
-0
application/service/UserService.php
application/service/UserService.php
+22
-22
未找到文件。
application/service/AdminPowerService.php
浏览文件 @
a2157b0c
...
...
@@ -27,12 +27,12 @@ class AdminPowerService
$order_by
=
empty
(
$params
[
'order_by'
])
?
'id desc'
:
trim
(
$params
[
'order_by'
]);
// 获取管理员列表
$data
=
db
(
'Power'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
select
();
$data
=
Db
::
name
(
'Power'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
select
();
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
&
$v
)
{
$v
[
'item'
]
=
db
(
'Power'
)
->
field
(
$field
)
->
where
([
'pid'
=>
$v
[
'id'
]])
->
order
(
$order_by
)
->
select
();
$v
[
'item'
]
=
Db
::
name
(
'Power'
)
->
field
(
$field
)
->
where
([
'pid'
=>
$v
[
'id'
]])
->
order
(
$order_by
)
->
select
();
}
}
return
$data
;
...
...
@@ -109,7 +109,7 @@ class AdminPowerService
if
(
empty
(
$params
[
'id'
]))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'Power'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'Power'
)
->
insertGetId
(
$data
)
>
0
)
{
// 清除用户权限数据
self
::
PowerCacheDelete
();
...
...
@@ -118,7 +118,7 @@ class AdminPowerService
}
return
DataReturn
(
'添加失败'
,
-
100
);
}
else
{
if
(
db
(
'Power'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
)
!==
false
)
if
(
Db
::
name
(
'Power'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
)
!==
false
)
{
// 清除用户权限数据
self
::
PowerCacheDelete
();
...
...
@@ -145,7 +145,7 @@ class AdminPowerService
return
DataReturn
(
'权限菜单id有误'
,
-
1
);
}
if
(
db
(
'Power'
)
->
delete
(
intval
(
$params
[
'id'
])))
if
(
Db
::
name
(
'Power'
)
->
delete
(
intval
(
$params
[
'id'
])))
{
// 清除用户权限数据
self
::
PowerCacheDelete
();
...
...
@@ -170,7 +170,7 @@ class AdminPowerService
$order_by
=
empty
(
$params
[
'order_by'
])
?
'id desc'
:
trim
(
$params
[
'order_by'
]);
// 获取管理员列表
$data
=
db
(
'Role'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
select
();
$data
=
Db
::
name
(
'Role'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
select
();
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
&
$v
)
...
...
@@ -178,9 +178,9 @@ class AdminPowerService
// 关联查询权限和角色数据
if
(
$v
[
'id'
]
==
1
)
{
$v
[
'item'
]
=
db
(
'Power'
)
->
select
();
$v
[
'item'
]
=
Db
::
name
(
'Power'
)
->
select
();
}
else
{
$v
[
'item'
]
=
db
(
'Role'
)
->
alias
(
'r'
)
->
join
([
'__ROLE_POWER__'
=>
'rp'
],
'rp.role_id = r.id'
)
->
join
([
'__POWER__'
=>
'p'
],
'rp.power_id = p.id'
)
->
where
(
array
(
'r.id'
=>
$v
[
'id'
]))
->
field
(
'p.id,p.name'
)
->
select
();
$v
[
'item'
]
=
Db
::
name
(
'Role'
)
->
alias
(
'r'
)
->
join
([
'__ROLE_POWER__'
=>
'rp'
],
'rp.role_id = r.id'
)
->
join
([
'__POWER__'
=>
'p'
],
'rp.power_id = p.id'
)
->
where
(
array
(
'r.id'
=>
$v
[
'id'
]))
->
field
(
'p.id,p.name'
)
->
select
();
}
}
}
...
...
@@ -218,7 +218,7 @@ class AdminPowerService
}
// 数据更新
if
(
db
(
'Role'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
if
(
Db
::
name
(
'Role'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
{
return
DataReturn
(
'编辑成功'
);
}
...
...
@@ -236,11 +236,11 @@ class AdminPowerService
public
static
function
RolePowerEditData
(
$params
=
[])
{
// 当前角色关联的所有菜单id
$action
=
empty
(
$params
[
'role_id'
])
?
[]
:
db
(
'RolePower'
)
->
where
([
'role_id'
=>
$params
[
'role_id'
]])
->
column
(
'power_id'
);
$action
=
empty
(
$params
[
'role_id'
])
?
[]
:
Db
::
name
(
'RolePower'
)
->
where
([
'role_id'
=>
$params
[
'role_id'
]])
->
column
(
'power_id'
);
// 权限列表
$power_field
=
'id,name,is_show'
;
$power
=
db
(
'Power'
)
->
field
(
$power_field
)
->
where
([
'pid'
=>
0
])
->
order
(
'sort'
)
->
select
();
$power
=
Db
::
name
(
'Power'
)
->
field
(
$power_field
)
->
where
([
'pid'
=>
0
])
->
order
(
'sort'
)
->
select
();
if
(
!
empty
(
$power
))
{
foreach
(
$power
as
&
$v
)
...
...
@@ -249,7 +249,7 @@ class AdminPowerService
$v
[
'is_power'
]
=
in_array
(
$v
[
'id'
],
$action
)
?
'ok'
:
'no'
;
// 获取子权限
$item
=
db
(
'Power'
)
->
field
(
$power_field
)
->
where
(
array
(
'pid'
=>
$v
[
'id'
]))
->
order
(
'sort'
)
->
select
();
$item
=
Db
::
name
(
'Power'
)
->
field
(
$power_field
)
->
where
(
array
(
'pid'
=>
$v
[
'id'
]))
->
order
(
'sort'
)
->
select
();
if
(
!
empty
(
$item
))
{
foreach
(
$item
as
$ks
=>
$vs
)
...
...
@@ -304,9 +304,9 @@ class AdminPowerService
if
(
empty
(
$params
[
'id'
]))
{
$role_data
[
'add_time'
]
=
time
();
$role_id
=
db
(
'Role'
)
->
insertGetId
(
$role_data
);
$role_id
=
Db
::
name
(
'Role'
)
->
insertGetId
(
$role_data
);
}
else
{
if
(
db
(
'Role'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
update
(
$role_data
)
!==
false
)
if
(
Db
::
name
(
'Role'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
update
(
$role_data
)
!==
false
)
{
$role_id
=
$params
[
'id'
];
}
...
...
@@ -318,7 +318,7 @@ class AdminPowerService
}
// 权限关联数据删除
if
(
db
(
'RolePower'
)
->
where
([
'role_id'
=>
$role_id
])
->
delete
()
===
false
)
if
(
Db
::
name
(
'RolePower'
)
->
where
([
'role_id'
=>
$role_id
])
->
delete
()
===
false
)
{
Db
::
rollback
();
return
DataReturn
(
'角色权限操作失败'
,
-
3
);
...
...
@@ -341,7 +341,7 @@ class AdminPowerService
}
if
(
!
empty
(
$rp_data
))
{
if
(
db
(
'RolePower'
)
->
insertAll
(
$rp_data
)
<
count
(
$rp_data
))
if
(
Db
::
name
(
'RolePower'
)
->
insertAll
(
$rp_data
)
<
count
(
$rp_data
))
{
Db
::
rollback
();
return
DataReturn
(
'角色权限添加失败'
,
-
10
);
...
...
@@ -378,7 +378,7 @@ class AdminPowerService
Db
::
startTrans
();
// 删除角色
if
(
db
(
'Role'
)
->
delete
(
intval
(
$params
[
'id'
]))
!==
false
&&
db
(
'RolePower'
)
->
where
([
'role_id'
=>
intval
(
$params
[
'id'
])])
->
delete
()
!==
false
)
if
(
Db
::
name
(
'Role'
)
->
delete
(
intval
(
$params
[
'id'
]))
!==
false
&&
Db
::
name
(
'RolePower'
)
->
where
([
'role_id'
=>
intval
(
$params
[
'id'
])])
->
delete
()
!==
false
)
{
// 提交事务
Db
::
commit
();
...
...
@@ -402,7 +402,7 @@ class AdminPowerService
*/
public
static
function
PowerCacheDelete
()
{
$admin
=
db
(
'Admin'
)
->
column
(
'id'
);
$admin
=
Db
::
name
(
'Admin'
)
->
column
(
'id'
);
if
(
!
empty
(
$admin
))
{
foreach
(
$admin
as
$id
)
...
...
@@ -439,10 +439,10 @@ class AdminPowerService
if
(
$admin_id
==
1
)
{
$field
=
'id,name,control,action,is_show,icon'
;
$admin_left_menu
=
db
(
'Power'
)
->
where
(
array
(
'pid'
=>
0
))
->
field
(
$field
)
->
order
(
'sort'
)
->
select
();
$admin_left_menu
=
Db
::
name
(
'Power'
)
->
where
(
array
(
'pid'
=>
0
))
->
field
(
$field
)
->
order
(
'sort'
)
->
select
();
}
else
{
$field
=
'p.id,p.name,p.control,p.action,p.is_show,p.icon'
;
$admin_left_menu
=
db
(
'Power'
)
->
alias
(
'p'
)
->
join
([
'__ROLE_POWER__'
=>
'rp'
],
'p.id=rp.power_id'
)
->
where
(
array
(
'rp.role_id'
=>
$role_id
,
'p.pid'
=>
0
))
->
field
(
$field
)
->
order
(
'p.sort'
)
->
select
();
$admin_left_menu
=
Db
::
name
(
'Power'
)
->
alias
(
'p'
)
->
join
([
'__ROLE_POWER__'
=>
'rp'
],
'p.id=rp.power_id'
)
->
where
(
array
(
'rp.role_id'
=>
$role_id
,
'p.pid'
=>
0
))
->
field
(
$field
)
->
order
(
'p.sort'
)
->
select
();
}
// 有数据,则处理子级数据
...
...
@@ -456,9 +456,9 @@ class AdminPowerService
// 获取子权限
if
(
$admin_id
==
1
)
{
$item
=
db
(
'Power'
)
->
where
(
array
(
'pid'
=>
$v
[
'id'
]))
->
field
(
$field
)
->
order
(
'sort'
)
->
select
();
$item
=
Db
::
name
(
'Power'
)
->
where
(
array
(
'pid'
=>
$v
[
'id'
]))
->
field
(
$field
)
->
order
(
'sort'
)
->
select
();
}
else
{
$item
=
db
(
'Power'
)
->
alias
(
'p'
)
->
join
([
'__ROLE_POWER__'
=>
'rp'
],
'p.id=rp.power_id'
)
->
where
(
array
(
'rp.role_id'
=>
$role_id
,
'p.pid'
=>
$v
[
'id'
]))
->
field
(
$field
)
->
order
(
'p.sort'
)
->
select
();
$item
=
Db
::
name
(
'Power'
)
->
alias
(
'p'
)
->
join
([
'__ROLE_POWER__'
=>
'rp'
],
'p.id=rp.power_id'
)
->
where
(
array
(
'rp.role_id'
=>
$role_id
,
'p.pid'
=>
$v
[
'id'
]))
->
field
(
$field
)
->
order
(
'p.sort'
)
->
select
();
}
// 权限列表
...
...
application/service/AdminService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 管理员服务层
* @author Devil
...
...
@@ -28,12 +30,12 @@ class AdminService
$n
=
isset
(
$params
[
'n'
])
?
intval
(
$params
[
'n'
])
:
10
;
// 获取管理员列表
$data
=
db
(
'Admin'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
limit
(
$m
,
$n
)
->
select
();
$data
=
Db
::
name
(
'Admin'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
limit
(
$m
,
$n
)
->
select
();
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
&
$v
)
{
$v
[
'role_name'
]
=
db
(
'Role'
)
->
where
([
'id'
=>
$v
[
'role_id'
]])
->
value
(
'name'
);
$v
[
'role_name'
]
=
Db
::
name
(
'Role'
)
->
where
([
'id'
=>
$v
[
'role_id'
]])
->
value
(
'name'
);
}
}
return
$data
;
...
...
@@ -77,7 +79,7 @@ class AdminService
*/
public
static
function
AdminTotal
(
$where
)
{
return
(
int
)
db
(
'Admin'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'Admin'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -92,7 +94,7 @@ class AdminService
{
$where
=
empty
(
$params
[
'where'
])
?
[]
:
$params
[
'where'
];
$field
=
empty
(
$params
[
'field'
])
?
'*'
:
$params
[
'field'
];
return
db
(
'Role'
)
->
field
(
$field
)
->
where
(
$where
)
->
select
();
return
Db
::
name
(
'Role'
)
->
field
(
$field
)
->
where
(
$where
)
->
select
();
}
/**
...
...
@@ -193,7 +195,7 @@ class AdminService
];
// 添加
if
(
db
(
'Admin'
)
->
insert
(
$data
)
>
0
)
if
(
Db
::
name
(
'Admin'
)
->
insert
(
$data
)
>
0
)
{
return
DataReturn
(
'新增成功'
,
0
);
}
...
...
@@ -254,7 +256,7 @@ class AdminService
}
// 更新
if
(
db
(
'Admin'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
if
(
Db
::
name
(
'Admin'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
{
// 自己修改密码则重新登录
if
(
!
empty
(
$params
[
'login_pwd'
])
&&
$params
[
'id'
]
==
$params
[
'admin'
][
'id'
])
...
...
@@ -292,7 +294,7 @@ class AdminService
}
// 删除操作
if
(
db
(
'Admin'
)
->
delete
(
intval
(
$params
[
'id'
])))
if
(
Db
::
name
(
'Admin'
)
->
delete
(
intval
(
$params
[
'id'
])))
{
return
DataReturn
(
'删除成功'
);
}
...
...
@@ -341,7 +343,7 @@ class AdminService
}
// 获取管理员
$admin
=
db
(
'Admin'
)
->
field
(
'id,username,login_pwd,login_salt,mobile,login_total,role_id'
)
->
where
([
'username'
=>
$params
[
'username'
]])
->
find
();
$admin
=
Db
::
name
(
'Admin'
)
->
field
(
'id,username,login_pwd,login_salt,mobile,login_total,role_id'
)
->
where
([
'username'
=>
$params
[
'username'
]])
->
find
();
if
(
empty
(
$admin
))
{
return
DataReturn
(
'管理员不存在'
,
-
2
);
...
...
@@ -368,7 +370,7 @@ class AdminService
'login_total'
=>
$admin
[
'login_total'
]
+
1
,
'login_time'
=>
time
(),
);
if
(
db
(
'Admin'
)
->
where
([
'id'
=>
$admin
[
'id'
]])
->
update
(
$data
))
if
(
Db
::
name
(
'Admin'
)
->
where
([
'id'
=>
$admin
[
'id'
]])
->
update
(
$data
))
{
// 清空缓存目录下的数据
\
base\FileUtil
::
UnlinkDir
(
ROOT
.
'runtime'
.
DS
.
'cache'
);
...
...
application/service/AnswerService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
use
app\service\GoodsService
;
/**
...
...
@@ -23,7 +24,7 @@ class AnswerService
*/
public
static
function
AnswerTotal
(
$where
=
[])
{
return
(
int
)
db
(
'Answer'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'Answer'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -43,7 +44,7 @@ class AnswerService
$order_by
=
empty
(
$params
[
'order_by'
])
?
'id desc'
:
$params
[
'order_by'
];
// 获取数据列表
$data
=
db
(
'Answer'
)
->
where
(
$where
)
->
limit
(
$m
,
$n
)
->
order
(
$order_by
)
->
select
();
$data
=
Db
::
name
(
'Answer'
)
->
where
(
$where
)
->
limit
(
$m
,
$n
)
->
order
(
$order_by
)
->
select
();
if
(
!
empty
(
$data
))
{
$common_is_show_list
=
lang
(
'common_is_show_list'
);
...
...
@@ -51,7 +52,7 @@ class AnswerService
foreach
(
$data
as
&
$v
)
{
// 用户信息
$user
=
db
(
'User'
)
->
where
([
'id'
=>
$v
[
'user_id'
]])
->
field
(
'username,nickname,mobile,gender,avatar'
)
->
find
();
$user
=
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$v
[
'user_id'
]])
->
field
(
'username,nickname,mobile,gender,avatar'
)
->
find
();
$v
[
'username'
]
=
empty
(
$user
[
'username'
])
?
''
:
$user
[
'username'
];
$v
[
'nickname'
]
=
empty
(
$user
[
'nickname'
])
?
''
:
$user
[
'nickname'
];
$v
[
'mobile'
]
=
empty
(
$user
[
'mobile'
])
?
''
:
$user
[
'mobile'
];
...
...
@@ -171,7 +172,7 @@ class AnswerService
}
// 获取数据
$temp
=
db
(
'Answer'
)
->
where
(
$where
)
->
field
(
'id'
)
->
find
();
$temp
=
Db
::
name
(
'Answer'
)
->
where
(
$where
)
->
field
(
'id'
)
->
find
();
if
(
empty
(
$temp
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
...
...
@@ -181,7 +182,7 @@ class AnswerService
$data
=
[
'is_delete_time'
=>
time
(),
];
if
(
db
(
'Answer'
)
->
where
(
$where
)
->
update
(
$data
))
if
(
Db
::
name
(
'Answer'
)
->
where
(
$where
)
->
update
(
$data
))
{
return
DataReturn
(
'删除成功'
,
0
);
}
...
...
@@ -230,7 +231,7 @@ class AnswerService
];
// 问答是否存在
$temp
=
db
(
'Answer'
)
->
where
(
$where
)
->
field
(
'id'
)
->
find
();
$temp
=
Db
::
name
(
'Answer'
)
->
where
(
$where
)
->
field
(
'id'
)
->
find
();
if
(
empty
(
$temp
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
2
);
...
...
@@ -241,7 +242,7 @@ class AnswerService
'is_reply'
=>
1
,
'upd_time'
=>
time
()
];
if
(
db
(
'Answer'
)
->
where
(
$where
)
->
update
(
$data
))
if
(
Db
::
name
(
'Answer'
)
->
where
(
$where
)
->
update
(
$data
))
{
return
DataReturn
(
'操作成功'
);
}
...
...
@@ -279,7 +280,7 @@ class AnswerService
}
// 数据更新
if
(
db
(
'Answer'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_show'
=>
intval
(
$params
[
'state'
])]))
if
(
Db
::
name
(
'Answer'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_show'
=>
intval
(
$params
[
'state'
])]))
{
return
DataReturn
(
'编辑成功'
);
}
...
...
application/service/AppMiniService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 小程序服务层
* @author Devil
...
...
application/service/AppNavService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* APP导航服务层
* @author Devil
...
...
@@ -28,7 +30,7 @@ class AppNavService
$n
=
isset
(
$params
[
'n'
])
?
intval
(
$params
[
'n'
])
:
10
;
// 获取品牌列表
$data
=
db
(
'AppHomeNav'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
limit
(
$m
,
$n
)
->
select
();
$data
=
Db
::
name
(
'AppHomeNav'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
limit
(
$m
,
$n
)
->
select
();
if
(
!
empty
(
$data
))
{
$common_platform_type
=
lang
(
'common_platform_type'
);
...
...
@@ -88,7 +90,7 @@ class AppNavService
*/
public
static
function
AppHomeNavTotal
(
$where
)
{
return
(
int
)
db
(
'AppHomeNav'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'AppHomeNav'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -215,14 +217,14 @@ class AppNavService
if
(
empty
(
$params
[
'id'
]))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'AppHomeNav'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'AppHomeNav'
)
->
insertGetId
(
$data
)
>
0
)
{
return
DataReturn
(
'添加成功'
,
0
);
}
return
DataReturn
(
'添加失败'
,
-
100
);
}
else
{
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'AppHomeNav'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
if
(
Db
::
name
(
'AppHomeNav'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
{
return
DataReturn
(
'编辑成功'
,
0
);
}
...
...
@@ -256,7 +258,7 @@ class AppNavService
}
// 删除操作
if
(
db
(
'AppHomeNav'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
if
(
Db
::
name
(
'AppHomeNav'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
{
return
DataReturn
(
'删除成功'
);
}
...
...
@@ -295,7 +297,7 @@ class AppNavService
}
// 数据更新
if
(
db
(
'AppHomeNav'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
if
(
Db
::
name
(
'AppHomeNav'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
{
return
DataReturn
(
'编辑成功'
);
}
...
...
application/service/ArticleService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
use
app\service\ResourcesService
;
/**
...
...
@@ -28,7 +29,7 @@ class ArticleService
$m
=
isset
(
$params
[
'm'
])
?
intval
(
$params
[
'm'
])
:
0
;
$n
=
isset
(
$params
[
'n'
])
?
intval
(
$params
[
'n'
])
:
10
;
$data
=
db
(
'Article'
)
->
alias
(
'a'
)
->
join
([
'__ARTICLE_CATEGORY__'
=>
'ac'
],
'a.article_category_id=ac.id'
)
->
field
(
$field
)
->
where
(
$where
)
->
order
(
'a.id desc'
)
->
limit
(
$m
,
$n
)
->
select
();
$data
=
Db
::
name
(
'Article'
)
->
alias
(
'a'
)
->
join
([
'__ARTICLE_CATEGORY__'
=>
'ac'
],
'a.article_category_id=ac.id'
)
->
field
(
$field
)
->
where
(
$where
)
->
order
(
'a.id desc'
)
->
limit
(
$m
,
$n
)
->
select
();
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
&
$v
)
...
...
@@ -58,12 +59,12 @@ class ArticleService
*/
public
static
function
ArticleCategoryList
(
$params
=
[])
{
$data
=
db
(
'ArticleCategory'
)
->
field
(
'id,name'
)
->
where
([
'is_enable'
=>
1
])
->
order
(
'id asc, sort asc'
)
->
select
();
$data
=
Db
::
name
(
'ArticleCategory'
)
->
field
(
'id,name'
)
->
where
([
'is_enable'
=>
1
])
->
order
(
'id asc, sort asc'
)
->
select
();
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
&
$v
)
{
$v
[
'items'
]
=
db
(
'Article'
)
->
field
(
'id,title,title_color'
)
->
where
([
'article_category_id'
=>
$v
[
'id'
],
'is_enable'
=>
1
])
->
select
();
$v
[
'items'
]
=
Db
::
name
(
'Article'
)
->
field
(
'id,title,title_color'
)
->
where
([
'article_category_id'
=>
$v
[
'id'
],
'is_enable'
=>
1
])
->
select
();
}
}
return
$data
;
...
...
@@ -82,7 +83,7 @@ class ArticleService
{
if
(
!
empty
(
$params
[
'id'
]))
{
return
db
(
'Article'
)
->
where
(
array
(
'id'
=>
intval
(
$params
[
'id'
])))
->
setInc
(
'access_count'
);
return
Db
::
name
(
'Article'
)
->
where
(
array
(
'id'
=>
intval
(
$params
[
'id'
])))
->
setInc
(
'access_count'
);
}
return
false
;
}
...
...
application/service/BannerService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 轮播服务层
* @author Devil
...
...
@@ -21,7 +23,7 @@ class BannerService
*/
public
static
function
Banner
(
$params
=
[])
{
$banner
=
db
(
'Slide'
)
->
field
(
'name,images_url,event_value,event_type,bg_color'
)
->
where
([
'platform'
=>
APPLICATION_CLIENT_TYPE
,
'is_enable'
=>
1
])
->
order
(
'sort asc'
)
->
select
();
$banner
=
Db
::
name
(
'Slide'
)
->
field
(
'name,images_url,event_value,event_type,bg_color'
)
->
where
([
'platform'
=>
APPLICATION_CLIENT_TYPE
,
'is_enable'
=>
1
])
->
order
(
'sort asc'
)
->
select
();
if
(
!
empty
(
$banner
))
{
$images_host
=
config
(
'IMAGE_HOST'
);
...
...
application/service/BrandService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
use
app\service\GoodsService
;
use
app\service\ResourcesService
;
...
...
@@ -31,7 +32,7 @@ class BrandService
$n
=
isset
(
$params
[
'n'
])
?
intval
(
$params
[
'n'
])
:
10
;
// 获取品牌列表
$data
=
db
(
'Brand'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
limit
(
$m
,
$n
)
->
select
();
$data
=
Db
::
name
(
'Brand'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
limit
(
$m
,
$n
)
->
select
();
if
(
!
empty
(
$data
))
{
$common_is_enable_tips
=
lang
(
'common_is_enable_tips'
);
...
...
@@ -47,7 +48,7 @@ class BrandService
// 分类名称
if
(
isset
(
$v
[
'brand_category_id'
]))
{
$v
[
'brand_category_name'
]
=
db
(
'BrandCategory'
)
->
where
([
'id'
=>
$v
[
'brand_category_id'
]])
->
value
(
'name'
);
$v
[
'brand_category_name'
]
=
Db
::
name
(
'BrandCategory'
)
->
where
([
'id'
=>
$v
[
'brand_category_id'
]])
->
value
(
'name'
);
}
// logo
...
...
@@ -83,7 +84,7 @@ class BrandService
*/
public
static
function
BrandTotal
(
$where
)
{
return
(
int
)
db
(
'Brand'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'Brand'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -140,12 +141,12 @@ class BrandService
*/
public
static
function
CategoryBrand
(
$params
=
[])
{
$data
=
db
(
'BrandCategory'
)
->
where
([
'is_enable'
=>
1
])
->
select
();
$data
=
Db
::
name
(
'BrandCategory'
)
->
where
([
'is_enable'
=>
1
])
->
select
();
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
&
$v
)
{
$v
[
'items'
]
=
db
(
'Brand'
)
->
field
(
'id,name'
)
->
where
([
'is_enable'
=>
1
,
'brand_category_id'
=>
$v
[
'id'
]])
->
order
(
'sort asc'
)
->
select
();
$v
[
'items'
]
=
Db
::
name
(
'Brand'
)
->
field
(
'id,name'
)
->
where
([
'is_enable'
=>
1
,
'brand_category_id'
=>
$v
[
'id'
]])
->
order
(
'sort asc'
)
->
select
();
}
}
return
$data
;
...
...
@@ -168,11 +169,11 @@ class BrandService
// 根据分类获取品牌id
$category_ids
=
GoodsService
::
GoodsCategoryItemsIds
([
$params
[
'category_id'
]],
1
);
$where
=
[
'g.is_delete_time'
=>
0
,
'g.is_shelves'
=>
1
,
'gci.id'
=>
$category_ids
];
$brand_where
[
'id'
]
=
db
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
field
(
'g.brand_id'
)
->
where
(
$where
)
->
group
(
'g.brand_id'
)
->
column
(
'brand_id'
);
$brand_where
[
'id'
]
=
Db
::
name
(
'Goods'
)
->
alias
(
'g'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'g.id=gci.goods_id'
)
->
field
(
'g.brand_id'
)
->
where
(
$where
)
->
group
(
'g.brand_id'
)
->
column
(
'brand_id'
);
}
// 获取品牌列表
$brand
=
db
(
'Brand'
)
->
where
(
$brand_where
)
->
field
(
'id,name,logo,website_url'
)
->
select
();
$brand
=
Db
::
name
(
'Brand'
)
->
where
(
$brand_where
)
->
field
(
'id,name,logo,website_url'
)
->
select
();
if
(
!
empty
(
$brand
))
{
$image_host
=
config
(
'IMAGE_HOST'
);
...
...
@@ -197,7 +198,7 @@ class BrandService
*/
public
static
function
BrandName
(
$brand_id
=
0
)
{
return
empty
(
$brand_id
)
?
null
:
db
(
'Brand'
)
->
where
([
'id'
=>
intval
(
$brand_id
)])
->
value
(
'name'
);
return
empty
(
$brand_id
)
?
null
:
Db
::
name
(
'Brand'
)
->
where
([
'id'
=>
intval
(
$brand_id
)])
->
value
(
'name'
);
}
/**
...
...
@@ -214,7 +215,7 @@ class BrandService
$field
=
empty
(
$params
[
'field'
])
?
'*'
:
$params
[
'field'
];
$order_by
=
empty
(
$params
[
'order_by'
])
?
'sort asc'
:
trim
(
$params
[
'order_by'
]);
$data
=
db
(
'BrandCategory'
)
->
where
([
'is_enable'
=>
1
])
->
field
(
$field
)
->
order
(
$order_by
)
->
select
();
$data
=
Db
::
name
(
'BrandCategory'
)
->
where
([
'is_enable'
=>
1
])
->
field
(
$field
)
->
order
(
$order_by
)
->
select
();
return
DataReturn
(
'处理成功'
,
0
,
$data
);
}
...
...
@@ -280,14 +281,14 @@ class BrandService
if
(
empty
(
$params
[
'id'
]))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'Brand'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'Brand'
)
->
insertGetId
(
$data
)
>
0
)
{
return
DataReturn
(
'添加成功'
,
0
);
}
return
DataReturn
(
'添加失败'
,
-
100
);
}
else
{
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'Brand'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
if
(
Db
::
name
(
'Brand'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
{
return
DataReturn
(
'编辑成功'
,
0
);
}
...
...
@@ -321,7 +322,7 @@ class BrandService
}
// 删除操作
if
(
db
(
'Brand'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
if
(
Db
::
name
(
'Brand'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
{
return
DataReturn
(
'删除成功'
);
}
...
...
@@ -360,7 +361,7 @@ class BrandService
}
// 数据更新
if
(
db
(
'Brand'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
if
(
Db
::
name
(
'Brand'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
{
return
DataReturn
(
'编辑成功'
);
}
...
...
@@ -382,12 +383,12 @@ class BrandService
// 获取数据
$field
=
'*'
;
$data
=
db
(
'BrandCategory'
)
->
field
(
$field
)
->
where
([
'pid'
=>
$id
])
->
order
(
'sort asc'
)
->
select
();
$data
=
Db
::
name
(
'BrandCategory'
)
->
field
(
$field
)
->
where
([
'pid'
=>
$id
])
->
order
(
'sort asc'
)
->
select
();
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
&
$v
)
{
$v
[
'is_son'
]
=
(
db
(
'BrandCategory'
)
->
where
([
'pid'
=>
$v
[
'id'
]])
->
count
()
>
0
)
?
'ok'
:
'no'
;
$v
[
'is_son'
]
=
(
Db
::
name
(
'BrandCategory'
)
->
where
([
'pid'
=>
$v
[
'id'
]])
->
count
()
>
0
)
?
'ok'
:
'no'
;
$v
[
'ajax_url'
]
=
url
(
'admin/brandcategory/getnodeson'
,
array
(
'id'
=>
$v
[
'id'
]));
$v
[
'delete_url'
]
=
url
(
'admin/brandcategory/delete'
);
$v
[
'json'
]
=
json_encode
(
$v
);
...
...
@@ -434,14 +435,14 @@ class BrandService
if
(
empty
(
$params
[
'id'
]))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'BrandCategory'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'BrandCategory'
)
->
insertGetId
(
$data
)
>
0
)
{
return
DataReturn
(
'添加成功'
,
0
);
}
return
DataReturn
(
'添加失败'
,
-
100
);
}
else
{
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'BrandCategory'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
if
(
Db
::
name
(
'BrandCategory'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
{
return
DataReturn
(
'编辑成功'
,
0
);
}
...
...
@@ -479,7 +480,7 @@ class BrandService
}
// 开始删除
if
(
db
(
'BrandCategory'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
delete
())
if
(
Db
::
name
(
'BrandCategory'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
delete
())
{
return
DataReturn
(
'删除成功'
,
0
);
}
...
...
application/service/BuyService.php
浏览文件 @
a2157b0c
...
...
@@ -51,7 +51,7 @@ class BuyService
// 获取商品
$goods_id
=
intval
(
$params
[
'goods_id'
]);
$goods
=
db
(
'Goods'
)
->
where
([
'id'
=>
$goods_id
,
'is_shelves'
=>
1
,
'is_delete_time'
=>
0
])
->
find
();
$goods
=
Db
::
name
(
'Goods'
)
->
where
([
'id'
=>
$goods_id
,
'is_shelves'
=>
1
,
'is_delete_time'
=>
0
])
->
find
();
if
(
empty
(
$goods
))
{
return
DataReturn
(
'商品不存在或已删除'
,
-
2
);
...
...
@@ -81,11 +81,11 @@ class BuyService
// 存在则更新
$where
=
[
'user_id'
=>
$data
[
'user_id'
],
'goods_id'
=>
$data
[
'goods_id'
],
'spec'
=>
$data
[
'spec'
]];
$temp
=
db
(
'Cart'
)
->
where
(
$where
)
->
find
();
$temp
=
Db
::
name
(
'Cart'
)
->
where
(
$where
)
->
find
();
if
(
empty
(
$temp
))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'Cart'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'Cart'
)
->
insertGetId
(
$data
)
>
0
)
{
return
DataReturn
(
'加入成功'
,
0
,
self
::
UserCartTotal
(
$params
));
}
...
...
@@ -96,7 +96,7 @@ class BuyService
{
$data
[
'stock'
]
=
$goods
[
'inventory'
];
}
if
(
db
(
'Cart'
)
->
where
(
$where
)
->
update
(
$data
))
if
(
Db
::
name
(
'Cart'
)
->
where
(
$where
)
->
update
(
$data
))
{
return
DataReturn
(
'加入成功'
,
0
,
self
::
UserCartTotal
(
$params
));
}
...
...
@@ -156,7 +156,7 @@ class BuyService
$where
[
'c.user_id'
]
=
$params
[
'user'
][
'id'
];
$field
=
'c.*, g.title, g.images, g.inventory_unit, g.is_shelves, g.is_delete_time, g.buy_min_number, g.buy_max_number'
;
$data
=
db
(
'Cart'
)
->
alias
(
'c'
)
->
join
([
'__GOODS__'
=>
'g'
],
'g.id=c.goods_id'
)
->
where
(
$where
)
->
field
(
$field
)
->
select
();
$data
=
Db
::
name
(
'Cart'
)
->
alias
(
'c'
)
->
join
([
'__GOODS__'
=>
'g'
],
'g.id=c.goods_id'
)
->
where
(
$where
)
->
field
(
$field
)
->
select
();
// 数据处理
...
...
@@ -226,7 +226,7 @@ class BuyService
'id'
=>
explode
(
','
,
$params
[
'id'
]),
'user_id'
=>
$params
[
'user'
][
'id'
]
];
if
(
db
(
'Cart'
)
->
where
(
$where
)
->
delete
())
if
(
Db
::
name
(
'Cart'
)
->
where
(
$where
)
->
delete
())
{
return
DataReturn
(
'删除成功'
,
0
,
self
::
UserCartTotal
(
$params
));
}
...
...
@@ -283,7 +283,7 @@ class BuyService
'stock'
=>
intval
(
$params
[
'stock'
]),
'upd_time'
=>
time
(),
];
if
(
db
(
'Cart'
)
->
where
(
$where
)
->
update
(
$data
))
if
(
Db
::
name
(
'Cart'
)
->
where
(
$where
)
->
update
(
$data
))
{
return
DataReturn
(
'更新成功'
,
0
);
}
...
...
@@ -417,7 +417,7 @@ class BuyService
{
if
(
isset
(
$params
[
'buy_type'
])
&&
$params
[
'buy_type'
]
==
'cart'
&&
!
empty
(
$params
[
'ids'
]))
{
db
(
'Cart'
)
->
where
([
'id'
=>
explode
(
','
,
$params
[
'ids'
])])
->
delete
();
Db
::
name
(
'Cart'
)
->
where
([
'id'
=>
explode
(
','
,
$params
[
'ids'
])])
->
delete
();
}
}
...
...
@@ -486,7 +486,7 @@ class BuyService
foreach
(
$params
[
'goods'
]
as
$v
)
{
// 获取商品信息
$goods
=
db
(
'Goods'
)
->
find
(
$v
[
'goods_id'
]);
$goods
=
Db
::
name
(
'Goods'
)
->
find
(
$v
[
'goods_id'
]);
// 规格
$goods_base
=
GoodsService
::
GoodsSpecDetail
([
'id'
=>
$v
[
'goods_id'
],
'spec'
=>
isset
(
$v
[
'spec'
])
?
$v
[
'spec'
]
:
[]]);
...
...
@@ -623,7 +623,7 @@ class BuyService
Db
::
startTrans
();
// 订单添加
$order_id
=
db
(
'Order'
)
->
insertGetId
(
$order
);
$order_id
=
Db
::
name
(
'Order'
)
->
insertGetId
(
$order
);
if
(
$order_id
>
0
)
{
foreach
(
$goods
[
'data'
]
as
$v
)
...
...
@@ -641,7 +641,7 @@ class BuyService
'buy_number'
=>
$v
[
'stock'
],
'add_time'
=>
time
(),
];
if
(
db
(
'OrderDetail'
)
->
insertGetId
(
$detail
)
<=
0
)
if
(
Db
::
name
(
'OrderDetail'
)
->
insertGetId
(
$detail
)
<=
0
)
{
Db
::
rollback
();
return
DataReturn
(
'订单详情添加失败'
,
-
1
);
...
...
@@ -673,7 +673,7 @@ class BuyService
// 返回信息
$result
=
[
'order'
=>
db
(
'Order'
)
->
find
(
$order_id
),
'order'
=>
Db
::
name
(
'Order'
)
->
find
(
$order_id
),
'jump_url'
=>
url
(
'index/order/index'
),
];
...
...
@@ -711,7 +711,7 @@ class BuyService
*/
public
static
function
CartTotal
(
$where
=
[])
{
return
(
int
)
db
(
'Cart'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'Cart'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -813,20 +813,20 @@ class BuyService
}
// 获取订单商品
$order_detail
=
db
(
'OrderDetail'
)
->
field
(
'goods_id,buy_number'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
]])
->
select
();
$order_detail
=
Db
::
name
(
'OrderDetail'
)
->
field
(
'goods_id,buy_number'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
]])
->
select
();
if
(
!
empty
(
$order_detail
))
{
foreach
(
$order_detail
as
$v
)
{
// 查看是否已扣除过库存,避免更改模式导致重复扣除
$temp
=
db
(
'OrderGoodsInventoryLog'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
],
'goods_id'
=>
$v
[
'goods_id'
]])
->
find
();
$temp
=
Db
::
name
(
'OrderGoodsInventoryLog'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
],
'goods_id'
=>
$v
[
'goods_id'
]])
->
find
();
if
(
empty
(
$temp
))
{
$goods
=
db
(
'Goods'
)
->
field
(
'is_deduction_inventory,inventory'
)
->
find
(
$v
[
'goods_id'
]);
$goods
=
Db
::
name
(
'Goods'
)
->
field
(
'is_deduction_inventory,inventory'
)
->
find
(
$v
[
'goods_id'
]);
if
(
isset
(
$goods
[
'is_deduction_inventory'
])
&&
$goods
[
'is_deduction_inventory'
]
==
1
)
{
// 扣除操作
if
(
!
db
(
'Goods'
)
->
where
([
'id'
=>
$v
[
'goods_id'
]])
->
setDec
(
'inventory'
,
$v
[
'buy_number'
]))
if
(
!
Db
::
name
(
'Goods'
)
->
where
([
'id'
=>
$v
[
'goods_id'
]])
->
setDec
(
'inventory'
,
$v
[
'buy_number'
]))
{
return
DataReturn
(
'库存扣减失败['
.
$params
[
'order_id'
]
.
'-'
.
$v
[
'goods_id'
]
.
']'
,
-
10
);
}
...
...
@@ -837,10 +837,10 @@ class BuyService
'goods_id'
=>
$v
[
'goods_id'
],
'order_status'
=>
$params
[
'order_data'
][
'status'
],
'original_inventory'
=>
$goods
[
'inventory'
],
'new_inventory'
=>
db
(
'Goods'
)
->
where
([
'id'
=>
$v
[
'goods_id'
]])
->
value
(
'inventory'
),
'new_inventory'
=>
Db
::
name
(
'Goods'
)
->
where
([
'id'
=>
$v
[
'goods_id'
]])
->
value
(
'inventory'
),
'add_time'
=>
time
(),
];
if
(
db
(
'OrderGoodsInventoryLog'
)
->
insertGetId
(
$log_data
)
<=
0
)
if
(
Db
::
name
(
'OrderGoodsInventoryLog'
)
->
insertGetId
(
$log_data
)
<=
0
)
{
return
DataReturn
(
'库存扣减日志添加失败['
.
$params
[
'order_id'
]
.
'-'
.
$v
[
'goods_id'
]
.
']'
,
-
100
);
}
...
...
@@ -894,17 +894,17 @@ class BuyService
}
// 获取订单商品
$order_detail
=
db
(
'OrderDetail'
)
->
field
(
'goods_id,buy_number'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
]])
->
select
();
$order_detail
=
Db
::
name
(
'OrderDetail'
)
->
field
(
'goods_id,buy_number'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
]])
->
select
();
if
(
!
empty
(
$order_detail
))
{
foreach
(
$order_detail
as
$v
)
{
// 查看是否已扣除过库存
$temp
=
db
(
'OrderGoodsInventoryLog'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
],
'goods_id'
=>
$v
[
'goods_id'
],
'is_rollback'
=>
0
])
->
find
();
$temp
=
Db
::
name
(
'OrderGoodsInventoryLog'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
],
'goods_id'
=>
$v
[
'goods_id'
],
'is_rollback'
=>
0
])
->
find
();
if
(
!
empty
(
$temp
))
{
// 回滚操作
if
(
!
db
(
'Goods'
)
->
where
([
'id'
=>
$v
[
'goods_id'
]])
->
setInc
(
'inventory'
,
$v
[
'buy_number'
]))
if
(
!
Db
::
name
(
'Goods'
)
->
where
([
'id'
=>
$v
[
'goods_id'
]])
->
setInc
(
'inventory'
,
$v
[
'buy_number'
]))
{
return
DataReturn
(
'库存回滚失败['
.
$params
[
'order_id'
]
.
'-'
.
$v
[
'goods_id'
]
.
']'
,
-
10
);
}
...
...
@@ -914,7 +914,7 @@ class BuyService
'is_rollback'
=>
1
,
'rollback_time'
=>
time
(),
];
if
(
!
db
(
'OrderGoodsInventoryLog'
)
->
where
([
'id'
=>
$temp
[
'id'
]])
->
update
(
$log_data
))
if
(
!
Db
::
name
(
'OrderGoodsInventoryLog'
)
->
where
([
'id'
=>
$temp
[
'id'
]])
->
update
(
$log_data
))
{
return
DataReturn
(
'库存回滚日志更新失败['
.
$temp
[
'id'
]
.
'-'
.
$params
[
'order_id'
]
.
']'
,
-
100
);
}
...
...
application/service/ConfigService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 配置服务层
* @author Devil
...
...
@@ -22,7 +24,7 @@ class ConfigService
public
static
function
ConfigList
(
$params
=
[])
{
$field
=
isset
(
$params
[
'field'
])
?
$params
[
'field'
]
:
'only_tag,name,describe,value,error_tips'
;
return
db
(
'Config'
)
->
column
(
$field
);
return
Db
::
name
(
'Config'
)
->
column
(
$field
);
}
/**
...
...
@@ -60,7 +62,7 @@ class ConfigService
{
$v
=
htmlentities
(
$v
);
}
if
(
db
(
'Config'
)
->
where
([
'only_tag'
=>
$k
])
->
update
([
'value'
=>
$v
,
'upd_time'
=>
time
()]))
if
(
Db
::
name
(
'Config'
)
->
where
([
'only_tag'
=>
$k
])
->
update
([
'value'
=>
$v
,
'upd_time'
=>
time
()]))
{
$success
++
;
}
...
...
@@ -90,7 +92,7 @@ class ConfigService
if
(
$status
==
1
||
empty
(
$data
))
{
// 所有配置
$data
=
db
(
'Config'
)
->
column
(
'value'
,
'only_tag'
);
$data
=
Db
::
name
(
'Config'
)
->
column
(
'value'
,
'only_tag'
);
// 数据处理
// 开启用户注册列表
...
...
application/service/CustomViewService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
use
app\service\ResourcesService
;
/**
...
...
@@ -28,7 +29,7 @@ class CustomViewService
$m
=
isset
(
$params
[
'm'
])
?
intval
(
$params
[
'm'
])
:
0
;
$n
=
isset
(
$params
[
'n'
])
?
intval
(
$params
[
'n'
])
:
10
;
$data
=
db
(
'CustomView'
)
->
field
(
$field
)
->
where
(
$where
)
->
order
(
'id desc'
)
->
limit
(
$m
,
$n
)
->
select
();
$data
=
Db
::
name
(
'CustomView'
)
->
field
(
$field
)
->
where
(
$where
)
->
order
(
'id desc'
)
->
limit
(
$m
,
$n
)
->
select
();
if
(
!
empty
(
$data
))
{
$common_is_enable_list
=
lang
(
'common_is_enable_list'
);
...
...
@@ -73,7 +74,7 @@ class CustomViewService
*/
public
static
function
CustomViewTotal
(
$where
=
[])
{
return
(
int
)
db
(
'CustomView'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'CustomView'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -143,7 +144,7 @@ class CustomViewService
{
if
(
!
empty
(
$params
[
'id'
]))
{
return
db
(
'CustomView'
)
->
where
(
array
(
'id'
=>
intval
(
$params
[
'id'
])))
->
setInc
(
'access_count'
);
return
Db
::
name
(
'CustomView'
)
->
where
(
array
(
'id'
=>
intval
(
$params
[
'id'
])))
->
setInc
(
'access_count'
);
}
return
false
;
}
...
...
@@ -197,14 +198,14 @@ class CustomViewService
if
(
empty
(
$params
[
'id'
]))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'CustomView'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'CustomView'
)
->
insertGetId
(
$data
)
>
0
)
{
return
DataReturn
(
'添加成功'
,
0
);
}
return
DataReturn
(
'添加失败'
,
-
100
);
}
else
{
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'CustomView'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
if
(
Db
::
name
(
'CustomView'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
{
return
DataReturn
(
'编辑成功'
,
0
);
}
...
...
@@ -258,7 +259,7 @@ class CustomViewService
}
// 删除操作
if
(
db
(
'CustomView'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
if
(
Db
::
name
(
'CustomView'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
{
return
DataReturn
(
'删除成功'
);
}
...
...
@@ -302,7 +303,7 @@ class CustomViewService
}
// 数据更新
if
(
db
(
'CustomView'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
$params
[
'field'
]
=>
intval
(
$params
[
'state'
])]))
if
(
Db
::
name
(
'CustomView'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
$params
[
'field'
]
=>
intval
(
$params
[
'state'
])]))
{
return
DataReturn
(
'编辑成功'
);
}
...
...
application/service/ExpressService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 快递服务层
* @author Devil
...
...
@@ -21,7 +23,7 @@ class ExpressService
*/
public
static
function
ExpressName
(
$express_id
=
0
)
{
return
empty
(
$express_id
)
?
null
:
db
(
'Express'
)
->
where
([
'id'
=>
intval
(
$express_id
)])
->
value
(
'name'
);
return
empty
(
$express_id
)
?
null
:
Db
::
name
(
'Express'
)
->
where
([
'id'
=>
intval
(
$express_id
)])
->
value
(
'name'
);
}
/**
...
...
@@ -40,7 +42,7 @@ class ExpressService
{
$where
[
'is_enable'
]
=
intval
(
$params
[
'is_enable'
]);
}
$data
=
db
(
'Express'
)
->
where
(
$where
)
->
field
(
'id,icon,name,sort,is_enable'
)
->
order
(
'sort asc'
)
->
select
();
$data
=
Db
::
name
(
'Express'
)
->
where
(
$where
)
->
field
(
'id,icon,name,sort,is_enable'
)
->
order
(
'sort asc'
)
->
select
();
if
(
!
empty
(
$data
)
&&
is_array
(
$data
))
{
$images_host
=
config
(
'IMAGE_HOST'
);
...
...
application/service/GoodsService.php
浏览文件 @
a2157b0c
此差异已折叠。
点击以展开。
application/service/IntegralService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
use
app\service\MessageService
;
/**
...
...
@@ -38,7 +38,7 @@ class IntegralService
'operation_id'
=>
intval
(
$operation_id
),
'add_time'
=>
time
(),
);
if
(
db
(
'UserIntegralLog'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'UserIntegralLog'
)
->
insertGetId
(
$data
)
>
0
)
{
$type_msg
=
lang
(
'common_integral_log_type_list'
)[
$type
][
'name'
];
$integral
=
(
$data
[
'type'
]
==
0
)
?
$data
[
'original_integral'
]
-
$data
[
'new_integral'
]
:
$data
[
'new_integral'
]
-
$data
[
'original_integral'
];
...
...
@@ -106,7 +106,7 @@ class IntegralService
*/
public
static
function
UserIntegralLogTotal
(
$where
=
[])
{
return
(
int
)
db
(
'UserIntegralLog'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'UserIntegralLog'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -126,7 +126,7 @@ class IntegralService
$order_by
=
empty
(
$params
[
'order_by'
])
?
'id desc'
:
$params
[
'order_by'
];
// 获取数据列表
$data
=
db
(
'UserIntegralLog'
)
->
where
(
$where
)
->
limit
(
$m
,
$n
)
->
order
(
$order_by
)
->
select
();
$data
=
Db
::
name
(
'UserIntegralLog'
)
->
where
(
$where
)
->
limit
(
$m
,
$n
)
->
order
(
$order_by
)
->
select
();
if
(
!
empty
(
$data
))
{
$common_integral_log_type_list
=
lang
(
'common_integral_log_type_list'
);
...
...
@@ -169,7 +169,7 @@ class IntegralService
}
// 订单
$order
=
db
(
'Order'
)
->
field
(
'id,user_id,status'
)
->
find
(
intval
(
$params
[
'order_id'
]));
$order
=
Db
::
name
(
'Order'
)
->
field
(
'id,user_id,status'
)
->
find
(
intval
(
$params
[
'order_id'
]));
if
(
empty
(
$order
))
{
return
DataReturn
(
'订单不存在或已删除,中止操作'
,
0
);
...
...
@@ -180,24 +180,24 @@ class IntegralService
}
// 获取用户信息
$user
=
db
(
'User'
)
->
field
(
'id'
)
->
find
(
intval
(
$order
[
'user_id'
]));
$user
=
Db
::
name
(
'User'
)
->
field
(
'id'
)
->
find
(
intval
(
$order
[
'user_id'
]));
if
(
empty
(
$user
))
{
return
DataReturn
(
'用户不存在或已删除,中止操作'
,
0
);
}
// 获取订单商品
$goods_all
=
db
(
'OrderDetail'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
]])
->
column
(
'goods_id'
);
$goods_all
=
Db
::
name
(
'OrderDetail'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
]])
->
column
(
'goods_id'
);
if
(
!
empty
(
$goods_all
))
{
foreach
(
$goods_all
as
$goods_id
)
{
$give_integral
=
db
(
'Goods'
)
->
where
([
'id'
=>
$goods_id
])
->
value
(
'give_integral'
);
$give_integral
=
Db
::
name
(
'Goods'
)
->
where
([
'id'
=>
$goods_id
])
->
value
(
'give_integral'
);
if
(
!
empty
(
$give_integral
))
{
// 用户积分添加
$user_integral
=
db
(
'User'
)
->
where
([
'id'
=>
$user
[
'id'
]])
->
value
(
'integral'
);
if
(
!
db
(
'User'
)
->
where
([
'id'
=>
$user
[
'id'
]])
->
setInc
(
'integral'
,
$give_integral
))
$user_integral
=
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$user
[
'id'
]])
->
value
(
'integral'
);
if
(
!
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$user
[
'id'
]])
->
setInc
(
'integral'
,
$give_integral
))
{
return
DataReturn
(
'用户积分赠送失败['
.
$params
[
'order_id'
]
.
'-'
.
$goods_id
.
']'
,
-
10
);
}
...
...
application/service/LinkService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
use
app\service\GoodsService
;
/**
...
...
@@ -23,7 +24,7 @@ class LinkService
*/
public
static
function
LinkList
(
$params
=
[])
{
$data
=
db
(
'Link'
)
->
order
(
'sort asc'
)
->
select
();
$data
=
Db
::
name
(
'Link'
)
->
order
(
'sort asc'
)
->
select
();
return
DataReturn
(
'处理成功'
,
0
,
$data
);
}
...
...
@@ -96,14 +97,14 @@ class LinkService
if
(
empty
(
$params
[
'id'
]))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'Link'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'Link'
)
->
insertGetId
(
$data
)
>
0
)
{
return
DataReturn
(
'添加成功'
,
0
);
}
return
DataReturn
(
'添加失败'
,
-
100
);
}
else
{
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'Link'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
if
(
Db
::
name
(
'Link'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
{
return
DataReturn
(
'编辑成功'
,
0
);
}
...
...
@@ -137,7 +138,7 @@ class LinkService
}
// 删除操作
if
(
db
(
'Link'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
if
(
Db
::
name
(
'Link'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
{
return
DataReturn
(
'删除成功'
);
}
...
...
@@ -176,7 +177,7 @@ class LinkService
}
// 数据更新
if
(
db
(
'Link'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
if
(
Db
::
name
(
'Link'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
{
return
DataReturn
(
'编辑成功'
);
}
...
...
application/service/MessageService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 消息服务层
* @author Devil
...
...
@@ -38,7 +39,7 @@ class MessageService
'is_read'
=>
0
,
'add_time'
=>
time
(),
);
return
db
(
'Message'
)
->
insertGetId
(
$data
)
>
0
;
return
Db
::
name
(
'Message'
)
->
insertGetId
(
$data
)
>
0
;
}
/**
...
...
@@ -121,7 +122,7 @@ class MessageService
*/
public
static
function
MessageTotal
(
$where
=
[])
{
return
(
int
)
db
(
'Message'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'Message'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -168,7 +169,7 @@ class MessageService
$order_by
=
empty
(
$params
[
'order_by'
])
?
'id desc'
:
$params
[
'order_by'
];
// 获取数据列表
$data
=
db
(
'Message'
)
->
where
(
$where
)
->
limit
(
$m
,
$n
)
->
order
(
$order_by
)
->
select
();
$data
=
Db
::
name
(
'Message'
)
->
where
(
$where
)
->
limit
(
$m
,
$n
)
->
order
(
$order_by
)
->
select
();
if
(
!
empty
(
$data
))
{
$common_business_type_list
=
lang
(
'common_business_type_list'
);
...
...
@@ -220,7 +221,7 @@ class MessageService
// 更新用户未读消息为已读
$where
=
[
'user_id'
=>
$params
[
'user'
][
'id'
],
'is_read'
=>
0
];
$ret
=
db
(
'Message'
)
->
where
(
$where
)
->
update
([
'is_read'
=>
1
]);
$ret
=
Db
::
name
(
'Message'
)
->
where
(
$where
)
->
update
([
'is_read'
=>
1
]);
return
DataReturn
(
'处理成功'
,
0
,
$ret
);
}
}
...
...
application/service/NavigationService.php
浏览文件 @
a2157b0c
...
...
@@ -28,7 +28,7 @@ class NavigationService
$footer
=
cache
(
config
(
'cache_common_home_nav_footer_key'
));
// 导航模型
$m
=
db
(
'Navigation'
);
$m
=
Db
::
name
(
'Navigation'
);
$field
=
array
(
'id'
,
'pid'
,
'name'
,
'url'
,
'value'
,
'data_type'
,
'is_new_window_open'
);
// 缓存没数据则从数据库重新读取,顶部菜单
...
...
@@ -114,12 +114,12 @@ class NavigationService
}
$field
=
'id,pid,name,url,value,data_type,sort,is_show,is_new_window_open'
;
$data
=
self
::
NavDataDealWith
(
db
(
'Navigation'
)
->
field
(
$field
)
->
where
([
'nav_type'
=>
$params
[
'nav_type'
],
'pid'
=>
0
])
->
order
(
'sort'
)
->
select
());
$data
=
self
::
NavDataDealWith
(
Db
::
name
(
'Navigation'
)
->
field
(
$field
)
->
where
([
'nav_type'
=>
$params
[
'nav_type'
],
'pid'
=>
0
])
->
order
(
'sort'
)
->
select
());
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
&
$v
)
{
$v
[
'item'
]
=
self
::
NavDataDealWith
(
db
(
'Navigation'
)
->
field
(
$field
)
->
where
([
'nav_type'
=>
$params
[
'nav_type'
],
'pid'
=>
$v
[
'id'
]])
->
order
(
'sort'
)
->
select
());
$v
[
'item'
]
=
self
::
NavDataDealWith
(
Db
::
name
(
'Navigation'
)
->
field
(
$field
)
->
where
([
'nav_type'
=>
$params
[
'nav_type'
],
'pid'
=>
$v
[
'id'
]])
->
order
(
'sort'
)
->
select
());
}
}
return
$data
;
...
...
@@ -141,7 +141,7 @@ class NavigationService
return
[];
}
return
db
(
'Navigation'
)
->
field
(
'id,name'
)
->
where
([
'is_show'
=>
1
,
'pid'
=>
0
,
'nav_type'
=>
$params
[
'nav_type'
]])
->
select
();
return
Db
::
name
(
'Navigation'
)
->
field
(
'id,name'
)
->
where
([
'is_show'
=>
1
,
'pid'
=>
0
,
'nav_type'
=>
$params
[
'nav_type'
]])
->
select
();
}
/**
...
...
@@ -292,17 +292,17 @@ class NavigationService
{
// 文章分类导航
case
'article'
:
$temp_name
=
db
(
'Article'
)
->
where
([
'id'
=>
$params
[
'value'
]])
->
value
(
'title'
);
$temp_name
=
Db
::
name
(
'Article'
)
->
where
([
'id'
=>
$params
[
'value'
]])
->
value
(
'title'
);
break
;
// 自定义页面导航
case
'customview'
:
$temp_name
=
db
(
'CustomView'
)
->
where
([
'id'
=>
$params
[
'value'
]])
->
value
(
'title'
);
$temp_name
=
Db
::
name
(
'CustomView'
)
->
where
([
'id'
=>
$params
[
'value'
]])
->
value
(
'title'
);
break
;
// 商品分类导航
case
'goods_category'
:
$temp_name
=
db
(
'GoodsCategory'
)
->
where
([
'id'
=>
$params
[
'value'
]])
->
value
(
'name'
);
$temp_name
=
Db
::
name
(
'GoodsCategory'
)
->
where
([
'id'
=>
$params
[
'value'
]])
->
value
(
'name'
);
break
;
}
// 只截取16个字符
...
...
@@ -329,7 +329,7 @@ class NavigationService
if
(
empty
(
$params
[
'id'
]))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'Navigation'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'Navigation'
)
->
insertGetId
(
$data
)
>
0
)
{
// 清除缓存
cache
(
config
(
'cache_common_home_nav_'
.
$params
[
'nav_type'
]
.
'_key'
),
null
);
...
...
@@ -340,7 +340,7 @@ class NavigationService
}
}
else
{
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'Navigation'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
if
(
Db
::
name
(
'Navigation'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
{
// 清除缓存
cache
(
config
(
'cache_common_home_nav_'
.
$params
[
'nav_type'
]
.
'_key'
),
null
);
...
...
@@ -381,7 +381,7 @@ class NavigationService
Db
::
startTrans
();
// 删除操作
if
(
db
(
'Navigation'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
()
!==
false
&&
db
(
'Navigation'
)
->
where
([
'pid'
=>
$params
[
'id'
]])
->
delete
()
!==
false
)
if
(
Db
::
name
(
'Navigation'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
()
!==
false
&&
Db
::
name
(
'Navigation'
)
->
where
([
'pid'
=>
$params
[
'id'
]])
->
delete
()
!==
false
)
{
// 提交事务
Db
::
commit
();
...
...
@@ -430,7 +430,7 @@ class NavigationService
}
// 数据更新
if
(
db
(
'Navigation'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_show'
=>
intval
(
$params
[
'state'
])]))
if
(
Db
::
name
(
'Navigation'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_show'
=>
intval
(
$params
[
'state'
])]))
{
// 清除缓存
cache
(
config
(
'cache_common_home_nav_header_key'
),
null
);
...
...
application/service/OrderService.php
浏览文件 @
a2157b0c
...
...
@@ -51,7 +51,7 @@ class OrderService
// 获取订单信息
$where
=
[
'id'
=>
intval
(
$params
[
'id'
]),
'user_id'
=>
$params
[
'user'
][
'id'
]];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
find
();
if
(
empty
(
$order
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
...
...
@@ -154,7 +154,7 @@ class OrderService
// 获取订单信息
$where
=
[
'id'
=>
intval
(
$params
[
'id'
])];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
find
();
if
(
empty
(
$order
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
...
...
@@ -256,7 +256,7 @@ class OrderService
{
// 获取订单信息
$where
=
[
'order_no'
=>
$ret
[
'data'
][
'out_trade_no'
],
'is_delete_time'
=>
0
,
'user_is_delete_time'
=>
0
];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
find
();
// 非线上支付处理
self
::
OrderPaymentUnderLine
([
...
...
@@ -297,7 +297,7 @@ class OrderService
// 获取订单信息
$where
=
[
'order_no'
=>
$ret
[
'data'
][
'out_trade_no'
],
'is_delete_time'
=>
0
,
'user_is_delete_time'
=>
0
];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
find
();
// 支付处理
$pay_params
=
[
...
...
@@ -357,7 +357,7 @@ class OrderService
'business_type'
=>
1
,
'add_time'
=>
time
(),
];
db
(
'PayLog'
)
->
insertGetId
(
$pay_log_data
);
Db
::
name
(
'PayLog'
)
->
insertGetId
(
$pay_log_data
);
// 消息通知
$detail
=
'订单支付成功,金额'
.
PriceBeautify
(
$params
[
'order'
][
'total_price'
])
.
'元'
;
...
...
@@ -375,7 +375,7 @@ class OrderService
'pay_time'
=>
time
(),
'upd_time'
=>
time
(),
);
if
(
db
(
'Order'
)
->
where
([
'id'
=>
$params
[
'order'
][
'id'
]])
->
update
(
$upd_data
))
if
(
Db
::
name
(
'Order'
)
->
where
([
'id'
=>
$params
[
'order'
][
'id'
]])
->
update
(
$upd_data
))
{
// 添加状态日志
if
(
self
::
OrderHistoryAdd
(
$params
[
'order'
][
'id'
],
2
,
$params
[
'order'
][
'status'
],
'支付'
,
0
,
'系统'
))
...
...
@@ -511,7 +511,7 @@ class OrderService
*/
public
static
function
OrderTotal
(
$where
=
[])
{
return
(
int
)
db
(
'Order'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -532,7 +532,7 @@ class OrderService
$is_items
=
isset
(
$params
[
'is_items'
])
?
intval
(
$params
[
'is_items'
])
:
1
;
// 获取订单
$data
=
db
(
'Order'
)
->
where
(
$where
)
->
limit
(
$m
,
$n
)
->
order
(
$order_by
)
->
select
();
$data
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
limit
(
$m
,
$n
)
->
order
(
$order_by
)
->
select
();
if
(
!
empty
(
$data
))
{
$detail_field
=
'id,goods_id,title,images,original_price,price,spec,buy_number'
;
...
...
@@ -600,7 +600,7 @@ class OrderService
// 订单详情
if
(
$is_items
==
1
)
{
$items
=
db
(
'OrderDetail'
)
->
where
([
'order_id'
=>
$v
[
'id'
]])
->
field
(
$detail_field
)
->
select
();
$items
=
Db
::
name
(
'OrderDetail'
)
->
where
([
'order_id'
=>
$v
[
'id'
]])
->
field
(
$detail_field
)
->
select
();
if
(
!
empty
(
$items
))
{
foreach
(
$items
as
&
$vs
)
...
...
@@ -655,7 +655,7 @@ class OrderService
'creator_name'
=>
htmlentities
(
$creator_name
),
'add_time'
=>
time
(),
];
return
db
(
'OrderStatusHistory'
)
->
insertGetId
(
$data
)
>
0
;
return
Db
::
name
(
'OrderStatusHistory'
)
->
insertGetId
(
$data
)
>
0
;
}
/**
...
...
@@ -690,7 +690,7 @@ class OrderService
// 获取订单信息
$where
=
[
'id'
=>
intval
(
$params
[
'id'
]),
'user_id'
=>
$params
[
'user_id'
],
'is_delete_time'
=>
0
,
'user_is_delete_time'
=>
0
];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
if
(
empty
(
$order
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
...
...
@@ -708,7 +708,7 @@ class OrderService
'cancel_time'
=>
time
(),
'upd_time'
=>
time
(),
];
if
(
db
(
'Order'
)
->
where
(
$where
)
->
update
(
$upd_data
))
if
(
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
update
(
$upd_data
))
{
// 库存扣除
$ret
=
BuyService
::
OrderInventoryRollback
([
'order_id'
=>
$order
[
'id'
],
'order_data'
=>
$upd_data
]);
...
...
@@ -779,7 +779,7 @@ class OrderService
// 获取订单信息
$where
=
[
'id'
=>
intval
(
$params
[
'id'
]),
'user_id'
=>
$params
[
'user_id'
],
'is_delete_time'
=>
0
,
'user_is_delete_time'
=>
0
];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
if
(
empty
(
$order
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
...
...
@@ -799,7 +799,7 @@ class OrderService
'delivery_time'
=>
time
(),
'upd_time'
=>
time
(),
];
if
(
db
(
'Order'
)
->
where
(
$where
)
->
update
(
$upd_data
))
if
(
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
update
(
$upd_data
))
{
// 库存扣除
$ret
=
BuyService
::
OrderInventoryDeduct
([
'order_id'
=>
$order
[
'id'
],
'order_data'
=>
$upd_data
]);
...
...
@@ -860,7 +860,7 @@ class OrderService
// 获取订单信息
$where
=
[
'id'
=>
intval
(
$params
[
'id'
]),
'user_id'
=>
$params
[
'user_id'
],
'is_delete_time'
=>
0
,
'user_is_delete_time'
=>
0
];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
if
(
empty
(
$order
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
...
...
@@ -880,7 +880,7 @@ class OrderService
'collect_time'
=>
time
(),
'upd_time'
=>
time
(),
];
if
(
db
(
'Order'
)
->
where
(
$where
)
->
update
(
$upd_data
))
if
(
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
update
(
$upd_data
))
{
// 订单商品积分赠送
$ret
=
IntegralService
::
OrderGoodsIntegralGiving
([
'order_id'
=>
$order
[
'id'
]]);
...
...
@@ -950,7 +950,7 @@ class OrderService
// 获取订单信息
$where
=
[
'id'
=>
intval
(
$params
[
'id'
]),
'user_id'
=>
$params
[
'user_id'
],
'is_delete_time'
=>
0
,
'user_is_delete_time'
=>
0
];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
if
(
empty
(
$order
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
...
...
@@ -970,7 +970,7 @@ class OrderService
'confirm_time'
=>
time
(),
'upd_time'
=>
time
(),
];
if
(
db
(
'Order'
)
->
where
(
$where
)
->
update
(
$upd_data
))
if
(
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
update
(
$upd_data
))
{
// 库存扣除
$ret
=
BuyService
::
OrderInventoryDeduct
([
'order_id'
=>
$params
[
'id'
],
'order_data'
=>
$upd_data
]);
...
...
@@ -1052,7 +1052,7 @@ class OrderService
// 获取订单信息
$where
=
[
'id'
=>
intval
(
$params
[
'id'
]),
'user_id'
=>
$params
[
'user_id'
],
'is_delete_time'
=>
0
,
'user_is_delete_time'
=>
0
];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,user_id'
)
->
find
();
if
(
empty
(
$order
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
...
...
@@ -1067,7 +1067,7 @@ class OrderService
$delete_field
=>
time
(),
'upd_time'
=>
time
(),
];
if
(
db
(
'Order'
)
->
where
(
$where
)
->
update
(
$data
))
if
(
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
update
(
$data
))
{
// 用户消息
MessageService
::
MessageAdd
(
$order
[
'user_id'
],
'订单删除'
,
'订单删除成功'
,
1
,
$order
[
'id'
]);
...
...
@@ -1140,7 +1140,7 @@ class OrderService
// 获取订单信息
$order_id
=
intval
(
$params
[
'id'
]);
$where
=
[
'id'
=>
$order_id
,
'user_id'
=>
$params
[
'user'
][
'id'
],
'is_delete_time'
=>
0
,
'user_is_delete_time'
=>
0
];
$order
=
db
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,shop_id,user_is_comments'
)
->
find
();
$order
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
field
(
'id,status,shop_id,user_is_comments'
)
->
find
();
if
(
empty
(
$order
))
{
return
DataReturn
(
'资源不存在或已被删除'
,
-
1
);
...
...
@@ -1168,7 +1168,7 @@ class OrderService
'rating'
=>
isset
(
$params
[
'rating'
][
$k
])
?
intval
(
$params
[
'rating'
][
$k
])
:
0
,
'add_time'
=>
time
(),
];
if
(
db
(
'OrderComments'
)
->
insertGetId
(
$data
)
<=
0
)
if
(
Db
::
name
(
'OrderComments'
)
->
insertGetId
(
$data
)
<=
0
)
{
Db
::
rollback
();
return
DataReturn
(
'评价内容添加失败'
,
-
100
);
...
...
@@ -1176,7 +1176,7 @@ class OrderService
}
// 订单评价状态更新
if
(
!
db
(
'Order'
)
->
where
(
$where
)
->
update
([
'user_is_comments'
=>
time
(),
'upd_time'
=>
time
()]))
if
(
!
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
update
([
'user_is_comments'
=>
time
(),
'upd_time'
=>
time
()]))
{
Db
::
rollback
();
return
DataReturn
(
'订单更新失败'
,
-
101
);
...
...
@@ -1236,7 +1236,7 @@ class OrderService
}
$field
=
'COUNT(DISTINCT id) AS count, status'
;
$data
=
db
(
'Order'
)
->
where
(
$where
)
->
field
(
$field
)
->
group
(
'status'
)
->
select
();
$data
=
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
field
(
$field
)
->
group
(
'status'
)
->
select
();
// 数据处理
if
(
!
empty
(
$data
))
...
...
@@ -1273,7 +1273,7 @@ class OrderService
$result
[]
=
[
'name'
=>
'待评价'
,
'status'
=>
100
,
'count'
=>
(
int
)
db
(
'Order'
)
->
where
(
$where
)
->
count
(),
'count'
=>
(
int
)
Db
::
name
(
'Order'
)
->
where
(
$where
)
->
count
(),
];
}
...
...
@@ -1306,12 +1306,12 @@ class OrderService
}
// 获取订单商品
$order_detail
=
db
(
'OrderDetail'
)
->
field
(
'goods_id,buy_number'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
]])
->
select
();
$order_detail
=
Db
::
name
(
'OrderDetail'
)
->
field
(
'goods_id,buy_number'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
]])
->
select
();
if
(
!
empty
(
$order_detail
))
{
foreach
(
$order_detail
as
$v
)
{
if
(
!
db
(
'Goods'
)
->
where
([
'id'
=>
$v
[
'goods_id'
]])
->
setInc
(
'sales_count'
,
$v
[
'buy_number'
]))
if
(
!
Db
::
name
(
'Goods'
)
->
where
([
'id'
=>
$v
[
'goods_id'
]])
->
setInc
(
'sales_count'
,
$v
[
'buy_number'
]))
{
return
DataReturn
(
'订单商品销量增加失败['
.
$params
[
'order_id'
]
.
'-'
.
$v
[
'goods_id'
]
.
']'
,
-
10
);
}
...
...
application/service/RegionService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 地区服务层
* @author Devil
...
...
@@ -21,7 +23,7 @@ class RegionService
*/
public
static
function
RegionName
(
$region_id
=
0
)
{
return
empty
(
$region_id
)
?
null
:
db
(
'Region'
)
->
where
([
'id'
=>
intval
(
$region_id
)])
->
value
(
'name'
);
return
empty
(
$region_id
)
?
null
:
Db
::
name
(
'Region'
)
->
where
([
'id'
=>
intval
(
$region_id
)])
->
value
(
'name'
);
}
/**
...
...
@@ -35,7 +37,7 @@ class RegionService
public
static
function
RegionItems
(
$param
=
[])
{
$pid
=
isset
(
$param
[
'pid'
])
?
intval
(
$param
[
'pid'
])
:
0
;
return
db
(
'Region'
)
->
where
([
'pid'
=>
$pid
,
'is_enable'
=>
1
])
->
select
();
return
Db
::
name
(
'Region'
)
->
where
([
'pid'
=>
$pid
,
'is_enable'
=>
1
])
->
select
();
}
/**
...
...
@@ -53,7 +55,7 @@ class RegionService
$where
=
empty
(
$params
[
'where'
])
?
[]
:
$params
[
'where'
];
$where
[
'is_enable'
]
=
1
;
return
db
(
'Region'
)
->
where
(
$where
)
->
field
(
$field
)
->
order
(
'id asc, sort asc'
)
->
select
();
return
Db
::
name
(
'Region'
)
->
where
(
$where
)
->
field
(
$field
)
->
order
(
'id asc, sort asc'
)
->
select
();
}
}
?>
\ No newline at end of file
application/service/ResourcesService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 资源服务层
* @author Devil
...
...
@@ -21,7 +23,7 @@ class ResourcesService
*/
public
static
function
OrderPaymentName
(
$order_id
=
0
)
{
return
empty
(
$order_id
)
?
null
:
db
(
'PayLog'
)
->
where
([
'order_id'
=>
intval
(
$order_id
)])
->
value
(
'payment_name'
);
return
empty
(
$order_id
)
?
null
:
Db
::
name
(
'PayLog'
)
->
where
([
'order_id'
=>
intval
(
$order_id
)])
->
value
(
'payment_name'
);
}
/**
...
...
@@ -45,7 +47,7 @@ class ResourcesService
$where
[
'is_open_user'
]
=
intval
(
$params
[
'is_open_user'
]);
}
$data
=
db
(
'Payment'
)
->
where
(
$where
)
->
field
(
'id,logo,name,sort,payment,config,apply_terminal,apply_terminal,element,is_enable,is_open_user'
)
->
order
(
'sort asc'
)
->
select
();
$data
=
Db
::
name
(
'Payment'
)
->
where
(
$where
)
->
field
(
'id,logo,name,sort,payment,config,apply_terminal,apply_terminal,element,is_enable,is_open_user'
)
->
order
(
'sort asc'
)
->
select
();
if
(
!
empty
(
$data
)
&&
is_array
(
$data
))
{
$images_host
=
config
(
'IMAGE_HOST'
);
...
...
@@ -164,7 +166,7 @@ class ResourcesService
*/
public
static
function
AppHomeNav
(
$params
=
[])
{
$data
=
db
(
'AppHomeNav'
)
->
field
(
'id,name,images_url,event_value,event_type,bg_color'
)
->
where
([
'platform'
=>
APPLICATION_CLIENT_TYPE
,
'is_enable'
=>
1
])
->
order
(
'sort asc'
)
->
select
();
$data
=
Db
::
name
(
'AppHomeNav'
)
->
field
(
'id,name,images_url,event_value,event_type,bg_color'
)
->
where
([
'platform'
=>
APPLICATION_CLIENT_TYPE
,
'is_enable'
=>
1
])
->
order
(
'sort asc'
)
->
select
();
if
(
!
empty
(
$data
))
{
$images_host
=
config
(
'IMAGE_HOST'
);
...
...
application/service/SafetyService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
use
app\service\UserService
;
/**
...
...
@@ -55,7 +56,7 @@ class SafetyService
}
// 获取用户账户信息
$user
=
db
(
'User'
)
->
field
(
'id,pwd,salt'
)
->
find
(
$params
[
'user'
][
'id'
]);
$user
=
Db
::
name
(
'User'
)
->
field
(
'id,pwd,salt'
)
->
find
(
$params
[
'user'
][
'id'
]);
// 原密码校验
if
(
LoginPwdEncryption
(
$params
[
'my_pwd'
],
$user
[
'salt'
])
!=
$user
[
'pwd'
])
...
...
@@ -78,7 +79,7 @@ class SafetyService
];
// 更新数据库
if
(
db
(
'User'
)
->
where
([
'id'
=>
$params
[
'user'
][
'id'
]])
->
update
(
$data
)
!==
false
)
if
(
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$params
[
'user'
][
'id'
]])
->
update
(
$data
)
!==
false
)
{
return
DataReturn
(
'操作成功'
,
0
);
}
...
...
@@ -97,7 +98,7 @@ class SafetyService
private
static
function
IsExistAccounts
(
$accounts
,
$type
)
{
$field
=
(
$type
==
'sms'
)
?
'mobile'
:
'email'
;
$user
=
db
(
'User'
)
->
where
([
$field
=>
$accounts
])
->
value
(
'id'
);
$user
=
Db
::
name
(
'User'
)
->
where
([
$field
=>
$accounts
])
->
value
(
'id'
);
if
(
!
empty
(
$user
))
{
$msg
=
(
$type
==
'sms'
)
?
'手机号码已存在'
:
'电子邮箱已存在'
;
...
...
@@ -379,7 +380,7 @@ class SafetyService
'upd_time'
=>
time
(),
);
// 更新数据库
if
(
db
(
'User'
)
->
where
(
array
(
'id'
=>
$params
[
'user'
][
'id'
]))
->
update
(
$data
)
!==
false
)
if
(
Db
::
name
(
'User'
)
->
where
(
array
(
'id'
=>
$params
[
'user'
][
'id'
]))
->
update
(
$data
)
!==
false
)
{
// 更新用户session数据
UserService
::
UserLoginRecord
(
$params
[
'user'
][
'id'
]);
...
...
application/service/ScreeningPriceService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 筛选价格服务层
...
...
@@ -26,13 +27,13 @@ class ScreeningPriceService
// 获取数据
$field
=
'id,name,sort,is_enable,min_price,max_price'
;
$data
=
db
(
'ScreeningPrice'
)
->
field
(
$field
)
->
where
([
'pid'
=>
$id
])
->
order
(
'sort asc'
)
->
select
();
$data
=
Db
::
name
(
'ScreeningPrice'
)
->
field
(
$field
)
->
where
([
'pid'
=>
$id
])
->
order
(
'sort asc'
)
->
select
();
if
(
!
empty
(
$data
))
{
$image_host
=
config
(
'IMAGE_HOST'
);
foreach
(
$data
as
&
$v
)
{
$v
[
'is_son'
]
=
(
db
(
'ScreeningPrice'
)
->
where
([
'pid'
=>
$v
[
'id'
]])
->
count
()
>
0
)
?
'ok'
:
'no'
;
$v
[
'is_son'
]
=
(
Db
::
name
(
'ScreeningPrice'
)
->
where
([
'pid'
=>
$v
[
'id'
]])
->
count
()
>
0
)
?
'ok'
:
'no'
;
$v
[
'ajax_url'
]
=
url
(
'admin/screeningprice/getnodeson'
,
array
(
'id'
=>
$v
[
'id'
]));
$v
[
'delete_url'
]
=
url
(
'admin/screeningprice/delete'
);
$v
[
'json'
]
=
json_encode
(
$v
);
...
...
@@ -89,14 +90,14 @@ class ScreeningPriceService
if
(
empty
(
$params
[
'id'
]))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'ScreeningPrice'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'ScreeningPrice'
)
->
insertGetId
(
$data
)
>
0
)
{
return
DataReturn
(
'添加成功'
,
0
);
}
return
DataReturn
(
'添加失败'
,
-
100
);
}
else
{
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'ScreeningPrice'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
if
(
Db
::
name
(
'ScreeningPrice'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
{
return
DataReturn
(
'编辑成功'
,
0
);
}
...
...
@@ -134,7 +135,7 @@ class ScreeningPriceService
}
// 开始删除
if
(
db
(
'ScreeningPrice'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
delete
())
if
(
Db
::
name
(
'ScreeningPrice'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
delete
())
{
return
DataReturn
(
'删除成功'
,
0
);
}
...
...
application/service/SearchService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
use
app\service\GoodsService
;
/**
...
...
@@ -39,7 +39,7 @@ class SearchService
public
static
function
ScreeningPriceList
(
$params
=
[])
{
$field
=
empty
(
$params
[
'field'
])
?
'*'
:
$params
[
'field'
];
return
db
(
'ScreeningPrice'
)
->
field
(
$field
)
->
where
([
'is_enable'
=>
1
])
->
order
(
'sort asc'
)
->
select
();
return
Db
::
name
(
'ScreeningPrice'
)
->
field
(
$field
)
->
where
([
'is_enable'
=>
1
])
->
order
(
'sort asc'
)
->
select
();
}
/**
...
...
@@ -86,7 +86,7 @@ class SearchService
// 筛选价格
if
(
!
empty
(
$params
[
'screening_price_id'
]))
{
$price
=
db
(
'ScreeningPrice'
)
->
field
(
'min_price,max_price'
)
->
where
([
'is_enable'
=>
1
,
'id'
=>
intval
(
$params
[
'screening_price_id'
])])
->
find
();
$price
=
Db
::
name
(
'ScreeningPrice'
)
->
field
(
'min_price,max_price'
)
->
where
([
'is_enable'
=>
1
,
'id'
=>
intval
(
$params
[
'screening_price_id'
])])
->
find
();
if
(
!
empty
(
$price
))
{
$params
[
'min_price'
]
=
$price
[
'min_price'
];
...
...
@@ -141,7 +141,7 @@ class SearchService
$screening_price
=
''
;
if
(
!
empty
(
$params
[
'screening_price_id'
]))
{
$price
=
db
(
'ScreeningPrice'
)
->
field
(
'min_price,max_price'
)
->
where
([
'is_enable'
=>
1
,
'id'
=>
intval
(
$params
[
'screening_price_id'
])])
->
find
();
$price
=
Db
::
name
(
'ScreeningPrice'
)
->
field
(
'min_price,max_price'
)
->
where
([
'is_enable'
=>
1
,
'id'
=>
intval
(
$params
[
'screening_price_id'
])])
->
find
();
}
else
{
$price
=
[
'min_price'
=>
!
empty
(
$params
[
'min_price'
])
?
$params
[
'min_price'
]
:
0
,
...
...
@@ -160,7 +160,7 @@ class SearchService
unset
(
$params
[
'screening_price_id'
]);
// 添加日志
db
(
'SearchHistory'
)
->
insert
(
$params
);
Db
::
name
(
'SearchHistory'
)
->
insert
(
$params
);
}
/**
...
...
@@ -173,7 +173,7 @@ class SearchService
*/
public
function
SearchKeywordsList
(
$params
=
[])
{
return
db
(
'SearchHistory'
)
->
where
([
'keywords'
=>
[
'neq'
,
''
]])
->
group
(
'keywords'
)
->
limit
(
10
)
->
column
(
'keywords'
);
return
Db
::
name
(
'SearchHistory'
)
->
where
([
'keywords'
=>
[
'neq'
,
''
]])
->
group
(
'keywords'
)
->
limit
(
10
)
->
column
(
'keywords'
);
}
}
?>
\ No newline at end of file
application/service/SlideService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 轮播图服务层
* @author Devil
...
...
@@ -26,7 +28,7 @@ class SlideService
$m
=
isset
(
$params
[
'm'
])
?
intval
(
$params
[
'm'
])
:
0
;
$n
=
isset
(
$params
[
'n'
])
?
intval
(
$params
[
'n'
])
:
10
;
$data
=
db
(
'Slide'
)
->
field
(
$field
)
->
where
(
$where
)
->
order
(
'sort asc'
)
->
limit
(
$m
,
$n
)
->
select
();
$data
=
Db
::
name
(
'Slide'
)
->
field
(
$field
)
->
where
(
$where
)
->
order
(
'sort asc'
)
->
limit
(
$m
,
$n
)
->
select
();
if
(
!
empty
(
$data
))
{
$common_platform_type
=
lang
(
'common_platform_type'
);
...
...
@@ -87,7 +89,7 @@ class SlideService
*/
public
static
function
SlideTotal
(
$where
=
[])
{
return
(
int
)
db
(
'Slide'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'Slide'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -214,14 +216,14 @@ class SlideService
if
(
empty
(
$params
[
'id'
]))
{
$data
[
'add_time'
]
=
time
();
if
(
db
(
'Slide'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'Slide'
)
->
insertGetId
(
$data
)
>
0
)
{
return
DataReturn
(
'添加成功'
,
0
);
}
return
DataReturn
(
'添加失败'
,
-
100
);
}
else
{
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'Slide'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
if
(
Db
::
name
(
'Slide'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
(
$data
))
{
return
DataReturn
(
'编辑成功'
,
0
);
}
...
...
@@ -255,7 +257,7 @@ class SlideService
}
// 删除操作
if
(
db
(
'Slide'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
if
(
Db
::
name
(
'Slide'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
delete
())
{
return
DataReturn
(
'删除成功'
);
}
...
...
@@ -294,7 +296,7 @@ class SlideService
}
// 数据更新
if
(
db
(
'Slide'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
if
(
Db
::
name
(
'Slide'
)
->
where
([
'id'
=>
intval
(
$params
[
'id'
])])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
])]))
{
return
DataReturn
(
'编辑成功'
);
}
...
...
application/service/ThemeService.php
浏览文件 @
a2157b0c
<?php
namespace
app\service
;
use
think\Db
;
/**
* 主题服务层
* @author Devil
...
...
application/service/UserService.php
浏览文件 @
a2157b0c
...
...
@@ -34,7 +34,7 @@ class UserService
$n
=
isset
(
$params
[
'n'
])
?
intval
(
$params
[
'n'
])
:
10
;
// 获取管理员列表
$data
=
db
(
'User'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
limit
(
$m
,
$n
)
->
select
();
$data
=
Db
::
name
(
'User'
)
->
where
(
$where
)
->
order
(
$order_by
)
->
limit
(
$m
,
$n
)
->
select
();
if
(
!
empty
(
$data
))
{
$common_gender_list
=
lang
(
'common_gender_list'
);
...
...
@@ -115,7 +115,7 @@ class UserService
*/
public
static
function
UserTotal
(
$where
)
{
return
(
int
)
db
(
'User'
)
->
where
(
$where
)
->
count
();
return
(
int
)
Db
::
name
(
'User'
)
->
where
(
$where
)
->
count
();
}
/**
...
...
@@ -214,20 +214,20 @@ class UserService
if
(
!
empty
(
$params
[
'id'
]))
{
// 获取用户信息
$user
=
db
(
'User'
)
->
field
(
'id,integral'
)
->
find
(
$params
[
'id'
]);
$user
=
Db
::
name
(
'User'
)
->
field
(
'id,integral'
)
->
find
(
$params
[
'id'
]);
if
(
empty
(
$user
))
{
return
DataReturn
(
'用户信息不存在'
,
-
10
);
}
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'User'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
update
(
$data
))
if
(
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$params
[
'id'
]])
->
update
(
$data
))
{
$user_id
=
$params
[
'id'
];
}
}
else
{
$data
[
'add_time'
]
=
time
();
$user_id
=
db
(
'User'
)
->
insertGetId
(
$data
);
$user_id
=
Db
::
name
(
'User'
)
->
insertGetId
(
$data
);
}
// 状态
...
...
@@ -274,7 +274,7 @@ class UserService
}
// 删除操作
if
(
db
(
'User'
)
->
delete
(
intval
(
$params
[
'id'
])))
if
(
Db
::
name
(
'User'
)
->
delete
(
intval
(
$params
[
'id'
])))
{
return
DataReturn
(
'删除成功'
);
}
...
...
@@ -312,7 +312,7 @@ class UserService
// 获取用户地址
$field
=
'id,alias,name,tel,province,city,county,address,lng,lat,is_default'
;
$data
=
db
(
'UserAddress'
)
->
where
(
$where
)
->
field
(
$field
)
->
order
(
'id desc'
)
->
select
();
$data
=
Db
::
name
(
'UserAddress'
)
->
where
(
$where
)
->
field
(
$field
)
->
order
(
'id desc'
)
->
select
();
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
&
$v
)
...
...
@@ -458,7 +458,7 @@ class UserService
if
(
!
empty
(
$params
[
'id'
]))
{
$where
=
[
'user_id'
=>
$params
[
'user'
][
'id'
],
'id'
=>
$params
[
'id'
]];
$temp
=
db
(
'UserAddress'
)
->
where
(
$where
)
->
find
();
$temp
=
Db
::
name
(
'UserAddress'
)
->
where
(
$where
)
->
find
();
}
// 操作数据
...
...
@@ -481,7 +481,7 @@ class UserService
// 默认地址处理
if
(
$is_default
==
1
)
{
db
(
'UserAddress'
)
->
where
([
'user_id'
=>
$params
[
'user'
][
'id'
],
'is_default'
=>
1
])
->
update
([
'is_default'
=>
0
]);
Db
::
name
(
'UserAddress'
)
->
where
([
'user_id'
=>
$params
[
'user'
][
'id'
],
'is_default'
=>
1
])
->
update
([
'is_default'
=>
0
]);
}
// 添加/更新数据
...
...
@@ -489,7 +489,7 @@ class UserService
{
$data
[
'user_id'
]
=
$params
[
'user'
][
'id'
];
$data
[
'add_time'
]
=
time
();
if
(
db
(
'UserAddress'
)
->
insertGetId
(
$data
)
>
0
)
if
(
Db
::
name
(
'UserAddress'
)
->
insertGetId
(
$data
)
>
0
)
{
Db
::
commit
();
return
DataReturn
(
'新增成功'
,
0
);
...
...
@@ -499,7 +499,7 @@ class UserService
}
}
else
{
$data
[
'upd_time'
]
=
time
();
if
(
db
(
'UserAddress'
)
->
where
(
$where
)
->
update
(
$data
))
if
(
Db
::
name
(
'UserAddress'
)
->
where
(
$where
)
->
update
(
$data
))
{
Db
::
commit
();
return
DataReturn
(
'更新成功'
,
0
);
...
...
@@ -542,7 +542,7 @@ class UserService
// 软删除数据
$where
=
[
'user_id'
=>
$params
[
'user'
][
'id'
],
'id'
=>
$params
[
'id'
]];
$data
=
[
'is_delete_time'
=>
time
()];
if
(
db
(
'UserAddress'
)
->
where
(
$where
)
->
update
(
$data
))
if
(
Db
::
name
(
'UserAddress'
)
->
where
(
$where
)
->
update
(
$data
))
{
return
DataReturn
(
'删除成功'
,
0
);
}
else
{
...
...
@@ -584,8 +584,8 @@ class UserService
Db
::
startTrans
();
// 先全部设置为0 再将当前设置为1
$all_status
=
db
(
'UserAddress'
)
->
where
([
'user_id'
=>
$params
[
'user'
][
'id'
]])
->
update
([
'is_default'
=>
0
]);
$my_status
=
db
(
'UserAddress'
)
->
where
([
'user_id'
=>
$params
[
'user'
][
'id'
],
'id'
=>
$params
[
'id'
]])
->
update
([
'is_default'
=>
1
]);
$all_status
=
Db
::
name
(
'UserAddress'
)
->
where
([
'user_id'
=>
$params
[
'user'
][
'id'
]])
->
update
([
'is_default'
=>
0
]);
$my_status
=
Db
::
name
(
'UserAddress'
)
->
where
([
'user_id'
=>
$params
[
'user'
][
'id'
],
'id'
=>
$params
[
'id'
]])
->
update
([
'is_default'
=>
1
]);
if
(
$all_status
!==
false
&&
$my_status
)
{
// 提交事务
...
...
@@ -611,7 +611,7 @@ class UserService
{
if
(
!
empty
(
$user_id
))
{
$user
=
db
(
'User'
)
->
field
(
'*'
)
->
find
(
$user_id
);
$user
=
Db
::
name
(
'User'
)
->
field
(
'*'
)
->
find
(
$user_id
);
if
(
!
empty
(
$user
))
{
// 基础数据处理
...
...
@@ -738,7 +738,7 @@ class UserService
'avatar'
=>
DS
.
$img_path
.
'compr'
.
$date
.
$compr
,
'upd_time'
=>
time
(),
];
if
(
db
(
'User'
)
->
where
([
'id'
=>
$params
[
'user'
][
'id'
]])
->
update
(
$data
))
if
(
Db
::
name
(
'User'
)
->
where
([
'id'
=>
$params
[
'user'
][
'id'
]])
->
update
(
$data
))
{
self
::
UserLoginRecord
(
$params
[
'user'
][
'id'
]);
return
DataReturn
(
'上传成功'
,
0
);
...
...
@@ -778,7 +778,7 @@ class UserService
// 获取用户账户信息
$where
=
array
(
'mobile|email'
=>
$params
[
'accounts'
],
'is_delete_time'
=>
0
);
$user
=
db
(
'User'
)
->
field
(
array
(
'id'
,
'pwd'
,
'salt'
,
'status'
))
->
where
(
$where
)
->
find
();
$user
=
Db
::
name
(
'User'
)
->
field
(
array
(
'id'
,
'pwd'
,
'salt'
,
'status'
))
->
where
(
$where
)
->
find
();
if
(
empty
(
$user
))
{
return
DataReturn
(
'帐号不存在'
,
-
3
);
...
...
@@ -802,7 +802,7 @@ class UserService
'salt'
=>
$salt
,
'upd_time'
=>
time
(),
);
if
(
db
(
'User'
)
->
where
(
array
(
'id'
=>
$user
[
'id'
]))
->
update
(
$data
)
!==
false
)
if
(
Db
::
name
(
'User'
)
->
where
(
array
(
'id'
=>
$user
[
'id'
]))
->
update
(
$data
)
!==
false
)
{
// 登录记录
if
(
self
::
UserLoginRecord
(
$user
[
'id'
]))
...
...
@@ -903,7 +903,7 @@ class UserService
}
// 数据添加
$user_id
=
db
(
'User'
)
->
insertGetId
(
$data
);
$user_id
=
Db
::
name
(
'User'
)
->
insertGetId
(
$data
);
if
(
$user_id
>
0
)
{
// 清除验证码
...
...
@@ -980,7 +980,7 @@ class UserService
*/
private
static
function
IsExistAccounts
(
$accounts
,
$field
=
'mobile'
)
{
$id
=
db
(
'User'
)
->
where
(
array
(
$field
=>
$accounts
))
->
value
(
'id'
);
$id
=
Db
::
name
(
'User'
)
->
where
(
array
(
$field
=>
$accounts
))
->
value
(
'id'
);
return
!
empty
(
$id
);
}
...
...
@@ -1281,7 +1281,7 @@ class UserService
'salt'
=>
$salt
,
'upd_time'
=>
time
(),
);
if
(
db
(
'User'
)
->
where
(
array
(
$ret
[
'data'
]
=>
$params
[
'accounts'
]))
->
update
(
$data
)
!==
false
)
if
(
Db
::
name
(
'User'
)
->
where
(
array
(
$ret
[
'data'
]
=>
$params
[
'accounts'
]))
->
update
(
$data
)
!==
false
)
{
return
DataReturn
(
'操作成功'
);
}
...
...
@@ -1336,7 +1336,7 @@ class UserService
'gender'
=>
intval
(
$params
[
'gender'
]),
'upd_time'
=>
time
(),
];
if
(
db
(
'User'
)
->
where
(
array
(
'id'
=>
$params
[
'user'
][
'id'
]))
->
update
(
$data
))
if
(
Db
::
name
(
'User'
)
->
where
(
array
(
'id'
=>
$params
[
'user'
][
'id'
]))
->
update
(
$data
))
{
// 更新用户session数据
self
::
UserLoginRecord
(
$params
[
'user'
][
'id'
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录