|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+
|
|
|
/**
|
|
|
* Created by PhpStorm.
|
|
|
* User: hp
|
|
@@ -8,14 +9,33 @@
|
|
|
|
|
|
namespace App\Modules\SendOrder\Services;
|
|
|
|
|
|
+use App\Modules\BaseService;
|
|
|
+use App\Modules\SendOrder\Models\QuickAppSendOrder;
|
|
|
use App\Modules\SendOrder\Models\SendOrder;
|
|
|
use App\Modules\SendOrder\Models\SendOrderExtraStat;
|
|
|
use App\Modules\Statistic\Services\WapVisitStatService;
|
|
|
use DB;
|
|
|
use Redis;
|
|
|
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @method static \App\Modules\SendOrder\Models\SendOrder getSendOrderStatic(int $id) 根据ID获取派单信息
|
|
|
+ * @method static \App\Modules\SendOrder\Models\QuickAppSendOrder getQuickAppSendOrderStatic(int $send_order_id) 获取快应用派单信息
|
|
|
+ */
|
|
|
class SendOrderService
|
|
|
{
|
|
|
+ use BaseService;
|
|
|
+
|
|
|
+ public function getSendOrder(int $id)
|
|
|
+ {
|
|
|
+ return SendOrder::find($id);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getQuickAppSendOrder(int $send_order_id)
|
|
|
+ {
|
|
|
+ return QuickAppSendOrder::where('send_order_id', $send_order_id)->first();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 更新派单的备注
|
|
|
* @param $id 派单id
|
|
@@ -61,9 +81,9 @@ class SendOrderService
|
|
|
* @param $channel_type 派单渠道类型.(允许值: AUTHENTICATED, UNAUTHENTICATED)
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- static function updateSendOrderInfo($id, $distribution_channel_id, $name, $pre_send_date, $channel_type, $cost, $promotion_type,$subscribe_chapter=[])
|
|
|
+ static function updateSendOrderInfo($id, $distribution_channel_id, $name, $pre_send_date, $channel_type, $cost, $promotion_type, $subscribe_chapter = [])
|
|
|
{
|
|
|
- return SendOrder::updateSendOrderInfo($id, $distribution_channel_id, $name, $pre_send_date, $channel_type, $cost, $promotion_type,$subscribe_chapter);
|
|
|
+ return SendOrder::updateSendOrderInfo($id, $distribution_channel_id, $name, $pre_send_date, $channel_type, $cost, $promotion_type, $subscribe_chapter);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -160,7 +180,7 @@ class SendOrderService
|
|
|
*/
|
|
|
static function getSendOrders($bookId, $distribution_channel_id, $name = null, $bookName = null, $sendOrderId, $start_time = '', $end_time = '', $isAll = false)
|
|
|
{
|
|
|
- return SendOrder:: getSendOrders($bookId, $distribution_channel_id, $name, $bookName, $sendOrderId, $start_time, $end_time, $isAll);
|
|
|
+ return SendOrder::getSendOrders($bookId, $distribution_channel_id, $name, $bookName, $sendOrderId, $start_time, $end_time, $isAll);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -178,7 +198,7 @@ class SendOrderService
|
|
|
*/
|
|
|
static function getManageSendOrders($params = [], $is_all = false)
|
|
|
{
|
|
|
- return SendOrder:: getManageSendOrders($params, $is_all);
|
|
|
+ return SendOrder::getManageSendOrders($params, $is_all);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -219,7 +239,8 @@ class SendOrderService
|
|
|
//return (float)Redis::hget('send_order_pv_' . $id, 'total');
|
|
|
}
|
|
|
|
|
|
- static function getBrowserUvAndPv($id){
|
|
|
+ static function getBrowserUvAndPv($id)
|
|
|
+ {
|
|
|
return WapVisitStatService::getBrowserSendOrderTotalPvAndUv($id);
|
|
|
}
|
|
|
|
|
@@ -274,7 +295,7 @@ class SendOrderService
|
|
|
*/
|
|
|
static function getRedirectUrlById($id)
|
|
|
{
|
|
|
- return SendOrder::where('id', $id)->select('redirect_url', 'book_id', 'send_time', 'distribution_channel_id', 'name','promotion_point','force_show_qrcode','promotion_type')->first();
|
|
|
+ return SendOrder::where('id', $id)->select('redirect_url', 'book_id', 'send_time', 'distribution_channel_id', 'name', 'promotion_point', 'force_show_qrcode', 'promotion_type')->first();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -295,8 +316,8 @@ class SendOrderService
|
|
|
$uv = 0;
|
|
|
$pv = 0;
|
|
|
foreach ($send_orders as $send_order) {
|
|
|
- $uv += (float)Redis::hget('send_order_uv_' . $send_order->id, $date);
|
|
|
- $pv += (float)Redis::hget('send_order_pv_' . $send_order->id, $date);
|
|
|
+ $uv += (float) Redis::hget('send_order_uv_' . $send_order->id, $date);
|
|
|
+ $pv += (float) Redis::hget('send_order_pv_' . $send_order->id, $date);
|
|
|
}
|
|
|
return compact('uv', 'pv');
|
|
|
}
|
|
@@ -317,7 +338,7 @@ class SendOrderService
|
|
|
*/
|
|
|
static function getContinueTotalReadUv($send_order_id)
|
|
|
{
|
|
|
- return (float)Redis::hget('send_order:continue:' . $send_order_id, 'total');
|
|
|
+ return (float) Redis::hget('send_order:continue:' . $send_order_id, 'total');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -391,7 +412,7 @@ class SendOrderService
|
|
|
*/
|
|
|
static function search($params, $isAll = false)
|
|
|
{
|
|
|
- return SendOrder:: search($params, $isAll);
|
|
|
+ return SendOrder::search($params, $isAll);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -450,30 +471,33 @@ class SendOrderService
|
|
|
return SendOrderExtraStat::getBySendOrderId($send_order_id);
|
|
|
}
|
|
|
|
|
|
- static function getPeriodActualSendOrdersNum($channel_id,$start_time,$end_time) {
|
|
|
+ static function getPeriodActualSendOrdersNum($channel_id, $start_time, $end_time)
|
|
|
+ {
|
|
|
return SendOrder::where([
|
|
|
- ['distribution_channel_id','=',$channel_id],
|
|
|
- ['send_time','>=',$start_time],
|
|
|
- ['send_time','<=',$end_time],
|
|
|
+ ['distribution_channel_id', '=', $channel_id],
|
|
|
+ ['send_time', '>=', $start_time],
|
|
|
+ ['send_time', '<=', $end_time],
|
|
|
])->count();
|
|
|
}
|
|
|
|
|
|
- static function getCompanyPromotionBooks($company_id,$start_time,$end_time) {
|
|
|
+ static function getCompanyPromotionBooks($company_id, $start_time, $end_time)
|
|
|
+ {
|
|
|
$res = DB::select("select * from (select bcs.bid,bcs.book_name,count(so.id) as promotion_times
|
|
|
from channel_users cu
|
|
|
left join distribution_channels dc on dc.channel_user_id=cu.id
|
|
|
left join send_orders so on so.distribution_channel_id=dc.id
|
|
|
left join book_configs bcs on bcs.bid=so.book_id
|
|
|
- where cu.company_id=".$company_id." and so.book_id is not null and so.send_time between '".$start_time."' and '".$end_time."'
|
|
|
+ where cu.company_id=" . $company_id . " and so.book_id is not null and so.send_time between '" . $start_time . "' and '" . $end_time . "'
|
|
|
group by so.book_id) tmp order by tmp.promotion_times desc");
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
//成本统计
|
|
|
- static function getCostStats($distribution_channels) {
|
|
|
- return SendOrder::whereIn('distribution_channel_id',$distribution_channels)
|
|
|
- ->where('is_enable',1)
|
|
|
+ static function getCostStats($distribution_channels)
|
|
|
+ {
|
|
|
+ return SendOrder::whereIn('distribution_channel_id', $distribution_channels)
|
|
|
+ ->where('is_enable', 1)
|
|
|
->whereNotNull('send_time')
|
|
|
->sum('cost');
|
|
|
}
|
|
|
-}
|
|
|
+}
|