123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\admin\service\coupon;
- use support\exception\BusinessException;
- class CardService
- {
- /**
- * @Desc 生成卡ID
- * @Author Gorden
- * @Date 2024/11/25 13:46
- *
- * @param $params
- * @param $i
- * @return false|string
- */
- public static function generateCardId($params, $i)
- {
- $prefixLength = strlen($params['card_issue_serial_prefix']);
- $suffixLength = strlen($params['card_issue_serial_suffix']);
- $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'];
- if (!empty($params['card_issue_not_contain'])) {
- $notContains = explode(',', $params['card_issue_not_contain']);
- foreach ($notContains as $notContain) {
- if (strpos($cardId, $notContain) !== false) {
- return false;
- }
- }
- }
- return $cardId;
- }
- public static $status = [
- 'INIT' => '待分配',
- 'WAITING' => '已分配,待售',
- 'PENDING' => '已售,待激活',
- 'USED' => '已激活',
- 'DONE' => '使用完成',
- 'EXPIRED' => '已过期',
- 'PAUSED' => '冻结'
- ];
- }
|