Fullorderamz.php 230 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509
  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. $tmp_list = $this->db->from('fullorderamz')->where_in('id',$id_arr)->select('id,orderinfo,number,type,express')->get()->result_array();
  2936. $count_warehouse_list = [];
  2937. $count_express_list = [];
  2938. $flag = 0;
  2939. $flag_str = '';
  2940. foreach ($tmp_list as $k => $v) {
  2941. $count_warehouse_list[$v['type']] = $v['type'];
  2942. if(empty($v['express'])){
  2943. $flag = 1;
  2944. $flag_str.= $v['number'].'仓库未选,请先选快递;';
  2945. }
  2946. $count_express_list[$v['express']] = $v['express'];
  2947. }
  2948. if($flag == 1){
  2949. echo json_encode(array('msg'=>$flag_str,'success'=>false));exit;
  2950. }
  2951. if(count($count_warehouse_list) > 1){
  2952. echo json_encode(array('msg'=>'合并单的仓库不一致,无法合并!','success'=>false));exit;
  2953. }
  2954. if(count($count_express_list) > 1){
  2955. echo json_encode(array('msg'=>'合并单的快递不一致,无法合并!','success'=>false));exit;
  2956. }
  2957. $post = array();
  2958. $u = $this->fullorderamz->read($id_arr[0]);
  2959. unset($id_arr[0]);
  2960. $this->db->trans_begin();
  2961. $hd = $this->fullorderamzhb->get_orderinfo($u['orderinfo']);
  2962. if(!$hd)
  2963. {
  2964. $this->fullorderamzhb->insert($u);
  2965. }
  2966. //相加
  2967. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  2968. $post['budget'] = $u['budget'];//预估到帐金额
  2969. $post['expressmoney']= $u['expressmoney'];//物流金额
  2970. //$post['refundy'] = $u['refundy'];//补/退原额
  2971. //$post['refundj'] = $u['refundj'];//补/退净额
  2972. $post['cost'] = $u['cost'];//成本金额
  2973. //$post['zzl'] = $u['zzl'];//总重量
  2974. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  2975. $post['ts'] = $u['ts'];//条数
  2976. $post['cost'] = $u['cost'];//成本金额
  2977. //追加
  2978. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  2979. $post['rtext'] = $u['rtext'];//补/退原因
  2980. $post['pay'] = $u['pay'];//付款方式
  2981. $post['paypal'] = $u['paypal'];//交易号
  2982. $post['clientremarks'] = $u['clientremarks'];//客户留言
  2983. $post['product'] = $u['product'];//商品名称
  2984. //$post['issku'] = $u['issku'];//sku
  2985. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  2986. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  2987. //产品追加
  2988. $post['fpdata'] = $u['fpdata'];//产品内容
  2989. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  2990. $merge = $u['id'];
  2991. $d = array($u['id']);$order = '';
  2992. $zsl = 0;$zccsl = 0;
  2993. foreach ($id_arr as $v)
  2994. {
  2995. $v = $this->fullorderamz->read($v);
  2996. if($u['type'] != $v['type'])
  2997. {
  2998. echo json_encode(array('msg'=>'仓库不一致,无法合并!','success'=>false));exit;
  2999. }
  3000. if($v['shop'] = $u['shop'])
  3001. {
  3002. $hd = $this->fullorderamzhb->get_orderinfo($v['orderinfo']);
  3003. if(!$hd)
  3004. {
  3005. $this->fullorderamzhb->insert($v);
  3006. }
  3007. // $post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  3008. // $post['budget'] += $v['budget'];//预估到帐金额
  3009. // $post['expressmoney'] += $v['expressmoney'];//物流金额
  3010. //$post['refundy'] += $v['refundy'];//补/退原额
  3011. //$post['refundj'] += $v['refundj'];//补/退净额
  3012. $post['cost'] += $v['cost'];//成本金额
  3013. //$post['zzl'] += $v['zzl'];//总重量
  3014. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  3015. $post['ts'] += $v['ts'];//条数
  3016. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  3017. //$post['rtext'] .= $v['rtext'];//补/退原因
  3018. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  3019. //$post['paypal'] .= $v['paypal'];//交易号
  3020. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  3021. $post['product'] .= $v['product'];//商品名称
  3022. //$post['issku'] .= $v['issku'];//sku
  3023. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  3024. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  3025. $post['fpdata'] .= $v['fpdata'];//产品内容
  3026. $post['whlabel'] .= $v['whlabel'];//产品对应库存码
  3027. $d[] = $v['id'];
  3028. $order .= $v['orderinfo'].'('.$v['number'].')、';
  3029. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  3030. $i = 0;
  3031. if($wl)//如果有那么清除所有占用
  3032. {
  3033. foreach ($wl as $val)
  3034. {
  3035. if($val['sku'] == 'Preset' && $val['state'] == '9')
  3036. {
  3037. $this->whlabel->remove($val['id']);//删除预设
  3038. $i++;
  3039. }
  3040. else
  3041. {
  3042. $this->whlabel->save(array('zd'=>''),$val['id']);//专属
  3043. $i++;
  3044. }
  3045. }
  3046. }
  3047. $zsl += count($wl);
  3048. $zccsl += $i;
  3049. $this->fullorderamz->save(array('merge'=>$u['id'],'mergeid'=>1,'orderremarks'=>' 《合并信息》:'.'已合并到'.$u['orderinfo'].'('.$u['number'].')中; '.$v['orderremarks'],'print'=>1,'libraryconfirm'=>1,'whlabel'=>'','fpdata'=>'','shipremarks'=>''),$v['id']);
  3050. }
  3051. }
  3052. //计算出单条价值
  3053. /**
  3054. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  3055. {
  3056. //$post['dtsbjz'] = 0;
  3057. }
  3058. else
  3059. {
  3060. //$post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  3061. }
  3062. **/
  3063. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];
  3064. $post['merge'] = $u['id'];
  3065. //$post['mergeid'] = 1;
  3066. //合并重复项
  3067. //解决whlabel 合并在一起是 多出的那个|
  3068. $post['whlabel'] = str_replace("||","|",$post['whlabel']);
  3069. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  3070. $hbcff = explode(';',trim($post['fpdata'],';'));
  3071. $c = 0;
  3072. $hbw = array();
  3073. $hbf = array();
  3074. for($i=0;$i<count($hbcfw);$i++)
  3075. {
  3076. $w = explode('-',$hbcfw[$i]);
  3077. $f = explode('|',$hbcff[$i]);
  3078. $w2 = ($w[2]==0)?0:'';
  3079. if(!isset($hbw[$w[0].$w2]))
  3080. {
  3081. $hbw[$w[0].$w2] = $hbcfw[$i];
  3082. $hbf[$w[0].$w2] = $hbcff[$i];
  3083. }
  3084. else
  3085. {
  3086. $c++;
  3087. $cw = explode('-',$hbw[$w[0].$w2]);
  3088. $cf = explode('|',$hbf[$w[0].$w2]);
  3089. if($cw[2] != 0 && $w[2] != 0)
  3090. {
  3091. $cf[2] += $f[2];
  3092. $cf[9] .= '~'.$f[9];
  3093. $hbf[$w[0].$w2] = implode("|",$cf);
  3094. $cw[1] += $f[2];
  3095. $cw[2] .= '~'.$f[9];
  3096. $hbw[$w[0].$w2] = implode("-",$cw);
  3097. }
  3098. else if($cw[2] == 0 && $w[2] == 0)
  3099. {
  3100. $cf[2] += $f[2];
  3101. $hbf[$w[0].$w2] = implode("|",$cf);
  3102. $cw[1] += $f[2];
  3103. $hbw[$w[0].$w2] = implode("-",$cw);
  3104. }
  3105. else
  3106. {
  3107. $hbw[] = $hbcfw[$i];
  3108. $hbf[] = $hbcff[$i];
  3109. }
  3110. }
  3111. }
  3112. if($c > 0)
  3113. {
  3114. $post['fpdata'] = implode(";",$hbf).';';
  3115. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  3116. }
  3117. //合并重复项结束
  3118. $this->fullorderamz->save($post,$u['id']);
  3119. if ($this->db->trans_status() === FALSE)
  3120. {
  3121. $this->db->trans_commit();
  3122. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3123. }
  3124. else
  3125. {
  3126. $this->db->trans_commit();
  3127. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$u['id'],'success'=>true));
  3128. }
  3129. }
  3130. }
  3131. //评价管理
  3132. public function _evaluate()
  3133. {
  3134. $user = $this->user->get_api($_SESSION['api']);
  3135. if($user)
  3136. {
  3137. $fgshop = "";$sid = "";
  3138. $user = explode('|',trim($user['shop'],'|'));
  3139. foreach ($user as $value)
  3140. {
  3141. $fgshop .= " shop = ".$value." or";
  3142. $sid .= " id = ".$value." or";
  3143. }
  3144. }
  3145. $post = $this->input->post(NULL, TRUE);
  3146. if(isset($post['page']))
  3147. {
  3148. $page = $this->input->post('page',true);
  3149. $perpage = $this->input->post('perpage',true);
  3150. $shop = $this->input->post('shop',true);
  3151. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  3152. if($shop)
  3153. {
  3154. $where .= " and shop = '$shop'";
  3155. }
  3156. //数据排序
  3157. $order_str = "id desc";
  3158. if(empty($page))
  3159. {
  3160. $start = 0;
  3161. $perpage = 1;
  3162. }
  3163. else
  3164. {
  3165. $start = ($page - 1)*$perpage;
  3166. }
  3167. //取得信息列表
  3168. $info_list = $this->fullorderamz->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  3169. //格式化数据
  3170. foreach ($info_list as $key=>$value)
  3171. {
  3172. $shop = $this->shop->read($value['shop']);
  3173. $info_list[$key]['shop'] = $shop['shopname'];
  3174. $info_list[$key]['operation'] = "评价";
  3175. }
  3176. $total = $this->fullorderamz->find_count($where);
  3177. $pagenum = ceil($total/$perpage);
  3178. $over = $total-($start+$perpage);
  3179. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3180. echo json_encode($rows);exit;
  3181. }
  3182. $this->_Template('fullorderamz_evaluate',$this->data);
  3183. }
  3184. //订单消息
  3185. public function _state()
  3186. {
  3187. $user = $this->user->get_api($_SESSION['api']);
  3188. if($user)
  3189. {
  3190. $fgshop = "";$sid = "";
  3191. $user = explode('|',trim($user['shop'],'|'));
  3192. foreach ($user as $value)
  3193. {
  3194. $fgshop .= " shop = ".$value." or";
  3195. $sid .= " id = ".$value." or";
  3196. }
  3197. }
  3198. $post = $this->input->post(NULL, TRUE);
  3199. if(isset($post['page']))
  3200. {
  3201. $page = $this->input->post('page',true);
  3202. $perpage = $this->input->post('perpage',true);
  3203. $timetk = $this->input->post('timetk',true);
  3204. $timetj = $this->input->post('timetj',true);
  3205. $shop = $this->input->post('shop',true);
  3206. $expressstate = $this->input->post('expressstate',true);
  3207. $fs = $this->input->post('fs',true);
  3208. $state = $this->input->post('state',true);
  3209. $express = $this->input->post('express',true);
  3210. $review = $this->input->post('review',true);
  3211. $orderinfo = $this->input->post('orderinfo',true);
  3212. $number = $this->input->post('number',true);
  3213. $waybill = $this->input->post('waybill',true);
  3214. $xztime = $this->input->post('xztime',true);
  3215. $timetk = strtotime($timetk);
  3216. $timetj = strtotime($timetj);
  3217. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3218. if($timetk && $timetj)
  3219. {
  3220. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3221. }
  3222. if($xztime == 'librarytime')
  3223. {
  3224. $order_str = "librarytime desc";
  3225. }
  3226. else if($xztime == 'dtime')
  3227. {
  3228. $order_str = "dtime desc";
  3229. }
  3230. if($shop)
  3231. {
  3232. $where .= " and shop = '$shop'";
  3233. }
  3234. if($expressstate)
  3235. {
  3236. $where .= " and expressstate = '$expressstate'";
  3237. }
  3238. if($review)
  3239. {
  3240. $where .= " and review = '$review'";
  3241. }
  3242. if($fs)
  3243. {
  3244. if($fs == '2')
  3245. {
  3246. $where .= " and exstateerror != ''";
  3247. }
  3248. else
  3249. {
  3250. $where .= " and exstateerror = ''";
  3251. }
  3252. }
  3253. if($state)
  3254. {
  3255. $where .= " and state = '$state'";
  3256. }
  3257. if($express)
  3258. {
  3259. $where .= " and express = '$express'";
  3260. }
  3261. if($orderinfo)
  3262. {
  3263. $where .= " and orderinfo = '$orderinfo'";
  3264. }
  3265. if($number)
  3266. {
  3267. $where .= " and number = '$number'";
  3268. }
  3269. if($waybill)
  3270. {
  3271. $where .= " and waybill = '$waybill'";
  3272. }
  3273. if(empty($page))
  3274. {
  3275. $start = 0;
  3276. $perpage = 1;
  3277. }
  3278. else
  3279. {
  3280. $start = ($page - 1)*$perpage;
  3281. }
  3282. //取得信息列表
  3283. $info_list = $this->fullorderamz->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,content,orderremarks,exstateerror',$order_str,$start,$perpage);
  3284. //格式化数据
  3285. foreach ($info_list as $key=>$value)
  3286. {
  3287. $shop = $this->shop->read($value['shop']);
  3288. $info_list[$key]['shop'] = $shop['shopname'];
  3289. $country = $this->country->read($value['country']);
  3290. $info_list[$key]['country'] = $country['name'];
  3291. //$state = $this->typeclass->read($value['state']);
  3292. //$info_list[$key]['state'] = $state['title'];
  3293. if($value['library'] == 1)
  3294. {
  3295. $info_list[$key]['library'] = "未出库";
  3296. }
  3297. else if($value['library'] == 2)
  3298. {
  3299. $info_list[$key]['library'] = "已出库";
  3300. }
  3301. else if($value['library'] == 3)
  3302. {
  3303. $info_list[$key]['library'] = "已退库";
  3304. }
  3305. if($value['librarytime'] == '0')
  3306. {
  3307. $info_list[$key]['librarytime'] = '无';
  3308. }
  3309. else
  3310. {
  3311. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  3312. }
  3313. $express = $this->express->read($value['express']);
  3314. $info_list[$key]['express'] = $express['servicename'];
  3315. }
  3316. $total = $this->fullorderamz->find_count($where);
  3317. $pagenum = ceil($total/$perpage);
  3318. $over = $total-($start+$perpage);
  3319. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3320. echo json_encode($rows);exit;
  3321. }
  3322. $notice = $this->notice->find_all("type = '1' and (".rtrim($fgshop,'or').")");
  3323. $this->data['notice'] = $notice;
  3324. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3325. $this->data['wlshop'] = $wlshop;
  3326. $this->data['express'] = $this->express->find_all();
  3327. $this->_Template('fullorderamz_state',$this->data);
  3328. }
  3329. //物流信息
  3330. public function _wl()
  3331. {
  3332. $user = $this->user->get_api($_SESSION['api']);
  3333. if($user)
  3334. {
  3335. $fgshop = "";$sid = "";
  3336. $user = explode('|',trim($user['shop'],'|'));
  3337. foreach ($user as $value)
  3338. {
  3339. $fgshop .= " shop = ".$value." or";
  3340. $sid .= " id = ".$value." or";
  3341. }
  3342. }
  3343. $post = $this->input->post(NULL, TRUE);
  3344. if(isset($post['page']))
  3345. {
  3346. $page = $this->input->post('page',true);
  3347. $perpage = $this->input->post('perpage',true);
  3348. $timetk = $this->input->post('timetk',true);
  3349. $timetj = $this->input->post('timetj',true);
  3350. $shop = $this->input->post('shop',true);
  3351. $expressstate = $this->input->post('expressstate',true);
  3352. $fs = $this->input->post('fs',true);
  3353. $state = $this->input->post('state',true);
  3354. $express = $this->input->post('express',true);
  3355. $orderinfo = $this->input->post('orderinfo',true);
  3356. $number = $this->input->post('number',true);
  3357. $waybill = $this->input->post('waybill',true);
  3358. $wlyc = $this->input->post('wlyc',true);
  3359. $wltype = $this->input->post('wltype',true);
  3360. $source = $this->input->post('source',true);
  3361. $xztime = $this->input->post('xztime',true);
  3362. $timetk = strtotime($timetk);
  3363. $timetj = strtotime($timetj);
  3364. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3365. if($timetk && $timetj)
  3366. {
  3367. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3368. }
  3369. if($xztime == 'librarytime')
  3370. {
  3371. $order_str = "librarytime desc";
  3372. }
  3373. else if($xztime == 'dtime')
  3374. {
  3375. $order_str = "dtime desc";
  3376. }
  3377. else if ($xztime == 'wlfstime')
  3378. {
  3379. $order_str = "wlfstime desc";
  3380. }
  3381. if($shop)
  3382. {
  3383. $where .= " and shop = '$shop'";
  3384. }
  3385. if($expressstate != '')
  3386. {
  3387. $where .= " and expressstate = '$expressstate'";
  3388. }
  3389. if($fs)
  3390. {
  3391. if($fs == '1')
  3392. {
  3393. $where .= " and wlcontent != ''";
  3394. }
  3395. if($fs == '2')
  3396. {
  3397. $where .= " and wlerror != ''";
  3398. }
  3399. if($fs == '3')
  3400. {
  3401. $where .= " and wlcontent = '' and shouldmoney > 100";
  3402. }
  3403. else if($fs == '4')
  3404. {
  3405. $where .= " and wltype = '1'";
  3406. }
  3407. }
  3408. if($state)
  3409. {
  3410. $where .= " and state = '$state'";
  3411. }
  3412. if($express)
  3413. {
  3414. $where .= " and express = '$express'";
  3415. }
  3416. if($orderinfo)
  3417. {
  3418. $where .= " and orderinfo = '$orderinfo'";
  3419. }
  3420. if($number)
  3421. {
  3422. $where .= " and number = '$number'";
  3423. }
  3424. if($waybill)
  3425. {
  3426. $where .= " and waybill = '$waybill'";
  3427. }
  3428. if($wlyc!='')
  3429. {
  3430. $where .= " and wlyc = '$wlyc'";
  3431. }
  3432. if($wltype!='')
  3433. {
  3434. $where .= " and wltype = '$wltype'";
  3435. }
  3436. if($source)
  3437. {
  3438. if($source == 1)
  3439. {
  3440. $where .= " and source = '$source'";
  3441. }
  3442. else
  3443. {
  3444. $where .= " and source != '1'";
  3445. }
  3446. }
  3447. if(empty($page))
  3448. {
  3449. $start = 0;
  3450. $perpage = 1;
  3451. }
  3452. else
  3453. {
  3454. $start = ($page - 1)*$perpage;
  3455. }
  3456. //取得信息列表
  3457. $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);
  3458. //格式化数据
  3459. foreach ($info_list as $key=>$value)
  3460. {
  3461. $f = $this->fullorderamz->read($value['id']);
  3462. $info_list[$key]['number'] = "<p>".$value['number']."</p>"."<p>".$f['email']."</p>";
  3463. $country = $this->country->read($value['country']);
  3464. $info_list[$key]['country'] = "<p>".$country['name']."</p><p>".$f['phone']."</p>";
  3465. //$state = $this->typeclass->read($value['state']);
  3466. //$info_list[$key]['state'] = $state['title'];
  3467. if($value['library'] == 1)
  3468. {
  3469. $info_list[$key]['library'] = "未出库";
  3470. }
  3471. else if($value['library'] == 2)
  3472. {
  3473. $info_list[$key]['library'] = "已出库";
  3474. }
  3475. else if($value['library'] == 3)
  3476. {
  3477. $info_list[$key]['library'] = "已退库";
  3478. }
  3479. if($value['librarytime'] == '0')
  3480. {
  3481. $info_list[$key]['librarytime'] = '无';
  3482. }
  3483. else
  3484. {
  3485. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']).'<br>'.$f['shouldmoney'];
  3486. }
  3487. if($value['expressstate'] == 0)
  3488. {
  3489. $info_list[$key]['expressstate'] = "无信息";
  3490. }
  3491. else if($value['expressstate'] == 2)
  3492. {
  3493. $info_list[$key]['expressstate'] = "已取件";
  3494. }
  3495. else if($value['expressstate'] == 3)
  3496. {
  3497. $info_list[$key]['expressstate'] = "在途中";
  3498. }
  3499. else if($value['expressstate'] == 4)
  3500. {
  3501. $info_list[$key]['expressstate'] = "到达目的地国".$value['expressstate'];
  3502. }
  3503. else if($value['expressstate'] == 5)
  3504. {
  3505. $info_list[$key]['expressstate'] = "即将派送";
  3506. }
  3507. else if($value['expressstate'] == 6)
  3508. {
  3509. $info_list[$key]['expressstate'] = "已签收";
  3510. }
  3511. else if($value['expressstate'] == 1)
  3512. {
  3513. $info_list[$key]['expressstate'] = "派送异常";
  3514. }
  3515. $express = $this->express->read($value['express']);
  3516. $info_list[$key]['express'] = $express['servicename'];
  3517. if($value['wltype'] == '0')
  3518. {
  3519. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>禁止发送</b></p>";
  3520. }
  3521. else
  3522. {
  3523. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>允许发送</b></p>";
  3524. }
  3525. if($f['wlyc'] == '0')
  3526. {
  3527. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='1'>加入异常</b></p>";
  3528. }
  3529. else if($f['wlyc'] == '1')
  3530. {
  3531. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='2'>物流异常</b></p>";
  3532. }
  3533. else if($f['wlyc'] == '2')
  3534. {
  3535. $info_list[$key]['wltype'] .= "<p><b>异常已处理</b></p>";
  3536. }
  3537. if(stripos($value['excontent'],'<br />') !== false)
  3538. {
  3539. $excontent = explode('<br />',$value['excontent']);
  3540. $info_list[$key]['excontent'] = '<i class="method fa fa-list-ul" data-t="'.$value['excontent'].'"></i> '.$excontent[0];
  3541. }
  3542. }
  3543. $total = $this->fullorderamz->find_count($where);
  3544. $pagenum = ceil($total/$perpage);
  3545. $over = $total-($start+$perpage);
  3546. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3547. echo json_encode($rows);exit;
  3548. }
  3549. if(isset($post['q']))
  3550. {
  3551. $id = $this->input->post('id',true);
  3552. $f = $this->fullorderamz->read($id);
  3553. $wl = ($f['wltype']=='0')?1:0;
  3554. $wltitle = ($f['wltype']=='0')?'已禁发送':'已允发送';
  3555. if($this->fullorderamz->save(array('wltype'=>$wl),$id))
  3556. {
  3557. echo json_encode(array('msg'=>'ckn','id'=>$id,'wltitle'=>$wltitle,'success'=>true));exit;
  3558. }
  3559. else
  3560. {
  3561. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$wltitle,'success'=>false));exit;
  3562. }
  3563. }
  3564. if(isset($post['t']))
  3565. {
  3566. $id = $this->input->post('id',true);
  3567. $f = $this->fullorderamz->read($id);
  3568. $t = $this->input->post('t',true);
  3569. $yc = ($f['wlyc']=='0')?1:2;
  3570. $yctitle = ($f['wlyc']=='0')?'物流异常':'异常已处理';
  3571. if($this->fullorderamz->save(array('wlyc'=>$yc),$id))
  3572. {
  3573. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3574. }
  3575. else
  3576. {
  3577. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3578. }
  3579. }
  3580. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  3581. $this->data['notice'] = $notice;
  3582. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3583. $this->data['wlshop'] = $wlshop;
  3584. $this->data['express'] = $this->express->find_all();
  3585. $this->_Template('fullorderamz_wl',$this->data);
  3586. }
  3587. //审核订单
  3588. public function _review()
  3589. {
  3590. $user = $this->user->get_api($_SESSION['api']);
  3591. if($user)
  3592. {
  3593. $fgshop = "";$sid = "";
  3594. $user = explode('|',trim($user['shop'],'|'));
  3595. foreach ($user as $value)
  3596. {
  3597. $sid .= " id = ".$value." or";
  3598. $fgshop .= " shop = ".$value." or";
  3599. }
  3600. $fgshop = " and (".rtrim($fgshop,'or').")";
  3601. }
  3602. $post = $this->input->post(NULL, TRUE);
  3603. if(isset($post['page']))
  3604. {
  3605. $page = $this->input->post('page',true);
  3606. $perpage = $this->input->post('perpage',true);
  3607. $source = $this->input->post('source',true);
  3608. $warehouse = $this->input->post('warehouse',true);
  3609. $express = $this->input->post('express',true);
  3610. $orderremarks = $this->input->post('orderremarks',true);
  3611. $shop = $this->input->post('shop',true);
  3612. $review = $this->input->post('review',true);
  3613. $orderinfo = $this->input->post('orderinfo',true);
  3614. $shipremarks = $this->input->post('shipremarks',true);
  3615. $number = $this->input->post('number',true);
  3616. $timetk = $this->input->post('timetk',true);
  3617. $timetj = $this->input->post('timetj',true);
  3618. $timetk = strtotime($timetk);
  3619. $timetj = strtotime($timetj);
  3620. $where = "mergeid = 0 and state = '207'".$fgshop;
  3621. if($timetk && $timetj)
  3622. {
  3623. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3624. }
  3625. if($source)
  3626. {
  3627. if($source == '2d')
  3628. {
  3629. $where .= " and source >= '2'";
  3630. }
  3631. else
  3632. {
  3633. $where .= " and source = '$source'";
  3634. }
  3635. }
  3636. if($review)
  3637. {
  3638. $where .= " and review = '$review'";
  3639. }
  3640. else
  3641. {
  3642. $where .= " and ((review = '2' and source = '1') or (review = '1' and source >= '2'))";
  3643. }
  3644. if($shop)
  3645. {
  3646. $where .= " and shop = '$shop'";
  3647. }
  3648. if($warehouse)
  3649. {
  3650. $where .= " and type = '$warehouse'";
  3651. }
  3652. if($express)
  3653. {
  3654. $where .= " and express = '$express'";
  3655. }
  3656. if($orderremarks)
  3657. {
  3658. $where .= " and orderremarks like '%$orderremarks%'";
  3659. }
  3660. if($orderinfo)
  3661. {
  3662. $where .= " and orderinfo = '$orderinfo'";
  3663. }
  3664. if($number)
  3665. {
  3666. $where .= " and number = '$number'";
  3667. }
  3668. if($shipremarks)
  3669. {
  3670. $where .= " and shipremarks like '%$shipremarks%'";
  3671. }
  3672. //数据排序
  3673. $order_str = "id desc";
  3674. if(empty($page))
  3675. {
  3676. $start = 0;
  3677. $perpage = 1;
  3678. }
  3679. else
  3680. {
  3681. $start = ($page - 1)*$perpage;
  3682. }
  3683. //取得信息列表
  3684. $info_list = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,client,express,dtime,shouldmoney,review,orderremarks');
  3685. //格式化数据
  3686. foreach ($info_list as $key=>$value)
  3687. {
  3688. $lr = $this->fullorderamz->read($value['id']);
  3689. $shop = $this->shop->read($value['shop']);
  3690. $info_list[$key]['shop'] = $shop['shopname'];
  3691. $warehouse = $this->warehouse->read($value['type']);
  3692. $info_list[$key]['type'] = $warehouse['title'];
  3693. $express = $this->express->read($value['express']);
  3694. $info_list[$key]['express'] = $express['servicename'];
  3695. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']).'</p><p>'.date('H:i:s',$value['dtime']).'</p>';
  3696. if($value['review'] == 1)
  3697. {
  3698. $info_list[$key]['review'] = "未送审";
  3699. }
  3700. else if($value['review'] == 2)
  3701. {
  3702. $info_list[$key]['review'] = "待审核";
  3703. }
  3704. else if($value['review'] == 3)
  3705. {
  3706. $info_list[$key]['review'] = "不通过";
  3707. }
  3708. else if($value['review'] == 4)
  3709. {
  3710. $info_list[$key]['review'] = "取消重审";
  3711. }
  3712. else if($value['review'] == 5)
  3713. {
  3714. $info_list[$key]['review'] = "审核通过";
  3715. }
  3716. else if($value['review'] == 6)
  3717. {
  3718. $info_list[$key]['review'] = "自动通过";
  3719. }
  3720. /**
  3721. $info_list[$key]['library'] = "";
  3722. if($value['review'] == 1)
  3723. {
  3724. $info_list[$key]['library'] = "<p><b class='focz' data-type='6' data-id='".$value['id']."'>审核通过</b></p>";
  3725. }
  3726. if($value['review'] == 2)
  3727. {
  3728. $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>";
  3729. }
  3730. else if($value['review'] == 3)
  3731. {
  3732. $info_list[$key]['library'] = "<p><b class='fullorderamzreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  3733. }
  3734. else if($value['review'] == 5)
  3735. {
  3736. $info_list[$key]['library'] = "<p><b class='fullorderamzreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  3737. }
  3738. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  3739. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  3740. $cost = $lr['cost']/$lr['hl'];
  3741. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  3742. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  3743. **/
  3744. }
  3745. $total = $this->fullorderamz->find_count($where);
  3746. $pagenum = ceil($total/$perpage);
  3747. $over = $total-($start+$perpage);
  3748. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3749. echo json_encode($rows);exit;
  3750. }
  3751. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3752. $this->data['shop'] = $wlshop;
  3753. $this->_Template('fullorderamz_review',$this->data);
  3754. }
  3755. public function _wlbz($arg_array)
  3756. {
  3757. $post = $this->input->post(NULL, TRUE);
  3758. if(isset($post['id']))
  3759. {
  3760. $id = $this->input->post('id',true);
  3761. $post['wlbz'] = $this->input->post('wlbz',true);
  3762. if($post['wlbz'] == '')
  3763. {
  3764. echo json_encode(array('msg'=>'备注不能为空','success'=>false));exit;
  3765. }
  3766. if($this->fullorderamz->save($post,$id))
  3767. {
  3768. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  3769. }
  3770. else
  3771. {
  3772. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  3773. }
  3774. }
  3775. $arg_array = $arg_array[0];
  3776. $fullorderamz = $this->fullorderamz->read($arg_array);
  3777. $this->data['fullorderamz'] = $fullorderamz;
  3778. $this->_Template('fullorderamz_wlbz',$this->data);
  3779. }
  3780. //导出资金统计excel
  3781. public function _fmexcel()
  3782. {
  3783. $user = $this->user->get_api($_SESSION['api']);
  3784. if($user)
  3785. {
  3786. $fgshop = "";$sid = "";
  3787. $user = explode('|',trim($user['shop'],'|'));
  3788. foreach ($user as $value)
  3789. {
  3790. $fgshop .= " shop = ".$value." or";
  3791. $sid .= " id = ".$value." or";
  3792. }
  3793. }
  3794. if(isset($_GET['excel']))
  3795. {
  3796. $timetk = $this->input->get('timetk',true);
  3797. $timetj = $this->input->get('timetj',true);
  3798. $shop = $this->input->get('shop',true);
  3799. $source = $this->input->get('source',true);
  3800. $state = $this->input->get('state',true);
  3801. $type = $this->input->get('type',true);
  3802. $orderinfo = $this->input->get('orderinfo',true);
  3803. $user = $this->input->get('user',true);
  3804. $name = $this->input->get('name',true);
  3805. $timetk = strtotime($timetk);
  3806. $timetj = strtotime($timetj);
  3807. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3808. if($timetk && $timetj)
  3809. {
  3810. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3811. }
  3812. if($shop)
  3813. {
  3814. $where .= " and shop = '$shop'";
  3815. }
  3816. if($source)
  3817. {
  3818. $where .= " and source = '$source'";
  3819. }
  3820. if($state)
  3821. {
  3822. if($state == 1)
  3823. {
  3824. $where .= " and state = '$state'";
  3825. }
  3826. }
  3827. if($type)
  3828. {
  3829. $where .= " and type = '$type'";
  3830. }
  3831. if($orderinfo)
  3832. {
  3833. $where .= " and orderinfo = '$orderinfo'";
  3834. }
  3835. if($user)
  3836. {
  3837. $where .= " and user = '$user'";
  3838. }
  3839. if($name)
  3840. {
  3841. $where .= " and name = '$name'";
  3842. }
  3843. //取得信息列表
  3844. $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');
  3845. //格式化数据
  3846. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  3847. foreach ($info_list as $key=>$value)
  3848. {
  3849. $info_list[$key]['id'] = $i;
  3850. if($value['currencytitle'] != "CNY")
  3851. {
  3852. $hl=$value['hl'];
  3853. }
  3854. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3855. $budget=$budget+($value['budget']*$hl);
  3856. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3857. $refund=$refund+($value['refund']*$hl);
  3858. $shop = $this->shop->read($value['shop']);
  3859. $info_list[$key]['shop'] = $shop['shopname'];
  3860. $info_list[$key]['user'] = $shop['shopuser'];
  3861. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3862. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3863. $country = $this->country->read($value['country']);
  3864. $info_list[$key]['country'] = $country['name'];
  3865. $express = $this->express->read($value['express']);
  3866. $info_list[$key]['express'] = $express['servicename'];
  3867. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3868. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  3869. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  3870. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  3871. $fpdata = array();
  3872. if(stripos($value['fpdata'],';') !== false)
  3873. {
  3874. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3875. foreach ($fpdata as $ke=>$va)
  3876. {
  3877. $v = explode('|',rtrim($va,'|'));
  3878. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3879. }
  3880. }
  3881. $info_list[$key]['fpdata'] = $fpdata;
  3882. $i++;
  3883. }
  3884. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  3885. $title = "订单资金信息";
  3886. $titlename = "<table border=1>
  3887. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3888. <tr>
  3889. <td>NO.</td>
  3890. <td>店铺</td>
  3891. <td>负责人</td>
  3892. <td>编号</td>
  3893. <td>订单号</td>
  3894. <td>客户姓名</td>
  3895. <td>国家</td>
  3896. <td>订单日期</td>
  3897. <td>发货日期</td>
  3898. <td>快递公司</td>
  3899. <td>运单号</td>
  3900. <td>订单金额</td>
  3901. <td>退款金额</td>
  3902. <td>手续费</td>
  3903. <td>预估金额</td>
  3904. <td>
  3905. <table border=1>
  3906. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  3907. <tr>
  3908. <td>产品</td>
  3909. <td>条数</td>
  3910. <td>数量</td>
  3911. </tr>
  3912. </table>
  3913. </td>
  3914. <td>总条数</td>
  3915. </tr>
  3916. </table>";
  3917. $filename = $title.".xls";
  3918. $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";
  3919. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  3920. }
  3921. }
  3922. //导出订单excel
  3923. public function _fdexcel()
  3924. {
  3925. if(isset($_GET['excel']))
  3926. {
  3927. $page = $this->input->post('page',true);
  3928. $perpage = $this->input->post('perpage',true);
  3929. $timetk = $this->input->post('timetk',true);
  3930. $timetj = $this->input->post('timetj',true);
  3931. $shop = $this->input->post('shop',true);
  3932. $source = $this->input->post('source',true);
  3933. $state = $this->input->post('state',true);
  3934. $review = $this->input->post('review',true);
  3935. $express = $this->input->post('express',true);
  3936. $orderinfo = $this->input->post('orderinfo',true);
  3937. $user = $this->input->post('user',true);
  3938. $name = $this->input->post('name',true);
  3939. $waybill = $this->input->post('waybill',true);
  3940. $timetk = strtotime($timetk);
  3941. $timetj = strtotime($timetj);
  3942. $where = "1=1 and mergeid = 0";
  3943. if($timetk && $timetj)
  3944. {
  3945. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3946. }
  3947. if($shop)
  3948. {
  3949. $where .= " and shop = '$shop'";
  3950. }
  3951. if($source)
  3952. {
  3953. $where .= " and source = '$source'";
  3954. }
  3955. if($state)
  3956. {
  3957. $where .= " and state = '$state'";
  3958. }
  3959. if($review)
  3960. {
  3961. $where .= " and review = '$review'";
  3962. }
  3963. if($express)
  3964. {
  3965. $where .= " and express = '$express'";
  3966. }
  3967. if($orderinfo)
  3968. {
  3969. $where .= " and orderinfo = '$orderinfo'";
  3970. }
  3971. if($user)
  3972. {
  3973. $where .= " and user = '$user'";
  3974. }
  3975. if($name)
  3976. {
  3977. $where .= " and name = '$name'";
  3978. }
  3979. if($waybill)
  3980. {
  3981. $where .= " and waybill = '$waybill'";
  3982. }
  3983. //取得信息列表
  3984. $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');
  3985. //格式化数据
  3986. $i = 1;$shouldmoney = 0;$hl=1;
  3987. foreach ($info_list as $key=>$value)
  3988. {
  3989. $info_list[$key]['id'] = $i;
  3990. if($value['source'] == 1)
  3991. {
  3992. $info_list[$key]['source'] = "线下订单";
  3993. }
  3994. else if($value['source'] == 2)
  3995. {
  3996. $info_list[$key]['source'] = "PC订单";
  3997. }
  3998. else if($value['source'] == 3)
  3999. {
  4000. $info_list[$key]['source'] = "手机订单";
  4001. }
  4002. if($value['currencytitle'] != "CNY")
  4003. {
  4004. $hl=$value['hl'];
  4005. }
  4006. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  4007. $shop = $this->shop->read($value['shop']);
  4008. $info_list[$key]['shop'] = $shop['shopname'];
  4009. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  4010. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  4011. $state = $this->typeclass->read($value['state']);
  4012. $info_list[$key]['state'] = $state['title'];
  4013. $country = $this->country->read($value['country']);
  4014. $info_list[$key]['country'] = $country['name'];
  4015. $express = $this->express->read($value['express']);
  4016. $info_list[$key]['express'] = $express['servicename'];
  4017. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  4018. $fpdata = array();
  4019. if(stripos($value['fpdata'],';') !== false)
  4020. {
  4021. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  4022. foreach ($fpdata as $ke=>$va)
  4023. {
  4024. $v = explode('|',rtrim($va,'|'));
  4025. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  4026. }
  4027. }
  4028. $info_list[$key]['fpdata'] = $fpdata;
  4029. $i++;
  4030. }
  4031. $data = array($shouldmoney.' CNY');
  4032. $title = "订单信息表";
  4033. $titlename = "<table border=1>
  4034. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  4035. <tr>
  4036. <td>NO.</td>
  4037. <td>店铺</td>
  4038. <td>编号</td>
  4039. <td>订单号</td>
  4040. <td>订单类型</td>
  4041. <td>客户姓名</td>
  4042. <td>收件人名称</td>
  4043. <td>收货人地址</td>
  4044. <td>城市</td>
  4045. <td>邮编</td>
  4046. <td>州</td>
  4047. <td>国家</td>
  4048. <td>收件电话</td>
  4049. <td>订单日期</td>
  4050. <td>发货日期</td>
  4051. <td>订单状态</td>
  4052. <td>订单金额</td>
  4053. <td>快递公司</td>
  4054. <td>运单号</td>
  4055. <td>订单备注</td>
  4056. <td>客户备注</td>
  4057. <td>
  4058. <table border=1>
  4059. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4060. <tr>
  4061. <td>产品</td>
  4062. <td>条数</td>
  4063. <td>数量</td>
  4064. </tr>
  4065. </table>
  4066. </td>
  4067. <td>总条数</td>
  4068. </tr>
  4069. </table>";
  4070. $filename = $title.".xls";
  4071. $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";
  4072. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4073. }
  4074. }
  4075. public function _black()
  4076. {
  4077. $post = $this->input->post(NULL, TRUE);
  4078. if(isset($post['bd']))
  4079. {
  4080. $bd = $this->input->post('bd',true);
  4081. $rows = $this->fullorderamz->read($bd);
  4082. $post['shop'] = $rows['shop'];
  4083. $post['source'] = 1;
  4084. $post['name'] = $rows['client'];
  4085. $post['email'] = $rows['email'];
  4086. $post['phone'] = $rows['phone'];
  4087. $post['country'] = $rows['country'];
  4088. $post['money'] = $rows['shouldmoney'];
  4089. $post['num'] = 1;
  4090. $post['time'] = $rows['dtime'];
  4091. $post['province'] = $rows['province'];
  4092. $post['city'] = $rows['city'];
  4093. $post['street'] = $rows['street'];
  4094. $post['address'] = $rows['address'];
  4095. $post['address2'] = $rows['address2'];
  4096. $post['zipcode'] = $rows['zipcode'];
  4097. $post['type'] = 2;
  4098. if($this->customeramz->insert($post))
  4099. {
  4100. $this->fullorderamz->save(array('black'=>1),$bd);
  4101. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4102. }
  4103. else
  4104. {
  4105. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4106. }
  4107. }
  4108. }
  4109. public function _ryf()
  4110. {
  4111. $post = $this->input->post(NULL, TRUE);
  4112. if(isset($post['bd']))
  4113. {
  4114. $bd = $this->input->post('bd',true);
  4115. $d = $this->fullorderamz->read($bd);
  4116. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  4117. {
  4118. if($d['print'] < 3)//打印状态为未打印
  4119. {
  4120. $print = 1;//未打印
  4121. $libraryconfirm = 1;//不允许出库
  4122. $a = "订单未打印,";
  4123. }
  4124. else//已打印订单
  4125. {
  4126. $libraryconfirm = 2;//允许出库
  4127. $a = "";
  4128. }
  4129. if($this->fullorderamz->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4130. {
  4131. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4132. }
  4133. else
  4134. {
  4135. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4136. }
  4137. }
  4138. if($this->fullorderamz->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4139. {
  4140. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  4141. }
  4142. else
  4143. {
  4144. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4145. }
  4146. }
  4147. }
  4148. public function _fsstate()
  4149. {
  4150. $post = $this->input->post(NULL, TRUE);
  4151. if(isset($post['s']))
  4152. {
  4153. $id_arr = $this->input->post('s');
  4154. $id_arr = explode(',',$id_arr);
  4155. if(!$id_arr)
  4156. {
  4157. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4158. }
  4159. foreach ($id_arr as $v)
  4160. {
  4161. $data = $this->fullorderamz->read($v);
  4162. $warehouse = $this->warehouse->read($data['type']);
  4163. $fs = $this->notice->get_ordertatus($data['state']);
  4164. if($fs)
  4165. {
  4166. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  4167. if($ck == 1)
  4168. {
  4169. $this->fullorderamz->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  4170. }
  4171. }
  4172. }
  4173. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  4174. }
  4175. }
  4176. public function _power()
  4177. {
  4178. $user = $this->user->get_api($_SESSION['api']);
  4179. $post = $this->input->post(NULL, TRUE);
  4180. if(isset($post['id']))
  4181. {
  4182. $id = $this->input->post('id',true);
  4183. $fullorderamz = $this->fullorderamz->read($id);
  4184. $express = $this->express->read($fullorderamz['express']);
  4185. $warehouse = $this->warehouse->read($fullorderamz['type']);
  4186. if(($warehouse['zd'] == '1' || stripos($fullorderamz['whlabel'],'z|') !== false) && $fullorderamz['library'] == '2')
  4187. {
  4188. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  4189. }
  4190. /**
  4191. if($fullorderamz['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  4192. {
  4193. $lj = $this->ali->get_lj($fullorderamz['number'],2,'订单修改');
  4194. if($lj != '1' && $lj != '订单不存在')
  4195. {
  4196. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  4197. }
  4198. }
  4199. **/
  4200. $warehouse = $this->warehouse->read($fullorderamz['warehouse']);
  4201. $typeclass = $this->typeclass->read($fullorderamz['state']);
  4202. $express = $this->express->read($fullorderamz['express']);
  4203. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  4204. $teset['number']=$fullorderamz['number'];
  4205. $teset['orderinfo']=$fullorderamz['orderinfo'];
  4206. $teset['shop']=$fullorderamz['shop'];
  4207. $teset['user']=$user['userid'];
  4208. $teset['ip']=$this->input->ip_address();
  4209. $teset['time']=time();
  4210. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  4211. $teset['state']=(isset($typeclass['title']))?$typeclass['spare']:'未选择';
  4212. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  4213. $teset['printtype']=(isset($printtype[$fullorderamz['printtype']]))?$printtype[$fullorderamz['printtype']]:'未选择';
  4214. $teset['reviewtime']=($fullorderamz['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullorderamz['reviewtime']):'无';
  4215. $teset['printtime']=($fullorderamz['printtime'] > '0')?date('Y-m-d H:i:s',$fullorderamz['printtime']):'无';
  4216. $teset['librarytime']=($fullorderamz['librarytime'] > '0')?date('Y-m-d H:i:s',$fullorderamz['librarytime']):'无';
  4217. $teset['shipremarks']=$fullorderamz['shipremarks'];
  4218. $teset['fpdata']=$fullorderamz['fpdata'];
  4219. $teset['oldwaybill']=$fullorderamz['oldwaybill'];
  4220. $teset['oldprinttime']=$fullorderamz['oldprinttime'];
  4221. if($fullorderamz['printtype'] == 1)
  4222. {
  4223. if($fullorderamz['waybill'] != '' && stripos($fullorderamz['oldwaybill'],$fullorderamz['waybill']) === false)
  4224. {
  4225. $teset['oldwaybill'] .= '-'.date('Ymd',$fullorderamz['printtime']).'/'.$fullorderamz['waybill'];
  4226. $teset['oldprinttime'] .= '-'.$fullorderamz['printtime'];
  4227. }
  4228. }
  4229. $review = ($fullorderamz['source']==1)?2:1;//线下单审核状态直接为待审核
  4230. if(!$this->fullreset->insert($teset))
  4231. {
  4232. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  4233. }
  4234. 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))
  4235. {
  4236. echo json_encode(array('msg'=>'重置成功!如需再次提交,请先保存、再提交','success'=>true));exit;
  4237. }
  4238. else
  4239. {
  4240. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  4241. }
  4242. }
  4243. }
  4244. public function _expresstype()
  4245. {
  4246. $post = $this->input->post(NULL, TRUE);
  4247. if(isset($post['id']))
  4248. {
  4249. $id = $this->input->post('id',true);
  4250. $data = $this->express->read($id);
  4251. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  4252. }
  4253. }
  4254. public function _email($content,$data,$shopname)
  4255. {
  4256. $express = $this->express->read($data['express']);
  4257. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  4258. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  4259. $content = str_replace($t,$h,$content);
  4260. $this->load->library('email');
  4261. $config['protocol'] = 'smtp';
  4262. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  4263. $config['smtp_port'] = 465;
  4264. $config['smtp_user'] = 'service@email.supernovahair.com';
  4265. $config['smtp_pass'] = 'LONGyihair374';
  4266. $config['smtp_crypto'] = 'ssl';
  4267. $config['crlf'] = "\r\n";
  4268. $config['newline'] = "\r\n";
  4269. $this->email->initialize($config);
  4270. $this->email->from('service@email.supernovahair.com',$shopname);
  4271. $this->email->to($data['email']);//收件
  4272. $this->email->subject('The product you purchased has a new progress');//标题
  4273. $this->email->message($content);//内容
  4274. if ( ! $this->email->send())
  4275. {
  4276. return 2;
  4277. }
  4278. else
  4279. {
  4280. return 1;
  4281. }
  4282. }
  4283. public function _error()
  4284. {
  4285. if(isset($_SESSION['api']))
  4286. {
  4287. $user = $this->user->get_api($_SESSION['api']);
  4288. $usp = $user;
  4289. $fgshop = "";$sid = "";
  4290. $user = explode('|',trim($user['shop'],'|'));
  4291. foreach ($user as $value)
  4292. {
  4293. $fgshop .= " shop = ".$value." or";
  4294. $sid .= " id = ".$value." or";
  4295. }
  4296. }
  4297. $post = $this->input->post(NULL, TRUE);
  4298. if(isset($post['page']))
  4299. {
  4300. $page = $this->input->post('page',true);
  4301. $perpage = $this->input->post('perpage',true);
  4302. $orderinfo = $this->input->post('orderinfo',true);
  4303. $waybill = $this->input->post('waybill',true);
  4304. $number = $this->input->post('number',true);
  4305. $timetk = $this->input->post('timetk',true);
  4306. $timetj = $this->input->post('timetj',true);
  4307. $timetk = strtotime($timetk);
  4308. $timetj = strtotime($timetj);
  4309. $where = "failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').")";
  4310. if($orderinfo)
  4311. {
  4312. $where .= " and orderinfo = '$orderinfo'";
  4313. }
  4314. if($waybill)
  4315. {
  4316. $where .= " and waybill = '$waybill'";
  4317. }
  4318. if($number)
  4319. {
  4320. $where .= " and number = '$number'";
  4321. }
  4322. if($timetk && $timetj)
  4323. {
  4324. $timetj = $timetj+24*3600;
  4325. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4326. }
  4327. //数据排序
  4328. $order_str = "dtime desc";
  4329. if(empty($page))
  4330. {
  4331. $start = 0;
  4332. $perpage = 1;
  4333. }
  4334. else
  4335. {
  4336. $start = ($page - 1)*$perpage;
  4337. }
  4338. $info_list = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  4339. //格式化数据
  4340. foreach ($info_list as $key=>$value)
  4341. {
  4342. $ud = $this->fullorderamz->read($value['id']);
  4343. $shop = $this->shop->read($value['shop']);
  4344. $info_list[$key]['shop'] = $shop['shopname'];
  4345. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorderamz/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4346. $warehouse = $this->warehouse->read($value['type']);
  4347. $warehousetitle = $warehouse['title'];
  4348. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4349. $info_list[$key]['type'] = $warehousetitle;
  4350. if($value['express'] != 0)
  4351. {
  4352. $express = $this->express->read($value['express']);
  4353. $expressservicename = $express['servicename'];
  4354. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4355. $info_list[$key]['express'] = $expressservicename;
  4356. }
  4357. else
  4358. {
  4359. $info_list[$key]['express'] = "无";
  4360. }
  4361. $x = "";
  4362. if($ud['review'] >4 && $ud['print'] == 1)
  4363. {
  4364. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  4365. }
  4366. else
  4367. {
  4368. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  4369. }
  4370. $info_list[$key]['operation'] = $x;
  4371. }
  4372. $total = $this->fullorderamz->find_count($where);
  4373. $pagenum = ceil($total/$perpage);
  4374. $over = $total-($start+$perpage);
  4375. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4376. echo json_encode($rows);exit;
  4377. }
  4378. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4379. $this->data['wlshop'] = $wlshop;
  4380. $this->data['express'] = $this->express->find_all();
  4381. $user = $this->user->get_api($_SESSION['api']);
  4382. $powerid = $this->power->read($user['power']);
  4383. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4384. $pid = '';
  4385. foreach ($powertext as $v)
  4386. {
  4387. $pid .= " id = ".$v." or";
  4388. }
  4389. $fullorderexcel = $this->fullorderexcel->find_all("type = '100009' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4390. $this->data['fullorderexcel'] = $fullorderexcel;
  4391. $this->_Template('fullorderamz_error',$this->data);
  4392. }
  4393. public function _yc()
  4394. {
  4395. if(isset($_SESSION['api']))
  4396. {
  4397. $user = $this->user->get_api($_SESSION['api']);
  4398. $usp = $user;
  4399. $fgshop = "";$sid = "";
  4400. $user = explode('|',trim($user['shop'],'|'));
  4401. foreach ($user as $value)
  4402. {
  4403. $fgshop .= " shop = ".$value." or";
  4404. $sid .= " id = ".$value." or";
  4405. }
  4406. }
  4407. $post = $this->input->post(NULL, TRUE);
  4408. if(isset($post['page']))
  4409. {
  4410. $page = $this->input->post('page',true);
  4411. $perpage = $this->input->post('perpage',true);
  4412. $orderinfo = $this->input->post('orderinfo',true);
  4413. $waybill = $this->input->post('waybill',true);
  4414. $number = $this->input->post('number',true);
  4415. $timetk = $this->input->post('timetk',true);
  4416. $timetj = $this->input->post('timetj',true);
  4417. $timetk = strtotime($timetk);
  4418. $timetj = strtotime($timetj);
  4419. $where = "library = 2 and state = 214 and (".rtrim($fgshop,'or').")";
  4420. if($orderinfo)
  4421. {
  4422. $where .= " and orderinfo = '$orderinfo'";
  4423. }
  4424. if($waybill)
  4425. {
  4426. $where .= " and waybill = '$waybill'";
  4427. }
  4428. if($number)
  4429. {
  4430. $where .= " and number = '$number'";
  4431. }
  4432. if($timetk && $timetj)
  4433. {
  4434. $timetj = $timetj+24*3600;
  4435. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4436. }
  4437. //数据排序
  4438. $order_str = "dtime desc";
  4439. if(empty($page))
  4440. {
  4441. $start = 0;
  4442. $perpage = 1;
  4443. }
  4444. else
  4445. {
  4446. $start = ($page - 1)*$perpage;
  4447. }
  4448. $info_list = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,state,dtime,express,waybill,library,operation',$order_str,$start,$perpage);
  4449. //格式化数据
  4450. foreach ($info_list as $key=>$value)
  4451. {
  4452. $ud = $this->fullorderamz->read($value['id']);
  4453. $shop = $this->shop->read($value['shop']);
  4454. $info_list[$key]['shop'] = $shop['shopname'];
  4455. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorderamz/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4456. $warehouse = $this->warehouse->read($value['type']);
  4457. $warehousetitle = $warehouse['title'];
  4458. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4459. $info_list[$key]['type'] = $warehousetitle;
  4460. if($value['express'] != 0)
  4461. {
  4462. $express = $this->express->read($value['express']);
  4463. $expressservicename = $express['servicename'];
  4464. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4465. $info_list[$key]['express'] = $expressservicename;
  4466. }
  4467. else
  4468. {
  4469. $info_list[$key]['express'] = "无";
  4470. }
  4471. $typeclass = $this->typeclass->read($value['state']);
  4472. $info_list[$key]['state'] = "<font style='font-size: 13px;'>".$typeclass['spare']."</font>";
  4473. $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>';
  4474. if($value['library'] == 1 && $ud['printtype'] == 3)
  4475. {
  4476. $info_list[$key]['library'] = "不需要";
  4477. }
  4478. else if($value['library'] == 1 && $ud['printtype'] != 3)
  4479. {
  4480. $info_list[$key]['library'] = "未出库";
  4481. }
  4482. else if($value['library'] == 2)
  4483. {
  4484. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  4485. }
  4486. else if($value['library'] == 3)
  4487. {
  4488. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  4489. }
  4490. $info_list[$key]['operation'] = "<p class='ckn'><b class='ycyc' data-id='".$value['id']."'>移 出</b></p>";
  4491. }
  4492. $total = $this->fullorderamz->find_count($where);
  4493. $pagenum = ceil($total/$perpage);
  4494. $over = $total-($start+$perpage);
  4495. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4496. echo json_encode($rows);exit;
  4497. }
  4498. if(isset($post['id']))
  4499. {
  4500. $id = $this->input->post('id',true);
  4501. $data = $this->fullorderamz->read($id);
  4502. if($this->fullorderamz->save(array('state'=>217),$id))
  4503. {
  4504. echo json_encode(array('msg'=>'移除成功','id'=>$id,'success'=>true));exit;
  4505. }
  4506. else
  4507. {
  4508. echo json_encode(array('msg'=>"操作失败请重试",'success'=>false));exit;
  4509. }
  4510. }
  4511. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4512. $this->data['wlshop'] = $wlshop;
  4513. $this->data['express'] = $this->express->find_all();
  4514. $user = $this->user->get_api($_SESSION['api']);
  4515. $powerid = $this->power->read($user['power']);
  4516. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4517. $pid = '';
  4518. foreach ($powertext as $v)
  4519. {
  4520. $pid .= " id = ".$v." or";
  4521. }
  4522. $fullorderexcel = $this->fullorderexcel->find_all("type = '100009' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4523. $this->data['fullorderexcel'] = $fullorderexcel;
  4524. $this->_Template('fullorderamz_yc',$this->data);
  4525. }
  4526. //验证地址
  4527. public function _yzaddress()
  4528. {
  4529. $post = $this->input->post(NULL, TRUE);
  4530. if(isset($post['address']))
  4531. {
  4532. $address = $this->input->post('address',true);
  4533. $address2 = $this->input->post('address2',true);
  4534. $city = $this->input->post('city',true);
  4535. $province = $this->input->post('province',true);
  4536. $zipcode = $this->input->post('zipcode',true);
  4537. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  4538. echo $barcode;
  4539. }
  4540. }
  4541. //清除退货信息
  4542. public function _clearreturn()
  4543. {
  4544. $post = $this->input->post(NULL, TRUE);
  4545. if(isset($post['orderinfo']))
  4546. {
  4547. $orderinfo = $this->input->post('orderinfo',true);
  4548. $data = $this->fullorderamz->get_orderinfo($orderinfo);
  4549. $fu = 'fullorderamz';
  4550. if(!$data)
  4551. {
  4552. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4553. $fu = 'fullorder_smt';
  4554. }
  4555. $this->$fu->save(array('library'=>'2','retreattime'=>'0','returndata'=>''),$data['id']);
  4556. echo json_encode(array('msg'=>'清除成功!','success'=>true));exit;
  4557. }
  4558. }
  4559. //订单退货
  4560. public function _return()
  4561. {
  4562. $post = $this->input->post(NULL, TRUE);
  4563. if(isset($post['orderinfo']))
  4564. {
  4565. $orderinfo = $this->input->post('orderinfo',true);
  4566. $data = $this->fullorderamz->get_orderinfo($orderinfo);
  4567. $fu = 'fullorderamz';
  4568. if(!$data)
  4569. {
  4570. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4571. $fu = 'fullorder_smt';
  4572. }
  4573. if($data['library'] != 2){
  4574. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  4575. }
  4576. $bctime = date('Ymd',time());
  4577. if($data['returndata'] != "")
  4578. {
  4579. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4580. }
  4581. $barcode = $this->usps->get_return($data);
  4582. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4583. {
  4584. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4585. }
  4586. else if(isset($barcode['trackingNumber']))
  4587. {
  4588. $pdf = $this->_pdf($barcode['returnLabelImage'],'t-'.$barcode['trackingNumber'],$bctime);
  4589. $read = 'PostalRouting:'.$barcode['routingInformation'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['trackingNumber'].'.pdf" target="_blank">'.$barcode['trackingNumber'].'</a>';
  4590. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4591. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4592. }
  4593. else
  4594. {
  4595. echo json_encode(array('msg'=>'请求失败,请稍后重试!'.json_encode($barcode),'cs'=>$barcode,'success'=>false));exit;
  4596. }
  4597. // if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4598. // {
  4599. // echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4600. // }
  4601. // else if(isset($barcode['TrackingNumber']))
  4602. // {
  4603. // $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  4604. // $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  4605. // $this->$fu->save(array('returndata'=>$read),$data['id']);
  4606. // echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4607. // }
  4608. // else
  4609. // {
  4610. // echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4611. // }
  4612. }
  4613. }
  4614. public function _pdf($pdf,$title,$bctime)
  4615. {
  4616. $pdf_path = './data/pdf/'.$bctime.'/';
  4617. $file_base64 = $pdf;
  4618. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4619. $file_base64 = base64_decode($file_base64);
  4620. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  4621. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  4622. return $bctime;
  4623. }
  4624. public function _find($find)
  4625. {
  4626. preg_match_all('/\d+/',$find,$n);
  4627. $a = '';
  4628. foreach($n[0] as $v)
  4629. {
  4630. $a .= $v;
  4631. }
  4632. return $a;
  4633. }
  4634. public function _dqpm()
  4635. {
  4636. if(isset($_SESSION['api']))
  4637. {
  4638. $user = $this->user->get_api($_SESSION['api']);
  4639. $usp = $user;
  4640. $fgshop = "";$sid = "";
  4641. $usersp = explode('|',trim($user['shop'],'|'));
  4642. foreach ($usersp as $value)
  4643. {
  4644. $fgshop .= " shop = ".$value." or";
  4645. $sid .= " id = ".$value." or";
  4646. }
  4647. }
  4648. $post = $this->input->post(NULL, TRUE);
  4649. if(isset($post['page']))
  4650. {
  4651. $timetk = $this->input->post('timetk',true);
  4652. $timetj = $this->input->post('timetj',true);
  4653. $timetk = strtotime($timetk);
  4654. $timetj = strtotime($timetj);
  4655. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  4656. if($timetk && $timetj)
  4657. {
  4658. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4659. }
  4660. //数据排序
  4661. $order_str = "dtime desc";
  4662. if(empty($page))
  4663. {
  4664. $start = 0;
  4665. $perpage = 1;
  4666. }
  4667. else
  4668. {
  4669. $start = ($page - 1)*$perpage;
  4670. }
  4671. $continentdata = '';
  4672. $continent = array();//陆地板块
  4673. $num = $this->fullorderamz->find_count($where);//订单总数量
  4674. $country = $this->country->find_all('1=1','id,continent,ename,zname');
  4675. foreach ($country as $k=>$v)
  4676. {
  4677. $tc = $this->typeclass->read($v['continent']);
  4678. $continent[$v['continent']] = array(0=>$tc['title'],1=>0,2=>'');
  4679. }
  4680. foreach ($country as $k=>$v)
  4681. {
  4682. $n = $this->fullorderamz->find_count($where.' and country = "'.$v['id'].'"');
  4683. $country[$k]['continent'] = $continent[$v['continent']][0];//此国家数量
  4684. $country[$k]['zname'] = '<a href="/fullorderamz/dqpmprovince/'.$v['id'].'/'.$timetk.'/'.$timetj.'">'.$v['zname'].'</a>';//此国家数量
  4685. $country[$k]['num'] = $n;//此国家数量
  4686. $country[$k]['zb'] = (sprintf("%.4f",$n/$num)*100).'%';//此国家占比
  4687. $continent[$v['continent']]['1'] += $n;//此洲数量增加;
  4688. }
  4689. array_multisort(array_column($continent, '1'), SORT_DESC, $continent);
  4690. array_multisort(array_column($country, 'num'), SORT_DESC, $country);
  4691. foreach ($continent as $k=>$v)
  4692. {
  4693. $continentdata .= $v['0'].' 总量:'.$v['1'].' 占比:'.(sprintf("%.4f",$v['1']/$num)*100).'%&nbsp;&nbsp; - &nbsp;&nbsp;';
  4694. }
  4695. echo json_encode(array('ewnr'=>$continentdata,'rows'=>$country,'total'=>count($country),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4696. }
  4697. $this->_Template('fullorderamz_dqpm',$this->data);
  4698. }
  4699. public function _dqpmprovince($arg_array)
  4700. {
  4701. if(isset($_SESSION['api']))
  4702. {
  4703. $user = $this->user->get_api($_SESSION['api']);
  4704. $usp = $user;
  4705. $fgshop = "";$sid = "";
  4706. $usersp = explode('|',trim($user['shop'],'|'));
  4707. foreach ($usersp as $value)
  4708. {
  4709. $fgshop .= " shop = ".$value." or";
  4710. $sid .= " id = ".$value." or";
  4711. }
  4712. }
  4713. $post = $this->input->post(NULL, TRUE);
  4714. if(isset($post['page']))
  4715. {
  4716. $country = $this->input->post('country',true);
  4717. $timetk = $this->input->post('timetk',true);
  4718. $timetj = $this->input->post('timetj',true);
  4719. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4720. $province = array();
  4721. $city_list = $this->fullorderamz->find_all($where,'id,province');
  4722. $ToState = array('AL'=>'alabama','AK'=>'alaska','AZ'=>'arizona','AR'=>'arkansas','CA'=>'california','CO'=>'colorado','CT'=>'connecticut','DE'=>'delaware','FL'=>'florida','GA'=>'georgia','HI'=>'hawaii','ID'=>'idaho','IL'=>'illinois','IN'=>'indiana','IA'=>'iowa','KS'=>'kansas','KY'=>'kentucky','LA'=>'louisiana','ME'=>'maine','MD'=>'maryland','MA'=>'massachusetts','MI'=>'michigan','MN'=>'minnesota','MS'=>'mississippi','MO'=>'missouri','MT'=>'montana','NE'=>'nebraska','NV'=>'nevada','NH'=>'new hampshire','NJ'=>'new jersey','NM'=>'new mexico','NY'=>'new york','NC'=>'north carolina','ND'=>'north dakota','OH'=>'ohio','OK'=>'oklahoma','OR'=>'oregon','PA'=>'pennsylvania','RI'=>'rhode island','SC'=>'south carolina','SD'=>'south dakota','TN'=>'tennessee','TX'=>'texas','UT'=>'utah','VT'=>'vermont','VA'=>'virginia','WA'=>'washington','WV'=>'west virginia','WI'=>'wisconsin','WY'=>'wyoming','DC'=>'district of columbia','VI'=>'virgin islands');
  4723. foreach ($city_list as $k=>$v)
  4724. {
  4725. $v['province'] = strtoupper(trim($v['province'],' '));
  4726. if(isset($ToState[$v['province']]))
  4727. {
  4728. $v['province'] = $ToState[$v['province']];
  4729. }
  4730. if(!isset($province[$v['province']]))
  4731. {
  4732. $province[$v['province']] = array('id'=>$v['id'],'province'=>'<a href="/fullorderamz/ddpmdata/'.$country.'/'.$timetk.'/'.$timetj.'/'.strtoupper($v['province']).'">'.$v['province'].'</a>','num'=>0,'zb'=>'');
  4733. }
  4734. $province[$v['province']]['num'] += 1;
  4735. }
  4736. array_multisort(array_column($province, 'num'), SORT_DESC, $province);
  4737. $province = array_values($province);
  4738. foreach ($province as $k=>$v)
  4739. {
  4740. $province[$k]['zb'] = (sprintf("%.4f",$v['num']/count($city_list))*100).'%';
  4741. }
  4742. echo json_encode(array('rows'=>($province),'total'=>count($province),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4743. }
  4744. $this->data['arg_array'] = $arg_array;
  4745. $this->_Template('fullorderamz_dqpmprovince',$this->data);
  4746. }
  4747. public function _ddpmdata($arg_array)
  4748. {
  4749. $arg_array[3] = str_replace('%20',' ',$arg_array[3]);
  4750. if(isset($_SESSION['api']))
  4751. {
  4752. $user = $this->user->get_api($_SESSION['api']);
  4753. $usp = $user;
  4754. $fgshop = "";$sid = "";
  4755. $usersp = explode('|',trim($user['shop'],'|'));
  4756. foreach ($usersp as $value)
  4757. {
  4758. $fgshop .= " shop = ".$value." or";
  4759. $sid .= " id = ".$value." or";
  4760. }
  4761. }
  4762. $post = $this->input->post(NULL, TRUE);
  4763. if(isset($post['page']))
  4764. {
  4765. $page = $this->input->post('page',true);
  4766. $perpage = $this->input->post('perpage',true);
  4767. $province = $this->input->post('province',true);
  4768. $timetk = $this->input->post('timetk',true);;
  4769. $timetj = $this->input->post('timetj',true);;
  4770. $country = $this->input->post('country',true);;
  4771. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4772. if($province)
  4773. {
  4774. $where .= " and province = '$province'";
  4775. }
  4776. $order_str = "dtime desc";
  4777. if(empty($page))
  4778. {
  4779. $start = 0;
  4780. $perpage = 1;
  4781. }
  4782. else
  4783. {
  4784. $start = ($page - 1)*$perpage;
  4785. }
  4786. $info_list = $this->fullorderamz->find_all($where,'id,orderinfo,number,shipremarks,shouldmoney',$order_str,$start,$perpage);
  4787. $total = $this->fullorderamz->find_count($where);
  4788. $pagenum = ceil($total/$perpage);
  4789. $over = $total-($start+$perpage);
  4790. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4791. echo json_encode($rows);exit;
  4792. }
  4793. $province = array();
  4794. $city_list = $this->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');
  4795. $ToState = array('AL'=>'alabama','AK'=>'alaska','AZ'=>'arizona','AR'=>'arkansas','CA'=>'california','CO'=>'colorado','CT'=>'connecticut','DE'=>'delaware','FL'=>'florida','GA'=>'georgia','HI'=>'hawaii','ID'=>'idaho','IL'=>'illinois','IN'=>'indiana','IA'=>'iowa','KS'=>'kansas','KY'=>'kentucky','LA'=>'louisiana','ME'=>'maine','MD'=>'maryland','MA'=>'massachusetts','MI'=>'michigan','MN'=>'minnesota','MS'=>'mississippi','MO'=>'missouri','MT'=>'montana','NE'=>'nebraska','NV'=>'nevada','NH'=>'new hampshire','NJ'=>'new jersey','NM'=>'new mexico','NY'=>'new york','NC'=>'north carolina','ND'=>'north dakota','OH'=>'ohio','OK'=>'oklahoma','OR'=>'oregon','PA'=>'pennsylvania','RI'=>'rhode island','SC'=>'south carolina','SD'=>'south dakota','TN'=>'tennessee','TX'=>'texas','UT'=>'utah','VT'=>'vermont','VA'=>'virginia','WA'=>'washington','WV'=>'west virginia','WI'=>'wisconsin','WY'=>'wyoming','DC'=>'district of columbia','VI'=>'virgin islands');
  4796. foreach ($city_list as $k=>$v)
  4797. {
  4798. $v['province'] = strtoupper(trim($v['province'],' '));
  4799. if(isset($ToState[$v['province']]))
  4800. {
  4801. $v['province'] = $ToState[$v['province']];
  4802. }
  4803. $province[$v['province']] = array('province'=>$v['province']);
  4804. }
  4805. $this->data['province'] = $province;
  4806. $this->data['arg_array'] = $arg_array;
  4807. $this->_Template('fullorderamz_ddpmdata',$this->data);
  4808. }
  4809. public function _ddpmexcel($arg_array)
  4810. {
  4811. if(isset($_SESSION['api']))
  4812. {
  4813. $user = $this->user->get_api($_SESSION['api']);
  4814. $usp = $user;
  4815. $fgshop = "";$sid = "";
  4816. $usersp = explode('|',trim($user['shop'],'|'));
  4817. foreach ($usersp as $value)
  4818. {
  4819. $fgshop .= " shop = ".$value." or";
  4820. $sid .= " id = ".$value." or";
  4821. }
  4822. }
  4823. $province = $this->input->get('province',true);
  4824. $timetk = $arg_array[1];
  4825. $timetj = $arg_array[2];
  4826. $country = $arg_array[0];
  4827. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4828. if($province)
  4829. {
  4830. $where .= " and province = '$province'";
  4831. }
  4832. $order_str = "dtime desc";
  4833. $info_list = $this->fullorderamz->find_all($where,'orderinfo,number,shipremarks,shouldmoney',$order_str);
  4834. $country = $this->country->read($arg_array[0]);
  4835. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  4836. $titlename = "<table border=1>
  4837. <tr><th colspan='4' align='left'><h3>".$title."<h3></th></tr>
  4838. <tr>
  4839. <td>订单号</td>
  4840. <td>订单编号</td>
  4841. <td>仓库品名</td>
  4842. <td>订单金额</td>
  4843. </tr>
  4844. </table>";
  4845. $filename = $title.".xls";
  4846. $tail = "\n";
  4847. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4848. }
  4849. public function _statedc()
  4850. {
  4851. $user = $this->user->get_api($_SESSION['api']);
  4852. if($user)
  4853. {
  4854. $fgshop = "";$sid = "";
  4855. $user = explode('|',trim($user['shop'],'|'));
  4856. foreach ($user as $value)
  4857. {
  4858. $fgshop .= " shop = ".$value." or";
  4859. $sid .= " id = ".$value." or";
  4860. }
  4861. }
  4862. $post = $this->input->get(NULL, TRUE);
  4863. if(isset($post['timetk']))
  4864. {
  4865. $page = $this->input->get('page',true);
  4866. $perpage = $this->input->get('perpage',true);
  4867. $timetk = $this->input->get('timetk',true);
  4868. $timetj = $this->input->get('timetj',true);
  4869. $shop = $this->input->get('shop',true);
  4870. $source = $this->input->get('source',true);
  4871. $state = $this->input->get('state',true);
  4872. $review = $this->input->get('review',true);
  4873. $express = $this->input->get('express',true);
  4874. $fs = $this->input->get('fs',true);
  4875. $orderinfo = $this->input->get('orderinfo',true);
  4876. $number = $this->input->get('number',true);
  4877. $user = $this->input->get('user',true);
  4878. $name = $this->input->get('name',true);
  4879. $waybill = $this->input->get('waybill',true);
  4880. $expressstate = $this->input->get('expressstate',true);
  4881. $wltype = $this->input->get('wltype',true);
  4882. $wlyc = $this->input->get('wlyc',true);
  4883. $xztime = $this->input->get('xztime',true);
  4884. $timetk = strtotime($timetk);
  4885. $timetj = strtotime($timetj);
  4886. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  4887. if($timetk && $timetj)
  4888. {
  4889. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  4890. }
  4891. if($xztime == 'librarytime')
  4892. {
  4893. $order_str = "librarytime desc";
  4894. }
  4895. else if($xztime == 'dtime')
  4896. {
  4897. $order_str = "dtime desc";
  4898. }
  4899. if($shop)
  4900. {
  4901. $where .= " and shop = '$shop'";
  4902. }
  4903. if($source)
  4904. {
  4905. if($source == 11)
  4906. {
  4907. $where .= " and source != '1'";
  4908. }
  4909. else
  4910. {
  4911. $where .= " and source = '$source'";
  4912. }
  4913. }
  4914. if($fs)
  4915. {
  4916. if($fs == '2')
  4917. {
  4918. $where .= " and exstateerror != ''";
  4919. }
  4920. else
  4921. {
  4922. $where .= " and exstateerror = ''";
  4923. }
  4924. }
  4925. if($state)
  4926. {
  4927. $where .= " and state = '$state'";
  4928. }
  4929. if($review)
  4930. {
  4931. $where .= " and review = '$review'";
  4932. }
  4933. if($expressstate != "")
  4934. {
  4935. $where .= " and expressstate = '$expressstate'";
  4936. }
  4937. if($wltype != "")
  4938. {
  4939. $where .= " and wltype = '$wltype'";
  4940. }
  4941. if($wlyc != "")
  4942. {
  4943. $where .= " and wlyc = '$wlyc'";
  4944. }
  4945. if($express)
  4946. {
  4947. $where .= " and express = '$express'";
  4948. }
  4949. if($orderinfo)
  4950. {
  4951. $where .= " and orderinfo = '$orderinfo'";
  4952. }
  4953. if($number)
  4954. {
  4955. $where .= " and number = '$number'";
  4956. }
  4957. if($user)
  4958. {
  4959. $where .= " and user = '$user'";
  4960. }
  4961. if($name)
  4962. {
  4963. $where .= " and name = '$name'";
  4964. }
  4965. if($waybill)
  4966. {
  4967. $where .= " and waybill = '$waybill'";
  4968. }
  4969. if(empty($page))
  4970. {
  4971. $start = 0;
  4972. $perpage = 1;
  4973. }
  4974. else
  4975. {
  4976. $start = ($page - 1)*$perpage;
  4977. }
  4978. //取得信息列表
  4979. $info_list = $this->fullorderamz->find_all($where,'shop,number,country,library,librarytime,expressstate,express,waybill,content,exstateerror,excontent',$order_str);
  4980. //格式化数据
  4981. foreach ($info_list as $key=>$value)
  4982. {
  4983. $shop = $this->shop->read($value['shop']);
  4984. $info_list[$key]['shop'] = $shop['shopname'];
  4985. $country = $this->country->read($value['country']);
  4986. $info_list[$key]['country'] = $country['name'];
  4987. //$state = $this->typeclass->read($value['state']);
  4988. //$info_list[$key]['state'] = $state['title'];
  4989. if($value['library'] == 1)
  4990. {
  4991. $info_list[$key]['library'] = "未出库";
  4992. }
  4993. else if($value['library'] == 2)
  4994. {
  4995. $info_list[$key]['library'] = "已出库";
  4996. }
  4997. else if($value['library'] == 3)
  4998. {
  4999. $info_list[$key]['library'] = "已退库";
  5000. }
  5001. if($value['librarytime'] == '0')
  5002. {
  5003. $info_list[$key]['librarytime'] = '无';
  5004. }
  5005. else
  5006. {
  5007. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5008. }
  5009. if($value['expressstate'] == 0)
  5010. {
  5011. $info_list[$key]['expressstate'] = "无信息";
  5012. }
  5013. else if($value['expressstate'] == 2)
  5014. {
  5015. $info_list[$key]['expressstate'] = "已取件";
  5016. }
  5017. else if($value['expressstate'] == 3)
  5018. {
  5019. $info_list[$key]['expressstate'] = "在途中";
  5020. }
  5021. else if($value['expressstate'] == 4)
  5022. {
  5023. $info_list[$key]['expressstate'] = "到达目的地国";
  5024. }
  5025. else if($value['expressstate'] == 5)
  5026. {
  5027. $info_list[$key]['expressstate'] = "即将派送";
  5028. }
  5029. else if($value['expressstate'] == 6)
  5030. {
  5031. $info_list[$key]['expressstate'] = "已签收";
  5032. }
  5033. else if($value['expressstate'] == 1)
  5034. {
  5035. $info_list[$key]['expressstate'] = "派送异常";
  5036. }
  5037. $express = $this->express->read($value['express']);
  5038. $info_list[$key]['express'] = $express['servicename'];
  5039. }
  5040. }
  5041. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5042. $titlename = "<table border=1>
  5043. <tr>
  5044. <td>店铺名称</td>
  5045. <td>编号</td>
  5046. <td>收件人国家</td>
  5047. <td>出库状态</td>
  5048. <td>发货时间</td>
  5049. <td>物流状态</td>
  5050. <td>快递公司</td>
  5051. <td>运单号</td>
  5052. <td>消息状态</td>
  5053. <td>错误提示</td>
  5054. <td>物流信息</td>
  5055. </tr>
  5056. </table>";
  5057. $filename = $title.".xls";
  5058. $tail = "\n";
  5059. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5060. }
  5061. public function _statedcwl()
  5062. {
  5063. $user = $this->user->get_api($_SESSION['api']);
  5064. if($user)
  5065. {
  5066. $fgshop = "";$sid = "";
  5067. $user = explode('|',trim($user['shop'],'|'));
  5068. foreach ($user as $value)
  5069. {
  5070. $fgshop .= " shop = ".$value." or";
  5071. $sid .= " id = ".$value." or";
  5072. }
  5073. }
  5074. $post = $this->input->get(NULL, TRUE);
  5075. if(isset($post['timetk']))
  5076. {
  5077. $dowid = $this->input->get('a');
  5078. $wid = "";
  5079. if($dowid != "")
  5080. {
  5081. $id_arr = explode(',',rtrim($dowid,','));
  5082. $wid .= " id = 0 or";
  5083. foreach ($id_arr as $v)
  5084. {
  5085. $wid .= " id = '$v' or";
  5086. }
  5087. $wid = " and".rtrim($wid,'or');
  5088. }
  5089. $page = $this->input->get('page',true);
  5090. $perpage = $this->input->get('perpage',true);
  5091. $timetk = $this->input->get('timetk',true);
  5092. $timetj = $this->input->get('timetj',true);
  5093. $shop = $this->input->get('shop',true);
  5094. $expressstate = $this->input->get('expressstate',true);
  5095. $fs = $this->input->get('fs',true);
  5096. $state = $this->input->get('state',true);
  5097. $express = $this->input->get('express',true);
  5098. $orderinfo = $this->input->get('orderinfo',true);
  5099. $number = $this->input->get('number',true);
  5100. $waybill = $this->input->get('waybill',true);
  5101. $wlyc = $this->input->get('wlyc',true);
  5102. $wltype = $this->input->get('wltype',true);
  5103. $source = $this->input->get('source',true);
  5104. $xztime = $this->input->get('xztime',true);
  5105. $timetk = strtotime($timetk);
  5106. $timetj = strtotime($timetj);
  5107. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5108. if($timetk && $timetj)
  5109. {
  5110. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5111. }
  5112. if($xztime == 'librarytime')
  5113. {
  5114. $order_str = "librarytime desc";
  5115. }
  5116. else if($xztime == 'dtime')
  5117. {
  5118. $order_str = "dtime desc";
  5119. }
  5120. if($shop)
  5121. {
  5122. $where .= " and shop = '$shop'";
  5123. }
  5124. if($expressstate)
  5125. {
  5126. $where .= " and expressstate = '$expressstate'";
  5127. }
  5128. if($fs)
  5129. {
  5130. if($fs == '1')
  5131. {
  5132. $where .= " and wlcontent != ''";
  5133. }
  5134. if($fs == '2')
  5135. {
  5136. $where .= " and wlerror != ''";
  5137. }
  5138. if($fs == '3')
  5139. {
  5140. $where .= " and wlcontent = '' and shouldmoney > 100";
  5141. }
  5142. else if($fs == '4')
  5143. {
  5144. $where .= " and wltype = '1'";
  5145. }
  5146. }
  5147. if($state)
  5148. {
  5149. $where .= " and state = '$state'";
  5150. }
  5151. if($express)
  5152. {
  5153. $where .= " and express = '$express'";
  5154. }
  5155. if($orderinfo)
  5156. {
  5157. $where .= " and orderinfo = '$orderinfo'";
  5158. }
  5159. if($number)
  5160. {
  5161. $where .= " and number = '$number'";
  5162. }
  5163. if($waybill)
  5164. {
  5165. $where .= " and waybill = '$waybill'";
  5166. }
  5167. if($wlyc!='')
  5168. {
  5169. $where .= " and wlyc = '$wlyc'";
  5170. }
  5171. if($wltype!='')
  5172. {
  5173. $where .= " and wltype = '$wltype'";
  5174. }
  5175. if($source)
  5176. {
  5177. if($source == 1)
  5178. {
  5179. $where .= " and source = '$source'";
  5180. }
  5181. else
  5182. {
  5183. $where .= " and source != '1'";
  5184. }
  5185. }
  5186. $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);
  5187. //格式化数据
  5188. foreach ($info_list as $key=>$value)
  5189. {
  5190. $country = $this->country->read($value['country']);
  5191. $info_list[$key]['country'] = $country['name'];
  5192. //$state = $this->typeclass->read($value['state']);
  5193. //$info_list[$key]['state'] = $state['title'];
  5194. if($value['library'] == 1)
  5195. {
  5196. $info_list[$key]['library'] = "未出库";
  5197. }
  5198. else if($value['library'] == 2)
  5199. {
  5200. $info_list[$key]['library'] = "已出库";
  5201. }
  5202. else if($value['library'] == 3)
  5203. {
  5204. $info_list[$key]['library'] = "已退库";
  5205. }
  5206. if($value['librarytime'] == '0')
  5207. {
  5208. $info_list[$key]['librarytime'] = '无';
  5209. }
  5210. else
  5211. {
  5212. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5213. }
  5214. if($value['expressstate'] == 0)
  5215. {
  5216. $info_list[$key]['expressstate'] = "无信息";
  5217. }
  5218. else if($value['expressstate'] == 2)
  5219. {
  5220. $info_list[$key]['expressstate'] = "已取件";
  5221. }
  5222. else if($value['expressstate'] == 3)
  5223. {
  5224. $info_list[$key]['expressstate'] = "在途中";
  5225. }
  5226. else if($value['expressstate'] == 4)
  5227. {
  5228. $info_list[$key]['expressstate'] = "到达目的地国";
  5229. }
  5230. else if($value['expressstate'] == 5)
  5231. {
  5232. $info_list[$key]['expressstate'] = "即将派送";
  5233. }
  5234. else if($value['expressstate'] == 6)
  5235. {
  5236. $info_list[$key]['expressstate'] = "已签收";
  5237. }
  5238. else if($value['expressstate'] == 1)
  5239. {
  5240. $info_list[$key]['expressstate'] = "派送异常";
  5241. }
  5242. $info_list[$key]['wlfstime'] = date('Y-m-d H:i:s',$value['wlfstime']);
  5243. $express = $this->express->read($value['express']);
  5244. $info_list[$key]['express'] = $express['servicename'];
  5245. $info_list[$key]['excontent'] = str_replace('<br />','',$value['excontent']);
  5246. }
  5247. }
  5248. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5249. $titlename = "<table border=1>
  5250. <tr>
  5251. <td>订单号</td>
  5252. <td>编号</td>
  5253. <td>收件人国家</td>
  5254. <td>出库状态</td>
  5255. <td>出库时间</td>
  5256. <td>物流状态</td>
  5257. <td>快递公司</td>
  5258. <td>运单号</td>
  5259. <td>物流备注</td>
  5260. <td>订单备注</td>
  5261. <td>仓库品名</td>
  5262. <td>发送时间</td>
  5263. <td>邮箱</td>
  5264. <td>电话</td>
  5265. <td>邮件发送</td>
  5266. <td>错误提示</td>
  5267. <td>物流信息</td>
  5268. </tr>
  5269. </table>";
  5270. $filename = $title.".xls";
  5271. $tail = "\n";
  5272. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5273. }
  5274. public function _waybillemail()
  5275. {
  5276. $user = $this->user->get_api($_SESSION['api']);
  5277. if($user)
  5278. {
  5279. $fgshop = "";$sid = "";
  5280. $user = explode('|',trim($user['shop'],'|'));
  5281. foreach ($user as $value)
  5282. {
  5283. $fgshop .= " shop = ".$value." or";
  5284. $sid .= " id = ".$value." or";
  5285. }
  5286. }
  5287. $post = $this->input->post(NULL, TRUE);
  5288. if(isset($post['page']))
  5289. {
  5290. $page = $this->input->post('page',true);
  5291. $perpage = $this->input->post('perpage',true);
  5292. $timetk = $this->input->post('timetk',true);
  5293. $timetj = $this->input->post('timetj',true);
  5294. $shop = $this->input->post('shop',true);
  5295. $expressstate = $this->input->post('expressstate',true);
  5296. $fs = $this->input->post('fs',true);
  5297. $state = $this->input->post('state',true);
  5298. $express = $this->input->post('express',true);
  5299. $orderinfo = $this->input->post('orderinfo',true);
  5300. $number = $this->input->post('number',true);
  5301. $waybill = $this->input->post('waybill',true);
  5302. $dlzemail = $this->input->post('dlzemail',true);
  5303. $xztime = $this->input->post('xztime',true);
  5304. $timetk = strtotime($timetk);
  5305. $timetj = strtotime($timetj);
  5306. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5307. if($timetk && $timetj)
  5308. {
  5309. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5310. }
  5311. $order_str = $xztime." desc";
  5312. if($shop)
  5313. {
  5314. $where .= " and shop = '$shop'";
  5315. }
  5316. if($expressstate)
  5317. {
  5318. $where .= " and expressstate = '$expressstate'";
  5319. }
  5320. if($state)
  5321. {
  5322. $where .= " and state = '$state'";
  5323. }
  5324. if($express)
  5325. {
  5326. $where .= " and express = '$express'";
  5327. }
  5328. if($orderinfo)
  5329. {
  5330. $where .= " and orderinfo = '$orderinfo'";
  5331. }
  5332. if($number)
  5333. {
  5334. $where .= " and number = '$number'";
  5335. }
  5336. if($waybill)
  5337. {
  5338. $where .= " and waybill = '$waybill'";
  5339. }
  5340. if($dlzemail != '')
  5341. {
  5342. $where .= " and dlzemail = '$dlzemail'";
  5343. }
  5344. if(empty($page))
  5345. {
  5346. $start = 0;
  5347. $perpage = 1;
  5348. }
  5349. else
  5350. {
  5351. $start = ($page - 1)*$perpage;
  5352. }
  5353. //取得信息列表
  5354. $info_list = $this->fullorderamz->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,dlzemail,dlzemailtime',$order_str,$start,$perpage);
  5355. //格式化数据
  5356. foreach ($info_list as $key=>$value)
  5357. {
  5358. $shop = $this->shop->read($value['shop']);
  5359. $info_list[$key]['shop'] = $shop['shopname'];
  5360. $country = $this->country->read($value['country']);
  5361. $info_list[$key]['country'] = $country['name'];
  5362. //$state = $this->typeclass->read($value['state']);
  5363. //$info_list[$key]['state'] = $state['title'];
  5364. if($value['library'] == 1)
  5365. {
  5366. $info_list[$key]['library'] = "未出库";
  5367. }
  5368. else if($value['library'] == 2)
  5369. {
  5370. $info_list[$key]['library'] = "已出库";
  5371. }
  5372. else if($value['library'] == 3)
  5373. {
  5374. $info_list[$key]['library'] = "已退库";
  5375. }
  5376. if($value['librarytime'] == '0')
  5377. {
  5378. $info_list[$key]['librarytime'] = '无';
  5379. }
  5380. else
  5381. {
  5382. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  5383. }
  5384. $express = $this->express->read($value['express']);
  5385. $info_list[$key]['express'] = $express['servicename'];
  5386. if($value['dlzemail'] == '1')
  5387. {
  5388. $info_list[$key]['dlzemail'] = '发送成功';
  5389. }
  5390. else if ($value['dlzemail'] == '2')
  5391. {
  5392. $info_list[$key]['dlzemail'] = '发送失败';
  5393. }
  5394. else
  5395. {
  5396. $info_list[$key]['dlzemail'] = '';
  5397. }
  5398. $info_list[$key]['dlzemailtime'] = ($value['dlzemailtime']>0)?date('Y-m-d H:i:s',$value['dlzemailtime']):'';
  5399. }
  5400. $total = $this->fullorderamz->find_count($where);
  5401. $pagenum = ceil($total/$perpage);
  5402. $over = $total-($start+$perpage);
  5403. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5404. echo json_encode($rows);exit;
  5405. }
  5406. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  5407. $this->data['notice'] = $notice;
  5408. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  5409. $this->data['wlshop'] = $wlshop;
  5410. $this->data['express'] = $this->express->find_all();
  5411. $this->_Template('fullorderamz_waybillemail',$this->data);
  5412. }
  5413. public function _khdd()
  5414. {
  5415. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  5416. if(isset($_SESSION['api']))
  5417. {
  5418. $user = $this->user->get_api($_SESSION['api']);
  5419. $usp = $user;
  5420. $fgshop = "";$sid = "";
  5421. $usersp = explode('|',trim($user['shop'],'|'));
  5422. foreach ($usersp as $value)
  5423. {
  5424. $fgshop .= " shop = ".$value." or";
  5425. $sid .= " id = ".$value." or";
  5426. }
  5427. if($user['vip'] == 1)
  5428. {
  5429. $vip = 1;
  5430. }
  5431. else
  5432. {
  5433. $vip = 0;
  5434. }
  5435. }
  5436. $post = $this->input->post(NULL, TRUE);
  5437. if(isset($_GET['excel']))
  5438. {
  5439. $page = $this->input->get('page',true);
  5440. $perpage = $this->input->get('perpage',true);
  5441. $warehouse = $this->input->get('warehouse',true);
  5442. $timetk = $this->input->get('timetk',true);
  5443. $timetj = $this->input->get('timetj',true);
  5444. $shop = $this->input->get('shop',true);
  5445. $source = $this->input->get('source',true);
  5446. $state = $this->input->get('state',true);
  5447. $review = $this->input->get('review',true);
  5448. $type = $this->input->get('type',true);
  5449. $express = $this->input->get('express',true);
  5450. $orderinfo = $this->input->get('orderinfo',true);
  5451. $user = $this->input->get('user',true);
  5452. $client = $this->input->get('name',true);
  5453. $waybill = $this->input->get('waybill',true);
  5454. $number = $this->input->get('number',true);
  5455. $email = $this->input->get('email',true);
  5456. $phone = $this->input->get('phone',true);
  5457. $dlz = $this->input->get('dlz',true);
  5458. $print = $this->input->get('print',true);
  5459. $library = $this->input->get('library',true);
  5460. $js = $this->input->get('js',true);
  5461. $exstate = $this->input->get('exstate',true);
  5462. $xztime = $this->input->get('xztime',true);
  5463. $libraryconfirm = $this->input->get('libraryconfirm',true);
  5464. $timetk = strtotime($timetk);
  5465. $timetj = strtotime($timetj);
  5466. $plorder = $this->input->get('pl',true);
  5467. $paypal = $this->input->get('paypal',true);
  5468. $zf = $this->input->get('zf',true);
  5469. $pay = $this->input->get('pay',true);
  5470. $excel = $this->input->get('excel',true);
  5471. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5472. if($warehouse)
  5473. {
  5474. $where .= " and type = '$warehouse'";
  5475. }
  5476. if($timetk && $timetj)
  5477. {
  5478. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5479. }
  5480. if($shop)
  5481. {
  5482. $where .= " and shop = '$shop'";
  5483. }
  5484. if($source)
  5485. {
  5486. if($source == '2d')
  5487. {
  5488. $where .= " and source >= '2'";
  5489. }
  5490. else
  5491. {
  5492. $where .= " and source = '$source'";
  5493. }
  5494. }
  5495. if($state)
  5496. {
  5497. $where .= " and state = '$state'";
  5498. }
  5499. if($review)
  5500. {
  5501. $where .= " and review = '$review'";
  5502. }
  5503. if($type)
  5504. {
  5505. $where .= " and type = '$type'";
  5506. }
  5507. if($express)
  5508. {
  5509. $where .= " and express = '$express'";
  5510. }
  5511. if($orderinfo)
  5512. {
  5513. $where .= " and orderinfo = '$orderinfo'";
  5514. }
  5515. if($user)
  5516. {
  5517. $where .= " and user = '$user'";
  5518. }
  5519. if($client)
  5520. {
  5521. $where .= " and client like '%$client%'";
  5522. }
  5523. if($waybill)
  5524. {
  5525. $where .= " and waybill = '$waybill'";
  5526. }
  5527. if($number)
  5528. {
  5529. $where .= " and number = '$number'";
  5530. }
  5531. if($email)
  5532. {
  5533. $where .= " and email = '$email'";
  5534. }
  5535. if($phone)
  5536. {
  5537. $where .= " and phone like '%$phone%'";
  5538. }
  5539. if($library)
  5540. {
  5541. $where .= " and library = '$library'";
  5542. }
  5543. if($print)
  5544. {
  5545. $where .= " and print = '$print'";
  5546. }
  5547. if($dlz != '')
  5548. {
  5549. $where .= " and dlz = '$dlz'";
  5550. }
  5551. if($js)
  5552. {
  5553. $where .= " and js = '$js'";
  5554. }
  5555. if($exstate)
  5556. {
  5557. $where .= " and exstate = '$exstate'";
  5558. }
  5559. if($libraryconfirm)
  5560. {
  5561. $where .= " and libraryconfirm = '$libraryconfirm'";
  5562. }
  5563. if($paypal)
  5564. {
  5565. $where .= " and paypal = '$paypal'";
  5566. }
  5567. if($pay)
  5568. {
  5569. $where .= " and pay = '$pay'";
  5570. }
  5571. if($zf)
  5572. {
  5573. if($zf == 1)
  5574. {
  5575. $where .= " and paypal not like '%-%-%-%'";
  5576. }
  5577. else
  5578. {
  5579. $where .= " and paypal like '%-%-%-%'";
  5580. }
  5581. }
  5582. if($plorder)
  5583. {
  5584. $plorderinfo = '';$plnumber = '';$pln = 0;
  5585. $plorder = explode(',',trim($plorder,','));
  5586. foreach ($plorder as $value)
  5587. {
  5588. if(is_numeric($value))
  5589. {
  5590. $plorderinfo .= " orderinfo = ".$value." or";
  5591. }
  5592. else if($value != '')
  5593. {
  5594. $plorderinfo .= " number = '".$value."' or";
  5595. }
  5596. }
  5597. if($pln > 0)
  5598. {
  5599. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  5600. }
  5601. else
  5602. {
  5603. $where .= " and (".rtrim($plorderinfo,'or').")";
  5604. }
  5605. }
  5606. //数据排序
  5607. $order_str = "dtime desc";
  5608. if(empty($page))
  5609. {
  5610. $start = 0;
  5611. $perpage = 1;
  5612. }
  5613. else
  5614. {
  5615. $start = ($page - 1)*$perpage;
  5616. }
  5617. if($excel == '1')
  5618. {
  5619. $shop = array();
  5620. $shopdata = $this->shop->find_all("type = '269'");
  5621. foreach ($shopdata as $v)
  5622. {
  5623. $shop[$v['id']] = array('t'=>$v['brandname'],'z'=>0,'l'=>0,'x'=>0);//店铺名称,总客户,老客户,新客户
  5624. }
  5625. $oldnumber = 0;$newnumber = 0;
  5626. $info_list = $this->db->query('select distinct shop,email from crowd_fullorderamz where '.$where)->result_array();
  5627. foreach ($info_list as $key=>$v)
  5628. {
  5629. $shop[$v['shop']]['z'] += 1;
  5630. $num = $this->fullorderamz->find_count("email = '".$v['email']."' and shop = '".$v['shop']."' and ".$xztime." < '$timetj'");
  5631. if($num > 1)
  5632. {
  5633. $shop[$v['shop']]['l'] += 1;
  5634. }
  5635. else
  5636. {
  5637. $shop[$v['shop']]['x'] += 1;
  5638. }
  5639. if(isset($v['email']) && $usp['excelpass'] == '1')
  5640. {
  5641. $emailpass = $this->setting->get_excelpass($v['email']);
  5642. $info_list[$key]['email'] = $emailpass;
  5643. }
  5644. }
  5645. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5646. $titlename = "<table border=1>
  5647. <tr>
  5648. <td>店铺</td>
  5649. <td>客户数</td>
  5650. <td>老客户数</td>
  5651. <td>新客户数</td>
  5652. </tr>
  5653. </table>";
  5654. $filename = $title.".xls";
  5655. $tail = "\n";
  5656. $this->excel->get_fz2($shop,$titlename,$filename,$tail);
  5657. }
  5658. else if($excel == '2' || $excel == '3')
  5659. {
  5660. $kh = array();
  5661. $info_list = $this->db->query('select distinct shop,email from crowd_fullorderamz where email != "" and '.$where)->result_array();
  5662. foreach ($info_list as $key=>$v)
  5663. {
  5664. $k = $this->fullorderamz->find_all("shop = '".$v['shop']."' and email = '".$v['email']."' and ".$xztime." < '$timetj'",'name,email,dtime,shouldmoney','dtime desc');
  5665. if($excel == 2 && count($k) > 1)
  5666. {
  5667. $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')));
  5668. }
  5669. if($excel == 3 && count($k) < 2)
  5670. {
  5671. $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')));
  5672. }
  5673. if(isset($v['email']) && $usp['excelpass'] == '1')
  5674. {
  5675. $emailpass = $this->setting->get_excelpass($v['email']);
  5676. $info_list[$key]['email'] = $emailpass;
  5677. }
  5678. }
  5679. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5680. $titlename = "<table border=1>
  5681. <tr>
  5682. <td>名称</td>
  5683. <td>邮箱</td>
  5684. <td>最后购买时间</td>
  5685. <td>购买次数</td>
  5686. <td>购买总额</td>
  5687. </tr>
  5688. </table>";
  5689. $filename = $title.".xls";
  5690. $tail = "\n";
  5691. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5692. }
  5693. else if($excel == '4' || $excel == '5')
  5694. {
  5695. $kh = array();
  5696. $info_list = $this->db->query('select distinct shop,email from crowd_fullorderamz where email != "" and '.$where)->result_array();
  5697. foreach ($info_list as $key=>$value)
  5698. {
  5699. $k = $this->fullorderamz->find_all("shop = '".$value['shop']."' and email = '".$value['email']."' and ".$xztime." < '$timetj'",'orderinfo,state,product,name,email,dtime,shouldmoney','dtime desc');
  5700. if($excel == 4 && count($k) > 1)
  5701. {
  5702. foreach ($k as $v)
  5703. {
  5704. $typeclass = $this->typeclass->read($v['state']);
  5705. $kh[] = array($v['orderinfo'],$typeclass['spare'],$v['product'],$v['name'],$v['email'],date("Y-m-d H:i:s",$v['dtime']),$v['shouldmoney']);
  5706. }
  5707. }
  5708. if($excel == 5 && count($k) < 2)
  5709. {
  5710. if(!isset($k[0]['state']))
  5711. {
  5712. $typeclass = $k[0]['state'].'-数据字典无此信息';
  5713. }
  5714. else
  5715. {
  5716. $typeclass = $this->typeclass->read($k[0]['state']);
  5717. }
  5718. $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']);
  5719. }
  5720. if(isset($value['email']) && $usp['excelpass'] == '1')
  5721. {
  5722. $emailpass = $this->setting->get_excelpass($value['email']);
  5723. $info_list[$key]['email'] = $emailpass;
  5724. }
  5725. }
  5726. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5727. $titlename = "<table border=1>
  5728. <tr>
  5729. <td>订单号</td>
  5730. <td>订单状态</td>
  5731. <td>产品名</td>
  5732. <td>客户名</td>
  5733. <td>客户邮箱</td>
  5734. <td>下单时间</td>
  5735. <td>订单金额</td>
  5736. </tr>
  5737. </table>";
  5738. $filename = $title.".xls";
  5739. $tail = "\n";
  5740. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5741. }
  5742. }
  5743. }
  5744. public function _klarnadata()
  5745. {
  5746. $post = $this->input->post(NULL, TRUE);
  5747. if(isset($post['number']))
  5748. {
  5749. $number = $this->input->post('number',true);
  5750. $data = $this->fullorderamz->get_number($number);
  5751. $shop = $this->shop->read($data['shop']);
  5752. $f = '';
  5753. if($data['pay'] == '23')
  5754. {
  5755. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$data['paypal'];
  5756. $header[] = "Content-Type:application/json";
  5757. $header[] = "Authorization: Basic ".base64_encode($shop['klarnaname'].":".$shop['klarnapass']);
  5758. $ch = curl_init();
  5759. curl_setopt($ch, CURLOPT_URL, $url);
  5760. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5761. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5762. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5763. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5764. $res = curl_exec($ch);
  5765. curl_close($ch);
  5766. $res = json_decode($res,true);
  5767. if(isset($res['fraud_status']) && $shop['klarnaname'] != '')
  5768. {
  5769. $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'];
  5770. }
  5771. }
  5772. else if($data['pay'] == '22' && $shop['paypalname'] != '')
  5773. {
  5774. $f = $this->paypal->data($data['paypal'],$shop);
  5775. }
  5776. else if(($data['pay'] == '26') && $shop['afterpayname'] != '')
  5777. {
  5778. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  5779. $header[] = "Accept:application/json";
  5780. $header[] = "User-Agent: Readme.io API Simulator'";
  5781. $header[] = "Authorization: Basic ".base64_encode($shop['afterpayname'].":".$shop['afterpaypass']);
  5782. $ch = curl_init();
  5783. curl_setopt($ch, CURLOPT_URL, $url);
  5784. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5785. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5786. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5787. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5788. $res = curl_exec($ch);
  5789. curl_close($ch);
  5790. $res = json_decode($res,true);
  5791. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  5792. {
  5793. $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'];
  5794. $f = str_replace(',,',',',$f);
  5795. }
  5796. }
  5797. else if(($data['pay'] == '27') && $shop['clearpayname'] != '')
  5798. {
  5799. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  5800. $header[] = "Accept:application/json";
  5801. $header[] = "User-Agent: Readme.io API Simulator'";
  5802. $header[] = "Authorization: Basic ".base64_encode($shop['clearpayname'].":".$shop['clearpaypass']);
  5803. $ch = curl_init();
  5804. curl_setopt($ch, CURLOPT_URL, $url);
  5805. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5806. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5807. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5808. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5809. $res = curl_exec($ch);
  5810. curl_close($ch);
  5811. $res = json_decode($res,true);
  5812. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  5813. {
  5814. $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'];
  5815. $f = str_replace(',,',',',$f);
  5816. }
  5817. }
  5818. else if($data['pay'] == '1211')
  5819. {
  5820. $url = 'https://api.stripe.com/v1/payment_intents/'.$data['paypal'];
  5821. $header[] = "Authorization:Bearer ".$shop['stripe'];
  5822. $ch = curl_init();
  5823. curl_setopt($ch, CURLOPT_URL, $url);
  5824. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5825. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5826. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5827. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5828. $res = curl_exec($ch);
  5829. curl_close($ch);
  5830. $res = json_decode($res,true);
  5831. $f = '';
  5832. if(isset($res['shipping']['name']))
  5833. {
  5834. $line = ($res['shipping']['address']['line2'] != '')?$res['shipping']['address']['line1'].' '.$res['shipping']['address']['line2']:$res['shipping']['address']['line1'];
  5835. $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));
  5836. }
  5837. }
  5838. else
  5839. {
  5840. echo json_encode(array('msg'=>'此店铺没有对接信息','success'=>false));exit;
  5841. }
  5842. if($f != '')
  5843. {
  5844. if($this->fullorderamz->save(array('klarnadata'=>$f),$data['id']))
  5845. {
  5846. echo json_encode(array('msg'=>'获取成功,请关闭此页重新打开','success'=>true));exit;
  5847. }
  5848. else
  5849. {
  5850. echo json_encode(array('msg'=>'写入失败,请重试','success'=>false));exit;
  5851. }
  5852. }
  5853. else
  5854. {
  5855. echo json_encode(array('msg'=>'获取失败,请稍后重试','cl'=>base64_encode($shop['afterpayname'].":".$shop['afterpaypass']),'a'=>$data['paypal'],'success'=>false));exit;
  5856. }
  5857. }
  5858. }
  5859. public function _kcyz($warehouse,$whlabel,$id,$shop,$number)
  5860. {
  5861. if(!$whlabel || $whlabel == '|')
  5862. {
  5863. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5864. }
  5865. $w = $this->warehouse->read($warehouse);
  5866. if($w['zd'] != 1)
  5867. {
  5868. return 1;
  5869. }
  5870. $pp = explode('|',trim($whlabel,'|'));
  5871. $x = 0;$save = array();
  5872. foreach ($pp as $va)
  5873. {
  5874. $num = explode('-',$va);
  5875. if($number)
  5876. {
  5877. $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 = '')");//通用
  5878. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5879. }
  5880. else
  5881. {
  5882. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5883. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5884. }
  5885. $x++;
  5886. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5887. {
  5888. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5889. }
  5890. }
  5891. return $save;
  5892. }
  5893. public function _epod()
  5894. {
  5895. $post = $this->input->post(NULL, TRUE);
  5896. if(isset($post['number']))
  5897. {
  5898. $number = $this->input->post('number',true);
  5899. $data = $this->fullorderamz->get_number($number);
  5900. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  5901. {
  5902. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  5903. }
  5904. else
  5905. {
  5906. $epod = $this->dhl->get_epod($data);
  5907. if($epod['c'] == 1)
  5908. {
  5909. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  5910. }
  5911. else
  5912. {
  5913. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  5914. }
  5915. }
  5916. }
  5917. }
  5918. public function _zw($arg_array)
  5919. {
  5920. $arg_array = $arg_array[0];$fpdata = array();
  5921. $fullorderamz = $this->fullorderamz->read($arg_array);
  5922. $fullorderamz['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullorderamz['shipremarks']);
  5923. $fullorderamz['parameter'] = str_replace(",","---",$fullorderamz['parameter']);
  5924. $this->data['fullorderamz'] = $fullorderamz;
  5925. $this->data['countrys'] = $this->country->find_all();
  5926. $this->data['express'] = $this->express->find_all();
  5927. $warehouse = $this->warehouse->read($fullorderamz['type']);
  5928. if(stripos($fullorderamz['fpdata'],';') !== false)
  5929. {
  5930. $fpdata = explode(';',rtrim($fullorderamz['fpdata'],';'));
  5931. foreach ($fpdata as $k=>$v)
  5932. {
  5933. $xxv = explode('|',$v);
  5934. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  5935. {
  5936. $xxv['zd'] = "<p>已占单</p>";
  5937. $bdck = $warehouse['bdck'];
  5938. if(stripos($xxv[9],'~') !== false)
  5939. {
  5940. $dxxv = explode('~',trim($xxv[9],'~'));
  5941. foreach ($dxxv as $val)
  5942. {
  5943. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  5944. if($wzid['details'] != '')
  5945. {
  5946. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  5947. }
  5948. }
  5949. }
  5950. else
  5951. {
  5952. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  5953. if($wzid['details'] != '')
  5954. {
  5955. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  5956. }
  5957. }
  5958. }
  5959. $fpdata[$k] = $xxv;
  5960. }
  5961. }
  5962. $this->data['fpdata'] = $fpdata;
  5963. $this->data['fpdata'] = $fpdata;
  5964. $thfpdataxs = array();
  5965. if($fullorderamz['thfpdata'] != '')
  5966. {
  5967. $thfpdata = explode(';',trim($fullorderamz['thfpdata'],';'));
  5968. foreach ($thfpdata as $k=>$v)
  5969. {
  5970. $thxs = explode('~',trim($v,'~'));
  5971. $thxs[0] = explode('|',trim($thxs[0],'|'));
  5972. $thxs[1] = explode('|',trim($thxs[1],'|'));
  5973. $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]);
  5974. }
  5975. }
  5976. $this->data['thfpdata'] = $thfpdataxs;
  5977. $shop = $this->shop->read($fullorderamz['shop']);
  5978. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  5979. $is = 0;
  5980. if($shop['type'] == 269)//判断是否独立站,269是独立站
  5981. {
  5982. $is = 1;
  5983. }
  5984. $this->data['is'] = $is;
  5985. //单项开始
  5986. $warehouse = $this->warehouse->read($fullorderamz['warehouse']);//发货仓库
  5987. $state = $this->typeclass->read($fullorderamz['state']);//订单状态
  5988. $country = $this->country->read($fullorderamz['country']);//国家
  5989. if($fullorderamz['capital'] == 1)
  5990. {
  5991. $capital = '暂未支付';
  5992. }
  5993. else if($fullorderamz['capital'] == 2)
  5994. {
  5995. $capital = '部分支付';
  5996. }
  5997. else if($fullorderamz['capital'] == 3)
  5998. {
  5999. $capital = '全部支付';
  6000. }
  6001. if($fullorderamz['printtype'] == 1)
  6002. {
  6003. $printtype = '运单';
  6004. }
  6005. else if($fullorderamz['printtype'] == 2)
  6006. {
  6007. $printtype = '发货单';
  6008. }
  6009. else if($fullorderamz['printtype'] == 3)
  6010. {
  6011. $printtype = '不打印单据';
  6012. }
  6013. else
  6014. {
  6015. $printtype = '未选择';
  6016. }
  6017. $this->data['warehouse'] = $warehouse['title'];
  6018. $this->data['state'] = $state['title'];
  6019. $this->data['capital'] = $capital;
  6020. $this->data['country'] = $country['name'];
  6021. $this->data['printtype'] = $printtype;
  6022. //单项结束
  6023. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  6024. $downwaybill = '';$dwls = array();
  6025. $oldwaybill = explode('-',ltrim($fullorderamz['oldwaybill'],'-'));
  6026. if(isset($oldwaybill[0][1]))
  6027. {
  6028. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6029. foreach ($oldwaybill as $v)
  6030. {
  6031. $dw = explode('/',$v);
  6032. if(isset($dw[1]))
  6033. {
  6034. if(stripos($downwaybill,$dw[1]) === false)
  6035. {
  6036. $dwls[$dw[1]] = 1;
  6037. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  6038. }
  6039. }
  6040. }
  6041. }
  6042. if($fullorderamz['printtype'] == 1)
  6043. {
  6044. if($fullorderamz['waybill'] != '' && !isset($dwls[$fullorderamz['waybill']]))
  6045. {
  6046. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullorderamz['printtime']).'/y-'.$fullorderamz['waybill'].'.pdf" target="_blank">'.$fullorderamz['waybill'].'</a>、'.$downwaybill;
  6047. }
  6048. }
  6049. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  6050. /** 历史打印时间 **/
  6051. $printtime = '';
  6052. if($fullorderamz['oldprinttime'])
  6053. {
  6054. $pte = explode('-',rtrim($fullorderamz['oldprinttime'],'-'));
  6055. foreach ($pte as $v)
  6056. {
  6057. $printtime .= date('Y-m-d H:i:s',$v).'、';
  6058. }
  6059. }
  6060. $this->data['printtime'] = rtrim($printtime,'、');
  6061. $product = '';
  6062. $fullorderamz['product'] = str_replace("'","",$fullorderamz['product']);
  6063. if($fullorderamz['link'] != '' && $fullorderamz['source'] != '1')
  6064. {
  6065. $pt = explode(',',$fullorderamz['product']);
  6066. $lk = explode(',',$fullorderamz['link']);
  6067. for($i=0;$i<count($pt);$i++)
  6068. {
  6069. if(isset($lk[$i]))
  6070. {
  6071. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  6072. }
  6073. else
  6074. {
  6075. $octs = '';
  6076. }
  6077. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  6078. //$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];
  6079. if(isset($lk[$i]))
  6080. {
  6081. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  6082. }
  6083. else
  6084. {
  6085. $product .= ($product != '')?' , '.$a:$a;
  6086. }
  6087. }
  6088. }
  6089. else
  6090. {
  6091. $octs = $this->colourorderts->get_text($fullorderamz['product']);
  6092. $a = $octs?'<font style="color:#F39">'.$fullorderamz['product'].'</font>':$fullorderamz['product'];
  6093. //$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'];
  6094. $product = $a;
  6095. }
  6096. $this->data['product'] = $product;
  6097. $out = $this->systemtransfer->find_all("number = '".$fullorderamz['number']."'");
  6098. $outread = '';
  6099. if($out)
  6100. {
  6101. foreach ($out as $val)
  6102. {
  6103. $list = '';
  6104. $rk = explode('|',trim($val['rk'],'|'));
  6105. $rktime = explode('|',trim($val['rktime'],'|'));
  6106. $zw = array();
  6107. $t = $this->transfer->find_all("1=1");
  6108. foreach ($t as $v)
  6109. {
  6110. $zw[$v['id']] = $v['title'];
  6111. }
  6112. if($val['rk'] != '' && count($rk) > 0)
  6113. {
  6114. for($i=0;$i<count($rk);$i++)
  6115. {
  6116. if(!isset($rktime[$i]))
  6117. {
  6118. $list .= $zw[$cz[$i]];
  6119. }
  6120. else
  6121. {
  6122. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  6123. }
  6124. }
  6125. }
  6126. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  6127. }
  6128. }
  6129. else
  6130. {
  6131. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullorderamz['number']."'");
  6132. $outread = array();
  6133. if($systemwigsout)
  6134. {
  6135. foreach ($systemwigsout as $v)
  6136. {
  6137. if($v['czwarehouse'] == 37)
  6138. {
  6139. $outread[] = '华荣厂';
  6140. }
  6141. else if($v['czwarehouse'] == 0)
  6142. {
  6143. $outread[] = '龙盈厂';
  6144. }
  6145. $cz = explode('|',trim($v['cz'],'|'));
  6146. $cztime = explode('|',trim($v['cztime'],'|'));
  6147. $zw = $this->transfer->get_list();
  6148. if($v['cz'] != '' && count($cz) > 0)
  6149. {
  6150. for($i=0;$i<count($cz);$i++)
  6151. {
  6152. if(!isset($cztime[$i]))
  6153. {
  6154. $outread[] = $zw[$cz[$i]].' -&gt; ';
  6155. }
  6156. else
  6157. {
  6158. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  6159. }
  6160. }
  6161. $outread[] = '<br>';
  6162. }
  6163. }
  6164. }
  6165. }
  6166. $klarnacolor = '';
  6167. if($fullorderamz['klarnadata'] !='')
  6168. {
  6169. $klarnadata = explode('|',$fullorderamz['klarnadata']);
  6170. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  6171. {
  6172. $klarnadata[1] = json_decode($klarnadata[1],true);
  6173. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullorderamz['shouldmoney'] && $fullorderamz['pay'] == 1211)
  6174. {
  6175. $klarnacolor = 'style="color:#F00"';
  6176. }
  6177. }
  6178. else if($klarnadata[0]!=1 && $fullorderamz['pay']!=26 && $fullorderamz['pay']!=27 && $fullorderamz['pay']!=1211)
  6179. {
  6180. $klarnacolor = 'style="color:#F00"';
  6181. }
  6182. if($fullorderamz['pay'] == 23)//klarna
  6183. {
  6184. $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');
  6185. $ToState = array_flip($ToState);
  6186. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  6187. $city = str_replace(' ','',$fullorderamz['city']);
  6188. $klarnadataaddress = explode($city,$klarnadata3);
  6189. if(isset($klarnadataaddress[1]))
  6190. {
  6191. $klarnadata3 = $city.$klarnadataaddress[1];
  6192. $klarnadatacolor = explode(',',$klarnadata3);
  6193. unset($klarnadatacolor[4]);
  6194. unset($klarnadatacolor[6]);
  6195. if(isset($ToState[$klarnadatacolor[1]]))
  6196. {
  6197. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  6198. }
  6199. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  6200. }
  6201. else
  6202. {
  6203. $klarnadata['color'] = $klarnadata3;
  6204. }
  6205. }
  6206. }
  6207. else
  6208. {
  6209. $klarnadata = '';
  6210. }
  6211. $p = explode('-',$fullorderamz['paypal']);
  6212. $this->data['klarnacolor'] = $klarnacolor;
  6213. $this->data['klarnadata'] = $klarnadata;
  6214. $this->data['systemwigsout'] = $outread;
  6215. $this->_Template('fullorderamz_zw',$this->data);
  6216. }
  6217. public function _dcdxyz()
  6218. {
  6219. $post = $this->input->get(NULL, TRUE);
  6220. if(isset($post['timetk']))
  6221. {
  6222. $timetk = $this->input->get('timetk',true);
  6223. $timetj = $this->input->get('timetj',true);
  6224. $timetk = strtotime($timetk);
  6225. $timetj = strtotime($timetj);
  6226. $where = "oldwaybill != ''";
  6227. if($timetk && $timetj)
  6228. {
  6229. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6230. }
  6231. //数据排序
  6232. $order_str = "dtime desc";
  6233. //取得信息列表
  6234. $info_list = $this->fullorderamz->find_all($where,'orderinfo,number,oldwaybill',$order_str);
  6235. $data = array();
  6236. foreach ($info_list as $key=>$value)
  6237. {
  6238. $ob = '';
  6239. $oldwaybill = explode('-',trim($value['oldwaybill'],'-'));
  6240. if(count($oldwaybill) < 2)
  6241. {
  6242. continue;
  6243. }
  6244. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6245. foreach ($oldwaybill as $v)
  6246. {
  6247. $dw = explode('/',$v);
  6248. if(isset($dw[1]))
  6249. {
  6250. $dwls[$dw[1]] = 1;
  6251. $ob .= $dw[1].'、';
  6252. }
  6253. }
  6254. $info_list[$key]['oldwaybill'] = trim($ob,'、');
  6255. $data[] = $info_list[$key];
  6256. }
  6257. $title = "多运单信息 ".date("Y-m-d");
  6258. $titlename = "<table border=1>
  6259. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6260. <tr>
  6261. <td>订单号</td>
  6262. <td>编号</td>
  6263. <td>运单号</td>
  6264. </tr>
  6265. </table>";
  6266. $filename = $title.".xls";
  6267. $tail = "\n";
  6268. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  6269. }
  6270. }
  6271. public function _thxz()
  6272. {
  6273. $post = $this->input->get(NULL, TRUE);
  6274. if(isset($post['timetk']))
  6275. {
  6276. $timetk = $this->input->get('timetk',true);
  6277. $timetj = $this->input->get('timetj',true);
  6278. $timetk = strtotime($timetk);
  6279. $timetj = strtotime($timetj);
  6280. $where = "returndata != ''";
  6281. if($timetk && $timetj)
  6282. {
  6283. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6284. }
  6285. //数据排序
  6286. $order_str = "dtime desc";
  6287. //取得信息列表
  6288. $info_list = $this->fullorderamz->find_all($where,'orderinfo,number,returndata',$order_str);
  6289. foreach ($info_list as $key=>$value)
  6290. {
  6291. $ydh = explode('">',$value['returndata']);
  6292. $ydh = explode('</a>',$ydh[1]);
  6293. $info_list[$key]['returndata'] = $ydh[0];
  6294. $time = explode('pdf/',$value['returndata']);
  6295. $time = explode('/',$time[1]);
  6296. $info_list[$key]['time'] = $time[0];
  6297. }
  6298. $title = "退货订单信息 ".date("Y-m-d");
  6299. $titlename = "<table border=1>
  6300. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6301. <tr>
  6302. <td>订单号</td>
  6303. <td>编号</td>
  6304. <td>退货运单号</td>
  6305. <td>退货时间</td>
  6306. </tr>
  6307. </table>";
  6308. $filename = $title.".xls";
  6309. $tail = "\n";
  6310. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  6311. }
  6312. }
  6313. public function _ddcf()
  6314. {
  6315. $post = $this->input->post(NULL, TRUE);
  6316. if(isset($post['number']))
  6317. {
  6318. $number = $this->input->post('number',true);
  6319. $data = $this->fullorderamz->get_number($number);
  6320. if(!$data)
  6321. {
  6322. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  6323. }
  6324. if($data['review'] != 1 && $data['review'] != 2)
  6325. {
  6326. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  6327. }
  6328. if($data['merge'] != 0)
  6329. {
  6330. echo json_encode(array('msg'=>'已合并的订单无法使用此拆分功能','success'=>false));exit;
  6331. }
  6332. $cfnum = explode('-',trim($number,'-'));
  6333. if(count($cfnum)> 4)
  6334. {
  6335. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6336. }
  6337. $num = $this->fullorderamz->find_count("number like '".$number."%'");
  6338. $data['number'] = $data['number'].'-'.$num;
  6339. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);
  6340. $data['shouldmoney'] = 0;
  6341. $data['budget'] = 0;
  6342. $data['shipremarks'] = '';
  6343. $data['source'] = 1;
  6344. $data['extra_status'] = 1;//拆分的订单
  6345. unset($data['id']);
  6346. unset($data['jweight']);
  6347. unset($data['fpcount']);
  6348. unset($data['returndata']);
  6349. unset($data['oldwaybill']);
  6350. unset($data['waybill']);
  6351. unset($data['printtime']);
  6352. if($this->fullorderamz->insert($data))
  6353. {
  6354. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  6355. }
  6356. else
  6357. {
  6358. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  6359. }
  6360. }
  6361. }
  6362. public function _cf() //合并订单拆分
  6363. {
  6364. $post = $this->input->post(NULL, TRUE);
  6365. if(isset($post['id']))
  6366. {
  6367. $id = $this->input->post('id',true);
  6368. $b = $this->fullorderamz->read($id);
  6369. $order = array();
  6370. if($b['merge'] == $b['id'])
  6371. {
  6372. $data = $this->fullorderamz->find_all("merge = '".$b['merge']."'");
  6373. foreach ($data as $v)
  6374. {
  6375. $a = $this->fullorderamzhb->get_orderinfo($v['orderinfo']);
  6376. if($a)
  6377. {
  6378. $this->fullorderamz->save($a,$v['id']);
  6379. }
  6380. $order[] = $v['id'];
  6381. }
  6382. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  6383. }
  6384. else
  6385. {
  6386. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  6387. }
  6388. }
  6389. }
  6390. public function _pljzzd()
  6391. {
  6392. $post = $this->input->post(NULL, TRUE);
  6393. if(isset($post['s']))
  6394. {
  6395. $id_arr = $this->input->post('s');
  6396. $id_arr = explode(',',$id_arr);
  6397. if(!$id_arr)
  6398. {
  6399. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  6400. }
  6401. //循环删除记录
  6402. $this->db->trans_begin();
  6403. foreach ($id_arr as $value)
  6404. {
  6405. $post = $this->fullorderamz->read($value);
  6406. $hbw = explode('|',trim($post['whlabel'],'|'));
  6407. $hbf = explode(';',trim($post['fpdata'],';'));
  6408. foreach ($hbw as $k=>$val)
  6409. {
  6410. $w = explode('-',$val);
  6411. $f = explode('|',$hbf[$k]);
  6412. $w[2] = "DNOTO";
  6413. $f[9] = "DNOTO";
  6414. $hbf[$k] = implode("|",$f);
  6415. $hbw[$k] = implode("-",$w);
  6416. }
  6417. $w = $this->whlabel->find_all("zd = '".$post['number']."'");
  6418. foreach ($w as $k=>$val)
  6419. {
  6420. $this->whlabel->save(array('zd'=>''),$val['id']);
  6421. }
  6422. $fpdata = implode(";",$hbf).';';
  6423. $whlabel = '|'.implode("|",$hbw).'|';
  6424. $this->fullorderamz->save(array('fpdata'=>$fpdata,'whlabel'=>$whlabel),$post['id']);
  6425. }
  6426. if ($this->db->trans_status() === FALSE)
  6427. {
  6428. $this->db->trans_rollback();
  6429. }
  6430. else
  6431. {
  6432. $this->db->trans_commit();
  6433. }
  6434. echo json_encode(array('del'=>$id_arr,'msg'=>'操作成功,已暂时隐藏,可继续操作其它订单,刷新即可显示!','success'=>true));
  6435. }
  6436. }
  6437. }