mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-01 03:18:33 +08:00
钱包管理
This commit is contained in:
parent
c8c8d8e7a4
commit
491fc4c757
@ -9,53 +9,57 @@
|
||||
</legend>
|
||||
|
||||
<div class="wallet-content">
|
||||
<!-- form start -->
|
||||
<form class="am-form form-validation view-save" action="{{:PluginsAdminUrl('wallet', 'level', 'save')}}" method="POST" request-type="ajax-url" request-value="{{:PluginsAdminUrl('wallet', 'walletadmin', 'index')}}" enctype="multipart/form-data">
|
||||
<div class="am-alert am-alert-secondary saveinfo-view" data-am-alert="">
|
||||
<div>
|
||||
<span>有效金额:</span>
|
||||
<span class="normal-money">{{$data.normal_money}}</span>
|
||||
{{if !empty($data)}}
|
||||
<!-- form start -->
|
||||
<form class="am-form form-validation view-save" action="{{:PluginsAdminUrl('wallet', 'walletadmin', 'save')}}" method="POST" request-type="ajax-url" request-value="{{:PluginsAdminUrl('wallet', 'walletadmin', 'index')}}" enctype="multipart/form-data">
|
||||
<div class="am-alert am-alert-secondary saveinfo-view" data-am-alert="">
|
||||
<div>
|
||||
<span>有效金额:</span>
|
||||
<span class="normal-money">{{$data.normal_money}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>冻结金额:</span>
|
||||
<span class="frozen-money">{{$data.frozen_money}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>赠送金额:</span>
|
||||
<span class="give-money">{{$data.give_money}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<span>冻结金额:</span>
|
||||
<span class="frozen-money">{{$data.frozen_money}}</span>
|
||||
<div class="am-form-group">
|
||||
<label>有效金额<span class="am-form-group-label-tips">包含赠送金额,最多两位小数</span></label>
|
||||
<input type="text" name="normal_money" placeholder="有效金额" pattern="^([0-9]{1}\d{0,6})(\.\d{1,2})?$" data-validation-message="请输入有效的有效金额" class="am-radius" {{if !empty($data['normal_money']) and $data['normal_money'] gt 0}} value="{{$data.normal_money}}"{{/if}} />
|
||||
</div>
|
||||
<div>
|
||||
<span>赠送金额:</span>
|
||||
<span class="give-money">{{$data.give_money}}</span>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>冻结金额<span class="am-form-group-label-tips">最多两位小数</span></label>
|
||||
<input type="text" name="frozen_money" placeholder="冻结金额" pattern="^([0-9]{1}\d{0,6})(\.\d{1,2})?$" data-validation-message="请输入有效的冻结金额" class="am-radius" {{if !empty($data['frozen_money']) and $data['frozen_money'] gt 0}} value="{{$data.frozen_money}}"{{/if}} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label>有效金额<span class="am-form-group-label-tips">包含赠送金额</span></label>
|
||||
<input type="number" name="normal_money" placeholder="有效金额" step="0.01" min="0.00" data-validation-message="请输入有效的有效金额" class="am-radius" {{if !empty($data['normal_money']) and $data['normal_money'] gt 0}} value="{{$data.normal_money}}"{{/if}} />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>冻结金额</label>
|
||||
<input type="number" name="frozen_money" placeholder="冻结金额" step="0.01" min="0.00" data-validation-message="请输入有效的冻结金额" class="am-radius" {{if !empty($data['frozen_money']) and $data['frozen_money'] gt 0}} value="{{$data.frozen_money}}"{{/if}} />
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label>赠送金额<span class="am-form-group-label-tips">最多两位小数</span></label>
|
||||
<input type="text" name="give_money" placeholder="赠送金额" pattern="^([0-9]{1}\d{0,6})(\.\d{1,2})?$" data-validation-message="请输入有效的赠送金额" class="am-radius" {{if !empty($data['give_money']) and $data['give_money'] gt 0}} value="{{$data.give_money}}"{{/if}} />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>赠送金额</label>
|
||||
<input type="number" name="give_money" placeholder="赠送金额" step="0.01" min="0.00" data-validation-message="请输入有效的赠送金额" class="am-radius" {{if !empty($data['give_money']) and $data['give_money'] gt 0}} value="{{$data.give_money}}"{{/if}} />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>状态</label>
|
||||
<select name="status" class="am-radius chosen-select" data-validation-message="请选择状态" required>
|
||||
{{foreach $wallet_status_list as $v}}
|
||||
<option value="{{$v.value}}" {{if isset($data['status']) and $data['status'] eq $v['value']}}selected{{else /}}{{if !isset($data['status']) and isset($v['checked']) and $v['checked'] eq true}}selected{{/if}}{{/if}}>{{$v.name}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label>状态</label>
|
||||
<select name="status" class="am-radius chosen-select" data-validation-message="请选择状态" required>
|
||||
{{foreach $wallet_status_list as $v}}
|
||||
<option value="{{$v.value}}" {{if isset($data['status']) and $data['status'] eq $v['value']}}selected{{else /}}{{if !isset($data['status']) and isset($v['checked']) and $v['checked'] eq true}}selected{{/if}}{{/if}}>{{$v.name}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="am-form-group am-form-group-refreshing">
|
||||
<input type="hidden" name="id" {{if !empty($data['id'])}} value="{{$data.id}}"{{/if}} />
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">保存</button>
|
||||
</div>
|
||||
</form>
|
||||
<!-- form end -->
|
||||
<div class="am-form-group am-form-group-refreshing">
|
||||
<input type="hidden" name="id" {{if !empty($data['id'])}} value="{{$data.id}}"{{/if}} />
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">保存</button>
|
||||
</div>
|
||||
</form>
|
||||
<!-- form end -->
|
||||
{{else /}}
|
||||
<div class="table-no"><i class="am-icon-warning"></i> {{$msg}}</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -86,6 +86,7 @@ class Walletadmin extends Controller
|
||||
*/
|
||||
public function saveinfo($params = [])
|
||||
{
|
||||
$data = [];
|
||||
if(!empty($params['id']))
|
||||
{
|
||||
$data_params = array(
|
||||
@ -93,20 +94,36 @@ class Walletadmin extends Controller
|
||||
'n' => 1,
|
||||
'where' => ['id'=>intval($params['id'])],
|
||||
);
|
||||
$data = WalletService::WalletList($data_params);
|
||||
if(empty($data['data'][0]))
|
||||
$ret = WalletService::WalletList($data_params);
|
||||
if(!empty($ret['data'][0]))
|
||||
{
|
||||
return '钱包有误';
|
||||
$data = $ret['data'][0];
|
||||
|
||||
// 静态数据
|
||||
$this->assign('wallet_status_list', WalletService::$wallet_status_list);
|
||||
} else {
|
||||
$this->assign('msg', '钱包有误');
|
||||
}
|
||||
$this->assign('data', $data['data'][0]);
|
||||
|
||||
// 静态数据
|
||||
$this->assign('wallet_status_list', WalletService::$wallet_status_list);
|
||||
|
||||
return $this->fetch('../../../plugins/view/wallet/walletadmin/saveinfo');
|
||||
} else {
|
||||
return '钱包id有误';
|
||||
$this->assign('msg', '钱包id有误');
|
||||
}
|
||||
|
||||
$this->assign('data', $data);
|
||||
return $this->fetch('../../../plugins/view/wallet/walletadmin/saveinfo');
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱包编辑
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2019-05-06
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function save($params = [])
|
||||
{
|
||||
return WalletService::WalletEdit($params);
|
||||
}
|
||||
}
|
||||
?>
|
@ -36,13 +36,13 @@ CREATE TABLE `s_plugins_wallet_log` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
|
||||
`wallet_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '钱包id',
|
||||
`business_type` tinyint(2) NOT NULL DEFAULT '-1' COMMENT '业务类型(-1未知, 0充值, 1提现, 2消费)',
|
||||
`operation_type` tinyint(2) NOT NULL DEFAULT '-1' COMMENT '操作类型(-1未知, 0减少, 1增加)',
|
||||
`money_type` tinyint(2) NOT NULL DEFAULT '-1' COMMENT '金额类型(-1未知, 0正常, 1冻结)',
|
||||
`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` 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 '添加时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `wallet_id` (`wallet_id`),
|
||||
KEY `user_id` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='钱包日志 - 应用';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='钱包日志 - 应用'
|
@ -33,9 +33,10 @@ class WalletService
|
||||
|
||||
// 业务类型
|
||||
public static $business_type_list = [
|
||||
0 => ['value' => 0, 'name' => '充值', 'checked' => true],
|
||||
1 => ['value' => 1, 'name' => '提现'],
|
||||
2 => ['value' => 2, 'name' => '消费'],
|
||||
0 => ['value' => 0, 'name' => '系统', 'checked' => true],
|
||||
1 => ['value' => 1, 'name' => '充值'],
|
||||
2 => ['value' => 2, 'name' => '提现'],
|
||||
3 => ['value' => 3, 'name' => '消费'],
|
||||
];
|
||||
|
||||
// 操作类型
|
||||
@ -48,6 +49,7 @@ class WalletService
|
||||
public static $money_type_list = [
|
||||
0 => ['value' => 0, 'name' => '正常', 'checked' => true],
|
||||
1 => ['value' => 1, 'name' => '冻结'],
|
||||
2 => ['value' => 2, 'name' => '赠送'],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -220,5 +222,92 @@ class WalletService
|
||||
|
||||
return DataReturn('操作成功', 0, $wallet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱包编辑
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2019-05-06
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function WalletEdit($params = [])
|
||||
{
|
||||
// 请求参数
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'id',
|
||||
'error_msg' => '钱包id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'in',
|
||||
'key_name' => 'status',
|
||||
'checked_data' => array_column(self::$wallet_status_list, 'value'),
|
||||
'error_msg' => '钱包状态有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'fun',
|
||||
'key_name' => 'normal_money',
|
||||
'checked_data' => 'CheckPrice',
|
||||
'is_checked' => 1,
|
||||
'error_msg' => '有效金额格式有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'fun',
|
||||
'key_name' => 'frozen_money',
|
||||
'checked_data' => 'CheckPrice',
|
||||
'is_checked' => 1,
|
||||
'error_msg' => '冻结金额格式有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'fun',
|
||||
'key_name' => 'give_money',
|
||||
'checked_data' => 'CheckPrice',
|
||||
'is_checked' => 1,
|
||||
'error_msg' => '赠送金额格式有误',
|
||||
],
|
||||
];
|
||||
$ret = ParamsChecked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 获取钱包
|
||||
$wallet = Db::name('PluginsWallet')->find(intval($params['id']));
|
||||
if(empty($wallet))
|
||||
{
|
||||
return DataReturn('钱包不存在或已删除', -10);
|
||||
}
|
||||
|
||||
// 数据
|
||||
$data = [
|
||||
'status' => intval($params['status']),
|
||||
'normal_money' => empty($params['normal_money']) ? 0.00 : PriceNumberFormat($params['normal_money']),
|
||||
'frozen_money' => empty($params['frozen_money']) ? 0.00 : PriceNumberFormat($params['frozen_money']),
|
||||
'give_money' => empty($params['give_money']) ? 0.00 : PriceNumberFormat($params['give_money']),
|
||||
'upd_time' => time(),
|
||||
];
|
||||
|
||||
// 日志
|
||||
$log_data = [];
|
||||
if($wallet['normal_money'] != $data['normal_money'])
|
||||
{
|
||||
$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(),
|
||||
];
|
||||
}
|
||||
print_r($data);
|
||||
print_r($log_data);
|
||||
}
|
||||
}
|
||||
?>
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user