Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @GrabConfig(systemClassLoader=true)
- @Grab(group='mysql', module='mysql-connector-java', version='5.1.6')
- import groovy.sql.Sql
- sql = Sql.newInstance("jdbc:mysql://localhost:3306/sd_magento", "root",
- "password", "com.mysql.jdbc.Driver")
- //def idz = [ 140 : getSomeDate(30),
- // 142 : getSomeDate(7),
- // 144 : getSomeDate(0),
- // 146 : getSomeDate(-15),
- // 148 : getSomeDate(-30),
- // 147 : getSomeDate(0),
- // 155 : getSomeDate(-31),
- // ]
- def idz = [ 219: getSomeDate(30) , 220: getSomeDate(30) ];
- println "\n\nBEGINNING TO SET DATA..\n\n";
- idz.each{id,date->
- def qinfo = String.format('select ce.email, srp.schedule_description from sales_recurring_profile srp, customer_entity ce ' +
- ' where ce.entity_id = srp.customer_id ' +
- ' and srp.profile_id = %d',id);
- def info = sql.firstRow(qinfo);
- def qry = String.format("update sales_recurring_profile set sd_updated_at = '%s', " +
- "created_at = '%s' where profile_id = %d",date,date,id)
- println info
- println qry + "\n"
- sql.execute(qry)
- def qry2 = String.format("update sales_recurring_profile set state='active' where profile_id = %d",id)
- sql.execute(qry2)
- }
- println "\nTHE END....\n";
- def getSomeDate(def days){
- def cal = new GregorianCalendar()
- cal.add(cal.YEAR,-1)
- cal.add(cal.DAY_OF_YEAR,days)
- return new java.sql.Timestamp(cal.time.time)
- }
Add Comment
Please, Sign In to add comment