BaseController.php 15 KB

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