Fullorder.php 228 KB

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