SmsRecordServices.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\services\message\sms;
  12. use app\dao\message\sms\SmsRecordDao;
  13. use app\services\BaseServices;
  14. use app\services\serve\ServeServices;
  15. /**
  16. * 短信发送记录
  17. * Class SmsRecordServices
  18. * @package app\services\message\sms
  19. * @mixin SmsRecordDao
  20. */
  21. class SmsRecordServices extends BaseServices
  22. {
  23. /**
  24. * 构造方法
  25. * SmsRecordServices constructor.
  26. * @param SmsRecordDao $dao
  27. */
  28. public function __construct(SmsRecordDao $dao)
  29. {
  30. $this->dao = $dao;
  31. }
  32. /**
  33. * 获取短信发送列表
  34. * @param array $where
  35. * @return array
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\DbException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. */
  40. public function getRecordList(array $where)
  41. {
  42. [$page, $limit] = $this->getPageValue();
  43. $data = $this->dao->getRecordList($where, $page, $limit);
  44. $count = $this->dao->count($where);
  45. return compact('data', 'count');
  46. }
  47. /**
  48. * 修改短信发送记录短信状态
  49. */
  50. public function modifyResultCode()
  51. {
  52. $recordIds = $this->dao->getCodeNull();
  53. if (count($recordIds)) {
  54. /** @var ServeServices $smsHandle */
  55. $smsHandle = app()->make(ServeServices::class);
  56. $codeLists = $smsHandle->sms()->getStatus($recordIds);
  57. foreach ($codeLists as $item) {
  58. if (isset($item['id']) && isset($item['resultcode'])) {
  59. if ($item['resultcode'] == '' || $item['resultcode'] == null) $item['resultcode'] = 134;
  60. $this->dao->update($item['id'], ['resultcode' => $item['resultcode']], 'record_id');
  61. }
  62. }
  63. return true;
  64. }
  65. return true;
  66. }
  67. }