VipDataLogic.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * DayPayLogic.php UTF-8
  4. *
  5. *
  6. * @date : 2017/12/18 11:42
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : liguanglong <lgl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\logic\data;
  13. use huo\model\common\CommonModel;
  14. use huo\model\member\VipModel;
  15. use think\Lang;
  16. class VipDataLogic extends CommonModel {
  17. /**
  18. *
  19. * 会员卡状态
  20. * @param $data
  21. *
  22. * @return null|string
  23. */
  24. static public function getVipStatus($data){
  25. $status = null;
  26. /*试用*/
  27. if($data['type_id'] == VipModel::NOT_MEMBER && time() <= $data['try_time']){
  28. $status = lang('shakedown period');
  29. }
  30. /*成功*/
  31. else if($data['type_id'] != VipModel::NOT_MEMBER && time() <= $data['end_time']){
  32. $status = lang('success');
  33. }
  34. /*退订*/
  35. else if($data['auto_renew'] == VipModel::NOT_AUTO_RENEW){
  36. $status = lang('unsubscribe');
  37. }
  38. /*宽限期*/
  39. else if($data['auto_renew'] != VipModel::NOT_AUTO_RENEW && (time() <= $data['end_time'] || time() <= $data['try_time'])){
  40. $status = lang('grace period');
  41. }
  42. else{
  43. $status = lang('overdue');
  44. }
  45. return $status;
  46. }
  47. /**
  48. *
  49. * 会员卡类型显示
  50. * @param int $type_id
  51. *
  52. * @return mixed
  53. */
  54. static public function getVipTypeLabel($type_id = 1){
  55. foreach (self::vipType() as $key => $val){
  56. if($key == $type_id){
  57. return $val;
  58. }
  59. }
  60. }
  61. /**
  62. *
  63. * 会员卡类型
  64. * @return array
  65. */
  66. static public function vipType(){
  67. return
  68. [
  69. VipModel::NOT_MEMBER => lang('outsider'),
  70. VipModel::DAY_MEMBER => lang('day card'),
  71. VipModel::WEEK_MEMBER => lang('week card'),
  72. VipModel::MONTH_MEMBER => lang('month card'),
  73. ];
  74. }
  75. /**
  76. * 续(退)订类型
  77. * @return array
  78. */
  79. static public function vipRenewType(){
  80. return [
  81. VipModel::NOT_AUTO_RENEW => lang('not auto renew'),
  82. VipModel::AUTO_RENEW => lang('auto renew'),
  83. VipModel::NOT_RENEW => lang('unsubscribe'),
  84. ];
  85. }
  86. }