|
@@ -3,6 +3,7 @@ package youngee_talent_service
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
"youngmini_server/app/dao"
|
|
"youngmini_server/app/dao"
|
|
|
|
+ "youngmini_server/app/model"
|
|
"youngmini_server/app/model/youngee_talent_model"
|
|
"youngmini_server/app/model/youngee_talent_model"
|
|
"youngmini_server/app/utils"
|
|
"youngmini_server/app/utils"
|
|
|
|
|
|
@@ -79,6 +80,15 @@ func OnAddTalentAddress(r *ghttp.Request) *TalentHttpResult {
|
|
return tErr
|
|
return tErr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 如果当前无地址则将其设为默认地址
|
|
|
|
+ c, tErr := tx.Ctx(ctx).Model(dao.YoungeeTalentDeliveryAddress.Table).Where("talent_id", tid).Count()
|
|
|
|
+ if tErr != nil {
|
|
|
|
+ return tErr
|
|
|
|
+ }
|
|
|
|
+ if c == 0 {
|
|
|
|
+ tAddr.DefaultTag = 1
|
|
|
|
+ }
|
|
|
|
+
|
|
// 如果设置的是地址是默认地址,则把当前默认地址设为非默认
|
|
// 如果设置的是地址是默认地址,则把当前默认地址设为非默认
|
|
if tAddr.DefaultTag > 0 {
|
|
if tAddr.DefaultTag > 0 {
|
|
_, tErr = tx.Ctx(ctx).Model(dao.YoungeeTalentDeliveryAddress.Table).
|
|
_, tErr = tx.Ctx(ctx).Model(dao.YoungeeTalentDeliveryAddress.Table).
|
|
@@ -87,14 +97,12 @@ func OnAddTalentAddress(r *ghttp.Request) *TalentHttpResult {
|
|
return tErr
|
|
return tErr
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 如果当前无地址则将其设为默认地址
|
|
|
|
- c, tErr := tx.Ctx(ctx).Model(dao.YoungeeTalentDeliveryAddress.Table).Where("talent_id", tid).Count()
|
|
|
|
- if tErr != nil {
|
|
|
|
- return tErr
|
|
|
|
- }
|
|
|
|
- if c == 0 {
|
|
|
|
- tAddr.DefaultTag = 1
|
|
|
|
|
|
+ if tAddr.DefaultTag == 1 {
|
|
|
|
+ _, tErr = tx.Ctx(ctx).Model(dao.YoungeeTalentInfo.Table).
|
|
|
|
+ Update("talent_phone_number = ?", "id = ?", tAddr.PhoneNumber, tid)
|
|
|
|
+ if tErr != nil {
|
|
|
|
+ return tErr
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// 将达人id存入结构体
|
|
// 将达人id存入结构体
|
|
@@ -104,7 +112,6 @@ func OnAddTalentAddress(r *ghttp.Request) *TalentHttpResult {
|
|
if tErr != nil {
|
|
if tErr != nil {
|
|
return tErr
|
|
return tErr
|
|
}
|
|
}
|
|
-
|
|
|
|
return nil
|
|
return nil
|
|
})
|
|
})
|
|
|
|
|
|
@@ -189,7 +196,7 @@ func SetDefaultDeliveryAddr(r *ghttp.Request) *TalentHttpResult {
|
|
|
|
|
|
aid := r.GetRequestInt32("address_id", 0)
|
|
aid := r.GetRequestInt32("address_id", 0)
|
|
if aid == 0 {
|
|
if aid == 0 {
|
|
- return &TalentHttpResult{Code: -1, Msg: "address id error"}
|
|
|
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get address id error"}
|
|
}
|
|
}
|
|
|
|
|
|
rec, err := g.DB().Model(dao.YoungeeTalentDeliveryAddress.Table).One("talent_id = ? and default_tag = 1", tid)
|
|
rec, err := g.DB().Model(dao.YoungeeTalentDeliveryAddress.Table).One("talent_id = ? and default_tag = 1", tid)
|
|
@@ -214,10 +221,20 @@ func SetDefaultDeliveryAddr(r *ghttp.Request) *TalentHttpResult {
|
|
return nil
|
|
return nil
|
|
})
|
|
})
|
|
}
|
|
}
|
|
-
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
return &TalentHttpResult{Code: -3, Msg: "database error"}
|
|
return &TalentHttpResult{Code: -3, Msg: "database error"}
|
|
}
|
|
}
|
|
|
|
+ addressInfo := model.YoungeeTalentDeliveryAddress{}
|
|
|
|
+ err = g.DB().Model(dao.YoungeeTalentDeliveryAddress.Table).Where("address_id", aid).Scan(&addressInfo)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return &TalentHttpResult{Code: -4, Msg: "address id error"}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _, err = g.DB().Model(dao.YoungeeTalentInfo.Table).
|
|
|
|
+ Update("talent_phone_number = ?", "id = ?", addressInfo.PhoneNumber, tid)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return &TalentHttpResult{Code: -4, Msg: "address id error"}
|
|
|
|
+ }
|
|
|
|
|
|
return &TalentHttpResult{Code: 0, Msg: "success"}
|
|
return &TalentHttpResult{Code: 0, Msg: "success"}
|
|
}
|
|
}
|