Fullordertt.php 230 KB

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