mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-02 20:10:30 +08:00
充值
This commit is contained in:
parent
52200d01a2
commit
986f52486d
@ -12,7 +12,7 @@
|
||||
|
||||
<div class="am-topbar-right">
|
||||
{{if in_array($plugins_action, ['index', 'recharge'])}}
|
||||
<button class="am-btn am-btn-secondary am-topbar-btn am-btn-sm am-icon-shield" data-am-modal="{target: '#plugins-recharge-pay-modal-popup'}"> 在线充值</button>
|
||||
<button class="am-btn am-btn-secondary am-topbar-btn am-btn-sm am-icon-shield" data-am-modal="{target: '#plugins-recharge-pay-modal', width: 260, height: 130}"> 在线充值</button>
|
||||
{{/if}}
|
||||
{{if in_array($plugins_action, ['index', 'cash'])}}
|
||||
<a class="am-btn am-btn-success am-topbar-btn am-btn-sm am-icon-money"> 申请提现</a>
|
||||
@ -37,17 +37,37 @@
|
||||
</div>
|
||||
|
||||
<!-- 充值窗口 -->
|
||||
<div class="am-popup" id="plugins-recharge-pay-modal-popup">
|
||||
<div class="am-modal am-modal-no-btn" tabindex="-1" id="plugins-recharge-pay-modal">
|
||||
<div class="am-modal-dialog">
|
||||
<div class="am-modal-hd">
|
||||
<a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>×</a>
|
||||
</div>
|
||||
<div class="am-modal-bd">
|
||||
<form class="am-form form-validation-plugins-recharge-modal" action="{{:PluginsHomeUrl('wallet', 'wallet', 'rechargecreate')}}" method="POST" request-type="ajax-fun" request-value="PluginsRechargeBack">
|
||||
<label>充值金额</label>
|
||||
<div class="am-input-group am-input-group-sm">
|
||||
<input type="number" autocomplete="off" name="money" step="0.01" class="am-radius" placeholder="充值金额" data-validation-message="请输入充值金额" required />
|
||||
<span class="am-input-group-btn">
|
||||
<button type="button" class="am-btn am-btn-default am-radius">元</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">确认</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 支付方式 -->
|
||||
<div class="am-popup" id="plugins-recharge-pay-popup">
|
||||
<div class="am-popup-inner">
|
||||
<div class="am-popup-hd">
|
||||
<h4 class="am-popup-title">充值</h4>
|
||||
<h4 class="am-popup-title">支付方式</h4>
|
||||
<span data-am-modal-close class="am-close">×</span>
|
||||
</div>
|
||||
<div class="am-popup-bd">
|
||||
<form class="am-form form-validation-plugins-recharge-pay" action="{{:PluginsHomeUrl('wallet', 'wallet', 'rechargecreate')}}" method="POST" request-type="ajax-fun" request-value="PluginsRechargeFormBack">
|
||||
<!-- 支付方式 -->
|
||||
<div class="business-item am-form-group">
|
||||
<label>选择支付</label>
|
||||
<form class="am-form form-validation-plugins-recharge-popup" action="{{:PluginsHomeUrl('wallet', 'wallet', 'pay')}}" method="POST" request-type="ajax-fun" request-value="PluginsRechargePayBack">
|
||||
<div class="business-item ">
|
||||
{{if !empty($buy_payment_list)}}
|
||||
<ul class="payment-list" data-type="payment">
|
||||
{{foreach $buy_payment_list as $payment}}
|
||||
@ -68,17 +88,8 @@
|
||||
<input type="number" name="payment_id" min="1" data-validation-message="请选择支付方式" value="0" required />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>充值金额</label>
|
||||
<div class="am-input-group am-input-group-sm">
|
||||
<input type="number" autocomplete="off" name="money" step="0.01" class="am-radius" placeholder="充值金额" data-validation-message="请输入充值金额" required />
|
||||
<span class="am-input-group-btn">
|
||||
<button class="am-btn am-btn-default am-radius">元</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group am-form-group-refreshing">
|
||||
<input type="hidden" name="recharge_id" value="" />
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">确认</button>
|
||||
</div>
|
||||
</form>
|
||||
@ -86,13 +97,34 @@
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
function PluginsRechargeFormBack(e)
|
||||
/**
|
||||
* 充值回调
|
||||
*/
|
||||
function PluginsRechargeBack(e)
|
||||
{
|
||||
$.AMUI.progress.done();
|
||||
$('form.form-validation-plugins-recharge-modal').find('button[type="submit"]').button('reset');
|
||||
if(e.code == 0)
|
||||
{
|
||||
$('#plugins-recharge-pay-modal').modal('close');
|
||||
var $popup = $('#plugins-recharge-pay-popup');
|
||||
$popup.find('input[name="recharge_id"]').val(e.data.recharge_id);
|
||||
$popup.modal('open');
|
||||
} else {
|
||||
Prompt(e.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
*/
|
||||
function PluginsRechargePayBack(e)
|
||||
{
|
||||
if(e.code == 0)
|
||||
{
|
||||
window.location.href = e.data;
|
||||
} else {
|
||||
$('form.form-validation-plugins-recharge-pay').find('button[type="submit"]').button('reset');
|
||||
$('form.form-validation-plugins-recharge-popup').find('button[type="submit"]').button('reset');
|
||||
$.AMUI.progress.done();
|
||||
Prompt(e.msg);
|
||||
}
|
||||
|
@ -44,8 +44,8 @@
|
||||
<tr>
|
||||
<th>充值单号</th>
|
||||
<th>充值金额(元)</th>
|
||||
<th>支付方式</th>
|
||||
<th>状态</th>
|
||||
<th class="am-hide-sm-only">支付方式</th>
|
||||
<th class="am-hide-sm-only">支付时间</th>
|
||||
<th class="am-hide-sm-only">创建时间</th>
|
||||
<th>操作</th>
|
||||
@ -55,11 +55,15 @@
|
||||
{{if !empty($data_list)}}
|
||||
{{foreach $data_list as $v}}
|
||||
<tr>
|
||||
<td>{{$v.type_name}}</td>
|
||||
<td class="am-hide-sm-only">{{$v.msg}}</td>
|
||||
<td>{{$v.original_integral}}</td>
|
||||
<td>{{$v.new_integral}}</td>
|
||||
<td class="am-hide-sm-only">{{$v.add_time_time}}</td>
|
||||
<td>{{$v.recharge_no}}</td>
|
||||
<td>{{$v.money}}</td>
|
||||
<td>{{$v.status_text}}</td>
|
||||
<td class="am-hide-sm-only">{{$v.payment_name}}</td>
|
||||
<td class="am-hide-sm-only">{{$v.pay_time_text}}</td>
|
||||
<td class="am-hide-sm-only">{{$v.add_time_text}}</td>
|
||||
<td>
|
||||
<button class="am-btn am-btn-success am-topbar-btn am-btn-sm am-icon-shield recharge-submit" data-value="{{$v.id}}"> 继续支付</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
@ -29,12 +29,101 @@ class Service
|
||||
'default_level_images'
|
||||
];
|
||||
|
||||
// 等级规则
|
||||
public static $members_level_rules_list = [
|
||||
0 => ['value' => 0, 'name' => '积分(可用积分)', 'checked' => true],
|
||||
1 => ['value' => 1, 'name' => '消费总额(已完成订单)'],
|
||||
// 充值支付状态
|
||||
public static $recharge_status_list = [
|
||||
0 => ['value' => 0, 'name' => '未支付', 'checked' => true],
|
||||
1 => ['value' => 1, 'name' => '已支付'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 充值列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-04-30T00:13:14+0800
|
||||
* @param array $params [description]
|
||||
*/
|
||||
public static function RechargeList($params = [])
|
||||
{
|
||||
$where = empty($params['where']) ? [] : $params['where'];
|
||||
$m = isset($params['m']) ? intval($params['m']) : 0;
|
||||
$n = isset($params['n']) ? intval($params['n']) : 10;
|
||||
$field = empty($params['field']) ? '*' : $params['field'];
|
||||
$order_by = empty($params['order_by']) ? 'id desc' : $params['order_by'];
|
||||
|
||||
// 获取数据列表
|
||||
$data = Db::name('PluginsWalletRecharge')->field($field)->where($where)->limit($m, $n)->order($order_by)->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
$common_gender_list = lang('common_gender_list');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
// 用户信息
|
||||
if(!empty($v['user_id']))
|
||||
{
|
||||
$user = Db::name('User')->where(['id'=>$v['user_id']])->field('username,nickname,mobile,gender,avatar')->find();
|
||||
$v['username'] = empty($user['username']) ? '' : $user['username'];
|
||||
$v['nickname'] = empty($user['nickname']) ? '' : $user['nickname'];
|
||||
$v['mobile'] = empty($user['mobile']) ? '' : $user['mobile'];
|
||||
$v['avatar'] = empty($user['avatar']) ? '' : $user['avatar'];
|
||||
$v['gender_text'] = isset($user['gender']) ? $common_gender_list[$user['gender']]['name'] : '';
|
||||
}
|
||||
|
||||
// 支付状态
|
||||
$v['status_text'] = isset($v['status']) ? self::$recharge_status_list[$v['status']]['name'] : '';
|
||||
|
||||
// 支付时间
|
||||
$v['pay_time_text'] = empty($v['pay_time']) ? '' : date('Y-m-d H:i:s', $v['pay_time']);
|
||||
|
||||
// 创建时间
|
||||
$v['add_time_text'] = empty($v['pay_time']) ? '' : date('Y-m-d H:i:s', $v['pay_time']);
|
||||
}
|
||||
}
|
||||
return DataReturn('处理成功', 0, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 总数
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-29
|
||||
* @desc description
|
||||
* @param [array] $where [条件]
|
||||
*/
|
||||
public static function RechargeTotal($where = [])
|
||||
{
|
||||
return (int) Db::name('PluginsWalletRecharge')->where($where)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值列表条件
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function RechargeListWhere($params = [])
|
||||
{
|
||||
$where = [];
|
||||
|
||||
// 用户id
|
||||
if(!empty($params['user']))
|
||||
{
|
||||
$where[] = ['user_id', '=', $params['user']['id']];
|
||||
}
|
||||
|
||||
// 关键字
|
||||
if(!empty($params['keywords']))
|
||||
{
|
||||
$where[] = ['recharge_no', 'like', '%'.$params['keywords'].'%'];
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值订单创建
|
||||
* @author Devil
|
||||
@ -81,10 +170,14 @@ class Service
|
||||
'add_time' => time(),
|
||||
|
||||
];
|
||||
$params['recharge_id'] = Db::name('PluginsWalletRecharge')->insertGetId($data);
|
||||
if($params['recharge_id'] > 0)
|
||||
$recharge_id = Db::name('PluginsWalletRecharge')->insertGetId($data);
|
||||
if($recharge_id > 0)
|
||||
{
|
||||
return self::Pay($params);
|
||||
return DataReturn('添加成功',0, [
|
||||
'recharge_id' => $recharge_id,
|
||||
'recharge_no' => $data['recharge_no'],
|
||||
]);
|
||||
//return self::Pay($params);
|
||||
}
|
||||
return DataReturn('添加失败', -100);
|
||||
}
|
||||
|
@ -121,10 +121,36 @@ class Wallet extends Controller
|
||||
public function recharge($params = [])
|
||||
{
|
||||
// 参数
|
||||
$params = input();
|
||||
$params['user'] = $this->user;
|
||||
|
||||
$this->assign('data_list', []);
|
||||
// 分页
|
||||
$number = MyC('admin_page_number', 10, true);
|
||||
|
||||
// 条件
|
||||
$where = Service::RechargeListWhere($params);
|
||||
|
||||
// 获取总数
|
||||
$total = Service::RechargeTotal($where);
|
||||
|
||||
// 分页
|
||||
$page_params = array(
|
||||
'number' => $number,
|
||||
'total' => $total,
|
||||
'where' => $params,
|
||||
'page' => isset($params['page']) ? intval($params['page']) : 1,
|
||||
'url' => PluginsHomeUrl('wallet', 'wallet', 'recharge'),
|
||||
);
|
||||
$page = new \base\Page($page_params);
|
||||
$this->assign('page_html', $page->GetPageHtml());
|
||||
|
||||
// 获取列表
|
||||
$data_params = array(
|
||||
'm' => $page->GetPageStarNumber(),
|
||||
'n' => $number,
|
||||
'where' => $where,
|
||||
);
|
||||
$data = Service::RechargeList($data_params);
|
||||
$this->assign('data_list', $data['data']);
|
||||
|
||||
// 参数
|
||||
$this->assign('params', $params);
|
||||
@ -186,12 +212,7 @@ class Wallet extends Controller
|
||||
{
|
||||
// 用户
|
||||
$params['user'] = $this->user;
|
||||
$ret = Service::Pay($params);
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
return redirect($ret['data']['data']);
|
||||
}
|
||||
return $ret['msg'];
|
||||
return Service::Pay($params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -907,6 +907,75 @@ function ConfirmDataDelete(e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [AjaxRequest ajax网络请求]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-04-30T00:25:21+0800
|
||||
* @param {[object]} e [当前元素对象]
|
||||
*/
|
||||
function AjaxRequest(e)
|
||||
{
|
||||
var id = e.data('id');
|
||||
var field = e.data('field') || 'value';
|
||||
var value = e.data('value') || '';
|
||||
var url = e.data('url');
|
||||
var view = e.data('view') || '';
|
||||
|
||||
// ajax
|
||||
$.ajax({
|
||||
url:url,
|
||||
type:'POST',
|
||||
dataType:"json",
|
||||
timeout:10000,
|
||||
data:{id:id, field: value},
|
||||
success:function(result)
|
||||
{
|
||||
if(result.code == 0)
|
||||
{
|
||||
switch(view)
|
||||
{
|
||||
// 成功则删除数据列表
|
||||
case 'delete' :
|
||||
Prompt(result.msg, 'success');
|
||||
$('#data-list-'+id).remove();
|
||||
break;
|
||||
|
||||
// 刷新
|
||||
case 'reload' :
|
||||
Prompt(result.msg, 'success');
|
||||
setTimeout(function()
|
||||
{
|
||||
window.location.reload();
|
||||
}, 1500);
|
||||
break;
|
||||
|
||||
// 回调函数
|
||||
case 'fun' :
|
||||
if(IsExitsFunction(value))
|
||||
{
|
||||
window[value](result);
|
||||
} else {
|
||||
Prompt('['+value+']配置方法未定义');
|
||||
}
|
||||
break;
|
||||
|
||||
// 默认提示成功
|
||||
default :
|
||||
Prompt(result.msg, 'success');
|
||||
}
|
||||
} else {
|
||||
Prompt(result.msg);
|
||||
}
|
||||
},
|
||||
error:function(xhr, type)
|
||||
{
|
||||
Prompt('网络异常出错');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* [ConfirmNetworkAjax 确认网络请求]
|
||||
* @author Devil
|
||||
@ -917,10 +986,6 @@ function ConfirmDataDelete(e)
|
||||
*/
|
||||
function ConfirmNetworkAjax(e)
|
||||
{
|
||||
var id = e.data('id');
|
||||
var value = e.data('value') || '';
|
||||
var url = e.data('url');
|
||||
var view = e.data('view') || '';
|
||||
var title = e.data('title') || '温馨提示';
|
||||
var msg = e.data('msg') || '操作后不可恢复、确认继续吗?';
|
||||
|
||||
@ -929,57 +994,7 @@ function ConfirmNetworkAjax(e)
|
||||
content: msg,
|
||||
onConfirm: function(e)
|
||||
{
|
||||
// ajax
|
||||
$.ajax({
|
||||
url:url,
|
||||
type:'POST',
|
||||
dataType:"json",
|
||||
timeout:10000,
|
||||
data:{id:id, value: value},
|
||||
success:function(result)
|
||||
{
|
||||
if(result.code == 0)
|
||||
{
|
||||
switch(view)
|
||||
{
|
||||
// 成功则删除数据列表
|
||||
case 'delete' :
|
||||
Prompt(result.msg, 'success');
|
||||
$('#data-list-'+id).remove();
|
||||
break;
|
||||
|
||||
// 刷新
|
||||
case 'reload' :
|
||||
Prompt(result.msg, 'success');
|
||||
setTimeout(function()
|
||||
{
|
||||
window.location.reload();
|
||||
}, 1500);
|
||||
break;
|
||||
|
||||
// 回调函数
|
||||
case 'fun' :
|
||||
if(IsExitsFunction(value))
|
||||
{
|
||||
window[value](result);
|
||||
} else {
|
||||
Prompt('['+value+']配置方法未定义');
|
||||
}
|
||||
break;
|
||||
|
||||
// 默认提示成功
|
||||
default :
|
||||
Prompt(result.msg, 'success');
|
||||
}
|
||||
} else {
|
||||
Prompt(result.msg);
|
||||
}
|
||||
},
|
||||
error:function(xhr, type)
|
||||
{
|
||||
Prompt('网络异常出错');
|
||||
}
|
||||
});
|
||||
AjaxRequest(e);
|
||||
},
|
||||
onCancel: function(){}
|
||||
});
|
||||
@ -1535,7 +1550,13 @@ $(function()
|
||||
*/
|
||||
$(document).on('click', '.submit-ajax', function()
|
||||
{
|
||||
ConfirmNetworkAjax($(this));
|
||||
var is_confirm = $(this).data('is-confirm');
|
||||
if(is_confirm == undefined || is_confirm == 1)
|
||||
{
|
||||
ConfirmNetworkAjax($(this));
|
||||
} else {
|
||||
AjaxRequest($(this));
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -117,7 +117,15 @@
|
||||
/**
|
||||
* 充值窗口
|
||||
*/
|
||||
#plugins-recharge-pay-modal-popup input[name="payment_id"] {
|
||||
#plugins-recharge-pay-modal button[type="submit"] {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付选择窗口
|
||||
*/
|
||||
#plugins-recharge-pay-popup input[name="payment_id"] {
|
||||
margin-left: -10000px;
|
||||
position: absolute;
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
$(function()
|
||||
{
|
||||
// 支付操作表单
|
||||
FromInit('form.form-validation-plugins-recharge-pay');
|
||||
// 表单初始化
|
||||
FromInit('form.form-validation-plugins-recharge-modal');
|
||||
FromInit('form.form-validation-plugins-recharge-popup');
|
||||
|
||||
// 混合列表选择
|
||||
$('.business-item ul li').on('click', function()
|
||||
@ -14,6 +15,20 @@ $(function()
|
||||
value = $(this).data('value');
|
||||
$(this).addClass('selected').siblings('li').removeClass('selected');
|
||||
}
|
||||
$('form.form-validation-plugins-recharge-pay input[name='+$(this).parent().data('type')+'_id]').val(value).blur();
|
||||
$('form.form-validation-plugins-recharge-popup input[name='+$(this).parent().data('type')+'_id]').val(value).blur();
|
||||
});
|
||||
|
||||
// 充值列表支付发起事件
|
||||
$('.recharge-submit').on('click', function()
|
||||
{
|
||||
var recharge_id = $(this).data('value') || null;
|
||||
var $popup = $('#plugins-recharge-pay-popup');
|
||||
if(recharge_id != null)
|
||||
{
|
||||
$popup.find('input[name="recharge_id"]').val(recharge_id);
|
||||
$popup.modal('open');
|
||||
} else {
|
||||
Prompt('充值id有误');
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user