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
2b37a451
authored
Nov 30, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
深茂订单详情
parent
415d30a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
app/Http/Controllers/Api/OrderApiController.php
app/Http/Services/OrderService.php
app/Http/Controllers/Api/OrderApiController.php
View file @
2b37a451
...
...
@@ -2,6 +2,7 @@
namespace
App\Http\Controllers\Api
;
use
App\Http\ApiHelper\ApiCode
;
use
App\Http\Requests\UserRegister
;
use
App\Http\Services\CartService
;
use
App\Http\Services\InquiryService
;
...
...
@@ -41,8 +42,8 @@ class OrderApiController extends Controller
'shipping_address_id'
,
]);
$
result
=
OrderService
::
addOrder
(
$data
,
$request
->
user
->
id
);
return
!
$
result
?
$this
->
setError
(
'Add order failed , please contact administrator'
)
:
$this
->
setSuccess
(
'Add order success'
);
$
order_id
=
OrderService
::
addOrder
(
$data
,
$request
->
user
->
id
);
return
!
$
order_id
?
$this
->
setError
(
'Add order failed , please contact administrator'
)
:
$this
->
setSuccessData
(
$order_id
,
0
,
ApiCode
::
API_CODE_SUCCESS
,
'Add order success'
);
}
//订单列表
...
...
app/Http/Services/OrderService.php
View file @
2b37a451
...
...
@@ -127,6 +127,7 @@ class OrderService
$goods_id
=
$v
[
'goods_id'
];
$skuInfo
=
$goodsInfoArr
[
$goods_id
];
//sku详情
$cartInfo
=
CartModel
::
where
([
"user_id"
=>
$user_id
,
"goods_id"
=>
(
string
)
$goods_id
,
"status"
=>
1
])
->
first
();
$buy_number
=
$v
[
"buy_number"
];
$buy_price
=
$v
[
"buy_price"
];
$orderAmount
+=
round
(
$buy_number
*
$buy_price
,
2
);
...
...
@@ -166,14 +167,15 @@ class OrderService
"remarks"
=>
$v
[
"remark"
],
//客户备注
];
#扣减购物车库存
$temp
[
"status"
]
=
$v
[
"buy_number"
]
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$temp
[
"create_time"
]
=
time
();
$temp
[
"update_time"
]
=
time
();
$cartUpdate
=
CartModel
::
where
(
"cart_id"
,
$cartInfo
[
"cart_id"
])
->
update
(
$temp
);
if
(
!
$cartUpdate
){
throw
new
InvalidRequestException
(
"error:update cart"
);
if
(
$cartInfo
){
#扣减购物车库存
$temp
[
"status"
]
=
$v
[
"buy_number"
]
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$temp
[
"create_time"
]
=
time
();
$temp
[
"update_time"
]
=
time
();
$cartUpdate
=
CartModel
::
where
(
"cart_id"
,
$cartInfo
[
"cart_id"
])
->
update
(
$temp
);
if
(
!
$cartUpdate
){
throw
new
InvalidRequestException
(
"error:update cart"
);
}
}
}
...
...
@@ -203,7 +205,7 @@ class OrderService
$con
->
commit
();
return
true
;
return
$order_id
;
}
catch
(
\Exception
$e
){
$con
->
rollback
();
throw
new
InvalidRequestException
(
$e
->
getMessage
()
.
$e
->
getFile
()
.
$e
->
getLine
());
...
...
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