Преглед на файлове

*商城商品*过滤功能:
1、用账户登录系统后只能看到所属机构发的商品;
2、机构登录后只能看自己发的商品。

zhou.xiaoning преди 4 години
родител
ревизия
15057f3ddf
променени са 6 файла, в които са добавени 341 реда и са изтрити 10 реда
  1. 27 2
      controllers/hsby/hsby.go
  2. 94 2
      docs/docs.go
  3. 94 2
      docs/swagger.json
  4. 65 1
      docs/swagger.yaml
  5. 59 3
      models/hsby.go
  6. 2 0
      routers/router.go

+ 27 - 2
controllers/hsby/hsby.go

@@ -1063,7 +1063,7 @@ func QueryHsbyMarkets(c *gin.Context) {
 type QueryHsbyMarketGoodsesReq struct {
 	app.PageInfo
 	MarketIDs    string `form:"marketIDs" binding:"required"`
-	AccountID    int    `form:"accountID"`
+	AccountID    int    `form:"accountID" binding:"required"`
 	CategoryID   int    `form:"categoryID"`
 	GoodsIDs     string `form:"goodsIDs"`
 	CouponTypeID int    `form:"couponTypeID"`
@@ -1076,7 +1076,7 @@ type QueryHsbyMarketGoodsesReq struct {
 // @Param page query int false "页码"
 // @Param pagesize query int false "每页条数"
 // @Param marketIDs query string true "市场ID列表,格式:1,2,3"
-// @Param accountID query int false "资金账户,主要用于判断商品是否有可用的优惠卷;如未登录可不传。"
+// @Param accountID query int true "资金账户,用于判断商品是否有可用的优惠卷;同时只显示此账户所属机构下的商城委托单。"
 // @Param categoryID query int false "类别ID"
 // @Param goodsIDs query string false "商品ID列表,格式:1,2,3。主要用于商品搜索。"
 // @Param couponTypeID query int false "优惠券类型ID,主要用于显示优惠卷对应的商品列表。"
@@ -1333,3 +1333,28 @@ func QueryMyUsedCoupon(c *gin.Context) {
 	logger.GetLogger().Debugln("QueryMyUsedCoupon successed: %v", myCoupons)
 	appG.Response(http.StatusOK, e.SUCCESS, myCoupons)
 }
+
+// QueryClientFixedADConfigs 获取终端固定广告配置
+// @Summary 获取终端固定广告配置
+// @Produce json
+// @Security ApiKeyAuth
+// @Success 200 {object} models.Clientfixedadconfig
+// @Failure 500 {object} app.Response
+// @Router /HSBY/QueryClientFixedADConfigs [get]
+// @Tags 定制【海商报业】
+func QueryClientFixedADConfigs(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取数据
+	adConfigs, err := models.GetClientFixedADConfigs()
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryClientFixedADConfigs failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 查询成功返回
+	logger.GetLogger().Debugln("QueryClientFixedADConfigs successed: %v", adConfigs)
+	appG.Response(http.StatusOK, e.SUCCESS, adConfigs)
+}

+ 94 - 2
docs/docs.go

@@ -1835,6 +1835,36 @@ var doc = `{
                 }
             }
         },
+        "/HSBY/QueryClientFixedADConfigs": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "获取终端固定广告配置",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.Clientfixedadconfig"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyBuyMyTradeDetail": {
             "get": {
                 "security": [
@@ -2077,9 +2107,10 @@ var doc = `{
                     },
                     {
                         "type": "integer",
-                        "description": "资金账户,主要用于判断商品是否有可用的优惠卷;如未登录可不传。",
+                        "description": "资金账户,用于判断商品是否有可用的优惠卷;同时只显示此账户所属机构下的商城委托单。",
                         "name": "accountID",
-                        "in": "query"
+                        "in": "query",
+                        "required": true
                     },
                     {
                         "type": "integer",
@@ -7789,6 +7820,67 @@ var doc = `{
                 }
             }
         },
+        "models.Clientfixedadconfig": {
+            "type": "object",
+            "required": [
+                "adsort",
+                "adtype"
+            ],
+            "properties": {
+                "adsort": {
+                    "description": "排序",
+                    "type": "integer"
+                },
+                "adtype": {
+                    "description": "广告位类型 - 1:新品抢购(HSBY)",
+                    "type": "integer"
+                },
+                "areauserid": {
+                    "description": "所属机构ID",
+                    "type": "integer"
+                },
+                "createdate": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "imagepath": {
+                    "description": "图片",
+                    "type": "string"
+                },
+                "isshow": {
+                    "description": "是否展示 - 0:不展示 1:展示",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "操作人",
+                    "type": "integer"
+                },
+                "recsize": {
+                    "description": "推荐尺寸",
+                    "type": "string"
+                },
+                "title": {
+                    "description": "标题",
+                    "type": "string"
+                },
+                "updatedate": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "urlcontent": {
+                    "description": "链接(地址或商品ID)",
+                    "type": "string"
+                },
+                "urltype": {
+                    "description": "链接类型 - 1:直接地址 2:商品ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Division": {
             "type": "object",
             "required": [

+ 94 - 2
docs/swagger.json

@@ -1819,6 +1819,36 @@
                 }
             }
         },
+        "/HSBY/QueryClientFixedADConfigs": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "获取终端固定广告配置",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.Clientfixedadconfig"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyBuyMyTradeDetail": {
             "get": {
                 "security": [
@@ -2061,9 +2091,10 @@
                     },
                     {
                         "type": "integer",
-                        "description": "资金账户,主要用于判断商品是否有可用的优惠卷;如未登录可不传。",
+                        "description": "资金账户,用于判断商品是否有可用的优惠卷;同时只显示此账户所属机构下的商城委托单。",
                         "name": "accountID",
-                        "in": "query"
+                        "in": "query",
+                        "required": true
                     },
                     {
                         "type": "integer",
@@ -7773,6 +7804,67 @@
                 }
             }
         },
+        "models.Clientfixedadconfig": {
+            "type": "object",
+            "required": [
+                "adsort",
+                "adtype"
+            ],
+            "properties": {
+                "adsort": {
+                    "description": "排序",
+                    "type": "integer"
+                },
+                "adtype": {
+                    "description": "广告位类型 - 1:新品抢购(HSBY)",
+                    "type": "integer"
+                },
+                "areauserid": {
+                    "description": "所属机构ID",
+                    "type": "integer"
+                },
+                "createdate": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "imagepath": {
+                    "description": "图片",
+                    "type": "string"
+                },
+                "isshow": {
+                    "description": "是否展示 - 0:不展示 1:展示",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "操作人",
+                    "type": "integer"
+                },
+                "recsize": {
+                    "description": "推荐尺寸",
+                    "type": "string"
+                },
+                "title": {
+                    "description": "标题",
+                    "type": "string"
+                },
+                "updatedate": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "urlcontent": {
+                    "description": "链接(地址或商品ID)",
+                    "type": "string"
+                },
+                "urltype": {
+                    "description": "链接类型 - 1:直接地址 2:商品ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Division": {
             "type": "object",
             "required": [

+ 65 - 1
docs/swagger.yaml

@@ -2593,6 +2593,51 @@ definitions:
         $ref: '#/definitions/models.Division'
         description: 省
     type: object
+  models.Clientfixedadconfig:
+    properties:
+      adsort:
+        description: 排序
+        type: integer
+      adtype:
+        description: 广告位类型 - 1:新品抢购(HSBY)
+        type: integer
+      areauserid:
+        description: 所属机构ID
+        type: integer
+      createdate:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人
+        type: integer
+      imagepath:
+        description: 图片
+        type: string
+      isshow:
+        description: 是否展示 - 0:不展示 1:展示
+        type: integer
+      modifierid:
+        description: 操作人
+        type: integer
+      recsize:
+        description: 推荐尺寸
+        type: string
+      title:
+        description: 标题
+        type: string
+      updatedate:
+        description: 更新时间
+        type: string
+      urlcontent:
+        description: 链接(地址或商品ID)
+        type: string
+      urltype:
+        description: 链接类型 - 1:直接地址 2:商品ID
+        type: integer
+    required:
+    - adsort
+    - adtype
+    type: object
   models.Division:
     properties:
       autoid:
@@ -7245,6 +7290,24 @@ paths:
       summary: 获取我的订单与包裹数量
       tags:
       - 定制【海商报业】
+  /HSBY/QueryClientFixedADConfigs:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.Clientfixedadconfig'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 获取终端固定广告配置
+      tags:
+      - 定制【海商报业】
   /HSBY/QueryHsbyBuyMyTradeDetail:
     get:
       parameters:
@@ -7391,9 +7454,10 @@ paths:
         name: marketIDs
         required: true
         type: string
-      - description: 资金账户,主要用于判断商品是否有可用的优惠卷;如未登录可不传
+      - description: 资金账户,用于判断商品是否有可用的优惠卷;同时只显示此账户所属机构下的商城委托单
         in: query
         name: accountID
+        required: true
         type: integer
       - description: 类别ID
         in: query

+ 59 - 3
models/hsby.go

@@ -208,6 +208,28 @@ func (Hiscouponhold) TableName() string {
 	return "HIS_COUPONHOLD"
 }
 
+// Clientfixedadconfig 终端固定广告配置 - 通用功能
+type Clientfixedadconfig struct {
+	Adtype     int32     `json:"adtype"  xorm:"'ADTYPE'" binding:"required"` // 广告位类型 - 1:新品抢购(HSBY)
+	Adsort     int32     `json:"adsort"  xorm:"'ADSORT'" binding:"required"` // 排序
+	Imagepath  string    `json:"imagepath"  xorm:"'IMAGEPATH'"`              // 图片
+	Recsize    string    `json:"recsize"  xorm:"'RECSIZE'"`                  // 推荐尺寸
+	Title      string    `json:"title"  xorm:"'TITLE'"`                      // 标题
+	Urltype    int32     `json:"urltype"  xorm:"'URLTYPE'"`                  // 链接类型 - 1:直接地址 2:商品ID
+	Urlcontent string    `json:"urlcontent"  xorm:"'URLCONTENT'"`            // 链接(地址或商品ID)
+	Isshow     int32     `json:"isshow"  xorm:"'ISSHOW'"`                    // 是否展示 - 0:不展示 1:展示
+	Createdate time.Time `json:"createdate"  xorm:"'CREATEDATE'"`            // 创建时间
+	Creatorid  int64     `json:"creatorid"  xorm:"'CREATORID'"`              // 创建人
+	Updatedate time.Time `json:"updatedate"  xorm:"'UPDATEDATE'"`            // 更新时间
+	Modifierid int64     `json:"modifierid"  xorm:"'MODIFIERID'"`            // 操作人
+	Areauserid int64     `json:"areauserid"  xorm:"'AREAUSERID'"`            // 所属机构ID
+}
+
+// TableName is CLIENT_FIXEDADCONFIG
+func (Clientfixedadconfig) TableName() string {
+	return "CLIENT_FIXEDADCONFIG"
+}
+
 // HsbyTopGoods 热卖商品(二级市场挂牌点选)
 type HsbyTopGoods struct {
 	Goodsid      int64   `json:"goodsid"  xorm:"'GOODSID'" binding:"required"`     // 商品ID(自增ID SEQ_GOODS)
@@ -1021,7 +1043,7 @@ func GetHsbySellMyTradeDetails(accountIDs string) ([]HsbySellMyDetail, error) {
 	marketIDs := "" // 我的闲置-发布中: 二级市场卖方向成交单(包括历史成交单)
 	// 默认取 TradeMode = 16
 	for _, v := range markets {
-		if v.Trademode == 16 {
+		if v.Trademode == 16 || v.Trademode == 70 {
 			if len(marketIDs) == 0 {
 				marketIDs = strconv.Itoa(int(v.Marketid))
 			} else {
@@ -1248,7 +1270,7 @@ func GetHsbyBuyMyTradeDetails(accountIDs string) ([]HsbyBuyMyTradeDetail, error)
 	marketIDs := "" // 我的订单包括一二级市场卖方向成交单(包括历史成交单)
 	// 默认取 TradeMode = 16
 	for _, v := range markets {
-		if v.Trademode == 16 || v.Trademode == 71 {
+		if v.Trademode == 16 || v.Trademode == 71 || v.Trademode == 70 {
 			if len(marketIDs) == 0 {
 				marketIDs = strconv.Itoa(int(v.Marketid))
 			} else {
@@ -1538,6 +1560,27 @@ type HsbyMarketGoods struct {
 func GetHsbyMarketGoodses(marketIDs string, accountID, categoryID int, goodsIDs string, couponTypeID int) ([]HsbyMarketGoods, error) {
 	engine := db.GetEngine()
 
+	// 新需求:当账号登录后传入accountID时,只显示此账户所属会员下面的商城商品(注意会员账号的所属会员就是自己)
+	// 获取accountID对应账户的所属会员UserID
+	var memberUserIDs []string
+	if err := engine.Table("USERACCOUNT U").
+		Select("to_char(U.MEMBERUSERID) MEMBERUSERID").
+		Join("INNER", "TAACCOUNT TA", "TA.RELATEDUSERID = U.USERID").
+		Where("TA.ACCOUNTID = ?", accountID).
+		Find(&memberUserIDs); err != nil {
+		return nil, err
+	}
+
+	// 获取此会员下所有的资金账户
+	var memberAccountIDs []string
+	if err := engine.Table("TAACCOUNT").
+		Select("to_char(ACCOUNTID) ACCOUNTID").
+		Where(fmt.Sprintf("RELATEDUSERID in (%s)", strings.Join(memberUserIDs, ","))).
+		Find(&memberAccountIDs); err != nil {
+		fmt.Println(err.Error())
+		return nil, err
+	}
+
 	// 获取优惠卷类型信息
 	var couponType Coupontype
 	if _, err := engine.Where("ISVALID = 1 and COUPONTYPEID = ?", couponTypeID).Get(&couponType); err != nil {
@@ -1560,7 +1603,8 @@ func GetHsbyMarketGoodses(marketIDs string, accountID, categoryID int, goodsIDs
 		Join("LEFT", "TAACCOUNT TA", "TA.ACCOUNTID = T.ACCOUNTID").
 		Join("LEFT", "USERINFO U", "U.USERID = TA.RELATEDUSERID").
 		Where(fmt.Sprintf("T.MARKETID in (%s)", marketIDs)).
-		And("T.ORDERSTATUS in (3,7) and T.BUYORSELL = 1 and (T.ORDERQTY - T.TRADEQTY - T.CANCELQTY) > 0")
+		And("T.ORDERSTATUS in (3,7) and T.BUYORSELL = 1 and (T.ORDERQTY - T.TRADEQTY - T.CANCELQTY) > 0").
+		And(fmt.Sprintf("T.ACCOUNTID in (%s)", strings.Join(memberAccountIDs, ",")))
 	if categoryID != 0 {
 		session = session.And("GX.CATEGORYID = ?", categoryID)
 	}
@@ -1936,3 +1980,15 @@ func GetMyUsedCoupon(accountIDs string) ([]MyUsedCoupon, error) {
 
 	return myUsedCoupons, nil
 }
+
+// GetClientFixedADConfigs 获取终端固定广告配置
+func GetClientFixedADConfigs() ([]Clientfixedadconfig, error) {
+	engine := db.GetEngine()
+
+	clientFixedADConfigs := make([]Clientfixedadconfig, 0)
+	if err := engine.Where("ISSHOW = 1").Find(&clientFixedADConfigs); err != nil {
+		return nil, err
+	}
+
+	return clientFixedADConfigs, nil
+}

+ 2 - 0
routers/router.go

@@ -291,6 +291,8 @@ func InitRouter() *gin.Engine {
 		hsbyR.GET("/QueryMyCouponHolds", hsby.QueryMyCouponHolds)
 		// 已使用优惠卷查询
 		hsbyR.GET("/QueryMyUsedCoupon", hsby.QueryMyUsedCoupon)
+		// 获取终端固定广告配置
+		hsbyR.GET("/QueryClientFixedADConfigs", hsby.QueryClientFixedADConfigs)
 	}
 
 	// ***************************** 企业风险管理(app)***************************