diff --git a/application/plugins/view/wallet/public/nav.html b/application/plugins/view/wallet/public/nav.html index bfc5a95cc59bc0ed7bd581fcd76a21281ab8b36f..10d010641cf749edf24a9def639fbbe6983114c1 100755 --- a/application/plugins/view/wallet/public/nav.html +++ b/application/plugins/view/wallet/public/nav.html @@ -23,18 +23,24 @@ {{if empty($wallet_error)}}
-
- 可用金额 +
+ 有效金额 {{$user_wallet.normal_money}} - 正常可以使用的金额 + 正常可以使用的金额、包含赠送金额
-
+
冻结金额 {{$user_wallet.frozen_money}} 一般积分交易中、提现、交易并未完成,锁定相应的积分
+
+ 赠送金额 + {{$user_wallet.give_money}} + + 所有赠送金额总额 +
{{else /}}
diff --git a/application/plugins/wallet/install.sql b/application/plugins/wallet/install.sql index 723c145cbbf8ee523678a3e08589a308134b6605..ebd09d94a570020afd69e3037a4f35d6dadd85e5 100644 --- a/application/plugins/wallet/install.sql +++ b/application/plugins/wallet/install.sql @@ -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 '添加时间', diff --git a/application/plugins/wallet/service/WalletService.php b/application/plugins/wallet/service/WalletService.php index 8b56a9d30a8343666120222272f5b6c2fa4f1766..0604e9239a904867fcded83c4fd7bbcdeabfb3be 100644 --- a/application/plugins/wallet/service/WalletService.php +++ b/application/plugins/wallet/service/WalletService.php @@ -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 diff --git a/public/static/plugins/css/wallet/index/common.css b/public/static/plugins/css/wallet/index/common.css index a2349021fa5f185a74dab8bf186c0df5a2a6c134..109835221850ea7039fa2977667c65a48b6ba972 100644 --- a/public/static/plugins/css/wallet/index/common.css +++ b/public/static/plugins/css/wallet/index/common.css @@ -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