|
@@ -4,7 +4,7 @@ namespace Longyi\RewardPoints\Config;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 积分交易类型配置类
|
|
* 积分交易类型配置类
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* 统一管理所有积分交易类型,避免硬编码
|
|
* 统一管理所有积分交易类型,避免硬编码
|
|
|
* 新增类型只需在此类中添加,无需修改其他代码
|
|
* 新增类型只需在此类中添加,无需修改其他代码
|
|
|
*/
|
|
*/
|
|
@@ -14,65 +14,70 @@ class TransactionType
|
|
|
* 签到
|
|
* 签到
|
|
|
*/
|
|
*/
|
|
|
const SIGN_IN = 1;
|
|
const SIGN_IN = 1;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 注册
|
|
* 注册
|
|
|
*/
|
|
*/
|
|
|
const REGISTRATION = 2;
|
|
const REGISTRATION = 2;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 订单
|
|
* 订单
|
|
|
*/
|
|
*/
|
|
|
const ORDER = 3;
|
|
const ORDER = 3;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 评价
|
|
* 评价
|
|
|
*/
|
|
*/
|
|
|
const REVIEW = 4;
|
|
const REVIEW = 4;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 推荐
|
|
* 推荐
|
|
|
*/
|
|
*/
|
|
|
const REFERRAL = 5;
|
|
const REFERRAL = 5;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 生日
|
|
* 生日
|
|
|
*/
|
|
*/
|
|
|
const BIRTHDAY = 6;
|
|
const BIRTHDAY = 6;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 分享
|
|
* 分享
|
|
|
*/
|
|
*/
|
|
|
const SHARE = 7;
|
|
const SHARE = 7;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 订阅
|
|
* 订阅
|
|
|
*/
|
|
*/
|
|
|
const SUBSCRIBE = 8;
|
|
const SUBSCRIBE = 8;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 登录
|
|
* 登录
|
|
|
*/
|
|
*/
|
|
|
const LOGIN = 9;
|
|
const LOGIN = 9;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 过期积分
|
|
* 过期积分
|
|
|
*/
|
|
*/
|
|
|
const EXPIRED = 10;
|
|
const EXPIRED = 10;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 兑换礼品卡
|
|
* 兑换礼品卡
|
|
|
*/
|
|
*/
|
|
|
const GIFT_CARD_REDEEM = 11;
|
|
const GIFT_CARD_REDEEM = 11;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 后台管理员修改
|
|
* 后台管理员修改
|
|
|
*/
|
|
*/
|
|
|
const ADMIN_ACTION = 99;
|
|
const ADMIN_ACTION = 99;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 取消订单退回积分
|
|
|
|
|
+ */
|
|
|
|
|
+ const ORDER_CANCEL_REFUND = 12;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取所有类型配置
|
|
* 获取所有类型配置
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @return array [type_id => ['code' => string, 'name' => string, 'description' => string]]
|
|
* @return array [type_id => ['code' => string, 'name' => string, 'description' => string]]
|
|
|
*/
|
|
*/
|
|
|
public static function all(): array
|
|
public static function all(): array
|
|
@@ -162,27 +167,43 @@ class TransactionType
|
|
|
'icon' => 'icon-setting',
|
|
'icon' => 'icon-setting',
|
|
|
'color' => 'gray',
|
|
'color' => 'gray',
|
|
|
],
|
|
],
|
|
|
|
|
+ self::ORDER_CANCEL_REFUND => [
|
|
|
|
|
+ 'code' => 'order_cancel_refund',
|
|
|
|
|
+ 'name' => '取消订单退回',
|
|
|
|
|
+ 'description' => '订单取消后退回积分',
|
|
|
|
|
+ 'icon' => 'icon-undo',
|
|
|
|
|
+ 'color' => 'cyan',
|
|
|
|
|
+ ],
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取可用于规则配置的类型(排除管理员操作、过期、兑换等特殊类型)
|
|
* 获取可用于规则配置的类型(排除管理员操作、过期、兑换等特殊类型)
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @return array
|
|
* @return array
|
|
|
*/
|
|
*/
|
|
|
public static function getRuleTypes(): array
|
|
public static function getRuleTypes(): array
|
|
|
{
|
|
{
|
|
|
$all = self::all();
|
|
$all = self::all();
|
|
|
- // 排除特殊类型:管理员操作(99)、过期(10)、兑换礼品卡(11)
|
|
|
|
|
- unset($all[self::ADMIN_ACTION]);
|
|
|
|
|
- unset($all[self::EXPIRED]);
|
|
|
|
|
- unset($all[self::GIFT_CARD_REDEEM]);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 排除特殊类型:管理员操作(99)、过期(10)、兑换礼品卡(11)、取消订单退回(12)
|
|
|
|
|
+ $excludedTypes = [
|
|
|
|
|
+ self::ADMIN_ACTION,
|
|
|
|
|
+ self::EXPIRED,
|
|
|
|
|
+ self::GIFT_CARD_REDEEM,
|
|
|
|
|
+ self::ORDER_CANCEL_REFUND,
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($excludedTypes as $typeId) {
|
|
|
|
|
+ unset($all[$typeId]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return $all;
|
|
return $all;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取单个类型信息
|
|
* 获取单个类型信息
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param int $typeId
|
|
* @param int $typeId
|
|
|
* @return array|null
|
|
* @return array|null
|
|
|
*/
|
|
*/
|
|
@@ -194,7 +215,7 @@ class TransactionType
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据 code 获取类型 ID
|
|
* 根据 code 获取类型 ID
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param string $code
|
|
* @param string $code
|
|
|
* @return int|null
|
|
* @return int|null
|
|
|
*/
|
|
*/
|
|
@@ -210,7 +231,7 @@ class TransactionType
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取类型名称
|
|
* 获取类型名称
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param int $typeId
|
|
* @param int $typeId
|
|
|
* @return string
|
|
* @return string
|
|
|
*/
|
|
*/
|
|
@@ -222,7 +243,7 @@ class TransactionType
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取类型代码
|
|
* 获取类型代码
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param int $typeId
|
|
* @param int $typeId
|
|
|
* @return string
|
|
* @return string
|
|
|
*/
|
|
*/
|
|
@@ -234,7 +255,7 @@ class TransactionType
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 检查类型是否存在
|
|
* 检查类型是否存在
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param int $typeId
|
|
* @param int $typeId
|
|
|
* @return bool
|
|
* @return bool
|
|
|
*/
|
|
*/
|
|
@@ -245,7 +266,7 @@ class TransactionType
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取所有类型选项(用于下拉选择)
|
|
* 获取所有类型选项(用于下拉选择)
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @return array [type_id => name]
|
|
* @return array [type_id => name]
|
|
|
*/
|
|
*/
|
|
|
public static function options(): array
|
|
public static function options(): array
|
|
@@ -259,7 +280,7 @@ class TransactionType
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取所有类型代码列表
|
|
* 获取所有类型代码列表
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @return array
|
|
* @return array
|
|
|
*/
|
|
*/
|
|
|
public static function codes(): array
|
|
public static function codes(): array
|