Fullordertt.php 229 KB

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