123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- namespace App\Http\Utils\TaoBao;
- use App\Exceptions\CommonException;
- use App\Exceptions\TaobaoException;
- use App\Http\Enum\AccountTypeEnum;
- use App\Http\Enum\ErrorEnum;
- use App\Http\Enum\MeiTuanLinkTypeEnum;
- use App\Http\Utils\BaseUtil;
- use App\Http\Utils\LoggerFactoryUtil;
- use App\Models\UnionActivityModel;
- use App\Models\WechatSpreadAccountModel;
- use ETaobao\Factory;
- /**
- * 淘宝联盟工具类
- * Class TaobaoLianMengUtil
- * @package App\Http\Utils\TaoBao
- */
- class TaobaoLianMengUtil extends BaseUtil
- {
- /**
- * 获取淘宝联盟实例对象
- * @return \ETaobao\Tbk\Application
- */
- public static function getApp()
- {
- $config = config("taobao");
- return Factory::tbk($config);
- }
- /**
- * 获取官方活动信息接口
- * @param $adzone_id string 推广位ID
- * @param $activity_material_id string 活动ID
- */
- public static function getActivityInfo($adzone_id,$activity_material_id)
- {
- $app = self::getApp();
- $params = [
- "adzone_id"=>$adzone_id,
- "activity_material_id"=>$activity_material_id
- ];
- $res = $app->content->getActivityInfo($params);
- $res = json_decode(json_encode($res),true);
- if(isset($res["code"])){
- throw new TaobaoException($res["sub_msg"]);
- }
- return $res["data"];
- }
- /**
- * 获取私域用户邀请码
- * @param $codeType int 邀请码类型,1 - 渠道邀请,2 - 渠道裂变,3 -会员邀请
- * @param int $relationId 渠道关系ID
- */
- public static function getInviteCode($codeType, $relationId = 0)
- {
- $app = self::getApp();
- $params = [
- "relation_app"=>"common",
- "code_type"=>$codeType
- ];
- if($relationId){
- $params["relation_id"] = $relationId;
- }
-
- $res = $app->sc->getInviteCode($params);
- $res = json_decode(json_encode($res),true);
- if(isset($res["code"])){
- throw new TaobaoException($res["msg"]);
- }
- return $res["data"];
- }
- /**
- * 渠道备案
- * @param $inviteCode string 邀请码
- * @param $infoType int 类型,必选 默认为1:
- */
- public static function savePublisherInfo($inviteCode, $infoType)
- {
- $app = self::getApp();
- $params = [
- "inviter_code"=>$inviteCode,
- "info_type"=>$infoType
- ];
- $res = $app->sc->savePublisherInfo($params);
- $res = json_decode(json_encode($res),true);
- if(isset($res["code"])){
- throw new TaobaoException($res["sub_msg"]);
- }
- return $res["data"];
- }
- /**
- * 获取备案信息
- * @param $infoType int 类型,必选 1:渠道信息;2:会员信息
- * @param $id string 渠道或者会员ID
- * @param string $relationApp 默认common
- */
- public static function getPublisherInfo($infoType,$id,$relationApp="common")
- {
- $app = self::getApp();
- $params = [
- "info_type"=>$infoType,
- "relation_app"=>$relationApp
- ];
- switch ($infoType){
- case 1:
- $params["relation_id"] = $id;
- break;
- case 2:
- $params["special_id"] = $id;
- break;
- }
- $res = $app->sc->getPublisherInfo($params);
- $res = json_decode(json_encode($res),true);
- if(isset($res["code"])){
- throw new TaobaoException($res["sub_msg"]);
- }
- return $res["data"];
- }
- /**
- * 获取拉新用户订单
- * @param $activityId string 活动ID
- * @param int $page int 第几页
- */
- public static function getNewOrder($activityId, $page = 1)
- {
- $app = self::getApp();
- $params = [
- "page_no"=>$page,
- "activity_id"=>$activityId
- ];
- $res = $app->dg->getOrderNewUser($params);
- $res = json_decode(json_encode($res),true);
- if(isset($res["code"])){
- throw new TaobaoException($res["sub_msg"]);
- }
- return $res["results"];
- }
- /**
- * 获取淘口令接口
- * @param $url string 地址
- */
- public static function taokoulingCreate($url)
- {
- $app = self::getApp();
- $params = [
- "url"=>$url
- ];
- $res = $app->tpwd->create($params);
- $res = json_decode(json_encode($res),true);
- if(isset($res["code"])){
- throw new TaobaoException($res["sub_msg"]);
- }
- return $res["data"];
- }
- }
|