Exemplo n.º 1
0
 public function getData($currentPage, $pageSize, $map = array())
 {
     $data = $this->where($map)->page($currentPage . ',' . $pageSize)->select();
     $data = get_customer_info_by_openid($data);
     $data = get_issueinfo_by_id($data);
     return $data;
 }
Exemplo n.º 2
0
 public function justAction()
 {
     $flag = I('get.flag', '');
     $p = I('get.p', 1);
     $beginTime = $this->dateArr['beginTime'];
     $endTime = $this->dateArr['endTime'];
     $achModel = new \Achievement\Model\AchievementModel();
     //取出当前结算周期的信息,没有,则说明未生成数据
     $asModel = new \Achievement\Model\AchievementIssueModel();
     $asModel->setBeginTime($beginTime);
     $asModel->setEndTime($endTime);
     $asInfo = $asModel->getInfo();
     //如果未生成,或是用户手动生成,则执行
     if ($flag == 'createSettle' || $asInfo == false) {
         //未生成结算周期则先生成
         if ($asInfo == false) {
             $asInfo = $asModel->creatIssue();
         }
         $issue = $asInfo['id'];
         //取结算信息
         $settles = $achModel->getJustInfo();
         //进行信息的更新
         $achModel->updateInfo($issue, $settles);
     }
     $issue = $asInfo['id'];
     //取出信息并展示
     $achModel->setIssue($issue);
     //取总条数
     $counts = $achModel->getIssueCounts();
     $this->page->setCurrentPage($p);
     $this->page->setPageStyle(2);
     $this->page->setCounts($counts);
     $pageStr = $this->page->fetch();
     $currentPage = $this->page->getCurrentPage();
     $pageSize = $this->page->getPageSize();
     $achModel->setCurrentPage = $currentPage - 1;
     $achModel->setPageSize = $pageSize;
     $data = $achModel->getIssueData();
     foreach ($data as $key => $value) {
         $data[$key]['actionUrl']['payUrl'] = U('pay?id=' . $value['id']);
     }
     $data = get_customer_info_by_openid($data);
     $this->assign('beginTime', $beginTime);
     $this->assign('endTime', $endTime);
     $createUrl = U('just?flag=createSettle&p=' . $p);
     //重新生成业绩参数
     $this->assign('createUrl', $createUrl);
     $this->assign('page', $pageStr);
     $this->assign('data', $data);
     $this->assign('YZRight', $this->fetch('just'));
     $this->display(YZ_TEMPLATE);
 }
 public function getPayedOrder()
 {
     if ($this->beginTime == null || $this->endTime == null) {
         return false;
     }
     /*
      * 取出本时间段的全部信息
      * 1.拼接PID信息
      * 2.按ID进行分组
      * 3.按PID分组        * 
      * 4.得到PID信息
      * 5.在原ID信息拼接上对应的PID信息
      */
     $map['payed_time'] = array('BETWEEN', $this->beginTime . ',' . $this->endTime);
     $map['is_pay'] = 1;
     $map['is_cancel'] = 0;
     $resData = $this->where($map)->select();
     //拼接客户信息
     $kewWord = 'buy_openid';
     $resData = get_customer_info_by_openid($resData, $kewWord);
     //按客户id分组
     $key1 = 'buy_openid';
     $key2 = 'id';
     $direData = group_by_key1_key2($resData, $key1, $key2);
     $dataRes = array();
     //生成客户信息
     foreach ($direData as $key => $value) {
         $data = array();
         $totalDirectFee = 0;
         //直销业绩
         $totalLineFee = 0;
         //线销业绩
         $totalGoodsFee = 0;
         //商品总价(基数)
         foreach ($value as $ke => $va) {
             $totalDirectFee += $va['total_direct_fee'];
             $totalLineFee += $va['total_line_fee'];
             $totalGoodsFee += $va['total_goods_fee'];
         }
         //添加业绩信息
         $data['totalDirectFee'] = $totalDirectFee;
         $data['totalLineFee'] = $totalLineFee;
         $data['totalGoodsFee'] = $totalGoodsFee;
         $data['_detail'] = $value;
         //添加parentId
         $data['parId'] = $value[0]['buy_openid']['parentid'];
         $data['_customer_id'] = $value[0]['buy_openid']['id'];
         $dataRes[$key] = $data;
     }
     //按客户pid再分组,拼接线销信息
     $key2 = 'parId';
     $lineData = group_by_key($dataRes, $key2);
     $lineDateRes = array();
     foreach ($lineData as $key1 => $value1) {
         $ltotalDirectFee = 0;
         //下线直销业绩
         $ltotalLineFee = 0;
         //下线线销业绩
         $ltotalGoodsFee = 0;
         //下线商品总价(基数)
         foreach ($value1 as $key => $value) {
             $ltotalDirectFee += $value['totalDirectFee'];
             $ltotalLineFee += $value['totalLineFee'];
             $ltotalGoodsFee += $value['totalGoodsFee'];
         }
         $lineDateRes[$key1]['parId'] = $value['parId'];
         $lineDateRes[$key1]['totalDirectFee'] = $ltotalDirectFee;
         $lineDateRes[$key1]['totalLineFee'] = $ltotalLineFee;
         $lineDateRes[$key1]['totalGoodsFee'] = $ltotalGoodsFee;
         $lineDateRes[$key1]['_lineDetail'] = $value1;
     }
     //设置空数组
     $emptyArr = array("totalDirectFee" => 0, "totalLineFee" => 0, "totalGoodsFee" => 0, "_lineDetail" => array());
     //把id与它所对应的下线信息拼接到一起
     foreach ($dataRes as $key => $value) {
         if (isset($lineDateRes[$key])) {
             $dataRes[$key]['_line'] = $lineDateRes[$key];
             unset($lineDateRes[$key]);
         } else {
             $dataRes[$key]['_line'] = $emptyArr;
         }
         $dataRes[$key]['lineTotalLineFee'] = $dataRes[$key]['_line']['totalLineFee'];
         $dataRes[$key]['lineTotalGoodsFee'] = $dataRes[$key]['_line']['totalGoodsFee'];
     }
     //设置空数组
     $emptyArr = array("totalDirectFee" => 0, "totalLineFee" => 0, "totalGoodsFee" => 0, "_detail" => array());
     //将上线无数据的元素进行空数拼接
     foreach ($lineDateRes as $key => $value) {
         $dataRes[$key] = $emptyArr;
         $dataRes[$key]['_line'] = $value;
         $dataRes[$key]['_customer_id'] = $key;
         $dataRes[$key]['lineTotalLineFee'] = $value['totalLineFee'];
         $dataRes[$key]['lineTotalGoodsFee'] = $value['totalGoodsFee'];
     }
     //去除上线为系统的记录
     unset($dataRes[0]);
     return $dataRes;
     //
     //
     //
     //
     //
     //
     //
     //        /*
     //         * 先获取直销信息,再获取线销信息
     //         */
     //        foreach($customerArr as $ke => $value)
     //        {
     //            $map['openid'] = $value[$key];
     //
     //            $res = $this->where($map)->select();
     //            $customerArr[$ke]['achievement'] = $res;
     //            $customerArr[$ke] = array_merge($value,$this->_getAchieveData($res));
     //
     //            //取下线的业绩
     //            $mapChild = array();
     //            $mapChild['parentid'] = $v['id'];
     //            $child = $this->where($mapChild)->select();
     //
     //            $totalDirectFee = 0; //直销业绩
     //            $totalLineFee = 0;  //线销业绩
     //            $totalGoodsFee = 0; //商品总价(基数)
     //            foreach($child as $cke => $cva)
     //            {
     //                $map['openid'] = $cva[$key];
     //                $res = $this->where($map)->select();
     //                $detailData = $this->_getAchieveData($res);
     //                $child[$cke]['achievement'] = array_merge($cva,$detailData);
     //                $totalDirectFee += $detailData['_totalDirectFee'];
     //                $totalLineFee += $detailData['_totalLineFee'];
     //                $totalGoodsFee += $detailData['_totalGoodsFee'];
     //            }
     //            $child['_totalDirectFee'] = $totalDirectFee;
     //            $child['_totalLineFee'] = $totalLineFee;
     //            $child['_totalGoodsFee'] = $totalGoodsFee;
     //
     //            $customerArr[$ke]['_child'] = $child;
     //        }
     //
     //        return $customerArr;
 }