Fullorderamz.php 231 KB

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