ztt 10 months ago
parent 2b478e2e97
commit 81f81d4f52
  1. 52
      addons/shopro/controller/user/WalletLog.php
  2. 8
      application/admin/model/shopro/user/WalletLog.php

@ -3,7 +3,9 @@
namespace addons\shopro\controller\user; namespace addons\shopro\controller\user;
use addons\shopro\controller\Common; use addons\shopro\controller\Common;
use addons\shopro\service\Wallet as WalletService;
use app\admin\model\shopro\user\WalletLog as UserWalletLogModel; use app\admin\model\shopro\user\WalletLog as UserWalletLogModel;
use think\Db;
class WalletLog extends Common class WalletLog extends Common
{ {
@ -35,4 +37,54 @@ class WalletLog extends Common
$logs = UserWalletLogModel::where($where)->{$type}()->whereTime('createtime', 'between', $date)->order('createtime', 'desc')->paginate($list_rows); $logs = UserWalletLogModel::where($where)->{$type}()->whereTime('createtime', 'between', $date)->order('createtime', 'desc')->paginate($list_rows);
$this->success('获取成功', ['list' => $logs, 'income' => $income, 'expense' => $expense]); $this->success('获取成功', ['list' => $logs, 'income' => $income, 'expense' => $expense]);
} }
/**
* 用户充值积分
*/
public function recharge()
{
$params = $this->request->only(['type', 'amount']);
if (!in_array($params['type'], ['money', 'score'])) {
$this->error('参数错误');
}
$user = auth_user();
$user_id = $user->id;
$result = Db::transaction(function () use ($params, $user_id) {
return WalletService::change($user_id, $params['type'], $params['amount'], 'admin_recharge', [], '积分充值');
});
if ($result) {
$this->success('充值成功');
}
$this->error('充值失败');
}
/**
* 用户转让积分
*/
public function exchange() {
$params = $this->request->only(['type', 'exchange_amount', 'exchange_phone', 'code']);
if (!in_array($params['type'], ['money', 'score'])) {
$this->error('参数错误');
}
$user = auth_user();
$user_id = $user->id;
$exchange_user = \app\common\model\User::get(['phone' => $params['exchange_phone']]);
if (!$exchange_user) {
$this->error('转让人不存在');
}
$exchange_user_id = $exchange_user->id;
$result = Db::transaction(function () use ($params, $exchange_user_id, $user_id) {
WalletService::change($user_id, $params['type'], -$params['amount'], 'user_exchange', [], '积分转让');
return WalletService::change($exchange_user_id, $params['type'], $params['amount'], 'user_exchange', [], '积分转让');
});
if ($result) {
$this->success('转让成功');
}
$this->error('转让失败');
}
} }

@ -30,10 +30,14 @@ class WalletLog extends Common
'replenish_signin' => '签到-补签', 'replenish_signin' => '签到-补签',
'activity_gift' => '活动-赠送积分', 'activity_gift' => '活动-赠送积分',
'score_shop_pay' => '积分商城-积分支付', 'score_shop_pay' => '积分商城-积分支付',
'order_pay' => '商城订单-积分抵扣', // 'order_pay' => '商城订单-积分抵扣',
'order_pay' => '个人下单',
'order_refund' => '订单退款-退还积分', 'order_refund' => '订单退款-退还积分',
'admin_recharge' => '后台-积分充值', 'admin_recharge' => '后台-积分充值',
'recharge_gift' => '线上充值-赠送积分' 'recharge_gift' => '线上充值-赠送积分',
'user_recharge' => '积分充值',
'user_exchange' => '积分转让',
'team_order' => '团队下单',
], ],
'money' => [ 'money' => [
'order_pay' => '商城订单-余额支付', 'order_pay' => '商城订单-余额支付',

Loading…
Cancel
Save