123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- <?php
- Doo::loadCore ( 'db/DooModel' );
- class wasteBook extends DooModel {
- public $wid;
- public $expensesType;
- public $accountType;
-
- public $dailyType;
- public $operatingBankType;
- public $depositMethod;
- public $accountMsg;
- public $accountPrice;
- public $accountBank;
- public $category;
- public $cid;
- public $name;
- public $sid;
- public $dailyIncomeType;
- public $dailyExpenditureType;
- public $inputDate;
- public $dataID;
- public $remarks;
- public $accountPriceShow;
- public $createAt;
- public $updateAt;
- public $synPaymentDate;
-
-
- public $_table = 'CLD_wasteBook';
- public $_primarykey = 'wid';
- public $_fields = array (
- 'wid',
- 'expensesType',
- 'accountType',
- 'dailyType',
- 'operatingBankType',
- 'depositMethod',
- 'accountMsg',
-
- 'accountPrice',
- 'accountBank',
- 'category',
- 'name',
- 'cid',
- 'sid',
- 'dailyIncomeType',
- 'dailyExpenditureType',
- 'inputDate' ,
- 'dataID',
- 'remarks',
- 'accountPriceShow',
-
- 'createAt',
- 'updateAt',
- 'synPaymentDate',
- );
-
- // 获得所有流水
- function GetAll(){
- $list = $this->find ( array (
-
- 'asArray' => TRUE
- ) );
-
- return $list;
- }
-
-
- //
- function getWasteBookByStatisticsYear($year=''){
- if (empty($year))
- $year=date ( "Y" );
-
- $list = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice ',
- 'where' => " Year(inputDate) <" . $year ,
- //'groupby' => 'Month(inputDate)',
- 'asArray' => TRUE
- ) );
-
- return $list;
- }
- function getWasteBookByStatisticsDay($year='',$month=''){
- $day=cal_days_in_month(CAL_GREGORIAN, date('m'), date('Y'));
- if (empty($year)){
- $year=date ( "Y" );
- $month=date("m");
- }
-
- $list = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice ',
- 'where' => " inputDate <'" . $year."-".$month."-1'" ,
- //'groupby' => 'Month(inputDate)',
- 'asArray' => TRUE
- ) );
-
- return $list;
- }
-
- function getWasteBookByStatistics($expensesType=1,$year=''){
-
- if (empty($year))
- $year=date ( "Y" );
-
- $list = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,sum(accountPriceShow) as accountPriceShow ,Month(inputDate) as month,expensesType,Year(inputDate)',
- 'where' => " Year(inputDate) =" . $year . " and expensesType=" . $expensesType,
- 'groupby' => 'Month(inputDate),expensesType',
- 'asArray' => TRUE
- ) );
-
- //print_r($list);
- return $list;
- }
-
- function getStatisticsByMonthAll($year= '',$month=''){
-
- $startYear=$year."-".$month."-01:00.00.00";
- // $endYear=$data['year']."-".$data['month']."-31:23.59.59";
- // date_format(inputDate,'%Y-%m')<date_format('".$year."-".$month."-1','%Y-%m')
-
- $list = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,sum(accountPriceShow) as accountPriceShow,date_format(inputDate,"%Y-%m") ,Month(inputDate) as month,expensesType,Year(inputDate),Day(inputDate) as day',
- 'where' => " inputDate< ? and (expensesType=1 or expensesType=2)",
- 'param' =>array($startYear),
- //'groupby' => 'Day(inputDate)',
- 'asArray' => TRUE
- ) );
- return $list;
- }
-
- public function getStatisticsByDay($expensesType=1,$year= '',$month='') {
-
-
-
- $list = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,sum(accountPriceShow) as accountPriceShow,date_format(inputDate,"%Y-%m") ,Month(inputDate) as month,expensesType,Year(inputDate),Day(inputDate) as day',
- 'where' => " date_format(inputDate,'%Y-%m')=date_format('".$year."-".$month."-1','%Y-%m') and expensesType=" . $expensesType,
- 'groupby' => 'Day(inputDate),expensesType',
- 'asArray' => TRUE
- ) );
-
- // $list = $this->find ( array (
- // 'select' => 'sum(inComePrice) as inComePrice,sum(payPrice) as payPrice,Month(date) as month,expensesType,Year(date),Day(date) as day',
- // 'where' => " Year(date) =" . $year . " and expensesType=" . $expensesType.$con,
- // 'groupby' => $groupby,
- // 'asArray' => TRUE
- // ) );
-
- return $list;
-
- }
-
- function getAccountBookByExpensesType($limit=4,$expensesType=1,$con=''){
-
- $where= array (
- 'where' => "expensesType=".$expensesType.$con,
- 'desc' => 'inputDate',
- 'asArray' => TRUE
- );
- if($limit!=0){
- $where += array (
- 'limit' => $limit
- );
- }
-
-
-
- $list= $this->find ( $where );
- //print_r($list);
- Doo::loadModel ( "accountBook" );
- $accountBook = new accountBook ();
- Doo::loadModel ( 'receipt' );
- $receipt = new receipt ();
- Doo::loadModel ( 'invoiceReceivables' );
- $invoiceReceivables = new invoiceReceivables ();
- Doo::loadModel ( 'invoice' );
- $invoice = new invoice ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- //print_r($list);
- foreach ($list as $key=>$value){
- $list[$key]['widKey']=$XDeode->encode ( $value ['wid'] );
- $list[$key]['accountTypeKey']=$XDeode->encode ( $value ['accountType'] );
-
- $list[$key]['accountBankMsg']='';
- if($value['accountBank']=='CGBDeposit'){
- $list[$key]['accountBankMsg']='纵横广发';
- }elseif($value['accountBank']=='ICBCDeposit'){
- $list[$key]['accountBankMsg']='纵横工行';
- }elseif($value['accountBank']=='HUADeposit'){
- $list[$key]['accountBankMsg']='广发纵横知道';
- }elseif($value['accountBank']=='PersonalDeposit'||$value['accountBank']=='CGBPersonalDeposit'){
- $list[$key]['accountBankMsg']='个人广发';
- }
-
- $list[$key]['data']=array();
- if ($value['accountType']==5||$value['accountType']==6||$value['accountType']==9||$value['accountType']==10){
-
- $list[$key]['data']=$accountBook->getAccountBookByAid($value['dataID']);
- }elseif($value['accountType']==7||$value['accountType']==11){
-
- $ir=$invoiceReceivables->getInvoiceReceivablesByIrid($value['dataID']);
- $idetail=$invoice->getInvoiceByIid ( $ir['iid'] );
- //$ir['settlementType']=0;
- if(!empty($idetail)){
- $ir['settlementType']=$idetail['settlementType'];
- }
-
- $list[$key]['data']=$ir;//$invoiceReceivables->getInvoiceReceivablesByIrid($value['dataID']);
- }elseif($value['accountType']==8){
- $list[$key]['data']= $invoice->getInvoiceByIid ( $value['dataID'] );
-
- }elseif($value['accountType']==1||$value['accountType']==2||$value['accountType']==3||$value['accountType']==4||$value['accountType']==12){
- $list[$key]['data']=$receipt->getReceiptByRid($value['dataID']);
- }
-
- }
- //print_r($list);
- return $list;
- }
-
- /**
- */
- function getAccountBookByLimit($limit = 3) {
- $sql = 'select *
- from ' . $this->_table . '
- ORDER BY aid desc limit ' . $limit;
- $query = Doo::db ()->query ( $sql );
- $list = $query->fetchAll ();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- foreach ( $list as $key => $value ) {
- $list [$key] ['aidKey'] = $XDeode->encode ( $value ['aid'] );
- }
-
- return $list;
- }
- /**
- *
- * @param number $limit
- * @param string $con
- * @param string $desc
- * @return boolean
- */
- function getAccountBookBySql($limit = 0, $con = "", $desc = 'desc') {
-
- // $listCount = $this->count ( array (
- // 'where' => $con,
- // 'asArray' => TRUE
- // ) );
- $list = $this->find ( array (
- 'where' => '1 ' . $con,
- 'limit' => $limit,
- $desc => 'aid',
- 'asArray' => TRUE
- ) ); // echo $con;
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- foreach ( $list as $key => $value ) {
- // $list [$key] ['count'] = $listCount;
- $list [$key] ['aidKey'] = $XDeode->encode ( $value ['aid'] );
- }
-
- return $list;
- }
-
- function _getAccountBankEN($receivablesBank){
- $accountBank = '';
- if ($receivablesBank == '纵横广发') {
- $accountBank = 'CGBDeposit';
- } elseif ($receivablesBank == '纵横工行') {
- $accountBank = 'ICBCDeposit';
- } elseif ($receivablesBank == '华润银行') {
- $accountBank = 'HUADeposit';
- } elseif ($receivablesBank == '个人广发') {
- $accountBank = 'PersonalDeposit';
- }
- return $accountBank;
- }
-
- /**
- *
- * @param number $expensesType
- * @param number $accountType
- * @param number $dataID
- * @param string $select
- * @return unknown|string[]
- */
- function getAccountBookByAid($expensesType=1,$accountType=1,$dataID = 0, $select = "") {
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- if (! is_numeric ( $dataID ))
- $rid=$XDeode->decode( $dataID );
-
-
- $condition = array (
- 'where' => "dataID=" . $dataID.' and expensesType='.$expensesType.' and accountType='.$accountType,
- 'asArray' => TRUE
- );
- if (! empty ( $select ))
- $condition += array (
- 'select' => $select
- );
-
- $Detail = array ();
- if (is_numeric ( $dataID ) && ! empty ( $dataID ))
- $Detail = $this->getOne ( $condition );
-
- if (empty ( $Detail ))
- return $Detail;
-
- $Detail ['widKey'] = $XDeode->encode ( $Detail ['wid'] );
-
-
- return $Detail;
- }
-
-
-
-
- function getReportData(){
- $list = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType,depositMethod,operatingBankType',
- 'where' => " dailyType =3 and operatingBankType=2 and (accountType =5 or accountType =6) ",
- 'groupby' => 'accountBank',
- 'asArray' => TRUE
- ) );
- return $list;
- }
-
- //日常收支改变后的金额汇总
- function getBankSavingsStatistics(){
- $list = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType,depositMethod,operatingBankType',
- 'where' => " dailyType =3 and operatingBankType=2 and (accountType =5 or accountType =6) ",
- 'groupby' => 'accountBank',
- 'asArray' => TRUE
- ) );
- return $list;
- }
- /**
- * 理财部分的面板总计
- *
- * @return void
- */
- function getFinancesStatistics(){
- //理财-理财账号
- $list['financesAccount'] = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType,depositMethod,operatingBankType',
- 'where' => " dailyType =2 and operatingBankType=1 and (accountType =5 or accountType =6) ",
- 'groupby' => 'accountBank,depositMethod',
- 'asArray' => TRUE
- ) );
- //理财-公司账号
- $list['companyAccount'] = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType,depositMethod,operatingBankType',
- 'where' => " dailyType =2 and operatingBankType=2 and (accountType =5 or accountType =6) ",
- 'groupby' => 'accountBank',
- 'asArray' => TRUE
- ) );
- return $list;
- }
- /**
- * 统计存款部分
- */
- function getWasteBookStatisticsByIncome(){
- //and dailyIncomeType!=7
- $list['incomeStatistics'] = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyIncomeType',
- 'where' => " expensesType=1 and dailyType=0 and (accountType =6 or accountType =7 or accountType=8 or accountType =1 or accountType =2 or accountType=3 or accountType=4 or accountType=12 ) ",
- 'groupby' => 'accountBank',
- 'asArray' => TRUE
- ) );
-
- $list['expenditureStatistics'] = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType',
- 'where' => " expensesType=2 and dailyType=0 and (accountType =1 or accountType =2 or accountType=3 or accountType=4 or accountType=5 or accountType=11 or accountType=12) ",
- 'groupby' => 'accountBank',
- 'asArray' => TRUE
- ) );
- //活期
- $list['currentStatistics'] = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType',
- 'where' => " accountType =10 ",
- 'groupby' => 'accountBank',
- 'asArray' => TRUE
- ) );
- //固期
- $list['fixedStatistics'] = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,expensesType,accountType,accountBank,dailyExpenditureType',
- 'where' => " accountType =9 ",
- 'groupby' => 'accountBank',
- 'asArray' => TRUE
- ) );
- //月份总计
- $list['incomeReport'] = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,sum(accountPriceShow) as accountPriceShow,date_format(inputDate,"%Y-%m") as inputDate,expensesType',
- 'where' => " YEAR(inputDate)= YEAR( NOW( ) ) and expensesType=1",
- 'groupby' => 'date_format(inputDate,"%Y-%m"),expensesType',
- 'asArray' => TRUE
- ) );
- $list['expenditureReport'] = $this->find ( array (
- 'select' => 'sum(accountPrice) as accountPrice,sum(accountPriceShow) as accountPriceShow,date_format(inputDate,"%Y-%m") as inputDate,expensesType',
- 'where' => " YEAR(inputDate)= YEAR( NOW( ) ) and expensesType=2",
- 'groupby' => 'date_format(inputDate,"%Y-%m"),expensesType',
- 'asArray' => TRUE
- ) );
-
- //print_r($list);
-
- // //合计
- // $list['total'] = $this->find ( array (
- // 'select' => 'sum(accountPrice) as accountPrice',
- // //'where' => " accountType =9 ",
- // //'groupby' => 'accountBank',
- // 'asArray' => TRUE
- // ) );
- return $list;
- }
-
- /**
- * 插入数据
- * @param array $item
- * @return number
- */
- function setAccountBookStatistics($item=array()){
- $lid = 0;
- if (is_array ( $item ) && ! empty ( $item )) {
- foreach ( $item as $key => $value ) {
- $this->$key = $value;
- }
- $lid = $this->insert ();
- }
- return $lid;
- }
-
- function getWateBookByAD($accountType='',$dataID=''){
- $detail=$this->getOne(array (
- 'where' => "accountType=".$accountType.' and dataID='.$dataID,
- 'asArray' => TRUE
- ));
-
- return $detail;
- }
- }
- ?>
|