PayController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * MainController
  4. * Feel free to delete the methods and replace them with your own code.
  5. *
  6. * @author JieRen
  7. */
  8. class PayController extends DooController {
  9. public $data;
  10. function __construct() {
  11. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  12. }
  13. /*
  14. * 支付删除
  15. */
  16. public function pay_del() {
  17. $id = intval($this->params['pid']);
  18. if (empty($id))
  19. return false;
  20. Doo::loadModel('pay');
  21. $pay = new Pay();
  22. $pay->delete(array(
  23. 'where' => 'id=?',
  24. 'param' => array($id),
  25. 'asArray' => TRUE));
  26. return $this->data['rootUrl'] . 'm/pay/add';
  27. }
  28. /*
  29. * 支付取消
  30. */
  31. public function pay_cancel() {
  32. $id = intval($this->params['pid']);
  33. if (empty($id))
  34. return false;
  35. Doo::loadModel('pay');
  36. $pay = new Pay();
  37. $pay->status = 'cancel';
  38. $pay->update(array('where' => 'id=' . $id));
  39. // showmessage(L('state_change_succ'), HTTP_REFERER);
  40. return $this->data['rootUrl'] . 'm/pay/add';
  41. }
  42. /**
  43. *
  44. */
  45. public function pay() {
  46. if (isset($_GET['op']) && !empty($_POST['ids'])) {
  47. $ops = $_GET['op'];
  48. // $ids = implode(',', $_POST['ids']);
  49. $ids = $_POST['ids'];
  50. var_dump($ids);
  51. Doo::loadModel('pay');
  52. $p = new Pay();
  53. if (!empty($ids)) {
  54. if ($ops == 'del') {
  55. foreach ($ids as $key => $val) {
  56. $p->id = $val;
  57. $p->delete();
  58. }
  59. }
  60. if ($ops == 'act') {
  61. foreach ($ids as $key => $val) {
  62. $p->status = 'succ';
  63. $p->update(array('where' => 'id=' . $val));
  64. }
  65. }
  66. }
  67. }
  68. Doo::loadHelper('DooPager');
  69. Doo::loadModel('pay');
  70. $pay = new Pay();
  71. $totalArchive = $pay->count();
  72. $pager = new DooPager(Doo::conf()->APP_URL . "m/pay/add/page", $totalArchive, 5, 5);
  73. if (isset($this->params['pindex']))
  74. $pager->paginate(intval($this->params['pindex']));
  75. else
  76. $pager->paginate(1);
  77. $this->data['userArray'] = $pay->get_all_posts($pager->limit);
  78. $this->data['pager'] = $pager->output;
  79. $this->render('admin/pay', $this->data, TRUE);
  80. }
  81. }
  82. ?>