BaseController.php 16 KB

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