Guest User

Untitled

a guest
Oct 24th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. @GrabConfig(systemClassLoader=true)
  2. @Grab(group='mysql', module='mysql-connector-java', version='5.1.6')
  3. import groovy.sql.Sql
  4.  
  5. sql = Sql.newInstance("jdbc:mysql://localhost:3306/sd_magento", "root",
  6. "password", "com.mysql.jdbc.Driver")
  7.  
  8. //def idz = [ 140 : getSomeDate(30),
  9. // 142 : getSomeDate(7),
  10. // 144 : getSomeDate(0),
  11. // 146 : getSomeDate(-15),
  12. // 148 : getSomeDate(-30),
  13. // 147 : getSomeDate(0),
  14. // 155 : getSomeDate(-31),
  15. // ]
  16. def idz = [ 219: getSomeDate(30) , 220: getSomeDate(30) ];
  17.  
  18. println "\n\nBEGINNING TO SET DATA..\n\n";
  19.  
  20. idz.each{id,date->
  21. def qinfo = String.format('select ce.email, srp.schedule_description from sales_recurring_profile srp, customer_entity ce ' +
  22. ' where ce.entity_id = srp.customer_id ' +
  23. ' and srp.profile_id = %d',id);
  24. def info = sql.firstRow(qinfo);
  25. def qry = String.format("update sales_recurring_profile set sd_updated_at = '%s', " +
  26. "created_at = '%s' where profile_id = %d",date,date,id)
  27. println info
  28. println qry + "\n"
  29. sql.execute(qry)
  30. def qry2 = String.format("update sales_recurring_profile set state='active' where profile_id = %d",id)
  31. sql.execute(qry2)
  32. }
  33.  
  34. println "\nTHE END....\n";
  35.  
  36. def getSomeDate(def days){
  37. def cal = new GregorianCalendar()
  38. cal.add(cal.YEAR,-1)
  39. cal.add(cal.DAY_OF_YEAR,days)
  40. return new java.sql.Timestamp(cal.time.time)
  41. }
Add Comment
Please, Sign In to add comment