public static function addOutletAgent($agent_name, $agent_mobile, $agent_position, $outlet_id) { $outlet = \app\models\ClientOutlet::findOne(['outlet_id' => $outlet_id]); if (empty($outlet)) { return json_encode(['code' => -1, 'errMsg' => "门店不存在!({$outlet_id})"]); } $agent = self::find()->join('INNER JOIN', 'client_agent_mobile', 'client_agent.agent_id=client_agent_mobile.agent_id')->where(['name' => $agent_name, 'mobile' => $agent_mobile])->one(); if (!empty($agent)) { // return json_encode([ // 'code' => -1, // 'errMsg' => "{$agent_name}({$agent_mobile})已存在!", // ]); } else { $agent = new self(); $agent->name = $agent_name; $agent->save(false); \Yii::$app->db->createCommand()->insert('client_agent_mobile', ['agent_id' => $agent->agent_id, 'mobile' => $agent_mobile])->execute(); } $row = (new \yii\db\Query())->select('*')->from('client_agent_outlet')->where(['agent_id' => $agent->agent_id, 'outlet_id' => $outlet->outlet_id])->one(); if (false === $row) { \Yii::$app->db->createCommand()->insert('client_agent_outlet', ['agent_id' => $agent->agent_id, 'outlet_id' => $outlet->outlet_id, 'position' => $agent_position])->execute(); } else { return json_encode(['code' => -1, 'errMsg' => "{$agent_name}({$agent_mobile})已存在门店{$outlet->title}中!"]); } return json_encode(['code' => 0]); }
public function actionAgent($filename = 'agent.csv') { $xyunicom = \app\models\WosoClient::findOne(['title_abbrev' => '襄阳联通']); if (empty($xyunicom)) { die('不能找到襄阳联通。'); } $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'imported_data' . DIRECTORY_SEPARATOR . $filename; $fh = fopen($filepathname, "r"); while (!feof($fh)) { $contact_person = trim($fields[0]); $contact_person_utf8 = iconv('GBK', 'UTF-8//IGNORE', $contact_person); $msc_brev_name = trim($fields[1]); $msc_brev_name_utf8 = iconv('GBK', 'UTF-8//IGNORE', $msc_brev_name); $title = trim($fields[2]); $title_utf8 = iconv('GBK', 'UTF-8//IGNORE', $title); $mobiles = explode(';', trim($fields[3])); // echo "{$contact_person_utf8},{$msc_brev_name_utf8},{$title_utf8},{$fields[3]}".PHP_EOL; $supervision_organization = \app\models\ClientOrganization::find()->where(['like', 'title', $msc_brev_name_utf8])->andWhere(['client_id' => $xyunicom->client_id])->one(); // $supervision_organization = \Yii::$app->db->createCommand('select * from client_organization where title like \'%:title%\'') // ->bindValue(':title', $msc_brev_name_utf8)->queryOne(); if (empty($supervision_organization)) { die("找不到{$msc_brev_name_utf8}"); } // var_dump($supervision_organization); $row = false; foreach ($mobiles as $mobile) { $mobile = trim($mobile); $row = (new \yii\db\Query())->select('*')->from('client_agent')->join('INNER JOIN', 'client_agent_mobile', ['client_agent.agent_id' => 'client_agent_mobile.agent_id'])->where(['name' => $contact_person_utf8, 'mobile' => $mobile])->one(); if (false !== $row) { break; } } if (false !== $row) { $agent = \app\models\ClientAgent::findOne(['agent_id' => $row['agent_id']]); } else { $agent = new \app\models\ClientAgent(); $agent->name = $contact_person_utf8; $agent->save(false); } $outlet = \app\models\ClientOutlet::findOne(['title' => $title_utf8]); if (empty($outlet)) { $outlet = new \app\models\ClientOutlet(); $outlet->title = $title_utf8; $outlet->client_id = $xyunicom->client_id; $outlet->telephone = $fields[3]; $outlet->category = \app\models\ClientOutlet::CATEGORY_COOPERATED; $outlet->supervison_organization_id = $supervision_organization->organization_id; $outlet->save(false); } else { $outlet->client_id = $xyunicom->client_id; $outlet->telephone = $fields[3]; $outlet->category = \app\models\ClientOutlet::CATEGORY_COOPERATED; $outlet->supervison_organization_id = $supervision_organization->organization_id; $outlet->save(false); } $row = (new \yii\db\Query())->select('*')->from('client_agent_outlet')->where(['agent_id' => $agent->agent_id, 'outlet_id' => $outlet->outlet_id])->one(); if (false === $row) { \Yii::$app->db->createCommand()->insert('client_agent_outlet', ['agent_id' => $agent->agent_id, 'outlet_id' => $outlet->outlet_id, 'position' => '店主'])->execute(); } foreach ($mobiles as $mobile) { if (strlen($mobile) != 11 || !is_numeric($mobile)) { echo "[{$mobile}]非手机号码." . PHP_EOL; } else { $row = (new \yii\db\Query())->select('*')->from('client_agent_mobile')->where(['mobile' => $mobile])->one(); if (false === $row) { \Yii::$app->db->createCommand()->insert('client_agent_mobile', ['agent_id' => $agent->agent_id, 'mobile' => $mobile])->execute(); } } } } fclose($fh); }
public function actionClientOutletEmployeeEdit($gh_id, $openid, $backwards = true, $pop = false) { if (!$backwards) { \app\models\utils\BrowserHistory::delete($gh_id, $openid); \app\models\utils\BrowserHistory::push($gh_id, $openid); } else { if ($pop) { \app\models\utils\BrowserHistory::pop($gh_id, $openid); } else { \app\models\utils\BrowserHistory::push($gh_id, $openid); } } $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $this->layout = false; $is_agent = $_GET['is_agent']; $outlet_id = $_GET['outlet_id']; if ($is_agent) { $agent_id = $_GET['entity_id']; $entity = \app\models\ClientAgent::findOne(['agent_id' => $agent_id]); } else { $employee_id = $_GET['entity_id']; $entity = \app\models\ClientEmployee::findOne(['employee_id' => $employee_id]); } $outlet = \app\models\ClientOutlet::findOne(['outlet_id' => $outlet_id]); return $this->render('client-outlet-employee-edit', ['wx_user' => $wx_user, 'entity' => $entity, 'is_agent' => $is_agent, 'outlet' => $outlet, 'backwards' => $backwards]); }
<header class="bar bar-nav"> <a class="icon icon-left-nav pull-left" id="btn_back" onclick="back2pre();"></a> <h1 class="title"> <!-- <img src="../web/images/comm-icon/iconfont-liwu.png?v5" width="18"> --> 员工管理 </h1> </header> <?php $outlet = \app\models\ClientOutlet::findOne(['outlet_id' => $outlet_id]); ?> <!-- Wrap all non-bar HTML in the .content div (this is actually what scrolls) --> <div class="content"> <p class="content-padded"> <table width="100%" border=0 style="padding:3px;text-align:center"> <tr> <td width=100%> <button class="btn btn-positive btn-block"> <?php echo $outlet->title; ?> 员工总数
/** * Finds the ClientOutlet model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return ClientOutlet the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ClientOutlet::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionYgglxiugaiajax() { $is_agent = $_GET['is_agent']; $entity_id = $_GET['entity_id']; $outlet_id = $_GET['outlet_id']; $mobile = $_GET['mobile']; $position = $_GET['position']; $outlet = \app\models\ClientOutlet::findOne(['outlet_id' => $outlet_id]); if ($is_agent) { $ret = $outlet->alterAgent($entity_id, $mobile, $position); } else { $ret = $outlet->alterEmployee($entity_id, $mobile, $position); } if (false === $ret) { return json_encode(['code' => -1]); } else { return json_encode(['code' => 0]); } }