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

780 lines
30 KiB
PHTML

5 years ago
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Home\Controller;
use Think\Controller;
use Base\Repository\PromoteRepository;
5 years ago
use Base\Tool\TaskClient;
5 years ago
/**
* 扩展控制器
* 用于调度各个扩展的URL访问需求
*/
class SafeController extends BaseController{
public function setSafeIndex() {
$id = get_pid();
5 years ago
$safePwd = M('promote','tab_')->where(['id'=>$id])->field('second_pwd, level, login_phone')->find();
if(!empty($safePwd['login_phone'])) {
$this->assign('login_phone', $safePwd['login_phone']);
5 years ago
}
5 years ago
if ($safePwd['level'] != 1) {
return $this->error('非会长无法更改');
}
return $this->display();
// if(empty($safePwd['second_pwd'])) {
// return $this->display();
// }else {
// return $this->display("verifySafePwd");
// }
5 years ago
}
5 years ago
public function setSafePwd() {
$this->display('Public/setSafePwd');
}
5 years ago
public function setSafePassword() {
$password = $_REQUEST['password'];
$confirmpassword = $_REQUEST['confirm_password'];
if($password == "") {
$this->error("新密码不能为空");
}
if($confirmpassword == "") {
$this->error("确认密码不能为空");
}
if($password !== $confirmpassword) {
$this->error("两次密码不一致,请确认!");
}
$this->checkPaswwordFormat($confirmpassword);
$data['second_pwd'] = $this->think_ucenter_md5($confirmpassword, UC_AUTH_KEY);
$id = get_pid();
5 years ago
M("promote","tab_")->where(['id'=>$id])->save($data);
recordPromoteLogs('安全管理','设置安全密码');
$this->success("安全密码设置成功");
5 years ago
}
public function think_ucenter_md5($str, $key = 'ThinkUCenter')
{
return '' === $str ? '' : md5(sha1($str) . $key);
}
public function checkPaswwordFormat($confirmpwd) {
if(strlen($confirmpwd) < 6 || strlen($confirmpwd) > 24) {
$this->error("密码至少6位数,最多24位");
}
if(preg_match("/^\d*$/",$confirmpwd))
{
$this->error("密码必须包含字母,强度:弱");
}
if(preg_match("/^[a-z]*$/i",$confirmpwd))
{
$this->error("密码必须包含数字,强度:中");
}
if(!preg_match("/^[a-z\d]*$/i",$confirmpwd))
{
$this->error("密码只能包含数字和字母,强度:强");
}
}
public function modifyPwdIndex() {
5 years ago
$id = get_pid();
$promote = M('promote', 'tab_')->where(['id' => $id])->find();
if(!empty($promote['login_phone'])) {
$this->assign('login_phone', $promote['login_phone']);
}
5 years ago
if($_POST) {
5 years ago
if ($promote['level'] != 1) {
return $this->error('修改失败,非会长无法修改!');
5 years ago
}
5 years ago
//$oldpwd = $_POST['oldpwd'];
$safepwd = $_POST['safepwd'];
// if(empty($oldpwd)) {
// $this->error("旧密码不能为空");
// }
5 years ago
$this->checkPaswwordFormat($safepwd);
5 years ago
if(empty($safepwd)) {
$this->error("安全密码不能为空");
}
5 years ago
if (!$this->checksafecode($promote['login_phone'], $_POST['code'])) {
return $this->error('验证码错误');
5 years ago
}
5 years ago
$id = get_pid();
$data['second_pwd'] = $this->think_ucenter_md5($safepwd, UC_AUTH_KEY);
5 years ago
M("promote","tab_")->where(['id'=>$id])->save($data);
$this->success("修改成功");
5 years ago
}
5 years ago
5 years ago
$this->display();
}
5 years ago
public function ajaxVerifyCode($phone, $code)
{
if (!$this->checksafecode($phone, $code)) {
return $this->error('验证码错误');
} else {
return $this->success('验证成功');
}
}
5 years ago
public function verifySafePwd() {
if($_POST) {
$password = $_POST['safepwd'];
if($password == "" || $password == NULL) {
$this->error("密码不能为空");
}
$id = get_pid();
$safePwd = M('promote','tab_')->where(['id'=>$id])->field('second_pwd')->find();
if($safePwd['second_pwd'] == $this->think_ucenter_md5($password, UC_AUTH_KEY)){
$this->success("登陆成功,即将跳转",U('modifyPwdIndex'));
}
else {
$this->error('密码错误,请重新输入密码');
}
}
$this->display();
}
//修改登陆密码
public function modifyLoginPassword() {
if($_POST) {
$oldpwd = $_POST['oldpwd'];
$newpwd = $_POST['newpwd'];
$id = get_pid();
$pwd = M('promote','tab_')->where(['id'=>$id])->field('password')->find();
$password = $pwd["password"];
if($oldpwd != "0" && empty($oldpwd)) {
$this->error("旧密码不能为空");
return false;
}
if($newpwd != "0" && empty($newpwd)) {
$this->error("新密码不能为空");
return false;
}
if($this->think_ucenter_md5($oldpwd, UC_AUTH_KEY) !== $password) {
$this->error("请输入正确旧密码");
return false;
}
$this->checkPaswwordFormat($newpwd);
$data['password'] = $this->think_ucenter_md5($newpwd, UC_AUTH_KEY);
$updateRs = M('promote','tab_')->where(['id'=>$id])->save($data);
if($updateRs) {
5 years ago
recordPromoteLogs('安全管理','修改登陆密码');
5 years ago
$this->success("修改成功");
}else {
$this->error("修改失败");
return false;
}
}
$this->display();
}
//修改用户信息
public function modifyBaseInfo() {
4 years ago
$loginPromote = $this->getLoginPromote();
$id = $loginPromote['id'];
if(empty($loginPromote['second_pwd'])) {
5 years ago
$this->display('Public/setSafePwd');
exit;
}
5 years ago
$metaTitle = '基础信息';
$modelList = ['基础信息', $metaTitle];
$this->verifyPasswordView($modelList);
4 years ago
if($loginPromote['ver_status'] == 1) {
5 years ago
//return $this->display('editModify');
$this->redirect('editModify');
5 years ago
exit;
5 years ago
}
5 years ago
if($_POST) {
$username = $_REQUEST['username']; //真实姓名
$id_card = $_REQUEST["id_card"]; //身份证号码
$tel = $_REQUEST['tel'];
$address = $_REQUEST['s_province'].$_REQUEST['s_city'].$_REQUEST['s_county']; //省市县
$contactAddress = $_REQUEST['address']; //具体地址
// $userAddress = $address.'('.$contactAddress.')';
$userAddress[0] = $_REQUEST['s_province'].','.$_REQUEST['s_city'].','.$_REQUEST['s_county'];
$userAddress[1] = $contactAddress;
$email = $_REQUEST['email'];
$bank_name = $_REQUEST["bank_name"]; //开户银行
$bank_account = $_REQUEST['bank_account']; //银行账户名
$bank_card = $_REQUEST['bank_card']; //银行账号
$idcarpic = $_REQUEST['idcarpic'];
$businesspic = $_REQUEST['businesspic'];
$agreementpic = $_REQUEST['agreementpic'];
5 years ago
$alipayaccount = $_REQUEST['alipay_account'];
4 years ago
$alipayrealname = $_REQUEST['alipay_real_name'];
5 years ago
if(empty($_REQUEST['agree'])) {
$this->error("请先认真阅读协议,然后勾选协议");
return false;
}
if(empty($username)) {
$this->error("真实姓名不能为空");
return false;
}
if(empty($tel)) {
$this->error("手机号码不能为空");
return false;
}
$pattern = "/^1[3|5|7|8]\\d{9}$/i";
if(!preg_match($pattern, $tel)) {
$this->error("手机号码格式不合法");
return false;
}
4 years ago
$telInfo = M('promote','tab_')->field('id')->where("mobile_phone = $tel and id <> $id")->find();
5 years ago
if(!empty($telInfo)) {
$this->error("手机号码已存在");
return false;
}
5 years ago
if(empty($id_card)) {
$this->error("身份证号码不能为空");
return false;
}
if(empty($idcarpic)) {
$this->error("身份证证件照不能为空");
return false;
}
if(!is_idcard($id_card)) {
$this->error('证件号码错误');
return false;
}
if(empty($address)) {
$this->error("城市地址不能为空");
return false;
}
if(empty($contactAddress)) {
$this->error("联系地址不能为空");
}
if(empty($email)) {
$this->error("邮箱不能为空");
return false;
}
$patternemail = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
if (!preg_match($patternemail, $email)) {
$this->error('邮箱地址错误');
return false;
}
if(empty($bank_name)) {
$this->error("开户银行不能为空");
return false;
}
if(empty($bank_account)) {
4 years ago
$this->error("银行账户名不能为空");
5 years ago
return false;
}
$bank_account_pattern = "/^[\x{4e00}-\x{9fa5}]{2,}$/u";
if (!preg_match($bank_account_pattern, $bank_account)) {
4 years ago
$this->error('银行账户名格式错误');
5 years ago
return false;
}
if(empty($bank_card)) {
$this->error("卡号不能为空");
return false;
}
$bank_card_pattern = "/^\d{10,19}$/u";
if (!preg_match($bank_card_pattern, $bank_card)) {
$this->error('卡号格式错误');
return false;
}
5 years ago
if (empty($alipayaccount)) {
$this->error('支付宝账户不能为空');
return false;
}
// TODO::验证支付宝的账户格式
if (!preg_match("/^(?:1[3-9]\d{9}|[a-zA-Z\d._-]*\@[a-zA-Z\d.-]{1,10}\.[a-zA-Z\d]{1,20})$/", $alipayaccount)) {
$this->error('支付宝账户错误');
return false;
}
if (empty($alipayrealname)) {
$this->error('支付宝真实姓名不能为空');
return false;
}
if (!preg_match($bank_account_pattern, $alipayrealname)) {
$this->error('支付宝真实姓名错误');
return false;
}
5 years ago
$data["real_name"] = $username;
$data['mobile_phone'] = $tel;
$data['idcard'] = $id_card;
$data['address'] = json_encode($userAddress,FALSE);
$data['email'] = $email;
$data['bank_name'] = $bank_name;
$data['bank_account'] = $bank_account;
$data['bank_card'] = $bank_card;
$data['idcarpic'] = $idcarpic;
$data['businesspic'] = $businesspic;
$data['agreementpic'] = $agreementpic;
5 years ago
$data['ver_status'] = 3;
4 years ago
$data['alipay_account'] = $alipayaccount;
$data['alipay_real_name'] = $alipayrealname;
// if($account_type == "公司") {
// $data['account_type'] = 1;
// }else {
// $data['account_type'] = 2;
// }
5 years ago
$updateRs = M("promote","tab_")->where(['id'=>$id])->save($data);
if($updateRs) {
4 years ago
if ($loginPromote['level'] == 1 && $loginPromote['company_id'] > 0 && $loginPromote['withdraw_done'] == 1) {
4 years ago
M('promote_company', 'tab_')->where(['id' => $loginPromote['company_id']])->save([
'ali_account' => $alipayaccount,
4 years ago
'ali_user' => $alipayrealname,
]);
}
5 years ago
recordPromoteLogs('安全管理','修改用户信息');
5 years ago
$this->success("更新信息成功");
}else {
$this->error("更新信息失败");
}
4 years ago
} else {
5 years ago
$result = M("promote","tab_")->where(['id'=>$id])->select();
$promoteInfo = $result[0];
$idcarpic = $promoteInfo['idcarpic'];
$businesspic = $promoteInfo['businesspic'];
$agreementpic = $promoteInfo['agreementpic'];
$account_type = $promoteInfo['account_type'];
$address = $promoteInfo["address"];
if(!empty($idcarpic)) {
$idcarpicArr = explode(',', $idcarpic);
$str = '';
foreach ($idcarpicArr as $key => $value) {
$promoteInfo['valuedata'][$key] =$value;
}
}
if(!empty($businesspic)) {
$businesspicArr = explode(',', $businesspic);
$str = '';
foreach ($businesspicArr as $key1 => $value1) {
$promoteInfo['valuedata1'][$key1] =$value1;
}
}
if(!empty($agreementpic)) {
$agreementpicArr = explode(',', $agreementpic);
$str = '';
foreach ($agreementpicArr as $key2 => $value2) {
$promoteInfo['valuedata2'][$key2] =$value2;
}
}
if($account_type == 1) {
$promoteInfo['complanystatus'] = true;
$promoteInfo['personalstatus'] = false;
}else {
$promoteInfo['personalstatus'] = true;
$promoteInfo['complanystatus'] = false;
}
if(!empty(json_decode($address)) && count(json_decode($address)) >= 2) {
5 years ago
$addressArr = explode(',', json_decode($address)[0]);
$promoteInfo['addressdata'] = $addressArr;
5 years ago
$this->assign('addr',json_decode($address)[1]);
5 years ago
}
$promoteInfo['address'] = json_decode($address);
5 years ago
// 获取推广员的公司
$promoteCompany = M('promote_company', 'tab_')->where(['id'=>$promoteInfo['company_id']])->find();
if ($promoteCompany['service_agreement_show'] > 0) {
$serviceAgreement = M('service_agreement', 'tab_')->where(['id'=>$promoteCompany['service_agreement_show']])->find();
$serviceAgreement['content'] = $this->renderServiceAgreement($serviceAgreement['content'], $promoteInfo);
$this->assign("serviceAgreement",$serviceAgreement);
}
$this->assign("promoteCompany",$promoteCompany);
5 years ago
$this->assign("ver_status",$promoteInfo['ver_status']);
5 years ago
$this->assign('promoteinfo', $promoteInfo);
}
$this->display();
}
5 years ago
public function editModify() {
$id = get_pid();
5 years ago
$rs = M("promote","tab_")->field('anothpic,ver_status,real_name,bank_name,bank_card,bank_account,mobile_phone,email,address,idcard,alipay_account,alipay_real_name')->where(['id'=>$id])->find();
5 years ago
$anothpic = $rs['anothpic'];
$promoteInfo = "";
5 years ago
$address = json_decode($rs['address'],true);
5 years ago
$realname = mb_strlen($rs['real_name'],'utf-8') == 2 ? mb_substr($rs['real_name'],0,1,'utf-8').'*':mb_substr($rs['real_name'],0,1,'utf-8').'**';
5 years ago
$this->assign('addr',$address);
5 years ago
$this->assign('ver_status',$rs['ver_status']);
5 years ago
$this->assign('rs',$rs);
5 years ago
$this->assign('idcard',encryption($rs['idcard']));
$this->assign('real_name',$realname);
5 years ago
$this->assign('promoteInfo',$promoteInfo);
5 years ago
$this->assign('tel',encryption($rs['mobile_phone']));
5 years ago
$this->display();
5 years ago
}
5 years ago
public function edit() {
4 years ago
$loginPromote = $this->getLoginPromote();
5 years ago
$id = get_pid();
5 years ago
$tel = $_REQUEST["tel"];
5 years ago
$address1 = $_REQUEST["address"];
5 years ago
$email = $_REQUEST["email"];
5 years ago
//$account_type = $_REQUEST["account_type"];
$bank = $_REQUEST["bank_card"]; //银行账号
$bank_name = $_REQUEST["bank_name"]; //开户银行
$bank_account = $_REQUEST['bank_account']; //银行账户名
4 years ago
$agreementpic = $_REQUEST["agreementpic"] ?? '';
5 years ago
$alipayaccount = $_REQUEST['alipay_account'];
$alipayrealname = $_REQUEST['alipay_real_name'];
if(empty($tel)) {
$this->error("手机号码不能为空");
return false;
}
5 years ago
// 判断是否验证过手机号
// 获取最后一次验证的手机
5 years ago
// $lastVerified = M('sms_logs', 'tab_')->where(['mobile'=>$tel])->order('id desc')->find();
5 years ago
5 years ago
// if ($lastVerified['is_checked'] != 1) // 判断是否失效, 有效时间2分钟
// {
// $this->error("尚未验证过短信或者短信验证已失效,请重新验证");
// return false;
// } else if (time()-strtotime($lastVerified['created_at']) > 120) {
// $this->error("短信验证已失效,请重新验证");
// return false;
// }
5 years ago
$pattern = "/^1[3|5|7|8]\\d{9}$/i";
if(!preg_match($pattern, $tel)) {
$this->error("手机号码格式不合法");
return false;
}
5 years ago
$telInfo = M('promote','tab_')->field('id')->where(['mobile_phone'=>$tel, 'id'=>['neq'=>get_pid()]])->find();
5 years ago
if(!empty($telInfo)) {
$this->error("手机号码已存在");
return false;
}
if(empty($address1)) {
$this->error("地址不能为空");
return false;
}
if(empty($email)) {
$this->error("邮箱不能为空");
return false;
}
5 years ago
if(empty($bank_name)) {
$this->error("开户银行不能为空");
return false;
}
if(empty($bank_account)) {
$this->error("银行户名不能为空");
return false;
}
$bank_account_pattern = "/^[\x{4e00}-\x{9fa5}]{2,}$/u";
if (!preg_match($bank_account_pattern, $bank_account)) {
$this->error('银行卡开户人姓名错误');
return false;
}
$patternemail = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
if (!preg_match($patternemail, $email)) {
$this->error('邮箱地址错误');
return false;
}
if(empty($bank)) {
$this->error("卡号不能为空");
return false;
}
$bank_card_pattern = "/^\d{10,19}$/u";
if (!preg_match($bank_card_pattern, $bank)) {
$this->error('卡号格式错误');
return false;
}
4 years ago
// if(empty($agreementpic)) {
// $this->error("补充协议不能为空");
// return false;
// }
5 years ago
if (empty($alipayaccount)) {
$this->error('支付宝账户不能为空');
return false;
}
// TODO::验证支付宝的账户格式
if (!preg_match("/^(?:1[3-9]\d{9}|[a-zA-Z\d._-]*\@[a-zA-Z\d.-]{1,10}\.[a-zA-Z\d]{1,20})$/", $alipayaccount)) {
$this->error('支付宝账户错误');
return false;
}
if (empty($alipayrealname)) {
$this->error('支付宝真实姓名不能为空');
return false;
}
if (!preg_match($bank_account_pattern, $alipayrealname)) {
$this->error('支付宝真实姓名错误');
return false;
}
5 years ago
$Res = M("promote","tab_")->field('address')->where(['id'=>$id])->find();
5 years ago
$address = json_decode($Res['address'],true);
5 years ago
$address[1] = $address1;
5 years ago
$data['mobile_phone'] = $tel;
5 years ago
$data['address'] = json_encode($address,TRUE);
5 years ago
$data['email'] = $email;
5 years ago
//$data['account_type'] = $account_type;
5 years ago
$data['bank_card'] = $bank;
5 years ago
$data['bank_name'] = $bank_name;
$data['bank_account'] = $bank_account;
5 years ago
$data['ver_status'] = 4;
5 years ago
$data['alipay_account'] = $alipayaccount;
$data['alipay_real_name'] = $alipayrealname;
5 years ago
// $data['agreementpic'] = $
4 years ago
$agreementpic ? $data['anothpic'] = $agreementpic : null;
5 years ago
$id = get_pid();
$updateRs = M("promote","tab_")->where(['id'=>$id])->save($data);
4 years ago
if($updateRs) {
if ($loginPromote['level'] == 1 && $loginPromote['company_id'] > 0 && $loginPromote['withdraw_done'] == 1) {
4 years ago
M('promote_company', 'tab_')->where(['id' => $loginPromote['company_id']])->save([
'ali_account' => $alipayaccount,
4 years ago
'ali_user' => $alipayrealname,
]);
5 years ago
}
4 years ago
recordPromoteLogs('安全管理','二次修改信息');
$this->success("更新信息成功",U('modifyBaseInfo'));
}else {
$this->error("更新信息失败");
}
5 years ago
}
public function ajaxEdit() {
$id = get_pid();
5 years ago
$rs = M("promote","tab_")->field('mobile_phone,login_phone,address,email,account_type,bank_name,bank_card,bank_account,anothpic,alipay_account,alipay_real_name')->where(['id'=>$id])->find();
5 years ago
$this->assign('tel',$rs['mobile_phone']);
$this->assign('address',$rs['address']);
$this->assign('email',$rs['email']);
$this->assign('account_type',$rs['account_type']);
$this->assign('bank_card',$rs['bank_card']);
$res = [
'tel'=> $rs['mobile_phone'],
5 years ago
'login_phone' => $rs['login_phone'],
5 years ago
'address'=> json_decode($rs['address'],true)[1],
5 years ago
'email'=> $rs['email'],
'account_type'=> $rs['account_type'],
'bank_card'=> $rs['bank_card'],
5 years ago
'bank_name'=> $rs['bank_name'],
'bank_account'=> $rs['bank_account'],
5 years ago
'idcarpic' => $rs['idcarpic'],
5 years ago
'anothpic' => $rs['anothpic'],
5 years ago
'alipay_account' => $rs['alipay_account'],
'alipay_real_name' => $rs['alipay_real_name'],
5 years ago
];
if($rs['account_type'] == 1) {
$res['complanystatus'] = true;
$res['personalstatus'] = false;
}else {
$res['personalstatus'] = true;
$res['complanystatus'] = false;
}
$this->ajaxReturn($res);
}
5 years ago
public function safeDocument($templateId=0) {
$template = M('service_agreement', 'tab_')->where(['id'=>$templateId])->find();
$promoteInfo = $this->getLoginPromote();
$sn = date('Ymd') . '-' . strtoupper(substr(md5($promoteInfo['id']), 8, 16));
$content = $template['content'];
$content = str_replace("{time}", date('Y-m-d'), $content);
$content = str_replace("{sn}", $sn, $content);
$content = str_replace("{endTime}", date('Y-m-d',strtotime('+1 year')), $content);
$content = str_replace("{account}", $promoteInfo['account'], $content);
$content = str_replace("{email}", $promoteInfo['email'], $content);
$content = str_replace("{realname}", $promoteInfo['real_name'], $content);
$content = str_replace("{phone}", $promoteInfo['mobile_phone'], $content);
5 years ago
$content = str_replace("{address}", json_decode($promoteInfo['address'],true)[1] ?? '', $content);
5 years ago
// $realname = $_REQUEST['realname'];
// $phone = $_REQUEST['phone'];
// $email = $_REQUEST['email'];
// $address = $_REQUEST['address'];
// if (empty($realname)) {
// $realname = '您未填写真实姓名';
// }
// if (empty($email)) {
// $email = '您未填写联系邮箱';
// }
// if (empty($address)) {
// $address = '您未填写注册地址';
// }
// if (empty($phone)) {
// $phone = '您未填写联系号码';
// }
// $time = time();
// $loginPromote = $this->getLoginPromote();
// $endTime = date('Y-m-d',strtotime('+1 year'));
// $this->assign('time',date('Y-m-d',$time));
// $this->assign('endTime',$endTime);
// $this->assign('sn',$sn);
// $this->assign('realname',$realname);
// $this->assign('email',$email);
// $this->assign('address',$address);
// $this->assign('phone',$phone);
$this->assign('content', $content);
$this->display();
}
5 years ago
5 years ago
private function renderServiceAgreement($content, $promoteInfo)
{
$content = str_replace("{account}", $promoteInfo['account'], $content);
$content = str_replace("{email}", $promoteInfo['email'], $content);
$content = str_replace("{real_name}", $promoteInfo['real_name'], $content);
$content = str_replace("{mobile_phone}", $promoteInfo['mobile_phone'], $content);
$content = str_replace("{addr}", $promoteInfo['addr'], $content);
return $content;
}
5 years ago
public function promoteLogs() {
$page = intval(I('p', 1));
$row = intval(I('row', 10));
$user_account = I('user_account');
$action_type = I('action_type');
$begTime = strtotime(I('begtime'));
$endTime = strtotime(I('endtime'));
$id = get_pid();
$loginPromote = $this->getLoginPromote();
$map1['chain'] = ['like', $loginPromote['chain'] . $loginPromote['id'] . '/%'];
$ids = M('promote', 'tab_')->where($map1)->getField('id', true);
$ids[] = $loginPromote['id'];
$map = [];
$map['promote_id'] = ['in', $ids];
if (!empty($user_account)) {
$map['promote'] = ['like','%'.$user_account.'%'];
}
if (!empty($action_type)) {
$map['action_type'] = ['like','%'.$action_type.'%'];
}
if (!empty($begTime) && !empty($endTime)) {
$map['create_time'] = ['between', [$begTime, $endTime + 24*3600 - 1]];
}else if (empty($begTime) && !empty($endTime)) {
$map['create_time'] = ['elt',$endTime + 24*3600];
}else if (!empty($begTime) && empty($endTime)) {
$map['create_time'] = ['EGT',$begTime + 24*3600];
}
$page = intval(I('get.p', 1));
$page = $page ? $page : 1; //默认显示第一页数据arraypage
$rs = M('promote_action_logs','tab_')->where($map)->order('create_time DESC')
5 years ago
->page($page, $row)->select();
foreach($rs as $key => $v) {
$rs[$key]['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
}
$count = M('promote_action_logs', 'tab_')
->field('id')
->where($map)
->select();
$count = count($count);
//分页
$parameter['p'] = $page;
$parameter['row'] = $row;
$parameter['begtime'] = I('begtime');
$parameter['endtime'] = I('endtime');
$parameter['user_account'] = $user_account;
$parameter['action_type'] = $action_type;
$page = set_pagination($count, $row, $parameter);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('listData',$rs);
$this->assign('initBegTime', I('begtime'));
$this->assign('initEndTime', I('endtime'));
$this->display();
}
public function deletePromoteLogs() {
$id = $_REQUEST['id'];
$rs = M('promote_action_logs','tab_')->where(['id'=>$id])->delete();
if($rs) {
$this->ajaxReturn(['code'=>0000,'mes'=>'删除成功']);
}
}
5 years ago
public function bindTel() {
$id = get_pid();
$promote = M('promote', 'tab_')->where(['id' => $id])->find();
if(!empty($promote['login_phone'])) {
$this->assign('login_phone', $promote['login_phone']);
}
return $this->display();
}
/**
* 发动手机验证码
*/
5 years ago
public function telsafecode($phone = '', $exceptExists=1, $delay = 10, $flag = true)
5 years ago
{
5 years ago
$exists = M('promote', 'tab_')->where(['login_phone'=>$phone])->find();
if (!$exceptExists) {
if ($exists) {
return $this->ajaxReturn(['status'=>0,'msg'=>'手机号已被绑定']);
}
} else {
if (!$exists) {
return $this->ajaxReturn(['status'=>0,'msg'=>'手机号未被绑定']);
}
}
5 years ago
$taskClient = new TaskClient();
$result = $taskClient->sendSmsCode($phone, get_client_ip());
$data = [];
if ($result['code'] == TaskClient::SUCCESS) {
$data['status'] = 1;
} else {
$data['status'] = 0;
}
$data['msg'] = $result['message'];
echo json_encode($data);
exit;
}
/**
* 手机安全码验证
*/
public function checksafecode($phone, $code)
{
$taskClient = new TaskClient();
$result = $taskClient->checkSms($phone, $code);
$data = [];
if ($result && $result['code'] == TaskClient::SUCCESS) {
return true;
} else {
return false;
}
}
5 years ago
public function addLoginMobile() {
5 years ago
if (IS_POST) {
/* 检测验证码 TODO: */
5 years ago
$mobile = $_POST['login_phone'];
$verify = $_POST['code'];
5 years ago
if (!$this->checksafecode($mobile, $verify)) {
$this->error('验证码错误');
}
$id = get_pid();
$promote = M('promote', 'tab_')->where([
'id' => $id
])->find();
if ($promote) {
$promote['login_phone'] = $mobile;
$updateRs = M('promote', 'tab_')->where(['id' => $id])->save($promote);
if($updateRs) {
$this->success("更新登陆手机号成功");
}else {
$this->error("更新登陆手机号失败");
}
}else {
$this->error("无此推广账号信息");
}
}
}
5 years ago
}