Loan.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: qisse
  5. * Date: 2017/6/27
  6. * Time: 20:02
  7. */
  8. namespace app\core\model;
  9. use think\Model;
  10. use tool\Common;
  11. class Loan extends Model
  12. {
  13. protected $pk = 'loanID';
  14. protected $resultSetType = 'collection';
  15. protected $updateTime = 'updateTime';
  16. protected $createTime = 'addTime';
  17. protected $autoWriteTimestamp = true;
  18. const STATUS_OK = 1;
  19. const STATUS_INVALID = 2;
  20. const STATUSS = [
  21. self::STATUS_OK=>'有效的',
  22. self::STATUS_INVALID=>'无效的'
  23. ];
  24. public function subjectList() {
  25. return $this->hasMany('Subject', 'loanID');
  26. }
  27. public function certTypeText($value, $data) {
  28. $text = '未知';
  29. if($data['certType'] == 1) {
  30. $text = '身份证';
  31. }
  32. else if($data['certType'] == 1){
  33. $text = '营业执照';
  34. }
  35. return $text;
  36. }
  37. public function pledgeTypeText($value, $data) {
  38. $text = '未知';
  39. if($data['pledgeType'] == 1) {
  40. $text = '车辆抵押';
  41. }
  42. return $text;
  43. }
  44. public function getStatusTextAttr($value, $data) {
  45. return self::STATUSS[$data['status']];
  46. }
  47. public function setMoneyAttr($value) {
  48. return $value * 100;
  49. }
  50. public function getMoneyAttr($value) {
  51. return Common::price2($value / 100);
  52. }
  53. }