Commit c4516540 by 朱继来

用户统计添加退款金额

parent 71d10771
...@@ -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中已合并金额的用户
} }
......
...@@ -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
...@@ -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
...@@ -89,8 +89,8 @@ ...@@ -89,8 +89,8 @@
// 猎芯活动用户金额统计时间 // 猎芯活动用户金额统计时间
'lx_activity_time' => [ 'lx_activity_time' => [
'start_time' => '2018-10-1', 'start_time' => '2019-7-24',
'end_time' => '2018-10-31 23:59:59', 'end_time' => '2019-10-31 23:59:59',
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment