qhj.go 83 KB

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