SubscribeLogic.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\NoticeEnum;
  18. use app\common\enum\YesNoEnum;
  19. use app\common\logic\BaseLogic;
  20. use app\common\model\NoticeSetting;
  21. /**
  22. * 小程序订阅消息
  23. */
  24. class SubscribeLogic extends BaseLogic
  25. {
  26. /**
  27. * @notes 获取小程序模板ID (取已启用的3条)
  28. * @param $params
  29. * @return array
  30. * @throws \think\db\exception\DataNotFoundException
  31. * @throws \think\db\exception\DbException
  32. * @throws \think\db\exception\ModelNotFoundException
  33. * @author Tab
  34. * @date 2021/10/12 11:56
  35. */
  36. public static function lists($params)
  37. {
  38. $where = [
  39. ['mnp_notice', '<>', ''],
  40. ['type', '=', 1]
  41. ];
  42. if (!empty($params['scene_id']) && is_array($params['scene_id'])) {
  43. $where[] = ['scene_id', 'in', $params['scene_id']];
  44. } else {
  45. $where[] = ['scene_id', '<>', NoticeEnum::RECEIPT_PAYMENT_NOTICE];
  46. }
  47. $lists = NoticeSetting::where($where)->field('mnp_notice')->select()->toArray();
  48. $template_id = [];
  49. foreach ($lists as $item) {
  50. if (isset($item['mnp_notice']['status']) && $item['mnp_notice']['status'] != YesNoEnum::YES) {
  51. continue;
  52. }
  53. $template_id[] = $item['mnp_notice']['template_id'] ?? '';
  54. // 限制3条
  55. if (count($template_id) == 3) {
  56. break;
  57. }
  58. }
  59. return $template_id;
  60. }
  61. }