NDeliveryOrderViewModel.cs 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139
  1. using GalaSoft.MvvmLight;
  2. using GalaSoft.MvvmLight.Ioc;
  3. using Muchinfo.MTPClient.Data.Enums;
  4. using Muchinfo.MTPClient.Data.DTO;
  5. using Muchinfo.MTPClient.Data.Model.Account;
  6. using Muchinfo.MTPClient.Data.Model.Delivery;
  7. using Muchinfo.MTPClient.Infrastructure.Utilities;
  8. using Muchinfo.MTPClient.IService;
  9. using System.Collections.Generic;
  10. using System.Windows;
  11. using System.Linq;
  12. using Muchinfo.MTPClient.Data;
  13. using System.Collections.ObjectModel;
  14. using Muchinfo.MTPClient.Data.Model;
  15. using System;
  16. using GalaSoft.MvvmLight.Command;
  17. using Muchinfo.MTPClient.Resources;
  18. using Muchinfo.MTPClient.Infrastructure.Cache;
  19. using Muchinfo.MTPClient.Infrastructure.MessageBox;
  20. using Muchinfo.MTPClient.Infrastructure.Helpers;
  21. namespace Muchinfo.MTPClient.Delivery.ViewModels
  22. {
  23. /// <summary>
  24. /// 新交割申报
  25. /// <para>
  26. /// </para>
  27. /// </summary>
  28. public class NDeliveryOrderViewModel : ViewModelBase
  29. {
  30. private QuoteGoodsDTO _goodsItem;
  31. #region "=========私有成员/Private Data Members"
  32. private Window _openWindow; ///下单窗口
  33. private IDeliveryService _deliveryService;
  34. private IGoodsService _goodsService;
  35. private Direction _currentDirection = Direction.Bid;
  36. private decimal usableFunds = UserManager.CurrentAccountUsableFunds();
  37. private DeliveryOrderMessage _parameterInfo;
  38. protected const int defaut_minLot = 1;
  39. protected const int defaut_maxLot = int.MaxValue;
  40. private bool _action = false;//控制点选仓库多次触发事件
  41. private decimal submitDeliveryQty = decimal.Zero;//点选的交割总数量
  42. #endregion "Private Data Members"
  43. #region "=========构造函数/Constructor/Initialization"
  44. public NDeliveryOrderViewModel(DeliveryOrderMessage parameterInfo)
  45. {
  46. this._parameterInfo = parameterInfo;
  47. _deliveryService = SimpleIoc.Default.GetInstance<IDeliveryService>();
  48. _goodsService = SimpleIoc.Default.GetInstance<IGoodsService>();
  49. // 初始化交割商品列表数据
  50. InitData(parameterInfo);
  51. }
  52. #endregion "Constructor/Initialization"
  53. private void RegisterMessages()
  54. {
  55. MessengerHelper.QuoteRegister<List<QuoteGoods>>(this, MessengerTokens.ReceiveRealTimeQuote, (quoteList) =>
  56. {
  57. if (quoteList == null || !quoteList.Any()) return;
  58. foreach (var goods in quoteList)
  59. {
  60. if (goods == null) continue;
  61. if (this._goodsItem != null && this._goodsItem.GoodsCode == goods.GoodsCode)
  62. {
  63. this._goodsItem.UpdateFromQuoteGoods(goods);
  64. this.XPriceFormat = this._goodsItem.CurrentPriceDisplay;
  65. }
  66. }
  67. });
  68. }
  69. #region "=========接口重写/Interface implementation Or override"
  70. //To do interface implementation
  71. #endregion "Interface implementation Or override"
  72. #region "=========公共属性/Public Properties To Get/Set "
  73. #region 所有单据ListSource
  74. private List<DeliveryEntrustOrder> _allOrders;
  75. /// <summary>
  76. /// 所有单据ListSource
  77. /// </summary>
  78. public List<DeliveryEntrustOrder> AllOrders
  79. {
  80. get { return _allOrders; }
  81. set { Set(() => AllOrders, ref _allOrders, value); }
  82. }
  83. #endregion
  84. #region 当前资金账户
  85. private ulong _accountid;
  86. public ulong AccountID
  87. {
  88. get { return _accountid; }
  89. set { Set(() => AccountID, ref _accountid, value); }
  90. }
  91. #endregion
  92. #region 主商品
  93. public uint XGoodsID { get; set; }
  94. private string _xgoodsCode;
  95. public string XGoodsCode
  96. {
  97. get { return _xgoodsCode; }
  98. set { Set(() => XGoodsCode, ref _xgoodsCode, value); }
  99. }
  100. private string _xgoodsName;
  101. public string XGoodsName
  102. {
  103. get { return _xgoodsName; }
  104. set { Set(() => XGoodsName, ref _xgoodsName, value); }
  105. }
  106. private string _deliveryFactor;
  107. public string DeliveryFactor
  108. {
  109. get { return _deliveryFactor; }
  110. set { Set(() => DeliveryFactor, ref _deliveryFactor, value); }
  111. }
  112. public string DisplayXGoods
  113. {
  114. get
  115. {
  116. return XGoodsCode + "/" + XGoodsName;
  117. }
  118. }
  119. #endregion
  120. #region 辅助商品
  121. public uint P1GoodsID { get; set; }
  122. private string _p1goodsCode;
  123. public string P1GoodsCode
  124. {
  125. get { return _p1goodsCode; }
  126. set { Set(() => P1GoodsCode, ref _p1goodsCode, value); }
  127. }
  128. private string _p1goodsName;
  129. public string P1GoodsName
  130. {
  131. get { return _p1goodsName; }
  132. set { Set(() => P1GoodsName, ref _p1goodsName, value); }
  133. }
  134. public uint P2GoodsID { get; set; }
  135. private string _p2goodsCode;
  136. public string P2GoodsCode
  137. {
  138. get { return _p2goodsCode; }
  139. set { Set(() => P2GoodsCode, ref _p2goodsCode, value); }
  140. }
  141. private string _p2goodsName;
  142. public string P2GoodsName
  143. {
  144. get { return _p2goodsName; }
  145. set { Set(() => P2GoodsName, ref _p2goodsName, value); }
  146. }
  147. #endregion
  148. #region 交割商品
  149. private string _deliverygoodsCode;
  150. public string DeliveryGoodsCode
  151. {
  152. get { return _deliverygoodsCode; }
  153. set { Set(() => DeliveryGoodsCode, ref _deliverygoodsCode, value); }
  154. }
  155. private string _deliverygoodsName;
  156. public string DeliveryGoodsName
  157. {
  158. get { return _deliverygoodsName; }
  159. set { Set(() => DeliveryGoodsName, ref _deliverygoodsName, value); }
  160. }
  161. private string _deliverygoodsNamecode;
  162. public string DeliveryGoodsNameCode
  163. {
  164. get { return _deliverygoodsNamecode; }
  165. set { Set(() => DeliveryGoodsNameCode, ref _deliverygoodsNamecode, value); }
  166. }
  167. #endregion
  168. #region 仓库ListSource
  169. private ObservableCollection<KeyValuePair<string, string>> _warehouselst;
  170. public ObservableCollection<KeyValuePair<string, string>> DeliveryWarehouseList
  171. {
  172. get { return _warehouselst; }
  173. set { Set(() => DeliveryWarehouseList, ref _warehouselst, value); }
  174. }
  175. private KeyValuePair<string, string> _selectedWareHouse;
  176. public KeyValuePair<string, string> SelectedWareHouse
  177. {
  178. get { return _selectedWareHouse; }
  179. set { Set(() => SelectedWareHouse, ref _selectedWareHouse, value); }
  180. }
  181. #endregion
  182. #region 品质ListSource
  183. private List<KeyValuePair<string, string>> _qualitylst;
  184. public List<KeyValuePair<string, string>> DeliveryQualityList
  185. {
  186. get { return _qualitylst; }
  187. set { Set(() => DeliveryQualityList, ref _qualitylst, value); }
  188. }
  189. private KeyValuePair<string, string> _selectedQuality;
  190. public KeyValuePair<string, string> SelectedQuality
  191. {
  192. get { return _selectedQuality; }
  193. set { Set(() => SelectedQuality, ref _selectedQuality, value); }
  194. }
  195. #endregion
  196. #region 规格ListSource
  197. private List<KeyValuePair<string, string>> _spelst;
  198. public List<KeyValuePair<string, string>> DeliverySpeciList
  199. {
  200. get { return _spelst; }
  201. set { Set(() => DeliverySpeciList, ref _spelst, value); }
  202. }
  203. private KeyValuePair<string, string> _selectedSpeci;
  204. public KeyValuePair<string, string> SelectedSpeci
  205. {
  206. get { return _selectedSpeci; }
  207. set { Set(() => SelectedSpeci, ref _selectedSpeci, value); }
  208. }
  209. #endregion
  210. #region 品质ListSource
  211. private List<KeyValuePair<string, string>> _brandlst;
  212. public List<KeyValuePair<string, string>> DeliveryBrandList
  213. {
  214. get { return _brandlst; }
  215. set { Set(() => DeliveryBrandList, ref _brandlst, value); }
  216. }
  217. private KeyValuePair<string, string> _selectedBrand;
  218. public KeyValuePair<string, string> SelectedBrand
  219. {
  220. get { return _selectedBrand; }
  221. set { Set(() => SelectedBrand, ref _selectedBrand, value); }
  222. }
  223. #endregion
  224. #region 过滤条件
  225. private List<KeyValuePair<string, string>> _filterlst = new List<KeyValuePair<string, string>>();
  226. public List<KeyValuePair<string, string>> FilterList
  227. {
  228. get { return _filterlst; }
  229. set { Set(() => FilterList, ref _filterlst, value); }
  230. }
  231. #endregion
  232. #region 可用持仓数量
  233. private decimal _availHoldQty = decimal.Zero;
  234. /// <summary>
  235. /// 可用持仓数量
  236. /// </summary>
  237. public decimal AvailHoldQty
  238. {
  239. get
  240. {
  241. return _availHoldQty;
  242. }
  243. set
  244. {
  245. Set(() => AvailHoldQty, ref _availHoldQty, value);
  246. RaisePropertyChanged(() => AvailHoldQtyUnit);
  247. }
  248. }
  249. private decimal _availHoldQtyUnit = decimal.Zero;
  250. /// <summary>
  251. /// 可用持仓数量- 转- 交割可用数量
  252. /// </summary>
  253. public decimal AvailHoldQtyUnit
  254. {
  255. get
  256. {
  257. return _availHoldQtyUnit;
  258. }
  259. set
  260. {
  261. Set(() => AvailHoldQtyUnit, ref _availHoldQtyUnit, value);
  262. }
  263. }
  264. #endregion
  265. #region 当前选择仓单
  266. private DeliveryWhRecieptInfo _currentSelectedWhReciept;
  267. /// <summary>
  268. /// 当前选择仓单详细
  269. /// </summary>
  270. public DeliveryWhRecieptInfo CurrentSelectedWhReciept
  271. {
  272. get
  273. {
  274. return _currentSelectedWhReciept;
  275. }
  276. set
  277. {
  278. Set(() => CurrentSelectedWhReciept, ref _currentSelectedWhReciept, value);
  279. }
  280. }
  281. private TradeWRPositionModel _currentSelectedWhRecieptEx;
  282. /// <summary>
  283. /// 当前选择仓单详细
  284. /// </summary>
  285. public TradeWRPositionModel CurrentSelectedWhRecieptEx
  286. {
  287. get
  288. {
  289. return _currentSelectedWhRecieptEx;
  290. }
  291. set
  292. {
  293. Set(() => CurrentSelectedWhRecieptEx, ref _currentSelectedWhRecieptEx, value);
  294. }
  295. }
  296. #endregion
  297. #region 交割点选仓单
  298. private List<DeliveryWhRecieptInfo> _wrPairDetailsList = new List<DeliveryWhRecieptInfo>();
  299. /// <summary>
  300. /// 交割点选仓单
  301. /// </summary>
  302. public List<DeliveryWhRecieptInfo> WrPairDetailsList
  303. {
  304. get
  305. {
  306. return _wrPairDetailsList;
  307. }
  308. set
  309. {
  310. Set(() => WrPairDetailsList, ref _wrPairDetailsList, value);
  311. }
  312. }
  313. private static List<TradeWRPositionModel> CachedPairDetailsList = new List<TradeWRPositionModel>();
  314. private List<TradeWRPositionModel> _wrPairDetailsListEx = new List<TradeWRPositionModel>();
  315. /// <summary>
  316. /// 交割点选仓单
  317. /// </summary>
  318. public List<TradeWRPositionModel> WrPairDetailsListEx
  319. {
  320. get
  321. {
  322. return _wrPairDetailsListEx;
  323. }
  324. set
  325. {
  326. Set(() => WrPairDetailsListEx, ref _wrPairDetailsListEx, value);
  327. }
  328. }
  329. #endregion
  330. #region 最小交割数量/倍数
  331. private decimal _MinMultiple = 1;
  332. /// <summary>
  333. /// 最小交割数量/倍数
  334. /// </summary>
  335. public decimal MinMultiple
  336. {
  337. get
  338. {
  339. return _MinMultiple;
  340. }
  341. set
  342. {
  343. Set(() => MinMultiple, ref _MinMultiple, value);
  344. }
  345. }
  346. #endregion
  347. #region 加载中 字符串显示
  348. private string _BusyContent = Client_Resource.Content_GetBusy;
  349. /// <summary>
  350. /// 加载中 字符串显示
  351. /// </summary>
  352. public string BusyContent
  353. {
  354. get
  355. {
  356. return _BusyContent;
  357. }
  358. set
  359. {
  360. Set(() => BusyContent, ref _BusyContent, value);
  361. }
  362. }
  363. #endregion
  364. #region 当前账号提货人信息
  365. private DepositPersonalInfoRspModel _currentDepositPersonalInfo;
  366. /// <summary>
  367. /// 当前账号提货人信息
  368. /// </summary>
  369. public DepositPersonalInfoRspModel CurrentDepositPersonalInfo
  370. {
  371. get
  372. {
  373. return _currentDepositPersonalInfo;
  374. }
  375. set
  376. {
  377. Set(() => CurrentDepositPersonalInfo, ref _currentDepositPersonalInfo, value);
  378. }
  379. }
  380. #endregion
  381. #region 收货人
  382. private string _RecievePerson = string.Empty;
  383. /// <summary>
  384. /// 收货人
  385. /// </summary>
  386. public string RecievePerson
  387. {
  388. get
  389. {
  390. return _RecievePerson;
  391. }
  392. set
  393. {
  394. Set(() => RecievePerson, ref _RecievePerson, value);
  395. }
  396. }
  397. #endregion
  398. #region 收货地址
  399. private string _RecieveAddress = string.Empty;
  400. /// <summary>
  401. /// 收货地址
  402. /// </summary>
  403. public string RecieveAddress
  404. {
  405. get
  406. {
  407. return _RecieveAddress;
  408. }
  409. set
  410. {
  411. Set(() => RecieveAddress, ref _RecieveAddress, value);
  412. }
  413. }
  414. #endregion
  415. #region 联系方式
  416. private string _PhoneNum = string.Empty;
  417. /// <summary>
  418. /// 联系方式
  419. /// </summary>
  420. public string PhoneNum
  421. {
  422. get
  423. {
  424. return _PhoneNum;
  425. }
  426. set
  427. {
  428. Set(() => PhoneNum, ref _PhoneNum, value);
  429. }
  430. }
  431. #endregion
  432. #region 主商品-申报数量-错误提示
  433. private bool _isError_DeliveryCount = false;
  434. /// <summary>
  435. /// 主商品-申报数量-错误提示
  436. /// </summary>
  437. public bool IsError_DeliveryCount
  438. {
  439. get
  440. {
  441. return _isError_DeliveryCount;
  442. }
  443. set
  444. {
  445. Set(() => IsError_DeliveryCount, ref _isError_DeliveryCount, value);
  446. }
  447. }
  448. #endregion
  449. #region 关联商品-申报数量-错误提示
  450. private bool _isError_RelationDeliveryCount = false;
  451. /// <summary>
  452. /// 关联商品-申报数量-错误提示
  453. /// </summary>
  454. public bool IsError_RelationDeliveryCount
  455. {
  456. get
  457. {
  458. return _isError_RelationDeliveryCount;
  459. }
  460. set
  461. {
  462. Set(() => IsError_RelationDeliveryCount, ref _isError_RelationDeliveryCount, value);
  463. }
  464. }
  465. private bool _isError_RelationDeliveryCount2 = false;
  466. /// <summary>
  467. /// 关联商品-申报数量-错误提示
  468. /// </summary>
  469. public bool IsError_RelationDeliveryCount2
  470. {
  471. get
  472. {
  473. return _isError_RelationDeliveryCount2;
  474. }
  475. set
  476. {
  477. Set(() => IsError_RelationDeliveryCount2, ref _isError_RelationDeliveryCount2, value);
  478. }
  479. }
  480. #endregion
  481. #region 买卖名称改变
  482. private string _directionTitle = string.Empty;
  483. /// <summary>
  484. /// 买卖名称改变
  485. /// </summary>
  486. public string DirectionTitle
  487. {
  488. get
  489. {
  490. return _directionTitle;
  491. }
  492. set
  493. {
  494. Set(() => DirectionTitle, ref _directionTitle, value);
  495. }
  496. }
  497. #endregion
  498. #region 窗体标题
  499. private string _title = string.Empty;
  500. /// <summary>
  501. /// 窗体标题
  502. /// </summary>
  503. public string Title
  504. {
  505. get
  506. {
  507. return _title = Client_Resource.DeliveryOrderView_DeliveryDeclaration + "(" + AccountID.ToString() + ")";
  508. }
  509. }
  510. #endregion
  511. #region 当前勾选单据LIST
  512. private List<WrDetailModel> _currentSelectedWrDetail = new List<WrDetailModel>();
  513. /// <summary>
  514. /// 当前勾选的仓单配对
  515. /// </summary>
  516. public List<WrDetailModel> CurrentSelectedWrDetail
  517. {
  518. get
  519. {
  520. return _currentSelectedWrDetail;
  521. }
  522. set
  523. {
  524. Set(() => CurrentSelectedWrDetail, ref _currentSelectedWrDetail, value);
  525. }
  526. }
  527. #endregion
  528. #region 合约单位名称枚举-当前商品
  529. private string _currentGoodsUnitType = string.Empty;
  530. /// <summary>
  531. /// 合约单位名称枚举-当前商品
  532. /// </summary>
  533. public string CurrentGoodsUnitType
  534. {
  535. get
  536. {
  537. return _currentGoodsUnitType;
  538. }
  539. set
  540. {
  541. Set(() => CurrentGoodsUnitType, ref _currentGoodsUnitType, value);
  542. }
  543. }
  544. #endregion
  545. #region 合约单位名称枚举-关联商品商品
  546. private string _relationGoodsUnitType = string.Empty;
  547. /// <summary>
  548. /// 合约单位名称枚举-关联商品商品
  549. /// </summary>
  550. public string RelationGoodsUnitType
  551. {
  552. get
  553. {
  554. return _relationGoodsUnitType;
  555. }
  556. set
  557. {
  558. Set(() => RelationGoodsUnitType, ref _relationGoodsUnitType, value);
  559. }
  560. }
  561. #endregion
  562. #region 合约单位名称枚举-交割商品
  563. private string _deliveryAgreeUnitType = string.Empty;
  564. /// <summary>
  565. /// 合约单位名称枚举-交割商品
  566. /// </summary>
  567. public string DeliveryAgreeUnitType
  568. {
  569. get
  570. {
  571. return _deliveryAgreeUnitType;
  572. }
  573. set
  574. {
  575. Set(() => DeliveryAgreeUnitType, ref _deliveryAgreeUnitType, value);
  576. }
  577. }
  578. #endregion
  579. #region 交割商品数量-转换显示
  580. private decimal _deliveryNum = decimal.Zero;
  581. /// <summary>
  582. /// 交割商品数量-转换显示
  583. /// </summary>
  584. public decimal DeliveryNum
  585. {
  586. get
  587. {
  588. return _deliveryNum;
  589. }
  590. set
  591. {
  592. Set(() => DeliveryNum, ref _deliveryNum, value);
  593. if (CurrentGoods != null)
  594. {
  595. if (DeliveryNum > 0)
  596. {
  597. DeliveryCount = Math.Round(DeliveryNum * CurrentGoods.MinDeliveryQty * CurrentGoods.XDeliveryRatio / StandardQty, 0, MidpointRounding.AwayFromZero);//反推:得知交割数量,计算需要主商品数量 X数量 = 交割数量 * 最小交割单位 / 合约单位.
  598. if (CurrentGoods.P1Type !=uint.MaxValue)
  599. {
  600. RelationDeliveryCount = Math.Round(DeliveryCount * CurrentGoods.PDeliveryRatio1 / CurrentGoods.XDeliveryRatio, 0, MidpointRounding.AwayFromZero);
  601. }
  602. else
  603. {
  604. RelationDeliveryCount = 0;
  605. }
  606. if (CurrentGoods.P2Type != uint.MaxValue)
  607. {
  608. RelationDeliveryCount2 = Math.Round(DeliveryCount * CurrentGoods.PDeliveryRatio2 /CurrentGoods.XDeliveryRatio, 0, MidpointRounding.AwayFromZero);
  609. }
  610. else
  611. {
  612. RelationDeliveryCount2 = 0;
  613. }
  614. RaisePropertyChanged(() => DeliveryNumDisplay);
  615. }
  616. }
  617. }
  618. }
  619. public decimal StandardQty
  620. {
  621. get;
  622. set;
  623. }
  624. public uint DeliveryGoodsID
  625. {
  626. get;
  627. set;
  628. }
  629. /// <summary>
  630. /// 交割商品数量-转交-格式化
  631. /// </summary>
  632. public string DeliveryNumDisplay
  633. {
  634. get { return DeliveryNum.ToString(); }
  635. }
  636. #endregion
  637. #region 主商品数量-转换显示
  638. private decimal _goodsNum = decimal.Zero;
  639. /// <summary>
  640. /// 主商品数量-转换显示
  641. /// </summary>
  642. public decimal GoodsNum
  643. {
  644. get
  645. {
  646. return _goodsNum;
  647. }
  648. set
  649. {
  650. Set(() => GoodsNum, ref _goodsNum, value);
  651. RaisePropertyChanged(() => GoodsNumDisplay);
  652. }
  653. }
  654. /// <summary>
  655. /// 主商品数量-转交-格式化
  656. /// </summary>
  657. public string GoodsNumDisplay
  658. {
  659. get { return GoodsNum.ToString("f2"); }
  660. }
  661. #endregion
  662. #region 关联商品申报数量-转换显示
  663. private decimal _relationNum = decimal.Zero;
  664. /// <summary>
  665. /// 关联商品申报数量-转换显示
  666. /// </summary>
  667. public decimal RelationNum
  668. {
  669. get
  670. {
  671. return _relationNum;
  672. }
  673. set
  674. {
  675. Set(() => RelationNum, ref _relationNum, value);
  676. RaisePropertyChanged(() => RelationNumDisplay);
  677. RaisePropertyChanged(() => IsError);
  678. }
  679. }
  680. public bool IsError
  681. {
  682. get
  683. {
  684. return _relationNum > _relationGoodsHoldQty;
  685. }
  686. }
  687. /// <summary>
  688. /// 关联商品申报数量-转换显示-格式化
  689. /// </summary>
  690. public string RelationNumDisplay
  691. {
  692. get { return RelationNum.ToString("f2"); }
  693. }
  694. #endregion
  695. #region 关联交易商品持仓数量[P+X]
  696. private decimal _relationGoodsHoldQty = decimal.Zero;
  697. /// <summary>
  698. /// 关联交易商品持仓数量[P+X]
  699. /// </summary>
  700. public decimal RelationGoodsHoldQty
  701. {
  702. get
  703. {
  704. return _relationGoodsHoldQty;
  705. }
  706. set
  707. {
  708. Set(() => RelationGoodsHoldQty, ref _relationGoodsHoldQty, value);
  709. RaisePropertyChanged(() => RelationGoodsHoldQtyDisp);
  710. RaisePropertyChanged(() => RelationGoodsHoldQtyUnit);
  711. RaisePropertyChanged(() => IsError);
  712. }
  713. }
  714. private decimal _relationGoodsHoldQty2 = decimal.Zero;
  715. /// <summary>
  716. /// 关联交易商品持仓数量[P+X]2
  717. /// </summary>
  718. public decimal RelationGoodsHoldQty2
  719. {
  720. get
  721. {
  722. return _relationGoodsHoldQty2;
  723. }
  724. set
  725. {
  726. Set(() => RelationGoodsHoldQty2, ref _relationGoodsHoldQty2, value);
  727. RaisePropertyChanged(() => RelationGoodsHoldQty2Disp);
  728. RaisePropertyChanged(() => IsError);
  729. }
  730. }
  731. private decimal _relationGoodsHoldQtyUnit = decimal.Zero;
  732. /// <summary>
  733. /// 关联交易商品持仓数量-转交割数量
  734. /// </summary>
  735. public decimal RelationGoodsHoldQtyUnit
  736. {
  737. get
  738. {
  739. return _relationGoodsHoldQtyUnit;
  740. }
  741. set
  742. {
  743. Set(() => RelationGoodsHoldQtyUnit, ref _relationGoodsHoldQtyUnit, value);
  744. }
  745. }
  746. #endregion
  747. #region 关联交易商品交割价格[P+X]
  748. private decimal _relationGoodsHoldPrice = decimal.Zero;
  749. /// <summary>
  750. /// 关联交易商品交割价格[P+X]
  751. /// </summary>
  752. public decimal RelationGoodsHoldPrice
  753. {
  754. get
  755. {
  756. return _relationGoodsHoldPrice;
  757. }
  758. set
  759. {
  760. Set(() => RelationGoodsHoldPrice, ref _relationGoodsHoldPrice, value);
  761. RaisePropertyChanged(() => RelationGoodsHoldPriceFormat);
  762. }
  763. }
  764. private decimal _relationGoodsHoldPrice2 = decimal.Zero;
  765. /// <summary>
  766. /// 关联交易商品交割价格[P+X]
  767. /// </summary>
  768. public decimal RelationGoodsHoldPrice2
  769. {
  770. get
  771. {
  772. return _relationGoodsHoldPrice2;
  773. }
  774. set
  775. {
  776. Set(() => RelationGoodsHoldPrice2, ref _relationGoodsHoldPrice2, value);
  777. RaisePropertyChanged(() => RelationGoodsHoldPriceFormat2);
  778. }
  779. }
  780. /// <summary>
  781. /// 关联交易商品交割价格[P+X]格式化
  782. /// </summary>
  783. public string RelationGoodsHoldPriceFormat
  784. {
  785. get
  786. {
  787. if (RelationGoodsHoldPrice > decimal.Zero)
  788. {
  789. return RelationGoodsHoldPrice.ToString("f2");
  790. }
  791. else
  792. {
  793. return "--";
  794. }
  795. }
  796. }
  797. public string RelationGoodsHoldPriceFormat2
  798. {
  799. get
  800. {
  801. if (RelationGoodsHoldPrice2 > decimal.Zero)
  802. {
  803. return RelationGoodsHoldPrice2.ToString("f2");
  804. }
  805. else
  806. {
  807. return "--";
  808. }
  809. }
  810. }
  811. #endregion
  812. #region 最小交割数量
  813. private decimal _minDeliveryUnit = 1;
  814. /// <summary>
  815. /// 最小交割数量
  816. /// </summary>
  817. public decimal MinDeliveryUnit
  818. {
  819. get
  820. {
  821. return _minDeliveryUnit;
  822. }
  823. set
  824. {
  825. Set(() => MinDeliveryUnit, ref _minDeliveryUnit, value);
  826. }
  827. }
  828. #endregion
  829. #region 最大交割数量
  830. private decimal _maxDeliveryUnit = 1;
  831. /// <summary>
  832. /// 最大交割数量
  833. /// </summary>
  834. public decimal MaxDeliveryUnit
  835. {
  836. get
  837. {
  838. return _maxDeliveryUnit;
  839. }
  840. set
  841. {
  842. Set(() => MaxDeliveryUnit, ref _maxDeliveryUnit, value);
  843. }
  844. }
  845. #endregion
  846. #region 仓单查询命令
  847. private RelayCommand<List<KeyValuePair<string,string>>> _searchCommand;
  848. /// <summary>
  849. /// 仓单号详细命令
  850. /// </summary>
  851. public RelayCommand<List<KeyValuePair<string, string>>> SearchCommand
  852. {
  853. get
  854. {
  855. return _searchCommand
  856. ?? (_searchCommand = new RelayCommand<List<KeyValuePair<string, string>>>(
  857. p =>
  858. {
  859. string brandType=string.Empty;
  860. string qualityType=string.Empty;
  861. string speciType=string.Empty;
  862. string warehouseType=string.Empty;
  863. foreach (KeyValuePair<string, string> item in p)
  864. {
  865. if (item.Key.Split('_')[0] == ((int)ePriceMoveType.PRICEMOVETYPE_BRAND).ToString())
  866. {
  867. brandType=item.Key;
  868. }
  869. if (item.Key.Split('_')[0] == ((int)ePriceMoveType.PRICEMOVETYPE_QUALITY).ToString())
  870. {
  871. qualityType = item.Key;
  872. }
  873. if (item.Key.Split('_')[0] == ((int)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION).ToString())
  874. {
  875. speciType = item.Key;
  876. }
  877. if (item.Key.Split('_')[0] == ((int)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE).ToString())
  878. {
  879. warehouseType = item.Key;
  880. }
  881. }
  882. List<TradeWRPositionModel> localLst = new List<TradeWRPositionModel>();
  883. if (string.IsNullOrEmpty(brandType))
  884. {
  885. foreach (TradeWRPositionModel item in CachedPairDetailsList)
  886. {
  887. localLst.Add(item);
  888. }
  889. }
  890. else
  891. {
  892. localLst = CachedPairDetailsList.Where(x => x.BrandType == brandType).ToList();
  893. }
  894. if (!string.IsNullOrEmpty(qualityType))
  895. {
  896. localLst = localLst.Where(x => x.QualityType == qualityType).ToList();
  897. }
  898. if (!string.IsNullOrEmpty(speciType))
  899. {
  900. localLst = localLst.Where(x => x.SpecType == speciType).ToList();
  901. }
  902. if (!string.IsNullOrEmpty(warehouseType))
  903. {
  904. localLst = localLst.Where(x => x.WarehouseType == warehouseType).ToList();
  905. }
  906. WrPairDetailsListEx = localLst;
  907. }));
  908. }
  909. }
  910. #endregion
  911. #region 冻结头寸数量
  912. private decimal _positionFzQty;
  913. /// <summary>
  914. /// 冻结头寸数量
  915. /// </summary>
  916. public decimal PositionFzQty
  917. {
  918. get
  919. {
  920. return _positionFzQty;
  921. }
  922. set
  923. {
  924. Set(() => PositionFzQty, ref _positionFzQty, value);
  925. }
  926. }
  927. #endregion
  928. #region 申报数量
  929. private decimal _deliveryCount = decimal.Zero;
  930. /// <summary>
  931. /// 申报数量
  932. /// X数量 = 交割数量 * 最小交割单位 / 合约单位.
  933. /// </summary>
  934. public decimal DeliveryCount
  935. {
  936. get
  937. {
  938. return _deliveryCount;
  939. }
  940. set
  941. {
  942. Set(() => DeliveryCount, ref _deliveryCount, value);
  943. if (DeliveryNum > 0)
  944. {
  945. MainGoodsToLot();
  946. RaisePropertyChanged(() => DeliveryCountCalcAlgrithm);
  947. }
  948. //MainGoodsToRelationGoodsLot(value);
  949. //RaisePropertyChanged(() => RelationDeliveryCount);
  950. //DeclareToDeliveryLot();
  951. //MainGoodsToLot();
  952. //RelationGoodsToLot();
  953. //DeliveryCountEvent();
  954. }
  955. }
  956. public string DeliveryCountCalcAlgrithm
  957. {
  958. get
  959. {
  960. string calcAlgrithm = string.Empty;
  961. if (DeliveryNum > 0)
  962. {
  963. calcAlgrithm = "(" + DeliveryNumDisplay + "*" + MinDeliveryUnit.ToString() + "*" + CurrentGoods.XDeliveryRatio + "/" + StandardQty.ToString() + ")";
  964. }
  965. return calcAlgrithm;
  966. }
  967. }
  968. public string RelationDeliveryCountCalcAlgrithm
  969. {
  970. get
  971. {
  972. //DeliveryCount
  973. string calcAlgrithm = string.Empty;
  974. if (DeliveryNum > 0)
  975. {
  976. calcAlgrithm = "(" + DeliveryCount + "*(" + CurrentGoods.PDeliveryRatio1 + "/" + CurrentGoods.XDeliveryRatio + "))";
  977. //calcAlgrithm = "(" + DeliveryNumDisplay + "*" + MinDeliveryUnit.ToString() + "*" + CurrentGoods.PDeliveryRatio1 + "/(" + StandardQty.ToString() + "*" + CurrentGoods.XDeliveryRatio + "))";
  978. }
  979. return calcAlgrithm;
  980. }
  981. }
  982. public string RelationDeliveryCountCalcAlgrithm2
  983. {
  984. get
  985. {
  986. string calcAlgrithm = string.Empty;
  987. if (DeliveryNum > 0)
  988. {
  989. calcAlgrithm = "(" + DeliveryCount + "*(" + CurrentGoods.PDeliveryRatio2 + "/" + CurrentGoods.XDeliveryRatio + "))";
  990. //calcAlgrithm = "(" + DeliveryNumDisplay + "*" + MinDeliveryUnit.ToString() + "*" + CurrentGoods.PDeliveryRatio2 + "/(" + StandardQty.ToString() + "*" + CurrentGoods.XDeliveryRatio + "))";
  991. }
  992. return calcAlgrithm;
  993. }
  994. }
  995. #endregion
  996. #region 关联商品申报数量
  997. private decimal _relationDeliveryCount =decimal.Zero;
  998. /// <summary>
  999. /// 关联商品申报数量
  1000. /// P数量 = X数量 * P辅助商品转换系数 / X辅助商品转换系数.
  1001. /// </summary>
  1002. public decimal RelationDeliveryCount
  1003. {
  1004. get
  1005. {
  1006. return _relationDeliveryCount;
  1007. }
  1008. set
  1009. {
  1010. Set(() => RelationDeliveryCount, ref _relationDeliveryCount, value);
  1011. RaisePropertyChanged(() => RelationDeliveryCountDisp);
  1012. RaisePropertyChanged(() => RelationDeliveryCountCalcAlgrithm);
  1013. RelationGoodsToLot();
  1014. }
  1015. }
  1016. public string RelationDeliveryCountDisp
  1017. {
  1018. get
  1019. {
  1020. if (RelationDeliveryCount == 0)
  1021. return "--";
  1022. return RelationDeliveryCount.ToString();
  1023. }
  1024. }
  1025. public string RelationGoodsHoldQtyDisp
  1026. {
  1027. get
  1028. {
  1029. if (RelationGoodsHoldQty == 0)
  1030. return "--";
  1031. return RelationGoodsHoldQty.ToString();
  1032. }
  1033. }
  1034. public string RelationGoodsHoldQty2Disp
  1035. {
  1036. get
  1037. {
  1038. if (RelationGoodsHoldQty2 == 0)
  1039. return "--";
  1040. return RelationGoodsHoldQty2.ToString();
  1041. }
  1042. }
  1043. private decimal _relationDeliveryCount2 = decimal.Zero;
  1044. /// <summary>
  1045. /// 关联商品申报数量
  1046. /// P数量 = X数量 * P辅助商品转换系数 / X辅助商品转换系数.
  1047. /// </summary>
  1048. public decimal RelationDeliveryCount2
  1049. {
  1050. get
  1051. {
  1052. return _relationDeliveryCount2;
  1053. }
  1054. set
  1055. {
  1056. Set(() => RelationDeliveryCount2, ref _relationDeliveryCount2, value);
  1057. RaisePropertyChanged(() => RelationDeliveryCountDisp2);
  1058. RaisePropertyChanged(() => RelationDeliveryCountCalcAlgrithm2);
  1059. RelationGoodsToLot();
  1060. }
  1061. }
  1062. public string RelationDeliveryCountDisp2
  1063. {
  1064. get
  1065. {
  1066. if (RelationDeliveryCount2 == 0)
  1067. return "--";
  1068. return RelationDeliveryCount2.ToString();
  1069. }
  1070. }
  1071. #endregion
  1072. #region 持仓汇总
  1073. private decimal _totalHoldDetails;
  1074. /// <summary>
  1075. /// 持仓汇总
  1076. /// </summary>
  1077. public decimal TotalHoldDetails
  1078. {
  1079. get
  1080. {
  1081. return _totalHoldDetails;
  1082. }
  1083. set
  1084. {
  1085. Set(() => TotalHoldDetails, ref _totalHoldDetails, value);
  1086. }
  1087. }
  1088. #endregion
  1089. #region 交割价格
  1090. private string _xpriceFormat;
  1091. public string XPriceFormat
  1092. {
  1093. get
  1094. {
  1095. return _xpriceFormat;
  1096. }
  1097. set
  1098. {
  1099. Set(() => XPriceFormat, ref _xpriceFormat, value);
  1100. }
  1101. }
  1102. private decimal _deliveryPrice = decimal.Zero;
  1103. /// <summary>
  1104. /// 交割价格
  1105. /// </summary>
  1106. public decimal DeliveryPrice
  1107. {
  1108. get
  1109. {
  1110. return _deliveryPrice;
  1111. }
  1112. set
  1113. {
  1114. Set(() => DeliveryPrice, ref _deliveryPrice, value);
  1115. RaisePropertyChanged(() => DeliveryPriceFormat);
  1116. }
  1117. }
  1118. /// <summary>
  1119. /// 交割价格-格式化
  1120. /// </summary>
  1121. public string DeliveryPriceFormat
  1122. {
  1123. get
  1124. {
  1125. if (DeliveryPrice > decimal.Zero)
  1126. {
  1127. return DeliveryPrice.ToString("f2");
  1128. }
  1129. else
  1130. {
  1131. return "--";
  1132. }
  1133. }
  1134. }
  1135. #endregion
  1136. #region 是否忙
  1137. private bool _isBusy;
  1138. /// <summary>
  1139. /// 是否忙
  1140. /// </summary>
  1141. public bool IsBusy
  1142. {
  1143. get { return _isBusy; }
  1144. set { Set(() => IsBusy, ref _isBusy, value); }
  1145. }
  1146. #endregion
  1147. #region 是否忙
  1148. private bool _isBusyWR;
  1149. /// <summary>
  1150. /// 是否忙
  1151. /// </summary>
  1152. public bool IsBusyWR
  1153. {
  1154. get { return _isBusyWR; }
  1155. set { Set(() => IsBusyWR, ref _isBusyWR, value); }
  1156. }
  1157. #endregion
  1158. #region 交割关系表LIST
  1159. private List<GoodsDeliveryRelationModel> _goodsDeliveryRelationList;
  1160. public List<GoodsDeliveryRelationModel> GoodsDeliveryRelationList
  1161. {
  1162. get { return _goodsDeliveryRelationList; }
  1163. set { _goodsDeliveryRelationList = value; }
  1164. }
  1165. #endregion
  1166. #region 当前选择交易商品
  1167. private QuoteGoods _currentGoods;
  1168. /// <summary>
  1169. /// 当前选择交易商品
  1170. /// </summary>
  1171. public QuoteGoods CurrentGoods
  1172. {
  1173. get { return _currentGoods; }
  1174. set
  1175. {
  1176. Set(() => CurrentGoods, ref _currentGoods, value);
  1177. }
  1178. }
  1179. #endregion
  1180. #region 关联交易商品LIST
  1181. private ObservableCollection<string> _relationGoodsNameList = new ObservableCollection<string>();
  1182. /// <summary>
  1183. /// 关联交易商品LIST
  1184. /// </summary>
  1185. public ObservableCollection<string> RelationGoodsNameList
  1186. {
  1187. get { return _relationGoodsNameList; }
  1188. set { Set(() => RelationGoodsNameList, ref _relationGoodsNameList, value); }
  1189. }
  1190. private string _currentRelationGoodsName = string.Empty;
  1191. /// <summary>
  1192. /// Sets and gets the CurrentRelationGoodsName property.
  1193. /// </summary>
  1194. public string CurrentRelationGoodsName
  1195. {
  1196. get
  1197. {
  1198. return _currentRelationGoodsName;
  1199. }
  1200. set
  1201. {
  1202. Set(() => CurrentRelationGoodsName, ref _currentRelationGoodsName, value);
  1203. }
  1204. }
  1205. #endregion
  1206. #region 交割商品LIST
  1207. private ObservableCollection<string> _deliveryGoodsNameList = new ObservableCollection<string>();
  1208. /// <summary>
  1209. /// 交割商品LIST
  1210. /// </summary>
  1211. public ObservableCollection<string> DeliveryGoodsNameList
  1212. {
  1213. get { return _deliveryGoodsNameList; }
  1214. set { Set(() => DeliveryGoodsNameList, ref _deliveryGoodsNameList, value); }
  1215. }
  1216. private string _currentDeliveryGoodsName = string.Empty;
  1217. /// <summary>
  1218. /// Sets and gets the CurrentDeliveryGoodsName property.
  1219. /// </summary>
  1220. public string CurrentDeliveryGoodsName
  1221. {
  1222. get
  1223. {
  1224. return _currentDeliveryGoodsName;
  1225. }
  1226. set
  1227. {
  1228. Set(() => CurrentDeliveryGoodsName, ref _currentDeliveryGoodsName, value);
  1229. }
  1230. }
  1231. #endregion
  1232. #region 买卖方向LIST
  1233. private ObservableCollection<BuyOrSellDirection> _directionList = new ObservableCollection<BuyOrSellDirection>();
  1234. /// <summary>
  1235. /// 买卖方向LIST
  1236. /// </summary>
  1237. public ObservableCollection<BuyOrSellDirection> DirectionList
  1238. {
  1239. get
  1240. {
  1241. _directionList.Clear();
  1242. _directionList.Add(new BuyOrSellDirection() { BuyOrSell = Direction.Bid, BuyOrSellTitle = Resources.Client_Resource.Domain_BuyIn });
  1243. _directionList.Add(new BuyOrSellDirection() { BuyOrSell = Direction.Ask, BuyOrSellTitle = Resources.Client_Resource.Domain_SellOut });
  1244. CurrentBuyOrSell = _directionList.FirstOrDefault();
  1245. return _directionList;
  1246. }
  1247. }
  1248. #endregion
  1249. #region 当前商品的持仓单
  1250. private List<HoldingOrder> _holdDetails;
  1251. /// <summary>
  1252. /// 当前商品的持仓单
  1253. /// </summary>
  1254. public List<HoldingOrder> HoldDetails
  1255. {
  1256. get { return _holdDetails; }
  1257. set { Set(() => HoldDetails, ref _holdDetails, value); }
  1258. }
  1259. #endregion
  1260. #region 当前买卖方向实体
  1261. private BuyOrSellDirection _currentBuyOrSell;
  1262. /// <summary>
  1263. /// 当前买卖方向实体
  1264. /// </summary>
  1265. public BuyOrSellDirection CurrentBuyOrSell
  1266. {
  1267. get
  1268. {
  1269. return _currentBuyOrSell;
  1270. }
  1271. set
  1272. {
  1273. Set(() => CurrentBuyOrSell, ref _currentBuyOrSell, value);
  1274. //SetDeliveryCount();
  1275. }
  1276. }
  1277. #endregion
  1278. #region 当前关联模式
  1279. private eDeliveryContractLink _currentRelationMode = eDeliveryContractLink.None;
  1280. /// <summary>
  1281. /// 当前关联模式
  1282. /// </summary>
  1283. public eDeliveryContractLink CurrentRelationMode
  1284. {
  1285. get
  1286. {
  1287. return _currentRelationMode;
  1288. }
  1289. set
  1290. {
  1291. Set(() => CurrentRelationMode, ref _currentRelationMode, value);
  1292. }
  1293. }
  1294. #endregion
  1295. #region 当前资金模式
  1296. private eMoneyMode _currentMoneyMode = eMoneyMode.MONEYMODE_MARGIN;
  1297. /// <summary>
  1298. /// 当前资金模式
  1299. /// </summary>
  1300. public eMoneyMode CurrentMoneyMode
  1301. {
  1302. get
  1303. {
  1304. return _currentMoneyMode;
  1305. }
  1306. set
  1307. {
  1308. Set(() => CurrentMoneyMode, ref _currentMoneyMode, value);
  1309. }
  1310. }
  1311. #endregion
  1312. #region 交割商品列表
  1313. private List<QuoteGoods> _deliveryGoodsList;
  1314. /// <summary>
  1315. /// 交割商品列表
  1316. /// </summary>
  1317. public List<QuoteGoods> DeliveryGoodsList
  1318. {
  1319. get { return _deliveryGoodsList; }
  1320. set
  1321. {
  1322. Set(() => DeliveryGoodsList, ref _deliveryGoodsList, value);
  1323. }
  1324. }
  1325. #endregion
  1326. #region 错误信息提示
  1327. private string _ShowErrorInfo = string.Empty;
  1328. /// <summary>
  1329. /// Sets and gets the ShowErrorInfo property.
  1330. /// </summary>
  1331. public string ShowErrorInfo
  1332. {
  1333. get
  1334. {
  1335. return _ShowErrorInfo;
  1336. }
  1337. set
  1338. {
  1339. Set(() => ShowErrorInfo, ref _ShowErrorInfo, value);
  1340. }
  1341. }
  1342. private Visibility _IsShowErrorInfo = Visibility.Collapsed;
  1343. /// <summary>
  1344. /// Sets and gets the IsShowErrorInfo property.
  1345. /// </summary>
  1346. public Visibility IsShowErrorInfo
  1347. {
  1348. get
  1349. {
  1350. return _IsShowErrorInfo;
  1351. }
  1352. set
  1353. {
  1354. Set(() => IsShowErrorInfo, ref _IsShowErrorInfo, value);
  1355. }
  1356. }
  1357. #endregion
  1358. #region N 模式需要隐藏字段
  1359. private Visibility _isVisibility_N = Visibility.Collapsed;
  1360. /// <summary>
  1361. /// N 模式需要隐藏字段
  1362. /// </summary>
  1363. public Visibility IsVisibility_N
  1364. {
  1365. get
  1366. {
  1367. return _isVisibility_N;
  1368. }
  1369. set
  1370. {
  1371. Set(() => IsVisibility_N, ref _isVisibility_N, value);
  1372. }
  1373. }
  1374. private Visibility _isVisibility_Type1 = Visibility.Collapsed;
  1375. public Visibility IsVisibility_Type1
  1376. {
  1377. get
  1378. {
  1379. return _isVisibility_Type1;
  1380. }
  1381. set
  1382. {
  1383. Set(() => IsVisibility_Type1, ref _isVisibility_Type1, value);
  1384. }
  1385. }
  1386. private Visibility _isVisibility_Type2 = Visibility.Collapsed;
  1387. public Visibility IsVisibility_Type2
  1388. {
  1389. get
  1390. {
  1391. return _isVisibility_Type2;
  1392. }
  1393. set
  1394. {
  1395. Set(() => IsVisibility_Type2, ref _isVisibility_Type2, value);
  1396. }
  1397. }
  1398. #endregion
  1399. #region P 模式需要隐藏字段
  1400. private Visibility _isVisibility_P = Visibility.Collapsed;
  1401. /// <summary>
  1402. /// P 模式需要隐藏字段
  1403. /// </summary>
  1404. public Visibility IsVisibility_P
  1405. {
  1406. get
  1407. {
  1408. return _isVisibility_P;
  1409. }
  1410. set
  1411. {
  1412. Set(() => IsVisibility_P, ref _isVisibility_P, value);
  1413. }
  1414. }
  1415. #endregion
  1416. #region 升贴水类型查询条件隐藏
  1417. private Visibility _isVisibility_WareHouse = Visibility.Collapsed;
  1418. public Visibility IsVisibility_WareHouse
  1419. {
  1420. get { return _isVisibility_WareHouse; }
  1421. set { Set(() => IsVisibility_WareHouse, ref _isVisibility_WareHouse, value); }
  1422. }
  1423. private Visibility _isVisibility_Brand = Visibility.Collapsed;
  1424. public Visibility IsVisibility_Brand
  1425. {
  1426. get { return _isVisibility_Brand; }
  1427. set { Set(() => IsVisibility_Brand, ref _isVisibility_Brand, value); }
  1428. }
  1429. private Visibility _isVisibility_Quality = Visibility.Collapsed;
  1430. public Visibility IsVisibility_Quality
  1431. {
  1432. get { return _isVisibility_Quality; }
  1433. set { Set(() => IsVisibility_Quality, ref _isVisibility_Quality, value); }
  1434. }
  1435. private Visibility _isVisibility_Spec = Visibility.Collapsed;
  1436. public Visibility IsVisibility_Spec
  1437. {
  1438. get { return _isVisibility_Spec; }
  1439. set { Set(() => IsVisibility_Spec, ref _isVisibility_Spec, value); }
  1440. }
  1441. private Visibility _isVisibility_BtnSearch = Visibility.Collapsed;
  1442. public Visibility IsVisibility_BtnSearch
  1443. {
  1444. get { return _isVisibility_BtnSearch; }
  1445. set { Set(() => IsVisibility_BtnSearch, ref _isVisibility_BtnSearch, value); }
  1446. }
  1447. #endregion
  1448. #region PAndX 模式需要隐藏字段
  1449. private Visibility _isVisibility_PAndX = Visibility.Visible;
  1450. /// <summary>
  1451. /// PAndX 模式需要隐藏字段
  1452. /// </summary>
  1453. public Visibility IsVisibility_PAndX
  1454. {
  1455. get
  1456. {
  1457. return _isVisibility_PAndX;
  1458. }
  1459. set
  1460. {
  1461. Set(() => IsVisibility_PAndX, ref _isVisibility_PAndX, value);
  1462. }
  1463. }
  1464. #endregion
  1465. #region N 模式需要显示字段
  1466. private Visibility _isVisibility_Only_N = Visibility.Collapsed;
  1467. /// <summary>
  1468. /// N 模式需要显示字段
  1469. /// </summary>
  1470. public Visibility IsVisibility_Only_N
  1471. {
  1472. get
  1473. {
  1474. return _isVisibility_Only_N;
  1475. }
  1476. set
  1477. {
  1478. Set(() => IsVisibility_Only_N, ref _isVisibility_Only_N, value);
  1479. }
  1480. }
  1481. #endregion
  1482. #region 买卖方向选择是否可用
  1483. private bool _isEnable_Direction = false;
  1484. /// <summary>
  1485. /// 买卖方向选择是否可用
  1486. /// </summary>
  1487. public bool IsEnable_Direction
  1488. {
  1489. get
  1490. {
  1491. return _isEnable_Direction;
  1492. }
  1493. set
  1494. {
  1495. Set(() => IsEnable_Direction, ref _isEnable_Direction, value);
  1496. }
  1497. }
  1498. #endregion
  1499. #region 【置灰】设置按键不可用
  1500. private bool _oKButtonEnabled = false;
  1501. /// <summary>
  1502. ///设置按键不可用
  1503. /// </summary>
  1504. public bool OKButtonEnabled
  1505. {
  1506. get
  1507. {
  1508. return _oKButtonEnabled;
  1509. }
  1510. set
  1511. {
  1512. Set(() => OKButtonEnabled, ref _oKButtonEnabled, value);
  1513. }
  1514. }
  1515. #endregion
  1516. #region 提货方式
  1517. private TakeGoodsWay _takeGoodsWay;
  1518. /// <summary>
  1519. /// 提货方式
  1520. /// </summary>
  1521. public TakeGoodsWay TakeGoodsWay
  1522. {
  1523. get { return _takeGoodsWay; }
  1524. set { Set(() => TakeGoodsWay, ref _takeGoodsWay, value); }
  1525. }
  1526. #endregion
  1527. #region 身份证
  1528. private string _idCardNum;
  1529. /// <summary>
  1530. /// 身份证号
  1531. /// </summary>
  1532. public string IdCardNum
  1533. {
  1534. get { return _idCardNum; }
  1535. set { Set(() => IdCardNum, ref _idCardNum, value); }
  1536. }
  1537. #endregion
  1538. #endregion "Public Properties To Get/Set "
  1539. #region "=========公共命令/Public Commands"
  1540. /// <summary>
  1541. /// 下单窗口取消
  1542. /// </summary>
  1543. public RelayCommand<Window> CancelCommand
  1544. {
  1545. get
  1546. {
  1547. return new RelayCommand<Window>((dialog) =>
  1548. {
  1549. dialog.DialogResult = false;
  1550. });
  1551. }
  1552. }
  1553. /// <summary>
  1554. /// 下单确定
  1555. /// </summary>
  1556. public RelayCommand<Window> OKCommand
  1557. {
  1558. get
  1559. {
  1560. return new RelayCommand<Window>((dialog) =>
  1561. {
  1562. OKButtonEnabled = false;
  1563. string errorMsg = string.Empty;
  1564. bool validateBool = true; ////内容验证
  1565. if (validateBool)
  1566. {
  1567. //BusyContent = Client_Resource.Content_Busy;
  1568. //IsBusy = true;
  1569. _openWindow = dialog;
  1570. GetDataBeforeSubmit();
  1571. var newOrder = new DeliveryOrderReqModel()
  1572. {
  1573. AccountID = AccountID,
  1574. EntrustTime = ApplicationParameter.ServerTimeNow,
  1575. DeliveryGoodsID = DeliveryGoodsID,
  1576. DeliveryQty = (ulong)submitDeliveryQty,
  1577. OperatorID = (uint)AccountID,
  1578. PGoodsID = P1GoodsID,
  1579. PQty = ulong.Parse((RelationDeliveryCountDisp == "--") ? "0" : RelationDeliveryCountDisp),
  1580. P2GoodsID = P2GoodsID,
  1581. P2Qty = ulong.Parse((RelationDeliveryCountDisp2 == "--") ? "0" : RelationDeliveryCountDisp2),
  1582. XGoodsID = XGoodsID,
  1583. XQty = (ulong)DeliveryCount,
  1584. };
  1585. foreach (var writem in CurrentSelectedWrDetail)
  1586. {
  1587. newOrder.wrDetail = writem;
  1588. _deliveryService.DeliveryApplyOrder(newOrder, null, null);
  1589. }
  1590. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  1591. {
  1592. OKButtonEnabled = true;
  1593. MessageBoxHelper.ShowSuccess("交割申请已提交",
  1594. Client_Resource.UI2014_Tips);
  1595. if (_openWindow != null)
  1596. {
  1597. _openWindow.Close();
  1598. this.Cleanup();
  1599. }
  1600. }));
  1601. }
  1602. else
  1603. {
  1604. MessageBoxHelper.ShowInfo(errorMsg, Client_Resource.MessageBox_Error_Title);
  1605. OKButtonEnabled = true;
  1606. }
  1607. });
  1608. }
  1609. }
  1610. #region 选中Command
  1611. /// <summary>
  1612. /// 选中
  1613. /// </summary>
  1614. private RelayCommand<TradeWRPositionModel> selectCommand;
  1615. public RelayCommand<TradeWRPositionModel> SelectCommand
  1616. {
  1617. get
  1618. {
  1619. return selectCommand ?? (selectCommand = new RelayCommand<TradeWRPositionModel>(
  1620. (x) =>
  1621. {
  1622. if (_action == false)
  1623. {
  1624. _action = true;
  1625. x.IsEnable = true;
  1626. CurrentSelectedWhRecieptEx = x;
  1627. SettlementDeliveryMatchNum(CommandFromType.SelectedCommand);
  1628. _action = false;
  1629. }
  1630. }));
  1631. }
  1632. }
  1633. #endregion
  1634. #region 取消选中Command
  1635. /// <summary>
  1636. /// 取消选中
  1637. /// </summary>
  1638. private RelayCommand<TradeWRPositionModel> unSelectCommand;
  1639. public RelayCommand<TradeWRPositionModel> UnSelectCommand
  1640. {
  1641. get
  1642. {
  1643. return unSelectCommand ?? (unSelectCommand = new RelayCommand<TradeWRPositionModel>(
  1644. (x) =>
  1645. {
  1646. if (_action == false)
  1647. {
  1648. _action = true;
  1649. CurrentSelectedWhRecieptEx = x;
  1650. CurrentSelectedWhRecieptEx.SelectQty = 0;
  1651. CurrentSelectedWhRecieptEx.SelectedQty = "0";
  1652. SettlementDeliveryMatchNum(CommandFromType.UnSelectedCommand);
  1653. _action = false;
  1654. }
  1655. }));
  1656. }
  1657. }
  1658. #endregion
  1659. #region 文本改变命令Command
  1660. private RelayCommand<TradeWRPositionModel> _selectQtyTextChangedCommand;
  1661. /// <summary>
  1662. /// 文本改变命令Command
  1663. /// </summary>
  1664. public RelayCommand<TradeWRPositionModel> SelectQtyTextChangedCommand
  1665. {
  1666. get
  1667. {
  1668. return _selectQtyTextChangedCommand
  1669. ?? (_selectQtyTextChangedCommand = new RelayCommand<TradeWRPositionModel>(
  1670. p =>
  1671. {
  1672. if (_action == false)
  1673. {
  1674. _action = true;
  1675. CurrentSelectedWhRecieptEx = p;
  1676. SettlementDeliveryMatchNum(CommandFromType.TextCommand);
  1677. _action = false;
  1678. }
  1679. }));
  1680. }
  1681. }
  1682. #endregion
  1683. #endregion "Public Commands"
  1684. #region WarehouseSelectionChangedCommand
  1685. private RelayCommand _warehouseSelectionChanged;
  1686. /// <summary>
  1687. /// Gets the WarehouseSelectionChanged.
  1688. /// </summary>
  1689. public RelayCommand WarehouseSelectionChanged
  1690. {
  1691. get
  1692. {
  1693. return _warehouseSelectionChanged
  1694. ?? (_warehouseSelectionChanged = new RelayCommand(
  1695. () =>
  1696. {
  1697. if (!string.IsNullOrEmpty(SelectedWareHouse.Key))
  1698. {
  1699. FilterList.Clear();
  1700. if (SelectedWareHouse.Key != "0")
  1701. {
  1702. FilterList.Add(SelectedWareHouse);
  1703. }
  1704. if (!string.IsNullOrEmpty(SelectedBrand.Key) && SelectedBrand.Key != "0")
  1705. {
  1706. FilterList.Add(SelectedBrand);
  1707. }
  1708. if (!string.IsNullOrEmpty(SelectedQuality.Key) && SelectedQuality.Key != "0")
  1709. {
  1710. FilterList.Add(SelectedQuality);
  1711. }
  1712. if (!string.IsNullOrEmpty(SelectedSpeci.Key) && SelectedSpeci.Key != "0")
  1713. {
  1714. FilterList.Add(SelectedSpeci);
  1715. }
  1716. }
  1717. }));
  1718. }
  1719. }
  1720. #endregion
  1721. #region BrandSelectionChanged
  1722. private RelayCommand _brandSelectionChanged;
  1723. /// <summary>
  1724. /// Gets the BrandSelectionChanged.
  1725. /// </summary>
  1726. public RelayCommand BrandSelectionChanged
  1727. {
  1728. get
  1729. {
  1730. return _brandSelectionChanged
  1731. ?? (_brandSelectionChanged = new RelayCommand(
  1732. () =>
  1733. {
  1734. if (!string.IsNullOrEmpty(SelectedBrand.Key))
  1735. {
  1736. FilterList.Clear();
  1737. if (SelectedBrand.Key != "0")
  1738. {
  1739. FilterList.Add(SelectedBrand);
  1740. }
  1741. if (!string.IsNullOrEmpty(SelectedWareHouse.Key) && SelectedWareHouse.Key != "0")
  1742. {
  1743. FilterList.Add(SelectedWareHouse);
  1744. }
  1745. if (!string.IsNullOrEmpty(SelectedQuality.Key) && SelectedQuality.Key != "0")
  1746. {
  1747. FilterList.Add(SelectedQuality);
  1748. }
  1749. if (!string.IsNullOrEmpty(SelectedSpeci.Key) && SelectedSpeci.Key != "0")
  1750. {
  1751. FilterList.Add(SelectedSpeci);
  1752. }
  1753. }
  1754. }));
  1755. }
  1756. }
  1757. #endregion
  1758. #region QualitySelectionChangedCommand
  1759. private RelayCommand _qualitySelectionChanged;
  1760. /// <summary>
  1761. /// Gets the RankSelectionChangedCommand.
  1762. /// </summary>
  1763. public RelayCommand QualitySelectionChanged
  1764. {
  1765. get
  1766. {
  1767. return _qualitySelectionChanged
  1768. ?? (_qualitySelectionChanged = new RelayCommand(
  1769. () =>
  1770. {
  1771. if (!string.IsNullOrEmpty(SelectedQuality.Key))
  1772. {
  1773. FilterList.Clear();
  1774. if (SelectedQuality.Key != "0")
  1775. {
  1776. FilterList.Add(SelectedQuality);
  1777. }
  1778. if (!string.IsNullOrEmpty(SelectedWareHouse.Key) && SelectedWareHouse.Key != "0")
  1779. {
  1780. FilterList.Add(SelectedWareHouse);
  1781. }
  1782. if (!string.IsNullOrEmpty(SelectedBrand.Key) && SelectedBrand.Key != "0")
  1783. {
  1784. FilterList.Add(SelectedBrand);
  1785. }
  1786. if (!string.IsNullOrEmpty(SelectedSpeci.Key) && SelectedSpeci.Key != "0")
  1787. {
  1788. FilterList.Add(SelectedSpeci);
  1789. }
  1790. }
  1791. }));
  1792. }
  1793. }
  1794. #endregion
  1795. #region SpeciSelectionChangedCommand
  1796. private RelayCommand _speciSelectionChanged;
  1797. /// <summary>
  1798. /// Gets the RankSelectionChangedCommand.
  1799. /// </summary>
  1800. public RelayCommand SpeciSelectionChanged
  1801. {
  1802. get
  1803. {
  1804. return _speciSelectionChanged
  1805. ?? (_speciSelectionChanged = new RelayCommand(
  1806. () =>
  1807. {
  1808. if (!string.IsNullOrEmpty(SelectedSpeci.Key))
  1809. {
  1810. FilterList.Clear();
  1811. if (SelectedSpeci.Key != "0")
  1812. {
  1813. FilterList.Add(SelectedSpeci);
  1814. }
  1815. if (!string.IsNullOrEmpty(SelectedWareHouse.Key) && SelectedWareHouse.Key != "0")
  1816. {
  1817. FilterList.Add(SelectedWareHouse);
  1818. }
  1819. if (!string.IsNullOrEmpty(SelectedBrand.Key) && SelectedBrand.Key != "0")
  1820. {
  1821. FilterList.Add(SelectedBrand);
  1822. }
  1823. if (!string.IsNullOrEmpty(SelectedQuality.Key) && SelectedQuality.Key != "0")
  1824. {
  1825. FilterList.Add(SelectedQuality);
  1826. }
  1827. }
  1828. }));
  1829. }
  1830. }
  1831. #endregion
  1832. #region "=========私有方法/Private Methods"
  1833. /// <summary>
  1834. /// 勾选仓单处理
  1835. /// </summary>
  1836. /// <param name="commandType"></param>
  1837. private void SettlementDeliveryMatchNum(CommandFromType commandType)
  1838. {
  1839. switch (commandType)
  1840. {
  1841. case CommandFromType.TextCommand:
  1842. CurrentSelectedWhRecieptEx.SelectedQty = (CurrentSelectedWhRecieptEx.SelectQty * StandardQty).ToString();
  1843. //SelectQtyTextChangedHandleEvent();
  1844. break;
  1845. case CommandFromType.SelectedCommand:
  1846. CurrentSelectedWhRecieptEx.SelectedQty = (CurrentSelectedWhRecieptEx.SelectQty * StandardQty).ToString();
  1847. break;
  1848. case CommandFromType.UnSelectedCommand:
  1849. CurrentSelectedWhRecieptEx.IsEnable = false;
  1850. break;
  1851. default:
  1852. break;
  1853. }
  1854. CtrlDeliveryQtyChangeEvent();
  1855. }
  1856. /// <summary>
  1857. /// 控制点选仓单时候,交割数量的变化事件
  1858. /// </summary>
  1859. private void CtrlDeliveryQtyChangeEvent()
  1860. {
  1861. OKButtonEnabled = false;
  1862. var sourceList = WrPairDetailsListEx.FindAll(p => p.IsSelected == true);
  1863. DeliveryNum = decimal.Zero;
  1864. if (sourceList != null && sourceList.Count > 0)
  1865. {
  1866. foreach (var item in sourceList)
  1867. {
  1868. DeliveryNum += Convert.ToDecimal(item.SelectQty) * StandardQty;
  1869. }
  1870. }
  1871. if (DeliveryNum != decimal.Zero)
  1872. {
  1873. OKButtonEnabled = true;//是否已经点选仓单且数量大于零
  1874. }
  1875. }
  1876. /// <summary>
  1877. /// DataGrid 选择文本改变处理事件
  1878. /// </summary>
  1879. private void SelectQtyTextChangedHandleEvent()
  1880. {
  1881. if (CurrentSelectedWhRecieptEx.SelectQty>0)
  1882. {
  1883. CurrentSelectedWhRecieptEx.IsSelected = true;
  1884. }
  1885. else
  1886. {
  1887. CurrentSelectedWhRecieptEx.IsSelected = false;
  1888. }
  1889. }
  1890. /// <summary>
  1891. /// 提交数据前获取选择的仓单ID/数量
  1892. /// </summary>
  1893. private void GetDataBeforeSubmit()
  1894. {
  1895. if (CurrentSelectedWrDetail != null)
  1896. {
  1897. CurrentSelectedWrDetail.Clear();
  1898. }
  1899. var sourceList = WrPairDetailsListEx.FindAll(p => p.IsSelected == true);
  1900. submitDeliveryQty = decimal.Zero;//点选的交割总数量
  1901. foreach (var item in sourceList)
  1902. {
  1903. if (!CurrentSelectedWrDetail.Any(x => x.WRPositionID == item.WRPositionID))
  1904. {
  1905. var newWrDetail = getWrItem(item.WRPositionID);
  1906. CurrentSelectedWrDetail.Add(newWrDetail);
  1907. submitDeliveryQty += (decimal)newWrDetail.Qty;
  1908. }
  1909. }
  1910. }
  1911. /// <summary>
  1912. /// 获取指定WrDetailModel实例
  1913. /// </summary>
  1914. /// <returns></returns>
  1915. private WrDetailModel getWrItem(ulong wrcode)
  1916. {
  1917. var selectItem = WrPairDetailsListEx.Where(x => x.WRPositionID == wrcode).FirstOrDefault();
  1918. var item = new WrDetailModel()
  1919. {
  1920. AccountID=selectItem.AccountID,
  1921. BrandID=selectItem.BrandID,
  1922. DeliveryMonthID=selectItem.DeliveryMonthID,
  1923. Qty=ulong.Parse(selectItem.SelectedQty),
  1924. QualityID=selectItem.QualityID,
  1925. StandardID=selectItem.SpecID,
  1926. WarehouseID=selectItem.WarehouseID
  1927. };
  1928. return item;
  1929. }
  1930. /// <summary>
  1931. /// 触发提交按钮是否可用
  1932. /// </summary>
  1933. private void IsEnableButtonEvent()
  1934. {
  1935. //交易员账户,且商品是做市商品时,不可以发起交割申报
  1936. OKButtonEnabled = false;
  1937. if (_currentDirection == Direction.Ask)
  1938. {
  1939. if (CurrentSelectedWrDetail != null
  1940. && CurrentSelectedWrDetail.Any()
  1941. && CurrentSelectedWrDetail.Count() > 0
  1942. //&& AlreadyMatchQty == preOtherCanMatchQty
  1943. && CurrentGoods != null
  1944. //&& FreezeDeliveryMoney <= usableFunds
  1945. && DeliveryCount <= MaxDeliveryUnit && DeliveryCount > 0
  1946. && (UserManager.CurrentTradeAccount.AccountType == eUserType.USERTYPE_INVESTOR )//|| CurrentGoods.currentTradeMode != eTradeMode.TRADEMODE_MARKETMAKE)
  1947. )
  1948. {
  1949. OKButtonEnabled = true;
  1950. }
  1951. else
  1952. {
  1953. OKButtonEnabled = false;
  1954. }
  1955. }
  1956. else
  1957. {
  1958. if (MaxDeliveryUnit <= 0 || MinDeliveryUnit <= 0 || CurrentGoods == null
  1959. || DeliveryCount > MaxDeliveryUnit || DeliveryCount <= 0
  1960. || (RelationDeliveryCount > RelationGoodsHoldQty && CurrentRelationMode == eDeliveryContractLink.PAndX)
  1961. || (MinDeliveryUnit != 0 && DeliveryCount % MinDeliveryUnit != 0 )
  1962. )
  1963. {
  1964. OKButtonEnabled = false;
  1965. }
  1966. else
  1967. {
  1968. OKButtonEnabled = true;
  1969. }
  1970. }
  1971. }
  1972. private void DeliveryCountEvent()
  1973. {
  1974. ShowErrorInfo = string.Empty;
  1975. IsError_DeliveryCount = false;
  1976. IsError_RelationDeliveryCount = false;
  1977. IsError_RelationDeliveryCount2 = false;
  1978. if (CurrentGoods != null)
  1979. {
  1980. //if (FreezeDeliveryMoney > usableFunds)
  1981. //{
  1982. // ShowErrorInfo = Client_Resource.DeliveryOrderViewModel_usableFundsNotEnough;// "资金不足,请修改交割数量";
  1983. //}
  1984. var maxQty = Math.Min(AvailHoldQty, MaxDeliveryUnit);
  1985. if (MinDeliveryUnit != 0 && DeliveryCount % MinDeliveryUnit != 0)
  1986. {
  1987. IsError_DeliveryCount = true;
  1988. ShowErrorInfo = string.Format(Client_Resource.DeliveryOrderViewModel_MaxMin_Error, MinDeliveryUnit, maxQty, MinDeliveryUnit);// 申报数量需小于可用数量,且为最小交割数量{***}的整数倍
  1989. }
  1990. if (DeliveryCount > MaxDeliveryUnit || DeliveryCount < MinDeliveryUnit)
  1991. {
  1992. IsError_DeliveryCount = true;
  1993. ShowErrorInfo = string.Format(Client_Resource.DeliveryOrderViewModel_MaxMin_Error, MinDeliveryUnit, maxQty, MinDeliveryUnit);// 申报数量应当在最小申报数量{0}与最大申报数量之间。
  1994. }
  1995. if (RelationDeliveryCount > RelationGoodsHoldQty && CurrentRelationMode == eDeliveryContractLink.PAndX)
  1996. {
  1997. IsError_RelationDeliveryCount = true;
  1998. ShowErrorInfo = Client_Resource.DeliveryOrderViewModel_RelationHolderNotEnough;// 关联商品可用数量不足,请修改申报数量
  1999. }
  2000. //if ((UserManager.CurrentTradeAccount.AccountType == eLoginUserType.LOGINUSERTYPE_TRADER && CurrentGoods.currentTradeMode == eTradeMode.TRADEMODE_MARKETMAKE))
  2001. //{
  2002. // ShowErrorInfo = Client_Resource.DeliveryOrderViewModel_AccountTypeNotEnough;// "交易员账户,且商品是做市商品时,不可以发起交割申报";
  2003. //}
  2004. // IsEnableButtonEvent();
  2005. }
  2006. }
  2007. /// <summary>
  2008. /// 提交成功返回
  2009. /// </summary>
  2010. /// <param name="order"></param>
  2011. private void EntrurstSuccessCallBack(DeliveryOrderRspModel order)
  2012. {
  2013. //IsBusy = false;
  2014. //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  2015. //{
  2016. // OKButtonEnabled = true;
  2017. // MessageBoxHelper.ShowSuccess(Client_Resource.Order_Success_Result,
  2018. // Client_Resource.UI2014_Tips);
  2019. // if (_openWindow != null)
  2020. // {
  2021. // _openWindow.Close();
  2022. // this.Cleanup();
  2023. // }
  2024. //}));
  2025. //刷新正常单
  2026. MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.OrderNoticeToken);
  2027. }
  2028. /// <summary>
  2029. /// 委托失败返回
  2030. /// </summary>
  2031. /// <param name="errorEntity"></param>
  2032. private void EntrurstErrorCallBack(ErrorEntity errorEntity)
  2033. {
  2034. IsBusy = false;
  2035. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  2036. {
  2037. OKButtonEnabled = true;
  2038. ErrorManager.ShowReturnError(errorEntity, Client_Resource.UI2014_Tips, true);
  2039. if (_openWindow != null)
  2040. {
  2041. _openWindow.Close();
  2042. MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.HolderUpdate);
  2043. this.Cleanup();
  2044. }
  2045. }));
  2046. }
  2047. /// <summary>
  2048. /// 初始化交割商品列表数据
  2049. /// </summary>
  2050. private void InitData(DeliveryOrderMessage parameterInfo)
  2051. {
  2052. IsBusy = true;
  2053. XGoodsID = parameterInfo.GoodsId;
  2054. AccountID = parameterInfo.AccountID;
  2055. Direction buyOrSell = parameterInfo.Direction;
  2056. CurrentGoods = CacheManager.CacheGoodsBaseInfos.FirstOrDefault(p => p.GoodsId == XGoodsID);
  2057. XGoodsCode = CurrentGoods.GoodsCode;
  2058. XGoodsName = CurrentGoods.Name;
  2059. this._goodsItem = new QuoteGoodsDTO(CurrentGoods);
  2060. XPriceFormat = this._goodsItem.CurrentPriceDisplay;
  2061. string deliveryFactorTips = string.Empty;
  2062. var goodsPMLst = CurrentGoods.GoodsPMList;
  2063. if (goodsPMLst != null)
  2064. {
  2065. foreach (var pm in goodsPMLst)
  2066. {
  2067. string pmTip = string.Empty;
  2068. if (pm.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_BRAND)
  2069. {
  2070. pmTip = "品牌:";
  2071. }
  2072. else if (pm.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_QUALITY)
  2073. {
  2074. pmTip = "品质:";
  2075. }
  2076. else if (pm.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION)
  2077. {
  2078. pmTip = "规格:";
  2079. }
  2080. else if (pm.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE)
  2081. {
  2082. pmTip = "仓库:";
  2083. }
  2084. pmTip += pm.PriceMoveDesc;
  2085. deliveryFactorTips += pmTip + ", ";
  2086. }
  2087. if (deliveryFactorTips.Length > 0)
  2088. {
  2089. deliveryFactorTips = deliveryFactorTips.Substring(0, deliveryFactorTips.Length - 5);
  2090. }
  2091. }
  2092. DeliveryFactor = deliveryFactorTips;
  2093. var currentHolding = CacheManager.HoldingSummaries[AccountID].FirstOrDefault(p => p.GoodsId == XGoodsID);
  2094. if (currentHolding != null)
  2095. {
  2096. if (buyOrSell == Direction.Bid)
  2097. {
  2098. this.AvailHoldQty = currentHolding.BuyCurPositionQty - currentHolding.BuyFrozenQty - currentHolding.BuyOtherFrozenQty;
  2099. }
  2100. else
  2101. {
  2102. this.AvailHoldQty = currentHolding.SellCurPositionQty = currentHolding.SellFrozenQty - currentHolding.SellOtherFrozenQty;
  2103. }
  2104. }
  2105. if (CurrentGoods.P1Type == uint.MaxValue && CurrentGoods.P2Type == uint.MaxValue)
  2106. {
  2107. IsVisibility_P = Visibility.Collapsed;
  2108. IsVisibility_Type1 = Visibility.Collapsed;
  2109. IsVisibility_Type2 = Visibility.Collapsed;
  2110. }
  2111. else
  2112. {
  2113. IsVisibility_P = Visibility.Visible;
  2114. if (CurrentGoods.P1Type != uint.MaxValue)
  2115. {
  2116. IsVisibility_Type1 = Visibility.Visible;
  2117. if (CurrentGoods.P1Type == 1)
  2118. {
  2119. var currentP1 = CacheManager.CacheGoodsBaseInfos.FirstOrDefault(p => p.GoodsId == CurrentGoods.PGoodsID1);
  2120. var P1Holding = CacheManager.HoldingSummaries[AccountID].FirstOrDefault(p => p.GoodsId == CurrentGoods.PGoodsID1);
  2121. if (P1Holding != null)
  2122. {
  2123. if (buyOrSell == Direction.Bid)
  2124. {
  2125. this.RelationGoodsHoldQty = P1Holding.BuyCurPositionQty - P1Holding.BuyFrozenQty - P1Holding.BuyOtherFrozenQty;
  2126. }
  2127. else
  2128. {
  2129. this.RelationGoodsHoldQty = P1Holding.SellCurPositionQty - P1Holding.SellFrozenQty - P1Holding.SellOtherFrozenQty;
  2130. }
  2131. }
  2132. P1GoodsName = currentP1.Name;
  2133. P1GoodsCode = currentP1.GoodsCode;
  2134. P1GoodsID = currentP1.GoodsId;
  2135. }
  2136. else
  2137. {
  2138. P1GoodsName = "固定价";
  2139. RelationGoodsHoldPrice = CurrentGoods.P1value;
  2140. }
  2141. }
  2142. else
  2143. {
  2144. IsVisibility_Type1 = Visibility.Collapsed;
  2145. }
  2146. if (CurrentGoods.P2Type != uint.MaxValue)
  2147. {
  2148. IsVisibility_Type2 = Visibility.Visible;
  2149. if (CurrentGoods.P2Type == 1)
  2150. {
  2151. var currentP2 = CacheManager.CacheGoodsBaseInfos.FirstOrDefault(p => p.GoodsId == CurrentGoods.PGoodsID2);
  2152. var P2Holding = CacheManager.HoldingSummaries[AccountID].FirstOrDefault(p => p.GoodsId == CurrentGoods.PGoodsID2);
  2153. if (P2Holding != null)
  2154. {
  2155. if (buyOrSell == Direction.Bid)
  2156. {
  2157. this.RelationGoodsHoldQty2 = P2Holding.BuyCurPositionQty - P2Holding.BuyFrozenQty - P2Holding.BuyOtherFrozenQty;
  2158. }
  2159. else
  2160. {
  2161. this.RelationGoodsHoldQty2 = P2Holding.SellCurPositionQty = P2Holding.SellFrozenQty - P2Holding.SellOtherFrozenQty;
  2162. }
  2163. }
  2164. P2GoodsName = currentP2.Name;
  2165. P2GoodsCode = currentP2.GoodsCode;
  2166. P2GoodsID = currentP2.GoodsId;
  2167. }
  2168. else
  2169. {
  2170. P2GoodsName = "固定价";
  2171. RelationGoodsHoldPrice2 = CurrentGoods.P2value;
  2172. }
  2173. }
  2174. else
  2175. {
  2176. IsVisibility_Type2 = Visibility.Collapsed;
  2177. }
  2178. }
  2179. DeliveryGoodsName = CurrentGoods.DeliveryGoodsName;
  2180. DeliveryGoodsCode = CurrentGoods.DeliveryGoodsCode;
  2181. DeliveryGoodsNameCode = CurrentGoods.DeliveryGoodsNameCode;
  2182. uint DeliveryGoodsID = CurrentGoods.DeliveryGoodsId;
  2183. uint TradeProperty = (uint)CurrentGoods.TradeProperty;
  2184. _deliveryService.QueryDeliveryWarehouseOrdersNew(XGoodsID, DeliveryGoodsID, TradeProperty, QuerySuccessCallBackNew, QueryErrorCallbackNew);
  2185. }
  2186. private void QuerySuccessCallBackNew(DeliveryWRRspModel model)
  2187. {
  2188. var currentDeliveryGoods = CacheManager.CacheDeliveryGoodsInfo.FirstOrDefault(p => p.DeliveryGoodsCode == DeliveryGoodsCode);
  2189. StandardQty = currentDeliveryGoods.StandardQty;
  2190. DeliveryGoodsID = currentDeliveryGoods.DeliveryGoodsID;
  2191. List<GoodsDryPriceModel> goodsDryLst = model.GoodsDeliveryPriceList;
  2192. List<TradeWRPositionModel> tradeWRPositionLst = model.TradeWRPositionList;
  2193. List<PriceMoveModel> AllFilterLst = currentDeliveryGoods.DeliveryGoodsPMList;
  2194. List<PriceMoveModel> ExceptFilterLst = CurrentGoods.GoodsPMList;
  2195. foreach (var item in ExceptFilterLst)
  2196. {
  2197. AllFilterLst = AllFilterLst.FindAll(p => p.PriceMoveType != item.PriceMoveType);
  2198. }
  2199. if (AllFilterLst != null && AllFilterLst.Count > 0)
  2200. {
  2201. IsVisibility_BtnSearch=Visibility.Visible;
  2202. var brandLst = AllFilterLst.FindAll(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_BRAND);
  2203. if (brandLst.Count > 0)
  2204. {
  2205. IsVisibility_Brand = Visibility.Visible;
  2206. DeliveryBrandList = brandLst.Select(p => { return new KeyValuePair<string, string>(p.PriceMoveType +"_"+ p.PriceMoveID.ToString(), p.PriceMoveDesc); }).ToList();
  2207. SelectedBrand = new KeyValuePair<string, string>("0", "所有品牌");
  2208. DeliveryBrandList.Insert(0, SelectedBrand);
  2209. }
  2210. else
  2211. {
  2212. IsVisibility_Brand = Visibility.Collapsed;
  2213. }
  2214. var qualityLst = AllFilterLst.FindAll(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_QUALITY);
  2215. if (qualityLst.Count > 0)
  2216. {
  2217. IsVisibility_Quality = Visibility.Visible;
  2218. DeliveryQualityList = qualityLst.Select(p => { return new KeyValuePair<string, string>(p.PriceMoveType +"_"+ p.PriceMoveID.ToString(), p.PriceMoveDesc); }).ToList();
  2219. SelectedQuality = new KeyValuePair<string, string>("0", "所有品质");
  2220. DeliveryQualityList.Insert(0, SelectedQuality);
  2221. }
  2222. else
  2223. {
  2224. IsVisibility_Quality = Visibility.Collapsed;
  2225. }
  2226. var speciLst = AllFilterLst.FindAll(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION);
  2227. if (speciLst.Count > 0)
  2228. {
  2229. IsVisibility_Spec = Visibility.Visible;
  2230. DeliverySpeciList = speciLst.Select(p => { return new KeyValuePair<string, string>(p.PriceMoveType +"_"+ p.PriceMoveID.ToString(), p.PriceMoveDesc); }).ToList();
  2231. SelectedSpeci = new KeyValuePair<string, string>("0", "所有规格");
  2232. DeliverySpeciList.Insert(0, SelectedSpeci);
  2233. }
  2234. else
  2235. {
  2236. IsVisibility_Spec = Visibility.Collapsed;
  2237. }
  2238. var warehouseLst = AllFilterLst.FindAll(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE);
  2239. if (warehouseLst.Count > 0)
  2240. {
  2241. IsVisibility_WareHouse = Visibility.Visible;
  2242. List<KeyValuePair<string, string>> wareLst = warehouseLst.Select(p => { return new KeyValuePair<string, string>(p.PriceMoveType +"_"+ p.PriceMoveID.ToString(), p.PriceMoveDesc); }).ToList();
  2243. SelectedWareHouse = new KeyValuePair<string, string>("0", "所有仓库");
  2244. wareLst.Insert(0, SelectedWareHouse);
  2245. DeliveryWarehouseList = new ObservableCollection<KeyValuePair<string, string>>(wareLst);
  2246. }
  2247. else
  2248. {
  2249. IsVisibility_WareHouse = Visibility.Collapsed;
  2250. }
  2251. }
  2252. else
  2253. {
  2254. IsVisibility_Brand = Visibility.Collapsed;
  2255. IsVisibility_Quality = Visibility.Collapsed;
  2256. IsVisibility_Spec = Visibility.Collapsed;
  2257. IsVisibility_WareHouse = Visibility.Collapsed;
  2258. IsVisibility_BtnSearch = Visibility.Collapsed;
  2259. }
  2260. foreach (var tradeWR in tradeWRPositionLst)
  2261. {
  2262. tradeWR.BrandName = currentDeliveryGoods.DeliveryGoodsPMList.FirstOrDefault(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_BRAND && p.PriceMoveID == tradeWR.BrandID).PriceMoveDesc;
  2263. tradeWR.BrandType = ((int)ePriceMoveType.PRICEMOVETYPE_BRAND).ToString() +"_"+ tradeWR.BrandID;
  2264. tradeWR.MaximunQty = (uint)tradeWR.RestQty / (uint)StandardQty;
  2265. tradeWR.QualityName = currentDeliveryGoods.DeliveryGoodsPMList.FirstOrDefault(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_QUALITY && p.PriceMoveID == tradeWR.QualityID).PriceMoveDesc;
  2266. tradeWR.QualityType = ((int)ePriceMoveType.PRICEMOVETYPE_QUALITY).ToString() +"_"+ tradeWR.QualityID;
  2267. tradeWR.SpecName = currentDeliveryGoods.DeliveryGoodsPMList.FirstOrDefault(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION && p.PriceMoveID == tradeWR.SpecID).PriceMoveDesc;
  2268. tradeWR.SpecType = ((int)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION).ToString() +"_"+ tradeWR.SpecID;
  2269. tradeWR.WarehouseName = currentDeliveryGoods.DeliveryGoodsPMList.FirstOrDefault(p => p.PriceMoveType == (uint)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE && p.PriceMoveID == tradeWR.WarehouseID).PriceMoveDesc;
  2270. tradeWR.WarehouseType = ((int)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE).ToString() + "_" + tradeWR.WarehouseID;
  2271. var brand = goodsDryLst.FirstOrDefault(p => p.PriceMoveType == ((uint)ePriceMoveType.PRICEMOVETYPE_BRAND).ToString() && p.PriceMoveID == tradeWR.BrandID);
  2272. if (brand != null)
  2273. {
  2274. tradeWR.PriceMove += brand.PriceMoveValue;
  2275. }
  2276. var quality = goodsDryLst.FirstOrDefault(p => p.PriceMoveType == ((uint)ePriceMoveType.PRICEMOVETYPE_QUALITY).ToString() && p.PriceMoveID == tradeWR.QualityID);
  2277. if (quality != null)
  2278. {
  2279. tradeWR.PriceMove += quality.PriceMoveValue;
  2280. }
  2281. var speci = goodsDryLst.FirstOrDefault(p => p.PriceMoveType == ((uint)ePriceMoveType.PRICEMOVETYPE_SPECIFICATION).ToString() && p.PriceMoveID == tradeWR.SpecID);
  2282. if (speci != null)
  2283. {
  2284. tradeWR.PriceMove += speci.PriceMoveValue;
  2285. }
  2286. var warehouse = goodsDryLst.FirstOrDefault(p => p.PriceMoveType == ((uint)ePriceMoveType.PRICEMOVETYPE_WAREHOUSE).ToString() && p.PriceMoveID == tradeWR.WarehouseID);
  2287. if (warehouse != null)
  2288. {
  2289. tradeWR.PriceMove += warehouse.PriceMoveValue;
  2290. }
  2291. }
  2292. WrPairDetailsListEx = tradeWRPositionLst;
  2293. CachedPairDetailsList = tradeWRPositionLst;
  2294. IsBusy = false;
  2295. }
  2296. private void QueryErrorCallbackNew(ErrorEntity error)
  2297. {
  2298. IsBusy = false;
  2299. }
  2300. /// <summary>
  2301. /// 检测卖方向是否可用
  2302. /// </summary>
  2303. private void CheckIsSellEnable()
  2304. {
  2305. IsEnable_Direction = false;
  2306. //if (CurrentGoods != null)
  2307. //{
  2308. // var currentGoodsTradeMode = CurrentGoods.TradeMode;
  2309. // var tempAvailHoldQty = LoadingHolder(CurrentGoods.RelationGoodsId, Direction.Ask);
  2310. // //无卖持仓时,卖方向不可选置灰,仅竞价与混合-保证金商品-才可以发起卖交割
  2311. // if (tempAvailHoldQty > decimal.Zero && CurrentGoods != null && CurrentGoods.Sponsor == eSponsorType.Both && CurrentMoneyMode == eMoneyMode.MONEYMODE_MARGIN && (currentGoodsTradeMode == eTradeMode.TRADEMODE_BIDDING || currentGoodsTradeMode == eTradeMode.TRADEMODE_BIDDINGMARKETMAKE))
  2312. // {
  2313. // IsEnable_Direction = true;
  2314. // }
  2315. //}
  2316. }
  2317. /// <summary>
  2318. /// 加载最大最小交割数量
  2319. /// </summary>
  2320. private void MinMaxDeliveryLot()
  2321. {
  2322. if (CurrentGoods != null)
  2323. {
  2324. var maxQty = _goodsService.GetGoodsParamerRule((int)CurrentGoods.GoodsId,
  2325. CurrentGoods.TradeMode, GoodsTradeConts.MaxDeliveryQty);
  2326. var minQty = _goodsService.GetGoodsParamerRule((int)CurrentGoods.GoodsId,
  2327. CurrentGoods.TradeMode, GoodsTradeConts.MinDeliveryQty);
  2328. MinDeliveryUnit = minQty == null ? defaut_minLot : minQty.FeeValue;
  2329. MaxDeliveryUnit = maxQty == null ? defaut_maxLot : maxQty.FeeValue;
  2330. MaxDeliveryUnit = Math.Min((AvailHoldQty - AvailHoldQty % MinDeliveryUnit), MaxDeliveryUnit);
  2331. #region #33584 最小交收数量(手数),最大交收数量(手数)改从申报商品的交易规则中取
  2332. //MinDeliveryUnit = CurrentGoods.minDeliveryQty;
  2333. ////最小交割手数转换为交易手数
  2334. //MinDeliveryUnit = Math.Round(MinDeliveryUnit * CurrentGoods.Conversion, 2, MidpointRounding.AwayFromZero);
  2335. //MaxDeliveryUnit = CurrentGoods.maxDeliveryQty;
  2336. ////最大交割手数转换为交易手数
  2337. //var tempMaxDeliveryUnit = Math.Round(MaxDeliveryUnit * CurrentGoods.Conversion, 2, MidpointRounding.AwayFromZero);
  2338. //MaxDeliveryUnit = tempMaxDeliveryUnit - tempMaxDeliveryUnit % MinDeliveryUnit;
  2339. //MaxDeliveryUnit = Math.Min((AvailHoldQty - AvailHoldQty % MinDeliveryUnit), MaxDeliveryUnit);
  2340. #endregion
  2341. DeliveryCount = (MinDeliveryUnit == decimal.Zero ? 1 : MinDeliveryUnit);//默认设置下单数量
  2342. }
  2343. else
  2344. {
  2345. MinDeliveryUnit = defaut_minLot;
  2346. MaxDeliveryUnit = defaut_maxLot;
  2347. }
  2348. }
  2349. /// <summary>
  2350. /// 申报数量转交割数量
  2351. /// 交割数量 = 申报商品的申报手数 * 申报商品合约单位 * 兑换系数;
  2352. /// </summary>
  2353. private void DeclareToDeliveryLot()
  2354. {
  2355. if (CurrentGoods != null)
  2356. {
  2357. DeliveryNum = (int)(DeliveryCount / CurrentGoods.PDeliveryRatio1) * CurrentGoods.MinDeliveryQty;//CurrentGoods.currentAgreeunit * CurrentGoods.Conversion;
  2358. }
  2359. }
  2360. /// <summary>
  2361. /// 主商品申报手数-转-数量
  2362. /// </summary>
  2363. private void MainGoodsToLot()
  2364. {
  2365. if (CurrentGoods != null)
  2366. {
  2367. GoodsNum = DeliveryCount* CurrentGoods.AgreeUnit;
  2368. }
  2369. }
  2370. /// <summary>
  2371. /// 关联商品申报手数-转-数量
  2372. /// </summary>
  2373. private void RelationGoodsToLot()
  2374. {
  2375. //if (CurrentGoods != null && (eDeliveryContractLink)CurrentGoods.RelationMode == eDeliveryContractLink.PAndX)
  2376. //{
  2377. // var RelationGoodsItem = FindRelationGoodsInfoByID(CurrentGoods.RelationGoodsId);
  2378. // //关联商品转换显示数量
  2379. // RelationNum = RelationDeliveryCount * RelationGoodsItem.AgreeUnit;
  2380. //}
  2381. }
  2382. /// <summary>
  2383. /// 主商品-关联商品-配比转换
  2384. /// </summary>
  2385. private void MainGoodsToRelationGoodsLot(decimal deliveryCount)
  2386. {
  2387. if (CurrentGoods != null)
  2388. {
  2389. RelationDeliveryCount = ((int)(deliveryCount / CurrentGoods.PDeliveryRatio1) * CurrentGoods.XDeliveryRatio);//deliveryCount * (CurrentGoods.goodsscale == 0 ? 1 : CurrentGoods.goodsscale);//商品配比,默认为1
  2390. }
  2391. }
  2392. /// <summary>
  2393. /// 设置可交收数量
  2394. /// </summary>
  2395. private void SetDeliveryCount()
  2396. {
  2397. ResetData();
  2398. if (CurrentGoods != null)
  2399. {
  2400. _deliveryService.QueryDeliveryWhRecieptInfo(AccountID, CurrentGoods.GoodsId, QueryWhRecieptSuccess, DeliveryGoodsCallBack);
  2401. MinMultiple = CurrentGoods.MinDeliveryQty;//默认值
  2402. _currentMoneyMode = eMoneyMode.MONEYMODE_MARGIN;//CurrentGoods.currentMoneymode;
  2403. _currentDirection = Direction.Bid;//CurrentBuyOrSell.BuyOrSell;
  2404. ChangeDirectionTitle();
  2405. AvailHoldQty = LoadingHolder(CurrentGoods.GoodsId, _currentDirection);
  2406. AvailHoldQtyUnit = AvailHoldQty * CurrentGoods.AgreeUnit;
  2407. DeliveryPrice = GetDeliveryPriceCalcMethod(CurrentGoods.GoodsId, GoodsOfCR.CurrentGoods);
  2408. SwichDeliveryGoodsInfo();
  2409. // DeclareToDeliveryLot();
  2410. //MainGoodsToLot();
  2411. //RelationGoodsToLot();
  2412. //MinMaxDeliveryLot();
  2413. CurrentGoodsUnitType = CurrentGoods.GoodsUnit;// CacheManager.TradeGoodsUnit.Where(x => x.UNITID == CurrentGoods.currentGoodsunit).Select(x => x.GOODSUNITNAME).FirstOrDefault();
  2414. DeliveryAgreeUnitType = CurrentGoods.DeliveryGoodsUnit;//CacheManager.TradeGoodsUnit.Where(x => x.UNITID == CurrentGoods.GoodsUnitId).Select(x => x.GOODSUNITNAME).FirstOrDefault();
  2415. //IsEnableButtonEvent();
  2416. switch (_currentRelationMode)
  2417. {
  2418. case eDeliveryContractLink.None:
  2419. RelationMode_N_HandleEvent(_currentMoneyMode);
  2420. break;
  2421. case eDeliveryContractLink.Normal:
  2422. RelationMode_P_HandleEvent(_currentMoneyMode);
  2423. break;
  2424. case eDeliveryContractLink.PAndX:
  2425. RelationMode_PAndX_HandleEvent(_currentMoneyMode);
  2426. break;
  2427. default:
  2428. break;
  2429. }
  2430. }
  2431. }
  2432. /// <summary>
  2433. /// 买卖名称改变
  2434. /// </summary>
  2435. private void ChangeDirectionTitle()
  2436. {
  2437. if (_currentDirection == Direction.Bid)
  2438. {
  2439. DirectionTitle = Resources.Client_Resource.Domain_BuyIn;
  2440. }
  2441. else
  2442. {
  2443. DirectionTitle = Resources.Client_Resource.Domain_SellOut;
  2444. }
  2445. }
  2446. /// <summary>
  2447. /// 交割算法取值//持仓均价
  2448. /// </summary>
  2449. private decimal GetDeliveryPriceCalcMethod(long goodsID, GoodsOfCR type)
  2450. {
  2451. HoldDetails = null;
  2452. var CurrentAgreeunit = CurrentGoods.AgreeUnit;
  2453. if (type == GoodsOfCR.RelationGoods)
  2454. {
  2455. CurrentAgreeunit = CacheManager.CacheGoodsBaseInfos.Where(x=>x.GoodsId==goodsID).Select(x=>x.AgreeUnit).FirstOrDefault();
  2456. }
  2457. //持仓价=持仓价均价
  2458. var TempDeliveryPrice = LoadingHolder(goodsID, _currentDirection);
  2459. switch (eReckonPriceCalcMethodType.HolderPriceMove)
  2460. {
  2461. case eReckonPriceCalcMethodType.LastPrice:
  2462. case eReckonPriceCalcMethodType.HolderPriceMove:
  2463. case eReckonPriceCalcMethodType.AgreedPrice:
  2464. case eReckonPriceCalcMethodType.ReckonPrice:
  2465. case eReckonPriceCalcMethodType.HolderPrice:
  2466. //持仓价
  2467. //if (HoldDetails != null && HoldDetails.Any())
  2468. //{
  2469. // if (HoldDetails.Sum((item) => item.Lot - item.LockQty) > 0)
  2470. // TempDeliveryPrice = HoldDetails.Sum((order) => order.HoldAmount - order.lockHolderAmount) / HoldDetails.Sum((item) => item.Lot - item.LockQty) / CurrentAgreeunit;
  2471. //}
  2472. TempDeliveryPrice = TempDeliveryPrice / CurrentAgreeunit;
  2473. break;
  2474. }
  2475. return TempDeliveryPrice;
  2476. }
  2477. /// <summary>
  2478. /// N 模式处理
  2479. /// </summary>
  2480. private void RelationMode_N_HandleEvent(eMoneyMode moneyMode)
  2481. {
  2482. IsVisibility_Only_N = Visibility.Visible;
  2483. IsVisibility_N = Visibility.Collapsed;
  2484. //MinDeliveryUnit = 1;
  2485. //MaxDeliveryUnit = AvailHoldQty;
  2486. if (_currentDirection == Direction.Bid)//买方向
  2487. {
  2488. if (moneyMode == eMoneyMode.MONEYMODE_MARGIN)//保证金
  2489. {
  2490. }
  2491. else
  2492. {
  2493. }
  2494. }
  2495. }
  2496. /// <summary>
  2497. /// P 模式处理
  2498. /// </summary>
  2499. private void RelationMode_P_HandleEvent(eMoneyMode moneyMode)
  2500. {
  2501. IsVisibility_Only_N = Visibility.Collapsed;
  2502. IsVisibility_P = Visibility.Collapsed;
  2503. if (_currentDirection == Direction.Bid)//买方向
  2504. {
  2505. if (moneyMode == eMoneyMode.MONEYMODE_MARGIN)//保证金
  2506. {
  2507. }
  2508. else
  2509. {
  2510. }
  2511. }
  2512. }
  2513. /// <summary>
  2514. /// P+X 模式处理
  2515. /// </summary>
  2516. private void RelationMode_PAndX_HandleEvent(eMoneyMode moneyMode)
  2517. {
  2518. IsVisibility_Only_N = Visibility.Collapsed;
  2519. IsVisibility_PAndX = Visibility.Visible;
  2520. LoadingRelationGoodsInfo();
  2521. if (_currentDirection == Direction.Bid)//买方向
  2522. {
  2523. //var tempAvailHoldQty = Math.Min(RelationGoodsHoldQty, AvailHoldQty);
  2524. //MaxDeliveryUnit = Math.Min((tempAvailHoldQty - tempAvailHoldQty % MinDeliveryUnit), MaxDeliveryUnit);
  2525. if (moneyMode == eMoneyMode.MONEYMODE_MARGIN)//保证金
  2526. {
  2527. }
  2528. else
  2529. {
  2530. }
  2531. }
  2532. else
  2533. {
  2534. }
  2535. }
  2536. /// <summary>
  2537. /// 重置数据初始值
  2538. /// </summary>
  2539. private void ResetData()
  2540. {
  2541. _currentRelationMode = eDeliveryContractLink.None;
  2542. _currentMoneyMode = eMoneyMode.MONEYMODE_MARGIN;
  2543. IsVisibility_N = Visibility.Visible;
  2544. IsVisibility_PAndX = Visibility.Visible;
  2545. AvailHoldQty = decimal.Zero;
  2546. DeliveryPrice = decimal.Zero;
  2547. RelationGoodsHoldQty = decimal.Zero;
  2548. RelationGoodsHoldPrice = decimal.Zero;
  2549. DeliveryCount = 0;
  2550. RelationDeliveryCount = 0;
  2551. DeliveryNum = 0;
  2552. MinMultiple = 0;
  2553. }
  2554. /// <summary>
  2555. /// 查询-交割规则-成功返回
  2556. /// </summary>
  2557. /// <param name="orders"></param>
  2558. protected void QueryWhRecieptSuccess(List<DeliveryWhRecieptInfo> itemList)
  2559. {
  2560. if (WrPairDetailsList != null)
  2561. {
  2562. WrPairDetailsList = new List<DeliveryWhRecieptInfo>();
  2563. }
  2564. if (itemList.Any() && itemList.Count > 0)
  2565. {
  2566. WrPairDetailsList = itemList;
  2567. }
  2568. IsBusyWR = false;
  2569. }
  2570. /// <summary>
  2571. /// 查询-交割规则 MTP2.0
  2572. /// </summary>
  2573. /// <param name="itemList"></param>
  2574. protected void QueryRelationList()
  2575. {
  2576. #region 初始化交割商品
  2577. List<QuoteGoods> tempGoods = new List<QuoteGoods>();
  2578. if (CacheManager.CacheGoodsPositionList != null || CacheManager.CacheRealGoodsPositionList!=null)
  2579. {
  2580. //持仓头寸-商品ID LIST
  2581. var AdvanceGoodsIDList = CacheManager.CacheGoodsPositionList.Select((item) => item.GoodsId).Distinct().ToList();
  2582. var FullPayGoodsIDList = CacheManager.CacheRealGoodsPositionList.Select((item) => item.GoodsId).Distinct().ToList();
  2583. List<uint> AllDeliveryGoodsIDList = AdvanceGoodsIDList.Concat(FullPayGoodsIDList).ToList<uint>();
  2584. foreach (var id in AllDeliveryGoodsIDList)
  2585. {
  2586. //过滤可以交割的商品ID
  2587. foreach (var item in CacheManager.CacheGoodsBaseInfos.Where(x=>x.DeliveryFlag==1))
  2588. {
  2589. if (id == item.GoodsId && !tempGoods.Exists(x => x.GoodsId == item.GoodsId))
  2590. {
  2591. tempGoods.Add(item);
  2592. }
  2593. }
  2594. }
  2595. }
  2596. DeliveryGoodsList = tempGoods;
  2597. LoadingDeliveryGoods();
  2598. //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  2599. //{
  2600. // //GetDepositPersonalInfo();
  2601. //}));
  2602. #endregion
  2603. }
  2604. /// <summary>
  2605. /// 判断商品是否在可交割期内
  2606. /// </summary>
  2607. /// <returns></returns>
  2608. private bool IsGoodsBetweenDate(GoodsDeliveryRelationModel item)
  2609. {
  2610. bool flag = false;
  2611. #region 交割开始日期
  2612. if (item.MinDateDeliveryDate == DateTime.MinValue)
  2613. {
  2614. flag = true;
  2615. }
  2616. else if (item.MinDateDeliveryDate != DateTime.MinValue && ApplicationParameter.ServerTimeNow >= item.MinDateDeliveryDate)
  2617. {
  2618. flag = true;
  2619. }
  2620. else
  2621. {
  2622. flag = false;
  2623. }
  2624. #endregion
  2625. #region 交割结束日期
  2626. if (item.MaxDateDeliveryDate == DateTime.MinValue)
  2627. {
  2628. flag = true;
  2629. }
  2630. else if (item.MaxDateDeliveryDate != DateTime.MinValue && ApplicationParameter.ServerTimeNow <= item.MaxDateDeliveryDate)
  2631. {
  2632. flag = true;
  2633. }
  2634. else
  2635. {
  2636. flag = false;
  2637. }
  2638. #endregion
  2639. return flag;
  2640. }
  2641. /// <summary>
  2642. /// 交割商品关系配置失败返回
  2643. /// </summary>
  2644. /// <param name="errorEntity"></param>
  2645. private void DeliveryGoodsCallBack(ErrorEntity errorEntity)
  2646. {
  2647. IsBusyWR = false;
  2648. }
  2649. /// <summary>
  2650. /// 获取交割提货个人信息
  2651. /// </summary>
  2652. private void GetDepositPersonalInfo()
  2653. {
  2654. if (CurrentGoods != null)
  2655. {
  2656. var accountid = UserManager.CurrentTradeAccount.AccountId;
  2657. //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
  2658. //{
  2659. // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
  2660. //}
  2661. var ReqModel = new DepositPersonalInfoReqModel();
  2662. ReqModel.accountId = (long)accountid;
  2663. IsBusy = true;
  2664. //交割提货个人信息查询
  2665. //_deliveryService.SearchDepositPersonalInfoReq(ReqModel, QueryDepositPersonalInfoSuccess, QueryDepositPersonalInfoCallBack);
  2666. }
  2667. }
  2668. /// <summary>
  2669. /// 交割提货个人信息-成功返回
  2670. /// </summary>
  2671. /// <param name="orders"></param>
  2672. protected void QueryDepositPersonalInfoSuccess(DepositPersonalInfoRspModel itemModel)
  2673. {
  2674. if (itemModel != null)
  2675. {
  2676. CurrentDepositPersonalInfo = itemModel;
  2677. if (CurrentDepositPersonalInfo != null)
  2678. {
  2679. RecieveAddress = CurrentDepositPersonalInfo.address;
  2680. RecievePerson = CurrentDepositPersonalInfo.personName;
  2681. PhoneNum = CurrentDepositPersonalInfo.telphone;
  2682. IdCardNum = CurrentDepositPersonalInfo.IdCardNum;
  2683. }
  2684. }
  2685. IsBusy = false;
  2686. }
  2687. /// <summary>
  2688. /// 获取交割提货个人信息失败返回
  2689. /// </summary>
  2690. /// <param name="errorEntity"></param>
  2691. private void QueryDepositPersonalInfoCallBack(ErrorEntity errorEntity)
  2692. {
  2693. IsBusy = false;
  2694. }
  2695. /// <summary>
  2696. /// 【首次运行】加载交易商品
  2697. /// </summary>
  2698. private void LoadingDeliveryGoods()
  2699. {
  2700. if (DeliveryGoodsList != null && DeliveryGoodsList.Any() && DeliveryGoodsList.Count() > 0)
  2701. {
  2702. CurrentGoods = DeliveryGoodsList.FirstOrDefault();
  2703. //MinMultiple = CurrentGoods.LimitSum;//默认值
  2704. //DeliveryCount = CurrentGoods.PlimitConversion;//默认值
  2705. _currentMoneyMode = eMoneyMode.MONEYMODE_MARGIN;//暂时固定为保证金//CurrentGoods.currentMoneymode;
  2706. DeliveryGoodsNameList.Clear();
  2707. DeliveryGoodsNameList.Add(DeliveryGoodsList.FirstOrDefault().DeliveryGoodsNameCode);
  2708. CurrentDeliveryGoodsName = DeliveryGoodsNameList.FirstOrDefault();
  2709. if (_parameterInfo != null && _parameterInfo.GoodsId > 0)
  2710. {
  2711. CurrentGoods = DeliveryGoodsList.FirstOrDefault(x => x.GoodsId == _parameterInfo.GoodsId);
  2712. DeliveryGoodsNameList.Clear();
  2713. DeliveryGoodsNameList.Add(DeliveryGoodsList.FirstOrDefault(x => x.GoodsId == _parameterInfo.GoodsId).DeliveryGoodsNameCode);
  2714. CurrentDeliveryGoodsName = DeliveryGoodsNameList.FirstOrDefault();
  2715. }
  2716. }
  2717. }
  2718. /// <summary>
  2719. /// 加载持仓//可用持仓数量
  2720. /// </summary>
  2721. private decimal LoadingHolder(long goodsID,Direction buyOrSell)
  2722. {
  2723. var TempAvailHoldQty = decimal.Zero;
  2724. var holders = CacheManager.CacheGoodsPositionList;//UserManager.GetCacheOrders<HoldingOrder>();
  2725. if (holders != null && holders.Any())
  2726. {
  2727. #region MTP2.0 变动
  2728. //HoldDetails = holders.Where((item) => item.GoodsId == goodsID && item.Direction == buyOrSell).ToList();//买卖方向持仓
  2729. //if (HoldDetails != null && HoldDetails.Any())
  2730. //{
  2731. // var TempPositionFzQty = HoldDetails.FirstOrDefault().PositionFzQty;
  2732. // var TempTotalHoldDetails = HoldDetails.Sum((order) => order.Lot - order.LockQty);
  2733. // TempAvailHoldQty = TempTotalHoldDetails - TempPositionFzQty;
  2734. //}
  2735. #endregion
  2736. var TempInstan = holders.Where(x => x.GoodsId == goodsID).ToList().FirstOrDefault();
  2737. if (TempInstan != null)
  2738. {
  2739. if (buyOrSell == Direction.Bid)
  2740. {
  2741. TempAvailHoldQty = (decimal)(TempInstan.BuyCurPositionQty - TempInstan.BuyFrozenQty - TempInstan.BuyOtherFrozenQty);
  2742. }
  2743. else
  2744. {
  2745. TempAvailHoldQty = (decimal)(TempInstan.SellCurPositionQty - TempInstan.SellFrozenQty - TempInstan.SellOtherFrozenQty);
  2746. }
  2747. }
  2748. }
  2749. return TempAvailHoldQty;
  2750. }
  2751. /// <summary>
  2752. /// 加载关联交易商品信息
  2753. /// </summary>
  2754. private void LoadingRelationGoodsInfo()
  2755. {
  2756. //RelationGoodsHoldQty = LoadingHolder(CurrentGoods.RelationGoodsId, _currentDirection);
  2757. //RelationGoodsHoldPrice = GetDeliveryPriceCalcMethod(CurrentGoods.RelationGoodsId, GoodsOfCR.RelationGoods);
  2758. //var RelationGoodsItem =FindRelationGoodsInfoByID(CurrentGoods.RelationGoodsId);
  2759. //RelationGoodsUnitType = RelationGoodsItem.GoodsUnit;//CacheManager.TradeGoodsUnit.Where(x => x.UNITID == RelationGoodsItem.RelationGoodsunit).Select(x => x.GOODSUNITNAME).FirstOrDefault();
  2760. //var RelationGoodsName = RelationGoodsItem.DeliveryGoodsNameCode;
  2761. //RelationGoodsHoldQtyUnit = RelationGoodsHoldQty * RelationGoodsItem.AgreeUnit;
  2762. //RelationGoodsNameList.Clear();
  2763. //RelationGoodsNameList.Add(RelationGoodsName);
  2764. //CurrentRelationGoodsName = RelationGoodsNameList.FirstOrDefault();
  2765. //IsEnableButtonEvent();
  2766. //DeliveryCountEvent();
  2767. }
  2768. /// <summary>
  2769. /// 查找关联商品信息BY商品ID
  2770. /// </summary>
  2771. private QuoteGoods FindRelationGoodsInfoByID(long RelationGoodsId)
  2772. {
  2773. if (CacheManager.CacheGoodsBaseInfos!= null)
  2774. {
  2775. return CacheManager.CacheGoodsBaseInfos.Find(x => x.GoodsId == RelationGoodsId);
  2776. }
  2777. return null;
  2778. }
  2779. /// <summary>
  2780. /// 切换交割商品信息
  2781. /// </summary>
  2782. private void SwichDeliveryGoodsInfo()
  2783. {
  2784. DeliveryGoodsNameList.Clear();
  2785. DeliveryGoodsNameList.Add(CurrentGoods.DeliveryGoodsNameCode);
  2786. CurrentDeliveryGoodsName = DeliveryGoodsNameList.FirstOrDefault();
  2787. }
  2788. #endregion "Private Methods"
  2789. #region "=========其它方法/Other Methods"
  2790. /// <summary>
  2791. /// 数据验证
  2792. /// </summary>
  2793. /// <param name="msg"></param>
  2794. /// <returns></returns>
  2795. public bool Validated(ref string msg)
  2796. {
  2797. //申报数量 > 最大可申报数量
  2798. if (DeliveryCount > MaxDeliveryUnit)
  2799. {
  2800. msg = string.Format(Muchinfo.MTPClient.Resources.Client_Resource.EntrustOrderViewModel_OpenLotGreatThanMaxLot, MaxDeliveryUnit);
  2801. return false;
  2802. }
  2803. //申报数量应为最小交割数量的整数倍
  2804. if (MinDeliveryUnit != 0 && DeliveryCount % MinDeliveryUnit != 0 && CurrentRelationMode != eDeliveryContractLink.None)
  2805. {
  2806. msg = string.Format(Muchinfo.MTPClient.Resources.Client_Resource.DeliveryCountShoutBeMinUnitDouble, MinDeliveryUnit); ;
  2807. return false;
  2808. }
  2809. if (DeliveryCount <= 0 || DeliveryCount == decimal.Zero)
  2810. {
  2811. //数量不在正确范围内
  2812. msg = string.Format(Muchinfo.MTPClient.Resources.Client_Resource.Delivery_ChooseCorrectDeclareNum, MaxDeliveryUnit); ;
  2813. return false;
  2814. }
  2815. #region MTP2.0 注销
  2816. //if (RecievePerson.Trim() == "" )
  2817. //{
  2818. // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_RecievePerson + Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_NeedToWrite;
  2819. // return false;
  2820. //}
  2821. //if (RecieveAddress.Trim() == "" && TakeGoodsWay == TakeGoodsWay.Express)
  2822. //{
  2823. // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_RecieveAddress + Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_NeedToWrite;
  2824. // return false;
  2825. //}
  2826. //if (PhoneNum.Trim() == "" )
  2827. //{
  2828. // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_PhoneNum + Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_NeedToWrite;
  2829. // return false;
  2830. //}
  2831. //if (PhoneNum.Trim() != "" && (!PhoneNum.StartsWith("1") || PhoneNum.Length != 11 || !ValidationHelper.IsMobile(PhoneNum)))
  2832. //{
  2833. // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_PhoneNumErrFormat;
  2834. // return false;
  2835. //}
  2836. //if (string.IsNullOrWhiteSpace(IdCardNum) || !ValidationHelper.IsIDcard(IdCardNum))
  2837. //{
  2838. // msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_IDCardNumErrFormat;
  2839. // return false;
  2840. //}
  2841. #endregion
  2842. return true;
  2843. }
  2844. #endregion "Other Methods"
  2845. }
  2846. public enum GoodsOfCR
  2847. {
  2848. /// <summary>
  2849. /// 当前商品
  2850. /// </summary>
  2851. CurrentGoods = 1,
  2852. /// <summary>
  2853. /// 关联商品
  2854. /// </summary>
  2855. RelationGoods = 2,
  2856. }
  2857. }