Fullorderamz.php 231 KB

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