StoreServiceAuxiliaryServices.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\service;
  12. use app\dao\message\service\StoreServiceAuxiliaryDao;
  13. use app\services\BaseServices;
  14. /**
  15. * Class StoreServiceAuxiliaryServices
  16. * @package app\services\message\service
  17. * @mixin StoreServiceAuxiliaryDao
  18. */
  19. class StoreServiceAuxiliaryServices extends BaseServices
  20. {
  21. /**
  22. * StoreServiceAuxiliaryServices constructor.
  23. * @param StoreServiceAuxiliaryDao $dao
  24. */
  25. public function __construct(StoreServiceAuxiliaryDao $dao)
  26. {
  27. $this->dao = $dao;
  28. }
  29. /**
  30. * 保存转接信息
  31. * @param array $data
  32. * @return array
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\DbException
  35. * @throws \think\db\exception\ModelNotFoundException
  36. */
  37. public function saveAuxliary(array $data)
  38. {
  39. $auxliaryInfo = $this->dao->get(['type' => 0, 'binding_id' => $data['binding_id'], 'relation_id' => $data['relation_id']]);
  40. if ($auxliaryInfo) {
  41. $auxliaryInfo->update_time = time();
  42. return $auxliaryInfo->save();
  43. } else {
  44. return $this->dao->save([
  45. 'type' => 0,
  46. 'binding_id' => $data['binding_id'],
  47. 'relation_id' => $data['relation_id'],
  48. 'update_time' => time(),
  49. 'add_time' => time(),
  50. ]);
  51. }
  52. }
  53. }