Fullordertt.php 232 KB

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