Browse Source

no message

xingzai 11 months ago
parent
commit
0d5268a51d
4 changed files with 102 additions and 13 deletions
  1. 32 13
      controllers/cygx/order.go
  2. 2 0
      models/cygx/orde.go
  3. 29 0
      models/cygx/user_business_card.go
  4. 39 0
      services/cygx/order.go

+ 32 - 13
controllers/cygx/order.go

@@ -114,6 +114,11 @@ func (this *OrderController) OrderList() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+	var mobiles []string
+	for _, v := range list {
+		mobiles = append(mobiles, v.Mobile)
+	}
+	inviteNameMap := cygxService.GetCygxUserBusinessCardMap(mobiles) // 根据手机号获取邀请人
 
 	for _, v := range list {
 		item := new(cygx.OrderListResp)
@@ -153,15 +158,20 @@ func (this *OrderController) OrderList() {
 		item.CompanyId = v.CompanyId
 		item.CompanyName = v.CompanyName
 		item.SellerName = v.SellerName
-		item.InviteName = "推荐人"
+		item.InviteName = inviteNameMap[v.Mobile]
 		item.PaymentProject = v.GoodsName
 
-		if v.OrderStatus == 2 {
-			item.PayTime = v.PayTime.Format(utils.FormatDateTime)
-		}
+		//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)
+			if v.GoodsId == 1 {
+				item.StartDate = v.StartDate.Format(utils.FormatDateTime)
+				item.EndDate = v.EndDate.Format(utils.FormatDateTime)
+			} else {
+				item.StartDate = v.StartDate.Format(utils.FormatDate)
+				item.EndDate = v.EndDate.Format(utils.FormatDate)
+			}
 		}
 		item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
 		resp.List = append(resp.List, item)
@@ -344,7 +354,11 @@ func (this *OrderController) OrderRefundList() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-
+	var mobiles []string
+	for _, v := range list {
+		mobiles = append(mobiles, v.Mobile)
+	}
+	inviteNameMap := cygxService.GetCygxUserBusinessCardMap(mobiles) // 根据手机号获取邀请人
 	for _, v := range list {
 		item := new(cygx.OrderListResp)
 		item.OrderCode = v.OrderCode
@@ -377,17 +391,22 @@ func (this *OrderController) OrderRefundList() {
 		item.CompanyId = v.CompanyId
 		item.CompanyName = v.CompanyName
 		item.SellerName = v.SellerName
-		item.InviteName = "推荐人"
+		item.InviteName = inviteNameMap[v.Mobile]
 		item.PaymentProject = v.GoodsName
 		item.RefundTime = v.RefundTime.Format(utils.FormatDateTime)
 		item.RefundRemark = v.RefundRemark
 
-		if v.OrderStatus == 2 {
-			item.PayTime = v.PayTime.Format(utils.FormatDateTime)
-		}
+		//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)
+			if v.GoodsId == 1 {
+				item.StartDate = v.StartDate.Format(utils.FormatDateTime)
+				item.EndDate = v.EndDate.Format(utils.FormatDateTime)
+			} else {
+				item.StartDate = v.StartDate.Format(utils.FormatDate)
+				item.EndDate = v.EndDate.Format(utils.FormatDate)
+			}
 		}
 		item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
 		resp.List = append(resp.List, item)

+ 2 - 0
models/cygx/orde.go

@@ -67,6 +67,8 @@ type CygxOrderResp struct {
 	CompanyName      string    `comment:"公司名称"`
 	RealName         string    `comment:"用户实际名称"`
 	SellerName       string    `comment:"所属销售"`
+	StartDate        time.Time `comment:"开始日期"`
+	EndDate          time.Time `comment:"结束日期"`
 	CreateTime       time.Time `comment:"创建时间"`
 	ModifyTime       time.Time `comment:"修改时间"`
 	RegisterPlatform int       `comment:"来源 1小程序,2:网页"`

+ 29 - 0
models/cygx/user_business_card.go

@@ -0,0 +1,29 @@
+package cygx
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserBusinessCard struct {
+	UserId           int       `comment:"用户ID"`
+	Mobile           string    `comment:"手机号"`
+	Email            string    `comment:"邮箱"`
+	CompanyName      string    `comment:"公司名称"`
+	RealName         string    `comment:"用户实际名称"`
+	InviteName       string    `comment:"用户实际名称"`
+	CreateTime       time.Time `comment:"创建时间"`
+	ModifyTime       time.Time `comment:"修改时间"`
+	RegisterPlatform int       `comment:"来源 1小程序,2:网页"`
+}
+
+func GetCygxUserBusinessCardList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxUserBusinessCard, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT *
+			FROM
+			cygx_user_business_card
+			WHERE 1 = 1 ` + condition
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 39 - 0
services/cygx/order.go

@@ -0,0 +1,39 @@
+package cygx
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hz_crm_api/models/cygx"
+	"hongze/hz_crm_api/services/alarm_msg"
+	"hongze/hz_crm_api/utils"
+)
+
+// GetCygxUserBusinessCardMap 获取手机号对应的邀请人
+func GetCygxUserBusinessCardMap(mobileArr []string) (mapResp map[string]string) {
+	lenArr := len(mobileArr)
+	if lenArr == 0 {
+		return
+	}
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg("获取手机号对应的邀请人,信息失败,GetCygxUserBusinessCardMap Err:"+err.Error(), 3)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+
+	condition = ` AND  mobile IN (` + utils.GetOrmInReplace(lenArr) + `)`
+	pars = append(pars, mobileArr)
+	list, e := cygx.GetCygxUserBusinessCardList(condition, pars, 0, lenArr)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetArticlList, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[string]string, 0)
+	for _, v := range list {
+		mapResp[v.Mobile] = v.InviteName
+	}
+	return
+}