line_push/changepage/changepage/dayscount.sh
2022-07-17 13:16:16 +08:00

42 lines
1.9 KiB
Bash

ID_COUNT=`jq . users|grep id| tail -n1 |awk -F " " '{ print $2 }'`
echo $ID_COUNT
touch OnedayTRIP
touch TwodayTRIP
for ((i=1;i<=$ID_COUNT;i++))
do
echo $i
curl -s https://json_2series.digitalent.tw/users?id=$i |grep -q 一日遊
daytrip_status=$?
echo $daytrip_status
if [ $daytrip_status -eq 0 ]
then
NumberOfPeople=`curl -s https://json_2series.digitalent.tw/users?id=$i |grep NumberOfPeople | awk -F "\"" '{ print $4 }'`
NumberOfChild=`curl -s https://json_2series.digitalent.tw/users?id=$i |grep NumberOfChild | awk -F "\"" '{ print $4 }'`
NumberOfBaby=`curl -s https://json_2series.digitalent.tw/users?id=$i |grep NumberOfBaby | awk -F "\"" '{ print $4 }'`
OneDAYTotalPeople=$((OneDAYTotalPeople+$NumberOfPeople))
OneDAYTotalChild=$((OneDAYTotalChild+$NumberOfChild))
OneDAYTotalBaby=$((OneDAYTotalBaby+$NumberOfBaby))
echo "一日遊 7歲以上 ${OneDAYTotalPeople}" >OnedayTRIP
echo "一日遊 3-6歲 ${OneDAYTotalChild}">>OnedayTRIP
echo "一日遊 2歲以下 ${OneDAYTotalBaby}">>OnedayTRIP
fi
curl -s https://json_2series.digitalent.tw/users?id=$i |grep -q 二日遊
daytrip_status=$?
echo $daytrip_status
if [ $daytrip_status -eq 0 ]
then
NumberOfPeople=`curl -s https://json_2series.digitalent.tw/users?id=$i |grep NumberOfPeople | awk -F "\"" '{ print $4 }'`
NumberOfChild=`curl -s https://json_2series.digitalent.tw/users?id=$i |grep NumberOfChild | awk -F "\"" '{ print $4 }'`
NumberOfBaby=`curl -s https://json_2series.digitalent.tw/users?id=$i |grep NumberOfBaby | awk -F "\"" '{ print $4 }'`
TwoDAYTotalPeople=$((TwoDAYTotalPeople+$NumberOfPeople))
TwoDAYTotalChild=$((TwoDAYTotalChild+$NumberOfChild))
TwoDAYTotalBaby=$((TwoDAYTotalBaby+$NumberOfBaby))
echo "二日遊 7歲以上 ${TwoDAYTotalPeople}">TwodayTRIP
echo "二日遊 3-6歲 ${TwoDAYTotalChild}">>TwodayTRIP
echo "二日遊 2歲以下 ${TwoDAYTotalBaby}">>TwodayTRIP
fi
done