Fullordertt.php 226 KB

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