diff --git a/.gitignore b/.gitignore index 1c0b2b3..be5398c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ example/iris/config .idea/ .DS_Store static/ +run/ #app petHouseApp diff --git a/business/api/init.go b/business/api/init.go index a32d98b..4570a69 100644 --- a/business/api/init.go +++ b/business/api/init.go @@ -34,7 +34,13 @@ func ModuleInit() { &models.SystemConfig{}, &models.OrderMain{}, &models.OrderSub{}, - &models.OrderDetail{}) + &models.OrderDetail{}, + &models.ServiceCar{}, + &models.CarOrder{}, + &models.ServiceCarUser{}, + &models.ServiceUserMark{}, + &models.ServiceUserMarkRecord{}, + ) DataInit() DataCacheJob() } diff --git a/business/api/order.go b/business/api/order.go index 21a47ed..cf11d04 100644 --- a/business/api/order.go +++ b/business/api/order.go @@ -95,14 +95,87 @@ type OrderListRequest struct { PageSize int //数据数量 } +type SubOrder struct { + OrderId string `json:"orderId"` //子订单ID + Status int `json:"status"` //子订单状态 1待服务 2服务中 3已完成 4已取消 + UserPetInfo UserPetInfo `json:"userPetInfo"` //用户宠物信息 + TotalAmount int32 `json:"totalAmount"` //总金额 单位:分 + PayAmount int32 `json:"payAmount"` //实际支付金额 单位:分 + Goods []models.Goods `json:"goods"` //商品信息 +} + +type OrderDetail struct { + OrderId string `json:"orderId"` //主订单号 + Status int `json:"status"` //主订单状态 1待服务 2服务中 3已完成 + ServiceTime string `json:"serviceTime"` //服务时间 + ServiceAddr models.UserServiceAddr `json:"serviceAddr"` //服务地址信息 + ServiceRemark string `json:"serviceRemark"` //服务备注 + CreateTime string `json:"createTime"` //创建时间 + SubOrderList []SubOrder `json:"subOrderList"` //子订单列表 +} + type OrderListResponse struct { + OrderDetail []OrderDetail //订单列表 + PageNo int //页码 + PageSize int //数据数量 } // 订单列表 func (p DefParty) orderList() web_iris.Party { return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) { index.Post(OrderBase+"/orderList", func(ctx *context.Context) { - + headerBaseInfo := GetHeaderBaseInfo(ctx) + body, _ := io.ReadAll(ctx.Request().Body) + var orderListRequest OrderListRequest + json.Unmarshal(body, &orderListRequest) + if orderListRequest.PageNo == 0 { + ParamError.DefFail(ctx, orderListRequest, "页码必须>0") + return + } + var orderList []models.OrderMain + database.Instance().Model(&models.OrderMain{}).Where("where uid = ?", headerBaseInfo.Uid).Limit(orderListRequest.PageSize).Offset(orderListRequest.PageNo - 1).Find(&orderList) + var orderDetails []OrderDetail + for _, value := range orderList { + var findUserServiceAddr models.UserServiceAddr + database.Instance().Model(&models.UserServiceAddr{}).Where("id = ? and uid = ?", value.ServiceAddrId, headerBaseInfo.Uid).Find(&findUserServiceAddr) + orderListResponse := OrderDetail{ + OrderId: value.OrderId, + Status: value.Status, + ServiceTime: value.ServiceTime, + ServiceAddr: findUserServiceAddr, + ServiceRemark: value.ServiceRemark, + CreateTime: value.CreateTime.String(), + } + var subOrderList []SubOrder + var orderSubList []models.OrderSub + database.Instance().Model(&models.OrderSub{}).Where("where main_order_id = ? ", value.OrderId).Find(&orderSubList) + for _, orderSub := range orderSubList { + var orderDetailList []models.OrderDetail + database.Instance().Model(&models.OrderDetail{}).Where("where sub_order_id = ? ", orderSub.OrderId).Find(&orderDetailList) + var goods []models.Goods + for _, orderDetail := range orderDetailList { + good := GoodsMap[orderDetail.GoodsId] + goods = append(goods, good) + } + orderSub := SubOrder{ + OrderId: orderSub.OrderId, + Status: orderSub.Status, + UserPetInfo: GetUserPet(headerBaseInfo.Uid, orderSub.PetId), + TotalAmount: orderSub.TotalAmount, + PayAmount: orderSub.PayAmount, + Goods: goods, + } + subOrderList = append(subOrderList, orderSub) + } + orderListResponse.SubOrderList = subOrderList + orderDetails = append(orderDetails, orderListResponse) + } + var orderListResponse = OrderListResponse{ + OrderDetail: orderDetails, + PageNo: orderListRequest.PageNo, + PageSize: orderListRequest.PageSize, + } + Success(ctx, orderListRequest, orderListResponse) }) }} } diff --git a/business/utils/commonUtil.go b/business/utils/commonUtil.go new file mode 100644 index 0000000..57175d2 --- /dev/null +++ b/business/utils/commonUtil.go @@ -0,0 +1,14 @@ +package utils + +import ( + "encoding/json" + "github.com/kataras/iris/v12/context" + "io" +) + +func CtxBodyJSONParse(ctx *context.Context) any { + body, _ := io.ReadAll(ctx.Request().Body) + var _i interface{} + _ = json.Unmarshal(body, _i) + return _i +} diff --git a/core/go.sum b/core/go.sum index c3ce8bb..eafca18 100644 --- a/core/go.sum +++ b/core/go.sum @@ -316,6 +316,7 @@ github.com/redis/go-redis/v9 v9.4.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0 github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230126093431-47fa9a501578 h1:VstopitMQi3hZP0fzvnsLmzXZdQGc4bEcgu24cp+d4M= github.com/remyoudompheng/bigfft v0.0.0-20230126093431-47fa9a501578/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=