Fullorder.php 230 KB

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