Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
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
c4516540
authored
Jul 26, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
用户统计添加退款金额
parent
71d10771
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
11 deletions
app/Http/Controllers/CronController.php
app/Model/OrderRefundModel.php
app/Model/OrderReturnModel.php
config/params.php
app/Http/Controllers/CronController.php
View file @
c4516540
...
@@ -12,6 +12,8 @@ use App\Model\RemovalModel;
...
@@ -12,6 +12,8 @@ use App\Model\RemovalModel;
use
App\Model\UserMainModel
;
use
App\Model\UserMainModel
;
use
App\Model\UserAmountModel
;
use
App\Model\UserAmountModel
;
use
App\Model\RedisModel
;
use
App\Model\RedisModel
;
use
App\Model\OrderRefundModel
;
use
App\Model\OrderReturnModel
;
class
CronController
extends
Controller
class
CronController
extends
Controller
{
{
...
@@ -23,12 +25,14 @@ class CronController extends Controller
...
@@ -23,12 +25,14 @@ class CronController extends Controller
$start_time
=
strtotime
(
$time
[
'start_time'
]);
$start_time
=
strtotime
(
$time
[
'start_time'
]);
$end_time
=
strtotime
(
$time
[
'end_time'
]);
$end_time
=
strtotime
(
$time
[
'end_time'
]);
$PayLogModel
=
new
PayLogModel
();
$PayLogModel
=
new
PayLogModel
();
$ErpPayLogModel
=
new
ErpPayLogModel
();
$ErpPayLogModel
=
new
ErpPayLogModel
();
$RemovalModel
=
new
RemovalModel
();
$RemovalModel
=
new
RemovalModel
();
$UserMainModel
=
new
UserMainModel
();
$UserMainModel
=
new
UserMainModel
();
$UserAmountModel
=
new
UserAmountModel
();
$UserAmountModel
=
new
UserAmountModel
();
$RedisModel
=
new
RedisModel
();
$RedisModel
=
new
RedisModel
();
$OrderRefundModel
=
new
OrderRefundModel
();
$OrderReturnModel
=
new
OrderReturnModel
();
// 查询联营、自营线上支付记录
// 查询联营、自营线上支付记录
$pay_log_list
=
$PayLogModel
->
getPayLog
(
$start_time
,
$end_time
);
$pay_log_list
=
$PayLogModel
->
getPayLog
(
$start_time
,
$end_time
);
...
@@ -53,7 +57,7 @@ class CronController extends Controller
...
@@ -53,7 +57,7 @@ class CronController extends Controller
// 合并用户
// 合并用户
$resp
=
$this
->
mergeUser
(
$pay_log_amount
,
$joint_offline_amount
);
$resp
=
$this
->
mergeUser
(
$pay_log_amount
,
$joint_offline_amount
);
$resp
=
$this
->
mergeUser
(
$resp
,
$self_accounts_amount
);
$resp
=
$this
->
mergeUser
(
$resp
,
$self_accounts_amount
);
dd
(
$
)
// 保存用户金额数据
// 保存用户金额数据
if
(
!
empty
(
$resp
))
{
if
(
!
empty
(
$resp
))
{
foreach
(
$resp
as
$k
=>
$v
)
{
foreach
(
$resp
as
$k
=>
$v
)
{
...
@@ -67,6 +71,31 @@ class CronController extends Controller
...
@@ -67,6 +71,31 @@ class CronController extends Controller
$data
[
'rmb_amount'
]
=
isset
(
$v
[
'rmb'
])
?
$v
[
'rmb'
]
:
0
;
$data
[
'rmb_amount'
]
=
isset
(
$v
[
'rmb'
])
?
$v
[
'rmb'
]
:
0
;
$data
[
'usd_amount'
]
=
isset
(
$v
[
'usd'
])
?
$v
[
'usd'
]
:
0
;
$data
[
'usd_amount'
]
=
isset
(
$v
[
'usd'
])
?
$v
[
'usd'
]
:
0
;
$joint_return_amount
=
$OrderRefundModel
->
getJointReturnAmount
(
$k
,
$start_time
,
$end_time
);
// 联营用户退款金额
if
(
$joint_return_amount
)
{
foreach
(
$joint_return_amount
as
$joint
)
{
if
(
$joint
[
'currency'
]
==
1
)
{
$data
[
'rmb_amount'
]
=
$data
[
'rmb_amount'
]
-
(
$joint
[
'pay_amount'
]
-
$joint
[
'price_fall'
]);
}
else
{
$data
[
'usd_amount'
]
=
$data
[
'usd_amount'
]
-
(
$joint
[
'pay_amount'
]
-
$joint
[
'price_fall'
]);
}
}
}
$self_return_amount
=
$OrderReturnModel
->
getSelfReturnAmount
(
$k
,
$start_time
,
$end_time
);
// 自营用户退款金额
if
(
$self_return_amount
)
{
foreach
(
$self_return_amount
as
$self
)
{
if
(
$self
[
'currency'
]
==
1
)
{
$data
[
'rmb_amount'
]
=
$data
[
'rmb_amount'
]
-
$joint
[
'return_amount'
];
}
else
{
$data
[
'usd_amount'
]
=
$data
[
'usd_amount'
]
-
$joint
[
'return_amount'
];
}
}
}
$data
[
'cur_rate'
]
=
$this
->
getRate
();
$data
[
'cur_rate'
]
=
$this
->
getRate
();
$data
[
'amount'
]
=
$data
[
'rmb_amount'
]
+
$data
[
'usd_amount'
]
*
$data
[
'cur_rate'
];
$data
[
'amount'
]
=
$data
[
'rmb_amount'
]
+
$data
[
'usd_amount'
]
*
$data
[
'cur_rate'
];
...
@@ -169,8 +198,8 @@ class CronController extends Controller
...
@@ -169,8 +198,8 @@ class CronController extends Controller
foreach
(
$amount_1
as
$k1
=>&
$v1
)
{
foreach
(
$amount_1
as
$k1
=>&
$v1
)
{
if
(
in_array
(
$k1
,
$keys
))
{
if
(
in_array
(
$k1
,
$keys
))
{
if
(
isset
(
$v1
[
'rmb'
]))
$v1
[
'rmb'
]
=
$v1
[
'rmb'
]
+
$amount_2
[
$k1
][
'rmb'
];
if
(
isset
(
$v1
[
'rmb'
])
&&
isset
(
$amount_2
[
$k1
][
'rmb'
])
)
$v1
[
'rmb'
]
=
$v1
[
'rmb'
]
+
$amount_2
[
$k1
][
'rmb'
];
if
(
isset
(
$v1
[
'usd'
]))
$v1
[
'usd'
]
=
$v1
[
'usd'
]
+
$amount_2
[
$k1
][
'usd'
];
if
(
isset
(
$v1
[
'usd'
])
&&
isset
(
$amount_2
[
$k1
][
'usd'
])
)
$v1
[
'usd'
]
=
$v1
[
'usd'
]
+
$amount_2
[
$k1
][
'usd'
];
unset
(
$amount_2
[
$k1
]);
// 删除amount_2中已合并金额的用户
unset
(
$amount_2
[
$k1
]);
// 删除amount_2中已合并金额的用户
}
}
...
...
app/Model/OrderRefundModel.php
View file @
c4516540
...
@@ -314,4 +314,16 @@ class OrderRefundModel extends Model
...
@@ -314,4 +314,16 @@ class OrderRefundModel extends Model
return
$tmp
;
return
$tmp
;
}
}
// 获取活动期间已完成退款的用户金额
public
function
getJointReturnAmount
(
$user_id
,
$start_time
,
$end_time
)
{
return
$this
->
where
(
'user_id'
,
$user_id
)
// ->where('status', 10)
->
whereBetween
(
'refund_time'
,
[
$start_time
,
$end_time
])
->
select
(
'user_id'
,
'currency'
,
'pay_amount'
,
'price_fall'
)
->
get
()
->
toArray
();
}
}
}
\ No newline at end of file
app/Model/OrderReturnModel.php
View file @
c4516540
...
@@ -229,4 +229,15 @@ class OrderReturnModel extends Model
...
@@ -229,4 +229,15 @@ class OrderReturnModel extends Model
}
}
}
}
// 获取活动期间已完成退款的用户金额
public
function
getSelfReturnAmount
(
$user_id
,
$start_time
,
$end_time
)
{
return
$this
->
where
(
'user_id'
,
$user_id
)
->
where
(
'status'
,
10
)
->
whereBetween
(
'putaway_time'
,
[
$start_time
,
$end_time
])
->
select
(
'user_id'
,
'currency'
,
'return_amount'
)
->
get
()
->
toArray
();
}
}
}
\ No newline at end of file
config/params.php
View file @
c4516540
...
@@ -89,8 +89,8 @@
...
@@ -89,8 +89,8 @@
// 猎芯活动用户金额统计时间
// 猎芯活动用户金额统计时间
'lx_activity_time'
=>
[
'lx_activity_time'
=>
[
'start_time'
=>
'201
8-10-1
'
,
'start_time'
=>
'201
9-7-24
'
,
'end_time'
=>
'201
8
-10-31 23:59:59'
,
'end_time'
=>
'201
9
-10-31 23:59:59'
,
],
],
...
...
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