Fullorder.php 233 KB

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