|
@@ -11,7 +11,6 @@
|
|
|
namespace App\Http\Controllers\QuickApp\SendOrder;
|
|
|
|
|
|
use App\Http\Controllers\QuickApp\BaseController;
|
|
|
-use App\Modules\Book\Models\BookCategory;
|
|
|
use App\Modules\Book\Models\Chapter;
|
|
|
use App\Modules\Book\Services\BookConfigService;
|
|
|
use App\Modules\Channel\Services\QappSendOrderContentShieldConfigService;
|
|
@@ -32,17 +31,13 @@ class AdReplaceBookController extends BaseController
|
|
|
{
|
|
|
$book = [];
|
|
|
try {
|
|
|
-
|
|
|
$package = $request->header('x-package', '');
|
|
|
// 暂时关闭浩瀚书籍替换
|
|
|
- if ($package == "com.beidao.kuaiying.haohannew" || $package == "com.beidao.kuaiying.haohan") {
|
|
|
- return response()->success([]);
|
|
|
+ if (!in_array($package, [ "com.beidao.kuaiying.haohannew" , "com.beidao.kuaiying.haohan"])) {
|
|
|
+ $send_order_id = $request->input('send_order_id', 0);
|
|
|
+ $book = $this->sendOrderBookReplace($send_order_id);
|
|
|
+ if ($book) $book['bid'] = str_encode($book['bid']);
|
|
|
}
|
|
|
-
|
|
|
- $send_order_id = $request->input('send_order_id', 0);
|
|
|
- $book = $this->sendOrderBookReplace($send_order_id);
|
|
|
- if ($book) $book['bid'] = str_encode($book['bid']);
|
|
|
-
|
|
|
} catch (\Exception $exception) {
|
|
|
$book = [];
|
|
|
|
|
@@ -50,24 +45,25 @@ class AdReplaceBookController extends BaseController
|
|
|
return response()->success($book);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * ip屏蔽书籍替换
|
|
|
+ * name: advShield
|
|
|
+ * @param Request $request
|
|
|
+ * @return mixed
|
|
|
+ * date 2023/02/15 14:52
|
|
|
+ */
|
|
|
public function advShield(Request $request)
|
|
|
{
|
|
|
- $doShied = [];
|
|
|
try {
|
|
|
$this->send_order_id = $request->input('send_order_id', 0);
|
|
|
$this->package = $request->input('package');
|
|
|
- $bid = $request->input('bid', '');
|
|
|
$checkout_tx = strtolower($request->input('checkout_tx', '')); // 腾讯非广告
|
|
|
$platform = strtolower($request->input('platform', '')); // 投放平台小写
|
|
|
-
|
|
|
- if ($bid) {
|
|
|
- $bid = str_decode($bid);
|
|
|
- }
|
|
|
$send_order = SendOrderService::getSendOrderStatic($this->send_order_id);
|
|
|
$this->sendOrderStatistic($send_order); // 统计
|
|
|
-
|
|
|
$doShied = $this->getRealBookInfo($checkout_tx, $platform);
|
|
|
- if ($doShied){
|
|
|
+
|
|
|
+ if ($doShied) {
|
|
|
$doShied['bid'] = str_encode($doShied['bid']);
|
|
|
}
|
|
|
|
|
@@ -121,35 +117,35 @@ class AdReplaceBookController extends BaseController
|
|
|
* 获取替换书籍 优先集为 腾讯adq非广告用户展示书籍 ->展现备用书籍->系统屏蔽展示书籍
|
|
|
* name: getRealBookInfo
|
|
|
* @param mixed $checkout_tx 是否是腾讯adq非广告用户
|
|
|
- * @param mixed $platform 投放平台
|
|
|
+ * @param mixed $platform 投放平台
|
|
|
* date 2023/02/15 11:13
|
|
|
*/
|
|
|
- private function getRealBookInfo($checkout_tx = '',$platform = "")
|
|
|
+ private function getRealBookInfo($checkout_tx = '', $platform = "")
|
|
|
{
|
|
|
|
|
|
// 系统ip和城市屏蔽
|
|
|
$info = QappSendOrderContentShieldConfigService::doShied($this->send_order_id, _getIp()); // 系统书籍屏蔽
|
|
|
- if ($info){
|
|
|
- return $this->checkoutBookInfo($info);
|
|
|
+ if ($info) {
|
|
|
+ return $this->checkoutBookInfo($info);
|
|
|
}
|
|
|
|
|
|
// 腾讯非广告用户替换检测
|
|
|
if ($checkout_tx) {
|
|
|
$tx_info = $this->getNoAdvBookInfo();
|
|
|
if ($tx_info) {
|
|
|
- return $this->checkoutBookInfo($tx_info);
|
|
|
+ return $this->checkoutBookInfo($tx_info);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!in_array($platform,['tx_adq','tx_adq_new'])){
|
|
|
+ if (!in_array($platform, ['tx_adq', 'tx_adq_new'])) {
|
|
|
// 派单书籍替换针对非腾讯投放平台
|
|
|
$send_order_replace_info = $this->sendOrderBookReplace($this->send_order_id); // 派单替换书籍
|
|
|
if ($send_order_replace_info) {
|
|
|
- return $this->checkoutBookInfo($send_order_replace_info);
|
|
|
+ return $this->checkoutBookInfo($send_order_replace_info);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return [];
|
|
|
+ return [];
|
|
|
|
|
|
}
|
|
|
|
|
@@ -208,6 +204,7 @@ class AdReplaceBookController extends BaseController
|
|
|
if (!BookConfigService::getAvailableBIdsbyBids([$bid], $this->distribution_channel_id)) {
|
|
|
$info = $this->getAvailableBookInfoByBid($bid); // 获取可用书籍
|
|
|
}
|
|
|
+
|
|
|
return $info;
|
|
|
}
|
|
|
|
|
@@ -222,13 +219,13 @@ class AdReplaceBookController extends BaseController
|
|
|
{
|
|
|
$channel = DB::table('book_categories')->join('books', 'books.category_id', '=', 'book_categories.id')->where('books.id', $bid)->value('book_categories.pid');
|
|
|
$channel = $channel ?: 2;
|
|
|
- $bids = BookConfigService::getRecommendBids($this->package, $channel, [], 1);
|
|
|
- if ($bids){
|
|
|
+ $bids = BookConfigService::getRecommendBids($this->package, $channel, [], 1);
|
|
|
+ if ($bids) {
|
|
|
$bid = $bids[0];
|
|
|
}
|
|
|
- $cid = Chapter::where('bid',$bid)->orderBy('sequence','asc')->value('id');
|
|
|
+ $cid = Chapter::where('bid', $bid)->orderBy('sequence', 'asc')->value('id');
|
|
|
|
|
|
- return compact('bid','cid');
|
|
|
+ return compact('bid', 'cid');
|
|
|
}
|
|
|
|
|
|
|