$value) { $str .= $key . $value; } $str .= $secret; $sign = md5($str); return $sign; } /** * @param $actId int 活动id,可以在联盟活动列表中查看获取 * @param $sid string 推广位ID * @param $linkType int 链接类型(1、h5链接2、deeplink(唤起)链接3、中间页唤起链接4、微信小程序唤起路径) * @param $appkey string appkey * @param $secret string appkey * @return mixed */ public static function generateLink($actId,$sid,$linkType) { $appkey = env("MEITUAN_LIANMENG_KEY"); $url = "https://openapi.meituan.com/api/generateLink"; $params = [ "actId"=>$actId, "appkey"=>$appkey, "sid"=>$sid, "linkType"=>$linkType, "sign"=>"", "shortLink"=>1//0表示获取长链,1表示获取短链 ]; $sign = self::generateSign($params); $params["sign"] = $sign; $res = HttpCurl::getCurl($url,$params); if($res["status"]!=0){ $instance = new LoggerFactoryUtil(MeituanLianmengUtilV1::class); $instance->info("美团发挥结果:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } return $res["data"]; } /** * 获取订单列表接口 * @param OrderListParamBean $orderListParamBean */ public static function orderList(OrderListParamBean $orderListParamBean) { $url = "https://openapi.meituan.com/api/orderList"; $params = [ "appkey"=>$orderListParamBean->getAppkey(), "ts"=>time(), "businessLine"=>$orderListParamBean->getType(), "sign"=>"", "startTime"=>$orderListParamBean->getStartTime(), "endTime"=>$orderListParamBean->getEndTime(), "page"=>$orderListParamBean->getPage(), "limit"=>$orderListParamBean->getLimit(), "queryTimeType"=>$orderListParamBean->getQueryTimeType() ]; $sign = self::generateSign($params); $params["sign"] = $sign; $res = HttpCurl::getCurl($url,$params); return $res; } /** * 生成小程序二维码 * @param $sid string 推广为ID * @param $actId int 活动ID */ public static function miniCode($sid,$actId) { $appkey = env("MEITUAN_LIANMENG_KEY"); $url = "https://openapi.meituan.com/api/miniCode"; $params = [ "sid"=>$sid, "actId"=>$actId, "appKey"=>$appKey, "sign"=>"" ]; $sign = self::generateSign($params); $params["sign"] = $sign; $res = HttpCurl::getCurl($url,$params); return $res; } /** * 根据订单编号获取单个订单 * @param $orderNumber string 订单编号 * @param $key string 媒体appKey * @param $type string 订单类型 */ public static function queryOrderByOrderNumber($orderNumber,$type,$acId) { $appkey = env("MEITUAN_LIANMENG_KEY"); $url = "https://openapi.meituan.com/api/order"; $params = [ "appkey"=>$appkey, "orderId"=>$orderNumber, "full"=>1, "businessLine"=>$type, "sign"=>"", "acId"=>$acId ]; $sign = self::generateSign($params); $params["sign"] = $sign; $res = HttpCurl::getCurl($url,$params); return $res; } /** * 获取美团推广链接 * @param $userId string 用户ID * @param $spreadId string 推广位 * @param $actId string 活动ID * @param $linkType string 链接类型 */ public static function getMeituanWaimaiUrl($userId, $spreadId, $actId, $linkType) { $key = "meituanUrl:".$userId."linktype:".$linkType."actid:".$actId; $val = self::getCacheFromRedis($key); $instance = new LoggerFactoryUtil(MeituanLianmengUtilV1::class); if($val){ $instance->info("从缓存中获取美团链接"); return $val; } //不存在则从官方获取 $val = self::generateLink($actId,$spreadId,$linkType); $instance->info("从接口中获取美团链接"); self::setRedisCache($key,$val,0); return $val; } }