self::getMiniLianMengAccessToken() ]; $res = HttpCurl::getCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } return $res["productCats"]; } /** * 查询全量商品 * @param GetProductListParamBean $getProductListParamBean */ public static function getProductList(GetProductListParamBean $getProductListParamBean) { $url = "https://api.weixin.qq.com/union/promoter/product/list"; $params = [ "access_token"=>self::getMiniLianMengAccessToken(), "from"=>$getProductListParamBean->getFrom(), "limit"=>$getProductListParamBean->getLimit() ]; //搜索关键词 if($getProductListParamBean->getQuery()){ $params["query"] = $getProductListParamBean->getQuery(); } //搜索类型 if($getProductListParamBean->getQueryType()){ $params["queryType"] = $getProductListParamBean->getQueryType(); } //商品最高价格 if($getProductListParamBean->getMaxPrice()){ $params["maxPrice"] = $getProductListParamBean->getMaxPrice(); } //商品最低价格 if($getProductListParamBean->getMinPrice()){ $params["minPrice"] = $getProductListParamBean->getMinPrice(); } //佣金金额下限 if($getProductListParamBean->getMinCommissionValue()){ $params["minCommissionValue"] = $getProductListParamBean->getMinCommissionValue(); } //佣金比例下限 if($getProductListParamBean->getMinCommissionRatio()){ $params["minCommissionRatio"] = $getProductListParamBean->getMinCommissionRatio(); } //排序 if($getProductListParamBean->getSortType()){ $params["sortType"] = $getProductListParamBean->getSortType(); } //单个类目 if($getProductListParamBean->getCategoryId()){ $params["categoryId"] = $getProductListParamBean->getCategoryId(); } //小商店appId列表 if($getProductListParamBean->getShopAppIds()){ $params["shopAppIds"] = $getProductListParamBean->getShopAppIds(); } //是否有联盟全 if($getProductListParamBean->getHasCoupon()){ $params["hasCoupon"] = $getProductListParamBean->getHasCoupon(); } //多个类目ID if($getProductListParamBean->getCategory()){ $params["category"] = $getProductListParamBean->getCategory(); } //黑名单类目ID if($getProductListParamBean->getNoCategory()){ $params["noCategory"] = $getProductListParamBean->getNoCategory(); } //商品ID if($getProductListParamBean->getProductId()){ $params["productId"] = $getProductListParamBean->getProductId(); } //配送方式 if($getProductListParamBean->getShippingMethods()){ $params["shippingMethods"] = $getProductListParamBean->getShippingMethods(); } //发货地址 if($getProductListParamBean->getAddressList()){ $params["addressList"] = $getProductListParamBean->getAddressList(); } $res = HttpCurl::getCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } return [ "total"=>$res["total"], "product_list"=>$res["productList"] ]; } /** * 查询联盟精选商品 * @param GetProductListParamBean $getProductListParamBean */ public static function getProductSelect(GetProductListParamBean $getProductListParamBean) { $url = "https://api.weixin.qq.com/union/promoter/product/select"; $params = [ "access_token"=>self::getMiniLianMengAccessToken(), "from"=>$getProductListParamBean->getFrom(), "limit"=>$getProductListParamBean->getLimit() ]; //商品最高价格 if($getProductListParamBean->getMaxPrice()){ $params["maxPrice"] = $getProductListParamBean->getMaxPrice(); } //商品最低价格 if($getProductListParamBean->getMinPrice()){ $params["minPrice"] = $getProductListParamBean->getMinPrice(); } //佣金金额下限 if($getProductListParamBean->getMinCommissionValue()){ $params["minCommissionValue"] = $getProductListParamBean->getMinCommissionValue(); } //佣金比例下限 if($getProductListParamBean->getMinCommissionRatio()){ $params["minCommissionRatio"] = $getProductListParamBean->getMinCommissionRatio(); } //排序 if($getProductListParamBean->getSortType()){ $params["sortType"] = $getProductListParamBean->getSortType(); } //单个类目 if($getProductListParamBean->getCategoryId()){ $params["categoryId"] = $getProductListParamBean->getCategoryId(); } //小商店appId列表 if($getProductListParamBean->getShopAppIds()){ $params["shopAppIds"] = $getProductListParamBean->getShopAppIds(); } //是否有联盟全 if($getProductListParamBean->getHasCoupon()){ $params["hasCoupon"] = $getProductListParamBean->getHasCoupon(); } //多个类目ID if($getProductListParamBean->getCategory()){ $params["category"] = $getProductListParamBean->getCategory(); } //黑名单类目ID if($getProductListParamBean->getNoCategory()){ $params["noCategory"] = $getProductListParamBean->getNoCategory(); } //商品ID if($getProductListParamBean->getProductId()){ $params["productId"] = $getProductListParamBean->getProductId(); } //配送方式 if($getProductListParamBean->getShippingMethods()){ $params["shippingMethods"] = $getProductListParamBean->getShippingMethods(); } //发货地址 if($getProductListParamBean->getAddressList()){ $params["addressList"] = $getProductListParamBean->getAddressList(); } $res = HttpCurl::getCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } return [ "total"=>$res["total"], "product_list"=>$res["productList"] ]; } /** * 获取商品推广素材 * @param GetProductGenerateParamBean $getProductGenerateParamBean */ public static function getProductGenerate(GetProductGenerateParamBean $getProductGenerateParamBean) { $url = "https://api.weixin.qq.com/union/promoter/product/generate?access_token=".self::getMiniLianMengAccessToken(); $params = [ "pid"=>$getProductGenerateParamBean->getPid(), "productList"=>$getProductGenerateParamBean->getProductList() ]; // dd(json_encode($params)); $res = HttpCurl::postCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } return $res["list"]; } /** * 添加推广位 * @param $promotionSourceName string 推广位名称 */ public static function addPromotion($promotionSourceName) { $url = "https://api.weixin.qq.com/union/promoter/promotion/add?access_token=".self::getMiniLianMengAccessToken(); $params = [ "promotionSourceName"=>$promotionSourceName ]; $res = HttpCurl::postCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } return $res["pid"]; } /** * 删除推广位 * @param $promotionSourcePid string 推广位pid * @param $promotionSourceName string 推广位名称 * @throws CommonException */ public static function deletePromotion($promotionSourcePid, $promotionSourceName) { $url = "https://api.weixin.qq.com/union/promoter/promotion/del?access_token=".self::getMiniLianMengAccessToken(); $params = [ "promotionSourceName"=>$promotionSourceName, "promotionSourcePid"=>$promotionSourcePid ]; $res = HttpCurl::postCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } } /** * 修改推广位 * @param $previousPromotionInfo array 修改钱推广位信息 * @param $promotionInfo array 修改后推广位信息 */ public static function modifyPromotion($previousPromotionInfo, $promotionInfo) { $url = "https://api.weixin.qq.com/union/promoter/promotion/upd?access_token=".self::getMiniLianMengAccessToken(); $params = [ "previousPromotionInfo"=>$previousPromotionInfo, "promotionInfo"=>$promotionInfo ]; $res = HttpCurl::postCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } } /** * 获取推广位列表 * @param $start int 偏移 * @param $limit int 每页数据 */ public static function getPromotionList($start, $limit) { $url = "https://api.weixin.qq.com/union/promoter/promotion/list"; $params = [ "access_token"=>self::getMiniLianMengAccessToken(), "start"=>$start, "limit"=>$limit ]; $res = HttpCurl::getCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } return [ "total"=>$res["total"], "promotion_max_cnt"=>$res["promotionMaxCnt"], "promotion_source_list"=>$res["promotionSourceList"] ]; } /** * 根据订单ID查询订单详情 * @param $orderList array 订单id列表 */ public static function getOrderDetail($orderIdList) { $url = "https://api.weixin.qq.com/union/promoter/order/info?access_token=".self::getMiniLianMengAccessToken(); $params = [ "orderIdList"=>$orderIdList ]; $res = HttpCurl::postCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } return $res["orderList"]; } /** * 根据订单支付时间、订单分佣状态拉取订单详情 * @param GetOrderSearchParamBean $getOrderSearchParamBean */ public static function getOrderSearch(GetOrderSearchParamBean $getOrderSearchParamBean) { $url = "https://api.weixin.qq.com/union/promoter/order/search"; $params = [ "access_token"=>self::getMiniLianMengAccessToken() ]; //页码 if($getOrderSearchParamBean->getPage()){ $params["page"] = $getOrderSearchParamBean->getPage(); } //起始时间戳 if($getOrderSearchParamBean->getStartTimestamp()){ $params["startTimestamp"] = $getOrderSearchParamBean->getStartTimestamp(); } //结束时间戳 if($getOrderSearchParamBean->getEndTimestamp()){ $params["endTimestamp"] = $getOrderSearchParamBean->getEndTimestamp(); } $res = HttpCurl::getCurl($url,$params); if($res["errcode"]!=0){ $instance = new LoggerFactoryUtil(MiniprogrameLianMengUtil::class); $instance->info("微信信息:".json_encode($res)); throw new CommonException(ErrorEnum::ERROR_SYSTEM); } return $res["orderList"]; } }