Fullorderamz.php 227 KB

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