Commit 4b5f0628 by 朱继来

1.过滤测试账号;

2.添加钉钉通知;
parent 1fc20662
...@@ -14,6 +14,7 @@ use App\Model\UserAmountModel; ...@@ -14,6 +14,7 @@ use App\Model\UserAmountModel;
use App\Model\RedisModel; use App\Model\RedisModel;
use App\Model\OrderRefundModel; use App\Model\OrderRefundModel;
use App\Model\OrderReturnModel; use App\Model\OrderReturnModel;
use MonitorDing;
class CronController extends Controller class CronController extends Controller
{ {
...@@ -36,21 +37,16 @@ class CronController extends Controller ...@@ -36,21 +37,16 @@ class CronController extends Controller
// 查询联营、自营线上支付记录 // 查询联营、自营线上支付记录
$pay_log_list = $PayLogModel->getPayLog($start_time, $end_time); $pay_log_list = $PayLogModel->getPayLog($start_time, $end_time);
// $pay_log = $this->filterFake($pay_log_list); // 过滤数据
$pay_log_amount = $this->countByCurrency($pay_log_list); // 统计金额 $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 = $this->filterData($joint_offline_list); // 过滤数据
$joint_offline_amount = $this->countByCurrency($joint_offline, 'receipt_amount'); // 统计金额 $joint_offline_amount = $this->countByCurrency($joint_offline, 'receipt_amount'); // 统计金额
// 自营账期支付记录 // 自营账期支付记录
$self_accounts_list = $RemovalModel->getSelfAccounts($start_time, $end_time); $self_accounts_list = $RemovalModel->getSelfAccounts($start_time, $end_time);
$self_accounts_amount = $this->countByCurrency($self_accounts_list, 'checkout_paid_amount'); // 统计金额
$self_accounts = $this->filterFake($self_accounts_list); // 过滤数据
$self_accounts_amount = $this->countByCurrency($self_accounts, 'checkout_paid_amount'); // 统计金额
$resp = []; $resp = [];
...@@ -99,12 +95,12 @@ class CronController extends Controller ...@@ -99,12 +95,12 @@ class CronController extends Controller
} }
$data['cur_rate'] = $cur_rate; $data['cur_rate'] = $cur_rate;
$data['amount'] = $data['rmb_amount'] + $data['usd_amount'] * $data['cur_rate']; $data['amount'] = $data['rmb_amount'] + $data['usd_amount'] * $data['cur_rate'];
$res = $UserAmountModel->updateOrCreate(['user_id' => $k], $data); $res = $UserAmountModel->updateOrCreate(['user_id' => $k], $data);
if ($res === false) { if ($res === false) {
MonitorDing::sendText('活动用户汇总表---新增或更新失败,用户ID:'.$k);
echo '新增或更新失败,用户ID:'.$k; die; echo '新增或更新失败,用户ID:'.$k; die;
} }
} }
...@@ -114,30 +110,10 @@ class CronController extends Controller ...@@ -114,30 +110,10 @@ class CronController extends Controller
$rank = $UserAmountModel->getUserAmount(); $rank = $UserAmountModel->getUserAmount();
$RedisModel->set('api_lx_activity_user_rank', json_encode($rank)); $RedisModel->set('api_lx_activity_user_rank', json_encode($rank));
MonitorDing::sendText(date('Y-m-d').'活动用户排行榜:'.json_encode($rank));
return $RedisModel->get('api_lx_activity_user_rank'); return $RedisModel->get('api_lx_activity_user_rank');
} }
// 过滤尽调数据、添加币种
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;
}
// 过滤联营线下支付数据 // 过滤联营线下支付数据
public function filterData($data) public function filterData($data)
{ {
......
...@@ -142,7 +142,7 @@ Route::group(['middleware' => 'api'], function () { ...@@ -142,7 +142,7 @@ Route::group(['middleware' => 'api'], function () {
Route::get ('/api/check/changeprice', 'SpecialController@changeOrderPrice'); Route::get ('/api/check/changeprice', 'SpecialController@changeOrderPrice');
Route::get ('/api/check/exportdimission', 'SpecialController@exportDimission'); Route::get ('/api/check/exportdimission', 'SpecialController@exportDimission');
Route::match (['get', 'post'], '/api/check/importdimission', 'SpecialController@importDimission'); Route::match (['get', 'post'], '/api/check/importdimission', 'SpecialController@importDimission');
Route::get('/act/useramoumt', 'CronController@userAmount'); // 活动统计用户实付金额 Route::get('/act/useramount', 'CronController@userAmount'); // 活动统计用户实付金额
Route::get('/act/clear', 'CronController@clearData'); // 清除活动统计用户表和缓存 Route::get('/act/clear', 'CronController@clearData'); // 清除活动统计用户表和缓存
Route::get ('/handle/paylog', 'SpecialController@handlePayLog'); // 处理支付记录 Route::get ('/handle/paylog', 'SpecialController@handlePayLog'); // 处理支付记录
}); });
......
...@@ -13,16 +13,18 @@ class PayLogModel extends Model ...@@ -13,16 +13,18 @@ class PayLogModel extends Model
protected $primaryKey = 'pay_log_id'; protected $primaryKey = 'pay_log_id';
public $timestamps = false; public $timestamps = false;
// 获取联营、自营线上支付记录 // 获取联营、自营线上支付记录 (过滤尽调订单、测试账号)
public function getPayLog($start_time, $end_time) 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']; $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') $data = $this->from('lie_pay_log as p')
->leftJoin('lie_order as o', 'p.order_id', '=', 'o.order_id') ->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) ->where('p.is_paid', 1)
->whereBetween('p.pay_time', [$start_time, $end_time]) ->whereBetween('p.pay_time', [$start_time, $end_time])
->where('o.status', '>', 2) ->where('o.status', '>', 2)
->where('o.is_type', 0) ->where('o.is_type', 0)
->where('u.is_test', 0)
->select($field) ->select($field)
// ->select('user_id', DB::raw('sum(pay_amount) as pay_amount')) // ->select('user_id', DB::raw('sum(pay_amount) as pay_amount'))
->orderBy('p.pay_time', 'desc') ->orderBy('p.pay_time', 'desc')
......
...@@ -13,14 +13,17 @@ class RemovalModel extends Model ...@@ -13,14 +13,17 @@ class RemovalModel extends Model
protected $primaryKey = 'removal_id'; protected $primaryKey = 'removal_id';
public $timestamps = false; public $timestamps = false;
// 自营账期支付记录 // 自营账期支付记录 (过滤尽调订单、测试账号)
public function getSelfAccounts($start_time, $end_time) public function getSelfAccounts($start_time, $end_time)
{ {
$field = ['removal_id', 'order_id', 'order_sn', 'user_id', 'checkout_paid', 'checkout_paid_time', 'checkout_paid_amount']; $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->where('checkout_paid', 1) $data = $this->from('lie_removal as r')
->whereBetween('checkout_paid_time', [$start_time, $end_time]) ->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) ->select($field)
->orderBy('checkout_paid_time', 'desc') ->orderBy('r.checkout_paid_time', 'desc')
->get() ->get()
->toArray(); ->toArray();
......
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