Fullorder.php 227 KB

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