qhj.go 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678
  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. LOGINCODE string `json:"logincode" xorm:"'LOGINCODE'"` // 登录账号(代码)
  918. COUNTRYNAME string `json:"countryname"` // 国家名称
  919. CITYNAME string `json:"cityname"` // 城市名称
  920. PROVINCENAME string `json:"provincename"` // 省名称
  921. DISTRICTNAME string `json:"districtname"` // 地区名称
  922. CARDTYPENAME string `json:"cardtypename"` // 证件类型名称
  923. MEMBERUSERNAME string `json:"memberusername"` // 所属会员名称
  924. PARENTUSERNAME string `json:"parentusername"` //所属机构名称
  925. QUERYTYPE int32 `json:"-"` // 查询类型(1:未提交(网上开户表) 2:待审核(网上开户表) 3:正常 4:停用)
  926. IncludeSub int32 `json:"-"` // 包子机构客户 1-包含
  927. }
  928. func (r *QhjCustomer) calc() {
  929. r.MEMBERUSERNAME = mtpcache.GetUserNameByUserId(r.MEMBERUSERID)
  930. if len(r.USERNAME) == 0 {
  931. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  932. }
  933. r.PARENTUSERNAME = mtpcache.GetUserNameByUserId(r.PARENTUSERID)
  934. r.COUNTRYNAME = mtpcache.GetDivisionName(r.COUNTRYID)
  935. r.CITYNAME = mtpcache.GetDivisionName(r.CITYID)
  936. r.PROVINCENAME = mtpcache.GetDivisionName(r.PROVINCEID)
  937. r.DISTRICTNAME = mtpcache.GetDivisionName(r.DISTRICTID)
  938. switch r.QUERYTYPE {
  939. case 1, 2: // 网上开户表
  940. r.ADDRESS = DecryptField(r.ADDRESS)
  941. r.TELPHONE = DecryptField(r.TELPHONE)
  942. case 3, 4: // 正式表
  943. r.TELPHONE = DecryptField(r.TELPHONE)
  944. }
  945. r.CARDNUM = DecryptField(r.CARDNUM)
  946. r.MOBILE = DecryptField(r.MOBILE)
  947. r.EMAIL = DecryptField(r.EMAIL)
  948. }
  949. func (r *QhjCustomer) level() int32 {
  950. if r.IncludeSub > 0 {
  951. // 层级, 最多20层
  952. return 20
  953. }
  954. return 1
  955. }
  956. func (r *QhjCustomer) buildSql() string {
  957. if r.QUERYTYPE == 1 || r.QUERYTYPE == 2 {
  958. return r.buildSqlWskh()
  959. }
  960. return r.buildSqlNormal()
  961. }
  962. func (r *QhjCustomer) buildSqlWskh() string {
  963. var sqlId utils.SQLVal = "with tmp as" +
  964. " (select t.userid, wm_concat(t.logincode) logincode" +
  965. " from loginaccount t" +
  966. " group by t.userid)" +
  967. "select a.*" +
  968. " from (select t.userid," +
  969. " t.memberareaid MEMBERUSERID," +
  970. " t.USERINFOTYPE," +
  971. " t.username," +
  972. " t.CUSTOMERNAME," +
  973. " t.NICKNAME," +
  974. " t.CARDTYPE," +
  975. " t.CARDNUM," +
  976. " t.mobilephone MOBILE," +
  977. " t.TELPHONE," +
  978. " t.cardaddress ADDRESS," +
  979. " t.REMARK," +
  980. " t.ATTACHMENT1," +
  981. " t.CARDFRONTPHOTOURL," +
  982. " t.CARDBACKPHOTOURL," +
  983. " t.userstate status," +
  984. " t.countryid," +
  985. " t.provinceid," +
  986. " t.districtid," +
  987. " to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
  988. " t.cityid," +
  989. " to_char(t.modifiedtime, 'yyyy-mm-dd hh24:mi:ss') modifytime," +
  990. " to_char(t.auditime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
  991. " t.taxpayernum," +
  992. " t.legalpersonname," +
  993. " t.contactname," +
  994. " t.email," +
  995. " t.areaid parentuserid," +
  996. " t.logincode" +
  997. " from wskh_userinfo t" +
  998. " start with t.areaid = %v" +
  999. " connect by prior t.userid = t.areaid" +
  1000. " and t.usertype in(2,6)" +
  1001. " and level <= %v) a" +
  1002. " left join tmp k" +
  1003. " on a.userid = k.userid" +
  1004. " where 1 = 1 and a.status in(%v)"
  1005. status := DecodeStr(r.QUERYTYPE == 1, "1", "2,4,5")
  1006. sqlId.FormatParam(r.USERID, r.level(), status)
  1007. sqlId.AndEx("a.USERINFOTYPE", r.USERINFOTYPE, r.USERINFOTYPE > 0)
  1008. sqlId.JoinEx(len(r.CUSTOMERNAME) > 0, fmt.Sprintf(` and a.customername like '%%%v%%'`, r.CUSTOMERNAME))
  1009. sqlId.JoinEx(len(r.NICKNAME) > 0, fmt.Sprintf(` and a.nickname like '%%%v%%'`, r.NICKNAME))
  1010. return sqlId.String()
  1011. }
  1012. func (r *QhjCustomer) buildSqlNormal() string {
  1013. var sqlId utils.SQLVal = "with tmp as" +
  1014. " (select t.userid, wm_concat(t.logincode) logincode" +
  1015. " from loginaccount t" +
  1016. " group by t.userid)" +
  1017. "select a.*," +
  1018. " k.logincode," +
  1019. " u.USERINFOTYPE," +
  1020. " u.CUSTOMERNAME," +
  1021. " u.NICKNAME," +
  1022. " u.CARDTYPEID CARDTYPE," +
  1023. " u.CARDNUM," +
  1024. " u.MOBILE," +
  1025. " u.TELPHONE," +
  1026. " u.ADDRESS," +
  1027. " u.REMARK," +
  1028. " u.ATTACHMENT1," +
  1029. " u.CARDFRONTPHOTOURL," +
  1030. " u.CARDBACKPHOTOURL," +
  1031. " u.countryid," +
  1032. " u.provinceid," +
  1033. " u.districtid," +
  1034. " u.taxpayernum," +
  1035. " u.legalpersonname," +
  1036. " u.contactname," +
  1037. " u.email," +
  1038. " u.cityid" +
  1039. " from (select t.userid," +
  1040. " t.usertype," +
  1041. " t.parentuserid," +
  1042. " t.memberuserid," +
  1043. " t.accountstatus status," +
  1044. " to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
  1045. " to_char(t.modifytime, 'yyyy-mm-dd hh24:mi:ss') modifytime," +
  1046. " to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime" +
  1047. " from useraccount t" +
  1048. " start with t.usertype=6 and t.parentuserid = %v" +
  1049. " connect by prior t.userid = t.parentuserid" +
  1050. " and t.usertype = 6" +
  1051. " and level <= %v) a" +
  1052. " left join tmp k" +
  1053. " on a.userid = k.userid" +
  1054. " left join userinfo u" +
  1055. " on a.userid = u.userid" +
  1056. " where 1=1 and a.status in(%v)"
  1057. status := DecodeStr(r.QUERYTYPE == 3, "4", "6")
  1058. sqlId.FormatParam(r.USERID, r.level(), status)
  1059. sqlId.AndEx("u.USERINFOTYPE", r.USERINFOTYPE, r.USERINFOTYPE > 0)
  1060. sqlId.JoinEx(len(r.CUSTOMERNAME) > 0, fmt.Sprintf(` and u.customername like '%%%v%%'`, r.CUSTOMERNAME))
  1061. sqlId.JoinEx(len(r.NICKNAME) > 0, fmt.Sprintf(` and u.nickname like '%%%v%%'`, r.NICKNAME))
  1062. return sqlId.String()
  1063. }
  1064. // GetDataEx 获取客户资料
  1065. func (r *QhjCustomer) GetDataEx() (interface{}, error) {
  1066. sData := make([]QhjCustomer, 0)
  1067. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1068. for i := range sData {
  1069. sData[i].QUERYTYPE = r.QUERYTYPE
  1070. sData[i].calc()
  1071. }
  1072. return sData, err
  1073. }
  1074. // QhjCusBankInfo 托管银行信息
  1075. type QhjCusBankInfo struct {
  1076. CUSBANKID string `json:"cusbankid" xorm:"CUSBANKID"` // 托管银行编号(对应清算中心TRAN_NO)
  1077. CUSBANKNAME string `json:"cusbankname" xorm:"CUSBANKNAME"` // 银行业务名称
  1078. CUSBANKSHORTNAME string `json:"cusbankshortname" xorm:"CUSBANKSHORTNAME"` // 银行业务简称
  1079. EXCHBANKID string `json:"exchbankid" xorm:"EXCHBANKID"` // 交易所开户银行ID
  1080. EXCHPAYBANKACCNO string `json:"exchpaybankaccno" xorm:"EXCHPAYBANKACCNO"` // 交易所支出结算账户
  1081. EXCHPAYBANKACCNAME string `json:"exchpaybankaccname" xorm:"EXCHPAYBANKACCNAME"` // 交易所支出结算账户户名
  1082. CURRENCY string `json:"currency" xorm:"CURRENCY"` // 币种
  1083. CANSIGN int32 `json:"cansign" xorm:"CANSIGN"` // 是否可签约 - 0:不可 1:可以
  1084. CANRELEASE int32 `json:"canrelease" xorm:"CANRELEASE"` // 是否可解约 - 0:不可 1:可以
  1085. CANINAMOUNT int32 `json:"caninamount" xorm:"CANINAMOUNT"` // 是否可入金 - 0:不可 1:可以
  1086. CANOUTAMOUNT int32 `json:"canoutamount" xorm:"CANOUTAMOUNT"` // 是否可出金 - 0:不可 1:可以
  1087. RISKINFO string `json:"riskinfo" xorm:"RISKINFO"` // 签约风险提示书
  1088. CANSIGN2 int32 `json:"cansign2" xorm:"CANSIGN2"` // 是否可签约(网银端) - 0:不可 1:可以
  1089. CANRELEASE2 int32 `json:"canrelease2" xorm:"CANRELEASE2"` // 是否可解约(网银端) - 0:不可 1:可以
  1090. CANINAMOUNT2 int32 `json:"caninamount2" xorm:"CANINAMOUNT2"` // 是否可入金(网银端) - 0:不可 1:可以
  1091. CANOUTAMOUNT2 int32 `json:"canoutamount2" xorm:"CANOUTAMOUNT2"` // 是否可出金(网银端) - 0:不可 1:可以
  1092. CANBINDCARD int32 `json:"canbindcard" xorm:"CANBINDCARD"` // 是否可绑卡与解卡 - 0:不可 1:可以
  1093. ISNEEDCLEAR int32 `json:"isneedclear" xorm:"ISNEEDCLEAR"` // 是否需要清算 - 0:不需要 1:需要
  1094. CANMODIFYPHONE int32 `json:"canmodifyphone" xorm:"CANMODIFYPHONE"` // 是否可修改手机号 - 0:不可 1:可以
  1095. CANMODIFYSIGNINFO int32 `json:"canmodifysigninfo" xorm:"CANMODIFYSIGNINFO"` // 是否可修改签约信息 - 0:不可 1:可以
  1096. ISNEEDCHECK int32 `json:"isneedcheck" xorm:"ISNEEDCHECK"` // 是否需要对账 - 0:需要 1:不需要 [不需要界面配置]
  1097. CANMODIFYBANKCARD int32 `json:"canmodifybankcard" xorm:"CANMODIFYBANKCARD"` // 是否可修改银行卡号 - 0:不可 1:可以
  1098. CANALLOT int32 `json:"canallot" xorm:"CANALLOT"` // 是否支持跨行调拨 - 0:不支持 1:支持
  1099. CANALLOTQUERY int32 `json:"canallotquery" xorm:"CANALLOTQUERY"` // 是否支持跨行调拨查询 - 0:不支持 1:支持
  1100. TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
  1101. SIGNSTATUS int32 `json:"signstatus" xorm:"SIGNSTATUS"` // 当前签到/签退状态 - 1:签到 2:签退
  1102. UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 当前签到/签退更新时间
  1103. LASTSIGNINTIME string `json:"lastsignintime" xorm:"LASTSIGNINTIME"` // 最后签到时间
  1104. LASTSIGNOUTTIME string `json:"lastsignouttime" xorm:"LASTSIGNOUTTIME"` // 最后签退时间
  1105. LASTCHECKTIME string `json:"lastchecktime" xorm:"LASTCHECKTIME"` // 最后对账时间
  1106. LASTCHECKSTATUS int32 `json:"lastcheckstatus" xorm:"LASTCHECKSTATUS"` // 最后对账状态 - 对账状态 - 1:未对账 2:对账成功 3:对账失败
  1107. LASTCLEARTIME string `json:"lastcleartime" xorm:"LASTCLEARTIME"` // 最后清算时间
  1108. LASTCLEARSTATUS int32 `json:"lastclearstatus" xorm:"LASTCLEARSTATUS"` // 最后清算状态 - 1:未清算 2:清算成功 3:清算失败 4:清算部分成功
  1109. }
  1110. func (r *QhjCusBankInfo) calc() {
  1111. }
  1112. func (r *QhjCusBankInfo) buildSql() string {
  1113. var sqlId utils.SQLVal = "with tmp as" +
  1114. " (select *" +
  1115. " from (select row_number() over(partition by t.cusbankid order by t.tradedate desc) cn," +
  1116. " t.CUSBANKID id2," +
  1117. " t.TRADEDATE," +
  1118. " t.SIGNSTATUS," +
  1119. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  1120. " to_char(t.LASTSIGNINTIME, 'yyyy-mm-dd hh24:mi:ss') LASTSIGNINTIME," +
  1121. " to_char(t.LASTSIGNOUTTIME, 'yyyy-mm-dd hh24:mi:ss') LASTSIGNOUTTIME," +
  1122. " to_char(t.LASTCHECKTIME, 'yyyy-mm-dd hh24:mi:ss') LASTCHECKTIME," +
  1123. " t.LASTCHECKSTATUS," +
  1124. " to_char(t.LASTCLEARTIME, 'yyyy-mm-dd hh24:mi:ss') LASTCLEARTIME," +
  1125. " t.LASTCLEARSTATUS" +
  1126. " from bank_cusbankstatus t)" +
  1127. " where cn = 1)" +
  1128. "SELECT t.CUSBANKID," +
  1129. " t.CUSBANKNAME," +
  1130. " t.CUSBANKSHORTNAME," +
  1131. " t.EXCHBANKID," +
  1132. " t.EXCHPAYBANKACCNO," +
  1133. " t.EXCHPAYBANKACCNAME," +
  1134. " t.CURRENCY," +
  1135. " t.CANSIGN," +
  1136. " t.CANRELEASE," +
  1137. " t.CANINAMOUNT," +
  1138. " t.CANOUTAMOUNT," +
  1139. " to_char(t.RISKINFO) RISKINFO," +
  1140. " t.CANSIGN2," +
  1141. " t.CANRELEASE2," +
  1142. " t.CANINAMOUNT2," +
  1143. " t.CANOUTAMOUNT2," +
  1144. " t.CANBINDCARD," +
  1145. " t.ISNEEDCLEAR," +
  1146. " t.CANMODIFYPHONE," +
  1147. " t.CANMODIFYSIGNINFO," +
  1148. " t.ISNEEDCHECK," +
  1149. " t.CANMODIFYBANKCARD," +
  1150. " t.CANALLOT," +
  1151. " t.CANALLOTQUERY," +
  1152. " tmp.*" +
  1153. " FROM BANK_CUSBANKINFO t" +
  1154. " LEFT JOIN tmp" +
  1155. " on t.cusbankid = tmp.id2" +
  1156. " WHERE 1 = 1"
  1157. return sqlId.String()
  1158. }
  1159. // GetData 获取托管银行信息
  1160. func (r *QhjCusBankInfo) GetData() ([]QhjCusBankInfo, error) {
  1161. sData := make([]QhjCusBankInfo, 0)
  1162. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1163. for i := range sData {
  1164. sData[i].calc()
  1165. }
  1166. return sData, err
  1167. }
  1168. // GetDataEx 获取托管银行信息
  1169. func (r *QhjCusBankInfo) GetDataEx() (interface{}, error) {
  1170. return r.GetData()
  1171. }
  1172. // QhjCusBankSignBank 托管银行签约关系
  1173. type QhjCusBankSignBank struct {
  1174. CUSBANKID string `json:"cusbankid" xorm:"CUSBANKID"` // 托管银行ID
  1175. BANKID string `json:"bankid" xorm:"BANKID"` // 银行ID
  1176. }
  1177. func (r *QhjCusBankSignBank) calc() {
  1178. }
  1179. func (r *QhjCusBankSignBank) buildSql() string {
  1180. var sqlId utils.SQLVal = "select * from bank_cusbanksignbank"
  1181. return sqlId.String()
  1182. }
  1183. // GetData 获取托管银行签约关系
  1184. func (r *QhjCusBankSignBank) GetData() ([]QhjCusBankSignBank, error) {
  1185. sData := make([]QhjCusBankSignBank, 0)
  1186. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1187. for i := range sData {
  1188. sData[i].calc()
  1189. }
  1190. return sData, err
  1191. }
  1192. // GetDataEx 获取托管银行签约关系
  1193. func (r *QhjCusBankSignBank) GetDataEx() (interface{}, error) {
  1194. return r.GetData()
  1195. }
  1196. // QhjCusBankSignBankEx 托管银行签约银行详细
  1197. type QhjCusBankSignBankEx struct {
  1198. QhjCusBankInfo
  1199. Banklst []QhjBankInfo // 银行列表
  1200. }
  1201. // GetDataEx 获取托管银行签约银行详细
  1202. func (r *QhjCusBankSignBankEx) GetDataEx() (interface{}, error) {
  1203. sData := make([]QhjCusBankSignBankEx, 0)
  1204. a := QhjCusBankSignBank{}
  1205. relateData, _ := a.GetData()
  1206. if len(relateData) == 0 {
  1207. return sData, nil
  1208. }
  1209. b := QhjCusBankInfo{}
  1210. bData, _ := b.GetData()
  1211. c := QhjBankInfo{}
  1212. cData, _ := c.GetData()
  1213. for _, vb := range bData {
  1214. // 托管银行
  1215. v := QhjCusBankSignBankEx{QhjCusBankInfo: vb, Banklst: make([]QhjBankInfo, 0)}
  1216. for _, vr := range relateData {
  1217. // 托管关系
  1218. if vb.CUSBANKID == vr.CUSBANKID {
  1219. for _, vc := range cData {
  1220. if vc.BANKID == vr.BANKID {
  1221. v.Banklst = append(v.Banklst, vc)
  1222. }
  1223. }
  1224. }
  1225. }
  1226. if len(v.Banklst) > 0 {
  1227. sData = append(sData, v)
  1228. }
  1229. }
  1230. return sData, nil
  1231. }
  1232. // QhjSiteColumnDetail 资讯
  1233. type QhjSiteColumnDetail struct {
  1234. ID int64 `json:"id" xorm:"ID"` // ID(SEQ_SITE_COLUMNDETAIL)
  1235. COLUMNID int64 `json:"columnid" xorm:"COLUMNID"` // 所属栏目
  1236. USERID int64 `json:"userid" xorm:"USERID"` // 用户ID(默认为0, 核心为为机构用户ID)
  1237. TITLE string `json:"title" xorm:"TITLE"` // 标题
  1238. COVERIMAGE string `json:"coverimage" xorm:"COVERIMAGE"` // 封面图片
  1239. AUTHOR string `json:"author" xorm:"AUTHOR"` // 作者
  1240. BRIEF string `json:"brief" xorm:"BRIEF"` // 简介
  1241. CONTEXT string `json:"context" xorm:"CONTEXT"` // 内容
  1242. STATUS int32 `json:"status" xorm:"STATUS"` // 状态 - 1:暂存 10:待审核 20:审核通过 30:审核拒绝
  1243. ISTOP int32 `json:"istop" xorm:"ISTOP"` // 是否置顶 - 0:不置 1:置顶
  1244. HITS int64 `json:"hits" xorm:"HITS"` // 点击数
  1245. PUBLISHDATE string `json:"publishdate" xorm:"PUBLISHDATE"` // 发布日期
  1246. CREAEDATE string `json:"creaedate" xorm:"CREAEDATE"` // 创建时间
  1247. CREATORID int64 `json:"creatorid" xorm:"CREATORID"` // 创建人
  1248. UPDATEDATE string `json:"updatedate" xorm:"UPDATEDATE"` // 修改时间
  1249. MODIFIERID int64 `json:"modifierid" xorm:"MODIFIERID"` // 操作人
  1250. ISSHOW int32 `json:"isshow" xorm:"ISSHOW"` // 是否展示 - 0:不展示 1:展示
  1251. USERNAME string `json:"username"` // 用户名称
  1252. }
  1253. func (r *QhjSiteColumnDetail) calc() {
  1254. if r.USERID > 0 {
  1255. r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
  1256. }
  1257. }
  1258. func (r *QhjSiteColumnDetail) buildSql() string {
  1259. var sqlId utils.SQLVal = "SELECT t.ID," +
  1260. " t.COLUMNID," +
  1261. " t.USERID," +
  1262. " t.TITLE," +
  1263. " t.COVERIMAGE," +
  1264. " t.AUTHOR," +
  1265. " t.BRIEF," +
  1266. " to_char(t.CONTEXT) CONTEXT," +
  1267. " t.STATUS," +
  1268. " t.ISTOP," +
  1269. " t.HITS," +
  1270. " to_char(t.PUBLISHDATE, 'yyyy-mm-dd hh24:mi:ss') PUBLISHDATE," +
  1271. " to_char(t.CREAEDATE, 'yyyy-mm-dd hh24:mi:ss') CREAEDATE," +
  1272. " t.CREATORID," +
  1273. " to_char(t.UPDATEDATE, 'yyyy-mm-dd hh24:mi:ss') UPDATEDATE," +
  1274. " t.MODIFIERID," +
  1275. " t.ISSHOW" +
  1276. " FROM SITE_COLUMNDETAIL t" +
  1277. " WHERE 1 = 1"
  1278. sqlId.And("t.USERID", r.USERID)
  1279. return sqlId.String()
  1280. }
  1281. // GetDataEx 获取资讯
  1282. func (r *QhjSiteColumnDetail) GetDataEx() (interface{}, error) {
  1283. sData := make([]QhjSiteColumnDetail, 0)
  1284. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1285. for i := range sData {
  1286. sData[i].calc()
  1287. }
  1288. return sData, err
  1289. }
  1290. // QhjAccountOutInApply 充值提现(出入金)
  1291. type QhjAccountOutInApply struct {
  1292. EXECUTETYPE int32 `json:"executetype" xorm:"EXECUTETYPE"` // 申请类型 - 1:出金 2:入金 3: 单边账调整:入金; 4:单边账调整:出金 5:外部母账户调整:入金 6:外部母账户调整:出金 7:外部子账户:入金 8:外部子账户:出金
  1293. AMOUNT float64 `json:"amount" xorm:"AMOUNT"` // 金额
  1294. CURRENCY string `json:"currency" xorm:"CURRENCY"` // 币种
  1295. CHARGE float64 `json:"charge" xorm:"CHARGE"` // 手续费
  1296. ACCOUNTPWD string `json:"accountpwd" xorm:"ACCOUNTPWD"` // 资金密码
  1297. UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间(申请时间)
  1298. BANKID string `json:"bankid" xorm:"BANKID"` // 银行编号
  1299. BRANCHBANKID string `json:"branchbankid" xorm:"BRANCHBANKID"` // 银行支行号
  1300. BRANCHBANKNAME string `json:"branchbankname" xorm:"BRANCHBANKNAME"` // 银行支行名称
  1301. BANKACCOUNTNO string `json:"bankaccountno" xorm:"BANKACCOUNTNO"` // 银行卡号
  1302. BANKACCOUNTNAME string `json:"bankaccountname" xorm:"BANKACCOUNTNAME"` // 银行账户名
  1303. EXTENDINFO string `json:"extendinfo" xorm:"EXTENDINFO"` // 扩展信息
  1304. AUDITID int64 `json:"auditid" xorm:"AUDITID"` // 审核人
  1305. AUDITTIME string `json:"audittime" xorm:"AUDITTIME"` // 审核时间
  1306. REMARK string `json:"remark" xorm:"REMARK"` // 备注
  1307. NETADDR string `json:"netaddr" xorm:"NETADDR"` // 调转网址
  1308. ACCOUNTTICKET string `json:"accountticket" xorm:"ACCOUNTTICKET"` // 最新账户服务流水号
  1309. CHECKERRORFLAG int32 `json:"checkerrorflag" xorm:"CHECKERRORFLAG"` // 对账差错标志 - 1:为单边账;其它为正常出入金
  1310. REMARK2 string `json:"remark2" xorm:"REMARK2"` // 备注(失败原因)
  1311. REAUDITID int64 `json:"reauditid" xorm:"REAUDITID"` // 复审人
  1312. REAUDITTIME string `json:"reaudittime" xorm:"REAUDITTIME"` // 复审时间
  1313. REAUDITREMARK string `json:"reauditremark" xorm:"REAUDITREMARK"` // 复审备注
  1314. APPLYREMARK string `json:"applyremark" xorm:"APPLYREMARK"` // 申请备注
  1315. RELATEDORDERID string `json:"relatedorderid" xorm:"RELATEDORDERID"` // 三方关联ID
  1316. CAPAMOUNTOUT float64 `json:"capamountout" xorm:"CAPAMOUNTOUT"` // 出金(劣后本金) - 外部子账户
  1317. INFAMOUNT float64 `json:"infamount" xorm:"INFAMOUNT"` // 劣后金额(自有)
  1318. PRIAMOUNT float64 `json:"priamount" xorm:"PRIAMOUNT"` // 优先金额(授信)
  1319. BANK_APPLY_TICKET string `json:"bank_apply_ticket" xorm:"BANK_APPLY_TICKET"` // 银行申请流水
  1320. CERTIFICATEPHOTOURL string `json:"certificatephotourl" xorm:"CERTIFICATEPHOTOURL"` // 凭证地址
  1321. SOUCREAMOUNT float64 `json:"soucreamount" xorm:"SOUCREAMOUNT"` // 原始出入金金额
  1322. SOUCRECURRENCYID int64 `json:"soucrecurrencyid" xorm:"SOUCRECURRENCYID"` // 原始出入金币种
  1323. ACCOUNTCODE string `json:"accountcode" xorm:"ACCOUNTCODE"` // 资金账号
  1324. CUSBANKID string `json:"cusbankid" xorm:"CUSBANKID"` // 托管银行编号
  1325. TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
  1326. EXCHTICKET string `json:"exchticket" xorm:"EXCHTICKET"` // 银行服务流水号
  1327. EXTOPERATEID int64 `json:"extoperateid" xorm:"EXTOPERATEID"` // 交易服务流水号
  1328. BANKTICKET string `json:"bankticket" xorm:"BANKTICKET"` // 银行流水
  1329. 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: 复审通过,账户冻结金额检查中;
  1330. USERID int64 `json:"userid" xorm:"'USERID'"` // 用户id
  1331. LOGINCODE string `json:"logincode" xorm:"'LOGINCODE'"` // 登录账号(账号)
  1332. USERINFOTYPE int32 `json:"userinfotype" xorm:"'USERINFOTYPE'"` // 账户类型 1-个人 2-企业
  1333. ACCOUNTNAME string `json:"accountname" xorm:"'ACCOUNTNAME'"` // 用户名称(名称)
  1334. BeginDate string `json:"-"` // 开始日期(yyyymmdd)
  1335. EndDate string `json:"-"` // 结束日期(yyyymmdd)
  1336. FilterName string `json:"-"` // 账户(模糊匹配)
  1337. }
  1338. func (r *QhjAccountOutInApply) calc() {
  1339. }
  1340. func (r *QhjAccountOutInApply) buildSql() string {
  1341. var sqlId utils.SQLVal = "with tmp as(select t.userid, wm_concat(t.logincode) logincode from loginaccount t group by t.userid)" +
  1342. "SELECT t.EXECUTETYPE," +
  1343. " t.AMOUNT," +
  1344. " t.CURRENCY," +
  1345. " t.CHARGE," +
  1346. " t.ACCOUNTPWD," +
  1347. " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
  1348. " t.BANKID," +
  1349. " t.BRANCHBANKID," +
  1350. " t.BRANCHBANKNAME," +
  1351. " t.BANKACCOUNTNO," +
  1352. " t.BANKACCOUNTNAME," +
  1353. " t.EXTENDINFO," +
  1354. " t.AUDITID," +
  1355. " to_char(t.AUDITTIME, 'yyyy-mm-dd hh24:mi:ss') AUDITTIME," +
  1356. " t.REMARK," +
  1357. " t.NETADDR," +
  1358. " t.ACCOUNTTICKET," +
  1359. " t.CHECKERRORFLAG," +
  1360. " t.REMARK2," +
  1361. " t.REAUDITID," +
  1362. " to_char(t.REAUDITTIME, 'yyyy-mm-dd hh24:mi:ss') REAUDITTIME," +
  1363. " t.REAUDITREMARK," +
  1364. " t.APPLYREMARK," +
  1365. " t.RELATEDORDERID," +
  1366. " t.CAPAMOUNTOUT," +
  1367. " t.INFAMOUNT," +
  1368. " t.PRIAMOUNT," +
  1369. " t.BANK_APPLY_TICKET," +
  1370. " to_char(t.CERTIFICATEPHOTOURL) CERTIFICATEPHOTOURL," +
  1371. " t.SOUCREAMOUNT," +
  1372. " t.SOUCRECURRENCYID," +
  1373. " t.ACCOUNTCODE," +
  1374. " t.CUSBANKID," +
  1375. " t.TRADEDATE," +
  1376. " t.EXCHTICKET," +
  1377. " t.EXTOPERATEID," +
  1378. " t.BANKTICKET," +
  1379. " t.APPLYSTATUS," +
  1380. " ta.userid," +
  1381. " u.accountname," +
  1382. " ui.userinfotype," +
  1383. " tmp.logincode" +
  1384. " FROM BANK_ACCOUNTOUTINAPPLY t" +
  1385. " INNER JOIN TAACCOUNT ta on t.accountcode=to_char(ta.accountid)" +
  1386. " INNER JOIN USERACCOUNT u on ta.relateduserid=u.userid" +
  1387. " INNER JOIN USERINFO ui on u.userid=ui.userid" +
  1388. " LEFT JOIN tmp on u.userid=tmp.userid" +
  1389. " WHERE 1 = 1"
  1390. if len(r.BeginDate) > 0 {
  1391. sqlId.Join(fmt.Sprintf(" and t.UPDATETIME >= to_date(%v,'yyyymmdd')", r.BeginDate))
  1392. }
  1393. if len(r.EndDate) > 0 {
  1394. sqlId.Join(fmt.Sprintf(" and t.UPDATETIME <= to_date(%v,'yyyymmdd')", r.EndDate))
  1395. }
  1396. if len(r.FilterName) > 0 {
  1397. sqlId.Join(fmt.Sprintf(" and (tmp.logincode like '%%%v%%' or u.accountname like '%%%v%%')", r.FilterName, r.FilterName))
  1398. }
  1399. return sqlId.String()
  1400. }
  1401. // GetDataEx 获取充值提现(出入金)
  1402. func (r *QhjAccountOutInApply) GetDataEx() (interface{}, error) {
  1403. sData := make([]QhjAccountOutInApply, 0)
  1404. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1405. for i := range sData {
  1406. sData[i].calc()
  1407. }
  1408. return sData, err
  1409. }
  1410. type DBINT64 int64
  1411. func (r *DBINT64) FromDB(bytes []byte) error {
  1412. d, err := strconv.ParseInt(string(bytes), 10, 64)
  1413. if err == nil {
  1414. *r = DBINT64(d)
  1415. }
  1416. return err
  1417. }
  1418. func (r *DBINT64) ToDB() ([]byte, error) {
  1419. d := strconv.FormatInt(int64(*r), 10)
  1420. return []byte(d), nil
  1421. }
  1422. // QhjPayOrder 待付款单据
  1423. type QhjPayOrder struct {
  1424. OPERATETYPE int32 `json:"operatetype" xorm:"OPERATETYPE"` // 买委托操作类型 - 1:正常下单 16:融资买入
  1425. TRADEID string `json:"tradeid" xorm:"TRADEID"` // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
  1426. TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
  1427. MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
  1428. GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID
  1429. BUYORDERID string `json:"buyorderid" xorm:"BUYORDERID"` // 买方委托单号
  1430. BUYACCOUNTID int64 `json:"buyaccountid" xorm:"BUYACCOUNTID"` // 买方账号ID[报价币种]
  1431. SELLORDERID string `json:"sellorderid" xorm:"SELLORDERID"` // 卖方委托单号
  1432. SELLACCOUNTID int64 `json:"sellaccountid" xorm:"SELLACCOUNTID"` // 卖方账号ID[报价币种]
  1433. TRADEAMOUNT float64 `json:"tradeamount" xorm:"TRADEAMOUNT"` // 成交金额(优惠后金额)
  1434. TRADECHARGE float64 `json:"tradecharge" xorm:"TRADECHARGE"` // 成交手续费(买方)
  1435. PAYFLAG int32 `json:"payflag" xorm:"PAYFLAG"` // 付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期 6:预售终止
  1436. CREATETIME string `json:"createtime" xorm:"CREATETIME"` // 创建时间
  1437. PAYTIME string `json:"paytime" xorm:"PAYTIME"` // 付款时间
  1438. PAYLIMITEDTIME string `json:"paylimitedtime" xorm:"PAYLIMITEDTIME"` // 支付期限
  1439. OFFAMOUNT float64 `json:"offamount" xorm:"OFFAMOUNT"` // 优惠金额
  1440. TRADEPRICE float64 `json:"tradeprice" xorm:"TRADEPRICE"` // 成交价格
  1441. TRADEQTY int32 `json:"tradeqty" xorm:"TRADEQTY"` // 成交数量
  1442. PAYAMOUNT float64 `json:"payamount" xorm:"PAYAMOUNT"` // 支付金额=TradeAmount + TradeCharge
  1443. GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码
  1444. GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称
  1445. DECIMALPLACE int32 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 商品报价小数位
  1446. }
  1447. func (r *QhjPayOrder) calc() {
  1448. }
  1449. func (r *QhjPayOrder) buildSql() string {
  1450. var sqlId utils.SQLVal = "SELECT t.OPERATETYPE," +
  1451. " to_char(t.TRADEID) TRADEID," +
  1452. " t.TRADEDATE," +
  1453. " t.MARKETID," +
  1454. " t.GOODSID," +
  1455. " to_char(t.BUYORDERID) BUYORDERID," +
  1456. " t.BUYACCOUNTID," +
  1457. " to_char(t.SELLORDERID) SELLORDERID," +
  1458. " t.SELLACCOUNTID," +
  1459. " t.TRADEAMOUNT," +
  1460. " t.TRADECHARGE," +
  1461. " t.PAYFLAG," +
  1462. " to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
  1463. " to_char(t.PAYTIME, 'yyyy-mm-dd hh24:mi:ss') PAYTIME," +
  1464. " to_char(t.PAYLIMITEDTIME, 'yyyy-mm-dd hh24:mi:ss') PAYLIMITEDTIME," +
  1465. " t.OFFAMOUNT," +
  1466. " t.TRADEPRICE," +
  1467. " t.TRADEQTY," +
  1468. " t.PAYAMOUNT," +
  1469. " g.goodscode," +
  1470. " g.decimalplace," +
  1471. " g.goodsname" +
  1472. " FROM TRADE_PAYORDER t" +
  1473. " LEFT JOIN GOODS g on t.goodsid=g.goodsid" +
  1474. " WHERE 1 = 1"
  1475. sqlId.AndEx("t.BUYACCOUNTID", r.BUYACCOUNTID, r.BUYACCOUNTID > 0)
  1476. sqlId.AndEx("t.TRADEID", r.TRADEID, len(r.TRADEID) > 0)
  1477. sqlId.AndEx("t.PAYFLAG", r.PAYFLAG, r.PAYFLAG > 0)
  1478. return sqlId.String()
  1479. }
  1480. // GetDataEx 获取待付款单据
  1481. func (r *QhjPayOrder) GetDataEx() (interface{}, error) {
  1482. sData := make([]QhjPayOrder, 0)
  1483. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1484. for i := range sData {
  1485. sData[i].calc()
  1486. }
  1487. return sData, err
  1488. }
  1489. // Qhjgoodsex 交易商品扩展表(千海金)
  1490. type Qhjgoodsex struct {
  1491. Goodsid int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID(自增ID SEQ_GOODS)
  1492. Minamount float64 `json:"minamount" xorm:"MINAMOUNT"` // 最小购买金额
  1493. Canfinance int32 `json:"canfinance" xorm:"CANFINANCE"` // 是否支持融资 - 0:不支持 1:支持【69:铂金宝】
  1494. Canregularlybuy int32 `json:"canregularlybuy" xorm:"CANREGULARLYBUY"` // 是否支持定投 - 0:不支持 1:支持【69:铂金宝】
  1495. Regularlybuyminqty float64 `json:"regularlybuyminqty" xorm:"REGULARLYBUYMINQTY"` // 定投最小数量
  1496. Regularlybuyminamount float64 `json:"regularlybuyminamount" xorm:"REGULARLYBUYMINAMOUNT"` // 定投最小金额
  1497. Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"DELIVERYGOODSID"` // 现货品种ID
  1498. Wrstandardid int32 `json:"wrstandardid" xorm:"WRSTANDARDID"` // 现货商品ID
  1499. Spotgoodsbrandid int32 `json:"spotgoodsbrandid" xorm:"SPOTGOODSBRANDID"` // 现货品牌ID - 存“DGFactoryItem”表"DGFactoryItemID"
  1500. Defaulttradeuserid int64 `json:"defaulttradeuserid" xorm:"DEFAULTTRADEUSERID"` // 默认交易用户ID
  1501. }
  1502. func (r *Qhjgoodsex) calc() {
  1503. }
  1504. func (r *Qhjgoodsex) buildSql() string {
  1505. var sqlId utils.SQLVal = "SELECT t.GOODSID," +
  1506. " t.MINAMOUNT," +
  1507. " t.CANFINANCE," +
  1508. " t.CANREGULARLYBUY," +
  1509. " t.REGULARLYBUYMINQTY," +
  1510. " t.REGULARLYBUYMINAMOUNT," +
  1511. " t.DELIVERYGOODSID," +
  1512. " t.WRSTANDARDID," +
  1513. " t.SPOTGOODSBRANDID," +
  1514. " t.DEFAULTTRADEUSERID" +
  1515. " FROM QHJ_GOODSEX t" +
  1516. " WHERE 1 = 1"
  1517. sqlId.AndEx("t.GOODSID", r.Goodsid, r.Goodsid > 0)
  1518. return sqlId.String()
  1519. }
  1520. // GetDataEx 获取交易商品扩展表(千海金)
  1521. func (r *Qhjgoodsex) GetDataEx() (interface{}, error) {
  1522. sData := make([]Qhjgoodsex, 0)
  1523. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1524. for i := range sData {
  1525. sData[i].calc()
  1526. }
  1527. return sData, err
  1528. }
  1529. // QhjParentAreaList 所属机构列表
  1530. type QhjParentAreaList struct {
  1531. USERID int64 `json:"userid" xorm:"USERID"` // 用户ID
  1532. USERTYPE int32 `json:"usertype" xorm:"USERTYPE"` // 账户类型 - 1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 7:企业成员(云平台)
  1533. ACCOUNTNAME string `json:"accountname" xorm:"ACCOUNTNAME"` // 账户名称(机构名称)
  1534. }
  1535. func (r *QhjParentAreaList) calc() {
  1536. }
  1537. func (r *QhjParentAreaList) buildSql() string {
  1538. var sqlId utils.SQLVal = "select t.userid, t.accountname, t.usertype" +
  1539. " from useraccount t" +
  1540. " where 1 = 1" +
  1541. " and t.accountstatus = 4" +
  1542. " and t.usertype = 2" +
  1543. " and t.rootuserid = %v" +
  1544. " or t.userid = %v"
  1545. sqlId.FormatParam(r.USERID, r.USERID)
  1546. return sqlId.String()
  1547. }
  1548. // GetDataEx 获取所属机构列表
  1549. func (r *QhjParentAreaList) GetDataEx() (interface{}, error) {
  1550. sData := make([]QhjParentAreaList, 0)
  1551. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  1552. for i := range sData {
  1553. sData[i].calc()
  1554. }
  1555. return sData, err
  1556. }