Fullorder.php 229 KB

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