Fullorder.php 231 KB

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