Fullordertt.php 240 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Fullordertt extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_fullorder','fullorder');
  7. $this->load->_model('Model_fullordertt','fullordertt');
  8. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  9. $this->load->_model('Model_shop','shop');
  10. $this->load->_model('Model_typeclass','typeclass');
  11. $this->load->_model('Model_express','express');
  12. $this->load->_model('Model_country','country');
  13. $this->load->_model('Model_productdescribe','productdescribe');
  14. $this->load->_model('Model_customs','customs');
  15. $this->load->_model('Model_detailed','detailed');
  16. $this->load->_model('Model_productdescription','productdescription');
  17. $this->load->_model('Model_logistics','logistics');
  18. $this->load->_model('Model_hl','hl');
  19. $this->load->_model('Model_excel','excel');
  20. $this->load->_model('Model_warehouse','warehouse');
  21. $this->load->_model('Model_customertt','customertt');
  22. $this->load->_model('Model_user','user');
  23. $this->load->_model('Model_dhl','dhl');
  24. $this->load->_model('Model_ali','ali');
  25. $this->load->_model('Model_notice','notice');
  26. $this->load->_model('Model_api','api');
  27. $this->load->_model('Model_usps','usps');
  28. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  29. $this->load->_model('Model_whlabel','whlabel');
  30. $this->load->_model('Model_reset','fullreset');
  31. $this->load->_model('Model_specialstock','specialstock');
  32. $this->load->_model('Model_systemwigsout','systemwigsout');
  33. $this->load->_model('Model_colourorderts','colourorderts');
  34. $this->load->_model('Model_paypal','paypal');
  35. $this->load->_model('Model_ck','ck');
  36. $this->load->_model('Model_weight','weight');
  37. $this->load->_model('Model_pay','pay');
  38. $this->load->_model('Model_setting','setting');
  39. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  40. $this->load->_model('Model_transfer','transfer');
  41. $this->load->_model('Model_systemtransfer','systemtransfer');
  42. $this->load->_model('Model_power','power');
  43. $this->load->_model('Model_fullordertthb','fullordertthb');
  44. $this->load->_model('Model_returngoods','returngoods');
  45. $this->load->_model("Model_logic_order","logic_order");
  46. $this->load->_model("Model_excelnew",'excelnew');
  47. $this->load->_model("Model_fullordererrors","fullordererrors");
  48. $this->load->_model("Model_express_tt","express_tt");
  49. $this->load->_model("Model_retreatlogs","retreatlogs");
  50. }
  51. //定义方法的调用规则 获取URI第二段值
  52. public function _remap($arg,$arg_array)
  53. {
  54. if($arg == 'add')//添加
  55. {
  56. $this->_add();
  57. }
  58. else if($arg == 'edit')//修改
  59. {
  60. $this->_edit($arg_array);
  61. }
  62. else if($arg == 'readonly')//修改
  63. {
  64. $this->_readonly($arg_array);
  65. }
  66. else if($arg == 'readlist')
  67. {
  68. $this->_readlist();
  69. }
  70. else if($arg == 'readlistdown')
  71. {
  72. $this->_readlistdown();
  73. }
  74. else if($arg == 'del')//修改
  75. {
  76. $this->_del();
  77. }
  78. else if($arg == 'price')//价格明细
  79. {
  80. $this->_price();
  81. }
  82. else if($arg == 'customs')
  83. {
  84. $this->_customs();
  85. }
  86. else if($arg == 'express')
  87. {
  88. $this->_express();
  89. }
  90. else if($arg == 'hl')
  91. {
  92. $this->_hl();
  93. }
  94. else if($arg == 'repeat')
  95. {
  96. $this->_repeat();
  97. }
  98. else if($arg == 'operation')
  99. {
  100. $this->_operation();
  101. }
  102. else if($arg == 'merge')
  103. {
  104. $this->_merge();
  105. }
  106. else if($arg == 'fmexcel')
  107. {
  108. $this->_fmexcel();
  109. }
  110. else if($arg == 'fdexcel')
  111. {
  112. $this->_fdexcel();
  113. }
  114. else if($arg == 'fdfexcel')
  115. {
  116. $this->_fdfexcel();
  117. }
  118. else if($arg == 'evaluate')
  119. {
  120. $this->_evaluate();
  121. }
  122. else if($arg == 'state')
  123. {
  124. $this->_state();
  125. }
  126. else if($arg == 'wl')
  127. {
  128. $this->_wl();
  129. }
  130. else if($arg == 'wlbz')
  131. {
  132. $this->_wlbz($arg_array);
  133. }
  134. else if($arg == 'review')
  135. {
  136. $this->_review();
  137. }
  138. else if($arg == 'black')
  139. {
  140. $this->_black();
  141. }
  142. else if($arg == 'ryf')
  143. {
  144. $this->_ryf();
  145. }
  146. else if($arg == 'expresstype')
  147. {
  148. $this->_expresstype();
  149. }
  150. else if($arg == 'fsstate')
  151. {
  152. $this->_fsstate();
  153. }
  154. else if($arg == 'power')
  155. {
  156. $this->_power();
  157. }
  158. else if($arg == 'error')
  159. {
  160. $this->_error();
  161. }
  162. else if($arg == 'yc')
  163. {
  164. $this->_yc();
  165. }
  166. else if($arg == 'ycexcel')
  167. {
  168. $this->_ycexcel();
  169. }
  170. else if($arg == 'yzaddress')
  171. {
  172. $this->_yzaddress();
  173. }
  174. else if($arg == 'return')
  175. {
  176. $this->_return();
  177. }
  178. else if($arg == 'clearreturn')
  179. {
  180. $this->_clearreturn();
  181. }
  182. else if($arg == 'ali')
  183. {
  184. $this->_ali();
  185. }
  186. else if($arg == 'dqpm')
  187. {
  188. $this->_dqpm();
  189. }
  190. else if($arg == 'ddpmdata')
  191. {
  192. $this->_ddpmdata($arg_array);
  193. }
  194. else if($arg == 'dqpmprovince')
  195. {
  196. $this->_dqpmprovince($arg_array);
  197. }
  198. else if($arg == 'ddpmexcel')
  199. {
  200. $this->_ddpmexcel($arg_array);
  201. }
  202. else if($arg == 'statedc')
  203. {
  204. $this->_statedc();
  205. }
  206. else if($arg == 'statedcwl')
  207. {
  208. $this->_statedcwl();
  209. }
  210. else if($arg == 'waybillemail')
  211. {
  212. $this->_waybillemail();
  213. }
  214. else if($arg == 'khdd')
  215. {
  216. $this->_khdd();
  217. }
  218. else if($arg == 'klarnadata')
  219. {
  220. $this->_klarnadata();
  221. }
  222. else if($arg == 'epod')
  223. {
  224. $this->_epod();
  225. }
  226. else if($arg == 'zw')
  227. {
  228. $this->_zw($arg_array);
  229. }
  230. else if($arg == 'thxz')
  231. {
  232. $this->_thxz($arg_array);
  233. }
  234. else if($arg == 'dcdxyz')
  235. {
  236. $this->_dcdxyz();
  237. }
  238. else if($arg == 'ddcf')
  239. {
  240. $this->_ddcf();
  241. }
  242. else if($arg == 'cf')
  243. {
  244. $this->_cf();
  245. }
  246. else if($arg == 'pljzzd')
  247. {
  248. $this->_pljzzd();
  249. }
  250. else if($arg == 'cbtlabel'){
  251. $this->_cbtlabel($arg_array);
  252. }
  253. else
  254. {
  255. $this->_index();
  256. }
  257. }
  258. //管理
  259. public function _index()
  260. {
  261. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  262. if(isset($_SESSION['api']))
  263. {
  264. $user = $this->user->get_api($_SESSION['api']);
  265. $usp = $user;
  266. $fgshop = "";$sid = "";
  267. $usersp = explode('|',trim($user['shop'],'|'));
  268. foreach ($usersp as $value)
  269. {
  270. $fgshop .= " shop = ".$value." or";
  271. $sid .= " id = ".$value." or";
  272. }
  273. if($user['vip'] == 1)
  274. {
  275. $vip = 1;
  276. }
  277. else
  278. {
  279. $vip = 0;
  280. }
  281. }
  282. else
  283. {
  284. $vip = 0;
  285. header('Location: /');exit;
  286. }
  287. $post = $this->input->post(NULL, TRUE);
  288. if(isset($post['page']))
  289. {
  290. $page = $this->input->post('page',true);
  291. $perpage = $this->input->post('perpage',true);
  292. $warehouse = $this->input->post('warehouse',true);
  293. $timetk = $this->input->post('timetk',true);
  294. $timetj = $this->input->post('timetj',true);
  295. $shop = $this->input->post('shop',true);
  296. $source = $this->input->post('source',true);
  297. $state = $this->input->post('state',true);
  298. $review = $this->input->post('review',true);
  299. $type = $this->input->post('type',true);
  300. $express = $this->input->post('express',true);
  301. $orderinfo = $this->input->post('orderinfo',true);
  302. $user = $this->input->post('user',true);
  303. $client = $this->input->post('name');
  304. $waybill = $this->input->post('waybill',true);
  305. $waybillid = $this->input->post('waybillid',true);
  306. $number = $this->input->post('number',true);
  307. $email = $this->input->post('email',true);
  308. $phone = $this->input->post('phone',true);
  309. $dlz = $this->input->post('dlz',true);
  310. $print = $this->input->post('print',true);
  311. $library = $this->input->post('library',true);
  312. $js = $this->input->post('js',true);
  313. $exstate = $this->input->post('exstate',true);
  314. $xztime = $this->input->post('xztime',true);
  315. $libraryconfirm = $this->input->post('libraryconfirm',true);
  316. $timetk = strtotime($timetk);
  317. $timetj = strtotime($timetj);
  318. $plorder = $this->input->post('pl',true);
  319. $paypal = $this->input->post('paypal',true);
  320. $orderremarks = $this->input->post('orderremarks',true);
  321. $pay = $this->input->post('pay',true);
  322. $klarna = $this->input->post('klarna',true);
  323. $zf = $this->input->post('zf',true);
  324. $where = "1=1 and (".rtrim($fgshop,'or').")";
  325. if($warehouse)
  326. {
  327. $where .= " and type = '$warehouse'";
  328. }
  329. if($timetk && $timetj)
  330. {
  331. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  332. }
  333. if($shop)
  334. {
  335. $where .= " and shop = '$shop'";
  336. }
  337. if($source)
  338. {
  339. if($source == '2d')
  340. {
  341. $where .= " and source >= '2'";
  342. }
  343. else
  344. {
  345. $where .= " and source = '$source'";
  346. }
  347. }
  348. if($state)
  349. {
  350. $where .= " and state = '$state'";
  351. }
  352. if($review)
  353. {
  354. $where .= " and review = '$review'";
  355. }
  356. if($type)
  357. {
  358. $where .= " and type = '$type'";
  359. }
  360. if($express)
  361. {
  362. $where .= " and express = '$express'";
  363. }
  364. if($orderinfo)
  365. {
  366. $where .= " and orderinfo = '$orderinfo' and orderinfo != '0'";
  367. }
  368. if($user)
  369. {
  370. $where .= " and user = '$user'";
  371. }
  372. if($client)
  373. {
  374. $where .= " and client like '%$client%'";
  375. }
  376. if($waybill)
  377. {
  378. $where .= " and waybill = '$waybill'";
  379. }
  380. if($waybillid){
  381. $where .= " and waybillid like '%".$waybillid."%'";
  382. }
  383. if($number)
  384. {
  385. $where .= " and number like '$number%'";
  386. }
  387. if($email)
  388. {
  389. $where .= " and email = '$email'";
  390. }
  391. if($phone)
  392. {
  393. $where .= " and phone like '%$phone%'";
  394. }
  395. if($library)
  396. {
  397. $where .= " and library = '$library'";
  398. }
  399. if($print)
  400. {
  401. $where .= " and print = '$print'";
  402. }
  403. if($dlz != '')
  404. {
  405. $where .= " and dlz = '$dlz'";
  406. }
  407. if($js)
  408. {
  409. $where .= " and js = '$js'";
  410. }
  411. if($exstate)
  412. {
  413. $where .= " and exstate = '$exstate'";
  414. }
  415. if($libraryconfirm)
  416. {
  417. $where .= " and libraryconfirm = '$libraryconfirm'";
  418. }
  419. if($klarna != '')
  420. {
  421. if($klarna == 2)
  422. {
  423. $where .= " and klarna >= '$klarna'";
  424. }
  425. else
  426. {
  427. $where .= " and klarna = '$klarna'";
  428. }
  429. }
  430. if($paypal)
  431. {
  432. $where .= " and paypal = '$paypal'";
  433. }
  434. if($orderremarks){
  435. $where .= " and orderremarks like '%$orderremarks%'";
  436. }
  437. if($pay)
  438. {
  439. $where .= " and pay = '$pay'";
  440. }
  441. if($zf)
  442. {
  443. if($zf == 1)
  444. {
  445. $where .= " and paypal not like '%-%-%-%'";
  446. }
  447. else
  448. {
  449. $where .= " and paypal like '%-%-%-%'";
  450. }
  451. }
  452. if($plorder)
  453. {
  454. $plorderinfo = '';$plnumber = '';$pln = 0;
  455. $plorder = explode(',',trim($plorder,','));
  456. foreach ($plorder as $value)
  457. {
  458. if(is_numeric($value))
  459. {
  460. $plorderinfo .= " orderinfo = ".$value." or";
  461. }
  462. else if($value != '')
  463. {
  464. $plorderinfo .= " number = '".$value."' or";
  465. }
  466. }
  467. if($pln > 0)
  468. {
  469. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  470. }
  471. else
  472. {
  473. $where .= " and (".rtrim($plorderinfo,'or').")";
  474. }
  475. }
  476. //数据排序
  477. $order_str = "dtime desc";
  478. if(empty($page))
  479. {
  480. $start = 0;
  481. $perpage = 1;
  482. }
  483. else
  484. {
  485. $start = ($page - 1)*$perpage;
  486. }
  487. //取得信息列表id,shop,type,source,user,orderinfo,number,name,state,buytime,clientremarks,review,print,library,libraryconfirm,express,waybill,orderremarks,black
  488. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,sname,phone,state,dtime,review,libraryconfirm,express,waybill,orderremarks,library,black,clientremarks,waybillid',$order_str,$start,$perpage);
  489. //格式化数据
  490. foreach ($info_list as $key=>$value)
  491. {
  492. $ud = $this->fullordertt->read($value['id']);
  493. $ud['address'] = str_replace("'","’",$ud['address']);
  494. $ud['name'] = str_replace("'","’",$ud['name']);
  495. $customer = $this->customertt->get_email($ud['email'],$value['shop']);
  496. $customernum = $this->fullordertt->find_count("email = '".$ud['email']."' and shop = '".$value['shop']."' and extra_status = 0");
  497. preg_match_all('/[0-9]/u',$ud['phone'],$result);
  498. $numphone = join('',$result[0]);
  499. $hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($ud['address']));
  500. $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($ud['address']));
  501. $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($ud['address']));
  502. if($numphone == '0')
  503. {
  504. $customerb = $this->customertt->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or address = '".$hmdaddress1."' or address = '".$hmdaddress2."' or address = '".$hmdaddress3."' or phone = '".$numphone."')",'*','id desc');
  505. }
  506. else
  507. {
  508. $customerb = $this->customertt->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or address = '".$hmdaddress1."' or address = '".$hmdaddress2."' or address = '".$hmdaddress3."' or numphone = '".$numphone."')",'*','id desc');
  509. }
  510. $customerc = $this->customertt->find_all("type = 1 and shop = '".$ud['shop']."' and address = '".$ud['address']."' and numphone = '".$numphone."'",'*','id desc');
  511. $customerd = $this->customertt->find_all("type = 2 and shop = '".$ud['shop']."' and email = '".$ud['email']."'",'*','id desc');
  512. //$a = array_column($customer, 'email'); //三维找其中健的数组
  513. //$a = array_flip($a); //键和值调换
  514. $djcount = '';
  515. $lkh = $value['sname'];
  516. $djlkh = 0;$djhmd = 0;
  517. if($customer)
  518. {
  519. if($customer['count'] != '' && $customernum < 2)
  520. {
  521. $count = '<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>';
  522. $djcount = $count;
  523. }
  524. if(($customer['type'] == 1 && $customernum > 1))// || $customerc['type'] == 1 && $customerc['num'] > 1
  525. {
  526. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  527. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户(".$customer['num'].")</p>";
  528. $djlkh = 1;
  529. $djcount = $count;
  530. }
  531. else if(isset($customerc[0]['num']))
  532. {
  533. if($customerc[0]['num'] > 1)
  534. {
  535. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  536. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户(".$customer['num'].")</p>";
  537. $djlkh = 1;
  538. $djcount = $count;
  539. }
  540. }
  541. }
  542. if($customerb)
  543. {
  544. $hmsp = $this->shop->read($customerb[0]['shop']);
  545. $count = $customerb[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerb[0]['count'].'"></i>':'';
  546. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'>".$count."黑名单</p><p style='color:#9900CC' data-id='".$customerb[0]['id']."'>来自".$hmsp['shopname']."</p>";
  547. $djhmd = 1;
  548. if($customerd)
  549. {
  550. if($customerd[0]['num'] > 1)
  551. {
  552. $count = $customerd[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerd[0]['count'].'"></i>':'';
  553. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  554. $djlkh = 1;
  555. $djcount = $count;
  556. $djlkh = 1;
  557. }
  558. }
  559. }
  560. if($djlkh == '1' && $djhmd == '1')
  561. {
  562. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'><em style='color:#FF3333'>".$djcount."老客户</em> - ".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  563. }
  564. if($djlkh != '1' && $djhmd != '1' && $djcount)
  565. {
  566. $info_list[$key]['sname'] = $lkh."<p style='color:#FF3333'>".$djcount."</p>";
  567. }
  568. else
  569. {
  570. $info_list[$key]['sname'] = $lkh;
  571. }
  572. // $rginfo_list = $this->returngoods->find_all("email = '".$ud['email']."'");
  573. // if(!empty($rginfo_list))
  574. // {
  575. // $tmp_str = '';
  576. // foreach ($rginfo_list as $k => $v) {
  577. // $tmp_str .= $v['remark'].'<br/>';
  578. // }
  579. // $info_list[$key]['sname'] = $info_list[$key]['sname']."<br/>售后单(".count($rginfo_list).")".'<p style="color:blue"><i class="method fa fa-list-ul" data-t="'.$tmp_str.'"></i><p>';
  580. // }
  581. $shop = $this->shop->read($value['shop']);
  582. $info_list[$key]['shop'] = $shop['shopname'];
  583. //$info_list[$key]['user'] = $shop['shopuser'];
  584. $warehouse = $this->warehouse->read($value['type']);
  585. $warehousetitle = $warehouse['title'];
  586. if($value['type'] != 13){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  587. $info_list[$key]['type'] = $warehousetitle;
  588. $info_list[$key]['phone'] = $value['phone'];
  589. $typeclass = $this->typeclass->read($value['state']);
  590. $info_list[$key]['state'] = "<font style='font-size: 13px;'>".$typeclass['spare']."</font>";
  591. /**
  592. $wl = '';
  593. if($value['exstate'] == '99')
  594. {
  595. $wl = '<font style="color:#ccc">未获取到物流信息</font>';
  596. }
  597. else if($value['exstate'] == '1')
  598. {
  599. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已揽收<font style="display: none">'.$ud['excontent'].'</font></font>';
  600. }
  601. else if($value['exstate'] == '2')
  602. {
  603. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">在途中<font style="display: none">'.$ud['excontent'].'</font></font>';
  604. }
  605. else if($value['exstate'] == '3')
  606. {
  607. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送中<font style="display: none">'.$ud['excontent'].'</font></font>';
  608. }
  609. else if($value['exstate'] == '4')
  610. {
  611. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已签收<font style="display: none">'.$ud['excontent'].'</font></font>';
  612. }
  613. else if($value['exstate'] == '5')
  614. {
  615. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送异常<font style="display: none">'.$ud['excontent'].'</font></font>';
  616. }
  617. $info_list[$key]['exstate'] = $wl.'<br />';
  618. **/
  619. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  620. {
  621. $info_list[$key]['dtime'] = '<p style="font-size: 13px;">'.date('Y-m-d',$ud['dtime']).'</p><p style="font-size: 13px;">'.date('H:i:s',$ud['dtime']).'</p>';
  622. }
  623. else
  624. {
  625. $info_list[$key]['dtime'] = '<p style="font-size: 13px;">'.date('Y-m-d',$value['dtime']+$dt).'</p><p style="font-size: 13px;">'.date('H:i:s',$value['dtime']+$dt).'</p>';
  626. }
  627. if($value['review'] == 1)
  628. {
  629. $info_list[$key]['review'] = "<font style='font-size: 13px;'>未送审</font>";
  630. }
  631. else if($value['review'] == 2)
  632. {
  633. $info_list[$key]['review'] = "<font style='color:#555;font-size: 13px;'>待审核</font>";
  634. }
  635. else if($value['review'] == 3)
  636. {
  637. $info_list[$key]['review'] = "<font style='color:#f90f4b;font-size: 13px;'>不通过</font>";
  638. }
  639. else if($value['review'] == 4)
  640. {
  641. $info_list[$key]['review'] = "<font style='font-size: 13px;'>取消重审</font>";
  642. }
  643. else if($value['review'] == 5)
  644. {
  645. $info_list[$key]['review'] = "<font style='color:#2f80f9;font-size: 13px;'>审核通过</font>";
  646. }
  647. else if($value['review'] == 6)
  648. {
  649. $info_list[$key]['review'] = "<font style='color:#2f80f9;font-size: 13px;'>自动通过</font>";
  650. }
  651. if($ud['dlz'] == 1)
  652. {
  653. $dlz = "<p>独立站已更新</p>";
  654. }
  655. else if($ud['dlz'] == 3)
  656. {
  657. $dlz = "<p>不需要更新</p>";
  658. }
  659. else if($ud['dlz'] == 2)
  660. {
  661. $dlz = "<p style='color:#C3C'>独立站更新失败</p>";
  662. }
  663. else
  664. {
  665. $dlz = "";
  666. }
  667. if($value['waybill'] != "")
  668. {
  669. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  670. if( !empty($value['waybillid'])){
  671. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  672. }
  673. }
  674. if($value['express'] != 0)
  675. {
  676. $express = $this->express->read($value['express']);
  677. $expressservicename = $express['servicename'];
  678. if($value['express'] != 1 && $value['express'] != 63)
  679. {
  680. $expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";
  681. }
  682. else if($value['express'] == 63)
  683. {
  684. $expressservicename = "<font style='color:#a910f8'>".$express['servicename']."</font>";
  685. }
  686. $info_list[$key]['express'] = $expressservicename;
  687. }
  688. else
  689. {
  690. $info_list[$key]['express'] = "无";
  691. }
  692. $x = "";
  693. if($value['libraryconfirm'] == 2 && $value['review'] > 4 && $ud['library'] == 1)
  694. {
  695. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  696. }
  697. else if(($value['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  698. {
  699. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  700. }
  701. if(($value['review'] > 4) && $ud['print'] == 2)
  702. {
  703. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  704. }
  705. else if($value['review'] >4 && $ud['print'] == 1)
  706. {
  707. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  708. }
  709. if($value['waybill'] == "" && $value['review'] > 4)
  710. {
  711. $x .= "<p><b class='kn' data-type='2'>填写运单号</b></p>";
  712. }
  713. else if($value['waybill'] != "" && $value['review'] > 4)
  714. {
  715. $x .= "<p><b class='kn' data-type='2'>修改运单号</b></p>";
  716. }
  717. if(($value['review'] == 1 || $value['review'] == 3 ) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0)
  718. {
  719. $x .= "<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  720. }
  721. $x .= "<p><b class='window' data-h='/customertt/edit/".$customer['id']."' data-t='客户信息 - 修改'>客户信息</b></p>";
  722. $info_list[$key]['black'] = $x;
  723. if($ud['express'] == 83){
  724. $extra_text = json_decode($ud['extra_text'],true);
  725. if(!isset($extra_text['label_info'])){
  726. $info_list[$key]['black'] .= "<p><b style='background-color:#f64b4b' class='create_label' data-id='".$value['id']."'>创建CBT面单</b></p>";
  727. }
  728. }
  729. if($ud['express'] == 85){
  730. $extra_text = json_decode($ud['extra_text'],true);
  731. if(!isset($extra_text['label_info'])){
  732. $info_list[$key]['black'] .= "<p><b style='background-color:#f64b4b' class='create_label' data-id='".$value['id']."'>创建SP面单</b></p>";
  733. }
  734. }
  735. $tly = "";
  736. if($value['clientremarks'] != "")
  737. {
  738. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  739. }
  740. if($value['review'] > 4 && $usp['vip'] != 1 && ($ud['merge'] == 0 || $ud['merge'] == $ud['id']))
  741. {
  742. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/readonly/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  743. }
  744. else if($ud['merge'] == 0 || $ud['merge'] == $ud['id'])
  745. {
  746. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  747. }
  748. else if($ud['merge'] != 0 && $ud['merge'] != $ud['id'])
  749. {
  750. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."' style='color:#000'><p>".$value['orderinfo']."</p>".$tly."</h9>"."<p>合并订单</p>";
  751. }
  752. if($value['library'] == 1 && $ud['printtype'] == 3)
  753. {
  754. $info_list[$key]['library'] = "不需要";
  755. }
  756. else if($value['library'] == 1 && $ud['printtype'] != 3)
  757. {
  758. $info_list[$key]['library'] = "未出库";
  759. }
  760. else if($value['library'] == 2)
  761. {
  762. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  763. }
  764. else if($value['library'] == 3)
  765. {
  766. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  767. }
  768. unset($info_list[$key]['waybillid']);
  769. }
  770. $total = $this->fullordertt->find_count($where);
  771. $pagenum = ceil($total/$perpage);
  772. $over = $total-($start+$perpage);
  773. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  774. echo json_encode($rows);exit;
  775. }
  776. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  777. $this->data['wlshop'] = $wlshop;
  778. $this->data['express'] = $this->express->find_all();
  779. $user = $this->user->get_api($_SESSION['api']);
  780. $powerid = $this->power->read($user['power']);
  781. $powertext = explode('|',trim($powerid['excelid'],'|'));
  782. $pid = '';
  783. foreach ($powertext as $v)
  784. {
  785. $pid .= " id = ".$v." or";
  786. }
  787. $fullorderexcel = $this->fullorderexcel->find_all("type = '100006' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  788. $this->data['fullorderexcel'] = $fullorderexcel;
  789. $error = $this->fullordertt->find_count("failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').") and dtime > '".(time()-90*24*3600)."'");
  790. $this->data['error'] = $error;
  791. $yc = $this->fullordertt->find_count("library = 2 and state = 214 and (".rtrim($fgshop,'or').")");
  792. $this->data['yc'] = $yc;
  793. $cs_num = $this->fullordererrors->find_count( "plat = 'fullordertt' and error_type = 1 and (".rtrim($fgshop,'or'). " ) and error_time > '".(time()-90*24*3600)."'");
  794. $this->data['cs_num'] = $cs_num;
  795. $this->data['power'] = $vip;
  796. $this->_Template('fullordertt',$this->data);
  797. }
  798. //筛选重复订单
  799. public function _repeat()
  800. {
  801. $user = $this->user->get_api($_SESSION['api']);
  802. if($user)
  803. {
  804. $fgshop = "";$sid = "";
  805. $user = explode('|',trim($user['shop'],'|'));
  806. foreach ($user as $value)
  807. {
  808. $fgshop .= " shop = ".$value." or";
  809. $sid .= " id = ".$value." or";
  810. }
  811. }
  812. $post = $this->input->post(NULL, TRUE);
  813. if(isset($post['page']))
  814. {
  815. $page = $this->input->post('page',true);
  816. $perpage = $this->input->post('perpage',true);
  817. $shop = $this->input->post('shop',true);
  818. $timetk = $this->input->post('timetk',true);
  819. $timetj = $this->input->post('timetj',true);
  820. $timetk = strtotime($timetk);
  821. $timetj = strtotime($timetj);
  822. $where = "print != 999 and state = 207 and review = 1 and number NOT like '%-%-%-%-%' and (".rtrim($fgshop,'or').")";
  823. if($shop)
  824. {
  825. $where .= " and shop = '$shop'";
  826. }
  827. if($timetk && $timetj)
  828. {
  829. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  830. }
  831. //数据排序
  832. $order_str = "id desc";
  833. if(empty($page))
  834. {
  835. $start = 0;
  836. $perpage = 1;
  837. }
  838. else
  839. {
  840. $start = ($page - 1)*$perpage;
  841. }
  842. //取得信息列表
  843. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,name,phone,address,state,dtime,shipremarks,type,merge');
  844. $info = array();
  845. $len = count($info_list);
  846. //格式化数据
  847. foreach ($info_list as $key=>$value)
  848. {
  849. $ud = $this->fullordertt->read($value['id']);
  850. $shop = $this->shop->read($value['shop']);
  851. $warehouse = $this->warehouse->read($value['type']);
  852. $info_list[$key]['shop'] = '<p>'.$shop['shopname'].'</p>'.'<p>'.$warehouse['title'].'</p>';
  853. $typeclass = $this->typeclass->read($value['state']);
  854. $info_list[$key]['state'] = $typeclass['spare'];
  855. $info_list[$key]['type'] = $ud['orderremarks'];
  856. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']).'</p><p>'.date('H:i:s',$value['dtime']).'</p>';
  857. if($value['merge'] == 0)
  858. {
  859. $info_list[$key]['merge'] = "<p>可合并</p>";
  860. }
  861. else
  862. {
  863. if($value['merge'] == $value['id'])
  864. {
  865. if($ud['print'] < '3' && $ud['library'] == '1')
  866. {
  867. $info_list[$key]['merge'] = "<p><b class='cforder' data-id='".$value['id']."'>拆分订单</b></p>";
  868. }
  869. else
  870. {
  871. $info_list[$key]['merge'] = "已合并";
  872. }
  873. }
  874. else
  875. {
  876. $info_list[$key]['merge'] = "被合并";
  877. }
  878. }
  879. }
  880. /** 操作合并
  881. if($value['merge'] == 0)
  882. {
  883. $info_list[$key]['merge'] = "<p><b class='jd' data-type='5'>合并订单</b></p>";
  884. }
  885. else
  886. {
  887. if($value['merge'] == $value['id'])
  888. {
  889. $info_list[$key]['merge'] = "已合并";
  890. }
  891. else
  892. {
  893. $info_list[$key]['merge'] = "被合并";
  894. }
  895. }
  896. **/
  897. $asd = array();
  898. for($i=0;$i<$len;$i++)
  899. {
  900. for($j=$i+1;$j<$len;$j++)
  901. {
  902. if (strtolower($info_list[$i]['address']) == strtolower($info_list[$j]['address']) && stripos($info_list[$i]['number'],$info_list[$j]['number']) === false && stripos($info_list[$j]['number'],$info_list[$i]['number']) === false) //$info_list[$i]['email'] == $info_list[$j]['email']
  903. {
  904. if(!array_key_exists($j,$info))
  905. {
  906. $info[$j] = $info_list[$j];
  907. }
  908. if(!array_key_exists($i,$info))
  909. {
  910. $info[$i] = $info_list[$i];
  911. }
  912. }
  913. }
  914. }
  915. rsort($info);
  916. $total = count($info);
  917. $pagenum = ceil($total/$perpage);
  918. $over = $total-($start+$perpage);
  919. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_slice($info,$start,$perpage)));
  920. echo json_encode($rows);exit;
  921. }
  922. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  923. $this->data['wlshop'] = $wlshop;
  924. $this->_Template('fullordertt_repeat',$this->data);
  925. }
  926. //修改
  927. public function _edit($arg_array)
  928. {
  929. if(isset($_SESSION['api']))
  930. {
  931. $user = $this->user->get_api($_SESSION['api']);
  932. if($user['vip'] == 1)
  933. {
  934. $vip = 1;
  935. $this->data['userid'] = $user['id'];
  936. }
  937. else
  938. {
  939. $vip = 0;
  940. $this->data['userid'] = 0;
  941. }
  942. }
  943. else
  944. {
  945. $this->data['userid'] = 0;
  946. $vip = 0;
  947. }
  948. $post = $this->input->post(NULL, TRUE);
  949. if(isset($post['id']))
  950. {
  951. $id = $this->input->post('id',true);
  952. $data = $this->fullordertt->read($id);
  953. $post['type'] = $this->input->post('warehouse',true);
  954. $post['country'] = $this->input->post('country',true);
  955. $currency = $this->country->read($post['country']);
  956. $post['al'] = $currency['lb'];
  957. $post['freight'] = $this->input->post('freight',true);
  958. $post['expressmoney'] = $this->input->post('expressmoney',true);
  959. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  960. $orderremarks = $this->input->post('orderremarks');
  961. $orderremarks = str_replace(array('%26','%2B'),array('&','+'),$orderremarks);
  962. $post['orderremarks'] = $orderremarks;
  963. $shipremarks = $this->input->post('shipremarks');
  964. $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);
  965. $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
  966. $post['email'] = $this->input->post('email',true);
  967. //$post['paypal'] = $this->input->post('paypal',true);
  968. $name = $this->input->post('name',true);
  969. $post['name'] = str_replace("'","’",$name);
  970. $post['phone'] = $this->input->post('phone',true);
  971. $post['phone'] = preg_replace('/\D/s','',$post['phone']);
  972. $post['country'] = $this->input->post('country',true);
  973. $post['province'] = $this->input->post('province',true);//省、州
  974. $post['province'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['province']); //替换开头空字符
  975. $post['province'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['province']); //替换结尾空字符
  976. $post['city'] = $this->input->post('city',true);//城市
  977. $post['city'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['city']); //替换开头空字符
  978. $post['city'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['city']); //替换结尾空字符
  979. $post['zipcode'] = $this->input->post('zipcode',true);//邮编
  980. $post['zipcode'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['zipcode']); //替换开头空字符
  981. $post['zipcode'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['zipcode']); //替换结尾空字符
  982. $post['street'] = $this->input->post('street',true);
  983. $address = $this->input->post('address',true);
  984. $address = preg_replace('/( | | |\s)/',' ',$address);
  985. $post['address'] = str_replace("'","’",$address);
  986. $address2 = $this->input->post('address2',true);
  987. $address2 = preg_replace('/( | | |\s)/',' ',$address2);
  988. if($address2 == ' ')
  989. {
  990. $address2 = '';
  991. }
  992. $post['address2'] = str_replace("'","’",$address2);
  993. $post['express'] = $this->input->post('express',true);
  994. $post['printtype'] = $this->input->post('printtype',true);
  995. $fpdata = $this->input->post('fpdata');
  996. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  997. $post['fpdata'] = $fpdata;
  998. $post['waybill'] = $this->input->post('waybill',true);
  999. $post['msg'] = $this->input->post('msg',true);
  1000. $post['zsbjz'] = $this->input->post('zsbjz',true);
  1001. $post['refundy'] = $this->input->post('refundy',true);
  1002. $post['refundj'] = $this->input->post('refundj',true);
  1003. $rtime = $this->input->post('rtime',true);
  1004. $post['rtime'] = strtotime($rtime);
  1005. $post['rpaypal'] = $this->input->post('rpaypal',true);
  1006. $post['rtext'] = $this->input->post('rtext',true);
  1007. $post['sbpm'] = $this->input->post('sbpm',true);
  1008. $post['edittime'] = time();
  1009. $editstate = $this->input->post('state',true);
  1010. $whlabel = $this->input->post('whlabel',true);
  1011. $fpcount = $this->input->post('fpcount',true);
  1012. $post['ioss'] = $this->input->post('ioss',true);
  1013. $post['waybill'] = preg_replace('/( | | | |\s)/','',$post['waybill']);
  1014. $pay = $this->pay->get_typeclass($data['pay']);
  1015. $yga = $post['shouldmoney'];
  1016. $ygc = $data['estimaterate'];
  1017. $post['budget'] = $this->input->post('newbudget',true);
  1018. //$post['budget'] = $this->input->post('newbudget',true);
  1019. /**
  1020. $post['budget'] = 0;
  1021. $ifbudget = eval("return $yga*1.$ygc;");
  1022. if($ifbudget > 0)
  1023. {
  1024. $post['budget'] = eval("return $yga*1.$ygc;");
  1025. }
  1026. **/
  1027. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  1028. foreach ($whlabeldata as $va)
  1029. {
  1030. if(stripos($va,'z') !== false)
  1031. {
  1032. $way += 1;
  1033. }
  1034. }
  1035. //如果备注中出现网红的两个字 ,那么在fpdata种的品名中必须有 WH这两个字 且美仓不用
  1036. if($post['type'] !=5 ){
  1037. if(stripos($post['shipremarks'],'网红') !== false){
  1038. if(stripos($post['fpdata'],'-2090-') === false){
  1039. echo json_encode(array('msg'=>'网红单请在商品名称中勾选WH!','success'=>false));exit;
  1040. }
  1041. }
  1042. }
  1043. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64 || $post['express'] == 81 || $post['express'] == 83 || $post['express'] == 85 || $post['express'] == 87) && $post['type'] != 5) || ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['express'] != 81 && $post['express'] != 83 && $post['express'] != 85 & $post['express'] != 87 && $post['type'] == 5))
  1044. {
  1045. echo json_encode(array('msg'=>'此快递方式不可从美仓发货!','success'=>false));exit;
  1046. }
  1047. // if($post['express'] == 42 && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods' && $post['type'] != 34)//$post['express'] == 3 ||
  1048. // {
  1049. // echo json_encode(array('msg'=>'此快递方式必须选择Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1050. // }
  1051. //减少代码复用吧
  1052. if($post['type'] != 34){
  1053. $lo_ret = $this->logic_order->checkEditExpress($post);
  1054. if($lo_ret['code'] != 1){
  1055. echo json_encode(array('msg'=>$lo_ret['msg'],'success'=>false));exit;
  1056. }
  1057. }
  1058. $r = $this->logic_order->checkTtCate($post['cate_one'],$post['cate_two']);
  1059. if(!$r){
  1060. echo json_encode(array('msg'=>"请选择订单分类2的选项",'success'=>false));exit;
  1061. }
  1062. if($post['express'] == 24 && $post['sbpm'] != 'Hair Sample' && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods' && $post['type'] != 34)//$post['express'] == 3 ||
  1063. {
  1064. echo json_encode(array('msg'=>'此快递方式必须选择Hair Sample/Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1065. }
  1066. if($post['country'] != 192 && $post['express'] == 1 && $post['sbpm'] != 'Synthetic Hair Wigs' && $post['sbpm'] != 'Synthetic Hair Goods' && $post['type'] != 34)//$post['express'] == 3 ||
  1067. {
  1068. echo json_encode(array('msg'=>'非美国选择官方DHL必须选择Synthetic Hair Wigs/Synthetic Hair Goods','success'=>false));exit;
  1069. }
  1070. if($way == count($whlabeldata) && $post['type'] != 12)
  1071. {
  1072. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1073. }
  1074. if($way == '0' && $post['type'] == 12)
  1075. {
  1076. echo json_encode(array('msg'=>'特殊仓必须包含特殊仓货物!','success'=>false));exit;
  1077. }
  1078. $post['review'] = 1;
  1079. if($post['zsbjz'] < '0.01' && $post['type'] != 34)
  1080. {
  1081. echo json_encode(array('msg'=>'总申报价错误!'.$post['type'],'success'=>false));exit;
  1082. }
  1083. if($data['library'] == 1)
  1084. {
  1085. if($data['print'] != 3)
  1086. {
  1087. $post['print'] = 1;
  1088. $post['libraryconfirm'] = 1;
  1089. $post['librarynot'] = "订单未打印,未审核或未通过";
  1090. }
  1091. else
  1092. {
  1093. $post['libraryconfirm'] = 1;
  1094. $post['librarynot'] = "订单被修改或重新提交";
  1095. }
  1096. }
  1097. if($data['yhs'] == 1)
  1098. {
  1099. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1100. }
  1101. if($post['express'] == 2 && (stripos($post['name'],'&') !== false || stripos($post['name'],"'") !== false))
  1102. {
  1103. echo json_encode(array('msg'=>'USPS收件人或公司名不可用特殊符号!','success'=>false));exit;
  1104. }
  1105. if(strlen($post['client']) > 34 || strlen($post['name']) > 34)//收件人姓名或公司名不允许超过35位
  1106. {
  1107. if($post['express'] != 83){
  1108. echo json_encode(array('msg'=>'收件人姓名或公司名不可超过34个字符!','success'=>false));exit;
  1109. }
  1110. }
  1111. if($post['express'] == '3' && $post['address2'] != '')//UPS不允许提交地址2
  1112. {
  1113. echo json_encode(array('msg'=>'UPS不允许提交地址2','success'=>false));exit;
  1114. }
  1115. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '42' || $post['express'] == '31') && $post['country'] != 192 && $post['type'] != 34)
  1116. {
  1117. echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
  1118. }
  1119. if($post['express'] == '3' && $post['country'] != 192 && $post['country'] != 35)
  1120. {
  1121. echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
  1122. }
  1123. if($post['country'] == 35 && $post['zsbjz'] > 20)
  1124. {
  1125. echo json_encode(array('msg'=>'加拿大最高申报不可超过20','success'=>false));exit;
  1126. }
  1127. if(($post['express'] == '28' || $post['express'] == '7') && $post['country'] != 191)
  1128. {
  1129. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1130. }
  1131. $express = $this->express->read($post['express']);
  1132. if($express['ioss'] == 1 && $post['ioss'] == '')
  1133. {
  1134. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1135. }
  1136. if(strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize'])
  1137. {
  1138. echo json_encode(array('msg'=>'此快递地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  1139. }
  1140. // 根据禁用处理32长度
  1141. // if(strlen($post['address']) > 32 && ($post['express'] == 2 || $post['express'] == 16))
  1142. // {
  1143. // echo json_encode(array('msg'=>'此快递地址不可超出32个字符','success'=>false));exit;
  1144. // }
  1145. if(strlen($post['address']) < 5)
  1146. {
  1147. echo json_encode(array('msg'=>'地址不可留空!','success'=>false));exit;
  1148. }
  1149. if(($express['sbjz'] > 0) && ($post['zsbjz'] > $express['sbjz']))
  1150. {
  1151. echo json_encode(array('msg'=>'总申报价值不可超出'.$express['sbjz'],'success'=>false));exit;
  1152. }
  1153. if($post['shouldmoney'] > $express['shouldmoney'] && $express['shouldmoney'] != 0)
  1154. {
  1155. echo json_encode(array('msg'=>'订单金额不可超出'.$express['shouldmoney'],'success'=>false));exit;
  1156. }
  1157. if($post['express'] == '2' && $post['zzl'] > '16' && isset($post['js']) && $post['js'] == '0')
  1158. {
  1159. echo json_encode(array('msg'=>'重量大于16不可按Ground Advantage提交!','success'=>false));exit;
  1160. }
  1161. if($post['express'] == '2' && isset($post['js']) && $post['js'] == '0'&& $post['qm'] == '1')
  1162. {
  1163. echo json_encode(array('msg'=>'Ground Advantage不可使用签名服务!','success'=>false));exit;
  1164. }
  1165. if(isset($post['bx']))
  1166. {
  1167. if($post['express'] == '99' && $post['bx'] > 0)
  1168. {
  1169. echo json_encode(array('msg'=>'此物流不允许购买保险','success'=>false));exit;
  1170. }
  1171. }
  1172. if(($post['express'] == '3' || $post['express'] == '42' || $post['express'] == '24') && $post['shouldmoney'] < 1)
  1173. {
  1174. //echo json_encode(array('msg'=>'零金额订单不可发 UPS/DHL官方-美国/Fedex(杭州)','success'=>false));exit;
  1175. }
  1176. if($post['express'] == '42' && $post['zsbjz'] < 1)
  1177. {
  1178. echo json_encode(array('msg'=>'零申报金额不可发 DHL官方-美国','success'=>false));exit;
  1179. }
  1180. if($post['express'] == '6' && $post['province'] == '')
  1181. {
  1182. echo json_encode(array('msg'=>'选择DPEX必须填写州信息','success'=>false));exit;
  1183. }
  1184. if(($post['express'] == '24' || $post['express'] == '3') && $post['shouldmoney'] == 0)
  1185. {
  1186. echo json_encode(array('msg'=>'0金额订单不可发UPS/Fedex(杭州)!!!','success'=>false));exit;
  1187. }
  1188. if($post['country'] == '35' && $post['zsbjz'] > 20)
  1189. {
  1190. echo json_encode(array('msg'=>'加拿大不可申报超过20美金!!!','success'=>false));exit;
  1191. }
  1192. if($post['printtype'] == 1)//如果是运单
  1193. {
  1194. $post['productdescription'] = $this->input->post('productdescription',true);
  1195. $post['customs'] = $this->input->post('customs',true);
  1196. }
  1197. if($post['express'] == 2 && strlen($post['zipcode']) != 5)//如果usps 邮编不是5位
  1198. {
  1199. echo json_encode(array('msg'=>'USPS-USA的邮编需按5位数格式提交!','success'=>false));exit;
  1200. }
  1201. if(strlen($post['phone']) > 11 && $post['express'] == 63)
  1202. {
  1203. echo json_encode(array('msg'=>'美国联邦,电话号码不允许超过11位!','success'=>false));exit;
  1204. }
  1205. /**
  1206. if($post['paypal'] != '')
  1207. {
  1208. $pp = $this->fullordertt->get_paypal($post['paypal']);
  1209. if(isset($pp['number']) && $pp['number'] != $data['number'])
  1210. {
  1211. echo json_encode(array('msg'=>'此交易号的订单已存在!-'.$pp['number'],'success'=>false));exit;
  1212. }
  1213. }
  1214. **/
  1215. /**
  1216. if($editstate == 216 && $data['state'] != 216)
  1217. {
  1218. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1219. }
  1220. **/
  1221. if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  1222. {
  1223. //echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  1224. }
  1225. else
  1226. {
  1227. $post['review'] = $data['review'];
  1228. $post['state'] = $editstate;
  1229. }
  1230. $thisdata = $this->fullordertt->read($id);
  1231. $warehouse = $this->warehouse->read($thisdata['type']);
  1232. $warehousenew = $this->warehouse->read($post['type']);
  1233. if($warehousenew['bdcountry'] != 0 && $post['country'] != $warehousenew['bdcountry'])
  1234. {
  1235. echo json_encode(array('msg'=>'当前国家无法选择'.$warehousenew['title'].'!','success'=>false));exit;
  1236. }
  1237. /**
  1238. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1239. {
  1240. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1241. }
  1242. **/
  1243. if($thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1244. {
  1245. echo json_encode(array('msg'=>'此单已出库,无法更改仓库!','success'=>false));exit;
  1246. }
  1247. $expt = $this->express->read($post['express']);
  1248. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false && $post['type'] != 34)
  1249. {
  1250. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1251. }
  1252. if($expt['province'] != '' && stripos($expt['province'],$post['province'].'、') !== false)
  1253. {
  1254. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1255. }
  1256. /**
  1257. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1258. {
  1259. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1260. }
  1261. **/
  1262. //开始注释 xyxg
  1263. /**
  1264. $ft = array();
  1265. $ftdata = explode('|',rtrim($fpcount,'|'));
  1266. foreach ($ftdata as $va)
  1267. {
  1268. $ftitle = '';
  1269. $va = explode('-',trim($va,'-'));
  1270. foreach ($va as $v)
  1271. {
  1272. $v = $this->typeclass->read($v);
  1273. $ftitle .= $v['title'].' ';
  1274. }
  1275. $ft[] = rtrim($ftitle,' ');
  1276. }
  1277. if($data['library'] == 1)
  1278. {
  1279. $tqkcyz = $this->_kcyz($post['type'],$whlabel,$id,$data['shop'],$data['number']);
  1280. if(isset($tqkcyz[0]))
  1281. {
  1282. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$tqkcyz,'success'=>false));exit;
  1283. }
  1284. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1285. {
  1286. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1287. if($tskcyz['t'] > '0')
  1288. {
  1289. echo $tskcyz['m'];exit;
  1290. }
  1291. }
  1292. $kcyz = $this->whlabel->get_kc($thisdata['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1293. if($kcyz['t'] > '0')
  1294. {
  1295. echo $kcyz['m'];exit;
  1296. }
  1297. }
  1298. //结束注释
  1299. **/
  1300. /** 重新写产品名称
  1301. $dtctitle = array();
  1302. $dictionaries = $this->typeclass->find_all();
  1303. foreach ($dictionaries as $v)
  1304. {
  1305. $dtctitle[$v['id']] = array($v['title'],$v['bqsku']);
  1306. }
  1307. if(stripos($fpdata,'-128-') !== false || stripos($fpdata,'-127-') !== false)
  1308. {
  1309. $dfp = explode(';',trim($fpdata,';'));
  1310. $fdata = '';
  1311. foreach ($dfp as $k=>$v)
  1312. {
  1313. $ptitleb = '';
  1314. $fp = explode('|',trim($v,'|'));
  1315. $fp0 = explode(',',$fp[0]);
  1316. $fp1 = explode('-',trim($fp0[1],'-'));
  1317. foreach ($fp1 as $vv)
  1318. {
  1319. $ptitleb .= isset($dtctitle[$vv])?$dtctitle[$vv][0].' ':'';
  1320. }
  1321. $ptitleb .= $dtctitle[$fp0[0]][1].'inch ';
  1322. $fp[1] = $ptitleb;
  1323. $fdata .= implode("|",$fp).";";
  1324. }
  1325. $fpdata = $fdata;
  1326. }
  1327. **/
  1328. $warehouse = $this->warehouse->read($post['type']);
  1329. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1330. {
  1331. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1332. if($kcyz['t'] > '0')
  1333. {
  1334. echo $kcyz['m'];exit;
  1335. }
  1336. else if($kcyz['fpdata'] != '')
  1337. {
  1338. $post['whlabel'] = $kcyz['whlabel'];
  1339. $post['fpdata'] = $kcyz['fpdata'];
  1340. }
  1341. }
  1342. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1343. $post['sfxh'] = $fl['sfxh'];
  1344. $post['ckfl'] = $fl['ckfl'];
  1345. $post['is_edit'] = 1;
  1346. //查询净重开始
  1347. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1348. //查询净重结束
  1349. if($this->fullordertt->save($post,$id))
  1350. {
  1351. if($data['printtime'] == '0')
  1352. {
  1353. $xghz = ',将自动禁止打印';
  1354. }
  1355. else if($data['printtime'] > '0' && $data['librarytime'] == '0')
  1356. {
  1357. $q = '';
  1358. if($data['libraryconfirm'] == 1)
  1359. {
  1360. $q = ',<em style="color: #F00;">改前状态为:禁止出库</em>';
  1361. }
  1362. $xghz = ',将自动禁止发货'.$q;
  1363. }
  1364. else
  1365. {
  1366. $xghz = '';
  1367. }
  1368. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1369. }
  1370. else
  1371. {
  1372. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1373. }
  1374. }
  1375. $this->data['vip'] = $vip;
  1376. $arg_array = $arg_array[0];$fpdata = array();
  1377. $fullordertt = $this->fullordertt->read($arg_array);
  1378. $returngoods = $this->returngoods->get_orderinfo($fullordertt['orderinfo']);
  1379. $this->data['returngoods'] = $returngoods?1:0;
  1380. $fullordertt['parameter'] = str_replace(",","---",$fullordertt['parameter']);
  1381. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  1382. $express = $this->express->find_all('1=1');//所有快递配置信息
  1383. $fullordertt['cate_one'] = empty($fullordertt['cate_one'])?1:$fullordertt['cate_one'];
  1384. $this->data['fullordertt'] = $fullordertt;
  1385. if($fullordertt['express'] == 2)
  1386. {
  1387. $zzhl = 'oz';
  1388. }
  1389. else
  1390. {
  1391. $zzhl = 'kg';
  1392. }
  1393. $this->data['zzhl'] = $zzhl;
  1394. $this->data['country'] = $country;
  1395. $this->data['express'] = $express;
  1396. $this->data['dtime'] = date('Y-m-d H:i:s',$fullordertt['dtime']);
  1397. $warehouse = $this->warehouse->read($fullordertt['type']);
  1398. if(stripos($fullordertt['fpdata'],';') !== false)
  1399. {
  1400. $fpdata = explode(';',rtrim($fullordertt['fpdata'],';'));
  1401. foreach ($fpdata as $k=>$v)
  1402. {
  1403. $xxv = explode('|',$v);
  1404. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1405. {
  1406. $xxv['zd'] = "<p>已占单</p>";
  1407. $bdck = $warehouse['bdck'];
  1408. if(stripos($xxv[9],'~') !== false)
  1409. {
  1410. $dxxv = explode('~',trim($xxv[9],'~'));
  1411. foreach ($dxxv as $val)
  1412. {
  1413. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1414. if($wzid['details'] != '')
  1415. {
  1416. if($fullordertt['type'] == 5){
  1417. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1418. }else{
  1419. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1420. }
  1421. }
  1422. }
  1423. }
  1424. else
  1425. {
  1426. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1427. if($wzid['details'] != '')
  1428. {
  1429. if($fullordertt['type'] == 5){
  1430. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1431. }else{
  1432. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1433. }
  1434. }
  1435. }
  1436. }
  1437. $fpdata[$k] = $xxv;
  1438. }
  1439. }
  1440. $this->data['fpdata'] = $fpdata;
  1441. $thfpdataxs = array();
  1442. if($fullordertt['thfpdata'] != '')
  1443. {
  1444. $thfpdata = explode(';',trim($fullordertt['thfpdata'],';'));
  1445. foreach ($thfpdata as $k=>$v)
  1446. {
  1447. $thxs = explode('~',trim($v,'~'));
  1448. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1449. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1450. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  1451. }
  1452. }
  1453. $this->data['thfpdata'] = $thfpdataxs;
  1454. $shop = $this->shop->read($fullordertt['shop']);
  1455. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1456. $is = 0;
  1457. if($shop['type'] == 269)//判断是否独立站,269是独立站
  1458. {
  1459. $is = 1;
  1460. }
  1461. $this->data['is'] = $is;
  1462. if(isset($_SESSION['api']))
  1463. {
  1464. $user = $this->user->get_api($_SESSION['api']);
  1465. if($user['vip'] == 1)
  1466. {
  1467. $vip = 1;
  1468. }
  1469. else
  1470. {
  1471. $vip = 0;
  1472. }
  1473. }
  1474. else
  1475. {
  1476. $vip = 0;
  1477. }
  1478. $this->data['power'] = $vip;
  1479. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1480. $downwaybill = '';$dwls = array();
  1481. $oldwaybill = explode('-',ltrim($fullordertt['oldwaybill'],'-'));
  1482. if(isset($oldwaybill[0][1]))
  1483. {
  1484. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1485. foreach ($oldwaybill as $v)
  1486. {
  1487. $dw = explode('/',$v);
  1488. if(isset($dw[1]))
  1489. {
  1490. if(stripos($downwaybill,$dw[1]) === false)
  1491. {
  1492. $dwls[$dw[1]] = 1;
  1493. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1494. }
  1495. }
  1496. }
  1497. }
  1498. if($fullordertt['printtype'] == 1)
  1499. {
  1500. if($fullordertt['waybill'] != '' && !isset($dwls[$fullordertt['waybill']]))
  1501. {
  1502. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordertt['printtime']).'/y-'.$fullordertt['waybill'].'.pdf" target="_blank">'.$fullordertt['waybill'].'</a>、'.$downwaybill;
  1503. }
  1504. }
  1505. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1506. /** 历史打印时间 **/
  1507. $printtime = '';
  1508. if($fullordertt['oldprinttime'])
  1509. {
  1510. $pte = explode('-',rtrim($fullordertt['oldprinttime'],'-'));
  1511. foreach ($pte as $v)
  1512. {
  1513. $printtime .= date('Y-m-d H:i:s',$v).'、';
  1514. }
  1515. }
  1516. $this->data['printtime'] = rtrim($printtime,'、');
  1517. $product = '';
  1518. $fullordertt['product'] = str_replace("'","",$fullordertt['product']);
  1519. if($fullordertt['link'] != '' && $fullordertt['source'] != '1')
  1520. {
  1521. $pt = explode(',',$fullordertt['product']);
  1522. $lk = explode(',',$fullordertt['link']);
  1523. for($i=0;$i<count($pt);$i++)
  1524. {
  1525. if(isset($lk[$i]))
  1526. {
  1527. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  1528. }
  1529. else
  1530. {
  1531. $octs = '';
  1532. }
  1533. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  1534. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  1535. if(isset($lk[$i]))
  1536. {
  1537. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  1538. }
  1539. else
  1540. {
  1541. $product .= ($product != '')?' , '.$a:$a;
  1542. }
  1543. }
  1544. }
  1545. else
  1546. {
  1547. $octs = $this->colourorderts->get_text($fullordertt['product']);
  1548. $a = $octs?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  1549. //$a = (stripos($fullordertt['product'],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($fullordertt['product'],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($fullordertt['product'],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($fullordertt['product'],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($fullordertt['product'],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($fullordertt['product'],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($fullordertt['product'],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($fullordertt['product'],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($fullordertt['product'],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  1550. $product = $a;
  1551. }
  1552. $this->data['product'] = $product;
  1553. $ts_msg_flag = 0;
  1554. $ts_msg_msg = '';
  1555. if(in_array($fullordertt['express'],[85,87])){
  1556. if(empty($fullordertt['extra_text'])){
  1557. $this->data['serve_list'] = [];
  1558. }else{
  1559. $extra_info = json_decode($fullordertt['extra_text'],true);
  1560. if(isset($extra_info['server_info'])){
  1561. $this->data['serve_list'] = $extra_info['server_info']['shipping_services'];
  1562. foreach($extra_info['server_info']['shipping_services'] as $v1){
  1563. if((strpos($v1['shipping_provider_name'],'USPS') === false) && (strpos($v1['shipping_provider_name'],'FedEx') === false)){
  1564. $ts_msg_flag = 1;
  1565. $ts_msg_msg = "注意".$v1['shipping_provider_name']."出现!!!请勿选择此快递!";
  1566. }
  1567. }
  1568. }else{
  1569. $this->data['serve_list'] = [];
  1570. }
  1571. }
  1572. }else{
  1573. $this->data['serve_list'] = [];
  1574. }
  1575. $this->data['ts_msg_flag'] = $ts_msg_flag;
  1576. $this->data['ts_msg_msg'] = $ts_msg_msg;
  1577. $out = $this->systemtransfer->find_all("number = '".$fullordertt['number']."'");
  1578. $outread = '';
  1579. if($out)
  1580. {
  1581. foreach ($out as $val)
  1582. {
  1583. $list = '';
  1584. $rk = explode('|',trim($val['rk'],'|'));
  1585. $rktime = explode('|',trim($val['rktime'],'|'));
  1586. $zw = array();
  1587. $t = $this->transfer->find_all("1=1");
  1588. foreach ($t as $v)
  1589. {
  1590. $zw[$v['id']] = $v['title'];
  1591. }
  1592. if($val['rk'] != '' && count($rk) > 0)
  1593. {
  1594. for($i=0;$i<count($rk);$i++)
  1595. {
  1596. if(!isset($rktime[$i]))
  1597. {
  1598. $list .= $zw[$cz[$i]];
  1599. }
  1600. else
  1601. {
  1602. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1603. }
  1604. }
  1605. }
  1606. //$outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1607. $outread .= '<span style="color:#f00">'.$val['shipremarks'].'</span>:'.$list.'<br>';
  1608. }
  1609. }
  1610. else
  1611. {
  1612. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordertt['number']."'");
  1613. $outread = array();
  1614. if($systemwigsout)
  1615. {
  1616. foreach ($systemwigsout as $v)
  1617. {
  1618. if($v['czwarehouse'] == 37)
  1619. {
  1620. $outread[] = '华荣厂';
  1621. }
  1622. else if($v['czwarehouse'] == 0)
  1623. {
  1624. $outread[] = '龙盈厂';
  1625. }
  1626. $cz = explode('|',trim($v['cz'],'|'));
  1627. $cztime = explode('|',trim($v['cztime'],'|'));
  1628. $zw = $this->transfer->get_list();
  1629. if($v['cz'] != '' && count($cz) > 0)
  1630. {
  1631. for($i=0;$i<count($cz);$i++)
  1632. {
  1633. if(!isset($cztime[$i]))
  1634. {
  1635. $outread[] = $zw[$cz[$i]].' -&gt; ';
  1636. }
  1637. else
  1638. {
  1639. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1640. }
  1641. }
  1642. $outread[] = '<br>';
  1643. }
  1644. }
  1645. }
  1646. }
  1647. $klarnacolor = '';
  1648. if($fullordertt['klarnadata'] !='')
  1649. {
  1650. $klarnadata = explode('|',$fullordertt['klarnadata']);
  1651. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  1652. {
  1653. $klarnadata[1] = json_decode($klarnadata[1],true);
  1654. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullordertt['shouldmoney'] && $fullordertt['pay'] == 1211)
  1655. {
  1656. $klarnacolor = 'style="color:#F00"';
  1657. }
  1658. }
  1659. else if($klarnadata[0]!=1 && $fullordertt['pay']!=26 && $fullordertt['pay']!=27 && $fullordertt['pay']!=1211)
  1660. {
  1661. $klarnacolor = 'style="color:#F00"';
  1662. }
  1663. if($fullordertt['pay'] == 23)//klarna
  1664. {
  1665. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU','puerto rico'=>'PR');
  1666. $ToState = array_flip($ToState);
  1667. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  1668. $city = str_replace(' ','',$fullordertt['city']);
  1669. $klarnadataaddress = explode($city,$klarnadata3);
  1670. if(isset($klarnadataaddress[1]))
  1671. {
  1672. $klarnadata3 = $city.$klarnadataaddress[1];
  1673. $klarnadatacolor = explode(',',$klarnadata3);
  1674. unset($klarnadatacolor[4]);
  1675. unset($klarnadatacolor[6]);
  1676. if(isset($ToState[$klarnadatacolor[1]]))
  1677. {
  1678. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  1679. }
  1680. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  1681. }
  1682. else
  1683. {
  1684. $klarnadata['color'] = $klarnadata3;
  1685. }
  1686. }
  1687. }
  1688. else
  1689. {
  1690. $klarnadata = '';
  1691. }
  1692. $p = explode('-',$fullordertt['paypal']);
  1693. $this->data['klarnacolor'] = $klarnacolor;
  1694. $this->data['klarnadata'] = $klarnadata;
  1695. $this->data['systemwigsout'] = $outread;
  1696. $this->data['cate_one_list'] = $this->fullordertt->getCateOne();
  1697. $cate_two = $this->fullordertt->getCateTwo();
  1698. $this->data['cate_two_json'] = json_encode($cate_two,JSON_UNESCAPED_UNICODE);
  1699. $quantity = explode(';',trim($fullordertt['quantity'],';'));
  1700. $qc = 0;
  1701. foreach ($quantity as $v)
  1702. {
  1703. if($v > 1)
  1704. {
  1705. $qc += 1;
  1706. }
  1707. }
  1708. $this->data['qc'] = $qc;
  1709. $this->_Template('fullordertt_edit',$this->data);
  1710. }
  1711. //不可修改
  1712. public function _readonly($arg_array)
  1713. {
  1714. $post = $this->input->post(NULL, TRUE);
  1715. if(isset($post['id']))
  1716. {
  1717. $id = $this->input->post('id',true);
  1718. $ud = $this->fullordertt->read($id);
  1719. $post['type'] = $this->input->post('warehouse',true);
  1720. $post['orderremarks'] = $this->input->post('orderremarks',true);
  1721. $post['state'] = $this->input->post('state',true);
  1722. $post['msg'] = $this->input->post('msg',true);
  1723. $post['refundy'] = $this->input->post('refundy',true);
  1724. $post['refundj'] = $this->input->post('refundj',true);
  1725. $fpdata = $this->input->post('fpdata');
  1726. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  1727. $post['fpdata'] = $fpdata;
  1728. $rtime = $this->input->post('rtime',true);
  1729. $post['rtime'] = strtotime($rtime);
  1730. $post['rpaypal'] = $this->input->post('rpaypal',true);
  1731. $post['rtext'] = $this->input->post('rtext',true);
  1732. $post['express'] = $this->input->post('express',true);
  1733. $whlabel = $this->input->post('whlabel',true);
  1734. $post['budget'] = $this->input->post('newbudget',true);
  1735. //$post['ioss'] = $this->input->post('ioss',true);
  1736. $post['edittime'] = time();
  1737. $editstate = $post['state'];
  1738. /**
  1739. if($post['state'] == 216 && $ud['state'] != 216)
  1740. {
  1741. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1742. }
  1743. **/
  1744. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  1745. foreach ($whlabeldata as $va)
  1746. {
  1747. if(stripos($va,'z') !== false)
  1748. {
  1749. $way += 1;
  1750. }
  1751. }
  1752. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64 || $post['express'] == 81 || $post['express'] == 83) && $post['type'] != 5) || ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['express'] != 81 && $post['express'] != 83 && $post['type'] == 5))
  1753. {
  1754. echo json_encode(array('msg'=>'此快递方式必须选择美国仓!','success'=>false));exit;
  1755. }
  1756. if($way == count($whlabeldata) && $post['type'] != 12)
  1757. {
  1758. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1759. }
  1760. if($way == '0' && $post['type'] == 12)
  1761. {
  1762. echo json_encode(array('msg'=>'特殊仓必须包含特殊仓货物!','success'=>false));exit;
  1763. }
  1764. $fpcount = $this->input->post('fpcount',true);
  1765. if(!$fpcount)
  1766. {
  1767. echo json_encode(array('msg'=>'需要先清理浏览器缓存,刷新当前页面后再试!','success'=>false));exit;
  1768. }
  1769. if($ud['library'] == 1)
  1770. {
  1771. if($ud['print'] != 3)
  1772. {
  1773. $post['print'] = 1;
  1774. $post['libraryconfirm'] = 1;
  1775. $post['librarynot'] = "订单未打印,未审核或未通过";
  1776. }
  1777. else
  1778. {
  1779. $post['libraryconfirm'] = 1;
  1780. $post['librarynot'] = "订单被重新提交";
  1781. }
  1782. }
  1783. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '42' || $post['express'] == '31') && $ud['country'] != 192)
  1784. {
  1785. echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
  1786. }
  1787. if($post['express'] == '3' && $ud['country'] != 192 && $ud['country'] != 35)
  1788. {
  1789. echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
  1790. }
  1791. if(($post['express'] == '28' || $post['express'] == '7') && $ud['country'] != 191)
  1792. {
  1793. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1794. }
  1795. $r = $this->logic_order->checkTtCate($post['cate_one'],$post['cate_two']);
  1796. if(!$r){
  1797. echo json_encode(array('msg'=>"请选择订单分类2的选项",'success'=>false));exit;
  1798. }
  1799. if($post['type'] != 5 && in_array($post['express'],[2,63,64,81,83,85,87]))
  1800. {
  1801. echo json_encode(array('msg'=>"此快递方式必须从美仓发货!",'success'=>false));exit;
  1802. }
  1803. if($post['type'] == 5 && !in_array($post['express'],[2,63,64,81,83,85,87]))
  1804. {
  1805. echo json_encode(array('msg'=>"此快递方式不能美仓发货!",'success'=>false));exit;
  1806. }
  1807. $express = $this->express->read($post['express']);
  1808. /**
  1809. if($express['ioss'] == 1 && $post['ioss'] == '')
  1810. {
  1811. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1812. }
  1813. **/
  1814. $thisdata = $this->fullordertt->read($id);
  1815. $warehouse = $this->warehouse->read($thisdata['type']);
  1816. $warehousenew = $this->warehouse->read($post['type']);
  1817. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1818. {
  1819. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1820. }
  1821. if($ud['yhs'] == 1)
  1822. {
  1823. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1824. }
  1825. $expt = $this->express->read($post['express']);
  1826. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1827. {
  1828. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1829. }
  1830. if($expt['province'] != '' && stripos($expt['province'],$ud['province'].'、') !== false)
  1831. {
  1832. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1833. }
  1834. /**
  1835. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1836. {
  1837. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1838. }
  1839. **/
  1840. /**
  1841. if($warehousenew['zd'] == '1' && $editstate != $thisdata['state'] && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1842. {
  1843. echo json_encode(array('msg'=>'如需更改订单状态,请先把仓库选择为非开启库存模式仓库或等待订单出库!','success'=>false));exit;
  1844. }
  1845. if($warehousenew['zd'] == '1' && $editstate != '207' && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1846. {
  1847. echo json_encode(array('msg'=>'非待发货状态,不允许修改为开启库存模式仓库','success'=>false));exit;
  1848. }
  1849. **/
  1850. //开始注释 xyxg
  1851. /**
  1852. $ft = array();
  1853. $ftdata = explode('|',rtrim($fpcount,'|'));
  1854. foreach ($ftdata as $va)
  1855. {
  1856. $ftitle = '';
  1857. $va = explode('-',trim($va,'-'));
  1858. foreach ($va as $v)
  1859. {
  1860. $v = $this->typeclass->read($v);
  1861. $ftitle .= $v['title'].' ';
  1862. }
  1863. $ft[] = rtrim($ftitle,' ');
  1864. }
  1865. $user = $this->user->get_api($_SESSION['api']);
  1866. if($ud['library'] == 1)
  1867. {
  1868. $tqkcyz = $this->_kcyz($post['type'],$whlabel,$id,$ud['shop'],$ud['number']);
  1869. if(isset($tqkcyz[0]))
  1870. {
  1871. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$tqkcyz,'success'=>false));exit;
  1872. }
  1873. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1874. {
  1875. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1876. if($tskcyz['t'] > '0')
  1877. {
  1878. echo $tskcyz['m'];exit;
  1879. }
  1880. }
  1881. $kcyz = $this->whlabel->get_kc($thisdata['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1882. if($kcyz['t'] > '0')
  1883. {
  1884. echo $kcyz['m'];exit;
  1885. }
  1886. }
  1887. //结束注释
  1888. **/
  1889. $warehouse = $this->warehouse->read($post['type']);
  1890. if($ud['library'] == 1 || ($ud['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1891. {
  1892. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1893. if($kcyz['t'] > '0')
  1894. {
  1895. echo $kcyz['m'];exit;
  1896. }
  1897. else if($kcyz['fpdata'] != '')
  1898. {
  1899. $post['whlabel'] = $kcyz['whlabel'];
  1900. $post['fpdata'] = $kcyz['fpdata'];
  1901. }
  1902. }
  1903. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1904. $post['sfxh'] = $fl['sfxh'];
  1905. $post['ckfl'] = $fl['ckfl'];
  1906. //查询净重开始
  1907. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1908. //查询净重结束
  1909. if($this->fullordertt->save($post,$id))
  1910. {
  1911. if($ud['printtime'] == '0')
  1912. {
  1913. $xghz = ',将自动禁止打印';
  1914. }
  1915. else if($ud['printtime'] > '0' && $ud['librarytime'] == '0')
  1916. {
  1917. $q = '';
  1918. if($ud['libraryconfirm'] == 1)
  1919. {
  1920. $q = ',<em style="color: #F00;">改前状态为:禁止出库</em>';
  1921. }
  1922. $xghz = ',将自动禁止发货'.$q;
  1923. }
  1924. else
  1925. {
  1926. $xghz = '';
  1927. }
  1928. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1929. }
  1930. else
  1931. {
  1932. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1933. }
  1934. }
  1935. $arg_array = $arg_array[0];$fpdata = array();
  1936. $fullordertt = $this->fullordertt->read($arg_array);
  1937. $returngoods = $this->returngoods->get_orderinfo($fullordertt['orderinfo']);
  1938. $this->data['returngoods'] = $returngoods?1:0;
  1939. $fullordertt['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullordertt['shipremarks']);
  1940. $fullordertt['parameter'] = str_replace(",","---",$fullordertt['parameter']);
  1941. $fullordertt['cate_one'] = empty($fullordertt['cate_one'])?1:$fullordertt['cate_one'];
  1942. $this->data['fullordertt'] = $fullordertt;
  1943. if($fullordertt['express'] == 2)
  1944. {
  1945. $zzhl = 'oz';
  1946. }
  1947. else
  1948. {
  1949. $zzhl = 'kg';
  1950. }
  1951. $this->data['zzhl'] = $zzhl;
  1952. $this->data['countrys'] = $this->country->find_all();
  1953. $this->data['express'] = $this->express->find_all();
  1954. $warehouse = $this->warehouse->read($fullordertt['type']);
  1955. if(stripos($fullordertt['fpdata'],';') !== false)
  1956. {
  1957. $fpdata = explode(';',rtrim($fullordertt['fpdata'],';'));
  1958. foreach ($fpdata as $k=>$v)
  1959. {
  1960. $xxv = explode('|',$v);
  1961. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1962. {
  1963. $xxv['zd'] = "<p>已占单</p>";
  1964. $bdck = $warehouse['bdck'];
  1965. if(stripos($xxv[9],'~') !== false)
  1966. {
  1967. $dxxv = explode('~',trim($xxv[9],'~'));
  1968. foreach ($dxxv as $val)
  1969. {
  1970. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1971. if($wzid['details'] != '')
  1972. {
  1973. if($fullordertt['type'] == 5){
  1974. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1975. }else{
  1976. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1977. }
  1978. }
  1979. }
  1980. }
  1981. else
  1982. {
  1983. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1984. if($wzid['details'] != '')
  1985. {
  1986. if($fullordertt['type'] == 5){
  1987. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1988. }else{
  1989. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1990. }
  1991. }
  1992. }
  1993. }
  1994. $fpdata[$k] = $xxv;
  1995. }
  1996. }
  1997. $this->data['fpdata'] = $fpdata;
  1998. $this->data['fpdata'] = $fpdata;
  1999. $thfpdataxs = array();
  2000. if($fullordertt['thfpdata'] != '')
  2001. {
  2002. $thfpdata = explode(';',trim($fullordertt['thfpdata'],';'));
  2003. foreach ($thfpdata as $k=>$v)
  2004. {
  2005. $thxs = explode('~',trim($v,'~'));
  2006. $thxs[0] = explode('|',trim($thxs[0],'|'));
  2007. $thxs[1] = explode('|',trim($thxs[1],'|'));
  2008. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  2009. }
  2010. }
  2011. $this->data['thfpdata'] = $thfpdataxs;
  2012. $shop = $this->shop->read($fullordertt['shop']);
  2013. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  2014. $is = 0;
  2015. if($shop['type'] == 269)//判断是否独立站,269是独立站
  2016. {
  2017. $is = 1;
  2018. }
  2019. $this->data['is'] = $is;
  2020. //单项开始
  2021. $warehouse = $this->warehouse->read($fullordertt['warehouse']);//发货仓库
  2022. $state = $this->typeclass->read($fullordertt['state']);//订单状态
  2023. $country = $this->country->read($fullordertt['country']);//国家
  2024. if($fullordertt['capital'] == 1)
  2025. {
  2026. $capital = '暂未支付';
  2027. }
  2028. else if($fullordertt['capital'] == 2)
  2029. {
  2030. $capital = '部分支付';
  2031. }
  2032. else if($fullordertt['capital'] == 3)
  2033. {
  2034. $capital = '全部支付';
  2035. }
  2036. if($fullordertt['printtype'] == 1)
  2037. {
  2038. $printtype = '运单';
  2039. }
  2040. else if($fullordertt['printtype'] == 2)
  2041. {
  2042. $printtype = '发货单';
  2043. }
  2044. else if($fullordertt['printtype'] == 3)
  2045. {
  2046. $printtype = '不打印单据';
  2047. }
  2048. else
  2049. {
  2050. $printtype = '未选择';
  2051. }
  2052. $this->data['warehouse'] = $warehouse['title'];
  2053. $this->data['state'] = $state['title'];
  2054. $this->data['capital'] = $capital;
  2055. $this->data['country'] = $country['name'];
  2056. $this->data['printtype'] = $printtype;
  2057. //单项结束
  2058. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  2059. $downwaybill = '';$dwls = array();
  2060. $oldwaybill = explode('-',ltrim($fullordertt['oldwaybill'],'-'));
  2061. if(isset($oldwaybill[0][1]))
  2062. {
  2063. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  2064. foreach ($oldwaybill as $v)
  2065. {
  2066. $dw = explode('/',$v);
  2067. if(isset($dw[1]))
  2068. {
  2069. if(stripos($downwaybill,$dw[1]) === false)
  2070. {
  2071. $dwls[$dw[1]] = 1;
  2072. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  2073. }
  2074. }
  2075. }
  2076. }
  2077. if($fullordertt['printtype'] == 1)
  2078. {
  2079. if($fullordertt['waybill'] != '' && !isset($dwls[$fullordertt['waybill']]))
  2080. {
  2081. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordertt['printtime']).'/y-'.$fullordertt['waybill'].'.pdf" target="_blank">'.$fullordertt['waybill'].'</a>、'.$downwaybill;
  2082. }
  2083. }
  2084. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  2085. /** 历史打印时间 **/
  2086. $printtime = '';
  2087. if($fullordertt['oldprinttime'])
  2088. {
  2089. $pte = explode('-',rtrim($fullordertt['oldprinttime'],'-'));
  2090. foreach ($pte as $v)
  2091. {
  2092. if(is_numeric($v) && $v > 0)
  2093. {
  2094. $printtime .= date('Y-m-d H:i:s',$v).'、';
  2095. }
  2096. }
  2097. }
  2098. $this->data['printtime'] = rtrim($printtime,'、');
  2099. $product = '';
  2100. $fullordertt['product'] = str_replace("'","",$fullordertt['product']);
  2101. if($fullordertt['link'] != '' && $fullordertt['source'] != '1')
  2102. {
  2103. $pt = explode(',',$fullordertt['product']);
  2104. $lk = explode(',',$fullordertt['link']);
  2105. for($i=0;$i<count($pt);$i++)
  2106. {
  2107. if(isset($lk[$i]))
  2108. {
  2109. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  2110. }
  2111. else
  2112. {
  2113. $octs = '';
  2114. }
  2115. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  2116. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  2117. if(isset($lk[$i]))
  2118. {
  2119. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  2120. }
  2121. else
  2122. {
  2123. $product .= ($product != '')?' , '.$a:$a;
  2124. }
  2125. }
  2126. }
  2127. else
  2128. {
  2129. $octs = $this->colourorderts->get_text($fullordertt['product']);
  2130. $a = $octs?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  2131. //$a = (stripos($fullordertt['product'],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($fullordertt['product'],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($fullordertt['product'],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($fullordertt['product'],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($fullordertt['product'],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($fullordertt['product'],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($fullordertt['product'],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($fullordertt['product'],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($fullordertt['product'],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  2132. $product = $a;
  2133. }
  2134. $this->data['product'] = $product;
  2135. $out = $this->systemtransfer->find_all("number = '".$fullordertt['number']."'");
  2136. $outread = '';
  2137. if($out)
  2138. {
  2139. foreach ($out as $val)
  2140. {
  2141. $list = '';
  2142. $rk = explode('|',trim($val['rk'],'|'));
  2143. $rktime = explode('|',trim($val['rktime'],'|'));
  2144. $zw = array();
  2145. $t = $this->transfer->find_all("1=1");
  2146. foreach ($t as $v)
  2147. {
  2148. $zw[$v['id']] = $v['title'];
  2149. }
  2150. if($val['rk'] != '' && count($rk) > 0)
  2151. {
  2152. for($i=0;$i<count($rk);$i++)
  2153. {
  2154. if(!isset($rktime[$i]))
  2155. {
  2156. $list .= $zw[$cz[$i]];
  2157. }
  2158. else
  2159. {
  2160. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2161. }
  2162. }
  2163. }
  2164. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2165. }
  2166. }
  2167. else
  2168. {
  2169. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordertt['number']."'");
  2170. $outread = array();
  2171. if($systemwigsout)
  2172. {
  2173. foreach ($systemwigsout as $v)
  2174. {
  2175. if($v['czwarehouse'] == 37)
  2176. {
  2177. $outread[] = '华荣厂';
  2178. }
  2179. else if($v['czwarehouse'] == 0)
  2180. {
  2181. $outread[] = '龙盈厂';
  2182. }
  2183. $cz = explode('|',trim($v['cz'],'|'));
  2184. $cztime = explode('|',trim($v['cztime'],'|'));
  2185. $zw = $this->transfer->get_list();
  2186. if($v['cz'] != '' && count($cz) > 0)
  2187. {
  2188. for($i=0;$i<count($cz);$i++)
  2189. {
  2190. if(!isset($cztime[$i]))
  2191. {
  2192. $outread[] = $zw[$cz[$i]].' -&gt; ';
  2193. }
  2194. else
  2195. {
  2196. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2197. }
  2198. }
  2199. $outread[] = '<br>';
  2200. }
  2201. }
  2202. }
  2203. }
  2204. $klarnacolor = '';
  2205. if($fullordertt['klarnadata'] !='')
  2206. {
  2207. $klarnadata = explode('|',$fullordertt['klarnadata']);
  2208. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  2209. {
  2210. $klarnadata[1] = json_decode($klarnadata[1],true);
  2211. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullordertt['shouldmoney'] && $fullordertt['pay'] == 1211)
  2212. {
  2213. $klarnacolor = 'style="color:#F00"';
  2214. }
  2215. }
  2216. else if($klarnadata[0]!=1 && $fullordertt['pay']!=26 && $fullordertt['pay']!=27 && $fullordertt['pay']!=1211)
  2217. {
  2218. $klarnacolor = 'style="color:#F00"';
  2219. }
  2220. if($fullordertt['pay'] == 23)//klarna
  2221. {
  2222. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU','puerto rico'=>'PR');
  2223. $ToState = array_flip($ToState);
  2224. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  2225. $city = str_replace(' ','',$fullordertt['city']);
  2226. $klarnadataaddress = explode($city,$klarnadata3);
  2227. if(isset($klarnadataaddress[1]))
  2228. {
  2229. $klarnadata3 = $city.$klarnadataaddress[1];
  2230. $klarnadatacolor = explode(',',$klarnadata3);
  2231. unset($klarnadatacolor[4]);
  2232. unset($klarnadatacolor[6]);
  2233. if(isset($ToState[$klarnadatacolor[1]]))
  2234. {
  2235. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  2236. }
  2237. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  2238. }
  2239. else
  2240. {
  2241. $klarnadata['color'] = $klarnadata3;
  2242. }
  2243. }
  2244. }
  2245. else
  2246. {
  2247. $klarnadata = '';
  2248. }
  2249. $p = explode('-',$fullordertt['paypal']);
  2250. $this->data['klarnacolor'] = $klarnacolor;
  2251. $this->data['klarnadata'] = $klarnadata;
  2252. $this->data['systemwigsout'] = $outread;
  2253. $this->data['cate_one_list'] = $this->fullordertt->getCateOne();
  2254. $cate_two = $this->fullordertt->getCateTwo();
  2255. $this->data['cate_two_json'] = json_encode($cate_two,JSON_UNESCAPED_UNICODE);
  2256. $quantity = explode(';',trim($fullordertt['quantity'],';'));
  2257. $qc = 0;
  2258. foreach ($quantity as $v)
  2259. {
  2260. if($v > 1)
  2261. {
  2262. $qc += 1;
  2263. }
  2264. }
  2265. $this->data['qc'] = $qc;
  2266. $this->_Template('fullordertt_readonly',$this->data);
  2267. }
  2268. //浏览列表
  2269. public function _readlist()
  2270. {
  2271. if(isset($_SESSION['api']))
  2272. {
  2273. $user = $this->user->get_api($_SESSION['api']);
  2274. $usp = $user;
  2275. $fgshop = "";$sid = "";
  2276. $usersp = explode('|',trim($user['shop'],'|'));
  2277. foreach ($usersp as $value)
  2278. {
  2279. $fgshop .= " shop = ".$value." or";
  2280. $sid .= " id = ".$value." or";
  2281. }
  2282. }
  2283. $post = $this->input->post(NULL, TRUE);
  2284. if(isset($post['page']))
  2285. {
  2286. $page = $this->input->post('page',true);
  2287. $perpage = $this->input->post('perpage',true);
  2288. $shop = $this->input->post('shop',true);
  2289. $warehouse = $this->input->post('warehouse',true);
  2290. $express = $this->input->post('express',true);
  2291. $state = $this->input->post('state',true);
  2292. $print = $this->input->post('print',true);
  2293. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2294. $orderinfo = $this->input->post('orderinfo',true);
  2295. $client = $this->input->post('name',true);
  2296. $email = $this->input->post('email',true);
  2297. $number = $this->input->post('number',true);
  2298. $waybill = $this->input->post('waybill',true);
  2299. $authorid = $this->input->post('authorid',true);
  2300. $sourcecontentid = $this->input->post('sourcecontentid',true);
  2301. $timetk = $this->input->post('timetk',true);
  2302. $timetj = $this->input->post('timetj',true);
  2303. $timetk = strtotime($timetk);
  2304. $timetj = strtotime($timetj);
  2305. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2306. if($shop)
  2307. {
  2308. $where .= " and shop = '$shop'";
  2309. }
  2310. if($warehouse)
  2311. {
  2312. $where .= " and type = '$warehouse'";
  2313. }
  2314. if($express)
  2315. {
  2316. $where .= " and express = '$express'";
  2317. }
  2318. if($state)
  2319. {
  2320. $where .= " and state = '$state'";
  2321. }
  2322. if($print)
  2323. {
  2324. $where .= " and print = '$print'";
  2325. }
  2326. if($libraryconfirm)
  2327. {
  2328. $where .= " and libraryconfirm = '$libraryconfirm'";
  2329. }
  2330. if($orderinfo)
  2331. {
  2332. $where .= " and orderinfo = '$orderinfo'";
  2333. }
  2334. if($client)
  2335. {
  2336. $where .= " and client like '%$client%'";
  2337. }
  2338. if($email)
  2339. {
  2340. $where .= " and email = '$email'";
  2341. }
  2342. if($number)
  2343. {
  2344. $where .= " and number = '$number'";
  2345. }
  2346. if($waybill)
  2347. {
  2348. $where .= " and waybill = '$waybill'";
  2349. }
  2350. if($authorid)
  2351. {
  2352. $where .= " and authorid = '$authorid'";
  2353. }
  2354. if($sourcecontentid)
  2355. {
  2356. $where .= " and sourcecontentid = '$sourcecontentid'";
  2357. }
  2358. if($timetk && $timetj)
  2359. {
  2360. $timetj = $timetj+24*3600;
  2361. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2362. }
  2363. //数据排序
  2364. $order_str = "dtime desc";
  2365. if(empty($page))
  2366. {
  2367. $start = 0;
  2368. $perpage = 1;
  2369. }
  2370. else
  2371. {
  2372. $start = ($page - 1)*$perpage;
  2373. }
  2374. //取得信息列表
  2375. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,sname,state,dtime,review,libraryconfirm,express,waybill,exstate,orderremarks,library,clientremarks,waybillid',$order_str,$start,$perpage);
  2376. //格式化数据
  2377. $dt = 0;
  2378. foreach ($info_list as $key=>$value)
  2379. {
  2380. $ud = $this->fullordertt->read($value['id']);
  2381. $ud['address'] = str_replace("'","’",$ud['address']);
  2382. $ud['name'] = str_replace("'","’",$ud['name']);
  2383. $customer = $this->customertt->get_email($ud['email'],$value['shop']);
  2384. $customernum = $this->fullordertt->find_count("email = '".$ud['email']."' and shop = '".$value['shop']."'");
  2385. preg_match_all('/[0-9]/u',$ud['phone'],$result);
  2386. $numphone = join('',$result[0]);
  2387. $customerb = $this->customertt->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or numphone = '".$numphone."')",'*','id desc');
  2388. $customerc = $this->customertt->find_all("type = 1 and shop = '".$ud['shop']."' and address = '".$ud['address']."' and numphone = '".$numphone."'",'*','id desc');
  2389. //$a = array_column($customer, 'email'); //三维找其中健的数组
  2390. //$a = array_flip($a); //键和值调换
  2391. $lkh = $value['sname'];
  2392. $djlkh = 0;$djhmd = 0;
  2393. if($customer)
  2394. {
  2395. if(($customer['type'] == 1 && $customernum > 1))// || $customerc['type'] == 1 && $customerc['num'] > 1
  2396. {
  2397. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2398. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2399. $djlkh = 1;
  2400. $djcount = $count;
  2401. }
  2402. else if(isset($customerc[0]['num']))
  2403. {
  2404. if($customerc[0]['num'] > 1)
  2405. {
  2406. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2407. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2408. $djlkh = 1;
  2409. $djcount = $count;
  2410. }
  2411. }
  2412. }
  2413. if($customerb)
  2414. {
  2415. $hmsp = $this->shop->read($customerb[0]['shop']);
  2416. $count = $customerb[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerb[0]['count'].'"></i>':'';
  2417. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'>".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2418. $djhmd = 1;
  2419. }
  2420. if($djlkh == '1' && $djhmd == '1')
  2421. {
  2422. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'><em style='color:#FF3333'>".$djcount."老客户</em> - ".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2423. }
  2424. $info_list[$key]['sname'] = $lkh;
  2425. $shop = $this->shop->read($value['shop']);
  2426. $info_list[$key]['shop'] = $shop['shopname'];
  2427. //$info_list[$key]['user'] = $shop['shopuser'];
  2428. $warehouse = $this->warehouse->read($value['type']);
  2429. $warehousetitle = $warehouse['title'];
  2430. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  2431. $info_list[$key]['type'] = $warehousetitle;
  2432. $typeclass = $this->typeclass->read($value['state']);
  2433. $info_list[$key]['state'] = $typeclass['spare'];
  2434. $wl = '';
  2435. if($value['exstate'] == '99')
  2436. {
  2437. $wl = '<font style="color:#ccc">未获取到物流信息</font>';
  2438. }
  2439. else if($value['exstate'] == '1')
  2440. {
  2441. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已揽收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2442. }
  2443. else if($value['exstate'] == '2')
  2444. {
  2445. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">在途中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2446. }
  2447. else if($value['exstate'] == '3')
  2448. {
  2449. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2450. }
  2451. else if($value['exstate'] == '4')
  2452. {
  2453. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已签收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2454. }
  2455. else if($value['exstate'] == '5')
  2456. {
  2457. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送异常<font style="display: none">'.$ud['excontent'].'</font></font>';
  2458. }
  2459. $info_list[$key]['exstate'] = $wl.'<br />';
  2460. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  2461. {
  2462. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  2463. }
  2464. else
  2465. {
  2466. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']+$dt).'</p><p>'.date('H:i:s',$value['dtime']+$dt).'</p>';
  2467. }
  2468. if($value['review'] == 1)
  2469. {
  2470. $info_list[$key]['review'] = "未送审";
  2471. }
  2472. else if($value['review'] == 2)
  2473. {
  2474. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  2475. }
  2476. else if($value['review'] == 3)
  2477. {
  2478. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  2479. }
  2480. else if($value['review'] == 4)
  2481. {
  2482. $info_list[$key]['review'] = "取消重审";
  2483. }
  2484. else if($value['review'] == 5)
  2485. {
  2486. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  2487. }
  2488. else if($value['review'] == 6)
  2489. {
  2490. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  2491. }
  2492. if($ud['dlz'] == 1)
  2493. {
  2494. $dlz = "<p>独立站已更新</p>";
  2495. }
  2496. else if($ud['dlz'] == 3)
  2497. {
  2498. $dlz = "<p>不需要更新</p>";
  2499. }
  2500. else if($ud['dlz'] == 2)
  2501. {
  2502. $dlz = "<p style='color:#C3C'>独立站更新失败</p>";
  2503. }
  2504. else
  2505. {
  2506. $dlz = "";
  2507. }
  2508. if($value['waybill'] != "")
  2509. {
  2510. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  2511. if( !empty($value['waybillid'])){
  2512. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  2513. }
  2514. }
  2515. if($value['express'] != 0)
  2516. {
  2517. $express = $this->express->read($value['express']);
  2518. $expressservicename = $express['servicename'];
  2519. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  2520. $info_list[$key]['express'] = $expressservicename;
  2521. }
  2522. else
  2523. {
  2524. $info_list[$key]['express'] = "无";
  2525. }
  2526. $tly = "";
  2527. if($value['clientremarks'] != "")
  2528. {
  2529. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  2530. }
  2531. if($value['library'] == 1 && $ud['printtype'] == 3)
  2532. {
  2533. $info_list[$key]['library'] = "不需要";
  2534. }
  2535. else if($value['library'] == 1 && $ud['printtype'] != 3)
  2536. {
  2537. $info_list[$key]['library'] = "未出库";
  2538. }
  2539. else if($value['library'] == 2)
  2540. {
  2541. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  2542. }
  2543. else if($value['library'] == 3)
  2544. {
  2545. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  2546. }
  2547. if($ud['authorid'] != '' && $ud['authorid'] != 0)
  2548. {
  2549. $info_list[$key]['orderremarks'] = '<p>'.$value['orderremarks'].'</p><p style="border-top: 1px dashed #C2C2C2;">author_id:</p><p>'.$ud['authorid'].'</p><p>source_content_id:</p><p>'.$ud['sourcecontentid'].'</p>';
  2550. }
  2551. unset($info_list[$key]['waybillid']);
  2552. }
  2553. $total = $this->fullordertt->find_count($where);
  2554. $pagenum = ceil($total/$perpage);
  2555. $over = $total-($start+$perpage);
  2556. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2557. echo json_encode($rows);exit;
  2558. }
  2559. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2560. $this->data['wlshop'] = $wlshop;
  2561. $this->_Template('fullordertt_readlist',$this->data);
  2562. }
  2563. public function _readlistdown()
  2564. {
  2565. if(isset($_SESSION['api']))
  2566. {
  2567. $user = $this->user->get_api($_SESSION['api']);
  2568. $usp = $user;
  2569. $fgshop = "";$sid = "";
  2570. $usersp = explode('|',trim($user['shop'],'|'));
  2571. foreach ($usersp as $value)
  2572. {
  2573. $fgshop .= " shop = ".$value." or";
  2574. $sid .= " id = ".$value." or";
  2575. }
  2576. }
  2577. $post = $this->input->get(NULL, TRUE);
  2578. if(isset($post['excel']))
  2579. {
  2580. $shop = $this->input->get('shop',true);
  2581. $warehouse = $this->input->get('warehouse',true);
  2582. $express = $this->input->get('express',true);
  2583. $state = $this->input->get('state',true);
  2584. $print = $this->input->get('print',true);
  2585. $libraryconfirm = $this->input->get('libraryconfirm',true);
  2586. $orderinfo = $this->input->get('orderinfo',true);
  2587. $client = $this->input->get('name',true);
  2588. $email = $this->input->get('email',true);
  2589. $number = $this->input->get('number',true);
  2590. $waybill = $this->input->get('waybill',true);
  2591. $authorid = $this->input->get('authorid',true);
  2592. $sourcecontentid = $this->input->get('sourcecontentid',true);
  2593. $timetk = $this->input->get('timetk',true);
  2594. $timetj = $this->input->get('timetj',true);
  2595. $timetk = strtotime($timetk);
  2596. $timetj = strtotime($timetj);
  2597. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2598. if($shop)
  2599. {
  2600. $where .= " and shop = '$shop'";
  2601. }
  2602. if($warehouse)
  2603. {
  2604. $where .= " and type = '$warehouse'";
  2605. }
  2606. if($express)
  2607. {
  2608. $where .= " and express = '$express'";
  2609. }
  2610. if($state)
  2611. {
  2612. $where .= " and state = '$state'";
  2613. }
  2614. if($print)
  2615. {
  2616. $where .= " and print = '$print'";
  2617. }
  2618. if($libraryconfirm)
  2619. {
  2620. $where .= " and libraryconfirm = '$libraryconfirm'";
  2621. }
  2622. if($orderinfo)
  2623. {
  2624. $where .= " and orderinfo = '$orderinfo'";
  2625. }
  2626. if($client)
  2627. {
  2628. $where .= " and client like '%$client%'";
  2629. }
  2630. if($email)
  2631. {
  2632. $where .= " and email = '$email'";
  2633. }
  2634. if($number)
  2635. {
  2636. $where .= " and number = '$number'";
  2637. }
  2638. if($waybill)
  2639. {
  2640. $where .= " and waybill = '$waybill'";
  2641. }
  2642. if($authorid)
  2643. {
  2644. $where .= " and authorid = '$authorid'";
  2645. }
  2646. if($sourcecontentid)
  2647. {
  2648. $where .= " and sourcecontentid = '$sourcecontentid'";
  2649. }
  2650. if($timetk && $timetj)
  2651. {
  2652. $timetj = $timetj+24*3600;
  2653. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2654. }
  2655. //数据排序
  2656. $order_str = "dtime desc";
  2657. //取得信息列表
  2658. $info_list = $this->fullordertt->find_all($where,'shop,number,orderinfo,dtime,name,express,waybill,email,shipremarks,shouldmoney,orderremarks,librarytime,authorid,sourcecontentid',$order_str);
  2659. //格式化数据
  2660. $dt = 0;
  2661. foreach ($info_list as $key=>$value)
  2662. {
  2663. $shop = $this->shop->read($value['shop']);
  2664. $info_list[$key]['shop'] = $shop['shopname'];
  2665. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  2666. if($value['librarytime'] > 0)
  2667. {
  2668. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2669. }
  2670. if($value['express'] != 0)
  2671. {
  2672. $express = $this->express->read($value['express']);
  2673. $info_list[$key]['express'] = $express['servicename'];
  2674. }
  2675. else
  2676. {
  2677. $info_list[$key]['express'] = "无";
  2678. }
  2679. }
  2680. $title = "订单列表 ".date("Y-m-d");
  2681. $titlename = "<table border=1>
  2682. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  2683. <tr>
  2684. <td>店铺</td>
  2685. <td>编号</td>
  2686. <td>订单号</td>
  2687. <td>订单日期</td>
  2688. <td>客户姓名</td>
  2689. <td>快递方式</td>
  2690. <td>运单号</td>
  2691. <td>邮箱</td>
  2692. <td>仓库品名</td>
  2693. <td>订单金额</td>
  2694. <td>订单备注</td>
  2695. <td>出库时间</td>
  2696. <td>author_id</td>
  2697. <td>source_content_id</td>
  2698. </tr>
  2699. </table>";
  2700. $filename = $title.".xls";
  2701. $tail = "\n";
  2702. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2703. }
  2704. }
  2705. //删除
  2706. public function _del()
  2707. {
  2708. echo json_encode(array('msg'=>'不允许执行!','success'=>false));exit;
  2709. $post = $this->input->post(NULL, TRUE);
  2710. if(isset($post['s']))
  2711. {
  2712. $id_arr = $this->input->post('s');
  2713. $id_arr = explode(',',$id_arr);
  2714. if(!$id_arr)
  2715. {
  2716. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2717. }
  2718. //循环删除记录
  2719. foreach ($id_arr as $v)
  2720. {
  2721. $this->fullordertt->remove($v);
  2722. }
  2723. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  2724. }
  2725. }
  2726. //查找商品价格
  2727. public function _price()
  2728. {
  2729. $post = $this->input->post(NULL, TRUE);
  2730. if(isset($post['data']))
  2731. {
  2732. $data = $this->input->post('data');
  2733. $data = explode('-',$data);
  2734. $number = '';$num = count($data);
  2735. //循环删除记录
  2736. for($i=0;$i<$num-1;$i++)
  2737. {
  2738. if($data[$i] != 0)
  2739. {
  2740. $number=$number.$data[$i];
  2741. if($i == 2)
  2742. {
  2743. $number=$number.$data[$num-1];
  2744. }
  2745. }
  2746. }
  2747. $list = $this->productdescribe->get_number($number);
  2748. if($list)
  2749. {
  2750. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));
  2751. }
  2752. else
  2753. {
  2754. $list = array('purchase'=>0,'cost'=>0,'salesprice'=>0);
  2755. //echo json_encode(array('msg'=>'此信息没有配置价格!','n'=>$data[$num-1],'success'=>false));exit;
  2756. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));exit;
  2757. }
  2758. }
  2759. }
  2760. public function _customs()
  2761. {
  2762. $post = $this->input->post(NULL, TRUE);
  2763. if(isset($post['e']))
  2764. {
  2765. $e = $this->input->post('e');//快递信息
  2766. $c = $this->input->post('c');//国家信息
  2767. $data = $this->customs->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2768. $list = $this->productdescription->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2769. $rows = array();
  2770. foreach ($data as $key=>$value)
  2771. {
  2772. $detailed = explode('|',trim($value['detailed'],'|'));
  2773. //此处未对比重量选择价值,暂直接选择第一条海关价值
  2774. $detailed = $this->detailed->read($detailed[0]);
  2775. $money = $detailed['customsval'];//找到海关价值
  2776. }
  2777. foreach ($list as $key=>$value)
  2778. {
  2779. $description = $this->typeclass->read($value['description']);
  2780. $list[$key]['title'] = $description['title'];//产品描述名称
  2781. }
  2782. if(!$data && !$list)
  2783. {
  2784. echo json_encode(array('msg'=>'无此快递配置信息!','success'=>false));exit;
  2785. }
  2786. else
  2787. {
  2788. //$list-title -description 取值
  2789. echo json_encode(array('money'=>sprintf("%.2f",$money),'msg'=>$list,'success'=>true));
  2790. }
  2791. }
  2792. }
  2793. public function _express()
  2794. {
  2795. $post = $this->input->post(NULL, TRUE);
  2796. if(isset($post['e']))
  2797. {
  2798. $e = $this->input->post('e');//快递信息
  2799. $c = $this->input->post('c');//国家信息
  2800. $data = $this->logistics->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2801. if(!$data)
  2802. {
  2803. echo json_encode(array('success'=>false));exit;
  2804. }
  2805. else
  2806. {
  2807. echo json_encode(array('money'=>sprintf("%.2f",$data[0]['firstmoney']),'success'=>true));
  2808. }
  2809. }
  2810. }
  2811. public function _hl()
  2812. {
  2813. $post = $this->input->post(NULL, TRUE);
  2814. if(isset($post['cy']))
  2815. {
  2816. $hl = 0;
  2817. $cy = $this->input->post('cy');//币种ID
  2818. $cy = $this->typeclass->read($cy);
  2819. $gethl = $this->hl->get_hl();
  2820. foreach ($gethl as $v)
  2821. {
  2822. $code = str_replace(" ","",$v['code']);
  2823. if($code == $cy['title'])
  2824. {
  2825. $hl = $v['refePrice']/100;
  2826. }
  2827. }
  2828. echo json_encode(array('msg'=>$hl,'success'=>true));
  2829. }
  2830. }
  2831. public function _operation()
  2832. {
  2833. $post = $this->input->post(NULL, TRUE);
  2834. if(isset($post['type']))
  2835. {
  2836. $type = $this->input->post('type');
  2837. $id = $this->input->post('id');
  2838. $msg = $this->input->post('msg');
  2839. if($type == 1)//禁止发货
  2840. {
  2841. $d = $this->fullordertt->read($id);
  2842. if($d['library'] != 1)
  2843. {
  2844. echo json_encode(array('msg'=>'操作失败,订单非未出库状态!','success'=>false));exit;
  2845. }
  2846. if($msg == "")
  2847. {
  2848. echo json_encode(array('msg'=>'必须填写禁止原因!','success'=>false));exit;
  2849. }
  2850. if($d['print'] < 3)
  2851. {
  2852. $a = "订单未打印,";
  2853. }
  2854. else
  2855. {
  2856. $a = "";
  2857. }
  2858. if($this->fullordertt->save(array('libraryconfirm'=>1,'librarynot'=>$a.$msg),$id))
  2859. {
  2860. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2861. }
  2862. else
  2863. {
  2864. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2865. }
  2866. }
  2867. if($type == 6)//允许发货
  2868. {
  2869. $d = $this->fullordertt->read($id);
  2870. if($d['library'] > 1)
  2871. {
  2872. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2873. }
  2874. if($d['print'] < 3)
  2875. {
  2876. $a = "订单未打印,";
  2877. }
  2878. else
  2879. {
  2880. $a = "";
  2881. }
  2882. if($this->fullordertt->save(array('libraryconfirm'=>2,'librarynot'=>$a.$msg),$id))
  2883. {
  2884. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2885. }
  2886. else
  2887. {
  2888. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2889. }
  2890. }
  2891. if($type == 7)//禁止打印
  2892. {
  2893. $d = $this->fullordertt->read($id);
  2894. if($d['printtime'] != 0)
  2895. {
  2896. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2897. }
  2898. if($d['library'] > 1)
  2899. {
  2900. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2901. }
  2902. if($d['print'] < 3)
  2903. {
  2904. $a = "订单未打印,";
  2905. }
  2906. else
  2907. {
  2908. $a = "";
  2909. }
  2910. if($this->fullordertt->save(array('print'=>1),$id))
  2911. {
  2912. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2913. }
  2914. else
  2915. {
  2916. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2917. }
  2918. }
  2919. if($type == 8)//允许打印
  2920. {
  2921. $d = $this->fullordertt->read($id);
  2922. /**
  2923. if($d['printtime'] != 0)
  2924. {
  2925. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2926. }
  2927. **/
  2928. if($d['library'] > 1)
  2929. {
  2930. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2931. }
  2932. if($d['print'] < 3)
  2933. {
  2934. $a = "订单未打印,";
  2935. }
  2936. else
  2937. {
  2938. $a = "";
  2939. }
  2940. if($d['printtime'] == '0')
  2941. {
  2942. $bcprint = 2;
  2943. }
  2944. else
  2945. {
  2946. $bcprint = 3;
  2947. }
  2948. if($this->fullordertt->save(array('print'=>$bcprint,'failed'=>''),$id))
  2949. {
  2950. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2951. }
  2952. else
  2953. {
  2954. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2955. }
  2956. }
  2957. if($type == 9)//关闭
  2958. {
  2959. if($this->fullordertt->save(array('failed'=>''),$id))
  2960. {
  2961. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2962. }
  2963. else
  2964. {
  2965. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2966. }
  2967. }
  2968. if($type == 2)//填写运单、修改运单
  2969. {
  2970. $d = $this->fullordertt->read($id);
  2971. if($d['express'] == 0)
  2972. {
  2973. echo json_encode(array('msg'=>'操作失败,未选择物流方式!','success'=>false));exit;
  2974. }
  2975. if($d['library'] == 3 || ($d['print'] == 3 && $d['libraryconfirm'] == 1))
  2976. {
  2977. echo json_encode(array('msg'=>'操作失败,不允许填写运单号!','success'=>false));exit;
  2978. }
  2979. $xg = $this->fullordertt->read($id);
  2980. $shop = $this->shop->read($xg['shop']);
  2981. $ex = $this->express->read($xg['express']);
  2982. $fs = $this->notice->get_ordertatus(216);//216成功状态
  2983. if($xg['source'] != 1)
  2984. {
  2985. //独立站地址更新订单状态、物流信息
  2986. $gx = $this->api->get_gx(substr($xg['orderinfo'],1),$msg,$xg,$shop,$ex,$xg['msg'],$xg['shopify']);
  2987. }
  2988. else if($xg['source'] == 1)
  2989. {
  2990. $gx['res'] = 3;
  2991. $gx['state'] = 216;
  2992. }
  2993. if(!isset($gx['res']))
  2994. {
  2995. $gx['res'] = 2;
  2996. $gx['state'] = $xg['state'];
  2997. }
  2998. if($gx['res'] > 0 && $fs)
  2999. {
  3000. $warehouse = $this->warehouse->read($xg['type']);
  3001. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  3002. }
  3003. $msg = preg_replace('/( | | | |\s)/','',$msg);
  3004. if($this->fullordertt->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$id))
  3005. {
  3006. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3007. }
  3008. else
  3009. {
  3010. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3011. }
  3012. }
  3013. }
  3014. }
  3015. public function _merge()
  3016. {
  3017. $post = $this->input->post(NULL, TRUE);
  3018. if(isset($post['s']))
  3019. {
  3020. $id_arr = $this->input->post('s');
  3021. $id_arr = explode(',',trim( $id_arr,','));
  3022. $id_arr = array_reverse($id_arr);
  3023. if(!$id_arr)
  3024. {
  3025. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3026. }
  3027. if(count($id_arr) < 2)
  3028. {
  3029. echo json_encode(array('msg'=>'缺少可合并单!','success'=>false));exit;
  3030. }
  3031. $tmp_list = $this->db->from('fullordertt')->where_in('id',$id_arr)->select('id,orderinfo,number,type,express')->get()->result_array();
  3032. $count_warehouse_list = [];
  3033. $count_express_list = [];
  3034. $flag = 0;
  3035. $flag_str = '';
  3036. foreach ($tmp_list as $k => $v) {
  3037. $count_warehouse_list[$v['type']] = $v['type'];
  3038. if(empty($v['express'])){
  3039. $flag = 1;
  3040. $flag_str.= $v['number'].'仓库未选,请先选快递;';
  3041. }
  3042. $count_express_list[$v['express']] = $v['express'];
  3043. }
  3044. if($flag == 1){
  3045. echo json_encode(array('msg'=>$flag_str,'success'=>false));exit;
  3046. }
  3047. if(count($count_warehouse_list) > 1){
  3048. echo json_encode(array('msg'=>'合并单的仓库不一致,无法合并!','success'=>false));exit;
  3049. }
  3050. if(count($count_express_list) > 1){
  3051. echo json_encode(array('msg'=>'合并单的快递不一致,无法合并!','success'=>false));exit;
  3052. }
  3053. $post = array();
  3054. $u = $this->fullordertt->read($id_arr[0]);
  3055. unset($id_arr[0]);
  3056. $this->db->trans_begin();
  3057. $hd = $this->fullordertthb->get_orderinfo($u['orderinfo']);
  3058. if(!$hd)
  3059. {
  3060. $this->fullordertthb->insert($u);
  3061. }
  3062. //相加
  3063. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  3064. $post['budget'] = $u['budget'];//预估到帐金额
  3065. $post['expressmoney']= $u['expressmoney'];//物流金额
  3066. //$post['refundy'] = $u['refundy'];//补/退原额
  3067. //$post['refundj'] = $u['refundj'];//补/退净额
  3068. $post['cost'] = $u['cost'];//成本金额
  3069. //$post['zzl'] = $u['zzl'];//总重量
  3070. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  3071. $post['ts'] = $u['ts'];//条数
  3072. $post['cost'] = $u['cost'];//成本金额
  3073. //追加
  3074. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  3075. $post['rtext'] = $u['rtext'];//补/退原因
  3076. $post['pay'] = $u['pay'];//付款方式
  3077. $post['paypal'] = $u['paypal'];//交易号
  3078. $post['clientremarks'] = $u['clientremarks'];//客户留言
  3079. $post['product'] = $u['product'];//商品名称
  3080. //$post['issku'] = $u['issku'];//sku
  3081. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  3082. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  3083. //产品追加
  3084. $post['fpdata'] = $u['fpdata'];//产品内容
  3085. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  3086. $merge = $u['id'];
  3087. $d = array($u['id']);$order = '';
  3088. $zsl = 0;$zccsl = 0;
  3089. foreach ($id_arr as $v)
  3090. {
  3091. $v = $this->fullordertt->read($v);
  3092. if($u['type'] != $v['type'])
  3093. {
  3094. echo json_encode(array('msg'=>'仓库不一致,无法合并!','success'=>false));exit;
  3095. }
  3096. if($v['shop'] = $u['shop'])
  3097. {
  3098. $hd = $this->fullordertthb->get_orderinfo($v['orderinfo']);
  3099. if(!$hd)
  3100. {
  3101. $this->fullordertthb->insert($v);
  3102. }
  3103. // $post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  3104. // $post['budget'] += $v['budget'];//预估到帐金额
  3105. // $post['expressmoney'] += $v['expressmoney'];//物流金额
  3106. //$post['refundy'] += $v['refundy'];//补/退原额
  3107. //$post['refundj'] += $v['refundj'];//补/退净额
  3108. $post['cost'] += $v['cost'];//成本金额
  3109. //$post['zzl'] += $v['zzl'];//总重量
  3110. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  3111. $post['ts'] += $v['ts'];//条数
  3112. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  3113. //$post['rtext'] .= $v['rtext'];//补/退原因
  3114. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  3115. //$post['paypal'] .= $v['paypal'];//交易号
  3116. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  3117. $post['product'] .= $v['product'];//商品名称
  3118. //$post['issku'] .= $v['issku'];//sku
  3119. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  3120. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  3121. $post['fpdata'] .= $v['fpdata'];//产品内容
  3122. $post['whlabel'] .= $v['whlabel'];//产品对应库存码
  3123. $d[] = $v['id'];
  3124. $order .= $v['orderinfo'].'('.$v['number'].')、';
  3125. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  3126. $i = 0;
  3127. if($wl)//如果有那么清除所有占用
  3128. {
  3129. foreach ($wl as $val)
  3130. {
  3131. if($val['sku'] == 'Preset' && $val['state'] == '9')
  3132. {
  3133. $this->whlabel->remove($val['id']);//删除预设
  3134. $i++;
  3135. }
  3136. else
  3137. {
  3138. $this->whlabel->save(array('zd'=>''),$val['id']);//专属
  3139. $i++;
  3140. }
  3141. }
  3142. }
  3143. $zsl += count($wl);
  3144. $zccsl += $i;
  3145. $this->fullordertt->save(array('merge'=>$u['id'],'mergeid'=>1,'orderremarks'=>' 《合并信息》:'.'已合并到'.$u['orderinfo'].'('.$u['number'].')中; '.$v['orderremarks'],'print'=>1,'libraryconfirm'=>1,'whlabel'=>'','fpdata'=>'','shipremarks'=>''),$v['id']);
  3146. }
  3147. }
  3148. //计算出单条价值
  3149. /**
  3150. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  3151. {
  3152. //$post['dtsbjz'] = 0;
  3153. }
  3154. else
  3155. {
  3156. //$post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  3157. }
  3158. **/
  3159. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];
  3160. $post['merge'] = $u['id'];
  3161. //$post['mergeid'] = 1;
  3162. //合并重复项
  3163. //解决whlabel 合并在一起是 多出的那个|
  3164. $post['whlabel'] = str_replace("||","|",$post['whlabel']);
  3165. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  3166. $hbcff = explode(';',trim($post['fpdata'],';'));
  3167. $c = 0;
  3168. $hbw = array();
  3169. $hbf = array();
  3170. for($i=0;$i<count($hbcfw);$i++)
  3171. {
  3172. $w = explode('-',$hbcfw[$i]);
  3173. $f = explode('|',$hbcff[$i]);
  3174. $w2 = ($w[2]==0)?0:'';
  3175. if(!isset($hbw[$w[0].$w2]))
  3176. {
  3177. $hbw[$w[0].$w2] = $hbcfw[$i];
  3178. $hbf[$w[0].$w2] = $hbcff[$i];
  3179. }
  3180. else
  3181. {
  3182. $c++;
  3183. $cw = explode('-',$hbw[$w[0].$w2]);
  3184. $cf = explode('|',$hbf[$w[0].$w2]);
  3185. if($cw[2] != 0 && $w[2] != 0)
  3186. {
  3187. $cf[2] += $f[2];
  3188. $cf[9] .= '~'.$f[9];
  3189. $hbf[$w[0].$w2] = implode("|",$cf);
  3190. $cw[1] += $f[2];
  3191. $cw[2] .= '~'.$f[9];
  3192. $hbw[$w[0].$w2] = implode("-",$cw);
  3193. }
  3194. else if($cw[2] == 0 && $w[2] == 0)
  3195. {
  3196. $cf[2] += $f[2];
  3197. $hbf[$w[0].$w2] = implode("|",$cf);
  3198. $cw[1] += $f[2];
  3199. $hbw[$w[0].$w2] = implode("-",$cw);
  3200. }
  3201. else
  3202. {
  3203. $hbw[] = $hbcfw[$i];
  3204. $hbf[] = $hbcff[$i];
  3205. }
  3206. }
  3207. }
  3208. if($c > 0)
  3209. {
  3210. $post['fpdata'] = implode(";",$hbf).';';
  3211. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  3212. }
  3213. //合并重复项结束
  3214. $this->fullordertt->save($post,$u['id']);
  3215. if ($this->db->trans_status() === FALSE)
  3216. {
  3217. $this->db->trans_commit();
  3218. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3219. }
  3220. else
  3221. {
  3222. $this->db->trans_commit();
  3223. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$u['id'],'success'=>true));
  3224. }
  3225. }
  3226. }
  3227. //评价管理
  3228. public function _evaluate()
  3229. {
  3230. $user = $this->user->get_api($_SESSION['api']);
  3231. if($user)
  3232. {
  3233. $fgshop = "";$sid = "";
  3234. $user = explode('|',trim($user['shop'],'|'));
  3235. foreach ($user as $value)
  3236. {
  3237. $fgshop .= " shop = ".$value." or";
  3238. $sid .= " id = ".$value." or";
  3239. }
  3240. }
  3241. $post = $this->input->post(NULL, TRUE);
  3242. if(isset($post['page']))
  3243. {
  3244. $page = $this->input->post('page',true);
  3245. $perpage = $this->input->post('perpage',true);
  3246. $shop = $this->input->post('shop',true);
  3247. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  3248. if($shop)
  3249. {
  3250. $where .= " and shop = '$shop'";
  3251. }
  3252. //数据排序
  3253. $order_str = "id desc";
  3254. if(empty($page))
  3255. {
  3256. $start = 0;
  3257. $perpage = 1;
  3258. }
  3259. else
  3260. {
  3261. $start = ($page - 1)*$perpage;
  3262. }
  3263. //取得信息列表
  3264. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  3265. //格式化数据
  3266. foreach ($info_list as $key=>$value)
  3267. {
  3268. $shop = $this->shop->read($value['shop']);
  3269. $info_list[$key]['shop'] = $shop['shopname'];
  3270. $info_list[$key]['operation'] = "评价";
  3271. }
  3272. $total = $this->fullordertt->find_count($where);
  3273. $pagenum = ceil($total/$perpage);
  3274. $over = $total-($start+$perpage);
  3275. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3276. echo json_encode($rows);exit;
  3277. }
  3278. $this->_Template('fullordertt_evaluate',$this->data);
  3279. }
  3280. //订单消息
  3281. public function _state()
  3282. {
  3283. $user = $this->user->get_api($_SESSION['api']);
  3284. if($user)
  3285. {
  3286. $fgshop = "";$sid = "";
  3287. $user = explode('|',trim($user['shop'],'|'));
  3288. foreach ($user as $value)
  3289. {
  3290. $fgshop .= " shop = ".$value." or";
  3291. $sid .= " id = ".$value." or";
  3292. }
  3293. }
  3294. $post = $this->input->post(NULL, TRUE);
  3295. if(isset($post['page']))
  3296. {
  3297. $page = $this->input->post('page',true);
  3298. $perpage = $this->input->post('perpage',true);
  3299. $timetk = $this->input->post('timetk',true);
  3300. $timetj = $this->input->post('timetj',true);
  3301. $shop = $this->input->post('shop',true);
  3302. $expressstate = $this->input->post('expressstate',true);
  3303. $fs = $this->input->post('fs',true);
  3304. $state = $this->input->post('state',true);
  3305. $express = $this->input->post('express',true);
  3306. $review = $this->input->post('review',true);
  3307. $orderinfo = $this->input->post('orderinfo',true);
  3308. $number = $this->input->post('number',true);
  3309. $waybill = $this->input->post('waybill',true);
  3310. $xztime = $this->input->post('xztime',true);
  3311. $timetk = strtotime($timetk);
  3312. $timetj = strtotime($timetj);
  3313. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3314. if($timetk && $timetj)
  3315. {
  3316. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3317. }
  3318. if($xztime == 'librarytime')
  3319. {
  3320. $order_str = "librarytime desc";
  3321. }
  3322. else if($xztime == 'dtime')
  3323. {
  3324. $order_str = "dtime desc";
  3325. }
  3326. if($shop)
  3327. {
  3328. $where .= " and shop = '$shop'";
  3329. }
  3330. if($expressstate)
  3331. {
  3332. $where .= " and expressstate = '$expressstate'";
  3333. }
  3334. if($review)
  3335. {
  3336. $where .= " and review = '$review'";
  3337. }
  3338. if($fs)
  3339. {
  3340. if($fs == '2')
  3341. {
  3342. $where .= " and exstateerror != ''";
  3343. }
  3344. else
  3345. {
  3346. $where .= " and exstateerror = ''";
  3347. }
  3348. }
  3349. if($state)
  3350. {
  3351. $where .= " and state = '$state'";
  3352. }
  3353. if($express)
  3354. {
  3355. $where .= " and express = '$express'";
  3356. }
  3357. if($orderinfo)
  3358. {
  3359. $where .= " and orderinfo = '$orderinfo'";
  3360. }
  3361. if($number)
  3362. {
  3363. $where .= " and number = '$number'";
  3364. }
  3365. if($waybill)
  3366. {
  3367. $where .= " and waybill = '$waybill'";
  3368. }
  3369. if(empty($page))
  3370. {
  3371. $start = 0;
  3372. $perpage = 1;
  3373. }
  3374. else
  3375. {
  3376. $start = ($page - 1)*$perpage;
  3377. }
  3378. //取得信息列表
  3379. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,content,orderremarks,exstateerror',$order_str,$start,$perpage);
  3380. //格式化数据
  3381. foreach ($info_list as $key=>$value)
  3382. {
  3383. $shop = $this->shop->read($value['shop']);
  3384. $info_list[$key]['shop'] = $shop['shopname'];
  3385. $country = $this->country->read($value['country']);
  3386. $info_list[$key]['country'] = $country['name'];
  3387. //$state = $this->typeclass->read($value['state']);
  3388. //$info_list[$key]['state'] = $state['title'];
  3389. if($value['library'] == 1)
  3390. {
  3391. $info_list[$key]['library'] = "未出库";
  3392. }
  3393. else if($value['library'] == 2)
  3394. {
  3395. $info_list[$key]['library'] = "已出库";
  3396. }
  3397. else if($value['library'] == 3)
  3398. {
  3399. $info_list[$key]['library'] = "已退库";
  3400. }
  3401. if($value['librarytime'] == '0')
  3402. {
  3403. $info_list[$key]['librarytime'] = '无';
  3404. }
  3405. else
  3406. {
  3407. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  3408. }
  3409. $express = $this->express->read($value['express']);
  3410. $info_list[$key]['express'] = $express['servicename'];
  3411. }
  3412. $total = $this->fullordertt->find_count($where);
  3413. $pagenum = ceil($total/$perpage);
  3414. $over = $total-($start+$perpage);
  3415. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3416. echo json_encode($rows);exit;
  3417. }
  3418. $notice = $this->notice->find_all("type = '1' and (".rtrim($fgshop,'or').")");
  3419. $this->data['notice'] = $notice;
  3420. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3421. $this->data['wlshop'] = $wlshop;
  3422. $this->data['express'] = $this->express->find_all();
  3423. $this->_Template('fullordertt_state',$this->data);
  3424. }
  3425. //物流信息
  3426. public function _wl()
  3427. {
  3428. $user = $this->user->get_api($_SESSION['api']);
  3429. if($user)
  3430. {
  3431. $fgshop = "";$sid = "";
  3432. $user = explode('|',trim($user['shop'],'|'));
  3433. foreach ($user as $value)
  3434. {
  3435. $fgshop .= " shop = ".$value." or";
  3436. $sid .= " id = ".$value." or";
  3437. }
  3438. }
  3439. $post = $this->input->post(NULL, TRUE);
  3440. if(isset($post['page']))
  3441. {
  3442. $page = $this->input->post('page',true);
  3443. $perpage = $this->input->post('perpage',true);
  3444. $timetk = $this->input->post('timetk',true);
  3445. $timetj = $this->input->post('timetj',true);
  3446. $shop = $this->input->post('shop',true);
  3447. $expressstate = $this->input->post('expressstate',true);
  3448. $fs = $this->input->post('fs',true);
  3449. $state = $this->input->post('state',true);
  3450. $express = $this->input->post('express',true);
  3451. $orderinfo = $this->input->post('orderinfo',true);
  3452. $number = $this->input->post('number',true);
  3453. $waybill = $this->input->post('waybill',true);
  3454. $wlyc = $this->input->post('wlyc',true);
  3455. $wltype = $this->input->post('wltype',true);
  3456. $source = $this->input->post('source',true);
  3457. $xztime = $this->input->post('xztime',true);
  3458. $timetk = strtotime($timetk);
  3459. $timetj = strtotime($timetj);
  3460. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3461. if($timetk && $timetj)
  3462. {
  3463. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3464. }
  3465. if($xztime == 'librarytime')
  3466. {
  3467. $order_str = "librarytime desc";
  3468. }
  3469. else if($xztime == 'dtime')
  3470. {
  3471. $order_str = "dtime desc";
  3472. }
  3473. else if ($xztime == 'wlfstime')
  3474. {
  3475. $order_str = "wlfstime desc";
  3476. }
  3477. if($shop)
  3478. {
  3479. $where .= " and shop = '$shop'";
  3480. }
  3481. if($expressstate != '')
  3482. {
  3483. $where .= " and expressstate = '$expressstate'";
  3484. }
  3485. if($fs)
  3486. {
  3487. if($fs == '1')
  3488. {
  3489. $where .= " and wlcontent != ''";
  3490. }
  3491. if($fs == '2')
  3492. {
  3493. $where .= " and wlerror != ''";
  3494. }
  3495. if($fs == '3')
  3496. {
  3497. $where .= " and wlcontent = '' and shouldmoney > 100";
  3498. }
  3499. else if($fs == '4')
  3500. {
  3501. $where .= " and wltype = '1'";
  3502. }
  3503. }
  3504. if($state)
  3505. {
  3506. $where .= " and state = '$state'";
  3507. }
  3508. if($express)
  3509. {
  3510. $where .= " and express = '$express'";
  3511. }
  3512. if($orderinfo)
  3513. {
  3514. $where .= " and orderinfo = '$orderinfo'";
  3515. }
  3516. if($number)
  3517. {
  3518. $where .= " and number = '$number'";
  3519. }
  3520. if($waybill)
  3521. {
  3522. $where .= " and waybill = '$waybill'";
  3523. }
  3524. if($wlyc!='')
  3525. {
  3526. $where .= " and wlyc = '$wlyc'";
  3527. }
  3528. if($wltype!='')
  3529. {
  3530. $where .= " and wltype = '$wltype'";
  3531. }
  3532. if($source)
  3533. {
  3534. if($source == 1)
  3535. {
  3536. $where .= " and source = '$source'";
  3537. }
  3538. else
  3539. {
  3540. $where .= " and source != '1'";
  3541. }
  3542. }
  3543. if(empty($page))
  3544. {
  3545. $start = 0;
  3546. $perpage = 1;
  3547. }
  3548. else
  3549. {
  3550. $start = ($page - 1)*$perpage;
  3551. }
  3552. //取得信息列表
  3553. $info_list = $this->fullordertt->find_all($where,'id,orderinfo,number,country,library,librarytime,expressstate,express,waybill,wlbz,orderremarks,wlcontent,wlerror,excontent,wltype',$order_str,$start,$perpage);
  3554. //格式化数据
  3555. foreach ($info_list as $key=>$value)
  3556. {
  3557. $f = $this->fullordertt->read($value['id']);
  3558. $info_list[$key]['number'] = "<p>".$value['number']."</p>"."<p>".$f['email']."</p>";
  3559. $country = $this->country->read($value['country']);
  3560. $info_list[$key]['country'] = "<p>".$country['name']."</p><p>".$f['phone']."</p>";
  3561. //$state = $this->typeclass->read($value['state']);
  3562. //$info_list[$key]['state'] = $state['title'];
  3563. if($value['library'] == 1)
  3564. {
  3565. $info_list[$key]['library'] = "未出库";
  3566. }
  3567. else if($value['library'] == 2)
  3568. {
  3569. $info_list[$key]['library'] = "已出库";
  3570. }
  3571. else if($value['library'] == 3)
  3572. {
  3573. $info_list[$key]['library'] = "已退库";
  3574. }
  3575. if($value['librarytime'] == '0')
  3576. {
  3577. $info_list[$key]['librarytime'] = '无';
  3578. }
  3579. else
  3580. {
  3581. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']).'<br>'.$f['shouldmoney'];
  3582. }
  3583. if($value['expressstate'] == 0)
  3584. {
  3585. $info_list[$key]['expressstate'] = "无信息";
  3586. }
  3587. else if($value['expressstate'] == 2)
  3588. {
  3589. $info_list[$key]['expressstate'] = "已取件";
  3590. }
  3591. else if($value['expressstate'] == 3)
  3592. {
  3593. $info_list[$key]['expressstate'] = "在途中";
  3594. }
  3595. else if($value['expressstate'] == 4)
  3596. {
  3597. $info_list[$key]['expressstate'] = "到达目的地国".$value['expressstate'];
  3598. }
  3599. else if($value['expressstate'] == 5)
  3600. {
  3601. $info_list[$key]['expressstate'] = "即将派送";
  3602. }
  3603. else if($value['expressstate'] == 6)
  3604. {
  3605. $info_list[$key]['expressstate'] = "已签收";
  3606. }
  3607. else if($value['expressstate'] == 1)
  3608. {
  3609. $info_list[$key]['expressstate'] = "派送异常";
  3610. }
  3611. $express = $this->express->read($value['express']);
  3612. $info_list[$key]['express'] = $express['servicename'];
  3613. if($value['wltype'] == '0')
  3614. {
  3615. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>禁止发送</b></p>";
  3616. }
  3617. else
  3618. {
  3619. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>允许发送</b></p>";
  3620. }
  3621. if($f['wlyc'] == '0')
  3622. {
  3623. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='1'>加入异常</b></p>";
  3624. }
  3625. else if($f['wlyc'] == '1')
  3626. {
  3627. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='2'>物流异常</b></p>";
  3628. }
  3629. else if($f['wlyc'] == '2')
  3630. {
  3631. $info_list[$key]['wltype'] .= "<p><b>异常已处理</b></p>";
  3632. }
  3633. if(stripos($value['excontent'],'<br />') !== false)
  3634. {
  3635. $excontent = explode('<br />',$value['excontent']);
  3636. $info_list[$key]['excontent'] = '<i class="method fa fa-list-ul" data-t="'.$value['excontent'].'"></i> '.$excontent[0];
  3637. }
  3638. }
  3639. $total = $this->fullordertt->find_count($where);
  3640. $pagenum = ceil($total/$perpage);
  3641. $over = $total-($start+$perpage);
  3642. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3643. echo json_encode($rows);exit;
  3644. }
  3645. if(isset($post['q']))
  3646. {
  3647. $id = $this->input->post('id',true);
  3648. $f = $this->fullordertt->read($id);
  3649. $wl = ($f['wltype']=='0')?1:0;
  3650. $wltitle = ($f['wltype']=='0')?'已禁发送':'已允发送';
  3651. if($this->fullordertt->save(array('wltype'=>$wl),$id))
  3652. {
  3653. echo json_encode(array('msg'=>'ckn','id'=>$id,'wltitle'=>$wltitle,'success'=>true));exit;
  3654. }
  3655. else
  3656. {
  3657. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$wltitle,'success'=>false));exit;
  3658. }
  3659. }
  3660. if(isset($post['t']))
  3661. {
  3662. $id = $this->input->post('id',true);
  3663. $f = $this->fullordertt->read($id);
  3664. $t = $this->input->post('t',true);
  3665. $yc = ($f['wlyc']=='0')?1:2;
  3666. $yctitle = ($f['wlyc']=='0')?'物流异常':'异常已处理';
  3667. if($this->fullordertt->save(array('wlyc'=>$yc),$id))
  3668. {
  3669. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3670. }
  3671. else
  3672. {
  3673. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3674. }
  3675. }
  3676. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  3677. $this->data['notice'] = $notice;
  3678. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3679. $this->data['wlshop'] = $wlshop;
  3680. $this->data['express'] = $this->express->find_all();
  3681. $this->_Template('fullordertt_wl',$this->data);
  3682. }
  3683. //审核订单
  3684. public function _review()
  3685. {
  3686. $user = $this->user->get_api($_SESSION['api']);
  3687. if($user)
  3688. {
  3689. $fgshop = "";$sid = "";
  3690. $user = explode('|',trim($user['shop'],'|'));
  3691. foreach ($user as $value)
  3692. {
  3693. $sid .= " id = ".$value." or";
  3694. $fgshop .= " shop = ".$value." or";
  3695. }
  3696. $fgshop = " and (".rtrim($fgshop,'or').")";
  3697. }
  3698. $post = $this->input->post(NULL, TRUE);
  3699. if(isset($post['page']))
  3700. {
  3701. $page = $this->input->post('page',true);
  3702. $perpage = $this->input->post('perpage',true);
  3703. $source = $this->input->post('source',true);
  3704. $warehouse = $this->input->post('warehouse',true);
  3705. $express = $this->input->post('express',true);
  3706. $orderremarks = $this->input->post('orderremarks',true);
  3707. $shop = $this->input->post('shop',true);
  3708. $review = $this->input->post('review',true);
  3709. $orderinfo = $this->input->post('orderinfo',true);
  3710. $shipremarks = $this->input->post('shipremarks',true);
  3711. $number = $this->input->post('number',true);
  3712. $timetk = $this->input->post('timetk',true);
  3713. $timetj = $this->input->post('timetj',true);
  3714. $timetk = strtotime($timetk);
  3715. $timetj = strtotime($timetj);
  3716. $where = "mergeid = 0 and state = '207'".$fgshop;
  3717. if($timetk && $timetj)
  3718. {
  3719. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3720. }
  3721. if($source)
  3722. {
  3723. if($source == '2d')
  3724. {
  3725. $where .= " and source >= '2'";
  3726. }
  3727. else
  3728. {
  3729. $where .= " and source = '$source'";
  3730. }
  3731. }
  3732. if($review)
  3733. {
  3734. $where .= " and review = '$review'";
  3735. }
  3736. else
  3737. {
  3738. $where .= "and review <= '2'";
  3739. //$where .= " and ((review = '2' and source = '1') or (review = '1' and source >= '2'))";
  3740. }
  3741. if($shop)
  3742. {
  3743. $where .= " and shop = '$shop'";
  3744. }
  3745. if($warehouse)
  3746. {
  3747. $where .= " and type = '$warehouse'";
  3748. }
  3749. if($express)
  3750. {
  3751. $where .= " and express = '$express'";
  3752. }
  3753. if($orderremarks)
  3754. {
  3755. $where .= " and orderremarks like '%$orderremarks%'";
  3756. }
  3757. if($orderinfo)
  3758. {
  3759. $where .= " and orderinfo = '$orderinfo'";
  3760. }
  3761. if($number)
  3762. {
  3763. $where .= " and number = '$number'";
  3764. }
  3765. if($shipremarks)
  3766. {
  3767. $where .= " and shipremarks like '%$shipremarks%'";
  3768. }
  3769. //数据排序
  3770. $order_str = "id desc";
  3771. if(empty($page))
  3772. {
  3773. $start = 0;
  3774. $perpage = 1;
  3775. }
  3776. else
  3777. {
  3778. $start = ($page - 1)*$perpage;
  3779. }
  3780. //取得信息列表
  3781. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,client,express,dtime,shouldmoney,review,orderremarks');
  3782. //格式化数据
  3783. foreach ($info_list as $key=>$value)
  3784. {
  3785. $lr = $this->fullordertt->read($value['id']);
  3786. $shop = $this->shop->read($value['shop']);
  3787. $info_list[$key]['shop'] = $shop['shopname'];
  3788. $warehouse = $this->warehouse->read($value['type']);
  3789. $info_list[$key]['type'] = $warehouse['title'];
  3790. $express = $this->express->read($value['express']);
  3791. $info_list[$key]['express'] = $express['servicename'];
  3792. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']).'</p><p>'.date('H:i:s',$value['dtime']).'</p>';
  3793. if($value['review'] == 1)
  3794. {
  3795. $info_list[$key]['review'] = "未送审";
  3796. }
  3797. else if($value['review'] == 2)
  3798. {
  3799. $info_list[$key]['review'] = "待审核";
  3800. }
  3801. else if($value['review'] == 3)
  3802. {
  3803. $info_list[$key]['review'] = "不通过";
  3804. }
  3805. else if($value['review'] == 4)
  3806. {
  3807. $info_list[$key]['review'] = "取消重审";
  3808. }
  3809. else if($value['review'] == 5)
  3810. {
  3811. $info_list[$key]['review'] = "审核通过";
  3812. }
  3813. else if($value['review'] == 6)
  3814. {
  3815. $info_list[$key]['review'] = "自动通过";
  3816. }
  3817. /**
  3818. $info_list[$key]['library'] = "";
  3819. if($value['review'] == 1)
  3820. {
  3821. $info_list[$key]['library'] = "<p><b class='focz' data-type='6' data-id='".$value['id']."'>审核通过</b></p>";
  3822. }
  3823. if($value['review'] == 2)
  3824. {
  3825. $info_list[$key]['library'] = "<p><b class='focz' data-type='5' data-id='".$value['id']."'>审核通过</b></p><p><b class='focz' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  3826. }
  3827. else if($value['review'] == 3)
  3828. {
  3829. $info_list[$key]['library'] = "<p><b class='fullorderttreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  3830. }
  3831. else if($value['review'] == 5)
  3832. {
  3833. $info_list[$key]['library'] = "<p><b class='fullorderttreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  3834. }
  3835. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  3836. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  3837. $cost = $lr['cost']/$lr['hl'];
  3838. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  3839. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  3840. **/
  3841. }
  3842. $total = $this->fullordertt->find_count($where);
  3843. $pagenum = ceil($total/$perpage);
  3844. $over = $total-($start+$perpage);
  3845. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3846. echo json_encode($rows);exit;
  3847. }
  3848. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3849. $this->data['shop'] = $wlshop;
  3850. $this->_Template('fullordertt_review',$this->data);
  3851. }
  3852. public function _wlbz($arg_array)
  3853. {
  3854. $post = $this->input->post(NULL, TRUE);
  3855. if(isset($post['id']))
  3856. {
  3857. $id = $this->input->post('id',true);
  3858. $post['wlbz'] = $this->input->post('wlbz',true);
  3859. if($post['wlbz'] == '')
  3860. {
  3861. echo json_encode(array('msg'=>'备注不能为空','success'=>false));exit;
  3862. }
  3863. if($this->fullordertt->save($post,$id))
  3864. {
  3865. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  3866. }
  3867. else
  3868. {
  3869. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  3870. }
  3871. }
  3872. $arg_array = $arg_array[0];
  3873. $fullordertt = $this->fullordertt->read($arg_array);
  3874. $this->data['fullordertt'] = $fullordertt;
  3875. $this->_Template('fullordertt_wlbz',$this->data);
  3876. }
  3877. //导出资金统计excel
  3878. public function _fmexcel()
  3879. {
  3880. $user = $this->user->get_api($_SESSION['api']);
  3881. if($user)
  3882. {
  3883. $fgshop = "";$sid = "";
  3884. $user = explode('|',trim($user['shop'],'|'));
  3885. foreach ($user as $value)
  3886. {
  3887. $fgshop .= " shop = ".$value." or";
  3888. $sid .= " id = ".$value." or";
  3889. }
  3890. }
  3891. if(isset($_GET['excel']))
  3892. {
  3893. $timetk = $this->input->get('timetk',true);
  3894. $timetj = $this->input->get('timetj',true);
  3895. $shop = $this->input->get('shop',true);
  3896. $source = $this->input->get('source',true);
  3897. $state = $this->input->get('state',true);
  3898. $type = $this->input->get('type',true);
  3899. $orderinfo = $this->input->get('orderinfo',true);
  3900. $user = $this->input->get('user',true);
  3901. $name = $this->input->get('name',true);
  3902. $timetk = strtotime($timetk);
  3903. $timetj = strtotime($timetj);
  3904. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3905. if($timetk && $timetj)
  3906. {
  3907. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3908. }
  3909. if($shop)
  3910. {
  3911. $where .= " and shop = '$shop'";
  3912. }
  3913. if($source)
  3914. {
  3915. $where .= " and source = '$source'";
  3916. }
  3917. if($state)
  3918. {
  3919. if($state == 1)
  3920. {
  3921. $where .= " and state = '$state'";
  3922. }
  3923. }
  3924. if($type)
  3925. {
  3926. $where .= " and type = '$type'";
  3927. }
  3928. if($orderinfo)
  3929. {
  3930. $where .= " and orderinfo = '$orderinfo'";
  3931. }
  3932. if($user)
  3933. {
  3934. $where .= " and user = '$user'";
  3935. }
  3936. if($name)
  3937. {
  3938. $where .= " and name = '$name'";
  3939. }
  3940. //取得信息列表
  3941. $info_list = $this->fullordertt->find_all($where,'id,shop,user,number,orderinfo,client,country,dtime,ftime,express,waybill,shouldmoney,refund,currency,budget,fpdata,hl,currencytitle');
  3942. //格式化数据
  3943. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  3944. foreach ($info_list as $key=>$value)
  3945. {
  3946. $info_list[$key]['id'] = $i;
  3947. if($value['currencytitle'] != "CNY")
  3948. {
  3949. $hl=$value['hl'];
  3950. }
  3951. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3952. $budget=$budget+($value['budget']*$hl);
  3953. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3954. $refund=$refund+($value['refund']*$hl);
  3955. $shop = $this->shop->read($value['shop']);
  3956. $info_list[$key]['shop'] = $shop['shopname'];
  3957. $info_list[$key]['user'] = $shop['shopuser'];
  3958. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3959. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3960. $country = $this->country->read($value['country']);
  3961. $info_list[$key]['country'] = $country['name'];
  3962. $express = $this->express->read($value['express']);
  3963. $info_list[$key]['express'] = $express['servicename'];
  3964. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3965. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  3966. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  3967. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  3968. $fpdata = array();
  3969. if(stripos($value['fpdata'],';') !== false)
  3970. {
  3971. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3972. foreach ($fpdata as $ke=>$va)
  3973. {
  3974. $v = explode('|',rtrim($va,'|'));
  3975. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3976. }
  3977. }
  3978. $info_list[$key]['fpdata'] = $fpdata;
  3979. $i++;
  3980. }
  3981. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  3982. $title = "订单资金信息";
  3983. $titlename = "<table border=1>
  3984. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3985. <tr>
  3986. <td>NO.</td>
  3987. <td>店铺</td>
  3988. <td>负责人</td>
  3989. <td>编号</td>
  3990. <td>订单号</td>
  3991. <td>客户姓名</td>
  3992. <td>国家</td>
  3993. <td>订单日期</td>
  3994. <td>发货日期</td>
  3995. <td>快递公司</td>
  3996. <td>运单号</td>
  3997. <td>订单金额</td>
  3998. <td>退款金额</td>
  3999. <td>手续费</td>
  4000. <td>预估金额</td>
  4001. <td>
  4002. <table border=1>
  4003. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4004. <tr>
  4005. <td>产品</td>
  4006. <td>条数</td>
  4007. <td>数量</td>
  4008. </tr>
  4009. </table>
  4010. </td>
  4011. <td>总条数</td>
  4012. </tr>
  4013. </table>";
  4014. $filename = $title.".xls";
  4015. $tail = "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td><td>".$data[1]."</td><td>".$data[2]."</td><td>".$data[3]."</td></tr>\n";
  4016. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4017. }
  4018. }
  4019. //导出订单excel
  4020. public function _fdexcel()
  4021. {
  4022. if(isset($_GET['excel']))
  4023. {
  4024. $page = $this->input->post('page',true);
  4025. $perpage = $this->input->post('perpage',true);
  4026. $timetk = $this->input->post('timetk',true);
  4027. $timetj = $this->input->post('timetj',true);
  4028. $shop = $this->input->post('shop',true);
  4029. $source = $this->input->post('source',true);
  4030. $state = $this->input->post('state',true);
  4031. $review = $this->input->post('review',true);
  4032. $express = $this->input->post('express',true);
  4033. $orderinfo = $this->input->post('orderinfo',true);
  4034. $user = $this->input->post('user',true);
  4035. $name = $this->input->post('name',true);
  4036. $waybill = $this->input->post('waybill',true);
  4037. $timetk = strtotime($timetk);
  4038. $timetj = strtotime($timetj);
  4039. $where = "1=1 and mergeid = 0";
  4040. if($timetk && $timetj)
  4041. {
  4042. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4043. }
  4044. if($shop)
  4045. {
  4046. $where .= " and shop = '$shop'";
  4047. }
  4048. if($source)
  4049. {
  4050. $where .= " and source = '$source'";
  4051. }
  4052. if($state)
  4053. {
  4054. $where .= " and state = '$state'";
  4055. }
  4056. if($review)
  4057. {
  4058. $where .= " and review = '$review'";
  4059. }
  4060. if($express)
  4061. {
  4062. $where .= " and express = '$express'";
  4063. }
  4064. if($orderinfo)
  4065. {
  4066. $where .= " and orderinfo = '$orderinfo'";
  4067. }
  4068. if($user)
  4069. {
  4070. $where .= " and user = '$user'";
  4071. }
  4072. if($name)
  4073. {
  4074. $where .= " and name = '$name'";
  4075. }
  4076. if($waybill)
  4077. {
  4078. $where .= " and waybill = '$waybill'";
  4079. }
  4080. //取得信息列表
  4081. $info_list = $this->fullordertt->find_all($where,'id,shop,number,orderinfo,source,client,name,address,city,zipcode,province,country,phone,dtime,ftime,state,shouldmoney,express,waybill,orderremarks,clientremarks,fpdata,hl,currencytitle');
  4082. //格式化数据
  4083. $i = 1;$shouldmoney = 0;$hl=1;
  4084. foreach ($info_list as $key=>$value)
  4085. {
  4086. $info_list[$key]['id'] = $i;
  4087. if($value['source'] == 1)
  4088. {
  4089. $info_list[$key]['source'] = "线下订单";
  4090. }
  4091. else if($value['source'] == 2)
  4092. {
  4093. $info_list[$key]['source'] = "PC订单";
  4094. }
  4095. else if($value['source'] == 3)
  4096. {
  4097. $info_list[$key]['source'] = "手机订单";
  4098. }
  4099. if($value['currencytitle'] != "CNY")
  4100. {
  4101. $hl=$value['hl'];
  4102. }
  4103. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  4104. $shop = $this->shop->read($value['shop']);
  4105. $info_list[$key]['shop'] = $shop['shopname'];
  4106. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  4107. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  4108. $state = $this->typeclass->read($value['state']);
  4109. $info_list[$key]['state'] = $state['title'];
  4110. $country = $this->country->read($value['country']);
  4111. $info_list[$key]['country'] = $country['name'];
  4112. $express = $this->express->read($value['express']);
  4113. $info_list[$key]['express'] = $express['servicename'];
  4114. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  4115. $fpdata = array();
  4116. if(stripos($value['fpdata'],';') !== false)
  4117. {
  4118. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  4119. foreach ($fpdata as $ke=>$va)
  4120. {
  4121. $v = explode('|',rtrim($va,'|'));
  4122. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  4123. }
  4124. }
  4125. $info_list[$key]['fpdata'] = $fpdata;
  4126. $i++;
  4127. }
  4128. $data = array($shouldmoney.' CNY');
  4129. $title = "订单信息表";
  4130. $titlename = "<table border=1>
  4131. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  4132. <tr>
  4133. <td>NO.</td>
  4134. <td>店铺</td>
  4135. <td>编号</td>
  4136. <td>订单号</td>
  4137. <td>订单类型</td>
  4138. <td>客户姓名</td>
  4139. <td>收件人名称</td>
  4140. <td>收货人地址</td>
  4141. <td>城市</td>
  4142. <td>邮编</td>
  4143. <td>州</td>
  4144. <td>国家</td>
  4145. <td>收件电话</td>
  4146. <td>订单日期</td>
  4147. <td>发货日期</td>
  4148. <td>订单状态</td>
  4149. <td>订单金额</td>
  4150. <td>快递公司</td>
  4151. <td>运单号</td>
  4152. <td>订单备注</td>
  4153. <td>客户备注</td>
  4154. <td>
  4155. <table border=1>
  4156. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4157. <tr>
  4158. <td>产品</td>
  4159. <td>条数</td>
  4160. <td>数量</td>
  4161. </tr>
  4162. </table>
  4163. </td>
  4164. <td>总条数</td>
  4165. </tr>
  4166. </table>";
  4167. $filename = $title.".xls";
  4168. $tail = "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td></tr>\n";
  4169. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4170. }
  4171. }
  4172. public function _black()
  4173. {
  4174. $post = $this->input->post(NULL, TRUE);
  4175. if(isset($post['bd']))
  4176. {
  4177. $bd = $this->input->post('bd',true);
  4178. $rows = $this->fullordertt->read($bd);
  4179. $post['shop'] = $rows['shop'];
  4180. $post['source'] = 1;
  4181. $post['name'] = $rows['client'];
  4182. $post['email'] = $rows['email'];
  4183. $post['phone'] = $rows['phone'];
  4184. $post['country'] = $rows['country'];
  4185. $post['money'] = $rows['shouldmoney'];
  4186. $post['num'] = 1;
  4187. $post['time'] = $rows['dtime'];
  4188. $post['province'] = $rows['province'];
  4189. $post['city'] = $rows['city'];
  4190. $post['street'] = $rows['street'];
  4191. $post['address'] = $rows['address'];
  4192. $post['address2'] = $rows['address2'];
  4193. $post['zipcode'] = $rows['zipcode'];
  4194. $post['type'] = 2;
  4195. if($this->customertt->insert($post))
  4196. {
  4197. $this->fullordertt->save(array('black'=>1),$bd);
  4198. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4199. }
  4200. else
  4201. {
  4202. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4203. }
  4204. }
  4205. }
  4206. public function _ryf()
  4207. {
  4208. $post = $this->input->post(NULL, TRUE);
  4209. if(isset($post['bd']))
  4210. {
  4211. $bd = $this->input->post('bd',true);
  4212. $d = $this->fullordertt->read($bd);
  4213. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  4214. {
  4215. if($d['print'] < 3)//打印状态为未打印
  4216. {
  4217. $print = 1;//未打印
  4218. $libraryconfirm = 1;//不允许出库
  4219. $a = "订单未打印,";
  4220. }
  4221. else//已打印订单
  4222. {
  4223. $libraryconfirm = 2;//允许出库
  4224. $a = "";
  4225. }
  4226. if($this->fullordertt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4227. {
  4228. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4229. }
  4230. else
  4231. {
  4232. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4233. }
  4234. }
  4235. if($this->fullordertt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4236. {
  4237. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  4238. }
  4239. else
  4240. {
  4241. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4242. }
  4243. }
  4244. }
  4245. public function _fsstate()
  4246. {
  4247. $post = $this->input->post(NULL, TRUE);
  4248. if(isset($post['s']))
  4249. {
  4250. $id_arr = $this->input->post('s');
  4251. $id_arr = explode(',',$id_arr);
  4252. if(!$id_arr)
  4253. {
  4254. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4255. }
  4256. foreach ($id_arr as $v)
  4257. {
  4258. $data = $this->fullordertt->read($v);
  4259. $warehouse = $this->warehouse->read($data['type']);
  4260. $fs = $this->notice->get_ordertatus($data['state']);
  4261. if($fs)
  4262. {
  4263. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  4264. if($ck == 1)
  4265. {
  4266. $this->fullordertt->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  4267. }
  4268. }
  4269. }
  4270. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  4271. }
  4272. }
  4273. public function _power()
  4274. {
  4275. $user = $this->user->get_api($_SESSION['api']);
  4276. $post = $this->input->post(NULL, TRUE);
  4277. if(isset($post['id']))
  4278. {
  4279. $id = $this->input->post('id',true);
  4280. $fullordertt = $this->fullordertt->read($id);
  4281. $express = $this->express->read($fullordertt['express']);
  4282. $warehouse = $this->warehouse->read($fullordertt['type']);
  4283. if(($warehouse['zd'] == '1' || stripos($fullordertt['whlabel'],'z|') !== false) && $fullordertt['library'] == '2')
  4284. {
  4285. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  4286. }
  4287. /**
  4288. if($fullordertt['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  4289. {
  4290. $lj = $this->ali->get_lj($fullordertt['number'],2,'订单修改');
  4291. if($lj != '1' && $lj != '订单不存在')
  4292. {
  4293. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  4294. }
  4295. }
  4296. **/
  4297. $warehouse = $this->warehouse->read($fullordertt['warehouse']);
  4298. $typeclass = $this->typeclass->read($fullordertt['state']);
  4299. $express = $this->express->read($fullordertt['express']);
  4300. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  4301. $teset['number']=$fullordertt['number'];
  4302. $teset['orderinfo']=$fullordertt['orderinfo'];
  4303. $teset['shop']=$fullordertt['shop'];
  4304. $teset['user']=$user['userid'];
  4305. $teset['ip']=$this->input->ip_address();
  4306. $teset['time']=time();
  4307. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  4308. $teset['state']=(isset($typeclass['title']))?$typeclass['spare']:'未选择';
  4309. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  4310. $teset['printtype']=(isset($printtype[$fullordertt['printtype']]))?$printtype[$fullordertt['printtype']]:'未选择';
  4311. $teset['reviewtime']=($fullordertt['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullordertt['reviewtime']):'无';
  4312. $teset['printtime']=($fullordertt['printtime'] > '0')?date('Y-m-d H:i:s',$fullordertt['printtime']):'无';
  4313. $teset['librarytime']=($fullordertt['librarytime'] > '0')?date('Y-m-d H:i:s',$fullordertt['librarytime']):'无';
  4314. $teset['shipremarks']=$fullordertt['shipremarks'];
  4315. $teset['fpdata']=$fullordertt['fpdata'];
  4316. $teset['oldwaybill']=$fullordertt['oldwaybill'];
  4317. $teset['oldprinttime']=$fullordertt['oldprinttime'];
  4318. if($fullordertt['printtype'] == 1)
  4319. {
  4320. if($fullordertt['waybill'] != '' && stripos($fullordertt['oldwaybill'],$fullordertt['waybill']) === false)
  4321. {
  4322. $teset['oldwaybill'] .= '-'.date('Ymd',$fullordertt['printtime']).'/'.$fullordertt['waybill'];
  4323. $teset['oldprinttime'] .= '-'.$fullordertt['printtime'];
  4324. }
  4325. }
  4326. $review = ($fullordertt['source']==1)?2:1;//线下单审核状态直接为待审核
  4327. if(!$this->fullreset->insert($teset))
  4328. {
  4329. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  4330. }
  4331. if($this->fullordertt->save(array('library'=>1,'librarytime'=>0,'libraryconfirm'=>2,'print'=>1,'printtime'=>0,'printnumber'=>0,'retreattime'=>0,'librarynot'=>'订单未打印,未审核或未通过','review'=>$review,'reviewtime'=>0,'state'=>207,'waybill'=>'','waybill2'=>'','waybillid'=>'','oldwaybill'=>$teset['oldwaybill'],'oldprinttime'=>$teset['oldprinttime'],'dlzemail'=>0,'yhs'=>0,'failed'=>''),$id))
  4332. {
  4333. $th_info = $this->retreatlogs->getInfoByNumber($fullordertt['number']);
  4334. if(!empty($th_info)){
  4335. $this->retreatlogs->save(array('cz_time'=>time()),$th_info['id']);
  4336. }
  4337. echo json_encode(array('msg'=>'重置成功!如需再次提交,请先保存、再提交','success'=>true));exit;
  4338. }
  4339. else
  4340. {
  4341. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  4342. }
  4343. }
  4344. }
  4345. public function _expresstype()
  4346. {
  4347. $post = $this->input->post(NULL, TRUE);
  4348. if(isset($post['id']))
  4349. {
  4350. $id = $this->input->post('id',true);
  4351. $data = $this->express->read($id);
  4352. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  4353. }
  4354. }
  4355. public function _email($content,$data,$shopname)
  4356. {
  4357. $express = $this->express->read($data['express']);
  4358. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  4359. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  4360. $content = str_replace($t,$h,$content);
  4361. $this->load->library('email');
  4362. $config['protocol'] = 'smtp';
  4363. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  4364. $config['smtp_port'] = 465;
  4365. $config['smtp_user'] = 'service@email.supernovahair.com';
  4366. $config['smtp_pass'] = 'LONGyihair374';
  4367. $config['smtp_crypto'] = 'ssl';
  4368. $config['crlf'] = "\r\n";
  4369. $config['newline'] = "\r\n";
  4370. $this->email->initialize($config);
  4371. $this->email->from('service@email.supernovahair.com',$shopname);
  4372. $this->email->to($data['email']);//收件
  4373. $this->email->subject('The product you purchased has a new progress');//标题
  4374. $this->email->message($content);//内容
  4375. if ( ! $this->email->send())
  4376. {
  4377. return 2;
  4378. }
  4379. else
  4380. {
  4381. return 1;
  4382. }
  4383. }
  4384. public function _error()
  4385. {
  4386. if(isset($_SESSION['api']))
  4387. {
  4388. $user = $this->user->get_api($_SESSION['api']);
  4389. $usp = $user;
  4390. $fgshop = "";$sid = "";
  4391. $user = explode('|',trim($user['shop'],'|'));
  4392. foreach ($user as $value)
  4393. {
  4394. $fgshop .= " shop = ".$value." or";
  4395. $sid .= " id = ".$value." or";
  4396. }
  4397. }
  4398. $post = $this->input->post(NULL, TRUE);
  4399. if(isset($post['page']))
  4400. {
  4401. $page = $this->input->post('page',true);
  4402. $perpage = $this->input->post('perpage',true);
  4403. $orderinfo = $this->input->post('orderinfo',true);
  4404. $waybill = $this->input->post('waybill',true);
  4405. $number = $this->input->post('number',true);
  4406. $timetk = $this->input->post('timetk',true);
  4407. $timetj = $this->input->post('timetj',true);
  4408. $timetk = strtotime($timetk);
  4409. $timetj = strtotime($timetj);
  4410. $where = "failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').")";
  4411. if($orderinfo)
  4412. {
  4413. $where .= " and orderinfo = '$orderinfo'";
  4414. }
  4415. if($waybill)
  4416. {
  4417. $where .= " and waybill = '$waybill'";
  4418. }
  4419. if($number)
  4420. {
  4421. $where .= " and number = '$number'";
  4422. }
  4423. if($timetk && $timetj)
  4424. {
  4425. $timetj = $timetj+24*3600;
  4426. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4427. }
  4428. //数据排序
  4429. $order_str = "dtime desc";
  4430. if(empty($page))
  4431. {
  4432. $start = 0;
  4433. $perpage = 1;
  4434. }
  4435. else
  4436. {
  4437. $start = ($page - 1)*$perpage;
  4438. }
  4439. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  4440. //格式化数据
  4441. foreach ($info_list as $key=>$value)
  4442. {
  4443. $ud = $this->fullordertt->read($value['id']);
  4444. $shop = $this->shop->read($value['shop']);
  4445. $info_list[$key]['shop'] = $shop['shopname'];
  4446. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4447. $warehouse = $this->warehouse->read($value['type']);
  4448. $warehousetitle = $warehouse['title'];
  4449. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4450. $info_list[$key]['type'] = $warehousetitle;
  4451. if($value['express'] != 0)
  4452. {
  4453. $express = $this->express->read($value['express']);
  4454. $expressservicename = $express['servicename'];
  4455. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4456. $info_list[$key]['express'] = $expressservicename;
  4457. }
  4458. else
  4459. {
  4460. $info_list[$key]['express'] = "无";
  4461. }
  4462. $x = "";
  4463. if($ud['review'] >4 && $ud['print'] == 1)
  4464. {
  4465. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  4466. }
  4467. else
  4468. {
  4469. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  4470. }
  4471. $info_list[$key]['operation'] = $x;
  4472. }
  4473. $total = $this->fullordertt->find_count($where);
  4474. $pagenum = ceil($total/$perpage);
  4475. $over = $total-($start+$perpage);
  4476. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4477. echo json_encode($rows);exit;
  4478. }
  4479. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4480. $this->data['wlshop'] = $wlshop;
  4481. $this->data['express'] = $this->express->find_all();
  4482. $user = $this->user->get_api($_SESSION['api']);
  4483. $powerid = $this->power->read($user['power']);
  4484. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4485. $pid = '';
  4486. foreach ($powertext as $v)
  4487. {
  4488. $pid .= " id = ".$v." or";
  4489. }
  4490. $fullorderexcel = $this->fullorderexcel->find_all("type = '100006' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4491. $this->data['fullorderexcel'] = $fullorderexcel;
  4492. $this->_Template('fullordertt_error',$this->data);
  4493. }
  4494. public function _yc()
  4495. {
  4496. if(isset($_SESSION['api']))
  4497. {
  4498. $user = $this->user->get_api($_SESSION['api']);
  4499. $usp = $user;
  4500. $fgshop = "";$sid = "";
  4501. $user = explode('|',trim($user['shop'],'|'));
  4502. foreach ($user as $value)
  4503. {
  4504. $fgshop .= " shop = ".$value." or";
  4505. $sid .= " id = ".$value." or";
  4506. }
  4507. }
  4508. $post = $this->input->post(NULL, TRUE);
  4509. if(isset($post['page']))
  4510. {
  4511. $page = $this->input->post('page',true);
  4512. $perpage = $this->input->post('perpage',true);
  4513. $orderinfo = $this->input->post('orderinfo',true);
  4514. $waybill = $this->input->post('waybill',true);
  4515. $number = $this->input->post('number',true);
  4516. $timetk = $this->input->post('timetk',true);
  4517. $timetj = $this->input->post('timetj',true);
  4518. $timetk = strtotime($timetk);
  4519. $timetj = strtotime($timetj);
  4520. $where = "library = 2 and state = 214 and (".rtrim($fgshop,'or').")";
  4521. if($orderinfo)
  4522. {
  4523. $where .= " and orderinfo = '$orderinfo'";
  4524. }
  4525. if($waybill)
  4526. {
  4527. $where .= " and waybill = '$waybill'";
  4528. }
  4529. if($number)
  4530. {
  4531. $where .= " and number = '$number'";
  4532. }
  4533. if($timetk && $timetj)
  4534. {
  4535. $timetj = $timetj+24*3600;
  4536. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4537. }
  4538. //数据排序
  4539. $order_str = "dtime desc";
  4540. if(empty($page))
  4541. {
  4542. $start = 0;
  4543. $perpage = 1;
  4544. }
  4545. else
  4546. {
  4547. $start = ($page - 1)*$perpage;
  4548. }
  4549. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,state,dtime,express,waybill,library,operation',$order_str,$start,$perpage);
  4550. //格式化数据
  4551. foreach ($info_list as $key=>$value)
  4552. {
  4553. $ud = $this->fullordertt->read($value['id']);
  4554. $shop = $this->shop->read($value['shop']);
  4555. $info_list[$key]['shop'] = $shop['shopname'];
  4556. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4557. $warehouse = $this->warehouse->read($value['type']);
  4558. $warehousetitle = $warehouse['title'];
  4559. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4560. $info_list[$key]['type'] = $warehousetitle;
  4561. if($value['express'] != 0)
  4562. {
  4563. $express = $this->express->read($value['express']);
  4564. $expressservicename = $express['servicename'];
  4565. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4566. $info_list[$key]['express'] = $expressservicename;
  4567. }
  4568. else
  4569. {
  4570. $info_list[$key]['express'] = "无";
  4571. }
  4572. $typeclass = $this->typeclass->read($value['state']);
  4573. $info_list[$key]['state'] = "<font style='font-size: 13px;'>".$typeclass['spare']."</font>";
  4574. $info_list[$key]['dtime'] = '<p style="font-size: 13px;">'.date('Y-m-d',$ud['dtime']).'</p><p style="font-size: 13px;">'.date('H:i:s',$ud['dtime']).'</p>';
  4575. if($value['library'] == 1 && $ud['printtype'] == 3)
  4576. {
  4577. $info_list[$key]['library'] = "不需要";
  4578. }
  4579. else if($value['library'] == 1 && $ud['printtype'] != 3)
  4580. {
  4581. $info_list[$key]['library'] = "未出库";
  4582. }
  4583. else if($value['library'] == 2)
  4584. {
  4585. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  4586. }
  4587. else if($value['library'] == 3)
  4588. {
  4589. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  4590. }
  4591. $info_list[$key]['operation'] = "<p class='ckn'><b class='ycyc' data-id='".$value['id']."'>移 出</b></p>";
  4592. }
  4593. $total = $this->fullordertt->find_count($where);
  4594. $pagenum = ceil($total/$perpage);
  4595. $over = $total-($start+$perpage);
  4596. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4597. echo json_encode($rows);exit;
  4598. }
  4599. if(isset($post['id']))
  4600. {
  4601. $id = $this->input->post('id',true);
  4602. $data = $this->fullordertt->read($id);
  4603. if($this->fullordertt->save(array('state'=>217),$id))
  4604. {
  4605. echo json_encode(array('msg'=>'移除成功','id'=>$id,'success'=>true));exit;
  4606. }
  4607. else
  4608. {
  4609. echo json_encode(array('msg'=>"操作失败请重试",'success'=>false));exit;
  4610. }
  4611. }
  4612. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4613. $this->data['wlshop'] = $wlshop;
  4614. $this->data['express'] = $this->express->find_all();
  4615. $user = $this->user->get_api($_SESSION['api']);
  4616. $powerid = $this->power->read($user['power']);
  4617. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4618. $pid = '';
  4619. foreach ($powertext as $v)
  4620. {
  4621. $pid .= " id = ".$v." or";
  4622. }
  4623. $fullorderexcel = $this->fullorderexcel->find_all("type = '100006' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4624. $this->data['fullorderexcel'] = $fullorderexcel;
  4625. $this->_Template('fullordertt_yc',$this->data);
  4626. }
  4627. //导出异常取消列表
  4628. public function _ycexcel(){
  4629. if(isset($_SESSION['api']))
  4630. {
  4631. $user = $this->user->get_api($_SESSION['api']);
  4632. $usp = $user;
  4633. $fgshop = "";$sid = "";
  4634. $user = explode('|',trim($user['shop'],'|'));
  4635. foreach ($user as $value)
  4636. {
  4637. $fgshop .= " shop = ".$value." or";
  4638. $sid .= " id = ".$value." or";
  4639. }
  4640. }
  4641. $query = $this->input->get(NULL, TRUE);
  4642. if(empty($query['is_excel'])){
  4643. exit;
  4644. }
  4645. $where = "library = 2 and state = 214 and (".rtrim($fgshop,'or').")";
  4646. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,state,dtime,express,waybill,library,operation,librarytime,retreattime,printtype');
  4647. $shop_list = $this->shop->find_all('id > 0');
  4648. $shop_list = array_column($shop_list,'shopname','id');
  4649. $warehouse_list = $this->warehouse->find_all('id > 0');
  4650. $warehouse_list = array_column($warehouse_list,'title','id');
  4651. $express_list = $this->express->find_all('id > 0');
  4652. $express_list = array_column($express_list,'servicename','id');
  4653. $typeclass_list = $this->typeclass->find_all('classid = 29');
  4654. $typeclass_list = array_column($typeclass_list,'spare','classid');
  4655. //格式化数据
  4656. foreach ($info_list as $key=>$value)
  4657. {
  4658. $ud = $this->fullordertt->read($value['id']);
  4659. $info_list[$key]['shop'] = isset($shop_list[$value['shop']])? $shop_list[$value['shop']] : '';
  4660. $info_list[$key]['type'] = isset($warehouse_list[$value['type']])? $warehouse_list[$value['type']] : '';
  4661. if($value['express'] != 0)
  4662. {
  4663. $info_list[$key]['express'] = isset($express_list[$value['express']])? $express_list[$value['express']] : '';
  4664. }
  4665. else
  4666. {
  4667. $info_list[$key]['express'] = "无";
  4668. }
  4669. $info_list[$key]['state'] = isset($typeclass_list[$value['state']])? $typeclass_list[$value['state']] : '';
  4670. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$ud['dtime']);
  4671. if($value['library'] == 1 && $ud['printtype'] == 3)
  4672. {
  4673. $info_list[$key]['library'] = "不需要";
  4674. }
  4675. else if($value['library'] == 1 && $ud['printtype'] != 3)
  4676. {
  4677. $info_list[$key]['library'] = "未出库";
  4678. }
  4679. else if($value['library'] == 2)
  4680. {
  4681. $info_list[$key]['library'] = date('Y-m-d H:i:s',$value['librarytime'])." 出库";
  4682. }
  4683. else if($value['library'] == 3)
  4684. {
  4685. $info_list[$key]['library'] = date('Y-m-d H:i:s',$value['retreattime'])." 退库";
  4686. }
  4687. }
  4688. //生成excel
  4689. $filename = 'tiktok异常取消导出-'.date('Ymd',time()).".xlsx";
  4690. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4691. <head>
  4692. <!--[if gte mso 9]><xml>
  4693. <x:ExcelWorkbook>
  4694. <x:ExcelWorksheets>
  4695. <x:ExcelWorksheet>
  4696. <x:Name>EXCEL</x:Name>
  4697. <x:WorksheetOptions>
  4698. <x:Print>
  4699. <x:ValidPrinterInfo />
  4700. </x:Print>
  4701. </x:WorksheetOptions>
  4702. </x:ExcelWorksheet>
  4703. </x:ExcelWorksheets>
  4704. </x:ExcelWorkbook>
  4705. </xml>
  4706. <![endif]-->
  4707. </head><body>";
  4708. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4709. $str .= "<tr><td>店铺名称</td><td>发货仓库</td><td>订单号</td><td>编号</td><td>订单状态</td><td>订单时间</td><td>物流方式</td><td>运单号</td><td>发货状态</td></tr>";
  4710. foreach ($info_list as $key=>$v)
  4711. {
  4712. $str .= "<tr>";
  4713. $str .= "<td>". $v['shop']. "</td>";
  4714. $str .= "<td>". $v['type']. "</td>";
  4715. $str .= "<td>`". $v['orderinfo']. "</td>";
  4716. $str .= "<td>". $v['number']. "</td>";
  4717. $str .= "<td>". $v['state']. "</td>";
  4718. $str .= "<td>". $v['dtime']. "</td>";
  4719. $str .= "<td>". $v['express']. "</td>";
  4720. $str .= "<td>`". $v['waybill']. "</td>";
  4721. $str .= "<td>". $v['library']. "</td>";
  4722. $str .= "</tr>";
  4723. }
  4724. $str .= "</table></body></html>";
  4725. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4726. header( "Content-type: application/octet-stream" );
  4727. header( "Content-Disposition: attachment; filename=".$filename );
  4728. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4729. header( "Pragma: no-cache" );
  4730. header( "Expires: 0" );
  4731. exit($str);
  4732. }
  4733. //验证地址
  4734. public function _yzaddress()
  4735. {
  4736. $post = $this->input->post(NULL, TRUE);
  4737. if(isset($post['address']))
  4738. {
  4739. $address = $this->input->post('address',true);
  4740. $address2 = $this->input->post('address2',true);
  4741. $city = $this->input->post('city',true);
  4742. $province = $this->input->post('province',true);
  4743. $zipcode = $this->input->post('zipcode',true);
  4744. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  4745. echo $barcode;
  4746. }
  4747. }
  4748. //清除退货信息
  4749. public function _clearreturn()
  4750. {
  4751. $post = $this->input->post(NULL, TRUE);
  4752. if(isset($post['orderinfo']))
  4753. {
  4754. $orderinfo = $this->input->post('orderinfo',true);
  4755. $data = $this->fullordertt->get_orderinfo($orderinfo);
  4756. $fu = 'fullordertt';
  4757. if(!$data)
  4758. {
  4759. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4760. $fu = 'fullorder_smt';
  4761. }
  4762. $this->$fu->save(array('library'=>'2','retreattime'=>'0','returndata'=>''),$data['id']);
  4763. echo json_encode(array('msg'=>'清除成功!','success'=>true));exit;
  4764. }
  4765. }
  4766. //订单退货
  4767. public function _return()
  4768. {
  4769. $post = $this->input->post(NULL, TRUE);
  4770. if(isset($post['orderinfo']))
  4771. {
  4772. $orderinfo = $this->input->post('orderinfo',true);
  4773. $data = $this->fullordertt->get_orderinfo($orderinfo);
  4774. $fu = 'fullordertt';
  4775. if(!$data)
  4776. {
  4777. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4778. $fu = 'fullorder_smt';
  4779. }
  4780. if($data['library'] != 2){
  4781. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  4782. }
  4783. $bctime = date('Ymd',time());
  4784. if($data['returndata'] != "")
  4785. {
  4786. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4787. }
  4788. $barcode = $this->usps->get_return($data);
  4789. // if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4790. // {
  4791. // echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4792. // }
  4793. // else if(isset($barcode['TrackingNumber']))
  4794. // {
  4795. // $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  4796. // $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  4797. // $this->$fu->save(array('returndata'=>$read),$data['id']);
  4798. // echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4799. // }
  4800. // else
  4801. // {
  4802. // echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4803. // }
  4804. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4805. {
  4806. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4807. }
  4808. else if(isset($barcode['trackingNumber']))
  4809. {
  4810. $pdf = $this->_pdf($barcode['returnLabelImage'],'t-'.$barcode['trackingNumber'],$bctime);
  4811. $read = 'PostalRouting:'.$barcode['routingInformation'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['trackingNumber'].'.pdf" target="_blank">'.$barcode['trackingNumber'].'</a>';
  4812. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4813. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4814. }
  4815. else
  4816. {
  4817. echo json_encode(array('msg'=>'请求失败,请稍后重试!'.json_encode($barcode),'cs'=>$barcode,'success'=>false));exit;
  4818. }
  4819. }
  4820. }
  4821. public function _pdf($pdf,$title,$bctime)
  4822. {
  4823. $pdf_path = './data/pdf/'.$bctime.'/';
  4824. $file_base64 = $pdf;
  4825. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4826. $file_base64 = base64_decode($file_base64);
  4827. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  4828. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  4829. return $bctime;
  4830. }
  4831. public function _find($find)
  4832. {
  4833. preg_match_all('/\d+/',$find,$n);
  4834. $a = '';
  4835. foreach($n[0] as $v)
  4836. {
  4837. $a .= $v;
  4838. }
  4839. return $a;
  4840. }
  4841. public function _dqpm()
  4842. {
  4843. if(isset($_SESSION['api']))
  4844. {
  4845. $user = $this->user->get_api($_SESSION['api']);
  4846. $usp = $user;
  4847. $fgshop = "";$sid = "";
  4848. $usersp = explode('|',trim($user['shop'],'|'));
  4849. foreach ($usersp as $value)
  4850. {
  4851. $fgshop .= " shop = ".$value." or";
  4852. $sid .= " id = ".$value." or";
  4853. }
  4854. }
  4855. $post = $this->input->post(NULL, TRUE);
  4856. if(isset($post['page']))
  4857. {
  4858. $timetk = $this->input->post('timetk',true);
  4859. $timetj = $this->input->post('timetj',true);
  4860. $timetk = strtotime($timetk);
  4861. $timetj = strtotime($timetj);
  4862. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  4863. if($timetk && $timetj)
  4864. {
  4865. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4866. }
  4867. //数据排序
  4868. $order_str = "dtime desc";
  4869. if(empty($page))
  4870. {
  4871. $start = 0;
  4872. $perpage = 1;
  4873. }
  4874. else
  4875. {
  4876. $start = ($page - 1)*$perpage;
  4877. }
  4878. $continentdata = '';
  4879. $continent = array();//陆地板块
  4880. $num = $this->fullordertt->find_count($where);//订单总数量
  4881. $country = $this->country->find_all('1=1','id,continent,ename,zname');
  4882. foreach ($country as $k=>$v)
  4883. {
  4884. $tc = $this->typeclass->read($v['continent']);
  4885. $continent[$v['continent']] = array(0=>$tc['title'],1=>0,2=>'');
  4886. }
  4887. foreach ($country as $k=>$v)
  4888. {
  4889. $n = $this->fullordertt->find_count($where.' and country = "'.$v['id'].'"');
  4890. $country[$k]['continent'] = $continent[$v['continent']][0];//此国家数量
  4891. $country[$k]['zname'] = '<a href="/fullordertt/dqpmprovince/'.$v['id'].'/'.$timetk.'/'.$timetj.'">'.$v['zname'].'</a>';//此国家数量
  4892. $country[$k]['num'] = $n;//此国家数量
  4893. $country[$k]['zb'] = (sprintf("%.4f",$n/$num)*100).'%';//此国家占比
  4894. $continent[$v['continent']]['1'] += $n;//此洲数量增加;
  4895. }
  4896. array_multisort(array_column($continent, '1'), SORT_DESC, $continent);
  4897. array_multisort(array_column($country, 'num'), SORT_DESC, $country);
  4898. foreach ($continent as $k=>$v)
  4899. {
  4900. $continentdata .= $v['0'].' 总量:'.$v['1'].' 占比:'.(sprintf("%.4f",$v['1']/$num)*100).'%&nbsp;&nbsp; - &nbsp;&nbsp;';
  4901. }
  4902. echo json_encode(array('ewnr'=>$continentdata,'rows'=>$country,'total'=>count($country),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4903. }
  4904. $this->_Template('fullordertt_dqpm',$this->data);
  4905. }
  4906. public function _dqpmprovince($arg_array)
  4907. {
  4908. if(isset($_SESSION['api']))
  4909. {
  4910. $user = $this->user->get_api($_SESSION['api']);
  4911. $usp = $user;
  4912. $fgshop = "";$sid = "";
  4913. $usersp = explode('|',trim($user['shop'],'|'));
  4914. foreach ($usersp as $value)
  4915. {
  4916. $fgshop .= " shop = ".$value." or";
  4917. $sid .= " id = ".$value." or";
  4918. }
  4919. }
  4920. $post = $this->input->post(NULL, TRUE);
  4921. if(isset($post['page']))
  4922. {
  4923. $country = $this->input->post('country',true);
  4924. $timetk = $this->input->post('timetk',true);
  4925. $timetj = $this->input->post('timetj',true);
  4926. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4927. $province = array();
  4928. $city_list = $this->fullordertt->find_all($where,'id,province');
  4929. $ToState = array('AL'=>'alabama','AK'=>'alaska','AZ'=>'arizona','AR'=>'arkansas','CA'=>'california','CO'=>'colorado','CT'=>'connecticut','DE'=>'delaware','FL'=>'florida','GA'=>'georgia','HI'=>'hawaii','ID'=>'idaho','IL'=>'illinois','IN'=>'indiana','IA'=>'iowa','KS'=>'kansas','KY'=>'kentucky','LA'=>'louisiana','ME'=>'maine','MD'=>'maryland','MA'=>'massachusetts','MI'=>'michigan','MN'=>'minnesota','MS'=>'mississippi','MO'=>'missouri','MT'=>'montana','NE'=>'nebraska','NV'=>'nevada','NH'=>'new hampshire','NJ'=>'new jersey','NM'=>'new mexico','NY'=>'new york','NC'=>'north carolina','ND'=>'north dakota','OH'=>'ohio','OK'=>'oklahoma','OR'=>'oregon','PA'=>'pennsylvania','RI'=>'rhode island','SC'=>'south carolina','SD'=>'south dakota','TN'=>'tennessee','TX'=>'texas','UT'=>'utah','VT'=>'vermont','VA'=>'virginia','WA'=>'washington','WV'=>'west virginia','WI'=>'wisconsin','WY'=>'wyoming','DC'=>'district of columbia','VI'=>'virgin islands');
  4930. foreach ($city_list as $k=>$v)
  4931. {
  4932. $v['province'] = strtoupper(trim($v['province'],' '));
  4933. if(isset($ToState[$v['province']]))
  4934. {
  4935. $v['province'] = $ToState[$v['province']];
  4936. }
  4937. if(!isset($province[$v['province']]))
  4938. {
  4939. $province[$v['province']] = array('id'=>$v['id'],'province'=>'<a href="/fullordertt/ddpmdata/'.$country.'/'.$timetk.'/'.$timetj.'/'.strtoupper($v['province']).'">'.$v['province'].'</a>','num'=>0,'zb'=>'');
  4940. }
  4941. $province[$v['province']]['num'] += 1;
  4942. }
  4943. array_multisort(array_column($province, 'num'), SORT_DESC, $province);
  4944. $province = array_values($province);
  4945. foreach ($province as $k=>$v)
  4946. {
  4947. $province[$k]['zb'] = (sprintf("%.4f",$v['num']/count($city_list))*100).'%';
  4948. }
  4949. echo json_encode(array('rows'=>($province),'total'=>count($province),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4950. }
  4951. $this->data['arg_array'] = $arg_array;
  4952. $this->_Template('fullordertt_dqpmprovince',$this->data);
  4953. }
  4954. public function _ddpmdata($arg_array)
  4955. {
  4956. $arg_array[3] = str_replace('%20',' ',$arg_array[3]);
  4957. if(isset($_SESSION['api']))
  4958. {
  4959. $user = $this->user->get_api($_SESSION['api']);
  4960. $usp = $user;
  4961. $fgshop = "";$sid = "";
  4962. $usersp = explode('|',trim($user['shop'],'|'));
  4963. foreach ($usersp as $value)
  4964. {
  4965. $fgshop .= " shop = ".$value." or";
  4966. $sid .= " id = ".$value." or";
  4967. }
  4968. }
  4969. $post = $this->input->post(NULL, TRUE);
  4970. if(isset($post['page']))
  4971. {
  4972. $page = $this->input->post('page',true);
  4973. $perpage = $this->input->post('perpage',true);
  4974. $province = $this->input->post('province',true);
  4975. $timetk = $this->input->post('timetk',true);;
  4976. $timetj = $this->input->post('timetj',true);;
  4977. $country = $this->input->post('country',true);;
  4978. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4979. if($province)
  4980. {
  4981. $where .= " and province = '$province'";
  4982. }
  4983. $order_str = "dtime desc";
  4984. if(empty($page))
  4985. {
  4986. $start = 0;
  4987. $perpage = 1;
  4988. }
  4989. else
  4990. {
  4991. $start = ($page - 1)*$perpage;
  4992. }
  4993. $info_list = $this->fullordertt->find_all($where,'id,orderinfo,number,shipremarks,shouldmoney',$order_str,$start,$perpage);
  4994. $total = $this->fullordertt->find_count($where);
  4995. $pagenum = ceil($total/$perpage);
  4996. $over = $total-($start+$perpage);
  4997. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4998. echo json_encode($rows);exit;
  4999. }
  5000. $province = array();
  5001. $city_list = $this->fullordertt->find_all("mergeid = 0 and dtime > '$arg_array[1]' and dtime < '$arg_array[2]' and country = '$arg_array[0]' and (".rtrim($fgshop,'or').")",'province');
  5002. $ToState = array('AL'=>'alabama','AK'=>'alaska','AZ'=>'arizona','AR'=>'arkansas','CA'=>'california','CO'=>'colorado','CT'=>'connecticut','DE'=>'delaware','FL'=>'florida','GA'=>'georgia','HI'=>'hawaii','ID'=>'idaho','IL'=>'illinois','IN'=>'indiana','IA'=>'iowa','KS'=>'kansas','KY'=>'kentucky','LA'=>'louisiana','ME'=>'maine','MD'=>'maryland','MA'=>'massachusetts','MI'=>'michigan','MN'=>'minnesota','MS'=>'mississippi','MO'=>'missouri','MT'=>'montana','NE'=>'nebraska','NV'=>'nevada','NH'=>'new hampshire','NJ'=>'new jersey','NM'=>'new mexico','NY'=>'new york','NC'=>'north carolina','ND'=>'north dakota','OH'=>'ohio','OK'=>'oklahoma','OR'=>'oregon','PA'=>'pennsylvania','RI'=>'rhode island','SC'=>'south carolina','SD'=>'south dakota','TN'=>'tennessee','TX'=>'texas','UT'=>'utah','VT'=>'vermont','VA'=>'virginia','WA'=>'washington','WV'=>'west virginia','WI'=>'wisconsin','WY'=>'wyoming','DC'=>'district of columbia','VI'=>'virgin islands');
  5003. foreach ($city_list as $k=>$v)
  5004. {
  5005. $v['province'] = strtoupper(trim($v['province'],' '));
  5006. if(isset($ToState[$v['province']]))
  5007. {
  5008. $v['province'] = $ToState[$v['province']];
  5009. }
  5010. $province[$v['province']] = array('province'=>$v['province']);
  5011. }
  5012. $this->data['province'] = $province;
  5013. $this->data['arg_array'] = $arg_array;
  5014. $this->_Template('fullordertt_ddpmdata',$this->data);
  5015. }
  5016. public function _ddpmexcel($arg_array)
  5017. {
  5018. if(isset($_SESSION['api']))
  5019. {
  5020. $user = $this->user->get_api($_SESSION['api']);
  5021. $usp = $user;
  5022. $fgshop = "";$sid = "";
  5023. $usersp = explode('|',trim($user['shop'],'|'));
  5024. foreach ($usersp as $value)
  5025. {
  5026. $fgshop .= " shop = ".$value." or";
  5027. $sid .= " id = ".$value." or";
  5028. }
  5029. }
  5030. $province = $this->input->get('province',true);
  5031. $timetk = $arg_array[1];
  5032. $timetj = $arg_array[2];
  5033. $country = $arg_array[0];
  5034. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  5035. if($province)
  5036. {
  5037. $where .= " and province = '$province'";
  5038. }
  5039. $order_str = "dtime desc";
  5040. $info_list = $this->fullordertt->find_all($where,'orderinfo,number,shipremarks,shouldmoney',$order_str);
  5041. $country = $this->country->read($arg_array[0]);
  5042. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5043. $titlename = "<table border=1>
  5044. <tr><th colspan='4' align='left'><h3>".$title."<h3></th></tr>
  5045. <tr>
  5046. <td>订单号</td>
  5047. <td>订单编号</td>
  5048. <td>仓库品名</td>
  5049. <td>订单金额</td>
  5050. </tr>
  5051. </table>";
  5052. $filename = $title.".xls";
  5053. $tail = "\n";
  5054. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5055. }
  5056. public function _statedc()
  5057. {
  5058. $user = $this->user->get_api($_SESSION['api']);
  5059. if($user)
  5060. {
  5061. $fgshop = "";$sid = "";
  5062. $user = explode('|',trim($user['shop'],'|'));
  5063. foreach ($user as $value)
  5064. {
  5065. $fgshop .= " shop = ".$value." or";
  5066. $sid .= " id = ".$value." or";
  5067. }
  5068. }
  5069. $post = $this->input->get(NULL, TRUE);
  5070. if(isset($post['timetk']))
  5071. {
  5072. $page = $this->input->get('page',true);
  5073. $perpage = $this->input->get('perpage',true);
  5074. $timetk = $this->input->get('timetk',true);
  5075. $timetj = $this->input->get('timetj',true);
  5076. $shop = $this->input->get('shop',true);
  5077. $source = $this->input->get('source',true);
  5078. $state = $this->input->get('state',true);
  5079. $review = $this->input->get('review',true);
  5080. $express = $this->input->get('express',true);
  5081. $fs = $this->input->get('fs',true);
  5082. $orderinfo = $this->input->get('orderinfo',true);
  5083. $number = $this->input->get('number',true);
  5084. $user = $this->input->get('user',true);
  5085. $name = $this->input->get('name',true);
  5086. $waybill = $this->input->get('waybill',true);
  5087. $expressstate = $this->input->get('expressstate',true);
  5088. $wltype = $this->input->get('wltype',true);
  5089. $wlyc = $this->input->get('wlyc',true);
  5090. $xztime = $this->input->get('xztime',true);
  5091. $timetk = strtotime($timetk);
  5092. $timetj = strtotime($timetj);
  5093. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5094. if($timetk && $timetj)
  5095. {
  5096. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5097. }
  5098. if($xztime == 'librarytime')
  5099. {
  5100. $order_str = "librarytime desc";
  5101. }
  5102. else if($xztime == 'dtime')
  5103. {
  5104. $order_str = "dtime desc";
  5105. }
  5106. if($shop)
  5107. {
  5108. $where .= " and shop = '$shop'";
  5109. }
  5110. if($source)
  5111. {
  5112. if($source == 11)
  5113. {
  5114. $where .= " and source != '1'";
  5115. }
  5116. else
  5117. {
  5118. $where .= " and source = '$source'";
  5119. }
  5120. }
  5121. if($fs)
  5122. {
  5123. if($fs == '2')
  5124. {
  5125. $where .= " and exstateerror != ''";
  5126. }
  5127. else
  5128. {
  5129. $where .= " and exstateerror = ''";
  5130. }
  5131. }
  5132. if($state)
  5133. {
  5134. $where .= " and state = '$state'";
  5135. }
  5136. if($review)
  5137. {
  5138. $where .= " and review = '$review'";
  5139. }
  5140. if($expressstate != "")
  5141. {
  5142. $where .= " and expressstate = '$expressstate'";
  5143. }
  5144. if($wltype != "")
  5145. {
  5146. $where .= " and wltype = '$wltype'";
  5147. }
  5148. if($wlyc != "")
  5149. {
  5150. $where .= " and wlyc = '$wlyc'";
  5151. }
  5152. if($express)
  5153. {
  5154. $where .= " and express = '$express'";
  5155. }
  5156. if($orderinfo)
  5157. {
  5158. $where .= " and orderinfo = '$orderinfo'";
  5159. }
  5160. if($number)
  5161. {
  5162. $where .= " and number = '$number'";
  5163. }
  5164. if($user)
  5165. {
  5166. $where .= " and user = '$user'";
  5167. }
  5168. if($name)
  5169. {
  5170. $where .= " and name = '$name'";
  5171. }
  5172. if($waybill)
  5173. {
  5174. $where .= " and waybill = '$waybill'";
  5175. }
  5176. if(empty($page))
  5177. {
  5178. $start = 0;
  5179. $perpage = 1;
  5180. }
  5181. else
  5182. {
  5183. $start = ($page - 1)*$perpage;
  5184. }
  5185. //取得信息列表
  5186. $info_list = $this->fullordertt->find_all($where,'shop,number,country,library,librarytime,expressstate,express,waybill,content,exstateerror,excontent',$order_str);
  5187. //格式化数据
  5188. foreach ($info_list as $key=>$value)
  5189. {
  5190. $shop = $this->shop->read($value['shop']);
  5191. $info_list[$key]['shop'] = $shop['shopname'];
  5192. $country = $this->country->read($value['country']);
  5193. $info_list[$key]['country'] = $country['name'];
  5194. //$state = $this->typeclass->read($value['state']);
  5195. //$info_list[$key]['state'] = $state['title'];
  5196. if($value['library'] == 1)
  5197. {
  5198. $info_list[$key]['library'] = "未出库";
  5199. }
  5200. else if($value['library'] == 2)
  5201. {
  5202. $info_list[$key]['library'] = "已出库";
  5203. }
  5204. else if($value['library'] == 3)
  5205. {
  5206. $info_list[$key]['library'] = "已退库";
  5207. }
  5208. if($value['librarytime'] == '0')
  5209. {
  5210. $info_list[$key]['librarytime'] = '无';
  5211. }
  5212. else
  5213. {
  5214. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5215. }
  5216. if($value['expressstate'] == 0)
  5217. {
  5218. $info_list[$key]['expressstate'] = "无信息";
  5219. }
  5220. else if($value['expressstate'] == 2)
  5221. {
  5222. $info_list[$key]['expressstate'] = "已取件";
  5223. }
  5224. else if($value['expressstate'] == 3)
  5225. {
  5226. $info_list[$key]['expressstate'] = "在途中";
  5227. }
  5228. else if($value['expressstate'] == 4)
  5229. {
  5230. $info_list[$key]['expressstate'] = "到达目的地国";
  5231. }
  5232. else if($value['expressstate'] == 5)
  5233. {
  5234. $info_list[$key]['expressstate'] = "即将派送";
  5235. }
  5236. else if($value['expressstate'] == 6)
  5237. {
  5238. $info_list[$key]['expressstate'] = "已签收";
  5239. }
  5240. else if($value['expressstate'] == 1)
  5241. {
  5242. $info_list[$key]['expressstate'] = "派送异常";
  5243. }
  5244. $express = $this->express->read($value['express']);
  5245. $info_list[$key]['express'] = $express['servicename'];
  5246. }
  5247. }
  5248. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5249. $titlename = "<table border=1>
  5250. <tr>
  5251. <td>店铺名称</td>
  5252. <td>编号</td>
  5253. <td>收件人国家</td>
  5254. <td>出库状态</td>
  5255. <td>发货时间</td>
  5256. <td>物流状态</td>
  5257. <td>快递公司</td>
  5258. <td>运单号</td>
  5259. <td>消息状态</td>
  5260. <td>错误提示</td>
  5261. <td>物流信息</td>
  5262. </tr>
  5263. </table>";
  5264. $filename = $title.".xls";
  5265. $tail = "\n";
  5266. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5267. }
  5268. public function _statedcwl()
  5269. {
  5270. $user = $this->user->get_api($_SESSION['api']);
  5271. if($user)
  5272. {
  5273. $fgshop = "";$sid = "";
  5274. $user = explode('|',trim($user['shop'],'|'));
  5275. foreach ($user as $value)
  5276. {
  5277. $fgshop .= " shop = ".$value." or";
  5278. $sid .= " id = ".$value." or";
  5279. }
  5280. }
  5281. $post = $this->input->get(NULL, TRUE);
  5282. if(isset($post['timetk']))
  5283. {
  5284. $dowid = $this->input->get('a');
  5285. $wid = "";
  5286. if($dowid != "")
  5287. {
  5288. $id_arr = explode(',',rtrim($dowid,','));
  5289. $wid .= " id = 0 or";
  5290. foreach ($id_arr as $v)
  5291. {
  5292. $wid .= " id = '$v' or";
  5293. }
  5294. $wid = " and".rtrim($wid,'or');
  5295. }
  5296. $page = $this->input->get('page',true);
  5297. $perpage = $this->input->get('perpage',true);
  5298. $timetk = $this->input->get('timetk',true);
  5299. $timetj = $this->input->get('timetj',true);
  5300. $shop = $this->input->get('shop',true);
  5301. $expressstate = $this->input->get('expressstate',true);
  5302. $fs = $this->input->get('fs',true);
  5303. $state = $this->input->get('state',true);
  5304. $express = $this->input->get('express',true);
  5305. $orderinfo = $this->input->get('orderinfo',true);
  5306. $number = $this->input->get('number',true);
  5307. $waybill = $this->input->get('waybill',true);
  5308. $wlyc = $this->input->get('wlyc',true);
  5309. $wltype = $this->input->get('wltype',true);
  5310. $source = $this->input->get('source',true);
  5311. $xztime = $this->input->get('xztime',true);
  5312. $timetk = strtotime($timetk);
  5313. $timetj = strtotime($timetj);
  5314. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5315. if($timetk && $timetj)
  5316. {
  5317. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5318. }
  5319. if($xztime == 'librarytime')
  5320. {
  5321. $order_str = "librarytime desc";
  5322. }
  5323. else if($xztime == 'dtime')
  5324. {
  5325. $order_str = "dtime desc";
  5326. }
  5327. if($shop)
  5328. {
  5329. $where .= " and shop = '$shop'";
  5330. }
  5331. if($expressstate)
  5332. {
  5333. $where .= " and expressstate = '$expressstate'";
  5334. }
  5335. if($fs)
  5336. {
  5337. if($fs == '1')
  5338. {
  5339. $where .= " and wlcontent != ''";
  5340. }
  5341. if($fs == '2')
  5342. {
  5343. $where .= " and wlerror != ''";
  5344. }
  5345. if($fs == '3')
  5346. {
  5347. $where .= " and wlcontent = '' and shouldmoney > 100";
  5348. }
  5349. else if($fs == '4')
  5350. {
  5351. $where .= " and wltype = '1'";
  5352. }
  5353. }
  5354. if($state)
  5355. {
  5356. $where .= " and state = '$state'";
  5357. }
  5358. if($express)
  5359. {
  5360. $where .= " and express = '$express'";
  5361. }
  5362. if($orderinfo)
  5363. {
  5364. $where .= " and orderinfo = '$orderinfo'";
  5365. }
  5366. if($number)
  5367. {
  5368. $where .= " and number = '$number'";
  5369. }
  5370. if($waybill)
  5371. {
  5372. $where .= " and waybill = '$waybill'";
  5373. }
  5374. if($wlyc!='')
  5375. {
  5376. $where .= " and wlyc = '$wlyc'";
  5377. }
  5378. if($wltype!='')
  5379. {
  5380. $where .= " and wltype = '$wltype'";
  5381. }
  5382. if($source)
  5383. {
  5384. if($source == 1)
  5385. {
  5386. $where .= " and source = '$source'";
  5387. }
  5388. else
  5389. {
  5390. $where .= " and source != '1'";
  5391. }
  5392. }
  5393. $info_list = $this->fullordertt->find_all($where.$wid,'orderinfo,number,country,library,librarytime,expressstate,express,waybill,wlbz,orderremarks,shipremarks,wlfstime,email,phone,wlcontent,wlerror,excontent',$order_str);
  5394. //格式化数据
  5395. foreach ($info_list as $key=>$value)
  5396. {
  5397. $country = $this->country->read($value['country']);
  5398. $info_list[$key]['country'] = $country['name'];
  5399. //$state = $this->typeclass->read($value['state']);
  5400. //$info_list[$key]['state'] = $state['title'];
  5401. if($value['library'] == 1)
  5402. {
  5403. $info_list[$key]['library'] = "未出库";
  5404. }
  5405. else if($value['library'] == 2)
  5406. {
  5407. $info_list[$key]['library'] = "已出库";
  5408. }
  5409. else if($value['library'] == 3)
  5410. {
  5411. $info_list[$key]['library'] = "已退库";
  5412. }
  5413. if($value['librarytime'] == '0')
  5414. {
  5415. $info_list[$key]['librarytime'] = '无';
  5416. }
  5417. else
  5418. {
  5419. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5420. }
  5421. if($value['expressstate'] == 0)
  5422. {
  5423. $info_list[$key]['expressstate'] = "无信息";
  5424. }
  5425. else if($value['expressstate'] == 2)
  5426. {
  5427. $info_list[$key]['expressstate'] = "已取件";
  5428. }
  5429. else if($value['expressstate'] == 3)
  5430. {
  5431. $info_list[$key]['expressstate'] = "在途中";
  5432. }
  5433. else if($value['expressstate'] == 4)
  5434. {
  5435. $info_list[$key]['expressstate'] = "到达目的地国";
  5436. }
  5437. else if($value['expressstate'] == 5)
  5438. {
  5439. $info_list[$key]['expressstate'] = "即将派送";
  5440. }
  5441. else if($value['expressstate'] == 6)
  5442. {
  5443. $info_list[$key]['expressstate'] = "已签收";
  5444. }
  5445. else if($value['expressstate'] == 1)
  5446. {
  5447. $info_list[$key]['expressstate'] = "派送异常";
  5448. }
  5449. $info_list[$key]['wlfstime'] = date('Y-m-d H:i:s',$value['wlfstime']);
  5450. $express = $this->express->read($value['express']);
  5451. $info_list[$key]['express'] = $express['servicename'];
  5452. $info_list[$key]['excontent'] = str_replace('<br />','',$value['excontent']);
  5453. }
  5454. }
  5455. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5456. $titlename = "<table border=1>
  5457. <tr>
  5458. <td>订单号</td>
  5459. <td>编号</td>
  5460. <td>收件人国家</td>
  5461. <td>出库状态</td>
  5462. <td>出库时间</td>
  5463. <td>物流状态</td>
  5464. <td>快递公司</td>
  5465. <td>运单号</td>
  5466. <td>物流备注</td>
  5467. <td>订单备注</td>
  5468. <td>仓库品名</td>
  5469. <td>发送时间</td>
  5470. <td>邮箱</td>
  5471. <td>电话</td>
  5472. <td>邮件发送</td>
  5473. <td>错误提示</td>
  5474. <td>物流信息</td>
  5475. </tr>
  5476. </table>";
  5477. $filename = $title.".xls";
  5478. $tail = "\n";
  5479. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5480. }
  5481. public function _waybillemail()
  5482. {
  5483. $user = $this->user->get_api($_SESSION['api']);
  5484. if($user)
  5485. {
  5486. $fgshop = "";$sid = "";
  5487. $user = explode('|',trim($user['shop'],'|'));
  5488. foreach ($user as $value)
  5489. {
  5490. $fgshop .= " shop = ".$value." or";
  5491. $sid .= " id = ".$value." or";
  5492. }
  5493. }
  5494. $post = $this->input->post(NULL, TRUE);
  5495. if(isset($post['page']))
  5496. {
  5497. $page = $this->input->post('page',true);
  5498. $perpage = $this->input->post('perpage',true);
  5499. $timetk = $this->input->post('timetk',true);
  5500. $timetj = $this->input->post('timetj',true);
  5501. $shop = $this->input->post('shop',true);
  5502. $expressstate = $this->input->post('expressstate',true);
  5503. $fs = $this->input->post('fs',true);
  5504. $state = $this->input->post('state',true);
  5505. $express = $this->input->post('express',true);
  5506. $orderinfo = $this->input->post('orderinfo',true);
  5507. $number = $this->input->post('number',true);
  5508. $waybill = $this->input->post('waybill',true);
  5509. $dlzemail = $this->input->post('dlzemail',true);
  5510. $xztime = $this->input->post('xztime',true);
  5511. $timetk = strtotime($timetk);
  5512. $timetj = strtotime($timetj);
  5513. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5514. if($timetk && $timetj)
  5515. {
  5516. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5517. }
  5518. $order_str = $xztime." desc";
  5519. if($shop)
  5520. {
  5521. $where .= " and shop = '$shop'";
  5522. }
  5523. if($expressstate)
  5524. {
  5525. $where .= " and expressstate = '$expressstate'";
  5526. }
  5527. if($state)
  5528. {
  5529. $where .= " and state = '$state'";
  5530. }
  5531. if($express)
  5532. {
  5533. $where .= " and express = '$express'";
  5534. }
  5535. if($orderinfo)
  5536. {
  5537. $where .= " and orderinfo = '$orderinfo'";
  5538. }
  5539. if($number)
  5540. {
  5541. $where .= " and number = '$number'";
  5542. }
  5543. if($waybill)
  5544. {
  5545. $where .= " and waybill = '$waybill'";
  5546. }
  5547. if($dlzemail != '')
  5548. {
  5549. $where .= " and dlzemail = '$dlzemail'";
  5550. }
  5551. if(empty($page))
  5552. {
  5553. $start = 0;
  5554. $perpage = 1;
  5555. }
  5556. else
  5557. {
  5558. $start = ($page - 1)*$perpage;
  5559. }
  5560. //取得信息列表
  5561. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,dlzemail,dlzemailtime',$order_str,$start,$perpage);
  5562. //格式化数据
  5563. foreach ($info_list as $key=>$value)
  5564. {
  5565. $shop = $this->shop->read($value['shop']);
  5566. $info_list[$key]['shop'] = $shop['shopname'];
  5567. $country = $this->country->read($value['country']);
  5568. $info_list[$key]['country'] = $country['name'];
  5569. //$state = $this->typeclass->read($value['state']);
  5570. //$info_list[$key]['state'] = $state['title'];
  5571. if($value['library'] == 1)
  5572. {
  5573. $info_list[$key]['library'] = "未出库";
  5574. }
  5575. else if($value['library'] == 2)
  5576. {
  5577. $info_list[$key]['library'] = "已出库";
  5578. }
  5579. else if($value['library'] == 3)
  5580. {
  5581. $info_list[$key]['library'] = "已退库";
  5582. }
  5583. if($value['librarytime'] == '0')
  5584. {
  5585. $info_list[$key]['librarytime'] = '无';
  5586. }
  5587. else
  5588. {
  5589. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  5590. }
  5591. $express = $this->express->read($value['express']);
  5592. $info_list[$key]['express'] = $express['servicename'];
  5593. if($value['dlzemail'] == '1')
  5594. {
  5595. $info_list[$key]['dlzemail'] = '发送成功';
  5596. }
  5597. else if ($value['dlzemail'] == '2')
  5598. {
  5599. $info_list[$key]['dlzemail'] = '发送失败';
  5600. }
  5601. else
  5602. {
  5603. $info_list[$key]['dlzemail'] = '';
  5604. }
  5605. $info_list[$key]['dlzemailtime'] = ($value['dlzemailtime']>0)?date('Y-m-d H:i:s',$value['dlzemailtime']):'';
  5606. }
  5607. $total = $this->fullordertt->find_count($where);
  5608. $pagenum = ceil($total/$perpage);
  5609. $over = $total-($start+$perpage);
  5610. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5611. echo json_encode($rows);exit;
  5612. }
  5613. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  5614. $this->data['notice'] = $notice;
  5615. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  5616. $this->data['wlshop'] = $wlshop;
  5617. $this->data['express'] = $this->express->find_all();
  5618. $this->_Template('fullordertt_waybillemail',$this->data);
  5619. }
  5620. public function _khdd()
  5621. {
  5622. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  5623. if(isset($_SESSION['api']))
  5624. {
  5625. $user = $this->user->get_api($_SESSION['api']);
  5626. $usp = $user;
  5627. $fgshop = "";$sid = "";
  5628. $usersp = explode('|',trim($user['shop'],'|'));
  5629. foreach ($usersp as $value)
  5630. {
  5631. $fgshop .= " shop = ".$value." or";
  5632. $sid .= " id = ".$value." or";
  5633. }
  5634. if($user['vip'] == 1)
  5635. {
  5636. $vip = 1;
  5637. }
  5638. else
  5639. {
  5640. $vip = 0;
  5641. }
  5642. }
  5643. $post = $this->input->post(NULL, TRUE);
  5644. if(isset($_GET['excel']))
  5645. {
  5646. $page = $this->input->get('page',true);
  5647. $perpage = $this->input->get('perpage',true);
  5648. $warehouse = $this->input->get('warehouse',true);
  5649. $timetk = $this->input->get('timetk',true);
  5650. $timetj = $this->input->get('timetj',true);
  5651. $shop = $this->input->get('shop',true);
  5652. $source = $this->input->get('source',true);
  5653. $state = $this->input->get('state',true);
  5654. $review = $this->input->get('review',true);
  5655. $type = $this->input->get('type',true);
  5656. $express = $this->input->get('express',true);
  5657. $orderinfo = $this->input->get('orderinfo',true);
  5658. $user = $this->input->get('user',true);
  5659. $client = $this->input->get('name',true);
  5660. $waybill = $this->input->get('waybill',true);
  5661. $number = $this->input->get('number',true);
  5662. $email = $this->input->get('email',true);
  5663. $phone = $this->input->get('phone',true);
  5664. $dlz = $this->input->get('dlz',true);
  5665. $print = $this->input->get('print',true);
  5666. $library = $this->input->get('library',true);
  5667. $js = $this->input->get('js',true);
  5668. $exstate = $this->input->get('exstate',true);
  5669. $xztime = $this->input->get('xztime',true);
  5670. $libraryconfirm = $this->input->get('libraryconfirm',true);
  5671. $timetk = strtotime($timetk);
  5672. $timetj = strtotime($timetj);
  5673. $plorder = $this->input->get('pl',true);
  5674. $paypal = $this->input->get('paypal',true);
  5675. $zf = $this->input->get('zf',true);
  5676. $pay = $this->input->get('pay',true);
  5677. $excel = $this->input->get('excel',true);
  5678. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5679. if($warehouse)
  5680. {
  5681. $where .= " and type = '$warehouse'";
  5682. }
  5683. if($timetk && $timetj)
  5684. {
  5685. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5686. }
  5687. if($shop)
  5688. {
  5689. $where .= " and shop = '$shop'";
  5690. }
  5691. if($source)
  5692. {
  5693. if($source == '2d')
  5694. {
  5695. $where .= " and source >= '2'";
  5696. }
  5697. else
  5698. {
  5699. $where .= " and source = '$source'";
  5700. }
  5701. }
  5702. if($state)
  5703. {
  5704. $where .= " and state = '$state'";
  5705. }
  5706. if($review)
  5707. {
  5708. $where .= " and review = '$review'";
  5709. }
  5710. if($type)
  5711. {
  5712. $where .= " and type = '$type'";
  5713. }
  5714. if($express)
  5715. {
  5716. $where .= " and express = '$express'";
  5717. }
  5718. if($orderinfo)
  5719. {
  5720. $where .= " and orderinfo = '$orderinfo'";
  5721. }
  5722. if($user)
  5723. {
  5724. $where .= " and user = '$user'";
  5725. }
  5726. if($client)
  5727. {
  5728. $where .= " and client like '%$client%'";
  5729. }
  5730. if($waybill)
  5731. {
  5732. $where .= " and waybill = '$waybill'";
  5733. }
  5734. if($number)
  5735. {
  5736. $where .= " and number = '$number'";
  5737. }
  5738. if($email)
  5739. {
  5740. $where .= " and email = '$email'";
  5741. }
  5742. if($phone)
  5743. {
  5744. $where .= " and phone like '%$phone%'";
  5745. }
  5746. if($library)
  5747. {
  5748. $where .= " and library = '$library'";
  5749. }
  5750. if($print)
  5751. {
  5752. $where .= " and print = '$print'";
  5753. }
  5754. if($dlz != '')
  5755. {
  5756. $where .= " and dlz = '$dlz'";
  5757. }
  5758. if($js)
  5759. {
  5760. $where .= " and js = '$js'";
  5761. }
  5762. if($exstate)
  5763. {
  5764. $where .= " and exstate = '$exstate'";
  5765. }
  5766. if($libraryconfirm)
  5767. {
  5768. $where .= " and libraryconfirm = '$libraryconfirm'";
  5769. }
  5770. if($paypal)
  5771. {
  5772. $where .= " and paypal = '$paypal'";
  5773. }
  5774. if($pay)
  5775. {
  5776. $where .= " and pay = '$pay'";
  5777. }
  5778. if($zf)
  5779. {
  5780. if($zf == 1)
  5781. {
  5782. $where .= " and paypal not like '%-%-%-%'";
  5783. }
  5784. else
  5785. {
  5786. $where .= " and paypal like '%-%-%-%'";
  5787. }
  5788. }
  5789. if($plorder)
  5790. {
  5791. $plorderinfo = '';$plnumber = '';$pln = 0;
  5792. $plorder = explode(',',trim($plorder,','));
  5793. foreach ($plorder as $value)
  5794. {
  5795. if(is_numeric($value))
  5796. {
  5797. $plorderinfo .= " orderinfo = ".$value." or";
  5798. }
  5799. else if($value != '')
  5800. {
  5801. $plorderinfo .= " number = '".$value."' or";
  5802. }
  5803. }
  5804. if($pln > 0)
  5805. {
  5806. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  5807. }
  5808. else
  5809. {
  5810. $where .= " and (".rtrim($plorderinfo,'or').")";
  5811. }
  5812. }
  5813. //数据排序
  5814. $order_str = "dtime desc";
  5815. if(empty($page))
  5816. {
  5817. $start = 0;
  5818. $perpage = 1;
  5819. }
  5820. else
  5821. {
  5822. $start = ($page - 1)*$perpage;
  5823. }
  5824. if($excel == '1')
  5825. {
  5826. $shop = array();
  5827. $shopdata = $this->shop->find_all("type = '269'");
  5828. foreach ($shopdata as $v)
  5829. {
  5830. $shop[$v['id']] = array('t'=>$v['brandname'],'z'=>0,'l'=>0,'x'=>0);//店铺名称,总客户,老客户,新客户
  5831. }
  5832. $oldnumber = 0;$newnumber = 0;
  5833. $info_list = $this->db->query('select distinct shop,email from crowd_fullordertt where '.$where)->result_array();
  5834. foreach ($info_list as $key=>$v)
  5835. {
  5836. $shop[$v['shop']]['z'] += 1;
  5837. $num = $this->fullordertt->find_count("email = '".$v['email']."' and shop = '".$v['shop']."' and ".$xztime." < '$timetj'");
  5838. if($num > 1)
  5839. {
  5840. $shop[$v['shop']]['l'] += 1;
  5841. }
  5842. else
  5843. {
  5844. $shop[$v['shop']]['x'] += 1;
  5845. }
  5846. if(isset($v['email']) && $usp['excelpass'] == '1')
  5847. {
  5848. $emailpass = $this->setting->get_excelpass($v['email']);
  5849. $info_list[$key]['email'] = $emailpass;
  5850. }
  5851. }
  5852. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5853. $titlename = "<table border=1>
  5854. <tr>
  5855. <td>店铺</td>
  5856. <td>客户数</td>
  5857. <td>老客户数</td>
  5858. <td>新客户数</td>
  5859. </tr>
  5860. </table>";
  5861. $filename = $title.".xls";
  5862. $tail = "\n";
  5863. $this->excel->get_fz2($shop,$titlename,$filename,$tail);
  5864. }
  5865. else if($excel == '2' || $excel == '3')
  5866. {
  5867. $kh = array();
  5868. $info_list = $this->db->query('select distinct shop,email from crowd_fullordertt where email != "" and '.$where)->result_array();
  5869. foreach ($info_list as $key=>$v)
  5870. {
  5871. $k = $this->fullordertt->find_all("shop = '".$v['shop']."' and email = '".$v['email']."' and ".$xztime." < '$timetj'",'name,email,dtime,shouldmoney','dtime desc');
  5872. if($excel == 2 && count($k) > 1)
  5873. {
  5874. $kh[] = array($k[0]['name'],$k[0]['email'],date("Y-m-d H:i:s",$k[0]['dtime']),count($k),array_sum(array_column($k,'shouldmoney')));
  5875. }
  5876. if($excel == 3 && count($k) < 2)
  5877. {
  5878. $kh[] = array($k[0]['name'],$k[0]['email'],date("Y-m-d H:i:s",$k[0]['dtime']),count($k),array_sum(array_column($k,'shouldmoney')));
  5879. }
  5880. if(isset($v['email']) && $usp['excelpass'] == '1')
  5881. {
  5882. $emailpass = $this->setting->get_excelpass($v['email']);
  5883. $info_list[$key]['email'] = $emailpass;
  5884. }
  5885. }
  5886. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5887. $titlename = "<table border=1>
  5888. <tr>
  5889. <td>名称</td>
  5890. <td>邮箱</td>
  5891. <td>最后购买时间</td>
  5892. <td>购买次数</td>
  5893. <td>购买总额</td>
  5894. </tr>
  5895. </table>";
  5896. $filename = $title.".xls";
  5897. $tail = "\n";
  5898. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5899. }
  5900. else if($excel == '4' || $excel == '5')
  5901. {
  5902. $kh = array();
  5903. $info_list = $this->db->query('select distinct shop,email from crowd_fullordertt where email != "" and '.$where)->result_array();
  5904. foreach ($info_list as $key=>$value)
  5905. {
  5906. $k = $this->fullordertt->find_all("shop = '".$value['shop']."' and email = '".$value['email']."' and ".$xztime." < '$timetj'",'orderinfo,state,product,name,email,dtime,shouldmoney','dtime desc');
  5907. if($excel == 4 && count($k) > 1)
  5908. {
  5909. foreach ($k as $v)
  5910. {
  5911. $typeclass = $this->typeclass->read($v['state']);
  5912. $kh[] = array("'".$v['orderinfo'],$typeclass['spare'],$v['product'],$v['name'],$v['email'],date("Y-m-d H:i:s",$v['dtime']),$v['shouldmoney']);
  5913. }
  5914. }
  5915. if($excel == 5 && count($k) < 2)
  5916. {
  5917. if(!isset($k[0]['state']))
  5918. {
  5919. $typeclass = $k[0]['state'].'-数据字典无此信息';
  5920. }
  5921. else
  5922. {
  5923. $typeclass = $this->typeclass->read($k[0]['state']);
  5924. }
  5925. $kh[] = array($k[0]['orderinfo'],$typeclass['spare'],$k[0]['product'],$k[0]['name'],$k[0]['email'],date("Y-m-d H:i:s",$k[0]['dtime']),$k[0]['shouldmoney']);
  5926. }
  5927. if(isset($value['email']) && $usp['excelpass'] == '1')
  5928. {
  5929. $emailpass = $this->setting->get_excelpass($value['email']);
  5930. $info_list[$key]['email'] = $emailpass;
  5931. }
  5932. }
  5933. if($excel == '4'){
  5934. // $header = [
  5935. // [
  5936. // 'title'=>"订单号",
  5937. // 'width'=>0,//为0 默认为自动
  5938. // ],
  5939. // [
  5940. // 'title'=>"订单状态",
  5941. // 'width'=>0,//为0 默认为自动
  5942. // ],
  5943. // [
  5944. // 'title'=>"产品名",
  5945. // 'width'=>30,//为0 默认为自动
  5946. // ],
  5947. // [
  5948. // 'title'=>"客户名",
  5949. // 'width'=>0,//为0 默认为自动
  5950. // ],
  5951. // [
  5952. // 'title'=>"客户邮箱",
  5953. // 'width'=>0,//为0 默认为自动
  5954. // ],
  5955. // [
  5956. // 'title'=>"下单时间",
  5957. // 'width'=>0,//为0 默认为自动
  5958. // ],
  5959. // [
  5960. // 'title'=>"订单金额",
  5961. // 'width'=>0,//为0 默认为自动
  5962. // ],
  5963. // ];
  5964. // if(!empty($country['zname'])){
  5965. // $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5966. // }else{
  5967. // $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5968. // }
  5969. // $filename = $title;
  5970. // $data = $kh;
  5971. // $this->excelnew->doHeadMerg($title,$filename,$header,$data);
  5972. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5973. $titlename = "<table border=1>
  5974. <tr>
  5975. <td>订单号</td>
  5976. <td>订单状态</td>
  5977. <td>产品名</td>
  5978. <td>客户名</td>
  5979. <td>客户邮箱</td>
  5980. <td>下单时间</td>
  5981. <td>订单金额</td>
  5982. </tr>
  5983. </table>";
  5984. $filename = $title.".xls";
  5985. $tail = "\n";
  5986. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5987. }else{
  5988. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5989. $titlename = "<table border=1>
  5990. <tr>
  5991. <td>订单号</td>
  5992. <td>订单状态</td>
  5993. <td>产品名</td>
  5994. <td>客户名</td>
  5995. <td>客户邮箱</td>
  5996. <td>下单时间</td>
  5997. <td>订单金额</td>
  5998. </tr>
  5999. </table>";
  6000. $filename = $title.".xls";
  6001. $tail = "\n";
  6002. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  6003. }
  6004. }
  6005. }
  6006. }
  6007. public function _klarnadata()
  6008. {
  6009. $post = $this->input->post(NULL, TRUE);
  6010. if(isset($post['number']))
  6011. {
  6012. $number = $this->input->post('number',true);
  6013. $data = $this->fullordertt->get_number($number);
  6014. $shop = $this->shop->read($data['shop']);
  6015. $f = '';
  6016. if($data['pay'] == '23')
  6017. {
  6018. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$data['paypal'];
  6019. $header[] = "Content-Type:application/json";
  6020. $header[] = "Authorization: Basic ".base64_encode($shop['klarnaname'].":".$shop['klarnapass']);
  6021. $ch = curl_init();
  6022. curl_setopt($ch, CURLOPT_URL, $url);
  6023. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6024. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6025. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6026. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6027. $res = curl_exec($ch);
  6028. curl_close($ch);
  6029. $res = json_decode($res,true);
  6030. if(isset($res['fraud_status']) && $shop['klarnaname'] != '')
  6031. {
  6032. $f = (($res['fraud_status'] == 'ACCEPTED')?1:2).'|<strong>'.$res['purchase_currency'].($res['order_amount']/100).'</strong> , '.(($res['fraud_status'] != 'ACCEPTED')?'<font style="color:#f00">'.$res['fraud_status'].'</font>':$res['fraud_status']).' , description:'.$res['initial_payment_method']['description'].' , number of installments:'.$res['initial_payment_method']['number_of_installments'].'|'.$res['billing_address']['street_address'].(($res['billing_address']['street_address2']!='')?' '.$res['billing_address']['street_address2']:'').','.$res['billing_address']['city'].','.$res['billing_address']['region'].','.$res['billing_address']['postal_code'].','.$res['billing_address']['country'].','.$res['billing_address']['given_name'].' '.$res['billing_address']['family_name'].','.$res['billing_address']['phone'].','.$res['billing_address']['email'].'|'.$res['shipping_address']['street_address'].(($res['shipping_address']['street_address2']!='')?' '.$res['shipping_address']['street_address2']:'').','.$res['shipping_address']['city'].','.$res['shipping_address']['region'].','.$res['shipping_address']['postal_code'].','.$res['shipping_address']['country'].','.$res['shipping_address']['given_name'].' '.$res['shipping_address']['family_name'].','.$res['shipping_address']['phone'].','.$res['shipping_address']['email'];
  6033. }
  6034. }
  6035. else if($data['pay'] == '22' && $shop['paypalname'] != '')
  6036. {
  6037. $f = $this->paypal->data($data['paypal'],$shop);
  6038. }
  6039. else if(($data['pay'] == '26') && $shop['afterpayname'] != '')
  6040. {
  6041. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  6042. $header[] = "Accept:application/json";
  6043. $header[] = "User-Agent: Readme.io API Simulator'";
  6044. $header[] = "Authorization: Basic ".base64_encode($shop['afterpayname'].":".$shop['afterpaypass']);
  6045. $ch = curl_init();
  6046. curl_setopt($ch, CURLOPT_URL, $url);
  6047. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6048. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6049. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6050. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6051. $res = curl_exec($ch);
  6052. curl_close($ch);
  6053. $res = json_decode($res,true);
  6054. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  6055. {
  6056. $f = $res['results'][0]['orderDetails']['consumer']['email'].'|'.$res['results'][0]['orderDetails']['billing']['line1'].','.$res['results'][0]['orderDetails']['billing']['line2'].','.$res['results'][0]['orderDetails']['billing']['area1'].','.$res['results'][0]['orderDetails']['billing']['region'].','.$res['results'][0]['orderDetails']['billing']['postcode'].','.$res['results'][0]['orderDetails']['billing']['countryCode'].','.$res['results'][0]['orderDetails']['billing']['name'].','.$res['results'][0]['orderDetails']['billing']['phoneNumber'].'|'.$res['results'][0]['orderDetails']['shipping']['line1'].','.$res['results'][0]['orderDetails']['shipping']['line2'].','.$res['results'][0]['orderDetails']['shipping']['area1'].','.$res['results'][0]['orderDetails']['shipping']['region'].','.$res['results'][0]['orderDetails']['shipping']['postcode'].','.$res['results'][0]['orderDetails']['shipping']['countryCode'].','.$res['results'][0]['orderDetails']['shipping']['name'].','.$res['results'][0]['orderDetails']['shipping']['phoneNumber'];
  6057. $f = str_replace(',,',',',$f);
  6058. }
  6059. }
  6060. else if(($data['pay'] == '27') && $shop['clearpayname'] != '')
  6061. {
  6062. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  6063. $header[] = "Accept:application/json";
  6064. $header[] = "User-Agent: Readme.io API Simulator'";
  6065. $header[] = "Authorization: Basic ".base64_encode($shop['clearpayname'].":".$shop['clearpaypass']);
  6066. $ch = curl_init();
  6067. curl_setopt($ch, CURLOPT_URL, $url);
  6068. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6069. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6070. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6071. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6072. $res = curl_exec($ch);
  6073. curl_close($ch);
  6074. $res = json_decode($res,true);
  6075. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  6076. {
  6077. $f = $res['results'][0]['orderDetails']['consumer']['email'].'|'.$res['results'][0]['orderDetails']['billing']['line1'].','.$res['results'][0]['orderDetails']['billing']['line2'].','.$res['results'][0]['orderDetails']['billing']['area1'].','.$res['results'][0]['orderDetails']['billing']['region'].','.$res['results'][0]['orderDetails']['billing']['postcode'].','.$res['results'][0]['orderDetails']['billing']['countryCode'].','.$res['results'][0]['orderDetails']['billing']['name'].','.$res['results'][0]['orderDetails']['billing']['phoneNumber'].'|'.$res['results'][0]['orderDetails']['shipping']['line1'].','.$res['results'][0]['orderDetails']['shipping']['line2'].','.$res['results'][0]['orderDetails']['shipping']['area1'].','.$res['results'][0]['orderDetails']['shipping']['region'].','.$res['results'][0]['orderDetails']['shipping']['postcode'].','.$res['results'][0]['orderDetails']['shipping']['countryCode'].','.$res['results'][0]['orderDetails']['shipping']['name'].','.$res['results'][0]['orderDetails']['shipping']['phoneNumber'];
  6078. $f = str_replace(',,',',',$f);
  6079. }
  6080. }
  6081. else if($data['pay'] == '1211')
  6082. {
  6083. $url = 'https://api.stripe.com/v1/payment_intents/'.$data['paypal'];
  6084. $header[] = "Authorization:Bearer ".$shop['stripe'];
  6085. $ch = curl_init();
  6086. curl_setopt($ch, CURLOPT_URL, $url);
  6087. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6088. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6089. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6090. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6091. $res = curl_exec($ch);
  6092. curl_close($ch);
  6093. $res = json_decode($res,true);
  6094. $f = '';
  6095. if(isset($res['shipping']['name']))
  6096. {
  6097. $line = ($res['shipping']['address']['line2'] != '')?$res['shipping']['address']['line1'].' '.$res['shipping']['address']['line2']:$res['shipping']['address']['line1'];
  6098. $f = 'stripe|'.json_encode(array('name'=>$res['shipping']['name'],'email'=>$res['receipt_email'],'address'=>$line.','.$res['shipping']['address']['city'].','.$res['shipping']['address']['state'].','.$res['shipping']['address']['postal_code'].','.$res['shipping']['address']['country'].','.$res['shipping']['phone'],'shouldmoney'=>$res['amount']/100));
  6099. }
  6100. }
  6101. else
  6102. {
  6103. echo json_encode(array('msg'=>'此店铺没有对接信息','success'=>false));exit;
  6104. }
  6105. if($f != '')
  6106. {
  6107. if($this->fullordertt->save(array('klarnadata'=>$f),$data['id']))
  6108. {
  6109. echo json_encode(array('msg'=>'获取成功,请关闭此页重新打开','success'=>true));exit;
  6110. }
  6111. else
  6112. {
  6113. echo json_encode(array('msg'=>'写入失败,请重试','success'=>false));exit;
  6114. }
  6115. }
  6116. else
  6117. {
  6118. echo json_encode(array('msg'=>'获取失败,请稍后重试','cl'=>base64_encode($shop['afterpayname'].":".$shop['afterpaypass']),'a'=>$data['paypal'],'success'=>false));exit;
  6119. }
  6120. }
  6121. }
  6122. public function _kcyz($warehouse,$whlabel,$id,$shop,$number)
  6123. {
  6124. if(!$whlabel || $whlabel == '|')
  6125. {
  6126. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  6127. }
  6128. $w = $this->warehouse->read($warehouse);
  6129. if($w['zd'] != 1)
  6130. {
  6131. return 1;
  6132. }
  6133. $pp = explode('|',trim($whlabel,'|'));
  6134. $x = 0;$save = array();
  6135. foreach ($pp as $va)
  6136. {
  6137. $num = explode('-',$va);
  6138. if($number)
  6139. {
  6140. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')");//通用
  6141. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  6142. }
  6143. else
  6144. {
  6145. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  6146. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  6147. }
  6148. $x++;
  6149. if(count($whlabel)+count($shopwhlabel) < $num[1])
  6150. {
  6151. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  6152. }
  6153. }
  6154. return $save;
  6155. }
  6156. public function _epod()
  6157. {
  6158. $post = $this->input->post(NULL, TRUE);
  6159. if(isset($post['number']))
  6160. {
  6161. $number = $this->input->post('number',true);
  6162. $data = $this->fullordertt->get_number($number);
  6163. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  6164. {
  6165. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  6166. }
  6167. else
  6168. {
  6169. $epod = $this->dhl->get_epod($data);
  6170. if($epod['c'] == 1)
  6171. {
  6172. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  6173. }
  6174. else
  6175. {
  6176. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  6177. }
  6178. }
  6179. }
  6180. }
  6181. public function _zw($arg_array)
  6182. {
  6183. $arg_array = $arg_array[0];$fpdata = array();
  6184. $fullordertt = $this->fullordertt->read($arg_array);
  6185. $fullordertt['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullordertt['shipremarks']);
  6186. $fullordertt['parameter'] = str_replace(",","---",$fullordertt['parameter']);
  6187. $this->data['fullordertt'] = $fullordertt;
  6188. $this->data['countrys'] = $this->country->find_all();
  6189. $this->data['express'] = $this->express->find_all();
  6190. $warehouse = $this->warehouse->read($fullordertt['type']);
  6191. if(stripos($fullordertt['fpdata'],';') !== false)
  6192. {
  6193. $fpdata = explode(';',rtrim($fullordertt['fpdata'],';'));
  6194. foreach ($fpdata as $k=>$v)
  6195. {
  6196. $xxv = explode('|',$v);
  6197. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  6198. {
  6199. $xxv['zd'] = "<p>已占单</p>";
  6200. $bdck = $warehouse['bdck'];
  6201. if(stripos($xxv[9],'~') !== false)
  6202. {
  6203. $dxxv = explode('~',trim($xxv[9],'~'));
  6204. foreach ($dxxv as $val)
  6205. {
  6206. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  6207. if($wzid['details'] != '')
  6208. {
  6209. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6210. }
  6211. }
  6212. }
  6213. else
  6214. {
  6215. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  6216. if($wzid['details'] != '')
  6217. {
  6218. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6219. }
  6220. }
  6221. }
  6222. $fpdata[$k] = $xxv;
  6223. }
  6224. }
  6225. $this->data['fpdata'] = $fpdata;
  6226. $this->data['fpdata'] = $fpdata;
  6227. $thfpdataxs = array();
  6228. if($fullordertt['thfpdata'] != '')
  6229. {
  6230. $thfpdata = explode(';',trim($fullordertt['thfpdata'],';'));
  6231. foreach ($thfpdata as $k=>$v)
  6232. {
  6233. $thxs = explode('~',trim($v,'~'));
  6234. $thxs[0] = explode('|',trim($thxs[0],'|'));
  6235. $thxs[1] = explode('|',trim($thxs[1],'|'));
  6236. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  6237. }
  6238. }
  6239. $this->data['thfpdata'] = $thfpdataxs;
  6240. $shop = $this->shop->read($fullordertt['shop']);
  6241. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  6242. $is = 0;
  6243. if($shop['type'] == 269)//判断是否独立站,269是独立站
  6244. {
  6245. $is = 1;
  6246. }
  6247. $this->data['is'] = $is;
  6248. //单项开始
  6249. $warehouse = $this->warehouse->read($fullordertt['warehouse']);//发货仓库
  6250. $state = $this->typeclass->read($fullordertt['state']);//订单状态
  6251. $country = $this->country->read($fullordertt['country']);//国家
  6252. if($fullordertt['capital'] == 1)
  6253. {
  6254. $capital = '暂未支付';
  6255. }
  6256. else if($fullordertt['capital'] == 2)
  6257. {
  6258. $capital = '部分支付';
  6259. }
  6260. else if($fullordertt['capital'] == 3)
  6261. {
  6262. $capital = '全部支付';
  6263. }
  6264. if($fullordertt['printtype'] == 1)
  6265. {
  6266. $printtype = '运单';
  6267. }
  6268. else if($fullordertt['printtype'] == 2)
  6269. {
  6270. $printtype = '发货单';
  6271. }
  6272. else if($fullordertt['printtype'] == 3)
  6273. {
  6274. $printtype = '不打印单据';
  6275. }
  6276. else
  6277. {
  6278. $printtype = '未选择';
  6279. }
  6280. $this->data['warehouse'] = $warehouse['title'];
  6281. $this->data['state'] = $state['title'];
  6282. $this->data['capital'] = $capital;
  6283. $this->data['country'] = $country['name'];
  6284. $this->data['printtype'] = $printtype;
  6285. //单项结束
  6286. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  6287. $downwaybill = '';$dwls = array();
  6288. $oldwaybill = explode('-',ltrim($fullordertt['oldwaybill'],'-'));
  6289. if(isset($oldwaybill[0][1]))
  6290. {
  6291. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6292. foreach ($oldwaybill as $v)
  6293. {
  6294. $dw = explode('/',$v);
  6295. if(isset($dw[1]))
  6296. {
  6297. if(stripos($downwaybill,$dw[1]) === false)
  6298. {
  6299. $dwls[$dw[1]] = 1;
  6300. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  6301. }
  6302. }
  6303. }
  6304. }
  6305. if($fullordertt['printtype'] == 1)
  6306. {
  6307. if($fullordertt['waybill'] != '' && !isset($dwls[$fullordertt['waybill']]))
  6308. {
  6309. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordertt['printtime']).'/y-'.$fullordertt['waybill'].'.pdf" target="_blank">'.$fullordertt['waybill'].'</a>、'.$downwaybill;
  6310. }
  6311. }
  6312. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  6313. /** 历史打印时间 **/
  6314. $printtime = '';
  6315. if($fullordertt['oldprinttime'])
  6316. {
  6317. $pte = explode('-',rtrim($fullordertt['oldprinttime'],'-'));
  6318. foreach ($pte as $v)
  6319. {
  6320. $printtime .= date('Y-m-d H:i:s',$v).'、';
  6321. }
  6322. }
  6323. $this->data['printtime'] = rtrim($printtime,'、');
  6324. $product = '';
  6325. $fullordertt['product'] = str_replace("'","",$fullordertt['product']);
  6326. if($fullordertt['link'] != '' && $fullordertt['source'] != '1')
  6327. {
  6328. $pt = explode(',',$fullordertt['product']);
  6329. $lk = explode(',',$fullordertt['link']);
  6330. for($i=0;$i<count($pt);$i++)
  6331. {
  6332. if(isset($lk[$i]))
  6333. {
  6334. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  6335. }
  6336. else
  6337. {
  6338. $octs = '';
  6339. }
  6340. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  6341. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  6342. if(isset($lk[$i]))
  6343. {
  6344. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  6345. }
  6346. else
  6347. {
  6348. $product .= ($product != '')?' , '.$a:$a;
  6349. }
  6350. }
  6351. }
  6352. else
  6353. {
  6354. $octs = $this->colourorderts->get_text($fullordertt['product']);
  6355. $a = $octs?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  6356. //$a = (stripos($fullordertt['product'],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($fullordertt['product'],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($fullordertt['product'],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($fullordertt['product'],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($fullordertt['product'],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($fullordertt['product'],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($fullordertt['product'],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($fullordertt['product'],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($fullordertt['product'],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  6357. $product = $a;
  6358. }
  6359. $this->data['product'] = $product;
  6360. $out = $this->systemtransfer->find_all("number = '".$fullordertt['number']."'");
  6361. $outread = '';
  6362. if($out)
  6363. {
  6364. foreach ($out as $val)
  6365. {
  6366. $list = '';
  6367. $rk = explode('|',trim($val['rk'],'|'));
  6368. $rktime = explode('|',trim($val['rktime'],'|'));
  6369. $zw = array();
  6370. $t = $this->transfer->find_all("1=1");
  6371. foreach ($t as $v)
  6372. {
  6373. $zw[$v['id']] = $v['title'];
  6374. }
  6375. if($val['rk'] != '' && count($rk) > 0)
  6376. {
  6377. for($i=0;$i<count($rk);$i++)
  6378. {
  6379. if(!isset($rktime[$i]))
  6380. {
  6381. $list .= $zw[$cz[$i]];
  6382. }
  6383. else
  6384. {
  6385. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  6386. }
  6387. }
  6388. }
  6389. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  6390. }
  6391. }
  6392. else
  6393. {
  6394. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordertt['number']."'");
  6395. $outread = array();
  6396. if($systemwigsout)
  6397. {
  6398. foreach ($systemwigsout as $v)
  6399. {
  6400. if($v['czwarehouse'] == 37)
  6401. {
  6402. $outread[] = '华荣厂';
  6403. }
  6404. else if($v['czwarehouse'] == 0)
  6405. {
  6406. $outread[] = '龙盈厂';
  6407. }
  6408. $cz = explode('|',trim($v['cz'],'|'));
  6409. $cztime = explode('|',trim($v['cztime'],'|'));
  6410. $zw = $this->transfer->get_list();
  6411. if($v['cz'] != '' && count($cz) > 0)
  6412. {
  6413. for($i=0;$i<count($cz);$i++)
  6414. {
  6415. if(!isset($cztime[$i]))
  6416. {
  6417. $outread[] = $zw[$cz[$i]].' -&gt; ';
  6418. }
  6419. else
  6420. {
  6421. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  6422. }
  6423. }
  6424. $outread[] = '<br>';
  6425. }
  6426. }
  6427. }
  6428. }
  6429. $klarnacolor = '';
  6430. if($fullordertt['klarnadata'] !='')
  6431. {
  6432. $klarnadata = explode('|',$fullordertt['klarnadata']);
  6433. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  6434. {
  6435. $klarnadata[1] = json_decode($klarnadata[1],true);
  6436. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullordertt['shouldmoney'] && $fullordertt['pay'] == 1211)
  6437. {
  6438. $klarnacolor = 'style="color:#F00"';
  6439. }
  6440. }
  6441. else if($klarnadata[0]!=1 && $fullordertt['pay']!=26 && $fullordertt['pay']!=27 && $fullordertt['pay']!=1211)
  6442. {
  6443. $klarnacolor = 'style="color:#F00"';
  6444. }
  6445. if($fullordertt['pay'] == 23)//klarna
  6446. {
  6447. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU','puerto rico'=>'PR');
  6448. $ToState = array_flip($ToState);
  6449. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  6450. $city = str_replace(' ','',$fullordertt['city']);
  6451. $klarnadataaddress = explode($city,$klarnadata3);
  6452. if(isset($klarnadataaddress[1]))
  6453. {
  6454. $klarnadata3 = $city.$klarnadataaddress[1];
  6455. $klarnadatacolor = explode(',',$klarnadata3);
  6456. unset($klarnadatacolor[4]);
  6457. unset($klarnadatacolor[6]);
  6458. if(isset($ToState[$klarnadatacolor[1]]))
  6459. {
  6460. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  6461. }
  6462. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  6463. }
  6464. else
  6465. {
  6466. $klarnadata['color'] = $klarnadata3;
  6467. }
  6468. }
  6469. }
  6470. else
  6471. {
  6472. $klarnadata = '';
  6473. }
  6474. $p = explode('-',$fullordertt['paypal']);
  6475. $this->data['klarnacolor'] = $klarnacolor;
  6476. $this->data['klarnadata'] = $klarnadata;
  6477. $this->data['systemwigsout'] = $outread;
  6478. $this->_Template('fullordertt_zw',$this->data);
  6479. }
  6480. public function _dcdxyz()
  6481. {
  6482. $post = $this->input->get(NULL, TRUE);
  6483. if(isset($post['timetk']))
  6484. {
  6485. $timetk = $this->input->get('timetk',true);
  6486. $timetj = $this->input->get('timetj',true);
  6487. $timetk = strtotime($timetk);
  6488. $timetj = strtotime($timetj);
  6489. $where = "oldwaybill != ''";
  6490. if($timetk && $timetj)
  6491. {
  6492. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6493. }
  6494. //数据排序
  6495. $order_str = "dtime desc";
  6496. //取得信息列表
  6497. $info_list = $this->fullordertt->find_all($where,'orderinfo,number,oldwaybill',$order_str);
  6498. $data = array();
  6499. foreach ($info_list as $key=>$value)
  6500. {
  6501. $ob = '';
  6502. $oldwaybill = explode('-',trim($value['oldwaybill'],'-'));
  6503. if(count($oldwaybill) < 2)
  6504. {
  6505. continue;
  6506. }
  6507. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6508. foreach ($oldwaybill as $v)
  6509. {
  6510. $dw = explode('/',$v);
  6511. if(isset($dw[1]))
  6512. {
  6513. $dwls[$dw[1]] = 1;
  6514. $ob .= $dw[1].'、';
  6515. }
  6516. }
  6517. $info_list[$key]['oldwaybill'] = trim($ob,'、');
  6518. $data[] = $info_list[$key];
  6519. }
  6520. $title = "多运单信息 ".date("Y-m-d");
  6521. $titlename = "<table border=1>
  6522. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6523. <tr>
  6524. <td>订单号</td>
  6525. <td>编号</td>
  6526. <td>运单号</td>
  6527. </tr>
  6528. </table>";
  6529. $filename = $title.".xls";
  6530. $tail = "\n";
  6531. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  6532. }
  6533. }
  6534. public function _thxz()
  6535. {
  6536. $post = $this->input->get(NULL, TRUE);
  6537. if(isset($post['timetk']))
  6538. {
  6539. $timetk = $this->input->get('timetk',true);
  6540. $timetj = $this->input->get('timetj',true);
  6541. $timetk = strtotime($timetk);
  6542. $timetj = strtotime($timetj);
  6543. $where = "returndata != ''";
  6544. if($timetk && $timetj)
  6545. {
  6546. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6547. }
  6548. //数据排序
  6549. $order_str = "dtime desc";
  6550. //取得信息列表
  6551. $info_list = $this->fullordertt->find_all($where,'orderinfo,number,returndata',$order_str);
  6552. foreach ($info_list as $key=>$value)
  6553. {
  6554. $ydh = explode('">',$value['returndata']);
  6555. $ydh = explode('</a>',$ydh[1]);
  6556. $info_list[$key]['returndata'] = $ydh[0];
  6557. $time = explode('pdf/',$value['returndata']);
  6558. $time = explode('/',$time[1]);
  6559. $info_list[$key]['time'] = $time[0];
  6560. }
  6561. $title = "退货订单信息 ".date("Y-m-d");
  6562. $titlename = "<table border=1>
  6563. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6564. <tr>
  6565. <td>订单号</td>
  6566. <td>编号</td>
  6567. <td>退货运单号</td>
  6568. <td>退货时间</td>
  6569. </tr>
  6570. </table>";
  6571. $filename = $title.".xls";
  6572. $tail = "\n";
  6573. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  6574. }
  6575. }
  6576. public function _ddcf()
  6577. {
  6578. $post = $this->input->post(NULL, TRUE);
  6579. if(isset($post['number']))
  6580. {
  6581. $number = $this->input->post('number',true);
  6582. $data = $this->fullordertt->get_number($number);
  6583. if(!$data)
  6584. {
  6585. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  6586. }
  6587. if($data['review'] != 1 && $data['review'] != 2)
  6588. {
  6589. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  6590. }
  6591. if($data['merge'] != 0)
  6592. {
  6593. echo json_encode(array('msg'=>'已合并的订单无法使用此拆分功能','success'=>false));exit;
  6594. }
  6595. $cfnum = explode('-',trim($number,'-'));
  6596. if(count($cfnum)> 4)
  6597. {
  6598. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6599. }
  6600. $num = $this->fullordertt->find_count("number like '".$number."%'");
  6601. $data['number'] = $data['number'].'-'.$num;
  6602. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);
  6603. $data['shouldmoney'] = 0;
  6604. $data['budget'] = 0;
  6605. $data['shipremarks'] = '';
  6606. $data['source'] = 1;
  6607. //$data['review'] = 2;
  6608. $data['extra_status'] = 1;//拆分的订单
  6609. unset($data['id']);
  6610. unset($data['jweight']);
  6611. unset($data['fpcount']);
  6612. unset($data['returndata']);
  6613. unset($data['oldwaybill']);
  6614. unset($data['waybill']);
  6615. unset($data['printtime']);
  6616. if($this->fullordertt->insert($data))
  6617. {
  6618. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  6619. }
  6620. else
  6621. {
  6622. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  6623. }
  6624. }
  6625. }
  6626. public function _cf() //合并订单拆分
  6627. {
  6628. $post = $this->input->post(NULL, TRUE);
  6629. if(isset($post['id']))
  6630. {
  6631. $id = $this->input->post('id',true);
  6632. $b = $this->fullordertt->read($id);
  6633. $order = array();
  6634. if($b['merge'] == $b['id'])
  6635. {
  6636. $data = $this->fullordertt->find_all("merge = '".$b['merge']."'");
  6637. foreach ($data as $v)
  6638. {
  6639. $a = $this->fullordertthb->get_orderinfo($v['orderinfo']);
  6640. if($a)
  6641. {
  6642. $this->fullordertt->save($a,$v['id']);
  6643. }
  6644. $order[] = $v['id'];
  6645. }
  6646. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  6647. }
  6648. else
  6649. {
  6650. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  6651. }
  6652. }
  6653. }
  6654. public function _pljzzd()
  6655. {
  6656. $post = $this->input->post(NULL, TRUE);
  6657. if(isset($post['s']))
  6658. {
  6659. $id_arr = $this->input->post('s');
  6660. $id_arr = explode(',',$id_arr);
  6661. if(!$id_arr)
  6662. {
  6663. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  6664. }
  6665. //循环删除记录
  6666. $this->db->trans_begin();
  6667. foreach ($id_arr as $value)
  6668. {
  6669. $post = $this->fullordertt->read($value);
  6670. $hbw = explode('|',trim($post['whlabel'],'|'));
  6671. $hbf = explode(';',trim($post['fpdata'],';'));
  6672. foreach ($hbw as $k=>$val)
  6673. {
  6674. $w = explode('-',$val);
  6675. $f = explode('|',$hbf[$k]);
  6676. $w[2] = "DNOTO";
  6677. $f[9] = "DNOTO";
  6678. $hbf[$k] = implode("|",$f);
  6679. $hbw[$k] = implode("-",$w);
  6680. }
  6681. $w = $this->whlabel->find_all("zd = '".$post['number']."'");
  6682. foreach ($w as $k=>$val)
  6683. {
  6684. $this->whlabel->save(array('zd'=>''),$val['id']);
  6685. }
  6686. $fpdata = implode(";",$hbf).';';
  6687. $whlabel = '|'.implode("|",$hbw).'|';
  6688. $this->fullordertt->save(array('fpdata'=>$fpdata,'whlabel'=>$whlabel),$post['id']);
  6689. }
  6690. if ($this->db->trans_status() === FALSE)
  6691. {
  6692. $this->db->trans_rollback();
  6693. }
  6694. else
  6695. {
  6696. $this->db->trans_commit();
  6697. }
  6698. echo json_encode(array('del'=>$id_arr,'msg'=>'操作成功,已暂时隐藏,可继续操作其它订单,刷新即可显示!','success'=>true));
  6699. }
  6700. }
  6701. public function _cbtlabel($arg_array){
  6702. $id = $arg_array[0];
  6703. $info = $this->fullordertt->read($id);
  6704. if(empty($info)){
  6705. echo json_encode(array('msg'=>'订单不存在!','success'=>false));exit;
  6706. }
  6707. $extra_text = json_decode($info['extra_text'],true);
  6708. if(isset($extra_text['label_info'])){
  6709. echo json_encode(array('msg'=>'发货标签已执行,请勿重复操作!','success'=>false));exit;
  6710. }
  6711. $shop_info = $this->shop->read($info['shop']);
  6712. if(empty($shop_info)){
  6713. echo json_encode(array('msg'=>'店铺不存在!','success'=>false));exit;
  6714. }
  6715. $res = $this->express_tt->doCreateCBTLabel($info,$shop_info);
  6716. if($res['x'] == 0){
  6717. $msg = isset($res['Description'])?$res['Description']:$res['message'];
  6718. echo json_encode(array('msg'=>$msg,'success'=>false));exit;
  6719. }else{
  6720. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  6721. }
  6722. }
  6723. }