Fullorder.php 237 KB

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