| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace common\services;
- use Yii;
- use common\models\xhWifi;
- use common\components\dict;
- use common\components\wxUtil;
- use common\components\util;
- class xhWifiService {
- /**
- * 根据shopId取门店设置的所有wifi
- */
- public static function getListByShopId($shopId)
- {
- $cacheKey = dict::getCacheKey('xhWifiList').$shopId;
- $exists = Yii::$app->redis->executeCommand('EXISTS', [$cacheKey]);
- if(empty($exists)){
- $wifi = self::getAllByCondition(['shopId'=>$shopId]);
- $string = !empty($wifi) ? json_encode($wifi) : '';
- Yii::$app->redis->executeCommand('SET', [$cacheKey,$string]);
- }else{
- $cacheData = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $wifi = !empty($cacheData) ? json_decode($cacheData,true) : [];
- }
- return $wifi;
- }
-
- public static function getAllByCondition($condition)
- {
- return xhWifi::getAllByCondition($condition);
- }
- /**
- * Wifi二维码图片是否已下载
- * @param $shopId
- * @return bool true:存在; false:不存在
- */
- public static function existQrImage($shopId){
- $webRootDir = dirname(Yii::$app->basePath);
- $saveQrCodeDir = $webRootDir . '/images/qrcode/weixinQrcode/';
- $qrImage = $saveQrCodeDir . $shopId . '.jpg';
- return file_exists($qrImage);
- }
- }
|