where(['sjId' => $sjId])->asArray()->one(); return $merchant; } public static function add($data) { $return = xhMerchantExtend::add($data); $sjId = $return['id']; self::refresh($sjId); return $return; } /** * 更新缓存信息 */ public static function refresh($sjId) { $extendKey = dict::getCacheKey('merchantExtend') . $sjId; Yii::$app->redis->executeCommand('DEL', [$extendKey]); self::getBySjId($sjId); } /** * 更新数据 */ public static function updateBySjId($sjId, $data) { xhMerchantExtend::updateByCondition(['sjId' => $sjId], $data); $cacheKey = dict::getCacheKey('merchantExtend') . $sjId; $params = [$cacheKey]; foreach ($data as $key => $val) { $params[] = $key; $params[] = $val; } Yii::$app->redis->executeCommand('HMSET', $params); } /** * 积分等级列表 */ public static function getGradeList($extend, $order = 'asc') { $gradeStr = $extend['gradeList']; $data = []; if (!empty($gradeStr)) { $arr = explode("I", $gradeStr); $arr = array_filter($arr); foreach ($arr as $key => $val) { $son = explode("_", $val); $discount = $son[2]; $data[$son[0]] = ['level' => $son[0], 'growth' => $son[1], 'discount' => $discount]; } } $data = arrayUtil::sort($data, 'level', $order); return $data; } }