qhj.go 86 KB

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