first commit
This commit is contained in:
71
application/common/model/VipOrder.php
Normal file
71
application/common/model/VipOrder.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\common\model;
|
||||
|
||||
use tools\Str;
|
||||
|
||||
class VipOrder extends _Init
|
||||
{
|
||||
/**
|
||||
* 模型初始化【事件注册】
|
||||
*/
|
||||
protected static function init()
|
||||
{
|
||||
self::beforeInsert(function ($data) {
|
||||
$data->orderid = ($data['type'] == 'vip') ? Str::orderid('VIP') : Str::orderid('Agent');
|
||||
});
|
||||
}
|
||||
|
||||
public function getStatusAttr($value)
|
||||
{
|
||||
switch ($value) {
|
||||
case '0':
|
||||
return '<span style="color:red">未支付</span>';
|
||||
break;
|
||||
case '20':
|
||||
return '<span style="color:green">已支付</span>';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getModelAttr($value, $data)
|
||||
{
|
||||
if ($data['model'] == 'weixin') {
|
||||
return '微信支付';
|
||||
} else {
|
||||
return '未知';
|
||||
}
|
||||
}
|
||||
|
||||
public function getTypeTextAttr($value, $data)
|
||||
{
|
||||
switch ($data['type']) {
|
||||
case 'vip':
|
||||
return "会员";
|
||||
break;
|
||||
case 'agent':
|
||||
return "代理商";
|
||||
break;
|
||||
default:
|
||||
return "未知";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('MemberInfo', 'uid', 'uid');
|
||||
}
|
||||
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo('Member', 'uid', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user