Fullordertt.php 240 KB

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