1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace app\admin\model;
- use support\Db;
- use support\Model;
- /**
- * 医疗服务-预约服务业务员模型
- * Class Users
- * @package app\admin\model
- */
- class MedicalCareSalesman extends Model
- {
- const STATUS_DEL_NO = '0';
- const STATUS_DEL_YES = '1';
- const STATUS_DEL = [
- self::STATUS_DEL_NO => '正常',
- self::STATUS_DEL_YES => '删除'
- ];
- const SALESMAN_STATUS_NO = '0';
- const SALESMAN_STATUS_YES = '1';
- const SALESMAN_STATUS = [
- self::SALESMAN_STATUS_NO => '休班',
- self::SALESMAN_STATUS_YES => '在班'
- ];
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'medical_care_salesman';
- public $timestamps = false;
- /**
- * Notes:获取菜单列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: ZQ
- * Date: 2022/9/14
- */
- public static function getSalesmanList(int $page, int $limit, string $keywords)
- {
- $list = static::select(['medical_care_salesman.*','merchant_shop.shop_name'])->where(['salesman_del'=>static::STATUS_DEL_NO])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('salesman_resale_name', 'like', '%' . $keywords . '%');
- })
- ->leftJoin('merchant_shop', 'shop_id', '=', 'medical_care_salesman.salesman_shop_id')
- ->forPage($page,$limit)
- ->orderBy('salesman_create_time','DESC')
- ->get();
- $count = static::where(['salesman_del'=>static::STATUS_DEL_NO])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('salesman_resale_name', 'like', '%' . $keywords . '%');
- })
- ->count();
- return [$list,$count];
- }
- /**
- * Notes:查询指定条件下的某个字段内容
- * @param int $salesman_id
- * @param string $field
- * User: ZQ
- * Date: 2022/9/27
- */
- public static function getValue(int $salesman_id, string $field)
- {
- return static::where(['salesman_id' => $salesman_id])->value($field);
- }
- }
|