xhWxOpenService.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace common\services;
  3. use common\components\util;
  4. use Yii;
  5. use common\components\stringUtil;
  6. use common\components\dict;
  7. use common\models\xhWxOpen;
  8. class xhWxOpenService
  9. {
  10. public static function getById($id = 0)
  11. {
  12. $merchant = xhWxOpen::getByCondition(['id' => $id]);
  13. return $merchant;
  14. }
  15. public static function updateById($id, $data)
  16. {
  17. xhWxOpen::updateById($id, $data);
  18. self::refresh($id);
  19. }
  20. public static function refresh($id)
  21. {
  22. self::getById($id);
  23. }
  24. public static function add($data)
  25. {
  26. $data = xhWxOpen::add($data);
  27. $id = $data['id'];
  28. self::refresh($id);
  29. return $data;
  30. }
  31. /**
  32. * 取平台相应的商家
  33. */
  34. public static function getMerchant($isOpen)
  35. {
  36. $open = [];
  37. if ($isOpen == 1) {
  38. $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'hd')]);
  39. } elseif ($isOpen == 2) {
  40. $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
  41. } elseif ($isOpen == 3) {
  42. $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
  43. } else {
  44. util::fail('没有找到平台');
  45. }
  46. $sjId = $open['sjId'];
  47. $merchant = xhMerchantService::getById($sjId);
  48. return $merchant;
  49. }
  50. }