Fullorder.php 230 KB

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