Fullorder.php 232 KB

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