Fullorder.php 230 KB

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