Subversion Repositories SmartDukaan

Rev

Rev 2338 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2122 varun.gupt 1
#!/bin/bash
2
 
2160 chandransh 3
if [ $# -ne 1 ]
4
then
5
	echo "Usage: $0 <email>"
6
	exit  1
7
fi
8
 
9
EMAIL=$1
10
 
11
# resolve links - $0 may be a softlink
12
PRG="$0"
13
 
14
while [ -h "$PRG" ]; do
15
  ls=`ls -ld "$PRG"`
16
  link=`expr "$ls" : '.*-> \(.*\)$'`
17
  if expr "$link" : '/.*' > /dev/null; then
18
    PRG="$link"
19
  else
20
    PRG=`dirname "$PRG"`/"$link"
21
  fi
22
done
23
 
24
# Get standard environment variables
25
PRGDIR=`dirname $(readlink -f "$PRG")`
26
PYTHON_DIR=${PRGDIR}/../PyProj/src/shop2020/utils
27
 
2122 varun.gupt 28
DATE=`date +%Y-%b-%d`
3511 rajveer 29
mysql -uroot -pshop2020 -h192.168.190.114 user -e "SELECT u.email, u.communication_email, c.coupon_code, c.total_price, c.discounted_price FROM user u, cart c WHERE u.active_cart_id = c.id AND (c.coupon_code IS NOT NULL AND c.coupon_code <> '') ORDER BY c.coupon_code, u.email;" > /tmp/carts_with_coupon.${DATE}.csv
30
mysql -uroot -pshop2020 -h192.168.190.114 user -e "SELECT o.id AS order_id, u.email, u.communication_email, pt.coupon_code, pt.transaction_id, pt.applied_on FROM user.promotiontracker pt, user.user u, transaction.order o WHERE u.id = pt.user_id AND o.transaction_id = pt.transaction_id;" > /tmp/orders_with_coupon.${DATE}.csv
2122 varun.gupt 31
 
32
#Email the two report files.
2336 varun.gupt 33
python ${PYTHON_DIR}/EmailAttachmentSender.py -t ${EMAIL} -s "Daily Promotion Update - Carts" -a /tmp/carts_with_coupon.${DATE}.csv
34
python ${PYTHON_DIR}/EmailAttachmentSender.py -t ${EMAIL} -s "Daily Promotion Update - Orders" -a /tmp/orders_with_coupon.${DATE}.csv
35
 
36
rm /tmp/carts_with_coupon.${DATE}.csv
37
rm /tmp/orders_with_coupon.${DATE}.csv