Fullordertt.php 227 KB

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