|
@@ -0,0 +1,125 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+class refill_refundControl extends SystemControl
|
|
|
+{
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ parent::__construct();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function indexOp()
|
|
|
+ {
|
|
|
+ $mod = Model('refill_refund');
|
|
|
+ $condition = [];
|
|
|
+ if(!empty($_GET['provider_id'])) {
|
|
|
+ $condition['provider_id'] = $_GET['provider_id'];
|
|
|
+ }
|
|
|
+ if(!empty($_GET['mchid'])) {
|
|
|
+ $condition['mchid'] = $_GET['mchid'];
|
|
|
+ }
|
|
|
+ $start_unixtime = intval(strtotime($_GET['query_start_time']));
|
|
|
+ $end_unixtime = intval(strtotime($_GET['query_end_time']));
|
|
|
+ if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
|
|
|
+ $condition['refund_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
|
|
|
+ } elseif ($start_unixtime > 0) {
|
|
|
+ $condition['refund_time'] = ['egt', $start_unixtime];
|
|
|
+ } elseif ($end_unixtime > 0) {
|
|
|
+ $condition['refund_time'] = ['lt', $end_unixtime];
|
|
|
+ }
|
|
|
+
|
|
|
+ $providers = [];
|
|
|
+ $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.provider_id,refill_provider.name,store.store_name')->join('inner')
|
|
|
+ ->on('store.store_id=refill_provider.store_id')->limit(1000)->select();
|
|
|
+ foreach ($provider_list as $provider) {
|
|
|
+ $providers[$provider['provider_id']] = $provider;
|
|
|
+ }
|
|
|
+ $merchants = [];
|
|
|
+ $merchant_list = Model('')->table('merchant')->limit(1000)->select();
|
|
|
+ foreach ($merchant_list as $value) {
|
|
|
+ $merchants[$value['mchid']] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ $refund_list = $mod->getRefillRefundList($condition,50);
|
|
|
+ foreach ($refund_list as $key => $value) {
|
|
|
+ $refund_list[$key]['provider_name'] = $providers[$value['provider_id']]['name'];
|
|
|
+ $refund_list[$key]['store_name'] = $providers[$value['provider_id']]['store_name'];
|
|
|
+
|
|
|
+ $refund_list[$key]['merchant_name'] = $merchants[$value['mchid']]['name'];
|
|
|
+ $refund_list[$key]['company_name'] = $merchants[$value['mchid']]['company_name'];
|
|
|
+ }
|
|
|
+ Tpl::output('provider_list', $providers);
|
|
|
+ Tpl::output('merchants', $merchants);
|
|
|
+ Tpl::output('info_list', $refund_list);
|
|
|
+ Tpl::showpage('refill.refund');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addOp()
|
|
|
+ {
|
|
|
+ if (chksubmit()) {
|
|
|
+ $obj_validate = new Validator();
|
|
|
+ $obj_validate->validateparam = [
|
|
|
+ ["input" => $_POST["mchid"], "require" => "true", "message" => '机构不能为空'],
|
|
|
+ ["input" => $_POST["provider_id"], "require" => "true", "message" => '通道不能为空'],
|
|
|
+ ["input" => $_POST["mch_amount"], "require" => "true", "message" => '机构退款金额不能为空'],
|
|
|
+ ["input" => $_POST["channel_amount"], "require" => "true", "message" => '通道退款金额不能为空'],
|
|
|
+ ["input" => $_POST["refund_time"], "require" => "true", "message" => '退款日期不能为空'],
|
|
|
+ ["input" => $_POST["card_no"], "require" => "true", "message" => '退款卡号不能为空'],
|
|
|
+ ["input" => $_POST["card_type"], "require" => "true", "message" => '卡类型不能为空'],
|
|
|
+ ["input" => $_POST["refill_amount"], "require" => "true", "message" => '面值不能为空']
|
|
|
+ ];
|
|
|
+ $error = $obj_validate->validate();
|
|
|
+ if ($error != '') {
|
|
|
+ showMessage($error);
|
|
|
+ } else {
|
|
|
+ $merchant = Model('merchant')->getMerchantInfo(['mchid' => $_POST['mchid']]);
|
|
|
+ if(empty($merchant)) {
|
|
|
+ showMessage('此机构不存在!');
|
|
|
+ }
|
|
|
+ $provider = Model('refill_provider')->getProviderInfo(['provider_id' => $_POST['provider_id']]);
|
|
|
+ if(empty($provider)) {
|
|
|
+ showMessage('此上游通道不存在!');
|
|
|
+ }
|
|
|
+ $mod = Model('refill_refund');
|
|
|
+ $insert_array['mchid'] = $_POST['mchid'];
|
|
|
+ $insert_array['provider_id'] = $_POST['provider_id'];
|
|
|
+ $insert_array['mch_amount'] = $_POST['mch_amount'];
|
|
|
+ $insert_array['channel_amount'] = $_POST['channel_amount'];
|
|
|
+ $insert_array['refund_time'] = strtotime($_POST['refund_time']);
|
|
|
+ $insert_array['bz'] = $_POST['bz'] ?? '';
|
|
|
+ $insert_array['add_time'] = time();
|
|
|
+ $result = $mod->addRefund($insert_array);
|
|
|
+ if ($result) {
|
|
|
+ showMessage('添加成功', 'index.php?act=refill_refund&op=index');
|
|
|
+ } else {
|
|
|
+ showMessage('添加失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $merchant_list = Model('')->table('merchant')->limit(1000)->select();
|
|
|
+ $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.provider_id,store.store_name')->join('inner')
|
|
|
+ ->on('store.store_id=refill_provider.store_id')->limit(1000)->select();
|
|
|
+
|
|
|
+ Tpl::output('provider_list', $provider_list);
|
|
|
+ Tpl::output('merchant_list', $merchant_list);
|
|
|
+ Tpl::showpage('refill.refund.add');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function delOp()
|
|
|
+ {
|
|
|
+ $id = $_GET['id'];
|
|
|
+ $mod = Model('refill_refund');
|
|
|
+ $provider_info = $mod->getRefundInfo(['id' => $id]);
|
|
|
+ if (empty($provider_info)) {
|
|
|
+ showMessage('退款信息不存在');
|
|
|
+ }
|
|
|
+ $result = $mod->DelRefund(['id' => $id]);
|
|
|
+ if (!$result) {
|
|
|
+ showMessage('删除失败');
|
|
|
+ }
|
|
|
+ showMessage('删除成功','index.php?act=refill_refund&op=index');
|
|
|
+ }
|
|
|
+}
|