Fullordertt.php 226 KB

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