Fullordertt.php 231 KB

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