incomeExpenses_service.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <?php
  2. class incomeExpenses_service {
  3. private $accountBook;
  4. private $XDeode;
  5. function __construct() {
  6. Doo::loadClass ( 'XDeode' );
  7. $this->XDeode = new XDeode ( 9 );
  8. $this->XDeode5 = new XDeode ( 5 );
  9. Doo::loadModel ( 'cld/accountBook_cld' );
  10. $this->accountBook = new accountBook_cld ();
  11. }
  12. // 日常支出汇总
  13. public function GetExpensesCollect($parameter = array()) {
  14. $data = $this->accountBook->GetExpensesType ( $parameter );
  15. $list = array ();
  16. // 初始化日
  17. if (! empty ( $parameter ['month'] )) {
  18. $days = cal_days_in_month(CAL_GREGORIAN, $parameter['month'], $parameter['year']);
  19. for($i = 1; $i <= $days; $i ++) {
  20. $item = array (
  21. "month" => str_pad ( $i, 2, "0", STR_PAD_LEFT ),
  22. "bankCharges" => 0,
  23. "telephoneRate" => 0,
  24. // 缴税
  25. "addedTax" => 0,
  26. "surcharges" => 0,
  27. "corporateIncomeTax" => 0,
  28. "socialSecurity" => 0,
  29. "unionFees" => 0,
  30. "personalIncomeTax" => 0,
  31. "stampDuty" => 0,
  32. "payTaxesSubtotal" => 0,
  33. "bond" => 0,
  34. "wenku" => 0,
  35. "other" => 0,
  36. "subtotal" => 0
  37. );
  38. array_push ( $list, $item );
  39. }
  40. } else {
  41. // 初始化月份
  42. for($i = 1; $i <= 12; $i ++) {
  43. $item = array (
  44. "month" => str_pad ( $i, 2, "0", STR_PAD_LEFT ),
  45. "bankCharges" => 0,
  46. "telephoneRate" => 0,
  47. // 缴税
  48. "addedTax" => 0,
  49. "surcharges" => 0,
  50. "corporateIncomeTax" => 0,
  51. "socialSecurity" => 0,
  52. "unionFees" => 0,
  53. "personalIncomeTax" => 0,
  54. "stampDuty" => 0,
  55. "payTaxesSubtotal" => 0,
  56. "bond" => 0,
  57. "wenku" => 0,
  58. "other" => 0,
  59. "subtotal" => 0
  60. );
  61. array_push ( $list, $item );
  62. }
  63. }
  64. foreach ( $list as $k => $v ) {
  65. foreach ( $data as $key => $value ) {
  66. if (! empty ( $parameter ['month'] )) {
  67. $month = date ( "d", strtotime ( $value ['expenditureDate'] ) );
  68. }else{
  69. $month = date ( "m", strtotime ( $value ['expenditureDate'] ) );
  70. }
  71. if ($v ["month"] == $month) {
  72. // 银行手续费
  73. if ($value ['expenditureType'] == 1) {
  74. $list [$k] ['bankCharges'] = bcadd ( $list [$k] ['bankCharges'], $value ['expenditurePrice'], 2 );
  75. }
  76. // 电话费
  77. if ($value ['expenditureType'] == 2) {
  78. $list [$k] ['telephoneRate'] = bcadd ( $list [$k] ['telephoneRate'], $value ['expenditurePrice'], 2 );
  79. }
  80. // 缴税
  81. if ($value ['expenditureType'] == 3) {
  82. if ($value ['expenditureMsg'] == '增值税') {
  83. $list [$k] ['addedTax'] = bcadd ( $list [$k] ['addedTax'], $value ['expenditurePrice'], 2 );
  84. } elseif ($value ['expenditureMsg'] == '税金附加') {
  85. $list [$k] ['surcharges'] = bcadd ( $list [$k] ['surcharges'], $value ['expenditurePrice'], 2 );
  86. } elseif ($value ['expenditureMsg'] == '企业所得税') {
  87. $list [$k] ['corporateIncomeTax'] = bcadd ( $list [$k] ['corporateIncomeTax'], $value ['expenditurePrice'], 2 );
  88. } elseif ($value ['expenditureMsg'] == '工会费') {
  89. $list [$k] ['socialSecurity'] = bcadd ( $list [$k] ['socialSecurity'], $value ['expenditurePrice'], 2 );
  90. }elseif ($value ['expenditureMsg'] == '社保') {
  91. $list [$k] ['unionFees'] = bcadd ( $list [$k] ['unionFees'], $value ['expenditurePrice'], 2 );
  92. }elseif ($value ['expenditureMsg'] == '个税') {
  93. $list [$k] ['personalIncomeTax'] = bcadd ( $list [$k] ['personalIncomeTax'], $value ['expenditurePrice'], 2 );
  94. }elseif ($value ['expenditureMsg'] == '印花税') {
  95. $list [$k] ['stampDuty'] = bcadd ( $list [$k] ['stampDuty'], $value ['expenditurePrice'], 2 );
  96. }
  97. }
  98. // 保证金
  99. if ($value ['expenditureType'] == 5) {
  100. $list [$k] ['bond'] = bcadd ( $list [$k] ['bond'], $value ['expenditurePrice'], 2 );
  101. }
  102. // 纵横文库提现
  103. if ($value ['expenditureType'] == 13) {
  104. $list [$k] ['wenku'] = bcadd ( $list [$k] ['wenku'], $value ['expenditurePrice'], 2 );
  105. }
  106. // 其他
  107. if ($value ['expenditureType'] == 14) {
  108. $list [$k] ['other'] = bcadd ( $list [$k] ['other'], $value ['expenditurePrice'], 2 );
  109. }
  110. }
  111. }
  112. $list [$k] ['payTaxesSubtotal'] = bcadd ( $list [$k] ['addedTax'] + $list [$k] ['surcharges'] + $list [$k] ['corporateIncomeTax']
  113. , $list [$k] ['socialSecurity']+$list [$k] ['unionFees']+$list [$k] ['personalIncomeTax']+$list [$k] ['stampDuty'], 2 );
  114. $list [$k] ['subtotal'] = bcadd ( $list [$k] ['payTaxesSubtotal'] + $list [$k] ['bankCharges'] + $list [$k] ['telephoneRate'], $list [$k] ['bond'] + $list [$k] ['wenku'] + $list [$k] ['other'] , 2 );
  115. }
  116. return $list;
  117. }
  118. // 日常收入汇总
  119. public function GetIncomeCollect($parameter = array()) {
  120. $data = $this->accountBook->GetExpensesType ( $parameter );
  121. $list = array ();
  122. // 初始化日
  123. if (! empty ( $parameter ['month'] )) {
  124. $days = cal_days_in_month(CAL_GREGORIAN, $parameter['month'], $parameter['year']);
  125. for($i = 1; $i <= $days; $i ++) {
  126. $item = array (
  127. "month" => str_pad ( $i, 2, "0", STR_PAD_LEFT ),
  128. // 利息收入
  129. "bankDepositPrice" => 0,
  130. "currentFinancPrice" => 0,
  131. "fixedFinancPrice" => 0,
  132. "personalLoanPrice" => 0,
  133. "interestSubtotalPrice" => 0,
  134. // 补贴收入
  135. "socialSecurity" => 0,
  136. "finance" => 0,
  137. "subsidySubtotal" => 0,
  138. // 纵横知道
  139. "zongheng" => 0,
  140. // 借款收回
  141. "reserveFund" => 0,
  142. "privateBorrow" => 0,
  143. "loanSubtotal" => 0,
  144. // 退汇
  145. "returnRemittance" => 0,
  146. "bond" => 0,
  147. "other" => 0,
  148. "subtotal" => 0
  149. );
  150. array_push ( $list, $item );
  151. }
  152. } else {
  153. // 初始化月份
  154. for($i = 1; $i <= 12; $i ++) {
  155. $item = array (
  156. "month" => str_pad ( $i, 2, "0", STR_PAD_LEFT ),
  157. // 利息收入
  158. "bankDepositPrice" => 0,
  159. "currentFinancPrice" => 0,
  160. "fixedFinancPrice" => 0,
  161. "personalLoanPrice" => 0,
  162. "interestSubtotalPrice" => 0,
  163. // 补贴收入
  164. "socialSecurity" => 0,
  165. "finance" => 0,
  166. "subsidySubtotal" => 0,
  167. // 纵横知道
  168. "zongheng" => 0,
  169. // 借款收回
  170. "reserveFund" => 0,
  171. "privateBorrow" => 0,
  172. "loanSubtotal" => 0,
  173. // 退汇
  174. "returnRemittance" => 0,
  175. "bond" => 0,
  176. "other" => 0,
  177. "subtotal" => 0
  178. );
  179. array_push ( $list, $item );
  180. }
  181. }
  182. foreach ( $list as $k => $v ) {
  183. foreach ( $data as $key => $value ) {
  184. if (! empty ( $parameter ['month'] )) {
  185. $month = date ( "d", strtotime ( $value ['receivedDate'] ) );
  186. }else{
  187. $month = date ( "m", strtotime ( $value ['receivedDate'] ) );
  188. }
  189. if ($v ["month"] == $month) {
  190. // 利息收入
  191. if ($value ['accountType'] == 1) {
  192. if ($value ['accountMsg'] == '银行存款') {
  193. $list [$k] ['bankDepositPrice'] = bcadd ( $list [$k] ['bankDepositPrice'], $value ['receivedPrice'], 2 );
  194. } elseif ($value ['accountMsg'] == '活期理财收益') {
  195. $list [$k] ['currentFinancPrice'] = bcadd ( $list [$k] ['currentFinancPrice'], $value ['receivedPrice'], 2 );
  196. } elseif ($value ['accountMsg'] == '固定理财收益') {
  197. $list [$k] ['fixedFinancPrice'] = bcadd ( $list [$k] ['fixedFinancPrice'], $value ['receivedPrice'], 2 );
  198. } elseif ($value ['accountMsg'] == '个人借款') {
  199. $list [$k] ['personalLoanPrice'] = bcadd ( $list [$k] ['personalLoanPrice'], $value ['receivedPrice'], 2 );
  200. }
  201. }
  202. // 补贴收入
  203. if ($value ['accountType'] == 2) {
  204. if ($value ['accountMsg'] == '社保') {
  205. $list [$k] ['socialSecurity'] = bcadd ( $list [$k] ['socialSecurity'], $value ['receivedPrice'], 2 );
  206. } elseif ($value ['accountMsg'] == '财政') {
  207. $list [$k] ['finance'] = bcadd ( $list [$k] ['finance'], $value ['receivedPrice'], 2 );
  208. }
  209. }
  210. // 纵横知道
  211. if ($value ['accountType'] == 3) {
  212. $list [$k] ['zongheng'] = bcadd ( $list [$k] ['zongheng'], $value ['receivedPrice'], 2 );
  213. }
  214. // 借款收回
  215. if ($value ['accountType'] == 4) {
  216. if ($value ['accountMsg'] == '备用金') {
  217. $list [$k] ['reserveFund'] = bcadd ( $list [$k] ['reserveFund'], $value ['receivedPrice'], 2 );
  218. } elseif ($value ['accountMsg'] == '私人借款') {
  219. $list [$k] ['privateBorrow'] = bcadd ( $list [$k] ['privateBorrowing'], $value ['receivedPrice'], 2 );
  220. }
  221. }
  222. // 退汇
  223. if ($value ['accountType'] == 5) {
  224. $list [$k] ['returnRemittance'] = bcadd ( $list [$k] ['returnRemittance'], $value ['receivedPrice'], 2 );
  225. }
  226. // 保证金
  227. if ($value ['accountType'] == 8) {
  228. $list [$k] ['bond'] = bcadd ( $list [$k] ['bond'], $value ['receivedPrice'], 2 );
  229. }
  230. // 其他
  231. if ($value ['accountType'] == 6) {
  232. $list [$k] ['other'] = bcadd ( $list [$k] ['other'], $value ['receivedPrice'], 2 );
  233. }
  234. }
  235. }
  236. $list [$k] ['interestSubtotalPrice'] = bcadd ( $list [$k] ['bankDepositPrice'] + $list [$k] ['currentFinancPrice'] + $list [$k] ['fixedFinancPrice'], $list [$k] ['personalLoanPrice'], 2 );
  237. $list [$k] ['subsidySubtotal'] = bcadd ( $list [$k] ['socialSecurity'], $list [$k] ['finance'], 2 );
  238. $list [$k] ['loanSubtotal'] = bcadd ( $list [$k] ['reserveFund'], $list [$k] ['privateBorrowing'], 2 );
  239. $list [$k] ['subtotal'] = bcadd ( $list [$k] ['interestSubtotalPrice'] + $list [$k] ['subsidySubtotal'] + $list [$k] ['loanSubtotal'], $list [$k] ['zongheng'] + $list [$k] ['returnRemittance'] + $list [$k] ['bond'] + $list [$k] ['other'], 2 );
  240. }
  241. return $list;
  242. }
  243. // 费用分页
  244. public function GetIncomeExpensesPage($data = array()) {
  245. // if (!empty($data['categoryId'])){
  246. // $data['categoryId']=$this->XDeode->decode($data['categoryId']);
  247. // }
  248. // if (!empty($data['staffId'])){
  249. // $data['staffId']=$this->XDeode->decode($data['staffId']);
  250. // }
  251. if (empty ( $data ['year'] )) {
  252. $data ['year'] = date ( "Y" );
  253. }
  254. if (! is_numeric ( $data ['pSize'] )) {
  255. $data ['pSize'] = 20;
  256. }
  257. if (! is_numeric ( $data ['cPage'] )) {
  258. $data ['cPage'] = 0;
  259. } else {
  260. $data ['cPage'] = ($data ['cPage'] - 1) * $data ['pSize'];
  261. }
  262. $data = $this->accountBook->GetPage ( $data );
  263. foreach ( $data ['list'] as $key => $value ) {
  264. if ($value ['receivedBank'] == '华润银行') {
  265. $data ['list'] [$key] ['receivedBank'] = '广发纵横知道';
  266. }
  267. if ($value ['expensesType'] == 1) {
  268. $data ['list'] [$key] ['expensesTypeShow'] = "收入";
  269. if ($value ['accountType'] == 1) {
  270. $data ['list'] [$key] ['typeShow'] = "利息收入";
  271. } elseif ($value ['accountType'] == 2) {
  272. $data ['list'] [$key] ['typeShow'] = "补贴收入";
  273. } elseif ($value ['accountType'] == 3) {
  274. $data ['list'] [$key] ['typeShow'] = "纵横知道";
  275. } elseif ($value ['accountType'] == 4) {
  276. $data ['list'] [$key] ['typeShow'] = "借款收回";
  277. } elseif ($value ['accountType'] == 5) {
  278. $data ['list'] [$key] ['typeShow'] = "退汇";
  279. } elseif ($value ['accountType'] == 6) {
  280. $data ['list'] [$key] ['typeShow'] = "其他";
  281. } elseif ($value ['accountType'] == 7) {
  282. $data ['list'] [$key] ['typeShow'] = "广发理财";
  283. } elseif ($value ['accountType'] == 8) {
  284. $data ['list'] [$key] ['typeShow'] = "工行理财";
  285. } elseif ($value ['accountType'] == 9) {
  286. $data ['list'] [$key] ['typeShow'] = "保证金";
  287. } elseif ($value ['accountType'] == 10) {
  288. $data ['list'] [$key] ['typeShow'] = "理财收入";
  289. } elseif ($value ['accountType'] == 11) {
  290. $data ['list'] [$key] ['typeShow'] = "广发存款";
  291. } elseif ($value ['accountType'] == 12) {
  292. $data ['list'] [$key] ['typeShow'] = "工行存款";
  293. } elseif ($value ['accountType'] == 13) {
  294. $data ['list'] [$key] ['typeShow'] = "理财";
  295. if ($value ['operatingBankType'] == 1) {
  296. $data ['list'] [$key] ['typeShow'] .= "(理财账号)";
  297. } elseif ($value ['operatingBankType'] == 2) {
  298. $data ['list'] [$key] ['typeShow'] .= "(公司账号)";
  299. }
  300. } elseif ($value ['accountType'] == 14) {
  301. $data ['list'] [$key] ['typeShow'] = "存款";
  302. }
  303. if (! empty ( $value ['accountMsg'] )) {
  304. $data ['list'] [$key] ['typeShow'] .= ' / '.$value ['accountMsg'];
  305. }
  306. $data ['list'] [$key] ['priceShow'] = $value ['receivedPrice'];
  307. $data ['list'] [$key] ['dateShow'] = $value ['receivedDate'];
  308. $data ['list'] [$key] ['bankShow'] = $value ['receivedBank'];
  309. if ($value ['operatingBankType'] == 1) {
  310. $data ['list'] [$key] ['bankShow'] .= $value ['depositMethod'];
  311. }
  312. } elseif ($value ['expensesType'] == 2) {
  313. $data ['list'] [$key] ['expensesTypeShow'] = "支出";
  314. $data ['list'] [$key] ['dateShow'] = $value ['expenditureDate'];
  315. $data ['list'] [$key] ['bankShow'] = $value ['expenditureBank'];
  316. if ($value ['operatingBankType'] == 1) {
  317. $data ['list'] [$key] ['bankShow'] .= ' / '.$value ['depositMethod'];
  318. }
  319. if ($value ['expensesType'] == 1) {
  320. $data ['list'] [$key] ['typeShow'] = "银行手续费";
  321. } elseif ($value ['expensesType'] == 2) {
  322. $data ['list'] [$key] ['typeShow'] = "总部电话费";
  323. } elseif ($value ['expensesType'] == 3) {
  324. $data ['list'] [$key] ['typeShow'] = "缴税";
  325. } elseif ($value ['expensesType'] == 4) {
  326. $data ['list'] [$key] ['typeShow'] = "广发理财";
  327. } elseif ($value ['expensesType'] == 5) {
  328. $data ['list'] [$key] ['typeShow'] = "保证金";
  329. } elseif ($value ['expensesType'] == 6) {
  330. $data ['list'] [$key] ['typeShow'] = "工行理财";
  331. } elseif ($value ['expensesType'] == 7) {
  332. $data ['list'] [$key] ['typeShow'] = "理财支出";
  333. } elseif ($value ['expensesType'] == 8) {
  334. $data ['list'] [$key] ['typeShow'] = "广发存款";
  335. } elseif ($value ['expensesType'] == 9) {
  336. $data ['list'] [$key] ['typeShow'] = "工行存款";
  337. } elseif ($value ['expensesType'] == 10) {
  338. $data ['list'] [$key] ['typeShow'] = "工资";
  339. } elseif ($value ['expensesType'] == 11) {
  340. $data ['list'] [$key] ['typeShow'] = "理财";
  341. if ($value ['operatingBankType'] == 1) {
  342. $data ['list'] [$key] ['typeShow'] .= "(理财账号)";
  343. } elseif ($value ['operatingBankType'] == 2) {
  344. $data ['list'] [$key] ['typeShow'] .= "(公司账号)";
  345. }
  346. } elseif ($value ['expensesType'] == 12) {
  347. $data ['list'] [$key] ['typeShow'] = "存款";
  348. } elseif ($value ['expensesType'] == 13) {
  349. $data ['list'] [$key] ['typeShow'] = "纵横文库提现";
  350. } elseif ($value ['expensesType'] == 14) {
  351. $data ['list'] [$key] ['typeShow'] = "其他";
  352. }
  353. if (! empty ( $value ['expenditureMsg'] )) {
  354. $data ['list'] [$key] ['typeShow'] .=' / '. $value ['expenditureMsg'];
  355. }
  356. $data ['list'] [$key] ['priceShow'] = $value ['expenditurePrice'];
  357. }
  358. }
  359. return $data;
  360. // // //获得办事处信息
  361. // // $office=$this->category->GetAll();
  362. // // //获得员工信息
  363. // // $staffList=$this->staff->find(array('asArray' => TRUE));
  364. // foreach ($data['list'] as $key=>$value){
  365. // $data['list'][$key]['ridOld']=$value['rid'];
  366. // $data['list'][$key]['rid']=$this->XDeode->encode($value['rid']);
  367. // $data['list'][$key]['cid']=$this->XDeode->encode($value['cid']);
  368. // $data['list'][$key]['staff']=$this->XDeode->encode($value['staff']);
  369. // $data['list'][$key]['categoryValue']="";
  370. // $data['list'][$key]['statusValue']=$this->feeStatusValue[$value['status']];
  371. // foreach ($office as $k=>$v){
  372. // if($v['cid']==$data['list'][$key]['cid']){
  373. // $data['list'][$key]['categoryValue']=$v['title'];
  374. // }
  375. // }
  376. // $data['list'][$key]['staffName']="";
  377. // foreach ($staffList as $k=>$v){
  378. // if($v['sid']==$value['staff']){
  379. // $data['list'][$key]['staffName']=$v['username'];
  380. // }
  381. // }
  382. // $data['list'][$key]['Rtype']=$this->feeTypeValue[$value['Rtype']];
  383. // if($this->getFeeLoanType($value)){
  384. // $data['list'][$key]['Rtype'].="报销单";
  385. // }
  386. // if($value['pastDate']=="0000-00-00"){
  387. // $data['list'][$key]['pastDate']="";
  388. // }
  389. // if($value['version']==1){
  390. // $data['list'][$key]['explanation']=$this->getReceiptVerson1Explanation($value);
  391. // }
  392. // }
  393. // return $data;
  394. }
  395. }
  396. ?>