Преглед изворни кода

查业务关联单接口增加关联量字段
查现货商品详情不过滤停用的品牌

zou.yingbin пре 4 година
родитељ
комит
698c9b134c
7 измењених фајлова са 130 додато и 20 уклоњено
  1. 6 2
      docs/docs.go
  2. 6 2
      docs/swagger.json
  3. 5 2
      docs/swagger.yaml
  4. 1 0
      go.mod
  5. 2 0
      go.sum
  6. 26 14
      models/ermcp3.go
  7. 84 0
      mtpcache/goods.go

+ 6 - 2
docs/docs.go

@@ -22105,7 +22105,11 @@ var doc = `{
                     "type": "number"
                 },
                 "pricedqty": {
-                    "description": "已关联数量 | 已定价量",
+                    "description": "已定价量",
+                    "type": "number"
+                },
+                "relatedmiddlegoodsqty": {
+                    "description": "已关联量(套保品种)(期货)",
                     "type": "number"
                 },
                 "spotcontractid": {
@@ -36347,7 +36351,7 @@ var doc = `{
                     "type": "string"
                 },
                 "isvalid": {
-                    "description": "是否有效",
+                    "description": "是否有效 0-无效 1-有效",
                     "type": "integer"
                 }
             }

+ 6 - 2
docs/swagger.json

@@ -22089,7 +22089,11 @@
                     "type": "number"
                 },
                 "pricedqty": {
-                    "description": "已关联数量 | 已定价量",
+                    "description": "已定价量",
+                    "type": "number"
+                },
+                "relatedmiddlegoodsqty": {
+                    "description": "已关联量(套保品种)(期货)",
                     "type": "number"
                 },
                 "spotcontractid": {
@@ -36331,7 +36335,7 @@
                     "type": "string"
                 },
                 "isvalid": {
-                    "description": "是否有效",
+                    "description": "是否有效 0-无效 1-有效",
                     "type": "integer"
                 }
             }

+ 5 - 2
docs/swagger.yaml

@@ -6139,7 +6139,10 @@ definitions:
         description: 套保比例
         type: number
       pricedqty:
-        description: 已关联数量 | 已定价量
+        description: 已定价量
+        type: number
+      relatedmiddlegoodsqty:
+        description: 已关联量(套保品种)(期货)
         type: number
       spotcontractid:
         description: 合同编号
@@ -16700,7 +16703,7 @@ definitions:
         description: 品牌名称
         type: string
       isvalid:
-        description: 是否有效
+        description: 是否有效 0-无效 1-有效
         type: integer
     type: object
   models.XHDeliveryGoods:

+ 1 - 0
go.mod

@@ -33,6 +33,7 @@ require (
 	github.com/mattn/go-isatty v0.0.13 // indirect
 	github.com/mattn/go-oci8 v0.0.8
 	github.com/mattn/go-sqlite3 v1.14.6 // indirect
+	github.com/muesli/cache2go v0.0.0-20211005105910-8e46465cca4a // indirect
 	github.com/onsi/ginkgo v1.12.0 // indirect
 	github.com/onsi/gomega v1.9.0 // indirect
 	github.com/pkg/errors v0.9.1 // indirect

+ 2 - 0
go.sum

@@ -144,6 +144,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
 github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/muesli/cache2go v0.0.0-20211005105910-8e46465cca4a h1:IZxQOY9gAiiGGuEdlOBnqaC3yumj8UvyQluBNqGP2Ek=
+github.com/muesli/cache2go v0.0.0-20211005105910-8e46465cca4a/go.mod h1:WERUkUryfUWlrHnFSO/BEUZ+7Ns8aZy7iVOGewxKzcc=
 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

+ 26 - 14
models/ermcp3.go

@@ -2463,24 +2463,34 @@ func (r *XHDeliveryGoods) addBrandlst(lstBrand []XHBRAND) {
 
 // XHBRAND 现货品种/品牌
 type XHBRAND struct {
-	BRANDID         int64  `json:"brandid"`   // 品牌id
-	BRANDNAME       string `json:"brandname"` // 品牌名称
-	DELIVERYGOODSID int64  `json:"-"`         // 品种ID
-	AREAUSERID      int64  `json:"-"`         // 用户id
-	ISVALID         int32  `json:"isvalid"`   // 是否有效
+	BRANDID         int64  `json:"brandid"  xorm:"'BRANDID'"`     // 品牌id
+	BRANDNAME       string `json:"brandname"  xorm:"'BRANDNAME'"` // 品牌名称
+	DELIVERYGOODSID int64  `json:"-"  xorm:"'DELIVERYGOODSID'"`   // 品种ID
+	AREAUSERID      int64  `json:"-"  xorm:"'AREAUSERID'"`        // 用户id
+	ISVALID         int32  `json:"isvalid"  xorm:"'ISVALID'"`     // 是否有效 0-无效 1-有效
 }
 
 // GetDataEx 获取现货品种/品牌
 func (r *XHBRAND) GetDataEx() (interface{}, error) {
 	sData := make([]XHBRAND, 0)
-	m := Ermcp3Brand{AREAUSERID: r.AREAUSERID, DELIVERYGOODSID: r.DELIVERYGOODSID}
-	d, err := m.GetData()
-	if err == nil {
-		for _, v := range d {
-			sData = append(sData, XHBRAND{DELIVERYGOODSID: v.DELIVERYGOODSID,
-				BRANDID: v.BRANDID, BRANDNAME: v.BRANDNAME, ISVALID: v.ISVALID})
-		}
-	}
+	var sqlId utils.SQLVal = `
+SELECT DGFACTORYITEMID,
+        t.DELIVERYGOODSID,
+        to_char(t.DGFACTORYITEMTYPEID) brandid,
+        t.DGFACTORYITEMVALUE brandname,
+        to_char(t.WAREHOUSEID) WAREHOUSEID,
+        t.ISVALID,
+        t.ORDERINDEX,
+        g.areauserid
+   FROM DGFACTORYITEM t
+   left join deliverygoods g
+     on t.deliverygoodsid = g.deliverygoodsid
+  WHERE t.dgfactoryitemtypeid = 2
+    and t.orderindex = 1
+`
+	sqlId.AndEx("g.areauserid", r.AREAUSERID, r.AREAUSERID > 0)
+	sqlId.AndEx("g.deliverygoodsid", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	err := db.GetEngine().SQL(sqlId.String()).Find(&sData)
 	return sData, err
 }
 
@@ -3020,7 +3030,8 @@ type Ermcp3SCMiddleGoods struct {
 	UNITID                int32   `json:"unitid"  xorm:"'UNITID'"`                                       // 现货单位id
 	VATRATE               float64 `json:"vatrate"  xorm:"'VATRATE'"`                                     // 增值税率
 	MIDDLEGOODSPRICEDQTY3 float64 `json:"middlegoodspricedqty3"  xorm:"'MIDDLEGOODSPRICEDQTY3'"`         // 应套保数量 = MiddleGoodsPricedQty2 *  套保比率
-	PRICEDQTY             float64 `json:"pricedqty"  xorm:"'PRICEDQTY'"`                                 // 已关联数量 | 已定价量
+	RELATEDMIDDLEGOODSQTY float64 `json:"relatedmiddlegoodsqty"  xorm:"'RELATEDMIDDLEGOODSQTY'"`         // 已关联量(套保品种)(期货)
+	PRICEDQTY             float64 `json:"pricedqty"  xorm:"'PRICEDQTY'"`                                 // 已定价量
 	MIDDLEGOODSID         int64   `json:"middlegoodsid"  xorm:"'MIDDLEGOODSID'"`                         // 套保品种ID
 	NEEDHEDGERATIO        float64 `json:"needhedgeratio"  xorm:"'NEEDHEDGERATIO'"`                       // 套保比例
 	CONTRACTTYPE          int     `json:"contracttype"  xorm:"'CONTRACTTYPE'"`                           // 合同类型 1:采购 -1:销售
@@ -3060,6 +3071,7 @@ select s.userid,
        w.unitid,
        w.vatrate,
        t.middlegoodspricedqty3,
+       t.relatedmiddlegoodsqty,
        t.pricedqty,
        t.middlegoodsid,
        mg.needhedgeratio,

+ 84 - 0
mtpcache/goods.go

@@ -0,0 +1,84 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/10/27 14:20
+* @Modify  : 2021/10/27 14:20
+* @note    : 商品信息缓存
+ */
+
+package mtpcache
+
+import (
+	"mtp2_if/db"
+	"mtp2_if/utils"
+	"sync"
+	"time"
+)
+
+// GoodsCache 商品缓存
+type GoodsCache struct {
+	mtx  sync.RWMutex
+	data map[int64]Goods
+	last time.Time
+}
+
+// Load 加载数据
+func (r *GoodsCache) Load() {
+
+}
+
+// Goods 商品信息
+type Goods struct {
+	GOODSID         int64   `json:"goodsid"  xorm:"'GOODSID'"`                 // 商品ID(自增ID SEQ_GOODS)
+	GOODSCODE       string  `json:"goodscode"  xorm:"'GOODSCODE'"`             // 商品代码(内部)
+	GOODSNAME       string  `json:"goodsname"  xorm:"'GOODSNAME'"`             // 商品名称
+	MARKETID        string  `json:"marketid"  xorm:"'MARKETID'"`               // 所属市场ID
+	GOODSGROUPID    int32   `json:"goodsgroupid"  xorm:"'GOODSGROUPID'"`       // 所属商品组ID
+	GOODSSTATUS     int32   `json:"goodsstatus"  xorm:"'GOODSSTATUS'"`         // 商品状态- 1:待审核 2:未上市 3:上市 4:已注销 5:审核拒绝 6:退市 7:待退市
+	CURRENCYID      int32   `json:"currencyid"  xorm:"'CURRENCYID'"`           // 报价货币ID
+	GOODUNITID      int32   `json:"goodunitid"  xorm:"'GOODUNITID'"`           // 报价单位ID
+	AGREEUNIT       float64 `json:"agreeunit"  xorm:"'AGREEUNIT'"`             // 合约乘数
+	DECIMALPLACE    int32   `json:"decimalplace"  xorm:"'DECIMALPLACE'"`       // 报价小数位
+	QTYDECIMALPLACE int32   `json:"qtydecimalplace"  xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
+	GOODSCURRENCYID int32   `json:"goodscurrencyid"  xorm:"'GOODSCURRENCYID'"` // 合约货币ID
+	REFGOODSID      int64   `json:"refgoodsid"  xorm:"'REFGOODSID'"`           // 参考商品ID
+	REFGOODSCODE    string  `json:"refgoodscode"  xorm:"'REFGOODSCODE'"`       // 参考商品代码
+}
+
+func (r *Goods) calc() {
+
+}
+
+func (r *Goods) buildSql() string {
+	var sqlId utils.SQLVal = `
+select t.goodsid,
+        t.goodscode,
+        t.goodsname,
+        t.marketid,
+        t.goodsgroupid,
+        t.goodsstatus,
+        t.currencyid,
+        t.goodunitid,
+        t.agreeunit,
+        t.decimalplace,
+        t.qtydecimalplace,
+        t.goodscurrencyid,
+        t.goodsquotetype,
+        t.refgoodsid,
+        t.refgoodscode
+ from goods t
+ where 1=1
+`
+	sqlId.AndEx("t.goodsid", r.GOODSID, r.GOODSID > 0)
+	sqlId.AndEx("t.goodscode", r.GOODSCODE, r.GOODSCODE != "")
+	return sqlId.String()
+}
+
+// GetDataEx 获取商品信息
+func (r *Goods) GetData() ([]Goods, error) {
+	sData := make([]Goods, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}