BaseController.php 15 KB

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