yuliang1112 1 vuosi sitten
vanhempi
commit
399440daa8
8 muutettua tiedostoa jossa 185 lisäystä ja 12 poistoa
  1. 1 0
      .gitignore
  2. 26 0
      consts/project.go
  3. 41 0
      db/selection.go
  4. 7 1
      db/youngee.go
  5. 68 0
      handler/getSelectionInfo.go
  6. 31 0
      model/http_model/GetSelectionInfoRequest.go
  7. 10 10
      route/init.go
  8. 1 1
      service/auto_task.go

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+.history/

+ 26 - 0
consts/project.go

@@ -268,3 +268,29 @@ func GetKD(Kd string) string {
 	}
 	return "未知"
 }
+
+var TaskModel = map[int]string{
+	1: "悬赏任务",
+	2: "纯佣带货",
+}
+
+func GetTaskModel(task int) string {
+	toast, contain := TaskModel[task]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+var SampleModel = map[int]string{
+	1: "免费领样",
+	2: "垫付领样",
+}
+
+func GetSampleModel(sample int) string {
+	toast, contain := SampleModel[sample]
+	if contain {
+		return toast
+	}
+	return "未知"
+}

+ 41 - 0
db/selection.go

@@ -2,6 +2,11 @@ package db
 
 import (
 	"context"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"github.com/sirupsen/logrus"
+	"strconv"
+	"youngee_m_api/consts"
 	"youngee_m_api/model/gorm_model"
 	"youngee_m_api/model/http_model"
 )
@@ -17,3 +22,39 @@ func SelectionReviewNumber(ctx context.Context) (*http_model.ReviewNums, error)
 	ReviewNums.ReviewNums = reviewNums
 	return ReviewNums, err
 }
+
+func GetSelectionInfo(ctx context.Context, req *http_model.GetSelectionInfoRequest) (selectionInfoData http_model.SelectionInfoData, err error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model(gorm_model.YounggeeSelectionInfo{}).Where("enterprise_id = ?", req.EnterpriseId)
+	if req.UpdateAt != "" {
+		db = db.Where(fmt.Sprintf("updated_at like '%s%%'", req.UpdateAt))
+	}
+	// 查询总数
+	var total int64
+	if err = db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetSelectionInfo] error query mysql total, err:%+v", err)
+		return
+	}
+	var selectionInfos []*gorm_model.YounggeeSelectionInfo
+	// 查询该页数据
+	limit := req.PageSize
+	offset := req.PageSize * req.PageNum // assert pageNum start with 0
+	err = db.Order("updated_at desc").Limit(int(limit)).Offset(int(offset)).Find(&selectionInfos).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetSelectionInfo] error query mysql limit, err:%+v", err)
+		return
+	}
+	var selectionInfoPreviews []*http_model.SelectionInfoPreview
+	for _, selectionInfo := range selectionInfos {
+		selectionInfoPreview := new(http_model.SelectionInfoPreview)
+		selectionInfoPreview.SelectionId = selectionInfo.SelectionID
+		selectionInfoPreview.SelectionName = selectionInfo.SelectionName
+		selectionInfoPreview.UpdateAt = conv.MustString(selectionInfo.UpdatedAt, "")[:19]
+		selectionInfoPreview.TaskModel = consts.GetTaskModel(selectionInfo.TaskMode)
+		selectionInfoPreview.SampleModel = consts.GetSampleModel(selectionInfo.SampleMode)
+		selectionInfoPreviews = append(selectionInfoPreviews, selectionInfoPreview)
+	}
+	selectionInfoData.SelectionInfoPreview = selectionInfoPreviews
+	selectionInfoData.Total = strconv.FormatInt(total, 10)
+	return
+}

+ 7 - 1
db/youngee.go

@@ -19,7 +19,13 @@ func GetYoungeeRecords(ctx context.Context, talentId string) (*http_model.Younge
 		logrus.WithContext(ctx).Errorf("[GetyoungeeRecords] error query mysql total, err:%+v", err)
 		return nil, err
 	}
-
+	// 查询该页数据
+	//limit := pageSize
+	//offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("create_at desc").Find(&youngeeInfos).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetyoungeeRecords] error query mysql total, err:%+v", err)
+	}
 	var youngeeRecords []*http_model.YoungeeRecordsPreview
 	for _, youngeeInfo := range youngeeInfos {
 		pointIncome := strconv.FormatInt(youngeeInfo.PointIncome, 10)

+ 68 - 0
handler/getSelectionInfo.go

@@ -0,0 +1,68 @@
+package handler
+
+import (
+	"errors"
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapGetSelectionInfoHandler(ctx *gin.Context) {
+	handler := newGetSelectionInfoHandler(ctx)
+	BaseRun(handler)
+}
+
+type GetSelectionInfoHandler struct {
+	ctx  *gin.Context
+	req  *http_model.GetSelectionInfoRequest
+	resp *http_model.CommonResponse
+}
+
+func (g GetSelectionInfoHandler) getContext() *gin.Context {
+	return g.ctx
+}
+
+func (g GetSelectionInfoHandler) getResponse() interface{} {
+	return g.resp
+}
+
+func (g GetSelectionInfoHandler) getRequest() interface{} {
+	return g.req
+}
+
+func (g GetSelectionInfoHandler) run() {
+	//condition := pack.HttpRechargeRecordsRequestToCondition(g.req)
+	data, err := db.GetSelectionInfo(g.ctx, g.req)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[GetSelectionInfoHandler] call GetSelectionInfo err:%+v\n", err)
+		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, "")
+		logrus.Info("GetSelectionInfo fail,req:%+v", g.req)
+		return
+	}
+	g.resp.Data = data
+}
+
+func (g GetSelectionInfoHandler) checkParam() error {
+	var errs []error
+	if g.req.PageNum < 0 || g.req.PageSize <= 0 {
+		errs = append(errs, errors.New("page param error"))
+	}
+	g.req.PageNum--
+	if len(errs) != 0 {
+		return fmt.Errorf("check param errs:%+v", errs)
+	}
+	return nil
+}
+
+func newGetSelectionInfoHandler(ctx *gin.Context) *GetSelectionInfoHandler {
+	return &GetSelectionInfoHandler{
+		ctx:  ctx,
+		req:  http_model.NewGetSelectionInfoRequest(),
+		resp: http_model.NewGetSelectionInfoResponse(),
+	}
+}

+ 31 - 0
model/http_model/GetSelectionInfoRequest.go

@@ -0,0 +1,31 @@
+package http_model
+
+type GetSelectionInfoRequest struct {
+	PageSize     int32  `json:"page_size"`
+	PageNum      int32  `json:"page_num"`
+	EnterpriseId string `json:"enterprise_id"`
+	UpdateAt     string `json:"updated_at"`
+}
+
+type SelectionInfoPreview struct {
+	SelectionId   string `json:"selection_id"`
+	SelectionName string `json:"selection_name"`
+	TaskModel     string `json:"task_model"`
+	SampleModel   string `json:"sample_model"`
+	UpdateAt      string `json:"update_at"`
+}
+
+type SelectionInfoData struct {
+	SelectionInfoPreview []*SelectionInfoPreview `json:"selection_info_preview"`
+	Total                string                  `json:"total"`
+}
+
+func NewGetSelectionInfoRequest() *GetSelectionInfoRequest {
+	return new(GetSelectionInfoRequest)
+}
+
+func NewGetSelectionInfoResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SelectionInfoData)
+	return resp
+}

+ 10 - 10
route/init.go

@@ -109,21 +109,22 @@ func InitRoute(r *gin.Engine) {
 	}
 	u := r.Group("/youngee/m/user")
 	{
-		u.Use(middleware.LoginAuthMiddleware)
-		u.POST("/getUserList", handler.WrapGetUserListHandler)       // 查找员工账号信息
-		u.POST("/updateUserInfo", handler.WrapUpdateUserInfoHandler) // 修改员工信息
-		u.POST("/createUser", handler.WrapCreateUserHandler)         // 创建员工账号
-		u.POST("/disabledUser", handler.WrapDisabledUserHandler)     // 禁用员工账号
-		u.POST("/enterpriseUser", handler.WrapEnterpriseUserHandler) // 查找企业用户信息
-		u.POST("/creatorList", handler.WrapCreatorListHandler)       // 查找创作者信息
-		u.POST("/platformAccInfo", handler.WrapPlatformAccInfoHandler)
-		u.POST("/talentInfo", handler.WrapTalentInfoHandler)
+		//u.Use(middleware.LoginAuthMiddleware)
+		u.POST("/getUserList", handler.WrapGetUserListHandler)            // 查找员工账号信息
+		u.POST("/updateUserInfo", handler.WrapUpdateUserInfoHandler)      // 修改员工信息
+		u.POST("/createUser", handler.WrapCreateUserHandler)              // 创建员工账号
+		u.POST("/disabledUser", handler.WrapDisabledUserHandler)          // 禁用员工账号
+		u.POST("/enterpriseUser", handler.WrapEnterpriseUserHandler)      // 查找企业用户信息
+		u.POST("/creatorList", handler.WrapCreatorListHandler)            // 查找创作者信息
+		u.POST("/platformAccInfo", handler.WrapPlatformAccInfoHandler)    // 平台信息
+		u.POST("/talentInfo", handler.WrapTalentInfoHandler)              // 达人信息
 		u.POST("/accountInfo", handler.WrapAccountInfoHandler)            // 达人端账号信息
 		u.POST("/deleteAccount", handler.WrapDeleteAccountHandler)        // 解绑达人端账号
 		u.POST("/getTaskRecord", handler.WrapGetTaskRecordHandler)        // 创作者详细-任务记录
 		u.POST("/getYoungeeRecord", handler.WrapGetYoungeeRecordsHandler) // 创作者详细-youngee记录
 		u.POST("/modifyAccInfo", handler.WrapModifyAccInfoHandler)        // 更新用户账号信息
 		u.POST("/block", handler.WrapBlockHandler)                        // 创作者用户拉黑与还原
+		u.POST("/getSelectionInfo", handler.WrapGetSelectionInfoHandler)  // 用户管理选品记录
 	}
 	o := r.Group("/youngee/m/operate")
 	{
@@ -182,7 +183,6 @@ func InitRoute(r *gin.Engine) {
 		f.POST("/confirmInvoice", handler.WrapConfirmInvoiceHandler)           // 确认开票
 		f.POST("/rechargeRecords", handler.WrapRechargeRecordsHandler)         // 搜索充值记录
 		f.POST("/operateRecharge", handler.WrapOperateRechargeHandler)         // 充值记录的修改和确认操作
-
 	}
 	// 选品广场相关接口
 	s := r.Group("/youngee/m/selection")

+ 1 - 1
service/auto_task.go

@@ -35,7 +35,7 @@ func AutoTask() error {
 			}
 		}
 	}
-	//定时任务1 ,线下探店打卡的自动签收操作
+	//	定时任务1 ,线下探店打卡的自动签收操作
 	task1 := func() {
 		DB := db.GetReadDB(context.Background())
 		autoTaskTime := gorm_model.InfoAutoTask{}