| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace app\extra\tools;
- use app\model\system\SystemConfig;
- use yzh52521\EasyHttp\Http;
- class LifeWeb
- {
- protected string $getaway = "https://life.douyin.com";
- /**
- * 默认header
- * @var string[]
- */
- protected array $header = [];
- /**
- * 释放授权
- * @return $this
- */
- public function token(): static
- {
- $this->header = [
- "cookie" => $this->getCookies()
- ];
- return $this;
- }
- public function getOrderData(string $orderId = ""): array
- {
- $param = [
- "order_id" => $orderId,
- "current_time_ms" => round(microtime(true) * 1000),
- "show_reason" => "catering_comprehensive_coupon",
- "search_type" => 1,
- "source" => 1,
- "dito_biz_common_param" => [
- "page_id" => "502",
- "scene_version" => "management",
- "source" => "dlk_pc"
- ],
- "industry" => "industry_common"
- ];
- $resp = Http::asJson()->withHeaders($this->header)->post($this->getaway."/life/trade_view/v1/management/coupon/sale/get_detail?industry=industry_common&root_life_account_id=7595228109947947043&life_biz_view_id=22&life_account_biz_ids=",$param)->array();
- if (!isset($resp['data']['dito_data']['meta_data'])) return [0,'获取失败'];
- $metaData = $resp['data']['dito_data']['meta_data'];
- $dataRe = json_decode(json_decode($metaData, true), true);
- $orderFee = $dataRe['order_fee']['bill_commissions'];
- $starFee = $lifeFee = 0;
- foreach ($orderFee as $value) {
- if ($value['title'] == "软件服务费") {
- $lifeFee = substr($value['amount'],1);
- }
- if ($value['title'] == "达人服务费") {
- $starFee = substr($value['amount'],1);
- }
- }
- return [1,[
- "douyin_uid" => $dataRe['order_source']['sale_user_unique_id']??'',
- "star_fee" => $starFee,
- "life_fee" => $lifeFee,
- ]];
- }
- protected function getCookies()
- {
- return (new SystemConfig)->where(['type' => "life","name" => "cookies"])->value("value");
- }
- }
|