Fullordertt.php 226 KB

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