Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
73677bf6
authored
Nov 22, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev/ver/1.0.0' of
http://git.ichunt.net/semour/semour_web
into dev/ver/1.0.0
parents
430e09f8
e270b244
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
app/Http/Controllers/Api/CartApiController.php
app/Http/Services/CartService.php
app/Http/Services/OrderService.php
app/Http/Controllers/Api/CartApiController.php
View file @
73677bf6
...
...
@@ -60,7 +60,7 @@ class CartApiController extends Controller
//购物车列表
public
function
cartLists
(
Request
$request
){
$result
=
CartService
::
cartLists
(
$request
->
user
->
id
,
$request
->
user
->
gid
);
$result
=
CartService
::
cartLists
(
$request
->
user
->
id
,
$request
->
user
->
gid
,
$request
->
input
(
"cart_ids"
,
0
)
);
return
$this
->
setSuccessData
(
$result
);
}
...
...
app/Http/Services/CartService.php
View file @
73677bf6
...
...
@@ -62,17 +62,21 @@ class CartService
$temp
[
"buy_price"
]
=
$buy_price
;
$checkHas
=
CartModel
::
where
([
"user_id"
=>
$user_id
,
"goods_id"
=>
$goods_id
,
"status"
=>
1
])
->
first
();
$temp
[
"buy_number"
]
=
$skuInfo
[
"stock"
]
>
$buy_number
?
$buy_number
:
$skuInfo
[
"stock"
];
if
(
$checkHas
){
$buy_number
=
$buy_number
+
$checkHas
[
"buy_number"
];
$cart_id
=
$checkHas
[
"cart_id"
];
$temp
[
"update_time"
]
=
time
();
$temp
[
"status"
]
=
$buy_number
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$temp
[
"buy_number"
]
=
$skuInfo
[
"stock"
]
>
$buy_number
?
$buy_number
:
$skuInfo
[
"stock"
];
$flag
=
CartModel
::
where
([
"cart_id"
=>
$checkHas
[
"cart_id"
]])
->
update
(
$temp
);
if
(
!
$flag
){
return
false
;
}
}
else
{
//不存在插入购物车
$temp
[
"buy_number"
]
=
$skuInfo
[
"stock"
]
>
$buy_number
?
$buy_number
:
$skuInfo
[
"stock"
];
$temp
[
"status"
]
=
$buy_number
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$temp
[
"create_time"
]
=
time
();
$temp
[
"update_time"
]
=
time
();
...
...
@@ -187,8 +191,7 @@ class CartService
/*
* 刷新购物车并且返回列表
*/
public
static
function
cartLists
(
$user_id
,
$gid
=
""
,
$page_size
=
400
,
$page
=
1
){
public
static
function
cartLists
(
$user_id
,
$gid
=
""
,
$cart_ids
=
0
,
$page_size
=
400
,
$page
=
1
){
//当前用户所有可用的购物车数据
if
(
!
$user_id
&&
!
$gid
){
return
[];
...
...
@@ -201,6 +204,9 @@ class CartService
}
$query
=
CartModel
::
where
(
$where
)
->
wherein
(
"status"
,[
CartModel
::
status_no
,
CartModel
::
status_yes
])
->
orderBy
(
'status'
,
'desc'
);
if
(
$cart_ids
){
$query
=
$query
->
wherein
(
"cart_id"
,
explode
(
","
,
$cart_ids
));
}
$res
=
$query
->
paginate
(
$page_size
,
[
'*'
],
'page'
,
$page
)
->
toArray
();
$result
=
$res
[
"data"
];
...
...
app/Http/Services/OrderService.php
View file @
73677bf6
...
...
@@ -44,6 +44,7 @@ class OrderService
$billing_address_id
=
$data
[
"billing_address_id"
];
//账单地址
$items
=
json_decode
(
\Arr
::
get
(
$data
,
'items'
,
[]),
true
);
//查询用户详情
$userInfo
=
UserModel
::
getUserInfo
(
$user_id
);
$order_sn
=
self
::
createOrderSn
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment