From d9358adc7a65e8a26a77c6235b68ccc027571f84 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 11 Oct 2024 17:13:43 +0800 Subject: [PATCH] 1 --- app/agent/hdl/hdl_store.go | 69 ++++++++++++++++++++++++++++ app/db/model/community_team_order.go | 1 + app/hdl/hdl_order.go | 3 ++ app/router/router.go | 3 ++ app/store/hdl/hdl_store.go | 63 +++++++++++++++++++++++++ app/svc/svc_order.go | 27 +++++++++++ app/svc/svc_store_order.go | 1 + 7 files changed, 167 insertions(+) diff --git a/app/agent/hdl/hdl_store.go b/app/agent/hdl/hdl_store.go index 5948284..fab0118 100644 --- a/app/agent/hdl/hdl_store.go +++ b/app/agent/hdl/hdl_store.go @@ -9,6 +9,7 @@ import ( "applet/app/svc" "applet/app/utils" "encoding/json" + "fmt" "github.com/gin-gonic/gin" "time" ) @@ -160,6 +161,74 @@ func UserStoreOrder(c *gin.Context) { } e.OutSuc(c, res, nil) } +func UserStoreOrderPay(c *gin.Context) { + var arg map[string]string + if err := c.ShouldBindJSON(&arg); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + user := svc.GetUser(c) + str := "ctpo.parent_uid=" + utils.IntToStr(user.Info.Uid) + " and ctpo.state=1" + if arg["uid"] != "" { + str += " and ctpo.uid=" + arg["uid"] + } + if arg["store_id"] != "" { + str += " and ctpo.store_uid=" + arg["store_id"] + } + if arg["store_name"] != "" { + str += " and cts.name like '%" + arg["store_name"] + "%'" + } + if arg["phone"] != "" { + str += " and u.phone like '%" + arg["phone"] + "%'" + } + if arg["oid"] != "" { + str += " and ctpo.oid like '%" + arg["oid"] + "%'" + } + if arg["start_time"] != "" { + str += " and ctpo.pay_at>='" + arg["start_time"] + "'" + } + if arg["end_time"] != "" { + str += " and ctpo.pay_at<='" + arg["end_time"] + "'" + } + + sql := `select ctpo.pay_at,ctpo.oid,cts.name,u.phone,ctpo.uid,ctpo.amount,ctpo.agent_commission,ctpo.platform_commission from community_team_pay_order ctpo + LEFT JOIN user u on u.uid=ctpo.uid + LEFT JOIN community_team_store cts on cts.uid=ctpo.store_uid + where %s order by ctpo.pay_at desc %s` + size := utils.StrToInt(arg["size"]) + start := (utils.StrToInt(arg["p"]) - 1) * size + sql = fmt.Sprintf(sql, str, "limit "+utils.IntToStr(start)+","+utils.IntToStr(size)) + nativeString, _ := db.QueryNativeString(svc.MasterDb(c), sql) + list := make([]map[string]string, 0) + for _, v := range nativeString { + tmp := map[string]string{ + "time": v["pay_at"], + "name": v["name"], + "amount": v["amount"], + "phone": v["phone"], + "uid": v["uid"], + "agent_commission": v["agent_commission"], + "oid": v["oid"], + } + list = append(list, tmp) + } + sql1 := `select COUNT(*) as count from community_team_pay_order ctpo + LEFT JOIN user u on u.uid=ctpo.uid + where %s ` + sql = fmt.Sprintf(sql, str) + nativeString1, _ := db.QueryNativeString(svc.MasterDb(c), sql1) + total := 0 + for _, v := range nativeString1 { + total = utils.StrToInt(v["count"]) + } + res := map[string]interface{}{ + "total": total, + "list": list, + } + + e.OutSuc(c, res, nil) + return +} // UserStoreOrderDetail 门店订单详情-订单管理共用一个 // @Summary 门店-门店订单详情 diff --git a/app/db/model/community_team_order.go b/app/db/model/community_team_order.go index 4a668de..90bbd06 100644 --- a/app/db/model/community_team_order.go +++ b/app/db/model/community_team_order.go @@ -14,6 +14,7 @@ type CommunityTeamOrder struct { CouponId int `json:"coupon_id" xorm:"default 0 comment('') INT(11)"` Address string `json:"address" xorm:"comment('详细地址') VARCHAR(255)"` Commission string `json:"commission" xorm:"default 0.00 comment('分佣(元)') DECIMAL(20,2)"` + TableNum string `json:"table_num" xorm:"default 0.00 comment('分佣(元)') varchar(255)"` AgentCommission string `json:"agent_commission" xorm:"default 0.00 comment('分佣(元)') DECIMAL(20,2)"` PlatformCommission string `json:"platform_commission" xorm:"default 0.00 comment('分佣(元)') DECIMAL(20,2)"` CreateAt time.Time `json:"create_at" xorm:"DATETIME"` diff --git a/app/hdl/hdl_order.go b/app/hdl/hdl_order.go index dcade7f..9471f15 100644 --- a/app/hdl/hdl_order.go +++ b/app/hdl/hdl_order.go @@ -14,6 +14,9 @@ func OrderCreate(c *gin.Context) { func PayOrderCreate(c *gin.Context) { svc.PayOrderCreate(c) } +func PayOrderList(c *gin.Context) { + svc.PayOrderList(c) +} func OrderCoupon(c *gin.Context) { svc.OrderCoupon(c) } diff --git a/app/router/router.go b/app/router/router.go index 7acffe5..e6f2969 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -67,6 +67,7 @@ func routeCommunityTeamAgent(r *gin.RouterGroup) { r.POST("/store/list", agentHdl.UserStoreList) r.POST("/store/save", agentHdl.UserStoreSave) r.POST("/store/order", agentHdl.UserStoreOrder) + r.POST("/store/order/pay", agentHdl.UserStoreOrderPay) r.POST("/store/order/detail", agentHdl.UserStoreOrderDetail) r.POST("/store/total", agentHdl.UserStoreTotal) @@ -109,6 +110,7 @@ func routeCommunityTeamOwnStore(r *gin.RouterGroup) { r.GET("/audit/info", storeHdl.AuditInfo) r.POST("/audit/doing", storeHdl.AuditDoing) r.POST("/store/order", storeHdl.UserStoreOrder) + r.POST("/store/order/pay", storeHdl.UserStoreOrderPay) r.POST("/store/order/detail", storeHdl.UserStoreOrderDetail) r.POST("/store/order/confirm", storeHdl.StoreOrderConfirm) r.GET("/store/amount/base", storeHdl.StoreAmountBase) @@ -170,6 +172,7 @@ func routeCommunityTeam(r *gin.RouterGroup) { r.GET("/order/cate", hdl.OrderCate) r.POST("/pay/:payMethod/:orderType", hdl.Pay) r.POST("/pay/order/create", hdl.PayOrderCreate) + r.POST("/pay/order/list", hdl.PayOrderList) r.POST("/store/order/list", hdl.StoreOrderList) r.POST("/store/order/detail", hdl.StoreOrderDetail) r.POST("/store/order/confirm", hdl.StoreOrderConfirm) diff --git a/app/store/hdl/hdl_store.go b/app/store/hdl/hdl_store.go index 9a5edd0..8826223 100644 --- a/app/store/hdl/hdl_store.go +++ b/app/store/hdl/hdl_store.go @@ -9,6 +9,7 @@ import ( "applet/app/svc" "applet/app/utils" "encoding/json" + "fmt" "github.com/gin-gonic/gin" "github.com/tidwall/gjson" "time" @@ -133,6 +134,7 @@ func UserStoreOrder(c *gin.Context) { "agent_commission": v.AgentCommission, "platform_commission": v.PlatformCommission, "commission": v.Commission, + "table_num": v.TableNum, "state": utils.IntToStr(v.State), "create_at": v.CreateAt.Format("2006-01-02 15:04:05"), "confirm_at": utils.Int64ToStr(v.Oid), @@ -164,6 +166,67 @@ func UserStoreOrder(c *gin.Context) { } e.OutSuc(c, res, nil) } +func UserStoreOrderPay(c *gin.Context) { + var arg map[string]string + if err := c.ShouldBindJSON(&arg); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + user := svc.GetUser(c) + str := "ctpo.store_uid=" + utils.IntToStr(user.Info.Uid) + " and ctpo.state=1" + if arg["uid"] != "" { + str += " and ctpo.uid=" + arg["uid"] + } + if arg["phone"] != "" { + str += " and u.phone like '%" + arg["phone"] + "%'" + } + if arg["oid"] != "" { + str += " and ctpo.oid like '%" + arg["oid"] + "%'" + } + if arg["start_time"] != "" { + str += " and ctpo.pay_at>='" + arg["start_time"] + "'" + } + if arg["end_time"] != "" { + str += " and ctpo.pay_at<='" + arg["end_time"] + "'" + } + + sql := `select ctpo.pay_at,ctpo.oid,u.phone,ctpo.uid,ctpo.amount,ctpo.agent_commission,ctpo.platform_commission from community_team_pay_order ctpo + LEFT JOIN user u on u.uid=ctpo.uid + where %s order by ctpo.pay_at desc %s` + size := utils.StrToInt(arg["size"]) + start := (utils.StrToInt(arg["p"]) - 1) * size + sql = fmt.Sprintf(sql, str, "limit "+utils.IntToStr(start)+","+utils.IntToStr(size)) + nativeString, _ := db.QueryNativeString(svc.MasterDb(c), sql) + list := make([]map[string]string, 0) + for _, v := range nativeString { + tmp := map[string]string{ + "time": v["pay_at"], + "amount": v["amount"], + "phone": v["phone"], + "uid": v["uid"], + "agent_commission": v["agent_commission"], + "platform_commission": v["platform_commission"], + "oid": v["oid"], + } + list = append(list, tmp) + } + sql1 := `select COUNT(*) as count from community_team_pay_order ctpo + LEFT JOIN user u on u.uid=ctpo.uid + where %s ` + sql = fmt.Sprintf(sql, str) + nativeString1, _ := db.QueryNativeString(svc.MasterDb(c), sql1) + total := 0 + for _, v := range nativeString1 { + total = utils.StrToInt(v["count"]) + } + res := map[string]interface{}{ + "total": total, + "list": list, + } + + e.OutSuc(c, res, nil) + return +} // UserStoreOrderDetail 门店订单详情-订单管理共用一个 // @Summary 门店-门店订单详情 diff --git a/app/svc/svc_order.go b/app/svc/svc_order.go index 253e306..735f5ca 100644 --- a/app/svc/svc_order.go +++ b/app/svc/svc_order.go @@ -471,6 +471,33 @@ func OrderConfirm(c *gin.Context) { e.OutSuc(c, "success", nil) return } +func PayOrderList(c *gin.Context) { + var arg map[string]string + if err := c.ShouldBindJSON(&arg); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + sql := `select ctpo.pay_at,ctpo.oid,cts.name,ctpo.amount from community_team_pay_order ctpo + LEFT JOIN community_team_store cts on cts.uid=ctpo.store_uid + where ctpo.uid=%d and ctpo.state=1 order by ctpo.pay_at desc %s` + size := 10 + start := (utils.StrToInt(arg["p"]) - 1) * size + user := GetUser(c) + sql = fmt.Sprintf(sql, user.Info.Uid, "limit "+utils.IntToStr(start)+","+utils.IntToStr(size)) + nativeString, _ := db.QueryNativeString(MasterDb(c), sql) + list := make([]map[string]string, 0) + for _, v := range nativeString { + tmp := map[string]string{ + "time": v["pay_at"], + "name": v["name"], + "amount": v["amount"], + "oid": v["oid"], + } + list = append(list, tmp) + } + e.OutSuc(c, list, nil) + return +} func PayOrderCreate(c *gin.Context) { var arg map[string]string if err := c.ShouldBindJSON(&arg); err != nil { diff --git a/app/svc/svc_store_order.go b/app/svc/svc_store_order.go index 279305f..9d4a146 100644 --- a/app/svc/svc_store_order.go +++ b/app/svc/svc_store_order.go @@ -104,6 +104,7 @@ func StoreOrderList(c *gin.Context) { "commission": v.Commission, "username": nickname, "head_img": headImg, + "table_num": v.TableNum, "amount": v.Amount, "num": utils.IntToStr(v.Num), "down_time": downTime,