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
dc2d4310
authored
Nov 15, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
订单添加
parent
faa0009b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
4 deletions
app/Http/Controllers/Api/OrderApiController.php
app/Http/Services/OrderService.php
routes/api.php
app/Http/Controllers/Api/OrderApiController.php
View file @
dc2d4310
...
...
@@ -55,5 +55,11 @@ class OrderApiController extends Controller
return
$result
[
0
]
>
0
?
$this
->
setError
(
$result
[
1
],
$result
[
0
])
:
$this
->
setSuccessData
(
$result
[
1
]);
}
//订单详情
public
function
orderDetail
(
Request
$request
){
$result
=
OrderService
::
orderDetail
(
$request
->
user
->
id
,
$request
->
input
(
"order_id"
));
return
$this
->
setSuccessData
(
$result
);
}
}
app/Http/Services/OrderService.php
View file @
dc2d4310
...
...
@@ -187,8 +187,7 @@ class OrderService
}
/*
* 个人订单列表
*
* 个人所有订单列表
*/
public
static
function
orderLists
(
$user_id
,
$param
){
...
...
@@ -230,7 +229,7 @@ class OrderService
}
$result
=
$res
[
"data"
];
$orderAddressArr
=
OrderAddressModel
::
whereIn
(
"order_id"
,
array_column
(
$result
,
"order_id"
))
->
get
()
->
keyBy
(
"order_id"
)
->
toArray
();
//
发票
信息
$orderAddressArr
=
OrderAddressModel
::
whereIn
(
"order_id"
,
array_column
(
$result
,
"order_id"
))
->
get
()
->
keyBy
(
"order_id"
)
->
toArray
();
//
地址
信息
$temp
=
[];
foreach
(
$result
as
$k
=>
$v
){
$order_id
=
$v
[
"order_id"
];
...
...
@@ -260,7 +259,7 @@ class OrderService
}
/*
*
更新订单状态
*
取消订单
*/
public
static
function
cancelOrder
(
$user_id
,
$order_id
){
if
(
!
$order_id
){
...
...
@@ -278,6 +277,71 @@ class OrderService
return
$flag
?
[
0
,
"cancel order success"
]
:
[
1002
,
"error: cancel order"
];
}
/*
* 订单详情
*/
public
static
function
orderDetail
(
$user_id
,
$order_id
){
$where
[
"order_id"
]
=
$order_id
;
if
(
$user_id
>
0
){
$where
[
"user_id"
]
=
$user_id
;
}
$orderInfo
=
OrderModel
::
getOrderInfo
(
$where
);
if
(
!
$orderInfo
){
return
false
;
}
$items
=
OrderItemsModel
::
where
(
"order_id"
,
$order_id
)
->
get
()
->
toArray
();
//商品详情
$orderAddressArr
=
OrderAddressModel
::
selectRaw
(
"consignee,company_name,email,phone,detail_address,shipping_sn,shipping_name,order_address_type"
)
->
where
(
"order_id"
,
$order_id
)
->
get
()
->
keyBy
(
"order_address_type"
)
->
toArray
();
//地址信息,1收货信息 2账单邮寄信息
$goodsInfoArr
=
ThirdService
::
getGoodsInfo
(
array_column
(
$items
,
"goods_id"
));
//商品详情
$itemsTemp
=
[];
$merchandise_total
=
0
;
//商品总额
foreach
(
$items
as
$k
=>
$v
){
$goods_id
=
$v
[
"goods_id"
];
$oneInfo
=
\Arr
::
get
(
$goodsInfoArr
,
$goods_id
,[]);
$ext_price
=
round
(
$v
[
"goods_number"
]
*
$v
[
"goods_price"
],
2
);
$itemsTemp
=
[
"id"
=>
$k
+
1
,
"goods_id"
=>
$v
[
"goods_id"
],
"goods_name"
=>
$v
[
"goods_name"
],
"brand_name"
=>
$v
[
"brand_name"
],
"delivery_time"
=>
$v
[
"delivery_time"
],
"pdf"
=>
\Arr
::
get
(
$oneInfo
,
"pdf"
),
"goods_number"
=>
$v
[
"goods_number"
],
"goods_price"
=>
$v
[
"goods_price"
],
"ext_price"
=>
$ext_price
,
"remarks"
=>
$v
[
"remarks"
],
];
$merchandise_total
+=
$ext_price
;
}
$priceInfo
=
OrderPriceModel
::
selectRaw
(
"price_type,price"
)
->
where
(
"order_id"
,
$order_id
)
->
get
()
->
toArray
();
//金额类型(正数ID大于0,负数ID小于0)-8活动优惠 -7支付优惠 -6运费优惠 -5尾款减款 -4优惠券优惠金额 -3尾款 -2预付款 -1付款,1货款 2附加费 3运费 4退款 5支付手续费
$priceArr
=
array_column
(
$priceInfo
,
"price"
,
"price_type"
);
$temp
=
[
"order_id"
=>
$order_id
,
"order_sn"
=>
$orderInfo
[
"order_sn"
],
"order_amount"
=>
$orderInfo
[
"order_amount"
],
"sub_total "
=>
$orderInfo
[
"order_amount"
],
//小计
"shipping"
=>
\Arr
::
get
(
$priceArr
,
3
,
0
),
//运费
"payment_surcharge"
=>
\Arr
::
get
(
$priceArr
,
5
,
0
),
//支付手续费
"merchandise_total"
=>
$merchandise_total
,
//商品总额
"status"
=>
$v
[
"status"
],
"status_en"
=>
\Arr
::
get
(
OrderModel
::
$status
,
$v
[
"status"
],
""
),
"shipping_address"
=>
\Arr
::
get
(
$orderAddressArr
,
1
,[]),
"billing_address"
=>
\Arr
::
get
(
$orderAddressArr
,
2
,[]),
"items"
=>
$itemsTemp
,
];
return
$temp
;
}
}
routes/api.php
View file @
dc2d4310
...
...
@@ -53,6 +53,7 @@ Route::middleware(['api', 'api.check'])->namespace('Api')->group(function () {
Route
::
POST
(
'order/orderLists'
,
'OrderApiController@orderLists'
);
//订单列表
Route
::
POST
(
'order/updateOrder'
,
'OrderApiController@updateOrder'
);
//更新订单状态
Route
::
POST
(
'order/cancelOrder'
,
'OrderApiController@cancelOrder'
);
//取消订单
Route
::
POST
(
'order/orderDetail'
,
'OrderApiController@orderDetail'
);
//订单详情
});
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