1、修改查询优惠券列表接口,状态为3时查询3/4的数据;
2、新机预售券支付完成发放优惠券时同步更新发货和收货时间; 3、购买主机预售券不用填写地址; 4、增加限制:一个ID只能购买一张预售券; 5、商城订单退货增加判断,主机预售券退货不判断时间,只判断优惠券是否未使用; 6、增加新机优惠券对应错误码;
This commit is contained in:
parent
f3611088d5
commit
911f580bf6
|
@ -568,8 +568,12 @@ func MemberRenewalUserCouponList(c *gin.Context) {
|
||||||
|
|
||||||
qs := model.NewUserCouponQuerySet(model.DB).UidEq(uc.Uid)
|
qs := model.NewUserCouponQuerySet(model.DB).UidEq(uc.Uid)
|
||||||
if req.State != 0 {
|
if req.State != 0 {
|
||||||
|
if req.State == 3 {
|
||||||
|
qs = qs.StateIn(3, 4)
|
||||||
|
} else {
|
||||||
qs = qs.StateEq(req.State)
|
qs = qs.StateEq(req.State)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if req.ActivityId != 0 {
|
if req.ActivityId != 0 {
|
||||||
qs = qs.ActivityIdEq(req.ActivityId)
|
qs = qs.ActivityIdEq(req.ActivityId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -976,7 +976,7 @@ func PushWXPayNotice(c *gin.Context) {
|
||||||
|
|
||||||
if strings.Contains(goods.Name, "预售") { // 主机预售券,需要发放优惠券;默认为已收货
|
if strings.Contains(goods.Name, "预售") { // 主机预售券,需要发放优惠券;默认为已收货
|
||||||
model.NewGoodsOrderQuerySet(model.DB).IDEq(goodsOrder.ID).GetUpdater().
|
model.NewGoodsOrderQuerySet(model.DB).IDEq(goodsOrder.ID).GetUpdater().
|
||||||
SetState(model.GoodsOrderStateReceived).Update()
|
SetState(model.GoodsOrderStateReceived).SetDeliverTime(time.Now()).SetReceivedTime(time.Now()).Update()
|
||||||
|
|
||||||
var couponInfo model.Coupon
|
var couponInfo model.Coupon
|
||||||
err = model.NewCouponQuerySet(model.DB).ActivityIdEq(model.NewMachineActivityId).One(&couponInfo)
|
err = model.NewCouponQuerySet(model.DB).ActivityIdEq(model.NewMachineActivityId).One(&couponInfo)
|
||||||
|
@ -2496,7 +2496,7 @@ func HmPushWXPayNotice(c *gin.Context) {
|
||||||
|
|
||||||
if strings.Contains(goods.Name, "预售") { // 主机预售券,需要发放优惠券;默认为已收货
|
if strings.Contains(goods.Name, "预售") { // 主机预售券,需要发放优惠券;默认为已收货
|
||||||
model.NewGoodsOrderQuerySet(model.DB).IDEq(goodsOrder.ID).GetUpdater().
|
model.NewGoodsOrderQuerySet(model.DB).IDEq(goodsOrder.ID).GetUpdater().
|
||||||
SetState(model.GoodsOrderStateReceived).Update()
|
SetState(model.GoodsOrderStateReceived).SetDeliverTime(time.Now()).SetReceivedTime(time.Now()).Update()
|
||||||
|
|
||||||
var couponInfo model.Coupon
|
var couponInfo model.Coupon
|
||||||
err = model.NewCouponQuerySet(model.DB).ActivityIdEq(model.NewMachineActivityId).One(&couponInfo)
|
err = model.NewCouponQuerySet(model.DB).ActivityIdEq(model.NewMachineActivityId).One(&couponInfo)
|
||||||
|
|
|
@ -211,7 +211,7 @@ func MallOrderCreate(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果不是发放优惠券,需要判断用户地址
|
// 如果不是发放优惠券,需要判断用户地址
|
||||||
if !strings.Contains(goods.Name, "优惠券") {
|
if !(strings.Contains(goods.Name, "优惠券") || strings.Contains(goods.Name, "预售")) {
|
||||||
// 检测收货地址是否正确
|
// 检测收货地址是否正确
|
||||||
count, _ := model.NewUserAddressQuerySet(model.DB).UidEq(uc.Uid).IDEq(req.AddressId).Count()
|
count, _ := model.NewUserAddressQuerySet(model.DB).UidEq(uc.Uid).IDEq(req.AddressId).Count()
|
||||||
if count != 1 {
|
if count != 1 {
|
||||||
|
@ -221,6 +221,21 @@ func MallOrderCreate(c *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断是否已经购买或使用过新机预售券
|
||||||
|
if strings.Contains(goods.Name, "预售") {
|
||||||
|
var newMachineCoupon model.UserCoupon
|
||||||
|
err = model.NewUserCouponQuerySet(model.DB).UidEq(user.Uid).ActivityIdEq(model.NewMachineActivityId).
|
||||||
|
One(&newMachineCoupon)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msgf("query newMachineCoupon err:%#v, code is:", err, req.CouponCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if newMachineCoupon.ID != 0 {
|
||||||
|
RespJson(c, status.OutOffCouponLimit, "一个ID只能购买一张预售券")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 查找用户优惠券,判断是否可用
|
// 查找用户优惠券,判断是否可用
|
||||||
var userCoupon model.UserCoupon
|
var userCoupon model.UserCoupon
|
||||||
var coupon model.Coupon
|
var coupon model.Coupon
|
||||||
|
@ -628,12 +643,41 @@ func MallOrderRefund(c *gin.Context) {
|
||||||
RespJson(c, status.InternalServerError, nil)
|
RespJson(c, status.InternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if goodsOrder.Amount == 0 && goodsOrder.DeliverStoreId == 0 { // 新机预售券
|
||||||
|
// 查询新机预售券状态,只有未使用才能退
|
||||||
|
var newMachineCoupon model.UserCoupon
|
||||||
|
err = model.NewUserCouponQuerySet(model.DB).UidEq(goodsOrder.Uid).ActivityIdEq(model.NewMachineActivityId).
|
||||||
|
One(&newMachineCoupon)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error(err)
|
||||||
|
RespJson(c, status.BadRequest, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch newMachineCoupon.State {
|
||||||
|
case 2:
|
||||||
|
RespJson(c, status.NewMachineCouponUsed, nil)
|
||||||
|
return
|
||||||
|
case 3:
|
||||||
|
RespJson(c, status.NewMachineCouponOutOfTime, nil)
|
||||||
|
return
|
||||||
|
case 4:
|
||||||
|
RespJson(c, status.NewMachineCouponDisabled, nil)
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
RespJson(c, status.BadRequest, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
if goodsOrder.CreatedAt.AddDate(0, 0, 15).Before(utils.Now()) ||
|
if goodsOrder.CreatedAt.AddDate(0, 0, 15).Before(utils.Now()) ||
|
||||||
(!goodsOrder.ReceivedTime.IsZero() && goodsOrder.ReceivedTime.AddDate(0, 0, 7).Before(utils.Now())) {
|
(!goodsOrder.ReceivedTime.IsZero() && goodsOrder.ReceivedTime.AddDate(0, 0, 7).Before(utils.Now())) {
|
||||||
log.Error().Msg("goods order refund exceed the time limit")
|
log.Error().Msg("goods order refund exceed the time limit")
|
||||||
RespJson(c, status.InternalServerError, nil)
|
RespJson(c, status.InternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if goodsOrder.State != model.GoodsOrderStateDelivered &&
|
if goodsOrder.State != model.GoodsOrderStateDelivered &&
|
||||||
goodsOrder.State != model.GoodsOrderStateReceived &&
|
goodsOrder.State != model.GoodsOrderStateReceived &&
|
||||||
goodsOrder.State != model.GoodsOrderStateRefundedCancel {
|
goodsOrder.State != model.GoodsOrderStateRefundedCancel {
|
||||||
|
@ -641,6 +685,7 @@ func MallOrderRefund(c *gin.Context) {
|
||||||
RespJson(c, status.OrderDelivered, nil)
|
RespJson(c, status.OrderDelivered, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if goodsOrder.DeliverStoreId != 0 { // 线上购买预售券时没有发货门店
|
||||||
store, err := model.GetStore(goodsOrder.DeliverStoreId)
|
store, err := model.GetStore(goodsOrder.DeliverStoreId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Msgf("get store err:%#v", err)
|
log.Error().Msgf("get store err:%#v", err)
|
||||||
|
@ -648,6 +693,7 @@ func MallOrderRefund(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
goodsOrder.DeliverStore = store
|
goodsOrder.DeliverStore = store
|
||||||
|
}
|
||||||
err = model.NewGoodsOrderQuerySet(model.DB).OrderIdEq(req.GoodsOrderId).GetUpdater().
|
err = model.NewGoodsOrderQuerySet(model.DB).OrderIdEq(req.GoodsOrderId).GetUpdater().
|
||||||
SetRefundReason(req.RefundReason).SetState(model.GoodsOrderStateOnRefund).Update()
|
SetRefundReason(req.RefundReason).SetState(model.GoodsOrderStateOnRefund).Update()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -116,6 +116,10 @@ const (
|
||||||
NotShopperCodeStoreUser = 500533 // 您不是推广门店用户,请扫店员推广码后再使用优惠券
|
NotShopperCodeStoreUser = 500533 // 您不是推广门店用户,请扫店员推广码后再使用优惠券
|
||||||
NotAvailableCode = 500534 // 兑换码错误
|
NotAvailableCode = 500534 // 兑换码错误
|
||||||
NoSpecValue = 500535 // 优惠券未指定规格
|
NoSpecValue = 500535 // 优惠券未指定规格
|
||||||
|
OutOffCouponLimit = 500536 // 超出限制:一个ID只能购买一张预售券
|
||||||
|
NewMachineCouponUsed = 500537 // 新机预售券已使用
|
||||||
|
NewMachineCouponOutOfTime = 500538 // 新机预售券已过期
|
||||||
|
NewMachineCouponDisabled = 500539 // 新机预售券已失效
|
||||||
|
|
||||||
ToastErr = 600 // 报错
|
ToastErr = 600 // 报错
|
||||||
)
|
)
|
||||||
|
@ -283,6 +287,10 @@ var statusMsg = map[int]string{
|
||||||
NotShopperCodeStoreUser: "您不是推广门店用户,请扫店员推广码后再使用优惠券",
|
NotShopperCodeStoreUser: "您不是推广门店用户,请扫店员推广码后再使用优惠券",
|
||||||
NotAvailableCode: "兑换码错误",
|
NotAvailableCode: "兑换码错误",
|
||||||
NoSpecValue: "优惠券未指定规格",
|
NoSpecValue: "优惠券未指定规格",
|
||||||
|
OutOffCouponLimit: "超出限制:一个ID只能购买一张预售券",
|
||||||
|
NewMachineCouponUsed: "新机预售券已使用",
|
||||||
|
NewMachineCouponOutOfTime: "新机预售券已过期",
|
||||||
|
NewMachineCouponDisabled: "新机预售券已失效",
|
||||||
}
|
}
|
||||||
|
|
||||||
func StatusDesc(code int) string {
|
func StatusDesc(code int) string {
|
||||||
|
|
|
@ -49,7 +49,7 @@ type UserCoupon struct {
|
||||||
ActivityType uint32 `json:"activity_type"` // 活动类型 1-会员续费 2-关注公众号 3-运费包
|
ActivityType uint32 `json:"activity_type"` // 活动类型 1-会员续费 2-关注公众号 3-运费包
|
||||||
ActivityId uint32 `json:"activity_id" gorm:"index"` //
|
ActivityId uint32 `json:"activity_id" gorm:"index"` //
|
||||||
Value uint32 `json:"value"` //
|
Value uint32 `json:"value"` //
|
||||||
State uint32 `json:"state"` // 1-未使用 2-已使用 3-已过期
|
State uint32 `json:"state"` // 1-未使用 2-已使用 3-已过期 4-已失效
|
||||||
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
ActiveStart time.Time `json:"active_start"` // 有效期开始
|
||||||
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
ActiveEnd time.Time `json:"active_end"` // 有效期结束 零值永不结束
|
||||||
UseTime time.Time `json:"use_time"` //
|
UseTime time.Time `json:"use_time"` //
|
||||||
|
|
Loading…
Reference in New Issue
Block a user