Fullorder.php 227 KB

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