refill_refund.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. class refill_refundControl extends SystemControl
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. }
  8. public function indexOp()
  9. {
  10. $mod = Model('refill_refund');
  11. $condition = [];
  12. if(!empty($_GET['provider_id'])) {
  13. $condition['provider_id'] = $_GET['provider_id'];
  14. }
  15. if(!empty($_GET['mchid'])) {
  16. $condition['mchid'] = $_GET['mchid'];
  17. }
  18. $start_unixtime = intval(strtotime($_GET['query_start_time']));
  19. $end_unixtime = intval(strtotime($_GET['query_end_time']));
  20. if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
  21. $condition['refund_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
  22. } elseif ($start_unixtime > 0) {
  23. $condition['refund_time'] = ['egt', $start_unixtime];
  24. } elseif ($end_unixtime > 0) {
  25. $condition['refund_time'] = ['lt', $end_unixtime];
  26. }
  27. $providers = [];
  28. $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.provider_id,refill_provider.name,store.store_name')->join('inner')
  29. ->on('store.store_id=refill_provider.store_id')->limit(1000)->select();
  30. foreach ($provider_list as $provider) {
  31. $providers[$provider['provider_id']] = $provider;
  32. }
  33. $merchants = [];
  34. $merchant_list = Model('')->table('merchant')->limit(1000)->select();
  35. foreach ($merchant_list as $value) {
  36. $merchants[$value['mchid']] = $value;
  37. }
  38. $refund_list = $mod->getRefillRefundList($condition,50);
  39. foreach ($refund_list as $key => $value) {
  40. $refund_list[$key]['provider_name'] = $providers[$value['provider_id']]['name'];
  41. $refund_list[$key]['store_name'] = $providers[$value['provider_id']]['store_name'];
  42. $refund_list[$key]['merchant_name'] = $merchants[$value['mchid']]['name'];
  43. $refund_list[$key]['company_name'] = $merchants[$value['mchid']]['company_name'];
  44. $refund_list[$key]['card_type_text'] = $this->scard_type($value['card_type']);
  45. }
  46. Tpl::output('provider_list', $providers);
  47. Tpl::output('merchants', $merchants);
  48. Tpl::output('info_list', $refund_list);
  49. Tpl::showpage('refill.refund');
  50. }
  51. public function addOp()
  52. {
  53. if (chksubmit()) {
  54. $obj_validate = new Validator();
  55. $obj_validate->validateparam = [
  56. ["input" => $_POST["mchid"], "require" => "true", "message" => '机构不能为空'],
  57. ["input" => $_POST["provider_id"], "require" => "true", "message" => '通道不能为空'],
  58. ["input" => $_POST["mch_amount"], "require" => "true", "message" => '机构退款金额不能为空'],
  59. ["input" => $_POST["channel_amount"], "require" => "true", "message" => '通道退款金额不能为空'],
  60. ["input" => $_POST["refund_time"], "require" => "true", "message" => '退款日期不能为空'],
  61. ["input" => $_POST["card_no"], "require" => "true", "message" => '退款卡号不能为空'],
  62. ["input" => $_POST["card_type"], "require" => "true", "message" => '卡类型不能为空'],
  63. ["input" => $_POST["refill_amount"], "require" => "true", "message" => '面值不能为空']
  64. ];
  65. $error = $obj_validate->validate();
  66. if ($error != '') {
  67. showMessage($error);
  68. } else {
  69. $merchant = Model('merchant')->getMerchantInfo(['mchid' => $_POST['mchid']]);
  70. if(empty($merchant)) {
  71. showMessage('此机构不存在!');
  72. }
  73. $provider = Model('refill_provider')->getProviderInfo(['provider_id' => $_POST['provider_id']]);
  74. if(empty($provider)) {
  75. showMessage('此上游通道不存在!');
  76. }
  77. $mod = Model('refill_refund');
  78. $insert_array['mchid'] = $_POST['mchid'];
  79. $insert_array['provider_id'] = $_POST['provider_id'];
  80. $insert_array['mch_amount'] = $_POST['mch_amount'];
  81. $insert_array['channel_amount'] = $_POST['channel_amount'];
  82. $insert_array['refund_time'] = strtotime($_POST['refund_time']);
  83. $insert_array['card_no'] = $_POST['card_no'];
  84. $insert_array['card_type'] = $_POST['card_type'];
  85. $insert_array['refill_amount'] = $_POST['refill_amount'];
  86. $insert_array['bz'] = $_POST['bz'] ?? '';
  87. $insert_array['add_time'] = time();
  88. $result = $mod->addRefund($insert_array);
  89. if ($result) {
  90. showMessage('添加成功', 'index.php?act=refill_refund&op=index');
  91. } else {
  92. showMessage('添加失败');
  93. }
  94. }
  95. }
  96. else
  97. {
  98. $merchant_list = Model('')->table('merchant')->limit(1000)->select();
  99. $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.provider_id,store.store_name')->join('inner')
  100. ->on('store.store_id=refill_provider.store_id')->limit(1000)->select();
  101. Tpl::output('provider_list', $provider_list);
  102. Tpl::output('merchant_list', $merchant_list);
  103. Tpl::showpage('refill.refund.add');
  104. }
  105. }
  106. public function delOp()
  107. {
  108. $id = $_GET['id'];
  109. $mod = Model('refill_refund');
  110. $provider_info = $mod->getRefundInfo(['id' => $id]);
  111. if (empty($provider_info)) {
  112. showMessage('退款信息不存在');
  113. }
  114. $result = $mod->DelRefund(['id' => $id]);
  115. if (!$result) {
  116. showMessage('删除失败');
  117. }
  118. showMessage('删除成功','index.php?act=refill_refund&op=index');
  119. }
  120. }