KefuLog.php 986 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\admin\model;
  3. use app\BaseModel;
  4. class KefuLog extends BaseModel
  5. {
  6. // protected $autoWriteTimestamp = true;
  7. // protected $createTime = 'created_at';
  8. // protected $updateTime = 'updated_at';
  9. //客服对接记录表:type:类型:1主动接线;2转接接线;3自动接线
  10. public static function addData($cs_uid, $user_id, $type) {
  11. //先结束已存在的记录
  12. self::endData($user_id);
  13. return self::create([
  14. 'cs_uid' => $cs_uid,
  15. 'user_id' => $user_id,
  16. 'type' => $type,
  17. 'status' => 0,
  18. 'created_at' => date('Y-m-d H:i:s')
  19. ]);
  20. }
  21. //客服对接结束
  22. public static function endData($user_id) {
  23. $info = self::where('user_id', $user_id)->where('status', 0)->find();
  24. if ($info) {
  25. $info->status = 1;
  26. $info->updated_at = date('Y-m-d H:i:s');
  27. $info->save();
  28. }
  29. }
  30. }