Fullorder.php 227 KB

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