Mini.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\api\service\wechat;
  10. use app\api\service\Service;
  11. use app\common\models\Setting as SettingModel;
  12. use app\common\models\wechat\SubscribeMessage as SubscribeMessageModel;
  13. class Mini extends Service {
  14. /**
  15. * 获取订阅消息数据
  16. * @return array
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public static function getTemplate(){
  22. $config = SettingModel::getArrayData("wemini_base");
  23. if(isset($config["is_subscribe"]) && $config["is_subscribe"] == 1){
  24. throw new \Exception("订阅消息未开启",0);
  25. }
  26. $data = SubscribeMessageModel::where("status",0)->select()->toArray();
  27. $array = [];
  28. foreach($data as $value){
  29. $array[$value["sign"]] = $value["temp_id"];
  30. }
  31. return $array;
  32. }
  33. }