|
|
@@ -43,6 +43,13 @@ type ActivityItem struct {
|
|
|
//
|
|
|
// SC-2 要验 `type∈{2,3} 且 response_userid>0 → LEAVE`,这条守卫**只能**靠这个值触发。
|
|
|
ResponseUserID int64
|
|
|
+ // RecommendUserID >0 时给该报名行写 `recommend_userid`(老带新的推荐人)。
|
|
|
+ //
|
|
|
+ // 为什么只有 W4 需要它:`use_activity_recommend` 的游标从 **signed 行**读
|
|
|
+ // `recommend_userid` / `activity_money`(不是从活动读),并且
|
|
|
+ // `IF(recommendUserid<=0||activityMoney<=0) THEN LEAVE` —— 不种这一列,游标第一轮就 LEAVE,
|
|
|
+ // 三条 W4 case 会全部退化成"两侧零写入"的**空过**(而且照样全绿)。
|
|
|
+ RecommendUserID int64
|
|
|
}
|
|
|
|
|
|
// ActivitySeed 是"这个 case 要建活动种子"的声明。
|
|
|
@@ -336,9 +343,9 @@ VALUES (?, ?, ?, ?, ?, 1, ?, NOW())`,
|
|
|
// `activity_money` 与 `response_userid` 是活动链要验的两列:
|
|
|
// 前者验"`signed_add` 把活动金额抄进来",后者是"已审核不可取消"那条守卫的唯一触发器。
|
|
|
if err := tx.Exec(`
|
|
|
-INSERT INTO t_courses_activity_signed (activityid, userid, status, activity_money, activity_money_used, response_userid, create_time)
|
|
|
-VALUES (?, ?, ?, ?, ?, ?, NOW())`,
|
|
|
- it.ID, uid, it.SignedStatus, yuan(it.MoneyCents), yuan(it.ActivityMoneyUsedCents), it.ResponseUserID).Error; err != nil {
|
|
|
+INSERT INTO t_courses_activity_signed (activityid, userid, status, activity_money, activity_money_used, response_userid, recommend_userid, create_time)
|
|
|
+VALUES (?, ?, ?, ?, ?, ?, ?, NOW())`,
|
|
|
+ it.ID, uid, it.SignedStatus, yuan(it.MoneyCents), yuan(it.ActivityMoneyUsedCents), it.ResponseUserID, it.RecommendUserID).Error; err != nil {
|
|
|
return fmt.Errorf("种子 legacy 报名 %d 失败:%w", it.ID, err)
|
|
|
}
|
|
|
}
|
|
|
@@ -419,12 +426,13 @@ VALUES (?, ?, ?, ?, ?, 1, ?, NOW(3), NOW(3))`,
|
|
|
// 0 必须写成 **NULL**(不是 '0',也不是空串)—— 迁移口径里 0 与 NULL 同义,
|
|
|
// 写成空串会让 `assertIdentityZeroNull` 报出一条假差异。
|
|
|
respUID := sqlNullUID(it.ResponseUserID)
|
|
|
+ recUID := sqlNullUID(it.RecommendUserID)
|
|
|
if err := tx.Exec(`
|
|
|
INSERT INTO t_courses_activity_signed
|
|
|
- (activity_id, user_id, institution_id, campus_id, status, activity_money, activity_money_used, response_user_id, create_time)
|
|
|
-VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW(3))`,
|
|
|
+ (activity_id, user_id, institution_id, campus_id, status, activity_money, activity_money_used, response_user_id, recommend_user_id, create_time)
|
|
|
+VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(3))`,
|
|
|
it.ID, uid, it.InstitutionID, it.CampusID, it.SignedStatus,
|
|
|
- yuan(it.MoneyCents), yuan(it.ActivityMoneyUsedCents), respUID).Error; err != nil {
|
|
|
+ yuan(it.MoneyCents), yuan(it.ActivityMoneyUsedCents), respUID, recUID).Error; err != nil {
|
|
|
return fmt.Errorf("种子 target 报名 %d 失败:%w", it.ID, err)
|
|
|
}
|
|
|
}
|