zhou.xiaoning 4 лет назад
Родитель
Сommit
03d29a5004
5 измененных файлов с 252 добавлено и 215 удалено
  1. 1 1
      controllers/hsby/hsby.go
  2. 81 77
      docs/docs.go
  3. 81 77
      docs/swagger.json
  4. 60 57
      docs/swagger.yaml
  5. 29 3
      models/hsby.go

+ 1 - 1
controllers/hsby/hsby.go

@@ -1215,7 +1215,7 @@ type QueryMyCouponHoldsReq struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param accountIDs query string true "资金账户列表,格式:1,2,3"
-// @Success 200 {object} models.Couponhold
+// @Success 200 {object} models.MyCouponHold
 // @Failure 500 {object} app.Response
 // @Router /HSBY/QueryMyCouponHolds [get]
 // @Tags 定制【海商报业】

+ 81 - 77
docs/docs.go

@@ -2130,7 +2130,7 @@ var doc = `{
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.Couponhold"
+                            "$ref": "#/definitions/models.MyCouponHold"
                         }
                     },
                     "500": {
@@ -6469,82 +6469,6 @@ var doc = `{
                 }
             }
         },
-        "models.Couponhold": {
-            "type": "object",
-            "required": [
-                "couponholdid"
-            ],
-            "properties": {
-                "accountid": {
-                    "description": "资金账户ID",
-                    "type": "integer"
-                },
-                "conditionvalue": {
-                    "description": "条件阈值(可为0)",
-                    "type": "number"
-                },
-                "couponcategroy": {
-                    "description": "种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)",
-                    "type": "integer"
-                },
-                "couponholdid": {
-                    "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
-                },
-                "coupontypeid": {
-                    "description": "优惠券类型ID - SEQ_COUPONTYPE",
-                    "type": "integer"
-                },
-                "couponvalue": {
-                    "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
-                    "type": "number"
-                },
-                "createtime": {
-                    "description": "创建时间",
-                    "type": "string"
-                },
-                "enddate": {
-                    "description": "结束日期",
-                    "type": "string"
-                },
-                "giveapplyid": {
-                    "description": "发放申请ID(SEQ_COUPONGIVEAPPLY)",
-                    "type": "integer"
-                },
-                "holdstatus": {
-                    "description": "持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期",
-                    "type": "integer"
-                },
-                "isgeneral": {
-                    "description": "是否通用券 - 0:否 1:是",
-                    "type": "integer"
-                },
-                "limitedflag": {
-                    "description": "是否指定商品 - 0:不限 1:限制",
-                    "type": "integer"
-                },
-                "limitedgoodsids": {
-                    "description": "指定商品IDs[逗号分隔]",
-                    "type": "string"
-                },
-                "qty": {
-                    "description": "数量(按1平铺)",
-                    "type": "integer"
-                },
-                "startdate": {
-                    "description": "开始日期",
-                    "type": "string"
-                },
-                "userid": {
-                    "description": "用户ID",
-                    "type": "integer"
-                },
-                "userscope": {
-                    "description": "卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]",
-                    "type": "string"
-                }
-            }
-        },
         "models.Division": {
             "type": "object",
             "required": [
@@ -8210,6 +8134,86 @@ var doc = `{
                 }
             }
         },
+        "models.MyCouponHold": {
+            "type": "object",
+            "required": [
+                "couponholdid"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                },
+                "conditionvalue": {
+                    "description": "条件阈值(可为0)",
+                    "type": "number"
+                },
+                "couponcategroy": {
+                    "description": "种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)",
+                    "type": "integer"
+                },
+                "couponholdid": {
+                    "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "couponname": {
+                    "description": "优惠券名称",
+                    "type": "string"
+                },
+                "coupontypeid": {
+                    "description": "优惠券类型ID - SEQ_COUPONTYPE",
+                    "type": "integer"
+                },
+                "couponvalue": {
+                    "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "结束日期",
+                    "type": "string"
+                },
+                "giveapplyid": {
+                    "description": "发放申请ID(SEQ_COUPONGIVEAPPLY)",
+                    "type": "integer"
+                },
+                "holdstatus": {
+                    "description": "持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期",
+                    "type": "integer"
+                },
+                "isgeneral": {
+                    "description": "是否通用券 - 0:否 1:是",
+                    "type": "integer"
+                },
+                "limitedflag": {
+                    "description": "是否指定商品 - 0:不限 1:限制",
+                    "type": "integer"
+                },
+                "limitedgoodsids": {
+                    "description": "指定商品IDs[逗号分隔]",
+                    "type": "string"
+                },
+                "qty": {
+                    "description": "数量(按1平铺)",
+                    "type": "integer"
+                },
+                "startdate": {
+                    "description": "开始日期",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "userscope": {
+                    "description": "卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]",
+                    "type": "string"
+                }
+            }
+        },
         "models.OperationPrimaryMenu": {
             "type": "object",
             "properties": {

+ 81 - 77
docs/swagger.json

@@ -2114,7 +2114,7 @@
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.Couponhold"
+                            "$ref": "#/definitions/models.MyCouponHold"
                         }
                     },
                     "500": {
@@ -6453,82 +6453,6 @@
                 }
             }
         },
-        "models.Couponhold": {
-            "type": "object",
-            "required": [
-                "couponholdid"
-            ],
-            "properties": {
-                "accountid": {
-                    "description": "资金账户ID",
-                    "type": "integer"
-                },
-                "conditionvalue": {
-                    "description": "条件阈值(可为0)",
-                    "type": "number"
-                },
-                "couponcategroy": {
-                    "description": "种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)",
-                    "type": "integer"
-                },
-                "couponholdid": {
-                    "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
-                },
-                "coupontypeid": {
-                    "description": "优惠券类型ID - SEQ_COUPONTYPE",
-                    "type": "integer"
-                },
-                "couponvalue": {
-                    "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
-                    "type": "number"
-                },
-                "createtime": {
-                    "description": "创建时间",
-                    "type": "string"
-                },
-                "enddate": {
-                    "description": "结束日期",
-                    "type": "string"
-                },
-                "giveapplyid": {
-                    "description": "发放申请ID(SEQ_COUPONGIVEAPPLY)",
-                    "type": "integer"
-                },
-                "holdstatus": {
-                    "description": "持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期",
-                    "type": "integer"
-                },
-                "isgeneral": {
-                    "description": "是否通用券 - 0:否 1:是",
-                    "type": "integer"
-                },
-                "limitedflag": {
-                    "description": "是否指定商品 - 0:不限 1:限制",
-                    "type": "integer"
-                },
-                "limitedgoodsids": {
-                    "description": "指定商品IDs[逗号分隔]",
-                    "type": "string"
-                },
-                "qty": {
-                    "description": "数量(按1平铺)",
-                    "type": "integer"
-                },
-                "startdate": {
-                    "description": "开始日期",
-                    "type": "string"
-                },
-                "userid": {
-                    "description": "用户ID",
-                    "type": "integer"
-                },
-                "userscope": {
-                    "description": "卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]",
-                    "type": "string"
-                }
-            }
-        },
         "models.Division": {
             "type": "object",
             "required": [
@@ -8194,6 +8118,86 @@
                 }
             }
         },
+        "models.MyCouponHold": {
+            "type": "object",
+            "required": [
+                "couponholdid"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                },
+                "conditionvalue": {
+                    "description": "条件阈值(可为0)",
+                    "type": "number"
+                },
+                "couponcategroy": {
+                    "description": "种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)",
+                    "type": "integer"
+                },
+                "couponholdid": {
+                    "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "couponname": {
+                    "description": "优惠券名称",
+                    "type": "string"
+                },
+                "coupontypeid": {
+                    "description": "优惠券类型ID - SEQ_COUPONTYPE",
+                    "type": "integer"
+                },
+                "couponvalue": {
+                    "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "结束日期",
+                    "type": "string"
+                },
+                "giveapplyid": {
+                    "description": "发放申请ID(SEQ_COUPONGIVEAPPLY)",
+                    "type": "integer"
+                },
+                "holdstatus": {
+                    "description": "持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期",
+                    "type": "integer"
+                },
+                "isgeneral": {
+                    "description": "是否通用券 - 0:否 1:是",
+                    "type": "integer"
+                },
+                "limitedflag": {
+                    "description": "是否指定商品 - 0:不限 1:限制",
+                    "type": "integer"
+                },
+                "limitedgoodsids": {
+                    "description": "指定商品IDs[逗号分隔]",
+                    "type": "string"
+                },
+                "qty": {
+                    "description": "数量(按1平铺)",
+                    "type": "integer"
+                },
+                "startdate": {
+                    "description": "开始日期",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "userscope": {
+                    "description": "卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]",
+                    "type": "string"
+                }
+            }
+        },
         "models.OperationPrimaryMenu": {
             "type": "object",
             "properties": {

+ 60 - 57
docs/swagger.yaml

@@ -2014,62 +2014,6 @@ definitions:
         $ref: '#/definitions/models.Division'
         description: 省
     type: object
-  models.Couponhold:
-    properties:
-      accountid:
-        description: 资金账户ID
-        type: integer
-      conditionvalue:
-        description: 条件阈值(可为0)
-        type: number
-      couponcategroy:
-        description: 种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)
-        type: integer
-      couponholdid:
-        description: 优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)
-        type: integer
-      coupontypeid:
-        description: 优惠券类型ID - SEQ_COUPONTYPE
-        type: integer
-      couponvalue:
-        description: 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
-        type: number
-      createtime:
-        description: 创建时间
-        type: string
-      enddate:
-        description: 结束日期
-        type: string
-      giveapplyid:
-        description: 发放申请ID(SEQ_COUPONGIVEAPPLY)
-        type: integer
-      holdstatus:
-        description: 持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期
-        type: integer
-      isgeneral:
-        description: 是否通用券 - 0:否 1:是
-        type: integer
-      limitedflag:
-        description: 是否指定商品 - 0:不限 1:限制
-        type: integer
-      limitedgoodsids:
-        description: 指定商品IDs[逗号分隔]
-        type: string
-      qty:
-        description: 数量(按1平铺)
-        type: integer
-      startdate:
-        description: 开始日期
-        type: string
-      userid:
-        description: 用户ID
-        type: integer
-      userscope:
-        description: 卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]
-        type: string
-    required:
-    - couponholdid
-    type: object
   models.Division:
     properties:
       autoid:
@@ -3339,6 +3283,65 @@ definitions:
     - accountid
     - coupontypeid
     type: object
+  models.MyCouponHold:
+    properties:
+      accountid:
+        description: 资金账户ID
+        type: integer
+      conditionvalue:
+        description: 条件阈值(可为0)
+        type: number
+      couponcategroy:
+        description: 种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)
+        type: integer
+      couponholdid:
+        description: 优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      couponname:
+        description: 优惠券名称
+        type: string
+      coupontypeid:
+        description: 优惠券类型ID - SEQ_COUPONTYPE
+        type: integer
+      couponvalue:
+        description: 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
+        type: number
+      createtime:
+        description: 创建时间
+        type: string
+      enddate:
+        description: 结束日期
+        type: string
+      giveapplyid:
+        description: 发放申请ID(SEQ_COUPONGIVEAPPLY)
+        type: integer
+      holdstatus:
+        description: 持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期
+        type: integer
+      isgeneral:
+        description: 是否通用券 - 0:否 1:是
+        type: integer
+      limitedflag:
+        description: 是否指定商品 - 0:不限 1:限制
+        type: integer
+      limitedgoodsids:
+        description: 指定商品IDs[逗号分隔]
+        type: string
+      qty:
+        description: 数量(按1平铺)
+        type: integer
+      startdate:
+        description: 开始日期
+        type: string
+      userid:
+        description: 用户ID
+        type: integer
+      userscope:
+        description: 卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]
+        type: string
+    required:
+    - couponholdid
+    type: object
   models.OperationPrimaryMenu:
     properties:
       Children:
@@ -6692,7 +6695,7 @@ paths:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/models.Couponhold'
+            $ref: '#/definitions/models.MyCouponHold'
         "500":
           description: Internal Server Error
           schema:

+ 29 - 3
models/hsby.go

@@ -1668,12 +1668,38 @@ func GetMyCoupons(accountIDs string, goodsID, sellUserID int) ([]MyCoupon, error
 	return myCoupons, nil
 }
 
+// MyCouponHold 我的优惠卷持仓
+type MyCouponHold struct {
+	Couponholdid    int64     `json:"couponholdid"  xorm:"'COUPONHOLDID'" binding:"required"` // 优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)
+	Giveapplyid     int64     `json:"giveapplyid"  xorm:"'GIVEAPPLYID'"`                      // 发放申请ID(SEQ_COUPONGIVEAPPLY)
+	Accountid       int64     `json:"accountid"  xorm:"'ACCOUNTID'"`                          // 资金账户ID
+	Coupontypeid    int32     `json:"coupontypeid"  xorm:"'COUPONTYPEID'"`                    // 优惠券类型ID - SEQ_COUPONTYPE
+	Couponcategroy  int32     `json:"couponcategroy"  xorm:"'COUPONCATEGROY'"`                // 种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)
+	Conditionvalue  float64   `json:"conditionvalue"  xorm:"'CONDITIONVALUE'"`                // 条件阈值(可为0)
+	Couponvalue     float64   `json:"couponvalue"  xorm:"'COUPONVALUE'"`                      // 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
+	Limitedflag     int32     `json:"limitedflag"  xorm:"'LIMITEDFLAG'"`                      // 是否指定商品 - 0:不限 1:限制
+	Limitedgoodsids string    `json:"limitedgoodsids"  xorm:"'LIMITEDGOODSIDS'"`              // 指定商品IDs[逗号分隔]
+	Isgeneral       int32     `json:"isgeneral"  xorm:"'ISGENERAL'"`                          // 是否通用券 - 0:否 1:是
+	Userscope       string    `json:"userscope"  xorm:"'USERSCOPE'"`                          // 卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]
+	Userid          int64     `json:"userid"  xorm:"'USERID'"`                                // 用户ID
+	Qty             int64     `json:"qty"  xorm:"'QTY'"`                                      // 数量(按1平铺)
+	Startdate       time.Time `json:"startdate"  xorm:"'STARTDATE'"`                          // 开始日期
+	Holdstatus      int32     `json:"holdstatus"  xorm:"'HOLDSTATUS'"`                        // 持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期
+	Enddate         time.Time `json:"enddate"  xorm:"'ENDDATE'"`                              // 结束日期
+	Createtime      time.Time `json:"createtime"  xorm:"'CREATETIME'"`                        // 创建时间
+
+	Couponname string `json:"couponname"  xorm:"'COUPONNAME'"` // 优惠券名称
+}
+
 // GetMyCouponHolds 获取优惠卷明细
-func GetMyCouponHolds(accountIDs string) ([]Couponhold, error) {
+func GetMyCouponHolds(accountIDs string) ([]MyCouponHold, error) {
 	engine := db.GetEngine()
 
-	myCouponHolds := make([]Couponhold, 0)
-	if err := engine.Where(fmt.Sprintf("ACCOUNTID in (%s)", accountIDs)).Find(&myCouponHolds); err != nil {
+	myCouponHolds := make([]MyCouponHold, 0)
+	if err := engine.Table("COUPONHOLD CH").
+		Select(`CH.*, CT.COUPONNAME`).
+		Join("INNER", "COUPONTYPE CT", "CT.COUPONTYPEID = CH.COUPONTYPEID").
+		Where(fmt.Sprintf("CH.ACCOUNTID in (%s)", accountIDs)).Find(&myCouponHolds); err != nil {
 		return nil, err
 	}