Ejemplo n.º 1
0
 function listlogo()
 {
     echo parent::listimg();
 }
Ejemplo n.º 2
0
 public function agreeuser()
 {
     if (parent::isroot()) {
         $id = I('id', '');
         if ($id == '') {
             $this->ajaxReturn("找不到该认证信息");
         }
         $user = M('Userinfo')->where(array('id' => $id))->find();
         $datas['status'] = 3;
         if (M('Userinfo')->where(array('id' => $id))->save($datas)) {
             $this->ajaxReturn("同意修改");
         } else {
             $this->ajaxReturn("系统出错");
         }
     } else {
         redirect(__ROOT__ . '/Public/error.html');
     }
 }
Ejemplo n.º 3
0
 function listmonthtime()
 {
     if (parent::isroot()) {
     } else {
         redirect(__ROOT__ . '/Public/error.html');
         return;
     }
     $refshopid = I('refshopid', '');
     if ($refshopid != '') {
         $datas['refshopid'] = $refshopid;
     } else {
         $this->ajaxReturn('No shopid');
         //无店铺ID
     }
     $bt = I('bt', '');
     $et = I('et', '');
     if ($bt != '' and $et != '') {
     } else {
         //日期不完整
         $this->ajaxReturn('date not complete');
     }
     try {
         $data1 = explode('-', $bt);
         $data2 = explode('-', $et);
         $y1 = (int) $data1[0];
         $m1 = (int) $data1[1];
         $y2 = (int) $data2[0];
         $m2 = (int) $data2[1];
     } catch (Exception $e) {
         //日期不正确
         $this->ajaxReturn('date change error' . $e->getTrace());
     }
     if ($m1 <= 0 or $m1 > 12 or ($m2 <= 0 or $m2 > 12)) {
         //月数不对
         $this->ajaxReturn('month wrong');
     }
     if ($y1 > $y2) {
         //年数不对
         $this->ajaxReturn('year wrong');
     } else {
         if ($y1 == $y2) {
             if ($m1 >= $m2) {
                 //年对、月不对
                 $this->ajaxReturn('year right month wrong');
             }
         } else {
         }
     }
     $daylength = array();
     /*从这里开始干活了*/
     if ($y1 == $y2) {
         for ($i = $y1; $i <= $y2; $i++) {
             for ($j = $m1; $j <= $m2; $j++) {
                 if ($j < 10) {
                     $daylength[] = $i . '-0' . $j;
                 } else {
                     $daylength[] = $i . '-' . $j;
                 }
             }
         }
     } else {
         //2015-02**2016-08
         for ($k = $m1; $k <= 12; $k++) {
             if ($k < 10) {
                 $daylength[] = $y1 . '-0' . $k;
             } else {
                 $daylength[] = $y1 . '-' . $k;
                 //20
             }
         }
         for ($i = $y1 + 1; $i < $y2; $i++) {
             for ($j = 1; $j <= 12; $j++) {
                 if ($j < 10) {
                     $daylength[] = $i . '-0' . $j;
                 } else {
                     $daylength[] = $i . '-' . $j;
                 }
             }
         }
         for ($h = 1; $h <= $m2; $h++) {
             if ($h < 10) {
                 $daylength[] = $y2 . '-0' . $h;
             } else {
                 $daylength[] = $y2 . '-' . $h;
                 //20
             }
         }
     }
     /* 	$this->ajaxReturn($daylength);
     		return; */
     $rows = array();
     foreach ($daylength as $day) {
         $isexist = M('qingmu.timer', 'oa')->where(array('shopid' => $refshopid, 'yearmonth' => $day))->find();
         $updateid = 0;
         $pai = 0;
         if ($isexist) {
             $paichustatus = $isexist['paichustatus'];
             if ('0' === $paichustatus) {
                 $pai = 2;
                 //这个值好啊!!
             }
             //	var_dump('0'===$paichustatus);
             if ($isexist['status'] == 1 and $pai != 2) {
                 //last year data
                 $lastyear1 = explode('-', $day);
                 $lastyear2 = $lastyear1[0] - 1;
                 $lastyear = $lastyear2 . '-' . $lastyear1[1];
                 //var_dump($lastyear);
                 $qunian = M('qingmu.timer', 'oa')->where(array('shopid' => $refshopid, 'yearmonth' => $lastyear))->find();
                 //var_dump($qunian);
                 if ($qunian) {
                     $isexist['qcgmoney'] = $qunian['cgmoney'];
                     $isexist['qcgrate'] = $qunian['cgrate'];
                     $isexist['qsumrate'] = $qunian['sumrate'];
                 } else {
                     $isexist['qcgmoney'] = 'none';
                     $isexist['qcgrate'] = 'none';
                     $isexist['qsumrate'] = 'none';
                 }
                 $rows[] = $isexist;
                 continue;
             } else {
                 $updateid = $isexist['id'];
                 $paichushijian = explode(',', $isexist['paichushijian']);
             }
         }
         if (1 == 1) {
             //开始插数据、处理数据
             //笨蛋,不要看这里
             /*CREATE TABLE `oatimer` (
               `id` int(11) NOT NULL AUTO_INCREMENT,
               `shopname` varchar(200) DEFAULT NULL COMMENT '店铺名',
               `shopid` int(11) DEFAULT NULL COMMENT '店铺id',
               `yearmonth` varchar(100) DEFAULT NULL COMMENT '月-年(2015-02)',
               `day` varchar(100) DEFAULT NULL COMMENT '天(如果数据还没有到达月尾,则为那天,一般值为29,30,31)',
               `cgrate` varchar(45) DEFAULT NULL COMMENT '常规完成率',
               `sumrate` varchar(45) DEFAULT NULL COMMENT '总体完成率',
               `cgmoney` varchar(45) DEFAULT NULL COMMENT '日成交额(常规平均,活动聚划算当天不算)',
               `createtime` datetime DEFAULT NULL COMMENT '查询时间',
               `updatetime` datetime DEFAULT NULL COMMENT '更新时间',
               `username` varchar(64) DEFAULT NULL COMMENT '最后一次查询人',
               `status` tinyint(4) DEFAULT NULL COMMENT '是否到达月尾(1表示已经到达月尾,0表示需要重新计算)',
               `calday` tinyint(4) DEFAULT NULL COMMENT '该月常规天数',
               `summonthmoney` decimal(19,2) DEFAULT NULL COMMENT '月累计销售额',
               `sumcgmonthmoney` decimal(19,2) DEFAULT NULL COMMENT '月常规销售额',
               `plan` decimal(19,2) DEFAULT NULL COMMENT '月总目标',
               `lzcgplan` decimal(19,2) DEFAULT NULL COMMENT '常规目标',
               PRIMARY KEY (`id`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='OA时间序列预测统计数据表';*/
             //SELECT * FROM qingmu.statshopdata where refShopId=91 and statDay like '2016-02-%' order by statDay desc;
             //SELECT sum(sumcgmoney)/count(*) FROM qingmu.statshopdata where refShopId=8 and statDay like '2016-03-%' and sumjhsMoney=0 and sumhdMoney=0 order by statDay desc;
             //这样算日常规很快
             $sql1 = "refshopid=" . $refshopid . " and statday like '" . $day . "-%' and sumjhsmoney=0 and sumhdmoney=0";
             if ($pai != 2) {
             } else {
                 foreach ($paichushijian as $temp) {
                     $sql1 = $sql1 . " and statday not like '" . $day . "-" . $temp . "'";
                     //var_dump($sql1);
                 }
             }
             /* $this->ajaxReturn($sql1);return; */
             $sql1rs = M('shopdata', 'stat', C('qingmu'))->where($sql1)->field("count(*) as calday, sum(sumcgmoney)/count(*) as cgmoney")->order("statday desc")->select();
             $sql1r = $sql1rs[0];
             //var_dump($sql1r);
             /**************保护对象*******************/
             //日成交额常规
             $cgmoney = $sql1r['cgmoney'];
             //该月常规天数
             $calday = $sql1r['calday'];
             /***************保护对象******************/
             $sql2 = "refshopid=" . $refshopid . " and statday like '" . $day . "-%'";
             $sql2rs = M('shopdata', 'stat', C('qingmu'))->where($sql2)->order("statday desc")->limit(1)->select();
             if ($sql2rs == false) {
                 continue;
             }
             $sql2r = $sql2rs[0];
             //var_dump($sql2r);
             /**************保护对象*******************/
             //月累计销售额
             $summonthmoney = $sql2r['summonthmoney'];
             //月常规销售额
             $sumcgmonthmoney = $sql2r['sumcgmonthmoney'];
             //常规完成率
             $cgrate = 0;
             //总体完成率
             $sumrate = 0;
             //月总目标
             $plan = 0;
             //常规目标
             $lzcgplan = 0;
             //当月最后一天
             $lastday = $sql2r['statday'];
             //是否已经是最后一天
             $status = 0;
             $shopname = '';
             $shop = M('shop', 'ref', C('qingmu'))->where(array('id' => $refshopid))->find();
             if ($shop) {
                 //店铺名
                 $shopname = $shop['sname'];
             }
             $mubiao = M('sellplan', 'stat', C('qingmu'))->where("refshopid=" . $refshopid . " and pmonth='" . $day . "'")->find();
             if ($mubiao) {
                 //月总目标
                 $plan = $mubiao['plan'];
                 $sumrate = $summonthmoney / $plan;
                 //常规目标
                 $lzcgplan = $mubiao['lzcgplan'];
                 $cgrate = $sumcgmonthmoney / $lzcgplan;
                 //判断是否最后一天
                 $temp = explode('-', $lastday);
                 $tempy = $temp[0];
                 //2015
                 $tempm = $temp[1];
                 //05
                 $tempd = $temp[2];
                 //06
                 /*
                  * 这里傻逼放一个界定 是否最后一天的标记,排除BUG在此
                  * 
                  * 还是不放了!!
                  * */
                 switch ($tempd) {
                     case '29':
                         if ($tempm == '02') {
                             if ($tempy % 100 == 0 and $tempy % 400 == 0 or $tempy % 100 != 0 and $tempy % 4 == 0) {
                                 $status = 1;
                             } else {
                                 $status = 0;
                             }
                         }
                         break;
                     case '28':
                         if ($tempm == '02') {
                             if ($tempy % 100 == 0 and $tempy % 400 == 0 or $tempy % 100 != 0 and $tempy % 4 == 0) {
                                 $status = 0;
                             } else {
                                 $status = 1;
                             }
                         }
                         break;
                     case '31':
                         if ($tempm == '01' or $tempm == '03' or $tempm == '05' or $tempm == '07' or $tempm == '08' or $tempm == '10' or $tempm == '12') {
                             $status = 1;
                         } else {
                             $status = 0;
                         }
                         break;
                     case '30':
                         if ($tempm == '04' or $tempm == '06' or $tempm == '09' or $tempm == '11') {
                             $status = 1;
                         } else {
                             $status = 0;
                         }
                         break;
                     default:
                         $status = 0;
                 }
             }
             //插数据、look hear
             $data['day'] = $lastday;
             $data['status'] = $status;
             $data['shopname'] = $shopname;
             $data['shopid'] = $refshopid;
             $data['yearmonth'] = $day;
             $data['cgrate'] = $cgrate;
             $data['sumrate'] = $sumrate;
             $data['cgmoney'] = $cgmoney;
             $data['createtime'] = date("Y-m-d H:i:s", strtotime('now'));
             $username = $_SESSION['username'];
             $data['username'] = $username;
             $data['status'] = $status;
             $data['calday'] = $calday;
             $data['summonthmoney'] = $summonthmoney;
             $data['sumcgmonthmoney'] = $sumcgmonthmoney;
             $data['plan'] = $plan;
             $data['lzcgplan'] = $lzcgplan;
             //var_dump($data);
             if ($updateid != 0) {
                 $data['updatetime'] = date("Y-m-d H:i:s", strtotime('now'));
                 if ($pai == 2 and $status == 1) {
                     //没问题的
                     $data['paichustatus'] = 1;
                 } else {
                     if ($pai == 2 and $status == 0) {
                         //傻逼的最后一天
                         $data['paichustatus'] = 0;
                     } else {
                         $data['paichustatus'] = null;
                         //其他
                     }
                 }
                 $isexist1 = M('qingmu.timer', 'oa')->where('id=' . $updateid)->save($data);
                 $isexist1 = M('qingmu.timer', 'oa')->where('id=' . $updateid)->find();
                 $lastyear1 = explode('-', $day);
                 $lastyear2 = $lastyear1[0] - 1;
                 $lastyear = $lastyear2 . '-' . $lastyear1[1];
                 $qunian = M('qingmu.timer', 'oa')->where(array('shopid' => $refshopid, 'yearmonth' => $lastyear))->find();
                 if ($qunian) {
                     $isexist1['qcgmoney'] = $qunian['cgmoney'];
                     $isexist1['qcgrate'] = $qunian['cgrate'];
                     $isexist1['qsumrate'] = $qunian['sumrate'];
                 } else {
                     $isexist1['qcgmoney'] = 'none';
                     $isexist1['qcgrate'] = 'none';
                     $isexist1['qsumrate'] = 'none';
                 }
                 $rows[] = $isexist1;
             } else {
                 $isexist1 = M('qingmu.timer', 'oa')->add($data);
                 $isexist2 = M('qingmu.timer', 'oa')->where(array('yearmonth' => $day, 'shopname' => $shopname))->find();
                 $lastyear1 = explode('-', $day);
                 $lastyear2 = $lastyear1[0] - 1;
                 $lastyear = $lastyear2 . '-' . $lastyear1[1];
                 $qunian = M('qingmu.timer', 'oa')->where(array('shopid' => $refshopid, 'yearmonth' => $lastyear))->find();
                 if ($qunian) {
                     $isexist2['qcgmoney'] = $qunian['cgmoney'];
                     $isexist2['qcgrate'] = $qunian['cgrate'];
                     $isexist2['qsumrate'] = $qunian['sumrate'];
                 } else {
                     $isexist2['qcgmoney'] = 'none';
                     $isexist2['qcgrate'] = 'none';
                     $isexist2['qsumrate'] = 'none';
                 }
                 $rows[] = $isexist2;
             }
             /***************保护对象******************/
         }
         // 			var_dump($day);
     }
     // 		$temp=var_dump($daylength);
     $datajinhan['total'] = count($rows);
     $datajinhan['rows'] = $rows;
     $this->ajaxReturn($datajinhan);
 }
Ejemplo n.º 4
0
 public function deleteuser()
 {
     if (parent::isroot()) {
         $id = I('id', '');
         if ($id == '') {
             $this->ajaxReturn("找不到用户");
         }
         $user = M('User')->where(array('id' => $id))->find();
         if (in_array($user['username'], C('ADMIN_AUTH_KEY'))) {
             $this->ajaxReturn("神一样的存在,不能删除");
         }
         $datas['status'] = 3;
         if (M('User')->where(array('id' => $id))->save($datas)) {
             $this->ajaxReturn("成功删除");
         } else {
             $this->ajaxReturn("删除失败");
         }
     } else {
         redirect(__ROOT__ . '/Public/error.html');
     }
 }