receipt.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <?php
  2. Doo::loadCore ( 'db/DooModel' );
  3. class receipt extends DooModel {
  4. public $rid;
  5. public $accountItem;
  6. public $loanItem;
  7. public $staff;
  8. public $sum;
  9. public $date;
  10. public $pastDate;
  11. public $executeDate;
  12. public $loanDate;
  13. public $cid;
  14. public $status;
  15. public $Rtype;
  16. public $isBK;
  17. public $loanSum;
  18. public $loanRid;
  19. public $reviseDetail;
  20. public $revisePrice;
  21. public $receiptOrder;
  22. public $verify;
  23. public $verifyStaff;
  24. public $executeCopy;
  25. public $executeStaff;
  26. public $verifyBreakup;
  27. public $nowStaff;
  28. public $explanation;
  29. public $implementOpinions;
  30. public $notice;
  31. public $amount;
  32. public $remittanceName;
  33. public $bankName;
  34. public $bankNumber;
  35. public $coupletNumber;
  36. public $remittanceBankType;
  37. public $trainId;
  38. public $trainLoanRid;
  39. public $invoiceTrainId;
  40. public $paidStatus;
  41. public $statusTrain;
  42. public $receiptClass;
  43. public $itinerary;
  44. public $_table = 'CLD_receipt';
  45. public $_primarykey = 'rid';
  46. public $_fields = array (
  47. 'aid',
  48. 'accountItem',
  49. 'staff',
  50. 'sum',
  51. 'date',
  52. 'pastDate',
  53. 'cid',
  54. 'status',
  55. 'reviseDetail',
  56. 'revisePrice',
  57. 'verify',
  58. 'verifyStaff',
  59. 'nowStaff',
  60. 'receiptOrder',
  61. 'explanation',
  62. 'notice',
  63. 'Rtype',
  64. 'loanItem',
  65. 'loanRid',
  66. 'loanSum',
  67. 'implementOpinions',
  68. 'isBK',
  69. 'executeCopy',
  70. 'executeStaff',
  71. 'verifyBreakup',
  72. 'executeDate',
  73. 'amount',
  74. 'loanDate',
  75. 'remittanceName',
  76. 'bankName',
  77. 'bankNumber',
  78. 'coupletNumber',
  79. 'remittanceBankType',
  80. 'trainId',
  81. 'trainLoanRid',
  82. 'invoiceTrainId' ,
  83. 'paidStatus',
  84. 'statusTrain',
  85. 'receiptClass',
  86. 'itinerary',
  87. );
  88. /*
  89. $this->query($sql, array_merge( $opt['param'], $where_values));
  90. */
  91. /**
  92. * 获得培训班结算未收款
  93. */
  94. function getReceiptTrainByPaid($un=0,$limit=5,$cid=''){
  95. if (empty($cid)){
  96. return array();
  97. }
  98. $sql = "select b.* ,a.invoiceTrainId,a.rid,a.executeDate
  99. from " . $this->_table . " as a left JOIN CLD_receiptTraining as b on (a.trainId=b.rtid)
  100. where a.status not in (3,4,5) and a.Rtype=3 and a.trainId!=0 and invoiceTrainId!=0 and a.cid in (".$cid.") and paidStatus=".$un." limit ".$limit;
  101. $query = Doo::db ()->query ( $sql );
  102. $result = $query->fetchAll ();
  103. Doo::loadModel ( 'invoiceTraining' );
  104. $invoiceTraining = new invoiceTraining ();
  105. Doo::loadClass ( 'XDeode' );
  106. $XDeode = new XDeode ( 7 );
  107. Doo::loadModel ( 'RItem' );
  108. $RItem = new RItem ();
  109. Doo::loadModel ( 'RILecturer' );
  110. $RILecturer = new RILecturer ();
  111. Doo::loadModel ( 'accountItem' );
  112. $accountItem = new accountItem ();
  113. foreach ($result as $key=>$value){
  114. $result[$key]['ridKey']= $XDeode->encode ( $value ['rid'] );
  115. $result[$key]['iTrain']=$invoiceTraining->getInvoiceTrainingByItid ( $value ['invoiceTrainId'] );
  116. $result[$key]['iTrain']['receivablesAmount']=sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']-$result[$key]['iTrain']['invoiceArriveAmount']);
  117. $RItemList = $RItem->getRItemByRid ( $value ['rid'] );
  118. $RILecturerList = $RILecturer->getRILecturerByRid ( $value ['rid'] );
  119. // 支出项金额详情
  120. $expendList= $accountItem->getTrainingDetail ( $RItemList, $RILecturerList );
  121. $result[$key]['iTrain']['expendAmount']=sprintf ( "%.2f",$expendList['total']);
  122. $result[$key]['iTrain']['profit']= sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']-$expendList['total']);
  123. }
  124. return $result;
  125. }
  126. /**
  127. * 获得所有培训班结算
  128. */
  129. function getReceiptTrainByPaidAll($un='',$cid='',$dateSql='',$limit='0,18',$cidString="",$where=""){
  130. $psSql='';
  131. if(!empty($un)){
  132. $psSql=" and paidStatus=".$un." ";
  133. }
  134. $cidSql="";
  135. if(!empty($cid)){
  136. $cidSql=" and a.cid=".$cid." ";
  137. }elseif(!empty($cidString)){
  138. $cidSql=" and a.cid in (".$cidString.") ";
  139. }else{
  140. return array();
  141. }
  142. $sql = "select b.* ,a.invoiceTrainId,a.rid
  143. from " . $this->_table . " as a left JOIN CLD_receiptTraining as b on (a.trainId=b.rtid)
  144. ".$where.$psSql.$cidSql.$dateSql." limit ".$limit;
  145. $query = Doo::db ()->query ( $sql );
  146. $result = $query->fetchAll ();
  147. Doo::loadModel ( 'invoiceTraining' );
  148. $invoiceTraining = new invoiceTraining ();
  149. Doo::loadClass ( 'XDeode' );
  150. $XDeode = new XDeode ( 7 );
  151. Doo::loadModel ( 'RItem' );
  152. $RItem = new RItem ();
  153. Doo::loadModel ( 'RILecturer' );
  154. $RILecturer = new RILecturer ();
  155. Doo::loadModel ( 'accountItem' );
  156. $accountItem = new accountItem ();
  157. foreach ($result as $key=>$value){
  158. $result[$key]['ridKey']= $XDeode->encode ( $value ['rid'] );
  159. $result[$key]['iTrain']=$invoiceTraining->getInvoiceTrainingByItid ( $value ['invoiceTrainId'] );
  160. $result[$key]['iTrain']['receivablesAmount']=sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']-$result[$key]['iTrain']['invoiceArriveAmount']);
  161. $RItemList = $RItem->getRItemByRid ( $value ['rid'] );
  162. $RILecturerList = $RILecturer->getRILecturerByRid ( $value ['rid'] );
  163. // 支出项金额详情
  164. $expendList= $accountItem->getTrainingDetail ( $RItemList, $RILecturerList );
  165. $result[$key]['iTrain']['expendAmount']=sprintf ( "%.2f",$expendList['total']);
  166. $result[$key]['iTrain']['profit']= sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']-$expendList['total']);
  167. //利润
  168. $result[$key]['iTrain']['companyProfit']=sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']*0.4);
  169. $result[$key]['iTrain']['categoryProfit']=sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']*0.6);
  170. }
  171. return $result;
  172. }
  173. /**
  174. * 获得培训班结算的合计金额
  175. * @param string $itid 发票培训班ID
  176. */
  177. function getReceiptTrainSumByItid($sql=""){
  178. Doo::loadModel ( 'invoice' );
  179. $invoice = new invoice ();
  180. $query = Doo::db ()->query ( $sql );
  181. $result = $query->fetchAll ();
  182. //组合发票培训班ID
  183. $itidList = array ();$ridList=array();
  184. foreach ($result as $key=>$value){
  185. array_push ( $itidList, $value ['invoiceTrainId'] );
  186. array_push ( $ridList, $value ['rid'] );
  187. }
  188. $itidList = array_unique($itidList);
  189. $itidString=implode ( ',', $itidList );
  190. $ridList = array_unique($ridList);
  191. $ridString=implode ( ',', $ridList );
  192. //发票培训班ID-整合出开票金额合计-入账金额合计
  193. $invoiceList = $invoice->sumOfinvoiceTrain ( $itidString );//开票合计-开票收入
  194. $invoiceRecelvablesList = $invoice->sumOfInvoiceRecelvablesTrain ( $itidString );//入账合计-实际收入
  195. $invoiceTotalAmount=0;//开票金额合计
  196. $receivablesTotalAmount=0;//入账金额合计
  197. foreach ( $invoiceList as $k => $v ) {
  198. $invoiceTotalAmount+=$v ['invoicePrice'];
  199. }
  200. foreach ( $invoiceRecelvablesList as $i => $o ) {
  201. $receivablesTotalAmount+=$o ['receivablesPrice'];
  202. }
  203. //未收款
  204. $unReceivablesTotalAmount=sprintf ( "%.2f",$invoiceTotalAmount-$receivablesTotalAmount);
  205. //获得支出金额合计
  206. Doo::loadModel ( 'RItem' );
  207. $RItem = new RItem ();
  208. Doo::loadModel ( 'RILecturer' );
  209. $RILecturer = new RILecturer ();
  210. $RItemPrice=$RItem->getRItemPriceByRids($ridString);
  211. $RILecturerPrice=$RILecturer->getRILecturerPriceByRids($ridString);
  212. $payPrice=$RItemPrice+$RILecturerPrice;//支出金额合计
  213. $profit=$invoiceTotalAmount-$payPrice;
  214. return array('invoiceTotalAmount'=>sprintf ( "%.2f",$invoiceTotalAmount),
  215. 'payPrice'=>sprintf ( "%.2f",$payPrice),
  216. 'profit'=>sprintf ( "%.2f",$profit),
  217. 'unReceivablesTotalAmount'=>$unReceivablesTotalAmount,
  218. );
  219. }
  220. /**
  221. * @param string $sql
  222. */
  223. function initReceiptTrainRevenue($sql=""){
  224. Doo::loadModel ( 'invoice' );
  225. $invoice = new invoice ();
  226. $query = Doo::db ()->query ( $sql );
  227. $result = $query->fetchAll ();
  228. foreach ($result as $key=>$value){
  229. $invoiceList = $invoice->sumOfinvoiceTrain ( $value['invoiceTrainId'] );//开票合计-开票收入
  230. $invoiceRecelvablesList = $invoice->sumOfInvoiceRecelvablesTrain ( $value['invoiceTrainId'] );//入账合计-实际收入
  231. $invoiceTotalAmount=0;//开票金额合计
  232. $receivablesTotalAmount=0;//入账金额合计
  233. foreach ( $invoiceList as $k => $v ) {
  234. $invoiceTotalAmount+=$v ['invoicePrice'];
  235. }
  236. foreach ( $invoiceRecelvablesList as $i => $o ) {
  237. $receivablesTotalAmount+=$o ['receivablesPrice'];
  238. }
  239. //echo $invoiceTotalAmount.'-'.$receivablesTotalAmount.'</br>';
  240. if ($invoiceTotalAmount<=$receivablesTotalAmount){
  241. $itemData = array (
  242. 'rid' => $value['rid'],
  243. 'paidStatus' => 1,
  244. );
  245. $this->setReceiptByCondition($itemData);
  246. }
  247. }
  248. }
  249. /**
  250. * 获得培训班 年营收图表
  251. */
  252. function getReceiptTrainByYearChart($cid='',$year=''){
  253. if (empty($cid)){
  254. return array();
  255. }
  256. if(empty($year)){
  257. $year=date("Y");
  258. }
  259. $sql = "select GROUP_CONCAT(rid) as rid,GROUP_CONCAT(invoiceTrainId) as invoiceTrainId,date_format(date,\"%m\") as month
  260. from " . $this->_table . "
  261. where status not in (3,4,5) and Rtype=3 and trainId!=0 and invoiceTrainId!=0 and cid in (".$cid.") and paidStatus=1 and Year(date) =".$year."
  262. GROUP BY Month(date)";
  263. //
  264. $query = Doo::db ()->query ( $sql );
  265. $result = $query->fetchAll ();
  266. Doo::loadModel ( 'RItem' );
  267. $RItem = new RItem ();
  268. Doo::loadModel ( 'RILecturer' );
  269. $RILecturer = new RILecturer ();
  270. Doo::loadModel ( 'invoice' );
  271. $invoice = new invoice ();
  272. $MonthPriceList=array();
  273. foreach ($result as $key=>$value){
  274. //获得支出金额总和
  275. $RItemPrice=$RItem->getRItemPriceByRids($value['rid']);
  276. $RILecturerPrice=$RILecturer->getRILecturerPriceByRids($value['rid']);
  277. $RIprice=$RItemPrice+$RILecturerPrice;//支出金额合计
  278. //收款金额总和
  279. $ITprice=$invoice->getInvoicePriceByIids($value['invoiceTrainId']);
  280. $MonthPriceList[$value['month']]=array(
  281. 'RIprice'=>$RIprice,
  282. 'ITprice'=>$ITprice
  283. );
  284. }
  285. return $MonthPriceList;
  286. }
  287. function receiptByYear($dateCondition, $sid) {
  288. $sql = "select sum(sum) as sum from " . $this->_table . " where staff= '" . $sid . "' " . $dateCondition . " and status=2 ";
  289. // echo '<div style="display:none">'.$sql.'</div>';
  290. $query = Doo::db ()->query ( $sql );
  291. $result = $query->fetch ();
  292. return $result;
  293. }
  294. function getReceiptBySid($sid = '', $year = '', $month = '') {
  295. Doo::loadClass ( 'XDeode' );
  296. $XDeode = new XDeode ( 5 );
  297. if (empty ( $sid ))
  298. return array ();
  299. $sql = 'select a.*
  300. from ' . $this->_table . ' as a left join CLD_receiptDetail as b on b.rid=a.rid
  301. where b.staff =' . $sid . ' and Month(b.pastDate)=' . $month . ' and Year(b.pastDate)=' . $year . ' and b.status=1
  302. GROUP BY b.rid';
  303. $query = Doo::db ()->query ( $sql );
  304. $list = $query->fetchAll ();
  305. foreach ( $list as $key => $value ) {
  306. $list [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  307. }
  308. return $list;
  309. }
  310. function getReceiptByRid($rid = '') {
  311. Doo::loadClass ( 'XDeode' );
  312. $XDeode = new XDeode ( 5 );
  313. Doo::loadModel ( 'L_category' );
  314. $Lcategory = new L_category ();
  315. Doo::loadModel ( 'staff' );
  316. $staff = new staff ();
  317. if (! is_numeric ( $rid ))
  318. $rid = $XDeode->decode ( $rid );
  319. $rinfo = $this->getOne ( array (
  320. 'where' => 'rid=' . $rid,
  321. 'asArray' => true
  322. ) );
  323. $rinfo ['ridKey'] = $XDeode->encode ( $rinfo ['rid'] );
  324. //$rinfo ['trainLoanRidKey'] = $XDeode->encode ( $rinfo ['trainLoanRid'] );
  325. $XDeode = new XDeode ( 7 );
  326. $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  327. $rinfo ['category'] = $Lcategory->getCategoryById ( $rinfo ['cid'] );
  328. $rinfo ['staffDetail'] = $staff->getStaffBySid ( $rinfo ['staff'] );
  329. // $rinfo['sum']=number_format ($rinfo['sum'],2);
  330. return $rinfo;
  331. }
  332. function getReceiptInRid($rid = ''){
  333. /*
  334. if (! is_numeric ( $rid )){
  335. $rid = $XDeode->decode ( $rid );
  336. } */
  337. Doo::loadClass ( 'XDeode' );
  338. $XDeode = new XDeode ( 5 );
  339. Doo::loadModel ( 'L_category' );
  340. $Lcategory = new L_category ();
  341. Doo::loadModel ( 'staff' );
  342. $staff = new staff ();
  343. $rinfo = $this->find ( array (
  344. 'where' => 'rid in (' . $rid.')',
  345. 'asArray' => true
  346. ) );
  347. foreach ($rinfo as $key=>$value){
  348. $rinfo [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  349. //$rinfo [$key]['trainLoanRidKey'] = $XDeode->encode ( $value ['trainLoanRid'] );
  350. $XDeode = new XDeode ( 7 );
  351. $rinfo [$key]['ridKey7'] = $XDeode->encode ( $value ['rid'] );
  352. $rinfo[$key] ['category'] = $Lcategory->getCategoryById ( $value ['cid'] );
  353. $rinfo[$key] ['staffDetail'] = $staff->getStaffBySid ( $value ['staff'] );
  354. }
  355. //print_r($rinfo);
  356. return $rinfo;
  357. }
  358. function getReceiptByTrainLoanRid($rid = '') {
  359. Doo::loadClass ( 'XDeode' );
  360. $XDeode = new XDeode ( 5 );
  361. // Doo::loadModel ( 'L_category' );
  362. // $Lcategory = new L_category ();
  363. // Doo::loadModel ( 'staff' );
  364. // $staff = new staff ();
  365. if (! is_numeric ( $rid )){
  366. $rid = $XDeode->decode ( $rid );
  367. }
  368. $rinfo = $this->getOne ( array (
  369. 'where' => 'trainLoanRid=' . $rid,
  370. 'asArray' => true
  371. ) );
  372. if(empty($rinfo)){
  373. $rinfo = $this->getOne ( array (
  374. 'where' => 'trainLoanRid like "' . $rid.',%"',
  375. 'asArray' => true
  376. ) );
  377. }
  378. if(empty($rinfo)){
  379. $rinfo = $this->getOne ( array (
  380. 'where' => 'trainLoanRid like "%,' . $rid.'"',
  381. 'asArray' => true
  382. ) );
  383. }
  384. if(empty($rinfo)){
  385. $rinfo = $this->getOne ( array (
  386. 'where' => 'trainLoanRid like "%,' . $rid.',%"',
  387. 'asArray' => true
  388. ) );
  389. }
  390. $rinfo ['ridKey7']='';
  391. if (!empty($rinfo ['rid'])){
  392. $XDeode = new XDeode ( 7 );
  393. $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  394. }
  395. // $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  396. // $rinfo ['category'] = $Lcategory->getCategoryById ( $rinfo ['cid'] );
  397. // $rinfo ['staffDetail'] = $staff->getStaffBySid ( $rinfo ['staff'] );
  398. // $rinfo['sum']=number_format ($rinfo['sum'],2);
  399. return $rinfo;
  400. }
  401. function getReceiptByinvoiceTrainId($invoiceTrainId = 0) {
  402. Doo::loadClass ( 'XDeode' );
  403. $XDeode = new XDeode ( 5 );
  404. Doo::loadModel ( 'L_category' );
  405. $Lcategory = new L_category ();
  406. Doo::loadModel ( 'staff' );
  407. $staff = new staff ();
  408. if (! is_numeric ( $invoiceTrainId ))
  409. $invoiceTrainId = $XDeode->decode ( $invoiceTrainId );
  410. $rinfo = $this->getOne ( array (
  411. 'where' => 'invoiceTrainId=' . $invoiceTrainId,
  412. 'asArray' => true
  413. ) );
  414. if (empty ( $rinfo )) {
  415. return array ();
  416. }
  417. $rinfo ['ridKey'] = $XDeode->encode ( $rinfo ['rid'] );
  418. $rinfo ['trainLoanRidKey'] = '';//$XDeode->encode ( $rinfo ['trainLoanRid'] );
  419. $XDeode = new XDeode ( 7 );
  420. $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  421. $rinfo ['category'] = $Lcategory->getCategoryById ( $rinfo ['cid'] );
  422. $rinfo ['staffDetail'] = $staff->getStaffBySid ( $rinfo ['staff'] );
  423. return $rinfo;
  424. }
  425. /**
  426. * 默认获得10条
  427. * @param unknown $sid
  428. * @param unknown $cid
  429. * @param unknown $limit
  430. */
  431. function getReceiptLoanByStatus($sid, $cid, $status, $limit = 10) {
  432. $sql = '';
  433. if ($sid !== false && is_numeric ( $sid )) {
  434. $sql .= ' and staff=' . $sid;
  435. }
  436. if ($cid !== false && is_numeric ( $cid )) {
  437. $sql .= ' and cid=' . $cid;
  438. }
  439. $list = $this->find ( array (
  440. 'where' => 'Rtype=1 and status=' . $status . $sql,
  441. 'asArray' => true
  442. ) );
  443. Doo::loadClass ( 'XDeode' );
  444. $XDeode = new XDeode ( 5 );
  445. foreach ( $list as $key => $value ) {
  446. $list [$key] ['ridKey'] = $XDeode->encode ( $list [$key] ['rid'] );
  447. }
  448. return $list;
  449. }
  450. /**
  451. * 获得需要记录流水的费用
  452. * @param unknown $status
  453. * @return string
  454. */
  455. function getReceiptByWaste() {
  456. $list = $this->find ( array (
  457. 'where' => 'status=2 or status=6 or status=1',
  458. 'asArray' => true
  459. ) );
  460. Doo::loadClass ( 'XDeode' );
  461. $XDeode = new XDeode ( 5 );
  462. $XDeode7 = new XDeode ( 7 );
  463. Doo::loadModel ( 'wasteBook' );
  464. $wasteBook = new wasteBook ();
  465. $accountType = 0;
  466. foreach ( $list as $key => $value ) {
  467. $list [$key] ['ridKey7'] = $XDeode7->encode ( $list [$key] ['rid'] );
  468. $list [$key] ['ridKey'] = $XDeode->encode ( $list [$key] ['rid'] );
  469. if ($list [$key] ['Rtype'] == 0) {
  470. $accountType = 3;
  471. } elseif ($list [$key] ['Rtype'] == 1) {
  472. if (! empty ( $list [$key] ['accountItem'] ))
  473. $accountType = 2;
  474. else
  475. $accountType = 1;
  476. } elseif ($list [$key] ['Rtype'] == 2) {
  477. $accountType = 4;
  478. } elseif ($list [$key] ['Rtype'] == 3) {
  479. $accountType = 12;
  480. }
  481. // 是否已经生成流水
  482. $wbDetail = array ();
  483. if (! empty ( $accountType )) {
  484. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $list [$key] ['rid'] );
  485. if (! empty ( $wbDetail )) {
  486. unset ( $list [$key] );
  487. }
  488. } else {
  489. unset ( $list [$key] );
  490. }
  491. }
  492. return $list;
  493. }
  494. /**
  495. * 根据参数字段更新相应字段(主键ID必须传)
  496. * @param array $item 相关需要更新的字段信息
  497. * @return number 返回发票ID
  498. */
  499. public function setReceiptByCondition($item = array(), $rid = "") {
  500. $lid = 0;
  501. if (is_array ( $item ) && ! empty ( $item )) {
  502. foreach ( $item as $key => $value ) {
  503. $this->$key = $value;
  504. }
  505. if (! empty ( $isid )) {
  506. $condition = array (
  507. 'where' => "rid in (" . $rid . ")",
  508. 'asArray' => TRUE
  509. );
  510. $this->update ( $condition );
  511. } else
  512. $lid = $this->update ();
  513. }
  514. return $lid;
  515. }
  516. }
  517. ?>