链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.6 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Admin;
  4. use Dcat\Admin\Traits\HasDateTimeFormatter;
  5. use Illuminate\Database\Eloquent\Model;
  6. use Illuminate\Database\Eloquent\SoftDeletes;
  7. class LanzuMmInfo extends Model
  8. {
  9. use HasDateTimeFormatter;
  10. use SoftDeletes;
  11. protected $table = 'lanzu_mm_info';
  12. protected $dateFormat = 'U';
  13. public function Withdraw()
  14. {
  15. return $this->hasOne('\App\Models\LanzuMmWithdraw','mm_id','id');
  16. }
  17. public static function getMmInfoCount()
  18. {
  19. $adu = Admin::user();
  20. if ($adu->isRole('lanzu_mp')){
  21. $mpInfo = LanzuMpInfo::where('admin_user_id',$adu->id)->select('id')->first();
  22. if ($mpInfo){
  23. $ids = ImsCjdcMarket::where('mp_id',$mpInfo->id)->get()->pluck('id');
  24. $count = self::whereIn('market_id',$ids)->count();
  25. return $count;
  26. }else{
  27. return 0;
  28. }
  29. }else{
  30. return self::count();
  31. }
  32. }
  33. /**
  34. * 获取市场经理(只搜索状态为正常的经理)
  35. * id为键,name为值
  36. */
  37. public static function getMmInfoArray()
  38. {
  39. $list = self::select('id','name')
  40. ->where('status',2)
  41. ->whereNull('deleted_at')
  42. ->get();
  43. $array = [];
  44. if(count($list) > 0){
  45. foreach ($list as $key => $value){
  46. $array[$value->id] = $value->name;
  47. }
  48. }
  49. return $array;
  50. }
  51. /**
  52. * 根据id获取单条记录
  53. */
  54. public static function getMmInfo($id,$field = '*')
  55. {
  56. return self::select($field)->find($id);
  57. }}