|
|
|
@ -31,6 +31,10 @@ class Content extends Model |
|
|
|
|
'is_pay', |
|
|
|
|
'type_tag', |
|
|
|
|
]; |
|
|
|
|
protected static function init() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getStatusList() |
|
|
|
|
{ |
|
|
|
@ -42,8 +46,19 @@ class Content extends Model |
|
|
|
|
$type = ContentType::get($data['content_type_id']); |
|
|
|
|
return $type->is_pay; |
|
|
|
|
} |
|
|
|
|
protected function setMainPhoneAttr($value) |
|
|
|
|
{ |
|
|
|
|
$value = $this->maskPhoneNumber($value); |
|
|
|
|
return $value; |
|
|
|
|
} |
|
|
|
|
protected function setMainCardnoAttr($value) |
|
|
|
|
{ |
|
|
|
|
$value = $this->maskPhoneNumber($value); |
|
|
|
|
return $value; |
|
|
|
|
} |
|
|
|
|
public function getMoneyAttr($value, $data) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
//查询当前所属类型的费用 |
|
|
|
|
$type = ContentType::get($data['content_type_id']); |
|
|
|
|
if($type->is_pay){ |
|
|
|
@ -56,11 +71,7 @@ class Content extends Model |
|
|
|
|
{ |
|
|
|
|
//查询当前所属类型的费用 |
|
|
|
|
$type = ContentType::get($data['content_type_id']); |
|
|
|
|
if($type->is_pay){ |
|
|
|
|
return $type['tag']; |
|
|
|
|
}else{ |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 查询当前用户是否已经付过费 |
|
|
|
|
public function getlist($where, $order, $offset, $limit,$uid=0){ |
|
|
|
@ -131,6 +142,8 @@ class Content extends Model |
|
|
|
|
$order = Order::where(['content_id'=>$item['id'],'user_id'=>$uid,'status'=>1])->find(); |
|
|
|
|
$item['payed'] = $order||$item['user_id']==$uid?1:0; |
|
|
|
|
$item['content_tag'] = json_decode($item['content_tag'],true); |
|
|
|
|
$item['main_phone'] = $this->maskPhoneNumber($item['main_phone']); |
|
|
|
|
$item['main_cardno'] = $this->maskPhoneNumber($item['main_cardno']); |
|
|
|
|
}); |
|
|
|
|
$result = array("total" => $list->total(), "rows" => $list->items(),"sql"=>$this->fetchSql()); |
|
|
|
|
return $result; |
|
|
|
@ -142,4 +155,15 @@ class Content extends Model |
|
|
|
|
$list = $this->getStatusList(); |
|
|
|
|
return isset($list[$value]) ? $list[$value] : ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function maskPhoneNumber($idNumber) { |
|
|
|
|
// 假设身份证号码是18位,手机号码是11位,位于第11至第21位 |
|
|
|
|
if (strlen($idNumber) == 11) { |
|
|
|
|
return substr_replace($idNumber, '****', 3, 4); |
|
|
|
|
}elseif(strlen($idNumber) == 18){ |
|
|
|
|
return substr_replace($idNumber, '****', 14, 4); |
|
|
|
|
}else{ |
|
|
|
|
return $idNumber; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|