Fullordertt.php 241 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813
  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'] == '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. if((!in_array($post['express'],[2,63,64,81,85,86,87])) && ($post['type'] == 5)){
  1808. echo json_encode(array('msg'=>'此快递方式不能美仓发货!','success'=>false));exit;
  1809. }
  1810. $express = $this->express->read($post['express']);
  1811. /**
  1812. if($express['ioss'] == 1 && $post['ioss'] == '')
  1813. {
  1814. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1815. }
  1816. **/
  1817. $thisdata = $this->fullordertt->read($id);
  1818. $warehouse = $this->warehouse->read($thisdata['type']);
  1819. $warehousenew = $this->warehouse->read($post['type']);
  1820. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1821. {
  1822. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1823. }
  1824. if($ud['yhs'] == 1)
  1825. {
  1826. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1827. }
  1828. $expt = $this->express->read($post['express']);
  1829. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1830. {
  1831. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1832. }
  1833. if($expt['province'] != '' && stripos($expt['province'],$ud['province'].'、') !== false)
  1834. {
  1835. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1836. }
  1837. /**
  1838. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1839. {
  1840. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1841. }
  1842. **/
  1843. /**
  1844. if($warehousenew['zd'] == '1' && $editstate != $thisdata['state'] && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1845. {
  1846. echo json_encode(array('msg'=>'如需更改订单状态,请先把仓库选择为非开启库存模式仓库或等待订单出库!','success'=>false));exit;
  1847. }
  1848. if($warehousenew['zd'] == '1' && $editstate != '207' && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1849. {
  1850. echo json_encode(array('msg'=>'非待发货状态,不允许修改为开启库存模式仓库','success'=>false));exit;
  1851. }
  1852. **/
  1853. //开始注释 xyxg
  1854. /**
  1855. $ft = array();
  1856. $ftdata = explode('|',rtrim($fpcount,'|'));
  1857. foreach ($ftdata as $va)
  1858. {
  1859. $ftitle = '';
  1860. $va = explode('-',trim($va,'-'));
  1861. foreach ($va as $v)
  1862. {
  1863. $v = $this->typeclass->read($v);
  1864. $ftitle .= $v['title'].' ';
  1865. }
  1866. $ft[] = rtrim($ftitle,' ');
  1867. }
  1868. $user = $this->user->get_api($_SESSION['api']);
  1869. if($ud['library'] == 1)
  1870. {
  1871. $tqkcyz = $this->_kcyz($post['type'],$whlabel,$id,$ud['shop'],$ud['number']);
  1872. if(isset($tqkcyz[0]))
  1873. {
  1874. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$tqkcyz,'success'=>false));exit;
  1875. }
  1876. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1877. {
  1878. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1879. if($tskcyz['t'] > '0')
  1880. {
  1881. echo $tskcyz['m'];exit;
  1882. }
  1883. }
  1884. $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']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1885. if($kcyz['t'] > '0')
  1886. {
  1887. echo $kcyz['m'];exit;
  1888. }
  1889. }
  1890. //结束注释
  1891. **/
  1892. $warehouse = $this->warehouse->read($post['type']);
  1893. if($ud['library'] == 1 || ($ud['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1894. {
  1895. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1896. if($kcyz['t'] > '0')
  1897. {
  1898. echo $kcyz['m'];exit;
  1899. }
  1900. else if($kcyz['fpdata'] != '')
  1901. {
  1902. $post['whlabel'] = $kcyz['whlabel'];
  1903. $post['fpdata'] = $kcyz['fpdata'];
  1904. }
  1905. }
  1906. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1907. $post['sfxh'] = $fl['sfxh'];
  1908. $post['ckfl'] = $fl['ckfl'];
  1909. //查询净重开始
  1910. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1911. //查询净重结束
  1912. if($this->fullordertt->save($post,$id))
  1913. {
  1914. if($ud['printtime'] == '0')
  1915. {
  1916. $xghz = ',将自动禁止打印';
  1917. }
  1918. else if($ud['printtime'] > '0' && $ud['librarytime'] == '0')
  1919. {
  1920. $q = '';
  1921. if($ud['libraryconfirm'] == 1)
  1922. {
  1923. $q = ',<em style="color: #F00;">改前状态为:禁止出库</em>';
  1924. }
  1925. $xghz = ',将自动禁止发货'.$q;
  1926. }
  1927. else
  1928. {
  1929. $xghz = '';
  1930. }
  1931. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1932. }
  1933. else
  1934. {
  1935. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1936. }
  1937. }
  1938. $arg_array = $arg_array[0];$fpdata = array();
  1939. $fullordertt = $this->fullordertt->read($arg_array);
  1940. $returngoods = $this->returngoods->get_orderinfo($fullordertt['orderinfo']);
  1941. $this->data['returngoods'] = $returngoods?1:0;
  1942. $fullordertt['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullordertt['shipremarks']);
  1943. $fullordertt['parameter'] = str_replace(",","---",$fullordertt['parameter']);
  1944. $fullordertt['cate_one'] = empty($fullordertt['cate_one'])?1:$fullordertt['cate_one'];
  1945. $this->data['fullordertt'] = $fullordertt;
  1946. if($fullordertt['express'] == 2)
  1947. {
  1948. $zzhl = 'oz';
  1949. }
  1950. else
  1951. {
  1952. $zzhl = 'kg';
  1953. }
  1954. $this->data['zzhl'] = $zzhl;
  1955. $this->data['countrys'] = $this->country->find_all();
  1956. $this->data['express'] = $this->express->find_all();
  1957. $warehouse = $this->warehouse->read($fullordertt['type']);
  1958. if(stripos($fullordertt['fpdata'],';') !== false)
  1959. {
  1960. $fpdata = explode(';',rtrim($fullordertt['fpdata'],';'));
  1961. foreach ($fpdata as $k=>$v)
  1962. {
  1963. $xxv = explode('|',$v);
  1964. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1965. {
  1966. $xxv['zd'] = "<p>已占单</p>";
  1967. $bdck = $warehouse['bdck'];
  1968. if(stripos($xxv[9],'~') !== false)
  1969. {
  1970. $dxxv = explode('~',trim($xxv[9],'~'));
  1971. foreach ($dxxv as $val)
  1972. {
  1973. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1974. if($wzid['details'] != '')
  1975. {
  1976. if($fullordertt['type'] == 5){
  1977. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1978. }else{
  1979. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1980. }
  1981. }
  1982. }
  1983. }
  1984. else
  1985. {
  1986. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1987. if($wzid['details'] != '')
  1988. {
  1989. if($fullordertt['type'] == 5){
  1990. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1991. }else{
  1992. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1993. }
  1994. }
  1995. }
  1996. }
  1997. $fpdata[$k] = $xxv;
  1998. }
  1999. }
  2000. $this->data['fpdata'] = $fpdata;
  2001. $this->data['fpdata'] = $fpdata;
  2002. $thfpdataxs = array();
  2003. if($fullordertt['thfpdata'] != '')
  2004. {
  2005. $thfpdata = explode(';',trim($fullordertt['thfpdata'],';'));
  2006. foreach ($thfpdata as $k=>$v)
  2007. {
  2008. $thxs = explode('~',trim($v,'~'));
  2009. $thxs[0] = explode('|',trim($thxs[0],'|'));
  2010. $thxs[1] = explode('|',trim($thxs[1],'|'));
  2011. $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]);
  2012. }
  2013. }
  2014. $this->data['thfpdata'] = $thfpdataxs;
  2015. $shop = $this->shop->read($fullordertt['shop']);
  2016. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  2017. $is = 0;
  2018. if($shop['type'] == 269)//判断是否独立站,269是独立站
  2019. {
  2020. $is = 1;
  2021. }
  2022. $this->data['is'] = $is;
  2023. //单项开始
  2024. $warehouse = $this->warehouse->read($fullordertt['warehouse']);//发货仓库
  2025. $state = $this->typeclass->read($fullordertt['state']);//订单状态
  2026. $country = $this->country->read($fullordertt['country']);//国家
  2027. if($fullordertt['capital'] == 1)
  2028. {
  2029. $capital = '暂未支付';
  2030. }
  2031. else if($fullordertt['capital'] == 2)
  2032. {
  2033. $capital = '部分支付';
  2034. }
  2035. else if($fullordertt['capital'] == 3)
  2036. {
  2037. $capital = '全部支付';
  2038. }
  2039. if($fullordertt['printtype'] == 1)
  2040. {
  2041. $printtype = '运单';
  2042. }
  2043. else if($fullordertt['printtype'] == 2)
  2044. {
  2045. $printtype = '发货单';
  2046. }
  2047. else if($fullordertt['printtype'] == 3)
  2048. {
  2049. $printtype = '不打印单据';
  2050. }
  2051. else
  2052. {
  2053. $printtype = '未选择';
  2054. }
  2055. $this->data['warehouse'] = $warehouse['title'];
  2056. $this->data['state'] = $state['title'];
  2057. $this->data['capital'] = $capital;
  2058. $this->data['country'] = $country['name'];
  2059. $this->data['printtype'] = $printtype;
  2060. //单项结束
  2061. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  2062. $downwaybill = '';$dwls = array();
  2063. $oldwaybill = explode('-',ltrim($fullordertt['oldwaybill'],'-'));
  2064. if(isset($oldwaybill[0][1]))
  2065. {
  2066. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  2067. foreach ($oldwaybill as $v)
  2068. {
  2069. $dw = explode('/',$v);
  2070. if(isset($dw[1]))
  2071. {
  2072. if(stripos($downwaybill,$dw[1]) === false)
  2073. {
  2074. $dwls[$dw[1]] = 1;
  2075. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  2076. }
  2077. }
  2078. }
  2079. }
  2080. if($fullordertt['printtype'] == 1)
  2081. {
  2082. if($fullordertt['waybill'] != '' && !isset($dwls[$fullordertt['waybill']]))
  2083. {
  2084. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordertt['printtime']).'/y-'.$fullordertt['waybill'].'.pdf" target="_blank">'.$fullordertt['waybill'].'</a>、'.$downwaybill;
  2085. }
  2086. }
  2087. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  2088. /** 历史打印时间 **/
  2089. $printtime = '';
  2090. if($fullordertt['oldprinttime'])
  2091. {
  2092. $pte = explode('-',rtrim($fullordertt['oldprinttime'],'-'));
  2093. foreach ($pte as $v)
  2094. {
  2095. if(is_numeric($v) && $v > 0)
  2096. {
  2097. $printtime .= date('Y-m-d H:i:s',$v).'、';
  2098. }
  2099. }
  2100. }
  2101. $this->data['printtime'] = rtrim($printtime,'、');
  2102. $product = '';
  2103. $fullordertt['product'] = str_replace("'","",$fullordertt['product']);
  2104. if($fullordertt['link'] != '' && $fullordertt['source'] != '1')
  2105. {
  2106. $pt = explode(',',$fullordertt['product']);
  2107. $lk = explode(',',$fullordertt['link']);
  2108. for($i=0;$i<count($pt);$i++)
  2109. {
  2110. if(isset($lk[$i]))
  2111. {
  2112. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  2113. }
  2114. else
  2115. {
  2116. $octs = '';
  2117. }
  2118. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  2119. //$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];
  2120. if(isset($lk[$i]))
  2121. {
  2122. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  2123. }
  2124. else
  2125. {
  2126. $product .= ($product != '')?' , '.$a:$a;
  2127. }
  2128. }
  2129. }
  2130. else
  2131. {
  2132. $octs = $this->colourorderts->get_text($fullordertt['product']);
  2133. $a = $octs?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  2134. //$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'];
  2135. $product = $a;
  2136. }
  2137. $this->data['product'] = $product;
  2138. $out = $this->systemtransfer->find_all("number = '".$fullordertt['number']."'");
  2139. $outread = '';
  2140. if($out)
  2141. {
  2142. foreach ($out as $val)
  2143. {
  2144. $list = '';
  2145. $rk = explode('|',trim($val['rk'],'|'));
  2146. $rktime = explode('|',trim($val['rktime'],'|'));
  2147. $zw = array();
  2148. $t = $this->transfer->find_all("1=1");
  2149. foreach ($t as $v)
  2150. {
  2151. $zw[$v['id']] = $v['title'];
  2152. }
  2153. if($val['rk'] != '' && count($rk) > 0)
  2154. {
  2155. for($i=0;$i<count($rk);$i++)
  2156. {
  2157. if(!isset($rktime[$i]))
  2158. {
  2159. $list .= $zw[$cz[$i]];
  2160. }
  2161. else
  2162. {
  2163. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2164. }
  2165. }
  2166. }
  2167. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2168. }
  2169. }
  2170. else
  2171. {
  2172. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordertt['number']."'");
  2173. $outread = array();
  2174. if($systemwigsout)
  2175. {
  2176. foreach ($systemwigsout as $v)
  2177. {
  2178. if($v['czwarehouse'] == 37)
  2179. {
  2180. $outread[] = '华荣厂';
  2181. }
  2182. else if($v['czwarehouse'] == 0)
  2183. {
  2184. $outread[] = '龙盈厂';
  2185. }
  2186. $cz = explode('|',trim($v['cz'],'|'));
  2187. $cztime = explode('|',trim($v['cztime'],'|'));
  2188. $zw = $this->transfer->get_list();
  2189. if($v['cz'] != '' && count($cz) > 0)
  2190. {
  2191. for($i=0;$i<count($cz);$i++)
  2192. {
  2193. if(!isset($cztime[$i]))
  2194. {
  2195. $outread[] = $zw[$cz[$i]].' -&gt; ';
  2196. }
  2197. else
  2198. {
  2199. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2200. }
  2201. }
  2202. $outread[] = '<br>';
  2203. }
  2204. }
  2205. }
  2206. }
  2207. $klarnacolor = '';
  2208. if($fullordertt['klarnadata'] !='')
  2209. {
  2210. $klarnadata = explode('|',$fullordertt['klarnadata']);
  2211. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  2212. {
  2213. $klarnadata[1] = json_decode($klarnadata[1],true);
  2214. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullordertt['shouldmoney'] && $fullordertt['pay'] == 1211)
  2215. {
  2216. $klarnacolor = 'style="color:#F00"';
  2217. }
  2218. }
  2219. else if($klarnadata[0]!=1 && $fullordertt['pay']!=26 && $fullordertt['pay']!=27 && $fullordertt['pay']!=1211)
  2220. {
  2221. $klarnacolor = 'style="color:#F00"';
  2222. }
  2223. if($fullordertt['pay'] == 23)//klarna
  2224. {
  2225. $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');
  2226. $ToState = array_flip($ToState);
  2227. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  2228. $city = str_replace(' ','',$fullordertt['city']);
  2229. $klarnadataaddress = explode($city,$klarnadata3);
  2230. if(isset($klarnadataaddress[1]))
  2231. {
  2232. $klarnadata3 = $city.$klarnadataaddress[1];
  2233. $klarnadatacolor = explode(',',$klarnadata3);
  2234. unset($klarnadatacolor[4]);
  2235. unset($klarnadatacolor[6]);
  2236. if(isset($ToState[$klarnadatacolor[1]]))
  2237. {
  2238. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  2239. }
  2240. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  2241. }
  2242. else
  2243. {
  2244. $klarnadata['color'] = $klarnadata3;
  2245. }
  2246. }
  2247. }
  2248. else
  2249. {
  2250. $klarnadata = '';
  2251. }
  2252. $p = explode('-',$fullordertt['paypal']);
  2253. $this->data['klarnacolor'] = $klarnacolor;
  2254. $this->data['klarnadata'] = $klarnadata;
  2255. $this->data['systemwigsout'] = $outread;
  2256. $this->data['cate_one_list'] = $this->fullordertt->getCateOne();
  2257. $cate_two = $this->fullordertt->getCateTwo();
  2258. $this->data['cate_two_json'] = json_encode($cate_two,JSON_UNESCAPED_UNICODE);
  2259. $quantity = explode(';',trim($fullordertt['quantity'],';'));
  2260. $qc = 0;
  2261. foreach ($quantity as $v)
  2262. {
  2263. if($v > 1)
  2264. {
  2265. $qc += 1;
  2266. }
  2267. }
  2268. $this->data['qc'] = $qc;
  2269. $this->_Template('fullordertt_readonly',$this->data);
  2270. }
  2271. //浏览列表
  2272. public function _readlist()
  2273. {
  2274. if(isset($_SESSION['api']))
  2275. {
  2276. $user = $this->user->get_api($_SESSION['api']);
  2277. $usp = $user;
  2278. $fgshop = "";$sid = "";
  2279. $usersp = explode('|',trim($user['shop'],'|'));
  2280. foreach ($usersp as $value)
  2281. {
  2282. $fgshop .= " shop = ".$value." or";
  2283. $sid .= " id = ".$value." or";
  2284. }
  2285. }
  2286. $post = $this->input->post(NULL, TRUE);
  2287. if(isset($post['page']))
  2288. {
  2289. $page = $this->input->post('page',true);
  2290. $perpage = $this->input->post('perpage',true);
  2291. $shop = $this->input->post('shop',true);
  2292. $warehouse = $this->input->post('warehouse',true);
  2293. $express = $this->input->post('express',true);
  2294. $state = $this->input->post('state',true);
  2295. $print = $this->input->post('print',true);
  2296. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2297. $orderinfo = $this->input->post('orderinfo',true);
  2298. $client = $this->input->post('name',true);
  2299. $email = $this->input->post('email',true);
  2300. $number = $this->input->post('number',true);
  2301. $waybill = $this->input->post('waybill',true);
  2302. $authorid = $this->input->post('authorid',true);
  2303. $sourcecontentid = $this->input->post('sourcecontentid',true);
  2304. $timetk = $this->input->post('timetk',true);
  2305. $timetj = $this->input->post('timetj',true);
  2306. $timetk = strtotime($timetk);
  2307. $timetj = strtotime($timetj);
  2308. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2309. if($shop)
  2310. {
  2311. $where .= " and shop = '$shop'";
  2312. }
  2313. if($warehouse)
  2314. {
  2315. $where .= " and type = '$warehouse'";
  2316. }
  2317. if($express)
  2318. {
  2319. $where .= " and express = '$express'";
  2320. }
  2321. if($state)
  2322. {
  2323. $where .= " and state = '$state'";
  2324. }
  2325. if($print)
  2326. {
  2327. $where .= " and print = '$print'";
  2328. }
  2329. if($libraryconfirm)
  2330. {
  2331. $where .= " and libraryconfirm = '$libraryconfirm'";
  2332. }
  2333. if($orderinfo)
  2334. {
  2335. $where .= " and orderinfo = '$orderinfo'";
  2336. }
  2337. if($client)
  2338. {
  2339. $where .= " and client like '%$client%'";
  2340. }
  2341. if($email)
  2342. {
  2343. $where .= " and email = '$email'";
  2344. }
  2345. if($number)
  2346. {
  2347. $where .= " and number = '$number'";
  2348. }
  2349. if($waybill)
  2350. {
  2351. $where .= " and waybill = '$waybill'";
  2352. }
  2353. if($authorid)
  2354. {
  2355. $where .= " and authorid = '$authorid'";
  2356. }
  2357. if($sourcecontentid)
  2358. {
  2359. $where .= " and sourcecontentid = '$sourcecontentid'";
  2360. }
  2361. if($timetk && $timetj)
  2362. {
  2363. $timetj = $timetj+24*3600;
  2364. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2365. }
  2366. //数据排序
  2367. $order_str = "dtime desc";
  2368. if(empty($page))
  2369. {
  2370. $start = 0;
  2371. $perpage = 1;
  2372. }
  2373. else
  2374. {
  2375. $start = ($page - 1)*$perpage;
  2376. }
  2377. //取得信息列表
  2378. $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);
  2379. //格式化数据
  2380. $dt = 0;
  2381. foreach ($info_list as $key=>$value)
  2382. {
  2383. $ud = $this->fullordertt->read($value['id']);
  2384. $ud['address'] = str_replace("'","’",$ud['address']);
  2385. $ud['name'] = str_replace("'","’",$ud['name']);
  2386. $customer = $this->customertt->get_email($ud['email'],$value['shop']);
  2387. $customernum = $this->fullordertt->find_count("email = '".$ud['email']."' and shop = '".$value['shop']."'");
  2388. preg_match_all('/[0-9]/u',$ud['phone'],$result);
  2389. $numphone = join('',$result[0]);
  2390. $customerb = $this->customertt->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or numphone = '".$numphone."')",'*','id desc');
  2391. $customerc = $this->customertt->find_all("type = 1 and shop = '".$ud['shop']."' and address = '".$ud['address']."' and numphone = '".$numphone."'",'*','id desc');
  2392. //$a = array_column($customer, 'email'); //三维找其中健的数组
  2393. //$a = array_flip($a); //键和值调换
  2394. $lkh = $value['sname'];
  2395. $djlkh = 0;$djhmd = 0;
  2396. if($customer)
  2397. {
  2398. if(($customer['type'] == 1 && $customernum > 1))// || $customerc['type'] == 1 && $customerc['num'] > 1
  2399. {
  2400. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2401. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2402. $djlkh = 1;
  2403. $djcount = $count;
  2404. }
  2405. else if(isset($customerc[0]['num']))
  2406. {
  2407. if($customerc[0]['num'] > 1)
  2408. {
  2409. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2410. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2411. $djlkh = 1;
  2412. $djcount = $count;
  2413. }
  2414. }
  2415. }
  2416. if($customerb)
  2417. {
  2418. $hmsp = $this->shop->read($customerb[0]['shop']);
  2419. $count = $customerb[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerb[0]['count'].'"></i>':'';
  2420. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'>".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2421. $djhmd = 1;
  2422. }
  2423. if($djlkh == '1' && $djhmd == '1')
  2424. {
  2425. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'><em style='color:#FF3333'>".$djcount."老客户</em> - ".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2426. }
  2427. $info_list[$key]['sname'] = $lkh;
  2428. $shop = $this->shop->read($value['shop']);
  2429. $info_list[$key]['shop'] = $shop['shopname'];
  2430. //$info_list[$key]['user'] = $shop['shopuser'];
  2431. $warehouse = $this->warehouse->read($value['type']);
  2432. $warehousetitle = $warehouse['title'];
  2433. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  2434. $info_list[$key]['type'] = $warehousetitle;
  2435. $typeclass = $this->typeclass->read($value['state']);
  2436. $info_list[$key]['state'] = $typeclass['spare'];
  2437. $wl = '';
  2438. if($value['exstate'] == '99')
  2439. {
  2440. $wl = '<font style="color:#ccc">未获取到物流信息</font>';
  2441. }
  2442. else if($value['exstate'] == '1')
  2443. {
  2444. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已揽收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2445. }
  2446. else if($value['exstate'] == '2')
  2447. {
  2448. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">在途中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2449. }
  2450. else if($value['exstate'] == '3')
  2451. {
  2452. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2453. }
  2454. else if($value['exstate'] == '4')
  2455. {
  2456. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已签收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2457. }
  2458. else if($value['exstate'] == '5')
  2459. {
  2460. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送异常<font style="display: none">'.$ud['excontent'].'</font></font>';
  2461. }
  2462. $info_list[$key]['exstate'] = $wl.'<br />';
  2463. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  2464. {
  2465. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  2466. }
  2467. else
  2468. {
  2469. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']+$dt).'</p><p>'.date('H:i:s',$value['dtime']+$dt).'</p>';
  2470. }
  2471. if($value['review'] == 1)
  2472. {
  2473. $info_list[$key]['review'] = "未送审";
  2474. }
  2475. else if($value['review'] == 2)
  2476. {
  2477. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  2478. }
  2479. else if($value['review'] == 3)
  2480. {
  2481. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  2482. }
  2483. else if($value['review'] == 4)
  2484. {
  2485. $info_list[$key]['review'] = "取消重审";
  2486. }
  2487. else if($value['review'] == 5)
  2488. {
  2489. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  2490. }
  2491. else if($value['review'] == 6)
  2492. {
  2493. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  2494. }
  2495. if($ud['dlz'] == 1)
  2496. {
  2497. $dlz = "<p>独立站已更新</p>";
  2498. }
  2499. else if($ud['dlz'] == 3)
  2500. {
  2501. $dlz = "<p>不需要更新</p>";
  2502. }
  2503. else if($ud['dlz'] == 2)
  2504. {
  2505. $dlz = "<p style='color:#C3C'>独立站更新失败</p>";
  2506. }
  2507. else
  2508. {
  2509. $dlz = "";
  2510. }
  2511. if($value['waybill'] != "")
  2512. {
  2513. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  2514. if( !empty($value['waybillid'])){
  2515. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  2516. }
  2517. }
  2518. if($value['express'] != 0)
  2519. {
  2520. $express = $this->express->read($value['express']);
  2521. $expressservicename = $express['servicename'];
  2522. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  2523. $info_list[$key]['express'] = $expressservicename;
  2524. }
  2525. else
  2526. {
  2527. $info_list[$key]['express'] = "无";
  2528. }
  2529. $tly = "";
  2530. if($value['clientremarks'] != "")
  2531. {
  2532. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  2533. }
  2534. if($value['library'] == 1 && $ud['printtype'] == 3)
  2535. {
  2536. $info_list[$key]['library'] = "不需要";
  2537. }
  2538. else if($value['library'] == 1 && $ud['printtype'] != 3)
  2539. {
  2540. $info_list[$key]['library'] = "未出库";
  2541. }
  2542. else if($value['library'] == 2)
  2543. {
  2544. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  2545. }
  2546. else if($value['library'] == 3)
  2547. {
  2548. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  2549. }
  2550. if($ud['authorid'] != '' && $ud['authorid'] != 0)
  2551. {
  2552. $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>';
  2553. }
  2554. unset($info_list[$key]['waybillid']);
  2555. }
  2556. $total = $this->fullordertt->find_count($where);
  2557. $pagenum = ceil($total/$perpage);
  2558. $over = $total-($start+$perpage);
  2559. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2560. echo json_encode($rows);exit;
  2561. }
  2562. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2563. $this->data['wlshop'] = $wlshop;
  2564. $this->_Template('fullordertt_readlist',$this->data);
  2565. }
  2566. public function _readlistdown()
  2567. {
  2568. if(isset($_SESSION['api']))
  2569. {
  2570. $user = $this->user->get_api($_SESSION['api']);
  2571. $usp = $user;
  2572. $fgshop = "";$sid = "";
  2573. $usersp = explode('|',trim($user['shop'],'|'));
  2574. foreach ($usersp as $value)
  2575. {
  2576. $fgshop .= " shop = ".$value." or";
  2577. $sid .= " id = ".$value." or";
  2578. }
  2579. }
  2580. $post = $this->input->get(NULL, TRUE);
  2581. if(isset($post['excel']))
  2582. {
  2583. $shop = $this->input->get('shop',true);
  2584. $warehouse = $this->input->get('warehouse',true);
  2585. $express = $this->input->get('express',true);
  2586. $state = $this->input->get('state',true);
  2587. $print = $this->input->get('print',true);
  2588. $libraryconfirm = $this->input->get('libraryconfirm',true);
  2589. $orderinfo = $this->input->get('orderinfo',true);
  2590. $client = $this->input->get('name',true);
  2591. $email = $this->input->get('email',true);
  2592. $number = $this->input->get('number',true);
  2593. $waybill = $this->input->get('waybill',true);
  2594. $authorid = $this->input->get('authorid',true);
  2595. $sourcecontentid = $this->input->get('sourcecontentid',true);
  2596. $timetk = $this->input->get('timetk',true);
  2597. $timetj = $this->input->get('timetj',true);
  2598. $timetk = strtotime($timetk);
  2599. $timetj = strtotime($timetj);
  2600. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2601. if($shop)
  2602. {
  2603. $where .= " and shop = '$shop'";
  2604. }
  2605. if($warehouse)
  2606. {
  2607. $where .= " and type = '$warehouse'";
  2608. }
  2609. if($express)
  2610. {
  2611. $where .= " and express = '$express'";
  2612. }
  2613. if($state)
  2614. {
  2615. $where .= " and state = '$state'";
  2616. }
  2617. if($print)
  2618. {
  2619. $where .= " and print = '$print'";
  2620. }
  2621. if($libraryconfirm)
  2622. {
  2623. $where .= " and libraryconfirm = '$libraryconfirm'";
  2624. }
  2625. if($orderinfo)
  2626. {
  2627. $where .= " and orderinfo = '$orderinfo'";
  2628. }
  2629. if($client)
  2630. {
  2631. $where .= " and client like '%$client%'";
  2632. }
  2633. if($email)
  2634. {
  2635. $where .= " and email = '$email'";
  2636. }
  2637. if($number)
  2638. {
  2639. $where .= " and number = '$number'";
  2640. }
  2641. if($waybill)
  2642. {
  2643. $where .= " and waybill = '$waybill'";
  2644. }
  2645. if($authorid)
  2646. {
  2647. $where .= " and authorid = '$authorid'";
  2648. }
  2649. if($sourcecontentid)
  2650. {
  2651. $where .= " and sourcecontentid = '$sourcecontentid'";
  2652. }
  2653. if($timetk && $timetj)
  2654. {
  2655. $timetj = $timetj+24*3600;
  2656. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2657. }
  2658. //数据排序
  2659. $order_str = "dtime desc";
  2660. //取得信息列表
  2661. $info_list = $this->fullordertt->find_all($where,'shop,number,orderinfo,dtime,name,express,waybill,email,shipremarks,shouldmoney,orderremarks,librarytime,authorid,sourcecontentid',$order_str);
  2662. //格式化数据
  2663. $dt = 0;
  2664. foreach ($info_list as $key=>$value)
  2665. {
  2666. $shop = $this->shop->read($value['shop']);
  2667. $info_list[$key]['shop'] = $shop['shopname'];
  2668. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  2669. if($value['librarytime'] > 0)
  2670. {
  2671. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2672. }
  2673. if($value['express'] != 0)
  2674. {
  2675. $express = $this->express->read($value['express']);
  2676. $info_list[$key]['express'] = $express['servicename'];
  2677. }
  2678. else
  2679. {
  2680. $info_list[$key]['express'] = "无";
  2681. }
  2682. }
  2683. $title = "订单列表 ".date("Y-m-d");
  2684. $titlename = "<table border=1>
  2685. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  2686. <tr>
  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>订单金额</td>
  2697. <td>订单备注</td>
  2698. <td>出库时间</td>
  2699. <td>author_id</td>
  2700. <td>source_content_id</td>
  2701. </tr>
  2702. </table>";
  2703. $filename = $title.".xls";
  2704. $tail = "\n";
  2705. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2706. }
  2707. }
  2708. //删除
  2709. public function _del()
  2710. {
  2711. echo json_encode(array('msg'=>'不允许执行!','success'=>false));exit;
  2712. $post = $this->input->post(NULL, TRUE);
  2713. if(isset($post['s']))
  2714. {
  2715. $id_arr = $this->input->post('s');
  2716. $id_arr = explode(',',$id_arr);
  2717. if(!$id_arr)
  2718. {
  2719. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2720. }
  2721. //循环删除记录
  2722. foreach ($id_arr as $v)
  2723. {
  2724. $this->fullordertt->remove($v);
  2725. }
  2726. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  2727. }
  2728. }
  2729. //查找商品价格
  2730. public function _price()
  2731. {
  2732. $post = $this->input->post(NULL, TRUE);
  2733. if(isset($post['data']))
  2734. {
  2735. $data = $this->input->post('data');
  2736. $data = explode('-',$data);
  2737. $number = '';$num = count($data);
  2738. //循环删除记录
  2739. for($i=0;$i<$num-1;$i++)
  2740. {
  2741. if($data[$i] != 0)
  2742. {
  2743. $number=$number.$data[$i];
  2744. if($i == 2)
  2745. {
  2746. $number=$number.$data[$num-1];
  2747. }
  2748. }
  2749. }
  2750. $list = $this->productdescribe->get_number($number);
  2751. if($list)
  2752. {
  2753. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));
  2754. }
  2755. else
  2756. {
  2757. $list = array('purchase'=>0,'cost'=>0,'salesprice'=>0);
  2758. //echo json_encode(array('msg'=>'此信息没有配置价格!','n'=>$data[$num-1],'success'=>false));exit;
  2759. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));exit;
  2760. }
  2761. }
  2762. }
  2763. public function _customs()
  2764. {
  2765. $post = $this->input->post(NULL, TRUE);
  2766. if(isset($post['e']))
  2767. {
  2768. $e = $this->input->post('e');//快递信息
  2769. $c = $this->input->post('c');//国家信息
  2770. $data = $this->customs->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2771. $list = $this->productdescription->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2772. $rows = array();
  2773. foreach ($data as $key=>$value)
  2774. {
  2775. $detailed = explode('|',trim($value['detailed'],'|'));
  2776. //此处未对比重量选择价值,暂直接选择第一条海关价值
  2777. $detailed = $this->detailed->read($detailed[0]);
  2778. $money = $detailed['customsval'];//找到海关价值
  2779. }
  2780. foreach ($list as $key=>$value)
  2781. {
  2782. $description = $this->typeclass->read($value['description']);
  2783. $list[$key]['title'] = $description['title'];//产品描述名称
  2784. }
  2785. if(!$data && !$list)
  2786. {
  2787. echo json_encode(array('msg'=>'无此快递配置信息!','success'=>false));exit;
  2788. }
  2789. else
  2790. {
  2791. //$list-title -description 取值
  2792. echo json_encode(array('money'=>sprintf("%.2f",$money),'msg'=>$list,'success'=>true));
  2793. }
  2794. }
  2795. }
  2796. public function _express()
  2797. {
  2798. $post = $this->input->post(NULL, TRUE);
  2799. if(isset($post['e']))
  2800. {
  2801. $e = $this->input->post('e');//快递信息
  2802. $c = $this->input->post('c');//国家信息
  2803. $data = $this->logistics->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2804. if(!$data)
  2805. {
  2806. echo json_encode(array('success'=>false));exit;
  2807. }
  2808. else
  2809. {
  2810. echo json_encode(array('money'=>sprintf("%.2f",$data[0]['firstmoney']),'success'=>true));
  2811. }
  2812. }
  2813. }
  2814. public function _hl()
  2815. {
  2816. $post = $this->input->post(NULL, TRUE);
  2817. if(isset($post['cy']))
  2818. {
  2819. $hl = 0;
  2820. $cy = $this->input->post('cy');//币种ID
  2821. $cy = $this->typeclass->read($cy);
  2822. $gethl = $this->hl->get_hl();
  2823. foreach ($gethl as $v)
  2824. {
  2825. $code = str_replace(" ","",$v['code']);
  2826. if($code == $cy['title'])
  2827. {
  2828. $hl = $v['refePrice']/100;
  2829. }
  2830. }
  2831. echo json_encode(array('msg'=>$hl,'success'=>true));
  2832. }
  2833. }
  2834. public function _operation()
  2835. {
  2836. $post = $this->input->post(NULL, TRUE);
  2837. if(isset($post['type']))
  2838. {
  2839. $type = $this->input->post('type');
  2840. $id = $this->input->post('id');
  2841. $msg = $this->input->post('msg');
  2842. if($type == 1)//禁止发货
  2843. {
  2844. $d = $this->fullordertt->read($id);
  2845. if($d['library'] != 1)
  2846. {
  2847. echo json_encode(array('msg'=>'操作失败,订单非未出库状态!','success'=>false));exit;
  2848. }
  2849. if($msg == "")
  2850. {
  2851. echo json_encode(array('msg'=>'必须填写禁止原因!','success'=>false));exit;
  2852. }
  2853. if($d['print'] < 3)
  2854. {
  2855. $a = "订单未打印,";
  2856. }
  2857. else
  2858. {
  2859. $a = "";
  2860. }
  2861. if($this->fullordertt->save(array('libraryconfirm'=>1,'librarynot'=>$a.$msg),$id))
  2862. {
  2863. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2864. }
  2865. else
  2866. {
  2867. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2868. }
  2869. }
  2870. if($type == 6)//允许发货
  2871. {
  2872. $d = $this->fullordertt->read($id);
  2873. if($d['library'] > 1)
  2874. {
  2875. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2876. }
  2877. if($d['print'] < 3)
  2878. {
  2879. $a = "订单未打印,";
  2880. }
  2881. else
  2882. {
  2883. $a = "";
  2884. }
  2885. if($this->fullordertt->save(array('libraryconfirm'=>2,'librarynot'=>$a.$msg),$id))
  2886. {
  2887. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2888. }
  2889. else
  2890. {
  2891. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2892. }
  2893. }
  2894. if($type == 7)//禁止打印
  2895. {
  2896. $d = $this->fullordertt->read($id);
  2897. if($d['printtime'] != 0)
  2898. {
  2899. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2900. }
  2901. if($d['library'] > 1)
  2902. {
  2903. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2904. }
  2905. if($d['print'] < 3)
  2906. {
  2907. $a = "订单未打印,";
  2908. }
  2909. else
  2910. {
  2911. $a = "";
  2912. }
  2913. if($this->fullordertt->save(array('print'=>1),$id))
  2914. {
  2915. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2916. }
  2917. else
  2918. {
  2919. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2920. }
  2921. }
  2922. if($type == 8)//允许打印
  2923. {
  2924. $d = $this->fullordertt->read($id);
  2925. /**
  2926. if($d['printtime'] != 0)
  2927. {
  2928. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2929. }
  2930. **/
  2931. if($d['library'] > 1)
  2932. {
  2933. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2934. }
  2935. if($d['print'] < 3)
  2936. {
  2937. $a = "订单未打印,";
  2938. }
  2939. else
  2940. {
  2941. $a = "";
  2942. }
  2943. if($d['printtime'] == '0')
  2944. {
  2945. $bcprint = 2;
  2946. }
  2947. else
  2948. {
  2949. $bcprint = 3;
  2950. }
  2951. if($this->fullordertt->save(array('print'=>$bcprint,'failed'=>''),$id))
  2952. {
  2953. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2954. }
  2955. else
  2956. {
  2957. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2958. }
  2959. }
  2960. if($type == 9)//关闭
  2961. {
  2962. if($this->fullordertt->save(array('failed'=>''),$id))
  2963. {
  2964. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2965. }
  2966. else
  2967. {
  2968. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2969. }
  2970. }
  2971. if($type == 2)//填写运单、修改运单
  2972. {
  2973. $d = $this->fullordertt->read($id);
  2974. if($d['express'] == 0)
  2975. {
  2976. echo json_encode(array('msg'=>'操作失败,未选择物流方式!','success'=>false));exit;
  2977. }
  2978. if($d['library'] == 3 || ($d['print'] == 3 && $d['libraryconfirm'] == 1))
  2979. {
  2980. echo json_encode(array('msg'=>'操作失败,不允许填写运单号!','success'=>false));exit;
  2981. }
  2982. $xg = $this->fullordertt->read($id);
  2983. $shop = $this->shop->read($xg['shop']);
  2984. $ex = $this->express->read($xg['express']);
  2985. $fs = $this->notice->get_ordertatus(216);//216成功状态
  2986. if($xg['source'] != 1)
  2987. {
  2988. //独立站地址更新订单状态、物流信息
  2989. $gx = $this->api->get_gx(substr($xg['orderinfo'],1),$msg,$xg,$shop,$ex,$xg['msg'],$xg['shopify']);
  2990. }
  2991. else if($xg['source'] == 1)
  2992. {
  2993. $gx['res'] = 3;
  2994. $gx['state'] = 216;
  2995. }
  2996. if(!isset($gx['res']))
  2997. {
  2998. $gx['res'] = 2;
  2999. $gx['state'] = $xg['state'];
  3000. }
  3001. if($gx['res'] > 0 && $fs)
  3002. {
  3003. $warehouse = $this->warehouse->read($xg['type']);
  3004. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  3005. }
  3006. $msg = preg_replace('/( | | | |\s)/','',$msg);
  3007. if($this->fullordertt->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$id))
  3008. {
  3009. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3010. }
  3011. else
  3012. {
  3013. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3014. }
  3015. }
  3016. }
  3017. }
  3018. public function _merge()
  3019. {
  3020. $post = $this->input->post(NULL, TRUE);
  3021. if(isset($post['s']))
  3022. {
  3023. $id_arr = $this->input->post('s');
  3024. $id_arr = explode(',',trim( $id_arr,','));
  3025. $id_arr = array_reverse($id_arr);
  3026. if(!$id_arr)
  3027. {
  3028. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3029. }
  3030. if(count($id_arr) < 2)
  3031. {
  3032. echo json_encode(array('msg'=>'缺少可合并单!','success'=>false));exit;
  3033. }
  3034. $tmp_list = $this->db->from('fullordertt')->where_in('id',$id_arr)->select('id,orderinfo,number,type,express')->get()->result_array();
  3035. $count_warehouse_list = [];
  3036. $count_express_list = [];
  3037. $flag = 0;
  3038. $flag_str = '';
  3039. foreach ($tmp_list as $k => $v) {
  3040. $count_warehouse_list[$v['type']] = $v['type'];
  3041. if(empty($v['express'])){
  3042. $flag = 1;
  3043. $flag_str.= $v['number'].'仓库未选,请先选快递;';
  3044. }
  3045. $count_express_list[$v['express']] = $v['express'];
  3046. }
  3047. if($flag == 1){
  3048. echo json_encode(array('msg'=>$flag_str,'success'=>false));exit;
  3049. }
  3050. if(count($count_warehouse_list) > 1){
  3051. echo json_encode(array('msg'=>'合并单的仓库不一致,无法合并!','success'=>false));exit;
  3052. }
  3053. if(count($count_express_list) > 1){
  3054. echo json_encode(array('msg'=>'合并单的快递不一致,无法合并!','success'=>false));exit;
  3055. }
  3056. $post = array();
  3057. $u = $this->fullordertt->read($id_arr[0]);
  3058. unset($id_arr[0]);
  3059. $this->db->trans_begin();
  3060. $hd = $this->fullordertthb->get_orderinfo($u['orderinfo']);
  3061. if(!$hd)
  3062. {
  3063. $this->fullordertthb->insert($u);
  3064. }
  3065. //相加
  3066. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  3067. $post['budget'] = $u['budget'];//预估到帐金额
  3068. $post['expressmoney']= $u['expressmoney'];//物流金额
  3069. //$post['refundy'] = $u['refundy'];//补/退原额
  3070. //$post['refundj'] = $u['refundj'];//补/退净额
  3071. $post['cost'] = $u['cost'];//成本金额
  3072. //$post['zzl'] = $u['zzl'];//总重量
  3073. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  3074. $post['ts'] = $u['ts'];//条数
  3075. $post['cost'] = $u['cost'];//成本金额
  3076. //追加
  3077. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  3078. $post['rtext'] = $u['rtext'];//补/退原因
  3079. $post['pay'] = $u['pay'];//付款方式
  3080. $post['paypal'] = $u['paypal'];//交易号
  3081. $post['clientremarks'] = $u['clientremarks'];//客户留言
  3082. $post['product'] = $u['product'];//商品名称
  3083. //$post['issku'] = $u['issku'];//sku
  3084. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  3085. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  3086. //产品追加
  3087. $post['fpdata'] = $u['fpdata'];//产品内容
  3088. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  3089. $merge = $u['id'];
  3090. $d = array($u['id']);$order = '';
  3091. $zsl = 0;$zccsl = 0;
  3092. foreach ($id_arr as $v)
  3093. {
  3094. $v = $this->fullordertt->read($v);
  3095. if($u['type'] != $v['type'])
  3096. {
  3097. echo json_encode(array('msg'=>'仓库不一致,无法合并!','success'=>false));exit;
  3098. }
  3099. if($v['shop'] = $u['shop'])
  3100. {
  3101. $hd = $this->fullordertthb->get_orderinfo($v['orderinfo']);
  3102. if(!$hd)
  3103. {
  3104. $this->fullordertthb->insert($v);
  3105. }
  3106. // $post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  3107. // $post['budget'] += $v['budget'];//预估到帐金额
  3108. // $post['expressmoney'] += $v['expressmoney'];//物流金额
  3109. //$post['refundy'] += $v['refundy'];//补/退原额
  3110. //$post['refundj'] += $v['refundj'];//补/退净额
  3111. $post['cost'] += $v['cost'];//成本金额
  3112. //$post['zzl'] += $v['zzl'];//总重量
  3113. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  3114. $post['ts'] += $v['ts'];//条数
  3115. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  3116. //$post['rtext'] .= $v['rtext'];//补/退原因
  3117. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  3118. //$post['paypal'] .= $v['paypal'];//交易号
  3119. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  3120. $post['product'] .= $v['product'];//商品名称
  3121. //$post['issku'] .= $v['issku'];//sku
  3122. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  3123. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  3124. $post['fpdata'] .= $v['fpdata'];//产品内容
  3125. $post['whlabel'] .= $v['whlabel'];//产品对应库存码
  3126. $d[] = $v['id'];
  3127. $order .= $v['orderinfo'].'('.$v['number'].')、';
  3128. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  3129. $i = 0;
  3130. if($wl)//如果有那么清除所有占用
  3131. {
  3132. foreach ($wl as $val)
  3133. {
  3134. if($val['sku'] == 'Preset' && $val['state'] == '9')
  3135. {
  3136. $this->whlabel->remove($val['id']);//删除预设
  3137. $i++;
  3138. }
  3139. else
  3140. {
  3141. $this->whlabel->save(array('zd'=>''),$val['id']);//专属
  3142. $i++;
  3143. }
  3144. }
  3145. }
  3146. $zsl += count($wl);
  3147. $zccsl += $i;
  3148. $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']);
  3149. }
  3150. }
  3151. //计算出单条价值
  3152. /**
  3153. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  3154. {
  3155. //$post['dtsbjz'] = 0;
  3156. }
  3157. else
  3158. {
  3159. //$post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  3160. }
  3161. **/
  3162. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];
  3163. $post['merge'] = $u['id'];
  3164. //$post['mergeid'] = 1;
  3165. //合并重复项
  3166. //解决whlabel 合并在一起是 多出的那个|
  3167. $post['whlabel'] = str_replace("||","|",$post['whlabel']);
  3168. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  3169. $hbcff = explode(';',trim($post['fpdata'],';'));
  3170. $c = 0;
  3171. $hbw = array();
  3172. $hbf = array();
  3173. for($i=0;$i<count($hbcfw);$i++)
  3174. {
  3175. $w = explode('-',$hbcfw[$i]);
  3176. $f = explode('|',$hbcff[$i]);
  3177. $w2 = ($w[2]==0)?0:'';
  3178. if(!isset($hbw[$w[0].$w2]))
  3179. {
  3180. $hbw[$w[0].$w2] = $hbcfw[$i];
  3181. $hbf[$w[0].$w2] = $hbcff[$i];
  3182. }
  3183. else
  3184. {
  3185. $c++;
  3186. $cw = explode('-',$hbw[$w[0].$w2]);
  3187. $cf = explode('|',$hbf[$w[0].$w2]);
  3188. if($cw[2] != 0 && $w[2] != 0)
  3189. {
  3190. $cf[2] += $f[2];
  3191. $cf[9] .= '~'.$f[9];
  3192. $hbf[$w[0].$w2] = implode("|",$cf);
  3193. $cw[1] += $f[2];
  3194. $cw[2] .= '~'.$f[9];
  3195. $hbw[$w[0].$w2] = implode("-",$cw);
  3196. }
  3197. else if($cw[2] == 0 && $w[2] == 0)
  3198. {
  3199. $cf[2] += $f[2];
  3200. $hbf[$w[0].$w2] = implode("|",$cf);
  3201. $cw[1] += $f[2];
  3202. $hbw[$w[0].$w2] = implode("-",$cw);
  3203. }
  3204. else
  3205. {
  3206. $hbw[] = $hbcfw[$i];
  3207. $hbf[] = $hbcff[$i];
  3208. }
  3209. }
  3210. }
  3211. if($c > 0)
  3212. {
  3213. $post['fpdata'] = implode(";",$hbf).';';
  3214. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  3215. }
  3216. //合并重复项结束
  3217. $this->fullordertt->save($post,$u['id']);
  3218. if ($this->db->trans_status() === FALSE)
  3219. {
  3220. $this->db->trans_commit();
  3221. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3222. }
  3223. else
  3224. {
  3225. $this->db->trans_commit();
  3226. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$u['id'],'success'=>true));
  3227. }
  3228. }
  3229. }
  3230. //评价管理
  3231. public function _evaluate()
  3232. {
  3233. $user = $this->user->get_api($_SESSION['api']);
  3234. if($user)
  3235. {
  3236. $fgshop = "";$sid = "";
  3237. $user = explode('|',trim($user['shop'],'|'));
  3238. foreach ($user as $value)
  3239. {
  3240. $fgshop .= " shop = ".$value." or";
  3241. $sid .= " id = ".$value." or";
  3242. }
  3243. }
  3244. $post = $this->input->post(NULL, TRUE);
  3245. if(isset($post['page']))
  3246. {
  3247. $page = $this->input->post('page',true);
  3248. $perpage = $this->input->post('perpage',true);
  3249. $shop = $this->input->post('shop',true);
  3250. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  3251. if($shop)
  3252. {
  3253. $where .= " and shop = '$shop'";
  3254. }
  3255. //数据排序
  3256. $order_str = "id desc";
  3257. if(empty($page))
  3258. {
  3259. $start = 0;
  3260. $perpage = 1;
  3261. }
  3262. else
  3263. {
  3264. $start = ($page - 1)*$perpage;
  3265. }
  3266. //取得信息列表
  3267. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  3268. //格式化数据
  3269. foreach ($info_list as $key=>$value)
  3270. {
  3271. $shop = $this->shop->read($value['shop']);
  3272. $info_list[$key]['shop'] = $shop['shopname'];
  3273. $info_list[$key]['operation'] = "评价";
  3274. }
  3275. $total = $this->fullordertt->find_count($where);
  3276. $pagenum = ceil($total/$perpage);
  3277. $over = $total-($start+$perpage);
  3278. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3279. echo json_encode($rows);exit;
  3280. }
  3281. $this->_Template('fullordertt_evaluate',$this->data);
  3282. }
  3283. //订单消息
  3284. public function _state()
  3285. {
  3286. $user = $this->user->get_api($_SESSION['api']);
  3287. if($user)
  3288. {
  3289. $fgshop = "";$sid = "";
  3290. $user = explode('|',trim($user['shop'],'|'));
  3291. foreach ($user as $value)
  3292. {
  3293. $fgshop .= " shop = ".$value." or";
  3294. $sid .= " id = ".$value." or";
  3295. }
  3296. }
  3297. $post = $this->input->post(NULL, TRUE);
  3298. if(isset($post['page']))
  3299. {
  3300. $page = $this->input->post('page',true);
  3301. $perpage = $this->input->post('perpage',true);
  3302. $timetk = $this->input->post('timetk',true);
  3303. $timetj = $this->input->post('timetj',true);
  3304. $shop = $this->input->post('shop',true);
  3305. $expressstate = $this->input->post('expressstate',true);
  3306. $fs = $this->input->post('fs',true);
  3307. $state = $this->input->post('state',true);
  3308. $express = $this->input->post('express',true);
  3309. $review = $this->input->post('review',true);
  3310. $orderinfo = $this->input->post('orderinfo',true);
  3311. $number = $this->input->post('number',true);
  3312. $waybill = $this->input->post('waybill',true);
  3313. $xztime = $this->input->post('xztime',true);
  3314. $timetk = strtotime($timetk);
  3315. $timetj = strtotime($timetj);
  3316. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3317. if($timetk && $timetj)
  3318. {
  3319. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3320. }
  3321. if($xztime == 'librarytime')
  3322. {
  3323. $order_str = "librarytime desc";
  3324. }
  3325. else if($xztime == 'dtime')
  3326. {
  3327. $order_str = "dtime desc";
  3328. }
  3329. if($shop)
  3330. {
  3331. $where .= " and shop = '$shop'";
  3332. }
  3333. if($expressstate)
  3334. {
  3335. $where .= " and expressstate = '$expressstate'";
  3336. }
  3337. if($review)
  3338. {
  3339. $where .= " and review = '$review'";
  3340. }
  3341. if($fs)
  3342. {
  3343. if($fs == '2')
  3344. {
  3345. $where .= " and exstateerror != ''";
  3346. }
  3347. else
  3348. {
  3349. $where .= " and exstateerror = ''";
  3350. }
  3351. }
  3352. if($state)
  3353. {
  3354. $where .= " and state = '$state'";
  3355. }
  3356. if($express)
  3357. {
  3358. $where .= " and express = '$express'";
  3359. }
  3360. if($orderinfo)
  3361. {
  3362. $where .= " and orderinfo = '$orderinfo'";
  3363. }
  3364. if($number)
  3365. {
  3366. $where .= " and number = '$number'";
  3367. }
  3368. if($waybill)
  3369. {
  3370. $where .= " and waybill = '$waybill'";
  3371. }
  3372. if(empty($page))
  3373. {
  3374. $start = 0;
  3375. $perpage = 1;
  3376. }
  3377. else
  3378. {
  3379. $start = ($page - 1)*$perpage;
  3380. }
  3381. //取得信息列表
  3382. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,content,orderremarks,exstateerror',$order_str,$start,$perpage);
  3383. //格式化数据
  3384. foreach ($info_list as $key=>$value)
  3385. {
  3386. $shop = $this->shop->read($value['shop']);
  3387. $info_list[$key]['shop'] = $shop['shopname'];
  3388. $country = $this->country->read($value['country']);
  3389. $info_list[$key]['country'] = $country['name'];
  3390. //$state = $this->typeclass->read($value['state']);
  3391. //$info_list[$key]['state'] = $state['title'];
  3392. if($value['library'] == 1)
  3393. {
  3394. $info_list[$key]['library'] = "未出库";
  3395. }
  3396. else if($value['library'] == 2)
  3397. {
  3398. $info_list[$key]['library'] = "已出库";
  3399. }
  3400. else if($value['library'] == 3)
  3401. {
  3402. $info_list[$key]['library'] = "已退库";
  3403. }
  3404. if($value['librarytime'] == '0')
  3405. {
  3406. $info_list[$key]['librarytime'] = '无';
  3407. }
  3408. else
  3409. {
  3410. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  3411. }
  3412. $express = $this->express->read($value['express']);
  3413. $info_list[$key]['express'] = $express['servicename'];
  3414. }
  3415. $total = $this->fullordertt->find_count($where);
  3416. $pagenum = ceil($total/$perpage);
  3417. $over = $total-($start+$perpage);
  3418. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3419. echo json_encode($rows);exit;
  3420. }
  3421. $notice = $this->notice->find_all("type = '1' and (".rtrim($fgshop,'or').")");
  3422. $this->data['notice'] = $notice;
  3423. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3424. $this->data['wlshop'] = $wlshop;
  3425. $this->data['express'] = $this->express->find_all();
  3426. $this->_Template('fullordertt_state',$this->data);
  3427. }
  3428. //物流信息
  3429. public function _wl()
  3430. {
  3431. $user = $this->user->get_api($_SESSION['api']);
  3432. if($user)
  3433. {
  3434. $fgshop = "";$sid = "";
  3435. $user = explode('|',trim($user['shop'],'|'));
  3436. foreach ($user as $value)
  3437. {
  3438. $fgshop .= " shop = ".$value." or";
  3439. $sid .= " id = ".$value." or";
  3440. }
  3441. }
  3442. $post = $this->input->post(NULL, TRUE);
  3443. if(isset($post['page']))
  3444. {
  3445. $page = $this->input->post('page',true);
  3446. $perpage = $this->input->post('perpage',true);
  3447. $timetk = $this->input->post('timetk',true);
  3448. $timetj = $this->input->post('timetj',true);
  3449. $shop = $this->input->post('shop',true);
  3450. $expressstate = $this->input->post('expressstate',true);
  3451. $fs = $this->input->post('fs',true);
  3452. $state = $this->input->post('state',true);
  3453. $express = $this->input->post('express',true);
  3454. $orderinfo = $this->input->post('orderinfo',true);
  3455. $number = $this->input->post('number',true);
  3456. $waybill = $this->input->post('waybill',true);
  3457. $wlyc = $this->input->post('wlyc',true);
  3458. $wltype = $this->input->post('wltype',true);
  3459. $source = $this->input->post('source',true);
  3460. $xztime = $this->input->post('xztime',true);
  3461. $timetk = strtotime($timetk);
  3462. $timetj = strtotime($timetj);
  3463. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3464. if($timetk && $timetj)
  3465. {
  3466. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3467. }
  3468. if($xztime == 'librarytime')
  3469. {
  3470. $order_str = "librarytime desc";
  3471. }
  3472. else if($xztime == 'dtime')
  3473. {
  3474. $order_str = "dtime desc";
  3475. }
  3476. else if ($xztime == 'wlfstime')
  3477. {
  3478. $order_str = "wlfstime desc";
  3479. }
  3480. if($shop)
  3481. {
  3482. $where .= " and shop = '$shop'";
  3483. }
  3484. if($expressstate != '')
  3485. {
  3486. $where .= " and expressstate = '$expressstate'";
  3487. }
  3488. if($fs)
  3489. {
  3490. if($fs == '1')
  3491. {
  3492. $where .= " and wlcontent != ''";
  3493. }
  3494. if($fs == '2')
  3495. {
  3496. $where .= " and wlerror != ''";
  3497. }
  3498. if($fs == '3')
  3499. {
  3500. $where .= " and wlcontent = '' and shouldmoney > 100";
  3501. }
  3502. else if($fs == '4')
  3503. {
  3504. $where .= " and wltype = '1'";
  3505. }
  3506. }
  3507. if($state)
  3508. {
  3509. $where .= " and state = '$state'";
  3510. }
  3511. if($express)
  3512. {
  3513. $where .= " and express = '$express'";
  3514. }
  3515. if($orderinfo)
  3516. {
  3517. $where .= " and orderinfo = '$orderinfo'";
  3518. }
  3519. if($number)
  3520. {
  3521. $where .= " and number = '$number'";
  3522. }
  3523. if($waybill)
  3524. {
  3525. $where .= " and waybill = '$waybill'";
  3526. }
  3527. if($wlyc!='')
  3528. {
  3529. $where .= " and wlyc = '$wlyc'";
  3530. }
  3531. if($wltype!='')
  3532. {
  3533. $where .= " and wltype = '$wltype'";
  3534. }
  3535. if($source)
  3536. {
  3537. if($source == 1)
  3538. {
  3539. $where .= " and source = '$source'";
  3540. }
  3541. else
  3542. {
  3543. $where .= " and source != '1'";
  3544. }
  3545. }
  3546. if(empty($page))
  3547. {
  3548. $start = 0;
  3549. $perpage = 1;
  3550. }
  3551. else
  3552. {
  3553. $start = ($page - 1)*$perpage;
  3554. }
  3555. //取得信息列表
  3556. $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);
  3557. //格式化数据
  3558. foreach ($info_list as $key=>$value)
  3559. {
  3560. $f = $this->fullordertt->read($value['id']);
  3561. $info_list[$key]['number'] = "<p>".$value['number']."</p>"."<p>".$f['email']."</p>";
  3562. $country = $this->country->read($value['country']);
  3563. $info_list[$key]['country'] = "<p>".$country['name']."</p><p>".$f['phone']."</p>";
  3564. //$state = $this->typeclass->read($value['state']);
  3565. //$info_list[$key]['state'] = $state['title'];
  3566. if($value['library'] == 1)
  3567. {
  3568. $info_list[$key]['library'] = "未出库";
  3569. }
  3570. else if($value['library'] == 2)
  3571. {
  3572. $info_list[$key]['library'] = "已出库";
  3573. }
  3574. else if($value['library'] == 3)
  3575. {
  3576. $info_list[$key]['library'] = "已退库";
  3577. }
  3578. if($value['librarytime'] == '0')
  3579. {
  3580. $info_list[$key]['librarytime'] = '无';
  3581. }
  3582. else
  3583. {
  3584. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']).'<br>'.$f['shouldmoney'];
  3585. }
  3586. if($value['expressstate'] == 0)
  3587. {
  3588. $info_list[$key]['expressstate'] = "无信息";
  3589. }
  3590. else if($value['expressstate'] == 2)
  3591. {
  3592. $info_list[$key]['expressstate'] = "已取件";
  3593. }
  3594. else if($value['expressstate'] == 3)
  3595. {
  3596. $info_list[$key]['expressstate'] = "在途中";
  3597. }
  3598. else if($value['expressstate'] == 4)
  3599. {
  3600. $info_list[$key]['expressstate'] = "到达目的地国".$value['expressstate'];
  3601. }
  3602. else if($value['expressstate'] == 5)
  3603. {
  3604. $info_list[$key]['expressstate'] = "即将派送";
  3605. }
  3606. else if($value['expressstate'] == 6)
  3607. {
  3608. $info_list[$key]['expressstate'] = "已签收";
  3609. }
  3610. else if($value['expressstate'] == 1)
  3611. {
  3612. $info_list[$key]['expressstate'] = "派送异常";
  3613. }
  3614. $express = $this->express->read($value['express']);
  3615. $info_list[$key]['express'] = $express['servicename'];
  3616. if($value['wltype'] == '0')
  3617. {
  3618. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>禁止发送</b></p>";
  3619. }
  3620. else
  3621. {
  3622. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>允许发送</b></p>";
  3623. }
  3624. if($f['wlyc'] == '0')
  3625. {
  3626. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='1'>加入异常</b></p>";
  3627. }
  3628. else if($f['wlyc'] == '1')
  3629. {
  3630. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='2'>物流异常</b></p>";
  3631. }
  3632. else if($f['wlyc'] == '2')
  3633. {
  3634. $info_list[$key]['wltype'] .= "<p><b>异常已处理</b></p>";
  3635. }
  3636. if(stripos($value['excontent'],'<br />') !== false)
  3637. {
  3638. $excontent = explode('<br />',$value['excontent']);
  3639. $info_list[$key]['excontent'] = '<i class="method fa fa-list-ul" data-t="'.$value['excontent'].'"></i> '.$excontent[0];
  3640. }
  3641. }
  3642. $total = $this->fullordertt->find_count($where);
  3643. $pagenum = ceil($total/$perpage);
  3644. $over = $total-($start+$perpage);
  3645. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3646. echo json_encode($rows);exit;
  3647. }
  3648. if(isset($post['q']))
  3649. {
  3650. $id = $this->input->post('id',true);
  3651. $f = $this->fullordertt->read($id);
  3652. $wl = ($f['wltype']=='0')?1:0;
  3653. $wltitle = ($f['wltype']=='0')?'已禁发送':'已允发送';
  3654. if($this->fullordertt->save(array('wltype'=>$wl),$id))
  3655. {
  3656. echo json_encode(array('msg'=>'ckn','id'=>$id,'wltitle'=>$wltitle,'success'=>true));exit;
  3657. }
  3658. else
  3659. {
  3660. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$wltitle,'success'=>false));exit;
  3661. }
  3662. }
  3663. if(isset($post['t']))
  3664. {
  3665. $id = $this->input->post('id',true);
  3666. $f = $this->fullordertt->read($id);
  3667. $t = $this->input->post('t',true);
  3668. $yc = ($f['wlyc']=='0')?1:2;
  3669. $yctitle = ($f['wlyc']=='0')?'物流异常':'异常已处理';
  3670. if($this->fullordertt->save(array('wlyc'=>$yc),$id))
  3671. {
  3672. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3673. }
  3674. else
  3675. {
  3676. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3677. }
  3678. }
  3679. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  3680. $this->data['notice'] = $notice;
  3681. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3682. $this->data['wlshop'] = $wlshop;
  3683. $this->data['express'] = $this->express->find_all();
  3684. $this->_Template('fullordertt_wl',$this->data);
  3685. }
  3686. //审核订单
  3687. public function _review()
  3688. {
  3689. $user = $this->user->get_api($_SESSION['api']);
  3690. if($user)
  3691. {
  3692. $fgshop = "";$sid = "";
  3693. $user = explode('|',trim($user['shop'],'|'));
  3694. foreach ($user as $value)
  3695. {
  3696. $sid .= " id = ".$value." or";
  3697. $fgshop .= " shop = ".$value." or";
  3698. }
  3699. $fgshop = " and (".rtrim($fgshop,'or').")";
  3700. }
  3701. $post = $this->input->post(NULL, TRUE);
  3702. if(isset($post['page']))
  3703. {
  3704. $page = $this->input->post('page',true);
  3705. $perpage = $this->input->post('perpage',true);
  3706. $source = $this->input->post('source',true);
  3707. $warehouse = $this->input->post('warehouse',true);
  3708. $express = $this->input->post('express',true);
  3709. $orderremarks = $this->input->post('orderremarks',true);
  3710. $shop = $this->input->post('shop',true);
  3711. $review = $this->input->post('review',true);
  3712. $orderinfo = $this->input->post('orderinfo',true);
  3713. $shipremarks = $this->input->post('shipremarks',true);
  3714. $number = $this->input->post('number',true);
  3715. $timetk = $this->input->post('timetk',true);
  3716. $timetj = $this->input->post('timetj',true);
  3717. $timetk = strtotime($timetk);
  3718. $timetj = strtotime($timetj);
  3719. $where = "mergeid = 0 and state = '207'".$fgshop;
  3720. if($timetk && $timetj)
  3721. {
  3722. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3723. }
  3724. if($source)
  3725. {
  3726. if($source == '2d')
  3727. {
  3728. $where .= " and source >= '2'";
  3729. }
  3730. else
  3731. {
  3732. $where .= " and source = '$source'";
  3733. }
  3734. }
  3735. if($review)
  3736. {
  3737. $where .= " and review = '$review'";
  3738. }
  3739. else
  3740. {
  3741. $where .= "and review <= '2'";
  3742. //$where .= " and ((review = '2' and source = '1') or (review = '1' and source >= '2'))";
  3743. }
  3744. if($shop)
  3745. {
  3746. $where .= " and shop = '$shop'";
  3747. }
  3748. if($warehouse)
  3749. {
  3750. $where .= " and type = '$warehouse'";
  3751. }
  3752. if($express)
  3753. {
  3754. $where .= " and express = '$express'";
  3755. }
  3756. if($orderremarks)
  3757. {
  3758. $where .= " and orderremarks like '%$orderremarks%'";
  3759. }
  3760. if($orderinfo)
  3761. {
  3762. $where .= " and orderinfo = '$orderinfo'";
  3763. }
  3764. if($number)
  3765. {
  3766. $where .= " and number = '$number'";
  3767. }
  3768. if($shipremarks)
  3769. {
  3770. $where .= " and shipremarks like '%$shipremarks%'";
  3771. }
  3772. //数据排序
  3773. $order_str = "id desc";
  3774. if(empty($page))
  3775. {
  3776. $start = 0;
  3777. $perpage = 1;
  3778. }
  3779. else
  3780. {
  3781. $start = ($page - 1)*$perpage;
  3782. }
  3783. //取得信息列表
  3784. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,client,express,dtime,shouldmoney,review,orderremarks');
  3785. //格式化数据
  3786. foreach ($info_list as $key=>$value)
  3787. {
  3788. $lr = $this->fullordertt->read($value['id']);
  3789. $shop = $this->shop->read($value['shop']);
  3790. $info_list[$key]['shop'] = $shop['shopname'];
  3791. $warehouse = $this->warehouse->read($value['type']);
  3792. $info_list[$key]['type'] = $warehouse['title'];
  3793. $express = $this->express->read($value['express']);
  3794. $info_list[$key]['express'] = $express['servicename'];
  3795. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']).'</p><p>'.date('H:i:s',$value['dtime']).'</p>';
  3796. if($value['review'] == 1)
  3797. {
  3798. $info_list[$key]['review'] = "未送审";
  3799. }
  3800. else if($value['review'] == 2)
  3801. {
  3802. $info_list[$key]['review'] = "待审核";
  3803. }
  3804. else if($value['review'] == 3)
  3805. {
  3806. $info_list[$key]['review'] = "不通过";
  3807. }
  3808. else if($value['review'] == 4)
  3809. {
  3810. $info_list[$key]['review'] = "取消重审";
  3811. }
  3812. else if($value['review'] == 5)
  3813. {
  3814. $info_list[$key]['review'] = "审核通过";
  3815. }
  3816. else if($value['review'] == 6)
  3817. {
  3818. $info_list[$key]['review'] = "自动通过";
  3819. }
  3820. /**
  3821. $info_list[$key]['library'] = "";
  3822. if($value['review'] == 1)
  3823. {
  3824. $info_list[$key]['library'] = "<p><b class='focz' data-type='6' data-id='".$value['id']."'>审核通过</b></p>";
  3825. }
  3826. if($value['review'] == 2)
  3827. {
  3828. $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>";
  3829. }
  3830. else if($value['review'] == 3)
  3831. {
  3832. $info_list[$key]['library'] = "<p><b class='fullorderttreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  3833. }
  3834. else if($value['review'] == 5)
  3835. {
  3836. $info_list[$key]['library'] = "<p><b class='fullorderttreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  3837. }
  3838. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  3839. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  3840. $cost = $lr['cost']/$lr['hl'];
  3841. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  3842. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  3843. **/
  3844. }
  3845. $total = $this->fullordertt->find_count($where);
  3846. $pagenum = ceil($total/$perpage);
  3847. $over = $total-($start+$perpage);
  3848. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3849. echo json_encode($rows);exit;
  3850. }
  3851. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3852. $this->data['shop'] = $wlshop;
  3853. $this->_Template('fullordertt_review',$this->data);
  3854. }
  3855. public function _wlbz($arg_array)
  3856. {
  3857. $post = $this->input->post(NULL, TRUE);
  3858. if(isset($post['id']))
  3859. {
  3860. $id = $this->input->post('id',true);
  3861. $post['wlbz'] = $this->input->post('wlbz',true);
  3862. if($post['wlbz'] == '')
  3863. {
  3864. echo json_encode(array('msg'=>'备注不能为空','success'=>false));exit;
  3865. }
  3866. if($this->fullordertt->save($post,$id))
  3867. {
  3868. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  3869. }
  3870. else
  3871. {
  3872. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  3873. }
  3874. }
  3875. $arg_array = $arg_array[0];
  3876. $fullordertt = $this->fullordertt->read($arg_array);
  3877. $this->data['fullordertt'] = $fullordertt;
  3878. $this->_Template('fullordertt_wlbz',$this->data);
  3879. }
  3880. //导出资金统计excel
  3881. public function _fmexcel()
  3882. {
  3883. $user = $this->user->get_api($_SESSION['api']);
  3884. if($user)
  3885. {
  3886. $fgshop = "";$sid = "";
  3887. $user = explode('|',trim($user['shop'],'|'));
  3888. foreach ($user as $value)
  3889. {
  3890. $fgshop .= " shop = ".$value." or";
  3891. $sid .= " id = ".$value." or";
  3892. }
  3893. }
  3894. if(isset($_GET['excel']))
  3895. {
  3896. $timetk = $this->input->get('timetk',true);
  3897. $timetj = $this->input->get('timetj',true);
  3898. $shop = $this->input->get('shop',true);
  3899. $source = $this->input->get('source',true);
  3900. $state = $this->input->get('state',true);
  3901. $type = $this->input->get('type',true);
  3902. $orderinfo = $this->input->get('orderinfo',true);
  3903. $user = $this->input->get('user',true);
  3904. $name = $this->input->get('name',true);
  3905. $timetk = strtotime($timetk);
  3906. $timetj = strtotime($timetj);
  3907. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3908. if($timetk && $timetj)
  3909. {
  3910. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3911. }
  3912. if($shop)
  3913. {
  3914. $where .= " and shop = '$shop'";
  3915. }
  3916. if($source)
  3917. {
  3918. $where .= " and source = '$source'";
  3919. }
  3920. if($state)
  3921. {
  3922. if($state == 1)
  3923. {
  3924. $where .= " and state = '$state'";
  3925. }
  3926. }
  3927. if($type)
  3928. {
  3929. $where .= " and type = '$type'";
  3930. }
  3931. if($orderinfo)
  3932. {
  3933. $where .= " and orderinfo = '$orderinfo'";
  3934. }
  3935. if($user)
  3936. {
  3937. $where .= " and user = '$user'";
  3938. }
  3939. if($name)
  3940. {
  3941. $where .= " and name = '$name'";
  3942. }
  3943. //取得信息列表
  3944. $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');
  3945. //格式化数据
  3946. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  3947. foreach ($info_list as $key=>$value)
  3948. {
  3949. $info_list[$key]['id'] = $i;
  3950. if($value['currencytitle'] != "CNY")
  3951. {
  3952. $hl=$value['hl'];
  3953. }
  3954. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3955. $budget=$budget+($value['budget']*$hl);
  3956. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3957. $refund=$refund+($value['refund']*$hl);
  3958. $shop = $this->shop->read($value['shop']);
  3959. $info_list[$key]['shop'] = $shop['shopname'];
  3960. $info_list[$key]['user'] = $shop['shopuser'];
  3961. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3962. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3963. $country = $this->country->read($value['country']);
  3964. $info_list[$key]['country'] = $country['name'];
  3965. $express = $this->express->read($value['express']);
  3966. $info_list[$key]['express'] = $express['servicename'];
  3967. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3968. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  3969. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  3970. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  3971. $fpdata = array();
  3972. if(stripos($value['fpdata'],';') !== false)
  3973. {
  3974. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3975. foreach ($fpdata as $ke=>$va)
  3976. {
  3977. $v = explode('|',rtrim($va,'|'));
  3978. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3979. }
  3980. }
  3981. $info_list[$key]['fpdata'] = $fpdata;
  3982. $i++;
  3983. }
  3984. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  3985. $title = "订单资金信息";
  3986. $titlename = "<table border=1>
  3987. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3988. <tr>
  3989. <td>NO.</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>退款金额</td>
  4002. <td>手续费</td>
  4003. <td>预估金额</td>
  4004. <td>
  4005. <table border=1>
  4006. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4007. <tr>
  4008. <td>产品</td>
  4009. <td>条数</td>
  4010. <td>数量</td>
  4011. </tr>
  4012. </table>
  4013. </td>
  4014. <td>总条数</td>
  4015. </tr>
  4016. </table>";
  4017. $filename = $title.".xls";
  4018. $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";
  4019. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4020. }
  4021. }
  4022. //导出订单excel
  4023. public function _fdexcel()
  4024. {
  4025. if(isset($_GET['excel']))
  4026. {
  4027. $page = $this->input->post('page',true);
  4028. $perpage = $this->input->post('perpage',true);
  4029. $timetk = $this->input->post('timetk',true);
  4030. $timetj = $this->input->post('timetj',true);
  4031. $shop = $this->input->post('shop',true);
  4032. $source = $this->input->post('source',true);
  4033. $state = $this->input->post('state',true);
  4034. $review = $this->input->post('review',true);
  4035. $express = $this->input->post('express',true);
  4036. $orderinfo = $this->input->post('orderinfo',true);
  4037. $user = $this->input->post('user',true);
  4038. $name = $this->input->post('name',true);
  4039. $waybill = $this->input->post('waybill',true);
  4040. $timetk = strtotime($timetk);
  4041. $timetj = strtotime($timetj);
  4042. $where = "1=1 and mergeid = 0";
  4043. if($timetk && $timetj)
  4044. {
  4045. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4046. }
  4047. if($shop)
  4048. {
  4049. $where .= " and shop = '$shop'";
  4050. }
  4051. if($source)
  4052. {
  4053. $where .= " and source = '$source'";
  4054. }
  4055. if($state)
  4056. {
  4057. $where .= " and state = '$state'";
  4058. }
  4059. if($review)
  4060. {
  4061. $where .= " and review = '$review'";
  4062. }
  4063. if($express)
  4064. {
  4065. $where .= " and express = '$express'";
  4066. }
  4067. if($orderinfo)
  4068. {
  4069. $where .= " and orderinfo = '$orderinfo'";
  4070. }
  4071. if($user)
  4072. {
  4073. $where .= " and user = '$user'";
  4074. }
  4075. if($name)
  4076. {
  4077. $where .= " and name = '$name'";
  4078. }
  4079. if($waybill)
  4080. {
  4081. $where .= " and waybill = '$waybill'";
  4082. }
  4083. //取得信息列表
  4084. $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');
  4085. //格式化数据
  4086. $i = 1;$shouldmoney = 0;$hl=1;
  4087. foreach ($info_list as $key=>$value)
  4088. {
  4089. $info_list[$key]['id'] = $i;
  4090. if($value['source'] == 1)
  4091. {
  4092. $info_list[$key]['source'] = "线下订单";
  4093. }
  4094. else if($value['source'] == 2)
  4095. {
  4096. $info_list[$key]['source'] = "PC订单";
  4097. }
  4098. else if($value['source'] == 3)
  4099. {
  4100. $info_list[$key]['source'] = "手机订单";
  4101. }
  4102. if($value['currencytitle'] != "CNY")
  4103. {
  4104. $hl=$value['hl'];
  4105. }
  4106. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  4107. $shop = $this->shop->read($value['shop']);
  4108. $info_list[$key]['shop'] = $shop['shopname'];
  4109. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  4110. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  4111. $state = $this->typeclass->read($value['state']);
  4112. $info_list[$key]['state'] = $state['title'];
  4113. $country = $this->country->read($value['country']);
  4114. $info_list[$key]['country'] = $country['name'];
  4115. $express = $this->express->read($value['express']);
  4116. $info_list[$key]['express'] = $express['servicename'];
  4117. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  4118. $fpdata = array();
  4119. if(stripos($value['fpdata'],';') !== false)
  4120. {
  4121. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  4122. foreach ($fpdata as $ke=>$va)
  4123. {
  4124. $v = explode('|',rtrim($va,'|'));
  4125. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  4126. }
  4127. }
  4128. $info_list[$key]['fpdata'] = $fpdata;
  4129. $i++;
  4130. }
  4131. $data = array($shouldmoney.' CNY');
  4132. $title = "订单信息表";
  4133. $titlename = "<table border=1>
  4134. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  4135. <tr>
  4136. <td>NO.</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>运单号</td>
  4155. <td>订单备注</td>
  4156. <td>客户备注</td>
  4157. <td>
  4158. <table border=1>
  4159. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4160. <tr>
  4161. <td>产品</td>
  4162. <td>条数</td>
  4163. <td>数量</td>
  4164. </tr>
  4165. </table>
  4166. </td>
  4167. <td>总条数</td>
  4168. </tr>
  4169. </table>";
  4170. $filename = $title.".xls";
  4171. $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";
  4172. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4173. }
  4174. }
  4175. public function _black()
  4176. {
  4177. $post = $this->input->post(NULL, TRUE);
  4178. if(isset($post['bd']))
  4179. {
  4180. $bd = $this->input->post('bd',true);
  4181. $rows = $this->fullordertt->read($bd);
  4182. $post['shop'] = $rows['shop'];
  4183. $post['source'] = 1;
  4184. $post['name'] = $rows['client'];
  4185. $post['email'] = $rows['email'];
  4186. $post['phone'] = $rows['phone'];
  4187. $post['country'] = $rows['country'];
  4188. $post['money'] = $rows['shouldmoney'];
  4189. $post['num'] = 1;
  4190. $post['time'] = $rows['dtime'];
  4191. $post['province'] = $rows['province'];
  4192. $post['city'] = $rows['city'];
  4193. $post['street'] = $rows['street'];
  4194. $post['address'] = $rows['address'];
  4195. $post['address2'] = $rows['address2'];
  4196. $post['zipcode'] = $rows['zipcode'];
  4197. $post['type'] = 2;
  4198. if($this->customertt->insert($post))
  4199. {
  4200. $this->fullordertt->save(array('black'=>1),$bd);
  4201. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4202. }
  4203. else
  4204. {
  4205. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4206. }
  4207. }
  4208. }
  4209. public function _ryf()
  4210. {
  4211. $post = $this->input->post(NULL, TRUE);
  4212. if(isset($post['bd']))
  4213. {
  4214. $bd = $this->input->post('bd',true);
  4215. $d = $this->fullordertt->read($bd);
  4216. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  4217. {
  4218. if($d['print'] < 3)//打印状态为未打印
  4219. {
  4220. $print = 1;//未打印
  4221. $libraryconfirm = 1;//不允许出库
  4222. $a = "订单未打印,";
  4223. }
  4224. else//已打印订单
  4225. {
  4226. $libraryconfirm = 2;//允许出库
  4227. $a = "";
  4228. }
  4229. if($this->fullordertt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4230. {
  4231. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4232. }
  4233. else
  4234. {
  4235. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4236. }
  4237. }
  4238. if($this->fullordertt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4239. {
  4240. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  4241. }
  4242. else
  4243. {
  4244. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4245. }
  4246. }
  4247. }
  4248. public function _fsstate()
  4249. {
  4250. $post = $this->input->post(NULL, TRUE);
  4251. if(isset($post['s']))
  4252. {
  4253. $id_arr = $this->input->post('s');
  4254. $id_arr = explode(',',$id_arr);
  4255. if(!$id_arr)
  4256. {
  4257. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4258. }
  4259. foreach ($id_arr as $v)
  4260. {
  4261. $data = $this->fullordertt->read($v);
  4262. $warehouse = $this->warehouse->read($data['type']);
  4263. $fs = $this->notice->get_ordertatus($data['state']);
  4264. if($fs)
  4265. {
  4266. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  4267. if($ck == 1)
  4268. {
  4269. $this->fullordertt->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  4270. }
  4271. }
  4272. }
  4273. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  4274. }
  4275. }
  4276. public function _power()
  4277. {
  4278. $user = $this->user->get_api($_SESSION['api']);
  4279. $post = $this->input->post(NULL, TRUE);
  4280. if(isset($post['id']))
  4281. {
  4282. $id = $this->input->post('id',true);
  4283. $fullordertt = $this->fullordertt->read($id);
  4284. $express = $this->express->read($fullordertt['express']);
  4285. $warehouse = $this->warehouse->read($fullordertt['type']);
  4286. if(($warehouse['zd'] == '1' || stripos($fullordertt['whlabel'],'z|') !== false) && $fullordertt['library'] == '2')
  4287. {
  4288. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  4289. }
  4290. /**
  4291. if($fullordertt['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  4292. {
  4293. $lj = $this->ali->get_lj($fullordertt['number'],2,'订单修改');
  4294. if($lj != '1' && $lj != '订单不存在')
  4295. {
  4296. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  4297. }
  4298. }
  4299. **/
  4300. $warehouse = $this->warehouse->read($fullordertt['warehouse']);
  4301. $typeclass = $this->typeclass->read($fullordertt['state']);
  4302. $express = $this->express->read($fullordertt['express']);
  4303. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  4304. $teset['number']=$fullordertt['number'];
  4305. $teset['orderinfo']=$fullordertt['orderinfo'];
  4306. $teset['shop']=$fullordertt['shop'];
  4307. $teset['user']=$user['userid'];
  4308. $teset['ip']=$this->input->ip_address();
  4309. $teset['time']=time();
  4310. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  4311. $teset['state']=(isset($typeclass['title']))?$typeclass['spare']:'未选择';
  4312. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  4313. $teset['printtype']=(isset($printtype[$fullordertt['printtype']]))?$printtype[$fullordertt['printtype']]:'未选择';
  4314. $teset['reviewtime']=($fullordertt['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullordertt['reviewtime']):'无';
  4315. $teset['printtime']=($fullordertt['printtime'] > '0')?date('Y-m-d H:i:s',$fullordertt['printtime']):'无';
  4316. $teset['librarytime']=($fullordertt['librarytime'] > '0')?date('Y-m-d H:i:s',$fullordertt['librarytime']):'无';
  4317. $teset['shipremarks']=$fullordertt['shipremarks'];
  4318. $teset['fpdata']=$fullordertt['fpdata'];
  4319. $teset['oldwaybill']=$fullordertt['oldwaybill'];
  4320. $teset['oldprinttime']=$fullordertt['oldprinttime'];
  4321. if($fullordertt['printtype'] == 1)
  4322. {
  4323. if($fullordertt['waybill'] != '' && stripos($fullordertt['oldwaybill'],$fullordertt['waybill']) === false)
  4324. {
  4325. $teset['oldwaybill'] .= '-'.date('Ymd',$fullordertt['printtime']).'/'.$fullordertt['waybill'];
  4326. $teset['oldprinttime'] .= '-'.$fullordertt['printtime'];
  4327. }
  4328. }
  4329. $review = ($fullordertt['source']==1)?2:1;//线下单审核状态直接为待审核
  4330. if(!$this->fullreset->insert($teset))
  4331. {
  4332. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  4333. }
  4334. 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))
  4335. {
  4336. $th_info = $this->retreatlogs->getInfoByNumber($fullordertt['number']);
  4337. if(!empty($th_info)){
  4338. $this->retreatlogs->save(array('cz_time'=>time()),$th_info['id']);
  4339. }
  4340. echo json_encode(array('msg'=>'重置成功!如需再次提交,请先保存、再提交','success'=>true));exit;
  4341. }
  4342. else
  4343. {
  4344. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  4345. }
  4346. }
  4347. }
  4348. public function _expresstype()
  4349. {
  4350. $post = $this->input->post(NULL, TRUE);
  4351. if(isset($post['id']))
  4352. {
  4353. $id = $this->input->post('id',true);
  4354. $data = $this->express->read($id);
  4355. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  4356. }
  4357. }
  4358. public function _email($content,$data,$shopname)
  4359. {
  4360. $express = $this->express->read($data['express']);
  4361. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  4362. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  4363. $content = str_replace($t,$h,$content);
  4364. $this->load->library('email');
  4365. $config['protocol'] = 'smtp';
  4366. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  4367. $config['smtp_port'] = 465;
  4368. $config['smtp_user'] = 'service@email.supernovahair.com';
  4369. $config['smtp_pass'] = 'LONGyihair374';
  4370. $config['smtp_crypto'] = 'ssl';
  4371. $config['crlf'] = "\r\n";
  4372. $config['newline'] = "\r\n";
  4373. $this->email->initialize($config);
  4374. $this->email->from('service@email.supernovahair.com',$shopname);
  4375. $this->email->to($data['email']);//收件
  4376. $this->email->subject('The product you purchased has a new progress');//标题
  4377. $this->email->message($content);//内容
  4378. if ( ! $this->email->send())
  4379. {
  4380. return 2;
  4381. }
  4382. else
  4383. {
  4384. return 1;
  4385. }
  4386. }
  4387. public function _error()
  4388. {
  4389. if(isset($_SESSION['api']))
  4390. {
  4391. $user = $this->user->get_api($_SESSION['api']);
  4392. $usp = $user;
  4393. $fgshop = "";$sid = "";
  4394. $user = explode('|',trim($user['shop'],'|'));
  4395. foreach ($user as $value)
  4396. {
  4397. $fgshop .= " shop = ".$value." or";
  4398. $sid .= " id = ".$value." or";
  4399. }
  4400. }
  4401. $post = $this->input->post(NULL, TRUE);
  4402. if(isset($post['page']))
  4403. {
  4404. $page = $this->input->post('page',true);
  4405. $perpage = $this->input->post('perpage',true);
  4406. $orderinfo = $this->input->post('orderinfo',true);
  4407. $waybill = $this->input->post('waybill',true);
  4408. $number = $this->input->post('number',true);
  4409. $timetk = $this->input->post('timetk',true);
  4410. $timetj = $this->input->post('timetj',true);
  4411. $timetk = strtotime($timetk);
  4412. $timetj = strtotime($timetj);
  4413. $where = "failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').")";
  4414. if($orderinfo)
  4415. {
  4416. $where .= " and orderinfo = '$orderinfo'";
  4417. }
  4418. if($waybill)
  4419. {
  4420. $where .= " and waybill = '$waybill'";
  4421. }
  4422. if($number)
  4423. {
  4424. $where .= " and number = '$number'";
  4425. }
  4426. if($timetk && $timetj)
  4427. {
  4428. $timetj = $timetj+24*3600;
  4429. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4430. }
  4431. //数据排序
  4432. $order_str = "dtime desc";
  4433. if(empty($page))
  4434. {
  4435. $start = 0;
  4436. $perpage = 1;
  4437. }
  4438. else
  4439. {
  4440. $start = ($page - 1)*$perpage;
  4441. }
  4442. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  4443. //格式化数据
  4444. foreach ($info_list as $key=>$value)
  4445. {
  4446. $ud = $this->fullordertt->read($value['id']);
  4447. $shop = $this->shop->read($value['shop']);
  4448. $info_list[$key]['shop'] = $shop['shopname'];
  4449. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4450. $warehouse = $this->warehouse->read($value['type']);
  4451. $warehousetitle = $warehouse['title'];
  4452. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4453. $info_list[$key]['type'] = $warehousetitle;
  4454. if($value['express'] != 0)
  4455. {
  4456. $express = $this->express->read($value['express']);
  4457. $expressservicename = $express['servicename'];
  4458. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4459. $info_list[$key]['express'] = $expressservicename;
  4460. }
  4461. else
  4462. {
  4463. $info_list[$key]['express'] = "无";
  4464. }
  4465. $x = "";
  4466. if($ud['review'] >4 && $ud['print'] == 1)
  4467. {
  4468. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  4469. }
  4470. else
  4471. {
  4472. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  4473. }
  4474. $info_list[$key]['operation'] = $x;
  4475. }
  4476. $total = $this->fullordertt->find_count($where);
  4477. $pagenum = ceil($total/$perpage);
  4478. $over = $total-($start+$perpage);
  4479. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4480. echo json_encode($rows);exit;
  4481. }
  4482. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4483. $this->data['wlshop'] = $wlshop;
  4484. $this->data['express'] = $this->express->find_all();
  4485. $user = $this->user->get_api($_SESSION['api']);
  4486. $powerid = $this->power->read($user['power']);
  4487. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4488. $pid = '';
  4489. foreach ($powertext as $v)
  4490. {
  4491. $pid .= " id = ".$v." or";
  4492. }
  4493. $fullorderexcel = $this->fullorderexcel->find_all("type = '100006' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4494. $this->data['fullorderexcel'] = $fullorderexcel;
  4495. $this->_Template('fullordertt_error',$this->data);
  4496. }
  4497. public function _yc()
  4498. {
  4499. if(isset($_SESSION['api']))
  4500. {
  4501. $user = $this->user->get_api($_SESSION['api']);
  4502. $usp = $user;
  4503. $fgshop = "";$sid = "";
  4504. $user = explode('|',trim($user['shop'],'|'));
  4505. foreach ($user as $value)
  4506. {
  4507. $fgshop .= " shop = ".$value." or";
  4508. $sid .= " id = ".$value." or";
  4509. }
  4510. }
  4511. $post = $this->input->post(NULL, TRUE);
  4512. if(isset($post['page']))
  4513. {
  4514. $page = $this->input->post('page',true);
  4515. $perpage = $this->input->post('perpage',true);
  4516. $orderinfo = $this->input->post('orderinfo',true);
  4517. $waybill = $this->input->post('waybill',true);
  4518. $number = $this->input->post('number',true);
  4519. $timetk = $this->input->post('timetk',true);
  4520. $timetj = $this->input->post('timetj',true);
  4521. $timetk = strtotime($timetk);
  4522. $timetj = strtotime($timetj);
  4523. $where = "library = 2 and state = 214 and (".rtrim($fgshop,'or').")";
  4524. if($orderinfo)
  4525. {
  4526. $where .= " and orderinfo = '$orderinfo'";
  4527. }
  4528. if($waybill)
  4529. {
  4530. $where .= " and waybill = '$waybill'";
  4531. }
  4532. if($number)
  4533. {
  4534. $where .= " and number = '$number'";
  4535. }
  4536. if($timetk && $timetj)
  4537. {
  4538. $timetj = $timetj+24*3600;
  4539. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4540. }
  4541. //数据排序
  4542. $order_str = "dtime desc";
  4543. if(empty($page))
  4544. {
  4545. $start = 0;
  4546. $perpage = 1;
  4547. }
  4548. else
  4549. {
  4550. $start = ($page - 1)*$perpage;
  4551. }
  4552. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,state,dtime,express,waybill,library,operation',$order_str,$start,$perpage);
  4553. //格式化数据
  4554. foreach ($info_list as $key=>$value)
  4555. {
  4556. $ud = $this->fullordertt->read($value['id']);
  4557. $shop = $this->shop->read($value['shop']);
  4558. $info_list[$key]['shop'] = $shop['shopname'];
  4559. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4560. $warehouse = $this->warehouse->read($value['type']);
  4561. $warehousetitle = $warehouse['title'];
  4562. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4563. $info_list[$key]['type'] = $warehousetitle;
  4564. if($value['express'] != 0)
  4565. {
  4566. $express = $this->express->read($value['express']);
  4567. $expressservicename = $express['servicename'];
  4568. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4569. $info_list[$key]['express'] = $expressservicename;
  4570. }
  4571. else
  4572. {
  4573. $info_list[$key]['express'] = "无";
  4574. }
  4575. $typeclass = $this->typeclass->read($value['state']);
  4576. $info_list[$key]['state'] = "<font style='font-size: 13px;'>".$typeclass['spare']."</font>";
  4577. $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>';
  4578. if($value['library'] == 1 && $ud['printtype'] == 3)
  4579. {
  4580. $info_list[$key]['library'] = "不需要";
  4581. }
  4582. else if($value['library'] == 1 && $ud['printtype'] != 3)
  4583. {
  4584. $info_list[$key]['library'] = "未出库";
  4585. }
  4586. else if($value['library'] == 2)
  4587. {
  4588. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  4589. }
  4590. else if($value['library'] == 3)
  4591. {
  4592. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  4593. }
  4594. $info_list[$key]['operation'] = "<p class='ckn'><b class='ycyc' data-id='".$value['id']."'>移 出</b></p>";
  4595. }
  4596. $total = $this->fullordertt->find_count($where);
  4597. $pagenum = ceil($total/$perpage);
  4598. $over = $total-($start+$perpage);
  4599. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4600. echo json_encode($rows);exit;
  4601. }
  4602. if(isset($post['id']))
  4603. {
  4604. $id = $this->input->post('id',true);
  4605. $data = $this->fullordertt->read($id);
  4606. if($this->fullordertt->save(array('state'=>217),$id))
  4607. {
  4608. echo json_encode(array('msg'=>'移除成功','id'=>$id,'success'=>true));exit;
  4609. }
  4610. else
  4611. {
  4612. echo json_encode(array('msg'=>"操作失败请重试",'success'=>false));exit;
  4613. }
  4614. }
  4615. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4616. $this->data['wlshop'] = $wlshop;
  4617. $this->data['express'] = $this->express->find_all();
  4618. $user = $this->user->get_api($_SESSION['api']);
  4619. $powerid = $this->power->read($user['power']);
  4620. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4621. $pid = '';
  4622. foreach ($powertext as $v)
  4623. {
  4624. $pid .= " id = ".$v." or";
  4625. }
  4626. $fullorderexcel = $this->fullorderexcel->find_all("type = '100006' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4627. $this->data['fullorderexcel'] = $fullorderexcel;
  4628. $this->_Template('fullordertt_yc',$this->data);
  4629. }
  4630. //导出异常取消列表
  4631. public function _ycexcel(){
  4632. if(isset($_SESSION['api']))
  4633. {
  4634. $user = $this->user->get_api($_SESSION['api']);
  4635. $usp = $user;
  4636. $fgshop = "";$sid = "";
  4637. $user = explode('|',trim($user['shop'],'|'));
  4638. foreach ($user as $value)
  4639. {
  4640. $fgshop .= " shop = ".$value." or";
  4641. $sid .= " id = ".$value." or";
  4642. }
  4643. }
  4644. $query = $this->input->get(NULL, TRUE);
  4645. if(empty($query['is_excel'])){
  4646. exit;
  4647. }
  4648. $where = "library = 2 and state = 214 and (".rtrim($fgshop,'or').")";
  4649. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,state,dtime,express,waybill,library,operation,librarytime,retreattime,printtype');
  4650. $shop_list = $this->shop->find_all('id > 0');
  4651. $shop_list = array_column($shop_list,'shopname','id');
  4652. $warehouse_list = $this->warehouse->find_all('id > 0');
  4653. $warehouse_list = array_column($warehouse_list,'title','id');
  4654. $express_list = $this->express->find_all('id > 0');
  4655. $express_list = array_column($express_list,'servicename','id');
  4656. $typeclass_list = $this->typeclass->find_all('classid = 29');
  4657. $typeclass_list = array_column($typeclass_list,'spare','classid');
  4658. //格式化数据
  4659. foreach ($info_list as $key=>$value)
  4660. {
  4661. $ud = $this->fullordertt->read($value['id']);
  4662. $info_list[$key]['shop'] = isset($shop_list[$value['shop']])? $shop_list[$value['shop']] : '';
  4663. $info_list[$key]['type'] = isset($warehouse_list[$value['type']])? $warehouse_list[$value['type']] : '';
  4664. if($value['express'] != 0)
  4665. {
  4666. $info_list[$key]['express'] = isset($express_list[$value['express']])? $express_list[$value['express']] : '';
  4667. }
  4668. else
  4669. {
  4670. $info_list[$key]['express'] = "无";
  4671. }
  4672. $info_list[$key]['state'] = isset($typeclass_list[$value['state']])? $typeclass_list[$value['state']] : '';
  4673. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$ud['dtime']);
  4674. if($value['library'] == 1 && $ud['printtype'] == 3)
  4675. {
  4676. $info_list[$key]['library'] = "不需要";
  4677. }
  4678. else if($value['library'] == 1 && $ud['printtype'] != 3)
  4679. {
  4680. $info_list[$key]['library'] = "未出库";
  4681. }
  4682. else if($value['library'] == 2)
  4683. {
  4684. $info_list[$key]['library'] = date('Y-m-d H:i:s',$value['librarytime'])." 出库";
  4685. }
  4686. else if($value['library'] == 3)
  4687. {
  4688. $info_list[$key]['library'] = date('Y-m-d H:i:s',$value['retreattime'])." 退库";
  4689. }
  4690. }
  4691. //生成excel
  4692. $filename = 'tiktok异常取消导出-'.date('Ymd',time()).".xlsx";
  4693. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4694. <head>
  4695. <!--[if gte mso 9]><xml>
  4696. <x:ExcelWorkbook>
  4697. <x:ExcelWorksheets>
  4698. <x:ExcelWorksheet>
  4699. <x:Name>EXCEL</x:Name>
  4700. <x:WorksheetOptions>
  4701. <x:Print>
  4702. <x:ValidPrinterInfo />
  4703. </x:Print>
  4704. </x:WorksheetOptions>
  4705. </x:ExcelWorksheet>
  4706. </x:ExcelWorksheets>
  4707. </x:ExcelWorkbook>
  4708. </xml>
  4709. <![endif]-->
  4710. </head><body>";
  4711. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4712. $str .= "<tr><td>店铺名称</td><td>发货仓库</td><td>订单号</td><td>编号</td><td>订单状态</td><td>订单时间</td><td>物流方式</td><td>运单号</td><td>发货状态</td></tr>";
  4713. foreach ($info_list as $key=>$v)
  4714. {
  4715. $str .= "<tr>";
  4716. $str .= "<td>". $v['shop']. "</td>";
  4717. $str .= "<td>". $v['type']. "</td>";
  4718. $str .= "<td>`". $v['orderinfo']. "</td>";
  4719. $str .= "<td>". $v['number']. "</td>";
  4720. $str .= "<td>". $v['state']. "</td>";
  4721. $str .= "<td>". $v['dtime']. "</td>";
  4722. $str .= "<td>". $v['express']. "</td>";
  4723. $str .= "<td>`". $v['waybill']. "</td>";
  4724. $str .= "<td>". $v['library']. "</td>";
  4725. $str .= "</tr>";
  4726. }
  4727. $str .= "</table></body></html>";
  4728. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4729. header( "Content-type: application/octet-stream" );
  4730. header( "Content-Disposition: attachment; filename=".$filename );
  4731. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4732. header( "Pragma: no-cache" );
  4733. header( "Expires: 0" );
  4734. exit($str);
  4735. }
  4736. //验证地址
  4737. public function _yzaddress()
  4738. {
  4739. $post = $this->input->post(NULL, TRUE);
  4740. if(isset($post['address']))
  4741. {
  4742. $address = $this->input->post('address',true);
  4743. $address2 = $this->input->post('address2',true);
  4744. $city = $this->input->post('city',true);
  4745. $province = $this->input->post('province',true);
  4746. $zipcode = $this->input->post('zipcode',true);
  4747. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  4748. echo $barcode;
  4749. }
  4750. }
  4751. //清除退货信息
  4752. public function _clearreturn()
  4753. {
  4754. $post = $this->input->post(NULL, TRUE);
  4755. if(isset($post['orderinfo']))
  4756. {
  4757. $orderinfo = $this->input->post('orderinfo',true);
  4758. $data = $this->fullordertt->get_orderinfo($orderinfo);
  4759. $fu = 'fullordertt';
  4760. if(!$data)
  4761. {
  4762. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4763. $fu = 'fullorder_smt';
  4764. }
  4765. $this->$fu->save(array('library'=>'2','retreattime'=>'0','returndata'=>''),$data['id']);
  4766. echo json_encode(array('msg'=>'清除成功!','success'=>true));exit;
  4767. }
  4768. }
  4769. //订单退货
  4770. public function _return()
  4771. {
  4772. $post = $this->input->post(NULL, TRUE);
  4773. if(isset($post['orderinfo']))
  4774. {
  4775. $orderinfo = $this->input->post('orderinfo',true);
  4776. $data = $this->fullordertt->get_orderinfo($orderinfo);
  4777. $fu = 'fullordertt';
  4778. if(!$data)
  4779. {
  4780. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4781. $fu = 'fullorder_smt';
  4782. }
  4783. if($data['library'] != 2){
  4784. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  4785. }
  4786. $bctime = date('Ymd',time());
  4787. if($data['returndata'] != "")
  4788. {
  4789. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4790. }
  4791. $barcode = $this->usps->get_return($data);
  4792. // if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4793. // {
  4794. // echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4795. // }
  4796. // else if(isset($barcode['TrackingNumber']))
  4797. // {
  4798. // $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  4799. // $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  4800. // $this->$fu->save(array('returndata'=>$read),$data['id']);
  4801. // echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4802. // }
  4803. // else
  4804. // {
  4805. // echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4806. // }
  4807. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4808. {
  4809. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4810. }
  4811. else if(isset($barcode['trackingNumber']))
  4812. {
  4813. $pdf = $this->_pdf($barcode['returnLabelImage'],'t-'.$barcode['trackingNumber'],$bctime);
  4814. $read = 'PostalRouting:'.$barcode['routingInformation'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['trackingNumber'].'.pdf" target="_blank">'.$barcode['trackingNumber'].'</a>';
  4815. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4816. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4817. }
  4818. else
  4819. {
  4820. echo json_encode(array('msg'=>'请求失败,请稍后重试!'.json_encode($barcode),'cs'=>$barcode,'success'=>false));exit;
  4821. }
  4822. }
  4823. }
  4824. public function _pdf($pdf,$title,$bctime)
  4825. {
  4826. $pdf_path = './data/pdf/'.$bctime.'/';
  4827. $file_base64 = $pdf;
  4828. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4829. $file_base64 = base64_decode($file_base64);
  4830. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  4831. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  4832. return $bctime;
  4833. }
  4834. public function _find($find)
  4835. {
  4836. preg_match_all('/\d+/',$find,$n);
  4837. $a = '';
  4838. foreach($n[0] as $v)
  4839. {
  4840. $a .= $v;
  4841. }
  4842. return $a;
  4843. }
  4844. public function _dqpm()
  4845. {
  4846. if(isset($_SESSION['api']))
  4847. {
  4848. $user = $this->user->get_api($_SESSION['api']);
  4849. $usp = $user;
  4850. $fgshop = "";$sid = "";
  4851. $usersp = explode('|',trim($user['shop'],'|'));
  4852. foreach ($usersp as $value)
  4853. {
  4854. $fgshop .= " shop = ".$value." or";
  4855. $sid .= " id = ".$value." or";
  4856. }
  4857. }
  4858. $post = $this->input->post(NULL, TRUE);
  4859. if(isset($post['page']))
  4860. {
  4861. $timetk = $this->input->post('timetk',true);
  4862. $timetj = $this->input->post('timetj',true);
  4863. $timetk = strtotime($timetk);
  4864. $timetj = strtotime($timetj);
  4865. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  4866. if($timetk && $timetj)
  4867. {
  4868. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4869. }
  4870. //数据排序
  4871. $order_str = "dtime desc";
  4872. if(empty($page))
  4873. {
  4874. $start = 0;
  4875. $perpage = 1;
  4876. }
  4877. else
  4878. {
  4879. $start = ($page - 1)*$perpage;
  4880. }
  4881. $continentdata = '';
  4882. $continent = array();//陆地板块
  4883. $num = $this->fullordertt->find_count($where);//订单总数量
  4884. $country = $this->country->find_all('1=1','id,continent,ename,zname');
  4885. foreach ($country as $k=>$v)
  4886. {
  4887. $tc = $this->typeclass->read($v['continent']);
  4888. $continent[$v['continent']] = array(0=>$tc['title'],1=>0,2=>'');
  4889. }
  4890. foreach ($country as $k=>$v)
  4891. {
  4892. $n = $this->fullordertt->find_count($where.' and country = "'.$v['id'].'"');
  4893. $country[$k]['continent'] = $continent[$v['continent']][0];//此国家数量
  4894. $country[$k]['zname'] = '<a href="/fullordertt/dqpmprovince/'.$v['id'].'/'.$timetk.'/'.$timetj.'">'.$v['zname'].'</a>';//此国家数量
  4895. $country[$k]['num'] = $n;//此国家数量
  4896. $country[$k]['zb'] = (sprintf("%.4f",$n/$num)*100).'%';//此国家占比
  4897. $continent[$v['continent']]['1'] += $n;//此洲数量增加;
  4898. }
  4899. array_multisort(array_column($continent, '1'), SORT_DESC, $continent);
  4900. array_multisort(array_column($country, 'num'), SORT_DESC, $country);
  4901. foreach ($continent as $k=>$v)
  4902. {
  4903. $continentdata .= $v['0'].' 总量:'.$v['1'].' 占比:'.(sprintf("%.4f",$v['1']/$num)*100).'%&nbsp;&nbsp; - &nbsp;&nbsp;';
  4904. }
  4905. echo json_encode(array('ewnr'=>$continentdata,'rows'=>$country,'total'=>count($country),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4906. }
  4907. $this->_Template('fullordertt_dqpm',$this->data);
  4908. }
  4909. public function _dqpmprovince($arg_array)
  4910. {
  4911. if(isset($_SESSION['api']))
  4912. {
  4913. $user = $this->user->get_api($_SESSION['api']);
  4914. $usp = $user;
  4915. $fgshop = "";$sid = "";
  4916. $usersp = explode('|',trim($user['shop'],'|'));
  4917. foreach ($usersp as $value)
  4918. {
  4919. $fgshop .= " shop = ".$value." or";
  4920. $sid .= " id = ".$value." or";
  4921. }
  4922. }
  4923. $post = $this->input->post(NULL, TRUE);
  4924. if(isset($post['page']))
  4925. {
  4926. $country = $this->input->post('country',true);
  4927. $timetk = $this->input->post('timetk',true);
  4928. $timetj = $this->input->post('timetj',true);
  4929. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4930. $province = array();
  4931. $city_list = $this->fullordertt->find_all($where,'id,province');
  4932. $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');
  4933. foreach ($city_list as $k=>$v)
  4934. {
  4935. $v['province'] = strtoupper(trim($v['province'],' '));
  4936. if(isset($ToState[$v['province']]))
  4937. {
  4938. $v['province'] = $ToState[$v['province']];
  4939. }
  4940. if(!isset($province[$v['province']]))
  4941. {
  4942. $province[$v['province']] = array('id'=>$v['id'],'province'=>'<a href="/fullordertt/ddpmdata/'.$country.'/'.$timetk.'/'.$timetj.'/'.strtoupper($v['province']).'">'.$v['province'].'</a>','num'=>0,'zb'=>'');
  4943. }
  4944. $province[$v['province']]['num'] += 1;
  4945. }
  4946. array_multisort(array_column($province, 'num'), SORT_DESC, $province);
  4947. $province = array_values($province);
  4948. foreach ($province as $k=>$v)
  4949. {
  4950. $province[$k]['zb'] = (sprintf("%.4f",$v['num']/count($city_list))*100).'%';
  4951. }
  4952. echo json_encode(array('rows'=>($province),'total'=>count($province),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4953. }
  4954. $this->data['arg_array'] = $arg_array;
  4955. $this->_Template('fullordertt_dqpmprovince',$this->data);
  4956. }
  4957. public function _ddpmdata($arg_array)
  4958. {
  4959. $arg_array[3] = str_replace('%20',' ',$arg_array[3]);
  4960. if(isset($_SESSION['api']))
  4961. {
  4962. $user = $this->user->get_api($_SESSION['api']);
  4963. $usp = $user;
  4964. $fgshop = "";$sid = "";
  4965. $usersp = explode('|',trim($user['shop'],'|'));
  4966. foreach ($usersp as $value)
  4967. {
  4968. $fgshop .= " shop = ".$value." or";
  4969. $sid .= " id = ".$value." or";
  4970. }
  4971. }
  4972. $post = $this->input->post(NULL, TRUE);
  4973. if(isset($post['page']))
  4974. {
  4975. $page = $this->input->post('page',true);
  4976. $perpage = $this->input->post('perpage',true);
  4977. $province = $this->input->post('province',true);
  4978. $timetk = $this->input->post('timetk',true);;
  4979. $timetj = $this->input->post('timetj',true);;
  4980. $country = $this->input->post('country',true);;
  4981. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4982. if($province)
  4983. {
  4984. $where .= " and province = '$province'";
  4985. }
  4986. $order_str = "dtime desc";
  4987. if(empty($page))
  4988. {
  4989. $start = 0;
  4990. $perpage = 1;
  4991. }
  4992. else
  4993. {
  4994. $start = ($page - 1)*$perpage;
  4995. }
  4996. $info_list = $this->fullordertt->find_all($where,'id,orderinfo,number,shipremarks,shouldmoney',$order_str,$start,$perpage);
  4997. $total = $this->fullordertt->find_count($where);
  4998. $pagenum = ceil($total/$perpage);
  4999. $over = $total-($start+$perpage);
  5000. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5001. echo json_encode($rows);exit;
  5002. }
  5003. $province = array();
  5004. $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');
  5005. $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');
  5006. foreach ($city_list as $k=>$v)
  5007. {
  5008. $v['province'] = strtoupper(trim($v['province'],' '));
  5009. if(isset($ToState[$v['province']]))
  5010. {
  5011. $v['province'] = $ToState[$v['province']];
  5012. }
  5013. $province[$v['province']] = array('province'=>$v['province']);
  5014. }
  5015. $this->data['province'] = $province;
  5016. $this->data['arg_array'] = $arg_array;
  5017. $this->_Template('fullordertt_ddpmdata',$this->data);
  5018. }
  5019. public function _ddpmexcel($arg_array)
  5020. {
  5021. if(isset($_SESSION['api']))
  5022. {
  5023. $user = $this->user->get_api($_SESSION['api']);
  5024. $usp = $user;
  5025. $fgshop = "";$sid = "";
  5026. $usersp = explode('|',trim($user['shop'],'|'));
  5027. foreach ($usersp as $value)
  5028. {
  5029. $fgshop .= " shop = ".$value." or";
  5030. $sid .= " id = ".$value." or";
  5031. }
  5032. }
  5033. $province = $this->input->get('province',true);
  5034. $timetk = $arg_array[1];
  5035. $timetj = $arg_array[2];
  5036. $country = $arg_array[0];
  5037. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  5038. if($province)
  5039. {
  5040. $where .= " and province = '$province'";
  5041. }
  5042. $order_str = "dtime desc";
  5043. $info_list = $this->fullordertt->find_all($where,'orderinfo,number,shipremarks,shouldmoney',$order_str);
  5044. $country = $this->country->read($arg_array[0]);
  5045. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5046. $titlename = "<table border=1>
  5047. <tr><th colspan='4' align='left'><h3>".$title."<h3></th></tr>
  5048. <tr>
  5049. <td>订单号</td>
  5050. <td>订单编号</td>
  5051. <td>仓库品名</td>
  5052. <td>订单金额</td>
  5053. </tr>
  5054. </table>";
  5055. $filename = $title.".xls";
  5056. $tail = "\n";
  5057. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5058. }
  5059. public function _statedc()
  5060. {
  5061. $user = $this->user->get_api($_SESSION['api']);
  5062. if($user)
  5063. {
  5064. $fgshop = "";$sid = "";
  5065. $user = explode('|',trim($user['shop'],'|'));
  5066. foreach ($user as $value)
  5067. {
  5068. $fgshop .= " shop = ".$value." or";
  5069. $sid .= " id = ".$value." or";
  5070. }
  5071. }
  5072. $post = $this->input->get(NULL, TRUE);
  5073. if(isset($post['timetk']))
  5074. {
  5075. $page = $this->input->get('page',true);
  5076. $perpage = $this->input->get('perpage',true);
  5077. $timetk = $this->input->get('timetk',true);
  5078. $timetj = $this->input->get('timetj',true);
  5079. $shop = $this->input->get('shop',true);
  5080. $source = $this->input->get('source',true);
  5081. $state = $this->input->get('state',true);
  5082. $review = $this->input->get('review',true);
  5083. $express = $this->input->get('express',true);
  5084. $fs = $this->input->get('fs',true);
  5085. $orderinfo = $this->input->get('orderinfo',true);
  5086. $number = $this->input->get('number',true);
  5087. $user = $this->input->get('user',true);
  5088. $name = $this->input->get('name',true);
  5089. $waybill = $this->input->get('waybill',true);
  5090. $expressstate = $this->input->get('expressstate',true);
  5091. $wltype = $this->input->get('wltype',true);
  5092. $wlyc = $this->input->get('wlyc',true);
  5093. $xztime = $this->input->get('xztime',true);
  5094. $timetk = strtotime($timetk);
  5095. $timetj = strtotime($timetj);
  5096. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5097. if($timetk && $timetj)
  5098. {
  5099. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5100. }
  5101. if($xztime == 'librarytime')
  5102. {
  5103. $order_str = "librarytime desc";
  5104. }
  5105. else if($xztime == 'dtime')
  5106. {
  5107. $order_str = "dtime desc";
  5108. }
  5109. if($shop)
  5110. {
  5111. $where .= " and shop = '$shop'";
  5112. }
  5113. if($source)
  5114. {
  5115. if($source == 11)
  5116. {
  5117. $where .= " and source != '1'";
  5118. }
  5119. else
  5120. {
  5121. $where .= " and source = '$source'";
  5122. }
  5123. }
  5124. if($fs)
  5125. {
  5126. if($fs == '2')
  5127. {
  5128. $where .= " and exstateerror != ''";
  5129. }
  5130. else
  5131. {
  5132. $where .= " and exstateerror = ''";
  5133. }
  5134. }
  5135. if($state)
  5136. {
  5137. $where .= " and state = '$state'";
  5138. }
  5139. if($review)
  5140. {
  5141. $where .= " and review = '$review'";
  5142. }
  5143. if($expressstate != "")
  5144. {
  5145. $where .= " and expressstate = '$expressstate'";
  5146. }
  5147. if($wltype != "")
  5148. {
  5149. $where .= " and wltype = '$wltype'";
  5150. }
  5151. if($wlyc != "")
  5152. {
  5153. $where .= " and wlyc = '$wlyc'";
  5154. }
  5155. if($express)
  5156. {
  5157. $where .= " and express = '$express'";
  5158. }
  5159. if($orderinfo)
  5160. {
  5161. $where .= " and orderinfo = '$orderinfo'";
  5162. }
  5163. if($number)
  5164. {
  5165. $where .= " and number = '$number'";
  5166. }
  5167. if($user)
  5168. {
  5169. $where .= " and user = '$user'";
  5170. }
  5171. if($name)
  5172. {
  5173. $where .= " and name = '$name'";
  5174. }
  5175. if($waybill)
  5176. {
  5177. $where .= " and waybill = '$waybill'";
  5178. }
  5179. if(empty($page))
  5180. {
  5181. $start = 0;
  5182. $perpage = 1;
  5183. }
  5184. else
  5185. {
  5186. $start = ($page - 1)*$perpage;
  5187. }
  5188. //取得信息列表
  5189. $info_list = $this->fullordertt->find_all($where,'shop,number,country,library,librarytime,expressstate,express,waybill,content,exstateerror,excontent',$order_str);
  5190. //格式化数据
  5191. foreach ($info_list as $key=>$value)
  5192. {
  5193. $shop = $this->shop->read($value['shop']);
  5194. $info_list[$key]['shop'] = $shop['shopname'];
  5195. $country = $this->country->read($value['country']);
  5196. $info_list[$key]['country'] = $country['name'];
  5197. //$state = $this->typeclass->read($value['state']);
  5198. //$info_list[$key]['state'] = $state['title'];
  5199. if($value['library'] == 1)
  5200. {
  5201. $info_list[$key]['library'] = "未出库";
  5202. }
  5203. else if($value['library'] == 2)
  5204. {
  5205. $info_list[$key]['library'] = "已出库";
  5206. }
  5207. else if($value['library'] == 3)
  5208. {
  5209. $info_list[$key]['library'] = "已退库";
  5210. }
  5211. if($value['librarytime'] == '0')
  5212. {
  5213. $info_list[$key]['librarytime'] = '无';
  5214. }
  5215. else
  5216. {
  5217. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5218. }
  5219. if($value['expressstate'] == 0)
  5220. {
  5221. $info_list[$key]['expressstate'] = "无信息";
  5222. }
  5223. else if($value['expressstate'] == 2)
  5224. {
  5225. $info_list[$key]['expressstate'] = "已取件";
  5226. }
  5227. else if($value['expressstate'] == 3)
  5228. {
  5229. $info_list[$key]['expressstate'] = "在途中";
  5230. }
  5231. else if($value['expressstate'] == 4)
  5232. {
  5233. $info_list[$key]['expressstate'] = "到达目的地国";
  5234. }
  5235. else if($value['expressstate'] == 5)
  5236. {
  5237. $info_list[$key]['expressstate'] = "即将派送";
  5238. }
  5239. else if($value['expressstate'] == 6)
  5240. {
  5241. $info_list[$key]['expressstate'] = "已签收";
  5242. }
  5243. else if($value['expressstate'] == 1)
  5244. {
  5245. $info_list[$key]['expressstate'] = "派送异常";
  5246. }
  5247. $express = $this->express->read($value['express']);
  5248. $info_list[$key]['express'] = $express['servicename'];
  5249. }
  5250. }
  5251. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5252. $titlename = "<table border=1>
  5253. <tr>
  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. <td>消息状态</td>
  5263. <td>错误提示</td>
  5264. <td>物流信息</td>
  5265. </tr>
  5266. </table>";
  5267. $filename = $title.".xls";
  5268. $tail = "\n";
  5269. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5270. }
  5271. public function _statedcwl()
  5272. {
  5273. $user = $this->user->get_api($_SESSION['api']);
  5274. if($user)
  5275. {
  5276. $fgshop = "";$sid = "";
  5277. $user = explode('|',trim($user['shop'],'|'));
  5278. foreach ($user as $value)
  5279. {
  5280. $fgshop .= " shop = ".$value." or";
  5281. $sid .= " id = ".$value." or";
  5282. }
  5283. }
  5284. $post = $this->input->get(NULL, TRUE);
  5285. if(isset($post['timetk']))
  5286. {
  5287. $dowid = $this->input->get('a');
  5288. $wid = "";
  5289. if($dowid != "")
  5290. {
  5291. $id_arr = explode(',',rtrim($dowid,','));
  5292. $wid .= " id = 0 or";
  5293. foreach ($id_arr as $v)
  5294. {
  5295. $wid .= " id = '$v' or";
  5296. }
  5297. $wid = " and".rtrim($wid,'or');
  5298. }
  5299. $page = $this->input->get('page',true);
  5300. $perpage = $this->input->get('perpage',true);
  5301. $timetk = $this->input->get('timetk',true);
  5302. $timetj = $this->input->get('timetj',true);
  5303. $shop = $this->input->get('shop',true);
  5304. $expressstate = $this->input->get('expressstate',true);
  5305. $fs = $this->input->get('fs',true);
  5306. $state = $this->input->get('state',true);
  5307. $express = $this->input->get('express',true);
  5308. $orderinfo = $this->input->get('orderinfo',true);
  5309. $number = $this->input->get('number',true);
  5310. $waybill = $this->input->get('waybill',true);
  5311. $wlyc = $this->input->get('wlyc',true);
  5312. $wltype = $this->input->get('wltype',true);
  5313. $source = $this->input->get('source',true);
  5314. $xztime = $this->input->get('xztime',true);
  5315. $timetk = strtotime($timetk);
  5316. $timetj = strtotime($timetj);
  5317. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5318. if($timetk && $timetj)
  5319. {
  5320. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5321. }
  5322. if($xztime == 'librarytime')
  5323. {
  5324. $order_str = "librarytime desc";
  5325. }
  5326. else if($xztime == 'dtime')
  5327. {
  5328. $order_str = "dtime desc";
  5329. }
  5330. if($shop)
  5331. {
  5332. $where .= " and shop = '$shop'";
  5333. }
  5334. if($expressstate)
  5335. {
  5336. $where .= " and expressstate = '$expressstate'";
  5337. }
  5338. if($fs)
  5339. {
  5340. if($fs == '1')
  5341. {
  5342. $where .= " and wlcontent != ''";
  5343. }
  5344. if($fs == '2')
  5345. {
  5346. $where .= " and wlerror != ''";
  5347. }
  5348. if($fs == '3')
  5349. {
  5350. $where .= " and wlcontent = '' and shouldmoney > 100";
  5351. }
  5352. else if($fs == '4')
  5353. {
  5354. $where .= " and wltype = '1'";
  5355. }
  5356. }
  5357. if($state)
  5358. {
  5359. $where .= " and state = '$state'";
  5360. }
  5361. if($express)
  5362. {
  5363. $where .= " and express = '$express'";
  5364. }
  5365. if($orderinfo)
  5366. {
  5367. $where .= " and orderinfo = '$orderinfo'";
  5368. }
  5369. if($number)
  5370. {
  5371. $where .= " and number = '$number'";
  5372. }
  5373. if($waybill)
  5374. {
  5375. $where .= " and waybill = '$waybill'";
  5376. }
  5377. if($wlyc!='')
  5378. {
  5379. $where .= " and wlyc = '$wlyc'";
  5380. }
  5381. if($wltype!='')
  5382. {
  5383. $where .= " and wltype = '$wltype'";
  5384. }
  5385. if($source)
  5386. {
  5387. if($source == 1)
  5388. {
  5389. $where .= " and source = '$source'";
  5390. }
  5391. else
  5392. {
  5393. $where .= " and source != '1'";
  5394. }
  5395. }
  5396. $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);
  5397. //格式化数据
  5398. foreach ($info_list as $key=>$value)
  5399. {
  5400. $country = $this->country->read($value['country']);
  5401. $info_list[$key]['country'] = $country['name'];
  5402. //$state = $this->typeclass->read($value['state']);
  5403. //$info_list[$key]['state'] = $state['title'];
  5404. if($value['library'] == 1)
  5405. {
  5406. $info_list[$key]['library'] = "未出库";
  5407. }
  5408. else if($value['library'] == 2)
  5409. {
  5410. $info_list[$key]['library'] = "已出库";
  5411. }
  5412. else if($value['library'] == 3)
  5413. {
  5414. $info_list[$key]['library'] = "已退库";
  5415. }
  5416. if($value['librarytime'] == '0')
  5417. {
  5418. $info_list[$key]['librarytime'] = '无';
  5419. }
  5420. else
  5421. {
  5422. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5423. }
  5424. if($value['expressstate'] == 0)
  5425. {
  5426. $info_list[$key]['expressstate'] = "无信息";
  5427. }
  5428. else if($value['expressstate'] == 2)
  5429. {
  5430. $info_list[$key]['expressstate'] = "已取件";
  5431. }
  5432. else if($value['expressstate'] == 3)
  5433. {
  5434. $info_list[$key]['expressstate'] = "在途中";
  5435. }
  5436. else if($value['expressstate'] == 4)
  5437. {
  5438. $info_list[$key]['expressstate'] = "到达目的地国";
  5439. }
  5440. else if($value['expressstate'] == 5)
  5441. {
  5442. $info_list[$key]['expressstate'] = "即将派送";
  5443. }
  5444. else if($value['expressstate'] == 6)
  5445. {
  5446. $info_list[$key]['expressstate'] = "已签收";
  5447. }
  5448. else if($value['expressstate'] == 1)
  5449. {
  5450. $info_list[$key]['expressstate'] = "派送异常";
  5451. }
  5452. $info_list[$key]['wlfstime'] = date('Y-m-d H:i:s',$value['wlfstime']);
  5453. $express = $this->express->read($value['express']);
  5454. $info_list[$key]['express'] = $express['servicename'];
  5455. $info_list[$key]['excontent'] = str_replace('<br />','',$value['excontent']);
  5456. }
  5457. }
  5458. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5459. $titlename = "<table border=1>
  5460. <tr>
  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. <td>邮件发送</td>
  5476. <td>错误提示</td>
  5477. <td>物流信息</td>
  5478. </tr>
  5479. </table>";
  5480. $filename = $title.".xls";
  5481. $tail = "\n";
  5482. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5483. }
  5484. public function _waybillemail()
  5485. {
  5486. $user = $this->user->get_api($_SESSION['api']);
  5487. if($user)
  5488. {
  5489. $fgshop = "";$sid = "";
  5490. $user = explode('|',trim($user['shop'],'|'));
  5491. foreach ($user as $value)
  5492. {
  5493. $fgshop .= " shop = ".$value." or";
  5494. $sid .= " id = ".$value." or";
  5495. }
  5496. }
  5497. $post = $this->input->post(NULL, TRUE);
  5498. if(isset($post['page']))
  5499. {
  5500. $page = $this->input->post('page',true);
  5501. $perpage = $this->input->post('perpage',true);
  5502. $timetk = $this->input->post('timetk',true);
  5503. $timetj = $this->input->post('timetj',true);
  5504. $shop = $this->input->post('shop',true);
  5505. $expressstate = $this->input->post('expressstate',true);
  5506. $fs = $this->input->post('fs',true);
  5507. $state = $this->input->post('state',true);
  5508. $express = $this->input->post('express',true);
  5509. $orderinfo = $this->input->post('orderinfo',true);
  5510. $number = $this->input->post('number',true);
  5511. $waybill = $this->input->post('waybill',true);
  5512. $dlzemail = $this->input->post('dlzemail',true);
  5513. $xztime = $this->input->post('xztime',true);
  5514. $timetk = strtotime($timetk);
  5515. $timetj = strtotime($timetj);
  5516. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5517. if($timetk && $timetj)
  5518. {
  5519. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5520. }
  5521. $order_str = $xztime." desc";
  5522. if($shop)
  5523. {
  5524. $where .= " and shop = '$shop'";
  5525. }
  5526. if($expressstate)
  5527. {
  5528. $where .= " and expressstate = '$expressstate'";
  5529. }
  5530. if($state)
  5531. {
  5532. $where .= " and state = '$state'";
  5533. }
  5534. if($express)
  5535. {
  5536. $where .= " and express = '$express'";
  5537. }
  5538. if($orderinfo)
  5539. {
  5540. $where .= " and orderinfo = '$orderinfo'";
  5541. }
  5542. if($number)
  5543. {
  5544. $where .= " and number = '$number'";
  5545. }
  5546. if($waybill)
  5547. {
  5548. $where .= " and waybill = '$waybill'";
  5549. }
  5550. if($dlzemail != '')
  5551. {
  5552. $where .= " and dlzemail = '$dlzemail'";
  5553. }
  5554. if(empty($page))
  5555. {
  5556. $start = 0;
  5557. $perpage = 1;
  5558. }
  5559. else
  5560. {
  5561. $start = ($page - 1)*$perpage;
  5562. }
  5563. //取得信息列表
  5564. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,dlzemail,dlzemailtime',$order_str,$start,$perpage);
  5565. //格式化数据
  5566. foreach ($info_list as $key=>$value)
  5567. {
  5568. $shop = $this->shop->read($value['shop']);
  5569. $info_list[$key]['shop'] = $shop['shopname'];
  5570. $country = $this->country->read($value['country']);
  5571. $info_list[$key]['country'] = $country['name'];
  5572. //$state = $this->typeclass->read($value['state']);
  5573. //$info_list[$key]['state'] = $state['title'];
  5574. if($value['library'] == 1)
  5575. {
  5576. $info_list[$key]['library'] = "未出库";
  5577. }
  5578. else if($value['library'] == 2)
  5579. {
  5580. $info_list[$key]['library'] = "已出库";
  5581. }
  5582. else if($value['library'] == 3)
  5583. {
  5584. $info_list[$key]['library'] = "已退库";
  5585. }
  5586. if($value['librarytime'] == '0')
  5587. {
  5588. $info_list[$key]['librarytime'] = '无';
  5589. }
  5590. else
  5591. {
  5592. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  5593. }
  5594. $express = $this->express->read($value['express']);
  5595. $info_list[$key]['express'] = $express['servicename'];
  5596. if($value['dlzemail'] == '1')
  5597. {
  5598. $info_list[$key]['dlzemail'] = '发送成功';
  5599. }
  5600. else if ($value['dlzemail'] == '2')
  5601. {
  5602. $info_list[$key]['dlzemail'] = '发送失败';
  5603. }
  5604. else
  5605. {
  5606. $info_list[$key]['dlzemail'] = '';
  5607. }
  5608. $info_list[$key]['dlzemailtime'] = ($value['dlzemailtime']>0)?date('Y-m-d H:i:s',$value['dlzemailtime']):'';
  5609. }
  5610. $total = $this->fullordertt->find_count($where);
  5611. $pagenum = ceil($total/$perpage);
  5612. $over = $total-($start+$perpage);
  5613. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5614. echo json_encode($rows);exit;
  5615. }
  5616. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  5617. $this->data['notice'] = $notice;
  5618. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  5619. $this->data['wlshop'] = $wlshop;
  5620. $this->data['express'] = $this->express->find_all();
  5621. $this->_Template('fullordertt_waybillemail',$this->data);
  5622. }
  5623. public function _khdd()
  5624. {
  5625. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  5626. if(isset($_SESSION['api']))
  5627. {
  5628. $user = $this->user->get_api($_SESSION['api']);
  5629. $usp = $user;
  5630. $fgshop = "";$sid = "";
  5631. $usersp = explode('|',trim($user['shop'],'|'));
  5632. foreach ($usersp as $value)
  5633. {
  5634. $fgshop .= " shop = ".$value." or";
  5635. $sid .= " id = ".$value." or";
  5636. }
  5637. if($user['vip'] == 1)
  5638. {
  5639. $vip = 1;
  5640. }
  5641. else
  5642. {
  5643. $vip = 0;
  5644. }
  5645. }
  5646. $post = $this->input->post(NULL, TRUE);
  5647. if(isset($_GET['excel']))
  5648. {
  5649. $page = $this->input->get('page',true);
  5650. $perpage = $this->input->get('perpage',true);
  5651. $warehouse = $this->input->get('warehouse',true);
  5652. $timetk = $this->input->get('timetk',true);
  5653. $timetj = $this->input->get('timetj',true);
  5654. $shop = $this->input->get('shop',true);
  5655. $source = $this->input->get('source',true);
  5656. $state = $this->input->get('state',true);
  5657. $review = $this->input->get('review',true);
  5658. $type = $this->input->get('type',true);
  5659. $express = $this->input->get('express',true);
  5660. $orderinfo = $this->input->get('orderinfo',true);
  5661. $user = $this->input->get('user',true);
  5662. $client = $this->input->get('name',true);
  5663. $waybill = $this->input->get('waybill',true);
  5664. $number = $this->input->get('number',true);
  5665. $email = $this->input->get('email',true);
  5666. $phone = $this->input->get('phone',true);
  5667. $dlz = $this->input->get('dlz',true);
  5668. $print = $this->input->get('print',true);
  5669. $library = $this->input->get('library',true);
  5670. $js = $this->input->get('js',true);
  5671. $exstate = $this->input->get('exstate',true);
  5672. $xztime = $this->input->get('xztime',true);
  5673. $libraryconfirm = $this->input->get('libraryconfirm',true);
  5674. $timetk = strtotime($timetk);
  5675. $timetj = strtotime($timetj);
  5676. $plorder = $this->input->get('pl',true);
  5677. $paypal = $this->input->get('paypal',true);
  5678. $zf = $this->input->get('zf',true);
  5679. $pay = $this->input->get('pay',true);
  5680. $excel = $this->input->get('excel',true);
  5681. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5682. if($warehouse)
  5683. {
  5684. $where .= " and type = '$warehouse'";
  5685. }
  5686. if($timetk && $timetj)
  5687. {
  5688. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5689. }
  5690. if($shop)
  5691. {
  5692. $where .= " and shop = '$shop'";
  5693. }
  5694. if($source)
  5695. {
  5696. if($source == '2d')
  5697. {
  5698. $where .= " and source >= '2'";
  5699. }
  5700. else
  5701. {
  5702. $where .= " and source = '$source'";
  5703. }
  5704. }
  5705. if($state)
  5706. {
  5707. $where .= " and state = '$state'";
  5708. }
  5709. if($review)
  5710. {
  5711. $where .= " and review = '$review'";
  5712. }
  5713. if($type)
  5714. {
  5715. $where .= " and type = '$type'";
  5716. }
  5717. if($express)
  5718. {
  5719. $where .= " and express = '$express'";
  5720. }
  5721. if($orderinfo)
  5722. {
  5723. $where .= " and orderinfo = '$orderinfo'";
  5724. }
  5725. if($user)
  5726. {
  5727. $where .= " and user = '$user'";
  5728. }
  5729. if($client)
  5730. {
  5731. $where .= " and client like '%$client%'";
  5732. }
  5733. if($waybill)
  5734. {
  5735. $where .= " and waybill = '$waybill'";
  5736. }
  5737. if($number)
  5738. {
  5739. $where .= " and number = '$number'";
  5740. }
  5741. if($email)
  5742. {
  5743. $where .= " and email = '$email'";
  5744. }
  5745. if($phone)
  5746. {
  5747. $where .= " and phone like '%$phone%'";
  5748. }
  5749. if($library)
  5750. {
  5751. $where .= " and library = '$library'";
  5752. }
  5753. if($print)
  5754. {
  5755. $where .= " and print = '$print'";
  5756. }
  5757. if($dlz != '')
  5758. {
  5759. $where .= " and dlz = '$dlz'";
  5760. }
  5761. if($js)
  5762. {
  5763. $where .= " and js = '$js'";
  5764. }
  5765. if($exstate)
  5766. {
  5767. $where .= " and exstate = '$exstate'";
  5768. }
  5769. if($libraryconfirm)
  5770. {
  5771. $where .= " and libraryconfirm = '$libraryconfirm'";
  5772. }
  5773. if($paypal)
  5774. {
  5775. $where .= " and paypal = '$paypal'";
  5776. }
  5777. if($pay)
  5778. {
  5779. $where .= " and pay = '$pay'";
  5780. }
  5781. if($zf)
  5782. {
  5783. if($zf == 1)
  5784. {
  5785. $where .= " and paypal not like '%-%-%-%'";
  5786. }
  5787. else
  5788. {
  5789. $where .= " and paypal like '%-%-%-%'";
  5790. }
  5791. }
  5792. if($plorder)
  5793. {
  5794. $plorderinfo = '';$plnumber = '';$pln = 0;
  5795. $plorder = explode(',',trim($plorder,','));
  5796. foreach ($plorder as $value)
  5797. {
  5798. if(is_numeric($value))
  5799. {
  5800. $plorderinfo .= " orderinfo = ".$value." or";
  5801. }
  5802. else if($value != '')
  5803. {
  5804. $plorderinfo .= " number = '".$value."' or";
  5805. }
  5806. }
  5807. if($pln > 0)
  5808. {
  5809. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  5810. }
  5811. else
  5812. {
  5813. $where .= " and (".rtrim($plorderinfo,'or').")";
  5814. }
  5815. }
  5816. //数据排序
  5817. $order_str = "dtime desc";
  5818. if(empty($page))
  5819. {
  5820. $start = 0;
  5821. $perpage = 1;
  5822. }
  5823. else
  5824. {
  5825. $start = ($page - 1)*$perpage;
  5826. }
  5827. if($excel == '1')
  5828. {
  5829. $shop = array();
  5830. $shopdata = $this->shop->find_all("type = '269'");
  5831. foreach ($shopdata as $v)
  5832. {
  5833. $shop[$v['id']] = array('t'=>$v['brandname'],'z'=>0,'l'=>0,'x'=>0);//店铺名称,总客户,老客户,新客户
  5834. }
  5835. $oldnumber = 0;$newnumber = 0;
  5836. $info_list = $this->db->query('select distinct shop,email from crowd_fullordertt where '.$where)->result_array();
  5837. foreach ($info_list as $key=>$v)
  5838. {
  5839. $shop[$v['shop']]['z'] += 1;
  5840. $num = $this->fullordertt->find_count("email = '".$v['email']."' and shop = '".$v['shop']."' and ".$xztime." < '$timetj'");
  5841. if($num > 1)
  5842. {
  5843. $shop[$v['shop']]['l'] += 1;
  5844. }
  5845. else
  5846. {
  5847. $shop[$v['shop']]['x'] += 1;
  5848. }
  5849. if(isset($v['email']) && $usp['excelpass'] == '1')
  5850. {
  5851. $emailpass = $this->setting->get_excelpass($v['email']);
  5852. $info_list[$key]['email'] = $emailpass;
  5853. }
  5854. }
  5855. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5856. $titlename = "<table border=1>
  5857. <tr>
  5858. <td>店铺</td>
  5859. <td>客户数</td>
  5860. <td>老客户数</td>
  5861. <td>新客户数</td>
  5862. </tr>
  5863. </table>";
  5864. $filename = $title.".xls";
  5865. $tail = "\n";
  5866. $this->excel->get_fz2($shop,$titlename,$filename,$tail);
  5867. }
  5868. else if($excel == '2' || $excel == '3')
  5869. {
  5870. $kh = array();
  5871. $info_list = $this->db->query('select distinct shop,email from crowd_fullordertt where email != "" and '.$where)->result_array();
  5872. foreach ($info_list as $key=>$v)
  5873. {
  5874. $k = $this->fullordertt->find_all("shop = '".$v['shop']."' and email = '".$v['email']."' and ".$xztime." < '$timetj'",'name,email,dtime,shouldmoney','dtime desc');
  5875. if($excel == 2 && count($k) > 1)
  5876. {
  5877. $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')));
  5878. }
  5879. if($excel == 3 && count($k) < 2)
  5880. {
  5881. $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')));
  5882. }
  5883. if(isset($v['email']) && $usp['excelpass'] == '1')
  5884. {
  5885. $emailpass = $this->setting->get_excelpass($v['email']);
  5886. $info_list[$key]['email'] = $emailpass;
  5887. }
  5888. }
  5889. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5890. $titlename = "<table border=1>
  5891. <tr>
  5892. <td>名称</td>
  5893. <td>邮箱</td>
  5894. <td>最后购买时间</td>
  5895. <td>购买次数</td>
  5896. <td>购买总额</td>
  5897. </tr>
  5898. </table>";
  5899. $filename = $title.".xls";
  5900. $tail = "\n";
  5901. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5902. }
  5903. else if($excel == '4' || $excel == '5')
  5904. {
  5905. $kh = array();
  5906. $info_list = $this->db->query('select distinct shop,email from crowd_fullordertt where email != "" and '.$where)->result_array();
  5907. foreach ($info_list as $key=>$value)
  5908. {
  5909. $k = $this->fullordertt->find_all("shop = '".$value['shop']."' and email = '".$value['email']."' and ".$xztime." < '$timetj'",'orderinfo,state,product,name,email,dtime,shouldmoney','dtime desc');
  5910. if($excel == 4 && count($k) > 1)
  5911. {
  5912. foreach ($k as $v)
  5913. {
  5914. $typeclass = $this->typeclass->read($v['state']);
  5915. $kh[] = array("'".$v['orderinfo'],$typeclass['spare'],$v['product'],$v['name'],$v['email'],date("Y-m-d H:i:s",$v['dtime']),$v['shouldmoney']);
  5916. }
  5917. }
  5918. if($excel == 5 && count($k) < 2)
  5919. {
  5920. if(!isset($k[0]['state']))
  5921. {
  5922. $typeclass = $k[0]['state'].'-数据字典无此信息';
  5923. }
  5924. else
  5925. {
  5926. $typeclass = $this->typeclass->read($k[0]['state']);
  5927. }
  5928. $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']);
  5929. }
  5930. if(isset($value['email']) && $usp['excelpass'] == '1')
  5931. {
  5932. $emailpass = $this->setting->get_excelpass($value['email']);
  5933. $info_list[$key]['email'] = $emailpass;
  5934. }
  5935. }
  5936. if($excel == '4'){
  5937. // $header = [
  5938. // [
  5939. // 'title'=>"订单号",
  5940. // 'width'=>0,//为0 默认为自动
  5941. // ],
  5942. // [
  5943. // 'title'=>"订单状态",
  5944. // 'width'=>0,//为0 默认为自动
  5945. // ],
  5946. // [
  5947. // 'title'=>"产品名",
  5948. // 'width'=>30,//为0 默认为自动
  5949. // ],
  5950. // [
  5951. // 'title'=>"客户名",
  5952. // 'width'=>0,//为0 默认为自动
  5953. // ],
  5954. // [
  5955. // 'title'=>"客户邮箱",
  5956. // 'width'=>0,//为0 默认为自动
  5957. // ],
  5958. // [
  5959. // 'title'=>"下单时间",
  5960. // 'width'=>0,//为0 默认为自动
  5961. // ],
  5962. // [
  5963. // 'title'=>"订单金额",
  5964. // 'width'=>0,//为0 默认为自动
  5965. // ],
  5966. // ];
  5967. // if(!empty($country['zname'])){
  5968. // $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5969. // }else{
  5970. // $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5971. // }
  5972. // $filename = $title;
  5973. // $data = $kh;
  5974. // $this->excelnew->doHeadMerg($title,$filename,$header,$data);
  5975. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5976. $titlename = "<table border=1>
  5977. <tr>
  5978. <td>订单号</td>
  5979. <td>订单状态</td>
  5980. <td>产品名</td>
  5981. <td>客户名</td>
  5982. <td>客户邮箱</td>
  5983. <td>下单时间</td>
  5984. <td>订单金额</td>
  5985. </tr>
  5986. </table>";
  5987. $filename = $title.".xls";
  5988. $tail = "\n";
  5989. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5990. }else{
  5991. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5992. $titlename = "<table border=1>
  5993. <tr>
  5994. <td>订单号</td>
  5995. <td>订单状态</td>
  5996. <td>产品名</td>
  5997. <td>客户名</td>
  5998. <td>客户邮箱</td>
  5999. <td>下单时间</td>
  6000. <td>订单金额</td>
  6001. </tr>
  6002. </table>";
  6003. $filename = $title.".xls";
  6004. $tail = "\n";
  6005. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  6006. }
  6007. }
  6008. }
  6009. }
  6010. public function _klarnadata()
  6011. {
  6012. $post = $this->input->post(NULL, TRUE);
  6013. if(isset($post['number']))
  6014. {
  6015. $number = $this->input->post('number',true);
  6016. $data = $this->fullordertt->get_number($number);
  6017. $shop = $this->shop->read($data['shop']);
  6018. $f = '';
  6019. if($data['pay'] == '23')
  6020. {
  6021. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$data['paypal'];
  6022. $header[] = "Content-Type:application/json";
  6023. $header[] = "Authorization: Basic ".base64_encode($shop['klarnaname'].":".$shop['klarnapass']);
  6024. $ch = curl_init();
  6025. curl_setopt($ch, CURLOPT_URL, $url);
  6026. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6027. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6028. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6029. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6030. $res = curl_exec($ch);
  6031. curl_close($ch);
  6032. $res = json_decode($res,true);
  6033. if(isset($res['fraud_status']) && $shop['klarnaname'] != '')
  6034. {
  6035. $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'];
  6036. }
  6037. }
  6038. else if($data['pay'] == '22' && $shop['paypalname'] != '')
  6039. {
  6040. $f = $this->paypal->data($data['paypal'],$shop);
  6041. }
  6042. else if(($data['pay'] == '26') && $shop['afterpayname'] != '')
  6043. {
  6044. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  6045. $header[] = "Accept:application/json";
  6046. $header[] = "User-Agent: Readme.io API Simulator'";
  6047. $header[] = "Authorization: Basic ".base64_encode($shop['afterpayname'].":".$shop['afterpaypass']);
  6048. $ch = curl_init();
  6049. curl_setopt($ch, CURLOPT_URL, $url);
  6050. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6051. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6052. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6053. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6054. $res = curl_exec($ch);
  6055. curl_close($ch);
  6056. $res = json_decode($res,true);
  6057. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  6058. {
  6059. $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'];
  6060. $f = str_replace(',,',',',$f);
  6061. }
  6062. }
  6063. else if(($data['pay'] == '27') && $shop['clearpayname'] != '')
  6064. {
  6065. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  6066. $header[] = "Accept:application/json";
  6067. $header[] = "User-Agent: Readme.io API Simulator'";
  6068. $header[] = "Authorization: Basic ".base64_encode($shop['clearpayname'].":".$shop['clearpaypass']);
  6069. $ch = curl_init();
  6070. curl_setopt($ch, CURLOPT_URL, $url);
  6071. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6072. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6073. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6074. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6075. $res = curl_exec($ch);
  6076. curl_close($ch);
  6077. $res = json_decode($res,true);
  6078. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  6079. {
  6080. $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'];
  6081. $f = str_replace(',,',',',$f);
  6082. }
  6083. }
  6084. else if($data['pay'] == '1211')
  6085. {
  6086. $url = 'https://api.stripe.com/v1/payment_intents/'.$data['paypal'];
  6087. $header[] = "Authorization:Bearer ".$shop['stripe'];
  6088. $ch = curl_init();
  6089. curl_setopt($ch, CURLOPT_URL, $url);
  6090. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6091. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6092. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6093. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6094. $res = curl_exec($ch);
  6095. curl_close($ch);
  6096. $res = json_decode($res,true);
  6097. $f = '';
  6098. if(isset($res['shipping']['name']))
  6099. {
  6100. $line = ($res['shipping']['address']['line2'] != '')?$res['shipping']['address']['line1'].' '.$res['shipping']['address']['line2']:$res['shipping']['address']['line1'];
  6101. $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));
  6102. }
  6103. }
  6104. else
  6105. {
  6106. echo json_encode(array('msg'=>'此店铺没有对接信息','success'=>false));exit;
  6107. }
  6108. if($f != '')
  6109. {
  6110. if($this->fullordertt->save(array('klarnadata'=>$f),$data['id']))
  6111. {
  6112. echo json_encode(array('msg'=>'获取成功,请关闭此页重新打开','success'=>true));exit;
  6113. }
  6114. else
  6115. {
  6116. echo json_encode(array('msg'=>'写入失败,请重试','success'=>false));exit;
  6117. }
  6118. }
  6119. else
  6120. {
  6121. echo json_encode(array('msg'=>'获取失败,请稍后重试','cl'=>base64_encode($shop['afterpayname'].":".$shop['afterpaypass']),'a'=>$data['paypal'],'success'=>false));exit;
  6122. }
  6123. }
  6124. }
  6125. public function _kcyz($warehouse,$whlabel,$id,$shop,$number)
  6126. {
  6127. if(!$whlabel || $whlabel == '|')
  6128. {
  6129. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  6130. }
  6131. $w = $this->warehouse->read($warehouse);
  6132. if($w['zd'] != 1)
  6133. {
  6134. return 1;
  6135. }
  6136. $pp = explode('|',trim($whlabel,'|'));
  6137. $x = 0;$save = array();
  6138. foreach ($pp as $va)
  6139. {
  6140. $num = explode('-',$va);
  6141. if($number)
  6142. {
  6143. $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 = '')");//通用
  6144. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  6145. }
  6146. else
  6147. {
  6148. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  6149. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  6150. }
  6151. $x++;
  6152. if(count($whlabel)+count($shopwhlabel) < $num[1])
  6153. {
  6154. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  6155. }
  6156. }
  6157. return $save;
  6158. }
  6159. public function _epod()
  6160. {
  6161. $post = $this->input->post(NULL, TRUE);
  6162. if(isset($post['number']))
  6163. {
  6164. $number = $this->input->post('number',true);
  6165. $data = $this->fullordertt->get_number($number);
  6166. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  6167. {
  6168. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  6169. }
  6170. else
  6171. {
  6172. $epod = $this->dhl->get_epod($data);
  6173. if($epod['c'] == 1)
  6174. {
  6175. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  6176. }
  6177. else
  6178. {
  6179. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  6180. }
  6181. }
  6182. }
  6183. }
  6184. public function _zw($arg_array)
  6185. {
  6186. $arg_array = $arg_array[0];$fpdata = array();
  6187. $fullordertt = $this->fullordertt->read($arg_array);
  6188. $fullordertt['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullordertt['shipremarks']);
  6189. $fullordertt['parameter'] = str_replace(",","---",$fullordertt['parameter']);
  6190. $this->data['fullordertt'] = $fullordertt;
  6191. $this->data['countrys'] = $this->country->find_all();
  6192. $this->data['express'] = $this->express->find_all();
  6193. $warehouse = $this->warehouse->read($fullordertt['type']);
  6194. if(stripos($fullordertt['fpdata'],';') !== false)
  6195. {
  6196. $fpdata = explode(';',rtrim($fullordertt['fpdata'],';'));
  6197. foreach ($fpdata as $k=>$v)
  6198. {
  6199. $xxv = explode('|',$v);
  6200. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  6201. {
  6202. $xxv['zd'] = "<p>已占单</p>";
  6203. $bdck = $warehouse['bdck'];
  6204. if(stripos($xxv[9],'~') !== false)
  6205. {
  6206. $dxxv = explode('~',trim($xxv[9],'~'));
  6207. foreach ($dxxv as $val)
  6208. {
  6209. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  6210. if($wzid['details'] != '')
  6211. {
  6212. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6213. }
  6214. }
  6215. }
  6216. else
  6217. {
  6218. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  6219. if($wzid['details'] != '')
  6220. {
  6221. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6222. }
  6223. }
  6224. }
  6225. $fpdata[$k] = $xxv;
  6226. }
  6227. }
  6228. $this->data['fpdata'] = $fpdata;
  6229. $this->data['fpdata'] = $fpdata;
  6230. $thfpdataxs = array();
  6231. if($fullordertt['thfpdata'] != '')
  6232. {
  6233. $thfpdata = explode(';',trim($fullordertt['thfpdata'],';'));
  6234. foreach ($thfpdata as $k=>$v)
  6235. {
  6236. $thxs = explode('~',trim($v,'~'));
  6237. $thxs[0] = explode('|',trim($thxs[0],'|'));
  6238. $thxs[1] = explode('|',trim($thxs[1],'|'));
  6239. $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]);
  6240. }
  6241. }
  6242. $this->data['thfpdata'] = $thfpdataxs;
  6243. $shop = $this->shop->read($fullordertt['shop']);
  6244. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  6245. $is = 0;
  6246. if($shop['type'] == 269)//判断是否独立站,269是独立站
  6247. {
  6248. $is = 1;
  6249. }
  6250. $this->data['is'] = $is;
  6251. //单项开始
  6252. $warehouse = $this->warehouse->read($fullordertt['warehouse']);//发货仓库
  6253. $state = $this->typeclass->read($fullordertt['state']);//订单状态
  6254. $country = $this->country->read($fullordertt['country']);//国家
  6255. if($fullordertt['capital'] == 1)
  6256. {
  6257. $capital = '暂未支付';
  6258. }
  6259. else if($fullordertt['capital'] == 2)
  6260. {
  6261. $capital = '部分支付';
  6262. }
  6263. else if($fullordertt['capital'] == 3)
  6264. {
  6265. $capital = '全部支付';
  6266. }
  6267. if($fullordertt['printtype'] == 1)
  6268. {
  6269. $printtype = '运单';
  6270. }
  6271. else if($fullordertt['printtype'] == 2)
  6272. {
  6273. $printtype = '发货单';
  6274. }
  6275. else if($fullordertt['printtype'] == 3)
  6276. {
  6277. $printtype = '不打印单据';
  6278. }
  6279. else
  6280. {
  6281. $printtype = '未选择';
  6282. }
  6283. $this->data['warehouse'] = $warehouse['title'];
  6284. $this->data['state'] = $state['title'];
  6285. $this->data['capital'] = $capital;
  6286. $this->data['country'] = $country['name'];
  6287. $this->data['printtype'] = $printtype;
  6288. //单项结束
  6289. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  6290. $downwaybill = '';$dwls = array();
  6291. $oldwaybill = explode('-',ltrim($fullordertt['oldwaybill'],'-'));
  6292. if(isset($oldwaybill[0][1]))
  6293. {
  6294. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6295. foreach ($oldwaybill as $v)
  6296. {
  6297. $dw = explode('/',$v);
  6298. if(isset($dw[1]))
  6299. {
  6300. if(stripos($downwaybill,$dw[1]) === false)
  6301. {
  6302. $dwls[$dw[1]] = 1;
  6303. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  6304. }
  6305. }
  6306. }
  6307. }
  6308. if($fullordertt['printtype'] == 1)
  6309. {
  6310. if($fullordertt['waybill'] != '' && !isset($dwls[$fullordertt['waybill']]))
  6311. {
  6312. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordertt['printtime']).'/y-'.$fullordertt['waybill'].'.pdf" target="_blank">'.$fullordertt['waybill'].'</a>、'.$downwaybill;
  6313. }
  6314. }
  6315. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  6316. /** 历史打印时间 **/
  6317. $printtime = '';
  6318. if($fullordertt['oldprinttime'])
  6319. {
  6320. $pte = explode('-',rtrim($fullordertt['oldprinttime'],'-'));
  6321. foreach ($pte as $v)
  6322. {
  6323. $printtime .= date('Y-m-d H:i:s',$v).'、';
  6324. }
  6325. }
  6326. $this->data['printtime'] = rtrim($printtime,'、');
  6327. $product = '';
  6328. $fullordertt['product'] = str_replace("'","",$fullordertt['product']);
  6329. if($fullordertt['link'] != '' && $fullordertt['source'] != '1')
  6330. {
  6331. $pt = explode(',',$fullordertt['product']);
  6332. $lk = explode(',',$fullordertt['link']);
  6333. for($i=0;$i<count($pt);$i++)
  6334. {
  6335. if(isset($lk[$i]))
  6336. {
  6337. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  6338. }
  6339. else
  6340. {
  6341. $octs = '';
  6342. }
  6343. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  6344. //$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];
  6345. if(isset($lk[$i]))
  6346. {
  6347. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  6348. }
  6349. else
  6350. {
  6351. $product .= ($product != '')?' , '.$a:$a;
  6352. }
  6353. }
  6354. }
  6355. else
  6356. {
  6357. $octs = $this->colourorderts->get_text($fullordertt['product']);
  6358. $a = $octs?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  6359. //$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'];
  6360. $product = $a;
  6361. }
  6362. $this->data['product'] = $product;
  6363. $out = $this->systemtransfer->find_all("number = '".$fullordertt['number']."'");
  6364. $outread = '';
  6365. if($out)
  6366. {
  6367. foreach ($out as $val)
  6368. {
  6369. $list = '';
  6370. $rk = explode('|',trim($val['rk'],'|'));
  6371. $rktime = explode('|',trim($val['rktime'],'|'));
  6372. $zw = array();
  6373. $t = $this->transfer->find_all("1=1");
  6374. foreach ($t as $v)
  6375. {
  6376. $zw[$v['id']] = $v['title'];
  6377. }
  6378. if($val['rk'] != '' && count($rk) > 0)
  6379. {
  6380. for($i=0;$i<count($rk);$i++)
  6381. {
  6382. if(!isset($rktime[$i]))
  6383. {
  6384. $list .= $zw[$cz[$i]];
  6385. }
  6386. else
  6387. {
  6388. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  6389. }
  6390. }
  6391. }
  6392. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  6393. }
  6394. }
  6395. else
  6396. {
  6397. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordertt['number']."'");
  6398. $outread = array();
  6399. if($systemwigsout)
  6400. {
  6401. foreach ($systemwigsout as $v)
  6402. {
  6403. if($v['czwarehouse'] == 37)
  6404. {
  6405. $outread[] = '华荣厂';
  6406. }
  6407. else if($v['czwarehouse'] == 0)
  6408. {
  6409. $outread[] = '龙盈厂';
  6410. }
  6411. $cz = explode('|',trim($v['cz'],'|'));
  6412. $cztime = explode('|',trim($v['cztime'],'|'));
  6413. $zw = $this->transfer->get_list();
  6414. if($v['cz'] != '' && count($cz) > 0)
  6415. {
  6416. for($i=0;$i<count($cz);$i++)
  6417. {
  6418. if(!isset($cztime[$i]))
  6419. {
  6420. $outread[] = $zw[$cz[$i]].' -&gt; ';
  6421. }
  6422. else
  6423. {
  6424. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  6425. }
  6426. }
  6427. $outread[] = '<br>';
  6428. }
  6429. }
  6430. }
  6431. }
  6432. $klarnacolor = '';
  6433. if($fullordertt['klarnadata'] !='')
  6434. {
  6435. $klarnadata = explode('|',$fullordertt['klarnadata']);
  6436. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  6437. {
  6438. $klarnadata[1] = json_decode($klarnadata[1],true);
  6439. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullordertt['shouldmoney'] && $fullordertt['pay'] == 1211)
  6440. {
  6441. $klarnacolor = 'style="color:#F00"';
  6442. }
  6443. }
  6444. else if($klarnadata[0]!=1 && $fullordertt['pay']!=26 && $fullordertt['pay']!=27 && $fullordertt['pay']!=1211)
  6445. {
  6446. $klarnacolor = 'style="color:#F00"';
  6447. }
  6448. if($fullordertt['pay'] == 23)//klarna
  6449. {
  6450. $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');
  6451. $ToState = array_flip($ToState);
  6452. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  6453. $city = str_replace(' ','',$fullordertt['city']);
  6454. $klarnadataaddress = explode($city,$klarnadata3);
  6455. if(isset($klarnadataaddress[1]))
  6456. {
  6457. $klarnadata3 = $city.$klarnadataaddress[1];
  6458. $klarnadatacolor = explode(',',$klarnadata3);
  6459. unset($klarnadatacolor[4]);
  6460. unset($klarnadatacolor[6]);
  6461. if(isset($ToState[$klarnadatacolor[1]]))
  6462. {
  6463. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  6464. }
  6465. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  6466. }
  6467. else
  6468. {
  6469. $klarnadata['color'] = $klarnadata3;
  6470. }
  6471. }
  6472. }
  6473. else
  6474. {
  6475. $klarnadata = '';
  6476. }
  6477. $p = explode('-',$fullordertt['paypal']);
  6478. $this->data['klarnacolor'] = $klarnacolor;
  6479. $this->data['klarnadata'] = $klarnadata;
  6480. $this->data['systemwigsout'] = $outread;
  6481. $this->_Template('fullordertt_zw',$this->data);
  6482. }
  6483. public function _dcdxyz()
  6484. {
  6485. $post = $this->input->get(NULL, TRUE);
  6486. if(isset($post['timetk']))
  6487. {
  6488. $timetk = $this->input->get('timetk',true);
  6489. $timetj = $this->input->get('timetj',true);
  6490. $timetk = strtotime($timetk);
  6491. $timetj = strtotime($timetj);
  6492. $where = "oldwaybill != ''";
  6493. if($timetk && $timetj)
  6494. {
  6495. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6496. }
  6497. //数据排序
  6498. $order_str = "dtime desc";
  6499. //取得信息列表
  6500. $info_list = $this->fullordertt->find_all($where,'orderinfo,number,oldwaybill',$order_str);
  6501. $data = array();
  6502. foreach ($info_list as $key=>$value)
  6503. {
  6504. $ob = '';
  6505. $oldwaybill = explode('-',trim($value['oldwaybill'],'-'));
  6506. if(count($oldwaybill) < 2)
  6507. {
  6508. continue;
  6509. }
  6510. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6511. foreach ($oldwaybill as $v)
  6512. {
  6513. $dw = explode('/',$v);
  6514. if(isset($dw[1]))
  6515. {
  6516. $dwls[$dw[1]] = 1;
  6517. $ob .= $dw[1].'、';
  6518. }
  6519. }
  6520. $info_list[$key]['oldwaybill'] = trim($ob,'、');
  6521. $data[] = $info_list[$key];
  6522. }
  6523. $title = "多运单信息 ".date("Y-m-d");
  6524. $titlename = "<table border=1>
  6525. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6526. <tr>
  6527. <td>订单号</td>
  6528. <td>编号</td>
  6529. <td>运单号</td>
  6530. </tr>
  6531. </table>";
  6532. $filename = $title.".xls";
  6533. $tail = "\n";
  6534. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  6535. }
  6536. }
  6537. public function _thxz()
  6538. {
  6539. $post = $this->input->get(NULL, TRUE);
  6540. if(isset($post['timetk']))
  6541. {
  6542. $timetk = $this->input->get('timetk',true);
  6543. $timetj = $this->input->get('timetj',true);
  6544. $timetk = strtotime($timetk);
  6545. $timetj = strtotime($timetj);
  6546. $where = "returndata != ''";
  6547. if($timetk && $timetj)
  6548. {
  6549. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6550. }
  6551. //数据排序
  6552. $order_str = "dtime desc";
  6553. //取得信息列表
  6554. $info_list = $this->fullordertt->find_all($where,'orderinfo,number,returndata',$order_str);
  6555. foreach ($info_list as $key=>$value)
  6556. {
  6557. $ydh = explode('">',$value['returndata']);
  6558. $ydh = explode('</a>',$ydh[1]);
  6559. $info_list[$key]['returndata'] = $ydh[0];
  6560. $time = explode('pdf/',$value['returndata']);
  6561. $time = explode('/',$time[1]);
  6562. $info_list[$key]['time'] = $time[0];
  6563. }
  6564. $title = "退货订单信息 ".date("Y-m-d");
  6565. $titlename = "<table border=1>
  6566. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6567. <tr>
  6568. <td>订单号</td>
  6569. <td>编号</td>
  6570. <td>退货运单号</td>
  6571. <td>退货时间</td>
  6572. </tr>
  6573. </table>";
  6574. $filename = $title.".xls";
  6575. $tail = "\n";
  6576. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  6577. }
  6578. }
  6579. public function _ddcf()
  6580. {
  6581. $post = $this->input->post(NULL, TRUE);
  6582. if(isset($post['number']))
  6583. {
  6584. $number = $this->input->post('number',true);
  6585. $data = $this->fullordertt->get_number($number);
  6586. if(!$data)
  6587. {
  6588. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  6589. }
  6590. if($data['review'] != 1 && $data['review'] != 2)
  6591. {
  6592. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  6593. }
  6594. if($data['merge'] != 0)
  6595. {
  6596. echo json_encode(array('msg'=>'已合并的订单无法使用此拆分功能','success'=>false));exit;
  6597. }
  6598. $cfnum = explode('-',trim($number,'-'));
  6599. if(count($cfnum)> 4)
  6600. {
  6601. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6602. }
  6603. $num = $this->fullordertt->find_count("number like '".$number."%'");
  6604. $data['number'] = $data['number'].'-'.$num;
  6605. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);
  6606. $data['shouldmoney'] = 0;
  6607. $data['budget'] = 0;
  6608. $data['shipremarks'] = '';
  6609. $data['source'] = 1;
  6610. //$data['review'] = 2;
  6611. $data['extra_status'] = 1;//拆分的订单
  6612. unset($data['id']);
  6613. unset($data['jweight']);
  6614. unset($data['fpcount']);
  6615. unset($data['returndata']);
  6616. unset($data['oldwaybill']);
  6617. unset($data['waybill']);
  6618. unset($data['printtime']);
  6619. if($this->fullordertt->insert($data))
  6620. {
  6621. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  6622. }
  6623. else
  6624. {
  6625. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  6626. }
  6627. }
  6628. }
  6629. public function _cf() //合并订单拆分
  6630. {
  6631. $post = $this->input->post(NULL, TRUE);
  6632. if(isset($post['id']))
  6633. {
  6634. $id = $this->input->post('id',true);
  6635. $b = $this->fullordertt->read($id);
  6636. $order = array();
  6637. if($b['merge'] == $b['id'])
  6638. {
  6639. $data = $this->fullordertt->find_all("merge = '".$b['merge']."'");
  6640. foreach ($data as $v)
  6641. {
  6642. $a = $this->fullordertthb->get_orderinfo($v['orderinfo']);
  6643. if($a)
  6644. {
  6645. $this->fullordertt->save($a,$v['id']);
  6646. }
  6647. $order[] = $v['id'];
  6648. }
  6649. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  6650. }
  6651. else
  6652. {
  6653. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  6654. }
  6655. }
  6656. }
  6657. public function _pljzzd()
  6658. {
  6659. $post = $this->input->post(NULL, TRUE);
  6660. if(isset($post['s']))
  6661. {
  6662. $id_arr = $this->input->post('s');
  6663. $id_arr = explode(',',$id_arr);
  6664. if(!$id_arr)
  6665. {
  6666. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  6667. }
  6668. //循环删除记录
  6669. $this->db->trans_begin();
  6670. foreach ($id_arr as $value)
  6671. {
  6672. $post = $this->fullordertt->read($value);
  6673. $hbw = explode('|',trim($post['whlabel'],'|'));
  6674. $hbf = explode(';',trim($post['fpdata'],';'));
  6675. foreach ($hbw as $k=>$val)
  6676. {
  6677. $w = explode('-',$val);
  6678. $f = explode('|',$hbf[$k]);
  6679. $w[2] = "DNOTO";
  6680. $f[9] = "DNOTO";
  6681. $hbf[$k] = implode("|",$f);
  6682. $hbw[$k] = implode("-",$w);
  6683. }
  6684. $w = $this->whlabel->find_all("zd = '".$post['number']."'");
  6685. foreach ($w as $k=>$val)
  6686. {
  6687. $this->whlabel->save(array('zd'=>''),$val['id']);
  6688. }
  6689. $fpdata = implode(";",$hbf).';';
  6690. $whlabel = '|'.implode("|",$hbw).'|';
  6691. $this->fullordertt->save(array('fpdata'=>$fpdata,'whlabel'=>$whlabel),$post['id']);
  6692. }
  6693. if ($this->db->trans_status() === FALSE)
  6694. {
  6695. $this->db->trans_rollback();
  6696. }
  6697. else
  6698. {
  6699. $this->db->trans_commit();
  6700. }
  6701. echo json_encode(array('del'=>$id_arr,'msg'=>'操作成功,已暂时隐藏,可继续操作其它订单,刷新即可显示!','success'=>true));
  6702. }
  6703. }
  6704. public function _cbtlabel($arg_array){
  6705. $id = $arg_array[0];
  6706. $info = $this->fullordertt->read($id);
  6707. if(empty($info)){
  6708. echo json_encode(array('msg'=>'订单不存在!','success'=>false));exit;
  6709. }
  6710. $extra_text = json_decode($info['extra_text'],true);
  6711. if(isset($extra_text['label_info'])){
  6712. echo json_encode(array('msg'=>'发货标签已执行,请勿重复操作!','success'=>false));exit;
  6713. }
  6714. $shop_info = $this->shop->read($info['shop']);
  6715. if(empty($shop_info)){
  6716. echo json_encode(array('msg'=>'店铺不存在!','success'=>false));exit;
  6717. }
  6718. $res = $this->express_tt->doCreateCBTLabel($info,$shop_info);
  6719. if($res['x'] == 0){
  6720. $msg = isset($res['Description'])?$res['Description']:$res['message'];
  6721. echo json_encode(array('msg'=>$msg,'success'=>false));exit;
  6722. }else{
  6723. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  6724. }
  6725. }
  6726. }