| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139 |
- using GalaSoft.MvvmLight;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.DTO;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Data.Model.Delivery;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- using System.Collections.Generic;
- using System.Windows;
- using System.Linq;
- using Muchinfo.MTPClient.Data;
- using System.Collections.ObjectModel;
- using Muchinfo.MTPClient.Data.Model;
- using System;
- using GalaSoft.MvvmLight.Command;
- using Muchinfo.MTPClient.Resources;
- using Muchinfo.MTPClient.Infrastructure.Cache;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- namespace Muchinfo.MTPClient.Delivery.ViewModels
- {
- /// <summary>
- /// 新交割申报
- /// <para>
- /// </para>
- /// </summary>
- public class NDeliveryOrderViewModel : ViewModelBase
- {
- private QuoteGoodsDTO _goodsItem;
- #region "=========私有成员/Private Data Members"
- private Window _openWindow; ///下单窗口
- private IDeliveryService _deliveryService;
- private IGoodsService _goodsService;
- private Direction _currentDirection = Direction.Bid;
- private decimal usableFunds = UserManager.CurrentAccountUsableFunds();
- private DeliveryOrderMessage _parameterInfo;
- protected const int defaut_minLot = 1;
- protected const int defaut_maxLot = int.MaxValue;
- private bool _action = false;//控制点选仓库多次触发事件
- private decimal submitDeliveryQty = decimal.Zero;//点选的交割总数量
- #endregion "Private Data Members"
- #region "=========构造函数/Constructor/Initialization"
-
- public NDeliveryOrderViewModel(DeliveryOrderMessage parameterInfo)
- {
- this._parameterInfo = parameterInfo;
- _deliveryService = SimpleIoc.Default.GetInstance<IDeliveryService>();
- _goodsService = SimpleIoc.Default.GetInstance<IGoodsService>();
- // 初始化交割商品列表数据
- InitData(parameterInfo);
- }
- #endregion "Constructor/Initialization"
- private void RegisterMessages()
- {
- MessengerHelper.QuoteRegister<List<QuoteGoods>>(this, MessengerTokens.ReceiveRealTimeQuote, (quoteList) =>
- {
- if (quoteList == null || !quoteList.Any()) return;
- foreach (var goods in quoteList)
- {
- if (goods == null) continue;
- if (this._goodsItem != null && this._goodsItem.GoodsCode == goods.GoodsCode)
- {
- this._goodsItem.UpdateFromQuoteGoods(goods);
- this.XPriceFormat = this._goodsItem.CurrentPriceDisplay;
- }
- }
- });
- }
- #region "=========接口重写/Interface implementation Or override"
- //To do interface implementation
- #endregion "Interface implementation Or override"
- #region "=========公共属性/Public Properties To Get/Set "
- #region 所有单据ListSource
- private List<DeliveryEntrustOrder> _allOrders;
- /// <summary>
- /// 所有单据ListSource
- /// </summary>
- public List<DeliveryEntrustOrder> AllOrders
- {
- get { return _allOrders; }
- set { Set(() => AllOrders, ref _allOrders, value); }
- }
- #endregion
- #region 当前资金账户
- private ulong _accountid;
- public ulong AccountID
- {
- get { return _accountid; }
- set { Set(() => AccountID, ref _accountid, value); }
- }
- #endregion
- #region 主商品
- public uint XGoodsID { get; set; }
- private string _xgoodsCode;
- public string XGoodsCode
- {
- get { return _xgoodsCode; }
- set { Set(() => XGoodsCode, ref _xgoodsCode, value); }
- }
- private string _xgoodsName;
- public string XGoodsName
- {
- get { return _xgoodsName; }
- set { Set(() => XGoodsName, ref _xgoodsName, value); }
- }
- private string _deliveryFactor;
- public string DeliveryFactor
- {
- get { return _deliveryFactor; }
- set { Set(() => DeliveryFactor, ref _deliveryFactor, value); }
- }
- public string DisplayXGoods
- {
- get
- {
- return XGoodsCode + "/" + XGoodsName;
- }
- }
- #endregion
-
- #region 辅助商品
- public uint P1GoodsID { get; set; }
- private string _p1goodsCode;
- public string P1GoodsCode
- {
- get { return _p1goodsCode; }
- set { Set(() => P1GoodsCode, ref _p1goodsCode, value); }
- }
- private string _p1goodsName;
- public string P1GoodsName
- {
- get { return _p1goodsName; }
- set { Set(() => P1GoodsName, ref _p1goodsName, value); }
- }
- public uint P2GoodsID { get; set; }
- private string _p2goodsCode;
- public string P2GoodsCode
- {
- get { return _p2goodsCode; }
- set { Set(() => P2GoodsCode, ref _p2goodsCode, value); }
- }
- private string _p2goodsName;
- public string P2GoodsName
- {
- get { return _p2goodsName; }
- set { Set(() => P2GoodsName, ref _p2goodsName, value); }
- }
- #endregion
- #region 交割商品
- private string _deliverygoodsCode;
- public string DeliveryGoodsCode
- {
- get { return _deliverygoodsCode; }
- set { Set(() => DeliveryGoodsCode, ref _deliverygoodsCode, value); }
- }
- private string _deliverygoodsName;
- public string DeliveryGoodsName
- {
- get { return _deliverygoodsName; }
- set { Set(() => DeliveryGoodsName, ref _deliverygoodsName, value); }
- }
- private string _deliverygoodsNamecode;
- public string DeliveryGoodsNameCode
- {
- get { return _deliverygoodsNamecode; }
- set { Set(() => DeliveryGoodsNameCode, ref _deliverygoodsNamecode, value); }
- }
- #endregion
- #region 仓库ListSource
- private ObservableCollection<KeyValuePair<string, string>> _warehouselst;
- public ObservableCollection<KeyValuePair<string, string>> DeliveryWarehouseList
- {
- get { return _warehouselst; }
- set { Set(() => DeliveryWarehouseList, ref _warehouselst, value); }
- }
- private KeyValuePair<string, string> _selectedWareHouse;
- public KeyValuePair<string, string> SelectedWareHouse
- {
- get { return _selectedWareHouse; }
- set { Set(() => SelectedWareHouse, ref _selectedWareHouse, value); }
- }
- #endregion
- #region 品质ListSource
- private List<KeyValuePair<string, string>> _qualitylst;
- public List<KeyValuePair<string, string>> DeliveryQualityList
- {
- get { return _qualitylst; }
- set { Set(() => DeliveryQualityList, ref _qualitylst, value); }
- }
- private KeyValuePair<string, string> _selectedQuality;
- public KeyValuePair<string, string> SelectedQuality
- {
- get { return _selectedQuality; }
- set { Set(() => SelectedQuality, ref _selectedQuality, value); }
- }
- #endregion
- #region 规格ListSource
- private List<KeyValuePair<string, string>> _spelst;
- public List<KeyValuePair<string, string>> DeliverySpeciList
- {
- get { return _spelst; }
- set { Set(() => DeliverySpeciList, ref _spelst, value); }
- }
- private KeyValuePair<string, string> _selectedSpeci;
- public KeyValuePair<string, string> SelectedSpeci
- {
- get { return _selectedSpeci; }
- set { Set(() => SelectedSpeci, ref _selectedSpeci, value); }
- }
- #endregion
- #region 品质ListSource
- private List<KeyValuePair<string, string>> _brandlst;
- public List<KeyValuePair<string, string>> DeliveryBrandList
- {
- get { return _brandlst; }
- set { Set(() => DeliveryBrandList, ref _brandlst, value); }
- }
- private KeyValuePair<string, string> _selectedBrand;
- public KeyValuePair<string, string> SelectedBrand
- {
- get { return _selectedBrand; }
- set { Set(() => SelectedBrand, ref _selectedBrand, value); }
- }
- #endregion
- #region 过滤条件
- private List<KeyValuePair<string, string>> _filterlst = new List<KeyValuePair<string, string>>();
- public List<KeyValuePair<string, string>> FilterList
- {
- get { return _filterlst; }
- set { Set(() => FilterList, ref _filterlst, value); }
- }
- #endregion
- #region 可用持仓数量
- private decimal _availHoldQty = decimal.Zero;
- /// <summary>
- /// 可用持仓数量
- /// </summary>
- public decimal AvailHoldQty
- {
- get
- {
- return _availHoldQty;
- }
- set
- {
- Set(() => AvailHoldQty, ref _availHoldQty, value);
- RaisePropertyChanged(() => AvailHoldQtyUnit);
- }
- }
- private decimal _availHoldQtyUnit = decimal.Zero;
- /// <summary>
- /// 可用持仓数量- 转- 交割可用数量
- /// </summary>
- public decimal AvailHoldQtyUnit
- {
- get
- {
- return _availHoldQtyUnit;
- }
- set
- {
- Set(() => AvailHoldQtyUnit, ref _availHoldQtyUnit, value);
- }
- }
- #endregion
- #region 当前选择仓单
- private DeliveryWhRecieptInfo _currentSelectedWhReciept;
- /// <summary>
- /// 当前选择仓单详细
- /// </summary>
- public DeliveryWhRecieptInfo CurrentSelectedWhReciept
- {
- get
- {
- return _currentSelectedWhReciept;
- }
- set
- {
- Set(() => CurrentSelectedWhReciept, ref _currentSelectedWhReciept, value);
- }
- }
- private TradeWRPositionModel _currentSelectedWhRecieptEx;
- /// <summary>
- /// 当前选择仓单详细
- /// </summary>
- public TradeWRPositionModel CurrentSelectedWhRecieptEx
- {
- get
- {
- return _currentSelectedWhRecieptEx;
- }
- set
- {
- Set(() => CurrentSelectedWhRecieptEx, ref _currentSelectedWhRecieptEx, value);
- }
- }
- #endregion
- #region 交割点选仓单
- private List<DeliveryWhRecieptInfo> _wrPairDetailsList = new List<DeliveryWhRecieptInfo>();
- /// <summary>
- /// 交割点选仓单
- /// </summary>
- public List<DeliveryWhRecieptInfo> WrPairDetailsList
- {
- get
- {
- return _wrPairDetailsList;
- }
- set
- {
- Set(() => WrPairDetailsList, ref _wrPairDetailsList, value);
- }
- }
- private static List<TradeWRPositionModel> CachedPairDetailsList = new List<TradeWRPositionModel>();
- private List<TradeWRPositionModel> _wrPairDetailsListEx = new List<TradeWRPositionModel>();
- /// <summary>
- /// 交割点选仓单
- /// </summary>
- public List<TradeWRPositionModel> WrPairDetailsListEx
- {
- get
- {
- return _wrPairDetailsListEx;
- }
- set
- {
- Set(() => WrPairDetailsListEx, ref _wrPairDetailsListEx, value);
- }
- }
- #endregion
- #region 最小交割数量/倍数
- private decimal _MinMultiple = 1;
- /// <summary>
- /// 最小交割数量/倍数
- /// </summary>
- public decimal MinMultiple
- {
- get
- {
- return _MinMultiple;
- }
- set
- {
- Set(() => MinMultiple, ref _MinMultiple, value);
- }
- }
- #endregion
- #region 加载中 字符串显示
- private string _BusyContent = Client_Resource.Content_GetBusy;
- /// <summary>
- /// 加载中 字符串显示
- /// </summary>
- public string BusyContent
- {
- get
- {
- return _BusyContent;
- }
- set
- {
- Set(() => BusyContent, ref _BusyContent, value);
- }
- }
- #endregion
- #region 当前账号提货人信息
- private DepositPersonalInfoRspModel _currentDepositPersonalInfo;
- /// <summary>
- /// 当前账号提货人信息
- /// </summary>
- public DepositPersonalInfoRspModel CurrentDepositPersonalInfo
- {
- get
- {
- return _currentDepositPersonalInfo;
- }
- set
- {
- Set(() => CurrentDepositPersonalInfo, ref _currentDepositPersonalInfo, value);
- }
- }
- #endregion
- #region 收货人
- private string _RecievePerson = string.Empty;
- /// <summary>
- /// 收货人
- /// </summary>
- public string RecievePerson
- {
- get
- {
- return _RecievePerson;
- }
- set
- {
- Set(() => RecievePerson, ref _RecievePerson, value);
- }
- }
- #endregion
- #region 收货地址
- private string _RecieveAddress = string.Empty;
- /// <summary>
- /// 收货地址
- /// </summary>
- public string RecieveAddress
- {
- get
- {
- return _RecieveAddress;
- }
- set
- {
- Set(() => RecieveAddress, ref _RecieveAddress, value);
- }
- }
- #endregion
- #region 联系方式
- private string _PhoneNum = string.Empty;
- /// <summary>
- /// 联系方式
- /// </summary>
- public string PhoneNum
- {
- get
- {
- return _PhoneNum;
- }
- set
- {
- Set(() => PhoneNum, ref _PhoneNum, value);
- }
- }
- #endregion
- #region 主商品-申报数量-错误提示
- private bool _isError_DeliveryCount = false;
- /// <summary>
- /// 主商品-申报数量-错误提示
- /// </summary>
- public bool IsError_DeliveryCount
- {
- get
- {
- return _isError_DeliveryCount;
- }
- set
- {
- Set(() => IsError_DeliveryCount, ref _isError_DeliveryCount, value);
- }
- }
- #endregion
- #region 关联商品-申报数量-错误提示
- private bool _isError_RelationDeliveryCount = false;
- /// <summary>
- /// 关联商品-申报数量-错误提示
- /// </summary>
- public bool IsError_RelationDeliveryCount
- {
- get
- {
- return _isError_RelationDeliveryCount;
- }
- set
- {
- Set(() => IsError_RelationDeliveryCount, ref _isError_RelationDeliveryCount, value);
- }
- }
- private bool _isError_RelationDeliveryCount2 = false;
- /// <summary>
- /// 关联商品-申报数量-错误提示
- /// </summary>
- public bool IsError_RelationDeliveryCount2
- {
- get
- {
- return _isError_RelationDeliveryCount2;
- }
- set
- {
- Set(() => IsError_RelationDeliveryCount2, ref _isError_RelationDeliveryCount2, value);
- }
- }
- #endregion
- #region 买卖名称改变
- private string _directionTitle = string.Empty;
- /// <summary>
- /// 买卖名称改变
- /// </summary>
- public string DirectionTitle
- {
- get
- {
- return _directionTitle;
- }
- set
- {
- Set(() => DirectionTitle, ref _directionTitle, value);
- }
- }
- #endregion
- #region 窗体标题
- private string _title = string.Empty;
- /// <summary>
- /// 窗体标题
- /// </summary>
- public string Title
- {
- get
- {
- return _title = Client_Resource.DeliveryOrderView_DeliveryDeclaration + "(" + AccountID.ToString() + ")";
- }
-
- }
- #endregion
- #region 当前勾选单据LIST
- private List<WrDetailModel> _currentSelectedWrDetail = new List<WrDetailModel>();
- /// <summary>
- /// 当前勾选的仓单配对
- /// </summary>
- public List<WrDetailModel> CurrentSelectedWrDetail
- {
- get
- {
- return _currentSelectedWrDetail;
- }
- set
- {
- Set(() => CurrentSelectedWrDetail, ref _currentSelectedWrDetail, value);
- }
- }
- #endregion
- #region 合约单位名称枚举-当前商品
- private string _currentGoodsUnitType = string.Empty;
- /// <summary>
- /// 合约单位名称枚举-当前商品
- /// </summary>
- public string CurrentGoodsUnitType
- {
- get
- {
- return _currentGoodsUnitType;
- }
- set
- {
- Set(() => CurrentGoodsUnitType, ref _currentGoodsUnitType, value);
- }
- }
- #endregion
- #region 合约单位名称枚举-关联商品商品
- private string _relationGoodsUnitType = string.Empty;
- /// <summary>
- /// 合约单位名称枚举-关联商品商品
- /// </summary>
- public string RelationGoodsUnitType
- {
- get
- {
- return _relationGoodsUnitType;
- }
- set
- {
- Set(() => RelationGoodsUnitType, ref _relationGoodsUnitType, value);
- }
- }
- #endregion
- #region 合约单位名称枚举-交割商品
- private string _deliveryAgreeUnitType = string.Empty;
- /// <summary>
- /// 合约单位名称枚举-交割商品
- /// </summary>
- public string DeliveryAgreeUnitType
- {
- get
- {
- return _deliveryAgreeUnitType;
- }
- set
- {
- Set(() => DeliveryAgreeUnitType, ref _deliveryAgreeUnitType, value);
- }
- }
- #endregion
- #region 交割商品数量-转换显示
- private decimal _deliveryNum = decimal.Zero;
- /// <summary>
- /// 交割商品数量-转换显示
- /// </summary>
- public decimal DeliveryNum
- {
- get
- {
- return _deliveryNum;
- }
- set
- {
- Set(() => DeliveryNum, ref _deliveryNum, value);
- if (CurrentGoods != null)
- {
- if (DeliveryNum > 0)
- {
- DeliveryCount = Math.Round(DeliveryNum * CurrentGoods.MinDeliveryQty * CurrentGoods.XDeliveryRatio / StandardQty, 0, MidpointRounding.AwayFromZero);//反推:得知交割数量,计算需要主商品数量 X数量 = 交割数量 * 最小交割单位 / 合约单位.
- if (CurrentGoods.P1Type !=uint.MaxValue)
- {
- RelationDeliveryCount = Math.Round(DeliveryCount * CurrentGoods.PDeliveryRatio1 / CurrentGoods.XDeliveryRatio, 0, MidpointRounding.AwayFromZero);
- }
- else
- {
- RelationDeliveryCount = 0;
- }
- if (CurrentGoods.P2Type != uint.MaxValue)
- {
- RelationDeliveryCount2 = Math.Round(DeliveryCount * CurrentGoods.PDeliveryRatio2 /CurrentGoods.XDeliveryRatio, 0, MidpointRounding.AwayFromZero);
- }
- else
- {
- RelationDeliveryCount2 = 0;
- }
- RaisePropertyChanged(() => DeliveryNumDisplay);
- }
- }
- }
- }
- public decimal StandardQty
- {
- get;
- set;
- }
- public uint DeliveryGoodsID
- {
- get;
- set;
- }
- /// <summary>
- /// 交割商品数量-转交-格式化
- /// </summary>
- public string DeliveryNumDisplay
- {
- get { return DeliveryNum.ToString(); }
- }
- #endregion
- #region 主商品数量-转换显示
- private decimal _goodsNum = decimal.Zero;
- /// <summary>
- /// 主商品数量-转换显示
- /// </summary>
- public decimal GoodsNum
- {
- get
- {
- return _goodsNum;
- }
- set
- {
- Set(() => GoodsNum, ref _goodsNum, value);
- RaisePropertyChanged(() => GoodsNumDisplay);
- }
- }
- /// <summary>
- /// 主商品数量-转交-格式化
- /// </summary>
- public string GoodsNumDisplay
- {
- get { return GoodsNum.ToString("f2"); }
- }
- #endregion
- #region 关联商品申报数量-转换显示
- private decimal _relationNum = decimal.Zero;
- /// <summary>
- /// 关联商品申报数量-转换显示
- /// </summary>
- public decimal RelationNum
- {
- get
- {
- return _relationNum;
- }
- set
- {
- Set(() => RelationNum, ref _relationNum, value);
- RaisePropertyChanged(() => RelationNumDisplay);
- RaisePropertyChanged(() => IsError);
- }
- }
- public bool IsError
- {
- get
- {
- return _relationNum > _relationGoodsHoldQty;
- }
- }
- /// <summary>
- /// 关联商品申报数量-转换显示-格式化
- /// </summary>
- public string RelationNumDisplay
- {
- get { return RelationNum.ToString("f2"); }
- }
- #endregion
- #region 关联交易商品持仓数量[P+X]
- private decimal _relationGoodsHoldQty = decimal.Zero;
- /// <summary>
- /// 关联交易商品持仓数量[P+X]
- /// </summary>
- public decimal RelationGoodsHoldQty
- {
- get
- {
- return _relationGoodsHoldQty;
- }
- set
- {
- Set(() => RelationGoodsHoldQty, ref _relationGoodsHoldQty, value);
- RaisePropertyChanged(() => RelationGoodsHoldQtyDisp);
- RaisePropertyChanged(() => RelationGoodsHoldQtyUnit);
- RaisePropertyChanged(() => IsError);
- }
- }
- private decimal _relationGoodsHoldQty2 = decimal.Zero;
- /// <summary>
- /// 关联交易商品持仓数量[P+X]2
- /// </summary>
- public decimal RelationGoodsHoldQty2
- {
- get
- {
- return _relationGoodsHoldQty2;
- }
- set
- {
- Set(() => RelationGoodsHoldQty2, ref _relationGoodsHoldQty2, value);
- RaisePropertyChanged(() => RelationGoodsHoldQty2Disp);
- RaisePropertyChanged(() => IsError);
- }
- }
- private decimal _relationGoodsHoldQtyUnit = decimal.Zero;
- /// <summary>
- /// 关联交易商品持仓数量-转交割数量
- /// </summary>
- public decimal RelationGoodsHoldQtyUnit
- {
- get
- {
- return _relationGoodsHoldQtyUnit;
- }
- set
- {
- Set(() => RelationGoodsHoldQtyUnit, ref _relationGoodsHoldQtyUnit, value);
- }
- }
- #endregion
- #region 关联交易商品交割价格[P+X]
- private decimal _relationGoodsHoldPrice = decimal.Zero;
- /// <summary>
- /// 关联交易商品交割价格[P+X]
- /// </summary>
- public decimal RelationGoodsHoldPrice
- {
- get
- {
- return _relationGoodsHoldPrice;
- }
- set
- {
- Set(() => RelationGoodsHoldPrice, ref _relationGoodsHoldPrice, value);
- RaisePropertyChanged(() => RelationGoodsHoldPriceFormat);
- }
- }
- private decimal _relationGoodsHoldPrice2 = decimal.Zero;
- /// <summary>
- /// 关联交易商品交割价格[P+X]
- /// </summary>
- public decimal RelationGoodsHoldPrice2
- {
- get
- {
- return _relationGoodsHoldPrice2;
- }
- set
- {
- Set(() => RelationGoodsHoldPrice2, ref _relationGoodsHoldPrice2, value);
- RaisePropertyChanged(() => RelationGoodsHoldPriceFormat2);
- }
- }
- /// <summary>
- /// 关联交易商品交割价格[P+X]格式化
- /// </summary>
- public string RelationGoodsHoldPriceFormat
- {
- get
- {
- if (RelationGoodsHoldPrice > decimal.Zero)
- {
- return RelationGoodsHoldPrice.ToString("f2");
- }
- else
- {
- return "--";
- }
- }
- }
- public string RelationGoodsHoldPriceFormat2
- {
- get
- {
- if (RelationGoodsHoldPrice2 > decimal.Zero)
- {
- return RelationGoodsHoldPrice2.ToString("f2");
- }
- else
- {
- return "--";
- }
- }
- }
- #endregion
- #region 最小交割数量
- private decimal _minDeliveryUnit = 1;
- /// <summary>
- /// 最小交割数量
- /// </summary>
- public decimal MinDeliveryUnit
- {
- get
- {
- return _minDeliveryUnit;
- }
- set
- {
- Set(() => MinDeliveryUnit, ref _minDeliveryUnit, value);
- }
- }
- #endregion
- #region 最大交割数量
- private decimal _maxDeliveryUnit = 1;
- /// <summary>
- /// 最大交割数量
- /// </summary>
- public decimal MaxDeliveryUnit
- {
- get
- {
- return _maxDeliveryUnit;
- }
- set
- {
- Set(() => MaxDeliveryUnit, ref _maxDeliveryUnit, value);
- }
- }
- #endregion
- #region 仓单查询命令
- private RelayCommand<List<KeyValuePair<string,string>>> _searchCommand;
- /// <summary>
- /// 仓单号详细命令
- /// </summary>
- public RelayCommand<List<KeyValuePair<string, string>>> SearchCommand
- {
- get
- {
- return _searchCommand
- ?? (_searchCommand = new RelayCommand<List<KeyValuePair<string, string>>>(
- p =>
- {
- string brandType=string.Empty;
- string qualityType=string.Empty;
- string speciType=string.Empty;
- string warehouseType=string.Empty;
- foreach (KeyValuePair<string, string> item in p)
- {
- if (item.Key.Split('_')[0] == ((int)ePriceMoveType.PRICEMOVETYPE_BRAND).ToString())
- {
- brandType=item.Key;
- }
- if (item.Key.Split('_')[0] == ((int)ePriceMoveType.PRICEMOVETYPE_QUALITY).ToString())
- {
- qualityType = item.Key;
- }
- if (item.Key.Split('_')[0] == ((int)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION).ToString())
- {
- speciType = item.Key;
- }
- if (item.Key.Split('_')[0] == ((int)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE).ToString())
- {
- warehouseType = item.Key;
- }
- }
- List<TradeWRPositionModel> localLst = new List<TradeWRPositionModel>();
- if (string.IsNullOrEmpty(brandType))
- {
- foreach (TradeWRPositionModel item in CachedPairDetailsList)
- {
- localLst.Add(item);
- }
- }
- else
- {
- localLst = CachedPairDetailsList.Where(x => x.BrandType == brandType).ToList();
- }
- if (!string.IsNullOrEmpty(qualityType))
- {
- localLst = localLst.Where(x => x.QualityType == qualityType).ToList();
- }
- if (!string.IsNullOrEmpty(speciType))
- {
- localLst = localLst.Where(x => x.SpecType == speciType).ToList();
- }
- if (!string.IsNullOrEmpty(warehouseType))
- {
- localLst = localLst.Where(x => x.WarehouseType == warehouseType).ToList();
- }
- WrPairDetailsListEx = localLst;
- }));
- }
- }
- #endregion
-
-
- #region 冻结头寸数量
- private decimal _positionFzQty;
- /// <summary>
- /// 冻结头寸数量
- /// </summary>
- public decimal PositionFzQty
- {
- get
- {
- return _positionFzQty;
- }
- set
- {
- Set(() => PositionFzQty, ref _positionFzQty, value);
- }
- }
- #endregion
- #region 申报数量
- private decimal _deliveryCount = decimal.Zero;
- /// <summary>
- /// 申报数量
- /// X数量 = 交割数量 * 最小交割单位 / 合约单位.
- /// </summary>
- public decimal DeliveryCount
- {
- get
- {
- return _deliveryCount;
- }
- set
- {
- Set(() => DeliveryCount, ref _deliveryCount, value);
- if (DeliveryNum > 0)
- {
- MainGoodsToLot();
- RaisePropertyChanged(() => DeliveryCountCalcAlgrithm);
- }
- //MainGoodsToRelationGoodsLot(value);
- //RaisePropertyChanged(() => RelationDeliveryCount);
- //DeclareToDeliveryLot();
- //MainGoodsToLot();
- //RelationGoodsToLot();
- //DeliveryCountEvent();
- }
- }
- public string DeliveryCountCalcAlgrithm
- {
- get
- {
- string calcAlgrithm = string.Empty;
- if (DeliveryNum > 0)
- {
- calcAlgrithm = "(" + DeliveryNumDisplay + "*" + MinDeliveryUnit.ToString() + "*" + CurrentGoods.XDeliveryRatio + "/" + StandardQty.ToString() + ")";
- }
- return calcAlgrithm;
- }
- }
- public string RelationDeliveryCountCalcAlgrithm
- {
- get
- {
- //DeliveryCount
- string calcAlgrithm = string.Empty;
- if (DeliveryNum > 0)
- {
- calcAlgrithm = "(" + DeliveryCount + "*(" + CurrentGoods.PDeliveryRatio1 + "/" + CurrentGoods.XDeliveryRatio + "))";
- //calcAlgrithm = "(" + DeliveryNumDisplay + "*" + MinDeliveryUnit.ToString() + "*" + CurrentGoods.PDeliveryRatio1 + "/(" + StandardQty.ToString() + "*" + CurrentGoods.XDeliveryRatio + "))";
- }
- return calcAlgrithm;
- }
- }
- public string RelationDeliveryCountCalcAlgrithm2
- {
- get
- {
- string calcAlgrithm = string.Empty;
- if (DeliveryNum > 0)
- {
- calcAlgrithm = "(" + DeliveryCount + "*(" + CurrentGoods.PDeliveryRatio2 + "/" + CurrentGoods.XDeliveryRatio + "))";
- //calcAlgrithm = "(" + DeliveryNumDisplay + "*" + MinDeliveryUnit.ToString() + "*" + CurrentGoods.PDeliveryRatio2 + "/(" + StandardQty.ToString() + "*" + CurrentGoods.XDeliveryRatio + "))";
- }
- return calcAlgrithm;
- }
- }
- #endregion
- #region 关联商品申报数量
- private decimal _relationDeliveryCount =decimal.Zero;
- /// <summary>
- /// 关联商品申报数量
- /// P数量 = X数量 * P辅助商品转换系数 / X辅助商品转换系数.
- /// </summary>
- public decimal RelationDeliveryCount
- {
- get
- {
- return _relationDeliveryCount;
- }
- set
- {
- Set(() => RelationDeliveryCount, ref _relationDeliveryCount, value);
- RaisePropertyChanged(() => RelationDeliveryCountDisp);
- RaisePropertyChanged(() => RelationDeliveryCountCalcAlgrithm);
- RelationGoodsToLot();
-
- }
- }
- public string RelationDeliveryCountDisp
- {
- get
- {
- if (RelationDeliveryCount == 0)
- return "--";
- return RelationDeliveryCount.ToString();
- }
- }
- public string RelationGoodsHoldQtyDisp
- {
- get
- {
- if (RelationGoodsHoldQty == 0)
- return "--";
- return RelationGoodsHoldQty.ToString();
- }
- }
- public string RelationGoodsHoldQty2Disp
- {
- get
- {
- if (RelationGoodsHoldQty2 == 0)
- return "--";
- return RelationGoodsHoldQty2.ToString();
- }
- }
- private decimal _relationDeliveryCount2 = decimal.Zero;
- /// <summary>
- /// 关联商品申报数量
- /// P数量 = X数量 * P辅助商品转换系数 / X辅助商品转换系数.
- /// </summary>
- public decimal RelationDeliveryCount2
- {
- get
- {
- return _relationDeliveryCount2;
- }
- set
- {
- Set(() => RelationDeliveryCount2, ref _relationDeliveryCount2, value);
- RaisePropertyChanged(() => RelationDeliveryCountDisp2);
- RaisePropertyChanged(() => RelationDeliveryCountCalcAlgrithm2);
- RelationGoodsToLot();
- }
- }
- public string RelationDeliveryCountDisp2
- {
- get
- {
- if (RelationDeliveryCount2 == 0)
- return "--";
- return RelationDeliveryCount2.ToString();
- }
- }
- #endregion
- #region 持仓汇总
- private decimal _totalHoldDetails;
- /// <summary>
- /// 持仓汇总
- /// </summary>
- public decimal TotalHoldDetails
- {
- get
- {
- return _totalHoldDetails;
- }
- set
- {
- Set(() => TotalHoldDetails, ref _totalHoldDetails, value);
- }
- }
- #endregion
- #region 交割价格
- private string _xpriceFormat;
- public string XPriceFormat
- {
- get
- {
- return _xpriceFormat;
- }
- set
- {
- Set(() => XPriceFormat, ref _xpriceFormat, value);
- }
- }
- private decimal _deliveryPrice = decimal.Zero;
- /// <summary>
- /// 交割价格
- /// </summary>
- public decimal DeliveryPrice
- {
- get
- {
- return _deliveryPrice;
- }
- set
- {
- Set(() => DeliveryPrice, ref _deliveryPrice, value);
- RaisePropertyChanged(() => DeliveryPriceFormat);
- }
- }
- /// <summary>
- /// 交割价格-格式化
- /// </summary>
- public string DeliveryPriceFormat
- {
- get
- {
- if (DeliveryPrice > decimal.Zero)
- {
- return DeliveryPrice.ToString("f2");
- }
- else
- {
- return "--";
- }
- }
- }
- #endregion
- #region 是否忙
- private bool _isBusy;
- /// <summary>
- /// 是否忙
- /// </summary>
- public bool IsBusy
- {
- get { return _isBusy; }
- set { Set(() => IsBusy, ref _isBusy, value); }
- }
- #endregion
- #region 是否忙
- private bool _isBusyWR;
- /// <summary>
- /// 是否忙
- /// </summary>
- public bool IsBusyWR
- {
- get { return _isBusyWR; }
- set { Set(() => IsBusyWR, ref _isBusyWR, value); }
- }
- #endregion
- #region 交割关系表LIST
- private List<GoodsDeliveryRelationModel> _goodsDeliveryRelationList;
- public List<GoodsDeliveryRelationModel> GoodsDeliveryRelationList
- {
- get { return _goodsDeliveryRelationList; }
- set { _goodsDeliveryRelationList = value; }
- }
- #endregion
- #region 当前选择交易商品
- private QuoteGoods _currentGoods;
- /// <summary>
- /// 当前选择交易商品
- /// </summary>
- public QuoteGoods CurrentGoods
- {
- get { return _currentGoods; }
- set
- {
- Set(() => CurrentGoods, ref _currentGoods, value);
- }
- }
- #endregion
- #region 关联交易商品LIST
- private ObservableCollection<string> _relationGoodsNameList = new ObservableCollection<string>();
- /// <summary>
- /// 关联交易商品LIST
- /// </summary>
- public ObservableCollection<string> RelationGoodsNameList
- {
- get { return _relationGoodsNameList; }
- set { Set(() => RelationGoodsNameList, ref _relationGoodsNameList, value); }
- }
- private string _currentRelationGoodsName = string.Empty;
- /// <summary>
- /// Sets and gets the CurrentRelationGoodsName property.
- /// </summary>
- public string CurrentRelationGoodsName
- {
- get
- {
- return _currentRelationGoodsName;
- }
- set
- {
- Set(() => CurrentRelationGoodsName, ref _currentRelationGoodsName, value);
- }
- }
- #endregion
- #region 交割商品LIST
- private ObservableCollection<string> _deliveryGoodsNameList = new ObservableCollection<string>();
- /// <summary>
- /// 交割商品LIST
- /// </summary>
- public ObservableCollection<string> DeliveryGoodsNameList
- {
- get { return _deliveryGoodsNameList; }
- set { Set(() => DeliveryGoodsNameList, ref _deliveryGoodsNameList, value); }
- }
- private string _currentDeliveryGoodsName = string.Empty;
- /// <summary>
- /// Sets and gets the CurrentDeliveryGoodsName property.
- /// </summary>
- public string CurrentDeliveryGoodsName
- {
- get
- {
- return _currentDeliveryGoodsName;
- }
- set
- {
- Set(() => CurrentDeliveryGoodsName, ref _currentDeliveryGoodsName, value);
- }
- }
- #endregion
- #region 买卖方向LIST
- private ObservableCollection<BuyOrSellDirection> _directionList = new ObservableCollection<BuyOrSellDirection>();
- /// <summary>
- /// 买卖方向LIST
- /// </summary>
- public ObservableCollection<BuyOrSellDirection> DirectionList
- {
- get
- {
- _directionList.Clear();
- _directionList.Add(new BuyOrSellDirection() { BuyOrSell = Direction.Bid, BuyOrSellTitle = Resources.Client_Resource.Domain_BuyIn });
- _directionList.Add(new BuyOrSellDirection() { BuyOrSell = Direction.Ask, BuyOrSellTitle = Resources.Client_Resource.Domain_SellOut });
- CurrentBuyOrSell = _directionList.FirstOrDefault();
- return _directionList;
- }
- }
- #endregion
- #region 当前商品的持仓单
- private List<HoldingOrder> _holdDetails;
- /// <summary>
- /// 当前商品的持仓单
- /// </summary>
- public List<HoldingOrder> HoldDetails
- {
- get { return _holdDetails; }
- set { Set(() => HoldDetails, ref _holdDetails, value); }
- }
- #endregion
- #region 当前买卖方向实体
- private BuyOrSellDirection _currentBuyOrSell;
- /// <summary>
- /// 当前买卖方向实体
- /// </summary>
- public BuyOrSellDirection CurrentBuyOrSell
- {
- get
- {
- return _currentBuyOrSell;
- }
- set
- {
- Set(() => CurrentBuyOrSell, ref _currentBuyOrSell, value);
- //SetDeliveryCount();
- }
- }
- #endregion
- #region 当前关联模式
- private eDeliveryContractLink _currentRelationMode = eDeliveryContractLink.None;
- /// <summary>
- /// 当前关联模式
- /// </summary>
- public eDeliveryContractLink CurrentRelationMode
- {
- get
- {
- return _currentRelationMode;
- }
- set
- {
- Set(() => CurrentRelationMode, ref _currentRelationMode, value);
- }
- }
- #endregion
- #region 当前资金模式
- private eMoneyMode _currentMoneyMode = eMoneyMode.MONEYMODE_MARGIN;
- /// <summary>
- /// 当前资金模式
- /// </summary>
- public eMoneyMode CurrentMoneyMode
- {
- get
- {
- return _currentMoneyMode;
- }
- set
- {
- Set(() => CurrentMoneyMode, ref _currentMoneyMode, value);
- }
- }
- #endregion
- #region 交割商品列表
- private List<QuoteGoods> _deliveryGoodsList;
- /// <summary>
- /// 交割商品列表
- /// </summary>
- public List<QuoteGoods> DeliveryGoodsList
- {
- get { return _deliveryGoodsList; }
- set
- {
- Set(() => DeliveryGoodsList, ref _deliveryGoodsList, value);
- }
- }
- #endregion
- #region 错误信息提示
- private string _ShowErrorInfo = string.Empty;
- /// <summary>
- /// Sets and gets the ShowErrorInfo property.
- /// </summary>
- public string ShowErrorInfo
- {
- get
- {
- return _ShowErrorInfo;
- }
- set
- {
- Set(() => ShowErrorInfo, ref _ShowErrorInfo, value);
- }
- }
- private Visibility _IsShowErrorInfo = Visibility.Collapsed;
- /// <summary>
- /// Sets and gets the IsShowErrorInfo property.
- /// </summary>
- public Visibility IsShowErrorInfo
- {
- get
- {
- return _IsShowErrorInfo;
- }
- set
- {
- Set(() => IsShowErrorInfo, ref _IsShowErrorInfo, value);
- }
- }
- #endregion
- #region N 模式需要隐藏字段
- private Visibility _isVisibility_N = Visibility.Collapsed;
- /// <summary>
- /// N 模式需要隐藏字段
- /// </summary>
- public Visibility IsVisibility_N
- {
- get
- {
- return _isVisibility_N;
- }
- set
- {
- Set(() => IsVisibility_N, ref _isVisibility_N, value);
- }
- }
- private Visibility _isVisibility_Type1 = Visibility.Collapsed;
- public Visibility IsVisibility_Type1
- {
- get
- {
- return _isVisibility_Type1;
- }
- set
- {
- Set(() => IsVisibility_Type1, ref _isVisibility_Type1, value);
- }
- }
- private Visibility _isVisibility_Type2 = Visibility.Collapsed;
- public Visibility IsVisibility_Type2
- {
- get
- {
- return _isVisibility_Type2;
- }
- set
- {
- Set(() => IsVisibility_Type2, ref _isVisibility_Type2, value);
- }
- }
- #endregion
- #region P 模式需要隐藏字段
- private Visibility _isVisibility_P = Visibility.Collapsed;
- /// <summary>
- /// P 模式需要隐藏字段
- /// </summary>
- public Visibility IsVisibility_P
- {
- get
- {
- return _isVisibility_P;
- }
- set
- {
- Set(() => IsVisibility_P, ref _isVisibility_P, value);
- }
- }
- #endregion
- #region 升贴水类型查询条件隐藏
- private Visibility _isVisibility_WareHouse = Visibility.Collapsed;
- public Visibility IsVisibility_WareHouse
- {
- get { return _isVisibility_WareHouse; }
- set { Set(() => IsVisibility_WareHouse, ref _isVisibility_WareHouse, value); }
- }
- private Visibility _isVisibility_Brand = Visibility.Collapsed;
- public Visibility IsVisibility_Brand
- {
- get { return _isVisibility_Brand; }
- set { Set(() => IsVisibility_Brand, ref _isVisibility_Brand, value); }
- }
- private Visibility _isVisibility_Quality = Visibility.Collapsed;
- public Visibility IsVisibility_Quality
- {
- get { return _isVisibility_Quality; }
- set { Set(() => IsVisibility_Quality, ref _isVisibility_Quality, value); }
- }
- private Visibility _isVisibility_Spec = Visibility.Collapsed;
- public Visibility IsVisibility_Spec
- {
- get { return _isVisibility_Spec; }
- set { Set(() => IsVisibility_Spec, ref _isVisibility_Spec, value); }
- }
- private Visibility _isVisibility_BtnSearch = Visibility.Collapsed;
- public Visibility IsVisibility_BtnSearch
- {
- get { return _isVisibility_BtnSearch; }
- set { Set(() => IsVisibility_BtnSearch, ref _isVisibility_BtnSearch, value); }
- }
- #endregion
- #region PAndX 模式需要隐藏字段
- private Visibility _isVisibility_PAndX = Visibility.Visible;
- /// <summary>
- /// PAndX 模式需要隐藏字段
- /// </summary>
- public Visibility IsVisibility_PAndX
- {
- get
- {
- return _isVisibility_PAndX;
- }
- set
- {
- Set(() => IsVisibility_PAndX, ref _isVisibility_PAndX, value);
- }
- }
- #endregion
- #region N 模式需要显示字段
- private Visibility _isVisibility_Only_N = Visibility.Collapsed;
- /// <summary>
- /// N 模式需要显示字段
- /// </summary>
- public Visibility IsVisibility_Only_N
- {
- get
- {
- return _isVisibility_Only_N;
- }
- set
- {
- Set(() => IsVisibility_Only_N, ref _isVisibility_Only_N, value);
- }
- }
- #endregion
- #region 买卖方向选择是否可用
- private bool _isEnable_Direction = false;
- /// <summary>
- /// 买卖方向选择是否可用
- /// </summary>
- public bool IsEnable_Direction
- {
- get
- {
- return _isEnable_Direction;
- }
- set
- {
- Set(() => IsEnable_Direction, ref _isEnable_Direction, value);
- }
- }
- #endregion
- #region 【置灰】设置按键不可用
- private bool _oKButtonEnabled = false;
- /// <summary>
- ///设置按键不可用
- /// </summary>
- public bool OKButtonEnabled
- {
- get
- {
- return _oKButtonEnabled;
- }
- set
- {
- Set(() => OKButtonEnabled, ref _oKButtonEnabled, value);
- }
- }
- #endregion
- #region 提货方式
- private TakeGoodsWay _takeGoodsWay;
- /// <summary>
- /// 提货方式
- /// </summary>
- public TakeGoodsWay TakeGoodsWay
- {
- get { return _takeGoodsWay; }
- set { Set(() => TakeGoodsWay, ref _takeGoodsWay, value); }
- }
- #endregion
- #region 身份证
- private string _idCardNum;
- /// <summary>
- /// 身份证号
- /// </summary>
- public string IdCardNum
- {
- get { return _idCardNum; }
- set { Set(() => IdCardNum, ref _idCardNum, value); }
- }
- #endregion
-
-
- #endregion "Public Properties To Get/Set "
- #region "=========公共命令/Public Commands"
- /// <summary>
- /// 下单窗口取消
- /// </summary>
- public RelayCommand<Window> CancelCommand
- {
- get
- {
- return new RelayCommand<Window>((dialog) =>
- {
- dialog.DialogResult = false;
- });
- }
- }
- /// <summary>
- /// 下单确定
- /// </summary>
- public RelayCommand<Window> OKCommand
- {
- get
- {
- return new RelayCommand<Window>((dialog) =>
- {
- OKButtonEnabled = false;
- string errorMsg = string.Empty;
- bool validateBool = true; ////内容验证
- if (validateBool)
- {
- //BusyContent = Client_Resource.Content_Busy;
- //IsBusy = true;
- _openWindow = dialog;
- GetDataBeforeSubmit();
- var newOrder = new DeliveryOrderReqModel()
- {
- AccountID = AccountID,
- EntrustTime = ApplicationParameter.ServerTimeNow,
- DeliveryGoodsID = DeliveryGoodsID,
- DeliveryQty = (ulong)submitDeliveryQty,
-
- OperatorID = (uint)AccountID,
- PGoodsID = P1GoodsID,
- PQty = ulong.Parse((RelationDeliveryCountDisp == "--") ? "0" : RelationDeliveryCountDisp),
- P2GoodsID = P2GoodsID,
- P2Qty = ulong.Parse((RelationDeliveryCountDisp2 == "--") ? "0" : RelationDeliveryCountDisp2),
- XGoodsID = XGoodsID,
- XQty = (ulong)DeliveryCount,
- };
- foreach (var writem in CurrentSelectedWrDetail)
- {
- newOrder.wrDetail = writem;
- _deliveryService.DeliveryApplyOrder(newOrder, null, null);
- }
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- OKButtonEnabled = true;
- MessageBoxHelper.ShowSuccess("交割申请已提交",
- Client_Resource.UI2014_Tips);
- if (_openWindow != null)
- {
- _openWindow.Close();
- this.Cleanup();
- }
- }));
- }
- else
- {
- MessageBoxHelper.ShowInfo(errorMsg, Client_Resource.MessageBox_Error_Title);
- OKButtonEnabled = true;
- }
- });
- }
- }
- #region 选中Command
- /// <summary>
- /// 选中
- /// </summary>
- private RelayCommand<TradeWRPositionModel> selectCommand;
- public RelayCommand<TradeWRPositionModel> SelectCommand
- {
- get
- {
- return selectCommand ?? (selectCommand = new RelayCommand<TradeWRPositionModel>(
- (x) =>
- {
- if (_action == false)
- {
- _action = true;
- x.IsEnable = true;
- CurrentSelectedWhRecieptEx = x;
- SettlementDeliveryMatchNum(CommandFromType.SelectedCommand);
- _action = false;
- }
-
- }));
- }
- }
- #endregion
- #region 取消选中Command
- /// <summary>
- /// 取消选中
- /// </summary>
- private RelayCommand<TradeWRPositionModel> unSelectCommand;
- public RelayCommand<TradeWRPositionModel> UnSelectCommand
- {
- get
- {
- return unSelectCommand ?? (unSelectCommand = new RelayCommand<TradeWRPositionModel>(
- (x) =>
- {
- if (_action == false)
- {
- _action = true;
- CurrentSelectedWhRecieptEx = x;
- CurrentSelectedWhRecieptEx.SelectQty = 0;
- CurrentSelectedWhRecieptEx.SelectedQty = "0";
- SettlementDeliveryMatchNum(CommandFromType.UnSelectedCommand);
- _action = false;
- }
-
- }));
- }
- }
- #endregion
- #region 文本改变命令Command
- private RelayCommand<TradeWRPositionModel> _selectQtyTextChangedCommand;
- /// <summary>
- /// 文本改变命令Command
- /// </summary>
- public RelayCommand<TradeWRPositionModel> SelectQtyTextChangedCommand
- {
- get
- {
- return _selectQtyTextChangedCommand
- ?? (_selectQtyTextChangedCommand = new RelayCommand<TradeWRPositionModel>(
- p =>
- {
- if (_action == false)
- {
- _action = true;
- CurrentSelectedWhRecieptEx = p;
- SettlementDeliveryMatchNum(CommandFromType.TextCommand);
- _action = false;
- }
-
- }));
- }
- }
- #endregion
- #endregion "Public Commands"
- #region WarehouseSelectionChangedCommand
- private RelayCommand _warehouseSelectionChanged;
- /// <summary>
- /// Gets the WarehouseSelectionChanged.
- /// </summary>
- public RelayCommand WarehouseSelectionChanged
- {
- get
- {
- return _warehouseSelectionChanged
- ?? (_warehouseSelectionChanged = new RelayCommand(
- () =>
- {
- if (!string.IsNullOrEmpty(SelectedWareHouse.Key))
- {
- FilterList.Clear();
- if (SelectedWareHouse.Key != "0")
- {
- FilterList.Add(SelectedWareHouse);
- }
- if (!string.IsNullOrEmpty(SelectedBrand.Key) && SelectedBrand.Key != "0")
- {
- FilterList.Add(SelectedBrand);
- }
- if (!string.IsNullOrEmpty(SelectedQuality.Key) && SelectedQuality.Key != "0")
- {
- FilterList.Add(SelectedQuality);
- }
- if (!string.IsNullOrEmpty(SelectedSpeci.Key) && SelectedSpeci.Key != "0")
- {
- FilterList.Add(SelectedSpeci);
- }
- }
- }));
- }
- }
- #endregion
- #region BrandSelectionChanged
- private RelayCommand _brandSelectionChanged;
- /// <summary>
- /// Gets the BrandSelectionChanged.
- /// </summary>
- public RelayCommand BrandSelectionChanged
- {
- get
- {
- return _brandSelectionChanged
- ?? (_brandSelectionChanged = new RelayCommand(
- () =>
- {
- if (!string.IsNullOrEmpty(SelectedBrand.Key))
- {
- FilterList.Clear();
- if (SelectedBrand.Key != "0")
- {
- FilterList.Add(SelectedBrand);
- }
- if (!string.IsNullOrEmpty(SelectedWareHouse.Key) && SelectedWareHouse.Key != "0")
- {
- FilterList.Add(SelectedWareHouse);
- }
- if (!string.IsNullOrEmpty(SelectedQuality.Key) && SelectedQuality.Key != "0")
- {
- FilterList.Add(SelectedQuality);
- }
- if (!string.IsNullOrEmpty(SelectedSpeci.Key) && SelectedSpeci.Key != "0")
- {
- FilterList.Add(SelectedSpeci);
- }
- }
- }));
- }
- }
- #endregion
- #region QualitySelectionChangedCommand
- private RelayCommand _qualitySelectionChanged;
- /// <summary>
- /// Gets the RankSelectionChangedCommand.
- /// </summary>
- public RelayCommand QualitySelectionChanged
- {
- get
- {
- return _qualitySelectionChanged
- ?? (_qualitySelectionChanged = new RelayCommand(
- () =>
- {
- if (!string.IsNullOrEmpty(SelectedQuality.Key))
- {
- FilterList.Clear();
- if (SelectedQuality.Key != "0")
- {
- FilterList.Add(SelectedQuality);
- }
- if (!string.IsNullOrEmpty(SelectedWareHouse.Key) && SelectedWareHouse.Key != "0")
- {
- FilterList.Add(SelectedWareHouse);
- }
- if (!string.IsNullOrEmpty(SelectedBrand.Key) && SelectedBrand.Key != "0")
- {
- FilterList.Add(SelectedBrand);
- }
- if (!string.IsNullOrEmpty(SelectedSpeci.Key) && SelectedSpeci.Key != "0")
- {
- FilterList.Add(SelectedSpeci);
- }
- }
- }));
- }
- }
- #endregion
- #region SpeciSelectionChangedCommand
- private RelayCommand _speciSelectionChanged;
- /// <summary>
- /// Gets the RankSelectionChangedCommand.
- /// </summary>
- public RelayCommand SpeciSelectionChanged
- {
- get
- {
- return _speciSelectionChanged
- ?? (_speciSelectionChanged = new RelayCommand(
- () =>
- {
- if (!string.IsNullOrEmpty(SelectedSpeci.Key))
- {
- FilterList.Clear();
- if (SelectedSpeci.Key != "0")
- {
- FilterList.Add(SelectedSpeci);
- }
- if (!string.IsNullOrEmpty(SelectedWareHouse.Key) && SelectedWareHouse.Key != "0")
- {
- FilterList.Add(SelectedWareHouse);
- }
- if (!string.IsNullOrEmpty(SelectedBrand.Key) && SelectedBrand.Key != "0")
- {
- FilterList.Add(SelectedBrand);
- }
- if (!string.IsNullOrEmpty(SelectedQuality.Key) && SelectedQuality.Key != "0")
- {
- FilterList.Add(SelectedQuality);
- }
- }
- }));
- }
- }
- #endregion
- #region "=========私有方法/Private Methods"
- /// <summary>
- /// 勾选仓单处理
- /// </summary>
- /// <param name="commandType"></param>
- private void SettlementDeliveryMatchNum(CommandFromType commandType)
- {
- switch (commandType)
- {
- case CommandFromType.TextCommand:
- CurrentSelectedWhRecieptEx.SelectedQty = (CurrentSelectedWhRecieptEx.SelectQty * StandardQty).ToString();
- //SelectQtyTextChangedHandleEvent();
- break;
- case CommandFromType.SelectedCommand:
- CurrentSelectedWhRecieptEx.SelectedQty = (CurrentSelectedWhRecieptEx.SelectQty * StandardQty).ToString();
- break;
- case CommandFromType.UnSelectedCommand:
- CurrentSelectedWhRecieptEx.IsEnable = false;
- break;
- default:
- break;
- }
- CtrlDeliveryQtyChangeEvent();
-
-
- }
- /// <summary>
- /// 控制点选仓单时候,交割数量的变化事件
- /// </summary>
- private void CtrlDeliveryQtyChangeEvent()
- {
- OKButtonEnabled = false;
- var sourceList = WrPairDetailsListEx.FindAll(p => p.IsSelected == true);
- DeliveryNum = decimal.Zero;
- if (sourceList != null && sourceList.Count > 0)
- {
- foreach (var item in sourceList)
- {
- DeliveryNum += Convert.ToDecimal(item.SelectQty) * StandardQty;
- }
- }
- if (DeliveryNum != decimal.Zero)
- {
- OKButtonEnabled = true;//是否已经点选仓单且数量大于零
- }
-
-
- }
- /// <summary>
- /// DataGrid 选择文本改变处理事件
- /// </summary>
- private void SelectQtyTextChangedHandleEvent()
- {
- if (CurrentSelectedWhRecieptEx.SelectQty>0)
- {
- CurrentSelectedWhRecieptEx.IsSelected = true;
- }
- else
- {
- CurrentSelectedWhRecieptEx.IsSelected = false;
- }
-
- }
- /// <summary>
- /// 提交数据前获取选择的仓单ID/数量
- /// </summary>
- private void GetDataBeforeSubmit()
- {
- if (CurrentSelectedWrDetail != null)
- {
- CurrentSelectedWrDetail.Clear();
- }
- var sourceList = WrPairDetailsListEx.FindAll(p => p.IsSelected == true);
- submitDeliveryQty = decimal.Zero;//点选的交割总数量
- foreach (var item in sourceList)
- {
- if (!CurrentSelectedWrDetail.Any(x => x.WRPositionID == item.WRPositionID))
- {
- var newWrDetail = getWrItem(item.WRPositionID);
- CurrentSelectedWrDetail.Add(newWrDetail);
- submitDeliveryQty += (decimal)newWrDetail.Qty;
- }
- }
- }
- /// <summary>
- /// 获取指定WrDetailModel实例
- /// </summary>
- /// <returns></returns>
- private WrDetailModel getWrItem(ulong wrcode)
- {
- var selectItem = WrPairDetailsListEx.Where(x => x.WRPositionID == wrcode).FirstOrDefault();
- var item = new WrDetailModel()
- {
- AccountID=selectItem.AccountID,
- BrandID=selectItem.BrandID,
- DeliveryMonthID=selectItem.DeliveryMonthID,
- Qty=ulong.Parse(selectItem.SelectedQty),
- QualityID=selectItem.QualityID,
- StandardID=selectItem.SpecID,
- WarehouseID=selectItem.WarehouseID
- };
- return item;
- }
- /// <summary>
- /// 触发提交按钮是否可用
- /// </summary>
- private void IsEnableButtonEvent()
- {
- //交易员账户,且商品是做市商品时,不可以发起交割申报
- OKButtonEnabled = false;
- if (_currentDirection == Direction.Ask)
- {
- if (CurrentSelectedWrDetail != null
- && CurrentSelectedWrDetail.Any()
- && CurrentSelectedWrDetail.Count() > 0
- //&& AlreadyMatchQty == preOtherCanMatchQty
- && CurrentGoods != null
- //&& FreezeDeliveryMoney <= usableFunds
- && DeliveryCount <= MaxDeliveryUnit && DeliveryCount > 0
- && (UserManager.CurrentTradeAccount.AccountType == eUserType.USERTYPE_INVESTOR )//|| CurrentGoods.currentTradeMode != eTradeMode.TRADEMODE_MARKETMAKE)
- )
- {
- OKButtonEnabled = true;
- }
- else
- {
- OKButtonEnabled = false;
- }
- }
- else
- {
- if (MaxDeliveryUnit <= 0 || MinDeliveryUnit <= 0 || CurrentGoods == null
- || DeliveryCount > MaxDeliveryUnit || DeliveryCount <= 0
- || (RelationDeliveryCount > RelationGoodsHoldQty && CurrentRelationMode == eDeliveryContractLink.PAndX)
- || (MinDeliveryUnit != 0 && DeliveryCount % MinDeliveryUnit != 0 )
- )
- {
- OKButtonEnabled = false;
- }
- else
- {
- OKButtonEnabled = true;
- }
- }
- }
- private void DeliveryCountEvent()
- {
- ShowErrorInfo = string.Empty;
- IsError_DeliveryCount = false;
- IsError_RelationDeliveryCount = false;
- IsError_RelationDeliveryCount2 = false;
- if (CurrentGoods != null)
- {
- //if (FreezeDeliveryMoney > usableFunds)
- //{
- // ShowErrorInfo = Client_Resource.DeliveryOrderViewModel_usableFundsNotEnough;// "资金不足,请修改交割数量";
- //}
- var maxQty = Math.Min(AvailHoldQty, MaxDeliveryUnit);
- if (MinDeliveryUnit != 0 && DeliveryCount % MinDeliveryUnit != 0)
- {
- IsError_DeliveryCount = true;
- ShowErrorInfo = string.Format(Client_Resource.DeliveryOrderViewModel_MaxMin_Error, MinDeliveryUnit, maxQty, MinDeliveryUnit);// 申报数量需小于可用数量,且为最小交割数量{***}的整数倍
- }
- if (DeliveryCount > MaxDeliveryUnit || DeliveryCount < MinDeliveryUnit)
- {
- IsError_DeliveryCount = true;
- ShowErrorInfo = string.Format(Client_Resource.DeliveryOrderViewModel_MaxMin_Error, MinDeliveryUnit, maxQty, MinDeliveryUnit);// 申报数量应当在最小申报数量{0}与最大申报数量之间。
- }
- if (RelationDeliveryCount > RelationGoodsHoldQty && CurrentRelationMode == eDeliveryContractLink.PAndX)
- {
- IsError_RelationDeliveryCount = true;
- ShowErrorInfo = Client_Resource.DeliveryOrderViewModel_RelationHolderNotEnough;// 关联商品可用数量不足,请修改申报数量
- }
- //if ((UserManager.CurrentTradeAccount.AccountType == eLoginUserType.LOGINUSERTYPE_TRADER && CurrentGoods.currentTradeMode == eTradeMode.TRADEMODE_MARKETMAKE))
- //{
- // ShowErrorInfo = Client_Resource.DeliveryOrderViewModel_AccountTypeNotEnough;// "交易员账户,且商品是做市商品时,不可以发起交割申报";
- //}
- // IsEnableButtonEvent();
- }
-
-
- }
- /// <summary>
- /// 提交成功返回
- /// </summary>
- /// <param name="order"></param>
- private void EntrurstSuccessCallBack(DeliveryOrderRspModel order)
- {
- //IsBusy = false;
- //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- //{
- // OKButtonEnabled = true;
- // MessageBoxHelper.ShowSuccess(Client_Resource.Order_Success_Result,
- // Client_Resource.UI2014_Tips);
- // if (_openWindow != null)
- // {
- // _openWindow.Close();
- // this.Cleanup();
- // }
- //}));
- //刷新正常单
- MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.OrderNoticeToken);
- }
- /// <summary>
- /// 委托失败返回
- /// </summary>
- /// <param name="errorEntity"></param>
- private void EntrurstErrorCallBack(ErrorEntity errorEntity)
- {
- IsBusy = false;
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- OKButtonEnabled = true;
- ErrorManager.ShowReturnError(errorEntity, Client_Resource.UI2014_Tips, true);
- if (_openWindow != null)
- {
- _openWindow.Close();
- MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.HolderUpdate);
- this.Cleanup();
- }
- }));
- }
- /// <summary>
- /// 初始化交割商品列表数据
- /// </summary>
- private void InitData(DeliveryOrderMessage parameterInfo)
- {
- IsBusy = true;
- XGoodsID = parameterInfo.GoodsId;
- AccountID = parameterInfo.AccountID;
- Direction buyOrSell = parameterInfo.Direction;
- CurrentGoods = CacheManager.CacheGoodsBaseInfos.FirstOrDefault(p => p.GoodsId == XGoodsID);
- XGoodsCode = CurrentGoods.GoodsCode;
- XGoodsName = CurrentGoods.Name;
- this._goodsItem = new QuoteGoodsDTO(CurrentGoods);
- XPriceFormat = this._goodsItem.CurrentPriceDisplay;
- string deliveryFactorTips = string.Empty;
- var goodsPMLst = CurrentGoods.GoodsPMList;
- if (goodsPMLst != null)
- {
- foreach (var pm in goodsPMLst)
- {
- string pmTip = string.Empty;
- if (pm.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_BRAND)
- {
- pmTip = "品牌:";
- }
- else if (pm.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_QUALITY)
- {
- pmTip = "品质:";
- }
- else if (pm.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION)
- {
- pmTip = "规格:";
- }
- else if (pm.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE)
- {
- pmTip = "仓库:";
- }
- pmTip += pm.PriceMoveDesc;
- deliveryFactorTips += pmTip + ", ";
- }
- if (deliveryFactorTips.Length > 0)
- {
- deliveryFactorTips = deliveryFactorTips.Substring(0, deliveryFactorTips.Length - 5);
- }
- }
- DeliveryFactor = deliveryFactorTips;
-
- var currentHolding = CacheManager.HoldingSummaries[AccountID].FirstOrDefault(p => p.GoodsId == XGoodsID);
- if (currentHolding != null)
- {
- if (buyOrSell == Direction.Bid)
- {
- this.AvailHoldQty = currentHolding.BuyCurPositionQty - currentHolding.BuyFrozenQty - currentHolding.BuyOtherFrozenQty;
- }
- else
- {
- this.AvailHoldQty = currentHolding.SellCurPositionQty = currentHolding.SellFrozenQty - currentHolding.SellOtherFrozenQty;
- }
- }
- if (CurrentGoods.P1Type == uint.MaxValue && CurrentGoods.P2Type == uint.MaxValue)
- {
- IsVisibility_P = Visibility.Collapsed;
- IsVisibility_Type1 = Visibility.Collapsed;
- IsVisibility_Type2 = Visibility.Collapsed;
- }
- else
- {
- IsVisibility_P = Visibility.Visible;
- if (CurrentGoods.P1Type != uint.MaxValue)
- {
- IsVisibility_Type1 = Visibility.Visible;
- if (CurrentGoods.P1Type == 1)
- {
- var currentP1 = CacheManager.CacheGoodsBaseInfos.FirstOrDefault(p => p.GoodsId == CurrentGoods.PGoodsID1);
- var P1Holding = CacheManager.HoldingSummaries[AccountID].FirstOrDefault(p => p.GoodsId == CurrentGoods.PGoodsID1);
- if (P1Holding != null)
- {
- if (buyOrSell == Direction.Bid)
- {
- this.RelationGoodsHoldQty = P1Holding.BuyCurPositionQty - P1Holding.BuyFrozenQty - P1Holding.BuyOtherFrozenQty;
- }
- else
- {
- this.RelationGoodsHoldQty = P1Holding.SellCurPositionQty - P1Holding.SellFrozenQty - P1Holding.SellOtherFrozenQty;
- }
- }
- P1GoodsName = currentP1.Name;
- P1GoodsCode = currentP1.GoodsCode;
- P1GoodsID = currentP1.GoodsId;
- }
- else
- {
- P1GoodsName = "固定价";
- RelationGoodsHoldPrice = CurrentGoods.P1value;
- }
- }
- else
- {
- IsVisibility_Type1 = Visibility.Collapsed;
- }
- if (CurrentGoods.P2Type != uint.MaxValue)
- {
- IsVisibility_Type2 = Visibility.Visible;
- if (CurrentGoods.P2Type == 1)
- {
- var currentP2 = CacheManager.CacheGoodsBaseInfos.FirstOrDefault(p => p.GoodsId == CurrentGoods.PGoodsID2);
- var P2Holding = CacheManager.HoldingSummaries[AccountID].FirstOrDefault(p => p.GoodsId == CurrentGoods.PGoodsID2);
- if (P2Holding != null)
- {
- if (buyOrSell == Direction.Bid)
- {
- this.RelationGoodsHoldQty2 = P2Holding.BuyCurPositionQty - P2Holding.BuyFrozenQty - P2Holding.BuyOtherFrozenQty;
- }
- else
- {
- this.RelationGoodsHoldQty2 = P2Holding.SellCurPositionQty = P2Holding.SellFrozenQty - P2Holding.SellOtherFrozenQty;
- }
- }
- P2GoodsName = currentP2.Name;
- P2GoodsCode = currentP2.GoodsCode;
- P2GoodsID = currentP2.GoodsId;
- }
- else
- {
- P2GoodsName = "固定价";
- RelationGoodsHoldPrice2 = CurrentGoods.P2value;
- }
- }
- else
- {
- IsVisibility_Type2 = Visibility.Collapsed;
- }
- }
- DeliveryGoodsName = CurrentGoods.DeliveryGoodsName;
- DeliveryGoodsCode = CurrentGoods.DeliveryGoodsCode;
- DeliveryGoodsNameCode = CurrentGoods.DeliveryGoodsNameCode;
- uint DeliveryGoodsID = CurrentGoods.DeliveryGoodsId;
- uint TradeProperty = (uint)CurrentGoods.TradeProperty;
- _deliveryService.QueryDeliveryWarehouseOrdersNew(XGoodsID, DeliveryGoodsID, TradeProperty, QuerySuccessCallBackNew, QueryErrorCallbackNew);
- }
- private void QuerySuccessCallBackNew(DeliveryWRRspModel model)
- {
- var currentDeliveryGoods = CacheManager.CacheDeliveryGoodsInfo.FirstOrDefault(p => p.DeliveryGoodsCode == DeliveryGoodsCode);
- StandardQty = currentDeliveryGoods.StandardQty;
- DeliveryGoodsID = currentDeliveryGoods.DeliveryGoodsID;
- List<GoodsDryPriceModel> goodsDryLst = model.GoodsDeliveryPriceList;
- List<TradeWRPositionModel> tradeWRPositionLst = model.TradeWRPositionList;
- List<PriceMoveModel> AllFilterLst = currentDeliveryGoods.DeliveryGoodsPMList;
- List<PriceMoveModel> ExceptFilterLst = CurrentGoods.GoodsPMList;
- foreach (var item in ExceptFilterLst)
- {
- AllFilterLst = AllFilterLst.FindAll(p => p.PriceMoveType != item.PriceMoveType);
- }
- if (AllFilterLst != null && AllFilterLst.Count > 0)
- {
- IsVisibility_BtnSearch=Visibility.Visible;
- var brandLst = AllFilterLst.FindAll(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_BRAND);
- if (brandLst.Count > 0)
- {
- IsVisibility_Brand = Visibility.Visible;
- DeliveryBrandList = brandLst.Select(p => { return new KeyValuePair<string, string>(p.PriceMoveType +"_"+ p.PriceMoveID.ToString(), p.PriceMoveDesc); }).ToList();
- SelectedBrand = new KeyValuePair<string, string>("0", "所有品牌");
- DeliveryBrandList.Insert(0, SelectedBrand);
- }
- else
- {
- IsVisibility_Brand = Visibility.Collapsed;
- }
- var qualityLst = AllFilterLst.FindAll(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_QUALITY);
- if (qualityLst.Count > 0)
- {
- IsVisibility_Quality = Visibility.Visible;
- DeliveryQualityList = qualityLst.Select(p => { return new KeyValuePair<string, string>(p.PriceMoveType +"_"+ p.PriceMoveID.ToString(), p.PriceMoveDesc); }).ToList();
- SelectedQuality = new KeyValuePair<string, string>("0", "所有品质");
- DeliveryQualityList.Insert(0, SelectedQuality);
- }
- else
- {
- IsVisibility_Quality = Visibility.Collapsed;
- }
- var speciLst = AllFilterLst.FindAll(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION);
- if (speciLst.Count > 0)
- {
- IsVisibility_Spec = Visibility.Visible;
- DeliverySpeciList = speciLst.Select(p => { return new KeyValuePair<string, string>(p.PriceMoveType +"_"+ p.PriceMoveID.ToString(), p.PriceMoveDesc); }).ToList();
- SelectedSpeci = new KeyValuePair<string, string>("0", "所有规格");
- DeliverySpeciList.Insert(0, SelectedSpeci);
- }
- else
- {
- IsVisibility_Spec = Visibility.Collapsed;
- }
- var warehouseLst = AllFilterLst.FindAll(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE);
- if (warehouseLst.Count > 0)
- {
- IsVisibility_WareHouse = Visibility.Visible;
- List<KeyValuePair<string, string>> wareLst = warehouseLst.Select(p => { return new KeyValuePair<string, string>(p.PriceMoveType +"_"+ p.PriceMoveID.ToString(), p.PriceMoveDesc); }).ToList();
- SelectedWareHouse = new KeyValuePair<string, string>("0", "所有仓库");
- wareLst.Insert(0, SelectedWareHouse);
- DeliveryWarehouseList = new ObservableCollection<KeyValuePair<string, string>>(wareLst);
- }
- else
- {
- IsVisibility_WareHouse = Visibility.Collapsed;
- }
- }
- else
- {
- IsVisibility_Brand = Visibility.Collapsed;
- IsVisibility_Quality = Visibility.Collapsed;
- IsVisibility_Spec = Visibility.Collapsed;
- IsVisibility_WareHouse = Visibility.Collapsed;
- IsVisibility_BtnSearch = Visibility.Collapsed;
- }
- foreach (var tradeWR in tradeWRPositionLst)
- {
- tradeWR.BrandName = currentDeliveryGoods.DeliveryGoodsPMList.FirstOrDefault(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_BRAND && p.PriceMoveID == tradeWR.BrandID).PriceMoveDesc;
- tradeWR.BrandType = ((int)ePriceMoveType.PRICEMOVETYPE_BRAND).ToString() +"_"+ tradeWR.BrandID;
- tradeWR.MaximunQty = (uint)tradeWR.RestQty / (uint)StandardQty;
- tradeWR.QualityName = currentDeliveryGoods.DeliveryGoodsPMList.FirstOrDefault(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_QUALITY && p.PriceMoveID == tradeWR.QualityID).PriceMoveDesc;
- tradeWR.QualityType = ((int)ePriceMoveType.PRICEMOVETYPE_QUALITY).ToString() +"_"+ tradeWR.QualityID;
- tradeWR.SpecName = currentDeliveryGoods.DeliveryGoodsPMList.FirstOrDefault(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION && p.PriceMoveID == tradeWR.SpecID).PriceMoveDesc;
- tradeWR.SpecType = ((int)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION).ToString() +"_"+ tradeWR.SpecID;
- tradeWR.WarehouseName = currentDeliveryGoods.DeliveryGoodsPMList.FirstOrDefault(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE && p.PriceMoveID == tradeWR.WarehouseID).PriceMoveDesc;
- tradeWR.WarehouseType = ((int)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE).ToString() + "_" + tradeWR.WarehouseID;
- var brand = goodsDryLst.FirstOrDefault(p => p.PriceMoveType == ((uint)ePriceMoveType.PRICEMOVETYPE_BRAND).ToString() && p.PriceMoveID == tradeWR.BrandID);
- if (brand != null)
- {
- tradeWR.PriceMove += brand.PriceMoveValue;
- }
- var quality = goodsDryLst.FirstOrDefault(p => p.PriceMoveType == ((uint)ePriceMoveType.PRICEMOVETYPE_QUALITY).ToString() && p.PriceMoveID == tradeWR.QualityID);
- if (quality != null)
- {
- tradeWR.PriceMove += quality.PriceMoveValue;
- }
- var speci = goodsDryLst.FirstOrDefault(p => p.PriceMoveType == ((uint)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION).ToString() && p.PriceMoveID == tradeWR.SpecID);
- if (speci != null)
- {
- tradeWR.PriceMove += speci.PriceMoveValue;
- }
- var warehouse = goodsDryLst.FirstOrDefault(p => p.PriceMoveType == ((uint)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE).ToString() && p.PriceMoveID == tradeWR.WarehouseID);
- if (warehouse != null)
- {
- tradeWR.PriceMove += warehouse.PriceMoveValue;
- }
- }
- WrPairDetailsListEx = tradeWRPositionLst;
- CachedPairDetailsList = tradeWRPositionLst;
- IsBusy = false;
- }
- private void QueryErrorCallbackNew(ErrorEntity error)
- {
- IsBusy = false;
- }
- /// <summary>
- /// 检测卖方向是否可用
- /// </summary>
- private void CheckIsSellEnable()
- {
- IsEnable_Direction = false;
- //if (CurrentGoods != null)
- //{
- // var currentGoodsTradeMode = CurrentGoods.TradeMode;
- // var tempAvailHoldQty = LoadingHolder(CurrentGoods.RelationGoodsId, Direction.Ask);
- // //无卖持仓时,卖方向不可选置灰,仅竞价与混合-保证金商品-才可以发起卖交割
- // if (tempAvailHoldQty > decimal.Zero && CurrentGoods != null && CurrentGoods.Sponsor == eSponsorType.Both && CurrentMoneyMode == eMoneyMode.MONEYMODE_MARGIN && (currentGoodsTradeMode == eTradeMode.TRADEMODE_BIDDING || currentGoodsTradeMode == eTradeMode.TRADEMODE_BIDDINGMARKETMAKE))
- // {
- // IsEnable_Direction = true;
- // }
- //}
- }
- /// <summary>
- /// 加载最大最小交割数量
- /// </summary>
- private void MinMaxDeliveryLot()
- {
- if (CurrentGoods != null)
- {
- var maxQty = _goodsService.GetGoodsParamerRule((int)CurrentGoods.GoodsId,
- CurrentGoods.TradeMode, GoodsTradeConts.MaxDeliveryQty);
- var minQty = _goodsService.GetGoodsParamerRule((int)CurrentGoods.GoodsId,
- CurrentGoods.TradeMode, GoodsTradeConts.MinDeliveryQty);
- MinDeliveryUnit = minQty == null ? defaut_minLot : minQty.FeeValue;
- MaxDeliveryUnit = maxQty == null ? defaut_maxLot : maxQty.FeeValue;
- MaxDeliveryUnit = Math.Min((AvailHoldQty - AvailHoldQty % MinDeliveryUnit), MaxDeliveryUnit);
- #region #33584 最小交收数量(手数),最大交收数量(手数)改从申报商品的交易规则中取
- //MinDeliveryUnit = CurrentGoods.minDeliveryQty;
- ////最小交割手数转换为交易手数
- //MinDeliveryUnit = Math.Round(MinDeliveryUnit * CurrentGoods.Conversion, 2, MidpointRounding.AwayFromZero);
- //MaxDeliveryUnit = CurrentGoods.maxDeliveryQty;
- ////最大交割手数转换为交易手数
- //var tempMaxDeliveryUnit = Math.Round(MaxDeliveryUnit * CurrentGoods.Conversion, 2, MidpointRounding.AwayFromZero);
- //MaxDeliveryUnit = tempMaxDeliveryUnit - tempMaxDeliveryUnit % MinDeliveryUnit;
- //MaxDeliveryUnit = Math.Min((AvailHoldQty - AvailHoldQty % MinDeliveryUnit), MaxDeliveryUnit);
- #endregion
- DeliveryCount = (MinDeliveryUnit == decimal.Zero ? 1 : MinDeliveryUnit);//默认设置下单数量
- }
- else
- {
- MinDeliveryUnit = defaut_minLot;
- MaxDeliveryUnit = defaut_maxLot;
- }
-
- }
- /// <summary>
- /// 申报数量转交割数量
- /// 交割数量 = 申报商品的申报手数 * 申报商品合约单位 * 兑换系数;
- /// </summary>
- private void DeclareToDeliveryLot()
- {
- if (CurrentGoods != null)
- {
- DeliveryNum = (int)(DeliveryCount / CurrentGoods.PDeliveryRatio1) * CurrentGoods.MinDeliveryQty;//CurrentGoods.currentAgreeunit * CurrentGoods.Conversion;
- }
- }
- /// <summary>
- /// 主商品申报手数-转-数量
- /// </summary>
- private void MainGoodsToLot()
- {
- if (CurrentGoods != null)
- {
- GoodsNum = DeliveryCount* CurrentGoods.AgreeUnit;
- }
- }
- /// <summary>
- /// 关联商品申报手数-转-数量
- /// </summary>
- private void RelationGoodsToLot()
- {
- //if (CurrentGoods != null && (eDeliveryContractLink)CurrentGoods.RelationMode == eDeliveryContractLink.PAndX)
- //{
- // var RelationGoodsItem = FindRelationGoodsInfoByID(CurrentGoods.RelationGoodsId);
- // //关联商品转换显示数量
- // RelationNum = RelationDeliveryCount * RelationGoodsItem.AgreeUnit;
- //}
- }
- /// <summary>
- /// 主商品-关联商品-配比转换
- /// </summary>
- private void MainGoodsToRelationGoodsLot(decimal deliveryCount)
- {
- if (CurrentGoods != null)
- {
- RelationDeliveryCount = ((int)(deliveryCount / CurrentGoods.PDeliveryRatio1) * CurrentGoods.XDeliveryRatio);//deliveryCount * (CurrentGoods.goodsscale == 0 ? 1 : CurrentGoods.goodsscale);//商品配比,默认为1
- }
- }
- /// <summary>
- /// 设置可交收数量
- /// </summary>
- private void SetDeliveryCount()
- {
- ResetData();
- if (CurrentGoods != null)
- {
- _deliveryService.QueryDeliveryWhRecieptInfo(AccountID, CurrentGoods.GoodsId, QueryWhRecieptSuccess, DeliveryGoodsCallBack);
- MinMultiple = CurrentGoods.MinDeliveryQty;//默认值
- _currentMoneyMode = eMoneyMode.MONEYMODE_MARGIN;//CurrentGoods.currentMoneymode;
- _currentDirection = Direction.Bid;//CurrentBuyOrSell.BuyOrSell;
- ChangeDirectionTitle();
- AvailHoldQty = LoadingHolder(CurrentGoods.GoodsId, _currentDirection);
- AvailHoldQtyUnit = AvailHoldQty * CurrentGoods.AgreeUnit;
- DeliveryPrice = GetDeliveryPriceCalcMethod(CurrentGoods.GoodsId, GoodsOfCR.CurrentGoods);
- SwichDeliveryGoodsInfo();
- // DeclareToDeliveryLot();
- //MainGoodsToLot();
- //RelationGoodsToLot();
- //MinMaxDeliveryLot();
- CurrentGoodsUnitType = CurrentGoods.GoodsUnit;// CacheManager.TradeGoodsUnit.Where(x => x.UNITID == CurrentGoods.currentGoodsunit).Select(x => x.GOODSUNITNAME).FirstOrDefault();
- DeliveryAgreeUnitType = CurrentGoods.DeliveryGoodsUnit;//CacheManager.TradeGoodsUnit.Where(x => x.UNITID == CurrentGoods.GoodsUnitId).Select(x => x.GOODSUNITNAME).FirstOrDefault();
- //IsEnableButtonEvent();
- switch (_currentRelationMode)
- {
- case eDeliveryContractLink.None:
- RelationMode_N_HandleEvent(_currentMoneyMode);
- break;
- case eDeliveryContractLink.Normal:
- RelationMode_P_HandleEvent(_currentMoneyMode);
- break;
- case eDeliveryContractLink.PAndX:
- RelationMode_PAndX_HandleEvent(_currentMoneyMode);
- break;
- default:
- break;
- }
-
-
- }
- }
- /// <summary>
- /// 买卖名称改变
- /// </summary>
- private void ChangeDirectionTitle()
- {
- if (_currentDirection == Direction.Bid)
- {
- DirectionTitle = Resources.Client_Resource.Domain_BuyIn;
- }
- else
- {
- DirectionTitle = Resources.Client_Resource.Domain_SellOut;
- }
- }
- /// <summary>
- /// 交割算法取值//持仓均价
- /// </summary>
- private decimal GetDeliveryPriceCalcMethod(long goodsID, GoodsOfCR type)
- {
- HoldDetails = null;
- var CurrentAgreeunit = CurrentGoods.AgreeUnit;
- if (type == GoodsOfCR.RelationGoods)
- {
- CurrentAgreeunit = CacheManager.CacheGoodsBaseInfos.Where(x=>x.GoodsId==goodsID).Select(x=>x.AgreeUnit).FirstOrDefault();
- }
- //持仓价=持仓价均价
- var TempDeliveryPrice = LoadingHolder(goodsID, _currentDirection);
- switch (eReckonPriceCalcMethodType.HolderPriceMove)
- {
- case eReckonPriceCalcMethodType.LastPrice:
- case eReckonPriceCalcMethodType.HolderPriceMove:
- case eReckonPriceCalcMethodType.AgreedPrice:
- case eReckonPriceCalcMethodType.ReckonPrice:
- case eReckonPriceCalcMethodType.HolderPrice:
- //持仓价
- //if (HoldDetails != null && HoldDetails.Any())
- //{
- // if (HoldDetails.Sum((item) => item.Lot - item.LockQty) > 0)
- // TempDeliveryPrice = HoldDetails.Sum((order) => order.HoldAmount - order.lockHolderAmount) / HoldDetails.Sum((item) => item.Lot - item.LockQty) / CurrentAgreeunit;
- //}
- TempDeliveryPrice = TempDeliveryPrice / CurrentAgreeunit;
- break;
- }
- return TempDeliveryPrice;
- }
- /// <summary>
- /// N 模式处理
- /// </summary>
- private void RelationMode_N_HandleEvent(eMoneyMode moneyMode)
- {
- IsVisibility_Only_N = Visibility.Visible;
- IsVisibility_N = Visibility.Collapsed;
- //MinDeliveryUnit = 1;
- //MaxDeliveryUnit = AvailHoldQty;
- if (_currentDirection == Direction.Bid)//买方向
- {
- if (moneyMode == eMoneyMode.MONEYMODE_MARGIN)//保证金
- {
- }
- else
- {
- }
-
- }
-
- }
- /// <summary>
- /// P 模式处理
- /// </summary>
- private void RelationMode_P_HandleEvent(eMoneyMode moneyMode)
- {
- IsVisibility_Only_N = Visibility.Collapsed;
- IsVisibility_P = Visibility.Collapsed;
- if (_currentDirection == Direction.Bid)//买方向
- {
- if (moneyMode == eMoneyMode.MONEYMODE_MARGIN)//保证金
- {
- }
- else
- {
- }
- }
-
- }
- /// <summary>
- /// P+X 模式处理
- /// </summary>
- private void RelationMode_PAndX_HandleEvent(eMoneyMode moneyMode)
- {
- IsVisibility_Only_N = Visibility.Collapsed;
- IsVisibility_PAndX = Visibility.Visible;
- LoadingRelationGoodsInfo();
- if (_currentDirection == Direction.Bid)//买方向
- {
- //var tempAvailHoldQty = Math.Min(RelationGoodsHoldQty, AvailHoldQty);
- //MaxDeliveryUnit = Math.Min((tempAvailHoldQty - tempAvailHoldQty % MinDeliveryUnit), MaxDeliveryUnit);
- if (moneyMode == eMoneyMode.MONEYMODE_MARGIN)//保证金
- {
- }
- else
- {
- }
- }
- else
- {
-
- }
-
-
- }
- /// <summary>
- /// 重置数据初始值
- /// </summary>
- private void ResetData()
- {
- _currentRelationMode = eDeliveryContractLink.None;
- _currentMoneyMode = eMoneyMode.MONEYMODE_MARGIN;
- IsVisibility_N = Visibility.Visible;
- IsVisibility_PAndX = Visibility.Visible;
- AvailHoldQty = decimal.Zero;
- DeliveryPrice = decimal.Zero;
- RelationGoodsHoldQty = decimal.Zero;
- RelationGoodsHoldPrice = decimal.Zero;
- DeliveryCount = 0;
- RelationDeliveryCount = 0;
- DeliveryNum = 0;
- MinMultiple = 0;
- }
- /// <summary>
- /// 查询-交割规则-成功返回
- /// </summary>
- /// <param name="orders"></param>
- protected void QueryWhRecieptSuccess(List<DeliveryWhRecieptInfo> itemList)
- {
- if (WrPairDetailsList != null)
- {
- WrPairDetailsList = new List<DeliveryWhRecieptInfo>();
- }
- if (itemList.Any() && itemList.Count > 0)
- {
- WrPairDetailsList = itemList;
- }
-
- IsBusyWR = false;
- }
- /// <summary>
- /// 查询-交割规则 MTP2.0
- /// </summary>
- /// <param name="itemList"></param>
- protected void QueryRelationList()
- {
- #region 初始化交割商品
- List<QuoteGoods> tempGoods = new List<QuoteGoods>();
- if (CacheManager.CacheGoodsPositionList != null || CacheManager.CacheRealGoodsPositionList!=null)
- {
- //持仓头寸-商品ID LIST
- var AdvanceGoodsIDList = CacheManager.CacheGoodsPositionList.Select((item) => item.GoodsId).Distinct().ToList();
- var FullPayGoodsIDList = CacheManager.CacheRealGoodsPositionList.Select((item) => item.GoodsId).Distinct().ToList();
- List<uint> AllDeliveryGoodsIDList = AdvanceGoodsIDList.Concat(FullPayGoodsIDList).ToList<uint>();
- foreach (var id in AllDeliveryGoodsIDList)
- {
- //过滤可以交割的商品ID
- foreach (var item in CacheManager.CacheGoodsBaseInfos.Where(x=>x.DeliveryFlag==1))
- {
- if (id == item.GoodsId && !tempGoods.Exists(x => x.GoodsId == item.GoodsId))
- {
- tempGoods.Add(item);
- }
- }
- }
- }
- DeliveryGoodsList = tempGoods;
- LoadingDeliveryGoods();
- //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- //{
-
- // //GetDepositPersonalInfo();
- //}));
- #endregion
- }
- /// <summary>
- /// 判断商品是否在可交割期内
- /// </summary>
- /// <returns></returns>
- private bool IsGoodsBetweenDate(GoodsDeliveryRelationModel item)
- {
- bool flag = false;
- #region 交割开始日期
- if (item.MinDateDeliveryDate == DateTime.MinValue)
- {
- flag = true;
- }
- else if (item.MinDateDeliveryDate != DateTime.MinValue && ApplicationParameter.ServerTimeNow >= item.MinDateDeliveryDate)
- {
- flag = true;
- }
- else
- {
- flag = false;
- }
- #endregion
- #region 交割结束日期
- if (item.MaxDateDeliveryDate == DateTime.MinValue)
- {
- flag = true;
- }
- else if (item.MaxDateDeliveryDate != DateTime.MinValue && ApplicationParameter.ServerTimeNow <= item.MaxDateDeliveryDate)
- {
- flag = true;
- }
- else
- {
- flag = false;
- }
- #endregion
- return flag;
- }
- /// <summary>
- /// 交割商品关系配置失败返回
- /// </summary>
- /// <param name="errorEntity"></param>
- private void DeliveryGoodsCallBack(ErrorEntity errorEntity)
- {
- IsBusyWR = false;
- }
- /// <summary>
- /// 获取交割提货个人信息
- /// </summary>
- private void GetDepositPersonalInfo()
- {
- if (CurrentGoods != null)
- {
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- var ReqModel = new DepositPersonalInfoReqModel();
- ReqModel.accountId = (long)accountid;
- IsBusy = true;
- //交割提货个人信息查询
- //_deliveryService.SearchDepositPersonalInfoReq(ReqModel, QueryDepositPersonalInfoSuccess, QueryDepositPersonalInfoCallBack);
- }
- }
- /// <summary>
- /// 交割提货个人信息-成功返回
- /// </summary>
- /// <param name="orders"></param>
- protected void QueryDepositPersonalInfoSuccess(DepositPersonalInfoRspModel itemModel)
- {
- if (itemModel != null)
- {
- CurrentDepositPersonalInfo = itemModel;
- if (CurrentDepositPersonalInfo != null)
- {
- RecieveAddress = CurrentDepositPersonalInfo.address;
- RecievePerson = CurrentDepositPersonalInfo.personName;
- PhoneNum = CurrentDepositPersonalInfo.telphone;
- IdCardNum = CurrentDepositPersonalInfo.IdCardNum;
- }
- }
- IsBusy = false;
- }
- /// <summary>
- /// 获取交割提货个人信息失败返回
- /// </summary>
- /// <param name="errorEntity"></param>
- private void QueryDepositPersonalInfoCallBack(ErrorEntity errorEntity)
- {
- IsBusy = false;
- }
- /// <summary>
- /// 【首次运行】加载交易商品
- /// </summary>
- private void LoadingDeliveryGoods()
- {
-
- if (DeliveryGoodsList != null && DeliveryGoodsList.Any() && DeliveryGoodsList.Count() > 0)
- {
- CurrentGoods = DeliveryGoodsList.FirstOrDefault();
- //MinMultiple = CurrentGoods.LimitSum;//默认值
- //DeliveryCount = CurrentGoods.PlimitConversion;//默认值
- _currentMoneyMode = eMoneyMode.MONEYMODE_MARGIN;//暂时固定为保证金//CurrentGoods.currentMoneymode;
- DeliveryGoodsNameList.Clear();
- DeliveryGoodsNameList.Add(DeliveryGoodsList.FirstOrDefault().DeliveryGoodsNameCode);
- CurrentDeliveryGoodsName = DeliveryGoodsNameList.FirstOrDefault();
- if (_parameterInfo != null && _parameterInfo.GoodsId > 0)
- {
- CurrentGoods = DeliveryGoodsList.FirstOrDefault(x => x.GoodsId == _parameterInfo.GoodsId);
- DeliveryGoodsNameList.Clear();
- DeliveryGoodsNameList.Add(DeliveryGoodsList.FirstOrDefault(x => x.GoodsId == _parameterInfo.GoodsId).DeliveryGoodsNameCode);
- CurrentDeliveryGoodsName = DeliveryGoodsNameList.FirstOrDefault();
- }
- }
- }
- /// <summary>
- /// 加载持仓//可用持仓数量
- /// </summary>
- private decimal LoadingHolder(long goodsID,Direction buyOrSell)
- {
- var TempAvailHoldQty = decimal.Zero;
- var holders = CacheManager.CacheGoodsPositionList;//UserManager.GetCacheOrders<HoldingOrder>();
- if (holders != null && holders.Any())
- {
- #region MTP2.0 变动
- //HoldDetails = holders.Where((item) => item.GoodsId == goodsID && item.Direction == buyOrSell).ToList();//买卖方向持仓
- //if (HoldDetails != null && HoldDetails.Any())
- //{
- // var TempPositionFzQty = HoldDetails.FirstOrDefault().PositionFzQty;
- // var TempTotalHoldDetails = HoldDetails.Sum((order) => order.Lot - order.LockQty);
- // TempAvailHoldQty = TempTotalHoldDetails - TempPositionFzQty;
- //}
- #endregion
- var TempInstan = holders.Where(x => x.GoodsId == goodsID).ToList().FirstOrDefault();
- if (TempInstan != null)
- {
- if (buyOrSell == Direction.Bid)
- {
- TempAvailHoldQty = (decimal)(TempInstan.BuyCurPositionQty - TempInstan.BuyFrozenQty - TempInstan.BuyOtherFrozenQty);
- }
- else
- {
- TempAvailHoldQty = (decimal)(TempInstan.SellCurPositionQty - TempInstan.SellFrozenQty - TempInstan.SellOtherFrozenQty);
- }
-
- }
-
- }
- return TempAvailHoldQty;
- }
- /// <summary>
- /// 加载关联交易商品信息
- /// </summary>
- private void LoadingRelationGoodsInfo()
- {
- //RelationGoodsHoldQty = LoadingHolder(CurrentGoods.RelationGoodsId, _currentDirection);
- //RelationGoodsHoldPrice = GetDeliveryPriceCalcMethod(CurrentGoods.RelationGoodsId, GoodsOfCR.RelationGoods);
- //var RelationGoodsItem =FindRelationGoodsInfoByID(CurrentGoods.RelationGoodsId);
- //RelationGoodsUnitType = RelationGoodsItem.GoodsUnit;//CacheManager.TradeGoodsUnit.Where(x => x.UNITID == RelationGoodsItem.RelationGoodsunit).Select(x => x.GOODSUNITNAME).FirstOrDefault();
- //var RelationGoodsName = RelationGoodsItem.DeliveryGoodsNameCode;
- //RelationGoodsHoldQtyUnit = RelationGoodsHoldQty * RelationGoodsItem.AgreeUnit;
- //RelationGoodsNameList.Clear();
- //RelationGoodsNameList.Add(RelationGoodsName);
- //CurrentRelationGoodsName = RelationGoodsNameList.FirstOrDefault();
- //IsEnableButtonEvent();
- //DeliveryCountEvent();
- }
-
- /// <summary>
- /// 查找关联商品信息BY商品ID
- /// </summary>
- private QuoteGoods FindRelationGoodsInfoByID(long RelationGoodsId)
- {
- if (CacheManager.CacheGoodsBaseInfos!= null)
- {
- return CacheManager.CacheGoodsBaseInfos.Find(x => x.GoodsId == RelationGoodsId);
- }
- return null;
- }
- /// <summary>
- /// 切换交割商品信息
- /// </summary>
- private void SwichDeliveryGoodsInfo()
- {
- DeliveryGoodsNameList.Clear();
- DeliveryGoodsNameList.Add(CurrentGoods.DeliveryGoodsNameCode);
- CurrentDeliveryGoodsName = DeliveryGoodsNameList.FirstOrDefault();
- }
- #endregion "Private Methods"
- #region "=========其它方法/Other Methods"
- /// <summary>
- /// 数据验证
- /// </summary>
- /// <param name="msg"></param>
- /// <returns></returns>
- public bool Validated(ref string msg)
- {
- //申报数量 > 最大可申报数量
- if (DeliveryCount > MaxDeliveryUnit)
- {
- msg = string.Format(Muchinfo.MTPClient.Resources.Client_Resource.EntrustOrderViewModel_OpenLotGreatThanMaxLot, MaxDeliveryUnit);
- return false;
- }
- //申报数量应为最小交割数量的整数倍
- if (MinDeliveryUnit != 0 && DeliveryCount % MinDeliveryUnit != 0 && CurrentRelationMode != eDeliveryContractLink.None)
- {
- msg = string.Format(Muchinfo.MTPClient.Resources.Client_Resource.DeliveryCountShoutBeMinUnitDouble, MinDeliveryUnit); ;
- return false;
- }
- if (DeliveryCount <= 0 || DeliveryCount == decimal.Zero)
- {
- //数量不在正确范围内
- msg = string.Format(Muchinfo.MTPClient.Resources.Client_Resource.Delivery_ChooseCorrectDeclareNum, MaxDeliveryUnit); ;
- return false;
- }
- #region MTP2.0 注销
- //if (RecievePerson.Trim() == "" )
- //{
- // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_RecievePerson + Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_NeedToWrite;
- // return false;
- //}
- //if (RecieveAddress.Trim() == "" && TakeGoodsWay == TakeGoodsWay.Express)
- //{
- // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_RecieveAddress + Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_NeedToWrite;
- // return false;
- //}
- //if (PhoneNum.Trim() == "" )
- //{
- // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_PhoneNum + Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_NeedToWrite;
- // return false;
- //}
- //if (PhoneNum.Trim() != "" && (!PhoneNum.StartsWith("1") || PhoneNum.Length != 11 || !ValidationHelper.IsMobile(PhoneNum)))
- //{
- // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_PhoneNumErrFormat;
- // return false;
- //}
- //if (string.IsNullOrWhiteSpace(IdCardNum) || !ValidationHelper.IsIDcard(IdCardNum))
- //{
- // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_IDCardNumErrFormat;
- // return false;
- //}
- #endregion
- return true;
- }
- #endregion "Other Methods"
-
-
- }
- public enum GoodsOfCR
- {
- /// <summary>
- /// 当前商品
- /// </summary>
- CurrentGoods = 1,
- /// <summary>
- /// 关联商品
- /// </summary>
- RelationGoods = 2,
- }
- }
|