提交 426adacf 编写于 作者: D devil_gong

细节优化

上级 22f36f06
# 充值
CREATE TABLE `s_plugins_wallet_recharge` (
`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',
`recharge_no` char(60) NOT NULL DEFAULT '' COMMENT '充值单号',
`status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '状态(0未支付, 1已支付)',
`money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '金额',
`pay_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '支付金额',
`payment_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '支付方式id',
`payment` char(60) NOT NULL DEFAULT '' COMMENT '支付方式标记',
`payment_name` char(60) NOT NULL DEFAULT '' COMMENT '支付方式名称',
`pay_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '支付时间',
`add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`),
UNIQUE KEY `recharge_no` (`recharge_no`),
KEY `status` (`status`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='钱包充值 - 应用'
# 钱包
CREATE TABLE `s_plugins_wallet` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
`status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '状态(0正常, 1异常, 2已注销)',
`normal_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '有效金额(包含赠送金额)',
`frozen_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '冻结金额',
`give_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '赠送金额(所有赠送金额总计)',
`normal_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '有效金额(包含赠送金额)',
`frozen_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '冻结金额',
`give_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '赠送金额(所有赠送金额总计)',
`add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`upd_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`),
......@@ -41,9 +21,9 @@ CREATE TABLE `s_plugins_wallet_log` (
`business_type` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '业务类型(0系统, 1充值, 2提现, 3消费)',
`money_type` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '金额类型(0正常, 1冻结, 2赠送)',
`operation_type` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '操作类型( 0减少, 1增加)',
`operation_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '操作金额',
`original_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '原始金额',
`latest_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '最新金额',
`operation_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '操作金额',
`original_money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '原始金额',
`latest_money` decimal(10,2) 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`),
......@@ -51,6 +31,26 @@ CREATE TABLE `s_plugins_wallet_log` (
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='钱包日志 - 应用';
# 充值
CREATE TABLE `s_plugins_wallet_recharge` (
`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',
`recharge_no` char(60) NOT NULL DEFAULT '' COMMENT '充值单号',
`status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '状态(0未支付, 1已支付)',
`money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '金额',
`pay_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '支付金额',
`payment_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '支付方式id',
`payment` char(60) NOT NULL DEFAULT '' COMMENT '支付方式标记',
`payment_name` char(60) NOT NULL DEFAULT '' COMMENT '支付方式名称',
`pay_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '支付时间',
`add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`),
UNIQUE KEY `recharge_no` (`recharge_no`),
KEY `status` (`status`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='钱包充值 - 应用';
# 钱包提现
CREATE TABLE `s_plugins_wallet_cash` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
......
......@@ -271,5 +271,78 @@ class WalletService
Db::commit();
return DataReturn('操作成功', 0);
}
/**
* 用户钱包有效金额更新
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-06-10
* @desc description
* @param [int] $user_id [用户id]
* @param [float] $money [操作金额]
* @param [int] $type [类型(0减少, 1增加)]
* @param [string] $field [金额字段, 默认normal_money有效金额, frozen_money冻结金额, give_money赠送金额]
* @param [int] $business_type [业务类型(0系统, 1充值, 2提现, 3消费)]
* @param [string] $msg_title [附加描述标题]
*/
public static function UserWalletMoneyUpdate($user_id, $money, $type, $field = 'normal_money', $business_type = 0, $msg_title = '钱包变更')
{
// 获取用户钱包
$wallet = self::UserWallet($user_id);
if($wallet['code'] == 0)
{
// 金额字段
$money_field = ['normal_money' => 0, 'frozen_money '=> 1, 'give_money' => 2];
if(!in_array($field, $money_field))
{
return DataReturn('钱包操作金额字段有误', -10);
}
// 操作金额
$money = PriceNumberFormat($money);
// 开始处理
Db::startTrans();
// 钱包数据
$data = [
$field => ($type == 1) ? PriceNumberFormat($wallet['data'][$field]+$money) : PriceNumberFormat($wallet['data'][$field]-$money),
'upd_time' => time(),
];
if(!Db::name('PluginsWallet')->where(['id'=>$wallet['data']['id']])->update($data))
{
Db::rollback();
return DataReturn('钱包操作失败', -100);
}
// 日志
$log_data = [
'user_id' => $wallet['data']['user_id'],
'wallet_id' => $wallet['data']['id'],
'business_type' => $business_type,
'operation_type' => $type,
'money_type' => $money_field[$field],
'operation_money' => $money,
'original_money' => $wallet['data'][$field],
'latest_money' => $data[$field],
];
$operation_type_text = ($log_data['operation_type'] == 1) ? '增加' : '减少';
$log_data['msg'] = $msg_title.' [ '.self::$money_type_list[$log_data['money_type']]['name'].'金额'.$operation_type_text.$log_data['operation_money'].'元 ]';
if(!self::WalletLogInsert($log_data))
{
Db::rollback();
return DataReturn('钱包日志添加失败', -101);
}
// 消息通知
MessageService::MessageAdd($wallet['data']['user_id'], '钱包变更', $log_data['msg'], 0, $wallet['data']['id']);
// 处理成功
Db::commit();
return DataReturn('操作成功', 0);
}
return $wallet;
}
}
?>
\ No newline at end of file
......@@ -837,6 +837,20 @@ class OrderAftersaleService
return DataReturn('售后订单更新失败', -60);
}
// 订单售后审核处理完毕钩子
$hook_name = 'plugins_service_order_aftersale_audit_handle_end';
$ret = Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'params' => $params,
'order_id' => $order['data']['id'],
]);
if(isset($ret['code']) && $ret['code'] != 0)
{
Db::rollback();
return $ret;
}
// 提交事务
Db::commit();
return DataReturn('退款成功', 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册