RANetwork.m 172 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555
  1. //
  2. // iSalesNetwork.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 14-6-20.
  6. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "RANetwork.h"
  9. #import "RAUtils.h"
  10. #import "OLDataProvider.h"
  11. #import "Singleton.h"
  12. #import "GoogleAnalyst.h"
  13. #import "ERPUtils.h"
  14. #import "RAConvertor.h"
  15. NSString *const kScreenName = @"kScreenName";
  16. NSString *const kAction = @"kAction";
  17. NSString *const kExtra = @"kExtra";
  18. NSString *const ScreenCodeLoginView = @"Login Screen";
  19. NSString *const ScreenCodeHomeView = @"Home Screen";
  20. NSString *const ScreenCodeCategory = @"Category Screen";
  21. NSString *const ScreenCodeCart = @"Cart Sceen";
  22. NSString *const ScreenCodeOrderList = @"Order History Screen";
  23. NSString *const ScreenCodeSearch = @"Search Screen";
  24. NSString *const ScreenCodeAccount = @"Account Screen";
  25. NSString *const ScreenCodeWishList = @"Wish List Screen";
  26. NSString *const ScreenCodePortfolio = @"Portfolio Screen";
  27. NSString *const ScreenCodeViewPortfolios = @"View Portfolios Screen";
  28. NSString *const ScreenCodeCamScan = @"Cam Scan Screen";
  29. NSString *const ScreenCodeScannerSetting = @"Scanner Setting Screen";
  30. NSString *const ScreenCodeOfflineSetting = @"Offline Setting Screen";
  31. NSString *const ScreenCodePlaceOrder = @"Place Order Screen";
  32. NSString *const ScreenCodeCustomerInfo = @"Customer Information Screen";
  33. NSString *const ScreenCodeNewCustomer = @"New Customer Screen";
  34. NSString *const ScreenCodeEditCustomer = @"Edit Customer Information Screen";
  35. NSString *const ScreenCodeModelInfo = @"Model Information Screen";
  36. NSString *const ScreenCodeOrderInfo = @"Order Information Screeen";
  37. NSString *const ScreenCodeUserSign = @"User Sign Screen";
  38. NSString *const ScreenCodeNewAddress = @"New Address Screen";
  39. NSString *const ScreenCodeAdvanceSearch = @"Account Advance Search Screen";
  40. NSString *const ScreenCodeCreatePortfolio = @"Create Portfolio Screen";
  41. NSString *const ScreenCodeParticularCategory = @"Particular Category Screen";
  42. NSString *const ScreenCodeEditPortfolio = @"Edit Portfolio Screen";
  43. NSString *const ScreenCodePriceSetting = @"Price Setting Screen";
  44. NSString *const ScreenCodeCategoryPrice = @"Category Price Screen";
  45. NSString *const ScreenCodeSetCatetoryPrice = @"Set Category Price Screen";
  46. NSString *const ScreenCodeUploadImage = @"Upload Image Screen";
  47. NSString *const ScreenCodeOfflineSync = @"Offline Sync Screen";
  48. @implementation RANetwork
  49. +(NSMutableDictionary*) prepare_addtional_params:(NSMutableDictionary* ) params
  50. {
  51. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  52. // if(appDelegate.user!=nil)
  53. // [params setValue:[AESCrypt AES128Encrypt:appDelegate.user key:@"usai"] forKey:@"user"];
  54. // if(appDelegate.password!=nil)
  55. // [params setValue:[AESCrypt AES128Encrypt:appDelegate.password key:@"usai"] forKey:@"password"];
  56. //
  57. //
  58. //
  59. // if(appDelegate.user!=nil)
  60. // [params setValue:appDelegate.user forKey:@"user"];
  61. //
  62. // if(appDelegate.contact_id!=nil)
  63. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  64. // if(appDelegate.password!=nil)
  65. // [params setValue:appDelegate.password forKey:@"password"];
  66. //
  67. // [params setValue:appDelegate.build forKey:@"app_ver"];
  68. //
  69. // NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
  70. // NSString* short_version =[infoDict objectForKey:@"CFBundleShortVersionString"];
  71. // [params setValue:short_version forKey:@"app_short_ver"];
  72. //
  73. //
  74. //
  75. //#if TARGET_IPHONE_SIMULATOR//模拟器
  76. // [params setValue:@"simulator_uuid" forKey:@"deviceid"];
  77. //#elif TARGET_OS_IPHONE//真机
  78. // UIDevice * dev = [UIDevice currentDevice];
  79. // NSUUID* uuid =dev.identifierForVendor;
  80. // [params setValue:uuid.UUIDString forKey:@"deviceid"];
  81. //#endif
  82. if(appDelegate.user!=nil)
  83. [params setValue:appDelegate.user forKey:@"user"];
  84. if(appDelegate.password!=nil)
  85. [params setValue:appDelegate.password forKey:@"password"];
  86. if(appDelegate.ipad_perm!=nil)
  87. [params setValue:appDelegate.ipad_perm forKey:@"ipad_perm"];
  88. [params setValue:appDelegate.build forKey:@"app_ver"];
  89. NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
  90. NSString* short_version =[infoDict objectForKey:@"CFBundleShortVersionString"];
  91. [params setValue:short_version forKey:@"app_short_ver"];
  92. UIDevice * dev = [UIDevice currentDevice];
  93. NSUUID* uuid =dev.identifierForVendor;
  94. #if TARGET_IPHONE_SIMULATOR//模拟器
  95. [params setValue:@"simulator_uuid" forKey:@"idfv"];
  96. #elif TARGET_OS_IPHONE//真机
  97. [params setValue:uuid.UUIDString forKey:@"idfv"];
  98. #endif
  99. //
  100. // NSString *userAction = [params valueForKey:kAction];
  101. // NSMutableDictionary *extra = [[params valueForKey:kExtra] mutableCopy];
  102. // if ([userAction isEqualToString:@"Login"]) {
  103. // if (!extra) {
  104. // extra = [NSMutableDictionary dictionary];
  105. // }
  106. // [extra setObject:[params objectForKey:@"user"] forKey:@"user"];
  107. // }
  108. return params;
  109. }
  110. +(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params file:(NSString *) file //delegate:(id < NSURLConnectionDelegate >)delegate
  111. {
  112. // NSString* e=[AESCrypt AES128Encrypt:@"密码学中的高级加密标准(Advanced Encryption Standard,AES),又称 高级加密标准Rijndael加密法,是美国联邦政府采用的一种区块加密标准。这个标准用来替代原先的DES,已经被多方分析且广为全世界所使用。经过五年的甄选流程,高级加密标准由美国国家标准与技术研究院 (NIST)于2001年11月26日发布于FIPS PUB 197,并在2002年5月26日成为有效的标准。2006年,高级加密标准已然成为对称密钥加密中最流行的算法之一。 " key:@"usai2010"];
  113. // DebugLog(e);
  114. // NSString* d=[AESCrypt decrypt:@"VzB4+lENfbzWX7ggHh2Os1P69l5YBzKmM51yqA37AfoKgPY8bJgdK8M4WvF+wDyOsLWP\/o8H5+bHMivQp1u8wM2QV7SYzgzPwV85QKtYWIzEgLe9T0HO69EdutWz7k1rdAT\/mftsRin0Hy5SHk7txTZT\/zPH5X+FQiExCTFm5Zus39HYvp+VxCX4+kYeymn8B63AUd3mRQyscUvDjfgU2olKR\/TP8PV3g+VQMZxpKfol3P1iOtz3XQlHZV0pM6SAf+SwT0sPfrdn6CZFfNQlrKA9QjMrnBdMeSCquSIWXnmLv6okzvnlJnT0SjvJuUeqNdBC5EZ0ACnhI0MrXVZEsq1EuM9al7oPzvU5EZbjZpmx+fSFIkMzTT8bYClTnG1bsL1MCcU4pSODDorUj8zalA==" password:@"usai2010"];
  115. params = [self prepare_addtional_params:params];
  116. DebugLog(@"\n++++++++++++++++++++++Request++++++++++++++++++++++\n%@\n++++++++++++++++++++++Params++++++++++++++++++++++\n%@\n",url,[RAConvertor dict2string:params]);
  117. return [super get_json:url parameters:params file:(NSString*)file err_recorder:URL_ERR_LOG result_handler:^NSMutableDictionary *(NSMutableDictionary *jsobj) {
  118. int result=[[jsobj valueForKey:@"result"] intValue];
  119. // UIApplication * app = [UIApplication sharedApplication];
  120. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  121. switch (result) {
  122. case 0:
  123. [jsobj setValue:MSG_USERAUTH_ERROR forKey:@"err_msg"];
  124. break;
  125. case 1:
  126. [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
  127. break;
  128. case 2:
  129. [jsobj setValue:MSG_SUCCESS forKey:@"err_msg"];
  130. break;
  131. case 8:
  132. [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
  133. break;
  134. case 9:
  135. [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
  136. break;
  137. case 99:
  138. [jsobj setValue:MSG_TIMEOUT forKey:@"err_msg"];
  139. break;
  140. default:
  141. [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
  142. break;
  143. }
  144. // if([appDelegate.build intValue]< [[jsobj valueForKey:@"min_ver"]intValue])
  145. // {
  146. // [jsobj setValue:@"9" forKey:@"result"];
  147. // [jsobj setValue:MSG_VER_LOW forKey:@"err_msg"];
  148. // }
  149. return jsobj;
  150. } decrypt_handler:^NSMutableDictionary *(NSMutableDictionary *jsobj) {
  151. return nil;
  152. // NSString* base64str = jsobj[@"str"];
  153. // NSString* decryptstr=[AESCrypt AES128Decrypt:base64str key:@"usai2010"];
  154. // jsobj=[[RAUtils string2dict:decryptstr] mutableCopy];
  155. // return jsobj;
  156. }];
  157. /*
  158. */
  159. return nil;
  160. }
  161. +(void) LoadImage:(NSString*) url into:(UIImageView*) container
  162. {
  163. DebugLog(@"LoadImage:(NSString*) url in:(UIImageView*) container");
  164. NSString* file_name=[url lastPathComponent];
  165. NSData* img_data = [iSalesDB load_cached_img:file_name loadFrom:url];
  166. if(img_data==nil)
  167. {
  168. DebugLog(@"IMG NOT CACHED %@",file_name);
  169. img_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
  170. [iSalesDB cache_img:img_data filename:file_name saveTo:url];
  171. //load from internet;
  172. }
  173. if(img_data!=nil)
  174. {
  175. UIImage * img =[UIImage imageWithData:img_data];
  176. if(img==nil)
  177. DebugLog(@"UIIMAGE IS NIL! %@",file_name);
  178. else
  179. container.image =img;
  180. }
  181. else
  182. {
  183. DebugLog(@"IMG DOWNLOAD FAILED! %@",file_name);
  184. }
  185. }
  186. //+(NSData*)fake_json:(NSString*) url
  187. //{
  188. // NSString* jsonfile = nil;
  189. // if([url isEqualToString:URL_UPDATE_AUTH])
  190. // {
  191. // jsonfile=@"login";
  192. //
  193. // }
  194. // else if([url isEqualToString:URL_REQUEST_CATMENU])
  195. // {
  196. // jsonfile=@"categorymenu";
  197. // }
  198. // else if([url isEqualToString:URL_LOAD_HOME])
  199. // {
  200. // jsonfile=@"homepage";
  201. // }
  202. // else if([url isEqualToString:URL_SEARCH])
  203. // {
  204. // jsonfile=@"search";
  205. // }
  206. // else if([url isEqualToString:URL_CATEGORY_LOADMORE])
  207. // {
  208. // jsonfile=@"category_more";
  209. // }else if([url isEqualToString:URL_ITEM_DETAIL])
  210. // {
  211. // jsonfile=@"detail";
  212. // }else if([url isEqualToString:URL_CART])
  213. // {
  214. // jsonfile=@"cart";
  215. // }else if([url isEqualToString:URL_ORDER_LIST])
  216. // {
  217. // jsonfile=@"orderlist";
  218. // }
  219. //// else if([url isEqualToString:URL_ORDER_INFO])
  220. //// {
  221. //// jsonfile=@"orderinfo";
  222. //// }
  223. //// else if([url isEqualToString:URL_ORDER_INFO])
  224. //// {
  225. //// jsonfile=@"orderinfo2label";
  226. //// }
  227. //
  228. //
  229. //
  230. // NSData* json =[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:jsonfile ofType:@"json" ]];
  231. // NSMutableString *result = [[NSMutableString alloc] initWithData:json encoding:NSUTF8StringEncoding];
  232. //
  233. // DebugLog(@"result: \n%@",result);
  234. // return json;
  235. //}
  236. +(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params //delegate:(id < NSURLConnectionDelegate >)delegate
  237. {
  238. NSString *screenName = [params valueForKey:kScreenName];
  239. NSString *userAction = [params valueForKey:kAction];
  240. NSMutableDictionary *extra = [[params valueForKey:kExtra] mutableCopy];
  241. if ([userAction isEqualToString:@"Login"]) {
  242. if (!extra) {
  243. extra = [NSMutableDictionary dictionary];
  244. }
  245. [extra setObject:[params objectForKey:@"user"] forKey:@"user"];
  246. }
  247. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  248. [ERPUtils googleAnalyticsSendRequestString:url WithScreen:screenName Action:userAction Extra:extra];
  249. #endif
  250. return [self get_json:url parameters:params file:nil];
  251. int retry = 0;
  252. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  253. if(appDelegate.user!=nil)
  254. [params setValue:appDelegate.user forKey:@"user"];
  255. if(appDelegate.password!=nil)
  256. [params setValue:appDelegate.password forKey:@"password"];
  257. if(appDelegate.ipad_perm!=nil)
  258. [params setValue:appDelegate.ipad_perm forKey:@"ipad_perm"];
  259. [params setValue:appDelegate.build forKey:@"app_ver"];
  260. NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
  261. NSString* short_version =[infoDict objectForKey:@"CFBundleShortVersionString"];
  262. [params setValue:short_version forKey:@"app_short_ver"];
  263. UIDevice * dev = [UIDevice currentDevice];
  264. NSUUID* uuid =dev.identifierForVendor;
  265. #if TARGET_IPHONE_SIMULATOR//模拟器
  266. [params setValue:@"simulator_uuid" forKey:@"idfv"];
  267. #elif TARGET_OS_IPHONE//真机
  268. [params setValue:uuid.UUIDString forKey:@"idfv"];
  269. #endif
  270. // NSString *screenName = [params valueForKey:kScreenName];
  271. // NSString *userAction = [params valueForKey:kAction];
  272. // NSMutableDictionary *extra = [[params valueForKey:kExtra] mutableCopy];
  273. // if ([userAction isEqualToString:@"Login"]) {
  274. // if (!extra) {
  275. // extra = [NSMutableDictionary dictionary];
  276. // }
  277. // [extra setObject:[params objectForKey:@"user"] forKey:@"user"];
  278. // }
  279. repeat:
  280. {
  281. // return [self fake_json:url];
  282. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  283. //分界线的标识符
  284. NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
  285. //根据url初始化request
  286. NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
  287. cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
  288. timeoutInterval:JSON_TIMEOUT];
  289. //分界线 --AaB03x
  290. NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
  291. //结束符 AaB03x--
  292. NSString *endMPboundary=[[NSString alloc]initWithFormat:@"%@--",MPboundary];
  293. //要上传的图片
  294. // UIImage *image=[params objectForKey:@"pic"];
  295. //得到图片的data
  296. // NSData* data = UIImagePNGRepresentation(image);
  297. //http body的字符串
  298. NSMutableString *body=[[NSMutableString alloc]init];
  299. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  300. // [params setValue:@"handset_login" forKey:@"action"];
  301. // [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
  302. // [params setValue:appDelegate.sessionid forKey:@"sessionid"];
  303. // [params setValue:password forKey:@"password"];
  304. // [params setValue:[NSString stringWithFormat:@"%d",ver] forKey:@"auth_ver"];
  305. // [headers setValue:headQuerlString forKey:@"param"];
  306. //参数的集合的所有key的集合
  307. NSArray *keys= [params allKeys];
  308. DebugLog(@"================parms==================");
  309. //遍历keys
  310. for(int i=0;i<[keys count];i++)
  311. {
  312. //得到当前key
  313. NSString *key=[keys objectAtIndex:i];
  314. //如果key不是pic,说明value是字符类型,比如name:Boris
  315. if(![key isEqualToString:@"pic"])
  316. {
  317. //添加分界线,换行
  318. [body appendFormat:@"%@\r\n",MPboundary];
  319. //添加字段名称,换2行
  320. [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
  321. //添加字段的值
  322. [body appendFormat:@"%@\r\n",[params objectForKey:key]];
  323. DebugLog(@"parameter: key=%@ value=%@",key,[params objectForKey:key]);
  324. }
  325. }
  326. DebugLog(@"================parms==================");
  327. ////添加分界线,换行
  328. [body appendFormat:@"%@\r\n",MPboundary];
  329. //声明pic字段,文件名为boris.png
  330. [body appendFormat:@"Content-Disposition: form-data; name=\"pic\"; filename=\"boris.png\"\r\n"];
  331. //声明上传文件的格式
  332. [body appendFormat:@"Content-Type: image/png\r\n\r\n"];
  333. //声明结束符:--AaB03x--
  334. NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPboundary];
  335. //声明myRequestData,用来放入http body
  336. NSMutableData *myRequestData=[NSMutableData data];
  337. //将body字符串转化为UTF8格式的二进制
  338. [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
  339. //将image的data加入
  340. // [myRequestData appendData:data];
  341. //加入结束符--AaB03x--
  342. [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
  343. //设置HTTPHeader中Content-Type的值
  344. NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",TWITTERFON_FORM_BOUNDARY];
  345. //设置HTTPHeader
  346. [request setValue:content forHTTPHeaderField:@"Content-Type"];
  347. // 关闭keep alive
  348. [request setValue:@"close" forHTTPHeaderField:@"Connection"];
  349. //设置Content-Length
  350. [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[myRequestData length]] forHTTPHeaderField:@"Content-Length"];
  351. //设置http body
  352. [request setHTTPBody:myRequestData];
  353. //http method
  354. [request setHTTPMethod:@"POST"];
  355. NSHTTPURLResponse* urlResponse = nil;
  356. NSError *error = nil;
  357. NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
  358. DebugLog(@"url: %@",url);
  359. DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
  360. if (responseData==nil) {
  361. // DebugLog(@"response error:%@", [error localizedDescription]);
  362. NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
  363. //#define RESULT_FALSE 0
  364. //#define RESULT_TRUE 2
  365. //#define RESULT_NET_ERROR -3
  366. //#define RESULT_NET_NOTAVAILABLE -4
  367. //#define RESULT_ERROR -5
  368. //#define RESULT_LOCALFILE_ERROR -7
  369. //#define RESULT_USERAUTH_ERROR -9
  370. //#define RESULT_UPDATE_USERAUTH_ERROR -11
  371. //#define RESULT_SESSION_EXPIRED -13
  372. //#define RESULT_VER_LOW
  373. // NSString * moreinfo = error.description ;
  374. NSString* err_msg = [error localizedDescription];
  375. //-----------------retry 3 times for error code -1005------------------------
  376. if(error.code==-1005&&retry<3)
  377. {
  378. retry++;
  379. goto repeat;
  380. }
  381. //-----------------end retry 3 times for error code -1005------------------------
  382. NSDictionary* error_json = [RAUtils error_dict:error];
  383. [ret setObject:error_json forKey:@"err_obj"];
  384. NSString* resp_msg= nil;
  385. if(err_msg.length==0)
  386. {
  387. err_msg =[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode];
  388. resp_msg = err_msg;
  389. }
  390. [ret setValue:[NSString stringWithFormat:@"%d",RESULT_NET_ERROR] forKey:@"result"];
  391. [ret setValue:err_msg forKey:@"err_msg"];
  392. [ret setValue:resp_msg forKey:@"resp_msg"];
  393. [ret setValue:[NSString stringWithFormat:@"%ld",(long)urlResponse.statusCode] forKey:@"resp_code"];
  394. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ret
  395. options:0
  396. error:nil];
  397. if(![url isEqualToString:URL_ERR_LOG])
  398. {
  399. [RANetwork err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:[RAConvertor dict2string:ret]] module:url code:RESULT_NET_ERROR];
  400. }
  401. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  402. [ERPUtils googleAnalyticsSendRequestString:url WithScreen:screenName Action:userAction Extra:extra];
  403. #endif
  404. return jsonData;
  405. }
  406. else
  407. {
  408. NSString* err_msg = [error localizedDescription];
  409. NSMutableString *str = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
  410. DebugLog(@"data string: %@",str);
  411. NSError *error1 = nil;
  412. NSMutableDictionary* jsobj = [[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error1] mutableCopy];
  413. if(jsobj==nil)// 服务器返回不是json
  414. {
  415. jsobj=[[NSMutableDictionary alloc] init];
  416. [jsobj setValue:@"1" forKey:@"result"];
  417. }
  418. int result=[[jsobj valueForKey:@"result"] intValue];
  419. UIApplication * app = [UIApplication sharedApplication];
  420. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  421. NSString* mode =[jsobj valueForKey:@"mode"];
  422. [appDelegate SetMode:mode];
  423. switch (result) {
  424. case 0:
  425. [jsobj setValue:MSG_USERAUTH_ERROR forKey:@"err_msg"];
  426. break;
  427. case 1:
  428. [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
  429. break;
  430. case 2:
  431. [jsobj setValue:MSG_SUCCESS forKey:@"err_msg"];
  432. break;
  433. case 8:
  434. [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
  435. break;
  436. case 9:
  437. [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
  438. break;
  439. case 99:
  440. [jsobj setValue:MSG_TIMEOUT forKey:@"err_msg"];
  441. break;
  442. default:
  443. [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
  444. break;
  445. }
  446. if([appDelegate.build intValue]< [[jsobj valueForKey:@"min_ver"]intValue])
  447. {
  448. [jsobj setValue:@"9" forKey:@"result"];
  449. [jsobj setValue:MSG_VER_LOW forKey:@"err_msg"];
  450. }
  451. if(![url isEqualToString:URL_ERR_LOG]&&![url isEqualToString:URL_DOWNLOAD_OFFLINE]/*&&result!=-3*/&&result!=2&&result!=99)
  452. {
  453. [RANetwork err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:str] module:url code:result];
  454. }
  455. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsobj
  456. options:0
  457. error:nil];
  458. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  459. [ERPUtils googleAnalyticsSendRequestString:url WithScreen:screenName Action:userAction Extra:extra];
  460. #endif
  461. return jsonData;
  462. }
  463. return responseData;
  464. }
  465. }
  466. +(NSString*)DataTOjsonString:(id)object
  467. {
  468. NSString *jsonString = nil;
  469. NSError *error;
  470. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object
  471. options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
  472. error:&error];
  473. if (! jsonData) {
  474. DebugLog(@"Got an error: %@", error);
  475. } else {
  476. jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  477. }
  478. return jsonString;
  479. }
  480. //+(NSDictionary*)request_Editor:(NSString*) sourceid editor:(NSString*)editor
  481. //{
  482. //
  483. //}
  484. +(NSDictionary*) delete_portfoliolist:(NSString* ) listid
  485. {
  486. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  487. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  488. if(appDelegate.user!=nil)
  489. [params setValue:appDelegate.user forKey:@"user"];
  490. if(appDelegate.contact_id!=nil)
  491. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  492. if(appDelegate.password!=nil)
  493. [params setValue:appDelegate.password forKey:@"password"];
  494. [params setValue:listid forKey:@"tearsheetsId"];
  495. // [params setValue:editor forKey:@"editor"];
  496. [params setValue:ScreenCodeViewPortfolios forKey:kScreenName];
  497. // [params setValue:@"Delete Portfolio" forKey:kAction];
  498. NSData* json = nil;
  499. if(appDelegate.offline_mode)
  500. {
  501. json = [OLDataProvider offline_removePDF:params];
  502. } else {
  503. if(![self IsNetworkAvailable])
  504. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  505. json=[self get_json:URL_PORTFOLIOLIST_REMOVE parameters:params];
  506. }
  507. if(json!=nil)
  508. {
  509. NSError *error=nil;
  510. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  511. return jsobj;
  512. }
  513. else
  514. return nil;
  515. }
  516. +(NSDictionary*) portfolio_remove:(NSString* ) item_ids
  517. {
  518. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  519. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  520. if(appDelegate.user!=nil)
  521. [params setValue:appDelegate.user forKey:@"user"];
  522. if(appDelegate.contact_id!=nil)
  523. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  524. if(appDelegate.password!=nil)
  525. [params setValue:appDelegate.password forKey:@"password"];
  526. [params setValue:item_ids forKey:@"portfolioId"];
  527. // [params setValue:editor forKey:@"editor"];
  528. [params setValue:ScreenCodePortfolio forKey:kScreenName];
  529. NSData* json = nil;
  530. if(appDelegate.offline_mode)
  531. {
  532. json = [OLDataProvider offline_removePortfolio:params];
  533. } else {
  534. if(![self IsNetworkAvailable])
  535. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  536. json=[self get_json:URL_PORTFOLIO_REMOVE parameters:params];
  537. }
  538. if(json!=nil)
  539. {
  540. NSError *error=nil;
  541. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  542. int result = [[jsobj valueForKey:@"result"] intValue];
  543. if (result==2)
  544. {
  545. appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  546. [appDelegate update_count_mark];
  547. }
  548. return jsobj;
  549. }
  550. else
  551. return nil;
  552. }
  553. +(NSDictionary*) watchlist_remove:(NSString* ) item_ids
  554. {
  555. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  556. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  557. if(appDelegate.user!=nil)
  558. [params setValue:appDelegate.user forKey:@"user"];
  559. if(appDelegate.contact_id!=nil)
  560. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  561. if(appDelegate.password!=nil)
  562. [params setValue:appDelegate.password forKey:@"password"];
  563. [params setValue:item_ids forKey:@"collectId"];
  564. // [params setValue:editor forKey:@"editor"];
  565. [params setValue:ScreenCodeWishList forKey:kScreenName];
  566. if(appDelegate.offline_mode)
  567. {
  568. return [OLDataProvider offline_deletewishlist:params];
  569. }
  570. if(![self IsNetworkAvailable])
  571. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  572. NSData* json=[self get_json:URL_WATCHLIST_REMOVE parameters:params];
  573. if(json!=nil)
  574. {
  575. NSError *error=nil;
  576. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  577. int result = [[jsobj valueForKey:@"result"] intValue];
  578. if (result==2)
  579. {
  580. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  581. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  582. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  583. [appDelegate update_count_mark];
  584. }
  585. return jsobj;
  586. }
  587. else
  588. return nil;
  589. }
  590. +(NSDictionary*) move_cart2wish:(NSString* ) item_ids
  591. {
  592. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  593. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  594. if(appDelegate.user!=nil)
  595. [params setValue:appDelegate.user forKey:@"user"];
  596. if(appDelegate.contact_id!=nil)
  597. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  598. if(appDelegate.password!=nil)
  599. [params setValue:appDelegate.password forKey:@"password"];
  600. if(appDelegate.order_code!=nil)
  601. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  602. [params setValue:item_ids forKey:@"cartItemId"];
  603. // [params setValue:editor forKey:@"editor"];
  604. [params setValue:ScreenCodeCart forKey:kScreenName];
  605. // [params setValue:@"Cart Move To Wish List" forKey:kAction];
  606. NSData* json = nil;
  607. if(appDelegate.offline_mode)
  608. {
  609. json= [OLDataProvider offline_movecart2wish:params];
  610. }
  611. else
  612. {
  613. if(![self IsNetworkAvailable])
  614. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  615. json=[self get_json:URL_CART2WISH parameters:params];
  616. }
  617. if(json!=nil)
  618. {
  619. NSError *error=nil;
  620. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  621. int result = [[jsobj valueForKey:@"result"] intValue];
  622. if (result==2)
  623. {
  624. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  625. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  626. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  627. [appDelegate update_count_mark];
  628. }
  629. return jsobj;
  630. }
  631. else
  632. return nil;
  633. }
  634. +(NSDictionary*) move_wish2cart:(NSString* ) item_ids
  635. {
  636. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  637. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  638. if(appDelegate.user!=nil)
  639. [params setValue:appDelegate.user forKey:@"user"];
  640. if(appDelegate.contact_id!=nil)
  641. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  642. if(appDelegate.password!=nil)
  643. [params setValue:appDelegate.password forKey:@"password"];
  644. if(appDelegate.order_code!=nil)
  645. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  646. [params setValue:item_ids forKey:@"collectId"];
  647. // [params setValue:editor forKey:@"editor"];
  648. [params setValue:ScreenCodeWishList forKey:kScreenName];
  649. [params setValue:@"Move To Cart" forKey:kAction];
  650. NSData *json = nil;
  651. if(appDelegate.offline_mode)
  652. {
  653. json = [OLDataProvider offline_movewish2cart:params];
  654. } else {
  655. if(![self IsNetworkAvailable])
  656. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  657. json=[self get_json:URL_WISH2CART parameters:params];
  658. }
  659. if(json!=nil)
  660. {
  661. NSError *error=nil;
  662. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  663. int result = [[jsobj valueForKey:@"result"] intValue];
  664. if (result==2)
  665. {
  666. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  667. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  668. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  669. [appDelegate update_count_mark];
  670. }
  671. return jsobj;
  672. }
  673. else
  674. return nil;
  675. }
  676. +(NSDictionary*) cart_remove:(NSString* ) item_ids
  677. {
  678. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  679. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  680. if(appDelegate.user!=nil)
  681. [params setValue:appDelegate.user forKey:@"user"];
  682. if(appDelegate.contact_id!=nil)
  683. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  684. if(appDelegate.password!=nil)
  685. [params setValue:appDelegate.password forKey:@"password"];
  686. if(appDelegate.order_code!=nil)
  687. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  688. [params setValue:item_ids forKey:@"cartItemId"];
  689. // [params setValue:editor forKey:@"editor"];
  690. [params setValue:ScreenCodeCart forKey:kScreenName];
  691. // [params setValue:@"" forKey:kAction];
  692. NSData* json=nil;
  693. if(appDelegate.offline_mode)
  694. {
  695. json= [OLDataProvider offline_cartremove:params];
  696. }
  697. else
  698. {
  699. if(![self IsNetworkAvailable])
  700. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  701. json=[self get_json:URL_CART_REMOVE parameters:params];
  702. }
  703. if(json!=nil)
  704. {
  705. NSError *error=nil;
  706. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  707. int result = [[jsobj valueForKey:@"result"] intValue];
  708. if (result==2)
  709. {
  710. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  711. [appDelegate update_count_mark];
  712. }
  713. return jsobj;
  714. }
  715. else
  716. return nil;
  717. }
  718. //+(NSDictionary*) cart_check:(NSString* ) item_ids
  719. //{
  720. // return nil;
  721. // if(![self IsNetworkAvailable])
  722. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  723. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  724. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  725. // if(appDelegate.user!=nil)
  726. // [params setValue:appDelegate.user forKey:@"user"];
  727. // if(appDelegate.contact_id!=nil)
  728. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  729. // if(appDelegate.password!=nil)
  730. // [params setValue:appDelegate.password forKey:@"password"];
  731. // [params setValue:item_ids forKey:@"cartItemId"];
  732. // // [params setValue:editor forKey:@"editor"];
  733. // if(appDelegate.offline_mode)
  734. // {
  735. // return [OLDataProvider offline_notimpl];
  736. // }
  737. // NSData* json=[self get_json:URL_CART_CHECK parameters:params];
  738. // if(json!=nil)
  739. // {
  740. // NSError *error=nil;
  741. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  742. // return jsobj;
  743. // }
  744. // else
  745. // return nil;
  746. //}
  747. +(NSDictionary*)create_Address:(NSMutableDictionary*)params
  748. {
  749. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  750. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  751. if(appDelegate.user!=nil)
  752. [params setValue:appDelegate.user forKey:@"user"];
  753. if(appDelegate.contact_id!=nil)
  754. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  755. if(appDelegate.password!=nil)
  756. [params setValue:appDelegate.password forKey:@"password"];
  757. // [params setValue:sourceid forKey:@"sourceid"];
  758. // [params setValue:editor forKey:@"editor"];
  759. [params setValue:ScreenCodeNewAddress forKey:kScreenName];
  760. NSData* json=nil;
  761. if(appDelegate.offline_mode)
  762. {
  763. json= [OLDataProvider offline_saveaddr:params];
  764. }
  765. else
  766. {
  767. if(![self IsNetworkAvailable])
  768. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  769. json =[self get_json:URL_ADDRESS_SAVE parameters:params];
  770. }
  771. if(json!=nil)
  772. {
  773. NSError *error=nil;
  774. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  775. return jsobj;
  776. }
  777. else
  778. return nil;
  779. }
  780. +(NSDictionary*)copy_Order:(NSString*) order_code
  781. {
  782. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  783. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  784. if(appDelegate.user!=nil)
  785. [params setValue:appDelegate.user forKey:@"user"];
  786. if(appDelegate.contact_id!=nil)
  787. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  788. if(appDelegate.password!=nil)
  789. [params setValue:appDelegate.password forKey:@"password"];
  790. // NSString* ssaved = @"false";
  791. // if(saved)
  792. // ssaved=@"true";
  793. // [params setValue:@"true" forKey:@"saved"];
  794. [params setValue:order_code forKey:@"code"];
  795. // [params setValue:sourceid forKey:@"sourceid"];
  796. // [params setValue:editor forKey:@"editor"];
  797. [params setValue:ScreenCodeOrderInfo forKey:kScreenName];
  798. NSData* json=nil;
  799. if(appDelegate.offline_mode)
  800. {
  801. json= [OLDataProvider offline_copyorder:params];
  802. }
  803. else
  804. {
  805. if(![self IsNetworkAvailable])
  806. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  807. json=[self get_json:URL_COPY_ORDER parameters:params];
  808. }
  809. if(json!=nil)
  810. {
  811. NSError *error=nil;
  812. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  813. return jsobj;
  814. }
  815. else
  816. return nil;
  817. }
  818. +(NSDictionary*)sign_Order:(NSString*) order_code path:(NSString*)path
  819. {
  820. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  821. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  822. if(appDelegate.user!=nil)
  823. [params setValue:appDelegate.user forKey:@"user"];
  824. if(appDelegate.contact_id!=nil)
  825. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  826. if(appDelegate.password!=nil)
  827. [params setValue:appDelegate.password forKey:@"password"];
  828. // NSString* ssaved = @"false";
  829. // if(saved)
  830. // ssaved=@"true";
  831. // [params setValue:@"true" forKey:@"saved"];
  832. [params setValue:order_code forKey:@"orderCode"];
  833. [params setValue:path forKey:@"picpath"];
  834. // [params setValue:sourceid forKey:@"sourceid"];
  835. // [params setValue:editor forKey:@"editor"];
  836. [params setValue:ScreenCodeUserSign forKey:kScreenName];
  837. NSData* json=nil;
  838. if(appDelegate.offline_mode)
  839. {
  840. json= [OLDataProvider offline_signorder:params];
  841. }
  842. else
  843. {
  844. if(![self IsNetworkAvailable])
  845. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  846. json=[self get_json:URL_SIGN_ORDER parameters:params];
  847. }
  848. if(json!=nil)
  849. {
  850. NSError *error=nil;
  851. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  852. return jsobj;
  853. }
  854. else
  855. return nil;
  856. }
  857. +(NSDictionary*)commit_Order:(NSString*) order_code //saved:(bool) saved
  858. {
  859. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  860. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  861. if(appDelegate.user!=nil)
  862. [params setValue:appDelegate.user forKey:@"user"];
  863. if(appDelegate.contact_id!=nil)
  864. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  865. if(appDelegate.password!=nil)
  866. [params setValue:appDelegate.password forKey:@"password"];
  867. // NSString* ssaved = @"false";
  868. // if(saved)
  869. // ssaved=@"true";
  870. [params setValue:@"true" forKey:@"saved"];
  871. [params setValue:order_code forKey:@"orderCode"];
  872. // [params setValue:sourceid forKey:@"sourceid"];
  873. // [params setValue:editor forKey:@"editor"];
  874. [params setValue:ScreenCodePlaceOrder forKey:kScreenName];
  875. NSData* json = nil;
  876. if(appDelegate.offline_mode)
  877. {
  878. json= [OLDataProvider offline_submitorder:params];
  879. }
  880. else
  881. {
  882. if(![self IsNetworkAvailable])
  883. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  884. json=[self get_json:URL_COMMIT_ORDER parameters:params];
  885. }
  886. if(json!=nil)
  887. {
  888. NSError *error=nil;
  889. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  890. return jsobj;
  891. }
  892. else
  893. return nil;
  894. }
  895. +(NSDictionary*)open_Order:(NSString*) order_code
  896. {
  897. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  898. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  899. if(appDelegate.user!=nil)
  900. [params setValue:appDelegate.user forKey:@"user"];
  901. // if(appDelegate.contact_id!=nil)
  902. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  903. if(appDelegate.password!=nil)
  904. [params setValue:appDelegate.password forKey:@"password"];
  905. [params setValue:order_code forKey:@"orderCode"];
  906. // [params setValue:sourceid forKey:@"sourceid"];
  907. // [params setValue:editor forKey:@"editor"];
  908. [params setValue:ScreenCodeOrderInfo forKey:kScreenName];
  909. NSData* json=nil;
  910. if(appDelegate.offline_mode)
  911. {
  912. json=[OLDataProvider offline_editorder:params];
  913. }
  914. else
  915. {
  916. if(![self IsNetworkAvailable])
  917. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  918. json=[self get_json:URL_OPEN_ORDER parameters:params];
  919. }
  920. if(json!=nil)
  921. {
  922. NSError *error=nil;
  923. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  924. int result = [[jsobj valueForKey:@"result"] intValue];
  925. if (result==2)
  926. {
  927. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  928. //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  929. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  930. [appDelegate update_count_mark];
  931. if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
  932. [Singleton sharedInstance].currentOrderIsMerged = [[jsobj valueForKey:@"is_merged_order"] boolValue];
  933. }
  934. }
  935. return jsobj;
  936. }
  937. else
  938. return nil;
  939. }
  940. +(NSDictionary*)delete_Order:(NSString*) order_id
  941. {
  942. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  943. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  944. if(appDelegate.user!=nil)
  945. [params setValue:appDelegate.user forKey:@"user"];
  946. // if(appDelegate.contact_id!=nil)
  947. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  948. if(appDelegate.password!=nil)
  949. [params setValue:appDelegate.password forKey:@"password"];
  950. [params setValue:order_id forKey:@"orderId"];
  951. // [params setValue:sourceid forKey:@"sourceid"];
  952. // [params setValue:editor forKey:@"editor"];
  953. [params setValue:ScreenCodeOrderList forKey:kScreenName];
  954. if(appDelegate.offline_mode)
  955. {
  956. return [OLDataProvider offline_notimpl];
  957. }
  958. if(![self IsNetworkAvailable])
  959. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  960. NSData* json=[self get_json:URL_DELETE_ORDER parameters:params];
  961. if(json!=nil)
  962. {
  963. NSError *error=nil;
  964. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  965. return jsobj;
  966. }
  967. else
  968. return nil;
  969. }
  970. +(NSDictionary*)cancel_Order:(NSString*) order_id order_code:(NSString*) order_code
  971. {
  972. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  973. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  974. if(appDelegate.user!=nil)
  975. [params setValue:appDelegate.user forKey:@"user"];
  976. // if(appDelegate.contact_id!=nil)
  977. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  978. if(appDelegate.password!=nil)
  979. [params setValue:appDelegate.password forKey:@"password"];
  980. [params setValue:order_id forKey:@"orderId"];
  981. [params setValue:order_code forKey:@"orderCode"];
  982. // [params setValue:sourceid forKey:@"sourceid"];
  983. // [params setValue:editor forKey:@"editor"];
  984. [params setValue:ScreenCodeOrderList forKey:kScreenName];
  985. NSData* json=nil;
  986. if(appDelegate.offline_mode)
  987. {
  988. json=[OLDataProvider offline_cancelorder:params];
  989. }
  990. else
  991. {
  992. if(![self IsNetworkAvailable])
  993. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  994. json=[self get_json:URL_CANCEL_ORDER parameters:params];
  995. }
  996. if(json!=nil)
  997. {
  998. NSError *error=nil;
  999. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1000. return jsobj;
  1001. }
  1002. else
  1003. return nil;
  1004. }
  1005. +(NSDictionary*)release_Order:(NSString*) order_code withScreen:(NSString *)screenName
  1006. {
  1007. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1008. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1009. if(appDelegate.user!=nil)
  1010. [params setValue:appDelegate.user forKey:@"user"];
  1011. // if(appDelegate.contact_id!=nil)
  1012. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1013. if(appDelegate.password!=nil)
  1014. [params setValue:appDelegate.password forKey:@"password"];
  1015. [params setValue:order_code forKey:@"orderCode"];
  1016. // [params setValue:sourceid forKey:@"sourceid"];
  1017. // [params setValue:editor forKey:@"editor"];
  1018. if (screenName) {
  1019. [params setValue:screenName forKey:kScreenName];
  1020. }
  1021. NSData* json=nil;
  1022. if(appDelegate.offline_mode)
  1023. {
  1024. json= [OLDataProvider offline_resetorder:params];
  1025. }
  1026. else
  1027. {
  1028. if(![self IsNetworkAvailable])
  1029. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1030. json=[self get_json:URL_RELEASE_ORDER parameters:params];
  1031. }
  1032. if(json!=nil)
  1033. {
  1034. NSError *error=nil;
  1035. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1036. if([[jsobj valueForKey:@"result"]intValue]==2)
  1037. { [appDelegate SetSo:nil];
  1038. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1039. //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1040. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1041. [appDelegate update_count_mark];
  1042. }
  1043. return jsobj;
  1044. }
  1045. else
  1046. return nil;
  1047. }
  1048. +(NSDictionary*)update_OrderCustomer:(NSString*) order_code customerinfo:(NSMutableDictionary*)info
  1049. {
  1050. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1051. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1052. if(appDelegate.user!=nil)
  1053. [info setValue:appDelegate.user forKey:@"user"];
  1054. // if(appDelegate.contact_id!=nil)
  1055. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1056. if(appDelegate.password!=nil)
  1057. [info setValue:appDelegate.password forKey:@"password"];
  1058. [info setObject:ScreenCodeEditCustomer forKey:kScreenName];
  1059. [info setValue:order_code forKey:@"orderCode"];
  1060. // [params setValue:sourceid forKey:@"sourceid"];
  1061. // [params setValue:editor forKey:@"editor"];
  1062. if(appDelegate.offline_mode)
  1063. {
  1064. return [OLDataProvider offline_notimpl];
  1065. }
  1066. if(![self IsNetworkAvailable])
  1067. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1068. NSData* json=[self get_json:URL_UPDATE_ORDERCUSTOMER parameters:info];
  1069. if(json!=nil)
  1070. {
  1071. NSError *error=nil;
  1072. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1073. return jsobj;
  1074. }
  1075. else
  1076. return nil;
  1077. }
  1078. +(NSDictionary*)commoneditor_partialrefresh: (NSMutableDictionary*)params url:(NSString*)url
  1079. {
  1080. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1081. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1082. if(appDelegate.user!=nil)
  1083. [params setValue:appDelegate.user forKey:@"user"];
  1084. if(appDelegate.contact_id!=nil)
  1085. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1086. if(appDelegate.password!=nil)
  1087. [params setValue:appDelegate.password forKey:@"password"];
  1088. // if(appDelegate.order_code!=nil)
  1089. // [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1090. // NSDictionary* customerinfo= appDelegate.customerInfo;
  1091. //
  1092. // NSArray* keys=[customerinfo allKeys];
  1093. // for(int i=0;i<keys.count;i++)
  1094. // {
  1095. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1096. // }
  1097. //
  1098. // [params setValue:sourceid forKey:@"sourceid"];
  1099. // [params setValue:editor forKey:@"editor"];
  1100. [params setObject:ScreenCodeModelInfo forKey:kScreenName];
  1101. if(appDelegate.offline_mode)
  1102. {
  1103. params[@"offline_Command"]=url;
  1104. return [OLDataProvider offline_commoneditor_partialrefresh:params];
  1105. }
  1106. if(![self IsNetworkAvailable])
  1107. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1108. NSData* json=[self get_json:url parameters:params];
  1109. if(json!=nil)
  1110. {
  1111. NSError *error=nil;
  1112. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1113. if([[jsobj valueForKey:@"result"]intValue]==2)
  1114. [appDelegate SetSo:nil];
  1115. return jsobj;
  1116. }
  1117. else
  1118. return nil;
  1119. }
  1120. +(NSDictionary*)saveandcommit_Order:(NSMutableDictionary*)params
  1121. {
  1122. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1123. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1124. if(appDelegate.user!=nil)
  1125. [params setValue:appDelegate.user forKey:@"user"];
  1126. if(appDelegate.contact_id!=nil)
  1127. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1128. if(appDelegate.password!=nil)
  1129. [params setValue:appDelegate.password forKey:@"password"];
  1130. if(appDelegate.order_code!=nil)
  1131. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1132. // NSDictionary* customerinfo= appDelegate.customerInfo;
  1133. //
  1134. // NSArray* keys=[customerinfo allKeys];
  1135. // for(int i=0;i<keys.count;i++)
  1136. // {
  1137. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1138. // }
  1139. //
  1140. // [params setValue:sourceid forKey:@"sourceid"];
  1141. // [params setValue:editor forKey:@"editor"];
  1142. [params setObject:ScreenCodePlaceOrder forKey:kScreenName];
  1143. NSData* json=nil;
  1144. if(appDelegate.offline_mode)
  1145. {
  1146. json=[OLDataProvider offline_submitorder:params];
  1147. }
  1148. else
  1149. {
  1150. if(![self IsNetworkAvailable])
  1151. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1152. json=[self get_json:URL_COMMIT_ORDER parameters:params];
  1153. }
  1154. if(json!=nil)
  1155. {
  1156. NSError *error=nil;
  1157. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1158. if([[jsobj valueForKey:@"result"]intValue]==2)
  1159. [appDelegate SetSo:nil];
  1160. return jsobj;
  1161. }
  1162. else
  1163. return nil;
  1164. }
  1165. +(NSDictionary*)update_Customer:(NSMutableDictionary*)params
  1166. {
  1167. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1168. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1169. if(appDelegate.user!=nil)
  1170. [params setValue:appDelegate.user forKey:@"user"];
  1171. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  1172. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1173. // else
  1174. if(appDelegate.contact_id!=nil)
  1175. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1176. if(appDelegate.password!=nil)
  1177. [params setValue:appDelegate.password forKey:@"password"];
  1178. // NSDictionary* customerinfo=nil;
  1179. // if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
  1180. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1181. // else
  1182. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1183. //
  1184. // appDelegate.customerInfo;
  1185. // NSArray* keys=[customerinfo allKeys];
  1186. // for(int i=0;i<keys.count;i++)
  1187. // {
  1188. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1189. // }
  1190. // [params setValue:sourceid forKey:@"sourceid"];
  1191. // [params setValue:editor forKey:@"editor"];
  1192. [params setObject:ScreenCodeEditCustomer forKey:kScreenName];
  1193. NSData* json=nil;
  1194. if(appDelegate.offline_mode)
  1195. {
  1196. json= [OLDataProvider offline_saveContact:params];
  1197. }
  1198. else
  1199. {
  1200. if(![self IsNetworkAvailable])
  1201. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1202. json=[self get_json:URL_CUSTOMER_UPDATE parameters:params];
  1203. }
  1204. if(json!=nil)
  1205. {
  1206. NSError *error=nil;
  1207. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1208. return jsobj;
  1209. }
  1210. else
  1211. return nil;
  1212. }
  1213. +(NSDictionary*)save_newCustomer:(NSMutableDictionary*)params
  1214. {
  1215. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1216. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1217. if(appDelegate.user!=nil)
  1218. [params setValue:appDelegate.user forKey:@"user"];
  1219. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  1220. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1221. // else
  1222. if(appDelegate.contact_id!=nil)
  1223. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1224. if(appDelegate.password!=nil)
  1225. [params setValue:appDelegate.password forKey:@"password"];
  1226. // NSDictionary* customerinfo=nil;
  1227. // if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
  1228. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1229. // else
  1230. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1231. //
  1232. // appDelegate.customerInfo;
  1233. // NSArray* keys=[customerinfo allKeys];
  1234. // for(int i=0;i<keys.count;i++)
  1235. // {
  1236. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1237. // }
  1238. // [params setValue:sourceid forKey:@"sourceid"];
  1239. // [params setValue:editor forKey:@"editor"];
  1240. [params setObject:ScreenCodeNewCustomer forKey:kScreenName];
  1241. NSData* json=nil;
  1242. if(appDelegate.offline_mode)
  1243. {
  1244. json= [OLDataProvider offline_saveNewContact:params];
  1245. }
  1246. else
  1247. {
  1248. if(![self IsNetworkAvailable])
  1249. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1250. json=[self get_json:URL_CUSTOMER_SAVE parameters:params];
  1251. }
  1252. if(json!=nil)
  1253. {
  1254. NSError *error=nil;
  1255. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1256. return jsobj;
  1257. }
  1258. else
  1259. return nil;
  1260. }
  1261. +(NSDictionary*)save_Order:(NSMutableDictionary*)params
  1262. {
  1263. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1264. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1265. if(appDelegate.user!=nil)
  1266. [params setValue:appDelegate.user forKey:@"user"];
  1267. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  1268. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1269. // else
  1270. if(appDelegate.contact_id!=nil)
  1271. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1272. if(appDelegate.password!=nil)
  1273. [params setValue:appDelegate.password forKey:@"password"];
  1274. if(appDelegate.order_code!=nil)
  1275. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1276. // NSDictionary* customerinfo=nil;
  1277. // if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
  1278. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1279. // else
  1280. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1281. //
  1282. // appDelegate.customerInfo;
  1283. // NSArray* keys=[customerinfo allKeys];
  1284. // for(int i=0;i<keys.count;i++)
  1285. // {
  1286. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1287. // }
  1288. // [params setValue:sourceid forKey:@"sourceid"];
  1289. // [params setValue:editor forKey:@"editor"];
  1290. [params setObject:ScreenCodePlaceOrder forKey:kScreenName];
  1291. NSData* json=nil;
  1292. if(appDelegate.offline_mode)
  1293. {
  1294. json= [OLDataProvider offline_saveorder:params];
  1295. }
  1296. else
  1297. {
  1298. if(![self IsNetworkAvailable])
  1299. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1300. json=[self get_json:URL_SAVE_ORDER parameters:params];
  1301. }
  1302. if(json!=nil)
  1303. {
  1304. NSError *error=nil;
  1305. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1306. NSString *so = [jsobj valueForKey:@"so#"];
  1307. if (so) {
  1308. [appDelegate SetSo:so];
  1309. }
  1310. return jsobj;
  1311. }
  1312. else
  1313. return nil;
  1314. }
  1315. +(NSDictionary*)request_Editor:(NSString*) request_url params:(NSMutableDictionary*)params
  1316. {
  1317. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1318. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1319. if(appDelegate.user!=nil)
  1320. [params setValue:appDelegate.user forKey:@"user"];
  1321. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  1322. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1323. // else
  1324. if(appDelegate.contact_id!=nil)
  1325. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1326. if(appDelegate.password!=nil)
  1327. [params setValue:appDelegate.password forKey:@"password"];
  1328. if(appDelegate.order_code!=nil)
  1329. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1330. // [params setValue:sourceid forKey:@"sourceid"];
  1331. // [params setValue:editor forKey:@"editor"];
  1332. DebugLog(@"request editor url:%@",request_url);
  1333. if([request_url isEqualToString:URL_NEW_CUSTOMER])
  1334. {
  1335. [params setObject:ScreenCodeNewCustomer forKey:kScreenName];
  1336. }
  1337. else if([request_url isEqualToString:URL_EDIT_CUSTOMER])
  1338. {
  1339. [params setObject:ScreenCodeEditCustomer forKey:kScreenName];
  1340. }
  1341. else if([request_url isEqualToString:URL_CUSTOMER_ADV_SEARCH])
  1342. {
  1343. [params setObject:ScreenCodeAdvanceSearch forKey:kScreenName];
  1344. }
  1345. else if([request_url isEqualToString:URL_CARTDELIVERY])
  1346. {
  1347. [params setObject:ScreenCodePlaceOrder forKey:kScreenName];
  1348. }
  1349. else if([request_url isEqualToString:URL_ADDRESS_EDOTOR])
  1350. {
  1351. [params setObject:ScreenCodeNewAddress forKey:kScreenName];
  1352. }
  1353. else if ([request_url isEqualToString:URL_DM_PARAMS]){
  1354. [params setObject:ScreenCodeCreatePortfolio forKey:kScreenName];
  1355. }
  1356. NSData* json = nil;
  1357. if(appDelegate.offline_mode)
  1358. {
  1359. if([request_url isEqualToString:URL_NEW_CUSTOMER])
  1360. {
  1361. json= [OLDataProvider offline_createContact:params];
  1362. }
  1363. else if([request_url isEqualToString:URL_EDIT_CUSTOMER])
  1364. {
  1365. json= [OLDataProvider offline_editContact:params];
  1366. }
  1367. else if([request_url isEqualToString:URL_CUSTOMER_ADV_SEARCH])
  1368. {
  1369. json= [OLDataProvider offline_contactAdvancedSearch:params];
  1370. }
  1371. else if([request_url isEqualToString:URL_CARTDELIVERY])
  1372. {
  1373. json= [OLDataProvider offline_placeorder:params];
  1374. }
  1375. else if([request_url isEqualToString:URL_ADDRESS_EDOTOR])
  1376. {
  1377. json= [OLDataProvider offline_addreditor:params];
  1378. }
  1379. else if ([request_url isEqualToString:URL_DM_PARAMS]){
  1380. json = [OLDataProvider offline_createTearSheet:params];
  1381. }
  1382. else
  1383. return [OLDataProvider offline_notimpl];
  1384. }
  1385. else
  1386. {
  1387. if(![self IsNetworkAvailable])
  1388. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1389. if([request_url isEqualToString:URL_CARTDELIVERY])
  1390. {
  1391. NSError *error=nil;
  1392. NSString * uuid= [[NSUUID UUID] UUIDString];
  1393. params[@"resultSerial"]=uuid;
  1394. for(int i=0;i<150;i++)
  1395. {
  1396. // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
  1397. // result_params[@"resultSerial"]=uuid;
  1398. json=[self get_json:request_url parameters:params];
  1399. if(json!=nil)
  1400. {
  1401. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1402. if([jsobj[@"result"] intValue]==2 || [jsobj[@"result"] intValue] == 8)
  1403. {
  1404. break;
  1405. }
  1406. }
  1407. sleep(2);
  1408. }
  1409. }
  1410. else
  1411. json =[self get_json:request_url parameters:params];
  1412. }
  1413. if(json!=nil)
  1414. {
  1415. NSError *error=nil;
  1416. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1417. return jsobj;
  1418. }
  1419. else
  1420. return nil;
  1421. }
  1422. //+(NSDictionary*)request_OrderInfo:(NSString*) orderid
  1423. //{
  1424. // if(![self IsNetworkAvailable])
  1425. // return nil;
  1426. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1427. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1428. // if(appDelegate.user!=nil)
  1429. // [params setValue:appDelegate.user forKey:@"user"];
  1430. // if(appDelegate.password!=nil)
  1431. // [params setValue:appDelegate.password forKey:@"password"];
  1432. // [params setValue:orderid forKey:@"orderid"];
  1433. // NSData* json=[self get_json:URL_ORDER_INFO parameters:params];
  1434. // NSError *error=nil;
  1435. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1436. // return jsobj;
  1437. //}
  1438. +(NSDictionary*)request_OrderList:(int ) offset limit :(int)limit keywords :(NSString* ) keywords status:(NSString*) status_code customer:(NSString*) customer is_merged:(BOOL) isMerged
  1439. {
  1440. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1441. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1442. if(appDelegate.user!=nil)
  1443. [params setValue:appDelegate.user forKey:@"user"];
  1444. if(appDelegate.contact_id!=nil)
  1445. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1446. if(appDelegate.password!=nil)
  1447. [params setValue:appDelegate.password forKey:@"password"];
  1448. [params setValue:[NSString stringWithFormat:@"%d",offset ] forKey:@"offset"];
  1449. [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
  1450. [params setValue:keywords forKey:@"keyWord"];
  1451. [params setValue:customer forKey:@"customer_filter"];
  1452. [params setValue:[NSNumber numberWithBool:isMerged] forKey:@"isMerged"];
  1453. [params setValue:status_code forKey:@"orderStatus"];
  1454. [params setObject:ScreenCodeOrderList forKey:kScreenName];
  1455. if (keywords) {
  1456. [params setObject:@"Search" forKey:kAction];
  1457. }
  1458. NSData* json=nil;
  1459. if(appDelegate.offline_mode)
  1460. {
  1461. json= [OLDataProvider offline_orderlist:params];
  1462. }
  1463. else
  1464. {
  1465. if(![self IsNetworkAvailable])
  1466. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1467. json=[self get_json:URL_ORDER_LIST parameters:params];
  1468. }
  1469. if(json==nil)
  1470. return nil;
  1471. NSError *error=nil;
  1472. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1473. return jsobj;
  1474. }
  1475. +(NSDictionary*)request_PDFList:(int ) offset limit:(int)limit keywords:(NSString* ) keywords
  1476. {
  1477. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1478. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1479. if(appDelegate.user!=nil)
  1480. [params setValue:appDelegate.user forKey:@"user"];
  1481. if(appDelegate.contact_id!=nil)
  1482. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1483. if(appDelegate.password!=nil)
  1484. [params setValue:appDelegate.password forKey:@"password"];
  1485. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1486. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1487. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1488. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1489. // [params setValue:filter forKey:@"filter"];
  1490. [params setValue:keywords forKey:@"keyWord"];
  1491. [params setValue:[NSString stringWithFormat:@"%d",limit] forKey:@"limit"];
  1492. [params setValue:[NSString stringWithFormat:@"%d",offset] forKey:@"offset"];
  1493. [params setObject:ScreenCodeViewPortfolios forKey:kScreenName];
  1494. if (keywords) {
  1495. [params setObject:@"Search" forKey:kAction];
  1496. }
  1497. NSData* json = nil;
  1498. if(appDelegate.offline_mode)
  1499. {
  1500. json = [OLDataProvider offline_pdfList:params];
  1501. } else {
  1502. if(![self IsNetworkAvailable])
  1503. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1504. json=[self get_json:URL_DM_LIST parameters:params];
  1505. }
  1506. if(json==nil)
  1507. return nil;
  1508. NSError *error=nil;
  1509. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1510. return jsobj;
  1511. }
  1512. +(NSString*) create_portfolio:(NSMutableDictionary*)params
  1513. { AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1514. if(appDelegate.offline_mode)
  1515. {
  1516. NSData*json = [OLDataProvider offline_direct_save_TearSheet:params];
  1517. if(json==nil)
  1518. return nil;
  1519. NSError *error=nil;
  1520. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1521. return jsobj[@"pdf_path"];
  1522. }
  1523. else
  1524. {
  1525. return nil;
  1526. }
  1527. }
  1528. +(NSDictionary*)direct_save_TearSheet:(NSMutableDictionary*)params//(NSString*) request_url name:(NSString*)name delete:(NSString* )ids note:(NSString* )saveNote modelIds:(NSDictionary *)modelIds
  1529. {
  1530. NSMutableDictionary* off_params = [params mutableCopy];;
  1531. params[@"off_params"]=[RAConvertor dict2string:off_params];;
  1532. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1533. if(appDelegate.user!=nil)
  1534. [params setValue:appDelegate.user forKey:@"user"];
  1535. if(appDelegate.contact_id!=nil)
  1536. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1537. if(appDelegate.password!=nil)
  1538. [params setValue:appDelegate.password forKey:@"password"];
  1539. [params setObject:ScreenCodeCreatePortfolio forKey:kScreenName];
  1540. /*
  1541. [params setValue:request_url forKey:@"pdfUrl"];
  1542. [params setValue:name forKey:@"pdfName"];
  1543. [params setValue:ids forKey:@"itemIds"];
  1544. [params setValue:saveNote forKey:@"pdfNote"];
  1545. [params setValue:[modelIds objectForKey:@"product_ids"] forKey:@"product_ids"];
  1546. [params setValue:[modelIds objectForKey:@"item_ids"] forKey:@"item_ids"];
  1547. [params setValue:[modelIds objectForKey:@"remove_item"] forKey:@"remove_item"];
  1548. */
  1549. NSData* json= nil;
  1550. if(appDelegate.offline_mode)
  1551. {
  1552. json = [OLDataProvider offline_direct_save_TearSheet:params];
  1553. }
  1554. else
  1555. {
  1556. if(![self IsNetworkAvailable])
  1557. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1558. json=[self get_json:URL_REQUEST_DM parameters:params];
  1559. NSError *error=nil;
  1560. NSString * uuid= [[NSUUID UUID] UUIDString];
  1561. params[@"resultSerial"]=uuid;
  1562. for(int i=0;i<150;i++)
  1563. {
  1564. // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
  1565. // result_params[@"resultSerial"]=uuid;
  1566. json=[self get_json:URL_REQUEST_DM parameters:params];
  1567. if(json!=nil)
  1568. {
  1569. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1570. if([jsobj[@"result"] intValue]==2)
  1571. {
  1572. break;
  1573. }
  1574. }
  1575. sleep(5);
  1576. }
  1577. }
  1578. if(json==nil)
  1579. return nil;
  1580. NSError *error=nil;
  1581. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1582. return jsobj;
  1583. }
  1584. +(NSDictionary*)request_TearSheet:(NSMutableDictionary*)params//(NSString*) request_url
  1585. {
  1586. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1587. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1588. if(appDelegate.user!=nil)
  1589. [params setValue:appDelegate.user forKey:@"user"];
  1590. if(appDelegate.contact_id!=nil)
  1591. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1592. if(appDelegate.password!=nil)
  1593. [params setValue:appDelegate.password forKey:@"password"];
  1594. [params setObject:ScreenCodeCreatePortfolio forKey:kScreenName];
  1595. // [params setValue:request_url forKey:@"pdfUrl"];
  1596. NSData* json= nil;
  1597. if(appDelegate.offline_mode)
  1598. {
  1599. json= [OLDataProvider offline_request_tearsheet:params];
  1600. }
  1601. else
  1602. {
  1603. if(![self IsNetworkAvailable])
  1604. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1605. NSError *error=nil;
  1606. NSString * uuid= [[NSUUID UUID] UUIDString];
  1607. params[@"resultSerial"]=uuid;
  1608. for(int i=0;i<150;i++)
  1609. {
  1610. // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
  1611. // result_params[@"resultSerial"]=uuid;
  1612. json=[self get_json:URL_REQUEST_DM parameters:params];
  1613. if(json!=nil)
  1614. {
  1615. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1616. if([jsobj[@"result"] intValue]==2)
  1617. {
  1618. break;
  1619. }
  1620. }
  1621. sleep(5);
  1622. }
  1623. }
  1624. if(json==nil)
  1625. return nil;
  1626. NSError *error=nil;
  1627. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1628. return jsobj;
  1629. }
  1630. +(NSDictionary*)save_TearSheet:(NSMutableDictionary *)params//(NSString*) path name:(NSString*)name delete:(NSString* )ids note:(NSString*)note configureParams:(NSString *)configureParams modelIds:(NSDictionary *)modelIds
  1631. {
  1632. NSMutableDictionary* off_params = [params mutableCopy];;
  1633. params[@"off_params"]=[RAConvertor dict2string:off_params];
  1634. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1635. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1636. if(appDelegate.user!=nil)
  1637. [params setValue:appDelegate.user forKey:@"user"];
  1638. if(appDelegate.contact_id!=nil)
  1639. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1640. if(appDelegate.password!=nil)
  1641. [params setValue:appDelegate.password forKey:@"password"];
  1642. [params setObject:ScreenCodeCreatePortfolio forKey:kScreenName];
  1643. /*
  1644. [params setValue:path forKey:@"pdfPath"];
  1645. [params setValue:name forKey:@"pdfName"];
  1646. [params setValue:note forKey:@"pdfNote"];
  1647. [params setValue:ids forKey:@"itemIds"];
  1648. [params setValue:configureParams forKey:@"configureParams"];
  1649. [params setValue:[modelIds objectForKey:@"product_ids"] forKey:@"product_ids"];
  1650. [params setValue:[modelIds objectForKey:@"item_ids"] forKey:@"item_ids"];
  1651. [params setValue:[modelIds objectForKey:@"remove_item"] forKey:@"remove_item"];
  1652. */
  1653. NSData* json = nil;
  1654. if(appDelegate.offline_mode)
  1655. {
  1656. json = [OLDataProvider offline_save_TearSheet:params];
  1657. } else {
  1658. if(![self IsNetworkAvailable])
  1659. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1660. json=[self get_json:URL_SAVE_DM parameters:params];
  1661. }
  1662. if(json==nil)
  1663. return nil;
  1664. NSError *error=nil;
  1665. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1666. return jsobj;
  1667. }
  1668. +(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module code:(int) code//device:(NSString*) device
  1669. {
  1670. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1671. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1672. if(appDelegate.user!=nil)
  1673. [params setValue:appDelegate.user forKey:@"user"];
  1674. [params setValue:up_params forKey:@"upparam"];
  1675. [params setValue:[NSNumber numberWithInt:code ] forKey:@"code"];
  1676. [params setValue:result forKey:@"result"];
  1677. [params setValue:module forKey:@"interfac"];
  1678. [params setValue:[RAUtils base64en:[RAConvertor dict2string: [RAUtils device_info]]] forKey:@"device"];
  1679. // [params setValue:module forKey:@"module"];
  1680. // [[UIDevice currentDevice] name];
  1681. // if(appDelegate.offline_mode)
  1682. // {
  1683. // return [OLDataProvider offline_notimpl];
  1684. // }
  1685. if(![self IsNetworkAvailable])
  1686. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1687. NSData* json=[self get_json:URL_ERR_LOG parameters:params];
  1688. if(json==nil)
  1689. return nil;
  1690. NSError *error=nil;
  1691. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1692. return jsobj;
  1693. }
  1694. +(NSDictionary*)request_ContactList:(int) offset limit:(int)limit keywords:(NSString*) keywords type:(NSString*) contact_type adv_search:(NSDictionary*)upparams
  1695. {
  1696. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1697. if(upparams!=nil)
  1698. params = [upparams mutableCopy];
  1699. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1700. if(appDelegate.user!=nil)
  1701. [params setValue:appDelegate.user forKey:@"user"];
  1702. if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  1703. [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1704. else
  1705. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1706. if(appDelegate.password!=nil)
  1707. [params setValue:appDelegate.password forKey:@"password"];
  1708. [params setValue:[NSString stringWithFormat:@"%d",offset ] forKey:@"offset"];
  1709. [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
  1710. [params setValue:contact_type forKey:@"contactType"];
  1711. [params setValue:keywords forKey:@"keyword"];
  1712. [params setObject:ScreenCodeAccount forKey:kScreenName];
  1713. if (keywords) {
  1714. [params setObject:@"Search" forKey:kAction];
  1715. }
  1716. if (upparams) {
  1717. [params setObject:@"Advance Search" forKey:kAction];
  1718. }
  1719. NSString* url=nil;
  1720. if([contact_type isEqualToString:@"Sales_Order_Ship_To"])
  1721. url=URL_SHIPTO_LIST;
  1722. else
  1723. url=URL_CONTACT_LIST;
  1724. if(appDelegate.offline_mode)
  1725. return [OLDataProvider offline_contactlist:params];
  1726. if(![self IsNetworkAvailable])
  1727. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1728. NSData* json=[self get_json:url parameters:params];
  1729. if(json==nil)
  1730. return nil;
  1731. NSError *error=nil;
  1732. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1733. return jsobj;
  1734. }
  1735. +(NSDictionary*)request_OrderDetail:(NSMutableDictionary *) params
  1736. {
  1737. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1738. if (params == nil) {
  1739. params = [[NSMutableDictionary alloc] init];
  1740. }
  1741. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1742. if(appDelegate.user!=nil)
  1743. [params setValue:appDelegate.user forKey:@"user"];
  1744. if(appDelegate.contact_id!=nil)
  1745. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1746. if(appDelegate.password!=nil)
  1747. [params setValue:appDelegate.password forKey:@"password"];
  1748. // [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
  1749. [params setObject:ScreenCodeOrderInfo forKey:kScreenName];
  1750. NSData* json=nil;
  1751. if(appDelegate.offline_mode)
  1752. {
  1753. json= [OLDataProvider offline_orderdetail:params];
  1754. }
  1755. else
  1756. {
  1757. if(![self IsNetworkAvailable])
  1758. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1759. NSError *error=nil;
  1760. NSString * uuid= [[NSUUID UUID] UUIDString];
  1761. params[@"resultSerial"]=uuid;
  1762. for(int i=0;i<150;i++)
  1763. {
  1764. // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
  1765. // result_params[@"resultSerial"]=uuid;
  1766. json=[self get_json:URL_ORDER_DETAIL parameters:params];
  1767. if(json!=nil)
  1768. {
  1769. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1770. int resultCode = [jsobj[@"result"] intValue];
  1771. if(resultCode==2 || resultCode == 8)
  1772. {
  1773. break;
  1774. }
  1775. }
  1776. sleep(2);
  1777. }
  1778. }
  1779. if(json==nil)
  1780. return nil;
  1781. NSError *error=nil;
  1782. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1783. return jsobj;
  1784. }
  1785. +(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count name:(NSString *)name
  1786. {
  1787. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1788. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1789. if(appDelegate.user!=nil)
  1790. [params setValue:appDelegate.user forKey:@"user"];
  1791. if(appDelegate.contact_id!=nil)
  1792. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1793. if(appDelegate.password!=nil)
  1794. [params setValue:appDelegate.password forKey:@"password"];
  1795. if(appDelegate.order_code!=nil)
  1796. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1797. [params setValue:item_id forKey:@"product_id"];
  1798. [params setValue:[NSString stringWithFormat:@"%d",count] forKey:@"count"];
  1799. [params setObject:ScreenCodeModelInfo forKey:kScreenName];
  1800. [params setObject:@"Add To Cart" forKey:kAction];
  1801. if (name) {
  1802. NSDictionary *extra = @{@"ModelName" : name,@"Count" : @(count)};
  1803. [params setObject:extra forKey:kExtra];
  1804. }
  1805. NSDictionary* customerinfo= appDelegate.customerInfo;
  1806. NSArray* keys=[customerinfo allKeys];
  1807. for(int i=0;i<keys.count;i++)
  1808. {
  1809. [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1810. }
  1811. NSData* json=nil;
  1812. if(appDelegate.offline_mode)
  1813. {
  1814. json=[OLDataProvider offline_add2cart:params];
  1815. }
  1816. else
  1817. {
  1818. if(![self IsNetworkAvailable])
  1819. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1820. json=[self get_json:URL_ADD_TO_CART parameters:params];
  1821. }
  1822. if(json==nil)
  1823. return nil;
  1824. NSError *error=nil;
  1825. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1826. int result = [[jsobj valueForKey:@"result"] intValue];
  1827. if (result==2)
  1828. {
  1829. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1830. // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1831. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1832. [appDelegate update_count_mark];
  1833. }
  1834. return jsobj;
  1835. }
  1836. +(NSDictionary*) add_toCart_byName:(NSString* ) model_name withScreen:(NSString *)screenName
  1837. {
  1838. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1839. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1840. if(appDelegate.user!=nil)
  1841. [params setValue:appDelegate.user forKey:@"user"];
  1842. if(appDelegate.contact_id!=nil)
  1843. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1844. if(appDelegate.password!=nil)
  1845. [params setValue:appDelegate.password forKey:@"password"];
  1846. if(appDelegate.order_code!=nil)
  1847. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1848. [params setValue:model_name forKey:@"product_name"];
  1849. [params setValue:[NSString stringWithFormat:@"%d",-1] forKey:@"count"];
  1850. [params setObject:screenName forKey:kScreenName];
  1851. [params setObject:@"Add To Cart" forKey:kAction];
  1852. [params setObject:@{@"ModelName" : model_name} forKey:kExtra];
  1853. NSDictionary* customerinfo= appDelegate.customerInfo;
  1854. NSArray* keys=[customerinfo allKeys];
  1855. for(int i=0;i<keys.count;i++)
  1856. {
  1857. [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1858. }
  1859. NSData* json=nil;
  1860. if(appDelegate.offline_mode)
  1861. {
  1862. json= [OLDataProvider offline_add2cartbyname:params];
  1863. }
  1864. else
  1865. {
  1866. if(![self IsNetworkAvailable])
  1867. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1868. json=[self get_json:URL_ADD_TO_CART parameters:params];
  1869. }
  1870. if(json==nil)
  1871. return nil;
  1872. NSError *error=nil;
  1873. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1874. int result = [[jsobj valueForKey:@"result"] intValue];
  1875. if (result==2||result==8)
  1876. {
  1877. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1878. // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1879. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1880. [appDelegate update_count_mark];
  1881. }
  1882. return jsobj;
  1883. }
  1884. //+(NSDictionary*) new_Customer
  1885. //{
  1886. // if(![self IsNetworkAvailable])
  1887. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1888. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1889. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1890. // if(appDelegate.user!=nil)
  1891. // [params setValue:appDelegate.user forKey:@"user"];
  1892. //// if(appDelegate.contact_id!=nil)
  1893. //// [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1894. // if(appDelegate.password!=nil)
  1895. // [params setValue:appDelegate.password forKey:@"password"];
  1896. //
  1897. //// if(appDelegate.order_code!=nil)
  1898. //// [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1899. //
  1900. //
  1901. // NSDictionary* customerinfo= appDelegate.customerInfo;
  1902. //
  1903. // NSArray* keys=[customerinfo allKeys];
  1904. // for(int i=0;i<keys.count;i++)
  1905. // {
  1906. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1907. // }
  1908. //
  1909. // NSData* json=[self get_json:URL_CUSTOMER_EDIT parameters:params];
  1910. // if(json==nil)
  1911. // return nil;
  1912. // NSError *error=nil;
  1913. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1914. // return jsobj;
  1915. //}
  1916. +(NSDictionary*) new_Order
  1917. {
  1918. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1919. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1920. if(appDelegate.user!=nil)
  1921. [params setValue:appDelegate.user forKey:@"user"];
  1922. if(appDelegate.contact_id!=nil)
  1923. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1924. if(appDelegate.password!=nil)
  1925. [params setValue:appDelegate.password forKey:@"password"];
  1926. if(appDelegate.order_code!=nil)
  1927. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1928. [params setObject:ScreenCodeOrderList forKey:kScreenName];
  1929. NSDictionary* customerinfo= appDelegate.customerInfo;
  1930. NSArray* keys=[customerinfo allKeys];
  1931. for(int i=0;i<keys.count;i++)
  1932. {
  1933. [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1934. }
  1935. NSData* json = nil;
  1936. if(appDelegate.offline_mode)
  1937. {
  1938. json= [OLDataProvider offline_createorder:params];
  1939. }
  1940. else
  1941. {
  1942. if(![self IsNetworkAvailable])
  1943. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1944. json=[self get_json:URL_NEW_ORDER parameters:params];
  1945. }
  1946. if(json==nil)
  1947. return nil;
  1948. NSError *error=nil;
  1949. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1950. int result = [[jsobj valueForKey:@"result"] intValue];
  1951. if (result==2)
  1952. {
  1953. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1954. //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1955. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1956. [appDelegate update_count_mark];
  1957. }
  1958. [appDelegate SetSo:[jsobj valueForKey:@"soId"]];
  1959. if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
  1960. [Singleton sharedInstance].currentOrderIsMerged = NO;
  1961. }
  1962. return jsobj;
  1963. }
  1964. +(NSDictionary*) add_toPortfolio:(NSString* ) item_id withScreen:(NSString *)screenName
  1965. {
  1966. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1967. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1968. if(appDelegate.user!=nil)
  1969. [params setValue:appDelegate.user forKey:@"user"];
  1970. if(appDelegate.contact_id!=nil)
  1971. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1972. if(appDelegate.password!=nil)
  1973. [params setValue:appDelegate.password forKey:@"password"];
  1974. [params setValue:item_id forKey:@"product_id"];
  1975. [params setObject:screenName forKey:kScreenName];
  1976. NSData* json = nil;
  1977. if(appDelegate.offline_mode)
  1978. {
  1979. json = [OLDataProvider offline_add2Portfolio:params];
  1980. } else {
  1981. if(![self IsNetworkAvailable])
  1982. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1983. json=[self get_json:URL_ADD_TO_PORTFOLIO parameters:params];
  1984. }
  1985. if(json==nil)
  1986. return nil;
  1987. NSError *error=nil;
  1988. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1989. int result = [[jsobj valueForKey:@"result"] intValue];
  1990. if (result==2)
  1991. {
  1992. // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1993. // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1994. appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1995. [appDelegate update_count_mark];
  1996. }
  1997. return jsobj;
  1998. }
  1999. +(NSDictionary*) add_toWatchList:(NSString* ) item_id withScreen:(NSString *)screenName
  2000. {
  2001. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2002. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2003. if(appDelegate.user!=nil)
  2004. [params setValue:appDelegate.user forKey:@"user"];
  2005. if(appDelegate.contact_id!=nil)
  2006. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2007. if(appDelegate.password!=nil)
  2008. [params setValue:appDelegate.password forKey:@"password"];
  2009. [params setValue:item_id forKey:@"product_id"];
  2010. [params setObject:screenName forKey:kScreenName];
  2011. if(appDelegate.offline_mode)
  2012. {
  2013. return [OLDataProvider offline_add2wishlist:params];
  2014. }
  2015. if(![self IsNetworkAvailable])
  2016. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2017. NSData* json=[self get_json:URL_ADD_TO_WATCHLIST parameters:params];
  2018. if(json==nil)
  2019. return nil;
  2020. NSError *error=nil;
  2021. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2022. int result = [[jsobj valueForKey:@"result"] intValue];
  2023. if (result==2)
  2024. {
  2025. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  2026. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  2027. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  2028. [appDelegate update_count_mark];
  2029. }
  2030. return jsobj;
  2031. }
  2032. +(NSDictionary*) cart_setPrice:(NSString*) cart_id price:(float) price discount:(float) discount notes:(NSString*) notes
  2033. {
  2034. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2035. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2036. if(appDelegate.user!=nil)
  2037. [params setValue:appDelegate.user forKey:@"user"];
  2038. if(appDelegate.contact_id!=nil)
  2039. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2040. if(appDelegate.password!=nil)
  2041. [params setValue:appDelegate.password forKey:@"password"];
  2042. [params setValue:cart_id forKey:@"cartitem_id"];
  2043. [params setValue:notes forKey:@"item_note"];
  2044. [params setValue:[NSString stringWithFormat:@"%f",price] forKey:@"price"];
  2045. [params setValue:[NSString stringWithFormat:@"%f",discount] forKey:@"discount"];
  2046. [params setObject:ScreenCodeCart forKey:kScreenName];
  2047. NSData* json= nil;
  2048. if(appDelegate.offline_mode)
  2049. {
  2050. json=[OLDataProvider offline_cartsetprice:params];
  2051. }
  2052. else
  2053. {
  2054. if(![self IsNetworkAvailable])
  2055. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2056. json=[self get_json:URL_CART_SET_PRICE parameters:params];
  2057. }
  2058. if(json==nil)
  2059. return nil;
  2060. NSError *error=nil;
  2061. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2062. return jsobj;
  2063. }
  2064. //+(NSDictionary*) portfolio_setQTY:(NSString*) watchlist_id QTY:(int)qty
  2065. //{
  2066. // if(![self IsNetworkAvailable])
  2067. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2068. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2069. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2070. // if(appDelegate.user!=nil)
  2071. // [params setValue:appDelegate.user forKey:@"user"];
  2072. // if(appDelegate.contact_id!=nil)
  2073. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2074. // if(appDelegate.password!=nil)
  2075. // [params setValue:appDelegate.password forKey:@"password"];
  2076. //
  2077. // [params setValue:watchlist_id forKey:@"item_id"];
  2078. //
  2079. // [params setValue:[NSString stringWithFormat:@"%d",qty] forKey:@"available_qty"];
  2080. //
  2081. //
  2082. //
  2083. // NSData* json=[self get_json:URL_DM_SET_QTY parameters:params];
  2084. // if(json==nil)
  2085. // return nil;
  2086. // NSError *error=nil;
  2087. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2088. // return jsobj;
  2089. //}
  2090. +(NSDictionary*) portfolio_setPrice:(NSString*) watchlist_id price:(float) price discount:(float) discount QTY:(int)qty qty_p:(float) qty_p notes:(NSString*)notes
  2091. {
  2092. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2093. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2094. if(appDelegate.user!=nil)
  2095. [params setValue:appDelegate.user forKey:@"user"];
  2096. if(appDelegate.contact_id!=nil)
  2097. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2098. if(appDelegate.password!=nil)
  2099. [params setValue:appDelegate.password forKey:@"password"];
  2100. [params setValue:watchlist_id forKey:@"item_id"];
  2101. // if(notes.length>0)
  2102. // [params setValue:notes forKey:@"notes"];
  2103. if(notes)
  2104. [params setValue:notes forKey:@"notes"];
  2105. if(price != -MAXFLOAT)
  2106. [params setValue:[NSString stringWithFormat:@"%f",price] forKey:@"price"];
  2107. if (discount != -MAXFLOAT)
  2108. [params setValue:[NSString stringWithFormat:@"%f",discount] forKey:@"discount"];
  2109. if(qty_p != -MAXFLOAT)
  2110. [params setValue:[NSString stringWithFormat:@"%f",qty_p] forKey:@"available_percent"];
  2111. if(qty != -INT32_MAX)
  2112. [params setValue:[NSString stringWithFormat:@"%d",qty] forKey:@"available_qty"];
  2113. [params setObject:ScreenCodePortfolio forKey:kScreenName];
  2114. NSData* json = nil;
  2115. if(appDelegate.offline_mode)
  2116. {
  2117. json = [OLDataProvider offline_editPortfolio:params];
  2118. } else {
  2119. if(![self IsNetworkAvailable])
  2120. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2121. json = [self get_json:URL_PORTFOLIO_SET_PRICE parameters:params];
  2122. }
  2123. if(json==nil)
  2124. return nil;
  2125. NSError *error=nil;
  2126. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2127. return jsobj;
  2128. }
  2129. +(NSDictionary*) cart_setGeneralNote:(NSString*) order_code notes:(NSString*) notes
  2130. {
  2131. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2132. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2133. if(appDelegate.user!=nil)
  2134. [params setValue:appDelegate.user forKey:@"user"];
  2135. if(appDelegate.contact_id!=nil)
  2136. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2137. if(appDelegate.password!=nil)
  2138. [params setValue:appDelegate.password forKey:@"password"];
  2139. [params setValue:order_code forKey:@"orderCode"];
  2140. [params setObject:ScreenCodeCart forKey:kScreenName];
  2141. if(notes.length==0)
  2142. notes=@"";
  2143. [params setValue:notes forKey:@"comments"];
  2144. NSData* json=nil;
  2145. if(appDelegate.offline_mode)
  2146. {
  2147. json= [OLDataProvider offline_updategnotes:params];
  2148. }
  2149. else
  2150. {
  2151. if(![self IsNetworkAvailable])
  2152. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2153. json=[self get_json:URL_CART_GENERAL_NOTES parameters:params];
  2154. }
  2155. if(json==nil)
  2156. return nil;
  2157. NSError *error=nil;
  2158. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2159. return jsobj;
  2160. }
  2161. +(NSDictionary*) cart_setItemNote:(NSString*) cart_id notes:(NSString*) notes
  2162. {
  2163. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2164. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2165. if(appDelegate.user!=nil)
  2166. [params setValue:appDelegate.user forKey:@"user"];
  2167. if(appDelegate.contact_id!=nil)
  2168. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2169. if(appDelegate.password!=nil)
  2170. [params setValue:appDelegate.password forKey:@"password"];
  2171. [params setValue:cart_id forKey:@"cartitem_id"];
  2172. [params setObject:ScreenCodeCart forKey:kScreenName];
  2173. if(notes.length==0)
  2174. notes=@"";
  2175. [params setValue:notes forKey:@"notes"];
  2176. NSData* json=nil;
  2177. if(appDelegate.offline_mode)
  2178. {
  2179. json= [OLDataProvider offline_cartsetlnotes:params];
  2180. }
  2181. else
  2182. {
  2183. if(![self IsNetworkAvailable])
  2184. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2185. json=[self get_json:URL_CART_ITEM_NOTES parameters:params];
  2186. }
  2187. if(json==nil)
  2188. return nil;
  2189. NSError *error=nil;
  2190. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2191. return jsobj;
  2192. }
  2193. +(NSDictionary*) cart_setFree:(NSString*) cart_id isfree:(bool) isfree
  2194. {
  2195. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2196. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2197. if(appDelegate.user!=nil)
  2198. [params setValue:appDelegate.user forKey:@"user"];
  2199. if(appDelegate.contact_id!=nil)
  2200. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2201. if(appDelegate.password!=nil)
  2202. [params setValue:appDelegate.password forKey:@"password"];
  2203. [params setValue:cart_id forKey:@"cartitem_id"];
  2204. [params setObject:ScreenCodeCart forKey:kScreenName];
  2205. NSString* free=nil;
  2206. if(isfree)
  2207. free=@"true";
  2208. else
  2209. free=@"false";
  2210. [params setValue:free forKey:@"free_giveaway"];
  2211. if(appDelegate.offline_mode)
  2212. {
  2213. return [OLDataProvider offline_notimpl];
  2214. }
  2215. if(![self IsNetworkAvailable])
  2216. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2217. NSData* json=[self get_json:URL_CART_SET_PRICE parameters:params];
  2218. if(json==nil)
  2219. return nil;
  2220. NSError *error=nil;
  2221. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2222. return jsobj;
  2223. }
  2224. +(NSDictionary*) cart_setQTY:(NSString*) cart_id value:(int) value
  2225. {
  2226. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2227. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2228. if(appDelegate.user!=nil)
  2229. [params setValue:appDelegate.user forKey:@"user"];
  2230. if(appDelegate.contact_id!=nil)
  2231. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2232. if(appDelegate.password!=nil)
  2233. [params setValue:appDelegate.password forKey:@"password"];
  2234. [params setValue:cart_id forKey:@"cartitem_id"];
  2235. [params setObject:ScreenCodeCart forKey:kScreenName];
  2236. [params setValue:[NSString stringWithFormat:@"%d",value] forKey:@"inputInt"];
  2237. NSData* json=nil;
  2238. if(appDelegate.offline_mode)
  2239. {
  2240. json= [OLDataProvider offline_cartsetqty:params];
  2241. }
  2242. else
  2243. {
  2244. if(![self IsNetworkAvailable])
  2245. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2246. json=[self get_json:URL_CART_INCRESEMENT parameters:params];
  2247. }
  2248. if(json==nil)
  2249. return nil;
  2250. NSError *error=nil;
  2251. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2252. return jsobj;
  2253. }
  2254. +(NSDictionary*) cart_incresement:(NSString*) cart_id increse:(bool) increse
  2255. {
  2256. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2257. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2258. if(appDelegate.user!=nil)
  2259. [params setValue:appDelegate.user forKey:@"user"];
  2260. if(appDelegate.contact_id!=nil)
  2261. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2262. if(appDelegate.password!=nil)
  2263. [params setValue:appDelegate.password forKey:@"password"];
  2264. [params setValue:cart_id forKey:@"cartitem_id"];
  2265. if(increse)
  2266. [params setValue:@"1" forKey:@"incrementType"];
  2267. else
  2268. [params setValue:@"0" forKey:@"incrementType"];
  2269. if(appDelegate.offline_mode)
  2270. {
  2271. return [OLDataProvider offline_notimpl];
  2272. }
  2273. if(![self IsNetworkAvailable])
  2274. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2275. NSData* json=[self get_json:URL_CART_INCRESEMENT parameters:params];
  2276. if(json==nil)
  2277. return nil;
  2278. NSError *error=nil;
  2279. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2280. return jsobj;
  2281. }
  2282. +(NSDictionary*) finish_download_Offline:(NSString* )vid
  2283. {
  2284. if(![self IsNetworkAvailable])
  2285. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2286. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2287. [params setObject:ScreenCodeOfflineSetting forKey:kScreenName];
  2288. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2289. // if(appDelegate.user!=nil)
  2290. // [params setValue:appDelegate.user forKey:@"user"];
  2291. // // if(appDelegate.contact_id!=nil)
  2292. // // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2293. // if(appDelegate.password!=nil)
  2294. // [params setValue:appDelegate.password forKey:@"password"];
  2295. [params setValue:vid forKey:@"downSerial"];
  2296. NSData* json=[self get_json:URL_FINISH_DOWNLOAD_OFFLINE parameters:params];
  2297. if(json==nil)
  2298. return nil;
  2299. NSError *error=nil;
  2300. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2301. // int result = [[jsobj valueForKey:@"result"] intValue];
  2302. //
  2303. // if (result==2)
  2304. // {
  2305. //
  2306. //// appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  2307. //// //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  2308. //// // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  2309. ////
  2310. //// [appDelegate update_count_mark];
  2311. // }
  2312. return jsobj;
  2313. }
  2314. +(NSDictionary*) download_Offline:(NSString* )vid
  2315. {
  2316. if(![self IsNetworkAvailable])
  2317. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2318. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2319. [params setObject:ScreenCodeOfflineSync forKey:kScreenName];
  2320. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2321. // if(appDelegate.user!=nil)
  2322. // [params setValue:appDelegate.user forKey:@"user"];
  2323. // // if(appDelegate.contact_id!=nil)
  2324. // // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2325. // if(appDelegate.password!=nil)
  2326. // [params setValue:appDelegate.password forKey:@"password"];
  2327. [params setValue:vid forKey:@"downSerial"];
  2328. NSData* json=[self get_json:URL_DOWNLOAD_OFFLINE parameters:params];
  2329. if(json==nil)
  2330. return nil;
  2331. NSError *error=nil;
  2332. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2333. // int result = [[jsobj valueForKey:@"result"] intValue];
  2334. //
  2335. // if (result==2)
  2336. // {
  2337. //
  2338. //// appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  2339. //// //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  2340. //// // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  2341. ////
  2342. //// [appDelegate update_count_mark];
  2343. // }
  2344. return jsobj;
  2345. }
  2346. +(NSDictionary*) check_Offline:(NSString* )ver useInternalAddress:(bool)buseinternaladdress vid:(NSString*)vid
  2347. {
  2348. if(![self IsNetworkAvailable])
  2349. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2350. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2351. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2352. if(appDelegate.user!=nil)
  2353. [params setValue:appDelegate.user forKey:@"user"];
  2354. // if(appDelegate.contact_id!=nil)
  2355. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2356. if(appDelegate.password!=nil)
  2357. [params setValue:appDelegate.password forKey:@"password"];
  2358. [params setValue:ver forKey:@"ver"];
  2359. [params setValue:vid forKey:@"vid"];
  2360. if(buseinternaladdress)
  2361. [params setValue:@"true" forKey:@"internal_address"];
  2362. else
  2363. [params setValue:@"false" forKey:@"internal_address"];
  2364. [params setObject:ScreenCodeOfflineSync forKey:kScreenName];
  2365. NSData* json=[self get_json:URL_CHECK_OFFLINE parameters:params];
  2366. if(json==nil)
  2367. return nil;
  2368. NSError *error=nil;
  2369. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2370. // int result = [[jsobj valueForKey:@"result"] intValue];
  2371. //
  2372. // if (result==2)
  2373. // {
  2374. //
  2375. //// appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  2376. //// //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  2377. //// // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  2378. ////
  2379. //// [appDelegate update_count_mark];
  2380. // }
  2381. return jsobj;
  2382. }
  2383. +(NSDictionary*)request_Cart:(int)sort
  2384. {
  2385. DebugLog(@"iSalesNetwork::request_Cart");
  2386. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2387. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2388. if(appDelegate.user!=nil)
  2389. [params setValue:appDelegate.user forKey:@"user"];
  2390. // if(appDelegate.contact_id!=nil)
  2391. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2392. if(appDelegate.password!=nil)
  2393. [params setValue:appDelegate.password forKey:@"password"];
  2394. if(appDelegate.order_code!=nil)
  2395. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2396. [params setValue:[NSNumber numberWithInt:sort] forKey:@"sort"];
  2397. [params setObject:ScreenCodeCart forKey:kScreenName];
  2398. NSData* json=nil;
  2399. if(appDelegate.offline_mode)
  2400. {
  2401. json= [OLDataProvider offline_requestcart:params];
  2402. }
  2403. else
  2404. {
  2405. if(![self IsNetworkAvailable])
  2406. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2407. NSError *error=nil;
  2408. NSString * uuid= [[NSUUID UUID] UUIDString];
  2409. params[@"resultSerial"]=uuid;
  2410. for(int i=0;i<150;i++)
  2411. {
  2412. // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
  2413. // result_params[@"resultSerial"]=uuid;
  2414. json=[self get_json:URL_CART parameters:params];
  2415. if(json!=nil)
  2416. {
  2417. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2418. if([jsobj[@"result"] intValue]==2)
  2419. {
  2420. break;
  2421. }
  2422. }
  2423. sleep(2);
  2424. }
  2425. }
  2426. if(json==nil)
  2427. return nil;
  2428. NSError *error=nil;
  2429. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2430. int result = [[jsobj valueForKey:@"result"] intValue];
  2431. if (result==2)
  2432. {
  2433. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  2434. //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  2435. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  2436. [appDelegate update_count_mark];
  2437. }
  2438. return jsobj;
  2439. }
  2440. +(NSDictionary*)request_Portfolio:(int)sort
  2441. {
  2442. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2443. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2444. if(appDelegate.user!=nil)
  2445. [params setValue:appDelegate.user forKey:@"user"];
  2446. if(appDelegate.contact_id!=nil)
  2447. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2448. if(appDelegate.password!=nil)
  2449. [params setValue:appDelegate.password forKey:@"password"];
  2450. [params setValue:[NSString stringWithFormat:@"%d",0 ] forKey:@"offset"];
  2451. [params setValue:[NSString stringWithFormat:@"%d",INT_MAX ] forKey:@"limit"];
  2452. [params setValue:[NSNumber numberWithInt:sort] forKey:@"sort"];
  2453. [params setObject:ScreenCodePortfolio forKey:kScreenName];
  2454. NSData* json = nil;
  2455. if(appDelegate.offline_mode)
  2456. {
  2457. json = [OLDataProvider offline_portfolioList:params];
  2458. } else {
  2459. if(![self IsNetworkAvailable])
  2460. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2461. json = [self get_json:URL_PORTFOLIO parameters:params];
  2462. }
  2463. if(json==nil)
  2464. return nil;
  2465. NSError *error=nil;
  2466. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2467. int result = [[jsobj valueForKey:@"result"] intValue];
  2468. if (result==2)
  2469. {
  2470. // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  2471. //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  2472. appDelegate.port_count =[[jsobj valueForKey:@"count"] intValue];
  2473. [appDelegate update_count_mark];
  2474. }
  2475. return jsobj;
  2476. }
  2477. +(NSDictionary*)request_WatchList:(int)sort
  2478. {
  2479. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2480. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2481. if(appDelegate.user!=nil)
  2482. [params setValue:appDelegate.user forKey:@"user"];
  2483. if(appDelegate.contact_id!=nil)
  2484. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2485. if(appDelegate.password!=nil)
  2486. [params setValue:appDelegate.password forKey:@"password"];
  2487. [params setValue:[NSString stringWithFormat:@"%d",0 ] forKey:@"offset"];
  2488. [params setValue:[NSString stringWithFormat:@"%d",INT_MAX ] forKey:@"limit"];
  2489. [params setValue:[NSNumber numberWithInt:sort] forKey:@"sort"];
  2490. [params setObject:ScreenCodeWishList forKey:kScreenName];
  2491. if(appDelegate.offline_mode)
  2492. {
  2493. return [OLDataProvider offline_wishlist:params];
  2494. }
  2495. if(![self IsNetworkAvailable])
  2496. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2497. NSData* json=[self get_json:URL_WATCHLIST parameters:params];
  2498. if(json==nil)
  2499. return nil;
  2500. NSError *error=nil;
  2501. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2502. int result = [[jsobj valueForKey:@"result"] intValue];
  2503. if (result==2)
  2504. {
  2505. // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  2506. appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  2507. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  2508. [appDelegate update_count_mark];
  2509. }
  2510. return jsobj;
  2511. }
  2512. +(NSDictionary*)request_ItemDetail: (NSString* ) item_id model_name:(NSString*) model_name category_id:(NSString*) category_id use_name :(bool) use_name
  2513. {
  2514. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2515. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2516. if(appDelegate.user!=nil)
  2517. [params setValue:appDelegate.user forKey:@"user"];
  2518. if(appDelegate.contact_id!=nil)
  2519. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2520. if(appDelegate.password!=nil)
  2521. [params setValue:appDelegate.password forKey:@"password"];
  2522. if(appDelegate.order_code!=nil)
  2523. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2524. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  2525. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  2526. if(use_name)
  2527. [params setValue:model_name forKey:@"product_name"];
  2528. else
  2529. [params setValue:item_id forKey:@"product_id"];
  2530. [params setValue:category_id forKey:@"category"];
  2531. [params setObject:ScreenCodeModelInfo forKey:kScreenName];
  2532. [params setObject:@"Open A Model" forKey:kAction];
  2533. if (model_name) {
  2534. NSDictionary *extra = @{@"ModelName" : model_name};
  2535. [params setObject:extra forKey:kExtra];
  2536. }
  2537. if(appDelegate.offline_mode)
  2538. return [OLDataProvider offline_model:params];
  2539. if(![self IsNetworkAvailable])
  2540. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2541. NSData* json=[self get_json:URL_ITEM_DETAIL parameters:params];
  2542. if(json==nil)
  2543. return nil;
  2544. NSError *error=nil;
  2545. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2546. return jsobj;
  2547. }
  2548. //+(NSDictionary*)category_LoadMore: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(int)offset
  2549. //{
  2550. // if(![self IsNetworkAvailable])
  2551. // return nil;
  2552. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2553. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2554. // if(appDelegate.user!=nil)
  2555. // [params setValue:appDelegate.user forKey:@"user"];
  2556. // if(appDelegate.contact_id!=nil)
  2557. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2558. // if(appDelegate.password!=nil)
  2559. // [params setValue:appDelegate.password forKey:@"password"];
  2560. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  2561. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  2562. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  2563. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2564. // [params setValue:[NSString stringWithFormat:@"%d",offset] forKey:@"offset"];
  2565. // [params setValue:filter forKey:@"filter"];
  2566. // [params setValue:keyword forKey:@"keyword"];
  2567. //
  2568. //
  2569. // NSData* json=[self get_json:URL_CATEGORY_LOADMORE parameters:params];
  2570. // if(json==nil)
  2571. // return nil;
  2572. // NSError *error=nil;
  2573. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2574. // return jsobj;
  2575. //
  2576. //}
  2577. +(NSDictionary*)Category_addall: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip orderCode:(NSString*) orderCode addTo:(NSString*) addTo
  2578. {
  2579. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2580. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2581. if(appDelegate.user!=nil)
  2582. [params setValue:appDelegate.user forKey:@"user"];
  2583. if(appDelegate.contact_id!=nil)
  2584. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2585. if(appDelegate.password!=nil)
  2586. [params setValue:appDelegate.password forKey:@"password"];
  2587. if(appDelegate.order_code!=nil)
  2588. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2589. [params setValue:addTo forKey:@"addTo"];
  2590. [params setValue:orderCode forKey:@"orderCode"];
  2591. [params setValue:alert forKey:@"alert"];
  2592. [params setValue:qty forKey:@"sold_by_qty"];
  2593. [params setValue:available forKey:@"available"];
  2594. [params setValue:price forKey:@"price"];
  2595. [params setValue:bestseller forKey:@"bestseller"];
  2596. [params setValue:modelname forKey:@"modelName"];
  2597. [params setValue:modeldescrip forKey:@"modelDescription"];
  2598. [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  2599. [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  2600. [params setValue:category forKey:@"category"];
  2601. [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2602. [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2603. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  2604. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  2605. [params setValue:filter forKey:@"filter"];
  2606. [params setValue:keyword forKey:@"keyword"];
  2607. [params setObject:ScreenCodeCategory forKey:kScreenName];
  2608. if ([addTo isEqualToString:@"cart"]) {
  2609. [params setObject:@"Add To Cart" forKey:kAction];
  2610. }
  2611. NSData* json= nil;
  2612. if(appDelegate.offline_mode)
  2613. {
  2614. json= [OLDataProvider offline_categoryaddall:params];
  2615. }
  2616. else
  2617. {
  2618. if(![self IsNetworkAvailable])
  2619. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2620. NSError *error=nil;
  2621. NSString * uuid= [[NSUUID UUID] UUIDString];
  2622. params[@"resultSerial"]=uuid;
  2623. for(int i=0;i<150;i++)
  2624. {
  2625. // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
  2626. // result_params[@"resultSerial"]=uuid;
  2627. json=[self get_json:URL_CATEGORYADDALL parameters:params];
  2628. if(json!=nil)
  2629. {
  2630. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2631. int resultInt = [jsobj[@"result"] intValue];
  2632. if(resultInt == 2 || resultInt == 8)
  2633. {
  2634. break;
  2635. }
  2636. }
  2637. sleep(2);
  2638. }
  2639. }
  2640. if(json==nil)
  2641. return nil;
  2642. NSError *error=nil;
  2643. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2644. return jsobj;
  2645. }
  2646. //+(NSDictionary*)category_addall2portfolio: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip
  2647. //{
  2648. //
  2649. //
  2650. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2651. //
  2652. //
  2653. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2654. //
  2655. // if(appDelegate.user!=nil)
  2656. // [params setValue:appDelegate.user forKey:@"user"];
  2657. // if(appDelegate.contact_id!=nil)
  2658. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2659. // if(appDelegate.password!=nil)
  2660. // [params setValue:appDelegate.password forKey:@"password"];
  2661. // if(appDelegate.order_code!=nil)
  2662. // [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2663. //
  2664. // [params setValue:alert forKey:@"alert"];
  2665. // [params setValue:qty forKey:@"sold_by_qty"];
  2666. // [params setValue:available forKey:@"available"];
  2667. // [params setValue:price forKey:@"price"];
  2668. // [params setValue:bestseller forKey:@"bestseller"];
  2669. // [params setValue:modelname forKey:@"modelName"];
  2670. // [params setValue:modeldescrip forKey:@"modelDescription"];
  2671. //
  2672. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  2673. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  2674. // [params setValue:category forKey:@"category"];
  2675. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2676. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2677. // [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  2678. // [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  2679. // [params setValue:filter forKey:@"filter"];
  2680. // [params setValue:keyword forKey:@"keyword"];
  2681. //
  2682. //
  2683. //
  2684. // if(appDelegate.offline_mode)
  2685. // return [OLDataProvider offline_category:params];
  2686. // if(![self IsNetworkAvailable])
  2687. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2688. //
  2689. // NSData* json=[self get_json:URL_ADDALL2PORTFOLIO parameters:params];
  2690. // if(json==nil)
  2691. // return nil;
  2692. // NSError *error=nil;
  2693. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2694. // return jsobj;
  2695. //
  2696. //}
  2697. //+(NSDictionary*)category_addall2wish: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip
  2698. //{
  2699. //
  2700. //
  2701. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2702. //
  2703. //
  2704. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2705. //
  2706. // if(appDelegate.user!=nil)
  2707. // [params setValue:appDelegate.user forKey:@"user"];
  2708. // if(appDelegate.contact_id!=nil)
  2709. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2710. // if(appDelegate.password!=nil)
  2711. // [params setValue:appDelegate.password forKey:@"password"];
  2712. // if(appDelegate.order_code!=nil)
  2713. // [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2714. //
  2715. // [params setValue:alert forKey:@"alert"];
  2716. // [params setValue:qty forKey:@"sold_by_qty"];
  2717. // [params setValue:available forKey:@"available"];
  2718. // [params setValue:price forKey:@"price"];
  2719. // [params setValue:bestseller forKey:@"bestseller"];
  2720. // [params setValue:modelname forKey:@"modelName"];
  2721. // [params setValue:modeldescrip forKey:@"modelDescription"];
  2722. //
  2723. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  2724. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  2725. // [params setValue:category forKey:@"category"];
  2726. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2727. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2728. // [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  2729. // [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  2730. // [params setValue:filter forKey:@"filter"];
  2731. // [params setValue:keyword forKey:@"keyword"];
  2732. //
  2733. //
  2734. //
  2735. // if(appDelegate.offline_mode)
  2736. // return [OLDataProvider offline_category:params];
  2737. // if(![self IsNetworkAvailable])
  2738. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2739. //
  2740. // NSData* json=[self get_json:URL_ADDALL2WISH parameters:params];
  2741. // if(json==nil)
  2742. // return nil;
  2743. // NSError *error=nil;
  2744. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2745. // return jsobj;
  2746. //
  2747. //}
  2748. +(NSDictionary*)Category: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip
  2749. {
  2750. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2751. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2752. if(appDelegate.user!=nil)
  2753. [params setValue:appDelegate.user forKey:@"user"];
  2754. if(appDelegate.contact_id!=nil)
  2755. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2756. if(appDelegate.password!=nil)
  2757. [params setValue:appDelegate.password forKey:@"password"];
  2758. if(appDelegate.order_code!=nil)
  2759. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2760. [params setValue:alert forKey:@"alert"];
  2761. [params setValue:qty forKey:@"sold_by_qty"];
  2762. [params setValue:available forKey:@"available"];
  2763. [params setValue:price forKey:@"price"];
  2764. [params setValue:bestseller forKey:@"bestseller"];
  2765. [params setValue:modelname forKey:@"modelName"];
  2766. [params setValue:modeldescrip forKey:@"modelDescription"];
  2767. [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  2768. [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  2769. [params setValue:category forKey:@"category"];
  2770. [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2771. [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2772. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  2773. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  2774. [params setValue:filter forKey:@"filter"];
  2775. [params setValue:keyword forKey:@"keyword"];
  2776. [params setObject:ScreenCodeCategory forKey:kScreenName];
  2777. if (alert) {
  2778. [params setObject:@"Filter" forKey:kAction];
  2779. }
  2780. if ([Singleton sharedInstance].homeItemClick) {
  2781. [params setObject:@"Brow A Particular Category On Home" forKey:kAction];
  2782. [Singleton sharedInstance].homeItemClick = NO;
  2783. NSDictionary *extra = @{@"CoverName" : [Singleton sharedInstance].homeClickedItemName};
  2784. [Singleton sharedInstance].homeClickedItemName = nil;
  2785. [params setObject:extra forKey:kExtra];
  2786. }
  2787. if(appDelegate.offline_mode)
  2788. return [OLDataProvider offline_category:params];
  2789. if(![self IsNetworkAvailable])
  2790. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2791. NSData* json=[self get_json:URL_CATEGORY parameters:params];
  2792. if(json==nil)
  2793. return nil;
  2794. NSError *error=nil;
  2795. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2796. return jsobj;
  2797. }
  2798. +(NSDictionary*)Search_addall:(long ) offset limit :(long)limit keywords :(NSString*) keywords matchfull:(bool)matchfull orderCode:(NSString*) orderCode addTo:(NSString*) addTo
  2799. {
  2800. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2801. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2802. if(appDelegate.user!=nil)
  2803. [params setValue:appDelegate.user forKey:@"user"];
  2804. if(appDelegate.contact_id!=nil)
  2805. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2806. if(appDelegate.password!=nil)
  2807. [params setValue:appDelegate.password forKey:@"password"];
  2808. if(appDelegate.order_code!=nil)
  2809. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2810. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  2811. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  2812. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  2813. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2814. // [params setValue:filter forKey:@"filter"];
  2815. [params setValue:keywords forKey:@"keyword"];
  2816. [params setValue:addTo forKey:@"addTo"];
  2817. [params setValue:orderCode forKey:@"orderCode"];
  2818. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  2819. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  2820. if(matchfull)
  2821. [params setValue:@"true" forKey:@"exactMatch"];
  2822. else
  2823. [params setValue:@"false" forKey:@"exactMatch"];
  2824. [params setObject:ScreenCodeSearch forKey:kScreenName];
  2825. if ([addTo isEqualToString:@"cart"]) {
  2826. [params setObject:@"Add To Cart" forKey:kAction];
  2827. }
  2828. NSData* json=nil;
  2829. if(appDelegate.offline_mode)
  2830. {
  2831. json=[OLDataProvider offline_searchaddall:params];
  2832. }
  2833. else
  2834. {
  2835. if(![self IsNetworkAvailable])
  2836. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2837. NSError *error=nil;
  2838. NSString * uuid= [[NSUUID UUID] UUIDString];
  2839. params[@"resultSerial"]=uuid;
  2840. for(int i=0;i<150;i++)
  2841. {
  2842. // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
  2843. // result_params[@"resultSerial"]=uuid;
  2844. json=[self get_json:URL_SEARCHADDALL parameters:params];
  2845. if(json!=nil)
  2846. {
  2847. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2848. if([jsobj[@"result"] intValue]==2)
  2849. {
  2850. break;
  2851. }
  2852. }
  2853. sleep(2);
  2854. }
  2855. }
  2856. if(json==nil)
  2857. return nil;
  2858. NSError *error=nil;
  2859. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2860. return jsobj;
  2861. }
  2862. +(NSDictionary*)Search:(long ) offset limit :(long)limit keywords :(NSString*) keywords matchfull:(bool)matchfull
  2863. {
  2864. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2865. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2866. if(appDelegate.user!=nil)
  2867. [params setValue:appDelegate.user forKey:@"user"];
  2868. if(appDelegate.contact_id!=nil)
  2869. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2870. if(appDelegate.password!=nil)
  2871. [params setValue:appDelegate.password forKey:@"password"];
  2872. if(appDelegate.order_code!=nil)
  2873. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2874. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  2875. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  2876. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  2877. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2878. // [params setValue:filter forKey:@"filter"];
  2879. [params setValue:keywords forKey:@"keyword"];
  2880. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  2881. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  2882. if(matchfull)
  2883. [params setValue:@"true" forKey:@"exactMatch"];
  2884. else
  2885. [params setValue:@"false" forKey:@"exactMatch"];
  2886. [params setObject:ScreenCodeSearch forKey:kScreenName];
  2887. if (keywords) {
  2888. [params setObject:@"Search" forKey:kAction];
  2889. }
  2890. if(appDelegate.offline_mode)
  2891. {
  2892. return [OLDataProvider offline_search:params];
  2893. }
  2894. if(![self IsNetworkAvailable])
  2895. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2896. NSData* json=[self get_json:URL_SEARCH parameters:params];
  2897. if(json==nil)
  2898. return nil;
  2899. NSError *error=nil;
  2900. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2901. return jsobj;
  2902. }
  2903. +(NSDictionary*)ItemSearch_addall:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller orderCode:(NSString*) orderCode addTo:(NSString*) addTo
  2904. {
  2905. // for debug
  2906. // return [RAUtils error_json:RESULT_NET_ERROR err_msg:nil];
  2907. //return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2908. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2909. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2910. if(appDelegate.user!=nil)
  2911. [params setValue:appDelegate.user forKey:@"user"];
  2912. if(appDelegate.contact_id!=nil)
  2913. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2914. if(appDelegate.password!=nil)
  2915. [params setValue:appDelegate.password forKey:@"password"];
  2916. if(appDelegate.order_code!=nil)
  2917. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2918. [params setValue:addTo forKey:@"addTo"];
  2919. [params setValue:orderCode forKey:@"orderCode"];
  2920. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  2921. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  2922. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  2923. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  2924. // [params setValue:filter forKey:@"filter"];
  2925. [params setValue:covertype forKey:@"covertype"];
  2926. [params setValue:ctgid forKey:@"ctgId"];
  2927. [params setValue:modelname forKey:@"modelName"];
  2928. [params setValue:modeldescrip forKey:@"modelDescription"];
  2929. [params setValue:alert forKey:@"alert"];
  2930. [params setValue:qty forKey:@"sold_by_qty"];
  2931. [params setValue:available forKey:@"available"];
  2932. [params setValue:price forKey:@"price"];
  2933. [params setValue:bestseller forKey:@"bestseller"];
  2934. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  2935. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  2936. [params setObject:ScreenCodeParticularCategory forKey:kScreenName];
  2937. if ([addTo isEqualToString:@"cart"]) {
  2938. [params setObject:@"Add To Cart" forKey:kAction];
  2939. }
  2940. NSData* json = nil;
  2941. if(appDelegate.offline_mode)
  2942. {
  2943. json= [OLDataProvider offline_itemsearchaddall:params];
  2944. }
  2945. else
  2946. {
  2947. if(![self IsNetworkAvailable])
  2948. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2949. NSError *error=nil;
  2950. NSString * uuid= [[NSUUID UUID] UUIDString];
  2951. params[@"resultSerial"]=uuid;
  2952. for(int i=0;i<150;i++)
  2953. {
  2954. // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
  2955. // result_params[@"resultSerial"]=uuid;
  2956. json=[self get_json:URL_ITEMSEARCHADDALL parameters:params];
  2957. if(json!=nil)
  2958. {
  2959. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2960. if([jsobj[@"result"] intValue]==2)
  2961. {
  2962. break;
  2963. }
  2964. }
  2965. sleep(2);
  2966. }
  2967. }
  2968. if(json==nil)
  2969. return nil;
  2970. NSError *error=nil;
  2971. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  2972. return jsobj;
  2973. }
  2974. +(NSDictionary*)ItemSearch:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller
  2975. {
  2976. // for debug
  2977. // return [RAUtils error_json:RESULT_NET_ERROR err_msg:nil];
  2978. //return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  2979. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  2980. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2981. if(appDelegate.user!=nil)
  2982. [params setValue:appDelegate.user forKey:@"user"];
  2983. if(appDelegate.contact_id!=nil)
  2984. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  2985. if(appDelegate.password!=nil)
  2986. [params setValue:appDelegate.password forKey:@"password"];
  2987. if(appDelegate.order_code!=nil)
  2988. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  2989. [params setObject:ScreenCodeParticularCategory forKey:kScreenName];
  2990. if (alert && qty && available && price && bestseller) {
  2991. [params setObject:@"Filter" forKey:kAction];
  2992. }
  2993. if ([Singleton sharedInstance].homeItemClick) {
  2994. [params setObject:@"Brow A Particular Category On Home" forKey:kAction];
  2995. [Singleton sharedInstance].homeItemClick = NO;
  2996. NSDictionary *extra = @{@"CoverName" : [Singleton sharedInstance].homeClickedItemName};
  2997. [Singleton sharedInstance].homeClickedItemName = nil;
  2998. [params setObject:extra forKey:kExtra];
  2999. }
  3000. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  3001. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  3002. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  3003. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  3004. // [params setValue:filter forKey:@"filter"];
  3005. [params setValue:covertype forKey:@"covertype"];
  3006. [params setValue:ctgid forKey:@"ctgId"];
  3007. [params setValue:modelname forKey:@"modelName"];
  3008. [params setValue:modeldescrip forKey:@"modelDescription"];
  3009. [params setValue:alert forKey:@"alert"];
  3010. [params setValue:qty forKey:@"sold_by_qty"];
  3011. [params setValue:available forKey:@"available"];
  3012. [params setValue:price forKey:@"price"];
  3013. [params setValue:bestseller forKey:@"bestseller"];
  3014. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  3015. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  3016. if(appDelegate.offline_mode)
  3017. {
  3018. return [OLDataProvider offline_itemsearch:params];
  3019. }
  3020. if(![self IsNetworkAvailable])
  3021. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3022. NSData* json=[self get_json:URL_ITEM_SEARCH parameters:params];
  3023. if(json==nil)
  3024. return nil;
  3025. NSError *error=nil;
  3026. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3027. return jsobj;
  3028. }
  3029. //+(NSDictionary*)Search: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword
  3030. //{
  3031. // if(![self IsNetworkAvailable])
  3032. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3033. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3034. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3035. // if(appDelegate.user!=nil)
  3036. // [params setValue:appDelegate.user forKey:@"user"];
  3037. // if(appDelegate.contact_id!=nil)
  3038. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  3039. // if(appDelegate.password!=nil)
  3040. // [params setValue:appDelegate.password forKey:@"password"];
  3041. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  3042. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  3043. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  3044. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  3045. // [params setValue:filter forKey:@"filter"];
  3046. // [params setValue:keyword forKey:@"keyword"];
  3047. //
  3048. //
  3049. // NSData* json=[self get_json:URL_SEARCH parameters:params];
  3050. // if(json==nil)
  3051. // return nil;
  3052. // NSError *error=nil;
  3053. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3054. // return jsobj;
  3055. //}
  3056. +(NSDictionary*)request_model_qty: (NSString*) fashionId
  3057. {
  3058. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3059. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3060. if(appDelegate.user!=nil)
  3061. [params setValue:appDelegate.user forKey:@"user"];
  3062. if(appDelegate.contact_id!=nil)
  3063. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  3064. if(appDelegate.password!=nil)
  3065. [params setValue:appDelegate.password forKey:@"password"];
  3066. [params setValue:fashionId forKey:@"fashionId"];
  3067. [params setObject:ScreenCodeEditPortfolio forKey:kScreenName];
  3068. NSData* json = nil;
  3069. if(appDelegate.offline_mode)
  3070. {
  3071. json = [OLDataProvider offline_model_qty:params];
  3072. } else {
  3073. if(![self IsNetworkAvailable])
  3074. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3075. json=[self get_json:URL_REQUEST_MODEL_QTY parameters:params];
  3076. }
  3077. if(json==nil)
  3078. return nil;
  3079. NSError *error=nil;
  3080. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3081. return jsobj;
  3082. }
  3083. +(NSDictionary*)retrieve_password: (NSString*) user email:(NSString*) email
  3084. {
  3085. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3086. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3087. // if(appDelegate.user!=nil)
  3088. // [params setValue:appDelegate.user forKey:@"user"];
  3089. // if(appDelegate.contact_id!=nil)
  3090. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  3091. // if(appDelegate.password!=nil)
  3092. // [params setValue:appDelegate.password forKey:@"password"];
  3093. [params setValue:user forKey:@"username"];
  3094. [params setValue:email forKey:@"email"];
  3095. [params setObject:ScreenCodeLoginView forKey:kScreenName];
  3096. if(![self IsNetworkAvailable])
  3097. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3098. NSData* json=[self get_json:URL_RETRIEVE_PASS parameters:params];
  3099. if(json==nil)
  3100. return nil;
  3101. NSError *error=nil;
  3102. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3103. return jsobj;
  3104. }
  3105. +(NSDictionary*)load_HomePage:(int) price_template customid:(int) customid
  3106. {
  3107. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3108. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3109. if(appDelegate.user!=nil)
  3110. [params setValue:appDelegate.user forKey:@"user"];
  3111. if(appDelegate.contact_id!=nil)
  3112. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  3113. if(appDelegate.password!=nil)
  3114. [params setValue:appDelegate.password forKey:@"password"];
  3115. [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  3116. [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  3117. [params setObject:ScreenCodeHomeView forKey:kScreenName];
  3118. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3119. if(appDelegate.offline_mode)
  3120. {
  3121. //params[@"offline_Command"]=url;
  3122. return [OLDataProvider offline_home];
  3123. }
  3124. if(![self IsNetworkAvailable])
  3125. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3126. NSData* json=[self get_json:URL_LOAD_HOME parameters:params];
  3127. if(json==nil)
  3128. return nil;
  3129. NSError *error=nil;
  3130. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3131. return jsobj;
  3132. }
  3133. +(NSDictionary*)logout
  3134. {
  3135. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3136. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3137. if(appDelegate.user!=nil)
  3138. [params setValue:appDelegate.user forKey:@"user"];
  3139. if(appDelegate.password!=nil)
  3140. [params setValue:appDelegate.password forKey:@"password"];
  3141. if(appDelegate.offline_mode)
  3142. {
  3143. return [OLDataProvider offline_logout:params];
  3144. }
  3145. if(![self IsNetworkAvailable])
  3146. {
  3147. DebugLog(@"NET ERR");
  3148. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3149. // return nil;
  3150. }
  3151. NSData* json=[self get_json:URL_LOGOUT parameters:params];
  3152. //if(json==nil)
  3153. if(json==nil)
  3154. return nil;
  3155. NSError *error=nil;
  3156. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3157. int result = [[jsobj valueForKey:@"result"] intValue];
  3158. if (result==2)
  3159. {
  3160. appDelegate.cart_count = 0;//[[jsobj valueForKey:@"cart_count"] intValue];
  3161. appDelegate.wish_count =0;//[[jsobj valueForKey:@"wish_count"] intValue];
  3162. appDelegate.port_count =0;//[[jsobj valueForKey:@"portfolio_count"] intValue];
  3163. [appDelegate update_count_mark];
  3164. appDelegate.can_show_price =false;
  3165. appDelegate.can_see_price =false;
  3166. appDelegate.can_create_portfolio =false;
  3167. appDelegate.can_create_order =false;
  3168. appDelegate.can_cancel_order =false;
  3169. appDelegate.can_set_cart_price =false;
  3170. appDelegate.can_delete_order =false;
  3171. appDelegate.can_submit_order =false;
  3172. appDelegate.can_set_tearsheet_price =false;
  3173. appDelegate.can_update_contact_info = false;
  3174. appDelegate.save_order_logout = false;
  3175. appDelegate.submit_order_logout = false;
  3176. appDelegate.alert_sold_in_quantities = false;
  3177. appDelegate.ipad_perm =nil ;
  3178. appDelegate.user_type = USER_ROLE_UNKNOWN;
  3179. appDelegate.OrderFilter= nil;
  3180. [appDelegate SetSo:nil];
  3181. [appDelegate set_main_button_panel];
  3182. }
  3183. return jsobj;
  3184. }
  3185. +(NSDictionary*)request_Cagegory
  3186. {
  3187. // DebugLog(@"@@@@@@@@@@@@@@@@@@@LOADING CATEGORY MENU");
  3188. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3189. if(appDelegate.offline_mode)
  3190. {
  3191. //params[@"offline_Command"]=url;
  3192. return [OLDataProvider offline_category_menu];
  3193. }
  3194. if(![self IsNetworkAvailable])
  3195. {
  3196. DebugLog(@"NET ERR");
  3197. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3198. // return nil;
  3199. }
  3200. NSData* json=[self get_json:URL_REQUEST_CATMENU parameters:nil];
  3201. //if(json==nil)
  3202. if(json==nil)
  3203. return nil;
  3204. NSError *error=nil;
  3205. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3206. return jsobj;
  3207. }
  3208. +(int)Authorize : (NSString*) user password:(NSString*) password{
  3209. // if(![ApexMobileNetwork IsHostAvailable:URL_UPDATE_AUTH])
  3210. // return RESULT_NET_ERROR;
  3211. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  3212. long ver =[defaults integerForKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
  3213. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3214. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3215. if(appDelegate.duid !=nil)
  3216. [params setValue:appDelegate.duid forKey:@"udid"];
  3217. [params setValue:@"handset_login" forKey:@"action"];
  3218. // [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
  3219. [params setValue:user forKey:@"user"];
  3220. [params setValue:password forKey:@"password"];
  3221. [params setValue:[NSString stringWithFormat:@"%ld",ver] forKey:@"auth_ver"];
  3222. #ifdef TEST
  3223. [params setValue:@"true" forKey:@"is_debug"];
  3224. #else
  3225. [params setValue:@"false" forKey:@"is_debug"];
  3226. #endif
  3227. [params setObject:ScreenCodeLoginView forKey:kScreenName];
  3228. [params setObject:@"Login" forKey:kAction];
  3229. NSData* json= nil;
  3230. if(appDelegate.offline_mode)
  3231. {
  3232. json= [OLDataProvider offline_login:params] ;
  3233. }
  3234. else
  3235. {
  3236. if(![self IsNetworkAvailable])
  3237. return RESULT_NET_NOTAVAILABLE;
  3238. json =[self get_json:URL_UPDATE_AUTH parameters:params];
  3239. }
  3240. if(json==nil)
  3241. return RESULT_NET_ERROR;
  3242. int ret = [self parse_authinfo:json user:user password:password];
  3243. DebugLog(@"parse_authinfo return %d ",ret);
  3244. return ret;
  3245. }
  3246. +(NSDictionary*)update_customer_img: (NSString*) contactid img_url:(NSString*) url
  3247. {
  3248. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3249. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3250. if(appDelegate.user!=nil)
  3251. [params setValue:appDelegate.user forKey:@"user"];
  3252. // if(appDelegate.contact_id!=nil)
  3253. if(appDelegate.password!=nil)
  3254. [params setValue:appDelegate.password forKey:@"password"];
  3255. [params setValue:contactid forKey:@"contactId"];
  3256. [params setValue:url forKey:@"business_card"];
  3257. // [params setValue:[NSNumber numberWithInt:index ] forKey:@"index"];
  3258. [params setObject:ScreenCodeEditCustomer forKey:kScreenName];
  3259. if(appDelegate.offline_mode)
  3260. {
  3261. return [OLDataProvider offline_notimpl];
  3262. }
  3263. if(![self IsNetworkAvailable])
  3264. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3265. NSData* json=[self get_json:URL_UPDATE_CUSTOMER_BCARD parameters:params];
  3266. if(json==nil)
  3267. return nil;
  3268. NSError *error=nil;
  3269. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3270. return jsobj;
  3271. }
  3272. +(NSDictionary*)request_PendingOrder:(NSString *)contactid
  3273. {
  3274. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3275. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3276. if(appDelegate.user!=nil)
  3277. [params setValue:appDelegate.user forKey:@"user"];
  3278. // if(appDelegate.contact_id!=nil)
  3279. if(appDelegate.password!=nil)
  3280. [params setValue:appDelegate.password forKey:@"password"];
  3281. [params setValue:contactid forKey:@"contactId"];
  3282. if(appDelegate.offline_mode)
  3283. {
  3284. return [OLDataProvider offline_notimpl];
  3285. }
  3286. if(![self IsNetworkAvailable])
  3287. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3288. NSData* json=[self get_json:URL_CUSTOMER_PENDINGORDER parameters:params];
  3289. if(json==nil)
  3290. return nil;
  3291. NSError *error=nil;
  3292. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3293. return jsobj;
  3294. }
  3295. +(NSDictionary*)request_CustomerInfo:(NSString* ) contactid
  3296. {
  3297. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3298. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3299. if(appDelegate.user!=nil)
  3300. [params setValue:appDelegate.user forKey:@"user"];
  3301. // if(appDelegate.contact_id!=nil)
  3302. if(appDelegate.password!=nil)
  3303. [params setValue:appDelegate.password forKey:@"password"];
  3304. [params setValue:contactid forKey:@"contactId"];
  3305. [params setObject:ScreenCodeCustomerInfo forKey:kScreenName];
  3306. if(appDelegate.offline_mode)
  3307. return [OLDataProvider offline_contactinfo:params];
  3308. if(![self IsNetworkAvailable])
  3309. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3310. NSData* json=[self get_json:URL_CUSTOMER_INFO parameters:params];
  3311. if(json==nil)
  3312. return nil;
  3313. NSError *error=nil;
  3314. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3315. return jsobj;
  3316. }
  3317. +(int)parse_authinfo : (NSData *) json user:(NSString*) user password:(NSString*) password
  3318. {
  3319. DebugLog(@"parse_authinfo");
  3320. NSError *error=nil;
  3321. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3322. if(jsobj)
  3323. {
  3324. UIApplication * app = [UIApplication sharedApplication];
  3325. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  3326. int result = [[jsobj valueForKey:@"result"] intValue];
  3327. if (result<0)
  3328. return result;
  3329. if(result!=AP_USER_AUTH&& result!=9)
  3330. {
  3331. DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
  3332. [appDelegate Logout];
  3333. if(result==8)
  3334. {
  3335. return RESULT_LOGIN_DEVICE;
  3336. }
  3337. return RESULT_FALSE;
  3338. }
  3339. NSDictionary* objheader = [jsobj objectForKey:@"header"];
  3340. NSString* required_ver=[jsobj objectForKey:@"min_ver"] ;
  3341. user=[objheader objectForKey:@"username"] ;
  3342. DebugLog(@"required_ver=%@ ",required_ver);
  3343. // NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
  3344. // NSString* versionNum =[infoDict valueForKey:@"CFBundleVersion"];
  3345. // versionNum = [NSString stringWithFormat:@"A%@",versionNum];
  3346. int ibadge = [[objheader valueForKey:@"badge"] intValue];
  3347. // if([ibadge isEqual:[NSNull null]])
  3348. // strbadge=@"0";
  3349. // if(ibadge==nil)
  3350. // ibadge=@"0";
  3351. // if([strbadge isEqualToString:@"null"])
  3352. // strbadge=@"0";
  3353. app.applicationIconBadgeNumber = ibadge;//[strbadge intValue];
  3354. // BOOL bigger = [appDelegate.build compare:required_ver] ;
  3355. if([appDelegate.build intValue]<[required_ver intValue])
  3356. return RESULT_VER_LOW;
  3357. // appDelegate.sessionid = [objheader valueForKey:@"sessionid"];
  3358. appDelegate.user = user;
  3359. appDelegate.password = password;
  3360. appDelegate.user_type = [[objheader valueForKey:@"user_type"] intValue];
  3361. appDelegate.user_icon =[objheader valueForKey:@"user_img"] ;
  3362. appDelegate.bLogin = true;
  3363. appDelegate.customer_type = [[objheader valueForKey:@"customer_login_type"] integerValue];
  3364. if(appDelegate.user_type==USER_ROLE_CUSTOMER)
  3365. {
  3366. appDelegate.customerInfo = [[objheader objectForKeyedSubscript:@"customerInfo"] mutableCopy];
  3367. appDelegate.contact_id = [objheader valueForKey:@"contact_id"];
  3368. // appDelegate.order_code =[objheader valueForKey:@"orderCode"];
  3369. // appDelegate.order_status =[[objheader valueForKey:@"orderStatus"] intValue];
  3370. // [appDelegate SetSo:[objheader valueForKey:@"soId"]];
  3371. }
  3372. NSString* mode =[jsobj valueForKey:@"mode"] ;
  3373. [appDelegate SetMode:mode];
  3374. appDelegate.cart_count = [[objheader valueForKey:@"cart_count"] intValue];
  3375. appDelegate.wish_count =[[objheader valueForKey:@"wish_count"] intValue];
  3376. appDelegate.port_count =[[objheader valueForKey:@"portfolio_count"] intValue];
  3377. [appDelegate update_count_mark];
  3378. appDelegate.can_show_price =[[objheader valueForKey:@"can_show_price"] boolValue];
  3379. appDelegate.can_see_price =[[objheader valueForKey:@"can_see_price"] boolValue];
  3380. appDelegate.can_create_portfolio =[[objheader valueForKey:@"can_create_portfolio"] boolValue];
  3381. appDelegate.can_create_order =[[objheader valueForKey:@"can_create_order"] boolValue];
  3382. appDelegate.can_cancel_order =[[objheader valueForKey:@"can_cancel_order"] boolValue];
  3383. appDelegate.can_set_cart_price =[[objheader valueForKey:@"can_set_cart_price"] boolValue];
  3384. appDelegate.can_delete_order =[[objheader valueForKey:@"can_delete_order"] boolValue];
  3385. appDelegate.can_update_contact_info =[[objheader valueForKey:@"can_update_contact_info"] boolValue];
  3386. appDelegate.can_submit_order =[[objheader valueForKey:@"can_submit_order"] boolValue];
  3387. appDelegate.can_set_tearsheet_price =[[objheader valueForKey:@"can_set_tearsheet_price"] boolValue];
  3388. appDelegate.save_order_logout =[[objheader valueForKey:@"save_order_logout"] boolValue];
  3389. appDelegate.submit_order_logout =[[objheader valueForKey:@"submit_order_logout"] boolValue];
  3390. appDelegate.alert_sold_in_quantities = [[objheader valueForKey:@"alert_sold_in_quantities"] boolValue];
  3391. appDelegate.can_create_backorder = [[objheader valueForKey:@"can_create_backorder"] boolValue];
  3392. appDelegate.ipad_perm =[objheader valueForKey:@"ipad_perm"] ;
  3393. NSString* strfilter = [objheader valueForKey:@"statusFilter"] ;
  3394. appDelegate.OrderFilter= [[RAConvertor string2dict:strfilter] mutableCopy];
  3395. [appDelegate set_main_button_panel];
  3396. if(appDelegate.user_type==USER_ROLE_CUSTOMER) {
  3397. // shop order status filter
  3398. NSString *shopOrderStatusFilterStr = [objheader valueForKey:@"shopOrderFilter"] ;
  3399. [Singleton sharedInstance].shop_order_status_filter = [[RAConvertor string2dict:shopOrderStatusFilterStr] mutableCopy];
  3400. // Sales order status filter
  3401. NSString *salesOrderStatusFilterStr = [objheader valueForKey:@"purchaseOrderFilter"] ;
  3402. [Singleton sharedInstance].sales_order_status_filter = [[RAConvertor string2dict:salesOrderStatusFilterStr] mutableCopy];
  3403. // specialInstruction
  3404. [Singleton sharedInstance].specialInstruction = [objheader valueForKey:@"specialInstruction"];
  3405. //-价格类型
  3406. [Singleton sharedInstance].npd_shop_price_type = [[objheader valueForKey:@"price_type"] integerValue];
  3407. // 权限
  3408. [Singleton sharedInstance].permissions_price_setting = [[objheader valueForKey:@"can_set_price_formula"] boolValue];
  3409. [Singleton sharedInstance].permissions_edit_order = [[objheader valueForKey:@"can_place_order"] boolValue];
  3410. [Singleton sharedInstance].permissions_submit_order = [[objheader valueForKey:@"can_submit_order"] boolValue];
  3411. [Singleton sharedInstance].permissions_merge_order = [[objheader valueForKey:@"can_merge_order"] boolValue];
  3412. [Singleton sharedInstance].deliveryString = [objheader valueForKey:@"delivery_price"];
  3413. [[Singleton sharedInstance] resetGlobalLock];
  3414. [Singleton sharedInstance].customer_can_see_sales_Order = [[objheader valueForKey:@"can_see_salesorder"] boolValue];
  3415. [Singleton sharedInstance].customerInfo = [objheader objectForKeyedSubscript:@"customerInfo"];
  3416. }
  3417. // DebugLog(@"sessionid=%@ ",appDelegate.sessionid);
  3418. // if ([[objheader valueForKey:@"update"] boolValue]==false)
  3419. // {
  3420. // // no update on the server;
  3421. // return RESULT_TRUE;
  3422. // }
  3423. // int Auth_InfoVer = [[objheader valueForKey:@"ver"] intValue];
  3424. // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  3425. // [defaults removeObjectForKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
  3426. // [defaults setInteger:Auth_InfoVer forKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
  3427. // [defaults synchronize];
  3428. //
  3429. // NSDictionary* objfuncs = [jsobj objectForKey:@"functions"];
  3430. // NSArray* keys= [objfuncs allKeys];
  3431. /*
  3432. db.setTransactionSuccessful();
  3433. db.endTransaction();
  3434. */
  3435. return RESULT_TRUE;
  3436. }
  3437. // NSDictionary *weatherInfo = [jsobj objectForKey:@"weatherinfo"];
  3438. // txtView.text = [NSString stringWithFormat:@"今天是 %@ %@ %@ 的天气状况是:%@ %@ ",[weatherInfo objectForKey:@"date_y"],[weatherInfo objectForKey:@"week"],[weatherInfo objectForKey:@"city"], [weatherInfo objectForKey:@"weather1"], [weatherInfo objectForKey:@"temp1"]];
  3439. // DebugLog(@"weatherInfo字典里面的内容为--》%@", weatherDic );
  3440. return RESULT_USERAUTH_ERROR;
  3441. }
  3442. +(bool) IsNetworkAvailable
  3443. {
  3444. if (([Reachability reachabilityForInternetConnection].currentReachabilityStatus == NotReachable) &&
  3445. ([Reachability reachabilityForLocalWiFi].currentReachabilityStatus == NotReachable))
  3446. return false;
  3447. return true;
  3448. }
  3449. //+(NSString *)flattenHTML:(NSString *)html trimWhiteSpace:(BOOL)trim
  3450. //{
  3451. // NSScanner *theScanner = [NSScanner scannerWithString:html];
  3452. // NSString *text = nil;
  3453. //
  3454. // while ([theScanner isAtEnd] == NO) {
  3455. // // find start of tag
  3456. // [theScanner scanUpToString:@"<" intoString:NULL] ;
  3457. // // find end of tag
  3458. // [theScanner scanUpToString:@">" intoString:&text] ;
  3459. // // replace the found tag with a space
  3460. // //(you can filter multi-spaces out later if you wish)
  3461. // html = [html stringByReplacingOccurrencesOfString:
  3462. // [ NSString stringWithFormat:@"%@>", text]
  3463. // withString:@""];
  3464. // }
  3465. //
  3466. // return trim ? [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] : html;
  3467. //}
  3468. //
  3469. //+(NSString *)flattenURL:(NSString *)url trimWhiteSpace:(BOOL)trim
  3470. //{
  3471. // NSScanner *theScanner = [NSScanner scannerWithString:url];
  3472. // NSString *text = nil;
  3473. //
  3474. // while ([theScanner isAtEnd] == NO) {
  3475. // // find start of tag
  3476. // [theScanner scanUpToString:@"/" intoString:NULL] ;
  3477. // // find end of tag
  3478. // [theScanner scanUpToString:@"/" intoString:&text] ;
  3479. // // replace the found tag with a space
  3480. // //(you can filter multi-spaces out later if you wish)
  3481. // url = [url stringByReplacingOccurrencesOfString:
  3482. // [ NSString stringWithFormat:@"%@", text]
  3483. // withString:@""];
  3484. // }
  3485. //
  3486. // return trim ? [url stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] : url;
  3487. //}
  3488. + (NSDictionary *)set_npd_shop_price_type:(NSInteger)priceType {
  3489. NSMutableDictionary* dic = [[NSMutableDictionary alloc] init];
  3490. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3491. if(appDelegate.user!=nil)
  3492. [dic setValue:appDelegate.user forKey:@"user"];
  3493. if(appDelegate.password!=nil)
  3494. [dic setValue:appDelegate.password forKey:@"password"];
  3495. [dic setValue:[NSString stringWithFormat:@"%ld",priceType] forKey:@"price_type"];
  3496. [dic setObject:ScreenCodePriceSetting forKey:kScreenName];
  3497. NSData* json=nil;
  3498. if(appDelegate.offline_mode)
  3499. {
  3500. return [OLDataProvider offline_notimpl];
  3501. }
  3502. else
  3503. {
  3504. if(![self IsNetworkAvailable])
  3505. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3506. json = [RANetwork get_json:URL_SET_PRICE_TYPE parameters:dic];
  3507. }
  3508. if(json!=nil)
  3509. {
  3510. NSError *error=nil;
  3511. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3512. return jsobj;
  3513. }
  3514. return nil;
  3515. }
  3516. + (NSDictionary *)get_npd_shop_givenPrice {
  3517. NSMutableDictionary* dic = [[NSMutableDictionary alloc] init];
  3518. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3519. if(appDelegate.user!=nil)
  3520. [dic setValue:appDelegate.user forKey:@"user"];
  3521. if(appDelegate.password!=nil)
  3522. [dic setValue:appDelegate.password forKey:@"password"];
  3523. [dic setObject:ScreenCodeCategoryPrice forKey:kScreenName];
  3524. NSData* json=nil;
  3525. if(appDelegate.offline_mode)
  3526. {
  3527. return [OLDataProvider offline_notimpl];
  3528. }
  3529. else
  3530. {
  3531. if(![self IsNetworkAvailable])
  3532. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3533. json = [RANetwork get_json:URL_GET_CIVEN_PRICE parameters:dic];
  3534. }
  3535. if(json!=nil)
  3536. {
  3537. NSError *error=nil;
  3538. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3539. return jsobj;
  3540. }
  3541. return nil;
  3542. }
  3543. + (NSDictionary *)set_npd_shop_givenPrice:(NSMutableDictionary *)params {
  3544. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3545. if(appDelegate.user!=nil)
  3546. [params setValue:appDelegate.user forKey:@"user"];
  3547. if(appDelegate.password!=nil)
  3548. [params setValue:appDelegate.password forKey:@"password"];
  3549. [params setObject:ScreenCodeSetCatetoryPrice forKey:kScreenName];
  3550. NSData* json=nil;
  3551. if(appDelegate.offline_mode)
  3552. {
  3553. return [OLDataProvider offline_notimpl];
  3554. }
  3555. else
  3556. {
  3557. if(![self IsNetworkAvailable])
  3558. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3559. json = [RANetwork get_json:URL_SET_GIVEN_PRICE parameters:params];
  3560. }
  3561. if(json!=nil)
  3562. {
  3563. NSError *error=nil;
  3564. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3565. return jsobj;
  3566. }
  3567. return nil;
  3568. }
  3569. + (NSDictionary *)merge_order:(NSMutableDictionary *)params {
  3570. NSMutableDictionary* dic = [[NSMutableDictionary alloc] init];
  3571. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3572. if(appDelegate.user!=nil)
  3573. [dic setValue:appDelegate.user forKey:@"user"];
  3574. if(appDelegate.password!=nil)
  3575. [dic setValue:appDelegate.password forKey:@"password"];
  3576. [dic setValue:[params objectForKey:@"order_ids"] forKey:@"order_ids"];
  3577. [dic setValue:[params objectForKey:@"targetOrderId"] forKey:@"targetOrderId"];
  3578. [dic setValue:[params objectForKey:@"customerInfo"] forKey:@"customerInfo"];
  3579. [dic setObject:ScreenCodeOrderList forKey:kScreenName];
  3580. NSData* json=nil;
  3581. if(appDelegate.offline_mode)
  3582. {
  3583. return [OLDataProvider offline_notimpl];
  3584. }
  3585. else
  3586. {
  3587. if(![self IsNetworkAvailable])
  3588. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3589. json=[self get_json:URL_SET_MERGE_ORDER parameters:dic];
  3590. }
  3591. if(json!=nil)
  3592. {
  3593. NSError *error=nil;
  3594. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3595. return jsobj;
  3596. }
  3597. else
  3598. return nil;
  3599. }
  3600. + (NSDictionary *)lock_order:(NSString *)oderCode {
  3601. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  3602. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3603. if(appDelegate.user!=nil)
  3604. [params setValue:appDelegate.user forKey:@"user"];
  3605. if(appDelegate.password!=nil)
  3606. [params setValue:appDelegate.password forKey:@"password"];
  3607. [params setValue:oderCode forKey:@"orderCode"];
  3608. NSData* json=nil;
  3609. if(appDelegate.offline_mode)
  3610. {
  3611. json=[OLDataProvider offline_editorder:params];
  3612. }
  3613. else
  3614. {
  3615. if(![self IsNetworkAvailable])
  3616. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3617. json=[self get_json:URL_OPEN_ORDER parameters:params];
  3618. }
  3619. if(json!=nil)
  3620. {
  3621. NSError *error=nil;
  3622. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3623. return jsobj;
  3624. }
  3625. else
  3626. return nil;
  3627. }
  3628. + (NSDictionary *)quoteOrder:(NSString *)so_id emailAddr:(NSString *)addr {
  3629. NSMutableDictionary* dic = [[NSMutableDictionary alloc] init];
  3630. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3631. if(appDelegate.user!=nil)
  3632. [dic setValue:appDelegate.user forKey:@"user"];
  3633. if(appDelegate.password!=nil)
  3634. [dic setValue:appDelegate.password forKey:@"password"];
  3635. [dic setValue:so_id forKey:@"orderCode"];
  3636. [dic setValue:addr forKey:@"email"];
  3637. [dic setObject:ScreenCodeCart forKey:kScreenName];
  3638. if (appDelegate.customerInfo) {
  3639. NSString *customer_cid = [appDelegate.customerInfo objectForKey:@"customer_cid"];
  3640. if (customer_cid) {
  3641. [dic setValue:customer_cid forKey:@"contactId"];
  3642. }
  3643. }
  3644. NSData* json=nil;
  3645. if(appDelegate.offline_mode)
  3646. {
  3647. return [OLDataProvider offline_notimpl];
  3648. }
  3649. else
  3650. {
  3651. if(![self IsNetworkAvailable])
  3652. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3653. json = [RANetwork get_json:URL_EMAIL_CART parameters:dic];
  3654. }
  3655. if(json!=nil)
  3656. {
  3657. NSError *error=nil;
  3658. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3659. return jsobj;
  3660. }
  3661. return @{@"result" : @(RESULT_FALSE)};
  3662. }
  3663. + (NSDictionary *)notifyModel:(NSString *)modelID emailAddr:(NSString *)addr withScreen:(NSString *)screenName{
  3664. NSMutableDictionary* dic = [[NSMutableDictionary alloc] init];
  3665. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3666. if(appDelegate.user!=nil)
  3667. [dic setValue:appDelegate.user forKey:@"user"];
  3668. if(appDelegate.password!=nil)
  3669. [dic setValue:appDelegate.password forKey:@"password"];
  3670. if (appDelegate.user_type == USER_ROLE_EMPLOYEE && appDelegate.customerInfo) {
  3671. NSString *customer_cid = [appDelegate.customerInfo objectForKey:@"customer_cid"];
  3672. if (customer_cid) {
  3673. [dic setValue:customer_cid forKey:@"contactId"];
  3674. }
  3675. }
  3676. [dic setObject:screenName forKey:kScreenName];
  3677. [dic setValue:modelID forKey:@"productId"];
  3678. if (addr) { // 弹框输入
  3679. [dic setValue:addr forKey:@"email"];
  3680. } else {
  3681. // employee选择了Contact,并且Contact有Email
  3682. // if (appDelegate.user_type == USER_ROLE_EMPLOYEE && appDelegate.customerInfo) {
  3683. // NSString *email = [appDelegate.customerInfo objectForKey:@"customer_email"];
  3684. // if (email) {
  3685. // [dic setValue:email forKey:@"email"];
  3686. // }
  3687. // }
  3688. }
  3689. NSData* json=nil;
  3690. if(appDelegate.offline_mode)
  3691. {
  3692. return [OLDataProvider offline_notimpl];
  3693. }
  3694. else
  3695. {
  3696. if(![self IsNetworkAvailable])
  3697. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3698. json = [RANetwork get_json:URL_NOTIFY_ME parameters:dic];
  3699. }
  3700. if(json!=nil)
  3701. {
  3702. NSError *error=nil;
  3703. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3704. return jsobj;
  3705. }
  3706. return @{@"result" : @(RESULT_FALSE)};
  3707. }
  3708. + (NSDictionary *)quoteWishlist2EmailAddr:(NSString *)addr {
  3709. NSMutableDictionary* dic = [[NSMutableDictionary alloc] init];
  3710. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3711. if(appDelegate.user!=nil)
  3712. [dic setValue:appDelegate.user forKey:@"user"];
  3713. if(appDelegate.password!=nil)
  3714. [dic setValue:appDelegate.password forKey:@"password"];
  3715. [dic setValue:addr forKey:@"email"];
  3716. [dic setObject:ScreenCodeWishList forKey:kScreenName];
  3717. // if (appDelegate.customerInfo) {
  3718. // NSString *customer_cid = [appDelegate.customerInfo objectForKey:@"customer_cid"];
  3719. // if (customer_cid) {
  3720. // [dic setValue:customer_cid forKey:@"contactId"];
  3721. // }
  3722. // }
  3723. NSData* json=nil;
  3724. if(appDelegate.offline_mode)
  3725. {
  3726. return [OLDataProvider offline_notimpl];
  3727. }
  3728. else
  3729. {
  3730. if(![self IsNetworkAvailable])
  3731. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3732. json = [RANetwork get_json:URL_EMAIL_WISHLIST parameters:dic];
  3733. }
  3734. if(json!=nil)
  3735. {
  3736. NSError *error=nil;
  3737. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3738. return jsobj;
  3739. }
  3740. return @{@"result" : @(RESULT_FALSE)};
  3741. }
  3742. + (NSDictionary *)movetobackorder:(NSString *)cart_item_id {
  3743. if (cart_item_id == nil || cart_item_id.length < 1) {
  3744. return @{@"result" : @(RESULT_FALSE),@"err_msg" : @"invalided product"};
  3745. }
  3746. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3747. NSMutableDictionary* dic = [[NSMutableDictionary alloc] init];
  3748. if(appDelegate.user!=nil)
  3749. [dic setValue:appDelegate.user forKey:@"user"];
  3750. if(appDelegate.password!=nil)
  3751. [dic setValue:appDelegate.password forKey:@"password"];
  3752. [dic setValue:cart_item_id forKey:@"orderitem_id"];
  3753. [dic setValue:appDelegate.order_code forKey:@"order_code"];
  3754. [dic setObject:ScreenCodeCart forKey:kScreenName];
  3755. if(![self IsNetworkAvailable])
  3756. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  3757. NSData *json = [RANetwork get_json:URL_MOVE_TO_BACK_ORDER parameters:dic];
  3758. if(json!=nil)
  3759. {
  3760. NSError *error=nil;
  3761. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  3762. return jsobj;
  3763. }
  3764. return @{@"result" : @(RESULT_FALSE)};
  3765. }
  3766. @end