Files
2026-01-18 11:59:48 +03:30

591 lines
24 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# توابع مورد نیاز برای اتصال به ای پی آی سهند اس ام اس
from panel.helper import check_mobile_number
from ..models import SystemUserProfile
import requests
# USERNAME_SMS='user95'
# PASSWORD_SMS='Mm123456'
USERNAME_SMS='hamedan'
PASSWORD_SMS='hamedan12345'
USERNAME_SMS_FINANCIAL='hamedan'
PASSWORD_SMS_FINANCIAL='hamedan12345'
USERNAME_SMS_HAMEDAN='hamedan'
PASSWORD_SMS_HAMEDAN='hamedan12345'
OUT_SMS_USER='user95'
OUT_SMS_PASS='rasadyar123'
kill_house_price=21000
def test():
user = SystemUserProfile.objects.all()
for i in user:
if i.id > 9:
if i.first_name != None:
first = i.first_name
else:
first = ""
if i.last_name != None:
last = i.last_name
else:
last = ""
i.fullname = first + " " + last
i.save()
print("Done")
# این تابع برای ارسال پیامک نام کاربری و پسوورد برای مرعدار استفاده میشود
def send_sms(receptor=None, rand=None):
url = 'https://km.ravandno.ir'
receptor = str(receptor)
user = SystemUserProfile.objects.get(id=1825)
mobile = receptor
password = rand
message = '\n' \
'اتحادیه مرغ گوشتی استان کرمانشاه' \
'\n' \
'\n' \
'از این پس کلیه امور کشتاراز طریق سامانه سبحان انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{0}' \
'\n' \
'\n' \
'شماره همراه:\t{1}' \
'\n' \
'\n' \
'رمز عبور:\t{2}' \
'\n' \
'\n' \
'هرگونه فروش مرغ بدون اطلاع اتحادیه و خارج از سامانه ذکر شده پیگرد قانونی دارد و مجوز جوجه ریزی صادر نخواهد شد.'.format(
url,
mobile,
password)
check_mobile = check_mobile_number(mobile)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
mobile, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text, user.fullname, user.mobile, user.password)
def send_sms_2(receptor=None, rand=None):
users = SystemUserProfile.objects.filter(role__name='Poultry')
receptor = str(receptor)
for user in users:
url = 'https://sha.ravandno.ir'
message = '\n' \
'مرغدار محترم:' \
'\n' \
'{0}' \
'\n' \
'\n' \
'از این پس کلیه امور کشتاراز طریق سامانه رصدیار انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{1}' \
'\n' \
'\n' \
'شماره همراه:\t{2}' \
'\n' \
'\n' \
'رمز عبور:\t{3}' \
'\n' \
'\n' \
'هرگونه فروش مرغ بدون اطلاع اتحادیه و خارج از سامانه ذکر شده پیگرد قانونی دارد و مجوز جوجه ریزی صادر نخواهد شد.' \
'\n' \
'\n' \
'اتحادیه مرغ گوشتی'.format(
user.fullname,
url,
user.mobile,
user.password)
check_mobile = check_mobile_number(user.mobile)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
user.mobile, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(user.mobile + " " + user.fullname + " " + "Done")
# این تابع برای ارسال پیامک نام کاربری و پسوورد برای کشتارگاه استفاده میشود
def send_sms_kill_house(receptor=None, rand=None):
users = SystemUserProfile.objects.filter(role__name='KillHouse')
receptor = str(receptor)
for user in users:
url = 'https://sha.ravandno.ir'
# time.sleep(2)
message = '\n' \
'کشتارگاه دار محترم:' \
'\n' \
'{0}' \
'\n' \
'\n' \
'از این پس کلیه امور کشتاراز طریق سامانه رصدیار انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{1}' \
'\n' \
'\n' \
'شماره همراه:\t{2}' \
'\n' \
'\n' \
'رمز عبور:\t{3}' \
'\n' \
'\n' \
'هرگونه خرید مرغ بدون اطلاع اتحادیه و خارج از سامانه ذکر شده پیگرد قانونی دارد.' \
'\n' \
'\n' \
'اتحادیه مرغ گوشتی'.format(
user.fullname,
url,
user.mobile,
user.password)
check_mobile = check_mobile_number(user.mobile)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
user.mobile, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(user.mobile + " " + user.fullname + " " + "Done")
# این تابع برای ارسال پیامک نام کاربری و پسوورد برای اپراتور استان استفاده میشود
def send_sms_province(receptor=None, rand=None):
url = 'https://sha.ravandno.ir'
receptor = str(receptor)
message = '\n' \
'اتحادیه مرغ گوشتی استان لرستان' \
'\n' \
'\n' \
'از این پس کلیه امور کشتاراز طریق سامانه رصدیار انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{0}' \
'\n' \
'\n' \
'شماره همراه:\t{1}' \
'\n' \
'\n' \
'رمز عبور:\t{2}' \
'\n' \
'\n' \
'هرگونه خرید و فروش مرغ بدون اطلاع اتحادیه شهرستان و استان و خارج از سامانه ذکر شده پیگرد قانونی دارد.'.format(
url,
receptor,
rand)
check_mobile = check_mobile_number(receptor)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
receptor, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
# این تابع برای ارسال پیامک نام کاربری و پسوورد برای اپراتور شهرستان استفاده میشود
def send_sms_city(receptor, rand):
url = 'https://ravandno.ir'
receptor = str(receptor)
message = '\n' \
'اتحادیه مرغ گوشتی استان لرستان' \
'\n' \
'\n' \
'از این پس کلیه امور کشتاراز طریق سامانه سبحان انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{0}' \
'\n' \
'\n' \
'شماره همراه:\t{1}' \
'\n' \
'\n' \
'رمز عبور:\t{2}' \
'\n' \
'\n' \
'هرگونه خرید و فروش مرغ بدون اطلاع اتحادیه شهرستان و استان و خارج از سامانه ذکر شده پیگرد قانونی دارد.'.format(
url,
receptor,
rand)
check_mobile = check_mobile_number(receptor)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
receptor, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
# این تابع برای ارسال کد پیامکی (ا تی پی ) به کاربر استفاده میشود
def send_otp_code(receptor, rand):
receptor = str(receptor)
message = 'سلام همراه عزیز کد پیامکی ارسالی برای شما :{}'.format(rand)
check_mobile = check_mobile_number(receptor)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
receptor, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload, verify=False)
print(response.text)
# این تابع برای ارسال پسورد به کاربر استفاده میشود
def send_password(receptor, rand):
receptor = str(receptor)
message = 'سلام همراه عزیز پسورد ارسالی برای شما :{}'.format(rand)
check_mobile = check_mobile_number(receptor)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from" \
"=30002501&to={}&message={}".format(receptor, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
def sms_reminder(receptor, title, content, link_text, link, time):
receptor = str(receptor)
message = "\n{4}\n{3}\n{2}\n{1}\n{0}".format(title, content, link_text, link, time)
check_mobile = check_mobile_number(receptor)
if check_mobile:
url = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=" \
"Aht00100&from=30002501&to={}&message={}".format(receptor, message)
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
return response
def price_reminder(receptor, fullname):
receptor = str(receptor)
message = 'کاربر گرامی {} 2 ساعت تا شزوع روز بعد باقی است لطفا قیمت های روز بعد را وارد نمایید'.format(fullname)
check_mobile = check_mobile_number(receptor)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
receptor, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
# این تابع برای ارسال اطلاعات بار تخصیصی به کشتارگاه برای راننده استفاده میشود
def driver_sms(driver_mobile, drive_rname, quantity, poultry, barcode, province, city, address, date, time, kill_house):
message = ' راننده گرامی {0}\nحواله بار {1} قطعه مرغ\n با بارکد: {2}\nاز مرغدار:{3}\nبه آدرس:{4}, {5},{6} در تاریخ {7} با بازه زمانی{8} جهت {9} به شما تخصیص داده شده است.\nنسبت به حمل آن اقدام نمایید.'.format(
drive_rname, quantity, barcode, poultry, province, city, address, date, time, kill_house)
check_mobile = check_mobile_number(driver_mobile)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
driver_mobile, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
def send(receptor):
receptor = str(receptor)
message = 'کاربر گرامی آقای امیدی از درخواست کشتار 9000 قطعه شما \n 3000 قطعه به کشتارگاه پرطلایی \n 3000 قطعه به کشتارگاه افلاک \n 3000 قطعه به کشتارگاه پرند\n تخصیص داده شده است نسبت به تحویل بار به این واحد ها اقدام نمایید\n اطلاعات تکمیلی را در پنل سامانه سبحان مشاهده نمایید '
check_mobile = check_mobile_number(receptor)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
receptor, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
def send_2(receptor):
receptor = str(receptor)
message = ''
check_mobile = check_mobile_number(receptor)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
receptor, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
def sms_for_tabriz(receptor):
users = SystemUserProfile.objects.filter(role__name='KillHouse')
receptor = str(receptor)
for user in users:
url = 'https://sha.ravandno.ir'
message = '\n' \
'کشتارگاه دار محترم:' \
'\n' \
'{0}' \
'\n' \
'\n' \
'از این پس کلیه امور کشتاراز طریق سامانه رصدیار انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{1}' \
'\n' \
'\n' \
'شماره همراه:\t{2}' \
'\n' \
'\n' \
'رمز عبور:\t{3}' \
'\n' \
'\n' \
'هرگونه خرید مرغ بدون اطلاع اتحادیه و خارج از سامانه ذکر شده پیگرد قانونی دارد.' \
'\n' \
'\n' \
'اتحادیه مرغ گوشتی استان آذربایجان شرقی'.format(
user.fullname,
url,
user.mobile,
user.password)
check_mobile = check_mobile_number(user.mobile)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
user.mobile, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(user.mobile + " " + user.fullname + " " + "Done")
def send_sms_for_jahad(receptor=None, rand=None):
users = SystemUserProfile.objects.filter(role__name='Jahad')
receptor = str(receptor)
for user in users:
url = 'https://sha.ravandno.ir'
message = '\n' \
'ناظر محترم جهاد استان:' \
'\n' \
'{0}' \
'\n' \
'\n' \
'از این پس کلیه امور کشتار مرغ گوشتی از طریق سامانه رصدیار انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{1}' \
'\n' \
'\n' \
'شماره همراه:\t{2}' \
'\n' \
'\n' \
'رمز عبور:\t{3}' \
'\n' \
'\n' \
'جهت راه اندازی سامانه نیاز به همکاری شما دوستان در برطرف کردن مشکلات احتمالی می باشیم.' \
'\n' \
'\n' \
'باتشکر مدیریت سامانه رصدیار'.format(
user.fullname,
url,
user.mobile,
user.password)
check_mobile = check_mobile_number(user.mobile)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
user.mobile, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(user.mobile + " " + user.fullname + " " + "Done")
def send_sms_for_province(receptor=None, rand=None):
users = SystemUserProfile.objects.filter(role__name='ProvinceOperator')
receptor = str(receptor)
for user in users:
url = 'https://sha.ravandno.ir'
message = '\n' \
'اپراتور محترم:' \
'\n' \
'{0}' \
'\n' \
'\n' \
'از این پس کلیه امور کشتار مرغ گوشتی از طریق سامانه رصدیار انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{1}' \
'\n' \
'\n' \
'شماره همراه:\t{2}' \
'\n' \
'\n' \
'رمز عبور:\t{3}' \
'\n' \
'\n' \
'هرگونه خرید و فروش مرغ خارج از سامانه ذکر شده پیگرد قانونی دارد.'.format(
user.fullname,
url,
user.mobile,
user.password)
check_mobile = check_mobile_number(user.mobile)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
user.mobile, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(user.mobile + " " + user.fullname + " " + "Done")
def send_sms_for_city(receptor=None, rand=None):
users = SystemUserProfile.objects.filter(role__name='CityOperator')
receptor = str(receptor)
for user in users:
url = 'https://sha.ravandno.ir'
message = '\n' \
'اپراتور محترم:' \
'\n' \
'{0}' \
'\n' \
'\n' \
'از این پس کلیه امور کشتار مرغ گوشتی از طریق سامانه رصدیار انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{1}' \
'\n' \
'\n' \
'شماره همراه:\t{2}' \
'\n' \
'\n' \
'رمز عبور:\t{3}' \
'\n' \
'\n' \
'هرگونه خرید و فروش مرغ خارج از سامانه ذکر شده پیگرد قانونی دارد.'.format(
user.fullname,
url,
user.mobile,
user.password)
check_mobile = check_mobile_number(user.mobile)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
user.mobile, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(user.mobile + " " + user.fullname + " " + "Done")
def send_sms_for_vet(receptor=None, rand=None):
users = SystemUserProfile.objects.filter(role__name__in=('VetFarm','KillHouseVet'))
receptor = str(receptor)
for user in users:
url = 'https://sha.ravandno.ir'
message = '\n' \
'دامپزشک محترم:' \
'\n' \
'{0}' \
'\n' \
'\n' \
'از این پس کلیه امور کشتاراز طریق سامانه رصدیار انجام میگردد.' \
'\n' \
'\n' \
'لینک ورود به سامانه:' \
'\n' \
'\t\t\t{1}' \
'\n' \
'\n' \
'شماره همراه:\t{2}' \
'\n' \
'\n' \
'رمز عبور:\t{3}' \
'\n' \
'\n' \
'هرگونه خرید و فروش مرغ بدون اطلاع اتحادیه و خارج از سامانه ذکر شده پیگرد قانونی دارد.' \
'\n' \
'\n' \
'اتحادیه مرغ گوشتی'.format(
user.fullname,
url,
user.mobile,
user.password)
check_mobile = check_mobile_number(user.mobile)
if check_mobile:
u = "http://webservice.sahandsms.com/newsmswebservice.asmx/SendPostUrl?username=pmstores&password=Aht00100&from=30002501&to={}&message={}".format(
user.mobile, message)
url = u.format()
payload = {}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("GET", url, headers=headers, data=payload)
print(user.mobile + " " + user.fullname + " " + "Done")