You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB
PHP

<?php
namespace Base\Service;
class PromoteCoinTransferLogService {
public static $targetTypes = [
1 => '推广员',
2 => '玩家',
3 => '管理员',
];
public function addRecord($params)
{
$data = $this->createRecord($params);
$status = M('promote_coin_transfer_log', 'tab_')->add($data);
if ($status) {
$id = M()->getLastInsID();
return $id;
} else {
return 0;
}
}
public function getTargetTypeText($targetType, $targetLevel)
{
if ($targetType == 1) {
return PromoteService::$levels[$targetLevel] ?? '未知';
} else {
return self::$targetTypes[$targetType] ?? '未知';
}
}
public function createRecord($params)
{
$sn = '';
if (isset($params['sn'])) {
$sn = $params['sn'];
} else {
$sn = date('YmdHis').strtoupper(substr(md5(json_encode($params) . 'PromoteCoinTransferLog' . rand(0, 99999)), 8, 16));
}
$data = [];
$data['sn'] = $sn;
$data['promote_id'] = $params['promote_id'];
$data['target_type'] = $params['target_type'];
$data['target_level'] = $params['target_level'];
$data['target_id'] = $params['target_id'];
$data['game_id'] = $params['game_id'];
$data['num'] = $params['num'];
$data['status'] = 1;
$data['create_time'] = time();
$data['remark'] = isset($params['remark']) ? $params['remark'] : '';
$data['description'] = isset($params['description']) ? $params['description'] : '';
return $data;
}
}