Exemplo n.º 1
0
 public function getPromoter($gh_id)
 {
     if (empty($this->original_office_id)) {
         $office = new \app\models\MOffice();
         $office->title = $this->title;
         $office->gh_id = $gh_id;
         $office->save(false);
         $this->updateAttributes(['original_office_id' => $office->office_id]);
     }
     $promoter = \app\models\MStaff::find()->where(['office_id' => $this->original_office_id, 'gh_id' => $gh_id, 'cat' => \app\models\MStaff::SCENE_CAT_OFFICE])->one();
     if (empty($promoter)) {
         $promoter = new \app\models\MStaff();
         $promoter->name = $this->title;
         $promoter->office_id = $this->original_office_id;
         $promoter->gh_id = $gh_id;
         $promoter->cat = \app\models\MStaff::SCENE_CAT_OFFICE;
         $promoter->save(false);
     }
     return $promoter;
 }
Exemplo n.º 2
0
 public function getPromoter($gh_id)
 {
     $promoter = \app\models\MStaff::find()->where(['name' => $this->name, 'gh_id' => $gh_id])->andWhere(['in', 'mobile', $this->mobiles])->one();
     if (empty($promoter)) {
         $promoter = new \app\models\MStaff();
         $promoter->name = $this->name;
         $promoter->mobile = !empty($this->mobiles) ? $this->mobiles[0] : '';
         $promoter->gh_id = $gh_id;
         $promoter->cat = \app\models\MStaff::SCENE_CAT_IN;
         $promoter->save(false);
     }
     return $promoter;
 }