1.商城订单河马付新增终端号:200001;
2.修改兑换码兑换优惠券规则,已领取优惠券也可以兑换; 3.修改会员邀请规则,3日内扫码后开通都算店员邀请;
This commit is contained in:
parent
5086ade42b
commit
5535e0492e
|
@ -955,32 +955,41 @@ func UserCodeToCoupon(c *gin.Context) {
|
|||
}
|
||||
|
||||
for i, _ := range coupons {
|
||||
_, ok := userCouponMap[coupons[i].ID]
|
||||
if ok {
|
||||
continue
|
||||
}
|
||||
id, ok := userCouponMap[coupons[i].ID]
|
||||
if ok { // 更新规则,通过店员兑换码兑换优惠券,如果用户已经领取过优惠券,则每次兑换都更新之前的兑换码和过期时间
|
||||
userCoupons[id].PromotionalSales = shopperPromotionCode.Uid
|
||||
userCoupons[id].RedeemCode = shopperPromotionCode.Code
|
||||
userCoupons[id].ActiveStart = time.Now()
|
||||
userCoupons[id].ActiveEnd = time.Now().AddDate(0, 0, 30)
|
||||
userCoupons[id].UseTime = time.Time{}
|
||||
err := model.DB.Model(&userCoupons).Where("id = ?", userCoupons[id].ID).Updates(userCoupons[id]).Error
|
||||
if err != nil {
|
||||
logger.Error("user coupon err:", err)
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
userCoupon := &model.UserCoupon{
|
||||
Uid: uc.Uid,
|
||||
CouponId: coupons[i].ID,
|
||||
CouponType: coupons[i].CouponType,
|
||||
ActivityType: coupons[i].ActivityType,
|
||||
ActivityId: coupons[i].ActivityId,
|
||||
Value: coupons[i].Value,
|
||||
State: 1,
|
||||
ActiveStart: time.Now(),
|
||||
ActiveEnd: time.Now().AddDate(0, 0, 30),
|
||||
UseTime: time.Time{},
|
||||
MemberLevel: coupons[i].MemberLevel,
|
||||
Approach: 1,
|
||||
PromotionalSales: shopperPromotionCode.Uid,
|
||||
RedeemCode: shopperPromotionCode.Code,
|
||||
}
|
||||
|
||||
userCoupon := &model.UserCoupon{
|
||||
Uid: uc.Uid,
|
||||
CouponId: coupons[i].ID,
|
||||
CouponType: coupons[i].CouponType,
|
||||
ActivityType: coupons[i].ActivityType,
|
||||
ActivityId: coupons[i].ActivityId,
|
||||
Value: coupons[i].Value,
|
||||
State: 1,
|
||||
ActiveStart: time.Now(),
|
||||
ActiveEnd: time.Now().AddDate(0, 0, 30),
|
||||
UseTime: time.Time{},
|
||||
MemberLevel: coupons[i].MemberLevel,
|
||||
Approach: 1,
|
||||
PromotionalSales: shopperPromotionCode.Uid,
|
||||
RedeemCode: shopperPromotionCode.Code,
|
||||
}
|
||||
|
||||
err = model.DB.Create(userCoupon).Error
|
||||
if err != nil {
|
||||
logger.Error("user coupon err:", err)
|
||||
continue
|
||||
err = model.DB.Create(userCoupon).Error
|
||||
if err != nil {
|
||||
logger.Error("user coupon err:", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,10 @@ import (
|
|||
wechatpayutils "github.com/wechatpay-apiv3/wechatpay-go/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
EffectiveInviteDays = 3 // 3天之内的邀请有效
|
||||
)
|
||||
|
||||
// HomeCategoryList 首页分类列表
|
||||
// @Summary 首页分类列表
|
||||
// @Tags 首页分类, V1.4.5
|
||||
|
@ -654,7 +658,7 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
if invite.Action == 1 { // 1-未激活 用户首次开通
|
||||
logger.Info("invite.Action == 1")
|
||||
qs := model.NewUserInviteQuerySet(model.DB).IDEq(invite.ID).GetUpdater()
|
||||
if isShopAssistantCode {
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) {
|
||||
qs = qs.SetInviteForm(1)
|
||||
invite.RenewHide = 0 // 干预
|
||||
} else {
|
||||
|
@ -691,7 +695,7 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
MemberGenre: record.MemberGenre,
|
||||
RenewHide: 1,
|
||||
}
|
||||
if isShopAssistantCode { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
inviteRecordNew.Scan = 1
|
||||
inviteRecordNew.RenewHide = 0 // 店员干预续费
|
||||
//inviteRecordNew.FromUid = invite.FromUid
|
||||
|
@ -720,7 +724,7 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
MemberGenre: record.MemberGenre,
|
||||
RenewHide: 1,
|
||||
}
|
||||
if isShopAssistantCode { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
userInviteNew.Scan = 1
|
||||
userInviteNew.RenewHide = 0
|
||||
userInviteNew.InviteForm = 1
|
||||
|
@ -748,8 +752,8 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
SetCooperativeName(inviteUser.CooperativeName)
|
||||
|
||||
effectiveStoreId := invite.StoreId
|
||||
autoRenewFlag := true // 自动续费
|
||||
if isShopAssistantCode { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
autoRenewFlag := true // 自动续费
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
effectiveStoreId = effectiveStoreInfo.StoreID
|
||||
userQs = userQs.SetStoreId(effectiveStoreId) // 更新用户门店:邀请人的有效门店
|
||||
autoRenewFlag = false // 店员干预续费
|
||||
|
@ -978,7 +982,7 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
|
||||
if notifyInfo.Attach == wxpay.WxPayUpgradeMember {
|
||||
record := &model.UserOpenMemberRecord{OpenNo: notifyInfo.OutTradeNo}
|
||||
err := record.GetByOpenNo()
|
||||
err = record.GetByOpenNo()
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
}
|
||||
|
@ -1096,7 +1100,7 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
|
||||
if invite.Action != 2 {
|
||||
qs := model.NewUserInviteQuerySet(model.DB).IDEq(invite.ID).GetUpdater()
|
||||
if isShopAssistantCode {
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) {
|
||||
qs = qs.SetInviteForm(1)
|
||||
invite.RenewHide = 0 // 干预
|
||||
} else {
|
||||
|
@ -1132,7 +1136,7 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
MemberGenre: record.MemberGenre,
|
||||
RenewHide: 1,
|
||||
}
|
||||
if isShopAssistantCode {
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) {
|
||||
inviteRecordNew.RenewHide = 0
|
||||
}
|
||||
err = model.DB.Create(inviteRecordNew).Error
|
||||
|
@ -1159,7 +1163,7 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
MemberGenre: record.MemberGenre,
|
||||
RenewHide: 1,
|
||||
}
|
||||
if isShopAssistantCode {
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) {
|
||||
userInviteNew.InviteForm = 1
|
||||
userInviteNew.RenewHide = 0
|
||||
}
|
||||
|
@ -1215,7 +1219,7 @@ func PushWXPayNotice(c *gin.Context) {
|
|||
// 统计用户升级的数量,方便前端展示
|
||||
// 分3种情况:1-店员干预(使用了店员兑换码兑换的优惠券)、2-自动续费(开通会员时有店员邀请,原价or优惠券续费)
|
||||
// 3-自动续费(自己开通会员,原价or优惠券续费) 目前只有1算店员提成,正常1和2都会算;3不算提成
|
||||
if isShopAssistantCode { // 1-店员干预(使用了店员兑换码兑换的优惠券)
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) { // 1-店员干预(使用了店员兑换码兑换的优惠券)
|
||||
model.AddCooperativeMemberUpgrade(user.CooperativeBusinessId,
|
||||
uint32(effectiveStoreInfo.StoreID), invite.FromUid, user.MemberLevel, int(record.MemberLevel), false)
|
||||
|
||||
|
@ -2102,7 +2106,7 @@ func HmPushWXPayNotice(c *gin.Context) {
|
|||
if invite.Action == 1 { // 首次开通会员
|
||||
qs := model.NewUserInviteQuerySet(model.DB).IDEq(invite.ID).GetUpdater()
|
||||
|
||||
if isShopAssistantCode {
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) {
|
||||
qs = qs.SetInviteForm(1)
|
||||
invite.RenewHide = 0 // 干预
|
||||
} else {
|
||||
|
@ -2138,7 +2142,7 @@ func HmPushWXPayNotice(c *gin.Context) {
|
|||
MemberGenre: record.MemberGenre,
|
||||
RenewHide: 1,
|
||||
}
|
||||
if isShopAssistantCode { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
inviteRecordNew.Scan = 1
|
||||
inviteRecordNew.RenewHide = 0 // 店员干预续费
|
||||
//inviteRecordNew.FromUid = invite.FromUid
|
||||
|
@ -2168,7 +2172,7 @@ func HmPushWXPayNotice(c *gin.Context) {
|
|||
RenewHide: 1,
|
||||
//MemberOpenTime: invite.MemberOpenTime,
|
||||
}
|
||||
if isShopAssistantCode { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
userInviteNew.Scan = 1
|
||||
userInviteNew.RenewHide = 0
|
||||
userInviteNew.InviteForm = 1
|
||||
|
@ -2201,7 +2205,7 @@ func HmPushWXPayNotice(c *gin.Context) {
|
|||
|
||||
autoRenewFlag := true // 自动续费
|
||||
effectiveStoreId := invite.StoreId
|
||||
if isShopAssistantCode { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) { // 如果使用了优惠券,则是店员邀请续费;否则是用户自己发起续费
|
||||
effectiveStoreId = effectiveStoreInfo.StoreID
|
||||
userQs = userQs.SetStoreId(effectiveStoreId) // 更新用户门店:邀请人的有效门店
|
||||
autoRenewFlag = false // 店员干预续费
|
||||
|
@ -2552,7 +2556,7 @@ func HmPushWXPayNotice(c *gin.Context) {
|
|||
|
||||
if invite.Action != 2 {
|
||||
qs := model.NewUserInviteQuerySet(model.DB).IDEq(invite.ID).GetUpdater()
|
||||
if isShopAssistantCode {
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) {
|
||||
qs = qs.SetInviteForm(1)
|
||||
invite.RenewHide = 0 // 干预
|
||||
} else {
|
||||
|
@ -2588,7 +2592,7 @@ func HmPushWXPayNotice(c *gin.Context) {
|
|||
MemberGenre: record.MemberGenre,
|
||||
RenewHide: 1,
|
||||
}
|
||||
if isShopAssistantCode {
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) {
|
||||
inviteRecordNew.RenewHide = 0
|
||||
}
|
||||
err = model.DB.Create(inviteRecordNew).Error
|
||||
|
@ -2615,7 +2619,7 @@ func HmPushWXPayNotice(c *gin.Context) {
|
|||
MemberGenre: record.MemberGenre,
|
||||
RenewHide: 1,
|
||||
}
|
||||
if isShopAssistantCode {
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) {
|
||||
userInviteNew.InviteForm = 1
|
||||
userInviteNew.RenewHide = 0
|
||||
}
|
||||
|
@ -2673,7 +2677,7 @@ func HmPushWXPayNotice(c *gin.Context) {
|
|||
// 分3种情况:1-店员干预(使用了店员兑换码兑换的优惠券)、2-自动续费(开通会员时有店员邀请,原价or优惠券续费)
|
||||
// 3-自动续费(自己开通会员,原价or优惠券续费) 目前只有1算店员提成,正常1和2都会算;3不算提成
|
||||
fmt.Println("isShopAssistantCode:", isShopAssistantCode)
|
||||
if isShopAssistantCode { // 1-店员干预(使用了店员兑换码兑换的优惠券)
|
||||
if isShopAssistantCode || IsWithinDays(invite.CreatedAt, EffectiveInviteDays) { // 1-店员干预(使用了店员兑换码兑换的优惠券)
|
||||
model.AddCooperativeMemberUpgrade(user.CooperativeBusinessId,
|
||||
uint32(effectiveStoreInfo.StoreID), invite.FromUid, user.MemberLevel, int(record.MemberLevel), false)
|
||||
|
||||
|
@ -3431,3 +3435,18 @@ func AliyunStsTokenGet(c *gin.Context) {
|
|||
|
||||
RespOK(c, stsToken)
|
||||
}
|
||||
|
||||
// IsWithinDays 判断给定日期是否在当前日期的指定天数范围内
|
||||
func IsWithinDays(inputDate time.Time, days int) bool {
|
||||
// 获取当前日期,忽略时间部分
|
||||
currentDate := time.Now().Truncate(24 * time.Hour)
|
||||
|
||||
// 将输入日期也忽略时间部分
|
||||
truncatedInputDate := inputDate.Truncate(24 * time.Hour)
|
||||
|
||||
// 计算日期差
|
||||
diff := currentDate.Sub(truncatedInputDate).Hours() / 24
|
||||
|
||||
// 判断日期是否在 [-days, days] 的范围内
|
||||
return diff >= float64(-days) && diff <= float64(days)
|
||||
}
|
||||
|
|
|
@ -1093,11 +1093,11 @@ type HmPayBizContent struct {
|
|||
//LimitPay string `json:"limit_pay"`
|
||||
NotifyUrl string `json:"notify_url"`
|
||||
//OperatorId string `json:"operator_id"`
|
||||
OutOrderNo string `json:"out_order_no"`
|
||||
PayType string `json:"pay_type"`
|
||||
PayWay string `json:"pay_way"`
|
||||
StoreId string `json:"store_id"`
|
||||
//TerminalId string `json:"terminal_id"`
|
||||
OutOrderNo string `json:"out_order_no"`
|
||||
PayType string `json:"pay_type"`
|
||||
PayWay string `json:"pay_way"`
|
||||
StoreId string `json:"store_id"`
|
||||
TerminalId string `json:"terminal_id"`
|
||||
TotalAmount float64 `json:"total_amount"`
|
||||
}
|
||||
|
||||
|
@ -1514,7 +1514,8 @@ func HmJsPayUnifiedOrderForBuyGoods(orderId string, totalFee uint32, openId, not
|
|||
OutOrderNo: orderId,
|
||||
PayType: "JSAPI",
|
||||
PayWay: "WECHAT",
|
||||
StoreId: "200001",
|
||||
StoreId: "100001",
|
||||
TerminalId: "200001",
|
||||
TotalAmount: float64(totalFee) / 100,
|
||||
}
|
||||
unifiedOrderReq.HmPayPublicPara = publicPara
|
||||
|
|
Loading…
Reference in New Issue
Block a user