提交 576079b9 编写于 作者: G gongfuxiang

钱包管理

上级 491fc4c7
......@@ -23,18 +23,24 @@
<!-- 账户信息 -->
{{if empty($wallet_error)}}
<div class="am-alert am-alert-secondary" data-am-alert>
<div class="available">
<span>可用金额</span>
<div class="normal">
<span>有效金额</span>
<span class="integral-value">{{$user_wallet.normal_money}}</span>
<em></em>
<span class="integral-tips">正常可以使用的金额</span>
<span class="integral-tips">正常可以使用的金额、包含赠送金额</span>
</div>
<div class="locking">
<div class="frozen">
<span>冻结金额</span>
<span class="integral-value">{{$user_wallet.frozen_money}}</span>
<em></em>
<span class="integral-tips">一般积分交易中、提现、交易并未完成,锁定相应的积分</span>
</div>
<div class="give">
<span>赠送金额</span>
<span class="integral-value">{{$user_wallet.give_money}}</span>
<em></em>
<span class="integral-tips">所有赠送金额总额</span>
</div>
</div>
{{else /}}
<div class="am-alert am-alert-warning" data-am-alert>
......
......@@ -38,7 +38,7 @@ CREATE TABLE `s_plugins_wallet_log` (
`wallet_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '钱包id',
`business_type` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '业务类型(0系统, 1充值, 2提现, 3消费)',
`operation_type` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '操作类型( 0减少, 1增加)',
`money_type` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '金额类型(0正常, 1冻结, 2赠送)',
`money_type` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '金额类型(0有效, 1冻结, 2赠送)',
`money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '操作金额',
`msg` char(200) NOT NULL DEFAULT '' COMMENT '变更说明',
`add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
......
......@@ -47,7 +47,7 @@ class WalletService
// 金额类型
public static $money_type_list = [
0 => ['value' => 0, 'name' => '正常', 'checked' => true],
0 => ['value' => 0, 'name' => '有效', 'checked' => true],
1 => ['value' => 1, 'name' => '冻结'],
2 => ['value' => 2, 'name' => '赠送'],
];
......@@ -223,6 +223,30 @@ class WalletService
return DataReturn('操作成功', 0, $wallet);
}
/**
* 钱包日志添加
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-07T00:57:36+0800
* @param [array] $params [输入参数]
* @return [boolean] [成功true, 失败false]
*/
public static function WalletLogInsert($params = [])
{
$data = [
'user_id' => isset($params['user_id']) ? intval($params['user_id']) : 0,
'wallet_id' => isset($params['wallet_id']) ? intval($params['wallet_id']) : 0,
'business_type' => isset($params['business_type']) ? intval($params['business_type']) : 0,
'operation_type' => isset($params['operation_type']) ? intval($params['operation_type']) : 0,
'money_type' => isset($params['money_type']) ? intval($params['money_type']) : 0,
'money' => isset($params['money']) ? PriceNumberFormat($params['money']) : 0.00,
'msg' => empty($params['msg']) ? '系统' : $params['msg'],
'add_time' => time(),
];
return Db::name('PluginsWalletLog')->insertGetId($data) > 0;
}
/**
* 钱包编辑
* @author Devil
......@@ -282,6 +306,9 @@ class WalletService
return DataReturn('钱包不存在或已删除', -10);
}
// 开始处理
Db::startTrans();
// 数据
$data = [
'status' => intval($params['status']),
......@@ -290,24 +317,44 @@ class WalletService
'give_money' => empty($params['give_money']) ? 0.00 : PriceNumberFormat($params['give_money']),
'upd_time' => time(),
];
if(!Db::name('PluginsWallet')->where(['id'=>$wallet['id']])->update($data))
{
Db::rollback();
return DataReturn('编辑失败', -100);
}
// 日志
$log_data = [];
if($wallet['normal_money'] != $data['normal_money'])
// 字段名称 金额类型
$money_field = [
['field' => 'normal_money', 'money_type' => 0],
['field' => 'frozen_money', 'money_type' => 1],
['field' => 'give_money', 'money_type' => 2],
];
foreach($money_field as $v)
{
$log_data[] = [
'user_id' => $wallet['user_id'],
'wallet_id' => $wallet['id'],
'business_type' => 0,
'operation_type' => ($wallet['normal_money'] < $data['normal_money']) ? 1 : 0,
'money_type' => 0,
'money' => ($wallet['normal_money'] < $data['normal_money']) ? PriceNumberFormat($data['normal_money']-$wallet['normal_money']) : PriceNumberFormat($wallet['normal_money']-$data['normal_money']),
'msg' => '管理员操作',
'add_time' => time(),
];
// 有效金额
if($wallet[$v['field']] != $data[$v['field']])
{
$log_data = [
'user_id' => $wallet['user_id'],
'wallet_id' => $wallet['id'],
'business_type' => 0,
'operation_type' => ($wallet[$v['field']] < $data[$v['field']]) ? 1 : 0,
'money_type' => $v['money_type'],
'money' => ($wallet[$v['field']] < $data[$v['field']]) ? PriceNumberFormat($data[$v['field']]-$wallet[$v['field']]) : PriceNumberFormat($wallet[$v['field']]-$data[$v['field']]),
'msg' => '管理员操作',
];
if(!self::WalletLogInsert($log_data))
{
Db::rollback();
return DataReturn('日志添加失败', -101);
}
}
}
print_r($data);
print_r($log_data);
// 处理成功
Db::commit();
return DataReturn('编辑成功', 0);
}
}
?>
\ No newline at end of file
......@@ -68,13 +68,10 @@
border-color: #ececec;
margin-bottom: 20px;
}
.user-content-body .available .integral-value {
.user-content-body .normal .integral-value {
color: #4CAF50;
}
.user-content-body .locking {
margin-top: 5px;
}
.user-content-body .locking .integral-value {
.user-content-body .frozen .integral-value {
color: #FF9800;
}
.user-content-body .integral-value {
......@@ -146,4 +143,5 @@
}
.user-content-body .data-list .money {
color: #E4393C;
font-weight: 700;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册