| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace common\services;
- use common\components\util;
- use Yii;
- use common\components\stringUtil;
- use common\components\dict;
- 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)
- {
- 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' => dict::getDict('ptStyle', 'hd')]);
- } elseif ($isOpen == 2) {
- $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
- } elseif ($isOpen == 3) {
- $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
- } else {
- util::fail('没有找到平台');
- }
- $sjId = $open['sjId'];
- $merchant = xhMerchantService::getById($sjId);
- return $merchant;
- }
- }
|