131 lines
3.6 KiB
Go
131 lines
3.6 KiB
Go
|
package service_meal
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
"dubbo.apache.org/dubbo-go/v3/common/logger"
|
||
|
indent "github.com/fonchain_enterprise/fonchain-main/api/meal/backend/indent"
|
||
|
"github.com/fonchain_enterprise/fonchain-main/api/order"
|
||
|
"github.com/fonchain_enterprise/fonchain-main/api/prebook"
|
||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/e"
|
||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/service"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"github.com/gin-gonic/gin/binding"
|
||
|
)
|
||
|
|
||
|
//用户管理列表
|
||
|
func UserListMtgt(c *gin.Context) {
|
||
|
var req indent.UserListreq
|
||
|
if err := c.ShouldBind(&req); err != nil {
|
||
|
logger.Errorf("Select ShouldBind err", err)
|
||
|
service.ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := service.GrpcIndentImpl.UserList(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
||
|
return
|
||
|
}
|
||
|
for i := 0; i < len(resp.Data); i++ {
|
||
|
if resp.Data[i].Info == nil || len(resp.Data[i].Info) == 0 {
|
||
|
resp.Data[i].Info = make([]*indent.UserListres_Info_Ticketinfo, 0)
|
||
|
}
|
||
|
}
|
||
|
for b := 0; b < len(resp.Data); b++ {
|
||
|
if resp.Data[b].List == nil || len(resp.Data[b].Info) == 0 {
|
||
|
resp.Data[b].List = make([]*indent.UserListres_Info_OrderInfo, 0)
|
||
|
}
|
||
|
}
|
||
|
service.ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
//商品订单列表
|
||
|
func IndentList(c *gin.Context) {
|
||
|
var req indent.IndentListreq
|
||
|
if err := c.ShouldBind(&req); err != nil {
|
||
|
logger.Errorf("Select ShouldBind err: %s", err.Error())
|
||
|
service.ResponseQuickMsg(c, e.Failed, err.Error(), nil)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := service.GrpcIndentImpl.IndentList(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.ResponseQuickMsg(c, e.Ok, "", resp)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// 遍历订单列表
|
||
|
for x, info := range resp.Data {
|
||
|
if info.Source == 2 {
|
||
|
var req1 prebook.PreInforeq
|
||
|
fmt.Println("现在是第几个:", x)
|
||
|
req1.OrderUid = resp.Data[x].AppointmentUid
|
||
|
fmt.Println("=========================================")
|
||
|
fmt.Println(req1)
|
||
|
res, _ := service.GrpcPrebookImpl.PreInfo(context.Background(), &req1)
|
||
|
|
||
|
// 检查 res 是否为空
|
||
|
if res != nil {
|
||
|
info.PreName = res.PreName
|
||
|
info.PrePhone = res.PrePhone
|
||
|
info.PreTime = res.PreTime
|
||
|
info.PreId = res.PreId
|
||
|
// 处理 bringman
|
||
|
var bringman []*indent.IndentListres_Info_Note
|
||
|
if res.Bringman == nil || len(res.Bringman) == 0 {
|
||
|
bringman = make([]*indent.IndentListres_Info_Note, 0)
|
||
|
} else {
|
||
|
bringman = make([]*indent.IndentListres_Info_Note, len(res.Bringman))
|
||
|
for i, note := range res.Bringman {
|
||
|
bringman[i] = &indent.IndentListres_Info_Note{
|
||
|
IdCard: note.IdCard,
|
||
|
UserName: note.UserName,
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
info.Bringman = bringman // 将 bringman 赋值给 info.Bringman
|
||
|
}
|
||
|
}
|
||
|
for b := 0; b < len(resp.Data); b++ {
|
||
|
if resp.Data[b].Data == nil || len(resp.Data[b].Data) == 0 {
|
||
|
resp.Data[b].Data = make([]*indent.IndentListres_Info_Goodsinfo, 0)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
service.ResponseQuickMsg(c, e.Ok, resp.Msg, resp)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
//退款
|
||
|
func Orderback(c *gin.Context) {
|
||
|
var req order.WechatJsApiRefundsRequest
|
||
|
|
||
|
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
|
service.Error(c, e.InvalidParams, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
res, err := service.OrderProvider.WechatJsApiRefunds(c, &req)
|
||
|
fmt.Println(res)
|
||
|
if err != nil {
|
||
|
service.Error(c, e.Error, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
var req1 indent.UpdateBackreq
|
||
|
req1.OrderNo = req.OutTradeNo
|
||
|
_, err1 := service.GrpcIndentImpl.UpdateBack(context.Background(), &req1)
|
||
|
if err1 != nil {
|
||
|
service.ResponseQuickMsg(c, e.Ok, err.Error(), "更新失败")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
service.Success(c, "退款成功")
|
||
|
|
||
|
return
|
||
|
//log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
|
||
|
}
|