Fullorder.php 235 KB

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