Fullorder.php 228 KB

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