123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <?php
- namespace App\Http\Logic\Pdd;
- use App\Http\Bean\Util\Pdd\Ddk\GoodsPromotionUrlGenerateParamBean;
- use App\Http\Bean\Util\Pdd\Ddk\GoodsRecommendGetParamBean;
- use App\Http\Enum\PlatformTypeEnum;
- use App\Http\Logic\BaseLogic;
- use App\Http\Utils\BaseUtil;
- use App\Http\Utils\Pdd\DuoDuoKeUtil;
- class PddLogic extends BaseLogic
- {
- /**
- * pdd类目
- */
- public static function getCateListLogic()
- {
- return [
- "cate"=>[
- [
- "id"=>20100,
- "name"=>"百货"
- ],
- [
- "id"=>20200,
- "name"=>"母婴"
- ],
- [
- "id"=>20300,
- "name"=>"食品"
- ],
- [
- "id"=>20400,
- "name"=>"女装"
- ],
- [
- "id"=>20500,
- "name"=>"电器"
- ],
- [
- "id"=>20600,
- "name"=>"鞋包"
- ],
- [
- "id"=>20700,
- "name"=>"内衣"
- ],
- [
- "id"=>20800,
- "name"=>"美妆"
- ],
- [
- "id"=>20900,
- "name"=>"男装"
- ],
- [
- "id"=>21000,
- "name"=>"水果"
- ],
- [
- "id"=>21100,
- "name"=>"家纺"
- ],
- [
- "id"=>21200,
- "name"=>"文具"
- ],
- [
- "id"=>21300,
- "name"=>"运动"
- ],
- [
- "id"=>21400,
- "name"=>"虚拟"
- ],
- [
- "id"=>21500,
- "name"=>"汽车"
- ],
- [
- "id"=>21600,
- "name"=>"家装"
- ],
- [
- "id"=>21700,
- "name"=>"家具"
- ],
- [
- "id"=>21800,
- "name"=>"医药"
- ],
- ],
- "activity"=>[
- [
- "id"=>4,
- "name"=>"秒杀"
- ],
- [
- "id"=>7,
- "name"=>"百亿补贴"
- ],
- [
- "id"=>10851,
- "name"=>"千万补贴"
- ],
- [
- "id"=>10913,
- "name"=>"招商礼金商品"
- ],
- [
- "id"=>31,
- "name"=>"品牌黑标"
- ],
- [
- "id"=>10564,
- "name"=>"精选爆品-官方直推爆款"
- ],
- [
- "id"=>10584,
- "name"=>"精选爆品-团长推荐"
- ],
- [
- "id"=>24,
- "name"=>"品牌高佣"
- ],
- ],
- "channel"=>[
- [
- "id"=>1,
- "name"=>"今日销量榜"
- ],
- [
- "id"=>3,
- "name"=>"相似商品推荐"
- ],
- [
- "id"=>4,
- "name"=>"猜你喜欢"
- ],
- [
- "id"=>5,
- "name"=>"实时热销榜"
- ],
- [
- "id"=>6,
- "name"=>"实时收益榜"
- ]
- ]
- ];
- }
- /**
- * 商品列表逻辑
- */
- public static function getGoodsListLogic()
- {
- $params = request()->all();
- $userId = BaseUtil::getUserId();
- $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_PINGDUODUO,$userId);
- $beanData = [
- "pid"=>$platformSid,
- "offset"=>($params["page"]-1)*20
- ];
- //判断活动
- if(isset($params["activity_id"])){
- $beanData["activity_tags"] = json_encode([
- $params["activity_id"]
- ]);
- }
- //判断类目
- if(isset($params["cate_id"])){
- $beanData["cate_id"] = $params["cate_id"];
- }
- //判断频道
- if(isset($params["channel_id"])){
- $beanData["channel_type"] = $params["channel_type"];
- }
- $bean = new GoodsRecommendGetParamBean($beanData);
- $goods = DuoDuoKeUtil::goodsRecommendGet($bean);
- $datas = $goods["goods_basic_detail_response"]["list"];
- return [
- "total"=>$goods["goods_basic_detail_response"]["total"],
- "list"=>$datas
- ];
- }
- /**
- * 商品推广链接逻辑
- */
- public static function getGoodsRecommendUrlLogic()
- {
- $params = request()->all();
- $userId = BaseUtil::getUserId();
- $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_PINGDUODUO,$userId);
- //1.判断推广位是否备案
- $oauthRes = DuoDuoKeUtil::memberAuthorityQuery($platformSid);
- //2.未备案这授权,已备案则直接获取推广链接
- $beanData = [
- "p_id"=>$platformSid,
- "goods_sign_list"=>json_encode([$params["goods_sign"]]),
- ];
- if($oauthRes["authority_query_response"]["bind"]){
- //已备案
- }else{
- //未备案
- $beanData["generate_authority_url"] = "true";
- }
- $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
- $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
- return [
- "link_url"=>$res["goods_promotion_url_generate_response"]["goods_promotion_url_list"][0]["mobile_short_url"]
- ];
- }
- }
|