Fullordertt.php 226 KB

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