Fullorderxw.php 213 KB

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