/** * @Author: zou.yingbin * @Create : 2021/6/1 14:14 * @Modify : 2021/6/1 14:14 */ package models import ( "fmt" "mtp2_if/db" "mtp2_if/mtpcache" "mtp2_if/utils" ) // 大连千海金 // QhjContract 千海金融资明细(合同) type QhjContract struct { USERID int64 `json:"userid" xorm:"USERID"` // 用户ID SCFCONTRACTID int64 `json:"scfcontractid" xorm:"SCFCONTRACTID"` // SCF合同ID(310+Unix秒时间戳(10位)+xxxxxx) SCFCONTRACTTYPE int32 `json:"scfcontracttype" xorm:"SCFCONTRACTTYPE"` // 合同类型 - 1:仓单回购 2:仓单质押 3:合作套保 4:资金贷款 5:融资单 GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID [5:融资单] CONTRACTCONFIRMTIME string `json:"contractconfirmtime" xorm:"CONTRACTCONFIRMTIME"` // 合同确认时间(时间) WRQTY int32 `json:"wrqty" xorm:"WRQTY"` // 仓单数量(数量) TRADEPRICE float64 `json:"tradeprice" xorm:"TRADEPRICE"` // 成交价格(成本价格) LENDERAMOUNT float64 `json:"lenderamount" xorm:"LENDERAMOUNT"` // 贷款金额(总额|订单总额) MARGINRATIO float64 `json:"marginratio" xorm:"MARGINRATIO"` // 保证金比率(首付比例) INITMARGIN float64 `json:"initmargin" xorm:"'INITMARGIN'"` // 初始保证金(首付款) RECOVEREDMARGIN float64 `json:"recoveredmargin" xorm:"'RECOVEREDMARGIN'"` // 已追缴保证金 REMAINAMOUNT float64 `json:"remainamount" xorm:"'REMAINAMOUNT'"` // 合同剩余金额(融资额) TOTALINTEREST float64 `json:"totalinterest" xorm:"'TOTALINTEREST'"` // 已计总利息(利息) GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码 GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称 GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 商品单位id PAYAMOUNT float64 `json:"payamount" xorm:"'PAYAMOUNT'"` // 已付(已付货款) USERNAME string `json:"username" xorm:"'USERNAME'"` // 用户名称 ENUMDICNAME string `json:"enumdicname"` // 单位名称 } func (r *QhjContract) calc() { r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID) r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID) // 已付(已付货款) = 已追缴保证金 + 初始保证金 r.PAYAMOUNT = r.RECOVEREDMARGIN + r.INITMARGIN } func (r *QhjContract) buildSql() string { var sqlId utils.SQLVal = "select t.borroweruserid userid," + " t.scfcontractid," + " t.scfcontracttype," + " t.goodsid," + " to_char(t.contractconfirmtime, 'yyyy-mm-dd hh24:mi:ss') contractconfirmtime," + " t.wrqty," + " t.tradeprice," + " t.lenderamount," + " t.marginratio," + " s.initmargin," + " s.recoveredmargin," + " s.remainamount," + " s.totalinterest," + " g.goodscode," + " g.goodsname," + " g.goodunitid" + " from scf_contract t" + " left join scf_contractinfo s" + " on t.scfcontractid = s.scfcontractid" + " left join goods g" + " on t.goodsid = g.goodsid" + " where 1=1" sqlId.And("t.borroweruserid", r.USERID) sqlId.AndEx("t.SCFCONTRACTID", r.SCFCONTRACTID, r.SCFCONTRACTID > 0) return sqlId.String() } // GetDataEx 获取融资明细(合同) func (r *QhjContract) GetDataEx() (interface{}, error) { sData := make([]QhjContract, 0) err := db.GetEngine().SQL(r.buildSql()).Find(&sData) for i := range sData { sData[i].calc() } return sData, err } // QhjContractLog 融资明细流水log type QhjContractLog struct { LOGID string `json:"logid" xorm:"LOGID"` // LogID(315+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx) SCFCONTRACTID int64 `json:"scfcontractid" xorm:"SCFCONTRACTID"` // SCF合同ID(310+Unix秒时间戳(10位)+xxxxxx) AMOUNTTYPE int32 `json:"amounttype" xorm:"AMOUNTTYPE"` // 资金类型 - 1:首付款 2:尾款 3:利息 4:追加款 AMOUNT float64 `json:"amount" xorm:"AMOUNT"` // 支付金额 REMAINAMOUNT float64 `json:"remainamount" xorm:"REMAINAMOUNT"` // 剩余货款 UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间 FilterType string `json:"-"` // 资金类型 } func (r *QhjContractLog) calc() { } func (r *QhjContractLog) buildSql() string { var sqlId utils.SQLVal = "SELECT t.LOGID," + " t.SCFCONTRACTID," + " t.AMOUNTTYPE," + " t.AMOUNT," + " t.REMAINAMOUNT," + " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME" + " FROM SCF_CONTRACTAMOUNTLOG t" + " WHERE 1 = 1" sqlId.AndEx("t.SCFCONTRACTID", r.SCFCONTRACTID, r.SCFCONTRACTID > 0) sqlId.JoinEx(len(r.FilterType) > 0, fmt.Sprintf(" and t.AMOUNTTYPE in(%v)", r.FilterType)) return sqlId.String() } // GetDataEx 获取融资明细流水log func (r *QhjContractLog) GetDataEx() (interface{}, error) { sData := make([]QhjContractLog, 0) err := db.GetEngine().SQL(r.buildSql()).Find(&sData) for i := range sData { sData[i].calc() } return sData, err } // QhjRStrategy 定投规则策略 type QhjRStrategy struct { REGULARLYCYCLE int32 `json:"regularlycycle" xorm:"REGULARLYCYCLE"` // 定投频率 - 1:每周 2:每月 REGULARLYCYCLEVALUE string `json:"regularlycyclevalue" xorm:"REGULARLYCYCLEVALUE"` // 定投频率值 - 每周几(0-6) 或 每月几号(<=28) REGULARLYMODE int32 `json:"regularlymode" xorm:"REGULARLYMODE"` // 定投方式 - 1:按数量 2:按金额 REGULARLYMODEVALUE float64 `json:"regularlymodevalue" xorm:"REGULARLYMODEVALUE"` // 定投方式值 - 数量或金额 REMARK string `json:"remark" xorm:"REMARK"` // 备注 REGULARLYSTRATEGYSTATUS int32 `json:"regularlystrategystatus" xorm:"REGULARLYSTRATEGYSTATUS"` // 策略状态 - 1:正常 2:暂停 3:终止 TRIGGERTOTALTIMES string `json:"triggertotaltimes" xorm:"TRIGGERTOTALTIMES"` // 累计定投总次数 TRIGGERSUCCESSTIMES string `json:"triggersuccesstimes" xorm:"TRIGGERSUCCESSTIMES"` // 累计定投成功次数 TRIGGERTOTALQTY float64 `json:"triggertotalqty" xorm:"TRIGGERTOTALQTY"` // 累计定投数量(成功) [按小数位放大值] TRIGGERTOTALAMOUNT float64 `json:"triggertotalamount" xorm:"TRIGGERTOTALAMOUNT"` // 累计定投金额(成功) LASTEFFECTTRADEDATE string `json:"lasteffecttradedate" xorm:"LASTEFFECTTRADEDATE"` // 最新生效交易日 LASTSTOPTRADEDATE string `json:"laststoptradedate" xorm:"LASTSTOPTRADEDATE"` // 最新暂停交易日 LASTTRIGGERTRADEDATE string `json:"lasttriggertradedate" xorm:"LASTTRIGGERTRADEDATE"` // 最新触发交易日 NEXTTRIGGERDATE string `json:"nexttriggerdate" xorm:"NEXTTRIGGERDATE"` // 下次触发日期 NEXTTRIGGERQTY float64 `json:"nexttriggerqty" xorm:"NEXTTRIGGERQTY"` // 下次触发数量 [按小数位放大值] NEXTTRIGGERAMOUNT float64 `json:"nexttriggeramount" xorm:"NEXTTRIGGERAMOUNT"` // 下次触发金额 UPDATORID string `json:"updatorid" xorm:"UPDATORID"` // 更新人 UPDATESRC int32 `json:"updatesrc" xorm:"UPDATESRC"` // 更新来源 - 1:管理端 2:终端 UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间 REGULARLYSTRATEGYID int64 `json:"regularlystrategyid" xorm:"REGULARLYSTRATEGYID"` // 定投策略ID (SEQ_QHJ_REGULARLYSTRATEGY) USERID int64 `json:"userid" xorm:"USERID"` // 所属用户ID ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 用户资金账户 GOODSID string `json:"goodsid" xorm:"GOODSID"` // 定投商品ID GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 定投商品代码 GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 定投商品名称 GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 定投商品单位id CURRENCYID int32 `json:"currencyid" xorm:"'CURRENCYID'"` // 币种id USERNAME string `json:"username"` // 用户名称(userid对应的名称) ACCOUNTNAME string `json:"accountname"` // 账号名称(ACCOUNTID对应的名称) ENUMDICNAME string `json:"enumdicname"` // 单位名称 CURRENCYNAME string `json:"currencyname"` // 币种名称 FilterStatus string `json:"-"` // 状态过滤条件 } func (r *QhjRStrategy) calc() { r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID) r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID) r.CURRENCYNAME = mtpcache.GetCurrencyName(r.CURRENCYID) } func (r *QhjRStrategy) buildSql() string { var sqlId utils.SQLVal = "SELECT t.REGULARLYCYCLE," + " t.REGULARLYCYCLEVALUE," + " t.REGULARLYMODE," + " t.REGULARLYMODEVALUE," + " t.REMARK," + " t.REGULARLYSTRATEGYSTATUS," + " t.TRIGGERTOTALTIMES," + " t.TRIGGERSUCCESSTIMES," + " t.TRIGGERTOTALQTY," + " t.TRIGGERTOTALAMOUNT," + " t.LASTEFFECTTRADEDATE," + " t.LASTSTOPTRADEDATE," + " t.LASTTRIGGERTRADEDATE," + " to_char(t.NEXTTRIGGERDATE, 'yyyy-mm-dd hh24:mi:ss') NEXTTRIGGERDATE," + " t.NEXTTRIGGERQTY," + " t.NEXTTRIGGERAMOUNT," + " t.UPDATORID," + " t.UPDATESRC," + " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," + " t.REGULARLYSTRATEGYID," + " t.USERID," + " t.ACCOUNTID," + " t.GOODSID," + " g.goodscode," + " g.goodsname," + " g.goodunitid," + " ta.accountname" + " FROM QHJ_REGULARLYSTRATEGY t" + " LEFT JOIN GOODS g on t.goodsid=g.goodsid" + " LEFT JOIN TAACCOUNT ta on t.accountid=ta.accountid" + " WHERE 1 = 1" sqlId.And("t.USERID", r.USERID) sqlId.JoinEx(len(r.FilterStatus) > 0, fmt.Sprintf(" and t.REGULARLYSTRATEGYSTATUS in(%v)", r.FilterStatus)) return sqlId.String() } // GetDataEx 获取定投规则策略 func (r *QhjRStrategy) GetDataEx() (interface{}, error) { sData := make([]QhjRStrategy, 0) err := db.GetEngine().SQL(r.buildSql()).Find(&sData) for i := range sData { sData[i].calc() } return sData, err } // QhjRSTriggerLog 定投规则策略触发记录 type QhjRSTriggerLog struct { TRADEID string `json:"tradeid" xorm:"TRADEID"` // 成交单ID LOGID string `json:"logid" xorm:"LOGID"` // LogID(SEQ_QHJ_RSTRIGGERLOG) REGULARLYSTRATEGYID int64 `json:"regularlystrategyid" xorm:"REGULARLYSTRATEGYID"` // 定投策略ID USERID int64 `json:"userid" xorm:"USERID"` // 所属用户ID ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 用户资金账户 GOODSID string `json:"goodsid" xorm:"GOODSID"` // 定投商品ID REGULARLYCYCLE int32 `json:"regularlycycle" xorm:"REGULARLYCYCLE"` // 定投频率 - 1:每周 2:每月 REGULARLYCYCLEVALUE string `json:"regularlycyclevalue" xorm:"REGULARLYCYCLEVALUE"` // 定投频率值 - 每周几(0-6) 或 每月几号(<=28) REGULARLYMODE int32 `json:"regularlymode" xorm:"REGULARLYMODE"` // 定投方式 - 1:按数量 2:按金额 REGULARLYMODEVALUE float64 `json:"regularlymodevalue" xorm:"REGULARLYMODEVALUE"` // 定投方式值 - 数量或金额 TRIGGERTIME string `json:"triggertime" xorm:"TRIGGERTIME"` // 触发时间 TRIGGERTRADEDATE string `json:"triggertradedate" xorm:"TRIGGERTRADEDATE"` // 触发交易日 TRIGGERQTY float64 `json:"triggerqty" xorm:"TRIGGERQTY"` // 触发数量 TRIGGERAMOUNT float64 `json:"triggeramount" xorm:"TRIGGERAMOUNT"` // 触发金额 TRIGGERSTATUS int32 `json:"triggerstatus" xorm:"TRIGGERSTATUS"` // 触发状态 - 1:成功 2:失败 RETCODE string `json:"retcode" xorm:"RETCODE"` // 错误码 GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 定投商品代码 GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 定投商品名称 GOODUNITID int32 `json:"goodunitid" xorm:"'GOODUNITID'"` // 定投商品单位id CURRENCYID int32 `json:"currencyid" xorm:"'CURRENCYID'"` // 币种id USERNAME string `json:"username"` // 用户名称(userid对应的名称) ACCOUNTNAME string `json:"accountname"` // 账号名称(ACCOUNTID对应的名称) ENUMDICNAME string `json:"enumdicname"` // 单位名称 CURRENCYNAME string `json:"currencyname"` // 币种名称 } func (r *QhjRSTriggerLog) calc() { r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID) r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID) r.CURRENCYNAME = mtpcache.GetCurrencyName(r.CURRENCYID) } func (r *QhjRSTriggerLog) buildSql() string { var sqlId utils.SQLVal = "SELECT t.TRADEID," + " t.LOGID," + " t.REGULARLYSTRATEGYID," + " t.USERID," + " t.ACCOUNTID," + " t.GOODSID," + " t.REGULARLYCYCLE," + " t.REGULARLYCYCLEVALUE," + " t.REGULARLYMODE," + " t.REGULARLYMODEVALUE," + " to_char(t.TRIGGERTIME, 'yyyy-mm-dd hh24:mi:ss') TRIGGERTIME," + " t.TRIGGERTRADEDATE," + " t.TRIGGERQTY," + " t.TRIGGERAMOUNT," + " t.TRIGGERSTATUS," + " t.RETCODE," + " g.goodscode," + " g.goodsname," + " g.goodunitid," + " ta.accountname," + " ta.currencyid" + " FROM QHJ_RSTRIGGERLOG t" + " LEFT JOIN GOODS g" + " on t.goodsid = g.goodsid" + " LEFT JOIN TAACCOUNT ta" + " on t.accountid = ta.accountid" + " WHERE 1 = 1" sqlId.And("t.USERID", r.USERID) sqlId.AndEx("t.REGULARLYSTRATEGYID", r.REGULARLYSTRATEGYID, r.REGULARLYSTRATEGYID > 0) return sqlId.String() } // GetDataEx 获取定投规则策略触发记录 func (r *QhjRSTriggerLog) GetDataEx() (interface{}, error) { sData := make([]QhjRSTriggerLog, 0) err := db.GetEngine().SQL(r.buildSql()).Find(&sData) for i := range sData { sData[i].calc() } return sData, err } // UserReceiveInfo 用户收货信息 type UserReceiveInfo struct { AUTOID int32 `json:"autoid" xorm:"AUTOID"` // AutoID USERID int64 `json:"userid" xorm:"USERID"` // 用户ID RECEIVERNAME string `json:"receivername" xorm:"RECEIVERNAME"` // 提货人姓名 CARDTYPEID int32 `json:"cardtypeid" xorm:"CARDTYPEID"` // 证件类型 CARDNUM string `json:"cardnum" xorm:"CARDNUM"` // 证件号码(加密存储) PHONENUM string `json:"phonenum" xorm:"PHONENUM"` // 提货人联系方式(加密存储) ADDRESS string `json:"address" xorm:"ADDRESS"` // 提货人详细地址 TAKEREMARK string `json:"takeremark" xorm:"TAKEREMARK"` // 提货备注 COUNTRYID int32 `json:"countryid" xorm:"COUNTRYID"` // 国家 PROVINCEID int32 `json:"provinceid" xorm:"PROVINCEID"` // 省 CITYID int32 `json:"cityid" xorm:"CITYID"` // 市 DISTRICTID int32 `json:"districtid" xorm:"DISTRICTID"` // 地区 ISDEFAULT int32 `json:"isdefault" xorm:"ISDEFAULT"` // 是否默认地址 - 0:否 1:是 HASENCRYPT int32 `json:"hasencrypt" xorm:"HASENCRYPT"` // 数据是否已加密 - 0:未加密 1:已加密 COUNTRYNAME string `json:"countryname"` // 国家名称 CITYNAME string `json:"cityname"` // 城市名称 PROVINCENAME string `json:"provincename"` // 省名称 DISTRICTNAME string `json:"districtname"` // 地区名称 } func (r *UserReceiveInfo) calc() { // 加密过的长度 > 16, 否则是未加密的 if len(r.CARDNUM) > 16 { r.CARDNUM = DecryptField(r.CARDNUM) } if len(r.PHONENUM) > 16 { r.PHONENUM = DecryptField(r.PHONENUM) } r.COUNTRYNAME = mtpcache.GetDivisionName(r.COUNTRYID) r.CITYNAME = mtpcache.GetDivisionName(r.CITYID) r.PROVINCENAME = mtpcache.GetDivisionName(r.PROVINCEID) r.DISTRICTNAME = mtpcache.GetDivisionName(r.DISTRICTID) } func (r *UserReceiveInfo) buildSql() string { var sqlId utils.SQLVal = "SELECT t.AUTOID," + " t.USERID," + " t.RECEIVERNAME," + " t.CARDTYPEID," + " t.CARDNUM," + " t.PHONENUM," + " t.ADDRESS," + " t.TAKEREMARK," + " t.COUNTRYID," + " t.PROVINCEID," + " t.CITYID," + " t.DISTRICTID," + " t.ISDEFAULT," + " t.HASENCRYPT" + " FROM USERRECEIVEINFO t" + " WHERE 1 = 1" sqlId.And("t.USERID", r.USERID) return sqlId.String() } // GetDataEx 获取用户收货信息 func (r *UserReceiveInfo) GetDataEx() (interface{}, error) { sData := make([]UserReceiveInfo, 0) err := db.GetEngine().SQL(r.buildSql()).Find(&sData) for i := range sData { sData[i].calc() } return sData, err } // UserCollectConfig 提现账户设置 type UserCollectConfig struct { COLLECTCONFIGID string `json:"collectconfigid" xorm:"COLLECTCONFIGID"` // 收款账户配置ID(SEQ_USERCOLLECTCONFIG) USERID int64 `json:"userid" xorm:"USERID"` // 收款人用户ID COLLECTACCOUNTNO string `json:"collectaccountno" xorm:"COLLECTACCOUNTNO"` // 收款人账户 COLLECTACCOUNTNAME string `json:"collectaccountname" xorm:"COLLECTACCOUNTNAME"` // 收款人账户名称 COLLECTBANKNAME string `json:"collectbankname" xorm:"COLLECTBANKNAME"` // 收款人开户行 COLLECTBRANCHBANKNAME string `json:"collectbranchbankname" xorm:"COLLECTBRANCHBANKNAME"` // 收款人开户支行 REMARK string `json:"remark" xorm:"REMARK"` // 备注 ACCOUNTSTATUS int32 `json:"accountstatus" xorm:"ACCOUNTSTATUS"` // 账户状态 - 1:正常 2:停用 3:注销 } func (r *UserCollectConfig) calc() { // 加密后的长度是32的倍数 if len(r.COLLECTACCOUNTNO)%32 == 0 { r.COLLECTACCOUNTNO = DecryptField(r.COLLECTACCOUNTNO) } } func (r *UserCollectConfig) buildSql() string { var sqlId utils.SQLVal = "SELECT t.COLLECTCONFIGID," + " t.USERID," + " t.COLLECTACCOUNTNO," + " t.COLLECTACCOUNTNAME," + " t.COLLECTBANKNAME," + " t.COLLECTBRANCHBANKNAME," + " t.REMARK," + " t.ACCOUNTSTATUS" + " FROM USERCOLLECTCONFIG t" + " WHERE 1 = 1" sqlId.And("t.USERID", r.USERID) return sqlId.String() } // GetDataEx 获取提现账户设置 func (r *UserCollectConfig) GetDataEx() (interface{}, error) { sData := make([]UserCollectConfig, 0) err := db.GetEngine().SQL(r.buildSql()).Find(&sData) for i := range sData { sData[i].calc() } return sData, err } // QhjTradeGoodsPickup 提货单 type QhjTradeGoodsPickup struct { AUDITSRC int32 `json:"auditsrc" xorm:"AUDITSRC"` // 更新来源 - 1:管理端 2:终端 STOREUSERID int64 `json:"storeuserid" xorm:"STOREUSERID"` // 门店用户ID (千海金) ARTRADEDATE string `json:"artradedate" xorm:"ARTRADEDATE"` // 自动收货交易日(yyyyMMdd) EXPRESSCOMPANY string `json:"expresscompany" xorm:"EXPRESSCOMPANY"` // 物流公司 UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间 AUDITTRADEDATE string `json:"audittradedate" xorm:"AUDITTRADEDATE"` // 审核交易日(yyyyMMdd) EXPRESSNUM string `json:"expressnum" xorm:"EXPRESSNUM"` // 物流单号 TAKEORDERID int64 `json:"takeorderid" xorm:"TAKEORDERID"` // 提货单号(905+Unix秒时间戳(10位)+xxxxxx) ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 账户ID GOODSID int64 `json:"goodsid" xorm:"GOODSID"` // 商品ID USERID int64 `json:"userid" xorm:"USERID"` // 用户ID QTY float64 `json:"qty" xorm:"QTY"` // 交易商品总手数(交易商品 - 69模式按成交量放大) - 明细表的交易商品手数汇总 REQTIME string `json:"reqtime" xorm:"REQTIME"` // 提货申请时间 RECIVERNAME string `json:"recivername" xorm:"RECIVERNAME"` // 提货人姓名 CARDTYPEID int32 `json:"cardtypeid" xorm:"CARDTYPEID"` // 提货人证件类型 CARDNUM string `json:"cardnum" xorm:"CARDNUM"` // 提货人证件号码 PHONENUM string `json:"phonenum" xorm:"PHONENUM"` // 提货人联系方式 TAKEMODE int32 `json:"takemode" xorm:"TAKEMODE"` // 提货方式 - 2:自提 3:配送(邮寄) ADDRESS string `json:"address" xorm:"ADDRESS"` // 提货人详细地址 TAKEREMARK string `json:"takeremark" xorm:"TAKEREMARK"` // 提货备注 TAKEORDERSTATUS int32 `json:"takeorderstatus" xorm:"TAKEORDERSTATUS"` // 提货状态 - 1:备货中 2:待取货(自提) 3:已取货(自提) 4:待收货(邮寄) 5:已收货(邮寄) 6:自动收货(邮寄) 7:已拒绝 8:已撤销 AUDITER int32 `json:"auditer" xorm:"AUDITER"` // 审核人 AUDITTIME string `json:"audittime" xorm:"AUDITTIME"` // 审核时间(发货时间) CHECKREMARK string `json:"checkremark" xorm:"CHECKREMARK"` // 审核备注 TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd) MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID HANDLESTATUS int32 `json:"handlestatus" xorm:"HANDLESTATUS"` // 处理状态 AMOUNT float64 `json:"amount" xorm:"AMOUNT"` // 提货金额 COUNTRYID int32 `json:"countryid" xorm:"COUNTRYID"` // 国家 PROVINCEID int32 `json:"provinceid" xorm:"PROVINCEID"` // 省 CITYID int32 `json:"cityid" xorm:"CITYID"` // 市 DISTRICTID int32 `json:"districtid" xorm:"DISTRICTID"` // 地区 PICKUPGOODSID string `json:"pickupgoodsid" xorm:"PICKUPGOODSID"` // 提货商品ID GOODSAGREEUNIT float64 `json:"goodsagreeunit" xorm:"GOODSAGREEUNIT"` // 交易商品乘数 PICKUPGOODSAGREEUNIT float64 `json:"pickupgoodsagreeunit" xorm:"PICKUPGOODSAGREEUNIT"` // 提货商品合约乘数 PICKUPRATIO float64 `json:"pickupratio" xorm:"PICKUPRATIO"` // 提货系数 PICKUPGOODSQTY float64 `json:"pickupgoodsqty" xorm:"PICKUPGOODSQTY"` // 提货商品手数(数量) GOODSQTY float64 `json:"goodsqty" xorm:"GOODSQTY"` // 交易商品手数(69模式按成交量小数位放大取整) PREPAREDAYS int32 `json:"preparedays" xorm:"PREPAREDAYS"` // 备货期(天)-提货单明细表 PICKUPGOODSNAME string `json:"pickupgoodsname" xorm:"PICKUPGOODSNAME"` // 提货商品名称 PICKUPGOODSUNITID int32 `json:"pickupgoodsunitid" xorm:"PICKUPGOODSUNITID"` // 单位ID(提货商品) GOODSNAME string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称 GOODSCODE string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码 ENUMDICNAME string `json:"enumdicname"` // 单位名称(提货商品) USERNAME string `json:"username"` // 用户名称 STOREUSERNAME string `json:"storeusername"` // 门店用户名称 COUNTRYNAME string `json:"countryname"` // 国家名称 CITYNAME string `json:"cityname"` // 城市名称 PROVINCENAME string `json:"provincename"` // 省名称 DISTRICTNAME string `json:"districtname"` // 地区名称 } func (r *QhjTradeGoodsPickup) calc() { r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.PICKUPGOODSUNITID) r.STOREUSERNAME = mtpcache.GetUserNameByUserId(r.STOREUSERID) r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID) r.COUNTRYNAME = mtpcache.GetDivisionName(r.COUNTRYID) r.CITYNAME = mtpcache.GetDivisionName(r.CITYID) r.PROVINCENAME = mtpcache.GetDivisionName(r.PROVINCEID) r.DISTRICTNAME = mtpcache.GetDivisionName(r.DISTRICTID) } func (r *QhjTradeGoodsPickup) buildSql() string { var sqlId utils.SQLVal = "SELECT t.AUDITSRC," + " t.STOREUSERID," + " t.ARTRADEDATE," + " t.EXPRESSCOMPANY," + " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," + " t.AUDITTRADEDATE," + " t.EXPRESSNUM," + " t.TAKEORDERID," + " t.ACCOUNTID," + " t.GOODSID," + " t.USERID," + " t.QTY," + " to_char(t.REQTIME, 'yyyy-mm-dd hh24:mi:ss') REQTIME," + " t.RECIVERNAME," + " t.CARDTYPEID," + " t.CARDNUM," + " t.PHONENUM," + " t.TAKEMODE," + " t.ADDRESS," + " t.TAKEREMARK," + " t.TAKEORDERSTATUS," + " t.AUDITER," + " to_char(t.AUDITTIME, 'yyyy-mm-dd hh24:mi:ss') AUDITTIME," + " t.CHECKREMARK," + " t.TRADEDATE," + " t.MARKETID," + " t.HANDLESTATUS," + " t.AMOUNT," + " t.COUNTRYID," + " t.PROVINCEID," + " t.CITYID," + " t.DISTRICTID," + " k.PICKUPGOODSID," + " k.GOODSAGREEUNIT," + " k.PICKUPGOODSAGREEUNIT," + " k.PICKUPRATIO," + " k.PICKUPGOODSQTY," + " k.GOODSQTY," + " k.PREPAREDAYS," + " g.PICKUPGOODSNAME," + " g.PICKUPGOODSUNITID," + " g2.goodsname," + " g2.goodscode" + " FROM TRADE_GOODSPICKUP t" + " LEFT JOIN TRADE_GOODSPICKUPDETAIL k" + " on t.takeorderid = k.takeorderid" + " LEFT JOIN PICKUPGOODS g" + " on k.pickupgoodsid = g.pickupgoodsid" + " LEFT JOIN GOODS g2 on t.goodsid=g2.goodsid" + " WHERE 1 = 1" sqlId.And("t.USERID", r.USERID) return sqlId.String() } // GetDataEx 获取提货单 func (r *QhjTradeGoodsPickup) GetDataEx() (interface{}, error) { sData := make([]QhjTradeGoodsPickup, 0) err := db.GetEngine().SQL(r.buildSql()).Find(&sData) for i := range sData { sData[i].calc() } return sData, err } // QhjPickGoods 提货商品 type QhjPickGoods struct { PICKUPGOODSID string `json:"pickupgoodsid" xorm:"PICKUPGOODSID"` // 提货商品ID PICKUPGOODSNAME string `json:"pickupgoodsname" xorm:"PICKUPGOODSNAME"` // 提货商品名称 PICKUPGOODSUNITID int32 `json:"pickupgoodsunitid" xorm:"PICKUPGOODSUNITID"` // 单位ID PICKUPGOODSAGREEUNIT float64 `json:"pickupgoodsagreeunit" xorm:"PICKUPGOODSAGREEUNIT"` // 合约乘数 PICKUPGOODSDESC string `json:"pickupgoodsdesc" xorm:"PICKUPGOODSDESC"` // 描述 IMAGEADDRESS string `json:"imageaddress" xorm:"IMAGEADDRESS"` // 图片 REMARK string `json:"remark" xorm:"REMARK"` // 备注 MODIFYSRC int32 `json:"modifysrc" xorm:"MODIFYSRC"` // 修改来源 - 1:管理端 2:终端 MODIFIERID int64 `json:"modifierid" xorm:"MODIFIERID"` // 修改人 UPDATETIME string `json:"updatetime" xorm:"UPDATETIME"` // 更新时间 PREPAREDAYS int32 `json:"preparedays" xorm:"PREPAREDAYS"` // 备货期(天) PICKUPGOODSSTATUS int32 `json:"pickupgoodsstatus" xorm:"PICKUPGOODSSTATUS"` // 状态 - 1:正常 2:停用 3:注销 MODIFIERNAME string `json:"modifiername"` // 修改人名称 FilterStatus string `json:"-"` // 状态过淲 } func (r *QhjPickGoods) calc() { if r.MODIFYSRC == 1 { r.MODIFIERNAME = mtpcache.GetSystemmangerLoginCode(r.MODIFIERID) } else { r.MODIFIERNAME = mtpcache.GetLoginCodeByLoginId(r.MODIFIERID) } if r.MODIFIERNAME == "" { r.MODIFIERNAME = mtpcache.GetUserNameByUserId(r.MODIFIERID) } } func (r *QhjPickGoods) buildSql() string { var sqlId utils.SQLVal = "SELECT t.PICKUPGOODSID," + " t.PICKUPGOODSNAME," + " t.PICKUPGOODSUNITID," + " t.PICKUPGOODSAGREEUNIT," + " to_char(t.PICKUPGOODSDESC) PICKUPGOODSDESC," + " to_char(t.IMAGEADDRESS) IMAGEADDRESS," + " t.REMARK," + " t.MODIFYSRC," + " t.MODIFIERID," + " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," + " t.PREPAREDAYS," + " t.PICKUPGOODSSTATUS" + " FROM PICKUPGOODS t" + " WHERE 1 = 1" if len(r.FilterStatus) > 0 { sqlId.Join(fmt.Sprintf(" and t.PICKUPGOODSSTATUS in(%v)", r.FilterStatus)) } return sqlId.String() } // GetDataEx 获取提货商品 func (r *QhjPickGoods) GetDataEx() (interface{}, error) { sData := make([]QhjPickGoods, 0) err := db.GetEngine().SQL(r.buildSql()).Find(&sData) for i := range sData { sData[i].calc() } return sData, err }