Fullordertt.php 234 KB

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