- check status in CancelPromotion.
- return more accurate error in user related funcs
This commit is contained in:
@@ -144,9 +144,15 @@ func verifyMobileIsBlank(db *dao.DaoDB, mobile string) (user *legacymodel.WeiXin
|
|||||||
}
|
}
|
||||||
if err = dao.GetEntity(db, user, "Tel"); err == nil {
|
if err = dao.GetEntity(db, user, "Tel"); err == nil {
|
||||||
if user.ParentID != -1 && user.ParentID != 0 {
|
if user.ParentID != -1 && user.ParentID != 0 {
|
||||||
err = fmt.Errorf("%s已经是小组成员", mobile)
|
userParent := &legacymodel.WeiXins{
|
||||||
|
ID: user.ParentID,
|
||||||
|
}
|
||||||
|
if err = dao.GetEntity(db, userParent, "Tel"); err != nil && err != orm.ErrNoRows {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = fmt.Errorf("%s已经是组长:%s,门店:%d小组成员", mobile, userParent.Tel, userParent.JxStoreID)
|
||||||
} else if user.JxStoreID != 0 {
|
} else if user.JxStoreID != 0 {
|
||||||
err = fmt.Errorf("%s本身已经是%d的组长", mobile, user.JxStoreID)
|
err = fmt.Errorf("%s本身已经是门店:%d的组长", mobile, user.JxStoreID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return user, err
|
return user, err
|
||||||
@@ -160,7 +166,11 @@ func verifyMobileHasNoMembers(db *dao.DaoDB, mobile string) (err error) {
|
|||||||
JOIN weixins t2 ON t1.parentid = t2.id AND t2.tel = ?
|
JOIN weixins t2 ON t1.parentid = t2.id AND t2.tel = ?
|
||||||
`, mobile); err == nil {
|
`, mobile); err == nil {
|
||||||
if countInfo.Ct > 0 {
|
if countInfo.Ct > 0 {
|
||||||
err = fmt.Errorf("%s本身已经是组长", mobile)
|
user := &legacymodel.WeiXins{
|
||||||
|
Tel: mobile,
|
||||||
|
}
|
||||||
|
dao.GetEntity(db, user, "Tel")
|
||||||
|
err = fmt.Errorf("%s本身已经是门店:%d组长", mobile, user.JxStoreID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -555,6 +555,9 @@ func CancelJdPromotion(ctx *jxcontext.Context, promotionID int) (err error) {
|
|||||||
if err = dao.GetEntity(db, promotion); err != nil {
|
if err = dao.GetEntity(db, promotion); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if promotion.Status != model.PromotionStatusRemoteCreated {
|
||||||
|
return errors.New("当前状态不能进行取消操作")
|
||||||
|
}
|
||||||
promotionHandler := getPromotionHander(promotion.Type)
|
promotionHandler := getPromotionHander(promotion.Type)
|
||||||
if promotionHandler == nil {
|
if promotionHandler == nil {
|
||||||
return errors.New("非法的促销类型")
|
return errors.New("非法的促销类型")
|
||||||
|
|||||||
Reference in New Issue
Block a user