Fullorder.php 231 KB

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