12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376 |
- <?php
- namespace Mail\Lib;
- use Dever;
- class Manage
- {
- public function getArea($name)
- {
- if (strstr($name, '|—')) {
- $temp = explode('|—', $name);
- return $temp[0] . '|—' . Dever::load("area/api.string", $temp[1], '-');
- } else {
- return Dever::load("area/api.string", $name, '-');
- }
- }
- #代理商日数据统计
- public function day_api(){
- $day = Dever::input('day');
- if($day){
- $start = strtotime($day);
- $end = $start+86400-1;
- }else{
- $start=mktime(0,0,0,date('m'),date('d'),date('Y'));
- $end = $start+86400-1;
- }
-
- $time = Dever::maketime(date('Y-m-d'),'00:00:00');
- $where = array();
- $where['fstart'] = $start;
- $where['fend'] = $end;
- $w = array();
- $fstart = Dever::input('start', date('Y-m-01', $start));
- $w['fstart'] = Dever::maketime($fstart . ' 00:00:00');
- $w['fend'] = strtotime(date('Y-m-d 23:59:59',
- strtotime($fstart."+1 month - 1 day")));;
- $data = array();
- $data['start'] = date('Y-m-d',$start);
- $data['day'] = $this->content_api($where,1);
- $data['money'] = $this->c_api($where);
- $data['week'] = $this->zhou_api($start);
- $data['all'] = $this->content_api($w,2);
- $data['all_money'] = $this->c_api($w);
- $data['time'] = $this->day_time_api($w);
- $data['data'] = Dever::json_encode($data['time']);
- $data['money_time'] = $this->money_time_api($w);
- $data['qu_money'] = Dever::json_encode($data['money_time']);
- $data['xzhou'] = $this->button_day_api($w,1);
- $data['zhou'] = Dever::json_encode($data['xzhou']);
-
- return Dever::render('census', $data);
- }
- public function zhou_api($time='',$format="Y-m-d"){
- $time = $time != '' ? $time : time();
- $week = date('w', $time);
- $date = [];
- if($week == 0){
- $week = 7;
- }
- for ($i=1; $i<=7; $i++){
- $date[$i] = date($format ,strtotime( '+' . $i-$week .' days', $time));
- }
- $start = strtotime($date[1]);
- $end = strtotime($date[7])+86400-1;
- $where = array();
- $where['fstart'] = $start;
- $where['fend'] = $end;
- $data = array();
- $data['week'] = date('Y.m.d',$start).' - '.date('Y.m.d',$end);
- $data['all'] = $this->content_api($where,2);
- $data['all_money'] = $this->c_api($where);
- return $data;
- }
- #按时间统计
- public function content_api($where,$type){
- $data = array();
- if($type == 2){
- $data['time'] = date('Y.m',$where['fstart']);
- }elseif($type == 1){
- $data['time'] = date('Y.m.d',$where['fstart']);
- }
- #确认代理商订单数
- $where['status'] = 4;
- $data['num'] = Dever::db('agent/order')->getNum($where);
- #确认订单总费用
- $money = Dever::db('agent/order')->getCash($where);
- if($money['total']){
- $data['money'] = $money['total'];
- }else{
- $data['money'] = 0;
- }
- #确认代理费
- $dl_money = Dever::db('agent/order')->getDailiCash($where);
- if($dl_money['total']){
- $data['dl_money'] = $dl_money['total'];
- }else{
- $data['dl_money'] = 0;
- }
- #确认软件服务费
- $soft_money = Dever::db('agent/order')->getSoftCash($where);
- if($soft_money['total']){
- $data['soft_money'] = $soft_money['total'];
- }else{
- $data['soft_money'] = 0;
- }
- $wh['status'] = 3;
- $wh['fstart'] = $where['fstart'];
- $wh['fend'] = $where['fend'];
- $cash = Dever::db('agent/soft_cash')->getTotal($wh);
- if($cash['total']){
- $data['cash'] = $cash['total'];
- }else{
- $data['cash'] = 0;
- }
- $data['soft_cash'] = $data['soft_money'] + $data['cash'];
- #期权价值
- $option_money = Dever::db('agent/order')->getOptionPrice($where);
- if($option_money['total']){
- $data['option_money'] = $option_money['total'];
- }else{
- $data['option_money'] = 0;
- }
- return $data;
- }
- #各角色的金额,数量,原始期权价值,软件服务费
- public function c_api($where){
- $role = Dever::db('setting/role')->getAll(array('id'=>1,'state'=>1));
- foreach($role as $k => $v){
- $where['role'] = $v['id'];
- $data[$k]['name'] = $v['name'];
- $where['status'] = 4;
- $data[$k]['num'] = Dever::db('agent/order')->getNum($where);
- // $where['status'] = 4;
- $dl = Dever::db('agent/order')->getSum($where);
- if($dl['total']){
- $data[$k]['money'] = $dl['total'];
- }else{
- $data[$k]['money'] = 0;
- }
- #期权价值:
- $option_money = Dever::db('agent/order')->getOptionPrice($where);
- if($option_money['total']){
- $data[$k]['option_money'] = $option_money['total'];
- }else{
- $data[$k]['option_money'] = 0;
- }
- #软件服务费
- $soft_money = Dever::db('agent/order')->getSoftCash($where);
- if($soft_money['total']){
- $data[$k]['soft_money'] = $soft_money['total'];
- }else{
- $data[$k]['soft_money'] = 0;
- }
- $wh['role'] = $v['id'];
- $wh['status'] = 3;
- $wh['fstart'] = $where['fstart'];
- $wh['fend'] = $where['fend'];
- $cash = Dever::db('agent/soft_cash')->getTotal($wh);
- if($cash['total']){
- $data[$k]['cash'] = $cash['total'];
- }else{
- $data[$k]['cash'] = 0;
- }
- }
- return $data;
- }
- #数据趋势
- public function day_time_api($w){
- $time = date('m',time()) - date('m',$w['fstart']);
- $start = date('Y-m-01',$w['fstart']);
- if($time<=0){
- $w['fend'] = time();
- }elseif($time>0){
- $w['fend'] = strtotime(date('Y-m-d 23:59:59',
- strtotime($start."+1 month - 1 day")));
- }
- $days = ($w['fend']-$w['fstart'])/86400+1;
- // 保存每天日期
- $day = array();
- $data = array();
- for($i=0; $i<$days; $i++){
- $day[] = array($w['fstart']+(86400*$i),$w['fstart']+(86400*$i)+86400);
- }
- $res = array();
- $res['num'] = array();
- foreach($day as $k => $v){
- $where['fstart'] = $v[0];
- $where['fend'] =$v[1]-1;
- $data[$k]['time'] = date('m.d',$v[0]);
- #确认代理商订单数
- $where['status'] = 4;
- $res['num'][] = Dever::db('agent/order')->getNum($where);
- }
- // print_R($where);die;
- $data = array();
- $data['name'] = '数量';
- $data['type'] = 'line';
- // $data['stack'] = 'Total';
- $data['data'] = $res['num'];
- return $data;
- }
- #金额趋势
- public function money_time_api($w){
- $time = date('m',time()) - date('m',$w['fstart']);
- $start = date('Y-m-01',$w['fstart']);
- if($time<=0){
- $w['fend'] = time();
- }elseif($time>0){
- $w['fend'] = strtotime(date('Y-m-d 23:59:59',
- strtotime($start."+1 month - 1 day")));
- }
- $days = ($w['fend']-$w['fstart'])/86400+1;
- // 保存每天日期
- $day = array();
- $data = array();
- for($i=0; $i<$days; $i++){
- $day[] = array($w['fstart']+(86400*$i),$w['fstart']+(86400*$i)+86400);
- }
- $res = array();
- $res['money'] = array();
- foreach($day as $k => $v){
- $where['fstart'] = $v[0];
- $where['fend'] =$v[1]-1;
- $data[$k]['time'] = date('m.d',$v[0]);
- #确认订单总费用
- $money = Dever::db('agent/order')->getCash($where);
- if($money['total']){
- $res['money'][] = $money['total'];
- }else{
- $res['money'][] = 0;
- }
- }
- $money = array();
- $money['name'] = '金额';
- $money['type'] = 'line';
- $money['data'] = $res['money'];
- return $money;
- }
- #趋势底部日期
- public function button_day_api($w,$type){
- $time = date('m',time()) - date('m',$w['fstart']);
- $start = date('Y-m-01',$w['fstart']);
- if($time<=0){
- $w['fend'] = time();
- }elseif($time>0){
- $w['fend'] = strtotime(date('Y-m-d 23:59:59',
- strtotime($start."+1 month - 1 day")));
- }
- $days = ($w['fend']-$w['fstart'])/86400+1;
- if($type ==1){
- $daysd = $days-1;
- }else{
- $daysd = $days;
- }
- // 保存每天日期
- $day = array();
- $data = array();
- for($i=0; $i<$daysd; $i++){
- $day[] = date('m.d',$w['fstart']+(86400*$i));
- }
- $data['type'] = 'category';
- $data['boundaryGap'] = false;
- $data['date'] = $day;
- return $day;
- }
- #代理商日统计
- public function index_api(){
- $title = '代理商日数据统计';
- $data = Dever::db('mail/feature')->find(array('key'=>'lib/cron.day'));
- $email = explode(',',$data['email_id']);
- foreach($email as $k => $v){
- $res[] = Dever::db('mail/email')->find(array('id'=>$v));
- }
- $content = $this->index_api();
- foreach($res as $key => $val){
- $this->send($val['email'], $val['name'], $title, $content);
- }
- }
-
- #代理商统计发送邮件
- public function send($email, $username, $title, $content)
- {
- $config = Dever::config('base', 'project')->email;
- Dever::apply('src/PHPMailer', 'email');
- Dever::apply('src/Exception', 'email');
- Dever::apply('src/SMTP', 'email');
- $mail = new \PHPMailer\PHPMailer\PHPMailer();
- $mail->isSMTP();
- //$mail->SMTPDebug = 2;
- $mail->CharSet = 'UTF-8';
- $mail->Host = $config['smtp'];
- $mail->Port = 465;
- $mail->SMTPSecure = 'ssl';
- $mail->SMTPAuth = true;
- $mail->Username = $config['username'];
- $mail->Password = $config['password'];
- $mail->setFrom($config['from'][0], '统计');
- $mail->addAddress($email, $username);
- $mail->Subject = "=?utf-8?B?" . base64_encode($title) . "?=";
- $mail->Body = $content;
- $mail->isHTML(true);
- //$mail->addAttachment($file);
- if (!$mail->send()) {
- Dever::alert("Mailer Error: " . $mail->ErrorInfo);
- } else {
- return 'ok';
- }
- }
- #期权统计
- public function option_api(){
- #主账户数量
- $data['account'] = Dever::db('option/account')->getCount(array('state'=>1));
- #所有数量
- $data['member'] = Dever::db('option/member')->getCount(array('state'=>1));
- #已认证完成
- $data['y_num'] = Dever::db('option/account')->getCount(array('audit'=>3,'state'=>1));
- #尚未任何交付的
- $data['no_num'] = Dever::db('option/bill_jiaofu')->getCount(array('status'=>2,'state'=>1));
- #原始期权待交付
- $yq_nonum = Dever::db('option/bill_jiaofu')->getCash(array('status'=>2,'type'=>2,'state'=>1));
- if($yq_nonum['total']){
- $data['yq_nonum'] = $yq_nonum['total'];
- }else{
- $data['yq_nonum'] = 0;
- }
-
- #原始期权已交付未发放
- $yq_nof = Dever::db('option/bill_jiaofu')->getCash(array('status'=>1,'type'=>2,'state'=>1));
-
- if($yq_nof['total']){
- $data['yq_nof'] = $yq_nof['total'];
- }else{
- $data['yq_nof'] = 0;
- }
- #原始期权已发放
- $yq_fnum = Dever::db('option/bill_fafang')->getCash(array('status'=>1,'type'=>2,'state'=>1));
- if($yq_fnum['total']){
- $data['yq_fnum'] = $yq_fnum['total'];
- }else{
- $data['yq_fnum'] = 0;
- }
-
- #期权待交付
- $q_nonum = Dever::db('option/bill_jiaofu')->getCash(array('status'=>2,'type'=>1,'state'=>1));
- if($q_nonum['total']){
- $data['q_nonum'] = $q_nonum['total'];
- }else{
- $data['q_nonum'] = 0;
- }
-
- #期权已交付未发放
- $q_nof = Dever::db('option/bill_jiaofu')->getCash(array('status'=>1,'type'=>1,'state'=>1));
- if($q_nof['total']){
- $data['q_nof'] = $q_nof['total'];
- }else{
- $data['q_nof'] = 0;
- }
-
- #期权已发放
- $q_fnum = Dever::db('option/bill_fafang')->getCash(array('status'=>1,'type'=>1,'state'=>1));
- if($q_fnum['total']){
- $data['q_fnum'] = $q_fnum['total'];
- }else{
- $data['q_fnum'] = 0;
- }
-
- return Dever::render('qiquan', $data);
- }
- #代理商期权待交付
- public function option_nopay_api($start,$end,$type=false){
- $start = Dever::input('start',$start);
- $end = Dever::input('end',$end);
- if($start && $end){
- $start = strtotime($start);
- $end = strtotime($end);
- }else{
- $start=Dever::maketime(date('Y-m-01') . ' 00:00:00');
- $end = strtotime(date('Y-m-d 23:59:59',
- strtotime(date('Y-m-01')."+1 month - 1 day")));
- }
- $where['start'] = $start;
- $where['end'] = $end;
- $where['state'] = 1;
- $rest = array();
- $rest['start'] = date('Y-m-d',$start);
- $rest['end'] = date('Y-m-d',$end);
- $rest['data'] = array();
- $data = Dever::db('agent/order')->getAll($where);
- if($data){
- foreach($data as $k => $v){
- #单独购买的软件服务费
- $cash = Dever::db('agent/soft_cash')->getTotal(array('fstart'=>$start,'fend'=>$end,'mid'=>$v['mid']));
- $data[$k]['buy_cash'] = $cash['total'];
- $option = Dever::db('agent/soft_cash')->getPrice(array('fstart'=>$start,'fend'=>$end,'mid'=>$v['mid']));
- $data[$k]['y_price'] = $option['total'];
- }
- $rest['page'] = Dever::page("current");
- $rest['data'] = $data;
- if($type == 1){
- return $rest['data'];
- }else{
- return Dever::render('option_nopay', $rest);
- }
- }else{
- return Dever::render('option_nopay', $rest);
- }
-
-
- }
- #代理商期权待交付导出
- public function out_option_nopay_api(){
- $start = Dever::input('start');
- $end = Dever::input('end');
- if($start && $end){
- $start = strtotime($start);
- $end = strtotime($end);
- }else{
- $start=Dever::maketime(date('Y-m-01') . ' 00:00:00');
- $end = strtotime(date('Y-m-d 23:59:59',
- strtotime(date('Y-m-01')."+1 month - 1 day")));
- }
- $data = $this->option_nopay_api($start,$end,1);
- $header = array('用户姓名', '手机号', '身份证号', '软件服务费(订单)', '软件服务费(购买)', '原始期权', '期权赠送');
- if($data){
- $body = array();
- foreach($data as $k => $v){
- $d = array
- (
- $v['name'],
- $v['mobile'],
- $v['idcard'],
- $v['soft_cash'],
- $v['buy_cash'],
- $v['y_price'],
- $v['option_price'],
- );
- $body[] = $d;
- }
- $file = '代理商期权待交付';
- Dever::excelExport($body, $header, $file);
- }
- }
- #代理商期权发放统计
- public function option_grant_api($start,$end,$type=false){
- $start = Dever::input('start',$start);
- $end = Dever::input('end',$end);
- if($start && $end){
- $start = strtotime($start);
- $end = strtotime($end);
- }else{
- $start=Dever::maketime(date('Y-m-01') . ' 00:00:00');
- $end = strtotime(date('Y-m-d 23:59:59',
- strtotime(date('Y-m-01')."+1 month - 1 day")));
- }
- $data = array();
- $data['start'] = date('Y-m-d',$start);
- $data['end'] = date('Y-m-d',$end);
- $res = Dever::db('agent/member')->getAll(array('start'=>$start,'end'=>$end,'state'=>1));
- foreach($res as $k=>$v){
- $role = Dever::db('setting/role')->find($v['role']);
- $res[$k]['role_name'] = $role['name'];
- $res[$k]['cv_num'] = Dever::db('agent/member')->getNum(array('parent_mid'=>$v['id'],'fstart'=>$start,'fend'=>$end,'role'=>8,'state'=>1));
- $res[$k]['ck_num'] = Dever::db('agent/member')->getNum(array('parent_mid'=>$v['id'],'fstart'=>$start,'fend'=>$end,'role'=>6,'state'=>1));
- $res[$k]['cash'] = Dever::db('bill/cash')->getCash(array('mid'=>$v['id'],'type'=>'1,2','state'=>1));
- }
- $data['page'] = Dever::page("current");
- $data['data'] = $res;
- if($type == 1){
- return $res;
- }else{
- return Dever::render('option_grant', $data);
- }
- }
- #期权发放导出
- public function out_option_grant_api(){
- $start = Dever::input('start');
- $end = Dever::input('end');
- if($start && $end){
- $start = strtotime($start);
- $end = strtotime($end);
- }else{
- $start=Dever::maketime(date('Y-m-01') . ' 00:00:00');
- $end = strtotime(date('Y-m-d 23:59:59',
- strtotime(date('Y-m-01')."+1 month - 1 day")));
- }
- $data = $this->option_grant_api($start,$end,1);
- $header = array('用户姓名', '手机号', '身份证号', '角色', '完成团队业绩', '完成直推创v', '完成直推创客');
- if($data){
- $body = array();
- foreach($data as $k => $v){
- $d = array
- (
- $v['name'],
- $v['mobile'],
- $v['idcard'],
- $v['role_name'],
- $v['group_sell'],
- $v['cv_num'],
- $v['ck_num'],
- );
- $body[] = $d;
- }
- $file = '代理商期权发放';
- Dever::excelExport($body, $header, $file);
- }
- }
- #软件服务费数据统计
- public function soft_cash_api(){
- $start = Dever::input('start');
- $end = Dever::input('end');
- $where = array();
- if($start && $end){
- $where['fstart'] = strtotime($start.'00:00:00');
- $where['fend'] = strtotime($end.'23:59:59');
- }else{
- $where['fstart']=Dever::maketime(date('Y-m-01') . ' 00:00:00');
- $where['fend'] = strtotime(date('Y-m-d 23:59:59',
- strtotime(date('Y-m-01')."+1 month - 1 day")));
- }
- $where['state'] = 1;
- $data = array();
- $data['start'] = date('Y-m-d',$where['fstart']);
- $data['end'] = date('Y-m-d',$where['fend']);
- #软件服务费的已确认数量
- $where['soft_cash']=1;
- $where['status'] = 4;
- $order = Dever::db('agent/order')->getSoftNum($where);
- $where['status'] = 3;
- $soft_cash = Dever::db('agent/soft_cash')->getSoftNum($where);
- $data['num'] = $order + $soft_cash;
- #软件服务费未确认的数量
- $where['status'] = '-2,-1,1,2,3';
- $order = Dever::db('agent/order')->getSoftNoNum($where);
- $where['status'] = '1,2';
- $soft_cash = Dever::db('agent/soft_cash')->getSoftNoNum($where);
- $data['no_num'] = $order + $soft_cash;
- #总数量
- $data['total_num'] = $data['num'] + $data['no_num'];
-
- #已确认软件服务费
- $where['status'] = 4;
- $order = Dever::db('agent/order')->getSoftCash($where);
- $where['status'] = 3;
- $soft_cash = Dever::db('agent/soft_cash')->getSoftCash($where);
- $data['money'] = $order['total'] + $soft_cash['total'];
- #未确认软件服务费
- $where['status'] = '-2,-1,1,2,3';
- $order = Dever::db('agent/order')->getSoftNoCash($where);
- $where['status'] = '1,2';
- $soft_cash = Dever::db('agent/soft_cash')->getSoftNoCash($where);
- $data['no_money'] = $order['total'] + $soft_cash['total'];
- #总钱数
- $data['total_money'] = $data['money'] + $data['no_money'];
- #合同已确认数量:
- $where['status'] = 2;
- $data['a_num'] = Dever::db('agent/member_agreement')->getNum($where);
- #合同未确认数量:
- $where['status'] = 1;
- $data['a_nonum'] = Dever::db('agent/member_agreement')->getNoNum($where);
- $data['a_totalnum'] = $data['a_num'] + $data['a_nonum'];
- #合同已确认软件服务费
- $where['status'] = 2;
- $price = Dever::db('agent/member_agreement')->getPrice($where);
- if($price['total']){
- $data['a_price'] = $price['total'];
- }else{
- $data['a_price'] = 0;
- }
-
- #合同未确认软件服务费
- $where['status'] = 1;
- $noprice = Dever::db('agent/member_agreement')->getNoPrice($where);
- if($noprice['total']){
- $data['a_noprice'] = $noprice['total'];
- }else{
- $data['a_noprice'] = 0;
- }
-
- #总钱数
- $data['total_price'] = $data['a_price'] + $data['a_noprice'];
- return Dever::render('soft_cash', $data);
- }
- public function out_option_qiquan_api($data)
- {
- // print_R($data);die;
- $header = array('索引', '账户名称', '账户类型', '手机号', '邮箱', '邮箱认证', '账户认证', '合同审核状态','待交付期权', '待交付原始期权', '已交付期权', '已交付原始期权');
- // $data = Dever::db('option/member')->state();
- $body = array();
- $main = '';
- $f_money = 0;
- $j_money = 0;
- $dj_money = 0;
- $d_money = 0;
- $status = array();
- $set = Dever::db('option/account')->config['set'];
- $ag_audit = Dever::db('option/agreement')->config['audit'];
- foreach ($data as $k1 => $v1) {
- $member[$v1['id']] = Dever::db('option/member')->select(array('aid' => $v1['id']));
- $agreement = Dever::db('option/agreement')->find(array('aid' => $v1['id']));
- $status[$v1['id']] = array
- (
- 'email' => $v1['email'],
- 'is_email' => $v1['is_email'] == 1 ? '已验证' : '未验证',
- 'audit' => $set['audit'][$v1['audit']],
- 'agreement' => $agreement ? $ag_audit[$agreement['audit']] : '未签署',
- );
- }
- foreach ($member as $k => $v1) {
- foreach ($v1 as $v) {
- $daijiaofu_qiquan = $daijiaofu_yuanshiqiquan = $jiaofu_qiquan = $jiaofu_yaunshiqiquan = 0;
- if ($v['main'] == 1) {
- $main = '主账户';
- } else {
- $main = '子账户';
- }
- $where = array();
- $where['mid'] = $v['id'];
- /*
- $ff = Dever::db('option/bill_fafang')->getSearch($where);
- if ($ff && $ff['total']) {
- $f_money = $ff['total'];
- }
- $duifu = Dever::db('option/bill_duifu')->getSearch($where);
- if ($duifu && $duifu['total']){
- $d_money = $duifu['total'];
- }
- */
- $where['status'] = 2;
- $where['type'] = 1;
- $jiaofu = Dever::db('option/bill_jiaofu')->getSearch($where);
- if ($jiaofu && $jiaofu['total']){
- $daijiaofu_qiquan = $jiaofu['total'];
- }
- $where['status'] = 2;
- $where['type'] = 2;
- $jiaofu = Dever::db('option/bill_jiaofu')->getSearch($where);
- if ($jiaofu && $jiaofu['total']){
- $daijiaofu_yuanshiqiquan = $jiaofu['total'];
- }
- $where['status'] = 1;
- $where['type'] = 1;
- $jiaofu = Dever::db('option/bill_jiaofu')->getSearch($where);
- if ($jiaofu && $jiaofu['total']){
- $jiaofu_qiquan = $jiaofu['total'];
- }
- $where['status'] = 1;
- $where['type'] = 2;
- $jiaofu = Dever::db('option/bill_jiaofu')->getSearch($where);
- if ($jiaofu && $jiaofu['total']){
- $jiaofu_yaunshiqiquan = $jiaofu['total'];
- }
-
- $d =array
- (
- $v['key'],
- $v['name'],
- $main,
- $v['mobile'],
- $status[$v['aid']]['email'],
- $status[$v['aid']]['is_email'],
- $status[$v['aid']]['audit'],
- $status[$v['aid']]['agreement'],
-
- $daijiaofu_qiquan,
- $daijiaofu_yuanshiqiquan,
- $jiaofu_qiquan,
- $jiaofu_yaunshiqiquan,
- );
- $body[] = $d;
- }
-
- }
- $file = '期权导出';
- return Dever::excelExport($body, $header, $file);
- }
- # 体验店毛利:采购价-成本价
- public function t_buy($where, $shop_id, $per)
- {
- $where['type_id'] = $shop_id;
- $where['status'] = '5,6';
- $order = Dever::db('shop/buy_order')->getNewAll($where);
- $total = 0;
- $shop = array();
-
- if ($order) {
- foreach($order as $k => $v) {
- if (!isset($shop[$v['type_id']])) {
- $shop[$v['type_id']] = 0;
- }
-
- $order_goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id']));
- $c_price = 0;
- foreach($order_goods as $k1 => $v1){
- $goods = Dever::load('goods/lib/info')->getPayInfo($v1['goods_id'], $v1['sku_id']);
- if($goods['c_price'] && $goods['c_price'] >= 0){
- $c_price += $goods['c_price'] * $v1['num'];
- }
- }
- $price = ($v['price'] - $c_price);
- $total += $price;
- $shop[$v['type_id']] += $price * $per;
- $shop[$v['type_id']] = round($shop[$v['type_id']], 2);
- }
- }
-
- return array(round($total, 2), round($total*$per, 2), $shop);
- }
- # 零售店毛利
- public function l_buy($where, $shop_id, $per)
- {
- $where['shop_id'] = $shop_id;
- $data = Dever::db('mail/area_entry')->getBuy($where);
- $total = 0;
- $shop = array();
- if ($data) {
- foreach ($data as $k => $v) {
- if (!isset($shop[$v['shop_id']])) {
- $shop[$v['shop_id']] = 0;
- }
- $price = $v['buy'];
- $total += $price;
- $shop[$v['shop_id']] += $price * $per;
- $shop[$v['shop_id']] = round($shop[$v['shop_id']], 2);
- }
- }
- return array(round($total, 2), round($total*$per, 2), $shop);
- }
- # 区域分润
- public function area_api()
- {
- /*
- $month = Dever::input('month', date('Y-m'));
- $start_time = $month .'-01 00:00:00';
- $where = array();
- $end_time = date('Y-m-d', strtotime($start_time. ' +1 month -1 day')).' 23:59:59';
- $where['start'] = Dever::maketime($start_time);
- $where['end'] = Dever::maketime($end_time);
- */
- # 设置利润计算规则:
- $config = array
- (
- 1 => 0.01,
- 2 => 0.03,
- 3 => 0.05,
- );
- # 传入day,获取月开始和月结束日期
- list($where['start'], $where['end']) = Dever::month();
- $month = Dever::maketime(date('Y-m', $where['start']));
- # 获取区域
- $area = array();
- $shop = Dever::db('shop/info')->select();
- if ($shop) {
- foreach ($shop as $k => $v) {
- if ($v['type'] != 10) {
- if ($v['city'] > 0) {
- $key = $v['province'] . ',' . $v['city'];
- $area[$key]['shop_id'][$v['type']][] = $v['id'];
- $area[$key]['type'] = 1;
- }
- if ($v['county'] > 0) {
- $key = $v['province'] . ',' . $v['city'] . ',' . $v['county'];
- $area[$key]['shop_id'][$v['type']][] = $v['id'];
- $area[$key]['type'] = 2;
- }
- if ($v['town'] > 0) {
- $key = $v['province'] . ',' . $v['city'] . ',' . $v['county'] . ',' . $v['town'];
- $area[$key]['shop_id'][$v['type']][] = $v['id'];
- $area[$key]['type'] = 3;
- }
- }
- }
- $area_id = array();
- $shop_data = array();
- foreach ($area as $k => $v) {
- $update = array();
- $update['month'] = $month;
- $update['name'] = $k;
- $info = Dever::db('mail/area_stat')->find($update);
- # 设置金额
- $update['t_num'] = $update['l_num'] = $update['t_cash'] = $update['l_cash'] = $update['t_buy'] = $update['l_buy'] = 0;
- $update['data'] = array();
- foreach ($v['shop_id'] as $k1 => $v1) {
- if ($k1 == 1) {
- # 体验店
- $update['t_num'] = count($v1);
- list($update['t_buy'], $update['t_cash'], $shop_data) = $this->t_buy($where, $v1, $config[$v['type']]);
- if ($shop_data) {
- $update['data'] += $shop_data;
- }
- } elseif ($k1 == 2) {
- # 零售店
- $update['l_num'] = count($v1);
- list($update['l_buy'], $update['l_cash'], $shop_data) = $this->l_buy($where, $v1, $config[$v['type']]);
- if ($shop_data) {
- $update['data'] += $shop_data;
- }
- }
- }
- if ($update['t_buy'] == 0 && $update['l_buy'] == 0) {
- continue;
- }
- # 设置上级id,用来做列表层级展示
- if ($v['type'] == 1) {
- $update['parent_id'] = -1;
- } elseif ($v['type'] == 2) {
- $area_value = explode(',', $k);
- $k2 = $area_value[0] . ',' . $area_value[1];
- $update['parent_id'] = isset($area_id[$k2]) ? $area_id[$k2] : -1;
- } elseif ($v['type'] == 3) {
- $area_value = explode(',', $k);
- $k2 = $area_value[0] . ',' . $area_value[1] . ',' . $area_value[2];
- $update['parent_id'] = isset($area_id[$k2]) ? $area_id[$k2] : -1;
- }
- # 设置收益代理商
- $member = Dever::db('agent/member')->getAreaAll(array('area' => $k));
- if ($member) {
- $update['mid'] = $member['id'];
- }
- $update['data'] = Dever::json_encode($update['data']);
- if (!$info) {
- $stat_id = Dever::db('mail/area_stat')->insert($update);
- } else {
- $stat_id = $update['where_id'] = $info['id'];
- Dever::db('mail/area_stat')->update($update);
- }
- if ($v['type'] == 1) {
- $area_id[$k] = $stat_id;
- } elseif ($v['type'] == 2) {
- $area_id[$k] = $stat_id;
- }
- }
- }
- /*
- $data = array();
- $data = Dever::db('shop/info')->getAreaAll(array('state'=>1));
- foreach($data as $k => $v){
- $w['month'] = $where['start'];
- #城市
- if($v['city']>0){
- $city_area_stat = -1;
- $where['area'] = $v['city'];
- $data[$k]['citys']['area'] = $v['province'].','.$v['city'];
- $where['parent_type'] = '1,3';
- // print_R($where);die;
- $jia = $this->caigou($where);
- // $data[$k]['citys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
- $data[$k]['citys']['price']= $jia['money'] * 0.01;
- // $data[$k]['citys']['price']= round($data[$k]['citys']['money']['total']) * 0.3*0.01;
- $mid = Dever::db('agent/member')->getAreaAll(array('area'=>$data[$k]['citys']['area'],'role'=>2));
- $w['citys']['area'] = $v['city'];
-
- if($mid && $mid['id']){
- $data[$k]['citys']['mid'] = $mid['id'];
- }else{
- $data[$k]['citys']['mid'] = '-1';
- }
-
- $where['city'] = $v['city'];
- $data[$k]['citys']['num'] = Dever::db('shop/info')->getSerachNum($where);
- #体验店
- $t_shop = Dever::db('shop/info')->getAreaAll(array('city'=>$v['city'],'type'=>1,'state'=>1));
- $data[$k]['citys']['type'] = array_column($t_shop,'id');
- $where['type_id'] = implode(',',$data[$k]['citys']['type']);
- $data[$k]['citys']['t_num'] = count($t_shop);
- if($data[$k]['citys']['t_num']>0){
- $data[$k]['citys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
- $data[$k]['citys']['t_fprice'] = $data[$k]['citys']['price'];
- }else{
- $data[$k]['citys']['t_price'] = 0;
- $data[$k]['citys']['t_fprice'] = 0;
- }
- #零售店
- $shop_area = $this->ls($where,1);
- $data[$k]['citys']['l_price'] =$shop_area['price'];
- $data[$k]['citys']['l_fprice'] =$shop_area['price'] * 0.01;
- $data[$k]['citys']['l_num'] = $shop_area['num'];
- $data[$k]['citys']['price'] = $data[$k]['citys']['price'] + $data[$k]['citys']['l_fprice'];
- $w['mid'] = $data[$k]['citys']['mid'];
- $w['name'] = $data[$k]['citys']['area'];
- $w['price'] = $data[$k]['citys']['price'];
- $w['c_price'] = $jia['price'];
- // $data[$k]['citys']['money']['total'];
- $w['num'] = $data[$k]['citys']['num'];
- $w['t_num'] = $data[$k]['citys']['t_num'];
- $w['t_price'] = $data[$k]['citys']['t_price']['total'];
- $w['t_fprice'] = $data[$k]['citys']['t_fprice'];
- $w['l_num'] = $data[$k]['citys']['l_num'];
- $w['l_price'] = $shop_area['price'];
- $w['l_fprice'] = $data[$k]['citys']['l_fprice'];
- $w['parent_id'] = -1;
- $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'name'=>$data[$k]['citys']['area']));
- if(!$shop){
- $city_area_stat = Dever::db('mail/area_stat')->insert($w);
- }else{
- $city_area_stat = $w['where_id'] = $shop['id'];
- Dever::db('mail/area_stat')->update($w);
- }
- }
-
- #区县
- if($v['county']>0){
- $county_area_stat = -1;
- $where['area'] = $v['county'];
- $data[$k]['countys']['area'] = $v['province'].','.$v['city'].','.$v['county'];
- // $data[$k]['countys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
- $jia = $this->caigou($where);
- $data[$k]['countys']['price']= $jia['money'] *0.03;
- // $data[$k]['countys']['price']= round($data[$k]['countys']['money']['total']) * 0.3*0.03;
- $mid = Dever::db('agent/member')->getAreaAll(array('area'=>$data[$k]['countys']['area'],'role'=>3));
- if($mid && $mid['id']){
- $data[$k]['countys']['mid'] = $mid['id'];
- }else{
- $data[$k]['countys']['mid'] = '-1';
- }
- $wh['county'] = $v['county'];
- $data[$k]['countys']['num'] = Dever::db('shop/info')->getSerachNum($wh);
- // #体验店
- $t_shop = Dever::db('shop/info')->getAreaAll(array('county'=>$v['county'],'type'=>1,'state'=>1));
- $data[$k]['countys']['type'] = array_column($t_shop,'id');
- $where['type_id'] = implode(',',$data[$k]['countys']['type']);
- $data[$k]['countys']['t_num'] = count($t_shop);
- if($data[$k]['countys']['t_num']>0){
- $data[$k]['countys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
- $data[$k]['countys']['t_fprice'] = $data[$k]['countys']['price'];
- }else{
- $data[$k]['countys']['t_price'] = 0;
- $data[$k]['countys']['t_fprice'] = 0;
- }
- #零售店
- $where['county'] = $v['county'];
- $shop_area = $this->ls($where,2);
- $data[$k]['countys']['l_price'] = $shop_area['price'];
- $data[$k]['countys']['l_fprice'] = $shop_area['price'] * 0.03;
- $data[$k]['countys']['l_num'] = $shop_area['num'];
- $data[$k]['countys']['price'] = $data[$k]['countys']['price'] + $data[$k]['countys']['l_fprice'];
- $w['mid'] = $data[$k]['countys']['mid'];
- $w['name'] = $data[$k]['countys']['area'];
- $w['price'] = $data[$k]['countys']['price'];
- $w['num'] = $data[$k]['countys']['num'];
- $w['c_price'] = $jia['price'];
- // $data[$k]['countys']['money']['total'];
- $w['t_num'] = $data[$k]['countys']['t_num'];
- $w['t_price'] = $data[$k]['countys']['t_price']['total'];
- $w['t_fprice'] = $data[$k]['countys']['t_fprice'];
- $w['l_num'] = $data[$k]['countys']['l_num'];
- $w['l_price'] = $shop_area['price'];
- $w['l_fprice'] = $data[$k]['countys']['l_fprice'];
- $w['parent_id'] = $city_area_stat;
- $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'name'=>$data[$k]['countys']['area']));
- if(!$shop){
- $county_area_stat = Dever::db('mail/area_stat')->insert($w);
- }else{
- $county_area_stat = $w['where_id'] = $shop['id'];
- Dever::db('mail/area_stat')->update($w);
- }
- }
- #街道
- if($v['town']>0){
- $where['area'] = $v['town'];
- $data[$k]['towns']['area'] = $v['province'].','.$v['city'].','.$v['county'].','.$v['town'];
- // $data[$k]['towns']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
- $jia = $this->caigou($where);
- $data[$k]['towns']['price'] = $jia['money'] * 0.05;
- // $data[$k]['towns']['price']= round($data[$k]['towns']['money']['total']) * 0.3*0.05;
- $mid = Dever::db('agent/member')->getAreaAll(array('area'=>$data[$k]['towns']['area'],'role'=>4));
- if($mid && $mid['id']){
- $data[$k]['towns']['mid'] = $mid['id'];
- }else{
- $data[$k]['towns']['mid'] = '-1';
- }
-
- $whe['town'] = $v['town'];
- $data[$k]['towns']['num'] = Dever::db('shop/info')->getSerachNum($whe);
- #体验店
- $t_shop = Dever::db('shop/info')->getAreaAll(array('town'=>$v['town'],'type'=>1,'state'=>1));
- $data[$k]['towns']['type'] = array_column($t_shop,'id');
- $where['type_id'] = implode(',',$data[$k]['towns']['type']);
- $data[$k]['towns']['t_num'] = count($t_shop);
- if($data[$k]['towns']['t_num']>0){
- $data[$k]['towns']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
- $data[$k]['towns']['t_fprice'] = $data[$k]['towns']['price'];
- }else{
- $data[$k]['towns']['t_price'] = 0;
- $data[$k]['towns']['t_fprice'] = 0;
- }
- #零售店
- $where['town'] = $v['town'];
- $shop_area = $this->ls($where,3);
- $data[$k]['towns']['l_price'] =$shop_area['price'];
- $data[$k]['towns']['l_fprice'] =$shop_area['price'] * 0.05;
- $data[$k]['towns']['l_num'] = $shop_area['num'];
- $data[$k]['towns']['price'] = $data[$k]['towns']['price'] + $data[$k]['towns']['l_fprice'];
- $w['mid'] = $data[$k]['towns']['mid'];
- $w['name'] = $data[$k]['towns']['area'];
- $w['price'] = $data[$k]['towns']['price'];
- $w['num'] = $data[$k]['towns']['num'];
- $w['c_price'] = $jia['price'];
- // $data[$k]['towns']['money']['total'];
- $w['t_num'] = $data[$k]['towns']['t_num'];
- $w['t_price'] = $data[$k]['towns']['t_price']['total'];
- $w['t_fprice'] = $data[$k]['towns']['t_fprice'];
- $w['l_num'] = $data[$k]['towns']['l_num'];
- $w['l_price'] = $shop_area['price'];
- $w['l_fprice'] = $data[$k]['towns']['l_fprice'];
- $w['parent_id'] = $county_area_stat;
- $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'name'=>$data[$k]['towns']['area']));
- if(!$shop){
- Dever::db('mail/area_stat')->insert($w);
- }else{
- $w['where_id'] = $shop['id'];
- Dever::db('mail/area_stat')->update($w);
- }
- }
- }
- */
- return 'ok';
- }
- /*
- #采购价-成本价
- public function caigou($where){
- $data = Dever::db('shop/buy_order')->getNewAll($where);
- $res = array();
- $money = 0;
- $res['money'] = 0;
- if($data && isset($data['price']) && $data['price']){
- $res['price'] = $data['price'];
- }else{
- $res['price'] = 0;
- }
-
- foreach($data as $k => $v){
- // $goods_id,$skuid
- $order_goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id']));
- $c_price = 0;
- foreach($order_goods as $k1 => $v1){
- $goods = Dever::load('goods/lib/info')->getPayInfo($v1['goods_id'], $v1['sku_id']);
- if($goods['c_price'] && $goods['c_price'] >= 0){
- $c_price += $goods['c_price'] * $v1['num'];
- }
- }
- $res['money'] += ($v['price'] - $c_price);
- }
- return $res;
- }
- #零售
- public function ls($where,$type=false){
- $shop = Dever::db('mail/area_entry')->getNewAll($where);
- $data = array();
- $data['price'] = 0;
- foreach($shop as $k => $v){
- if ($type == 1) {
- $shop[$k]['shop'] = Dever::db('shop/info')->find(array('city'=>$where['city'],'id'=>$v['shop_id']));
- } elseif ($type == 2) {
- $shop[$k]['shop'] = Dever::db('shop/info')->find(array('county'=>$where['county'],'id'=>$v['shop_id']));
- } elseif ($type == 3) {
- $shop[$k]['shop'] = Dever::db('shop/info')->find(array('town'=>$where['town'],'id'=>$v['shop_id']));
- }
-
- }
- foreach($shop as $k => $v){
- if(!$v['shop']){
- unset($shop[$k]);
- }
- }
- foreach($shop as $k=>$v){
- $data['price'] +=$v['cprice'];
- }
- $data['num'] = count($shop);
- return $data;
- }
- */
- // public function area_api(){
- // #零售店的采购金额*0.4
- // $month = Dever::input('month', date('Y-m'));
- // $start_time = $month .'-01 00:00:00';
- // $where = array();
- // $end_time = date('Y-m-d', strtotime($start_time. ' +1 month -1 day')).' 23:59:59';
- // $where['start'] = Dever::maketime($start_time);
- // $where['end'] = Dever::maketime($end_time);
- // $where['state'] = 1;
-
- // $data = array();
- // $shop = Dever::db('shop/info')->getAreaAll(array('state'=>1));
- // foreach($shop as $k=>$v){
- // $data[$v['city']]=$v;
- // }
- // $shop_area = Dever::db('mail/area_entry')->getAll($where);
- // $res = array();
- // if($shop_area){
- // foreach($shop_area as $k => $v){
- // if($v['area']){
- // $area = explode(',',$v['area']);
- // if($area && isset($area[0])){
- // $res[$k]['province'] = $area[0];
- // }
- // if ($area && isset($area[1])){
- // $res[$k]['city'] = $area[1];
- // }else{
- // $res[$k]['city'] = 0;
- // }
- // if($area && isset($area[2])){
- // $res[$k]['county'] = $area[2];
- // }else{
- // $res[$k]['county'] = 0;
- // }
- // if($area && isset($area[3])){
- // $res[$k]['town'] = $area[3];
- // }else{
- // $res[$k]['town'] = 0;
- // }
- // }
- // }
- // }
-
- // $data = array_values($data);
- // $data = array_merge($data,$res);
- // // print_R($data);die;
- // $result=array_unique($data, SORT_REGULAR);
- // $rest=array();
- // foreach($data as $k=>$v){
- // $rest[$v['county']]=$v;
- // }
- // $data=array_values($rest);
- // foreach ($data as $k => $v) {
- // $edition[] = $v['province'];
- // }
- // array_multisort($edition, SORT_ASC, $data);
- // foreach($data as $k => $v){
- // $w['month'] = $where['start'];
- // #城市
- // if($v['city']>0){
- // $where['area'] = $v['city'];
- // $data[$k]['citys']['area'] = $v['province'].','.$v['city'];
- // $data[$k]['citys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
- // $data[$k]['citys']['price']= round($data[$k]['citys']['money']['total']) * 0.3*0.01;
- // $mid = Dever::db('agent/member')->getAreaAll($where);
- // $w['citys']['area'] = $v['city'];
-
- // if($mid && $mid['id']){
- // $data[$k]['citys']['mid'] = $mid['id'];
- // }else{
- // $data[$k]['citys']['mid'] = '';
- // }
-
- // $where['city'] = $v['city'];
- // $data[$k]['citys']['num'] = Dever::db('shop/info')->getSerachNum($where);
- // #体验店
- // $t_shop = Dever::db('shop/info')->getAreaAll(array('city'=>$v['city'],'type'=>1,'state'=>1));
- // $data[$k]['citys']['type'] = array_column($t_shop,'id');
- // $where['type_id'] = implode(',',$data[$k]['citys']['type']);
- // $data[$k]['citys']['t_num'] = count($t_shop);
- // if($data[$k]['citys']['t_num']>0){
- // $data[$k]['citys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
-
- // }else{
- // $data[$k]['citys']['t_price'] = 0;
- // }
- // #零售店
- // $entry = Dever::db('mail/area_entry')->getNum($where);
- // if ($entry && $entry['num']){
- // $data[$k]['citys']['l_num'] = $entry['num'];
- // $data[$k]['citys']['num'] = $data[$k]['citys']['num'] + $data[$k]['citys']['l_num'];
- // }else{
- // $data[$k]['citys']['l_num'] = 0;
- // }
- // $entry_price = Dever::db('mail/area_entry')->getPrice($where);
- // if ($entry_price && $entry_price['cprice'] ){
- // $data[$k]['citys']['l_price'] = $entry_price['cprice'] * 0.4;
- // $data[$k]['citys']['price'] = $data[$k]['citys']['price'] + $data[$k]['citys']['l_price'];
- // }else{
- // $data[$k]['citys']['l_price'] = 0;
- // }
- // $w['mid'] = $data[$k]['citys']['mid'];
- // $w['area'] = $data[$k]['citys']['area'];
- // $w['price'] = $data[$k]['citys']['price'];
- // $w['c_price'] = $data[$k]['citys']['money']['total'];
- // $w['num'] = $data[$k]['citys']['num'];
- // $w['t_num'] = $data[$k]['citys']['t_num'];
- // $w['t_price'] = $data[$k]['citys']['t_price']['total'];
- // $w['l_num'] = $data[$k]['citys']['l_num'];
- // $w['l_price'] = $data[$k]['citys']['l_price'];
- // $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['citys']['area']));
- // if(!$shop){
- // Dever::db('mail/area_stat')->insert($w);
- // }else{
- // $w['where_id'] = $shop['id'];
- // Dever::db('mail/area_stat')->update($w);
- // }
- // }
-
- // #区县
- // if($v['county']>0){
- // $where['area'] = $v['county'];
- // $data[$k]['countys']['area'] = $v['province'].','.$v['city'].','.$v['county'];
- // $data[$k]['countys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
- // $data[$k]['countys']['price']= round($data[$k]['countys']['money']['total']) * 0.3*0.03;
- // $mid = Dever::db('agent/member')->getAreaAll($where);
- // if($mid && $mid['id']){
- // $data[$k]['countys']['mid'] = $mid['id'];
- // }else{
- // $data[$k]['countys']['mid'] = '';
- // }
- // $wh['county'] = $v['county'];
- // $data[$k]['countys']['num'] = Dever::db('shop/info')->getSerachNum($wh);
- // // #体验店
- // $t_shop = Dever::db('shop/info')->getAreaAll(array('county'=>$v['county'],'type'=>1,'state'=>1));
- // $data[$k]['countys']['type'] = array_column($t_shop,'id');
- // $where['type_id'] = implode(',',$data[$k]['countys']['type']);
- // $data[$k]['countys']['t_num'] = count($t_shop);
- // if($data[$k]['countys']['t_num']>0){
- // $data[$k]['countys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
- // }else{
- // $data[$k]['countys']['t_price'] = 0;
- // }
- // #零售店
- // $entry = Dever::db('mail/area_entry')->getNum($where);
- // if ($entry && $entry['num']){
- // $data[$k]['countys']['l_num'] = $entry['num'];
- // $data[$k]['countys']['num'] = $data[$k]['countys']['num'] + $data[$k]['countys']['l_num'];
- // }else{
- // $data[$k]['countys']['l_num'] = 0;
- // }
- // $entry_price = Dever::db('mail/area_entry')->getPrice($where);
- // if ($entry_price && $entry_price['cprice'] ){
- // $data[$k]['countys']['l_price'] = $entry_price['cprice'] * 0.4;
- // $data[$k]['countys']['price'] = $data[$k]['countys']['price'] + $data[$k]['countys']['l_price'];
- // }else{
- // $data[$k]['countys']['l_price'] = 0;
- // }
- // $w['mid'] = $data[$k]['countys']['mid'];
- // $w['area'] = $data[$k]['countys']['area'];
- // $w['price'] = $data[$k]['countys']['price'];
- // $w['num'] = $data[$k]['countys']['num'];
- // $w['c_price'] = $data[$k]['countys']['money']['total'];
- // $w['t_num'] = $data[$k]['countys']['t_num'];
- // $w['t_price'] = $data[$k]['countys']['t_price']['total'];
- // $w['l_num'] = $data[$k]['countys']['l_num'];
- // $w['l_price'] = $data[$k]['countys']['l_price'];
- // $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['countys']['area']));
- // if(!$shop){
- // Dever::db('mail/area_stat')->insert($w);
- // }else{
- // $w['where_id'] = $shop['id'];
- // Dever::db('mail/area_stat')->update($w);
- // }
- // }
- // #街道
- // if($v['town']>0){
- // $where['area'] = $v['town'];
- // $data[$k]['towns']['area'] = $v['province'].','.$v['city'].','.$v['county'].','.$v['town'];
- // $data[$k]['towns']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
- // $data[$k]['towns']['price']= round($data[$k]['towns']['money']['total']) * 0.3*0.05;
- // $mid = Dever::db('agent/member')->getAreaAll($where);
- // if($mid && $mid['id']){
- // $data[$k]['towns']['mid'] = $mid['id'];
- // }else{
- // $data[$k]['towns']['mid'] = '';
- // }
-
- // $whe['town'] = $v['town'];
- // $data[$k]['towns']['num'] = Dever::db('shop/info')->getSerachNum($whe);
- // #体验店
- // $t_shop = Dever::db('shop/info')->getAreaAll(array('town'=>$v['town'],'type'=>1,'state'=>1));
- // $data[$k]['towns']['type'] = array_column($t_shop,'id');
- // $where['type_id'] = implode(',',$data[$k]['towns']['type']);
- // $data[$k]['towns']['t_num'] = count($t_shop);
- // if($data[$k]['towns']['t_num']>0){
- // $data[$k]['towns']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
- // }else{
- // $data[$k]['towns']['t_price'] = 0;
- // }
- // #零售店
- // $entry = Dever::db('mail/area_entry')->getNum($where);
- // if ($entry && $entry['num']){
- // $data[$k]['towns']['l_num'] = $entry['num'];
- // $data[$k]['towns']['num'] = $data[$k]['towns']['num'] + $data[$k]['towns']['l_num'];
- // }else{
- // $data[$k]['towns']['l_num'] = 0;
- // }
- // $entry_price = Dever::db('mail/area_entry')->getPrice($where);
- // if ($entry_price && $entry_price['cprice'] ){
- // $data[$k]['towns']['l_price'] = $entry_price['cprice'] * 0.4;
- // $data[$k]['towns']['price'] = $data[$k]['towns']['price'] + $data[$k]['towns']['l_price'];
- // }else{
- // $data[$k]['towns']['l_price'] = 0;
- // }
- // $w['mid'] = $data[$k]['towns']['mid'];
- // $w['area'] = $data[$k]['towns']['area'];
- // $w['price'] = $data[$k]['towns']['price'];
- // $w['num'] = $data[$k]['towns']['num'];
- // $w['c_price'] = $data[$k]['towns']['money']['total'];
- // $w['t_num'] = $data[$k]['towns']['t_num'];
- // $w['t_price'] = $data[$k]['towns']['t_price']['total'];
- // $w['l_num'] = $data[$k]['towns']['l_num'];
- // $w['l_price'] = $data[$k]['towns']['l_price'];
- // $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['towns']['area']));
- // if(!$shop){
- // Dever::db('mail/area_stat')->insert($w);
- // }else{
- // $w['where_id'] = $shop['id'];
- // Dever::db('mail/area_stat')->update($w);
- // }
- // }
- // }
- // return 'ok';
- // }
- public function area_member($id){
- $info = Dever::db('mail/area_stat')->find($id);
- $res = '-';
- if($info['mid']){
- $member = Dever::db('agent/member')->find($info['mid']);
- if ($member) {
- $res = $member['name']."<br/>".$member['mobile'];
- }
- }
- return $res;
- }
- public function entry_member($id){
- $info = Dever::db('mail/area_entry')->find($id);
- if($info['shop_id']){
- $member = Dever::db('shop/info')->find($info['shop_id']);
- // print_R($member);die;
- $res = $member['name'].'<br/>'.$member['sid'];
- }else{
- $res = '-';
- }
- return $res;
- }
- public function updateArea_entry($id,$name,$data){
- $sid = Dever::param('sid',$data);
- $month = Dever::param('month',$data);
- if ($id && $sid) {
- $info = Dever::db('mail/area_entry')->find($id);
- $member = Dever::db('shop/info')->find(array('sid'=>$sid));
- // print_R($member);die;
- $where['where_id'] = $id ;
- $where['shop_id'] = $member['id'];
- $where['month'] = strtotime($month);
- Dever::db('mail/area_entry')->update($where);
- }
- }
- }
|