Fullorder.php 231 KB

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