qhj.go 75 KB

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