public function mouthSoltPayment()
 {
     $Trade = D('Trade');
     $mouth_solt = get_month_solt($this->month_start, $this->month_end);
     $map['status'] = ['in', '2,3,4'];
     foreach ($mouth_solt as $k => $v) {
         $map['paytime'] = [['gt', $v['start']['ts']], ['lt', $v['end']['ts']]];
         $mouth_solt_trades[$k]['mouth_solt'] = $v;
         $mouth_solt_trades[$k]['trades'] = $Trade->field('itemid,amount')->where($map)->select();
         $mouth_solt_trades[$k]['mouth_name'] = date("Y-m", $v['start']['ts']);
         $mouth_solt_trades[$k]['trade_amount'] = get_arr_k_amount($mouth_solt_trades[$k]['trades'], 'amount');
         unset($mouth_solt_trades[$k]['trades']);
     }
     $xAxis_data = Tools::arr2str(Tools::getCols($mouth_solt_trades, 'mouth_name', true));
     $mouth_data = Tools::arr2str(Tools::getCols($mouth_solt_trades, 'trade_amount'));
     $this->assign(['xAxis_data' => $xAxis_data, 'mouth_data' => $mouth_data]);
     $this->display();
 }
 /**
  * 资讯/病虫害/农药中毒饼形图
  * @Edwin
  */
 public function ratioInformation()
 {
     $Information = D('Information');
     $map['addtime'] = [['gt', $this->month_start], ['lt', $this->month_end]];
     $month_start = strtotime('January 2013');
     //查询数据
     $mouth_solt = get_month_solt($month_start, $this->month_end);
     foreach ($mouth_solt as $k => $v) {
         $map['addtime'] = [['gt', $v['start']['ts']], ['lt', $v['end']['ts']]];
         $mouth_solt_information[$k]['mouth_solt'] = $v;
         $x = $Information->field('itemid')->where($map)->select();
         $mouth_solt_information[$k]['information_count'] = count($x);
     }
     /*
      * 月病虫害总量
      */
     $Pests = D('Pests');
     foreach ($mouth_solt as $k => $v) {
         $map['addtime'] = [['gt', $v['start']['ts']], ['lt', $v['end']['ts']]];
         $mouth_solt_pests[$k]['mouth_solt'] = $v;
         $x = $Pests->field('itemid')->where($map)->select();
         $mouth_solt_pests[$k]['pests_count'] = count($x);
     }
     /*
      * 月农药中毒总量
      */
     $Poisoning = D('Poisoning');
     foreach ($mouth_solt as $k => $v) {
         $map['addtime'] = [['gt', $v['start']['ts']], ['lt', $v['end']['ts']]];
         $mouth_solt_poisoning[$k]['mouth_solt'] = $v;
         $x = $Poisoning->field('itemid')->where($map)->select();
         $mouth_solt_poisoning[$k]['poisoning_count'] = count($x);
     }
     //重组数据_查询月份资讯总数据
     $series_data_inforamtion_information = get_arr_k_amount($mouth_solt_information, 'information_count');
     //重组数据_查询月份病虫害数总数据
     $series_data_inforamtion_pests = get_arr_k_amount($mouth_solt_pests, 'pests_count');
     //重组数据_查询月份农药中毒总数据
     $series_data_inforamtion_poisoning = get_arr_k_amount($mouth_solt_poisoning, 'poisoning_count');
     //注入显示
     $this->assign(['series_data_information' => $series_data_inforamtion_information, 'series_data_pests' => $series_data_inforamtion_pests, 'series_data_poisoning' => $series_data_inforamtion_poisoning]);
     $this->assign(['month_start' => $month_start]);
     $this->display();
 }
 /**
  *  公用查询时间
  */
 private function getRange()
 {
     if (I('day_start') && I('day_end')) {
         $this->day_start = strtotime(I('day_start') . " 00:00:00");
         $this->day_end = strtotime(I('day_end') . " 23:59:59");
     } else {
         $this->day_start = strtotime('-1 week');
         $this->day_end = time();
     }
     $this->day_solt = get_day_solt($this->day_start, $this->day_end);
     $this->assign(['day_start' => $this->day_start, 'day_end' => $this->day_end]);
     $this->mapDayRange = [['gt', $this->day_start], ['lt', $this->day_end]];
     if (I('month_start') && I('month_end')) {
         $this->month_start = strtotime(I('month_start') . "-01 00:00:00");
         $this->month_end = strtotime(I('month_end') . "-01 23:59:59");
     } else {
         $this->month_start = strtotime($this->now_Y . "-01-01 00:00:00");
         $this->month_end = time();
     }
     $this->month_solt = get_month_solt($this->month_start, $this->month_end);
     $this->assign(['month_start' => $this->month_start, 'month_end' => $this->month_end]);
     $this->mapMonthRange = [['gt', $this->month_start], ['lt', $this->month_end]];
     if (I('year_start') && I('year_end')) {
         $this->year_start = strtotime(I('year_start') . "-01-01 00:00:00");
         $this->year_end = strtotime(I('year_end') . "-12-31 23:59:59");
     } else {
         $this->year_start = strtotime($this->now_Y - 1 . "-01-01 00:00:00");
         $this->year_end = time();
     }
     $this->year_solt = get_year_solt($this->year_start, $this->year_end);
     $this->assign(['year_start' => $this->year_start, 'year_end' => $this->year_end]);
     $this->mapYearRange = [['gt', $this->year_start], ['lt', $this->year_end]];
 }
 public function memberPurchase()
 {
     //计算用户总量
     $Member = D("Member");
     $map['status'] = ['in', '2,3,4'];
     $mouth_solt = get_month_solt($this->month_start, $this->month_end);
     foreach ($mouth_solt as $k => $v) {
         $time_start = $mouth_solt[1]['start']['ts'];
         $time_end = $mouth_solt[$k]['end']['ts'];
         $map['regtime'] = [between, [$time_start, $time_end]];
         $mouth_solt_data[$k]['mouth_solt'] = $v;
         $x = $Member->field('userid')->where($map)->select();
         $mouth_solt_data[$k]['count'] = count($x);
         $sql = "SELECT count(username) as username FROM (SELECT a.username FROM destoon_member as a left join destoon_finance_trade as b on a.username=b.buyer WHERE b.updatetime BETWEEN {$time_start} AND {$time_end} GROUP BY b.buyer) AS x";
         $data = $Member->query($sql);
         $mouth_solt_data[$k]['count_pirchase'] = $data;
     }
     $count = $mouth_solt_data[$k]['count'];
     $count_pirchase = $mouth_solt_data[$k]['count_pirchase'];
     $this->assign(['member_count' => $count, 'count_pirchase' => $count_pirchase[0]['username']]);
     $this->display();
 }
 /**
  * 合作商提成月走势图
  * @author Edwin <*****@*****.**>
  */
 public function partnerTrend()
 {
     $Agent = D('Partner');
     $map['status'] = ['in', '2,3,4'];
     //查询数据
     $month_start = strtotime('September 2013');
     $month_solt = get_month_solt($month_start, $this->month_end);
     foreach ($month_solt as $k => $v) {
         $map['addtime'] = [['gt', $v['start']['ts']], ['lt', $v['end']['ts']]];
         $mouth_solt_partner[$k]['mouth_solt'] = $v;
         $x = $Agent->field('money')->where($map)->select();
         $mouth_solt_partner[$k]['mouth_name'] = date("Y-m", $v['start']['ts']);
         $mouth_solt_partner[$k]['partner_sum'] = get_arr_k_amount($x, 'money');
     }
     //重组数据_月资讯数据
     $xAxis_data = Tools::arr2str(Tools::getCols($mouth_solt_partner, 'mouth_name', true));
     $series_data = Tools::arr2str(Tools::getCols($mouth_solt_partner, 'partner_sum'));
     //注入显示
     $this->assign(['xAxis_data' => $xAxis_data, 'series_data' => $series_data]);
     $this->assign(['month_start' => $month_start]);
     $this->display();
 }