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
1de6de3f
authored
Nov 29, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新购物车
parent
3a60cc79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
app/Http/Services/CartService.php
app/Http/Services/OrderService.php
app/Http/Services/CartService.php
View file @
1de6de3f
...
@@ -10,6 +10,7 @@ use App\Models\InquiryModel;
...
@@ -10,6 +10,7 @@ use App\Models\InquiryModel;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Redis
;
use
Illuminate\Support\Facades\Redis
;
use
App\Models\CartModel
;
use
App\Models\CartModel
;
use
Mockery\Exception
;
//购物车服务器层
//购物车服务器层
class
CartService
class
CartService
...
@@ -48,7 +49,6 @@ class CartService
...
@@ -48,7 +49,6 @@ class CartService
$temp
[
"raw_brand_name"
]
=
$digikeyArr
[
"raw_brand_name"
];
$temp
[
"raw_brand_name"
]
=
$digikeyArr
[
"raw_brand_name"
];
}
}
//购买时价格
//购买时价格
$buy_price
=
0
;
$buy_price
=
0
;
$ladder_price
=
data_get
(
$skuInfo
,
"ladder_price"
);
$ladder_price
=
data_get
(
$skuInfo
,
"ladder_price"
);
...
@@ -65,7 +65,7 @@ class CartService
...
@@ -65,7 +65,7 @@ class CartService
$temp
[
"buy_price"
]
=
$buy_price
;
$temp
[
"buy_price"
]
=
$buy_price
;
if
(
$buy_number
<
\Arr
::
get
(
$skuInfo
,
"moq"
)
||
$buy_number
>
$skuInfo
[
"stock"
]
){
if
(
$buy_number
<
\Arr
::
get
(
$skuInfo
,
"moq"
)
||
$buy_number
>
$skuInfo
[
"stock"
]
){
return
false
;
throw
new
Exception
(
"error moq"
,
1001
)
;
}
}
$temp
[
"buy_number"
]
=
$buy_number
;
$temp
[
"buy_number"
]
=
$buy_number
;
...
@@ -77,18 +77,18 @@ class CartService
...
@@ -77,18 +77,18 @@ class CartService
$flag
=
CartModel
::
where
([
"cart_id"
=>
$checkHas
[
"cart_id"
]])
->
update
(
$temp
);
$flag
=
CartModel
::
where
([
"cart_id"
=>
$checkHas
[
"cart_id"
]])
->
update
(
$temp
);
if
(
!
$flag
){
if
(
!
$flag
){
return
false
;
throw
new
Exception
(
"error update"
,
1002
)
;
}
}
}
else
{
//不存在插入购物车
}
else
{
//不存在插入购物车
$temp
[
"user_id"
]
=
$user_id
;
$temp
[
"user_id"
]
=
$user_id
;
$temp
[
"gid"
]
=
$gid
;
$temp
[
"gid"
]
=
$
user_id
>
0
?
""
:
$
gid
;
$temp
[
"status"
]
=
$buy_number
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$temp
[
"status"
]
=
$buy_number
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$temp
[
"create_time"
]
=
time
();
$temp
[
"create_time"
]
=
time
();
$temp
[
"update_time"
]
=
time
();
$temp
[
"update_time"
]
=
time
();
$cart_id
=
CartModel
::
insertGetId
(
$temp
);
$cart_id
=
CartModel
::
insertGetId
(
$temp
);
if
(
!
$cart_id
){
if
(
!
$cart_id
){
return
false
;
throw
new
Exception
(
"error add"
,
1003
)
;
}
}
}
}
...
@@ -112,7 +112,8 @@ class CartService
...
@@ -112,7 +112,8 @@ class CartService
return
$te
;
return
$te
;
}
catch
(
\Exception
$e
){
}
catch
(
\Exception
$e
){
$con
->
rollback
();
$con
->
rollback
();
throw
new
InvalidRequestException
(
$e
->
getMessage
()
.
$e
->
getLine
());
# throw new InvalidRequestException($e->getMessage().$e->getLine());
return
false
;
}
}
}
}
...
@@ -174,7 +175,7 @@ class CartService
...
@@ -174,7 +175,7 @@ class CartService
$temp
[
"status"
]
=
$v
[
"buy_number"
]
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$temp
[
"status"
]
=
$v
[
"buy_number"
]
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$flag
=
CartModel
::
where
([
"cart_id"
=>
$checkHas
[
"cart_id"
]])
->
update
(
$temp
);
$flag
=
CartModel
::
where
([
"cart_id"
=>
$checkHas
[
"cart_id"
]])
->
update
(
$temp
);
if
(
!
$flag
){
if
(
!
$flag
){
return
false
;
throw
new
Exception
(
"error update"
,
1003
)
;
}
}
}
else
{
//不存在插入购物车
}
else
{
//不存在插入购物车
$temp
[
"buy_number"
]
=
$skuInfo
[
"stock"
]
>
$v
[
'buy_number'
]
?
$v
[
'buy_number'
]
:
$skuInfo
[
"stock"
];
$temp
[
"buy_number"
]
=
$skuInfo
[
"stock"
]
>
$v
[
'buy_number'
]
?
$v
[
'buy_number'
]
:
$skuInfo
[
"stock"
];
...
@@ -184,7 +185,7 @@ class CartService
...
@@ -184,7 +185,7 @@ class CartService
$flag
=
CartModel
::
insertGetId
(
$temp
);
$flag
=
CartModel
::
insertGetId
(
$temp
);
if
(
!
$flag
){
if
(
!
$flag
){
return
false
;
throw
new
Exception
(
"error add"
,
1003
)
;
}
}
}
}
}
}
...
@@ -194,7 +195,8 @@ class CartService
...
@@ -194,7 +195,8 @@ class CartService
return
true
;
return
true
;
}
catch
(
\Exception
$e
){
}
catch
(
\Exception
$e
){
$con
->
rollback
();
$con
->
rollback
();
throw
new
InvalidRequestException
(
$e
->
getMessage
()
.
$e
->
getLine
());
#throw new InvalidRequestException($e->getMessage().$e->getLine());
return
false
;
}
}
}
}
...
...
app/Http/Services/OrderService.php
View file @
1de6de3f
...
@@ -354,7 +354,7 @@ class OrderService
...
@@ -354,7 +354,7 @@ class OrderService
$where
[
"order_id"
]
=
$order_id
;
$where
[
"order_id"
]
=
$order_id
;
if
(
$user_id
>
0
){
if
(
$user_id
>
0
){
$where
[
"user_id"
]
=
$user_id
;
//
$where["user_id"] = $user_id;
}
}
$orderInfo
=
OrderModel
::
getOrderInfo
(
$where
);
$orderInfo
=
OrderModel
::
getOrderInfo
(
$where
);
if
(
!
$orderInfo
){
if
(
!
$orderInfo
){
...
...
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