| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Models;
- use Illuminate\Support\Facades\DB;
- /**
- * 账户明细-模型
- * @author laravel开发员
- * @since 2020/11/10
- * Class ActionLogModel
- * @package App\Models
- */
- 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';
- } else {
- $this->table = $table;
- }
- $this->initTable();
- }
- /**
- * 获取表
- * @param $date
- * @return bool
- */
- public function getTable($date='')
- {
- if($date){
- $tbl = env('DB_PREFIX', 'lev_') .'account_log';
- return $this->tableExists($tbl)? 'account_log':'';
- }
- return $this->table;
- }
- /**
- * 用户
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function member()
- {
- return $this->hasOne(MemberModel::class, 'id','user_id')
- ->where(['mark'=>1])
- ->select(['id','nickname as name','mobile']);
- }
- /**
- * 司机
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function driver()
- {
- return $this->hasOne(DriverModel::class, 'id','user_id')
- ->where(['mark'=>1])
- ->select(['id','realname as name','mobile']);
- }
- /**
- *
- * @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(10) NOT NULL DEFAULT '0' COMMENT '用户ID/司机ID',
- `source_id` int(10) 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-平台',
- `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '交易类型:1-普通消费,2-VIP升级消费,3-分销佣金,4-平台调整,5-充值,6-诚意金,7-退款,8-余额提现,9-接单收入,10-在线奖金,11-红包奖励,12-在线奖金提现,99-其他',
- `coin_type` tinyint(2) NOT NULL DEFAULT '1' COMMENT '币种账户类型:1-人民币,3-通证积分,4-余额,5-奖励,99-其他',
- `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(10) NOT NULL DEFAULT '0',
- `update_time` int(10) NOT NULL DEFAULT '0',
- `transaction_id` varchar(64) 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 `source_id` (`source_id`),
- 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;
- }
- }
|