BaseController.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. CronLogic::taobaoOrdersLogic();
  126. dd(1);
  127. $data = TaobaoPidModel::query()
  128. ->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"])
  129. ->groupBy("heima_sid")
  130. ->get()->toArray();
  131. $res = HeiMaUtil::getOrderList($data[0]);
  132. dd($res);
  133. // dd(TaobaoLianMengUtil::getGoodsInfo(621062906541));
  134. // $completeOrders = UserOrderCommissionModel::query()
  135. // ->where("commission_status",1)
  136. // ->where("order_commission",">",0)
  137. // ->where("user_id","<>",0)
  138. // ->where("order_complete_notify_status",0)
  139. // ->groupBy("user_id")
  140. // ->select(["user_id",DB::Raw("sum(order_commission) as total_order_commission"),DB::Raw("GROUP_CONCAT(id) as ids")])
  141. // ->get();
  142. // return $this->success($completeOrders);
  143. // return $this->success(JutuikeUtil::getActList());
  144. // TaobaoLianMengUtil::taokoulingConvert("淘宝,信这于好之他而着我而天到微喜【sheii苏茵茵】大小姐~韩国真皮粗跟中筒靴女秋弹力长靴瘦腿靴");
  145. $kouling = "38信有看么子他然是那年有去信 https://m.tb.cn/h.f8tCpoK?sm=67141d 骆驼男装 2021年新款羽绒服男短款加厚情侣款衣服冬季外套面包服";
  146. // $info = TaobaoLianMengUtil::taokoulingConvert($kouling,70362850341);
  147. // $goodsInfo = TaobaoLianMengUtil::getGoodsInfo(654351631402,70362850341);
  148. // $res = TaobaoLianMengUtil::taokoulingCreate($info["click_url"],70362850341);
  149. // $heimaData = HeiMaUtil::gaoYongZhuanLian(654351631402,70362850341);
  150. $taobaoSid = 70362850341;
  151. $info = TaobaoLianMengUtil::taokoulingConvert($kouling,$taobaoSid);
  152. $goodsInfo = TaobaoLianMengUtil::getGoodsInfo($info["num_iid"],$taobaoSid);
  153. $res = TaobaoLianMengUtil::taokoulingCreate($info["click_url"],$taobaoSid);
  154. $heimaData = HeiMaUtil::gaoYongZhuanLian($info["num_iid"],$taobaoSid);
  155. $goodsTitle = $goodsInfo["title"];
  156. $goodsPrice = $goodsInfo["zk_final_price"];
  157. $couponInfo = $heimaData["coupon_info"]??"";
  158. $couponPrice = 0;
  159. if (preg_match("/满\d*元减(\d*)元/",$couponInfo,$match)){
  160. $couponPrice = $match[1];
  161. }
  162. $afterCouponPrice = $goodsPrice-$couponPrice;
  163. $rebeatPrice = round($goodsInfo["zk_final_price"]*$heimaData["max_commission_rate"]/100*0.7,2);
  164. $url = $res["model"];
  165. //获取淘口令
  166. $msg = <<<S
  167. 【 $goodsTitle 】
  168. 【原价】:$goodsPrice 元
  169. 【优惠券】:$couponPrice 元
  170. 【券后价】:$afterCouponPrice 元
  171. 【返现金额】:$rebeatPrice 元
  172. -------------------------
  173. 复制这条信息:$url
  174. 打开【手机淘宝】即可查看
  175. 具体返现金额,以实际支付金额为准
  176. -------------------------
  177. 进入公众号=>我的=>钱包,可以1:1提现哦
  178. S;
  179. dd($msg);
  180. dump($heimaData);
  181. dump($res);
  182. dump($goodsInfo);
  183. dd($info);
  184. $res = HeiMaUtil::gaoYongZhuanLian(621062906541);
  185. // $res = TaobaoLianMengUtil::taokoulingConvert("49嘻学上时说他然上在家去了! https://m.tb.cn/h.fjEHoGt?sm=d75195 超大浴巾成人男女学生宿舍比纯棉全棉吸水速干洗澡可穿毛巾裹巾夏");
  186. dd($res);
  187. // $data = JutuikeUtil::goodsCategory("jd");
  188. // return $this->success($data);
  189. // $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";
  190. // $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";
  191. // $tmp = BaseUtil::getParamsByUrl($url);
  192. // $url = $tmp["url"]."?goods_id=".$tmp["goods_id"];
  193. //获取商品详情
  194. // $bean = new GoodsSearchParamBean(
  195. // [
  196. // "keyword"=>$url,
  197. // "pid"=>"23985775_220421267"
  198. // ]
  199. // );
  200. // dump($url);
  201. // $goodsData = DuoDuoKeUtil::goodsSearch($bean);
  202. // dd($goodsData);
  203. //
  204. // $url = "https://mobile.yangkeduo.com/goods.html?goods_id=276748200008";
  205. // $data = DuoDuoKeUtil::goodsZsUnitUrlGen("23985775_220421267",$url);
  206. // dd($data);
  207. // $app = WechatAccountUtil::getApp("fanbuting");
  208. // $msg = new Image(env("WECHAT_IMAGE_MEDIA_ID"));
  209. // $res = $app->customer_service->message($msg)->to("odg3c6jmqrrstlPH93KFC40dMtXs")->send();
  210. // dd($res);
  211. // $app = WechatAccountUtil::getApp("fanbuting");
  212. // $result = $app->material->uploadImage("1.png");
  213. // dd($result);
  214. // $data = JutuikeUtil::getActList();
  215. // return $this->success($data);
  216. // $url = "0.0₤R9nsXr6r5tH₴ https://m.tb.cn/h.fWKqJYQ?sm=9652d6 2-5条 收小肚子中高腰内裤女裆收腹提臀束腰塑身三角裤";
  217. //
  218. // $res = preg_match("/https\:\/\/m\.tb\.cn/",$url,$match);
  219. // dump($res);
  220. // dd($match);
  221. // $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";
  222. // $res = preg_match("/https\:\/\/m\.vip\.com/",$url,$match);
  223. // $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";
  224. // $url = "2👈啊brXxXrh98ep哈 https://m.tb.cn/h.fWqjHlK?sm=4fbca7 心相印纸巾茶语丝享抽纸家用实惠装餐巾纸面巾纸心心相印纸巾6包";
  225. // $url = "https://m-goods.kaola.com/product/1383664.html?shareOs=iOS&datid=__da_230bb323_5691a97408c33c80&klasspm=a215sy.page_kla_productpage.growthshare.copylink";
  226. // dump($url);
  227. // $url = "https://m.tb.cn/h.f6WeDYQ?sm=978306 ";
  228. // $goods = JutuikeUtil::transferGoodsLink($url);
  229. // dump($goods);
  230. // dump($goods["goodsId"]);
  231. // $data = JutuikeUtil::convert($goods["goodsId"],"jtkupstream21");
  232. $data = JutuikeUtil::convert("551557489590","jtkupstream21");
  233. dd($data);
  234. // return $this->success($data);
  235. // $oauthRes = DuoDuoKeUtil::memberAuthorityQuery("23985775_220421267");
  236. // if(!$oauthRes["authority_query_response"]["bind"]){
  237. // //未备案
  238. // $beanData = [
  239. // "p_id"=>"23985775_220421267",
  240. // "goods_sign_list"=>json_encode(["Y9f2liecoxFRU4gRwfDZm_tBr6P0jzj2_JKXkSmwdy"]),
  241. // ];
  242. //
  243. // $beanData["generate_authority_url"] = "true";
  244. // $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
  245. // $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
  246. // dd($res);
  247. // }else{
  248. //
  249. // }
  250. // $bean = new GoodsSearchParamBean(
  251. // []
  252. // );
  253. // $data = DuoDuoKeUtil::goodsSearch($bean);
  254. //
  255. // //获取到goods_sign
  256. // $goods_sign = $data["goods_search_response"]["goods_list"][0]["goods_sign"];
  257. // $beanData = [
  258. // "p_id"=>"23985775_220860321",
  259. // "goods_sign_list"=>json_encode([$goods_sign]),
  260. // ];
  261. //
  262. // $generateBean = new GoodsPromotionUrlGenerateParamBean($beanData);
  263. // $res = DuoDuoKeUtil::goodsPromotionUrlGenerate($generateBean);
  264. // return $this->success($data);
  265. // $params = [
  266. // "goodsSign"=>"134221771214"
  267. // ];
  268. // $bean = new GoodsDetailParamBean($params);
  269. // $data = DuoDuoKeUtil::goodsDetail($bean);
  270. // dd($data);
  271. // $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";
  272. // $res = preg_match("/goods_id=(.*)/",$url,$match);
  273. // if($res){
  274. // dd($match);
  275. // }
  276. // JutuikeUtil::transferGoodsLink($url);
  277. // $app = WechatAccountUtil::getApp("fanbuting");
  278. // return $this->success($app->qrcode->forever(12));
  279. // $data = JutuikeUtil::getActList();
  280. // $data = JutuikeUtil::transferAct(123,3);
  281. // $data = JutuikeUtil::getOrderList(new GetOrderListParamBean());
  282. // return $this->success($data);
  283. // $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";
  284. // $res = preg_match("/https\:\/\/mobile\.yangkeduo\.com/",$url,$match);
  285. // $data = DuoDuoKeUtil::goodsZsUnitUrlGen("23985775_219021997",$url);
  286. // dd($data);
  287. // $bean = new GetOrderSearchParamBean(
  288. // [
  289. // "startTimestamp"=>time()-20*60,
  290. // "endTimestamp"=>time()
  291. // ]
  292. // );
  293. // $data = MiniprogrameLianMengUtil::getOrderSearch($bean);
  294. // $bean = new GetProductListParamBean(
  295. // [
  296. // "from"=>0,
  297. // "limit"=>10,
  298. // "sortType"=>1
  299. // ]
  300. // );
  301. // $data = MiniprogrameLianMengUtil::getProductList($bean);
  302. // $bean = new GetProductGenerateParamBean(
  303. // [
  304. // "pid"=>"olIhv5Owrbf3EbOPjddpY8B5XR7Q_871679398",
  305. // "productList"=>[
  306. // [
  307. // "productId"=>"38133489",
  308. // "appId"=>"wxf565e2dfa175c3fa"
  309. // ]
  310. // ]
  311. // ]
  312. // );
  313. // $data = MiniprogrameLianMengUtil::getProductGenerate($bean);
  314. // $data = MiniprogrameLianMengUtil::addPromotion("测试推广位");
  315. // $data = MiniprogrameLianMengUtil::getPromotionList(0,10);
  316. // $data = DdkDaogouService::goodsPidGenerate(1);
  317. // $pdd_sid = "23985775_216467151";
  318. // $bean = new ResourceUrlGenParamBean(
  319. // [
  320. // "pid"=>$pdd_sid,
  321. // "resourceType"=>39997
  322. // ]
  323. // );
  324. // $data = DdkDaogouService::resourceUrlGen($bean);
  325. // $data = DianYingUtil::getDianYingActUrl(123);
  326. // $data =date("m月d日");
  327. // $data = TaobaoLianMengUtil::getActivityInfo("111538400047","20150318020002597");
  328. // $data = MeituanLianmengUtil::generateLink(22,"ceshi",MeiTuanLinkTypeEnum::MINIPROGRAME,env("MEITUAN_LIANMENG_KEY"));
  329. // $data = WechatAccountModel::findByWechatAppCode("fanbuting");
  330. return $data;
  331. }
  332. }