WxOpenClass.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. namespace bizHd\wx\classes;
  3. use biz\sj\classes\MerchantClass;
  4. use common\components\dict;
  5. use common\components\util;
  6. use Yii;
  7. use bizHd\base\classes\BaseClass;
  8. class WxOpenClass extends BaseClass
  9. {
  10. public static $baseFile = '\bizHd\wx\models\WxOpen';
  11. //平台管理员的手机号
  12. const ADMIN_MOBILE = 15280215347;
  13. const PLATFORM_ACCOUNT = 12359;
  14. const ID = 1;
  15. //取平台的帐号
  16. public static function getPlatformAccount()
  17. {
  18. return self::PLATFORM_ACCOUNT;
  19. }
  20. //获取平台基础信息 ssh 2020.2.11
  21. public static function getOpen()
  22. {
  23. return self::getById(self::ID);
  24. }
  25. //获取平台管理员的手机号 ssh 2020.3.4
  26. public static function getAdminMobile()
  27. {
  28. return self::ADMIN_MOBILE;
  29. }
  30. //获取平台微信信息
  31. public static function getOpenInfo()
  32. {
  33. $open = self::getById(self::ID);
  34. if (isset($open['sjId']) && !empty($open['sjId'])) {
  35. $sjId = $open['sjId'];
  36. return MerchantClass::getMerchantById($sjId);
  37. }
  38. util::fail('没有找到平台信息');
  39. }
  40. //更新开放平台信息 ssh 2020.4.13
  41. public static function updateOpen($data)
  42. {
  43. self::updateById(self::ID, $data);
  44. }
  45. //平台小程序信息 ssh 2020.4.13
  46. public static function getWxMiniBase()
  47. {
  48. $open = self::getByCondition(['style' => dict::getDict('ptStyle','hd')]);
  49. if (empty($open)) {
  50. util::fail('没有找到花店平台信息...');
  51. }
  52. $wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
  53. $base = WxMiniBaseClass::getById($wxMiniBaseId);
  54. if (empty($base)) {
  55. util::fail('没有找到平台小程序信息');
  56. }
  57. return $base;
  58. }
  59. //公众号信息 ssh 2020.4.14
  60. public static function getWxBase()
  61. {
  62. $open = self::getByCondition(['style' => dict::getDict('ptStyle','hd')]);
  63. if (empty($open)) {
  64. util::fail('没有找到花店平台信息...');
  65. }
  66. $wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
  67. $base = WxBaseClass::getById($wxBaseId);
  68. if (empty($base)) {
  69. util::fail('没有找到平台公众号信息');
  70. }
  71. return $base;
  72. }
  73. //获取微信和小程序信息 ssh 2020.4.14
  74. public static function getWxInfo()
  75. {
  76. $mini = self::getWxMiniBase();
  77. $wx = self::getWxBase();
  78. return array_merge($wx, $mini);
  79. }
  80. //公众号信息 ssh 2020.4.14
  81. public static function getGhsWxBase()
  82. {
  83. $open = self::getByCondition(['style' => dict::getDict('ptStyle','ghs')]);
  84. if (empty($open)) {
  85. util::fail('没有找到供货商平台信息...');
  86. }
  87. $wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
  88. $base = WxBaseClass::getById($wxBaseId);
  89. if (empty($base)) {
  90. util::fail('没有找到平台公众号信息');
  91. }
  92. return $base;
  93. }
  94. //平台小程序信息 ssh 2020.4.13
  95. public static function getGhsWxMiniBase()
  96. {
  97. $open = self::getByCondition(['style' => dict::getDict('ptStyle','ghs')]);
  98. if (empty($open)) {
  99. util::fail('没有找到供货商平台信息...');
  100. }
  101. $wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
  102. $base = WxMiniBaseClass::getById($wxMiniBaseId);
  103. if (empty($base)) {
  104. util::fail('没有找到平台小程序信息');
  105. }
  106. return $base;
  107. }
  108. public static function getGhsWxInfo()
  109. {
  110. $mini = self::getGhsWxMiniBase();
  111. $wx = self::getGhsWxBase();
  112. return array_merge($wx, $mini);
  113. }
  114. public static function getMallWxInfo()
  115. {
  116. $mini = self::getMallWxMiniBase();
  117. $wx = self::getMallWxBase();
  118. return array_merge($wx, $mini);
  119. }
  120. public static function getMallWxMiniBase()
  121. {
  122. $open = self::getByCondition(['style' => dict::getDict('ptStyle','mall')]);
  123. if (empty($open)) {
  124. util::fail('没有找到供货商平台信息...');
  125. }
  126. $wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
  127. $base = WxMiniBaseClass::getById($wxMiniBaseId);
  128. if (empty($base)) {
  129. util::fail('没有找到平台小程序信息');
  130. }
  131. return $base;
  132. }
  133. //公众号信息 ssh 2020.4.14
  134. public static function getMallWxBase()
  135. {
  136. $open = self::getByCondition(['style' => dict::getDict('ptStyle','mall')]);
  137. if (empty($open)) {
  138. util::fail('没有找到供货商平台信息...');
  139. }
  140. $wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
  141. $base = WxBaseClass::getById($wxBaseId);
  142. if (empty($base)) {
  143. util::fail('没有找到平台公众号信息');
  144. }
  145. return $base;
  146. }
  147. }