UserFinance.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 UserFinance extends Model
  12. {
  13. protected $resultSetType = 'collection';
  14. protected $updateTime = 'updateTime';
  15. protected $createTime = 'addTime';
  16. protected $autoWriteTimestamp = true;
  17. const MODE_RECHARGE = 'MODE_RECHARGE';//充值
  18. const MODE_DRAWCASH = 'MODE_DRAWCASH';//提现
  19. const MODE_CANG = 'MODE_CANG';//下单
  20. const MODE_REPAY_INTEREST = 'MODE_REPAY_INTEREST';//还息
  21. const MODE_REPAY_BEN = 'MODE_REPAY_BEN';//还本
  22. const MODE_EXT = 'MODE_EXT';//其他
  23. const MODE_BI = 'MODE_BI';//本息
  24. const MODE_CASHSEND = 'MODE_CASHSEND';//送现金
  25. const STATUS_OK = 1;
  26. const STATUS_INVALID = 2;
  27. const STATUS_FROZEN =3;
  28. public function setMoneyAttr($value) {
  29. return $value * 100;
  30. }
  31. public function getMoneyAttr($value) {
  32. return Common::price2($value / 100);
  33. }
  34. public function setMoneyPreAttr($value) {
  35. return $value * 100;
  36. }
  37. public function getMoneyPreAttr($value) {
  38. return Common::price2($value / 100);
  39. }
  40. public function setMoneyNowAttr($value) {
  41. return $value * 100;
  42. }
  43. public function getMoneyNowAttr($value) {
  44. return Common::price2($value / 100);
  45. }
  46. public function getModeTextAttr($value, $data) {
  47. $modeText = '未知';
  48. switch ($data['mode']) {
  49. case 'MODE_RECHARGE':
  50. $modeText = '充值'.($data['status'] == self::STATUS_OK ? '成功' : '失败');
  51. break;
  52. case 'MODE_DRAWCASH':
  53. //$modeText = '提现'.$data['status'] == self::STATUS_OK ? '成功' : '失败';
  54. if($data['status'] == self::STATUS_OK) {
  55. $modeText = '提现成功';
  56. }
  57. else if($data['status'] == self::STATUS_FROZEN){
  58. $modeText = '预备到账';
  59. }
  60. else {
  61. $modeText = '提现失败';
  62. }
  63. break;
  64. case 'MODE_CANG':
  65. $modeText = '购买'.($data['status'] == self::STATUS_OK ? '成功' : '失败');
  66. break;
  67. case 'MODE_REPAY_INTEREST':
  68. $modeText = '本金回款'.$data['status'] == self::STATUS_OK ? '成功' : '失败';
  69. break;
  70. case 'MODE_REPAY_BEN':
  71. $modeText = '利息回款'.$data['status'] == self::STATUS_OK ? '成功' : '失败';
  72. break;
  73. case 'MODE_EXT':
  74. $modeText = $data['status'] == self::STATUS_OK ? '成功' : '失败';
  75. break;
  76. case 'MODE_CASHSEND':
  77. $modeText = '送现金'.$data['status'] == self::STATUS_OK ? '成功' : '失败';
  78. break;
  79. default:
  80. $modeText = '未知';
  81. break;
  82. }
  83. return $modeText;
  84. }
  85. }