瀏覽代碼

no message

xingzai 11 月之前
父節點
當前提交
94c47ba753
共有 4 個文件被更改,包括 249 次插入0 次删除
  1. 152 0
      controllers/cygx/order.go
  2. 87 0
      models/cygx/orde.go
  3. 9 0
      routers/commentsRouter.go
  4. 1 0
      routers/router.go

+ 152 - 0
controllers/cygx/order.go

@@ -0,0 +1,152 @@
+package cygx
+
+import (
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hz_crm_api/controllers"
+	"hongze/hz_crm_api/models"
+	"hongze/hz_crm_api/models/cygx"
+	"hongze/hz_crm_api/utils"
+	"strconv"
+	"time"
+)
+
+// 产品内测
+type OrderController struct {
+	controllers.BaseAuthController
+}
+
+// @Title 列表
+// @Description 列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   StartDate   query   string  false       "开始时间 ,列如2021-03-06 "
+// @Param   EndDate   query   string  false       "结束时间,列如2021-03-06 "
+// @Param   AdminId   query   string  false       "销售ID "
+// @Param   OrderType   query   int  false       "订单类型 1:畅读卡订单,2:单场付费订单"
+// @Param   PaymentProject   query   string  false       "付款项目"
+// @Param   OrderCode   query   string  false       "订单编号"
+// @Param   KeyWord   query   string  false       "搜索关键词"
+// @Success Ret=200 {object} cygx.GetCygxTacticsTimeLineResp
+// @router /order/list [get]
+func (this *OrderController) OrderList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	resp := new(cygx.UserOrderListResp)
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	orderType, _ := this.GetInt("OrderType", 1)
+	startDate := this.GetString("StartDate")
+	endDate := this.GetString("EndDate")
+	adminId := this.GetString("AdminId")
+	orderCode := this.GetString("OrderCode")
+	keyWord := this.GetString("KeyWord")
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+
+	if orderType > 0 { //订单类型 1:畅读卡订单,2:单场付费订单
+		condition += `  AND order_type =   ? `
+		pars = append(pars, orderType)
+	}
+
+	if startDate != "" && endDate != "" { //时间范围
+		condition += ` 	AND create_time  BETWEEN ?   AND  ? `
+		pars = append(pars, startDate, endDate)
+	}
+
+	if adminId != "" { //所属销售筛选
+		condition += ` 	AND seller_id IN (` + adminId + `) `
+	}
+
+	if orderCode != "" { //订单编号
+		orderCode = "%" + orderCode + "%"
+		condition += ` 	AND order_code LIKE ? `
+		pars = append(pars, orderCode)
+	}
+
+	if keyWord != "" { //用户姓名,手机号
+		keyWord = "%" + keyWord + "%"
+		condition += ` 	AND (mobile LIKE ?  OR  real_name LIKE ? ) `
+		pars = append(pars, keyWord, keyWord)
+	}
+
+	total, err := cygx.GetCygxOrderCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	condition += "	ORDER BY order_id  DESC "
+	list, err := cygx.GetCygxOrderList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	for _, v := range list {
+		item := new(cygx.OrderListResp)
+		item.OrderCode = v.OrderCode
+		item.OrderMoney = v.OrderMoney
+		item.SourceId = v.SourceId
+		item.Source = v.Source
+		item.SourceTitle = v.SourceTitle
+		switch v.Source {
+		case "article": //文章详情
+			item.HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.SourceId)
+		case "activity": //活动详情
+			item.HttpUrl = utils.CYGX_WEB_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
+		}
+		item.OrderStatus = v.OrderStatus
+		if v.OrderStatus == 0 {
+			item.OrderStatusText = "已取消"
+		} else if v.OrderStatus == 1 {
+			item.OrderStatusText = "待支付"
+		} else if v.OrderStatus == 2 {
+			item.OrderStatusText = "已支付"
+		}
+		item.UserId = v.UserId
+		item.RealName = v.RealName
+		item.Mobile = v.Mobile
+		item.Email = v.Email
+		item.CompanyId = v.CompanyId
+		item.CompanyName = v.CompanyName
+		item.SellerName = v.SellerName
+		item.InviteName = "推荐人"
+		item.PaymentProject = v.GoodsName
+
+		if v.OrderStatus == 2 {
+			item.PayTime = v.PayTime.Format(utils.FormatDateTime)
+		}
+		if orderType == 1 {
+			item.StartDate = time.Now().Format(utils.FormatDateTime)
+			item.EndDate = time.Now().AddDate(0, 0, 3).Format(utils.FormatDateTime)
+		}
+		item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
+		resp.List = append(resp.List, item)
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 87 - 0
models/cygx/orde.go

@@ -0,0 +1,87 @@
+package cygx
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type CygxOrderResp struct {
+	OrderId          int       `orm:"column(order_id);pk";comment:"订单id"`
+	OrderCode        string    `comment:"订单编号"`
+	OutTradeCode     string    `comment:"外部交易号"`
+	PaymentType      int       `comment:"支付类型。取值范围:1微信支付,2支付宝支付。"`
+	GoodsName        string    `comment:"商品名称"`
+	GoodsId          int       `comment:"商品ID"`
+	BuyerInvoice     string    `comment:"买家发票信息"`
+	GoodsMoney       float64   `comment:"商品总价"`
+	OrderMoney       float64   `comment:"订单总价"`
+	Point            int       `comment:"订单消耗积分"`
+	PointMoney       float64   `comment:"订单消耗积分抵多少钱"`
+	PayMoney         float64   `comment:"订单实付金额"`
+	RefundMoney      float64   `comment:"订单退款金额"`
+	OrderStatus      int       `comment:"订单状态,0:已取消、1:待支付、2:已支付、3:已退款"`
+	PayTime          time.Time `comment:"订单付款时间"`
+	SourceId         int       `comment:"来源ID"`
+	Source           string    `comment:"来源\n报告 :article\n活动 :activity"`
+	SourceTitle      string    `comment:"来源名称,活动或者报告标题"`
+	UserId           int       `comment:"用户ID"`
+	Mobile           string    `comment:"手机号"`
+	Email            string    `comment:"邮箱"`
+	CompanyId        int       `comment:"公司ID"`
+	CompanyName      string    `comment:"公司名称"`
+	RealName         string    `comment:"用户实际名称"`
+	SellerName       string    `comment:"所属销售"`
+	CreateTime       time.Time `comment:"创建时间"`
+	ModifyTime       time.Time `comment:"修改时间"`
+	RegisterPlatform int       `comment:"来源 1小程序,2:网页"`
+}
+
+func GetCygxOrderList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxOrderResp, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT *
+			FROM
+			cygx_order
+			WHERE 1 = 1 ` + condition
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+// 获取数量
+func GetCygxOrderCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_order WHERE   1= 1  ` + condition
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+type OrderListResp struct {
+	OrderCode       string  `comment:"订单编号"`
+	UserId          int     `comment:"用户ID"`
+	Mobile          string  `comment:"手机号"`
+	Email           string  `comment:"邮箱"`
+	CompanyId       int     `comment:"公司ID"`
+	CompanyName     string  `comment:"公司名称"`
+	RealName        string  `comment:"用户实际名称"`
+	SellerName      string  `comment:"所属销售"`
+	OrderMoney      float64 `comment:"订单总价"`
+	CreateTime      string  `comment:"创建时间"`
+	SourceId        int     `comment:"来源ID"`
+	Source          string  `comment:"来源\n报告 :article\n活动 :activity"`
+	SourceTitle     string  `comment:"来源名称,活动或者报告标题"`
+	OrderStatus     int     `comment:"订单状态码"`
+	OrderStatusText string  `comment:"订单状态描述"`
+	StartDate       string  `comment:"开始日期"`
+	EndDate         string  `comment:"结束日期"`
+	InviteName      string  `description:"邀请人"`
+	PayTime         string  `comment:"订单付款时间"`
+	RefundTime      string  `comment:"订单付款时间"`
+	PaymentProject  string  `comment:"付款项目"`
+	HttpUrl         string  `description:"跳转地址"`
+}
+
+type UserOrderListResp struct {
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*OrderListResp
+}

+ 9 - 0
routers/commentsRouter.go

@@ -2095,6 +2095,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:OrderController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:OrderController"],
+        beego.ControllerComments{
+            Method: "OrderList",
+            Router: `/order/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ProductInteriorController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ProductInteriorController"],
         beego.ControllerComments{
             Method: "PvExport",

+ 1 - 0
routers/router.go

@@ -158,6 +158,7 @@ func init() {
 				&cygx.ContractAllocationController{},
 				&cygx.QuestionnaireController{},
 				&cygx.AskserieVideoController{},
+				&cygx.OrderController{},
 			),
 		),
 		web.NSNamespace("/advisory",