12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073 |
- <?php
- namespace Mail\Lib;
- use Dever;
- class Manage
- {
-
- 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'] = 2;
- $data[$k]['num'] = Dever::db('agent/member')->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);
- }
-
- $data = array();
- $data['name'] = '数量';
- $data['type'] = 'line';
-
- $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->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);
-
- 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 caigou($where){
- $data = Dever::db('shop/buy_order')->getNewAll($where);
- $res = array();
- foreach($data as $k => $v){
-
- $order_goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id']));
- 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){
- $data[$k]['money'] = $v['price'] - $goods['c_price'];
- }else{
- $data[$k]['money'] = $v['price'];
- }
- }
- }
- $money = 0;
- foreach($data as $k1 => $v1){
- $money +=$v1['money'];
- }
- return $money;
- }
- public function ls($where){
-
- $shop = Dever::db('mail/area_entry')->getNewAll($where);
- $data = array();
- $data['price'] = 0;
- foreach($shop as $k => $v){
- $shop[$k]['shop'] = Dever::db('shop/info')->find(array('area'=>$where['area'],'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(){
- $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;
- }
- 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'];
- $jia = $this->caigou($where);
- $data[$k]['citys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
- $data[$k]['citys']['price']= $jia * 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;
- }
-
- $shop_area = $this->ls($where);
- $data[$k]['citys']['l_price'] =$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_price'];
- $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'] = $shop_area['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);
- $jia = $this->caigou($where);
- $data[$k]['countys']['price']= $jia *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;
- }
-
- $shop_area = $this->ls($where);
- $data[$k]['countys']['l_price'] = $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_price'];
- $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'] = $shop_area['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);
- $jia = $this->caigou($where);
- $data[$k]['towns']['price'] = $jia * 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;
- }
-
- $shop_area = $this->ls($where);
- $data[$k]['towns']['l_price'] =$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_price'];
- $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'] = $shop_area['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);
- if($info['mid']){
- $member = Dever::db('agent/member')->find($info['mid']);
- $res = $member['name']."<br/>".$member['mobile'];
- }else{
- $res = '-';
- }
- 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']);
-
- $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));
-
- $where['where_id'] = $id ;
- $where['shop_id'] = $member['id'];
- $where['month'] = strtotime($month);
- Dever::db('mail/area_entry')->update($where);
- }
- }
- }
|