Fullorder.php 232 KB

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