Explorar o código

如果存在序列号,云存相关消息提示用序列号

locky %!s(int64=3) %!d(string=hai) anos
pai
achega
eac7ac9268
Modificáronse 2 ficheiros con 39 adicións e 18 borrados
  1. 29 17
      Controller/CloudStorage.py
  2. 10 1
      Service/CommonService.py

+ 29 - 17
Controller/CloudStorage.py

@@ -905,8 +905,11 @@ class CloudStorageView(View):
 
                     order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id, promotion_rule_id=promotion_rule_id)
                     datetime = time.strftime("%Y-%m-%d", time.localtime())
-                    sys_msg_text_list = ['温馨提示:尊敬的客户,您的'+UID+'设备在'+datetime+'已成功购买云存套餐', 'Dear customer,you already subscribed the cloud storage package successfully for device ' + UID + ' on '+ time.strftime("%b %dth,%Y", time.localtime())]
-                    self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
+                    # 如果存在序列号,消息提示用序列号
+                    device_name = CommonService.query_serial_with_uid(uid=UID)
+
+                    sys_msg_text_list = ['温馨提示:尊敬的客户,您的'+device_name+'设备在'+datetime+'已成功购买云存套餐', 'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on '+ time.strftime("%b %dth,%Y", time.localtime())]
+                    self.do_vod_msg_Notice(device_name, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
                     red_url = "{SERVER_DOMAIN_SSL}web/paid2/success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
                     if lang != 'cn':
                         red_url = "{SERVER_DOMAIN_SSL}web/paid2/en_success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
@@ -1049,11 +1052,14 @@ class CloudStorageView(View):
 
                 order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id, promotion_rule_id=promotion_rule_id)
                 datetime = time.strftime("%Y-%m-%d", time.localtime())
-                sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + UID + '设备在' + datetime + '已成功购买云存套餐',
-                                     'Dear customer,you already subscribed the cloud storage package successfully for device ' + UID + ' on ' + time.strftime(
+                # 如果存在序列号,消息提示用序列号
+                device_name = CommonService.query_serial_with_uid(uid=UID)
+
+                sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + datetime + '已成功购买云存套餐',
+                                     'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
                                          "%b %dth,%Y", time.localtime())]
 
-                self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
+                self.do_vod_msg_Notice(device_name, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
 
                 # return response.json(0)
                 red_url = "{SERVER_DOMAIN_SSL}web/paid2/success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
@@ -1175,10 +1181,13 @@ class CloudStorageView(View):
 
                     order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id, promotion_rule_id=promotion_rule_id)
                     datetime = time.strftime("%Y-%m-%d", time.localtime())
-                    sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + UID + '设备在' + datetime + '已成功购买云存套餐',
-                                         'Dear customer,you already subscribed the cloud storage package successfully for device ' + UID + ' on ' + time.strftime(
+                    # 如果存在序列号,消息提示用序列号
+                    device_name = CommonService.query_serial_with_uid(uid=UID)
+
+                    sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + datetime + '已成功购买云存套餐',
+                                         'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
                                              "%b %dth,%Y", time.localtime())]
-                    self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
+                    self.do_vod_msg_Notice(device_name, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
                     redisObj.del_data(key=orderID + 'do_notify')
                     return HttpResponse("<xml>\
                       <return_code><![CDATA[SUCCESS]]></return_code>\
@@ -1518,11 +1527,12 @@ class CloudStorageView(View):
                 #     UIDMainUser.objects.create(**uid_main_dict)
                 sms = 'SMS_219738485'
                 datetime = time.strftime("%Y-%m-%d", time.localtime())
-                sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + uid + '设备在' + datetime + '已成功购买云存套餐',
-                                     'Dear customer,you already subscribed the cloud storage package successfully for device ' + uid + ' on ' + time.strftime(
+                # 如果存在序列号,消息提示用序列号
+                device_name = CommonService.query_serial_with_uid(uid=uid)
+                sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + datetime + '已成功购买云存套餐',
+                                     'Dear customer,you already subscribed the cloud storage package successfully for device ' + device_name + ' on ' + time.strftime(
                                          "%b %dth,%Y", time.localtime())]
 
-                # return response.json(0)
                 returnurl = "{SERVER_DOMAIN_SSL}cloudstorage/payOK?lang={lang}".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL,lang=lang)
                 if pay_type == 10:
                     ExperienceContextModel.objects.create(
@@ -1532,8 +1542,8 @@ class CloudStorageView(View):
                     )
                     returnurl = "{SERVER_DOMAIN_SSL}cloudstorage/payOK?paytype=10&lang={lang}".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL,lang=lang)
                     datetime = time.strftime("%Y-%m-%d", time.localtime())
-                    sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + uid + '设备在' + datetime + '已成功开通云存体验套餐',
-                                         'Dear customer,you already subscribed the free trial cloud storage service successfully for device ' + uid + ' on '+ time.strftime("%b %dth,%Y", time.localtime())]
+                    sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + datetime + '已成功开通云存体验套餐',
+                                         'Dear customer,you already subscribed the free trial cloud storage service successfully for device ' + device_name + ' on '+ time.strftime("%b %dth,%Y", time.localtime())]
                     sms = 'SMS_222870823'
                 if pay_type == 11:
                     update_dict = {}
@@ -1543,8 +1553,8 @@ class CloudStorageView(View):
                     returnurl = "{SERVER_DOMAIN_SSL}cloudstorage/payOK?paytype=11&lang={lang}".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL,lang=lang)
 
                     datetime = time.strftime("%Y-%m-%d", time.localtime())
-                    sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + uid + '设备在' + datetime + '已成功兑换云存套餐',
-                                         'Dear customer, you already redeemed for the cloud storage package successfully for device ' +uid +' on '+time.strftime("%b %dth,%Y", time.localtime())]
+                    sys_msg_text_list = ['温馨提示:尊敬的客户,您的' + device_name + '设备在' + datetime + '已成功兑换云存套餐',
+                                         'Dear customer, you already redeemed for the cloud storage package successfully for device ' +device_name +' on '+time.strftime("%b %dth,%Y", time.localtime())]
                     sms = 'SMS_219748439'
 
                 self.do_vod_msg_Notice(uid, channel, userID, lang, sys_msg_text_list, sms)
@@ -1790,10 +1800,12 @@ class CloudStorageView(View):
         for ub in list:
             for oo in oqlist:
                 if ub['id'] == oo['uid_bucket_id']:
+                    # 如果存在序列号,消息提示用序列号
+                    device_name = CommonService.query_serial_with_uid(uid=ub['uid'])
                     if ub['bucket__area'] == 'cn':
-                        sys_msg_text = "温馨提示:尊敬的客户,您" + ub['uid'] + "设备的云存套餐将在" + time.strftime("%Y-%m-%d", time.localtime(ub['endTime'])) + "到期"
+                        sys_msg_text = "温馨提示:尊敬的客户,您" + device_name + "设备的云存套餐将在" + time.strftime("%Y-%m-%d", time.localtime(ub['endTime'])) + "到期"
                     else:
-                        sys_msg_text = 'Dear customer,the cloud storage package for your device '+ub['uid']+' will expire on '+time.strftime('%m-%d-%y',time.localtme(ub['endTime']))
+                        sys_msg_text = 'Dear customer,the cloud storage package for your device '+device_name+' will expire on '+time.strftime('%m-%d-%y',time.localtme(ub['endTime']))
                     uq_list.append(SysMsgModel(
                         userID_id=oo['userID_id'],
                         addTime=now_time,

+ 10 - 1
Service/CommonService.py

@@ -16,7 +16,7 @@ from Ansjer.config import BASE_DIR, UNICODE_ASCII_CHARACTER_SET, SERVER_DOMAIN_S
 import OpenSSL.crypto as ct
 from base64 import encodebytes
 from Controller.CheckUserData import RandomStr
-from Model.models import iotdeviceInfoModel
+from Model.models import iotdeviceInfoModel, Device_Info
 from Service.ModelService import ModelService
 
 
@@ -542,3 +542,12 @@ GCqvlyw5dfxNA+EtxNE2wCW/LW7ENJlACgcfgPlBZtpLheWoZB/maw4=
         pay_failed_url = "{}web/paid2/{}".format(SERVER_DOMAIN_SSL, file_name)
         return pay_failed_url
 
+    # 根据uid查询序列号,存在则返回序列号,否则返uid
+    @staticmethod
+    def query_serial_with_uid(uid):
+        device_info_qs = Device_Info.objects.filter(UID=uid)
+        if device_info_qs.exists():
+            serial_number = device_info_qs[0]['serial_number']
+            if serial_number:
+                return serial_number
+        return uid