MedicalCareSalesman.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\admin\model;
  3. use support\Db;
  4. use support\Model;
  5. /**
  6. * 医疗服务-预约服务业务员模型
  7. * Class Users
  8. * @package app\admin\model
  9. */
  10. class MedicalCareSalesman extends Model
  11. {
  12. const STATUS_DEL_NO = '0';
  13. const STATUS_DEL_YES = '1';
  14. const STATUS_DEL = [
  15. self::STATUS_DEL_NO => '正常',
  16. self::STATUS_DEL_YES => '删除'
  17. ];
  18. const SALESMAN_STATUS_NO = '0';
  19. const SALESMAN_STATUS_YES = '1';
  20. const SALESMAN_STATUS = [
  21. self::SALESMAN_STATUS_NO => '休班',
  22. self::SALESMAN_STATUS_YES => '在班'
  23. ];
  24. /**
  25. * The table associated with the model.
  26. *
  27. * @var string
  28. */
  29. protected $table = 'medical_care_salesman';
  30. public $timestamps = false;
  31. /**
  32. * Notes:获取菜单列表
  33. * @param string $keywords
  34. * @param int $page
  35. * @param int $limit
  36. * @return array
  37. * User: ZQ
  38. * Date: 2022/9/14
  39. */
  40. public static function getSalesmanList(int $page, int $limit, string $keywords)
  41. {
  42. $list = static::select(['medical_care_salesman.*','merchant_shop.shop_name'])->where(['salesman_del'=>static::STATUS_DEL_NO])
  43. ->when($keywords != '', function ($query) use ($keywords){
  44. $query->where('salesman_resale_name', 'like', '%' . $keywords . '%');
  45. })
  46. ->leftJoin('merchant_shop', 'shop_id', '=', 'medical_care_salesman.salesman_shop_id')
  47. ->forPage($page,$limit)
  48. ->orderBy('salesman_create_time','DESC')
  49. ->get();
  50. $count = static::where(['salesman_del'=>static::STATUS_DEL_NO])
  51. ->when($keywords != '', function ($query) use ($keywords){
  52. $query->where('salesman_resale_name', 'like', '%' . $keywords . '%');
  53. })
  54. ->count();
  55. return [$list,$count];
  56. }
  57. /**
  58. * Notes:查询指定条件下的某个字段内容
  59. * @param int $salesman_id
  60. * @param string $field
  61. * User: ZQ
  62. * Date: 2022/9/27
  63. */
  64. public static function getValue(int $salesman_id, string $field)
  65. {
  66. return static::where(['salesman_id' => $salesman_id])->value($field);
  67. }
  68. }