BaseController.php 13 KB

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