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;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Redis
;
use
App\Models\CartModel
;
use
Mockery\Exception
;
//购物车服务器层
class
CartService
...
...
@@ -48,7 +49,6 @@ class CartService
$temp
[
"raw_brand_name"
]
=
$digikeyArr
[
"raw_brand_name"
];
}
//购买时价格
$buy_price
=
0
;
$ladder_price
=
data_get
(
$skuInfo
,
"ladder_price"
);
...
...
@@ -65,7 +65,7 @@ class CartService
$temp
[
"buy_price"
]
=
$buy_price
;
if
(
$buy_number
<
\Arr
::
get
(
$skuInfo
,
"moq"
)
||
$buy_number
>
$skuInfo
[
"stock"
]
){
return
false
;
throw
new
Exception
(
"error moq"
,
1001
)
;
}
$temp
[
"buy_number"
]
=
$buy_number
;
...
...
@@ -77,18 +77,18 @@ class CartService
$flag
=
CartModel
::
where
([
"cart_id"
=>
$checkHas
[
"cart_id"
]])
->
update
(
$temp
);
if
(
!
$flag
){
return
false
;
throw
new
Exception
(
"error update"
,
1002
)
;
}
}
else
{
//不存在插入购物车
$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
[
"create_time"
]
=
time
();
$temp
[
"update_time"
]
=
time
();
$cart_id
=
CartModel
::
insertGetId
(
$temp
);
if
(
!
$cart_id
){
return
false
;
throw
new
Exception
(
"error add"
,
1003
)
;
}
}
...
...
@@ -112,7 +112,8 @@ class CartService
return
$te
;
}
catch
(
\Exception
$e
){
$con
->
rollback
();
throw
new
InvalidRequestException
(
$e
->
getMessage
()
.
$e
->
getLine
());
# throw new InvalidRequestException($e->getMessage().$e->getLine());
return
false
;
}
}
...
...
@@ -174,7 +175,7 @@ class CartService
$temp
[
"status"
]
=
$v
[
"buy_number"
]
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$flag
=
CartModel
::
where
([
"cart_id"
=>
$checkHas
[
"cart_id"
]])
->
update
(
$temp
);
if
(
!
$flag
){
return
false
;
throw
new
Exception
(
"error update"
,
1003
)
;
}
}
else
{
//不存在插入购物车
$temp
[
"buy_number"
]
=
$skuInfo
[
"stock"
]
>
$v
[
'buy_number'
]
?
$v
[
'buy_number'
]
:
$skuInfo
[
"stock"
];
...
...
@@ -184,7 +185,7 @@ class CartService
$flag
=
CartModel
::
insertGetId
(
$temp
);
if
(
!
$flag
){
return
false
;
throw
new
Exception
(
"error add"
,
1003
)
;
}
}
}
...
...
@@ -194,7 +195,8 @@ class CartService
return
true
;
}
catch
(
\Exception
$e
){
$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
$where
[
"order_id"
]
=
$order_id
;
if
(
$user_id
>
0
){
$where
[
"user_id"
]
=
$user_id
;
//
$where["user_id"] = $user_id;
}
$orderInfo
=
OrderModel
::
getOrderInfo
(
$where
);
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