get($url); $fp2 = @fopen($fullFileName, 'a');//文件大小 fwrite($fp2, $result); fclose($fp2); return $fileName;//默认大小 大 } /** * 保存logo * @return string */ public static function logoSave($url, $wxAppId) { return ''; $directory = dict::getDict('imgSavePath', 'wxMpAvatar'); $path = Yii::getAlias('@webroot') . '/../../images'; $pre = '/' . $directory . '/' . date('Y') . '/' . date('m') . '/' . date("d") . '/'; if (!file_exists($path . $pre)) { mkdir($path . $pre, 0777, true); } $randString = stringUtil::buildOrderNo(); $id = substr($wxAppId, -2); $name = $id . '_' . $randString . '.jpg'; $fullFileName = $path . $pre . $name; $fileName = $pre . $name; $curl = new curl\Curl(); $result = $curl->get($url); $fp2 = @fopen($fullFileName, 'a');//文件大小 fwrite($fp2, $result); fclose($fp2); $dstImg200 = $path . $pre . $id . '_' . $randString . '_200.jpg';//缩略宽 200px 中 util::img2thumb($fullFileName, $dstImg200, 200, 0, 0, 0); $dstImg50 = $path . $pre . $id . '_' . $randString . '_50.jpg';//缩略成宽50px 小 util::img2thumb($fullFileName, $dstImg50, 50, 0, 0, 0); return $fileName;//默认大小 大 } /** * 传入最大的logo,输出三种logo:大 中 小 */ public static function getLogoList($largeImg) { $extend = substr($largeImg, strrpos($largeImg, '.') + 1); $pre = substr($largeImg, 0, strrpos($largeImg, '.')); return ['small' => $pre . '_50.' . $extend, 'medium' => $pre . '_200.' . $extend, 'large' => $largeImg]; } /** * 商家接入审核通过 */ public static function pass($admin) { $openId = $admin['openId']; $merchant = xhWxOpenService::getMerchant(); $sjId = $merchant['id']; $allTM = xhTMessageService::getList($sjId); $shortTempId = 'OPENTM401915538'; $tempId = $allTM[$shortTempId]; $data = array( "touser" => $openId, "template_id" => $tempId,//模板id "url" => Yii::$app->params['adminUrl'] . "/main/approve?id={$merchant['id']}", "data" => array( "first" => array( "value" => "恭喜,您的公众号审核通过!", "color" => "#173177" ), "keyword1" => array( "value" => '审核通过', "color" => "#173177" ), "keyword2" => array( "value" => date("Y-m-d H:i:s"), "color" => "#173177" ), "remark" => array( "value" => '点此登陆后台查看详细', "color" => "#173177" ) ), ); wxUtil::sendTaskInform($data, $merchant); } public static function getById($id) { $merchant = xhMerchant::getByCondition(['id' => $id]); return $merchant; } public static function getByAccount($id) { $merchant = xhMerchant::getByCondition(['id' => $id]); return $merchant; } public static function getByAppId($appId) { $merchant = xhMerchant::getByCondition(['wxAppId' => $appId]); return $merchant; } public static function getByCondition($condition) { $merchant = xhMerchant::getByCondition($condition); return $merchant; } public static function getAllByCondition($condition) { return xhMerchant::getAllByCondition($condition); } public static function getOne() { $m = xhMerchant::find()->asArray()->one(); return $m; } /** * 更新商家的缓存信息 * @param int $id */ public static function refreshMerchantInfo($id) { $merchant = xhMerchant::getById($id); $account = $merchant['id']; $appId = $merchant['wxAppId']; $accountKey = dict::getCacheKey('merchantAccount') . $account; $idKey = dict::getCacheKey('sjId') . $id; $appIdKey = dict::getCacheKey('merchantAppId') . $appId; Yii::$app->redis->executeCommand('DEL', [$accountKey]); Yii::$app->redis->executeCommand('DEL', [$idKey]); Yii::$app->redis->executeCommand('DEL', [$appIdKey]); self::getByAccount($account); self::getById($id); self::getByAppId($appId); } /** * 更新数据 */ public static function updateById($id, $post) { xhMerchant::updateById($id, $post); self::refreshMerchantInfo($id); } /** * 增加,返回数组 */ public static function add($data) { $merchant = xhMerchant::add($data); $id = $merchant['id']; self::refreshMerchantInfo($id); return $merchant; } /** * 传入最大的照片,输出三种照片:大 中 小 */ public static function getShopPhotoList($largeImg) { $extend = substr($largeImg, strrpos($largeImg, '.') + 1); $pre = substr($largeImg, 0, strrpos($largeImg, '.')); return ['small' => $pre . '_50.' . $extend, 'medium' => $pre . '_200.' . $extend, 'large' => $largeImg]; } public static function getByName($name) { $merchant = xhMerchant::getByCondition(['name' => $name]); return $merchant; } public static function getAdmin($merchant) { $adminId = isset($merchant['adminId']) ? $merchant['adminId'] : 0; $admin = xhAdminService::getById($adminId); return $admin; } }