|
|
@@ -15,7 +15,7 @@ use App\Services\RedisService;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
/**
|
|
|
- * 行为日志-模型
|
|
|
+ * 账户明细-模型
|
|
|
* @author laravel开发员
|
|
|
* @since 2020/11/10
|
|
|
* Class ActionLogModel
|
|
|
@@ -24,116 +24,6 @@ use Illuminate\Support\Facades\DB;
|
|
|
class AccountLogModel extends BaseModel
|
|
|
{
|
|
|
// 设置数据表
|
|
|
- protected $table = null;
|
|
|
- // 自定义日志标题
|
|
|
- protected static $title = '';
|
|
|
- // 自定义日志内容
|
|
|
- protected static $content = '';
|
|
|
-
|
|
|
- public function __construct($table = null)
|
|
|
- {
|
|
|
- if ($table == null) {
|
|
|
- // 设置表名
|
|
|
- $this->table = 'account_log_' . date('Y');
|
|
|
- } else {
|
|
|
- $this->table = $table;
|
|
|
- }
|
|
|
-
|
|
|
- $this->initTable();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取表
|
|
|
- * @param $date
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- public function getTable($date='')
|
|
|
- {
|
|
|
-
|
|
|
- if($date){
|
|
|
- $tbl = env('DB_PREFIX', 'lev_') .'account_log_'. $date;
|
|
|
- return $this->tableExists($tbl)? 'account_log_'. $date : '';
|
|
|
- }
|
|
|
- return $this->table;
|
|
|
- }
|
|
|
-
|
|
|
- public function getTables()
|
|
|
- {
|
|
|
- $cacheKey = "caches:config:account_tables";
|
|
|
- $data = RedisService::get($cacheKey);
|
|
|
- if($data){
|
|
|
- return $data;
|
|
|
- }
|
|
|
-
|
|
|
- $tables = parent::getTablesList();
|
|
|
- $accountTables = [];
|
|
|
- if(empty($tables)){
|
|
|
- $accountTables = [$this->table];
|
|
|
- }else{
|
|
|
- foreach ($tables as $table){
|
|
|
- if(preg_match("/^account_log/", $table)){
|
|
|
- $accountTables[] = $table;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if($accountTables){
|
|
|
- krsort($accountTables);
|
|
|
- RedisService::set($cacheKey, $accountTables, rand(10, 20));
|
|
|
- }
|
|
|
-
|
|
|
- return $accountTables;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 初始化行为日志表
|
|
|
- * @return string|null
|
|
|
- * @since 2020/11/10
|
|
|
- * @author laravel开发员
|
|
|
- */
|
|
|
- protected function initTable()
|
|
|
- {
|
|
|
- $tbl = env('DB_PREFIX', 'lev_') . $this->table;
|
|
|
- try {
|
|
|
- if (!$this->tableExists($tbl)) {
|
|
|
- $sql = "CREATE TABLE `{$tbl}` (
|
|
|
- `id` int(10) NOT NULL AUTO_INCREMENT,
|
|
|
- `user_id` int NOT NULL DEFAULT '0' COMMENT '用户ID',
|
|
|
- `merch_id` int NOT NULL DEFAULT '0' COMMENT '来源商家ID',
|
|
|
- `source_uid` int NOT NULL DEFAULT '0' COMMENT '来源关联用户ID',
|
|
|
- `source_order_no` varchar(30) NOT NULL DEFAULT '' COMMENT '来源订单号',
|
|
|
- `user_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '账户类型:1-用户,2-商家,3-技师,4-代理,5-平台',
|
|
|
- `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '交易类型:1-商城消费,2-服务消费,3-分销佣金/工资/商家收入,4-平台调整,5-充值,6-转账,7-消费退款,8-聊天付费,9-招聘付费,10-代理佣金,11-用户提现,12-商家提现,13-平台收入,14-商家保证金,99-其他',
|
|
|
- `coin_type` tinyint NOT NULL DEFAULT '1' COMMENT '币种账户类型:1-人民币,2-佣金,3-积分,4-余额,5-收益,6-其他',
|
|
|
- `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '金额',
|
|
|
- `balance` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '更改前余额',
|
|
|
- `date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
- `create_time` int NOT NULL DEFAULT '0',
|
|
|
- `update_time` int NOT NULL DEFAULT '0',
|
|
|
- `transaction_id` varchar(64) NOT NULL DEFAULT '' COMMENT '涉及支付交易单号',
|
|
|
- `review_remark` varchar(150) NOT NULL DEFAULT '' COMMENT '审核备注',
|
|
|
- `remark` varchar(150) NOT NULL DEFAULT '' COMMENT '备注',
|
|
|
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态:1-已完成,2-待处理,3-失败/取消',
|
|
|
- `mark` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否有效:1-是,0-否',
|
|
|
- PRIMARY KEY (`id`),
|
|
|
- KEY `user_id` (`user_id`),
|
|
|
- KEY `shop_id` (`merch_id`),
|
|
|
- KEY `source_uid` (`source_uid`),
|
|
|
- KEY `type` (`type`),
|
|
|
- KEY `coin_type` (`coin_type`),
|
|
|
- KEY `mark` (`mark`),
|
|
|
- KEY `status` (`status`)
|
|
|
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='账户明细表';";
|
|
|
-
|
|
|
- DB::select($sql);
|
|
|
- }
|
|
|
- } catch (\Exception $exception){
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return $tbl;
|
|
|
- }
|
|
|
+ protected $table = 'account_log';
|
|
|
|
|
|
}
|