Fullordertt.php 239 KB

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