OrderStaff.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class OrderStaff extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'order_staff';
  9. public static function getuuid($order_id)
  10. {
  11. $staff = self::where('order_id', $order_id)->order('id desc')->find();
  12. return $staff->uuid;
  13. }
  14. public static function is_staff($order_id)
  15. {
  16. $staff = self::where('order_id', $order_id)->order('id desc')->find();
  17. return $staff->id;
  18. }
  19. public static function ordercount($uuid)
  20. {
  21. return self::where('uuid', $uuid)->count();
  22. }
  23. public static function staff($order_id)
  24. {
  25. $staff = self::where('order_id', $order_id)->order('id desc')->find();
  26. return Technical::getTitle($staff->uuid);
  27. }
  28. public static function checkstaff($technicalId, $selectDate, $begin_time, $end_time)
  29. {
  30. $ret = OrderStaff::where('begin_time', '>=', strtotime($selectDate . ' ' . $begin_time . ':00'))
  31. ->where('end_time', '<=', strtotime($selectDate . ' ' . $end_time . ':00'))
  32. ->where('uuid', $technicalId)
  33. ->find();
  34. return $ret;
  35. }
  36. public static function getTechnical($order_id)
  37. {
  38. $staff = self::where('order_id', $order_id)->order('id desc')->find();
  39. return Technical::getInfo($staff->uuid);
  40. }
  41. public static function addstaff($order_staff)
  42. {
  43. $order = self::where(['order_id' => $order_staff['order_id'], 'is_complete' => 0])->select()->toArray();
  44. if (!empty($order)) {
  45. self::where(['order_id' => $order_staff['order_id'], 'is_complete' => 0])->update(['uuid' => $order_staff['uuid']]);
  46. } else {
  47. $res = self::create($order_staff);
  48. }
  49. if (!empty($res)) {
  50. Broadcast::staff($order_staff);
  51. return $res;
  52. }
  53. }
  54. }