| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace common\services;
- use Yii;
- use common\components\stringUtil;
- use common\components\configDict;
- use common\models\xhWxOpen;
- class xhWxOpenService {
- public static function getById($id=0)
- {
- $merchant = xhWxOpen::getByCondition(['id'=>$id]);
- return $merchant;
- }
- public static function updateById($id, $data)
- {
- xhWxOpen::updateById($id, $data);
- self::refresh($id);
- }
- public static function refresh($id)
- {
- $preKey = configDict::getCacheKey('wxOpen');
- $cacheKey = $preKey.$id;
- Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
- self::getById($id);
- }
- public static function add($data)
- {
- $data = xhWxOpen::add($data);
- $id = $data['id'];
- self::refresh($id);
- return $data;
- }
- /**
- * 取平台相应的商家
- */
- public static function getMerchant()
- {
- $wxOpenId = configDict::getConfig('openId');
- $wxOpen = xhWxOpenService::getById($wxOpenId);
- $merchantId = $wxOpen['merchantId'];
- $merchant = xhMerchantService::getById($merchantId);
- return $merchant;
- }
- }
|