CardService.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\admin\service\coupon;
  3. use support\exception\BusinessException;
  4. class CardService
  5. {
  6. /**
  7. * @Desc 生成卡ID
  8. * @Author Gorden
  9. * @Date 2024/11/25 13:46
  10. *
  11. * @param $params
  12. * @param $i
  13. * @return false|string
  14. */
  15. public static function generateCardId($params, $i)
  16. {
  17. $prefixLength = strlen($params['card_issue_serial_prefix']);
  18. $suffixLength = strlen($params['card_issue_serial_suffix']);
  19. $cardId = $params['card_issue_serial_prefix'] . str_pad($params['card_issue_serial_begin'] + $i, $params['card_issue_serial_length'] - $prefixLength - $suffixLength, $params['card_issue_serial_fill'], STR_PAD_LEFT) . $params['card_issue_serial_suffix'];
  20. if (!empty($params['card_issue_not_contain'])) {
  21. $notContains = explode(',', $params['card_issue_not_contain']);
  22. foreach ($notContains as $notContain) {
  23. if (strpos($cardId, $notContain) !== false) {
  24. return false;
  25. }
  26. }
  27. }
  28. return $cardId;
  29. }
  30. public static $status = [
  31. 'INIT' => '待分配',
  32. 'WAITING' => '已分配,待售',
  33. 'PENDING' => '已售,待激活',
  34. 'USED' => '已激活',
  35. 'DONE' => '使用完成',
  36. 'EXPIRED' => '已过期',
  37. 'PAUSED' => '冻结'
  38. ];
  39. }