Fullordertt.php 229 KB

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