public function FinalRenewals() { $CustomersProjectID = $this->_POST['CustoProID']; $Year = $this->_POST['ryear']; $LogsFunction = new LogsFunction(); $CustProModule = new CustProModule(); $CustProInfo = $CustProModule->GetOneInfoByKeyID($CustomersProjectID); //获取项目版本名称 $vesion = $this->GetGBaoPenVesion($CustProInfo['GongNeng']); $CustomersModule = new CustomersModule(); $CustomersInfo = $CustomersModule->GetOneInfoByKeyID($CustProInfo['CustomersID']); //验证项目id是否属于本代理 if ($CustProInfo['AgentID'] == $_SESSION['AgentID']) { $data = $this->GetRenewals($CustomersProjectID, $Year); $AgentAccountModule = new AgentAccountModule(); //获取G宝盆项目id $ProjectId = TONGYI_ID; $sqlwhere = "where Agentid={$_SESSION['AgentID']} and ProjectID={$ProjectId}"; $AgentAccountInfo = $AgentAccountModule->GetLists($sqlwhere); if ($AgentAccountInfo[0]['Balance'] < $data['StandardCost']) { $LogsFunction->logsinfile('115', 4, $CustomersID); JsMessage('账户余额不足,请充值!', UrlRewriteSimple($this->MyModule, 'Customer', true) . '&Page=' . $Page, '继续操作'); exit; } else { $update['EndTime'] = date('Y-m-d H:i:s', strtotime("{$CustProInfo['EndTime']}+{$Year} years")); $LogOldEndTime = date('Y-m-d', strtotime($CustProInfo['EndTime'])); $LogEndTime = date('Y-m-d', strtotime($update['EndTime'])); $update['UpdateTime'] = date('Y-m-d H:i:s'); $filter['CustomersProjectID'] = $CustomersProjectID; $filter['ProjectID'] = intval($ProjectId); $filter['AgentID'] = intval($_SESSION['AgentID']); $a = $CustProModule->UpdateArray($update, $filter); $sql = "update {$AgentAccountModule->TableName} set Balance=Balance-{$data['StandardCost']} where Agentid={$_SESSION['AgentID']} and ProjectID={$ProjectId}"; //dd($sql); $b = $AgentAccountModule->Update($sql); if ($a) { $OrderModule = new OrderModule(); $OrderDescriptionModule = new OrderDescriptionModule(); $Description['Description'] = $CustomersInfo['CompanyName'] . $vesion . 'G宝盆项目续费成功:原定到期时间' . $LogOldEndTime . '+' . $Year . '年=' . $LogEndTime . ',消费金额¥' . $data['StandardCost'] . '(' . $data['AgenDiscount'] . '折)'; $OrderDescriptionModule->InsertArray($Description); $DescriptionID = mysql_insert_id(); $Order['OrderNO'] = GetOrderNO(); $Order['AgentID'] = $filter['AgentID']; $Order['CustomersID'] = $CustProInfo['CustomersID']; $Order['AddTime'] = $update['UpdateTime']; $Order['FromIP'] = GetIP(); $Order['ProjectID'] = $filter['ProjectID']; $Order['DescriptionID'] = $DescriptionID; $Order['Type'] = 0; $Order['Amount'] = $data['StandardCost']; $OrderModule->InsertArray($Order); $LogsFunction->logsinfile('115', 1, $CustomersID, '', $Order['OrderNO']); $Sync = $this->ToGbaoPenEditInfo($CustomersProjectID); if ($Sync) { $LogsFunction->logsinfile('115', 5, $CustomersID, $Description['Description'], $Order['OrderNO']); } else { $LogsFunction->logsinfile('115', 6, $CustomersID, $Description['Description'], $Order['OrderNO']); } JsMessage('续费成功!', UrlRewriteSimple($this->MyModule, 'Customer', true) . '&Page=' . $Page, '继续操作'); } else { $LogsFunction->logsinfile('115', 0, $CustomersID); JsMessage('续费失败!', UrlRewriteSimple($this->MyModule, 'Customer', true) . '&Page=' . $Page, '继续操作'); exit; } } } else { $LogsFunction->logsinfile('115', 3, $CustomersID); JsMessage('警告!非法操作...', UrlRewriteSimple($this->MyModule, 'Customer', true) . '&Page=' . $Page, '继续操作'); exit; } }
public function FinalRenewals() { $CustomersProjectID = intval($this->_POST['CustoProID']); $Year = $this->_POST['ryear']; $Across = $this->_POST['across']; $Page = _intval($this->_GET['Page']); $LogsFunction = new LogsFunction(); $CustProModule = new CustProModule(); $where = "where CustomersProjectID={$CustomersProjectID} and AgentID={$_SESSION['AgentID']}"; $CustProInfo = $CustProModule->GetInfoByWhere($where); $time = date('H:i:s'); $NewEndTime = $Year . ' ' . $time; if (empty($CustProInfo)) { JsMessage('数据错误或者非法操作!', UrlRewriteSimple('FengXin', 'Customer', true) . '&Page=' . $Page, '继续操作'); } else { $Version = $CustProInfo['GongNeng']; $PropertyModule = new PropertyModule(); $PropertyInfo = $PropertyModule->GetOneInfoByKeyID($Version); $MarketPrice = $PropertyInfo['MarketPrice']; //获取当前代理的等级 $AgentModule = new AgentModule(); $Agentinfo = $AgentModule->GetOneInfoByKeyID($_SESSION['AgentID']); $LevelID['AgentPriceID'] = $Agentinfo['FengXinAgentPriceID']; //获取该等级的折扣 $AgentPriceModule = new AgentPriceModule(); $AgentPriceinfo = $AgentPriceModule->GetOneInfoByArrayKeys($LevelID); $AgenDiscount = $AgentPriceinfo['AgenDiscount']; $CustomersModule = new CustomersModule(); $CustomersInfo = $CustomersModule->GetOneInfoByKeyID($CustProInfo['CustomersID']); $CustomersID = $CustomersInfo['CustomersID']; $OldEndTime = date('Y-m-d', strtotime($CustProInfo['EndTime'])); $cost = 0; $description = ''; $sql_version = ''; if (strtotime($Year) > strtotime($OldEndTime)) { $sql_version = "update tb_customers_project set EndTime ='{$NewEndTime}' where CustomersProjectID={$CustomersProjectID}"; $update1 = $CustProModule->UpdateArrayByKeyID($update1, $CustomersProjectID); $versioncost = (strtotime($Year) - strtotime($OldEndTime)) / (3600 * 24) * $MarketPrice * $AgenDiscount / 365; $cost += $versioncost; $description .= '版本约消费¥' . round($versioncost); } $CustFuwuModule = new CustFuwuModule(); $mysqlwhere = "where CustomersProjectID={$CustomersProjectID}"; $CustFuwuInfo = $CustFuwuModule->GetAll($mysqlwhere); $FuwuModule = new FuwuModule(); foreach ($CustFuwuInfo as $v) { $FuwuEndTime = date('Y-m-d', strtotime($v['EndTime'])); $FuwuInfo = $FuwuModule->GetOneInfoByKeyID($v['FuWuID']); $FuWuPrice = $FuwuInfo['FuWuPrice']; $FuWuName = $FuwuInfo['FuWuName']; $filter['FuWuID'] = intval($v['FuWuID']); $filter['CustomersProjectID'] = $CustomersProjectID; if (strtotime($FuwuEndTime) < strtotime(date('Y-m-d'))) { $FuwuEndTime = date('Y-m-d'); } if (in_array($v['FuWuID'], $Across)) { if (strtotime($Year) > strtotime($FuwuEndTime)) { $sqlfuwu[$FuWuName] = "update tbl_customers_fuwu set EndTime ='{$NewEndTime}' where FuWuID={$v['FuWuID']} and CustomersProjectID={$CustomersProjectID}"; $fuwucost = (strtotime($Year) - strtotime($FuwuEndTime)) / (3600 * 24) * $FuWuPrice * $AgenDiscount / 365; $cost += $fuwucost; $description .= ',' . $FuWuName . '约消费¥' . round($fuwucost); } } else { $array_search = array($FuWuName => $FuwuInfo['EndTime']); $seletname = 'upselect' . $v['FuWuID']; $selectEndTime = $this->_POST["{$seletname}"]; if (strtotime($selectEndTime) > strtotime($FuwuEndTime)) { $update3['EndTime'] = $selectEndTime . ' ' . $time; $sqlfuwu[$FuWuName] = "update tbl_customers_fuwu set EndTime ='{$update3['EndTime']}' where FuWuID={$v['FuWuID']} and CustomersProjectID={$CustomersProjectID}"; $fuwucost = (strtotime($selectEndTime) - strtotime($FuwuEndTime)) / (3600 * 24) * $FuWuPrice * $AgenDiscount / 365; $cost += $fuwucost; $description .= ',' . $FuWuName . '约消费¥' . round($fuwucost); } } } $cost = round($cost); $description .= ',合计消费¥' . $cost; //代理扣款 $AgentAccountModule = new AgentAccountModule(); $ProjectId = FENGXIN_ID; $sqlwhere = "where Agentid={$_SESSION['AgentID']} and ProjectID={$ProjectId}"; $AgentAccountInfo = $AgentAccountModule->GetLists($sqlwhere); if ($AgentAccountInfo[0]['Balance'] < $cost) { JsMessage('余额不足!', UrlRewriteSimple('FengXin', 'Customer', true) . '&Page=' . $Page, '继续操作'); } else { $sql = "update {$AgentAccountModule->TableName} set Balance=Balance-{$cost} where Agentid={$_SESSION['AgentID']} and ProjectID={$ProjectId}"; $b = $AgentAccountModule->Update($sql); if ($b) { if ($sql_version == '' || mysql_query($sql_version)) { } else { $description .= '(版本已扣款未延期到' . $Year . ',此次续费需手动操作!)'; } foreach ($sqlfuwu as $k => $s) { if (mysql_query($s)) { } else { $description .= '(' . $array_search[$k] . '已扣款未延期到,此次续费需手动操作!)'; } } $OrderModule = new OrderModule(); $OrderDescriptionModule = new OrderDescriptionModule(); $Description['Description'] = $CustomersInfo['CompanyName'] . '本次续费' . $description; $OrderDescriptionModule->InsertArray($Description); $DescriptionID = mysql_insert_id(); $Order['OrderNO'] = GetOrderNO(); $Order['AgentID'] = $_SESSION['AgentID']; $Order['CustomersID'] = $CustomersID; $Order['AddTime'] = date('Y-m-d') . ' ' . $time; $Order['FromIP'] = GetIP(); $Order['ProjectID'] = $ProjectId; $Order['DescriptionID'] = $DescriptionID; $Order['Type'] = 0; $Order['Amount'] = $cost; $OrderModule->InsertArray($Order); $LogsFunction->logsinfile('109', 1, $CustomersID, '', $Order['OrderNO']); $Sync = $this->ToFengXinEditInfo($CustomersProjectID); if ($Sync) { $LogsFunction->logsinfile('109', 5, $CustomersID, $Description['Description'], $Order['OrderNO']); } else { $LogsFunction->logsinfile('109', 6, $CustomersID, $Description['Description'], $Order['OrderNO']); } JsMessage('续费成功!', UrlRewriteSimple('FengXin', 'Customer', true) . '&Page=' . $Page, '继续操作'); } else { JsMessage('续费异常!', UrlRewriteSimple('FengXin', 'Customer', true) . '&Page=' . $Page, '继续操作'); } } } }
public function Seach() { $MysqlWhere = ' where 1'; $WhereGet = ''; $this->seachValue = trim($this->_GET['seachValue']); //订单号 $OrderNO = trim($this->_GET['OrderNO']); if ($OrderNO != 0) { $MysqlWhere .= ' and OrderNO=\'' . $OrderNO . '\''; $WhereGet .= '&OrderNO=' . $OrderNO; $this->OrderNO = $OrderNO; } //入账/消费 $Type = $this->_GET['Type']; if ($Type == '入账') { $MysqlWhere .= ' and Type=1'; $WhereGet .= '&Type=' . $Type; $this->Type = $Type; } if ($Type == '消费') { $MysqlWhere .= ' and Type=0'; $WhereGet .= '&Type=' . $Type; $this->Type = $Type; } //代理商 $AgentIDValue = trim($this->_GET['AgentIDValue']); if ($AgentIDValue != '') { $AgentModule = new AgentModule(); $AgentInfo = $AgentModule->GetOneInfoByArrayKeys(array('UserName' => $AgentIDValue)); $MysqlWhere .= ' and AgentID=' . $AgentInfo['AgentID']; $WhereGet .= '&AgentIDValue=' . $AgentIDValue; $this->AgentIDValue = $AgentIDValue; } //产品 $ProjectIDValue = trim($this->_GET['ProjectIDValue']); if ($ProjectIDValue != '') { $MysqlWhere .= ' and ProjectID=' . $ProjectIDValue; $WhereGet .= '&ProjectIDValue=' . $ProjectIDValue; $this->ProjectIDValue = $ProjectIDValue; } //客户企业名称 $CustomersIDValue = trim($this->_GET['CustomersIDValue']); if ($CustomersIDValue != '') { $CustomersModule = new CustomersModule(); $CustomersInfo = $CustomersModule->GetOneInfoByArrayKeys(array('CompanyName' => $CustomersIDValue)); $MysqlWhere .= ' and CustomersID=' . $CustomersInfo['CustomersID']; $WhereGet .= '&CustomersIDValue=' . $CustomersIDValue; $this->CustomersIDValue = $CustomersIDValue; } //下订单开始时间 $StartTime = trim($this->_GET['StartTime']); $this->StartTime = $StartTime; if ($StartTime != '') { $StartTime = $StartTime . ' 00:00:00'; $MysqlWhere .= ' and AddTime>\'' . $StartTime . '\''; $WhereGet .= '&StartTime=' . $StartTime; } //下订单结束时间 $EndTime = trim($this->_GET['EndTime']); $this->EndTime = $EndTime; if ($EndTime != '') { $EndTime = $EndTime . ' 23:59:59'; $MysqlWhere .= ' and AddTime<\'' . $EndTime . '\''; $WhereGet .= '&EndTime=' . $EndTime; } //最低交易金额 $MinAmount = trim($this->_GET['MinAmount']); if ($MinAmount != '') { $MysqlWhere .= ' and Amount>' . $MinAmount; $WhereGet .= '&MinAmount=' . $MinAmount; $this->MinAmount = $MinAmount; } //最高交易金额 $MaxAmount = trim($this->_GET['MaxAmount']); if ($MaxAmount != '') { $MysqlWhere .= ' and Amount<' . $MaxAmount; $WhereGet .= '&MaxAmount=' . $MaxAmount; $this->MaxAmount = $MaxAmount; } //客户端IP $FromIP = trim($this->_GET['FromIP']); if ($FromIP != '') { $MysqlWhere .= ' and FromIP=\'' . $FromIP . '\''; $WhereGet .= '&FromIP=' . $FromIP; $this->FromIP = $FromIP; } $Page = intval($this->_GET['Page']); $Page = $Page ? $Page : 1; $OrderModule = new OrderModule(); $ListsNum = $OrderModule->GetListsNum($MysqlWhere); $Rscount = $ListsNum['Num']; $PageSize = 5000; if ($WhereGet == '') { $PageSize = 10; } if ($Rscount) { $Data['RecordCount'] = $Rscount; $Data['PageSize'] = $PageSize ? $PageSize : $Data['RecordCount']; $Data['PageCount'] = ceil($Data['RecordCount'] / $PageSize); $Data['Page'] = min($Page, $Data['PageCount']); $Offset = ($Page - 1) * $Data['PageSize']; if ($Page > $Data['PageCount']) { $Page = $Data['PageCount']; } $Data['Data'] = $OrderModule->GetLists($MysqlWhere, $Offset, $Data['PageSize']); $AgentModule = new AgentModule(); $AgentAccountModule = new AgentAccountModule(); $ProjectModule = new ProjectModule(); $OrderDescriptionModule = new OrderDescriptionModule(); $RuZhangNum = 0; $RuZhang = 0; $XiaoFei = 0; $XiaoFeiNum = 0; foreach ($Data['Data'] as $Key => $Value) { $Array['AgentID'] = $Value['AgentID']; $AgentInfo = $AgentModule->GetOneInfoByKeyID($Array['AgentID']); $Data['Data'][$Key]['UserName'] = $AgentInfo['UserName']; $ProjectInfo = $ProjectModule->GetOneInfoByKeyID($Value['ProjectID']); $Data['Data'][$Key]['ProjectName'] = $ProjectInfo['ProjectName']; $AgentAccountInfo = $AgentAccountModule->GetLists('where AgentID=' . $Array['AgentID']); $Num = count($AgentAccountInfo); if ($Num == 0) { $Data['Data'][$Key]['Total'] = '0'; $Data['Data'][$Key]['Balance'] = '0'; } else { foreach ($AgentAccountInfo as $V) { $Data['Data'][$Key]['Total'] += $V['Total']; $Data['Data'][$Key]['Balance'] += $V['Balance']; } } $OrderDescriptionInfo = $OrderDescriptionModule->GetOneInfoByKeyID($Value['DescriptionID']); $Data['Data'][$Key]['Description'] = $OrderDescriptionInfo['Description']; if ($Value['Type'] == 1) { $Data['Data'][$Key]['TypeName'] = '入账'; $RuZhang += $Value['Amount']; $RuZhangNum++; } else { $Data['Data'][$Key]['TypeName'] = '消费'; $XiaoFei += $Value['Amount']; $XiaoFeiNum++; } } $this->RuZhangNum = $RuZhangNum; $this->RuZhang = $RuZhang; $this->XiaoFei = $XiaoFei; $this->XiaoFeiNum = $XiaoFeiNum; MultiPage($Data, 10); $this->Data = $Data; $this->WhereGet = $WhereGet; } }
public function AddAccount() { if ($this->_POST) { //提交添加 $Post['ProjectID'] = _intval($this->_POST['ProjectID']); $Post['AgentID'] = _intval($this->_POST['AgentID']); $Remarks = trim($this->_POST['Remarks']); $JinE = trim($this->_POST['JinE']); $Page = _intval($this->_POST['Page']); if ($JinE < 1 || $Post['ProjectID'] == 0 || $Post['AgentID'] == 0) { $this->__Message('信息填写错误!'); } $AgentAccountModule = new AgentAccountModule(); $AgentAccountInfo = $AgentAccountModule->GetOneInfoByArrayKeys($Post); if (empty($AgentAccountInfo)) { //添加数据表 $Post['Remarks'] = $Remarks; $Post['Total'] = $JinE; $Post['Balance'] = $JinE; $IsOk = $AgentAccountModule->InsertArray($Post); } else { //更新数据表 $UpdateInfo['Remarks'] = $Remarks; $UpdateInfo['Total'] = $AgentAccountInfo['Total'] + $JinE; $UpdateInfo['Balance'] = $AgentAccountInfo['Balance'] + $JinE; $IsOk = $AgentAccountModule->UpdateArrayByArrayKeys($UpdateInfo, $Post); } if ($IsOk) { $AddOrderIsOk = $this->AddOrder($Post['AgentID'], $Post['ProjectID'], $JinE + $AgentAccountInfo['Balance'], $JinE); if ($AddOrderIsOk == 0) { $this->__Message('入账成功,记录操作失败!', UrlRewriteSimple($this->MyModule, 'Lists', true) . '&Page=' . $Page, '继续操作'); } $this->__Message('入账成功!', UrlRewriteSimple($this->MyModule, 'Lists', true) . '&Page=' . $Page, '继续操作'); } else { $this->__Message('入账失败,请再一次尝试!'); } } else { $AgentID = trim($this->_GET['AgentID']); $AgentModule = new AgentModule(); $this->AgentInfo = $AgentModule->GetOneInfoByKeyID($AgentID); //print_r($this->AgentInfo);exit; include 'Include/LevelArray.php'; $ProjectModule = new ProjectModule(); $this->ProjectLists = $ProjectModule->GetProjectLists(); } }
public function Main() { $this->MyAction = 'Main'; $ArrayKeys['AgentID'] = intval($_SESSION['AgentID']); $FengxinID = FENGXIN_ID; $GBaoPenID = GBAOPEN_ID; $CustProModule = new CustProModule(); $CustomersModule = new CustomersModule(); $AgentAccountModule = new AgentAccountModule(); $SumBalance = $AgentAccountModule->GetSumBalanceByArrayKeys($ArrayKeys); $Data['Balance']['SUM'] = $SumBalance['sum'] ? $SumBalance['sum'] : 0; $GBaoPenBalance = $AgentAccountModule->GetLists("where ProjectID={$GBaoPenID} and AgentID={$ArrayKeys['AgentID']}"); $Data['Balance']['GBaoPen'] = $GBaoPenBalance[0]['Balance'] ? $GBaoPenBalance[0]['Balance'] : 0; $GBaoPenBalance = $AgentAccountModule->GetLists("where ProjectID={$FengxinID} and AgentID={$ArrayKeys['AgentID']}"); $Data['Balance']['FengXin'] = $GBaoPenBalance[0]['Balance'] ? $GBaoPenBalance[0]['Balance'] : 0; $CustProFengXin = $CustProModule->GetAll("where ProjectID={$FengxinID} and AgentID={$ArrayKeys['AgentID']}"); $Fcount = count($CustProFengXin); //风信客户数量 $Finvalid = 0; //风信无效客户 $Foverdue = 0; //风信到期客户 $Fbeoverdue = 0; //风信即将到期客户 $Fstandard = 0; //风信标准版用户 $Fgongneng = 0; //功能版用户 foreach ($CustProFengXin as $FengXin) { if ($FengXin['status'] == 0) { $Finvalid++; } if (strtotime($FengXin['EndTime']) < strtotime("now")) { $Foverdue++; } if (strtotime($FengXin['EndTime']) > strtotime("now") && strtotime($FengXin['EndTime']) <= strtotime("next month")) { $Fbeoverdue++; } if ($FengXin['GongNeng'] == '' || $FengXin['GongNeng'] == null) { $Fstandard++; } } $Fgongneng = $Fcount - $Fstandard; $CustProGBaoPen = $CustProModule->GetAll("where ProjectID={$GBaoPenID} and AgentID={$ArrayKeys['AgentID']}"); $Gcount = count($CustProGBaoPen); //G宝盆客户数量 $Ginvalid = 0; //G宝盆无效客户 $Goverdue = 0; //G宝盆到期客户 $Gbeoverdue = 0; //G宝盆即将到期客户 foreach ($CustProGBaoPen as $GBaoPen) { if ($GBaoPen['status'] == 0) { $Ginvalid++; } if (strtotime($GBaoPen['EndTime']) < strtotime("now")) { $Goverdue++; } if (strtotime($GBaoPen['EndTime']) > strtotime("now") && strtotime($GBaoPen['EndTime']) <= strtotime("next month")) { $Gbeoverdue++; } } $Data['Info']['FengXin'] = array('Fcount' => $Fcount, 'Finvalid' => $Finvalid, 'Foverdue' => $Foverdue, 'Fbeoverdue' => $Fbeoverdue, 'Fstandard' => $Fstandard, 'Fgongneng' => $Fgongneng); $Data['Info']['GBaoPen'] = array('Gcount' => $Gcount, 'Ginvalid' => $Ginvalid, 'Goverdue' => $Goverdue, 'Gbeoverdue' => $Gbeoverdue); //dd($Data); $this->Data = $Data; }