|
@@ -79,6 +79,11 @@ func (this *SubscribeChange) SaveChange() {
|
|
|
timeRenew := this.GetString("time")
|
|
|
req_price, _ := this.GetInteger("price")
|
|
|
openId := qutil.ObjToString(this.GetSession("s_m_openid"))
|
|
|
+ //用户当前使用卡卷
|
|
|
+ userLotteryId := this.GetString("userLotteryId")
|
|
|
+ //卡卷信息的id
|
|
|
+ lotteryId := this.GetString("lotteryId")
|
|
|
+ discount_price := 0
|
|
|
r := func() *entity.FuncResult {
|
|
|
if len(industry) == 1 && industry[0] == "" { //去掉[""]
|
|
|
industry = []string{}
|
|
@@ -155,40 +160,57 @@ func (this *SubscribeChange) SaveChange() {
|
|
|
filter.GiveCycle = date_count
|
|
|
}
|
|
|
}
|
|
|
- } else if !needUpgrade && needRenew { //只续费,不升级
|
|
|
- //保存修改
|
|
|
- if !entity.JyVipSubStruct.SubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), area, industry) {
|
|
|
- return &entity.FuncResult{false, errors.New("保存修改出错"), nil}
|
|
|
+ } else {
|
|
|
+ full_price, reduce_price := 0, 0
|
|
|
+ if userLotteryId != "" && lotteryId != "" {
|
|
|
+ userLotteryId = qutil.SE.Decode4Hex(userLotteryId)
|
|
|
+ full_price, reduce_price = util.GetCouponInfo(userId, lotteryId, "超级订阅")
|
|
|
}
|
|
|
- final_price = entity.JyVipSubStruct.GetSubVipPriceByBuySet(oldBuyset.NewCitys, oldBuyset.AreaCount, oldBuyset.BuyerclassCount, date_count, date_unit, false)
|
|
|
- filter.OrderType = 5
|
|
|
- filter.NewBuyset = oldBuyset
|
|
|
- log.Println("续费", final_price)
|
|
|
- //生效时间
|
|
|
- startTime = time.Unix(endUnix, 0)
|
|
|
- endTime = util.GetDATE(filter.Cycleunit, filter.Cyclecount, endUnix)
|
|
|
- } else { //升级
|
|
|
- //升级(若存在续费,升级单子必须高于每个续费单子;否则不能升级)
|
|
|
- totalPrice, subtotail := getUpgradeDetail(userId, upgradeBuyset, oldBuyset, endUnix, date_count, date_unit)
|
|
|
- if totalPrice < 0 {
|
|
|
- if totalPrice == -1 {
|
|
|
- return &entity.FuncResult{false, errors.New("不能升级此状态"), nil}
|
|
|
- } else {
|
|
|
- return &entity.FuncResult{false, errors.New("查询续费订单出错"), nil}
|
|
|
+ if !needUpgrade && needRenew { //只续费,不升级
|
|
|
+ //保存修改
|
|
|
+ if !entity.JyVipSubStruct.SubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), area, industry) {
|
|
|
+ return &entity.FuncResult{false, errors.New("保存修改出错"), nil}
|
|
|
}
|
|
|
- }
|
|
|
- final_price = totalPrice
|
|
|
- filter.OrderType = 3
|
|
|
- filter.OldBuyset = oldBuyset
|
|
|
- filter.NewBuyset = upgradeBuyset
|
|
|
- filter.UpgradeSubtotail = subtotail
|
|
|
-
|
|
|
- //生效时间
|
|
|
- startTime = now
|
|
|
- if needRenew {
|
|
|
+ final_price = entity.JyVipSubStruct.GetSubVipPriceByBuySet(oldBuyset.NewCitys, oldBuyset.AreaCount, oldBuyset.BuyerclassCount, date_count, date_unit, false)
|
|
|
+ filter.OrderType = 5
|
|
|
+ filter.NewBuyset = oldBuyset
|
|
|
+ //卡卷使用
|
|
|
+ if reduce_price > 0 && full_price <= final_price {
|
|
|
+ final_price = final_price - reduce_price
|
|
|
+ discount_price = reduce_price
|
|
|
+ }
|
|
|
+ log.Println("续费", final_price)
|
|
|
+ //生效时间
|
|
|
+ startTime = time.Unix(endUnix, 0)
|
|
|
endTime = util.GetDATE(filter.Cycleunit, filter.Cyclecount, endUnix)
|
|
|
- } else {
|
|
|
- endTime = time.Unix(endUnix, 0)
|
|
|
+ } else { //升级
|
|
|
+ //升级(若存在续费,升级单子必须高于每个续费单子;否则不能升级)
|
|
|
+ totalPrice, subtotail := getUpgradeDetail(userId, upgradeBuyset, oldBuyset, endUnix, date_count, date_unit)
|
|
|
+ if totalPrice < 0 {
|
|
|
+ if totalPrice == -1 {
|
|
|
+ return &entity.FuncResult{false, errors.New("不能升级此状态"), nil}
|
|
|
+ } else {
|
|
|
+ return &entity.FuncResult{false, errors.New("查询续费订单出错"), nil}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //卡卷使用
|
|
|
+ if reduce_price > 0 && full_price <= totalPrice {
|
|
|
+ totalPrice = totalPrice - reduce_price
|
|
|
+ discount_price = reduce_price
|
|
|
+ }
|
|
|
+ final_price = totalPrice
|
|
|
+ filter.OrderType = 3
|
|
|
+ filter.OldBuyset = oldBuyset
|
|
|
+ filter.NewBuyset = upgradeBuyset
|
|
|
+ filter.UpgradeSubtotail = subtotail
|
|
|
+
|
|
|
+ //生效时间
|
|
|
+ startTime = now
|
|
|
+ if needRenew {
|
|
|
+ endTime = util.GetDATE(filter.Cycleunit, filter.Cyclecount, endUnix)
|
|
|
+ } else {
|
|
|
+ endTime = time.Unix(endUnix, 0)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
log.Printf("是否需要升级%v,是否需要续费%v\n", needUpgrade, needRenew)
|
|
@@ -230,13 +252,15 @@ func (this *SubscribeChange) SaveChange() {
|
|
|
"order_code": ordercode,
|
|
|
"product_type": "VIP订阅",
|
|
|
"create_time": qutil.FormatDate(&now, qutil.Date_Full_Layout),
|
|
|
- "original_price": final_price,
|
|
|
+ "original_price": final_price + discount_price, //原价
|
|
|
"filter_id": "",
|
|
|
"user_id": userId,
|
|
|
"filter": string(filterStr), //筛选
|
|
|
"vip_endtime": qutil.FormatDate(&endTime, qutil.Date_Full_Layout),
|
|
|
"vip_starttime": qutil.FormatDate(&startTime, qutil.Date_Full_Layout),
|
|
|
"dis_word": disWord,
|
|
|
+ "discount_price": discount_price,
|
|
|
+ "d_relation_id": userLotteryId,
|
|
|
//"vip_type": qutil.If(filter.OrderType == 5, 1, 2), //1:续费 2:升级
|
|
|
}
|
|
|
if filter.OrderType != 1 {
|