PddLogic.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. namespace App\Http\Logic\Pdd;
  3. use App\Http\Bean\Util\Pdd\Ddk\GoodsPromotionUrlGenerateParamBean;
  4. use App\Http\Bean\Util\Pdd\Ddk\GoodsRecommendGetParamBean;
  5. use App\Http\Enum\PlatformTypeEnum;
  6. use App\Http\Logic\BaseLogic;
  7. use App\Http\Utils\BaseUtil;
  8. use App\Http\Utils\Pdd\DuoDuoKeUtil;
  9. class PddLogic extends BaseLogic
  10. {
  11. /**
  12. * pdd类目
  13. */
  14. public static function getCateListLogic()
  15. {
  16. return [
  17. "cate"=>[
  18. [
  19. "id"=>20100,
  20. "name"=>"百货"
  21. ],
  22. [
  23. "id"=>20200,
  24. "name"=>"母婴"
  25. ],
  26. [
  27. "id"=>20300,
  28. "name"=>"食品"
  29. ],
  30. [
  31. "id"=>20400,
  32. "name"=>"女装"
  33. ],
  34. [
  35. "id"=>20500,
  36. "name"=>"电器"
  37. ],
  38. [
  39. "id"=>20600,
  40. "name"=>"鞋包"
  41. ],
  42. [
  43. "id"=>20700,
  44. "name"=>"内衣"
  45. ],
  46. [
  47. "id"=>20800,
  48. "name"=>"美妆"
  49. ],
  50. [
  51. "id"=>20900,
  52. "name"=>"男装"
  53. ],
  54. [
  55. "id"=>21000,
  56. "name"=>"水果"
  57. ],
  58. [
  59. "id"=>21100,
  60. "name"=>"家纺"
  61. ],
  62. [
  63. "id"=>21200,
  64. "name"=>"文具"
  65. ],
  66. [
  67. "id"=>21300,
  68. "name"=>"运动"
  69. ],
  70. [
  71. "id"=>21400,
  72. "name"=>"虚拟"
  73. ],
  74. [
  75. "id"=>21500,
  76. "name"=>"汽车"
  77. ],
  78. [
  79. "id"=>21600,
  80. "name"=>"家装"
  81. ],
  82. [
  83. "id"=>21700,
  84. "name"=>"家具"
  85. ],
  86. [
  87. "id"=>21800,
  88. "name"=>"医药"
  89. ],
  90. ],
  91. "activity"=>[
  92. [
  93. "id"=>4,
  94. "name"=>"秒杀"
  95. ],
  96. [
  97. "id"=>7,
  98. "name"=>"百亿补贴"
  99. ],
  100. [
  101. "id"=>10851,
  102. "name"=>"千万补贴"
  103. ],
  104. [
  105. "id"=>10913,
  106. "name"=>"招商礼金商品"
  107. ],
  108. [
  109. "id"=>31,
  110. "name"=>"品牌黑标"
  111. ],
  112. [
  113. "id"=>10564,
  114. "name"=>"精选爆品-官方直推爆款"
  115. ],
  116. [
  117. "id"=>10584,
  118. "name"=>"精选爆品-团长推荐"
  119. ],
  120. [
  121. "id"=>24,
  122. "name"=>"品牌高佣"
  123. ],
  124. ],
  125. "channel"=>[
  126. [
  127. "id"=>1,
  128. "name"=>"今日销量榜"
  129. ],
  130. [
  131. "id"=>3,
  132. "name"=>"相似商品推荐"
  133. ],
  134. [
  135. "id"=>4,
  136. "name"=>"猜你喜欢"
  137. ],
  138. [
  139. "id"=>5,
  140. "name"=>"实时热销榜"
  141. ],
  142. [
  143. "id"=>6,
  144. "name"=>"实时收益榜"
  145. ]
  146. ]
  147. ];
  148. }
  149. /**
  150. * 商品列表逻辑
  151. */
  152. public static function getGoodsListLogic()
  153. {
  154. $params = request()->all();
  155. $userId = BaseUtil::getUserId();
  156. $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_PINGDUODUO,$userId);
  157. $beanData = [
  158. "pid"=>$platformSid,
  159. "offset"=>($params["page"]-1)*20
  160. ];
  161. //判断活动
  162. if(isset($params["activity_id"])){
  163. $beanData["activity_tags"] = json_encode([
  164. $params["activity_id"]
  165. ]);
  166. }
  167. //判断类目
  168. if(isset($params["cate_id"])){
  169. $beanData["cate_id"] = $params["cate_id"];
  170. }
  171. //判断频道
  172. if(isset($params["channel_id"])){
  173. $beanData["channel_type"] = $params["channel_type"];
  174. }
  175. $bean = new GoodsRecommendGetParamBean($beanData);
  176. $goods = DuoDuoKeUtil::goodsRecommendGet($bean);
  177. $datas = $goods["goods_basic_detail_response"]["list"];
  178. return [
  179. "total"=>$goods["goods_basic_detail_response"]["total"],
  180. "list"=>$datas
  181. ];
  182. }
  183. /**
  184. * 商品推广链接逻辑
  185. */
  186. public static function getGoodsRecommendUrlLogic()
  187. {
  188. $params = request()->all();
  189. $userId = BaseUtil::getUserId();
  190. $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_PINGDUODUO,$userId);
  191. //1.判断推广位是否备案
  192. $oauthRes = DuoDuoKeUtil::memberAuthorityQuery($platformSid);
  193. //2.未备案这授权,已备案则直接获取推广链接
  194. $beanData = [
  195. "p_id"=>$platformSid,
  196. "goods_sign_list"=>json_encode([$params["goods_sign"]]),
  197. ];
  198. if($oauthRes["authority_query_response"]["bind"]){
  199. //已备案
  200. }else{
  201. //未备案
  202. $beanData["generate_authority_url"] = "true";
  203. }
  204. $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
  205. $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
  206. return [
  207. "link_url"=>$res["goods_promotion_url_generate_response"]["goods_promotion_url_list"][0]["mobile_short_url"]
  208. ];
  209. }
  210. }