Fullordertt.php 230 KB

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