member
This commit is contained in:
@@ -387,99 +387,6 @@ func AddUserDeliveryAddress(ctx *jxcontext.Context, address *model.UserDeliveryA
|
|||||||
return outAddress, err
|
return outAddress, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddMyDeliveryAddress(ctx *jxcontext.Context, address *model.UserDeliveryAddress) (outAddress *model.UserDeliveryAddress, err error) {
|
|
||||||
globals.SugarLogger.Debugf("AddMyDeliveryAddress address:%s", utils.Format4Output(address, true))
|
|
||||||
_, address.UserID = ctx.GetMobileAndUserID()
|
|
||||||
outAddress, err = AddUserDeliveryAddress(ctx, address)
|
|
||||||
globals.SugarLogger.Debugf("AddMyDeliveryAddress2 address:%s, err:%v", utils.Format4Output(address, true), err)
|
|
||||||
return outAddress, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteUserDeliveryAddress(ctx *jxcontext.Context, userID string, addressID int) (err error) {
|
|
||||||
num, err := dao.DeleteEntityLogically(dao.GetDB(), &model.UserDeliveryAddress{}, nil, ctx.GetUserName(), map[string]interface{}{
|
|
||||||
model.FieldID: addressID,
|
|
||||||
"UserID": userID,
|
|
||||||
})
|
|
||||||
if err == nil {
|
|
||||||
if num == 0 {
|
|
||||||
err = fmt.Errorf("地址ID:%d不存在", addressID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteMyDeliveryAddress(ctx *jxcontext.Context, addressID int) (err error) {
|
|
||||||
_, userID := ctx.GetMobileAndUserID()
|
|
||||||
return DeleteUserDeliveryAddress(ctx, userID, addressID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func UpdateUserDeliveryAddress(ctx *jxcontext.Context, userID string, addressID int, payload map[string]interface{}) (err error) {
|
|
||||||
if userID == "" {
|
|
||||||
return fmt.Errorf("操作用户配送地址时必须指定UserID")
|
|
||||||
}
|
|
||||||
address := &model.UserDeliveryAddress{
|
|
||||||
UserID: userID,
|
|
||||||
}
|
|
||||||
address.ID = addressID
|
|
||||||
db := dao.GetDB()
|
|
||||||
if err = dao.GetEntity(db, address, model.FieldID, "UserID"); err == nil {
|
|
||||||
var outAddress *model.UserDeliveryAddress
|
|
||||||
valid := dao.StrictMakeMapByStructObject2(payload, address, &outAddress, ctx.GetUserName())
|
|
||||||
delete(valid, "autoAddress")
|
|
||||||
delete(valid, "districtCode")
|
|
||||||
delete(valid, "cityCode")
|
|
||||||
if len(valid) > 0 {
|
|
||||||
if valid["lng"] != nil || valid["lat"] != nil {
|
|
||||||
valid["autoAddress"], valid["districtCode"], valid["cityCode"], err = getAddressInfoFromCoord(db, outAddress.Lng, outAddress.Lat)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dao.Begin(db)
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
dao.Rollback(db)
|
|
||||||
panic(r)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if utils.ForceInterface2Int64(valid["isDefault"]) == 1 {
|
|
||||||
if err = dao.ClearUserDeliveryAddressDefault(db, userID, 0); err != nil {
|
|
||||||
dao.Rollback(db)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if _, err = dao.UpdateEntityLogically(db, address, valid, ctx.GetUserName(), nil); err == nil {
|
|
||||||
dao.Commit(db)
|
|
||||||
} else {
|
|
||||||
dao.Rollback(db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func UpdateMyDeliveryAddress(ctx *jxcontext.Context, addressID int, payload map[string]interface{}) (err error) {
|
|
||||||
_, userID := ctx.GetMobileAndUserID()
|
|
||||||
return UpdateUserDeliveryAddress(ctx, userID, addressID, payload)
|
|
||||||
}
|
|
||||||
|
|
||||||
func QueryUserDeliveryAddress(ctx *jxcontext.Context, userIDs []string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
|
||||||
addressList, totalCount, err := dao.QueryUserDeliveryAddress(dao.GetDB(), 0, userIDs, offset, pageSize)
|
|
||||||
if err == nil {
|
|
||||||
pagedInfo = &model.PagedInfo{
|
|
||||||
TotalCount: totalCount,
|
|
||||||
Data: addressList,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pagedInfo, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func QueryMyDeliveryAddress(ctx *jxcontext.Context) (addressList []*dao.UserDeliveryAddressEx, err error) {
|
|
||||||
_, userID := ctx.GetMobileAndUserID()
|
|
||||||
addressList, _, err = dao.QueryUserDeliveryAddress(dao.GetDB(), 0, []string{userID}, 0, model.UnlimitedPageSize)
|
|
||||||
return addressList, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func SaveUserCart(ctx *jxcontext.Context, userID string, storeID int, cartItems []*model.UserCartItem) (err error) {
|
func SaveUserCart(ctx *jxcontext.Context, userID string, storeID int, cartItems []*model.UserCartItem) (err error) {
|
||||||
if userID == "" || storeID == 0 {
|
if userID == "" || storeID == 0 {
|
||||||
return fmt.Errorf("用户与门店必须要指定")
|
return fmt.Errorf("用户与门店必须要指定")
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func OnPayFinished(order *model.Order) (err error) {
|
|||||||
if err = AddBillIncome(db, billID, order.Type, order.PayPrice); err != nil {
|
if err = AddBillIncome(db, billID, order.Type, order.PayPrice); err != nil {
|
||||||
dao.Rollback(db)
|
dao.Rollback(db)
|
||||||
}
|
}
|
||||||
//2、账户表保证金总额增加相应值
|
//2、账户表账户余额增加相应值
|
||||||
userBill.AccountBalance += order.PayPrice
|
userBill.AccountBalance += order.PayPrice
|
||||||
if _, err = dao.UpdateEntity(db, userBill, "AccountBalance"); err != nil {
|
if _, err = dao.UpdateEntity(db, userBill, "AccountBalance"); err != nil {
|
||||||
dao.Rollback(db)
|
dao.Rollback(db)
|
||||||
|
|||||||
@@ -83,93 +83,6 @@ func (c *User2Controller) GetUsers() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title 用户自己增加配送地址
|
|
||||||
// @Description 用户自己增加配送地址
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param consigneeName formData string true "收货人"
|
|
||||||
// @Param consigneeMobile formData string true "收货人手机"
|
|
||||||
// @Param address formData string false "地址(区县以下,门牌号以上的地址信息)"
|
|
||||||
// @Param detailAddress formData string false "门牌号"
|
|
||||||
// @Param lng formData float64 true "经度"
|
|
||||||
// @Param lat formData float64 true "纬度"
|
|
||||||
// @Param tag formData string false "标签"
|
|
||||||
// @Param remark formData string false "备注"
|
|
||||||
// @Param isDefault formData int false "是否是默认"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /AddMyDeliveryAddress [post]
|
|
||||||
func (c *User2Controller) AddMyDeliveryAddress() {
|
|
||||||
c.callAddMyDeliveryAddress(func(params *tUser2AddMyDeliveryAddressParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
// var address *model.UserDeliveryAddress
|
|
||||||
// if err = utils.Map2StructByJson(params.MapData, &address, true); err == nil {
|
|
||||||
// retVal, err = cms.AddMyDeliveryAddress(params.Ctx, address)
|
|
||||||
// }
|
|
||||||
address := &model.UserDeliveryAddress{
|
|
||||||
ConsigneeName: params.ConsigneeName,
|
|
||||||
ConsigneeMobile: params.ConsigneeMobile,
|
|
||||||
Address: params.Address,
|
|
||||||
DetailAddress: params.DetailAddress,
|
|
||||||
Lng: params.Lng,
|
|
||||||
Lat: params.Lat,
|
|
||||||
Tag: params.Tag,
|
|
||||||
Remark: params.Remark,
|
|
||||||
IsDefault: int8(params.IsDefault),
|
|
||||||
}
|
|
||||||
retVal, err = cms.AddMyDeliveryAddress(params.Ctx, address)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 用户自己删除配送地址
|
|
||||||
// @Description 用户自己删除送地址
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param id query int true "地址ID"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /DeleteMyDeliveryAddress [delete]
|
|
||||||
func (c *User2Controller) DeleteMyDeliveryAddress() {
|
|
||||||
c.callDeleteMyDeliveryAddress(func(params *tUser2DeleteMyDeliveryAddressParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
err = cms.DeleteMyDeliveryAddress(params.Ctx, params.Id)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 用户自己修改配送地址
|
|
||||||
// @Description 用户自己修改配送地址
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param id formData int true "地址ID"
|
|
||||||
// @Param consigneeName formData string false "收货人"
|
|
||||||
// @Param consigneeMobile formData string false "收货人手机"
|
|
||||||
// @Param address formData string false "地址(区县以下,门牌号以上的地址信息)"
|
|
||||||
// @Param detailAddress formData string false "门牌号"
|
|
||||||
// @Param lng formData float64 false "经度"
|
|
||||||
// @Param lat formData float64 false "纬度"
|
|
||||||
// @Param tag formData string false "标签"
|
|
||||||
// @Param remark formData string false "备注"
|
|
||||||
// @Param isDefault formData int false "是否是默认(0:否,1:是)"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /UpdateMyDeliveryAddress [put]
|
|
||||||
func (c *User2Controller) UpdateMyDeliveryAddress() {
|
|
||||||
c.callUpdateMyDeliveryAddress(func(params *tUser2UpdateMyDeliveryAddressParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
err = cms.UpdateMyDeliveryAddress(params.Ctx, params.Id, params.MapData)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 用户查询自己的配送地址
|
|
||||||
// @Description 用户查询自己的配送地址
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /QueryMyDeliveryAddress [get]
|
|
||||||
func (c *User2Controller) QueryMyDeliveryAddress() {
|
|
||||||
c.callQueryMyDeliveryAddress(func(params *tUser2QueryMyDeliveryAddressParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
retVal, err = cms.QueryMyDeliveryAddress(params.Ctx)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 得到用户指定门店的购物车信息
|
// @Title 得到用户指定门店的购物车信息
|
||||||
// @Description 得到用户指定门店的购物车信息
|
// @Description 得到用户指定门店的购物车信息
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
|||||||
@@ -295,15 +295,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "AddMyDeliveryAddress",
|
|
||||||
Router: `/AddMyDeliveryAddress`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "CreateUserAgreement",
|
Method: "CreateUserAgreement",
|
||||||
@@ -313,15 +304,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "DeleteMyDeliveryAddress",
|
|
||||||
Router: `/DeleteMyDeliveryAddress`,
|
|
||||||
AllowHTTPMethods: []string{"delete"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "DeleteUserInfo",
|
Method: "DeleteUserInfo",
|
||||||
@@ -376,15 +358,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "QueryMyDeliveryAddress",
|
|
||||||
Router: `/QueryMyDeliveryAddress`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "RegisterUser",
|
Method: "RegisterUser",
|
||||||
@@ -403,15 +376,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "UpdateMyDeliveryAddress",
|
|
||||||
Router: `/UpdateMyDeliveryAddress`,
|
|
||||||
AllowHTTPMethods: []string{"put"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "UpdateUserWxNoAndPercent",
|
Method: "UpdateUserWxNoAndPercent",
|
||||||
|
|||||||
Reference in New Issue
Block a user