feat: 完善会员资金明细与退款转账逻辑,新增支付密码组件与资金流水界面
这个提交包含在:
@@ -606,12 +606,16 @@ class V1 extends Api
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
/** 记一条资金流水 */
|
||||
protected function flow($type, $scene, $amount, $balance, $relatedId = 0, $remark = '')
|
||||
/**
|
||||
* 记一条资金流水(含归属用户,供余额中心按用户查询)
|
||||
* @param int $userId 归属用户 ID(0=平台/不可归属)
|
||||
*/
|
||||
protected function flow($type, $scene, $amount, $balance, $relatedId = 0, $remark = '', $userId = 0)
|
||||
{
|
||||
static $seq = 0;
|
||||
$seq++;
|
||||
Db::name('fc_finance_flow')->insert([
|
||||
'user_id' => (int)$userId,
|
||||
'flow_no' => 'F' . date('YmdHis') . bin2hex(random_bytes(4)) . $seq,
|
||||
'type' => $type,
|
||||
'scene' => $scene,
|
||||
@@ -623,6 +627,55 @@ class V1 extends Api
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记一条「用户钱包流水」(fc_wallet_flow)
|
||||
* 仅在 fa_user.money 发生增减时调用——余额中心的「余额明细」数据源。
|
||||
* 平台对账口径(微信收入等)继续走 flow() / fc_finance_flow。
|
||||
* @param int $userId 用户 ID
|
||||
* @param string $type income=入账 expense=支出(用户钱包口径)
|
||||
* @param string $scene 场景:余额充值/后台充值/会员开通/发布付费/付费查看/订单退款(余额)/佣金提现
|
||||
* @param float $amount 变动金额(正数)
|
||||
* @param float $balance 变动后钱包余额
|
||||
*/
|
||||
protected function walletFlow($userId, $type, $scene, $amount, $balance, $relatedId = 0, $remark = '')
|
||||
{
|
||||
Db::name('fc_wallet_flow')->insert([
|
||||
'user_id' => (int)$userId,
|
||||
'flow_no' => 'W' . date('YmdHis') . bin2hex(random_bytes(4)),
|
||||
'type' => $type,
|
||||
'scene' => $scene,
|
||||
'amount' => $amount,
|
||||
'balance' => $balance,
|
||||
'related_id' => (int)$relatedId,
|
||||
'remark' => $remark,
|
||||
'createtime' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额支付前的支付密码校验(开关关闭时直接放行)
|
||||
* 规则:后台开启「支付密码」后,所有余额支付必须携带正确的 payPassword;
|
||||
* 未设置过密码时提示先设置(余额中心 → 支付密码)。
|
||||
*/
|
||||
protected function verifyPayPassword($user)
|
||||
{
|
||||
if (!(int)$this->cfg('pay.payPasswordEnabled', 0)) {
|
||||
return;
|
||||
}
|
||||
$ext = $this->ext($user['id']);
|
||||
$hash = (string)(isset($ext['pay_password']) ? $ext['pay_password'] : '');
|
||||
if ($hash === '') {
|
||||
$this->fail('请先在「余额中心」设置支付密码');
|
||||
}
|
||||
$pwd = trim((string)$this->input('payPassword', ''));
|
||||
if ($pwd === '') {
|
||||
$this->fail('请输入支付密码');
|
||||
}
|
||||
if (!preg_match('/^\d{6}$/', $pwd) || !password_verify($pwd, $hash)) {
|
||||
$this->fail('支付密码错误');
|
||||
}
|
||||
}
|
||||
|
||||
/** 发一条站内消息 */
|
||||
protected function notify($userId, $type, $title, $content)
|
||||
{
|
||||
|
||||
在新工单中引用
屏蔽一个用户