MessageSystemServices.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\services\message;
  13. use app\dao\system\MessageSystemDao;
  14. use app\services\BaseServices;
  15. use crmeb\exceptions\ApiException;
  16. /**
  17. * 站内信services类
  18. * Class MessageSystemServices
  19. * @package app\services\system
  20. * @method save(array $data) 保存数据
  21. * @method mixed saveAll(array $data) 批量保存数据
  22. * @method update($id, array $data, ?string $key = null) 修改数据
  23. *
  24. */
  25. class MessageSystemServices extends BaseServices
  26. {
  27. /**
  28. * SystemNotificationServices constructor.
  29. * @param MessageSystemDao $dao
  30. */
  31. public function __construct(MessageSystemDao $dao)
  32. {
  33. $this->dao = $dao;
  34. }
  35. /**
  36. * 站内信列表
  37. * @param $uid
  38. * @return array
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\DbException
  41. * @throws \think\db\exception\ModelNotFoundException
  42. */
  43. public function getMessageSystemList($uid)
  44. {
  45. [$page, $limit] = $this->getPageValue();
  46. $where['is_del'] = 0;
  47. $where['uid'] = $uid;
  48. $list = $this->dao->getMessageList($where, '*', $page, $limit);
  49. $count = $this->dao->getCount($where);
  50. if (!$list) return ['list' => [], 'count' => 0];
  51. foreach ($list as &$item) {
  52. $item['add_time'] = time_tran($item['add_time']);
  53. if ($item['data'] != '') {
  54. $item['content'] = getLang($this->getMsgCode($item['mark']), json_decode($item['data'], true));
  55. }
  56. }
  57. return ['list' => $list, 'count' => $count];
  58. }
  59. /**
  60. * 站内信详情
  61. * @param $where
  62. * @return array
  63. * @throws \think\db\exception\DataNotFoundException
  64. * @throws \think\db\exception\DbException
  65. * @throws \think\db\exception\ModelNotFoundException
  66. */
  67. public function getInfo($where)
  68. {
  69. $info = $this->dao->getOne($where);
  70. if (!$info || $info['is_del'] == 1) {
  71. throw new ApiException(100026);
  72. }
  73. $info = $info->toArray();
  74. if ($info['look'] == 0) {
  75. $this->update($info['id'], ['look' => 1]);
  76. }
  77. if ($info['data'] != '') {
  78. $info['content'] = getLang($this->getMsgCode($info['mark']), json_decode($info['data'], true));
  79. }
  80. $info['add_time'] = time_tran($info['add_time']);
  81. return $info;
  82. }
  83. public function getMsgCode($mark)
  84. {
  85. switch ($mark) {
  86. case 'admin_pay_success_code':
  87. $code = 500004;
  88. break;
  89. case 'bind_spread_uid':
  90. $code = 500005;
  91. break;
  92. case 'order_pay_success':
  93. $code = 500006;
  94. break;
  95. case 'order_take':
  96. $code = 500007;
  97. break;
  98. case 'price_revision':
  99. $code = 500008;
  100. break;
  101. case 'order_refund':
  102. $code = 500009;
  103. break;
  104. case 'recharge_success':
  105. $code = 500010;
  106. break;
  107. case 'integral_accout':
  108. $code = 500011;
  109. break;
  110. case 'order_brokerage':
  111. $code = 500012;
  112. break;
  113. case 'bargain_success':
  114. $code = 500013;
  115. break;
  116. case 'order_user_groups_success':
  117. $code = 500014;
  118. break;
  119. case 'send_order_pink_fial':
  120. $code = 500015;
  121. break;
  122. case 'open_pink_success':
  123. $code = 500016;
  124. break;
  125. case 'user_extract':
  126. $code = 500017;
  127. break;
  128. case 'user_balance_change':
  129. $code = 500018;
  130. break;
  131. case 'recharge_order_refund_status':
  132. $code = 500019;
  133. break;
  134. case 'send_order_refund_no_status':
  135. $code = 500020;
  136. break;
  137. case 'send_order_apply_refund':
  138. $code = 500021;
  139. break;
  140. case 'order_deliver_success':
  141. case 'order_postage_success':
  142. $code = 500022;
  143. break;
  144. case 'send_order_pink_clone':
  145. $code = 500023;
  146. break;
  147. case 'can_pink_success':
  148. $code = 500024;
  149. break;
  150. case 'kefu_send_extract_application':
  151. $code = 500025;
  152. break;
  153. case 'send_admin_confirm_take_over':
  154. $code = 500026;
  155. break;
  156. case 'order_pay_false':
  157. $code = 500027;
  158. break;
  159. }
  160. return $code;
  161. }
  162. }