BaseController.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Exceptions\ValidateException;
  4. use App\Http\Bean\Util\Jutuike\GetOrderListParamBean;
  5. use App\Http\Bean\Util\Pdd\Ddk\GoodsDetailParamBean;
  6. use App\Http\Bean\Util\Pdd\Ddk\GoodsPromotionUrlGenerateParamBean;
  7. use App\Http\Bean\Util\Pdd\Ddk\GoodsSearchParamBean;
  8. use App\Http\Bean\Util\Wechat\Miniprograme\GetOrderSearchParamBean;
  9. use App\Http\Bean\Util\Wechat\Miniprograme\GetProductGenerateParamBean;
  10. use App\Http\Bean\Util\Wechat\Miniprograme\GetProductListParamBean;
  11. use App\Http\Enum\MeiTuanLinkTypeEnum;
  12. use App\Http\Utils\BaseUtil;
  13. use App\Http\Utils\DianYing\DianYingUtil;
  14. use App\Http\Utils\Jutuike\JutuikeUtil;
  15. use App\Http\Utils\KenDeJi\KenDeJiUtil;
  16. use App\Http\Utils\McDonalds\McDonaldsUtil;
  17. use App\Http\Utils\Meituan\MeituanLianmengUtil;
  18. use App\Http\Utils\Pdd\DuoDuoKeUtil;
  19. use App\Http\Utils\TaoBao\TaobaoLianMengUtil;
  20. use App\Http\Utils\Wechat\Miniprograme\MiniprogrameLianMengUtil;
  21. use App\Http\Utils\WechatAccountUtil;
  22. use App\Models\WechatAccountModel;
  23. use EasyWeChat\Kernel\Messages\Image;
  24. use Illuminate\Http\Request;
  25. use Tool\ShanTaoTool\Bean\Pdd\Ddk\ResourceUrlGenParamBean;
  26. use Tool\ShanTaoTool\Pdd\Ddk\DdkDaogouService;
  27. /**
  28. * @SWG\Swagger(
  29. * schemes={"http"},
  30. * host="test-daogou.codedreamit.com/api",
  31. * basePath="/",
  32. * @SWG\Info(
  33. * title="导购API文档",
  34. * version="1.0.0",
  35. * )
  36. * )
  37. */
  38. class BaseController extends Controller
  39. {
  40. /**
  41. * Controller constructor.
  42. */
  43. public function __construct(Request $request)
  44. {
  45. //进行统一的参数验证
  46. //判断对应目录下的验证类是否存在
  47. $controllerName = $request->route()->getActionName();
  48. $flag = preg_match("/Controllers\\\(.*)@(.*)/",$controllerName,$match);
  49. if($flag){
  50. $controllerName = $match[1];
  51. $actionName = $match[2];
  52. $class = "\\App\\Http\\Validate\\$controllerName"."Validate";
  53. //判断验证是否存在
  54. if(class_exists($class) && method_exists($class,$actionName)){
  55. $instance = new $class();
  56. $validateFlag = $instance->$actionName($request->all());
  57. if(!$validateFlag){
  58. throw new ValidateException($instance->getError(),501);
  59. }
  60. }
  61. }
  62. }
  63. /**
  64. * 成功返回
  65. * @param array $data
  66. * @param int $code
  67. * @param string $msg
  68. * @param string $url
  69. * @return \Illuminate\Http\JsonResponse
  70. */
  71. public function success($data = [], $code = 200, $msg = "", $url = "")
  72. {
  73. return response()->json(
  74. [
  75. "status"=>true,
  76. "data"=>$data,
  77. "code"=>$code,
  78. "msg"=>$msg,
  79. "url"=>$url
  80. ]
  81. );
  82. }
  83. /**
  84. * 错误返回
  85. * @param $msg
  86. * @param string $code
  87. * @param string $url
  88. */
  89. public function error($msg,$code="500",$url="")
  90. {
  91. return response()->json(
  92. [
  93. "status"=>false,
  94. "data"=>"",
  95. "code"=>$code,
  96. "msg"=>$msg,
  97. "url"=>$url
  98. ]
  99. );
  100. }
  101. /**
  102. * 生成swagger.json文件
  103. */
  104. public function swagger()
  105. {
  106. $swagger=\Swagger\scan(__DIR__."/../");
  107. $swagger->saveAs('./swagger.json');
  108. return $this->success();
  109. }
  110. /**
  111. * 读取swagger内容
  112. */
  113. public function loadSwagger()
  114. {
  115. $data = json_decode(file_get_contents("./swagger.json"),true);
  116. return $data;
  117. }
  118. public function test()
  119. {
  120. // TaobaoLianMengUtil::taokoulingConvert("淘宝,信这于好之他而着我而天到微喜【sheii苏茵茵】大小姐~韩国真皮粗跟中筒靴女秋弹力长靴瘦腿靴");
  121. TaobaoLianMengUtil::taokoulingConvert("89!就心也对他可大能们后小哈 https://m.tb.cn/h.fgXlN6a?sm=3efae5 儿童过家家小医生玩具套装仿真医疗箱女孩护士打针男孩听诊器工具");
  122. // $data = JutuikeUtil::goodsCategory("jd");
  123. // return $this->success($data);
  124. // $url = "https://mobile.yangkeduo.com/goods.html?_wvx=10&refer_share_uin=RKJBZMVHVOZWU3HQPZYUD5MAEQ_GEXDA&refer_share_uid=5985443220&share_uin=RKJBZMVHVOZWU3HQPZYUD5MAEQ_GEXDA&page_from=23&_wv=41729&refer_share_id=vJXEDkANGEc4uvPW9QgRCHPj3P6GELOc&refer_share_channel=copy_link&share_uid=5985443220&pxq_secret_key=EUEHP3OMNH3X4GQUAL37HDD7UJBLLM3OD42X55VHLGG6GT3EBPLQ&goods_id=276748200008";
  125. // $url = "https://mobile.yangkeduo.com/goods.html?_wvx=10&refer_share_uin=QKZTKYYF4LYNCB7SVBSL42IYWY_GEXDA&refer_share_uid=3669222324&share_uin=QKZTKYYF4LYNCB7SVBSL42IYWY_GEXDA&page_from=101&_wv=41729&refer_share_id=l6x0HEi8EMpQ2F9CJiCmsW1IqO5fnT3K&refer_share_channel=copy_link&share_uid=3669222324&pxq_secret_key=6T5MOY4WIDK2ALUXMKACS7QZ3CEYWBUQRZATVA5T5PDULJS3CV6A&goods_id=169921843493";
  126. // $tmp = BaseUtil::getParamsByUrl($url);
  127. // $url = $tmp["url"]."?goods_id=".$tmp["goods_id"];
  128. //获取商品详情
  129. // $bean = new GoodsSearchParamBean(
  130. // [
  131. // "keyword"=>$url,
  132. // "pid"=>"23985775_220421267"
  133. // ]
  134. // );
  135. // dump($url);
  136. // $goodsData = DuoDuoKeUtil::goodsSearch($bean);
  137. // dd($goodsData);
  138. //
  139. // $url = "https://mobile.yangkeduo.com/goods.html?goods_id=276748200008";
  140. // $data = DuoDuoKeUtil::goodsZsUnitUrlGen("23985775_220421267",$url);
  141. // dd($data);
  142. // $app = WechatAccountUtil::getApp("fanbuting");
  143. // $msg = new Image(env("WECHAT_IMAGE_MEDIA_ID"));
  144. // $res = $app->customer_service->message($msg)->to("odg3c6jmqrrstlPH93KFC40dMtXs")->send();
  145. // dd($res);
  146. // $app = WechatAccountUtil::getApp("fanbuting");
  147. // $result = $app->material->uploadImage("1.png");
  148. // dd($result);
  149. // $data = JutuikeUtil::getActList();
  150. // return $this->success($data);
  151. // $url = "0.0₤R9nsXr6r5tH₴ https://m.tb.cn/h.fWKqJYQ?sm=9652d6 2-5条 收小肚子中高腰内裤女裆收腹提臀束腰塑身三角裤";
  152. //
  153. // $res = preg_match("/https\:\/\/m\.tb\.cn/",$url,$match);
  154. // dump($res);
  155. // dd($match);
  156. // $url = "https://m.vip.com/product-1710619050-6919460940636579082.html?nmsns=shop_iphone-7.54.6-link&nst=product&nsbc=&nct=link&ncid=e65103bd61351bb17486b16b4492127425d68046&nabtid=13&nuid=&nchl_param=share:e65103bd61351bb17486b16b4492127425d68046:1632980761329&mars_cid_a=e65103bd61351bb17486b16b4492127425d68046&chl_type=share";
  157. // $res = preg_match("/https\:\/\/m\.vip\.com/",$url,$match);
  158. // $url = "https://item.m.jd.com/product/13441798.html?&utm_source=iosapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=CopyURL&ad_od=share";
  159. // $url = "2👈啊brXxXrh98ep哈 https://m.tb.cn/h.fWqjHlK?sm=4fbca7 心相印纸巾茶语丝享抽纸家用实惠装餐巾纸面巾纸心心相印纸巾6包";
  160. // $url = "https://m-goods.kaola.com/product/1383664.html?shareOs=iOS&datid=__da_230bb323_5691a97408c33c80&klasspm=a215sy.page_kla_productpage.growthshare.copylink";
  161. // dump($url);
  162. // $url = "https://m.tb.cn/h.f6WeDYQ?sm=978306 ";
  163. // $goods = JutuikeUtil::transferGoodsLink($url);
  164. // dump($goods);
  165. // dump($goods["goodsId"]);
  166. // $data = JutuikeUtil::convert($goods["goodsId"],"jtkupstream21");
  167. $data = JutuikeUtil::convert("551557489590","jtkupstream21");
  168. dd($data);
  169. // return $this->success($data);
  170. // $oauthRes = DuoDuoKeUtil::memberAuthorityQuery("23985775_220421267");
  171. // if(!$oauthRes["authority_query_response"]["bind"]){
  172. // //未备案
  173. // $beanData = [
  174. // "p_id"=>"23985775_220421267",
  175. // "goods_sign_list"=>json_encode(["Y9f2liecoxFRU4gRwfDZm_tBr6P0jzj2_JKXkSmwdy"]),
  176. // ];
  177. //
  178. // $beanData["generate_authority_url"] = "true";
  179. // $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
  180. // $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
  181. // dd($res);
  182. // }else{
  183. //
  184. // }
  185. // $bean = new GoodsSearchParamBean(
  186. // []
  187. // );
  188. // $data = DuoDuoKeUtil::goodsSearch($bean);
  189. //
  190. // //获取到goods_sign
  191. // $goods_sign = $data["goods_search_response"]["goods_list"][0]["goods_sign"];
  192. // $beanData = [
  193. // "p_id"=>"23985775_220860321",
  194. // "goods_sign_list"=>json_encode([$goods_sign]),
  195. // ];
  196. //
  197. // $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
  198. // $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
  199. // return $this->success($data);
  200. // $params = [
  201. // "goodsSign"=>"134221771214"
  202. // ];
  203. // $bean = new GoodsDetailParamBean($params);
  204. // $data = DuoDuoKeUtil::goodsDetail($bean);
  205. // dd($data);
  206. // $url="https://mobile.yangkeduo.com/goods.html?_wvx=10&refer_share_uid=3669222324&share_uin=QKZTKYYF4LYNCB7SVBSL42IYWY_GEXDA&page_from=35&_wv=41729&refer_share_channel=copy_link&refer_share_id=JH6kVhnKqN5NIuAIRfb9tmkmfyyWR8yF&share_uid=3669222324&pxq_secret_key=MQRO6DTQJ7RNUNBUJLWQXGXIUHVHKISZRWVIGNWUVQXV7P74HXDA&goods_id=134221771214";
  207. // $res = preg_match("/goods_id=(.*)/",$url,$match);
  208. // if($res){
  209. // dd($match);
  210. // }
  211. // JutuikeUtil::transferGoodsLink($url);
  212. // $app = WechatAccountUtil::getApp("fanbuting");
  213. // return $this->success($app->qrcode->forever(12));
  214. // $data = JutuikeUtil::getActList();
  215. // $data = JutuikeUtil::transferAct(123,3);
  216. // $data = JutuikeUtil::getOrderList(new GetOrderListParamBean());
  217. // return $this->success($data);
  218. // $url = "https://mobile.yangkeduo.com/goods2.html?_wvx=10&refer_share_uid=3669222324&share_uin=QKZTKYYF4LYNCB7SVBSL42IYWY_GEXDA&page_from=35&_wv=41729&refer_share_channel=copy_link&refer_share_id=ukvmmxZsICNVPodwgxOlWhD7cckCuUr4&share_uid=3669222324&pxq_secret_key=ZFW7YES6N7KIXS7XW4JZD6YGTK3VLAAPTC3RDW2BI45OMMQGCZPA&goods_id=266346895187";
  219. // $res = preg_match("/https\:\/\/mobile\.yangkeduo\.com/",$url,$match);
  220. // $data = DuoDuoKeUtil::goodsZsUnitUrlGen("23985775_219021997",$url);
  221. // dd($data);
  222. // $bean = new GetOrderSearchParamBean(
  223. // [
  224. // "startTimestamp"=>time()-20*60,
  225. // "endTimestamp"=>time()
  226. // ]
  227. // );
  228. // $data = MiniprogrameLianMengUtil::getOrderSearch($bean);
  229. // $bean = new GetProductListParamBean(
  230. // [
  231. // "from"=>0,
  232. // "limit"=>10,
  233. // "sortType"=>1
  234. // ]
  235. // );
  236. // $data = MiniprogrameLianMengUtil::getProductList($bean);
  237. // $bean = new GetProductGenerateParamBean(
  238. // [
  239. // "pid"=>"olIhv5Owrbf3EbOPjddpY8B5XR7Q_871679398",
  240. // "productList"=>[
  241. // [
  242. // "productId"=>"38133489",
  243. // "appId"=>"wxf565e2dfa175c3fa"
  244. // ]
  245. // ]
  246. // ]
  247. // );
  248. // $data = MiniprogrameLianMengUtil::getProductGenerate($bean);
  249. // $data = MiniprogrameLianMengUtil::addPromotion("测试推广位");
  250. // $data = MiniprogrameLianMengUtil::getPromotionList(0,10);
  251. // $data = DdkDaogouService::goodsPidGenerate(1);
  252. // $pdd_sid = "23985775_216467151";
  253. // $bean = new ResourceUrlGenParamBean(
  254. // [
  255. // "pid"=>$pdd_sid,
  256. // "resourceType"=>39997
  257. // ]
  258. // );
  259. // $data = DdkDaogouService::resourceUrlGen($bean);
  260. // $data = DianYingUtil::getDianYingActUrl(123);
  261. // $data =date("m月d日");
  262. // $data = TaobaoLianMengUtil::getActivityInfo("111538400047","20150318020002597");
  263. // $data = MeituanLianmengUtil::generateLink(22,"ceshi",MeiTuanLinkTypeEnum::MINIPROGRAME,env("MEITUAN_LIANMENG_KEY"));
  264. // $data = WechatAccountModel::findByWechatAppCode("fanbuting");
  265. return $data;
  266. }
  267. }