mcard.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. declare(strict_types=0);
  3. namespace mcard;
  4. const AmountType = 1;
  5. const PeriodType = 2;
  6. const BothType = 3;
  7. const STATE_UNSTART = 1;
  8. const STATE_USING = 2;
  9. const STATE_OVER = 3;
  10. const MonthPachage = 1;
  11. const QuarterPackage = 2;
  12. const YearPackage = 3;
  13. require_once(BASE_HELPER_PATH . '/mcard/card.php');
  14. require_once(BASE_HELPER_PATH . '/mcard/user_mcards.php');
  15. require_once(BASE_HELPER_PATH . '/mcard/amount_card.php');
  16. require_once(BASE_HELPER_PATH . '/mcard/amount_period_card.php');
  17. require_once(BASE_HELPER_PATH . '/mcard/period_card.php');
  18. require_once(BASE_HELPER_PATH . '/bonus_helper.php');
  19. require_once(BASE_HELPER_PATH . '/goods_helper.php');
  20. use goods_helper;
  21. use bonus;
  22. function getConfig($type,$total_amount = 10000)
  23. {
  24. if($type == 'year') {
  25. return ['card_type' => BothType, 'total_amount' => $total_amount, 'discount' => 0.04, 'package_type' => 'year'];
  26. }
  27. else {
  28. return [];
  29. }
  30. }
  31. function isVip($member_id)
  32. {
  33. if($member_id <=0 ) return false;
  34. $user_cards = new user_mcards($member_id);
  35. return $user_cards->hasCards();
  36. }
  37. function canUseVip($goods_id)
  38. {
  39. global $config;
  40. $exclue_gids = $config['exclude_preferential_goods_ids'];
  41. if(empty($exclue_gids)) {
  42. return true;
  43. } else {
  44. return in_array(intval($goods_id),$exclue_gids) === false;
  45. }
  46. }