zhou.xiaoning 1 anno fa
parent
commit
6d9c60fc5a
3 ha cambiato i file con 36 aggiunte e 12 eliminazioni
  1. 7 7
      config/config.xml
  2. 15 5
      controllers/order/order.go
  3. 14 0
      models/common.go

+ 7 - 7
config/config.xml

@@ -16,11 +16,11 @@
     <DbName value="orcl"/>
     <DbPort value="1521"/>
     <!-- DbUser DbPwd 支持明文密文 -->
-    <DbUser value="mtp2_test202"/>
+    <DbUser value="mtp2_test204"/>
     <DbPwd value="muchinfo"/>
   </DbSetting>
   <RedisSetting>
-    <Address value="192.168.31.202"/>
+    <Address value="192.168.31.204"/>
     <Port value="5007"/>
     <Timeout value="3"/>
     <ConnNum value="1"/>
@@ -30,11 +30,11 @@
   </RedisSetting>
   <MqSetting>
     <!-- Url 支持明文密文 -->
-    <Url value="amqp://guest:guest@192.168.31.202:5020/test"/>
+    <Url value="amqp://guest:guest@192.168.31.204:5020/test"/>
     <Exchange value="entry"/>
   </MqSetting>
   <MongoDBSetting>
-    <HostName value="192.168.31.202"/>
+    <HostName value="192.168.31.204"/>
     <Port value="5025"/>
     <DBName value="HistoryQuote"/>
     <!-- Username Password 支持明文密文 -->
@@ -44,9 +44,9 @@
   <MySQLSetting>
     <Host value="192.168.30.72"/>
     <Port value="3306"/>
-    <DBName value="historyquote_test202"/>
+    <DBName value="historyquote_test204"/>
     <!-- Username Password 支持明文密文 -->
-    <Username value="quote_test202"/>
+    <Username value="quote_test204"/>
     <Password value="123456"/>
   </MySQLSetting>
   <Tencent>
@@ -66,6 +66,6 @@
     <AppId value="896210645"/>
     <PrivateKey value="MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCqmByEbXbqqq+FYxD1+mJzqrVxG/7xNF3iZJV9q0PqOVwWPEtND8nNuB2FeAwHc5+W7dZwXheVaQqWXvV6lnWp3KaQ9S4CbeOX7zKKF0j42JMj4Adknid9X6OlULZeVoXcQsdQ2h9xpfJhwLka4aOX5p1eP6WocXMrkAVRXEA8aNAlTU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5RLH3/PfHd4TsnUhdqNOM1op0axlJhxI+iMpR2NKjOrg6m8diBpwvlRrgsvM2KWe0ouAm3e0GCZkd1KQTI2UuVRmaCdtkpF7GeU/BPAlnFpy6zON+61k/Z+wDC++8CgYEA54xmJqIr19BpKkcHAxE2pzDrj6ssu2qObKLfsS27o4RevBnrhoY9kPwn8kUKpngoCTd7tM42y9fcpAdUDv+lENAcIF/kz4u+zkyRGR+SpirgAsCYzxZN3GfRNDHBaFEiTkyL6NFdPGV2GTPcd0b6JGf82Thb0JJCxB/J3hVnDIs="/>
     <NotifyUrl value="http://218.17.158.45:15105/api/Asign/HandleASignCompleted"/>
-    <OpenApiUrl value="http://192.168.31.202:5015/mtp2-onlineopen"/>
+    <OpenApiUrl value="http://192.168.31.204:5015/mtp2-onlineopen"/>
   </Asign>
 </Configuration>

+ 15 - 5
controllers/order/order.go

@@ -174,7 +174,7 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
 	}
 
 	// 获取汇率配置
-	exchangeRateConfigs := make([]models.Exchangerateconfig, 0)
+	exchangeRateConfigs := make([]models.ExchangeRateConfig, 0)
 	if err := engine.Find(&exchangeRateConfigs); err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("获取汇率配置失败, err: %s", err.Error())
@@ -185,8 +185,13 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
 		rateMap[fmt.Sprintf("%d_%d", item.ORICURRENCYID, item.DESCURRENCYID)] = item.EXCHANGERATE
 	}
 
-	fCalcPL := func(goodsCode string, buyOrSell int64, qty, holderPrice,
-		agreeUnit float64, decimalPlace int64, exchangeRate float64) (positionPL float64, marketAmount float64, lastPrice float64) {
+	fCalcPL := func(goodsCode string,
+		buyOrSell int64,
+		qty,
+		holderPrice,
+		agreeUnit float64,
+		decimalPlace int64,
+		exchangeRate float64) (positionPL float64, marketAmount float64, lastPrice float64) {
 		positionPL = 0
 		for _, q := range goodGuotes {
 			if goodsCode == q.Goodscode {
@@ -255,8 +260,13 @@ func GetTradePosition(accIds string, tradeModes string) (rst []QueryTradePositio
 				// #3524 又改为跟商品价格小数位走 2022.04.07
 				// 运维提出, 不要四舍五入, 改为去尾法 2022.04.26
 				tradePosition.AveragePrice, _ = decimal.NewFromFloat(averagePrice).Truncate(int32(v.Decimalplace + 2)).Float64()
-				tradePosition.PositionPL, tradePosition.MarketAmount, tradePosition.LastPrice = fCalcPL(tradePosition.GoodsCode, tradePosition.BuyOrSell, tradePosition.CurPositionQTY,
-					tradePosition.AveragePrice, tradePosition.AgreeUnit, tradePosition.DecimalPlace+1, exchangeRate)
+				tradePosition.PositionPL, tradePosition.MarketAmount, tradePosition.LastPrice = fCalcPL(tradePosition.GoodsCode,
+					tradePosition.BuyOrSell,
+					tradePosition.CurPositionQTY,
+					tradePosition.AveragePrice,
+					tradePosition.AgreeUnit,
+					tradePosition.DecimalPlace,
+					exchangeRate)
 				if tradePosition.CurHolderAmount > 1e-10 {
 					tradePosition.PositionPLRate = tradePosition.PositionPL / tradePosition.CurHolderAmount
 					tradePosition.PositionPLRate, _ = strconv.ParseFloat(utils.FormatFloat(tradePosition.PositionPLRate, 4), 64)

+ 14 - 0
models/common.go

@@ -1163,6 +1163,20 @@ func GetNewErmcpRoleFuncMenuLists(loginID int, menuType int) ([]NewFuncmenulist,
 }
 
 // Exchangerateconfig 汇率配置表
+type ExchangeRateConfig struct {
+	ORICURRENCYID int32     `json:"oricurrencyid" xorm:"ORICURRENCYID" form:"oricurrencyid"` // 源币种ID
+	DESCURRENCYID int32     `json:"descurrencyid" xorm:"DESCURRENCYID" form:"descurrencyid"` // 目标币种ID
+	EXCHANGERATE  float64   `json:"exchangerate" xorm:"EXCHANGERATE"`                        // 汇率
+	REMARK        string    `json:"remark" xorm:"REMARK"`                                    // 备注
+	UPDATEBY      int64     `json:"-" xorm:"UPDATEBY"`                                       // 更新人
+	UPDATETIME    time.Time `json:"-" xorm:"UPDATETIME"`                                     // 更新时间
+}
+
+func (r *ExchangeRateConfig) TableName() string {
+	return "EXCHANGERATECONFIG"
+}
+
+// Exchangerateconfig 汇率配置表
 type Exchangerateconfig struct {
 	ORICURRENCYID int32     `json:"oricurrencyid" xorm:"ORICURRENCYID" form:"oricurrencyid"` // 源币种ID
 	DESCURRENCYID int32     `json:"descurrencyid" xorm:"DESCURRENCYID" form:"descurrencyid"` // 目标币种ID