1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\common\model;
- use think\Model;
- /**
- * 会员余额日志模型
- */
- class MoneyLog Extends Model
- {
- // 表名
- protected $name = 'user_money_log';
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = '';
- // 追加属性
- protected $append = [
- 'type_text',
- ];
- const TYPE_ORDER_PAY=1;
- const TYPE_CHARGE=2;
- const TYPE_TAKECASH=3;
- const TYPE_SETTLE=4;
- const TYPE_PROFIT=5;
- const TYPE_REFUND=6;
- const TYPE_TAKECASH_REJECT=7;
- const ADMIN=8;
- public static $types=[
- self::TYPE_ORDER_PAY=>'订单支付',
- self::TYPE_CHARGE=>'充值',
- self::TYPE_TAKECASH=>'提现',
- self::TYPE_TAKECASH_REJECT=>'提现驳回',
- self::TYPE_SETTLE=>'订单结算',
- self::TYPE_PROFIT=>'盈利',
- self::TYPE_REFUND=>'退款',
- self::ADMIN=>'后台变更',
- ];
- public function user(){
- return $this->belongsTo(User::class);
- }
- public function getTypeTextAttr($v, $d)
- {
- return self::$types[$d['type']]??'-';
- }
- /* protected static function init()
- {
- self::afterInsert(function (self $log){
- #结算的时候新增一条盈利记录
- if($log['type']==self::TYPE_SETTLE){
- $order=UserOrder::where('id',$log['order_id'])->find();
- if($order){
- self::create([
- 'type'=>self::TYPE_PROFIT,
- 'money'=>$log['money'],
- ]);
- }
- }
- });
- }*/
- }
|