BaseController.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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\DianYing\DianYingUtil;
  13. use App\Http\Utils\Jutuike\JutuikeUtil;
  14. use App\Http\Utils\KenDeJi\KenDeJiUtil;
  15. use App\Http\Utils\McDonalds\McDonaldsUtil;
  16. use App\Http\Utils\Meituan\MeituanLianmengUtil;
  17. use App\Http\Utils\Pdd\DuoDuoKeUtil;
  18. use App\Http\Utils\TaoBao\TaobaoLianMengUtil;
  19. use App\Http\Utils\Wechat\Miniprograme\MiniprogrameLianMengUtil;
  20. use App\Http\Utils\WechatAccountUtil;
  21. use App\Models\WechatAccountModel;
  22. use Illuminate\Http\Request;
  23. use Tool\ShanTaoTool\Bean\Pdd\Ddk\ResourceUrlGenParamBean;
  24. use Tool\ShanTaoTool\Pdd\Ddk\DdkDaogouService;
  25. /**
  26. * @SWG\Swagger(
  27. * schemes={"http"},
  28. * host="test-daogou.codedreamit.com/api",
  29. * basePath="/",
  30. * @SWG\Info(
  31. * title="导购API文档",
  32. * version="1.0.0",
  33. * )
  34. * )
  35. */
  36. class BaseController extends Controller
  37. {
  38. /**
  39. * Controller constructor.
  40. */
  41. public function __construct(Request $request)
  42. {
  43. //进行统一的参数验证
  44. //判断对应目录下的验证类是否存在
  45. $controllerName = $request->route()->getActionName();
  46. $flag = preg_match("/Controllers\\\(.*)@(.*)/",$controllerName,$match);
  47. if($flag){
  48. $controllerName = $match[1];
  49. $actionName = $match[2];
  50. $class = "\\App\\Http\\Validate\\$controllerName"."Validate";
  51. //判断验证是否存在
  52. if(class_exists($class) && method_exists($class,$actionName)){
  53. $instance = new $class();
  54. $validateFlag = $instance->$actionName($request->all());
  55. if(!$validateFlag){
  56. throw new ValidateException($instance->getError(),501);
  57. }
  58. }
  59. }
  60. }
  61. /**
  62. * 成功返回
  63. * @param array $data
  64. * @param int $code
  65. * @param string $msg
  66. * @param string $url
  67. * @return \Illuminate\Http\JsonResponse
  68. */
  69. public function success($data = [], $code = 200, $msg = "", $url = "")
  70. {
  71. return response()->json(
  72. [
  73. "status"=>true,
  74. "data"=>$data,
  75. "code"=>$code,
  76. "msg"=>$msg,
  77. "url"=>$url
  78. ]
  79. );
  80. }
  81. /**
  82. * 错误返回
  83. * @param $msg
  84. * @param string $code
  85. * @param string $url
  86. */
  87. public function error($msg,$code="500",$url="")
  88. {
  89. return response()->json(
  90. [
  91. "status"=>false,
  92. "data"=>"",
  93. "code"=>$code,
  94. "msg"=>$msg,
  95. "url"=>$url
  96. ]
  97. );
  98. }
  99. /**
  100. * 生成swagger.json文件
  101. */
  102. public function swagger()
  103. {
  104. $swagger=\Swagger\scan(__DIR__."/../");
  105. $swagger->saveAs('./swagger.json');
  106. return $this->success();
  107. }
  108. /**
  109. * 读取swagger内容
  110. */
  111. public function loadSwagger()
  112. {
  113. $data = json_decode(file_get_contents("./swagger.json"),true);
  114. return $data;
  115. }
  116. public function test()
  117. {
  118. // $data = JutuikeUtil::getActList();
  119. // return $this->success($data);
  120. // $url = "0.0₤R9nsXr6r5tH₴ https://m.tb.cn/h.fWKqJYQ?sm=9652d6 2-5条 收小肚子中高腰内裤女裆收腹提臀束腰塑身三角裤";
  121. //
  122. // $res = preg_match("/https\:\/\/m\.tb\.cn/",$url,$match);
  123. // dump($res);
  124. // dd($match);
  125. // $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";
  126. // $res = preg_match("/https\:\/\/m\.vip\.com/",$url,$match);
  127. $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";
  128. // $url = "2👈啊brXxXrh98ep哈 https://m.tb.cn/h.fWqjHlK?sm=4fbca7 心相印纸巾茶语丝享抽纸家用实惠装餐巾纸面巾纸心心相印纸巾6包";
  129. // $url = "https://m-goods.kaola.com/product/1383664.html?shareOs=iOS&datid=__da_230bb323_5691a97408c33c80&klasspm=a215sy.page_kla_productpage.growthshare.copylink";
  130. dump($url);
  131. $goods = JutuikeUtil::transferGoodsLink($url);
  132. // dump($goods);
  133. dump($goods["data"]["goodsId"]);
  134. $data = JutuikeUtil::convert($goods["data"]["goodsId"],"jtkupstream21","jd");
  135. // dd($data);
  136. // return $this->success($data);
  137. // $oauthRes = DuoDuoKeUtil::memberAuthorityQuery("23985775_220421267");
  138. // if(!$oauthRes["authority_query_response"]["bind"]){
  139. // //未备案
  140. // $beanData = [
  141. // "p_id"=>"23985775_220421267",
  142. // "goods_sign_list"=>json_encode(["Y9f2liecoxFRU4gRwfDZm_tBr6P0jzj2_JKXkSmwdy"]),
  143. // ];
  144. //
  145. // $beanData["generate_authority_url"] = "true";
  146. // $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
  147. // $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
  148. // dd($res);
  149. // }else{
  150. //
  151. // }
  152. // $bean = new GoodsSearchParamBean(
  153. // []
  154. // );
  155. // $data = DuoDuoKeUtil::goodsSearch($bean);
  156. //
  157. // //获取到goods_sign
  158. // $goods_sign = $data["goods_search_response"]["goods_list"][0]["goods_sign"];
  159. // $beanData = [
  160. // "p_id"=>"23985775_220860321",
  161. // "goods_sign_list"=>json_encode([$goods_sign]),
  162. // ];
  163. //
  164. // $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
  165. // $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
  166. // return $this->success($data);
  167. // $params = [
  168. // "goodsSign"=>"134221771214"
  169. // ];
  170. // $bean = new GoodsDetailParamBean($params);
  171. // $data = DuoDuoKeUtil::goodsDetail($bean);
  172. // dd($data);
  173. // $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";
  174. // $res = preg_match("/goods_id=(.*)/",$url,$match);
  175. // if($res){
  176. // dd($match);
  177. // }
  178. // JutuikeUtil::transferGoodsLink($url);
  179. // $app = WechatAccountUtil::getApp("fanbuting");
  180. // return $this->success($app->qrcode->forever(12));
  181. // $data = JutuikeUtil::getActList();
  182. // $data = JutuikeUtil::transferAct(123,3);
  183. // $data = JutuikeUtil::getOrderList(new GetOrderListParamBean());
  184. // return $this->success($data);
  185. // $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";
  186. // $res = preg_match("/https\:\/\/mobile\.yangkeduo\.com/",$url,$match);
  187. // $data = DuoDuoKeUtil::goodsZsUnitUrlGen("23985775_219021997",$url);
  188. // dd($data);
  189. // $bean = new GetOrderSearchParamBean(
  190. // [
  191. // "startTimestamp"=>time()-20*60,
  192. // "endTimestamp"=>time()
  193. // ]
  194. // );
  195. // $data = MiniprogrameLianMengUtil::getOrderSearch($bean);
  196. // $bean = new GetProductListParamBean(
  197. // [
  198. // "from"=>0,
  199. // "limit"=>10,
  200. // "sortType"=>1
  201. // ]
  202. // );
  203. // $data = MiniprogrameLianMengUtil::getProductList($bean);
  204. // $bean = new GetProductGenerateParamBean(
  205. // [
  206. // "pid"=>"olIhv5Owrbf3EbOPjddpY8B5XR7Q_871679398",
  207. // "productList"=>[
  208. // [
  209. // "productId"=>"38133489",
  210. // "appId"=>"wxf565e2dfa175c3fa"
  211. // ]
  212. // ]
  213. // ]
  214. // );
  215. // $data = MiniprogrameLianMengUtil::getProductGenerate($bean);
  216. // $data = MiniprogrameLianMengUtil::addPromotion("测试推广位");
  217. // $data = MiniprogrameLianMengUtil::getPromotionList(0,10);
  218. // $data = DdkDaogouService::goodsPidGenerate(1);
  219. // $pdd_sid = "23985775_216467151";
  220. // $bean = new ResourceUrlGenParamBean(
  221. // [
  222. // "pid"=>$pdd_sid,
  223. // "resourceType"=>39997
  224. // ]
  225. // );
  226. // $data = DdkDaogouService::resourceUrlGen($bean);
  227. // $data = DianYingUtil::getDianYingActUrl(123);
  228. // $data =date("m月d日");
  229. // $data = TaobaoLianMengUtil::getActivityInfo("111538400047","20150318020002597");
  230. // $data = MeituanLianmengUtil::generateLink(22,"ceshi",MeiTuanLinkTypeEnum::MINIPROGRAME,env("MEITUAN_LIANMENG_KEY"));
  231. // $data = WechatAccountModel::findByWechatAppCode("fanbuting");
  232. return $data;
  233. }
  234. }