StoreServiceAuxiliaryServices.php 1.9 KB

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