Fullorderamz.php 228 KB

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