You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
3.9 KiB
122 lines
3.9 KiB
<?php
|
|
|
|
namespace App\Service;
|
|
|
|
use App\Model\FinancialRecord;
|
|
|
|
class FinancialRecordService implements FinancialRecordServiceInterface
|
|
{
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function communityAwardByPlatNewUser($user_id, $source_id, $money, $user_type=2, $source_type=1, $money_type=1, $desc='新用户奖励', $comment='社区服务点')
|
|
{
|
|
$this->record(
|
|
$user_id,
|
|
[
|
|
'user_id' => $user_id,
|
|
'user_type' => $user_type,
|
|
'money' => $money,
|
|
'money_type' => $money_type,
|
|
'source_id' => $source_id,
|
|
'source_type' => $source_type,
|
|
'desc' => $desc,
|
|
'comment' => $comment,
|
|
'status' => FinancialRecord::STATUS_NORMAL,
|
|
]
|
|
);
|
|
|
|
$this->ledgerAccounts($source_id, $money, $source_type, $money_type, $desc, $comment);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function communityAwardByPlatNewUserFirstOLOrder($user_id, $source_id, $money, $user_type=2, $source_type=1, $money_type=1, $desc='新用户首单奖励', $comment='社区服务点')
|
|
{
|
|
$this->record(
|
|
$user_id,
|
|
[
|
|
'user_id' => $user_id,
|
|
'user_type' => $user_type,
|
|
'money' => $money,
|
|
'money_type' => $money_type,
|
|
'source_id' => $source_id,
|
|
'source_type' => $source_type,
|
|
'desc' => $desc,
|
|
'comment' => $comment,
|
|
'status' => FinancialRecord::STATUS_NORMAL,
|
|
]
|
|
);
|
|
|
|
$this->ledgerAccounts($source_id, $money, $source_type, $money_type, $desc, $comment);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function communitySeparateAccountsByOrderComp($user_id, $source_id, $money, $user_type=2, $source_type=1, $money_type=2, $desc='用户订单分成', $comment='社区服务点')
|
|
{
|
|
$this->record(
|
|
$user_id,
|
|
[
|
|
'user_id' => $user_id,
|
|
'user_type' => $user_type,
|
|
'money' => $money,
|
|
'money_type' => $money_type,
|
|
'source_id' => $source_id,
|
|
'source_type' => $source_type,
|
|
'desc' => $desc,
|
|
'comment' => $comment,
|
|
'status' => FinancialRecord::STATUS_NORMAL,
|
|
]
|
|
);
|
|
|
|
$this->ledgerAccounts($source_id, $money, $source_type, $money_type, $desc, $comment);
|
|
}
|
|
|
|
public function ledgerAccounts($source_id, $money, $source_type, $money_type, $desc, $comment='')
|
|
{
|
|
return $this->record(
|
|
FinancialRecord::ACCOUNT_LEDGER,
|
|
[
|
|
'user_id' => FinancialRecord::ACCOUNT_LEDGER,
|
|
'user_type' => FinancialRecord::USER_TYPE_LEDGER,
|
|
'money' => $money,
|
|
'money_type' => $money_type,
|
|
'source_id' => $source_id,
|
|
'source_type' => $source_type,
|
|
'desc' => $desc,
|
|
'comment' => $comment,
|
|
'status' => FinancialRecord::STATUS_NORMAL,
|
|
],
|
|
true
|
|
);
|
|
}
|
|
|
|
public function record($user_id, $record, $isLedger=false)
|
|
{
|
|
$financialRecord = new FinancialRecord();
|
|
|
|
if (!$isLedger) {
|
|
$mod = bcmod((string)$user_id, '5', 0);
|
|
$financialRecord->suffix($mod);
|
|
}
|
|
|
|
return $financialRecord->fill(
|
|
[
|
|
'user_id' => $user_id,
|
|
'user_type' => $record['user_type'],
|
|
'money' => $record['money'],
|
|
'money_type' => $record['money_type'],
|
|
'source_id' => $record['source_id'],
|
|
'source_type' => $record['source_type'],
|
|
'desc' => $record['desc'],
|
|
'comment' => $record['comment'],
|
|
'status' => $record['status'],
|
|
]
|
|
)->save();
|
|
|
|
}
|
|
}
|