| | |
| | | namespace app\common\model\supplier; |
| | | |
| | | use app\common\model\BaseModel; |
| | | use app\shop\model\auth\User as AuthUserModel; |
| | | use app\shop\model\auth\UserRole as UserRoleModel; |
| | | use app\common\model\shop\Role as RoleModel; |
| | | use app\common\model\supplier\member\Member as MemberModel; |
| | | use app\common\model\supplier\PointsLog as PointsLogModel; |
| | | |
| | | use app\shop\model\auth\UserRole as UserRoleModel; |
| | | use app\common\enum\supplier\SupplierType; |
| | | /** |
| | | * 商家供应商模型 |
| | | */ |
| | |
| | | { |
| | | protected $name = 'supplier'; |
| | | protected $pk = 'shop_supplier_id'; |
| | | protected $append = ['type_text','coordinate']; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | { |
| | | return $this->hasOne('app\\common\\model\\supplier\\User', 'shop_supplier_id', 'shop_supplier_id') |
| | | ->where('is_super','=', 1); |
| | | } |
| | | /** |
| | | * 供应商类型文本 |
| | | */ |
| | | public function getTypeTextAttr($value, $data) |
| | | { |
| | | return (new SupplierType())::getName(empty($data['supplier_type'])?0:$data['supplier_type']); |
| | | } |
| | | public function getCoordinateAttr($value, $data) |
| | | { |
| | | if (empty($data['latitude']) || empty($data['longitude'])) { |
| | | return ''; |
| | | } |
| | | return $data['latitude'].','.$data['longitude']; |
| | | } |
| | | /** |
| | | * 详情 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取供应商当前有效的年卡 |
| | | */ |
| | | public function getCurrentMember() |
| | | { |
| | | return MemberModel::getCurrentMember($this['shop_supplier_id'], $this['app_id']); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色管理的区域 |
| | | */ |
| | | public static function getAreaIdsByUser($user) |
| | |
| | | ->find(); |
| | | return empty($data['is_independent']) ? 0 : $data['is_independent']; |
| | | } |
| | | /** |
| | | * 冻结用户资金 |
| | | */ |
| | | public function freezeMoney($money) |
| | | { |
| | | $this->save(['money' => $this['money'] - $money,'freeze_money'=>$this['freeze_money']+$money]); |
| | | } |
| | | /** |
| | | * 直推供应商多少人 |
| | | */ |
| | | public function refereeSupplierCount ($referee_id) |
| | | { |
| | | $count = $this->where('referee_id', '=', $referee_id) |
| | | ->where('is_delete', '=', 0) |
| | | ->count(); |
| | | return $count; |
| | | } |
| | | |
| | | /** |
| | | * 下级商户数量 |
| | | * @param $user_id |
| | | * @return int |
| | | */ |
| | | public function getSubordinateNum($user_id) |
| | | { |
| | | return (new static())->where('is_delete', '=', 0) |
| | | ->where('referee_id', 'in', $user_id) |
| | | ->count(); |
| | | } |
| | | |
| | | } |