BaseController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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\HeiMaUtil;
  15. use App\Http\Utils\Jutuike\JutuikeUtil;
  16. use App\Http\Utils\KenDeJi\KenDeJiUtil;
  17. use App\Http\Utils\McDonalds\McDonaldsUtil;
  18. use App\Http\Utils\Meituan\MeituanLianmengUtil;
  19. use App\Http\Utils\Pdd\DuoDuoKeUtil;
  20. use App\Http\Utils\TaoBao\TaobaoLianMengUtil;
  21. use App\Http\Utils\Wechat\Miniprograme\MiniprogrameLianMengUtil;
  22. use App\Http\Utils\WechatAccountUtil;
  23. use App\Models\UserOrderCommissionModel;
  24. use App\Models\WechatAccountModel;
  25. use EasyWeChat\Kernel\Messages\Image;
  26. use Illuminate\Http\Request;
  27. use Illuminate\Support\Facades\DB;
  28. use Tool\ShanTaoTool\Bean\Pdd\Ddk\ResourceUrlGenParamBean;
  29. use Tool\ShanTaoTool\Pdd\Ddk\DdkDaogouService;
  30. /**
  31. * @SWG\Swagger(
  32. * schemes={"http"},
  33. * host="test-daogou.codedreamit.com/api",
  34. * basePath="/",
  35. * @SWG\Info(
  36. * title="导购API文档",
  37. * version="1.0.0",
  38. * )
  39. * )
  40. */
  41. class BaseController extends Controller
  42. {
  43. /**
  44. * Controller constructor.
  45. */
  46. public function __construct(Request $request)
  47. {
  48. //进行统一的参数验证
  49. //判断对应目录下的验证类是否存在
  50. $controllerName = $request->route()->getActionName();
  51. $flag = preg_match("/Controllers\\\(.*)@(.*)/",$controllerName,$match);
  52. if($flag){
  53. $controllerName = $match[1];
  54. $actionName = $match[2];
  55. $class = "\\App\\Http\\Validate\\$controllerName"."Validate";
  56. //判断验证是否存在
  57. if(class_exists($class) && method_exists($class,$actionName)){
  58. $instance = new $class();
  59. $validateFlag = $instance->$actionName($request->all());
  60. if(!$validateFlag){
  61. throw new ValidateException($instance->getError(),501);
  62. }
  63. }
  64. }
  65. }
  66. /**
  67. * 成功返回
  68. * @param array $data
  69. * @param int $code
  70. * @param string $msg
  71. * @param string $url
  72. * @return \Illuminate\Http\JsonResponse
  73. */
  74. public function success($data = [], $code = 200, $msg = "", $url = "")
  75. {
  76. return response()->json(
  77. [
  78. "status"=>true,
  79. "data"=>$data,
  80. "code"=>$code,
  81. "msg"=>$msg,
  82. "url"=>$url
  83. ]
  84. );
  85. }
  86. /**
  87. * 错误返回
  88. * @param $msg
  89. * @param string $code
  90. * @param string $url
  91. */
  92. public function error($msg,$code="500",$url="")
  93. {
  94. return response()->json(
  95. [
  96. "status"=>false,
  97. "data"=>"",
  98. "code"=>$code,
  99. "msg"=>$msg,
  100. "url"=>$url
  101. ]
  102. );
  103. }
  104. /**
  105. * 生成swagger.json文件
  106. */
  107. public function swagger()
  108. {
  109. $swagger=\Swagger\scan(__DIR__."/../");
  110. $swagger->saveAs('./swagger.json');
  111. return $this->success();
  112. }
  113. /**
  114. * 读取swagger内容
  115. */
  116. public function loadSwagger()
  117. {
  118. $data = json_decode(file_get_contents("./swagger.json"),true);
  119. return $data;
  120. }
  121. public function test()
  122. {
  123. // dd(TaobaoLianMengUtil::getGoodsInfo(621062906541));
  124. // $completeOrders = UserOrderCommissionModel::query()
  125. // ->where("commission_status",1)
  126. // ->where("order_commission",">",0)
  127. // ->where("user_id","<>",0)
  128. // ->where("order_complete_notify_status",0)
  129. // ->groupBy("user_id")
  130. // ->select(["user_id",DB::Raw("sum(order_commission) as total_order_commission"),DB::Raw("GROUP_CONCAT(id) as ids")])
  131. // ->get();
  132. // return $this->success($completeOrders);
  133. // return $this->success(JutuikeUtil::getActList());
  134. // TaobaoLianMengUtil::taokoulingConvert("淘宝,信这于好之他而着我而天到微喜【sheii苏茵茵】大小姐~韩国真皮粗跟中筒靴女秋弹力长靴瘦腿靴");
  135. $res = HeiMaUtil::gaoYongZhuanLian(621062906541);
  136. // $res = TaobaoLianMengUtil::taokoulingConvert("49嘻学上时说他然上在家去了! https://m.tb.cn/h.fjEHoGt?sm=d75195 超大浴巾成人男女学生宿舍比纯棉全棉吸水速干洗澡可穿毛巾裹巾夏");
  137. dd($res);
  138. // $data = JutuikeUtil::goodsCategory("jd");
  139. // return $this->success($data);
  140. // $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";
  141. // $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";
  142. // $tmp = BaseUtil::getParamsByUrl($url);
  143. // $url = $tmp["url"]."?goods_id=".$tmp["goods_id"];
  144. //获取商品详情
  145. // $bean = new GoodsSearchParamBean(
  146. // [
  147. // "keyword"=>$url,
  148. // "pid"=>"23985775_220421267"
  149. // ]
  150. // );
  151. // dump($url);
  152. // $goodsData = DuoDuoKeUtil::goodsSearch($bean);
  153. // dd($goodsData);
  154. //
  155. // $url = "https://mobile.yangkeduo.com/goods.html?goods_id=276748200008";
  156. // $data = DuoDuoKeUtil::goodsZsUnitUrlGen("23985775_220421267",$url);
  157. // dd($data);
  158. // $app = WechatAccountUtil::getApp("fanbuting");
  159. // $msg = new Image(env("WECHAT_IMAGE_MEDIA_ID"));
  160. // $res = $app->customer_service->message($msg)->to("odg3c6jmqrrstlPH93KFC40dMtXs")->send();
  161. // dd($res);
  162. // $app = WechatAccountUtil::getApp("fanbuting");
  163. // $result = $app->material->uploadImage("1.png");
  164. // dd($result);
  165. // $data = JutuikeUtil::getActList();
  166. // return $this->success($data);
  167. // $url = "0.0₤R9nsXr6r5tH₴ https://m.tb.cn/h.fWKqJYQ?sm=9652d6 2-5条 收小肚子中高腰内裤女裆收腹提臀束腰塑身三角裤";
  168. //
  169. // $res = preg_match("/https\:\/\/m\.tb\.cn/",$url,$match);
  170. // dump($res);
  171. // dd($match);
  172. // $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";
  173. // $res = preg_match("/https\:\/\/m\.vip\.com/",$url,$match);
  174. // $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";
  175. // $url = "2👈啊brXxXrh98ep哈 https://m.tb.cn/h.fWqjHlK?sm=4fbca7 心相印纸巾茶语丝享抽纸家用实惠装餐巾纸面巾纸心心相印纸巾6包";
  176. // $url = "https://m-goods.kaola.com/product/1383664.html?shareOs=iOS&datid=__da_230bb323_5691a97408c33c80&klasspm=a215sy.page_kla_productpage.growthshare.copylink";
  177. // dump($url);
  178. // $url = "https://m.tb.cn/h.f6WeDYQ?sm=978306 ";
  179. // $goods = JutuikeUtil::transferGoodsLink($url);
  180. // dump($goods);
  181. // dump($goods["goodsId"]);
  182. // $data = JutuikeUtil::convert($goods["goodsId"],"jtkupstream21");
  183. $data = JutuikeUtil::convert("551557489590","jtkupstream21");
  184. dd($data);
  185. // return $this->success($data);
  186. // $oauthRes = DuoDuoKeUtil::memberAuthorityQuery("23985775_220421267");
  187. // if(!$oauthRes["authority_query_response"]["bind"]){
  188. // //未备案
  189. // $beanData = [
  190. // "p_id"=>"23985775_220421267",
  191. // "goods_sign_list"=>json_encode(["Y9f2liecoxFRU4gRwfDZm_tBr6P0jzj2_JKXkSmwdy"]),
  192. // ];
  193. //
  194. // $beanData["generate_authority_url"] = "true";
  195. // $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
  196. // $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
  197. // dd($res);
  198. // }else{
  199. //
  200. // }
  201. // $bean = new GoodsSearchParamBean(
  202. // []
  203. // );
  204. // $data = DuoDuoKeUtil::goodsSearch($bean);
  205. //
  206. // //获取到goods_sign
  207. // $goods_sign = $data["goods_search_response"]["goods_list"][0]["goods_sign"];
  208. // $beanData = [
  209. // "p_id"=>"23985775_220860321",
  210. // "goods_sign_list"=>json_encode([$goods_sign]),
  211. // ];
  212. //
  213. // $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
  214. // $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
  215. // return $this->success($data);
  216. // $params = [
  217. // "goodsSign"=>"134221771214"
  218. // ];
  219. // $bean = new GoodsDetailParamBean($params);
  220. // $data = DuoDuoKeUtil::goodsDetail($bean);
  221. // dd($data);
  222. // $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";
  223. // $res = preg_match("/goods_id=(.*)/",$url,$match);
  224. // if($res){
  225. // dd($match);
  226. // }
  227. // JutuikeUtil::transferGoodsLink($url);
  228. // $app = WechatAccountUtil::getApp("fanbuting");
  229. // return $this->success($app->qrcode->forever(12));
  230. // $data = JutuikeUtil::getActList();
  231. // $data = JutuikeUtil::transferAct(123,3);
  232. // $data = JutuikeUtil::getOrderList(new GetOrderListParamBean());
  233. // return $this->success($data);
  234. // $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";
  235. // $res = preg_match("/https\:\/\/mobile\.yangkeduo\.com/",$url,$match);
  236. // $data = DuoDuoKeUtil::goodsZsUnitUrlGen("23985775_219021997",$url);
  237. // dd($data);
  238. // $bean = new GetOrderSearchParamBean(
  239. // [
  240. // "startTimestamp"=>time()-20*60,
  241. // "endTimestamp"=>time()
  242. // ]
  243. // );
  244. // $data = MiniprogrameLianMengUtil::getOrderSearch($bean);
  245. // $bean = new GetProductListParamBean(
  246. // [
  247. // "from"=>0,
  248. // "limit"=>10,
  249. // "sortType"=>1
  250. // ]
  251. // );
  252. // $data = MiniprogrameLianMengUtil::getProductList($bean);
  253. // $bean = new GetProductGenerateParamBean(
  254. // [
  255. // "pid"=>"olIhv5Owrbf3EbOPjddpY8B5XR7Q_871679398",
  256. // "productList"=>[
  257. // [
  258. // "productId"=>"38133489",
  259. // "appId"=>"wxf565e2dfa175c3fa"
  260. // ]
  261. // ]
  262. // ]
  263. // );
  264. // $data = MiniprogrameLianMengUtil::getProductGenerate($bean);
  265. // $data = MiniprogrameLianMengUtil::addPromotion("测试推广位");
  266. // $data = MiniprogrameLianMengUtil::getPromotionList(0,10);
  267. // $data = DdkDaogouService::goodsPidGenerate(1);
  268. // $pdd_sid = "23985775_216467151";
  269. // $bean = new ResourceUrlGenParamBean(
  270. // [
  271. // "pid"=>$pdd_sid,
  272. // "resourceType"=>39997
  273. // ]
  274. // );
  275. // $data = DdkDaogouService::resourceUrlGen($bean);
  276. // $data = DianYingUtil::getDianYingActUrl(123);
  277. // $data =date("m月d日");
  278. // $data = TaobaoLianMengUtil::getActivityInfo("111538400047","20150318020002597");
  279. // $data = MeituanLianmengUtil::generateLink(22,"ceshi",MeiTuanLinkTypeEnum::MINIPROGRAME,env("MEITUAN_LIANMENG_KEY"));
  280. // $data = WechatAccountModel::findByWechatAppCode("fanbuting");
  281. return $data;
  282. }
  283. }