Fullorderamz.php 228 KB

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