public static function confirmAjax($mobile, $score) { $hd201509t3 = \app\models\MHd201509t3::findOne(['mobile' => $mobile]); $hd201509t3->status = 1; //提交状态 $hd201509t3->score = $score; $hd201509t3->create_time = date('y-m-d h:i:s', time()); $hd201509t3->save(false); $hd201509t4 = new \app\models\MHd201509t4(); $bm = \app\models\OpenidBindMobile::findOne(['mobile' => $mobile]); $hd201509t4->gh_id = $bm->gh_id; $hd201509t4->openid = $bm->openid; $hd201509t4->mobile = $mobile; $hd201509t4->score = $score; $hd201509t4->status = 1; $hd201509t4->create_time = date('y-m-d h:i:s', time()); $hd201509t4->save(false); return \yii\helpers\Json::encode(['code' => 0]); }
public function actionOfficeCampaignScorer() { $scorers = \app\models\MOfficeCampaignScorer::find()->all(); foreach ($scorers as $scorer) { $openidbindmobile = \app\models\OpenidBindMobile::findOne(['mobile' => $scorer->mobile]); if (empty($openidbindmobile)) { echo "{$scorer->name}({$scorer->mobile})手机未绑定。" . PHP_EOL; } $staffs = \app\models\MStaff::find()->where(['gh_id' => \app\models\MGh::GH_XIANGYANGUNICOM, 'mobile' => $scorer->mobile])->all(); if (empty($staffs)) { echo "{$scorer->name}({$scorer->mobile})不在Staff表中。" . PHP_EOL; $staff = new \app\models\MStaff(); } else { if (count($staffs) > 1) { echo "{$scorer->name}({$scorer->mobile})在Staff表中存在多项。" . PHP_EOL; $n = count($staffs); $selected = -1; for ($i = 0; $i < $n; $i++) { $staff = $staffs[$i]; if (empty($staff->openid) || $selected != -1) { $staff->delete(); } else { if (!empty($staff->openid)) { $selected = $i; } } } if ($selected == -1) { $staff = new \app\models\MStaff(); } else { $staff = $staffs[$selected]; } } else { $staff = $staffs[0]; } } $staff->gh_id = \app\models\MGh::GH_XIANGYANGUNICOM; $staff->name = $scorer->name; $staff->mobile = $scorer->mobile; $staff->cat = \app\models\MStaff::SCENE_CAT_IN; $staff->save(false); } }
public function actionCs4gCharge($filename = 'cs4g-charge.csv') { $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'imported_data' . DIRECTORY_SEPARATOR . $filename; $fh = fopen($filepathname, "r"); while (!feof($fh)) { $line = trim(fgets($fh)); if (empty($line) || strlen($line) == 0) { continue; } $fields = explode(",", $line); $charge_mobile = trim($fields[0]); $charge_ammount = trim($fields[1]); if (empty($charge_ammount) || strlen($charge_ammount) == 0 || $charge_ammount == 0) { continue; } if (empty($charge_mobile) || strlen($charge_mobile) == 0 || strlen($charge_mobile) != 11) { continue; } $openidbindmobile = \app\models\OpenidBindMobile::findOne(['gh_id' => \app\models\MGh::GH_XIANGYANGUNICOM, 'mobile' => $charge_mobile]); if (!empty($openidbindmobile)) { $wx_user = $openidbindmobile->user; if (!empty($wx_user)) { echo $wx_user->nickname . " mobile " . $charge_mobile . " charged " . $charge_ammount . PHP_EOL; $user_account = new \app\models\MUserAccount(); $user_account->gh_id = $wx_user->gh_id; $user_account->openid = $wx_user->openid; // $user_account->scene_id = $wx_user->staff->scene_id; $user_account->cat = \app\models\MUserAccount::CAT_DEBIT_FAN; $user_account->amount = $charge_ammount * 100; $user_account->memo = "4G测速"; $user_account->charge_mobile = $charge_mobile; $user_account->save(false); $user_account = new \app\models\MUserAccount(); $user_account->gh_id = $wx_user->gh_id; $user_account->openid = $wx_user->openid; // $user_account->scene_id = $wx_user->staff->scene_id; $user_account->cat = \app\models\MUserAccount::CAT_CREDIT_CHARGE_MOBILE; $user_account->amount = -$charge_ammount * 100; $user_account->memo = "4G测速"; $user_account->charge_mobile = $charge_mobile; $user_account->save(false); } else { echo "can't find charge mobile " . $charge_mobile . "({$charge_ammount})" . PHP_EOL; } } } fclose($fh); }
/** * Finds the OpenidBindMobile model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return OpenidBindMobile the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = OpenidBindMobile::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionHd201509t6() { $this->layout = false; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if (empty($wx_user) || $wx_user->subscribe === 0) { return $this->render('need_subscribe'); } $bindMobiles = \app\models\OpenidBindMobile::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if (empty($bindMobiles)) { $url = \yii\helpers\Url::to(); \Yii::$app->getSession()->set('RETURN_URL', $url); return $this->redirect(['wap/addbindmobile', 'gh_id' => $gh_id, 'openid' => $openid]); } $hd201509t5 = \app\models\MHd201509t5::findOne(['mobile' => $bindMobiles->mobile]); if (empty($hd201509t5)) { //不在能充值的用户表中,表明是新用户 $tcnx_flag = 0; $yfzx = ""; $fsc = ""; } else { if ($hd201509t5->tcnx == 1) { //76元套餐以下 $tcnx_flag = 1; } else { $tcnx_flag = 2; } $yfzx = $hd201509t5->yfzx; $fsc = $hd201509t5->fsc; } $hd201509t6 = \app\models\MHd201509t6::findOne(['mobile' => $bindMobiles->mobile]); if (empty($hd201509t6)) { $hd201509t6 = new \app\models\MHd201509t6(); $hd201509t6->gh_id = $gh_id; $hd201509t6->openid = $openid; $hd201509t6->mobile = $bindMobiles->mobile; $hd201509t6->status = 0; $hd201509t6->yfzx = $yfzx; $hd201509t6->fsc = $fsc; $hd201509t6->tcnx = $tcnx_flag; $hd201509t6->hbme = 0; $hd201509t6->save(false); } return $this->render('hd201509t6', ['observer' => $wx_user, 'hd201509t6' => $hd201509t6]); }
public static function run() { if (self::enable()) { self::sms('18971288549'); // warning self::sms('13545296480'); // warning $cnt = 1; // first round: 76+ customers $offset = 0; $limit = self::SINGLE_STEP_LIMIT; while (true) { $mobiles = MHd201509t5::find()->where(['tcnx' => 2])->orderBy('mobile DESC')->offset($offset)->limit($limit)->all(); foreach ($mobiles as $mobile) { $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => MGh::GH_XIANGYANGUNICOM, 'mobile' => $mobile->mobile]); if (empty($openid_bind_mobile)) { $smslog = SmsMarketingLog::findOne(['mobile' => $mobile->mobile]); if (empty($smslog)) { self::sms($mobile->mobile); // $smslog = new SmsMarketingLog; // $smslog->mobile = $mobile->mobile; // $smslog->first_sendtime = time(); // $smslog->last_sendtime = time(); // $smslog->send_count = 1; // $smslog->save(false); $cnt++; if ($cnt > self::dailyLimit()) { return; } } } } $offset += $limit; } // 2nd round, 76- customers $offset = 0; $limit = self::SINGLE_STEP_LIMIT; while (true) { $mobiles = MHd201509t5::find()->where(['tcnx' => 1])->orderBy('mobile DESC')->offset($offset)->limit($limit)->all(); foreach ($mobiles as $mobile) { $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => MGh::GH_XIANGYANGUNICOM, 'mobile' => $mobile->mobile]); if (empty($openid_bind_mobile)) { $smslog = SmsMarketingLog::findOne(['mobile' => $mobile->mobile]); if (empty($smslog)) { self::sms($mobile->mobile); // $smslog = new SmsMarketingLog; // $smslog->mobile = $mobile->mobile; // $smslog->first_sendtime = time(); // $smslog->last_sendtime = time(); // $smslog->send_count = 1; // $smslog->save(false); $cnt++; if ($cnt > self::dailyLimit()) { return; } } } } $offset += $limit; } // 3rd round, 76+ customers $offset = 0; $limit = self::SINGLE_STEP_LIMIT; $max_send_count = SmsMarketingLog::sendCountMax(); while (true) { $mobiles = MHd201509t5::find()->where(['tcnx' => 2])->orderBy('mobile DESC')->offset($offset)->limit($limit)->all(); foreach ($mobiles as $mobile) { $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => MGh::GH_XIANGYANGUNICOM, 'mobile' => $mobile->mobile]); if (empty($openid_bind_mobile)) { $smslog = SmsMarketingLog::findOne(['mobile' => $mobile->mobile]); if (!empty($smslog) && $smslog->send_count < $max_send_count) { self::sms($mobile->mobile); // $smslog->send_count++; // $smslog->last_sendtime = time(); // $smslog->save(false); $cnt++; if ($cnt > self::dailyLimit()) { return; } } } } $offset += $limit; } // 4th round, 76- customers $offset = 0; $limit = self::SINGLE_STEP_LIMIT; $max_send_count = SmsMarketingLog::sendCountMax(); while (true) { $mobiles = MHd201509t5::find()->where(['tcnx' => 1])->orderBy('mobile DESC')->offset($offset)->limit($limit)->all(); foreach ($mobiles as $mobile) { $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => MGh::GH_XIANGYANGUNICOM, 'mobile' => $mobile->mobile]); if (empty($openid_bind_mobile)) { $smslog = SmsMarketingLog::findOne(['mobile' => $mobile->mobile]); if (!empty($smslog) && $smslog->send_count < $max_send_count) { self::sms($mobile->mobile); // $smslog->send_count++; // $smslog->last_sendtime = time(); // $smslog->save(false); $cnt++; if ($cnt > self::dailyLimit()) { return; } } } } $offset += $limit; } } }
public function actionGroupmember($filename = 'groupmember.csv') { //$xyunicom = \app\models\WosoClient::findOne(['title_abbrev' => '襄阳联通']); //if (empty($xyunicom)) die('不能找到襄阳联通。'); $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . $filename; $fh = fopen($filepathname, "r"); while (!feof($fh)) { $line = trim(fgets($fh)); if (empty($line) || strlen($line) == 0) { continue; } $fields = explode(",", $line); $mobile = trim($fields[0]); $mobile_utf8 = iconv('GBK', 'UTF-8//IGNORE', $mobile); $office_title = trim($fields[1]); $office_title_utf8 = iconv('GBK', 'UTF-8//IGNORE', $office_title); $bind = OpenidBindMobile::findOne(['mobile' => $mobile]); if (!empty($bind)) { $user = MUser::findOne(['openid' => $bind->openid]); if (!empty($user)) { $office = MOffice::findOne(['title' => $office_title_utf8]); if (!empty($office)) { $user->belongto = $office->office_id; $user->save(false); } } } echo "done\n"; } fclose($fh); }
public function actionDeletebindmobile($id) { if (($model = OpenidBindMobile::findOne($id)) !== null) { $model->delete(); } return $this->redirect(['addbindmobile', 'gh_id' => $model->gh_id, 'openid' => $model->openid]); }
public function actionAddMemberTag($filename = 'data20150819.csv') { $file = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'imported_data' . DIRECTORY_SEPARATOR . $filename; $fh = fopen($file, "r"); $i = 0; while (!feof($fh)) { $line = fgets($fh); $i++; if (empty($line)) { continue; } $fields = explode(",", $line); $manager = trim($fields[0]); $manager_utf8 = iconv('GBK', 'UTF-8//IGNORE', $manager); $mobile = trim($fields[1]); $custom = \app\models\OpenidBindMobile::findOne(['mobile' => $mobile]); if (!empty($custom)) { echo $manager_utf8 . "," . $mobile . ",是" . "\n"; } else { echo $manager_utf8 . "," . $mobile . ",否" . "\n"; } } fclose($fh); }
protected function onScan() { $this->saveAccessLogAll(); $openid = $this->getRequest('FromUserName'); $gh_id = $this->getRequest('ToUserName'); $Event = $this->getRequest('Event'); $EventKey = $this->getRequest('EventKey'); if (!empty($EventKey)) { $Ticket = $this->getRequest('Ticket'); $scene_pid = $EventKey; // U::yjhu_W("EventKey=$EventKey, scene_pid=$scene_pid"); if ($scene_pid > 100000) { $real_sceneid = $scene_pid - 100000; $sceneid_mobile = SceneidMobile::getModelBySceneId($real_sceneid); if (!empty($sceneid_mobile)) { // U::yjhu_W($sceneid_mobile); $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => $gh_id, 'mobile' => $sceneid_mobile->mobile]); if (empty($openid_bind_mobile)) { $openid_bind_mobile = new OpenidBindMobile(); $openid_bind_mobile->gh_id = $gh_id; $openid_bind_mobile->openid = $openid; $openid_bind_mobile->mobile = $sceneid_mobile->mobile; $openid_bind_mobile->save(false); // U::yjhu_W($openid_bind_mobile); U::yjhu_W($sceneid_mobile->mobile . '扫码绑定至' . $gh_id . ' ' . $openid); SmsMarketingLog::member($sceneid_mobile->mobile); $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $url = \yii\helpers\Url::to(['wap/hyzx1', 'gh_id' => $gh_id, 'openid' => $openid], true); $respText = $user->nickname . ', 您已成功绑定手机号码' . $sceneid_mobile->mobile . ', 成为襄阳联通微信平台会员,直接点击进入<a href="' . $url . '">会员中心</a>!'; RedpackLog::sendRedpack($gh_id, $openid, $sceneid_mobile->mobile); return $this->responseText($respText); } else { $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $respText = $user->nickname . ', ' . $sceneid_mobile->mobile . '已绑定!'; return $this->responseText($respText); } } } } return Wechat::NO_RESP; }