修改余额

This commit is contained in:
邹景立 2021-03-16 16:41:16 +08:00
parent 19b7ff8f7c
commit afb4828477
2 changed files with 3 additions and 3 deletions

View File

@ -74,7 +74,7 @@ class UserBalance extends Controller
protected function _form_filter(array &$data) protected function _form_filter(array &$data)
{ {
if (empty($data['code'])) { if (empty($data['code'])) {
$data['code'] = CodeExtend::uniqidDate('16', 'B'); $data['code'] = CodeExtend::uniqidDate('20', 'B');
} }
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data['create_by'] = AdminService::instance()->getUserId(); $data['create_by'] = AdminService::instance()->getUserId();

View File

@ -93,8 +93,8 @@ class UserUpgradeService extends Service
*/ */
public function syncBalance(int $uuid, array $nots = []): array public function syncBalance(int $uuid, array $nots = []): array
{ {
$total = abs($this->app->db->name('DataUserBalance')->where("uid='{$uuid}' and status=1 and amount>0 and deleted=0")->sum('amount')); $total = abs($this->app->db->name('DataUserBalance')->where("uid='{$uuid}' and amount>0 and deleted=0")->sum('amount'));
$count = abs($this->app->db->name('DataUserBalance')->where("uid='{$uuid}' and status=1 and amount<0 and deleted=0")->sum('amount')); $count = abs($this->app->db->name('DataUserBalance')->where("uid='{$uuid}' and amount<0 and deleted=0")->sum('amount'));
if (empty($nots)) { if (empty($nots)) {
$this->app->db->name('DataUser')->where(['id' => $uuid])->update(['balance_total' => $total, 'balance_used' => $count]); $this->app->db->name('DataUser')->where(['id' => $uuid])->update(['balance_total' => $total, 'balance_used' => $count]);
} else { } else {