where("category_status",1) ->orderBy("category_sort_id","desc") ->get(); $userId = BaseUtil::getUserId(); $datas = []; $categoryMaps = CategoryTypeEnum::MAP; //临时组合数据 $tmps = []; foreach ($recommends as $recommend) { $recommend->link_url = env("INDEX_BASE_URL")."/api/transfer/".$userId."/".$recommend->id; $tmps[$recommend->category_type][] = $recommend; } foreach ($tmps as $key=>$tmp){ $datas[] = [ "category_type_name"=>$categoryMaps[$key], "category_data"=>$tmp ]; } return $datas; } /** * 反钱赚钱列表逻辑 */ public static function getCommissionListLogic() { $params = request()->all(); $userId = BaseUtil::getUserId(); $query = UserOrderCommissionModel::query() ->where("user_id",$userId); switch ($params["type"]){ case 0: //赚钱 $query->where("user_provider_id",0); break; case 1: //返钱 $query->where("user_provider_id","<>",0); break; } $res = $query->select( [ "order_commission", "commission_status", "commission_type", "created_at", "user_id", "user_provider_id", "user_head_img_url", "user_provider_head_img_url", "order_title", "user_nickname" ] )->orderBy("id","desc") ->paginate($params["page_size"]); return [ "total"=>$res->total(), "list"=>$res->items() ]; } /** * 根据活动和用户生成推广链接 * @param $actId 活动ID * @param $userId 用户ID */ public static function getTransferLink($actId, $userId) { $instance = new LoggerFactoryUtil(HomeLogic::class); $linkUrl = env("INDEX_BASE_URL"); $data = [ "type"=>1, "url"=>$linkUrl, "app_id"=>"", "page_path"=>"" ]; //获取活动 $act = CategoryModel::query()->find($actId); if(!$act){ return $data; } $instance->info("基础地址:".$linkUrl); try{ //获取用户 switch ($act["platform_type"]){ case 1://淘宝 $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_TAOBAO,$userId); $response = TaobaoLianMengUtil::getActivityInfo($platformSid,$act->activity_id); $res = [ "h5"=>$response["short_click_url"], ]; break; case 2://拼多多 $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_PINGDUODUO,$userId); //判断类型 switch ($act["category_name"]){ case "话费充值": $bean = new ResourceUrlGenParamBean( [ "pid"=>$platformSid, "resourceType"=>39997 ] ); $data = DuoDuoKeUtil::resourceUrlGen($bean); $linkUrl = $data["resource_url_response"]["single_url_list"]["short_url"]; break; case "火车票": $bean = new ResourceUrlGenParamBean( [ "pid"=>$platformSid, "resourceType"=>50005 ] ); $data = DuoDuoKeUtil::resourceUrlGen($bean); $linkUrl = $data["resource_url_response"]["single_url_list"]["short_url"]; break; case "百亿补贴": $bean = new ResourceUrlGenParamBean( [ "pid"=>$platformSid, "resourceType"=>39996 ] ); $data = DuoDuoKeUtil::resourceUrlGen($bean); $linkUrl = $data["resource_url_response"]["single_url_list"]["short_url"]; break; case "领券中心": $bean = new ResourceUrlGenParamBean( [ "pid"=>$platformSid, "resourceType"=>40000 ] ); $data = DuoDuoKeUtil::resourceUrlGen($bean); $linkUrl = $data["resource_url_response"]["single_url_list"]["short_url"]; break; } $res["h5"] = $linkUrl; break; // case 3://京东 // // break; case 4://美团 switch ($act["category_name"]){ case "美团外卖": $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_MEITUAN,$userId); $linkUrl = MeituanLianmengUtilV1::getMeituanWaimaiUrl($userId,$platformSid,$act["activity_id"],MeiTuanLinkTypeEnum::H5); break; case "美团闪购": $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_MEITUAN,$userId); $linkUrl = MeituanLianmengUtilV1::getMeituanWaimaiUrl($userId,$platformSid,$act["activity_id"],MeiTuanLinkTypeEnum::H5); break; case "美团优选": $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_MEITUAN,$userId); $linkUrl = MeituanLianmengUtilV1::getMeituanWaimaiUrl($userId,$platformSid,$act["activity_id"],MeiTuanLinkTypeEnum::H5); break; case "美团酒店": $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_MEITUAN,$userId); $linkUrl = MeituanLianmengUtilV1::getMeituanWaimaiUrl($userId,$platformSid,$act["activity_id"],MeiTuanLinkTypeEnum::H5); break; default: $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_JUTUIKE,$userId); $linkUrl = JutuikeUtil::transferAct($platformSid,$act["activity_id"]); break; } $res["h5"] = $linkUrl; break; // case 5://本平台 break; case 6://聚推客 $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_JUTUIKE,$userId); $res = JutuikeUtil::transferAct($platformSid,$act->activity_id); break; } switch ($act["url_type"]){ case 1://h5链接 $data = [ "type"=>1, "url"=>$res["h5"], "app_id"=>$act["app_id"]??"", "page_path"=>$res["we_app_info"]["page_path"]??"" ]; break; case 2://小程序跳转 $data = [ "type"=>2, "url"=>$res["h5"], "app_id"=>$act["app_id"]??"", "page_path"=>"/pages".$res["we_app_info"]["page_path"]??"" ]; break; } }catch (\Throwable $exception){ } // $linkUrl = $linkUrl?$linkUrl:env("INDEX_BASE_URL"); // $instance->info("回调地址:".$linkUrl); return $data; } }