Fullordertt.php 239 KB

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