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
a327885e
authored
Jul 27, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix
parent
69bcdc34
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
46 deletions
app/Http/Controllers/CronController.php
app/Model/OrderRefundModel.php
app/Model/OrderReturnModel.php
app/Model/PayLogModel.php
app/Model/RemovalModel.php
app/Http/Controllers/CronController.php
View file @
a327885e
...
...
@@ -12,6 +12,9 @@ use App\Model\RemovalModel;
use
App\Model\UserMainModel
;
use
App\Model\UserAmountModel
;
use
App\Model\RedisModel
;
use
App\Model\OrderRefundModel
;
use
App\Model\OrderReturnModel
;
use
MonitorDing
;
class
CronController
extends
Controller
{
...
...
@@ -23,37 +26,34 @@ class CronController extends Controller
$start_time
=
strtotime
(
$time
[
'start_time'
]);
$end_time
=
strtotime
(
$time
[
'end_time'
]);
$PayLogModel
=
new
PayLogModel
();
$ErpPayLogModel
=
new
ErpPayLogModel
();
$RemovalModel
=
new
RemovalModel
();
$UserMainModel
=
new
UserMainModel
();
$UserAmountModel
=
new
UserAmountModel
();
$RedisModel
=
new
RedisModel
();
$PayLogModel
=
new
PayLogModel
();
$ErpPayLogModel
=
new
ErpPayLogModel
();
$RemovalModel
=
new
RemovalModel
();
$UserMainModel
=
new
UserMainModel
();
$UserAmountModel
=
new
UserAmountModel
();
$RedisModel
=
new
RedisModel
();
$OrderRefundModel
=
new
OrderRefundModel
();
$OrderReturnModel
=
new
OrderReturnModel
();
// 查询联营、自营线上支付记录
$pay_log_list
=
$PayLogModel
->
getPayLog
(
$start_time
,
$end_time
);
// $pay_log = $this->filterFake($pay_log_list); // 过滤数据
$pay_log_list
=
$PayLogModel
->
getPayLog
(
$start_time
,
$end_time
);
$pay_log_amount
=
$this
->
countByCurrency
(
$pay_log_list
);
// 统计金额
// 联营线下支付记录
$joint_offline_list
=
$ErpPayLogModel
->
getErpPayLog
(
$start_time
,
$end_time
);
$joint_offline_list
=
$ErpPayLogModel
->
getErpPayLog
(
$start_time
,
$end_time
);
$joint_offline
=
$this
->
filterData
(
$joint_offline_list
);
// 过滤数据
$joint_offline_amount
=
$this
->
countByCurrency
(
$joint_offline
,
'receipt_amount'
);
// 统计金额
// 自营账期支付记录
$self_accounts_list
=
$RemovalModel
->
getSelfAccounts
(
$start_time
,
$end_time
);
$self_accounts
=
$this
->
filterFake
(
$self_accounts_list
);
// 过滤数据
$self_accounts_amount
=
$this
->
countByCurrency
(
$self_accounts
,
'checkout_paid_amount'
);
// 统计金额
$self_accounts_list
=
$RemovalModel
->
getSelfAccounts
(
$start_time
,
$end_time
);
$self_accounts_amount
=
$this
->
countByCurrency
(
$self_accounts_list
,
'checkout_paid_amount'
);
// 统计金额
$resp
=
[];
// 合并用户
$resp
=
$this
->
mergeUser
(
$pay_log_amount
,
$joint_offline_amount
);
$resp
=
$this
->
mergeUser
(
$resp
,
$self_accounts_amount
);
// 保存用户金额数据
if
(
!
empty
(
$resp
))
{
$cur_rate
=
$this
->
getRate
();
...
...
@@ -69,12 +69,38 @@ class CronController extends Controller
$data
[
'rmb_amount'
]
=
isset
(
$v
[
'rmb'
])
?
$v
[
'rmb'
]
:
0
;
$data
[
'usd_amount'
]
=
isset
(
$v
[
'usd'
])
?
$v
[
'usd'
]
:
0
;
$data
[
'cur_rate'
]
=
$cur_rate
;
$data
[
'amount'
]
=
$data
[
'rmb_amount'
]
+
$data
[
'usd_amount'
]
*
$data
[
'cur_rate'
];
$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'
]
=
$cur_rate
;
$data
[
'amount'
]
=
$data
[
'rmb_amount'
]
+
$data
[
'usd_amount'
]
*
$data
[
'cur_rate'
];
$res
=
$UserAmountModel
->
updateOrCreate
([
'user_id'
=>
$k
],
$data
);
if
(
$res
===
false
)
{
MonitorDing
::
sendText
(
'活动用户汇总表---新增或更新失败,用户ID:'
.
$k
);
echo
'新增或更新失败,用户ID:'
.
$k
;
die
;
}
}
...
...
@@ -84,28 +110,8 @@ class CronController extends Controller
$rank
=
$UserAmountModel
->
getUserAmount
();
$RedisModel
->
set
(
'api_lx_activity_user_rank'
,
json_encode
(
$rank
));
return
$resp
;
}
// 过滤尽调数据、添加币种
public
function
filterFake
(
$data
)
{
if
(
!
$data
)
return
false
;
$OrderModel
=
new
OrderModel
();
foreach
(
$data
as
$k
=>&
$v
)
{
$order
=
$OrderModel
->
where
([
'order_id'
=>
$v
[
'order_id'
]])
->
select
(
'order_id'
,
'user_id'
,
'currency'
,
'is_type'
)
->
first
();
if
(
$order
[
'is_type'
])
{
unset
(
$data
[
$k
]);
continue
;
}
$v
[
'currency'
]
=
$order
[
'currency'
];
}
return
$data
;
MonitorDing
::
sendText
(
date
(
'Y-m-d'
)
.
'活动用户排行榜:'
.
json_encode
(
$rank
));
return
$RedisModel
->
get
(
'api_lx_activity_user_rank'
);
}
// 过滤联营线下支付数据
...
...
app/Model/OrderRefundModel.php
View file @
a327885e
...
...
@@ -314,4 +314,16 @@ class OrderRefundModel extends Model
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 @
a327885e
...
...
@@ -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
app/Model/PayLogModel.php
View file @
a327885e
...
...
@@ -13,16 +13,18 @@ class PayLogModel extends Model
protected
$primaryKey
=
'pay_log_id'
;
public
$timestamps
=
false
;
// 获取联营、自营线上支付记录
// 获取联营、自营线上支付记录
(过滤尽调订单、测试账号)
public
function
getPayLog
(
$start_time
,
$end_time
)
{
$field
=
[
'p.pay_log_id'
,
'p.order_id'
,
'p.order_sn'
,
'p.user_id'
,
'p.pay_type'
,
'p.is_paid'
,
'p.pay_amount'
,
'p.pay_time'
,
'o.currency'
];
$data
=
$this
->
from
(
'lie_pay_log as p'
)
->
leftJoin
(
'lie_order as o'
,
'p.order_id'
,
'='
,
'o.order_id'
)
->
leftJoin
(
'lie_user_main as u'
,
'p.user_id'
,
'='
,
'u.user_id'
)
->
where
(
'p.is_paid'
,
1
)
->
whereBetween
(
'p.pay_time'
,
[
$start_time
,
$end_time
])
->
where
(
'o.status'
,
'>'
,
2
)
->
where
(
'o.is_type'
,
0
)
->
where
(
'u.is_test'
,
0
)
->
select
(
$field
)
// ->select('user_id', DB::raw('sum(pay_amount) as pay_amount'))
->
orderBy
(
'p.pay_time'
,
'desc'
)
...
...
app/Model/RemovalModel.php
View file @
a327885e
...
...
@@ -13,14 +13,17 @@ class RemovalModel extends Model
protected
$primaryKey
=
'removal_id'
;
public
$timestamps
=
false
;
// 自营账期支付记录
// 自营账期支付记录
(过滤尽调订单、测试账号)
public
function
getSelfAccounts
(
$start_time
,
$end_time
)
{
$field
=
[
'removal_id'
,
'order_id'
,
'order_sn'
,
'user_id'
,
'checkout_paid'
,
'checkout_paid_time'
,
'checkout_paid_amount'
];
$data
=
$this
->
where
(
'checkout_paid'
,
1
)
->
whereBetween
(
'checkout_paid_time'
,
[
$start_time
,
$end_time
])
$field
=
[
'r.removal_id'
,
'r.order_id'
,
'r.order_sn'
,
'r.user_id'
,
'r.checkout_paid'
,
'r.checkout_paid_time'
,
'r.checkout_paid_amount'
,
'o.currency'
];
$data
=
$this
->
from
(
'lie_removal as r'
)
->
leftJoin
(
'lie_order as o'
,
'r.order_id'
,
'='
,
'o.order_id'
)
->
leftJoin
(
'lie_user_main as u'
,
'r.user_id'
,
'='
,
'u.user_id'
)
->
where
(
'r.checkout_paid'
,
1
)
->
whereBetween
(
'r.checkout_paid_time'
,
[
$start_time
,
$end_time
])
->
select
(
$field
)
->
orderBy
(
'
checkout_paid_time'
,
'desc'
)
->
orderBy
(
'
r.checkout_paid_time'
,
'desc'
)
->
get
()
->
toArray
();
...
...
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