Fullordertt.php 238 KB

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