Fullorder.php 229 KB

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