qhj.go 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760
  1. /**
  2. * @Author: zou.yingbin
  3. * @Create : 2021/6/1 14:14
  4. * @Modify : 2021/6/1 14:14
  5. */
  6. package models
  7. import (
  8. "fmt"
  9. "mtp2_if/db"
  10. "mtp2_if/mtpcache"
  11. "mtp2_if/utils"
  12. "strconv"
  13. )
  14. // 大连千海金
  15. // QhjAreaRole 角色查询
  16. type QhjAreaRole struct {
  17. FROMUSERID int64 `json:"fromuserid" xorm:"FROMUSERID"` // 所属机构(组织机构)( OrgType = 1时为自己, = 2\3时取上级机构的所属机构)
  18. SUBORGTYPE int32 `json:"suborgtype" xorm:"SUBORGTYPE"` // 子机构类型(千海金) - 0:机构 1:代理 2:门店
  19. USERID int64 `json:"userid" xorm:"USERID"` // 机构用户ID其他做市关系,都设置为 1
  20. ROLETYPE int32 `json:"roletype" xorm:"ROLETYPE"` // 角色类型 - 1:交易所 2:运营机构 3:营销中心 4:仓库机构 5:三方服务机构 6:自营会员 7:经纪会员 8:做市会员 9:产业会员 10:金融机构 11:商城店铺 12:子机构 13:报价商 14:积分服务商 15:供货商 16:圈内会员 17:物流机构 18:报价配置机构 19:场外期权做市商 20:组织机构 21:顶级机构 22:业务员 23:跟单员 24:交易员 25:客户 98:代理 99:门店
  21. TRADEACCOUNTID int64 `json:"tradeaccountid" xorm:"TRADEACCOUNTID"` // 默认交易资金账号ID(做市会员被动接单使用、商城店铺默认资金账 号、圈内会员默认资金账号) - 作废, 使用UserReckonAccount
  22. CREATETIME string `json:"createtime" xorm:"CREATETIME"` // 创建时间
  23. CREATORID int64 `json:"creatorid" xorm:"CREATORID"` // 创建人ID
  24. MODIFYTIME string `json:"modifytime" xorm:"MODIFYTIME"` // 修改时间
  25. MODIFIERID int64 `json:"modifierid" xorm:"MODIFIERID"` // 修改人ID
  26. SHOPPASSWORD string `json:"shoppassword" xorm:"SHOPPASSWORD"` // 商城店铺登陆密码(商城店铺角色使用)
  27. ISRETURNSCORE int32 `json:"isreturnscore" xorm:"ISRETURNSCORE"` // 是否返还积分 [经纪会员-辽东湾] - 0:不返还 1:返还
  28. TRANSURL string `json:"transurl" xorm:"TRANSURL"` // 物流地址(物流机构)
  29. OUTUSERID string `json:"outuserid" xorm:"OUTUSERID"` // 外部账户[场外期权做市商]
  30. PARENTUSERID int64 `json:"parentuserid" xorm:"PARENTUSERID"` // 上级组织机构(组织机构)
  31. ROOTUSERID int64 `json:"rootuserid" xorm:"ROOTUSERID"` // 顶级组织机构用户ID(组织机构)
  32. SUBLEVELPATH string `json:"sublevelpath" xorm:"SUBLEVELPATH"` // 组织机构层级路径(逗号分隔,首尾加逗号)
  33. ORGTYPE int32 `json:"orgtype" xorm:"ORGTYPE"` // 组织机构类型 1:机构\分支节点 2:交易员\叶子节点 3:部门\分支节点
  34. }
  35. func (r *QhjAreaRole) calc() {
  36. }
  37. func (r *QhjAreaRole) buildSql() string {
  38. var sqlId utils.SQLVal = "select * from arearole t where 1=1"
  39. sqlId.AndEx("t.USERID", r.USERID, r.USERID > 0)
  40. sqlId.AndEx("t.ROLETYPE", r.ROLETYPE, r.ROLETYPE > 0)
  41. sqlId.AndEx("t.SUBORGTYPE", r.SUBORGTYPE, r.SUBORGTYPE > 0)
  42. sqlId.AndEx("t.FROMUSERID", r.FROMUSERID, r.FROMUSERID > 0)
  43. return sqlId.String()
  44. }
  45. // GetDataEx 获取角色查询
  46. func (r *QhjAreaRole) GetData() ([]QhjAreaRole, error) {
  47. sData := make([]QhjAreaRole, 0)
  48. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  49. for i := range sData {
  50. sData[i].calc()
  51. }
  52. return sData, err
  53. }
  54. // QhjContract 千海金融资明细(合同)
  55. type QhjContract struct {
  56. USERID int64 `json:"userid" xorm:"USERID"` // 用户ID
  57. SCFCONTRACTID string `json:"scfcontractid" xorm:"SCFCONTRACTID"` // SCF合同ID(310+Unix秒时间戳(10位)+xxxxxx)
  58. SCFCONTRACTTYPE int32 `json:"scfcontracttype" xorm:"SCFCONTRACTTYPE"` // 合同类型 - 1:仓单回购 2:仓单质押 3:合作套保 4:资金贷款 5:融资单
  59. GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID [5:融资单]
  60. CONTRACTCONFIRMTIME string `json:"contractconfirmtime" xorm:"CONTRACTCONFIRMTIME"` // 合同确认时间(时间)
  61. WRQTY float64 `json:"wrqty" xorm:"WRQTY"` // 仓单数量(数量)
  62. TRADEPRICE float64 `json:"tradeprice" xorm:"TRADEPRICE"` // 成交价格(成本价格)
  63. LENDERAMOUNT float64 `json:"lenderamount" xorm:"LENDERAMOUNT"` // 贷款金额(总额|订单总额)
  64. MARGINRATIO float64 `json:"marginratio" xorm:"MARGINRATIO"` // 保证金比率(首付比例)
  65. INITMARGIN float64 `json:"initmargin" xorm:"'INITMARGIN'"` // 初始保证金(首付款)
  66. RECOVEREDMARGIN float64 `json:"recoveredmargin" xorm:"'RECOVEREDMARGIN'"` // 已追缴保证金
  67. REMAINAMOUNT float64 `json:"remainamount" xorm:"'REMAINAMOUNT'"` // 合同剩余金额(融资额)
  68. TOTALINTEREST float64 `json:"totalinterest" xorm:"'TOTALINTEREST'"` // 已计总利息(利息)
  69. GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码
  70. GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称
  71. GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 商品单位id
  72. CURRISKLEVEL int32 `json:"currisklevel" xorm:"'CURRISKLEVEL'"` // 风险级别 - 1:正常 2:追加货款 3:支付尾款
  73. RECKONRECOVERMARGIN float64 `json:"reckonrecovermargin" xorm:"'RECKONRECOVERMARGIN'"` // 结算应追缴保底金(结算时到过风险率时临时存储) - [仓单回购\仓单质押]
  74. DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
  75. SCFCONTRACTSTATUS int32 `json:"scfcontractstatus" xorm:"'SCFCONTRACTSTATUS'"` // 合同状态 - 1:待确认 2:已确认 3:确认拒绝 4:已支付保证金 5:已激活 6:已违约 7:到期结束 8:延期结束 9:违约结束 10:已注销 11:已关闭 99:未提交
  76. PAYAMOUNT float64 `json:"payamount" xorm:"'PAYAMOUNT'"` // 已付(已付货款)
  77. USERNAME string `json:"username" xorm:"'USERNAME'"` // 用户名称
  78. ENUMDICNAME string `json:"enumdicname"` // 单位名称
  79. }
  80. func (r *QhjContract) calc() {
  81. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  82. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
  83. // 已付(已付货款) = 已追缴保证金 + 初始保证金
  84. r.PAYAMOUNT = r.RECOVEREDMARGIN + r.INITMARGIN
  85. if r.SCFCONTRACTSTATUS == 10 || r.SCFCONTRACTSTATUS == 11 {
  86. // 当合同关闭时, 利息重置为0
  87. r.TOTALINTEREST = 0
  88. }
  89. }
  90. func (r *QhjContract) buildSql() string {
  91. var sqlId utils.SQLVal = "select t.borroweruserid userid," +
  92. " to_char(t.scfcontractid) scfcontractid," +
  93. " t.scfcontracttype," +
  94. " t.goodsid," +
  95. " to_char(t.contractconfirmtime, 'yyyy-mm-dd hh24:mi:ss') contractconfirmtime," +
  96. " t.wrqty," +
  97. " t.tradeprice," +
  98. " t.lenderamount," +
  99. " t.marginratio," +
  100. " s.initmargin," +
  101. " s.recoveredmargin," +
  102. " s.remainamount," +
  103. " s.totalinterest," +
  104. " s.currisklevel," +
  105. " s.reckonrecovermargin," +
  106. " s.scfcontractstatus," +
  107. " g.goodscode," +
  108. " g.goodsname," +
  109. " g.decimalplace," +
  110. " g.goodunitid" +
  111. " from scf_contract t" +
  112. " left join scf_contractinfo s" +
  113. " on t.scfcontractid = s.scfcontractid" +
  114. " left join goods g" +
  115. " on t.goodsid = g.goodsid" +
  116. " where 1=1"
  117. sqlId.AndEx("t.borroweruserid", r.USERID, r.USERID > 0)
  118. sqlId.AndEx("t.SCFCONTRACTID", r.SCFCONTRACTID, len(r.SCFCONTRACTID) > 0)
  119. return sqlId.String()
  120. }
  121. // GetDataEx 获取融资明细(合同)
  122. func (r *QhjContract) GetDataEx() (interface{}, error) {
  123. sData := make([]QhjContract, 0)
  124. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  125. for i := range sData {
  126. sData[i].calc()
  127. }
  128. return sData, err
  129. }
  130. // QhjContractLog 融资明细流水log
  131. type QhjContractLog struct {
  132. LOGID string `json:"logid" xorm:"LOGID"` // LogID(315+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
  133. SCFCONTRACTID int64 `json:"scfcontractid" xorm:"SCFCONTRACTID"` // SCF合同ID(310+Unix秒时间戳(10位)+xxxxxx)
  134. AMOUNTTYPE int32 `json:"amounttype" xorm:"AMOUNTTYPE"` // 资金类型 - 1:首付款 2:尾款 3:利息 4:追加款
  135. AMOUNT float64 `json:"amount" xorm:"AMOUNT"` // 支付金额
  136. REMAINAMOUNT float64 `json:"remainamount" xorm:"REMAINAMOUNT"` // 剩余货款
  137. UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
  138. FilterType string `json:"-"` // 资金类型
  139. }
  140. func (r *QhjContractLog) calc() {
  141. }
  142. func (r *QhjContractLog) buildSql() string {
  143. var sqlId utils.SQLVal = "SELECT t.LOGID," +
  144. " t.SCFCONTRACTID," +
  145. " t.AMOUNTTYPE," +
  146. " t.AMOUNT," +
  147. " t.REMAINAMOUNT," +
  148. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" +
  149. " FROM SCF_CONTRACTAMOUNTLOG t" +
  150. " WHERE 1 = 1"
  151. sqlId.AndEx("t.SCFCONTRACTID", r.SCFCONTRACTID, r.SCFCONTRACTID > 0)
  152. sqlId.JoinEx(len(r.FilterType) > 0, fmt.Sprintf(" and t.AMOUNTTYPE in(%v)", r.FilterType))
  153. return sqlId.String()
  154. }
  155. // GetDataEx 获取融资明细流水log
  156. func (r *QhjContractLog) GetDataEx() (interface{}, error) {
  157. sData := make([]QhjContractLog, 0)
  158. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  159. for i := range sData {
  160. sData[i].calc()
  161. }
  162. return sData, err
  163. }
  164. // QhjRStrategy 定投规则策略
  165. type QhjRStrategy struct {
  166. REGULARLYCYCLE int32 `json:"regularlycycle" xorm:"REGULARLYCYCLE"` // 定投频率 - 1:每周 2:每月
  167. REGULARLYCYCLEVALUE string `json:"regularlycyclevalue" xorm:"REGULARLYCYCLEVALUE"` // 定投频率值 - 每周几(0-6) 或 每月几号(<=28)
  168. REGULARLYMODE int32 `json:"regularlymode" xorm:"REGULARLYMODE"` // 定投方式 - 1:按数量 2:按金额
  169. REGULARLYMODEVALUE float64 `json:"regularlymodevalue" xorm:"REGULARLYMODEVALUE"` // 定投方式值 - 数量或金额
  170. REMARK string `json:"remark" xorm:"REMARK"` // 备注
  171. REGULARLYSTRATEGYSTATUS int32 `json:"regularlystrategystatus" xorm:"REGULARLYSTRATEGYSTATUS"` // 策略状态 - 1:正常 2:暂停 3:终止
  172. TRIGGERTOTALTIMES string `json:"triggertotaltimes" xorm:"TRIGGERTOTALTIMES"` // 累计定投总次数
  173. TRIGGERSUCCESSTIMES string `json:"triggersuccesstimes" xorm:"TRIGGERSUCCESSTIMES"` // 累计定投成功次数
  174. TRIGGERTOTALQTY float64 `json:"triggertotalqty" xorm:"TRIGGERTOTALQTY"` // 累计定投数量(成功) [按小数位放大值]
  175. TRIGGERTOTALAMOUNT float64 `json:"triggertotalamount" xorm:"TRIGGERTOTALAMOUNT"` // 累计定投金额(成功)
  176. LASTEFFECTTRADEDATE string `json:"lasteffecttradedate" xorm:"LASTEFFECTTRADEDATE"` // 最新生效交易日
  177. LASTSTOPTRADEDATE string `json:"laststoptradedate" xorm:"LASTSTOPTRADEDATE"` // 最新暂停交易日
  178. LASTTRIGGERTRADEDATE string `json:"lasttriggertradedate" xorm:"LASTTRIGGERTRADEDATE"` // 最新触发交易日
  179. NEXTTRIGGERDATE string `json:"nexttriggerdate" xorm:"NEXTTRIGGERDATE"` // 下次触发日期
  180. NEXTTRIGGERQTY float64 `json:"nexttriggerqty" xorm:"NEXTTRIGGERQTY"` // 下次触发数量 [按小数位放大值]
  181. NEXTTRIGGERAMOUNT float64 `json:"nexttriggeramount" xorm:"NEXTTRIGGERAMOUNT"` // 下次触发金额
  182. UPDATORID string `json:"updatorid" xorm:"UPDATORID"` // 更新人
  183. UPDATESRC int32 `json:"updatesrc" xorm:"UPDATESRC"` // 更新来源 - 1:管理端 2:终端
  184. UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
  185. REGULARLYSTRATEGYID int64 `json:"regularlystrategyid" xorm:"REGULARLYSTRATEGYID"` // 定投策略ID (SEQ_QHJ_REGULARLYSTRATEGY)
  186. USERID int64 `json:"userid" xorm:"USERID"` // 所属用户ID
  187. ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 用户资金账户
  188. GOODSID string `json:"goodsid" xorm:"GOODSID"` // 定投商品ID
  189. GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 定投商品代码
  190. GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 定投商品名称
  191. GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 定投商品单位id
  192. CURRENCYID int32 `json:"currencyid" xorm:"'CURRENCYID'"` // 币种id
  193. DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
  194. QTYDECIMALPLACE int `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
  195. LOGINCODE string `json:"logincode" xorm:"'LOGINCODE'"` // 账号(登录代码)
  196. USERINFOTYPE int32 `json:"userinfotype" xorm:"'USERINFOTYPE'"` // 用户类型 1-个人 2-企业
  197. MOBILE string `json:"-" xorm:"'MOBILE'"` // 电话号码(用户资料里的电话)
  198. USERNAME string `json:"username"` // 用户名称(userid对应的名称)
  199. ACCOUNTNAME string `json:"accountname"` // 账号名称(ACCOUNTID对应的名称)
  200. ENUMDICNAME string `json:"enumdicname"` // 单位名称
  201. CURRENCYNAME string `json:"currencyname"` // 币种名称
  202. FilterStatus string `json:"-"` // 状态过滤条件
  203. }
  204. func (r *QhjRStrategy) calc() {
  205. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  206. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
  207. r.CURRENCYNAME = mtpcache.GetCurrencyName(r.CURRENCYID)
  208. ZoomByDecimal(r.QTYDECIMALPLACE, &r.TRIGGERTOTALQTY, &r.NEXTTRIGGERQTY)
  209. if r.REGULARLYMODE == 1 {
  210. ZoomByDecimal(r.QTYDECIMALPLACE, &r.REGULARLYMODEVALUE)
  211. }
  212. if r.LOGINCODE == "" {
  213. r.LOGINCODE = DecryptField(r.MOBILE)
  214. }
  215. }
  216. func (r *QhjRStrategy) buildSql() string {
  217. var sqlId utils.SQLVal = "with k as (select t.userid, wm_concat(t.logincode) logincode from loginaccount t group by t.userid)" +
  218. "SELECT t.REGULARLYCYCLE," +
  219. " t.REGULARLYCYCLEVALUE," +
  220. " t.REGULARLYMODE," +
  221. " t.REGULARLYMODEVALUE," +
  222. " t.REMARK," +
  223. " t.REGULARLYSTRATEGYSTATUS," +
  224. " t.TRIGGERTOTALTIMES," +
  225. " t.TRIGGERSUCCESSTIMES," +
  226. " t.TRIGGERTOTALQTY," +
  227. " t.TRIGGERTOTALAMOUNT," +
  228. " t.LASTEFFECTTRADEDATE," +
  229. " t.LASTSTOPTRADEDATE," +
  230. " t.LASTTRIGGERTRADEDATE," +
  231. " to_char(t.NEXTTRIGGERDATE, 'yyyy-mm-dd hh24:mi:ss') NEXTTRIGGERDATE," +
  232. " t.NEXTTRIGGERQTY," +
  233. " t.NEXTTRIGGERAMOUNT," +
  234. " t.UPDATORID," +
  235. " t.UPDATESRC," +
  236. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  237. " t.REGULARLYSTRATEGYID," +
  238. " t.USERID," +
  239. " t.ACCOUNTID," +
  240. " t.GOODSID," +
  241. " g.goodscode," +
  242. " g.goodsname," +
  243. " g.decimalplace," +
  244. " g.qtydecimalplace," +
  245. " g.goodunitid," +
  246. " ta.accountname," +
  247. " k.logincode," +
  248. " ui.userinfotype" +
  249. " FROM QHJ_REGULARLYSTRATEGY t" +
  250. " LEFT JOIN GOODS g" +
  251. " on t.goodsid = g.goodsid" +
  252. " LEFT JOIN TAACCOUNT ta" +
  253. " on t.accountid = ta.accountid" +
  254. " LEFT JOIN USERINFO ui on t.userid=ui.userid" +
  255. " LEFT JOIN k on t.userid=k.userid" +
  256. " WHERE 1 = 1"
  257. sqlId.AndEx("t.USERID", r.USERID, r.USERID > 0)
  258. sqlId.JoinEx(len(r.FilterStatus) > 0, fmt.Sprintf(" and t.REGULARLYSTRATEGYSTATUS in(%v)", r.FilterStatus))
  259. return sqlId.String()
  260. }
  261. // GetDataEx 获取定投规则策略
  262. func (r *QhjRStrategy) GetDataEx() (interface{}, error) {
  263. sData := make([]QhjRStrategy, 0)
  264. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  265. for i := range sData {
  266. sData[i].calc()
  267. }
  268. return sData, err
  269. }
  270. // QhjRSTriggerLog 定投规则策略触发记录
  271. type QhjRSTriggerLog struct {
  272. TRADEID string `json:"tradeid" xorm:"TRADEID"` // 成交单ID
  273. LOGID string `json:"logid" xorm:"LOGID"` // LogID(SEQ_QHJ_RSTRIGGERLOG)
  274. REGULARLYSTRATEGYID int64 `json:"regularlystrategyid" xorm:"REGULARLYSTRATEGYID"` // 定投策略ID
  275. USERID int64 `json:"userid" xorm:"USERID"` // 所属用户ID
  276. ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 用户资金账户
  277. GOODSID string `json:"goodsid" xorm:"GOODSID"` // 定投商品ID
  278. REGULARLYCYCLE int32 `json:"regularlycycle" xorm:"REGULARLYCYCLE"` // 定投频率 - 1:每周 2:每月
  279. REGULARLYCYCLEVALUE string `json:"regularlycyclevalue" xorm:"REGULARLYCYCLEVALUE"` // 定投频率值 - 每周几(0-6) 或 每月几号(<=28)
  280. REGULARLYMODE int32 `json:"regularlymode" xorm:"REGULARLYMODE"` // 定投方式 - 1:按数量 2:按金额
  281. REGULARLYMODEVALUE float64 `json:"regularlymodevalue" xorm:"REGULARLYMODEVALUE"` // 定投方式值 - 数量或金额
  282. TRIGGERTIME string `json:"triggertime" xorm:"TRIGGERTIME"` // 触发时间
  283. TRIGGERTRADEDATE string `json:"triggertradedate" xorm:"TRIGGERTRADEDATE"` // 触发交易日
  284. TRIGGERQTY float64 `json:"triggerqty" xorm:"TRIGGERQTY"` // 触发数量
  285. TRIGGERAMOUNT float64 `json:"triggeramount" xorm:"TRIGGERAMOUNT"` // 触发金额
  286. TRIGGERSTATUS int32 `json:"triggerstatus" xorm:"TRIGGERSTATUS"` // 触发状态 - 1:成功 2:失败
  287. RETCODE string `json:"retcode" xorm:"RETCODE"` // 错误码
  288. GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 定投商品代码
  289. GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 定投商品名称
  290. GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 定投商品单位id
  291. CURRENCYID int32 `json:"currencyid" xorm:"'CURRENCYID'"` // 币种id
  292. DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
  293. QTYDECIMALPLACE int `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
  294. USERNAME string `json:"username"` // 用户名称(userid对应的名称)
  295. ACCOUNTNAME string `json:"accountname"` // 账号名称(ACCOUNTID对应的名称)
  296. ENUMDICNAME string `json:"enumdicname"` // 单位名称
  297. CURRENCYNAME string `json:"currencyname"` // 币种名称
  298. }
  299. func (r *QhjRSTriggerLog) calc() {
  300. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  301. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
  302. r.CURRENCYNAME = mtpcache.GetCurrencyName(r.CURRENCYID)
  303. ZoomByDecimal(r.QTYDECIMALPLACE, &r.TRIGGERQTY)
  304. if r.REGULARLYMODE == 1 {
  305. ZoomByDecimal(r.QTYDECIMALPLACE, &r.REGULARLYMODEVALUE)
  306. }
  307. }
  308. func (r *QhjRSTriggerLog) buildSql() string {
  309. var sqlId utils.SQLVal = "SELECT t.TRADEID," +
  310. " t.LOGID," +
  311. " t.REGULARLYSTRATEGYID," +
  312. " t.USERID," +
  313. " t.ACCOUNTID," +
  314. " t.GOODSID," +
  315. " t.REGULARLYCYCLE," +
  316. " t.REGULARLYCYCLEVALUE," +
  317. " t.REGULARLYMODE," +
  318. " t.REGULARLYMODEVALUE," +
  319. " to_char(t.TRIGGERTIME, 'yyyy-mm-dd hh24:mi:ss') TRIGGERTIME," +
  320. " t.TRIGGERTRADEDATE," +
  321. " t.TRIGGERQTY," +
  322. " t.TRIGGERAMOUNT," +
  323. " t.TRIGGERSTATUS," +
  324. " t.RETCODE," +
  325. " g.goodscode," +
  326. " g.goodsname," +
  327. " g.decimalplace," +
  328. " g.qtydecimalplace," +
  329. " g.goodunitid," +
  330. " ta.accountname," +
  331. " ta.currencyid" +
  332. " FROM QHJ_RSTRIGGERLOG t" +
  333. " LEFT JOIN GOODS g" +
  334. " on t.goodsid = g.goodsid" +
  335. " LEFT JOIN TAACCOUNT ta" +
  336. " on t.accountid = ta.accountid" +
  337. " WHERE 1 = 1"
  338. sqlId.AndEx("t.USERID", r.USERID, r.USERID > 0)
  339. sqlId.AndEx("t.REGULARLYSTRATEGYID", r.REGULARLYSTRATEGYID, r.REGULARLYSTRATEGYID > 0)
  340. return sqlId.String()
  341. }
  342. // GetDataEx 获取定投规则策略触发记录
  343. func (r *QhjRSTriggerLog) GetDataEx() (interface{}, error) {
  344. sData := make([]QhjRSTriggerLog, 0)
  345. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  346. for i := range sData {
  347. sData[i].calc()
  348. }
  349. return sData, err
  350. }
  351. // UserReceiveInfo 用户收货信息
  352. type UserReceiveInfo struct {
  353. AUTOID int32 `json:"autoid" xorm:"AUTOID"` // AutoID
  354. USERID int64 `json:"userid" xorm:"USERID"` // 用户ID
  355. RECEIVERNAME string `json:"receivername" xorm:"RECEIVERNAME"` // 提货人姓名
  356. CARDTYPEID int32 `json:"cardtypeid" xorm:"CARDTYPEID"` // 证件类型
  357. CARDNUM string `json:"cardnum" xorm:"CARDNUM"` // 证件号码(加密存储)
  358. PHONENUM string `json:"phonenum" xorm:"PHONENUM"` // 提货人联系方式(加密存储)
  359. ADDRESS string `json:"address" xorm:"ADDRESS"` // 提货人详细地址
  360. TAKEREMARK string `json:"takeremark" xorm:"TAKEREMARK"` // 提货备注
  361. COUNTRYID int32 `json:"countryid" xorm:"COUNTRYID"` // 国家
  362. PROVINCEID int32 `json:"provinceid" xorm:"PROVINCEID"` // 省
  363. CITYID int32 `json:"cityid" xorm:"CITYID"` // 市
  364. DISTRICTID int32 `json:"districtid" xorm:"DISTRICTID"` // 地区
  365. ISDEFAULT int32 `json:"isdefault" xorm:"ISDEFAULT"` // 是否默认地址 - 0:否 1:是
  366. HASENCRYPT int32 `json:"hasencrypt" xorm:"HASENCRYPT"` // 数据是否已加密 - 0:未加密 1:已加密
  367. COUNTRYNAME string `json:"countryname"` // 国家名称
  368. CITYNAME string `json:"cityname"` // 城市名称
  369. PROVINCENAME string `json:"provincename"` // 省名称
  370. DISTRICTNAME string `json:"districtname"` // 地区名称
  371. }
  372. func (r *UserReceiveInfo) calc() {
  373. // 加密过的长度 > 16, 否则是未加密的
  374. if len(r.CARDNUM) > 16 {
  375. r.CARDNUM = DecryptField(r.CARDNUM)
  376. }
  377. if len(r.PHONENUM) > 16 {
  378. r.PHONENUM = DecryptField(r.PHONENUM)
  379. }
  380. r.COUNTRYNAME = mtpcache.GetDivisionName(r.COUNTRYID)
  381. r.CITYNAME = mtpcache.GetDivisionName(r.CITYID)
  382. r.PROVINCENAME = mtpcache.GetDivisionName(r.PROVINCEID)
  383. r.DISTRICTNAME = mtpcache.GetDivisionName(r.DISTRICTID)
  384. }
  385. func (r *UserReceiveInfo) buildSql() string {
  386. var sqlId utils.SQLVal = "SELECT t.AUTOID," +
  387. " t.USERID," +
  388. " t.RECEIVERNAME," +
  389. " t.CARDTYPEID," +
  390. " t.CARDNUM," +
  391. " t.PHONENUM," +
  392. " t.ADDRESS," +
  393. " t.TAKEREMARK," +
  394. " t.COUNTRYID," +
  395. " t.PROVINCEID," +
  396. " t.CITYID," +
  397. " t.DISTRICTID," +
  398. " t.ISDEFAULT," +
  399. " t.HASENCRYPT" +
  400. " FROM USERRECEIVEINFO t" +
  401. " WHERE 1 = 1"
  402. sqlId.And("t.USERID", r.USERID)
  403. return sqlId.String()
  404. }
  405. // GetDataEx 获取用户收货信息
  406. func (r *UserReceiveInfo) GetDataEx() (interface{}, error) {
  407. sData := make([]UserReceiveInfo, 0)
  408. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  409. for i := range sData {
  410. sData[i].calc()
  411. }
  412. return sData, err
  413. }
  414. // UserCollectConfig 提现账户设置
  415. type UserCollectConfig struct {
  416. COLLECTCONFIGID string `json:"collectconfigid" xorm:"COLLECTCONFIGID"` // 收款账户配置ID(SEQ_USERCOLLECTCONFIG)
  417. USERID int64 `json:"userid" xorm:"USERID"` // 收款人用户ID
  418. COLLECTACCOUNTNO string `json:"collectaccountno" xorm:"COLLECTACCOUNTNO"` // 收款人账户
  419. COLLECTACCOUNTNAME string `json:"collectaccountname" xorm:"COLLECTACCOUNTNAME"` // 收款人账户名称
  420. COLLECTBANKNAME string `json:"collectbankname" xorm:"COLLECTBANKNAME"` // 收款人开户行
  421. COLLECTBRANCHBANKNAME string `json:"collectbranchbankname" xorm:"COLLECTBRANCHBANKNAME"` // 收款人开户支行
  422. REMARK string `json:"remark" xorm:"REMARK"` // 备注
  423. ACCOUNTSTATUS int32 `json:"accountstatus" xorm:"ACCOUNTSTATUS"` // 账户状态 - 1:正常 2:停用 3:注销
  424. }
  425. func (r *UserCollectConfig) calc() {
  426. // 加密后的长度是32的倍数
  427. if len(r.COLLECTACCOUNTNO)%32 == 0 {
  428. r.COLLECTACCOUNTNO = DecryptField(r.COLLECTACCOUNTNO)
  429. }
  430. }
  431. func (r *UserCollectConfig) buildSql() string {
  432. var sqlId utils.SQLVal = "SELECT t.COLLECTCONFIGID," +
  433. " t.USERID," +
  434. " t.COLLECTACCOUNTNO," +
  435. " t.COLLECTACCOUNTNAME," +
  436. " t.COLLECTBANKNAME," +
  437. " t.COLLECTBRANCHBANKNAME," +
  438. " t.REMARK," +
  439. " t.ACCOUNTSTATUS" +
  440. " FROM USERCOLLECTCONFIG t" +
  441. " WHERE 1 = 1"
  442. sqlId.And("t.USERID", r.USERID)
  443. return sqlId.String()
  444. }
  445. // GetDataEx 获取提现账户设置
  446. func (r *UserCollectConfig) GetDataEx() (interface{}, error) {
  447. sData := make([]UserCollectConfig, 0)
  448. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  449. for i := range sData {
  450. sData[i].calc()
  451. }
  452. return sData, err
  453. }
  454. // QhjTradeGoodsPickup 提货单
  455. type QhjTradeGoodsPickup struct {
  456. AUDITSRC int32 `json:"auditsrc" xorm:"AUDITSRC"` // 更新来源 - 1:管理端 2:终端
  457. STOREUSERID int64 `json:"storeuserid" xorm:"STOREUSERID"` // 门店用户ID (千海金)
  458. ARTRADEDATE string `json:"artradedate" xorm:"ARTRADEDATE"` // 自动收货交易日(yyyyMMdd)
  459. EXPRESSCOMPANY string `json:"expresscompany" xorm:"EXPRESSCOMPANY"` // 物流公司
  460. UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
  461. AUDITTRADEDATE string `json:"audittradedate" xorm:"AUDITTRADEDATE"` // 审核交易日(yyyyMMdd)
  462. EXPRESSNUM string `json:"expressnum" xorm:"EXPRESSNUM"` // 物流单号
  463. TAKEORDERID string `json:"takeorderid" xorm:"TAKEORDERID"` // 提货单号(905+Unix秒时间戳(10位)+xxxxxx)
  464. ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 账户ID
  465. GOODSID int64 `json:"goodsid" xorm:"GOODSID"` // 商品ID
  466. USERID int64 `json:"userid" xorm:"USERID"` // 用户ID
  467. QTY float64 `json:"qty" xorm:"QTY"` // 交易商品总手数(交易商品 - 69模式按成交量放大) - 明细表的交易商品手数汇总
  468. REQTIME string `json:"reqtime" xorm:"REQTIME"` // 提货申请时间
  469. RECIVERNAME string `json:"recivername" xorm:"RECIVERNAME"` // 提货人姓名
  470. CARDTYPEID int32 `json:"cardtypeid" xorm:"CARDTYPEID"` // 提货人证件类型
  471. CARDNUM string `json:"cardnum" xorm:"CARDNUM"` // 提货人证件号码
  472. PHONENUM string `json:"phonenum" xorm:"PHONENUM"` // 提货人联系方式
  473. TAKEMODE int32 `json:"takemode" xorm:"TAKEMODE"` // 提货方式 - 2:自提 3:配送(邮寄)
  474. ADDRESS string `json:"address" xorm:"ADDRESS"` // 提货人详细地址
  475. TAKEREMARK string `json:"takeremark" xorm:"TAKEREMARK"` // 提货备注
  476. TAKEORDERSTATUS int32 `json:"takeorderstatus" xorm:"TAKEORDERSTATUS"` // 提货状态 - 1:备货中 2:待取货(自提) 3:已取货(自提) 4:待收货(邮寄) 5:已收货(邮寄) 6:自动收货(邮寄) 7:已拒绝 8:已撤销
  477. AUDITER int32 `json:"auditer" xorm:"AUDITER"` // 审核人
  478. AUDITTIME string `json:"audittime" xorm:"AUDITTIME"` // 审核时间(发货时间 | 备货完成时间 都是这个字段)
  479. CONFIRMTIME string `json:"confirmtime" xorm:"'CONFIRMTIME'"` // 取货时间 或 收货时间
  480. CHECKREMARK string `json:"checkremark" xorm:"CHECKREMARK"` // 审核备注
  481. TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
  482. MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
  483. HANDLESTATUS int32 `json:"handlestatus" xorm:"HANDLESTATUS"` // 处理状态
  484. AMOUNT float64 `json:"amount" xorm:"AMOUNT"` // 提货金额
  485. COUNTRYID int32 `json:"countryid" xorm:"COUNTRYID"` // 国家
  486. PROVINCEID int32 `json:"provinceid" xorm:"PROVINCEID"` // 省
  487. CITYID int32 `json:"cityid" xorm:"CITYID"` // 市
  488. DISTRICTID int32 `json:"districtid" xorm:"DISTRICTID"` // 地区
  489. PICKUPGOODSID string `json:"pickupgoodsid" xorm:"PICKUPGOODSID"` // 提货商品ID
  490. GOODSAGREEUNIT float64 `json:"goodsagreeunit" xorm:"GOODSAGREEUNIT"` // 交易商品乘数
  491. PICKUPGOODSAGREEUNIT float64 `json:"pickupgoodsagreeunit" xorm:"PICKUPGOODSAGREEUNIT"` // 提货商品合约乘数
  492. PICKUPRATIO float64 `json:"pickupratio" xorm:"PICKUPRATIO"` // 提货系数
  493. PICKUPGOODSQTY float64 `json:"pickupgoodsqty" xorm:"PICKUPGOODSQTY"` // 提货商品手数(数量)
  494. GOODSQTY float64 `json:"goodsqty" xorm:"GOODSQTY"` // 交易商品手数(69模式按成交量小数位放大取整)
  495. PREPAREDAYS int32 `json:"preparedays" xorm:"PREPAREDAYS"` // 备货期(天)-提货单明细表
  496. PICKUPGOODSNAME string `json:"pickupgoodsname" xorm:"PICKUPGOODSNAME"` // 提货商品名称
  497. PICKUPGOODSUNITID int32 `json:"pickupgoodsunitid" xorm:"PICKUPGOODSUNITID"` // 单位ID(提货商品)
  498. GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称
  499. GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码
  500. DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
  501. QTYDECIMALPLACE int `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 商品数量小数位
  502. LOGINCODE string `json:"logincode" xorm:"'LOGINCODE'"` // 账号(登录代码, 有可能为空)
  503. USERINFOTYPE int32 `json:"userinfotype" xorm:"'USERINFOTYPE'"` // 客户类型 1-个人 2-企业
  504. MOBILE string `json:"-" xorm:"'MOBILE'"` // 手机号码(userinfo表中的手机号码)
  505. ENUMDICNAME string `json:"enumdicname"` // 单位名称(提货商品)
  506. USERNAME string `json:"username"` // 用户名称
  507. STOREUSERNAME string `json:"storeusername"` // 门店用户名称
  508. COUNTRYNAME string `json:"countryname"` // 国家名称
  509. CITYNAME string `json:"cityname"` // 城市名称
  510. PROVINCENAME string `json:"provincename"` // 省名称
  511. DISTRICTNAME string `json:"districtname"` // 地区名称
  512. }
  513. func (r *QhjTradeGoodsPickup) calc() {
  514. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.PICKUPGOODSUNITID)
  515. r.STOREUSERNAME = mtpcache.GetUserNameByUserId(r.STOREUSERID)
  516. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  517. r.COUNTRYNAME = mtpcache.GetDivisionName(r.COUNTRYID)
  518. r.CITYNAME = mtpcache.GetDivisionName(r.CITYID)
  519. r.PROVINCENAME = mtpcache.GetDivisionName(r.PROVINCEID)
  520. r.DISTRICTNAME = mtpcache.GetDivisionName(r.DISTRICTID)
  521. if len(r.LOGINCODE) == 0 {
  522. // 如果登录代码为空, 取手机号码显示
  523. r.LOGINCODE = DecryptField(r.MOBILE)
  524. }
  525. ZoomByDecimal(r.QTYDECIMALPLACE, &r.GOODSQTY)
  526. ZoomByDecimal(r.QTYDECIMALPLACE, &r.QTY)
  527. }
  528. func (r *QhjTradeGoodsPickup) buildSql() string {
  529. var sqlId utils.SQLVal = "with tmp as (select t.userid, wm_concat(t.logincode) logincode from loginaccount t group by t.userid)" +
  530. "SELECT t.AUDITSRC," +
  531. " t.STOREUSERID," +
  532. " t.ARTRADEDATE," +
  533. " t.EXPRESSCOMPANY," +
  534. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  535. " t.AUDITTRADEDATE," +
  536. " t.EXPRESSNUM," +
  537. " to_char(t.TAKEORDERID) TAKEORDERID," +
  538. " t.ACCOUNTID," +
  539. " t.GOODSID," +
  540. " t.USERID," +
  541. " t.QTY," +
  542. " to_char(t.REQTIME, 'yyyy-mm-dd hh24:mi:ss') REQTIME," +
  543. " t.RECIVERNAME," +
  544. " t.CARDTYPEID," +
  545. " t.CARDNUM," +
  546. " t.PHONENUM," +
  547. " t.TAKEMODE," +
  548. " decode(t.takemode, 3, t.address, u.address) address," +
  549. " t.TAKEREMARK," +
  550. " t.TAKEORDERSTATUS," +
  551. " t.AUDITER," +
  552. " to_char(t.AUDITTIME, 'yyyy-mm-dd hh24:mi:ss') AUDITTIME," +
  553. " to_char(t.CONFIRMTIME, 'yyyy-mm-dd hh24:mi:ss') CONFIRMTIME," +
  554. " t.CHECKREMARK," +
  555. " t.TRADEDATE," +
  556. " t.MARKETID," +
  557. " t.HANDLESTATUS," +
  558. " t.AMOUNT," +
  559. " decode(t.takemode, 3, t.COUNTRYID, u.countryid) COUNTRYID," +
  560. " decode(t.takemode, 3, t.PROVINCEID, u.provinceid) PROVINCEID," +
  561. " decode(t.takemode, 3, t.CITYID, u.cityid) CITYID," +
  562. " decode(t.takemode, 3, t.DISTRICTID, u.districtid) DISTRICTID," +
  563. " k.PICKUPGOODSID," +
  564. " k.GOODSAGREEUNIT," +
  565. " k.PICKUPGOODSAGREEUNIT," +
  566. " k.PICKUPRATIO," +
  567. " k.PICKUPGOODSQTY," +
  568. " k.GOODSQTY," +
  569. " k.PREPAREDAYS," +
  570. " g.PICKUPGOODSNAME," +
  571. " g.PICKUPGOODSUNITID," +
  572. " g2.goodsname," +
  573. " g2.decimalplace," +
  574. " g2.qtydecimalplace," +
  575. " g2.goodscode," +
  576. " u.userinfotype," +
  577. " u.mobile," +
  578. " tmp.logincode" +
  579. " FROM TRADE_GOODSPICKUP t" +
  580. " LEFT JOIN TRADE_GOODSPICKUPDETAIL k" +
  581. " on t.takeorderid = k.takeorderid" +
  582. " LEFT JOIN PICKUPGOODS g" +
  583. " on k.pickupgoodsid = g.pickupgoodsid" +
  584. " LEFT JOIN GOODS g2" +
  585. " on t.goodsid = g2.goodsid" +
  586. " LEFT JOIN USERINFO u" +
  587. " on t.storeuserid = u.userid" +
  588. " LEFT JOIN tmp on t.userid=tmp.userid" +
  589. " WHERE 1 = 1"
  590. // 获取角色=20组织的角色数据, 判断机构类型
  591. m := QhjAreaRole{USERID: r.USERID, ROLETYPE: 20}
  592. d, _ := m.GetData()
  593. if len(d) > 0 {
  594. v := d[0]
  595. if v.SUBORGTYPE == 0 {
  596. // 机构(企业) 查所有, 即不过淲userid
  597. } else if v.SUBORGTYPE == 2 {
  598. // 门店查询
  599. sqlId.And("t.storeuserid", r.USERID)
  600. } else {
  601. sqlId.And("t.USERID", r.USERID)
  602. }
  603. } else {
  604. sqlId.And("t.USERID", r.USERID)
  605. }
  606. sqlId.AndEx("t.TAKEORDERSTATUS", r.TAKEORDERSTATUS, r.TAKEORDERSTATUS > 0)
  607. return sqlId.String()
  608. }
  609. // GetDataEx 获取提货单
  610. func (r *QhjTradeGoodsPickup) GetDataEx() (interface{}, error) {
  611. sData := make([]QhjTradeGoodsPickup, 0)
  612. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  613. for i := range sData {
  614. sData[i].calc()
  615. }
  616. return sData, err
  617. }
  618. // QhjPickGoods 提货商品
  619. type QhjPickGoods struct {
  620. PICKUPGOODSID string `json:"pickupgoodsid" xorm:"PICKUPGOODSID"` // 提货商品ID
  621. PICKUPGOODSNAME string `json:"pickupgoodsname" xorm:"PICKUPGOODSNAME"` // 提货商品名称
  622. PICKUPGOODSUNITID int32 `json:"pickupgoodsunitid" xorm:"PICKUPGOODSUNITID"` // 单位ID
  623. PICKUPGOODSAGREEUNIT float64 `json:"pickupgoodsagreeunit" xorm:"PICKUPGOODSAGREEUNIT"` // 合约乘数
  624. PICKUPGOODSDESC string `json:"pickupgoodsdesc" xorm:"PICKUPGOODSDESC"` // 描述
  625. IMAGEADDRESS string `json:"imageaddress" xorm:"IMAGEADDRESS"` // 图片
  626. REMARK string `json:"remark" xorm:"REMARK"` // 备注
  627. MODIFYSRC int32 `json:"modifysrc" xorm:"MODIFYSRC"` // 修改来源 - 1:管理端 2:终端
  628. MODIFIERID int64 `json:"modifierid" xorm:"MODIFIERID"` // 修改人
  629. UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
  630. PREPAREDAYS int32 `json:"preparedays" xorm:"PREPAREDAYS"` // 备货期(天)
  631. PICKUPGOODSSTATUS int32 `json:"pickupgoodsstatus" xorm:"PICKUPGOODSSTATUS"` // 状态 - 1:正常 2:停用 3:注销
  632. GOODSID int32 `json:"goodsid" xorm:"'GOODSID'"` // 商品id
  633. PICKUPRATIO float64 `json:"pickupratio" xorm:"'PICKUPRATIO'"` // 提货系数
  634. MODIFIERNAME string `json:"modifiername"` // 修改人名称
  635. FilterStatus string `json:"-"` // 状态过淲
  636. ENUMDICNAME string `json:"enumdicname"` // 单位名称(提货商品)
  637. }
  638. func (r *QhjPickGoods) calc() {
  639. if r.MODIFYSRC == 1 {
  640. r.MODIFIERNAME = mtpcache.GetSystemmangerLoginCode(r.MODIFIERID)
  641. } else {
  642. r.MODIFIERNAME = mtpcache.GetLoginCodeByLoginId(r.MODIFIERID)
  643. }
  644. if r.MODIFIERNAME == "" {
  645. r.MODIFIERNAME = mtpcache.GetUserNameByUserId(r.MODIFIERID)
  646. }
  647. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.PICKUPGOODSUNITID)
  648. }
  649. func (r *QhjPickGoods) buildSql() string {
  650. var sqlId utils.SQLVal = "SELECT t.PICKUPGOODSID," +
  651. " t.PICKUPGOODSNAME," +
  652. " t.PICKUPGOODSUNITID," +
  653. " t.PICKUPGOODSAGREEUNIT," +
  654. " to_char(t.PICKUPGOODSDESC) PICKUPGOODSDESC," +
  655. " to_char(t.IMAGEADDRESS) IMAGEADDRESS," +
  656. " t.REMARK," +
  657. " t.MODIFYSRC," +
  658. " t.MODIFIERID," +
  659. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  660. " t.PREPAREDAYS," +
  661. " t.PICKUPGOODSSTATUS," +
  662. " c.goodsid," +
  663. " c.pickupratio" +
  664. " FROM PICKUPGOODS t" +
  665. " INNER JOIN GOODSPICKUPCONFIG c on t.pickupgoodsid=c.pickupgoodsid" +
  666. " WHERE 1 = 1"
  667. sqlId.AndEx("c.goodsid", r.GOODSID, r.GOODSID > 0)
  668. if len(r.FilterStatus) > 0 {
  669. sqlId.Join(fmt.Sprintf(" and t.PICKUPGOODSSTATUS in(%v)", r.FilterStatus))
  670. }
  671. return sqlId.String()
  672. }
  673. // GetDataEx 获取提货商品
  674. func (r *QhjPickGoods) GetDataEx() (interface{}, error) {
  675. sData := make([]QhjPickGoods, 0)
  676. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  677. for i := range sData {
  678. sData[i].calc()
  679. }
  680. return sData, err
  681. }
  682. // QhjPickArea 提货门店
  683. type QhjPickArea struct {
  684. ISRETURNSCORE int32 `json:"-" xorm:"ISRETURNSCORE"` // 是否返还积分 [经纪会员-辽东湾] - 0:不返还 1:返还
  685. ORGTYPE int32 `json:"-" xorm:"ORGTYPE"` // 组织机构类型 1:机构\分支节点 2:交易员\叶子节点 3:部门\分支节点
  686. ROLETYPE int32 `json:"-" xorm:"ROLETYPE"` // 角色类型
  687. SUBORGTYPE int32 `json:"suborgtype" xorm:"SUBORGTYPE"` // 子机构类型(千海金) - 0:机构 1:代理 2:门店
  688. CREATORID int64 `json:"-" xorm:"CREATORID"` // 创建人ID
  689. FROMUSERID int64 `json:"fromuserid" xorm:"FROMUSERID"` // 所属机构(组织机构)( OrgType = 1时为自己, = 2\3时取上级机构的所属机构)
  690. MODIFIERID int64 `json:"-" xorm:"MODIFIERID"` // 修改人ID
  691. PARENTUSERID int64 `json:"-" xorm:"PARENTUSERID"` // 上级组织机构(组织机构)
  692. ROOTUSERID int64 `json:"-" xorm:"ROOTUSERID"` // 顶级组织机构用户ID(组织机构)
  693. TRADEACCOUNTID int64 `json:"-" xorm:"TRADEACCOUNTID"` // 默认交易资金账号ID(做市会员被动接单使用、商城店铺默认资金账 号、圈内会员默认资金账号) - 作废, 使用UserReckonAccount
  694. USERID int64 `json:"userid" xorm:"USERID"` // 机构用户ID 其他做市关系,都设置为 1
  695. CREATETIME string `json:"-" xorm:"CREATETIME"` // 创建时间
  696. MODIFYTIME string `json:"-" xorm:"MODIFYTIME"` // 修改时间
  697. OUTUSERID string `json:"-" xorm:"OUTUSERID"` // 外部账户[场外期权做市商]
  698. SHOPPASSWORD string `json:"-" xorm:"SHOPPASSWORD"` // 商城店铺登陆密码(商城店铺角色使用)
  699. SUBLEVELPATH string `json:"-" xorm:"SUBLEVELPATH"` // 组织机构层级路径(逗号分隔,首尾加逗号)
  700. TRANSURL string `json:"-" xorm:"TRANSURL"` // 物流地址(物流机构)
  701. COUNTRYID int32 `json:"countryid" xorm:"COUNTRYID"` // 国家
  702. PROVINCEID int32 `json:"provinceid" xorm:"PROVINCEID"` // 省
  703. CITYID int32 `json:"cityid" xorm:"CITYID"` // 市
  704. DISTRICTID int32 `json:"districtid" xorm:"DISTRICTID"` // 地区
  705. ADDRESS string `json:"address" xorm:"'ADDRESS'"` // 详细地址
  706. USERNAME string `json:"username"` // 机构用户名称(门店门称)
  707. FROMUSERNAME string `json:"fromusername"` // 所属机构名称
  708. COUNTRYNAME string `json:"countryname"` // 国家名称
  709. CITYNAME string `json:"cityname"` // 城市名称
  710. PROVINCENAME string `json:"provincename"` // 省名称
  711. DISTRICTNAME string `json:"districtname"` // 地区名称
  712. }
  713. func (r *QhjPickArea) calc() {
  714. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  715. r.FROMUSERNAME = mtpcache.GetUserNameByUserId(r.FROMUSERID)
  716. r.COUNTRYNAME = mtpcache.GetDivisionName(r.COUNTRYID)
  717. r.CITYNAME = mtpcache.GetDivisionName(r.CITYID)
  718. r.PROVINCENAME = mtpcache.GetDivisionName(r.PROVINCEID)
  719. r.DISTRICTNAME = mtpcache.GetDivisionName(r.DISTRICTID)
  720. }
  721. func (r *QhjPickArea) buildSql() string {
  722. var sqlId utils.SQLVal = "SELECT distinct t.FROMUSERID," +
  723. " t.SUBORGTYPE," +
  724. " t.USERID," +
  725. " t.ROLETYPE," +
  726. " t.TRADEACCOUNTID," +
  727. " to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
  728. " t.CREATORID," +
  729. " to_char(t.MODIFYTIME, 'yyyy-mm-dd hh24:mi:ss') MODIFYTIME," +
  730. " t.MODIFIERID," +
  731. " t.SHOPPASSWORD," +
  732. " t.ISRETURNSCORE," +
  733. " t.TRANSURL," +
  734. " t.OUTUSERID," +
  735. " t.PARENTUSERID," +
  736. " t.ROOTUSERID," +
  737. " t.SUBLEVELPATH," +
  738. " t.ORGTYPE," +
  739. " u.countryid," +
  740. " u.provinceid," +
  741. " u.cityid," +
  742. " u.districtid," +
  743. " u.address" +
  744. " FROM AREAROLE t" +
  745. " LEFT JOIN USERINFO u on t.userid=u.userid" +
  746. " WHERE 1 = 1"
  747. sqlId.And("t.SUBORGTYPE", 2)
  748. sqlId.And("t.roletype", 99)
  749. return sqlId.String()
  750. }
  751. // GetDataEx 获取机构角色
  752. func (r *QhjPickArea) GetDataEx() (interface{}, error) {
  753. sData := make([]QhjPickArea, 0)
  754. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  755. for i := range sData {
  756. sData[i].calc()
  757. }
  758. return sData, err
  759. }
  760. // QhjBankAccountSign 签约银行
  761. type QhjBankAccountSign struct {
  762. ACCOUNTTYPE int32 `json:"accounttype" xorm:"ACCOUNTTYPE"` // 账户类型(UserType)
  763. BANKACCOUNTTYPE int32 `json:"bankaccounttype" xorm:"BANKACCOUNTTYPE"` // 银行账户类型 - 1-对私; 2-对公
  764. BANKCARDTYPE int32 `json:"bankcardtype" xorm:"BANKCARDTYPE"` // 银行卡类型
  765. DIRECT int32 `json:"direct" xorm:"DIRECT"` // 方向(可以判断那方先发起的签约)
  766. SIGNSTATUS int32 `json:"signstatus" xorm:"SIGNSTATUS"` // 签约状态 - 1:未签约 2:签约待审核 3:签约中 4:已签约 5:解约待审核 6:解约中 7:已解约 8:已解绑 9:绑卡中 10:审核拒绝 11:换签待审核
  767. AUDITID int64 `json:"auditid" xorm:"AUDITID"` // 审核人
  768. ACCOUNTCODE string `json:"accountcode" xorm:"ACCOUNTCODE"` // 资金账号
  769. ACCOUNTNAME string `json:"accountname" xorm:"ACCOUNTNAME"` // 资金账号对应的账号名(UserName)
  770. APPLICATIONTIME string `json:"applicationtime" xorm:"APPLICATIONTIME"` // 最后一次更新的时间
  771. APPLYEXCHTICKET string `json:"applyexchticket" xorm:"APPLYEXCHTICKET"` // 申请流水
  772. AUDITTIME string `json:"audittime" xorm:"AUDITTIME"` // 审核时间
  773. BANKACCOUNTNAME string `json:"bankaccountname" xorm:"BANKACCOUNTNAME"` // 签约银行卡账号名
  774. BANKACCOUNTNO string `json:"bankaccountno" xorm:"BANKACCOUNTNO"` // 银行卡号
  775. BANKCHILDACCOUNT string `json:"bankchildaccount" xorm:"BANKCHILDACCOUNT"` // 银行子账号(签约成功后,很多银行会返回对应的这个虚拟账号)
  776. BANKCITY string `json:"bankcity" xorm:"BANKCITY"` // 开户行城市
  777. BANKID string `json:"bankid" xorm:"BANKID"` // 签约银行ID
  778. BANKPROVINCE string `json:"bankprovince" xorm:"BANKPROVINCE"` // 开户行省份
  779. BRANCHBANKID string `json:"branchbankid" xorm:"BRANCHBANKID"` // 签约银行支行号
  780. BRANCHBANKNAME string `json:"branchbankname" xorm:"BRANCHBANKNAME"` // 签约银行支行名称
  781. CARDNO string `json:"cardno" xorm:"CARDNO"` // 证件号码
  782. CARDTYPE string `json:"cardtype" xorm:"CARDTYPE"` // 证件类型
  783. CURRENCY string `json:"currency" xorm:"CURRENCY"` // 币种
  784. CUSBANKID string `json:"cusbankid" xorm:"CUSBANKID"` // 托管银行编号
  785. EXCHTICKET string `json:"exchticket" xorm:"EXCHTICKET"` // 最后一次签约成功的流水号
  786. EXTENDINFO string `json:"extendinfo" xorm:"EXTENDINFO"` // 扩展信息(JSON字符串)
  787. MOBILEPHONE string `json:"mobilephone" xorm:"MOBILEPHONE"` // 手机号
  788. NETADDR string `json:"netaddr" xorm:"NETADDR"` // 调转网址
  789. UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间(签解约更新时间)
  790. RELATEDUSERID int64 `json:"relateduserid" xorm:"'RELATEDUSERID'"` // 关联使用者userid
  791. BANKNAME string `json:"bankname" xorm:"'BANKNAME'"` // 签约银行名称
  792. ACCOUNTNAME2 string `json:"accountname2"` // 资金账号对应的账号名(UserName) - 密文
  793. BANKACCOUNTNAME2 string `json:"bankaccountname2"` // 签约银行卡账号名 - 密文
  794. CARDNO2 string `json:"cardno2"` // 证件号码 - 密文
  795. BANKACCOUNTNO2 string `json:"bankaccountno2"` // 银行卡号 - 密文
  796. MOBILEPHONE2 string `json:"mobilephone2"` // 手机号 - 密文
  797. }
  798. func (r *QhjBankAccountSign) calc() {
  799. r.ACCOUNTNAME2 = r.ACCOUNTNAME
  800. r.BANKACCOUNTNAME2 = r.BANKACCOUNTNAME
  801. r.CARDNO2 = r.CARDNO
  802. r.BANKACCOUNTNO2 = r.BANKACCOUNTNO
  803. r.MOBILEPHONE2 = r.MOBILEPHONE
  804. r.ACCOUNTNAME = DecryptField(r.ACCOUNTNAME)
  805. r.BANKACCOUNTNAME = DecryptField(r.BANKACCOUNTNAME)
  806. r.CARDNO = DecryptField(r.CARDNO)
  807. r.BANKACCOUNTNO = DecryptField(r.BANKACCOUNTNO)
  808. r.MOBILEPHONE = DecryptField(r.MOBILEPHONE)
  809. }
  810. func (r *QhjBankAccountSign) buildSql() string {
  811. var sqlId utils.SQLVal = "SELECT t.ACCOUNTCODE," +
  812. " t.CUSBANKID," +
  813. " t.SIGNSTATUS," +
  814. " t.CURRENCY," +
  815. " t.ACCOUNTTYPE," +
  816. " t.ACCOUNTNAME," +
  817. " t.BANKCARDTYPE," +
  818. " t.BANKACCOUNTNO," +
  819. " t.BANKACCOUNTTYPE," +
  820. " t.BANKCHILDACCOUNT," +
  821. " t.BANKID," +
  822. " t.BRANCHBANKID," +
  823. " t.BRANCHBANKNAME," +
  824. " t.BANKACCOUNTNAME," +
  825. " t.CARDTYPE," +
  826. " t.CARDNO," +
  827. " t.BANKPROVINCE," +
  828. " t.BANKCITY," +
  829. " t.DIRECT," +
  830. " t.MOBILEPHONE," +
  831. " t.EXTENDINFO," +
  832. " t.EXCHTICKET," +
  833. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  834. " to_char(t.APPLICATIONTIME, 'yyyy-mm-dd hh24:mi:ss') APPLICATIONTIME," +
  835. " t.NETADDR," +
  836. " t.AUDITID," +
  837. " to_char(t.AUDITTIME, 'yyyy-mm-dd hh24:mi:ss') AUDITTIME," +
  838. " t.APPLYEXCHTICKET," +
  839. " ta.accountid," +
  840. " ta.relateduserid," +
  841. " b.bankname" +
  842. " FROM BANK_ACCOUNTSIGN t" +
  843. " INNER JOIN TAACCOUNT ta" +
  844. " on t.accountcode = to_char(ta.accountid)" +
  845. " LEFT JOIN BANK_BANKINFO b on t.bankid=b.bankid" +
  846. " WHERE 1 = 1" +
  847. " and ta.taaccounttype = 2"
  848. sqlId.And("ta.RELATEDUSERID", r.RELATEDUSERID)
  849. return sqlId.String()
  850. }
  851. // GetDataEx 获取签约银行
  852. func (r *QhjBankAccountSign) GetDataEx() (interface{}, error) {
  853. sData := make([]QhjBankAccountSign, 0)
  854. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  855. for i := range sData {
  856. sData[i].calc()
  857. }
  858. return sData, err
  859. }
  860. // QhjBankInfo 银行信息列表
  861. type QhjBankInfo struct {
  862. STATUS int32 `json:"status" xorm:"STATUS"` // 状态 - 0:正常 1:注销
  863. ORDERINDEX int64 `json:"orderindex" xorm:"ORDERINDEX"` // 排序顺序
  864. BANKID string `json:"bankid" xorm:"BANKID"` // 银行ID
  865. BANKNAME string `json:"bankname" xorm:"BANKNAME"` // 银行名称
  866. CLEARBANKNO string `json:"clearbankno" xorm:"CLEARBANKNO"` // 清算系统银行编号
  867. }
  868. func (r *QhjBankInfo) calc() {
  869. }
  870. func (r *QhjBankInfo) buildSql() string {
  871. var sqlId utils.SQLVal = "SELECT t.BANKID,t.BANKNAME,t.CLEARBANKNO,t.STATUS,t.ORDERINDEX FROM BANK_BANKINFO t WHERE 1=1 and t.status=0"
  872. return sqlId.String()
  873. }
  874. // GetData 获取银行信息列表
  875. func (r *QhjBankInfo) GetData() ([]QhjBankInfo, error) {
  876. sData := make([]QhjBankInfo, 0)
  877. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  878. for i := range sData {
  879. sData[i].calc()
  880. }
  881. return sData, err
  882. }
  883. // GetDataEx 获取银行信息列表
  884. func (r *QhjBankInfo) GetDataEx() (interface{}, error) {
  885. return r.GetData()
  886. }
  887. // QhjReckonPriceLog 结算价(定投价)
  888. type QhjReckonPriceLog struct {
  889. LASTRECKONPRICE float64 `json:"lastreckonprice" xorm:"LASTRECKONPRICE"` // 上日结算价
  890. NEXTDNLIMITPRICE float64 `json:"nextdnlimitprice" xorm:"NEXTDNLIMITPRICE"` // 下个交易日跌停价
  891. NEXTUPLIMITPRICE float64 `json:"nextuplimitprice" xorm:"NEXTUPLIMITPRICE"` // 下个交易日涨停价
  892. RECKONPRICE float64 `json:"reckonprice" xorm:"RECKONPRICE"` // 今日结算价(定投价)
  893. UPDOWNRATE float64 `json:"updownrate" xorm:"UPDOWNRATE"` // 今日涨跌幅
  894. UPDOWNRATE_2D float64 `json:"updownrate_2d" xorm:"UPDOWNRATE_2D"` // 连续两日涨跌幅
  895. UPDOWNRATE_3D float64 `json:"updownrate_3d" xorm:"UPDOWNRATE_3D"` // 连续三日涨跌幅
  896. TOTALHOLDERQTY int32 `json:"totalholderqty" xorm:"TOTALHOLDERQTY"` // 总持仓数
  897. TOTALSTOCK int32 `json:"totalstock" xorm:"TOTALSTOCK"` // 总库存
  898. UPDOWNCOUNT int32 `json:"updowncount" xorm:"UPDOWNCOUNT"` // 连续涨(跌)停天数 (涨跌停标志变为0时值归0,变成涨停或是跌停时值为1,连续涨停天数+1,连续跌停天数+1)
  899. UPDOWNFLAG int32 `json:"updownflag" xorm:"UPDOWNFLAG"` // 连续涨跌停标志 - 0:无涨跌停 -1:跌停 1:涨停
  900. GOODSID int64 `json:"goodsid" xorm:"GOODSID" form:"goodsid"` // 商品ID
  901. NEXTTRADE string `json:"nexttrade" xorm:"NEXTTRADE"` // 下个交易日
  902. RECKONTIME string `json:"reckontime" xorm:"RECKONTIME"` // 结算时间
  903. TRADEDATE string `json:"tradedate" xorm:"TRADEDATE" form:"tradedate"` // 交易日
  904. GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称
  905. GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码
  906. DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
  907. }
  908. func (r *QhjReckonPriceLog) calc() {
  909. }
  910. func (r *QhjReckonPriceLog) buildSql() string {
  911. var sqlId utils.SQLVal = "SELECT t.TRADEDATE," +
  912. " t.GOODSID," +
  913. " to_char(t.RECKONTIME, 'yyyy-mm-dd hh24:mi:ss') RECKONTIME," +
  914. " t.LASTRECKONPRICE," +
  915. " t.RECKONPRICE," +
  916. " t.UPDOWNRATE," +
  917. " t.UPDOWNFLAG," +
  918. " t.UPDOWNCOUNT," +
  919. " t.UPDOWNRATE_2D," +
  920. " t.UPDOWNRATE_3D," +
  921. " t.NEXTTRADE," +
  922. " t.NEXTUPLIMITPRICE," +
  923. " t.NEXTDNLIMITPRICE," +
  924. " t.TOTALHOLDERQTY," +
  925. " t.TOTALSTOCK," +
  926. " g.goodsname," +
  927. " g.decimalplace," +
  928. " g.goodscode" +
  929. " FROM RECKON_PRICELOG t" +
  930. " LEFT JOIN GOODS g on t.goodsid=g.goodsid" +
  931. " INNER JOIN MARKET m on g.marketid=g.marketid" +
  932. " WHERE 1 = 1 and m.marketid=69201"
  933. sqlId.AndEx("t.TRADEDATE", r.TRADEDATE, len(r.TRADEDATE) > 0)
  934. sqlId.AndEx("t.GOODSID", r.GOODSID, r.GOODSID > 0)
  935. return sqlId.String()
  936. }
  937. // GetDataEx 获取结算价(定投价)
  938. func (r *QhjReckonPriceLog) GetDataEx() (interface{}, error) {
  939. sData := make([]QhjReckonPriceLog, 0)
  940. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  941. for i := range sData {
  942. sData[i].calc()
  943. }
  944. return sData, err
  945. }
  946. // QhjCustomer 客户资料
  947. type QhjCustomer struct {
  948. USERID int64 `json:"userid" xorm:"'USERID'"` // 用户ID
  949. MEMBERUSERID int64 `json:"memberuserid" xorm:"'MEMBERUSERID'"` // 所属机构ID(所属会员)
  950. PARENTUSERID int64 `json:"parentuserid" xorm:"'PARENTUSERID'"` // 上级机构(所属机构)
  951. USERINFOTYPE int32 `json:"userinfotype" xorm:"'USERINFOTYPE'"` // 客户类型 1-个人 2-企业
  952. CUSTOMERNAME string `json:"customername" xorm:"'CUSTOMERNAME'"` // 客户名称
  953. CARDTYPE int32 `json:"cardtype" xorm:"'CARDTYPE'"` // 证件类型
  954. CARDNUM string `json:"cardnum" xorm:"'CARDNUM'"` // 证件号码
  955. MOBILE string `json:"mobile" xorm:"'MOBILE'"` // 手机号码
  956. TELPHONE string `json:"telphone" xorm:"'TELPHONE'"` // 联系电话
  957. ADDRESS string `json:"address" xorm:"'ADDRESS'"` // 通讯地址
  958. REMARK string `json:"remark" xorm:"'REMARK'"` // 备注
  959. STATUS int32 `json:"status" xorm:"'STATUS'"` // 账户状态 - 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:注销
  960. STATUSDESC string `json:"statusdesc"` // 账户状态中文描述
  961. ATTACHMENT1 string `json:"attachment1" xorm:"'ATTACHMENT1'"` // 附件1
  962. CARDFRONTPHOTOURL string `json:"cardfrontphotourl" xorm:"'CARDFRONTPHOTOURL'"` // 证件正面图片地址
  963. CARDBACKPHOTOURL string `json:"cardbackphotourl" xorm:"'CARDBACKPHOTOURL'"` // 证件反面图片地址
  964. COUNTRYID int32 `json:"countryid" xorm:"'COUNTRYID'"` // 国家
  965. PROVINCEID int32 `json:"provinceid" xorm:"'PROVINCEID'"` // 省
  966. CITYID int32 `json:"cityid" xorm:"'CITYID'"` // 市
  967. DISTRICTID int32 `json:"districtid" xorm:"'DISTRICTID'"` // 区域
  968. CREATETIME string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  969. MODIFYTIME string `json:"modifytime" xorm:"'MODIFYTIME'"` // 修改时间
  970. AUDITTIME string `json:"audittime" xorm:"'AUDITTIME'"` // 审核时间
  971. NICKNAME string `json:"nickname" xorm:"'NICKNAME'"` // 昵称
  972. TAXPAYERNUM string `json:"taxpayernum" xorm:"'taxpayernum'"` // 纳税人识别号
  973. LEGALPERSONNAME string `json:"legalpersonname" xorm:"'legalpersonname'"` // 法人姓名(企业)
  974. CONTACTNAME string `json:"contactname" xorm:"'contactname'"` // 联系人
  975. EMAIL string `json:"email" xorm:"'EMAIL'"` // 邮件
  976. USERNAME string `json:"username" xorm:"'USERNAME'"` // 用户名称
  977. LOGINCODE string `json:"logincode" xorm:"'LOGINCODE'"` // 登录账号(代码)
  978. COUNTRYNAME string `json:"countryname"` // 国家名称
  979. CITYNAME string `json:"cityname"` // 城市名称
  980. PROVINCENAME string `json:"provincename"` // 省名称
  981. DISTRICTNAME string `json:"districtname"` // 地区名称
  982. CARDTYPENAME string `json:"cardtypename"` // 证件类型名称
  983. MEMBERUSERNAME string `json:"memberusername"` // 所属会员名称
  984. PARENTUSERNAME string `json:"parentusername"` //所属机构名称
  985. QUERYTYPE int32 `json:"-"` // 查询类型(1:未提交(网上开户表) 2:待审核(网上开户表) 3:正常 4:停用)
  986. IncludeSub int32 `json:"-"` // 包子机构客户 1-包含
  987. }
  988. func (r *QhjCustomer) calc() {
  989. r.MEMBERUSERNAME = mtpcache.GetUserNameByUserId(r.MEMBERUSERID)
  990. if len(r.USERNAME) == 0 {
  991. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  992. }
  993. r.PARENTUSERNAME = mtpcache.GetUserNameByUserId(r.PARENTUSERID)
  994. r.COUNTRYNAME = mtpcache.GetDivisionName(r.COUNTRYID)
  995. r.CITYNAME = mtpcache.GetDivisionName(r.CITYID)
  996. r.PROVINCENAME = mtpcache.GetDivisionName(r.PROVINCEID)
  997. r.DISTRICTNAME = mtpcache.GetDivisionName(r.DISTRICTID)
  998. switch r.QUERYTYPE {
  999. case 1, 2: // 网上开户表
  1000. r.ADDRESS = DecryptField(r.ADDRESS)
  1001. r.TELPHONE = DecryptField(r.TELPHONE)
  1002. case 3, 4: // 正式表
  1003. r.TELPHONE = DecryptField(r.TELPHONE)
  1004. }
  1005. r.CARDNUM = DecryptField(r.CARDNUM)
  1006. r.MOBILE = DecryptField(r.MOBILE)
  1007. r.EMAIL = DecryptField(r.EMAIL)
  1008. if len(r.LOGINCODE) == 0 {
  1009. r.LOGINCODE = r.MOBILE
  1010. }
  1011. }
  1012. func (r *QhjCustomer) level() int32 {
  1013. if r.IncludeSub > 0 {
  1014. // 层级, 最多20层
  1015. return 20
  1016. }
  1017. return 1
  1018. }
  1019. func (r *QhjCustomer) buildSql() string {
  1020. if r.QUERYTYPE == 1 || r.QUERYTYPE == 2 {
  1021. return r.buildSqlWskh()
  1022. }
  1023. return r.buildSqlNormal()
  1024. }
  1025. func (r *QhjCustomer) buildSqlWskh() string {
  1026. var sqlId utils.SQLVal = "with tmp as" +
  1027. " (select t.userid, wm_concat(t.logincode) logincode" +
  1028. " from loginaccount t" +
  1029. " group by t.userid)" +
  1030. "select a.*" +
  1031. " from (select t.userid," +
  1032. " t.memberareaid MEMBERUSERID," +
  1033. " t.USERINFOTYPE," +
  1034. " t.username," +
  1035. " t.CUSTOMERNAME," +
  1036. " t.NICKNAME," +
  1037. " t.CARDTYPE," +
  1038. " t.CARDNUM," +
  1039. " t.mobilephone MOBILE," +
  1040. " t.TELPHONE," +
  1041. " t.cardaddress ADDRESS," +
  1042. " t.REMARK," +
  1043. " t.ATTACHMENT1," +
  1044. " t.CARDFRONTPHOTOURL," +
  1045. " t.CARDBACKPHOTOURL," +
  1046. " t.userstate status," +
  1047. " t.countryid," +
  1048. " t.provinceid," +
  1049. " t.districtid," +
  1050. " to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
  1051. " t.cityid," +
  1052. " to_char(t.modifiedtime, 'yyyy-mm-dd hh24:mi:ss') modifytime," +
  1053. " to_char(t.auditime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
  1054. " t.taxpayernum," +
  1055. " t.legalpersonname," +
  1056. " t.contactname," +
  1057. " t.email," +
  1058. " t.areaid parentuserid," +
  1059. " t.logincode" +
  1060. " from wskh_userinfo t" +
  1061. " start with t.areaid = %v" +
  1062. " connect by prior t.userid = t.areaid" +
  1063. " and t.usertype in(2,6)" +
  1064. " and level <= %v) a" +
  1065. " left join tmp k" +
  1066. " on a.userid = k.userid" +
  1067. " where 1 = 1 and a.status in(%v)"
  1068. status := DecodeStr(r.QUERYTYPE == 1, "1", "2,4,5")
  1069. sqlId.FormatParam(r.USERID, r.level(), status)
  1070. sqlId.AndEx("a.USERINFOTYPE", r.USERINFOTYPE, r.USERINFOTYPE > 0)
  1071. sqlId.JoinEx(len(r.CUSTOMERNAME) > 0, fmt.Sprintf(` and a.customername like '%%%v%%'`, r.CUSTOMERNAME))
  1072. sqlId.JoinEx(len(r.NICKNAME) > 0, fmt.Sprintf(` and a.nickname like '%%%v%%'`, r.NICKNAME))
  1073. return sqlId.String()
  1074. }
  1075. func (r *QhjCustomer) buildSqlNormal() string {
  1076. var sqlId utils.SQLVal = "with tmp as" +
  1077. " (select t.userid, wm_concat(t.logincode) logincode" +
  1078. " from loginaccount t" +
  1079. " group by t.userid)" +
  1080. "select a.*," +
  1081. " k.logincode," +
  1082. " u.USERINFOTYPE," +
  1083. " u.CUSTOMERNAME," +
  1084. " u.NICKNAME," +
  1085. " u.CARDTYPEID CARDTYPE," +
  1086. " u.CARDNUM," +
  1087. " u.MOBILE," +
  1088. " u.TELPHONE," +
  1089. " u.ADDRESS," +
  1090. " u.REMARK," +
  1091. " u.ATTACHMENT1," +
  1092. " u.CARDFRONTPHOTOURL," +
  1093. " u.CARDBACKPHOTOURL," +
  1094. " u.countryid," +
  1095. " u.provinceid," +
  1096. " u.districtid," +
  1097. " u.taxpayernum," +
  1098. " u.legalpersonname," +
  1099. " u.contactname," +
  1100. " u.email," +
  1101. " u.cityid" +
  1102. " from (select t.userid," +
  1103. " t.usertype," +
  1104. " t.parentuserid," +
  1105. " t.memberuserid," +
  1106. " t.accountstatus status," +
  1107. " to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
  1108. " to_char(t.modifytime, 'yyyy-mm-dd hh24:mi:ss') modifytime," +
  1109. " to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime" +
  1110. " from useraccount t" +
  1111. " start with t.usertype=6 and t.parentuserid = %v" +
  1112. " connect by prior t.userid = t.parentuserid" +
  1113. " and t.usertype = 6" +
  1114. " and level <= %v) a" +
  1115. " left join tmp k" +
  1116. " on a.userid = k.userid" +
  1117. " left join userinfo u" +
  1118. " on a.userid = u.userid" +
  1119. " where 1=1 and a.status in(%v)"
  1120. status := DecodeStr(r.QUERYTYPE == 3, "4", "6")
  1121. sqlId.FormatParam(r.USERID, r.level(), status)
  1122. sqlId.AndEx("u.USERINFOTYPE", r.USERINFOTYPE, r.USERINFOTYPE > 0)
  1123. sqlId.JoinEx(len(r.CUSTOMERNAME) > 0, fmt.Sprintf(` and u.customername like '%%%v%%'`, r.CUSTOMERNAME))
  1124. sqlId.JoinEx(len(r.NICKNAME) > 0, fmt.Sprintf(` and u.nickname like '%%%v%%'`, r.NICKNAME))
  1125. return sqlId.String()
  1126. }
  1127. // GetDataEx 获取客户资料
  1128. func (r *QhjCustomer) GetDataEx() (interface{}, error) {
  1129. sData := make([]QhjCustomer, 0)
  1130. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1131. for i := range sData {
  1132. sData[i].QUERYTYPE = r.QUERYTYPE
  1133. sData[i].calc()
  1134. }
  1135. return sData, err
  1136. }
  1137. // QhjCusBankInfo 托管银行信息
  1138. type QhjCusBankInfo struct {
  1139. CUSBANKID string `json:"cusbankid" xorm:"CUSBANKID"` // 托管银行编号(对应清算中心TRAN_NO)
  1140. CUSBANKNAME string `json:"cusbankname" xorm:"CUSBANKNAME"` // 银行业务名称
  1141. CUSBANKSHORTNAME string `json:"cusbankshortname" xorm:"CUSBANKSHORTNAME"` // 银行业务简称
  1142. EXCHBANKID string `json:"exchbankid" xorm:"EXCHBANKID"` // 交易所开户银行ID
  1143. EXCHPAYBANKACCNO string `json:"exchpaybankaccno" xorm:"EXCHPAYBANKACCNO"` // 交易所支出结算账户
  1144. EXCHPAYBANKACCNAME string `json:"exchpaybankaccname" xorm:"EXCHPAYBANKACCNAME"` // 交易所支出结算账户户名
  1145. CURRENCY string `json:"currency" xorm:"CURRENCY"` // 币种
  1146. CANSIGN int32 `json:"cansign" xorm:"CANSIGN"` // 是否可签约 - 0:不可 1:可以
  1147. CANRELEASE int32 `json:"canrelease" xorm:"CANRELEASE"` // 是否可解约 - 0:不可 1:可以
  1148. CANINAMOUNT int32 `json:"caninamount" xorm:"CANINAMOUNT"` // 是否可入金 - 0:不可 1:可以
  1149. CANOUTAMOUNT int32 `json:"canoutamount" xorm:"CANOUTAMOUNT"` // 是否可出金 - 0:不可 1:可以
  1150. RISKINFO string `json:"riskinfo" xorm:"RISKINFO"` // 签约风险提示书
  1151. CANSIGN2 int32 `json:"cansign2" xorm:"CANSIGN2"` // 是否可签约(网银端) - 0:不可 1:可以
  1152. CANRELEASE2 int32 `json:"canrelease2" xorm:"CANRELEASE2"` // 是否可解约(网银端) - 0:不可 1:可以
  1153. CANINAMOUNT2 int32 `json:"caninamount2" xorm:"CANINAMOUNT2"` // 是否可入金(网银端) - 0:不可 1:可以
  1154. CANOUTAMOUNT2 int32 `json:"canoutamount2" xorm:"CANOUTAMOUNT2"` // 是否可出金(网银端) - 0:不可 1:可以
  1155. CANBINDCARD int32 `json:"canbindcard" xorm:"CANBINDCARD"` // 是否可绑卡与解卡 - 0:不可 1:可以
  1156. ISNEEDCLEAR int32 `json:"isneedclear" xorm:"ISNEEDCLEAR"` // 是否需要清算 - 0:不需要 1:需要
  1157. CANMODIFYPHONE int32 `json:"canmodifyphone" xorm:"CANMODIFYPHONE"` // 是否可修改手机号 - 0:不可 1:可以
  1158. CANMODIFYSIGNINFO int32 `json:"canmodifysigninfo" xorm:"CANMODIFYSIGNINFO"` // 是否可修改签约信息 - 0:不可 1:可以
  1159. ISNEEDCHECK int32 `json:"isneedcheck" xorm:"ISNEEDCHECK"` // 是否需要对账 - 0:需要 1:不需要 [不需要界面配置]
  1160. CANMODIFYBANKCARD int32 `json:"canmodifybankcard" xorm:"CANMODIFYBANKCARD"` // 是否可修改银行卡号 - 0:不可 1:可以
  1161. CANALLOT int32 `json:"canallot" xorm:"CANALLOT"` // 是否支持跨行调拨 - 0:不支持 1:支持
  1162. CANALLOTQUERY int32 `json:"canallotquery" xorm:"CANALLOTQUERY"` // 是否支持跨行调拨查询 - 0:不支持 1:支持
  1163. TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
  1164. SIGNSTATUS int32 `json:"signstatus" xorm:"SIGNSTATUS"` // 当前签到/签退状态 - 1:签到 2:签退
  1165. UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 当前签到/签退更新时间
  1166. LASTSIGNINTIME string `json:"lastsignintime" xorm:"LASTSIGNINTIME"` // 最后签到时间
  1167. LASTSIGNOUTTIME string `json:"lastsignouttime" xorm:"LASTSIGNOUTTIME"` // 最后签退时间
  1168. LASTCHECKTIME string `json:"lastchecktime" xorm:"LASTCHECKTIME"` // 最后对账时间
  1169. LASTCHECKSTATUS int32 `json:"lastcheckstatus" xorm:"LASTCHECKSTATUS"` // 最后对账状态 - 对账状态 - 1:未对账 2:对账成功 3:对账失败
  1170. LASTCLEARTIME string `json:"lastcleartime" xorm:"LASTCLEARTIME"` // 最后清算时间
  1171. LASTCLEARSTATUS int32 `json:"lastclearstatus" xorm:"LASTCLEARSTATUS"` // 最后清算状态 - 1:未清算 2:清算成功 3:清算失败 4:清算部分成功
  1172. }
  1173. func (r *QhjCusBankInfo) calc() {
  1174. }
  1175. func (r *QhjCusBankInfo) buildSql() string {
  1176. var sqlId utils.SQLVal = "with tmp as" +
  1177. " (select *" +
  1178. " from (select row_number() over(partition by t.cusbankid order by t.tradedate desc) cn," +
  1179. " t.CUSBANKID id2," +
  1180. " t.TRADEDATE," +
  1181. " t.SIGNSTATUS," +
  1182. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  1183. " to_char(t.LASTSIGNINTIME, 'yyyy-mm-dd hh24:mi:ss') LASTSIGNINTIME," +
  1184. " to_char(t.LASTSIGNOUTTIME, 'yyyy-mm-dd hh24:mi:ss') LASTSIGNOUTTIME," +
  1185. " to_char(t.LASTCHECKTIME, 'yyyy-mm-dd hh24:mi:ss') LASTCHECKTIME," +
  1186. " t.LASTCHECKSTATUS," +
  1187. " to_char(t.LASTCLEARTIME, 'yyyy-mm-dd hh24:mi:ss') LASTCLEARTIME," +
  1188. " t.LASTCLEARSTATUS" +
  1189. " from bank_cusbankstatus t)" +
  1190. " where cn = 1)" +
  1191. "SELECT t.CUSBANKID," +
  1192. " t.CUSBANKNAME," +
  1193. " t.CUSBANKSHORTNAME," +
  1194. " t.EXCHBANKID," +
  1195. " t.EXCHPAYBANKACCNO," +
  1196. " t.EXCHPAYBANKACCNAME," +
  1197. " t.CURRENCY," +
  1198. " t.CANSIGN," +
  1199. " t.CANRELEASE," +
  1200. " t.CANINAMOUNT," +
  1201. " t.CANOUTAMOUNT," +
  1202. " to_char(t.RISKINFO) RISKINFO," +
  1203. " t.CANSIGN2," +
  1204. " t.CANRELEASE2," +
  1205. " t.CANINAMOUNT2," +
  1206. " t.CANOUTAMOUNT2," +
  1207. " t.CANBINDCARD," +
  1208. " t.ISNEEDCLEAR," +
  1209. " t.CANMODIFYPHONE," +
  1210. " t.CANMODIFYSIGNINFO," +
  1211. " t.ISNEEDCHECK," +
  1212. " t.CANMODIFYBANKCARD," +
  1213. " t.CANALLOT," +
  1214. " t.CANALLOTQUERY," +
  1215. " tmp.*" +
  1216. " FROM BANK_CUSBANKINFO t" +
  1217. " LEFT JOIN tmp" +
  1218. " on t.cusbankid = tmp.id2" +
  1219. " WHERE 1 = 1"
  1220. return sqlId.String()
  1221. }
  1222. // GetData 获取托管银行信息
  1223. func (r *QhjCusBankInfo) GetData() ([]QhjCusBankInfo, error) {
  1224. sData := make([]QhjCusBankInfo, 0)
  1225. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1226. for i := range sData {
  1227. sData[i].calc()
  1228. }
  1229. return sData, err
  1230. }
  1231. // GetDataEx 获取托管银行信息
  1232. func (r *QhjCusBankInfo) GetDataEx() (interface{}, error) {
  1233. return r.GetData()
  1234. }
  1235. // QhjCusBankSignBank 托管银行签约关系
  1236. type QhjCusBankSignBank struct {
  1237. CUSBANKID string `json:"cusbankid" xorm:"CUSBANKID"` // 托管银行ID
  1238. BANKID string `json:"bankid" xorm:"BANKID"` // 银行ID
  1239. }
  1240. func (r *QhjCusBankSignBank) calc() {
  1241. }
  1242. func (r *QhjCusBankSignBank) buildSql() string {
  1243. var sqlId utils.SQLVal = "select * from bank_cusbanksignbank"
  1244. return sqlId.String()
  1245. }
  1246. // GetData 获取托管银行签约关系
  1247. func (r *QhjCusBankSignBank) GetData() ([]QhjCusBankSignBank, error) {
  1248. sData := make([]QhjCusBankSignBank, 0)
  1249. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1250. for i := range sData {
  1251. sData[i].calc()
  1252. }
  1253. return sData, err
  1254. }
  1255. // GetDataEx 获取托管银行签约关系
  1256. func (r *QhjCusBankSignBank) GetDataEx() (interface{}, error) {
  1257. return r.GetData()
  1258. }
  1259. // QhjCusBankSignBankEx 托管银行签约银行详细
  1260. type QhjCusBankSignBankEx struct {
  1261. QhjCusBankInfo
  1262. Banklst []QhjBankInfo // 银行列表
  1263. }
  1264. // GetDataEx 获取托管银行签约银行详细
  1265. func (r *QhjCusBankSignBankEx) GetDataEx() (interface{}, error) {
  1266. sData := make([]QhjCusBankSignBankEx, 0)
  1267. a := QhjCusBankSignBank{}
  1268. relateData, _ := a.GetData()
  1269. if len(relateData) == 0 {
  1270. return sData, nil
  1271. }
  1272. b := QhjCusBankInfo{}
  1273. bData, _ := b.GetData()
  1274. c := QhjBankInfo{}
  1275. cData, _ := c.GetData()
  1276. for _, vb := range bData {
  1277. // 托管银行
  1278. v := QhjCusBankSignBankEx{QhjCusBankInfo: vb, Banklst: make([]QhjBankInfo, 0)}
  1279. for _, vr := range relateData {
  1280. // 托管关系
  1281. if vb.CUSBANKID == vr.CUSBANKID {
  1282. for _, vc := range cData {
  1283. if vc.BANKID == vr.BANKID {
  1284. v.Banklst = append(v.Banklst, vc)
  1285. }
  1286. }
  1287. }
  1288. }
  1289. if len(v.Banklst) > 0 {
  1290. sData = append(sData, v)
  1291. }
  1292. }
  1293. return sData, nil
  1294. }
  1295. // QhjSiteColumnDetail 资讯
  1296. type QhjSiteColumnDetail struct {
  1297. ID int64 `json:"id" xorm:"ID"` // ID(SEQ_SITE_COLUMNDETAIL)
  1298. COLUMNID int64 `json:"columnid" xorm:"COLUMNID"` // 所属栏目
  1299. USERID int64 `json:"userid" xorm:"USERID"` // 用户ID(默认为0, 核心为为机构用户ID)
  1300. TITLE string `json:"title" xorm:"TITLE"` // 标题
  1301. COVERIMAGE string `json:"coverimage" xorm:"COVERIMAGE"` // 封面图片
  1302. AUTHOR string `json:"author" xorm:"AUTHOR"` // 作者
  1303. BRIEF string `json:"brief" xorm:"BRIEF"` // 简介
  1304. CONTEXT string `json:"context" xorm:"CONTEXT"` // 内容
  1305. STATUS int32 `json:"status" xorm:"STATUS"` // 状态 - 1:暂存 10:待审核 20:审核通过 30:审核拒绝
  1306. ISTOP int32 `json:"istop" xorm:"ISTOP"` // 是否置顶 - 0:不置 1:置顶
  1307. HITS int64 `json:"hits" xorm:"HITS"` // 点击数
  1308. PUBLISHDATE string `json:"publishdate" xorm:"PUBLISHDATE"` // 发布日期
  1309. CREAEDATE string `json:"creaedate" xorm:"CREAEDATE"` // 创建时间
  1310. CREATORID int64 `json:"creatorid" xorm:"CREATORID"` // 创建人
  1311. UPDATEDATE string `json:"updatedate" xorm:"UPDATEDATE"` // 修改时间
  1312. MODIFIERID int64 `json:"modifierid" xorm:"MODIFIERID"` // 操作人
  1313. ISSHOW int32 `json:"isshow" xorm:"ISSHOW"` // 是否展示 - 0:不展示 1:展示
  1314. USERNAME string `json:"username"` // 用户名称
  1315. }
  1316. func (r *QhjSiteColumnDetail) calc() {
  1317. if r.USERID > 0 {
  1318. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  1319. }
  1320. }
  1321. func (r *QhjSiteColumnDetail) buildSql() string {
  1322. var sqlId utils.SQLVal = "SELECT t.ID," +
  1323. " t.COLUMNID," +
  1324. " t.USERID," +
  1325. " t.TITLE," +
  1326. " t.COVERIMAGE," +
  1327. " t.AUTHOR," +
  1328. " t.BRIEF," +
  1329. " to_char(t.CONTEXT) CONTEXT," +
  1330. " t.STATUS," +
  1331. " t.ISTOP," +
  1332. " t.HITS," +
  1333. " to_char(t.PUBLISHDATE, 'yyyy-mm-dd hh24:mi:ss') PUBLISHDATE," +
  1334. " to_char(t.CREAEDATE, 'yyyy-mm-dd hh24:mi:ss') CREAEDATE," +
  1335. " t.CREATORID," +
  1336. " to_char(t.UPDATEDATE, 'yyyy-mm-dd hh24:mi:ss') UPDATEDATE," +
  1337. " t.MODIFIERID," +
  1338. " t.ISSHOW" +
  1339. " FROM SITE_COLUMNDETAIL t" +
  1340. " WHERE 1 = 1"
  1341. sqlId.And("t.USERID", r.USERID)
  1342. return sqlId.String()
  1343. }
  1344. // GetDataEx 获取资讯
  1345. func (r *QhjSiteColumnDetail) GetDataEx() (interface{}, error) {
  1346. sData := make([]QhjSiteColumnDetail, 0)
  1347. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1348. for i := range sData {
  1349. sData[i].calc()
  1350. }
  1351. return sData, err
  1352. }
  1353. // QhjAccountOutInApply 充值提现(出入金)
  1354. type QhjAccountOutInApply struct {
  1355. EXECUTETYPE int32 `json:"executetype" xorm:"EXECUTETYPE"` // 申请类型 - 1:出金 2:入金 3: 单边账调整:入金; 4:单边账调整:出金 5:外部母账户调整:入金 6:外部母账户调整:出金 7:外部子账户:入金 8:外部子账户:出金
  1356. AMOUNT float64 `json:"amount" xorm:"AMOUNT"` // 金额
  1357. CURRENCY string `json:"currency" xorm:"CURRENCY"` // 币种
  1358. CHARGE float64 `json:"charge" xorm:"CHARGE"` // 手续费
  1359. ACCOUNTPWD string `json:"accountpwd" xorm:"ACCOUNTPWD"` // 资金密码
  1360. UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间(申请时间)
  1361. BANKID string `json:"bankid" xorm:"BANKID"` // 银行编号
  1362. BRANCHBANKID string `json:"branchbankid" xorm:"BRANCHBANKID"` // 银行支行号
  1363. BRANCHBANKNAME string `json:"branchbankname" xorm:"BRANCHBANKNAME"` // 银行支行名称
  1364. BANKACCOUNTNO string `json:"bankaccountno" xorm:"BANKACCOUNTNO"` // 银行卡号
  1365. BANKACCOUNTNAME string `json:"bankaccountname" xorm:"BANKACCOUNTNAME"` // 银行账户名
  1366. EXTENDINFO string `json:"extendinfo" xorm:"EXTENDINFO"` // 扩展信息
  1367. AUDITID int64 `json:"auditid" xorm:"AUDITID"` // 审核人
  1368. AUDITTIME string `json:"audittime" xorm:"AUDITTIME"` // 审核时间
  1369. REMARK string `json:"remark" xorm:"REMARK"` // 备注
  1370. NETADDR string `json:"netaddr" xorm:"NETADDR"` // 调转网址
  1371. ACCOUNTTICKET string `json:"accountticket" xorm:"ACCOUNTTICKET"` // 最新账户服务流水号
  1372. CHECKERRORFLAG int32 `json:"checkerrorflag" xorm:"CHECKERRORFLAG"` // 对账差错标志 - 1:为单边账;其它为正常出入金
  1373. REMARK2 string `json:"remark2" xorm:"REMARK2"` // 备注(失败原因)
  1374. REAUDITID int64 `json:"reauditid" xorm:"REAUDITID"` // 复审人
  1375. REAUDITTIME string `json:"reaudittime" xorm:"REAUDITTIME"` // 复审时间
  1376. REAUDITREMARK string `json:"reauditremark" xorm:"REAUDITREMARK"` // 复审备注
  1377. APPLYREMARK string `json:"applyremark" xorm:"APPLYREMARK"` // 申请备注
  1378. RELATEDORDERID string `json:"relatedorderid" xorm:"RELATEDORDERID"` // 三方关联ID
  1379. CAPAMOUNTOUT float64 `json:"capamountout" xorm:"CAPAMOUNTOUT"` // 出金(劣后本金) - 外部子账户
  1380. INFAMOUNT float64 `json:"infamount" xorm:"INFAMOUNT"` // 劣后金额(自有)
  1381. PRIAMOUNT float64 `json:"priamount" xorm:"PRIAMOUNT"` // 优先金额(授信)
  1382. BANK_APPLY_TICKET string `json:"bank_apply_ticket" xorm:"BANK_APPLY_TICKET"` // 银行申请流水
  1383. CERTIFICATEPHOTOURL string `json:"certificatephotourl" xorm:"CERTIFICATEPHOTOURL"` // 凭证地址
  1384. SOUCREAMOUNT float64 `json:"soucreamount" xorm:"SOUCREAMOUNT"` // 原始出入金金额
  1385. SOUCRECURRENCYID int64 `json:"soucrecurrencyid" xorm:"SOUCRECURRENCYID"` // 原始出入金币种
  1386. ACCOUNTCODE string `json:"accountcode" xorm:"ACCOUNTCODE"` // 资金账号
  1387. CUSBANKID string `json:"cusbankid" xorm:"CUSBANKID"` // 托管银行编号
  1388. TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
  1389. EXCHTICKET string `json:"exchticket" xorm:"EXCHTICKET"` // 银行服务流水号
  1390. EXTOPERATEID int64 `json:"extoperateid" xorm:"EXTOPERATEID"` // 交易服务流水号
  1391. BANKTICKET string `json:"bankticket" xorm:"BANKTICKET"` // 银行流水
  1392. APPLYSTATUS int32 `json:"applystatus" xorm:"APPLYSTATUS"` // 申请状态 - 1:待审核 2:待复审 3:初审拒绝 4:交易冻结中 5:交易解冻中 6:交易解冻扣款中 7:交易入金中 8:交易冻结/解冻/扣款中(银行发起出金时用) 9:银行出金中 10:银行入金中 11:成功 12:失败 13:银行审核中 14:账户服务入金失败; 15:账户服务解冻失败; 16:账户服务解冻扣款失败; 17:账户服务出金失败 18:复审通过 19:复审拒绝 20:提交审核,账户冻结中 21:审核拒绝,账户解冻中;22: 待审核,账户服务解冻回滚中; 23:待复审,账户服务解冻回滚中; 24: 审核通过,账户冻结金额检查中;25: 复审通过,账户冻结金额检查中;
  1393. USERID int64 `json:"userid" xorm:"'USERID'"` // 用户id
  1394. LOGINCODE string `json:"logincode" xorm:"'LOGINCODE'"` // 登录账号(账号)
  1395. USERINFOTYPE int32 `json:"userinfotype" xorm:"'USERINFOTYPE'"` // 账户类型 1-个人 2-企业
  1396. ACCOUNTNAME string `json:"accountname" xorm:"'ACCOUNTNAME'"` // 用户名称(名称)
  1397. MOBILE string `json:"-" xorm:"'MOBILE'"` // 手机号
  1398. BeginDate string `json:"-"` // 开始日期(yyyymmdd)
  1399. EndDate string `json:"-"` // 结束日期(yyyymmdd)
  1400. FilterName string `json:"-"` // 账户(模糊匹配)
  1401. }
  1402. func (r *QhjAccountOutInApply) calc() {
  1403. r.BANKACCOUNTNAME = DecryptField(r.BANKACCOUNTNAME)
  1404. r.BANKACCOUNTNO = DecryptField(r.BANKACCOUNTNO)
  1405. if len(r.LOGINCODE) == 0 {
  1406. r.LOGINCODE = DecryptField(r.MOBILE)
  1407. }
  1408. }
  1409. func (r *QhjAccountOutInApply) buildSql() string {
  1410. var sqlId utils.SQLVal = "with tmp as(select t.userid, wm_concat(t.logincode) logincode from loginaccount t group by t.userid)" +
  1411. "SELECT t.EXECUTETYPE," +
  1412. " t.AMOUNT," +
  1413. " t.CURRENCY," +
  1414. " t.CHARGE," +
  1415. " t.ACCOUNTPWD," +
  1416. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  1417. " t.BANKID," +
  1418. " t.BRANCHBANKID," +
  1419. " t.BRANCHBANKNAME," +
  1420. " t.BANKACCOUNTNO," +
  1421. " t.BANKACCOUNTNAME," +
  1422. " t.EXTENDINFO," +
  1423. " t.AUDITID," +
  1424. " to_char(t.AUDITTIME, 'yyyy-mm-dd hh24:mi:ss') AUDITTIME," +
  1425. " t.REMARK," +
  1426. " t.NETADDR," +
  1427. " t.ACCOUNTTICKET," +
  1428. " t.CHECKERRORFLAG," +
  1429. " t.REMARK2," +
  1430. " t.REAUDITID," +
  1431. " to_char(t.REAUDITTIME, 'yyyy-mm-dd hh24:mi:ss') REAUDITTIME," +
  1432. " t.REAUDITREMARK," +
  1433. " t.APPLYREMARK," +
  1434. " t.RELATEDORDERID," +
  1435. " t.CAPAMOUNTOUT," +
  1436. " t.INFAMOUNT," +
  1437. " t.PRIAMOUNT," +
  1438. " t.BANK_APPLY_TICKET," +
  1439. " to_char(t.CERTIFICATEPHOTOURL) CERTIFICATEPHOTOURL," +
  1440. " t.SOUCREAMOUNT," +
  1441. " t.SOUCRECURRENCYID," +
  1442. " t.ACCOUNTCODE," +
  1443. " t.CUSBANKID," +
  1444. " t.TRADEDATE," +
  1445. " t.EXCHTICKET," +
  1446. " t.EXTOPERATEID," +
  1447. " t.BANKTICKET," +
  1448. " t.APPLYSTATUS," +
  1449. " u.userid," +
  1450. " u.accountname," +
  1451. " ui.userinfotype," +
  1452. " ui.mobile," +
  1453. " tmp.logincode" +
  1454. " FROM BANK_ACCOUNTOUTINAPPLY t" +
  1455. " INNER JOIN TAACCOUNT ta on t.accountcode=to_char(ta.accountid)" +
  1456. " INNER JOIN USERACCOUNT u on ta.relateduserid=u.userid" +
  1457. " INNER JOIN USERINFO ui on u.userid=ui.userid" +
  1458. " LEFT JOIN tmp on u.userid=tmp.userid" +
  1459. " WHERE 1 = 1"
  1460. sqlId.And("u.userid", r.USERID)
  1461. if len(r.BeginDate) > 0 {
  1462. sqlId.Join(fmt.Sprintf(" and t.UPDATETIME >= to_date(%v,'yyyymmdd')", r.BeginDate))
  1463. }
  1464. if len(r.EndDate) > 0 {
  1465. sqlId.Join(fmt.Sprintf(" and t.UPDATETIME <= to_date(%v,'yyyymmdd')", r.EndDate))
  1466. }
  1467. if len(r.FilterName) > 0 {
  1468. sqlId.Join(fmt.Sprintf(" and (tmp.logincode like '%%%v%%' or u.accountname like '%%%v%%')", r.FilterName, r.FilterName))
  1469. }
  1470. return sqlId.String()
  1471. }
  1472. // GetDataEx 获取充值提现(出入金)
  1473. func (r *QhjAccountOutInApply) GetDataEx() (interface{}, error) {
  1474. sData := make([]QhjAccountOutInApply, 0)
  1475. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1476. for i := range sData {
  1477. sData[i].calc()
  1478. }
  1479. return sData, err
  1480. }
  1481. type DBINT64 int64
  1482. func (r *DBINT64) FromDB(bytes []byte) error {
  1483. d, err := strconv.ParseInt(string(bytes), 10, 64)
  1484. if err == nil {
  1485. *r = DBINT64(d)
  1486. }
  1487. return err
  1488. }
  1489. func (r *DBINT64) ToDB() ([]byte, error) {
  1490. d := strconv.FormatInt(int64(*r), 10)
  1491. return []byte(d), nil
  1492. }
  1493. // QhjPayOrder 待付款单据
  1494. type QhjPayOrder struct {
  1495. OPERATETYPE int32 `json:"operatetype" xorm:"OPERATETYPE"` // 买委托操作类型 - 1:正常下单 16:融资买入
  1496. TRADEID string `json:"tradeid" xorm:"TRADEID"` // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
  1497. TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
  1498. MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
  1499. GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID
  1500. BUYORDERID string `json:"buyorderid" xorm:"BUYORDERID"` // 买方委托单号
  1501. BUYACCOUNTID int64 `json:"buyaccountid" xorm:"BUYACCOUNTID"` // 买方账号ID[报价币种]
  1502. SELLORDERID string `json:"sellorderid" xorm:"SELLORDERID"` // 卖方委托单号
  1503. SELLACCOUNTID int64 `json:"sellaccountid" xorm:"SELLACCOUNTID"` // 卖方账号ID[报价币种]
  1504. TRADEAMOUNT float64 `json:"tradeamount" xorm:"TRADEAMOUNT"` // 成交金额(优惠后金额)
  1505. TRADECHARGE float64 `json:"tradecharge" xorm:"TRADECHARGE"` // 成交手续费(买方)
  1506. PAYFLAG int32 `json:"payflag" xorm:"PAYFLAG"` // 付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期 6:预售终止
  1507. CREATETIME string `json:"createtime" xorm:"CREATETIME"` // 创建时间
  1508. PAYTIME string `json:"paytime" xorm:"PAYTIME"` // 付款时间
  1509. PAYLIMITEDTIME string `json:"paylimitedtime" xorm:"PAYLIMITEDTIME"` // 支付期限
  1510. OFFAMOUNT float64 `json:"offamount" xorm:"OFFAMOUNT"` // 优惠金额
  1511. TRADEPRICE float64 `json:"tradeprice" xorm:"TRADEPRICE"` // 成交价格
  1512. TRADEQTY float64 `json:"tradeqty" xorm:"TRADEQTY"` // 成交数量
  1513. PAYAMOUNT float64 `json:"payamount" xorm:"PAYAMOUNT"` // 支付金额
  1514. GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码
  1515. GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称
  1516. GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 商品单位id
  1517. DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
  1518. QTYDECIMALPLACE int `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
  1519. ADVANCERATIO float64 `json:"advanceratio" xorm:"ADVANCERATIO"` // 首付比率
  1520. ENUMDICNAME string `json:"enumdicname"` // 单位名称
  1521. }
  1522. func (r *QhjPayOrder) calc() {
  1523. r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
  1524. zoomFun := NewZoomFun(r.QTYDECIMALPLACE)
  1525. zoomFun(&r.TRADEQTY)
  1526. }
  1527. func (r *QhjPayOrder) buildSql() string {
  1528. var sqlId utils.SQLVal = "SELECT t.OPERATETYPE," +
  1529. " to_char(t.TRADEID) TRADEID," +
  1530. " t.TRADEDATE," +
  1531. " t.MARKETID," +
  1532. " t.GOODSID," +
  1533. " to_char(t.BUYORDERID) BUYORDERID," +
  1534. " t.BUYACCOUNTID," +
  1535. " to_char(t.SELLORDERID) SELLORDERID," +
  1536. " t.SELLACCOUNTID," +
  1537. " t.TRADEAMOUNT," +
  1538. " t.TRADECHARGE," +
  1539. " t.PAYFLAG," +
  1540. " to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
  1541. " to_char(t.PAYTIME, 'yyyy-mm-dd hh24:mi:ss') PAYTIME," +
  1542. " to_char(t.PAYLIMITEDTIME, 'yyyy-mm-dd hh24:mi:ss') PAYLIMITEDTIME," +
  1543. " t.OFFAMOUNT," +
  1544. " t.TRADEPRICE," +
  1545. " t.TRADEQTY," +
  1546. " t.PAYAMOUNT," +
  1547. " t.ADVANCERATIO," +
  1548. " g.goodscode," +
  1549. " g.decimalplace," +
  1550. " g.qtydecimalplace," +
  1551. " g.goodunitid," +
  1552. " g.goodsname" +
  1553. " FROM TRADE_PAYORDER t" +
  1554. " LEFT JOIN GOODS g on t.goodsid=g.goodsid" +
  1555. " WHERE 1 = 1"
  1556. sqlId.AndEx("t.BUYACCOUNTID", r.BUYACCOUNTID, r.BUYACCOUNTID > 0)
  1557. sqlId.AndEx("t.TRADEID", r.TRADEID, len(r.TRADEID) > 0)
  1558. sqlId.AndEx("t.PAYFLAG", r.PAYFLAG, r.PAYFLAG > 0)
  1559. return sqlId.String()
  1560. }
  1561. // GetDataEx 获取待付款单据
  1562. func (r *QhjPayOrder) GetDataEx() (interface{}, error) {
  1563. sData := make([]QhjPayOrder, 0)
  1564. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1565. for i := range sData {
  1566. sData[i].calc()
  1567. }
  1568. return sData, err
  1569. }
  1570. // Qhjgoodsex 交易商品扩展表(千海金)
  1571. type Qhjgoodsex struct {
  1572. Goodsid int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID(自增ID SEQ_GOODS)
  1573. Minamount float64 `json:"minamount" xorm:"MINAMOUNT"` // 最小购买金额
  1574. Canfinance int32 `json:"canfinance" xorm:"CANFINANCE"` // 是否支持融资 - 0:不支持 1:支持【69:铂金宝】
  1575. Canregularlybuy int32 `json:"canregularlybuy" xorm:"CANREGULARLYBUY"` // 是否支持定投 - 0:不支持 1:支持【69:铂金宝】
  1576. Regularlybuyminqty float64 `json:"regularlybuyminqty" xorm:"REGULARLYBUYMINQTY"` // 定投最小数量
  1577. Regularlybuyminamount float64 `json:"regularlybuyminamount" xorm:"REGULARLYBUYMINAMOUNT"` // 定投最小金额
  1578. Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"DELIVERYGOODSID"` // 现货品种ID
  1579. Wrstandardid int32 `json:"wrstandardid" xorm:"WRSTANDARDID"` // 现货商品ID
  1580. Spotgoodsbrandid int32 `json:"spotgoodsbrandid" xorm:"SPOTGOODSBRANDID"` // 现货品牌ID - 存“DGFactoryItem”表"DGFactoryItemID"
  1581. Defaulttradeuserid int64 `json:"defaulttradeuserid" xorm:"DEFAULTTRADEUSERID"` // 默认交易用户ID
  1582. }
  1583. func (r *Qhjgoodsex) calc() {
  1584. }
  1585. func (r *Qhjgoodsex) buildSql() string {
  1586. var sqlId utils.SQLVal = "SELECT t.GOODSID," +
  1587. " t.MINAMOUNT," +
  1588. " t.CANFINANCE," +
  1589. " t.CANREGULARLYBUY," +
  1590. " t.REGULARLYBUYMINQTY / power(10,nvl(g.qtydecimalplace,0)) REGULARLYBUYMINQTY," +
  1591. " t.REGULARLYBUYMINAMOUNT," +
  1592. " t.DELIVERYGOODSID," +
  1593. " t.WRSTANDARDID," +
  1594. " t.SPOTGOODSBRANDID," +
  1595. " t.DEFAULTTRADEUSERID" +
  1596. " FROM QHJ_GOODSEX t" +
  1597. " LEFT JOIN GOODS g on t.goodsid=g.goodsid" +
  1598. " WHERE 1 = 1"
  1599. sqlId.AndEx("t.GOODSID", r.Goodsid, r.Goodsid > 0)
  1600. return sqlId.String()
  1601. }
  1602. // GetDataEx 获取交易商品扩展表(千海金)
  1603. func (r *Qhjgoodsex) GetDataEx() (interface{}, error) {
  1604. sData := make([]Qhjgoodsex, 0)
  1605. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1606. for i := range sData {
  1607. sData[i].calc()
  1608. }
  1609. return sData, err
  1610. }
  1611. // QhjParentAreaList 所属机构列表
  1612. type QhjParentAreaList struct {
  1613. USERID int64 `json:"userid" xorm:"USERID"` // 用户ID
  1614. USERTYPE int32 `json:"usertype" xorm:"USERTYPE"` // 账户类型 - 1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 7:企业成员(云平台)
  1615. ACCOUNTNAME string `json:"accountname" xorm:"ACCOUNTNAME"` // 账户名称(机构名称)
  1616. }
  1617. func (r *QhjParentAreaList) calc() {
  1618. }
  1619. func (r *QhjParentAreaList) buildSql() string {
  1620. var sqlId utils.SQLVal = "select t.userid, t.accountname, t.usertype" +
  1621. " from useraccount t" +
  1622. " where 1 = 1" +
  1623. " and t.accountstatus = 4" +
  1624. " and t.usertype = 2" +
  1625. " and t.rootuserid = %v" +
  1626. " or t.userid = %v"
  1627. sqlId.FormatParam(r.USERID, r.USERID)
  1628. return sqlId.String()
  1629. }
  1630. // GetDataEx 获取所属机构列表
  1631. func (r *QhjParentAreaList) GetDataEx() (interface{}, error) {
  1632. sData := make([]QhjParentAreaList, 0)
  1633. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1634. for i := range sData {
  1635. sData[i].calc()
  1636. }
  1637. return sData, err
  1638. }