OrderStaff.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 timesremain($order_id)
  20. {
  21. return self::where(['order_id' => $order_id, 'is_complete' => 0])->count();
  22. }
  23. public static function timesused($order_id)
  24. {
  25. return self::where(['order_id' => $order_id, 'is_complete' => 1])->count();
  26. }
  27. public static function ordercount($uuid)
  28. {
  29. return self::where('uuid', $uuid)->count();
  30. }
  31. public static function staff($order_id)
  32. {
  33. $staff = self::where('order_id', $order_id)->order('id desc')->find();
  34. return Technical::getTitle($staff->uuid);
  35. }
  36. public static function checkstaff($technicalId, $selectDate, $begin_time, $end_time)
  37. {
  38. $ret = OrderStaff::where('begin_time', '>=', strtotime($selectDate . ' ' . $begin_time . ':00'))
  39. ->where('end_time', '<=', strtotime($selectDate . ' ' . $end_time . ':00'))
  40. ->where('uuid', $technicalId)
  41. ->find();
  42. return $ret;
  43. }
  44. public static function getTechnical($order_id)
  45. {
  46. $staff = self::where('order_id', $order_id)->order('id desc')->find();
  47. return Technical::getInfo($staff->uuid);
  48. }
  49. public static function addstaff($order_staff)
  50. {
  51. $order = self::where(['order_id' => $order_staff['order_id'], 'is_complete' => 0])->select()->toArray();
  52. if (!empty($order)) {
  53. self::where(['order_id' => $order_staff['order_id'], 'is_complete' => 0])->update(['uuid' => $order_staff['uuid']]);
  54. } else {
  55. $res = self::create($order_staff);
  56. }
  57. if (!empty($res)) {
  58. Broadcast::staff($order_staff);
  59. return $res;
  60. }
  61. }
  62. }