ermcp3.go 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895
  1. /**
  2. * @Author: zou.yingbin
  3. * @Create : 2021/4/14 11:11
  4. * @Modify : 2021/4/14 11:11
  5. */
  6. package models
  7. import (
  8. "fmt"
  9. "mtp2_if/db"
  10. "mtp2_if/logger"
  11. "mtp2_if/mtpcache"
  12. "mtp2_if/utils"
  13. )
  14. // ErmcpDeliveryGoods 现货品种(交割品种)
  15. type ErmcpDeliveryGoods struct {
  16. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID(SEQ_DELIVERYGOODS)
  17. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  18. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  19. GOODSUNITID int32 `json:"goodsunitid" xorm:"'GOODSUNITID'"` // 现货品种单位ID
  20. DELIVERYGOODSTYPE int32 `json:"deliverygoodstype" xorm:"'DELIVERYGOODSTYPE'"` // 现货品种类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细
  21. STANDARDQTY int32 `json:"standardqty" xorm:"'STANDARDQTY'"` // 标准数量(库位数量) [标准品特有]
  22. STANDARDQTYRANGE int32 `json:"standardqtyrange" xorm:"'STANDARDQTYRANGE'"` // 标准数量偏差范围 [标准品特有]
  23. AUDITFLAG int32 `json:"auditflag" xorm:"'AUDITFLAG'"` // 交割是否需要审核 - 0:不需要 1:需要审核 默认为0
  24. ISVALID int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效
  25. AGREEUNIT int32 `json:"agreeunit" xorm:"'AGREEUNIT'"` // 合约单位[散货时默认为1, 整装时默认为标准数量]
  26. QTYDECIMALPLACE int32 `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
  27. CATEGORYID int32 `json:"categoryid" xorm:"'CATEGORYID'"` // 类别ID(SEQ_WRCATEGORY)
  28. DGSTATUS int32 `json:"dgstatus" xorm:"'DGSTATUS'"` // 品种状态 - 作废 - 0:未激活 1:正常
  29. AREAUSERID int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  30. REMARK string `json:"remark" xorm:"'REMARK'"` // 备注
  31. EnumdicName string `json:"enumdicname"` // 现货品种单位名称
  32. ExcludeCfg int32 `json:"-"` // 排除已配置项 1-排除
  33. }
  34. func (r *ErmcpDeliveryGoods) calc() {
  35. r.EnumdicName = mtpcache.GetEnumDicitemName(r.GOODSUNITID)
  36. }
  37. func (r *ErmcpDeliveryGoods) buildSql() string {
  38. var sqlId utils.SQLVal = "SELECT t.DELIVERYGOODSID," +
  39. " t.DELIVERYGOODSCODE," +
  40. " t.DELIVERYGOODSNAME," +
  41. " t.GOODSUNITID," +
  42. " t.DELIVERYGOODSTYPE," +
  43. " t.STANDARDQTY," +
  44. " t.STANDARDQTYRANGE," +
  45. " t.AUDITFLAG," +
  46. " t.ISVALID," +
  47. " t.ISSPLIT," +
  48. " t.AGREEUNIT," +
  49. " t.QTYDECIMALPLACE," +
  50. " t.CATEGORYID," +
  51. " t.DGSTATUS," +
  52. " t.REMARK," +
  53. " t.AREAUSERID" +
  54. " FROM DELIVERYGOODS t" +
  55. " WHERE 1 = 1"
  56. sqlId.AndEx("t.AREAUSERID", r.AREAUSERID, r.AREAUSERID > 0)
  57. sqlId.AndEx("t.DELIVERYGOODSID", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
  58. if r.ExcludeCfg == 1 {
  59. sqlId.Join(" and t.deliverygoodsid not in(select distinct deliverygoodsid from ermcp_bizgroupspotgoods)")
  60. }
  61. return sqlId.String()
  62. }
  63. // GetDataEx 获取现货商品(交割商品)
  64. func (r *ErmcpDeliveryGoods) GetDataEx() (interface{}, error) {
  65. return r.GetData()
  66. }
  67. // GetData
  68. func (r *ErmcpDeliveryGoods) GetData() ([]ErmcpDeliveryGoods, error) {
  69. sData := make([]ErmcpDeliveryGoods, 0)
  70. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  71. for i := range sData {
  72. sData[i].calc()
  73. }
  74. return sData, err
  75. }
  76. // ErmcpDGFactoryItem 品种选择项定义表
  77. type ErmcpDGFactoryItem struct {
  78. DGFACTORYITEMID int64 `json:"dgfactoryitemid" xorm:"'DGFACTORYITEMID'"` // 选择项ID(SEQ_DGFACTORYITEM)
  79. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID
  80. DGFACTORYITEMTYPEID int64 `json:"dgfactoryitemtypeid" xorm:"'DGFACTORYITEMTYPEID'"` // 要素项类型
  81. DGFACTORYITEMVALUE string `json:"dgfactoryitemvalue" xorm:"'DGFACTORYITEMVALUE'"` // 要素项值(类型为仓库时填写仓库名称)
  82. WAREHOUSEID int64 `json:"warehouseid" xorm:"'WAREHOUSEID'"` // 仓库ID(类型为仓库时填写)
  83. ISVALID int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效
  84. ORDERINDEX int32 `json:"orderindex" xorm:"'ORDERINDEX'"` // 顺序
  85. AREAUSERID int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 用户id
  86. }
  87. func (r *ErmcpDGFactoryItem) buildSql() string {
  88. var sqlId utils.SQLVal = "SELECT DGFACTORYITEMID," +
  89. " t.DELIVERYGOODSID," +
  90. " to_char(t.DGFACTORYITEMTYPEID) DGFACTORYITEMTYPEID," +
  91. " t.DGFACTORYITEMVALUE," +
  92. " to_char(t.WAREHOUSEID) WAREHOUSEID," +
  93. " t.ISVALID," +
  94. " t.ORDERINDEX," +
  95. " g.areauserid" +
  96. " FROM DGFACTORYITEM t" +
  97. " left join deliverygoods g" +
  98. " on t.deliverygoodsid = g.deliverygoodsid" +
  99. " WHERE t.ISVALID = 1"
  100. sqlId.AndEx("g.areauserid", r.AREAUSERID, r.AREAUSERID > 0)
  101. sqlId.AndEx("t.DGFACTORYITEMID", r.DGFACTORYITEMID, r.DGFACTORYITEMID > 0)
  102. sqlId.AndEx("t.DELIVERYGOODSID", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
  103. sqlId.AndEx("t.DGFACTORYITEMTYPEID", r.DGFACTORYITEMTYPEID, r.DGFACTORYITEMTYPEID > 0)
  104. sqlId.AndEx("t.ORDERINDEX", r.ORDERINDEX, r.ORDERINDEX > 0)
  105. return sqlId.String()
  106. }
  107. // GetDataEx 获取品种选择项定义
  108. func (r *ErmcpDGFactoryItem) GetDataEx() (interface{}, error) {
  109. return r.GetData()
  110. }
  111. // GetData
  112. func (r *ErmcpDGFactoryItem) GetData() (interface{}, error) {
  113. sData := make([]ErmcpDGFactoryItem, 0)
  114. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  115. return sData, err
  116. }
  117. // Ermcp3Brand 品牌(从品种选择项定义表中查)
  118. type Ermcp3Brand struct {
  119. BRANDID int64 `json:"brandid"` // 品牌id
  120. BRANDNAME string `json:"brandname"` // 品牌名称
  121. DELIVERYGOODSID int32 `json:"deliverygoodsid"` // 品种ID
  122. AREAUSERID int64 `json:"areauserid"` // 用户id
  123. }
  124. // GetDataEx
  125. func (r *Ermcp3Brand) GetDataEx() (interface{}, error) {
  126. return r.GetData()
  127. }
  128. // GetData 获取品牌数据
  129. func (r *Ermcp3Brand) GetData() ([]Ermcp3Brand, error) {
  130. m := ErmcpDGFactoryItem{
  131. DELIVERYGOODSID: r.DELIVERYGOODSID,
  132. DGFACTORYITEMTYPEID: 2,
  133. ORDERINDEX: 1,
  134. }
  135. sData := make([]Ermcp3Brand, 0)
  136. if d, err := m.GetDataEx(); err == nil {
  137. if dgLst, ok := d.([]ErmcpDGFactoryItem); ok {
  138. for _, val := range dgLst {
  139. sData = append(sData, Ermcp3Brand{BRANDID: val.DGFACTORYITEMID, AREAUSERID: val.AREAUSERID,
  140. BRANDNAME: val.DGFACTORYITEMVALUE, DELIVERYGOODSID: val.DELIVERYGOODSID})
  141. }
  142. }
  143. }
  144. return sData, nil
  145. }
  146. // ErmcpRelatedGoods 现货品种的关联交易商品
  147. type ErmcpRelatedGoods struct {
  148. GoodsId int `json:"goodsid" xorm:"'GoodsId'"` // 商品id
  149. GoodsCode string `json:"goodscode" xorm:"'GoodsCode'"` // 商品代码
  150. GoodsName string `json:"goodsname" xorm:"'GoodsName'"` // 商品名称
  151. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 品种ID
  152. AREAUSERID int64 `json:"-"` // 所属机构
  153. }
  154. func (r *ErmcpRelatedGoods) buildSql() string {
  155. var sqlId utils.SQLVal = "select distinct t.deliverygoodsid, g.goodsid, g.goodscode, g.goodsname" +
  156. " from deliverygoods t" +
  157. " inner join ERMS2_WRSConvertDetail w" +
  158. " on t.deliverygoodsid = w.deliverygoodsid" +
  159. " inner join erms_middlegoods m" +
  160. " on w.middlegoodsid = m.middlegoodsid" +
  161. " inner join ERMCP_GGConvertConfig gc" +
  162. " on m.goodsgroupid = gc.destgoodsgroupid" +
  163. " inner join goods g" +
  164. " on gc.srcgoodsgroupid = g.goodsgroupid" +
  165. " where 1 = 1"
  166. sqlId.AndEx("t.AREAUSERID", r.AREAUSERID, r.AREAUSERID > 0)
  167. sqlId.AndEx("t.DELIVERYGOODSID", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
  168. return sqlId.String()
  169. }
  170. // GetDataEx 获取现货关联交易商品
  171. func (r *ErmcpRelatedGoods) GetDataEx() (interface{}, error) {
  172. return r.GetData()
  173. }
  174. // GetData 获取现货关联交易商品
  175. func (r *ErmcpRelatedGoods) GetData() ([]ErmcpRelatedGoods, error) {
  176. sData := make([]ErmcpRelatedGoods, 0)
  177. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  178. return sData, err
  179. }
  180. // ErmcpDeliveryGoodsDetail 现货商品详情
  181. type ErmcpDeliveryGoodsDetail struct {
  182. Data ErmcpDeliveryGoods `json:"data"` // 现货商品基本信息(交割品种)
  183. GmList []Ermcp3Wrstandard `json:"gmlist"` // 品类列表(仓单标准)
  184. GbList []Ermcp3Brand `json:"gblist"` // 品牌列表
  185. }
  186. func (r *ErmcpDeliveryGoodsDetail) addGmList(lst []Ermcp3Wrstandard) {
  187. for i := range lst {
  188. if lst[i].DELIVERYGOODSID == r.Data.DELIVERYGOODSID {
  189. r.GmList = append(r.GmList, lst[i])
  190. }
  191. }
  192. }
  193. func (r *ErmcpDeliveryGoodsDetail) addGbList(lst []Ermcp3Brand) {
  194. for i := range lst {
  195. if lst[i].DELIVERYGOODSID == r.Data.DELIVERYGOODSID {
  196. r.GbList = append(r.GbList, lst[i])
  197. }
  198. }
  199. }
  200. // GetData
  201. func (r *ErmcpDeliveryGoodsDetail) GetData() ([]ErmcpDeliveryGoodsDetail, error) {
  202. sData := make([]ErmcpDeliveryGoodsDetail, 0)
  203. m := ErmcpDeliveryGoods{AREAUSERID: r.Data.AREAUSERID, DELIVERYGOODSID: r.Data.DELIVERYGOODSID}
  204. data, err := m.GetData()
  205. if err != nil {
  206. return sData, err
  207. }
  208. if data == nil || len(data) == 0 {
  209. return sData, nil
  210. }
  211. // 基本信息
  212. for i := range data {
  213. val := ErmcpDeliveryGoodsDetail{Data: data[i],
  214. GmList: make([]Ermcp3Wrstandard, 0), GbList: make([]Ermcp3Brand, 0),
  215. }
  216. sData = append(sData, val)
  217. }
  218. //品类/品牌/套保信息
  219. gm := Ermcp3Wrstandard{AREAUSERID: int(r.Data.AREAUSERID), DELIVERYGOODSID: r.Data.DELIVERYGOODSID, ISVALID: 1}
  220. gb := Ermcp3Brand{DELIVERYGOODSID: r.Data.DELIVERYGOODSID}
  221. gmLst, _ := gm.GetDataEx()
  222. gbLst, _ := gb.GetData()
  223. for i := range sData {
  224. sData[i].addGmList(gmLst.([]Ermcp3Wrstandard))
  225. sData[i].addGbList(gbLst)
  226. }
  227. return sData, nil
  228. }
  229. // GetDataEx
  230. func (r *ErmcpDeliveryGoodsDetail) GetDataEx() (interface{}, error) {
  231. return r.GetData()
  232. }
  233. // ErmcpDeliveryGoodsDetailEx 现货商品详情(含套保列表)
  234. type ErmcpDeliveryGoodsDetailEx struct {
  235. ErmcpDeliveryGoodsDetail
  236. MgList []Ermcp3MiddleGoodsDetail `json:"mgList"` // 套保列表
  237. }
  238. // GetData 获取现货商品详情(含套保信息列表)
  239. func (r *ErmcpDeliveryGoodsDetailEx) GetDataEx() (interface{}, error) {
  240. sData := make([]ErmcpDeliveryGoodsDetailEx, 0)
  241. mDg := r.ErmcpDeliveryGoodsDetail
  242. // 查现货商品列表
  243. if dgList, err := mDg.GetData(); err == nil {
  244. for i := range dgList {
  245. sData = append(sData, ErmcpDeliveryGoodsDetailEx{ErmcpDeliveryGoodsDetail: dgList[i],
  246. MgList: make([]Ermcp3MiddleGoodsDetail, 0)})
  247. }
  248. }
  249. if len(sData) == 0 {
  250. return sData, nil
  251. }
  252. // 查转换关系
  253. mWc := WRSConverTDetail{}
  254. if wc, err := mWc.GetData(); err == nil {
  255. // 查套保商品列表
  256. mMg := Ermcp3MiddleGoodsDetail{}
  257. mMg.Mg.AREAUSERID = r.Data.AREAUSERID
  258. if mgLst, err := mMg.GetData(); err == nil {
  259. for i := range sData {
  260. sData[i].addMgList(mgLst, wc)
  261. }
  262. }
  263. }
  264. return sData, nil
  265. }
  266. // addMgList 添加关联的套保信息列表
  267. func (r *ErmcpDeliveryGoodsDetailEx) addMgList(lst []Ermcp3MiddleGoodsDetail, wc []WRSConverTDetail) {
  268. for i := range wc {
  269. if r.Data.DELIVERYGOODSID == wc[i].DELIVERYGOODSID {
  270. for k := range lst {
  271. if int64(lst[k].Mg.MIDDLEGOODSID) == wc[i].MIDDLEGOODSID {
  272. r.MgList = append(r.MgList, lst[k])
  273. }
  274. }
  275. }
  276. }
  277. }
  278. // Ermcp3MiddleGoodsDetail 套保品种详情
  279. type Ermcp3MiddleGoodsDetail struct {
  280. Mg ErmcpMiddleGoodsModel `json:"mg"` // 套保商品信息
  281. GList []Ermcp3GoodsEx `json:"glist"` // 关联商品列表
  282. }
  283. // GetData 获取套保品种详情(不含现货列表)
  284. func (r *Ermcp3MiddleGoodsDetail) GetData() ([]Ermcp3MiddleGoodsDetail, error) {
  285. sData := make([]Ermcp3MiddleGoodsDetail, 0)
  286. // 查基本信息
  287. mMg := ErmcpMiddleGoodsModel{AREAUSERID: r.Mg.AREAUSERID, MIDDLEGOODSID: r.Mg.MIDDLEGOODSID, ISVALID: 1}
  288. if mgLst, err := mMg.GetData2(); err == nil {
  289. for i := range mgLst {
  290. sData = append(sData, Ermcp3MiddleGoodsDetail{Mg: mgLst[i], GList: make([]Ermcp3GoodsEx, 0)})
  291. }
  292. }
  293. if len(sData) == 0 {
  294. return sData, nil
  295. }
  296. mGoods := Ermcp3GoodsEx{AREAUSERID: r.Mg.AREAUSERID}
  297. if gLst, err := mGoods.GetData(); err == nil {
  298. for i := range sData {
  299. for _, ex := range gLst {
  300. if sData[i].Mg.MIDDLEGOODSID == ex.MIDDLEGOODSID {
  301. sData[i].GList = append(sData[i].GList, ex)
  302. }
  303. }
  304. }
  305. }
  306. return sData, nil
  307. }
  308. // Ermcp3MiddleGoodsDetailEx 套保品种详情(含现货列表)
  309. type Ermcp3MiddleGoodsDetailEx struct {
  310. Ermcp3MiddleGoodsDetail
  311. DgList []ErmcpDeliveryGoodsDetail `json:"dglist"` // 关联的现货品种列表
  312. }
  313. func (r *Ermcp3MiddleGoodsDetailEx) addDgList(dglst []ErmcpDeliveryGoodsDetail, wc []WRSConverTDetail) {
  314. for i := range wc {
  315. if wc[i].MIDDLEGOODSID == int64(r.Mg.MIDDLEGOODSID) {
  316. for _, detail := range dglst {
  317. if wc[i].DELIVERYGOODSID == detail.Data.DELIVERYGOODSID {
  318. r.DgList = append(r.DgList, detail)
  319. }
  320. }
  321. }
  322. }
  323. }
  324. // GetDataEx
  325. func (r *Ermcp3MiddleGoodsDetailEx) GetDataEx() (interface{}, error) {
  326. sData := make([]Ermcp3MiddleGoodsDetailEx, 0)
  327. // 查套保品种基本信息
  328. m := r.Ermcp3MiddleGoodsDetail
  329. if mgLst, err := m.GetData(); err == nil {
  330. for i := range mgLst {
  331. sData = append(sData, Ermcp3MiddleGoodsDetailEx{Ermcp3MiddleGoodsDetail: mgLst[i],
  332. DgList: make([]ErmcpDeliveryGoodsDetail, 0)})
  333. }
  334. }
  335. // 查转换关系
  336. mWc := WRSConverTDetail{}
  337. if wc, err := mWc.GetData(); err == nil {
  338. // 查现货商品列表
  339. mDg := ErmcpDeliveryGoodsDetail{}
  340. mDg.Data.AREAUSERID = r.Mg.AREAUSERID
  341. if dgLst, err := mDg.GetData(); err == nil {
  342. for i := range sData {
  343. sData[i].addDgList(dgLst, wc)
  344. }
  345. }
  346. }
  347. return sData, nil
  348. }
  349. // Ermcp3GoodsEx 套保品关联的期货商品(少量字段)
  350. type Ermcp3GoodsEx struct {
  351. MIDDLEGOODSID uint32 `json:"middlegoodsid" xorm:"'middlegoodsid'"` // 套保商品id
  352. GOODSID int32 `json:"goodsid" xorm:"'goodsid'"` // 期货商品id
  353. GOODSCODE string `json:"goodscode" xorm:"'goodscode'"` // 期货商品代码
  354. GOODSNAME string `json:"goodsname" xorm:"'goodsname'"` // 期货商品名称
  355. GOODUNITID int32 `json:"goodunitid" xorm:"'goodunitid'"` // 期货商品单位id
  356. CONVERTRATIO float64 `json:"convertratio" xorm:"'convertratio'"` // 折算系数(品种系数)
  357. EXEXCHANGECODE string `json:"exexchangecode" xorm:"'exexchangecode'"` // 交易所代码
  358. ENUMDICNAME string `json:"enumdicname"` // 单位名称
  359. AREAUSERID int64 `json:"-"` // 所属机构id
  360. }
  361. func (r *Ermcp3GoodsEx) calc() {
  362. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
  363. }
  364. func (r *Ermcp3GoodsEx) buildSql() string {
  365. var sqlId utils.SQLVal = "select mg.areauserid," +
  366. " mg.middlegoodsid," +
  367. " g.goodsid," +
  368. " g.goodscode," +
  369. " g.goodsname," +
  370. " g.goodunitid," +
  371. " gc.convertratio," +
  372. " ex.exexchangecode" +
  373. " from erms_middlegoods mg" +
  374. " inner join ERMCP_GGConvertConfig gc" +
  375. " on mg.goodsgroupid = gc.destgoodsgroupid" +
  376. " inner join goodsgroup gp" +
  377. " on gc.srcgoodsgroupid = gp.goodsgroupid" +
  378. " inner join goods g" +
  379. " on gp.goodsgroupid = g.goodsgroupid" +
  380. " left join externalexchange ex" +
  381. " on gp.exexchangeid = ex.autoid" +
  382. " where 1 = 1"
  383. sqlId.AndEx("mg.areauserid", r.AREAUSERID, r.AREAUSERID > 0)
  384. sqlId.Join(" order by mg.middlegoodsid")
  385. return sqlId.String()
  386. }
  387. // GetData
  388. func (r *Ermcp3GoodsEx) GetData() ([]Ermcp3GoodsEx, error) {
  389. sData := make([]Ermcp3GoodsEx, 0)
  390. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  391. for i := range sData {
  392. sData[i].calc()
  393. }
  394. return sData, err
  395. }
  396. // GetDataEx
  397. func (r *Ermcp3GoodsEx) GetDataEx() (interface{}, error) {
  398. return r.GetData()
  399. }
  400. // Ermcp3Contract 现货合同
  401. type Ermcp3Contract struct {
  402. SPOTCONTRACTID string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
  403. CONTRACTNO string `json:"contractno" xorm:"'CONTRACTNO'"` // 现货合同编号
  404. CONTRACTTYPE int32 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 现货合同类型 - 1:采购 -1:销售
  405. USERID int64 `json:"userid" xorm:"'USERID'"` // 所属机构ID
  406. BUYUSERID int64 `json:"buyuserid" xorm:"'BUYUSERID'"` // 采购方ID
  407. BUYUSERName string `json:"buyusername" xorm:"'BUYUSERName'"` // 采购方名称
  408. SELLUSERID int64 `json:"selluserid" xorm:"'SELLUSERID'"` // 销售方ID
  409. SELLUSERNAME string `json:"sellusername" xorm:"'SELLUSERNAME'"` // 销售方名称
  410. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID
  411. WRSTANDARDID int32 `json:"wrstandardid" xorm:"'wrstandardid'"` // 品类ID
  412. WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 品类名称
  413. WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 品类代码
  414. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  415. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  416. PRODUCTTYPE int32 `json:"producttype" xorm:"'PRODUCTTYPE'"` // 产品类型 - 1:标准仓单 2:等标 3:非标
  417. CONVERTFACTOR float64 `json:"convertfactor" xorm:"'CONVERTFACTOR'"` // 标仓系数(品类)
  418. SPOTGOODSDESC string `json:"spotgoodsdesc" xorm:"'SPOTGOODSDESC'"` // 商品型号
  419. PRICETYPE int32 `json:"pricetype" xorm:"'PRICETYPE'"` // 定价类型 - 1:一口价 2:点价 3:暂定价
  420. QTY float64 `json:"qty" xorm:"'QTY'"` // 数量
  421. PRICE float64 `json:"price" xorm:"'PRICE'"` // 价格\暂定价 [1:一口价、3:暂定价]
  422. AMOUNT float64 `json:"amount" xorm:"'AMOUNT'"` // 金额 [1:一口价、3:暂定价]
  423. DELIVERYSTARTDATE string `json:"deliverystartdate" xorm:"'DELIVERYSTARTDATE'"` // 交收期(开始)
  424. DELIVERYENDDATE string `json:"deliveryenddate" xorm:"'DELIVERYENDDATE'"` // 交收期(结束)
  425. GOODSID int32 `json:"goodsid" xorm:"'GOODSID'"` // 点价合约ID - 0:为现货,其它为期货商品合约ID [2:点价 3:暂定价]
  426. GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 点价合约代码
  427. GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 点价商品名称
  428. PRICEMOVE float64 `json:"pricemove" xorm:"'PRICEMOVE'"` // 升贴水 [2:点价 3:暂定价]
  429. STARTDATE string `json:"startdate" xorm:"'STARTDATE'"` // 点价开始日期 [2:点价 3:暂定价]
  430. ENDDATE string `json:"enddate" xorm:"'ENDDATE'"` // 点价结束日期 [2:点价 3:暂定价]
  431. MARGIN float64 `json:"margin" xorm:"'MARGIN'"` // 当前保证金
  432. CONTRACTMARGIN float64 `json:"contractmargin" xorm:"'CONTRACTMARGIN'"` // 合同保证金
  433. EnumdicName string `json:"enumdicname" xorm:"'ENUMDICNAME'"` // 单位名称
  434. CONTRACCTSTATUS int32 `json:"contracctstatus" xorm:"'CONTRACTSTATUS'"` // 合同状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
  435. Remark string `json:"remark" xorm:"'Remark'"` // 备注
  436. AUDITREMARK string `json:"auditremark" xorm:"'AUDITREMARK'"` // 审核意见
  437. AUDITTIME string `json:"audittime" xorm:"'AUDITTIME'"` // 审核时间
  438. CREATETIME string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  439. UPDATETIME string `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  440. SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID(DGFactoryItem表的ID)
  441. BRANDNAME string `json:"brandname" xorm:"'brandname'"` // 品牌名称
  442. ATTACHMENT string `json:"attachment" xorm:"'ATTACHMENT'"` // 附件
  443. UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 单位id(取品类上的单位id)
  444. TRADEUSERID int64 `json:"tradeuserid" xorm:"'TRADEUSERID'"` // 交易员id
  445. SALEUSERID int64 `json:"saleuserid" xorm:"'SALEUSERID'"` // 业务员id
  446. MERUSERID int64 `json:"meruserid" xorm:"'MERUSERID'"` // 跟单员id
  447. ACCOUNTID string `json:"accountid" xorm:"'ACCOUNTID'"` // 期货账户id
  448. BIZTYPE int32 `json:"biztype" xorm:"'BIZTYPE'"` // 业务类型 1-套保 2-套利
  449. SELLNICKNAME string `json:"sellnickname"` // 采购方昵称
  450. BUYNICKNAME string `json:"buynickname"` // 销售方昵称
  451. TRADEUSERLOGINCODE string `json:"tradeuserlogincode"` // 交易员登录代码
  452. SALEUSERLOGINCODE string `json:"saleuserlogincode"` // 业务员登录代码
  453. MERUSERLOGINCODE string `json:"meruserlogincode"` // 跟单员登录代码
  454. // 筛选条件
  455. QryType int32 `json:"-"` // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
  456. UserType int32 `json:"-"` // 用户类型 2-管理员 7-企业成员
  457. OwnUserId int64 `json:"-"` // 登录用户id
  458. }
  459. func (r *Ermcp3Contract) getQryTypeStatus() string {
  460. var status string
  461. switch r.QryType {
  462. case 1: // 未提交
  463. status = "0,4,6"
  464. case 2: // 待审核
  465. status = "1"
  466. case 3: // 履约中
  467. status = "2"
  468. case 4: // 已完成
  469. status = "3,5"
  470. }
  471. return status
  472. }
  473. func (r *Ermcp3Contract) calc() {
  474. r.BUYUSERName, r.BUYNICKNAME = mtpcache.GetUserNameAndNickName(r.BUYUSERID)
  475. r.SELLUSERNAME, r.SELLNICKNAME = mtpcache.GetUserNameAndNickName(r.SELLUSERID)
  476. r.EnumdicName = mtpcache.GetEnumDicitemName(r.UNITID)
  477. r.TRADEUSERLOGINCODE = mtpcache.GetLoginCodeByUserId(r.TRADEUSERID)
  478. r.SALEUSERLOGINCODE = mtpcache.GetLoginCodeByUserId(r.SALEUSERID)
  479. r.MERUSERLOGINCODE = mtpcache.GetLoginCodeByUserId(r.MERUSERID)
  480. }
  481. func (r *Ermcp3Contract) buildSql() string {
  482. var sqlId utils.SQLVal = "SELECT to_char(t.SPOTCONTRACTID) SPOTCONTRACTID," +
  483. " t.CONTRACTNO," +
  484. " t.CONTRACTTYPE," +
  485. " t.USERID," +
  486. " t.BUYUSERID," +
  487. " t.SELLUSERID," +
  488. " t.DELIVERYGOODSID," +
  489. " t.wrstandardid," +
  490. " t.PRODUCTTYPE," +
  491. " w.CONVERTFACTOR," +
  492. " t.SPOTGOODSDESC," +
  493. " t.PRICETYPE," +
  494. " t.QTY," +
  495. " t.PRICE," +
  496. " t.AMOUNT," +
  497. " to_char(t.DELIVERYSTARTDATE, 'yyyy-mm-dd hh24:mi:ss') DELIVERYSTARTDATE," +
  498. " to_char(t.DELIVERYENDDATE, 'yyyy-mm-dd hh24:mi:ss') DELIVERYENDDATE," +
  499. " t.GOODSID," +
  500. " t.PRICEMOVE," +
  501. " to_char(t.STARTDATE, 'yyyy-mm-dd hh24:mi:ss') STARTDATE," +
  502. " to_char(t.ENDDATE, 'yyyy-mm-dd hh24:mi:ss') ENDDATE," +
  503. " t.MARGIN," +
  504. " t.contractmargin," +
  505. " t.remark," +
  506. " t.auditremark," +
  507. " to_char(t.contractattachment) attachment," +
  508. " t.contractstatus," +
  509. " t.SPOTGOODSBRANDID," +
  510. " to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
  511. " to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
  512. " to_char(t.updatetime, 'yyyy-mm-dd hh24:mi:ss') updatetime," +
  513. " g.deliverygoodscode," +
  514. " g.deliverygoodsname," +
  515. " g2.goodscode," +
  516. " g2.goodsname," +
  517. " gb.dgfactoryitemvalue brandname," +
  518. " w.wrstandardname," +
  519. " w.wrstandardcode," +
  520. " w.unitid," +
  521. " t.tradeuserid," +
  522. " t.saleuserid," +
  523. " t.meruserid," +
  524. " to_char(t.accountid) accountid," +
  525. " t.biztype" +
  526. " FROM ERMCP_SPOTCONTRACT t" +
  527. " left join deliverygoods g" +
  528. " on t.deliverygoodsid = g.deliverygoodsid" +
  529. " left join goods g2" +
  530. " on t.goodsid = g2.goodsid" +
  531. " left join DGFACTORYITEM gb" +
  532. " on t.spotgoodsbrandid = gb.dgfactoryitemid" +
  533. " left join wrstandard w" +
  534. " on t.wrstandardid = w.wrstandardid" +
  535. " where 1 = 1"
  536. sqlId.AndEx("t.userid", r.USERID, r.USERID > 0)
  537. sqlId.AndEx("t.SPOTCONTRACTID", r.SPOTCONTRACTID, len(r.SPOTCONTRACTID) > 0)
  538. if r.UserType == 7 {
  539. // 企业成员
  540. sqlId.Join(fmt.Sprintf(" and %v in(t.saleuserid, t.tradeuserid, t.meruserid)", r.OwnUserId))
  541. }
  542. status := r.getQryTypeStatus()
  543. if len(status) > 0 {
  544. sqlId.Join(fmt.Sprintf(" and t.contractstatus in (%v)", status))
  545. }
  546. return sqlId.String()
  547. }
  548. // GetDataEx
  549. func (r *Ermcp3Contract) GetDataEx() (interface{}, error) {
  550. sData := make([]Ermcp3Contract, 0)
  551. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  552. for i := range sData {
  553. sData[i].calc()
  554. }
  555. return sData, err
  556. }
  557. // Ermcp3SellBuyContract 采购/销售合同
  558. type Ermcp3SellBuyContract struct {
  559. UserID int64 `json:"userid" xorm:"'UserID'"` // 机构ID
  560. SpotContractId string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 合同ID
  561. AccountName string `json:"accountname" xorm:"'ACCOUNTNAME'"` // 账户名称
  562. DeliveryGoodsId int `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货商品ID
  563. DeliveryGoodsCode string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  564. DeliveryGoodsName string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  565. SpotGoodsdesc string `json:"spotgoodsdesc" xorm:"'SPOTGOODSDESC'"` // 商品型号(商品规格)
  566. GoodsId int `json:"goodsid" xorm:"'GOODSID'"` // 点价商品ID
  567. GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 点价商品名称
  568. Goodscode string `json:"goodscode" xorm:"'GOODSCODE'"` // 点价商品代码
  569. Pricemove float64 `json:"pricemove" xorm:"'PRICEMOVE'"` // 升贴水
  570. Qty float64 `json:"qty" xorm:"'QTY'"` // 合同量
  571. UnpricedQty float64 `json:"unpricedqty" xorm:"'UNPRICEDQTY'"` // 未定价量
  572. PricedQty float64 `json:"pricedqty" xorm:"'PRICEDQTY'"` // 已定价量
  573. UnsureQty float64 `json:"unsureqty" xorm:"'UNSUREQTY'"` // 未确定量
  574. PayAmount float64 `json:"payamount" xorm:"'PAYAMOUNT'"` // 已收付额(收款或付款)
  575. UnpayAmount float64 `json:"unpayamount"` // 应收付款额(应支付或应收款)
  576. PrePayAmount float64 `json:"prepayamount"` // 预收付额
  577. InvoiceAmount float64 `json:"invoiceamount" xorm:"'INVOICEAMOUNT'"` // 已开票额
  578. DaikaiAmount float64 `json:"daikaiamount" xorm:"'DAIKAIAMOUNT'"` // 应收(开)票额
  579. PreInvoiceAmount float64 `json:"preinvoiceamount"` // 预收(开)票额
  580. StartDate string `json:"startdate" xorm:"'STARTDATE'"` // 点价开始日
  581. EndDate string `json:"enddate" xorm:"'ENDDATE'"` // 点价结束日
  582. DeliveryStartDate string `json:"deliverystartdate" xorm:"'DELIVERYSTARTDATE'"` // 交割开始日
  583. DeliveryendDate string `json:"deliveryenddate" xorm:"'DELIVERYENDDATE'"` // 交割结束日
  584. Convertfactor float64 `json:"convertfactor" xorm:"'CONVERTFACTOR'"` // 标仓系数(品类)
  585. EnumdicName string `json:"enumdicname" xorm:"'ENUMDICNAME'"` // 单位名称
  586. Contracctstatus uint `json:"contracctstatus" xorm:"'CONTRACTSTATUS'"` // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
  587. PriceType int `json:"pricetype" xorm:"'PRICETYPE'"` // 定价类型 - 1:一口价 2:点价 3:暂定价
  588. ProductType int `json:"producttype" xorm:"'PRODUCTTYPE'"` // 产品类型 - 1:标准仓单 2:等标 3:非标
  589. Contracttype int32 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 合同类型 1-采购, -1-销售
  590. Pricedamount float64 `json:"pricedamount" xorm:"'PRICEDAMOUNT'"` // 已定价额
  591. PricedAvg float64 `json:"pricedavg" xorm:"'PRICEDAVG'"` // 已点均价
  592. Margin float64 `json:"margin" xorm:"'MARGIN'"` // 保证金
  593. CONTRACTMARGIN float64 `json:"contractmargin" xorm:"'CONTRACTMARGIN'"` // 合同保证金
  594. Remark string `json:"remark" xorm:"'Remark'"` // 备注
  595. ATTACHMENT string `json:"attachment" xorm:"'ATTACHMENT'"` // 附件
  596. ReckonRealQty float64 `json:"reckonrealqty" xorm:"'ReckonRealQty'"` // 已确定量
  597. ReckonOtherAmount float64 `json:"reckonotheramount" xorm:"'ReckonOtherAmount'"` // 其它费用
  598. ReckonAdjustAmount float64 `json:"reckonadjustamount" xorm:"'ReckonAdjustAmount'"` // 调整金额
  599. Price float64 `json:"price" xorm:"'Price'"` // 价格
  600. LoanAmount float64 `json:"loanamount" xorm:"'LoanAmount'"` // 贷款总额=已定价额+调整金额
  601. Contractno string `json:"contractno" xorm:"'Contractno'"` // 合同编号
  602. TotalAmount float64 `json:"totalamount" xorm:"'-'"` // 合计总额
  603. ReckonedAmount float64 `json:"reckonedamount" xorm:"'ReckonedAmount'"` // 实际已收付额(已确定额,已收付总额-已退款总额)
  604. BUYUSERID int64 `json:"-" xorm:"'BUYUSERID'"` // 采购方ID
  605. SELLUSERID int64 `json:"-" xorm:"'SELLUSERID'"` // 销售方ID
  606. AUDITTIME string `json:"audittime" xorm:"'AUDITTIME'"` // 审核时间
  607. CREATETIME string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  608. SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID(DGFactoryItem表的ID)
  609. BRANDNAME string `json:"brandname" xorm:"'brandname'"` // 品牌名称
  610. WRSTANDARDID int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 品类ID
  611. WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 品类名称
  612. WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 品类代码
  613. NICKNAME string `json:"nickname"` // 账户昵称
  614. // 筛选条件
  615. QryType int32 `json:"-"` // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
  616. UserType int32 `json:"-"` // 用户类型 2-管理员 7-企业成员
  617. OwnUserId int64 `json:"-"` // 登录用户id
  618. }
  619. func (r *Ermcp3SellBuyContract) calc() {
  620. r.TotalAmount = r.LoanAmount + r.ReckonOtherAmount
  621. r.UnpayAmount = r.TotalAmount - r.ReckonedAmount
  622. r.PrePayAmount = r.ReckonedAmount - r.TotalAmount
  623. r.PreInvoiceAmount = r.InvoiceAmount - r.TotalAmount
  624. if r.Contracttype == 1 {
  625. //采购合同, 取销售方名称
  626. r.AccountName, r.NICKNAME = mtpcache.GetUserNameAndNickName(r.SELLUSERID)
  627. } else {
  628. //销售合同, 取采购方名称
  629. r.AccountName, r.NICKNAME = mtpcache.GetUserNameAndNickName(r.BUYUSERID)
  630. }
  631. }
  632. func (r *Ermcp3SellBuyContract) buildSql() string {
  633. var sqlId utils.SQLVal = "select t.contractno," +
  634. " to_char(t.SpotContractId) SpotContractId," +
  635. " t.deliverygoodsid," +
  636. " t.spotgoodsdesc," +
  637. " t.goodsid," +
  638. " t.pricemove," +
  639. " t.userid," +
  640. " t.BUYUSERID," +
  641. " t.SELLUSERID," +
  642. " t.qty," +
  643. " t.qty - t.pricedqty unpricedqty," +
  644. " t.pricedqty," +
  645. " (case" +
  646. " when t.pricetype = 3 then" +
  647. " t.qty - t.RECKONREALQTY" +
  648. " else" +
  649. " t.pricedqty - t.ReckonRealQty" +
  650. " end) unsureqty," +
  651. " t.reckonedamount PayAmount," +
  652. " t.invoiceamount," +
  653. " (t.pricedamount + t.RECKONADJUSTAMOUNT + t.RECKONOTHERAMOUNT -" +
  654. " t.invoiceamount) as daikaiAmount," +
  655. " to_char(t.startdate, 'yyyy-mm-dd hh24:mi:ss') startdate," +
  656. " to_char(t.enddate, 'yyyy-mm-dd hh24:mi:ss') enddate," +
  657. " to_char(t.deliverystartdate, 'yyyy-mm-dd hh24:mi:ss') deliverystartdate," +
  658. " to_char(t.deliveryenddate, 'yyyy-mm-dd hh24:mi:ss') deliveryenddate," +
  659. " wr.convertfactor," +
  660. " t.contractstatus," +
  661. " t.pricetype," +
  662. " t.producttype," +
  663. " t.contracttype," +
  664. " t.remark," +
  665. " to_char(t.contractattachment) attachment," +
  666. " t.margin," +
  667. " t.contractmargin," +
  668. " t.SPOTGOODSBRANDID," +
  669. " g.deliverygoodscode," +
  670. " g.deliverygoodsname," +
  671. " wr.wrstandardid," +
  672. " wr.wrstandardname," +
  673. " wr.wrstandardcode," +
  674. " g2.goodscode," +
  675. " g2.goodsname," +
  676. " e.enumdicname," +
  677. " t.contracttype," +
  678. " t.pricedamount," +
  679. " case" +
  680. " when t.pricedqty > 0 then" +
  681. " (t.pricedamount) / t.pricedqty" +
  682. " else" +
  683. " 0" +
  684. " end pricedAvg," +
  685. " t.ReckonRealQty," +
  686. " t.ReckonOtherAmount," +
  687. " t.ReckonAdjustAmount," +
  688. " t.Price," +
  689. " t.ReckonedAmount," +
  690. " to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
  691. " to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
  692. " t.pricedamount + t.ReckonAdjustAmount as LoanAmount," +
  693. " gb.dgfactoryitemvalue BRANDNAME" +
  694. " from ermcp_spotcontract t" +
  695. " left join deliverygoods g" +
  696. " on t.deliverygoodsid = g.deliverygoodsid" +
  697. " left join goods g2" +
  698. " on t.goodsid = g2.goodsid" +
  699. " left join wrstandard wr" +
  700. " on t.wrstandardid = wr.wrstandardid" +
  701. " left join DGFactoryItem gb" +
  702. " on t.spotgoodsbrandid = gb.dgfactoryitemid" +
  703. " left join enumdicitem e" +
  704. " on wr.unitid = e.enumitemname" +
  705. " and e.enumdiccode = 'goodsunit'" +
  706. " where 1 = 1"
  707. sqlId.AndEx("t.userid", r.UserID, r.UserID > 0)
  708. sqlId.AndEx("t.contracttype", r.Contracttype, r.Contracttype != 0)
  709. sqlId.AndEx("t.SpotContractId", r.SpotContractId, len(r.SpotContractId) > 0)
  710. if r.UserType == 7 {
  711. // 企业成员
  712. sqlId.Join(fmt.Sprintf(" and %v in(t.saleuserid, t.tradeuserid, t.meruserid)", r.OwnUserId))
  713. }
  714. var status string
  715. nQueryType := r.QryType
  716. if 1 == nQueryType {
  717. // 全部
  718. status = "2,3"
  719. } else if 2 == nQueryType {
  720. // 待点价
  721. status = "2"
  722. } else {
  723. // 履约
  724. status = "2"
  725. }
  726. if len(status) > 0 {
  727. sqlId.Join(fmt.Sprintf(" and t.contractstatus in (%v)", status))
  728. }
  729. sqlId.JoinEx(r.QryType == 2, " and t.qty - t.pricedqty > 0 and t.pricetype !=1")
  730. return sqlId.String()
  731. }
  732. // GetDataEx
  733. func (r *Ermcp3SellBuyContract) GetDataEx() (interface{}, error) {
  734. sData := make([]Ermcp3SellBuyContract, 0)
  735. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  736. for i := range sData {
  737. sData[i].calc()
  738. }
  739. return sData, err
  740. }
  741. // Ermcp3ExposureDetail 敞口现货明细
  742. type Ermcp3ExposureDetail struct {
  743. Createtime string `json:"createtime" xorm:"'createtime'"` // 时间
  744. Areauserid int64 `json:"areauserid" xorm:"'areauserid'"` // 机构ID
  745. Logtype int32 `json:"logtype" xorm:"'logtype'"` // 类型 - 1:套保计划 2:现货合同
  746. Contracttype int32 `json:"contracttype" xorm:"'contracttype'"` // 现货合同类型 - 1:采购 -1:销售
  747. Qty float64 `json:"qty" xorm:"'qty'"` // 数量
  748. RelateNo string `json:"relateNo" xorm:"'relateNo'"` // 现货合同/套保计划编号
  749. Middlegoodsname string `json:"middlegoodsname" xorm:"'middlegoodsname'"` // 套保商品名称
  750. Middlegoodscode string `json:"middlegoodscode" xorm:"'middlegoodscode'"` // 套保商品代码
  751. MiddlegoodsId int32 `json:"middlegoodsId" xorm:"'middlegoodsId'"` // 套保商品id
  752. Unitid int32 `json:"-" xorm:"'unitid'"` // 现货商品单位ID
  753. Enumdicname string `json:"enumdicname" xorm:"'enumdicname'"` // 现货商品单位名称
  754. ChangeQty float64 `json:"changeQty" xorm:"'changeQty'"` // 套保变动量
  755. Convertfactor float64 `json:"convertfactor" xorm:"'convertfactor'"` // 标仓系数
  756. Convertratio float64 `json:"convertratio" xorm:"'convertratio'"` // 套保系数
  757. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种id
  758. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  759. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  760. }
  761. func (r *Ermcp3ExposureDetail) calc() {
  762. // 销售合同转换为负数
  763. if r.Logtype == 2 && r.Contracttype == -1 {
  764. r.ChangeQty *= -1
  765. r.Qty *= -1
  766. }
  767. // 采购计划 转换为负数
  768. if r.Logtype == 1 && r.Contracttype == 1 {
  769. r.ChangeQty *= -1
  770. r.Qty *= -1
  771. }
  772. }
  773. func (r *Ermcp3ExposureDetail) buildSql() string {
  774. var sqlId utils.SQLVal = "with tmp as" +
  775. " (select 2 as LogType," +
  776. " s.spotcontractid as relatedid," +
  777. " s.contractno as relateNo," +
  778. " s.qty" +
  779. " from ermcp_spotcontract s" +
  780. " union all" +
  781. " select 1," +
  782. " t.hedgeplanid as relateid," +
  783. " t.hedgeplanno as relateNo," +
  784. " t.planqty as qty" +
  785. " from ermcp_hedgeplan t)" +
  786. "select to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
  787. " t.middlegoodsid," +
  788. " t.areauserid," +
  789. " t.logtype," +
  790. " t.contracttype," +
  791. " t.qty / t.convertfactor / t.convertratio as qty," +
  792. " t.convertfactor," +
  793. " t.convertratio," +
  794. " t.qty changeQty," +
  795. " tmp.relateNo," +
  796. " m.middlegoodsname," +
  797. " m.middlegoodscode," +
  798. " g.deliverygoodsid," +
  799. " g.deliverygoodscode," +
  800. " g.deliverygoodsname," +
  801. " g.goodsunitid unitid," +
  802. " e.enumdicname" +
  803. " from ermcp_spotexposurelog t" +
  804. " left join erms_middlegoods m" +
  805. " on t.middlegoodsid = m.middlegoodsid" +
  806. " left join deliverygoods g" +
  807. " on t.deliverygoodsid = g.deliverygoodsid" +
  808. " left join enumdicitem e" +
  809. " on g.goodsunitid = e.enumitemname" +
  810. " and e.enumdiccode = 'goodsunit'" +
  811. " left join tmp" +
  812. " on t.logtype = tmp.LogType" +
  813. " and t.relatedid = tmp.relatedid" +
  814. " where 1=1 and t.tradedate=to_char(sysdate, 'yyyymmdd')"
  815. sqlId.And("t.areauserid", r.Areauserid)
  816. sqlId.And("t.middlegoodsid", r.MiddlegoodsId)
  817. return sqlId.String()
  818. }
  819. // GetDataEx
  820. func (r *Ermcp3ExposureDetail) GetDataEx() (interface{}, error) {
  821. e := db.GetEngine()
  822. s := e.SQL(r.buildSql())
  823. sData := make([]Ermcp3ExposureDetail, 0)
  824. if err := s.Find(&sData); err != nil {
  825. return nil, err
  826. }
  827. for i := range sData {
  828. sData[i].calc()
  829. }
  830. return sData, nil
  831. }
  832. // Ermcp3AreaSpot 敞口现货头寸
  833. type Ermcp3AreaSpot struct {
  834. AREAUSERID int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  835. ORIBUYPLANQTY float64 `json:"-" xorm:"'ORIBUYPLANQTY'"` // 期初采购计划数量
  836. ORIBUYPRICEDQTY float64 `json:"-" xorm:"'ORIBUYPRICEDQTY'"` // 期初采购合同已定价数量
  837. ORISELLPLANQTY float64 `json:"-" xorm:"'ORISELLPLANQTY'"` // 期初销售计划数量
  838. ORISELLPRICEDQTY float64 `json:"-" xorm:"'ORISELLPRICEDQTY'"` // 期初销售合同已定价数量
  839. BUYPLANQTY float64 `json:"-" xorm:"'BUYPLANQTY'"` // 采购计划数量
  840. BUYPRICEDQTY float64 `json:"-" xorm:"'BUYPRICEDQTY'"` // 采购合同已定价数量
  841. SELLPLANQTY float64 `json:"-" xorm:"'SELLPLANQTY'"` // 销售计划数量
  842. SELLPRICEDQTY float64 `json:"-" xorm:"'SELLPRICEDQTY'"` // 销售合同已定价数量
  843. TOTALSPOTQTY float64 `json:"totalspotqty" xorm:"'TOTALSPOTQTY'"` // 当前数量(现货头寸总量) = (销售计划数量 - 销售已定价数量) - (采购计划数量 - 采购已定价数量)
  844. OriToalSpotQty float64 `json:"oritoalspotqty" xorm:"'OriToalSpotQty'"` // 昨日数量
  845. IncreaseQty float64 `json:"increaseqty" xorm:"'IncreaseQty'"` // 增加数量=销售计划数量+采购已定价数量
  846. DecreaseQty float64 `json:"decreaseqty" xorm:"'DecreaseQty'"` // 减少数量=-(销售已定价数量+采购计划数量)
  847. UPDATETIME string `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  848. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种id
  849. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  850. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  851. }
  852. func (r *Ermcp3AreaSpot) calc() {
  853. /*
  854. 增加数量=今日销售计划数量+今日采购已定价数量
  855. 减少数量=-(今日销售已定价数量+今日采购计划数量)
  856. 其中,
  857. 今日销售计划数量=期末销售计划数量-期初销售计划数量
  858. 今日采购已定价数量=期末采购已定价数量-期初采购已定价数量
  859. 今日销售已定价数量=期末销售已定价数量-期初销售已定价数量
  860. 今日采购计划数量=期末采购计划数量-期初采购计划数量
  861. */
  862. r.IncreaseQty = r.SELLPLANQTY - r.ORISELLPLANQTY + r.BUYPRICEDQTY - r.ORIBUYPRICEDQTY
  863. r.DecreaseQty = (r.SELLPRICEDQTY - r.ORISELLPRICEDQTY + r.BUYPLANQTY - r.ORIBUYPLANQTY) * -1
  864. r.OriToalSpotQty = (r.ORISELLPLANQTY - r.ORISELLPRICEDQTY) - (r.ORIBUYPLANQTY - r.ORIBUYPRICEDQTY)
  865. }
  866. func (r *Ermcp3AreaSpot) buildSql() string {
  867. var sqlId utils.SQLVal = "select t.AREAUSERID," +
  868. " t.ORIBUYPLANQTY," +
  869. " t.ORIBUYPRICEDQTY," +
  870. " t.ORISELLPLANQTY," +
  871. " t.ORISELLPRICEDQTY," +
  872. " t.BUYPLANQTY," +
  873. " t.BUYPRICEDQTY," +
  874. " t.SELLPLANQTY," +
  875. " t.SELLPRICEDQTY," +
  876. " t.TOTALSPOTQTY," +
  877. " g.deliverygoodsid," +
  878. " g.deliverygoodscode," +
  879. " g.deliverygoodsname," +
  880. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" +
  881. " from ermcp_areaspot t" +
  882. " left join deliverygoods g" +
  883. " on t.deliverygoodsid = g.deliverygoodsid" +
  884. " where 1 = 1"
  885. sqlId.And("t.areauserid", r.AREAUSERID)
  886. return sqlId.String()
  887. }
  888. // GetDataEx
  889. func (r *Ermcp3AreaSpot) GetDataEx() (interface{}, error) {
  890. e := db.GetEngine()
  891. s := e.SQL(r.buildSql())
  892. sData := make([]Ermcp3AreaSpot, 0)
  893. if err := s.Find(&sData); err != nil {
  894. return nil, err
  895. }
  896. for i := range sData {
  897. sData[i].calc()
  898. }
  899. return sData, nil
  900. }
  901. // Ermcp3AreaSpotDetail 敞口现货头寸明细
  902. type Ermcp3AreaSpotDetail struct {
  903. Relatedid string `json:"relatedid" xorm:"'relatedid'"` // 套保计划ID/现货合同ID
  904. Relatedno string `json:"relatedno" xorm:"'relatedno'"` // 编号
  905. LogType int32 `json:"logtype" xorm:"'logType'"` // 记录类型 1-套保 2-现货合同
  906. Contracttype int32 `json:"contracttype" xorm:"'contracttype'"` // 合同类型 1-采购 -1-销售
  907. Qty float64 `json:"qty" xorm:"'qty'"` // 数量
  908. Strtime string `json:"strtime" xorm:"'strtime'"` // 时间
  909. Enumdicname string `json:"enumdicname"` // 现货商品单位名称
  910. Recordname string `json:"recordname"` // 类型名称
  911. CREATETIME string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  912. Unitid int32 `json:"-" xorm:"'UNITID'"` // 单位ID
  913. UserId int `json:"-"` // 所属用户ID
  914. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种id
  915. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  916. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  917. }
  918. func (r *Ermcp3AreaSpotDetail) calc() {
  919. var logTypeName, contractTypeName string
  920. if r.LogType == 1 {
  921. logTypeName = "计划"
  922. } else {
  923. logTypeName = "合同"
  924. }
  925. if r.Contracttype == 1 {
  926. contractTypeName = "采购"
  927. } else {
  928. contractTypeName = "销售"
  929. }
  930. // 销售合同 数量转为负数
  931. if r.LogType == 2 && r.Contracttype == -1 {
  932. if r.Qty > 0 {
  933. r.Qty = r.Qty * -1
  934. }
  935. }
  936. // 采购计划 数量转为负数
  937. if r.LogType == 1 && r.Contracttype == 1 {
  938. if r.Qty > 0 {
  939. r.Qty = r.Qty * -1
  940. }
  941. }
  942. r.Recordname = contractTypeName + logTypeName
  943. r.Enumdicname = mtpcache.GetEnumDicitemName(r.Unitid)
  944. }
  945. func (r *Ermcp3AreaSpotDetail) buildSql() string {
  946. var sqlId utils.SQLVal = "with tmp as" +
  947. " (select to_char(t.hedgeplanid) relatedid," +
  948. " t.hedgeplanno relatedno," +
  949. " 1 as logType," +
  950. " t.contracttype" +
  951. " from ermcp_hedgeplan t" +
  952. " where t.areauserid = %v" +
  953. " and t.deliverygoodsid = %v" +
  954. " union all" +
  955. " select to_char(t.spotcontractid)," +
  956. " t.contractno," +
  957. " 2 as logType," +
  958. " t.contracttype" +
  959. " from ermcp_spotcontract t" +
  960. " where t.userid = %v" +
  961. " and t.deliverygoodsid = %v)" +
  962. "select t.relatedid," +
  963. " tmp.relatedno," +
  964. " t.LogType," +
  965. " tmp.contracttype," +
  966. " t.RealQty qty," +
  967. " to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
  968. " g.deliverygoodsid," +
  969. " g.deliverygoodsname," +
  970. " g.deliverygoodscode," +
  971. " g.goodsunitid unitid" +
  972. " from ermcp_spotlog t" +
  973. " inner join tmp" +
  974. " on t.LogType = tmp.logType" +
  975. " and t.relatedid = tmp.relatedid" +
  976. " and t.areauserid = %v" +
  977. " and t.deliverygoodsid = %v" +
  978. " left join deliverygoods g" +
  979. " on t.deliverygoodsid = g.deliverygoodsid" +
  980. " where t.tradedate = to_char(sysdate, 'yyyymmdd')"
  981. sqlId.FormatParam(r.UserId, r.DELIVERYGOODSID, r.UserId, r.DELIVERYGOODSID, r.UserId, r.DELIVERYGOODSID)
  982. return sqlId.String()
  983. }
  984. // GetDataEx
  985. func (r *Ermcp3AreaSpotDetail) GetDataEx() (interface{}, error) {
  986. e := db.GetEngine()
  987. s := e.SQL(r.buildSql())
  988. sData := make([]Ermcp3AreaSpotDetail, 0)
  989. if err := s.Find(&sData); err != nil {
  990. return nil, err
  991. }
  992. for i := range sData {
  993. sData[i].calc()
  994. }
  995. return sData, nil
  996. }
  997. // Ermcp3Wrstandard 现货品类
  998. type Ermcp3Wrstandard struct {
  999. WRSTANDARDID int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 品类ID(SEQ_WRSTANDARD)
  1000. WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 品类代码
  1001. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID
  1002. UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 品类单位ID
  1003. MINIVALUE int32 `json:"minivalue" xorm:"'MINIVALUE'"` // 最小变动值
  1004. MINIVALUEDP int32 `json:"minivaluedp" xorm:"'MINIVALUEDP'"` // 最小变动值小数位
  1005. REALMINIVALUE int32 `json:"realminivalue" xorm:"'REALMINIVALUE'"` // 实际最小变动值
  1006. REALMINIVALUEDP int32 `json:"realminivaluedp" xorm:"'REALMINIVALUEDP'"` // 实际最小变动值小数位
  1007. CREATORID int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人
  1008. CREATETIME string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  1009. WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 品类名称
  1010. AREAUSERID int `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  1011. EnumdicName string `json:"enumdicname"` // 品类单位名称
  1012. ISVALID int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 0-无效(停用) 1-有效(正常)
  1013. UPDATETIME string `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  1014. REMARK string `json:"remark" xorm:"'REMARK'"` // 备注
  1015. CONVERTFACTOR float64 `json:"convertfactor" xorm:"'CONVERTFACTOR'"` // 标仓系数
  1016. }
  1017. func (r *Ermcp3Wrstandard) calc() {
  1018. r.EnumdicName = mtpcache.GetEnumDicitemName(r.UNITID)
  1019. }
  1020. func (r *Ermcp3Wrstandard) buildSql() string {
  1021. str := "select WRSTANDARDID," +
  1022. " WRSTANDARDCODE," +
  1023. " DELIVERYGOODSID," +
  1024. " UNITID," +
  1025. " MINIVALUE," +
  1026. " MINIVALUEDP," +
  1027. " REALMINIVALUE," +
  1028. " REALMINIVALUEDP," +
  1029. " CREATORID," +
  1030. " to_char(CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
  1031. " WRSTANDARDNAME," +
  1032. " ISVALID," +
  1033. " to_char(UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  1034. " REMARK," +
  1035. " CONVERTFACTOR," +
  1036. " AREAUSERID" +
  1037. " from wrstandard t" +
  1038. " where t.AREAUSERID=%v"
  1039. sqlId := fmt.Sprintf(str, r.AREAUSERID)
  1040. if r.DELIVERYGOODSID > 0 {
  1041. sqlId = sqlId + fmt.Sprintf(" and DELIVERYGOODSID=%v", r.DELIVERYGOODSID)
  1042. }
  1043. sqlId += " order by createtime desc"
  1044. return sqlId
  1045. }
  1046. // GetDataEx
  1047. func (r *Ermcp3Wrstandard) GetDataEx() (interface{}, error) {
  1048. e := db.GetEngine()
  1049. s := e.SQL(r.buildSql())
  1050. sData := make([]Ermcp3Wrstandard, 0)
  1051. if err := s.Find(&sData); err != nil {
  1052. return nil, err
  1053. }
  1054. for i := range sData {
  1055. sData[i].calc()
  1056. }
  1057. return sData, nil
  1058. }
  1059. // Ermcp3AreaStockApply 出入库申请
  1060. type Ermcp3AreaStockApply struct {
  1061. INOUTAPPLYID string `json:"inoutapplyid" xorm:"'INOUTAPPLYID'"` // 申请ID(607+Unix秒时间戳(10位)+xxxxxx)
  1062. USERID int64 `json:"userid" xorm:"'USERID'"` // 机构ID
  1063. INOUTTYPE int32 `json:"inouttype" xorm:"'INOUTTYPE'"` // 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
  1064. WRSTANDARDID int32 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 品类ID
  1065. SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID
  1066. SPOTCONTRACTID string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 关联现货合同ID
  1067. WAREHOUSEINFOID string `json:"warehouseinfoid" xorm:"'WAREHOUSEINFOID'"` // 现货仓库ID
  1068. QTY float64 `json:"qty" xorm:"'QTY'"` // 数量
  1069. APPLYSTATUS int32 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
  1070. APPLYSRC int32 `json:"applysrc" xorm:"'APPLYSRC'"` // 申请来源 - 1:管理端 2:终端
  1071. APPLYID int64 `json:"applyid" xorm:"'APPLYID'"` // 申请人
  1072. APPLYREMARK string `json:"applyremark" xorm:"'APPLYREMARK'"` // 申请备注
  1073. APPLYTIME string `json:"applytime" xorm:"'APPLYTIME'"` // 申请时间
  1074. AUDITSRC int32 `json:"auditsrc" xorm:"'AUDITSRC'"` // 审核来源 - 1:管理端 2:终端
  1075. AUDITID int64 `json:"auditid" xorm:"'AUDITID'"` // 审核人
  1076. AUDITTIME string `json:"audittime" xorm:"'AUDITTIME'"` // 审核时间
  1077. AUDITREMARK string `json:"auditremark" xorm:"'AUDITREMARK'"` // 审核备注
  1078. AUDITTRADEDATE string `json:"audittradedate" xorm:"'AUDITTRADEDATE'"` // 审核交易日(yyyyMMdd)
  1079. WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 品类名称
  1080. WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 品类代码
  1081. UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 单位id
  1082. BRANDNAME string `json:"brandname" xorm:"'BRANDNAME'"` // 品牌名称
  1083. WAREHOUSENAME string `json:"warehousename" xorm:"'WAREHOUSENAME'"` // 仓库名称
  1084. WAREHOUSECODE string `json:"warehousecode" xorm:"'WAREHOUSECODE'"` // 仓库代码
  1085. WAREHOUSETYPE int32 `json:"warehousetype" xorm:"'WAREHOUSETYPE'"` // 仓库类型 - 1 厂库 2 自有库 3 合作库
  1086. CONTRACTNO string `json:"contractno" xorm:"'CONTRACTNO'"` // 合同编号
  1087. CONTRACTTYPE int32 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 现货合同类型 - 1:采购 -1:销售
  1088. BUYUSERID int64 `json:"buyuserid" xorm:"'BUYUSERID'"` // 采购方userid
  1089. SELLUSERID int64 `json:"selluserid" xorm:"'SELLUSERID'"` // 销售方userid
  1090. PRICETYPE int32 `json:"pricetype" xorm:"'PRICETYPE'"` // 定价类型 - 1:一口价 2:点价 3:暂定价
  1091. CONTRACTQTY float64 `json:"contractqty" xorm:"'CONTRACTQTY'"` // 合同量
  1092. BUYUSERNAME string `json:"buyusername"` // 采购方名称
  1093. SELLUSERNAME string `json:"sellusername"` // 销售方名称
  1094. APPLYNAME string `json:"applyname"` // 申请人名称
  1095. AUDITNAME string `json:"auditname"` // 审核人名称
  1096. ENUMDICNAME string `json:"enumdicname"` // 现货商品单位名称
  1097. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种id
  1098. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  1099. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  1100. BUYNICKNAME string `json:"buynickname"` // 采购方昵称
  1101. SELLNICKNAME string `json:"sellnickname"` // 销售方昵称
  1102. FilterStatus string `json:"-"` // 查询条件, 申请状态, 逗号隔开
  1103. FilterType string `json:"-"` // 查询条件, 出入库类型, 逗号隔开
  1104. BeginDate string `json:"-"` // 开始日期
  1105. EndDate string `json:"-"` // 结束日期
  1106. }
  1107. func (r *Ermcp3AreaStockApply) calc() {
  1108. // 采购方名称
  1109. r.BUYUSERNAME, r.BUYNICKNAME = mtpcache.GetUserNameAndNickName(r.BUYUSERID)
  1110. // 销售方名称
  1111. r.SELLUSERNAME, r.SELLNICKNAME = mtpcache.GetUserNameAndNickName(r.SELLUSERID)
  1112. // 申请人名称
  1113. if r.APPLYSRC == 1 {
  1114. r.APPLYNAME = mtpcache.GetSystemmangerLoginCode(r.APPLYID)
  1115. } else {
  1116. r.APPLYNAME = mtpcache.GetLoginCodeByLoginId(r.APPLYID)
  1117. }
  1118. // 审核人名称
  1119. if r.AUDITSRC == 1 {
  1120. r.AUDITNAME = mtpcache.GetSystemmangerLoginCode(r.AUDITID)
  1121. } else {
  1122. r.AUDITNAME = mtpcache.GetLoginCodeByLoginId(r.AUDITID)
  1123. }
  1124. // 单位名称
  1125. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
  1126. }
  1127. func (r *Ermcp3AreaStockApply) buildSql() string {
  1128. var sqlId utils.SQLVal = "SELECT to_char(t.INOUTAPPLYID) INOUTAPPLYID," +
  1129. " t.USERID," +
  1130. " t.INOUTTYPE," +
  1131. " t.WRSTANDARDID," +
  1132. " t.SPOTGOODSBRANDID," +
  1133. " t.DELIVERYGOODSID," +
  1134. " to_char(t.SPOTCONTRACTID) SPOTCONTRACTID," +
  1135. " to_char(t.WAREHOUSEINFOID) WAREHOUSEINFOID," +
  1136. " t.QTY," +
  1137. " t.APPLYSTATUS," +
  1138. " t.APPLYSRC," +
  1139. " t.APPLYID," +
  1140. " t.APPLYREMARK," +
  1141. " to_char(t.APPLYTIME, 'yyyy-mm-dd hh24:mi:ss') APPLYTIME," +
  1142. " t.AUDITSRC," +
  1143. " t.AUDITID," +
  1144. " to_char(t.AUDITTIME, 'yyyy-mm-dd hh24:mi:ss') AUDITTIME," +
  1145. " t.AUDITREMARK," +
  1146. " t.AUDITTRADEDATE," +
  1147. " w.wrstandardname," +
  1148. " w.wrstandardcode," +
  1149. " g.goodsunitid unitid," +
  1150. " gb.dgfactoryitemvalue brandname," +
  1151. " h.warehousename," +
  1152. " h.warehousecode," +
  1153. " h.warehousetype," +
  1154. " s.contractno," +
  1155. " s.contracttype," +
  1156. " s.buyuserid," +
  1157. " s.selluserid," +
  1158. " s.pricetype," +
  1159. " s.qty CONTRACTQTY," +
  1160. " g.deliverygoodscode," +
  1161. " g.deliverygoodsname" +
  1162. " FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
  1163. " left join wrstandard w" +
  1164. " on t.wrstandardid = w.wrstandardid" +
  1165. " left join dgfactoryitem gb" +
  1166. " on t.spotgoodsbrandid = gb.dgfactoryitemid" +
  1167. " left join deliverygoods g" +
  1168. " on t.deliverygoodsid = g.deliverygoodsid" +
  1169. " left join warehouseinfo h" +
  1170. " on t.warehouseinfoid = h.autoid" +
  1171. " left join ermcp_spotcontract s" +
  1172. " on t.spotcontractid = s.spotcontractid" +
  1173. " WHERE 1 = 1"
  1174. // 用户id(必要条件)
  1175. sqlId.And("t.USERID", r.USERID)
  1176. // 合同id
  1177. if len(r.SPOTCONTRACTID) > 0 {
  1178. sqlId.And("t.SPOTCONTRACTID", r.SPOTCONTRACTID)
  1179. }
  1180. // 现货品种id
  1181. if r.DELIVERYGOODSID > 0 {
  1182. sqlId.And("t.DELIVERYGOODSID", r.DELIVERYGOODSID)
  1183. }
  1184. // 品类id
  1185. if r.WRSTANDARDID > 0 {
  1186. sqlId.And("t.WRSTANDARDID", r.WRSTANDARDID)
  1187. }
  1188. // 品牌id
  1189. if r.SPOTGOODSBRANDID > 0 {
  1190. sqlId.And("t.SPOTGOODSBRANDID", r.SPOTGOODSBRANDID)
  1191. }
  1192. // 仓库id
  1193. if len(r.WAREHOUSEINFOID) > 0 {
  1194. sqlId.And("t.WAREHOUSEINFOID", r.WAREHOUSEINFOID)
  1195. }
  1196. // 日期范围
  1197. if len(r.BeginDate) > 0 {
  1198. if r.BeginDate == r.EndDate {
  1199. sqlId.And("t.audittradedate", r.BeginDate)
  1200. } else if r.EndDate > r.BeginDate {
  1201. sqlId.BiggerOrEq("t.audittradedate", r.BeginDate)
  1202. sqlId.LessOrEq("t.audittradedate", r.EndDate)
  1203. }
  1204. }
  1205. // 出入库类型
  1206. if len(r.FilterType) > 0 {
  1207. if len(r.FilterType) == 1 {
  1208. sqlId.And("t.INOUTTYPE", r.FilterType)
  1209. } else {
  1210. sqlId.Join(fmt.Sprintf(" and t.INOUTTYPE in(%v)", r.FilterType))
  1211. }
  1212. }
  1213. // 出入库状态
  1214. if len(r.FilterStatus) > 0 {
  1215. sqlId.Join(fmt.Sprintf(" and t.APPLYSTATUS in(%v)", r.FilterStatus))
  1216. }
  1217. // 排序
  1218. sqlId.Join(" order by t.APPLYTIME desc")
  1219. return sqlId.String()
  1220. }
  1221. // GetDataEx 查询库存申请(记录)
  1222. func (r *Ermcp3AreaStockApply) GetDataEx() (interface{}, error) {
  1223. sData := make([]Ermcp3AreaStockApply, 0)
  1224. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1225. if err == nil {
  1226. for i := range sData {
  1227. sData[i].calc()
  1228. }
  1229. }
  1230. return sData, err
  1231. }
  1232. // Ermcp3AreaStockApplySum 合同出入库数量汇总
  1233. type Ermcp3AreaStockApplySum struct {
  1234. INOUTTYPE int32 `json:"inouttype" xorm:"'INOUTTYPE'"` // 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
  1235. WRSTANDARDID int32 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 品类id
  1236. SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 品牌id
  1237. BRANDNAME string `json:"brandname" xorm:"'BRANDNAME'"` // 品牌名称
  1238. WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 品类名称
  1239. TOTALQTY float64 `json:"totalqty" xorm:"'TOTALQTY'"` // 总数量
  1240. SPOTCONTRACTID string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 关联现货合同ID
  1241. }
  1242. func (r *Ermcp3AreaStockApplySum) buildSql() string {
  1243. sqlId := "select a.*, gb.dgfactoryitemvalue brandname, w.wrstandardname" +
  1244. " from (SELECT t.INOUTTYPE," +
  1245. " t.wrstandardid," +
  1246. " t.SPOTGOODSBRANDID," +
  1247. " t.SPOTCONTRACTID," +
  1248. " sum(t.QTY) TOTALQTY" +
  1249. " FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
  1250. " WHERE t.applystatus = 2" +
  1251. " and t.spotcontractid = %v" +
  1252. " group by t.inouttype," +
  1253. " t.spotgoodsbrandid," +
  1254. " t.wrstandardid," +
  1255. " t.spotcontractid) a" +
  1256. " left join dgfactoryitem gb" +
  1257. " on a.spotgoodsbrandid = gb.dgfactoryitemid" +
  1258. " left join wrstandard w" +
  1259. " on a.wrstandardid = w.wrstandardid"
  1260. sqlId = fmt.Sprintf(sqlId, r.SPOTCONTRACTID)
  1261. // 不关联合同id
  1262. sqlId2 := "select a.*, gb.dgfactoryitemvalue brandname, w.wrstandardname" +
  1263. " from (SELECT t.INOUTTYPE," +
  1264. " t.wrstandardid," +
  1265. " t.SPOTGOODSBRANDID," +
  1266. " t.SPOTCONTRACTID," +
  1267. " sum(t.QTY) TOTALQTY" +
  1268. " FROM ERMCP_AREAINOUTSTOCKAPPLY t" +
  1269. " WHERE t.applystatus = 2" +
  1270. " group by t.inouttype," +
  1271. " t.spotgoodsbrandid," +
  1272. " t.wrstandardid," +
  1273. " t.spotcontractid) a" +
  1274. " left join dgfactoryitem gb" +
  1275. " on a.spotgoodsbrandid = gb.dgfactoryitemid" +
  1276. " left join wrstandard w" +
  1277. " on a.wrstandardid = w.wrstandardid"
  1278. if len(r.SPOTCONTRACTID) == 0 {
  1279. return sqlId2
  1280. }
  1281. return sqlId
  1282. }
  1283. // GetDataEx 获取合同出入库汇总信息
  1284. func (r *Ermcp3AreaStockApplySum) GetDataEx() (interface{}, error) {
  1285. sData := make([]Ermcp3AreaStockApplySum, 0)
  1286. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1287. return sData, err
  1288. }
  1289. // Ermcp3AreaStock 机构库存表
  1290. type Ermcp3AreaStock struct {
  1291. TODAYBUYINQTY float64 `json:"todaybuyinqty" xorm:"'TODAYBUYINQTY'"` // 今日采购入库量
  1292. TODAYPRODUCEINQTY float64 `json:"todayproduceinqty" xorm:"'TODAYPRODUCEINQTY'"` // 今日生产入库量
  1293. TODAYSELLOUTQTY float64 `json:"todayselloutqty" xorm:"'TODAYSELLOUTQTY'"` // 今日销售出库量
  1294. TODAYPRODUCEOUTQTY float64 `json:"todayproduceoutqty" xorm:"'TODAYPRODUCEOUTQTY'"` // 今日生产出库量
  1295. UPDATETIME string `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  1296. USERID int64 `json:"userid" xorm:"'USERID'" form:"userid" binding:"required"` // 机构ID
  1297. WRSTANDARDID string `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 品类ID
  1298. SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID
  1299. WAREHOUSEINFOID string `json:"warehouseinfoid" xorm:"'WAREHOUSEINFOID'"` // 仓库ID
  1300. ORISTOCK float64 `json:"oristock" xorm:"'ORISTOCK'"` // 期初库存量(昨日量)
  1301. CURSTOCK float64 `json:"curstock" xorm:"'CURSTOCK'"` // 期末库存量(今日量)
  1302. WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 品类名称
  1303. WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 品类代码
  1304. UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 单位id
  1305. BRANDNAME string `json:"brandname" xorm:"'BRANDNAME'"` // 品牌名称
  1306. WAREHOUSENAME string `json:"warehousename" xorm:"'WAREHOUSENAME'"` // 仓库名称
  1307. WAREHOUSECODE string `json:"warehousecode" xorm:"'WAREHOUSECODE'"` // 仓库代码
  1308. WAREHOUSETYPE int32 `json:"warehousetype" xorm:"'WAREHOUSETYPE'"` // 仓库类型 - 1 厂库 2 自有库 3 合作库
  1309. USERNAME string `json:"username"` // 机构名称
  1310. ENUMDICNAME string `json:"enumdicname"` // 单位名称
  1311. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种id
  1312. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  1313. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  1314. GOODSUNITID int32 `json:"goodsunitid" xorm:"'GOODSUNITID'"` // 现货商品单位id
  1315. }
  1316. func (r *Ermcp3AreaStock) calc() {
  1317. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  1318. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
  1319. }
  1320. func (r *Ermcp3AreaStock) buildSql() string {
  1321. var sqlId utils.SQLVal = "SELECT t.TODAYBUYINQTY," +
  1322. " t.TODAYPRODUCEINQTY," +
  1323. " t.TODAYSELLOUTQTY," +
  1324. " t.TODAYPRODUCEOUTQTY," +
  1325. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  1326. " t.USERID," +
  1327. " t.WRSTANDARDID," +
  1328. " t.SPOTGOODSBRANDID," +
  1329. " t.WAREHOUSEINFOID," +
  1330. " t.DELIVERYGOODSID," +
  1331. " t.ORISTOCK," +
  1332. " t.CURSTOCK," +
  1333. " w.wrstandardname," +
  1334. " w.wrstandardcode," +
  1335. " w.unitid," +
  1336. " gb.dgfactoryitemvalue brandname," +
  1337. " h.warehousename," +
  1338. " h.warehousecode," +
  1339. " h.warehousetype," +
  1340. " g.deliverygoodsid," +
  1341. " g.deliverygoodscode," +
  1342. " g.deliverygoodsname," +
  1343. " g.goodsunitid" +
  1344. " FROM ERMCP_AREASTOCK t" +
  1345. " LEFT JOIN WRSTANDARD w" +
  1346. " on t.wrstandardid = w.wrstandardid" +
  1347. " LEFT JOIN dgfactoryitem gb" +
  1348. " on t.spotgoodsbrandid = gb.dgfactoryitemvalue" +
  1349. " LEFT JOIN deliverygoods g" +
  1350. " on t.deliverygoodsid = g.deliverygoodsid" +
  1351. " LEFT JOIN WAREHOUSEINFO h" +
  1352. " on t.warehouseinfoid = h.autoid" +
  1353. " WHERE 1 = 1"
  1354. sqlId.And("t.USERID", r.USERID)
  1355. sqlId.Join(" order by t.WRSTANDARDID, t.UPDATETIME desc")
  1356. return sqlId.String()
  1357. }
  1358. // GetDataEx 获取机构库存信息
  1359. func (r *Ermcp3AreaStock) GetDataEx() (interface{}, error) {
  1360. sData := make([]Ermcp3AreaStock, 0)
  1361. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1362. if err == nil {
  1363. for i := range sData {
  1364. sData[i].calc()
  1365. }
  1366. }
  1367. return sData, err
  1368. }
  1369. // Ermcp3AreaStockReport 库存报表
  1370. type Ermcp3AreaStockReport struct {
  1371. USERID int64 `json:"userid" xorm:"'USERID'"` // 机构ID
  1372. WRSTANDARDID int32 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 品类ID
  1373. SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID
  1374. WAREHOUSEINFOID string `json:"warehouseinfoid" xorm:"'WAREHOUSEINFOID'"` // 仓库ID
  1375. ORISTOCK float64 `json:"oristock" xorm:"'ORISTOCK'"` // 期初库存量
  1376. CURSTOCK float64 `json:"curstock" xorm:"'CURSTOCK'"` // 期末库存量
  1377. TODAYBUYINQTY float64 `json:"todaybuyinqty" xorm:"'TODAYBUYINQTY'"` // 今日采购入库量
  1378. TODAYPRODUCEINQTY float64 `json:"todayproduceinqty" xorm:"'TODAYPRODUCEINQTY'"` // 今日生产入库量
  1379. TODAYSELLOUTQTY float64 `json:"todayselloutqty" xorm:"'TODAYSELLOUTQTY'"` // 今日销售出库量
  1380. TODAYPRODUCEOUTQTY float64 `json:"todayproduceoutqty" xorm:"'TODAYPRODUCEOUTQTY'"` // 今日生产出库量
  1381. UPDATETIME string `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  1382. WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 品类名称
  1383. WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 品类代码
  1384. UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 品类单位id
  1385. BRANDNAME string `json:"brandname" xorm:"'BRANDNAME'"` // 品牌名称
  1386. WAREHOUSENAME string `json:"warehousename" xorm:"'WAREHOUSENAME'"` // 仓库名称
  1387. WAREHOUSECODE string `json:"warehousecode" xorm:"'WAREHOUSECODE'"` // 仓库代码
  1388. WAREHOUSETYPE int32 `json:"warehousetype" xorm:"'WAREHOUSETYPE'"` // 仓库类型 - 1 厂库 2 自有库 3 合作库
  1389. USERNAME string `json:"username"` // 机构名称
  1390. ENUMDICNAME string `json:"enumdicname"` // 单位名称
  1391. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种id
  1392. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  1393. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  1394. GOODSUNITID int32 `json:"goodsunitid" xorm:"'GOODSUNITID'"` // 现货单位id
  1395. ReportType int32 `json:"-"` // 报表类型 1-日报表 2-月报表
  1396. ReportDate string `json:"-"` // 格式 日报表(YYYYMMDD) 月报表(YYYYMM)
  1397. }
  1398. func (r *Ermcp3AreaStockReport) calc() {
  1399. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  1400. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
  1401. }
  1402. func (r *Ermcp3AreaStockReport) buildSql() string {
  1403. var sqlId utils.SQLVal = "SELECT t.TODAYBUYINQTY," +
  1404. " t.TODAYPRODUCEINQTY," +
  1405. " t.TODAYSELLOUTQTY," +
  1406. " t.TODAYPRODUCEOUTQTY," +
  1407. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  1408. " t.USERID," +
  1409. " t.WRSTANDARDID," +
  1410. " t.SPOTGOODSBRANDID," +
  1411. " t.WAREHOUSEINFOID," +
  1412. " t.ORISTOCK," +
  1413. " t.CURSTOCK," +
  1414. " w.wrstandardname," +
  1415. " w.wrstandardcode," +
  1416. " w.unitid," +
  1417. " gb.dgfactoryitemvalue brandname," +
  1418. " h.warehousename," +
  1419. " h.warehousecode," +
  1420. " h.warehousetype," +
  1421. " g.deliverygoodsid," +
  1422. " g.deliverygoodscode," +
  1423. " g.deliverygoodsname," +
  1424. " g.goodsunitid" +
  1425. " FROM %v t" +
  1426. " LEFT JOIN WRSTANDARD w" +
  1427. " on t.wrstandardid = w.wrstandardid" +
  1428. " LEFT JOIN dgfactoryitem gb" +
  1429. " on t.spotgoodsbrandid = gb.dgfactoryitemid" +
  1430. " LEFT JOIN deliverygoods g" +
  1431. " on t.deliverygoodsid = g.deliverygoodsid" +
  1432. " LEFT JOIN WAREHOUSEINFO h" +
  1433. " on t.warehouseinfoid = h.autoid" +
  1434. " WHERE 1 = 1"
  1435. sqlId.And("t.USERID", r.USERID)
  1436. if r.ReportType == 1 {
  1437. // 日报表
  1438. sqlId.FormatParam("RECKON_ERMCP_AREASTOCK")
  1439. sqlId.And("t.reckondate", r.ReportDate)
  1440. } else {
  1441. // 月报表
  1442. sqlId.FormatParam("REPORT_ERMCP_AREASTOCK")
  1443. sqlId.And("t.cycletype", 1)
  1444. sqlId.And("t.cycletime", r.ReportDate)
  1445. }
  1446. // 现货商品id
  1447. sqlId.AndEx("t.DELIVERYGOODSID", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
  1448. // 品类id
  1449. sqlId.AndEx("t.WRSTANDARDID", r.WRSTANDARDID, r.WRSTANDARDID > 0)
  1450. // 品牌id
  1451. if r.SPOTGOODSBRANDID > 0 {
  1452. sqlId.And("t.SPOTGOODSBRANDID", r.SPOTGOODSBRANDID)
  1453. }
  1454. // 仓库id
  1455. if len(r.WAREHOUSEINFOID) > 0 {
  1456. sqlId.And("t.WAREHOUSEINFOID", r.WAREHOUSEINFOID)
  1457. }
  1458. return sqlId.String()
  1459. }
  1460. // GetDataEx 查询库存报表
  1461. func (r *Ermcp3AreaStockReport) GetDataEx() (interface{}, error) {
  1462. sData := make([]ErmcpAreaStockReport, 0)
  1463. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1464. if err == nil {
  1465. for i := range sData {
  1466. sData[i].calc()
  1467. }
  1468. }
  1469. return sData, err
  1470. }
  1471. // Ermcp3SpotGoodsPrice 现货市价
  1472. type Ermcp3SpotGoodsPrice struct {
  1473. WRSTANDARDID int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货品类ID(通用则为0)
  1474. SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID(通用则为0, 不为0则须先有品类ID)
  1475. CURRENCYID int64 `json:"currencyid" xorm:"'CURRENCYID'"` // 报价货币ID
  1476. SPOTGOODSPRICE float64 `json:"spotgoodsprice" xorm:"'SPOTGOODSPRICE'"` // 现货价格
  1477. TRADEDATE string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  1478. OPERATESRC int32 `json:"operatesrc" xorm:"'OPERATESRC'"` // 最后操作来源 - 1:管理端 2:终端
  1479. OPERATEID int64 `json:"operateid" xorm:"'OPERATEID'"` // 最后操作人
  1480. OPERATETIME string `json:"operatetime" xorm:"'OPERATETIME'"` // 最后操作时间
  1481. ISVALID int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效
  1482. AREAUSERID int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构id
  1483. WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 品类代码
  1484. WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 品类名称
  1485. UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 现货商品单位id
  1486. BRANDNAME string `json:"brandname" xorm:"'BRANDNAME'"` // 品牌名称
  1487. GMUNITID int32 `json:"gmunitid" xorm:"'GMUNITID'"` // 品类单位id
  1488. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货商品id
  1489. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
  1490. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
  1491. OPERATORNAME string `json:"operatorname"` // 操作人名称
  1492. ENUMDICNAME string `json:"enumdicname"` // 现货商品单位名称
  1493. GBENUMDICNAME string `json:"gbenumdicname"` // 品类单位名称
  1494. }
  1495. func (r *Ermcp3SpotGoodsPrice) calc() {
  1496. if r.OPERATESRC == 1 {
  1497. r.OPERATORNAME = mtpcache.GetSystemmangerLoginCode(r.OPERATEID)
  1498. } else {
  1499. r.OPERATORNAME = mtpcache.GetLoginCodeByLoginId(r.OPERATEID)
  1500. }
  1501. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
  1502. r.GBENUMDICNAME = mtpcache.GetEnumDicitemName(r.GMUNITID)
  1503. }
  1504. func (r *Ermcp3SpotGoodsPrice) buildSql() string {
  1505. var sqlId utils.SQLVal = "SELECT t.WRSTANDARDID," +
  1506. " t.SPOTGOODSBRANDID," +
  1507. " t.CURRENCYID," +
  1508. " t.SPOTGOODSPRICE," +
  1509. " t.TRADEDATE," +
  1510. " t.OPERATESRC," +
  1511. " t.OPERATEID," +
  1512. " to_char(t.OPERATETIME, 'yyyy-mm-dd hh24:mi:ss') OPERATETIME," +
  1513. " t.ISVALID," +
  1514. " w.areauserid," +
  1515. " w.wrstandardcode," +
  1516. " w.wrstandardname," +
  1517. " w.unitid gmunitid," +
  1518. " gb.dgfactoryitemvalue brandname," +
  1519. " g.deliverygoodsid," +
  1520. " g.deliverygoodscode," +
  1521. " g.deliverygoodsname," +
  1522. " g.goodsunitid unitid" +
  1523. " FROM ERMCP_SPOTGOODSPRICE t" +
  1524. " left join wrstandard w" +
  1525. " on t.wrstandardid = w.wrstandardid" +
  1526. " left join dgfactoryitem gb" +
  1527. " on t.spotgoodsbrandid = gb.dgfactoryitemid" +
  1528. " left join deliverygoods g" +
  1529. " on t.deliverygoodsid = g.deliverygoodsid" +
  1530. " WHERE 1 = 1"
  1531. sqlId.And("w.areauserid", r.AREAUSERID)
  1532. return sqlId.String()
  1533. }
  1534. // GetDataEx 获取现货市价
  1535. func (r *Ermcp3SpotGoodsPrice) GetDataEx() (interface{}, error) {
  1536. sData := make([]Ermcp3SpotGoodsPrice, 0)
  1537. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1538. if err == nil {
  1539. for i := range sData {
  1540. sData[i].calc()
  1541. }
  1542. }
  1543. return sData, err
  1544. }
  1545. // Ermcp3SpotGoodsPriceLog 现货市价操作日志
  1546. type Ermcp3SpotGoodsPriceLog struct {
  1547. LOGID int64 `json:"logid" xorm:"'LOGID'"` // 日志id
  1548. WRSTANDARDID int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货品类ID(通用则为0)
  1549. SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID(通用则为0, 不为0则须先有品类ID)
  1550. CURRENCYID int64 `json:"currencyid" xorm:"'CURRENCYID'"` // 报价货币ID
  1551. SPOTGOODSPRICE float64 `json:"spotgoodsprice" xorm:"'SPOTGOODSPRICE'"` // 现货价格
  1552. TRADEDATE string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  1553. OPERATESRC int32 `json:"operatesrc" xorm:"'OPERATESRC'"` // 最后操作来源 - 1:管理端 2:终端
  1554. OPERATEID int64 `json:"operateid" xorm:"'OPERATEID'"` // 最后操作人
  1555. OPERATETIME string `json:"operatetime" xorm:"'OPERATETIME'"` // 最后操作时间
  1556. AREAUSERID int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构id
  1557. WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 品类代码
  1558. WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 品类名称
  1559. UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 现货商品单位id
  1560. BRANDNAME string `json:"brandname" xorm:"'BRANDNAME'"` // 品牌名称
  1561. GMUNITID int32 `json:"gmunitid" xorm:"'GMUNITID'"` // 品类单位id
  1562. DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货商品id
  1563. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
  1564. DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
  1565. OPERATORNAME string `json:"operatorname"` // 操作人名称
  1566. ENUMDICNAME string `json:"enumdicname"` // 现货商品单位名称
  1567. GBENUMDICNAME string `json:"gbenumdicname"` // 品类单位名称
  1568. }
  1569. func (r *Ermcp3SpotGoodsPriceLog) calc() {
  1570. if r.OPERATESRC == 1 {
  1571. r.OPERATORNAME = mtpcache.GetSystemmangerLoginCode(r.OPERATEID)
  1572. } else {
  1573. r.OPERATORNAME = mtpcache.GetLoginCodeByLoginId(r.OPERATEID)
  1574. }
  1575. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
  1576. r.GBENUMDICNAME = mtpcache.GetEnumDicitemName(r.GMUNITID)
  1577. }
  1578. func (r *Ermcp3SpotGoodsPriceLog) buildSql() string {
  1579. var sqlId utils.SQLVal = "SELECT t.WRSTANDARDID," +
  1580. " t.SPOTGOODSBRANDID," +
  1581. " t.CURRENCYID," +
  1582. " t.SPOTGOODSPRICE," +
  1583. " t.TRADEDATE," +
  1584. " t.OPERATESRC," +
  1585. " t.OPERATEID," +
  1586. " to_char(t.OPERATETIME, 'yyyy-mm-dd hh24:mi:ss') OPERATETIME," +
  1587. " t.LOGID," +
  1588. " w.areauserid," +
  1589. " w.wrstandardcode," +
  1590. " w.wrstandardname," +
  1591. " w.unitid gmunitid," +
  1592. " gb.dgfactoryitemvalue brandname," +
  1593. " g.goodsunitid unitid ," +
  1594. " g.deliverygoodsid," +
  1595. " g.deliverygoodscode," +
  1596. " g.deliverygoodsname" +
  1597. " FROM ERMCP_SPOTGOODSPRICELOG t" +
  1598. " left join wrstandard w" +
  1599. " on t.wrstandardid = w.wrstandardid" +
  1600. " left join dgfactoryitem gb" +
  1601. " on t.spotgoodsbrandid = gb.dgfactoryitemid" +
  1602. " left join deliverygoods g" +
  1603. " on t.deliverygoodsid = g.deliverygoodsid" +
  1604. " WHERE 1 = 1"
  1605. sqlId.And("w.areauserid", r.AREAUSERID)
  1606. sqlId.And("t.deliverygoodsid", r.DELIVERYGOODSID)
  1607. return sqlId.String()
  1608. }
  1609. // GetDataEx 获取现货市价信息日志
  1610. func (r *Ermcp3SpotGoodsPriceLog) GetDataEx() (interface{}, error) {
  1611. sData := make([]Ermcp3SpotGoodsPriceLog, 0)
  1612. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1613. if err == nil {
  1614. for i := range sData {
  1615. sData[i].calc()
  1616. }
  1617. }
  1618. return sData, err
  1619. }
  1620. // Ermcp3HedgePlan 套保计划表结构
  1621. type Ermcp3HedgePlan struct {
  1622. Areauserid int64 `json:"areauserid" xorm:"'Areauserid'"` // 用户ID
  1623. Hedgeplanid string `json:"hedgeplanid" xorm:"'Hedgeplanid'"` // 套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
  1624. Hedgeplanno string `json:"hedgeplanno" xorm:"'Hedgeplanno'"` // 套保计划编号(名称)
  1625. Contracttype int `json:"contracttype" xorm:"'Contracttype'"` // 计划类型 - 1:采购 -1:销售
  1626. Deliverygoodsid int `json:"deliverygoodsid" xorm:"'Deliverygoodsid'"` // 现货品种ID
  1627. Deliverygoodsname string `json:"deliverygoodsname" xorm:"'Deliverygoodsname'"` // 现货品种名称
  1628. DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
  1629. Producttype int `json:"producttype" xorm:"'Producttype'"` // 产品类型 - 1:标准仓单 2:等标 3:非标
  1630. Spotgoodsdesc string `json:"spotgoodsdesc" xorm:"'Spotgoodsdesc'"` // 商品型号
  1631. Planqty float64 `json:"planqty" xorm:"'Planqty'"` // 计划数量
  1632. Convertfactor float64 `json:"convertfactor" xorm:"'Convertfactor'"` // 标仓系数
  1633. Plantime string `json:"plantime" xorm:"'Plantime'"` // 计划时间
  1634. Hedgeplanstatus int `json:"hedgeplanstatus" xorm:"'Hedgeplanstatus'"` // 套保计划状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
  1635. Remark string `json:"remark" xorm:"'Remark'"` // 备注
  1636. CREATETIME string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  1637. UPDATETIME string `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  1638. AUDITTIME string `json:"audittime" xorm:"'AUDITTIME'"` // 审核时间
  1639. UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 单位id
  1640. ENUMDICNAME string `json:"enumdicname"` // 单位名称
  1641. }
  1642. func (r *Ermcp3HedgePlan) calc() {
  1643. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
  1644. }
  1645. func (r *Ermcp3HedgePlan) buildSql(status string) string {
  1646. str := "select to_char(t.Hedgeplanid) Hedgeplanid," +
  1647. " t.Hedgeplanno," +
  1648. " t.Contracttype," +
  1649. " t.Deliverygoodsid," +
  1650. " g.Deliverygoodsname," +
  1651. " g.deliverygoodscode," +
  1652. " g.goodsunitid unitid," +
  1653. " t.Producttype," +
  1654. " t.Spotgoodsdesc," +
  1655. " t.Planqty," +
  1656. " t.Convertfactor," +
  1657. " to_char(t.Plantime, 'yyyy-mm-dd hh24:mi:ss') Plantime," +
  1658. " to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
  1659. " to_char(t.updatetime, 'yyyy-mm-dd hh24:mi:ss') updatetime," +
  1660. " to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
  1661. " t.Hedgeplanstatus," +
  1662. " t.Remark" +
  1663. " from ermcp_hedgeplan t" +
  1664. " left join deliverygoods g" +
  1665. " on t.deliverygoodsid = g.deliverygoodsid" +
  1666. " where t.hedgeplanstatus in (%v)" +
  1667. " and t.areauserid = %v"
  1668. if status == "2" {
  1669. // 执行中状态,按审核时间倒序
  1670. str += " order by t.audittime desc"
  1671. } else {
  1672. str += " order by t.updatetime desc"
  1673. }
  1674. return fmt.Sprintf(str, status, r.Areauserid)
  1675. }
  1676. // GetData 从数据库中查询套保计划数据
  1677. func (r *Ermcp3HedgePlan) GetData(status string) ([]Ermcp3HedgePlan, error) {
  1678. e := db.GetEngine()
  1679. sData := make([]Ermcp3HedgePlan, 0)
  1680. if err := e.SQL(r.buildSql(status)).Find(&sData); err != nil {
  1681. logger.GetLogger().Errorf("query hedgeplan:%v", err)
  1682. return sData, err
  1683. }
  1684. for i := range sData {
  1685. sData[i].calc()
  1686. }
  1687. return sData, nil
  1688. }
  1689. // Ermcp3GoodsGroup 商品组
  1690. type Ermcp3GoodsGroup struct {
  1691. GOODSGROUPID int32 `json:"goodsgroupid" xorm:"'GOODSGROUPID'"` // 商品组ID(自增ID)
  1692. GOODSGROUPNAME string `json:"goodsgroupname" xorm:"'GOODSGROUPNAME'"` // 商品组名称
  1693. GOODSGROUPSTATUS int32 `json:"goodsgroupstatus" xorm:"'GOODSGROUPSTATUS'"` // 商品组状态 - 1:正常 2:注销
  1694. MARKETID int32 `json:"marketid" xorm:"'MARKETID'"` // 所属市场ID
  1695. CREATETIME string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  1696. CREATORID int32 `json:"creatorid" xorm:"'CREATORID'"` // 创建人
  1697. MODIFYTIME string `json:"modifytime" xorm:"'MODIFYTIME'"` // 修改时间
  1698. MODIFIERID int32 `json:"modifierid" xorm:"'MODIFIERID'"` // 修改人
  1699. QUOTESOURCEGROUPID int64 `json:"quotesourcegroupid" xorm:"'QUOTESOURCEGROUPID'"` // 所属行情源分组ID[参考行情市场用\通道交易]
  1700. OUTERGROUPCODE string `json:"outergroupcode" xorm:"'OUTERGROUPCODE'"` // 外部商品组代码[通道交易]
  1701. CANSHORT int32 `json:"canshort" xorm:"'CANSHORT'"` // 是否允许做空[通道交易] - 0:不能做空 1:可以做空
  1702. EXEXCHANGEID int64 `json:"exexchangeid" xorm:"'EXEXCHANGEID'"` // 外部交易所ID[通道交易]
  1703. CURRENCYID int32 `json:"currencyid" xorm:"'CURRENCYID'"` // 报价货币ID
  1704. GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 报价单位ID
  1705. AGREEUNIT float32 `json:"agreeunit" xorm:"'AGREEUNIT'"` // 合约单位
  1706. DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 报价小数位
  1707. QUOTEMINUNIT int32 `json:"quoteminunit" xorm:"'QUOTEMINUNIT'"` // 行情最小变动单位 [整数,报价小数位一起使用]
  1708. INNERDEALMODE int32 `json:"innerdealmode" xorm:"'INNERDEALMODE'"` // 内部成交方式[通道交易] - 1:净头寸 2:开平 3:平今
  1709. OUTERDEALMODE int32 `json:"outerdealmode" xorm:"'OUTERDEALMODE'"` // 外部成交方式[通道交易]- 1:净头寸 2:开平 3:平今
  1710. SYNCGOODSQTY int32 `json:"syncgoodsqty" xorm:"'SYNCGOODSQTY'"` // 同步合约数[通道交易-投资管理用] - 0表示不限
  1711. CLOSEPRICEMODE int32 `json:"closepricemode" xorm:"'CLOSEPRICEMODE'"` // 强平价格方式 - 1:市价 2:最新价 3:涨跌停(未实现)
  1712. GROUPCATEGROYID int32 `json:"groupcategroyid" xorm:"'GROUPCATEGROYID'"` // 品种分类ID
  1713. AreaUserId int64 `json:"areauserid" form:"areauserid" binding:"required"` // 所属机构id(套保品是有areauserid的,当要排除已配置商品组时需要areauserid过滤)
  1714. ExcludeCfg int32 `json:"excludecfg" form:"excludecfg"` // 排除套保品已配置期货分类下的商品组(但显示已配置商品组) 1-排除
  1715. }
  1716. func (r *Ermcp3GoodsGroup) calc() {
  1717. }
  1718. func (r *Ermcp3GoodsGroup) buildSql() string {
  1719. var sqlId utils.SQLVal = "SELECT t.GOODSGROUPID," +
  1720. " t.GOODSGROUPNAME," +
  1721. " t.GOODSGROUPSTATUS," +
  1722. " t.MARKETID," +
  1723. " to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
  1724. " t.CREATORID," +
  1725. " to_char(t.MODIFYTIME, 'yyyy-mm-dd hh24:mi:ss') MODIFYTIME," +
  1726. " t.MODIFIERID," +
  1727. " t.QUOTESOURCEGROUPID," +
  1728. " t.OUTERGROUPCODE," +
  1729. " t.CANSHORT," +
  1730. " t.EXEXCHANGEID," +
  1731. " t.CURRENCYID," +
  1732. " t.GOODUNITID," +
  1733. " t.AGREEUNIT," +
  1734. " t.DECIMALPLACE," +
  1735. " t.QUOTEMINUNIT," +
  1736. " t.INNERDEALMODE," +
  1737. " t.OUTERDEALMODE," +
  1738. " t.SYNCGOODSQTY," +
  1739. " t.CLOSEPRICEMODE," +
  1740. " t.GROUPCATEGROYID" +
  1741. " FROM GOODSGROUP t" +
  1742. " WHERE 1 = 1"
  1743. if r.ExcludeCfg == 1 {
  1744. str := "select t.goodsgroupid" +
  1745. " from ERMS_MiddleGoods t" +
  1746. " where t.isvalid=1 and t.areauserid = %v" +
  1747. "union all" +
  1748. "select goodsgroupid" +
  1749. " from goodsgroup t" +
  1750. " where t.groupcategroyid not in" +
  1751. " (select distinct g.groupcategroyid" +
  1752. " from erms_middlegoods t" +
  1753. " left join goodsgroup g" +
  1754. " on t.goodsgroupid = g.goodsgroupid" +
  1755. " where t.isvalid=1 and t.areauserid = %v)"
  1756. str = fmt.Sprintf(str, r.AreaUserId, r.AreaUserId)
  1757. sqlId.Join(fmt.Sprintf("and t.groupcategroyid not in(%v)", str))
  1758. }
  1759. return sqlId.String()
  1760. }
  1761. // GetData
  1762. func (r *Ermcp3GoodsGroup) GetData() ([]Ermcp3GoodsGroup, error) {
  1763. sData := make([]Ermcp3GoodsGroup, 0)
  1764. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1765. for i := range sData {
  1766. sData[i].calc()
  1767. }
  1768. return sData, err
  1769. }
  1770. // GetDataEx 商品组信息
  1771. func (r *Ermcp3GoodsGroup) GetDataEx() (interface{}, error) {
  1772. return r.GetData()
  1773. }