|
|
@@ -1,14 +1,20 @@
|
|
|
package cn.muchinfo.rma.business.account.adapter
|
|
|
|
|
|
+import cn.muchinfo.rma.BuildConfig
|
|
|
import cn.muchinfo.rma.business.global.MessageHeadModel
|
|
|
+import cn.muchinfo.rma.global.ErrorMessageUtils
|
|
|
import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
import cn.muchinfo.rma.netcore.crypto.SHA256Encrypt
|
|
|
import cn.muchinfo.rma.netcore.packet.Packet50
|
|
|
import cn.muchinfo.rma.protobuf.funcode.FunCode
|
|
|
+import cn.muchinfo.rma.protobuf.protoclasses.ErmcpMI1
|
|
|
+import cn.muchinfo.rma.protobuf.protoclasses.ManageServiceMI2
|
|
|
import cn.muchinfo.rma.protobuf.protoclasses.SystemMI1
|
|
|
+import com.google.protobuf.ByteString
|
|
|
import java.io.ByteArrayOutputStream
|
|
|
import java.lang.Exception
|
|
|
import java.util.*
|
|
|
+import kotlin.math.log
|
|
|
|
|
|
/**
|
|
|
* 账户相关装解箱
|
|
|
@@ -19,7 +25,7 @@ class AccountAdapter {
|
|
|
* 构建登录请求报文
|
|
|
* @return Packet50 登录请求报文
|
|
|
*/
|
|
|
- fun buildLoginReqPacket(loginID: String, password: String): Packet50 {
|
|
|
+ fun buildLoginReqPacket(loginID: String, password: String,byteArray: ByteArray): Packet50 {
|
|
|
val funCode = FunCode.LoginReq
|
|
|
|
|
|
val builder = SystemMI1.LoginReq.newBuilder()
|
|
|
@@ -29,8 +35,10 @@ class AccountAdapter {
|
|
|
encrypt.getEncryptString(encrypt.encrypt(String.format("%s%s", loginID, password)))
|
|
|
.toLowerCase(Locale.ROOT)
|
|
|
builder.loginType = 0
|
|
|
+ builder.clientSystemInfo = ByteString.copyFrom(byteArray)
|
|
|
+ builder.clientAppID = "muchinfo_mtpclient_5.0.1"
|
|
|
builder.clientType = 3
|
|
|
- builder.version = "5.0.0.0"
|
|
|
+ builder.version = BuildConfig.VERSION_NAME
|
|
|
val uuid = UUID.randomUUID()
|
|
|
builder.guid = uuid.toString()
|
|
|
// deviceID主要用于标记设备唯一标识,由于无法获取MAC或IP信息,故使用UUID
|
|
|
@@ -194,5 +202,524 @@ class AccountAdapter {
|
|
|
Pair(false, Error("装箱失败"))
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户新增修改请求报文装箱
|
|
|
+ optional MessageHead Header = 1; // MessageHead
|
|
|
+ optional uint64 marketid = 2; // uint64 内部市场ID(HedgeOutMainConfig)
|
|
|
+ optional string hedgeaccountcode = 3; // string 对冲账号ID(HedgeOutMainConfig)
|
|
|
+ optional int32 connectflag = 4; // int32 是否联接外部交易 - 0:不连接 1:连接(HedgeOutMainConfig)
|
|
|
+ optional string hedgeaccountpwd = 5; // string 对冲账号密码(HedgeOutMainConfig)
|
|
|
+ optional string appid = 6; // string AppID(HedgeOutMainConfig)
|
|
|
+ optional string authcode = 7; // string 授权码(HedgeOutMainConfig)
|
|
|
+ optional uint64 limitnumber = 8; // uint64 挂单笔数限额默认0(HedgeOutMainConfig)
|
|
|
+ optional int32 status = 9; // int32 渠道账号状态 1-可买入可卖出 2-可卖出不可买入默认1(HedgeOutMainConfig)
|
|
|
+ optional string accountname = 10; // string 账户名称accountname1(Taaccount)
|
|
|
+ optional uint64 accountid = 11; // uint64 资金账户ID(Taaccount)
|
|
|
+ optional int32 taaccounttype = 12; // int32 账号类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号(Taaccount)
|
|
|
+ optional int32 currencyid = 13; // int32 货币ID默认为1(Taaccount)
|
|
|
+ optional double outthreshold = 14; // double 出金阈值默认为0(Taaccount)
|
|
|
+ optional int32 ismain = 15; // int32 是否母账号 0:不是母账户 1:是母账户(Taaccount)
|
|
|
+ optional uint64 parentaccountid = 16; // uint64 所属根账号(Taaccount)
|
|
|
+ optional uint64 relateduserid = 17; // uint64 关联用户(Taaccount)
|
|
|
+ optional uint64 fromaccountid = 18; // uint64 所属上级账户(Taaccount)
|
|
|
+ optional uint64 trademargintmpid = 19; // uint64 保证金模板id(TAACCOUNTCONFIG)
|
|
|
+ optional uint64 tradefeetmpid = 20; // uint64 手续费模板ID(TAACCOUNTCONFIG)
|
|
|
+ optional uint64 maxsubaccouts = 21; // uint64 最大子账户数[最大99999][外部母账户用 默认0(TAACCOUNTCONFIG)
|
|
|
+ optional uint64 fcid = 22; // uint64 期货公司
|
|
|
+ optional uint64 creatorid = 23; // uint64 创建人
|
|
|
+ optional uint64 modifierid = 24; // uint64 修改人
|
|
|
+ optional uint64 areauserid = 25; // uint64 机构用户ID
|
|
|
+ */
|
|
|
+ fun getHedgeOutMainConfigReqInfo(
|
|
|
+ hedgeaccountcode : String = "",
|
|
|
+ hedgeaccountpwd : String = "",
|
|
|
+ limitnumber : Long = 0,
|
|
|
+ status : Int = 1,
|
|
|
+ accountname : String = "",
|
|
|
+ currencyid : Int = 1,
|
|
|
+ outthreshold : Double = 0.0,
|
|
|
+ ismain : Int,
|
|
|
+ parentaccountid : Long = 0,
|
|
|
+ fromaccountid : Long = 0,
|
|
|
+ trademargintmpid : Long = 0,
|
|
|
+ tradefeetmpid : Long = 0,
|
|
|
+ maxsubaccouts : Long = 0,
|
|
|
+ fcid : Long = 0
|
|
|
+ ) : Packet50{
|
|
|
+ val builder = ManageServiceMI2.HedgeOutMainConfigReq.newBuilder()
|
|
|
+ val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
|
+ // FIXME: - 250000000005
|
|
|
+ builder.setHeader(
|
|
|
+ MessageHeadModel.getHead(
|
|
|
+ FunCode.HedgeOutMainConfigReq,
|
|
|
+ loginInfo.userID,
|
|
|
+ GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+ 0,
|
|
|
+ 18
|
|
|
+ )
|
|
|
+ )
|
|
|
+ if (hedgeaccountcode.isNotEmpty()){
|
|
|
+ builder.hedgeaccountcode = hedgeaccountcode
|
|
|
+ }
|
|
|
+ if (hedgeaccountpwd.isNotEmpty()){
|
|
|
+ builder.hedgeaccountpwd = hedgeaccountpwd
|
|
|
+ }
|
|
|
+// if (appid.isNotEmpty()){
|
|
|
+// builder.appid = appid
|
|
|
+// }
|
|
|
+// if (authcode.isNotEmpty()){
|
|
|
+// builder.authcode = authcode
|
|
|
+// }
|
|
|
+ builder.limitnumber = limitnumber
|
|
|
+ builder.status = status
|
|
|
+ builder.currencyid = currencyid
|
|
|
+ builder.outthreshold = outthreshold
|
|
|
+ if (accountname.isNotEmpty()){
|
|
|
+ builder.accountname = accountname
|
|
|
+ }
|
|
|
+ builder.ismain = ismain
|
|
|
+ if (parentaccountid != 0L){
|
|
|
+ builder.parentaccountid = parentaccountid
|
|
|
+ }
|
|
|
+ builder.relateduserid = loginInfo.userID.toLong()
|
|
|
+ if (tradefeetmpid != 0L){
|
|
|
+ builder.tradefeetmpid = tradefeetmpid
|
|
|
+ }
|
|
|
+ builder.maxsubaccouts = maxsubaccouts
|
|
|
+ if (fromaccountid != 0L){
|
|
|
+ builder.fromaccountid = fromaccountid
|
|
|
+ }
|
|
|
+ if (trademargintmpid != 0L){
|
|
|
+ builder.trademargintmpid = trademargintmpid
|
|
|
+ }
|
|
|
+ if (fcid != 0L){
|
|
|
+ builder.fcid = fcid
|
|
|
+ }
|
|
|
+ val arrayOutputStream = ByteArrayOutputStream()
|
|
|
+ builder.build().writeTo(arrayOutputStream)
|
|
|
+ return Packet50(FunCode.HedgeOutMainConfigReq, arrayOutputStream.toByteArray())
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户新增修改报文解析
|
|
|
+ * @param packet50 Packet50
|
|
|
+ * @return Triple<Boolean, Error?, ManageServiceMI2.HedgeOutMainConfigRsp?>
|
|
|
+ */
|
|
|
+ fun analysisHedgeOutMainConfigRsq(packet50: Packet50): Triple<Boolean, Error?, ManageServiceMI2.HedgeOutMainConfigRsp?> {
|
|
|
+ return try {
|
|
|
+ val loginRsp = ManageServiceMI2.HedgeOutMainConfigRsp.parseFrom(packet50.content)
|
|
|
+ if (loginRsp.retCode == 0) {
|
|
|
+ // 操作成功
|
|
|
+ Triple(true, null, loginRsp)
|
|
|
+ } else {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error("装箱失败"), null)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户设置请求报文装箱
|
|
|
+ optional uint64 BizGroupID = 2; // uint64 分组ID(修改/删除必填)
|
|
|
+ optional int32 BizType = 3; // int32 业务类型 - 1:套保 2:套利
|
|
|
+ optional string Remark = 4; // string 新增/修改备注
|
|
|
+ optional int32 ApplySrc = 5; // int32 新增/修改来源 - 1:管理端 2:终端
|
|
|
+ optional uint64 ApplyId = 6; // uint64 新增/修改人
|
|
|
+ repeated ManageServiceMI2.ErmcpBizGroupSpotGoods SpotGoods = 7; // ErmcpBizGroupSpotGoods 期货账户分组商品
|
|
|
+ repeated ManageServiceMI2.ErmcpBizGroupTAAccount TAAccount = 8; // ErmcpBizGroupTAAccount 期货账户分组账户
|
|
|
+ optional int32 OptType = 9; // int32 操作类型 - 1:新增 2:修改 3:删除
|
|
|
+ optional uint64 AreaUserID = 10; // uint64 所属机构
|
|
|
+ */
|
|
|
+ fun getErmcpBizGroupReqInfo(
|
|
|
+ BizGroupID : Long = 0,
|
|
|
+ BizType : Int,
|
|
|
+ Remark : String = "",
|
|
|
+ ApplySrc : Int = 2,
|
|
|
+ SpotGoods : List<ManageServiceMI2.ErmcpBizGroupSpotGoods>,
|
|
|
+ TAAccount : List<ManageServiceMI2.ErmcpBizGroupTAAccount>,
|
|
|
+ OptType : Int = 0,
|
|
|
+ AreaUserID : Long = 0
|
|
|
+ ) : Packet50{
|
|
|
+ val builder = ManageServiceMI2.ErmcpBizGroupReq.newBuilder()
|
|
|
+ val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
|
+
|
|
|
+ builder.setHeader(
|
|
|
+ MessageHeadModel.getHead(
|
|
|
+ FunCode.ErmcpBizGroupReq,
|
|
|
+ loginInfo.userID,
|
|
|
+ GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+ 0,
|
|
|
+ 18
|
|
|
+ )
|
|
|
+ )
|
|
|
+ if (BizGroupID != 0L){
|
|
|
+ builder.bizGroupID = BizGroupID
|
|
|
+ }
|
|
|
+ builder.bizType = BizType
|
|
|
+ builder.remark = Remark
|
|
|
+ builder.applySrc = ApplySrc
|
|
|
+ builder.applyId = loginInfo.loginID
|
|
|
+ builder.addAllSpotGoods(SpotGoods)
|
|
|
+ builder.addAllTAAccount(TAAccount)
|
|
|
+ builder.optType = OptType
|
|
|
+ builder.areaUserID = AreaUserID
|
|
|
+
|
|
|
+ val arrayOutputStream = ByteArrayOutputStream()
|
|
|
+ builder.build().writeTo(arrayOutputStream)
|
|
|
+ return Packet50(FunCode.ErmcpBizGroupReq, arrayOutputStream.toByteArray())
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户设置请求报文解析
|
|
|
+ * @param packet50 Packet50
|
|
|
+ * @return Triple<Boolean, Error?, ManageServiceMI2.HedgeOutMainConfigRsp?>
|
|
|
+ */
|
|
|
+ fun analysisErmcpBizGroupRsq(packet50: Packet50): Triple<Boolean, Error?, ManageServiceMI2.ErmcpBizGroupRsp?> {
|
|
|
+ return try {
|
|
|
+ val loginRsp = ManageServiceMI2.ErmcpBizGroupRsp.parseFrom(packet50.content)
|
|
|
+ if (loginRsp.retCode == 0) {
|
|
|
+ // 操作成功
|
|
|
+ Triple(true, null, loginRsp)
|
|
|
+ } else {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error("装箱失败"), null)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 角色设置操作请求报文装箱
|
|
|
+ * @param autoid Long 角色ID(新增成功接口返回的autoid,默认角色除外)
|
|
|
+ * @param operatetype Int 操作类型-1:新增 2:修改 3:删除(默认角色不能删除)
|
|
|
+ * @param areauserid Long 所属机构(当前登录userid 必填)
|
|
|
+ * @param modifierid Long 修改人ID(当前登录loginid 必填)
|
|
|
+ * @param modifyremark String 修改备注
|
|
|
+ * @param rolename String 角色名称(新增修改必填)
|
|
|
+ * @param memberfuncmenus List<MemberFuncMenu> 机构菜单(新增修改必填)
|
|
|
+ */
|
|
|
+ fun getManagerRoleOperateReqInfo(
|
|
|
+ autoid : Long = 0,
|
|
|
+ operatetype : Int,
|
|
|
+ modifyremark : String = "",
|
|
|
+ rolename : String,
|
|
|
+ memberfuncmenus : List<ManageServiceMI2.MemberFuncMenu>
|
|
|
+ ) : Packet50{
|
|
|
+ val builder = ManageServiceMI2.ManagerRoleOperateReq.newBuilder()
|
|
|
+ val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
|
+
|
|
|
+ builder.setHeader(
|
|
|
+ MessageHeadModel.getHead(
|
|
|
+ FunCode.ManagerRoleOperateReq,
|
|
|
+ loginInfo.userID,
|
|
|
+ GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+ 0,
|
|
|
+ 18
|
|
|
+ )
|
|
|
+ )
|
|
|
+ if (autoid != 0L){
|
|
|
+ builder.autoid = autoid
|
|
|
+ }
|
|
|
+ builder.operatetype = operatetype
|
|
|
+ builder.areauserid = loginInfo.userID.toLong()
|
|
|
+ builder.modifierid = loginInfo.loginID
|
|
|
+ builder.modifyremark = modifyremark
|
|
|
+ builder.rolename = rolename
|
|
|
+ builder.addAllMemberfuncmenus(memberfuncmenus)
|
|
|
+
|
|
|
+ val arrayOutputStream = ByteArrayOutputStream()
|
|
|
+ builder.build().writeTo(arrayOutputStream)
|
|
|
+ return Packet50(FunCode.ManagerRoleOperateReq, arrayOutputStream.toByteArray())
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 角色设置操作请求报文解析
|
|
|
+ * @param packet50 Packet50
|
|
|
+ * @return Triple<Boolean, Error?, ManageServiceMI2.HedgeOutMainConfigRsp?>
|
|
|
+ */
|
|
|
+ fun analysisManagerRoleOperateRsq(packet50: Packet50): Triple<Boolean, Error?, ManageServiceMI2.ManagerRoleOperateRsp?> {
|
|
|
+ return try {
|
|
|
+ val loginRsp = ManageServiceMI2.ManagerRoleOperateRsp.parseFrom(packet50.content)
|
|
|
+ if (loginRsp.retCode == 0) {
|
|
|
+ // 操作成功
|
|
|
+ Triple(true, null, loginRsp)
|
|
|
+ } else {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error("装箱失败"), null)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户注销报文装箱
|
|
|
+ * @param accountid Long 期货账户ID
|
|
|
+ * @return Packet50
|
|
|
+ */
|
|
|
+ fun getTaaccountOperateReqInfo(
|
|
|
+ accountid : Long
|
|
|
+ ) : Packet50{
|
|
|
+ val builder = ManageServiceMI2.TaaccountOperateReq.newBuilder()
|
|
|
+ val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
|
+
|
|
|
+ builder.setHeader(
|
|
|
+ MessageHeadModel.getHead(
|
|
|
+ FunCode.TaaccountOperateReq,
|
|
|
+ loginInfo.userID,
|
|
|
+ GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+ 0,
|
|
|
+ 18
|
|
|
+ )
|
|
|
+ )
|
|
|
+ builder.accountid = accountid
|
|
|
+ builder.tradestatus = 7
|
|
|
+ builder.modifierid = loginInfo.loginID
|
|
|
+ builder.areauserid = loginInfo.userID.toLong()
|
|
|
+ val arrayOutputStream = ByteArrayOutputStream()
|
|
|
+ builder.build().writeTo(arrayOutputStream)
|
|
|
+ return Packet50(FunCode.TaaccountOperateReq, arrayOutputStream.toByteArray())
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户注销报文解析
|
|
|
+ * @param packet50 Packet50
|
|
|
+ * @return Triple<Boolean, Error?, ManageServiceMI2.TaaccountOperateRsp?>
|
|
|
+ */
|
|
|
+ fun analysisTaaccountOperateRsq(packet50: Packet50): Triple<Boolean, Error?, ManageServiceMI2.TaaccountOperateRsp?> {
|
|
|
+ return try {
|
|
|
+ val loginRsp = ManageServiceMI2.TaaccountOperateRsp.parseFrom(packet50.content)
|
|
|
+ if (loginRsp.retCode == 0) {
|
|
|
+ // 操作成功
|
|
|
+ Triple(true, null, loginRsp)
|
|
|
+ } else {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error("装箱失败"), null)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户授信报文装箱
|
|
|
+ * @param accountid Long 期货账户ID
|
|
|
+ * @param sxmoney Double 授信金额正为加负为减
|
|
|
+ */
|
|
|
+ fun getTaaccountTransfersxmoneyReqInfo(
|
|
|
+ accountid : Long,
|
|
|
+ sxmoney : Double
|
|
|
+ ) : Packet50{
|
|
|
+ val builder = ManageServiceMI2.TaaccountTransfersxmoneyReq.newBuilder()
|
|
|
+ val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
|
+
|
|
|
+ builder.setHeader(
|
|
|
+ MessageHeadModel.getHead(
|
|
|
+ FunCode.TaaccountTransfersxmoneyReq,
|
|
|
+ loginInfo.userID,
|
|
|
+ GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+ 0,
|
|
|
+ 18
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ builder.accountid = accountid
|
|
|
+ builder.sxmoney = sxmoney
|
|
|
+ builder.modifierid = loginInfo.loginID
|
|
|
+ builder.areauserid = loginInfo.userID.toLong()
|
|
|
+ val arrayOutputStream = ByteArrayOutputStream()
|
|
|
+ builder.build().writeTo(arrayOutputStream)
|
|
|
+ return Packet50(FunCode.TaaccountTransfersxmoneyReq, arrayOutputStream.toByteArray())
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户授信报文解析
|
|
|
+ * @param packet50 Packet50
|
|
|
+ * @return Triple<Boolean, Error?, ManageServiceMI2.TaaccountOperateRsp?>
|
|
|
+ */
|
|
|
+ fun analysisTaaccountTransfersxmoneyRsq(packet50: Packet50): Triple<Boolean, Error?, ManageServiceMI2.TaaccountTransfersxmoneyRsp?> {
|
|
|
+ return try {
|
|
|
+ val loginRsp = ManageServiceMI2.TaaccountTransfersxmoneyRsp.parseFrom(packet50.content)
|
|
|
+ if (loginRsp.retCode == 0) {
|
|
|
+ // 操作成功
|
|
|
+ Triple(true, null, loginRsp)
|
|
|
+ } else {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error("装箱失败"), null)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 登录账户操作请求报文装箱
|
|
|
+ * @param operatetype Int 操作类型-1:新增 2:修改 3:新增管理员 4:修改管理员 5:锁定 6:解锁 7:注销 8:恢复 9:重置密码
|
|
|
+ * @param userid Long 用户ID(新增成功接口返回的userid)
|
|
|
+ * @param loginid Long 登录ID(新增成功接口返回的loginid)
|
|
|
+ * @param logincode String 登录账号
|
|
|
+ * @param accountname String 账户名称
|
|
|
+ * @param password String 登录密码(明文)
|
|
|
+ * @param mobile String 手机号码(明文)
|
|
|
+ * @param roleids List<Long> 账号角色
|
|
|
+ * @param logintaaccounts List<LoginTaaccount> 期货账户(勾选交易员必填)
|
|
|
+ * @return Packet50
|
|
|
+ */
|
|
|
+ fun getLoginaccountOperateReqInfo(
|
|
|
+ operatetype : Int,
|
|
|
+ userid : Long = 0,
|
|
|
+ loginid : Long = 0,
|
|
|
+ logincode : String = "",
|
|
|
+ accountname : String = "",
|
|
|
+ password : String = "",
|
|
|
+ mobile : String = "",
|
|
|
+ roleids : List<Long>,
|
|
|
+ logintaaccounts : List<ManageServiceMI2.LoginTaaccount>
|
|
|
+ ) : Packet50{
|
|
|
+ val builder = ManageServiceMI2.LoginaccountOperateReq.newBuilder()
|
|
|
+ val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
|
+
|
|
|
+ builder.setHeader(
|
|
|
+ MessageHeadModel.getHead(
|
|
|
+ FunCode.LoginaccountOperateReq,
|
|
|
+ loginInfo.userID,
|
|
|
+ GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+ 0,
|
|
|
+ 18
|
|
|
+ )
|
|
|
+ )
|
|
|
+ builder.modifierid = loginInfo.loginID
|
|
|
+ builder.areauserid = loginInfo.userID.toLong()
|
|
|
+ builder.operatetype = operatetype
|
|
|
+ builder.userid = userid
|
|
|
+ builder.loginid =loginid
|
|
|
+ if (logincode.isNotEmpty()){
|
|
|
+ builder.logincode = logincode
|
|
|
+ }
|
|
|
+ if (accountname.isNotEmpty()){
|
|
|
+ builder.accountname = accountname
|
|
|
+ }
|
|
|
+ if (password.isNotEmpty()){
|
|
|
+ builder.password = password
|
|
|
+ }
|
|
|
+ if (mobile.isNotEmpty()){
|
|
|
+ builder.mobile = mobile
|
|
|
+ }
|
|
|
+ builder.addAllRoleids(roleids)
|
|
|
+ builder.addAllLogintaaccounts(logintaaccounts)
|
|
|
+
|
|
|
+ val arrayOutputStream = ByteArrayOutputStream()
|
|
|
+ builder.build().writeTo(arrayOutputStream)
|
|
|
+ return Packet50(FunCode.LoginaccountOperateReq, arrayOutputStream.toByteArray())
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户授信报文解析
|
|
|
+ * @param packet50 Packet50
|
|
|
+ * @return Triple<Boolean, Error?, ManageServiceMI2.TaaccountOperateRsp?>
|
|
|
+ */
|
|
|
+ fun analysisLoginaccountOperateRsq(packet50: Packet50): Triple<Boolean, Error?, ManageServiceMI2.LoginaccountOperateRsp?> {
|
|
|
+ return try {
|
|
|
+ val loginRsp = ManageServiceMI2.LoginaccountOperateRsp.parseFrom(packet50.content)
|
|
|
+ if (loginRsp.retCode == 0) {
|
|
|
+ // 操作成功
|
|
|
+ Triple(true, null, loginRsp)
|
|
|
+ } else {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error("装箱失败"), null)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 现货市价请求报文装箱
|
|
|
+ * @param WRStandardID Long 现货商品ID
|
|
|
+ * @param SpotGoodsModelID Long 现货品类ID(通用则为0)
|
|
|
+ * @param SpotGoodsBrandID Long 现货品牌ID(通用则为0, 不为0则须先有品类ID)
|
|
|
+ * @param CurrencyID Long 报价货币ID
|
|
|
+ * @param SpotGoodsPrice Double 现货价格
|
|
|
+ * @param TradeDate String 交易日(yyyyMMdd)
|
|
|
+ * @param OperateType Int 操作类型 - 1:新增 2:修改 3:删除
|
|
|
+ */
|
|
|
+ fun getErmcpSpotGoodsPriceReqInfo(
|
|
|
+ WRStandardID : Long,
|
|
|
+ SpotGoodsModelID : Long = 0,
|
|
|
+ SpotGoodsBrandID : Long = 0,
|
|
|
+ CurrencyID : Long = 0,
|
|
|
+ SpotGoodsPrice : Double,
|
|
|
+ TradeDate : String,
|
|
|
+ OperateType : Int
|
|
|
+ ) : Packet50{
|
|
|
+ val builder = ManageServiceMI2.ErmcpSpotGoodsPriceReq.newBuilder()
|
|
|
+ val loginInfo = GlobalDataCollection.instance?.loginRsp!!
|
|
|
+
|
|
|
+ builder.setHeader(
|
|
|
+ MessageHeadModel.getHead(
|
|
|
+ FunCode.FunCode_Trade_ErmcpSpotGoodsPriceReq,
|
|
|
+ loginInfo.userID,
|
|
|
+ GlobalDataCollection.instance?.accountId ?: 0,
|
|
|
+ 0,
|
|
|
+ 18
|
|
|
+ )
|
|
|
+ )
|
|
|
+ builder.operateID = loginInfo.loginID
|
|
|
+ builder.operateSrc = 2
|
|
|
+ builder.wrStandardID = WRStandardID
|
|
|
+ if (SpotGoodsModelID != 0L){
|
|
|
+ builder.spotGoodsModelID = SpotGoodsModelID
|
|
|
+ }
|
|
|
+ if (SpotGoodsBrandID != 0L){
|
|
|
+ builder.spotGoodsBrandID = SpotGoodsBrandID
|
|
|
+ }
|
|
|
+ if (CurrencyID != 0L){
|
|
|
+ builder.currencyID = CurrencyID
|
|
|
+ }
|
|
|
+ builder.spotGoodsPrice = SpotGoodsPrice
|
|
|
+ builder.tradeDate = TradeDate
|
|
|
+ builder.operateType = OperateType
|
|
|
+
|
|
|
+ val arrayOutputStream = ByteArrayOutputStream()
|
|
|
+ builder.build().writeTo(arrayOutputStream)
|
|
|
+ return Packet50(FunCode.FunCode_Trade_ErmcpSpotGoodsPriceReq, arrayOutputStream.toByteArray())
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 期货账户授信报文解析
|
|
|
+ * @param packet50 Packet50
|
|
|
+ * @return Triple<Boolean, Error?, ManageServiceMI2.TaaccountOperateRsp?>
|
|
|
+ */
|
|
|
+ fun analysisErmcpSpotGoodsPriceRsq(packet50: Packet50): Triple<Boolean, Error?, ManageServiceMI2.ErmcpSpotGoodsPriceRsp?> {
|
|
|
+ return try {
|
|
|
+ val loginRsp = ManageServiceMI2.ErmcpSpotGoodsPriceRsp.parseFrom(packet50.content)
|
|
|
+ if (loginRsp.retCode == 0) {
|
|
|
+ // 操作成功
|
|
|
+ Triple(true, null, loginRsp)
|
|
|
+ } else {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error(ErrorMessageUtils.getErrorString(loginRsp.retCode)), null)
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // 操作失败
|
|
|
+ Triple(false, Error("装箱失败"), null)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|