Browse Source

wip:协议归档邮件

wkyuer 1 month ago
parent
commit
7a58933f47

+ 3 - 1
internal/controller/productHandler.go

@@ -15,9 +15,11 @@ import (
 func GetProductListHandler(r *ghttp.Request) {
 func GetProductListHandler(r *ghttp.Request) {
 	rData, err := func() (interface{}, error) {
 	rData, err := func() (interface{}, error) {
 		subject := r.Get("subject").Int()
 		subject := r.Get("subject").Int()
+		showAll := r.Get("showAll").Int()
+
 		u := jyutil.GetUserMsgFromCtx(r.Context())
 		u := jyutil.GetUserMsgFromCtx(r.Context())
 		//常规商品
 		//常规商品
-		productList := service.Product().GetList(u.EntDeptId, subject)
+		productList := service.Product().GetList(u.EntDeptId, showAll == 1, subject)
 		var rProjectJson []g.Map
 		var rProjectJson []g.Map
 		bytesArr, err := json.Marshal(productList)
 		bytesArr, err := json.Marshal(productList)
 		if err != nil {
 		if err != nil {

+ 7 - 3
internal/logic/productManager/productManager.go

@@ -53,7 +53,7 @@ func getInitJyProduct(ctx context.Context) (*sProductManager, error) {
 
 
 		deptProductPower = map[string]map[int]bool{}
 		deptProductPower = map[string]map[int]bool{}
 	)
 	)
-	classList, err := g.DB().Query(ctx, "SELECT * FROM jy_product_class WHERE state =1")
+	classList, err := g.DB().Query(ctx, "SELECT * FROM jy_product_class")
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -61,7 +61,7 @@ func getInitJyProduct(ctx context.Context) (*sProductManager, error) {
 		return nil, err
 		return nil, err
 	}
 	}
 	//查询所有产品
 	//查询所有产品
-	productList, err := g.DB().Query(ctx, "SELECT * FROM jy_product_item WHERE state =1")
+	productList, err := g.DB().Query(ctx, "SELECT * FROM jy_product_item")
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -123,7 +123,7 @@ func getInitJyProduct(ctx context.Context) (*sProductManager, error) {
 }
 }
 
 
 // GetList 获取商品列表
 // GetList 获取商品列表
-func (p *sProductManager) GetList(deptId int64, buySet ...int) []*model.ProductTop {
+func (p *sProductManager) GetList(deptId int64, all bool, buySet ...int) []*model.ProductTop {
 	var (
 	var (
 		result []*model.ProductTop
 		result []*model.ProductTop
 		set    int = 3 //1个人 2企业 3个人和企业都支持
 		set    int = 3 //1个人 2企业 3个人和企业都支持
@@ -136,6 +136,10 @@ func (p *sProductManager) GetList(deptId int64, buySet ...int) []*model.ProductT
 	for _, top := range p.ProductRoot {
 	for _, top := range p.ProductRoot {
 		var t []*model.ProductClass
 		var t []*model.ProductClass
 		for _, ps := range top.ProductClassList {
 		for _, ps := range top.ProductClassList {
+			if all {
+				t = append(t, ps)
+				continue
+			}
 			if pMap := p.DeptProductPower[ps.Code]; len(pMap) > 0 {
 			if pMap := p.DeptProductPower[ps.Code]; len(pMap) > 0 {
 				// todo 上线前删除注释
 				// todo 上线前删除注释
 				//if !pMap[gconv.Int(deptId)] {
 				//if !pMap[gconv.Int(deptId)] {

+ 2 - 0
internal/model/product.go

@@ -9,6 +9,7 @@ type (
 	}
 	}
 	ProductClass struct {
 	ProductClass struct {
 		ClassId     int64      `json:"id,omitempty"`
 		ClassId     int64      `json:"id,omitempty"`
+		State       int        `json:"state"`      //状态 1可售卖 0仅展示 -1删除
 		TopClass    string     `json:"top_class"`  //一级分类
 		TopClass    string     `json:"top_class"`  //一级分类
 		ClassName   string     `json:"class_name"` //产品类名称
 		ClassName   string     `json:"class_name"` //产品类名称
 		Code        string     `json:"code"`
 		Code        string     `json:"code"`
@@ -24,6 +25,7 @@ type (
 	}
 	}
 	Product struct {
 	Product struct {
 		Id             int64                  `json:"id"`
 		Id             int64                  `json:"id"`
+		State          int                    `json:"state"` //状态 1可售卖 0仅展示 -1删除
 		ProductClassId int64                  `json:"product_class_id,omitempty"`
 		ProductClassId int64                  `json:"product_class_id,omitempty"`
 		Code           string                 `json:"code"`
 		Code           string                 `json:"code"`
 		Name           string                 `json:"name"`                     //产品名称
 		Name           string                 `json:"name"`                     //产品名称

+ 1 - 1
internal/service/producttManager.go

@@ -9,7 +9,7 @@ import "jyOrderManager/internal/model"
 type (
 type (
 	IProducttManager interface {
 	IProducttManager interface {
 		// CheckParam 校验参数
 		// CheckParam 校验参数
-		GetList(deptId int64, buySet ...int) []*model.ProductTop
+		GetList(deptId int64, all bool, buySet ...int) []*model.ProductTop
 		// GetPriceConfig 获取价格计算
 		// GetPriceConfig 获取价格计算
 		GetPriceConfig(productCode string) (*model.PriceConfig, error)
 		GetPriceConfig(productCode string) (*model.PriceConfig, error)
 		// GetProductTopClass 获取商品详情
 		// GetProductTopClass 获取商品详情