Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_admin
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
fc74d7d6
authored
Nov 18, 2022
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
订单用户统计 更改订单跟进人
parent
3f7169f3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
6 deletions
app/Admin/Controllers/Api/OrderApiController.php
app/Admin/Service/OrderService.php
app/Admin/routes.php
app/Models/Order.php
app/Models/OrderItem.php
app/Models/OrderReturnItems.php
app/Admin/Controllers/Api/OrderApiController.php
View file @
fc74d7d6
...
@@ -82,12 +82,13 @@ class OrderApiController extends BaseController
...
@@ -82,12 +82,13 @@ class OrderApiController extends BaseController
$orderInfo
[
"orderItemList"
][
$k
][
"type_cn"
]
=
Arr
::
get
(
OrderReturnItems
::
$TYPE
,
$returnItems
[
"type"
]
??
0
,
""
);
$orderInfo
[
"orderItemList"
][
$k
][
"type_cn"
]
=
Arr
::
get
(
OrderReturnItems
::
$TYPE
,
$returnItems
[
"type"
]
??
0
,
""
);
}
}
$returnAmount
=
OrderService
::
getOrderReturnAmount
(
$order_id
);
return
response
()
->
json
([
"code"
=>
0
,
"msg"
=>
"ok"
,
"data"
=>
[
return
response
()
->
json
([
"code"
=>
0
,
"msg"
=>
"ok"
,
"data"
=>
[
"list"
=>
$orderInfo
[
"orderItemList"
],
"list"
=>
$orderInfo
[
"orderItemList"
],
"order_amount"
=>
decimal_number_format_usd
(
$orderInfo
[
"order_amount"
]),
"order_amount"
=>
decimal_number_format_usd
(
$orderInfo
[
"order_amount"
]),
"return_order_amount"
=>
decimal_number_format_usd
(
$orderInfo
[
"order_amount"
]),
"return_order_amount"
=>
$returnAmount
,
"return_order_amount_format"
=>
decimal_number_format_usd
(
$returnAmount
),
],
"count"
=>
count
(
$orderInfo
[
"orderItemList"
]
)]);
],
"count"
=>
count
(
$orderInfo
[
"orderItemList"
]
)]);
}
}
...
@@ -186,8 +187,22 @@ class OrderApiController extends BaseController
...
@@ -186,8 +187,22 @@ class OrderApiController extends BaseController
return
$this
->
setSuccess
();
return
$this
->
setSuccess
();
}
}
//修改订单结算信息
public
function
editOrderSettlement
(
Request
$request
){
public
function
editOrderSettlement
(
Request
$request
){
$reqParams
=
$request
->
all
();
$validator
=
Validator
::
make
(
$reqParams
,
[
'order_id'
=>
'required'
,
'order_address_type'
=>
'required'
,
],
[
'order_id.required'
=>
admin_trans
(
"order.validator.order_id_required"
),
'order_address_type.required'
=>
admin_trans
(
"order.validator.order_address.required"
),
],
[]);
if
(
$validator
->
fails
())
{
$errors
=
$validator
->
errors
()
->
toArray
();
$err_msg
=
ValidatorMsg
::
getMsg
(
$errors
);
throw
new
InvalidRequestException
(
$err_msg
);
}
}
}
}
}
app/Admin/Service/OrderService.php
View file @
fc74d7d6
...
@@ -199,14 +199,52 @@ class OrderService extends BaseService
...
@@ -199,14 +199,52 @@ class OrderService extends BaseService
]);
]);
}
}
public
static
function
changeOrderSales
(
$userids
,
$sale_id
){
//更新订单的业务员
public
static
function
changeOrderSales
(
$userids
,
$sale_id
,
$sale_name
){
return
Order
::
updateOrderSale
(
$userids
,
$sale_id
,
$sale_name
);
}
//返回用户的下单数
public
static
function
getUserOrderStatistical
(
$userIds
=
[])
{
$ongoingOrders
=
Order
::
getUserOrderStatistical
(
$userIds
,
1
);
$finishedOrders
=
Order
::
getUserOrderStatistical
(
$userIds
,
2
);
$arr
=
[];
foreach
(
$userIds
as
$user_id
){
$arr
[
$user_id
][
"pending"
]
=
0
;
$arr
[
$user_id
][
"all"
]
=
0
;
foreach
(
$ongoingOrders
as
$ongoingOrder
){
if
(
$ongoingOrder
[
"user_id"
]
==
$user_id
){
$arr
[
$user_id
][
"pending"
]
=
$ongoingOrder
[
"nums"
];
break
;
}
}
}
foreach
(
$finishedOrders
as
$finishedOrder
){
if
(
$finishedOrder
[
"user_id"
]
==
$user_id
){
$arr
[
$user_id
][
"all"
]
=
$finishedOrder
[
"nums"
];
break
;
}
}
}
return
$arr
;
}
//获取订单退款总金额
//获取订单退款总金额
public
static
function
getOrderReturnAmount
(
$order_id
=
0
)
public
static
function
getOrderReturnAmount
(
$order_id
=
0
)
{
{
$orderItemIds
=
OrderItem
::
getOrderItemids
(
$order_id
);
$returnAmount
=
0
;
foreach
(
$orderItemIds
as
$orderItemId
){
$returnInfo
=
OrderReturnItems
::
getOrderReturnItem
(
$orderItemId
);
if
(
!
empty
(
$returnInfo
)){
$returnAmount
+=
$returnInfo
[
"return_amount"
];
}
}
return
decimal_number_format
(
$returnAmount
);
}
}
}
}
app/Admin/routes.php
View file @
fc74d7d6
...
@@ -24,6 +24,7 @@ Route::group([
...
@@ -24,6 +24,7 @@ Route::group([
$router
->
resource
(
'country'
,
'CountryController'
);
$router
->
resource
(
'country'
,
'CountryController'
);
//下载pdf
//下载pdf
Route
::
get
(
'/api/order_download'
,
'\App\Admin\Controllers\Api\OrderApiController@orderDownload'
);
//下载订单pdf
Route
::
get
(
'/api/order_download'
,
'\App\Admin\Controllers\Api\OrderApiController@orderDownload'
);
//下载订单pdf
Route
::
get
(
'/api/test'
,
'\App\Admin\Controllers\Api\TestController@index'
);
Route
::
get
(
'/api/orderList'
,
'\App\Admin\Controllers\Api\OrderApiController@orderList'
);
//订单详情获取明细数据
Route
::
get
(
'/api/orderList'
,
'\App\Admin\Controllers\Api\OrderApiController@orderList'
);
//订单详情获取明细数据
Route
::
get
(
'/api/orderDownloadShow'
,
'\App\Admin\Controllers\Api\OrderApiController@orderDownloadShow'
);
//订单下载
Route
::
get
(
'/api/orderDownloadShow'
,
'\App\Admin\Controllers\Api\OrderApiController@orderDownloadShow'
);
//订单下载
Route
::
match
([
'get'
,
'post'
],
'/api/order/editOrderItems'
,
'\App\Admin\Controllers\Api\OrderApiController@editOrderItems'
);
//订单修改明细数据
Route
::
match
([
'get'
,
'post'
],
'/api/order/editOrderItems'
,
'\App\Admin\Controllers\Api\OrderApiController@editOrderItems'
);
//订单修改明细数据
...
...
app/Models/Order.php
View file @
fc74d7d6
...
@@ -104,4 +104,27 @@ class Order extends Model
...
@@ -104,4 +104,27 @@ class Order extends Model
return
self
::
where
(
$where
)
->
update
(
$update
);
return
self
::
where
(
$where
)
->
update
(
$update
);
}
}
//修改订单的销售
public
static
function
updateOrderSale
(
$userids
,
$sale_id
,
$sale_name
){
return
self
::
whereIn
(
"user_id"
,
$userids
)
->
whereRaw
(
"status >= 1 and status < 10"
)
->
update
([
"sale_id"
=>
$sale_id
,
"sale_name"
=>
$sale_name
,
"update_time"
=>
time
(),
]);
}
//统计用户的下单数
public
static
function
getUserOrderStatistical
(
$userIds
,
$type
){
$query
=
self
::
whereIn
(
"user_id"
,
$userIds
)
->
selectRaw
(
"user_id,count(order_id) as nums"
);
if
(
$type
==
"1"
){
$query
->
whereRaw
(
"status >= 1 and status <= 8"
);
}
elseif
(
$type
==
"2"
){
$query
->
whereRaw
(
"status >= 1"
);
}
return
$query
->
groupBy
(
"user_id"
)
->
get
()
->
toArray
();
}
}
}
app/Models/OrderItem.php
View file @
fc74d7d6
...
@@ -51,4 +51,8 @@ class OrderItem extends Model
...
@@ -51,4 +51,8 @@ class OrderItem extends Model
return
$info
?
decimal_number_format
(
$info
->
total_amount
)
:
0
;
return
$info
?
decimal_number_format
(
$info
->
total_amount
)
:
0
;
}
}
public
static
function
getOrderItemids
(
$order_id
){
return
self
::
where
(
"order_id"
,
$order_id
)
->
where
(
"status"
,
self
::
$STATUS_FORMAT
[
"正常"
])
->
pluck
(
"rec_id"
)
->
toArray
();
}
}
}
app/Models/OrderReturnItems.php
View file @
fc74d7d6
...
@@ -31,9 +31,7 @@ class OrderReturnItems extends Model
...
@@ -31,9 +31,7 @@ class OrderReturnItems extends Model
public
static
function
getOrderReturnTotalAmount
(
$order_id
){
}
...
...
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