SubscribeLogic.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LikeShop有特色的全开源社交分销电商系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
  7. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  8. // | 微信公众号:好象科技
  9. // | 访问官网:http://www.likemarket.net
  10. // | 访问社区:http://bbs.likemarket.net
  11. // | 访问手册:http://doc.likemarket.net
  12. // | 好象科技开发团队 版权所有 拥有最终解释权
  13. // +----------------------------------------------------------------------
  14. // | Author: LikeShopTeam
  15. // +----------------------------------------------------------------------
  16. namespace app\shopapi\logic;
  17. use app\common\enum\YesNoEnum;
  18. use app\common\logic\BaseLogic;
  19. use app\common\model\NoticeSetting;
  20. /**
  21. * 小程序订阅消息
  22. */
  23. class SubscribeLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 获取小程序模板ID (取已启用的3条)
  27. * @param $params
  28. * @return array
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\DbException
  31. * @throws \think\db\exception\ModelNotFoundException
  32. * @author Tab
  33. * @date 2021/10/12 11:56
  34. */
  35. public static function lists()
  36. {
  37. $where = [
  38. ['mnp_notice', '<>', ''],
  39. ['type', '=', 1]
  40. ];
  41. $lists = NoticeSetting::where($where)->field('mnp_notice')->select()->toArray();
  42. $template_id = [];
  43. foreach ($lists as $item) {
  44. if (isset($item['mnp_notice']['status']) && $item['mnp_notice']['status'] != YesNoEnum::YES) {
  45. continue;
  46. }
  47. $template_id[] = $item['mnp_notice']['template_id'] ?? '';
  48. // 限制3条
  49. if (count($template_id) == 3) {
  50. break;
  51. }
  52. }
  53. return $template_id;
  54. }
  55. }