Fullorder.php 230 KB

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