Fullorder.php 236 KB

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