comm_cld.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. /**
  3. * 获取get或者POST值
  4. *
  5. * @param string $name 属性名称
  6. * @return fixed 值
  7. */
  8. function get_args($name) {
  9. if (isset ( $_GET [$name] )) {
  10. return $_GET [$name];
  11. } elseif (isset ( $_POST [$name] )) {
  12. return $_POST [$name];
  13. } else
  14. return '';
  15. }
  16. function GetDecryptId($id){
  17. Doo::loadClass ( 'XDeode' );
  18. $XDeode = new XDeode ( 9 );
  19. $id=$XDeode->decode($id);
  20. if (!is_numeric($id)){
  21. die ( 'illegal request-参数解析错误' );
  22. }
  23. return $id;
  24. }
  25. function makeReceiptDataVersion1($receiptList){
  26. //办事处费用
  27. $receiptList[0]['officeJson']=json_decode($receiptList[0]['officeJson'],true);
  28. if (!empty($receiptList[0]['officeJson'])){
  29. $receiptList[0]['officeExplain']="<pre>".$receiptList[0]['officeJson']['officeExplain'][0]['officeExplain']."</pre>";
  30. $total=0;
  31. foreach ($receiptList[0]['officeJson']['daily'] as $value){
  32. $total=bcadd($total,$value['price'],2);
  33. }
  34. $receiptList[0]['dailyTotal']=$total;
  35. $total=0;
  36. foreach ($receiptList[0]['officeJson']['other'] as $value){
  37. $total=bcadd($total,$value['price'],2);
  38. }
  39. $receiptList[0]['otherTotal']=$total;
  40. $receiptList[0]['officeTotal']=bcadd($receiptList[0]['otherTotal'],$receiptList[0]['dailyTotal'],2);
  41. }
  42. //差旅费用
  43. $traveJson=json_decode($receiptList[0]['traveJson'],true);
  44. $receiptList[0]['traveJson']=$traveJson;
  45. if (!empty($receiptList[0]['traveJson'])){
  46. $receiptList[0]['traveExplain']="<pre>".$receiptList[0]['traveJson']['traveExplain'][0]['traveExplain']."</pre>";
  47. $total=0;
  48. foreach ($traveJson['traveList'] as $key=>$value){
  49. $receiptList[0]['traveJson']['traveList'][$key]['index']=$key+1;
  50. $detailCity='';
  51. $tripTotal=0;
  52. $tripItem=array();
  53. //1.行程list
  54. foreach ($value['tripList'] as $k=>$v){
  55. //2.组合各个城市
  56. $detailCity.=$v['city'].' ';
  57. //3.组合列详情
  58. foreach ($v['tripItem'] as $tk=>$tv){
  59. if (!isset($tripItem[$tv['name']])){
  60. $tripItem[$tv['name']]=0;
  61. }
  62. $tripItem[$tv['name']]=bcadd($tripItem[$tv['name']],$tv['price'],2);
  63. //3.行程金额小计
  64. $tripTotal=bcadd($tripTotal,$tv['price'],2);
  65. }
  66. $count=count($value['tripList'])-1;
  67. if($count>$k){
  68. $index=$k+1;
  69. $receiptList[0]['traveJson']['traveList'][$key]['tripList'][$k]['goCome']=$v['city'].'-'.$value['tripList'][$index]['city'];
  70. }
  71. $total=bcadd($total,$v['subtotal'],2);
  72. }
  73. $receiptList[0]['traveJson']['traveList'][$key]['detailCity']=$detailCity;
  74. $receiptList[0]['traveJson']['traveList'][$key]['detailTrip']=$tripItem;
  75. $receiptList[0]['traveJson']['traveList'][$key]['tripTotal']=$tripTotal;
  76. }
  77. $receiptList[0]['traveTotal']=$total;
  78. //print_r($receiptList[0]['traveJson']);
  79. }
  80. //内训费用
  81. $receiptList[0]['trainJson']=json_decode($receiptList[0]['trainJson'],true);
  82. if (!empty($receiptList[0]['trainJson'])){
  83. $receiptList[0]['trainExplain']="<pre>".$receiptList[0]['trainJson']['trainExplain'][0]['trainExplain']."</pre>";
  84. $total=0;
  85. foreach ($receiptList[0]['trainJson']['train'] as $value){
  86. $total=bcadd($total,$value['price'],2);
  87. }
  88. $receiptList[0]['trainTotal']=$total;
  89. }
  90. return $receiptList;
  91. }
  92. function num_to_rmb($num) {
  93. $c1 = "零壹贰叁肆伍陆柒捌玖";
  94. $c2 = "分角元拾佰仟万拾佰仟亿";
  95. // 精确到分后面就不要了,所以只留两个小数位
  96. $num = round ( $num, 2 );
  97. // 将数字转化为整数
  98. $num = $num * 100;
  99. if (strlen ( $num ) > 10) {
  100. return "金额太大,请检查";
  101. }
  102. $i = 0;
  103. $c = "";
  104. while ( 1 ) {
  105. if ($i == 0) {
  106. // 获取最后一位数字
  107. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  108. } else {
  109. $n = $num % 10;
  110. }
  111. // 每次将最后一位数字转化为中文
  112. $p1 = substr ( $c1, 3 * $n, 3 );
  113. $p2 = substr ( $c2, 3 * $i, 3 );
  114. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  115. $c = $p1 . $p2 . $c;
  116. } else {
  117. $c = $p1 . $c;
  118. }
  119. $i = $i + 1;
  120. // 去掉数字最后一位了
  121. $num = $num / 10;
  122. // echo $num.'</br>';
  123. $num = ( int ) $num;
  124. // $num =floor($num);
  125. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  126. // echo $num.'</br>';
  127. // 结束循环
  128. if ($num == 0) {
  129. break;
  130. }
  131. }
  132. // echo $c.'</br>';
  133. $j = 0;
  134. $slen = strlen ( $c );
  135. while ( $j < $slen ) {
  136. // utf8一个汉字相当3个字符
  137. $m = substr ( $c, $j, 6 );
  138. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  139. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  140. $left = substr ( $c, 0, $j );
  141. $right = substr ( $c, $j + 3 );
  142. $c = $left . $right;
  143. $j = $j - 3;
  144. $slen = $slen - 3;
  145. }
  146. $j = $j + 3;
  147. }
  148. // 这个是为了去掉类似23.0中最后一个“零”字
  149. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  150. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  151. }
  152. // 将处理的汉字加上“整”
  153. if (empty ( $c )) {
  154. return "零元整";
  155. } else {
  156. return $c . "整";
  157. }
  158. }
  159. ?>