Fullorder.php 238 KB

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