Fullorder.php 232 KB

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