| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?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($isOpen)
- {
- $open = [];
- if ($isOpen == 1) {
- $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_HD]);
- }
- if ($isOpen == 2) {
- $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_GHS]);
- }
- if (empty($open)) {
- util::fail('没有找到平台');
- }
- $merchantId = $open['merchantId'];
- $merchant = xhMerchantService::getById($merchantId);
- return $merchant;
- }
-
- }
|