Fullordertt.php 234 KB

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