Fullorder.php 232 KB

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