Пример #1
0
    def get(self):
        result = {'status': False, 'msg': ''}
        mobile = self.get_argument("mobile", None)

        UserVcode.delete().where(
            UserVcode.created < (int(time.time()) - 2 * 3600)).execute()

        uservcode = UserVcode()
        uservcode.mobile = mobile
        uservcode.vcode = random.randint(1000, 9999)

        try:
            uservcode.validate()

            if UserVcode.select().where(
                    UserVcode.mobile == mobile).count() > 3:
                result['msg'] = 503
            else:
                try:
                    sendmsg(self.settings, mobile,
                            "您在菜市优品获取的验证码为" + str(uservcode.vcode) + "【菜市优品】")
                    uservcode.save()

                    logging.info("sendmsg:%s - %d" % (mobile, uservcode.vcode))

                    result['status'] = True
                    result['msg'] = uservcode.vcode
                except Exception, ex:
                    logging.error(ex)
                    result['msg'] = 500

        except Exception, ex:
            logging.error(ex)
            result['msg'] = 400
Пример #2
0
 def get(self):
     result = {'status':False, 'msg':''}
     mobile = self.get_argument("mobile", None)
     
     UserVcode.delete().where(UserVcode.created < (int(time.time()) - 2 * 3600)).execute()
     
     uservcode = UserVcode()
     uservcode.mobile = mobile
     uservcode.vcode = random.randint(1000, 9999)
     
     try:
         uservcode.validate()
         
         if UserVcode.select().where(UserVcode.mobile == mobile).count() > 3:
             result['msg'] = 503
         else:
             try:
                 sendmsg(self.settings, mobile, "您在菜市优品获取的验证码为" + str(uservcode.vcode) + "【菜市优品】")
                 uservcode.save()
                 
                 logging.info("sendmsg:%s - %d" % (mobile, uservcode.vcode))
                 
                 result['status'] = True
                 result['msg'] = uservcode.vcode
             except Exception, ex:
                 logging.error(ex)
                 result['msg'] = 500
         
     except Exception, ex:
         logging.error(ex)
         result['msg'] = 400
Пример #3
0
    def get(self):
        result = {'status':False, 'msg':''}
        mobile = self.get_argument("mobile", None)
        
        UserVcode.delete().where(UserVcode.created < (int(time.time()) - 2 * 3600)).execute()
        
        uservcode = UserVcode()
        uservcode.mobile = mobile
        uservcode.vcode = random.randint(1000, 9999)
        
        try:
            uservcode.validate()
            
            if UserVcode.select().where(UserVcode.mobile == mobile).count() > 3:
                result['msg'] = 503
            else:
                try:
                    sendmsg(self.settings, mobile, "验证码:{0}【华图科技】".format(str(uservcode.vcode)))
                    uservcode.save()
                    
                    logging.info("sendmsg:%s - %d" % (mobile, uservcode.vcode))
                    
                    result['status'] = True
                    result['msg'] = uservcode.vcode
                except Exception as ex:
                    logging.error(ex)
                    result['msg'] = 500
            
        except Exception as ex:
            logging.error(ex)
            result['msg'] = 400
 
        self.write(simplejson.dumps(result))
Пример #4
0
    def get(self):
        orderitems = []
        user = self.current_user

        order = None

        distributions = self.get_distributions()
        price = 0.0
        credit = 0.0

        try:
            order = Order.get(uid=user.id, status=0)

            try:
                mobile = '18014349809'
                sendmsg(self.settings, mobile, '新订单')
            except:
                pass

            for orderitem in OrderItem.select().where(
                    OrderItem.oid == order.id).dicts():
                try:
                    orderitem['shop'] = Shop.get(id=orderitem['sid'])
                    _oiprice = orderitem['shop'].price

                    if orderitem['said'] > 0:
                        orderitem['shopattr'] = ShopAttr.get(
                            id=orderitem['said'])
                        if orderitem['shop'].cid == 1:
                            _oicredit = orderitem['shopattr'].price
                            credit = credit + _oicredit * orderitem['num']
                        else:
                            _oiprice = orderitem['shopattr'].price
                    else:
                        _oiprice = float(_oiprice)

                    orderitems.append(orderitem)

                    price = price + _oiprice * orderitem['num']

                except:
                    pass
            order.price = price
            order.save()

        except:
            pass

        if orderitems:
            self.render("shop/settle.html",
                        tmday=datetime.date.today() +
                        datetime.timedelta(days=1),
                        order=order,
                        orderitems=orderitems,
                        distributions=distributions.values(),
                        credit=credit)
Пример #5
0
 def get(self):
     orderitems = []
     user = self.current_user
     
     order = None
     
     distributions = self.get_distributions()
     price = 0.0
     credit = 0.0
     
     try:
         order = Order.get(uid = user.id, status = 0)
         
         try:
             mobile = '18014349809'
             sendmsg(self.settings, mobile, '新订单')
         except:
             pass
             
         for orderitem in OrderItem.select().where(OrderItem.oid == order.id).dicts():
             try:
                 orderitem['shop'] = Shop.get(id = orderitem['sid'])
                 _oiprice = orderitem['shop'].price
                 
                 if orderitem['said'] > 0:
                     orderitem['shopattr'] = ShopAttr.get(id = orderitem['said'])
                     if orderitem['shop'].cid == 1:
                         _oicredit = orderitem['shopattr'].price
                         credit = credit + _oicredit * orderitem['num']
                     else:
                         _oiprice = orderitem['shopattr'].price
                 else:
                     _oiprice = float(_oiprice)
                 
                 orderitems.append(orderitem)
                 
                 price = price + _oiprice * orderitem['num']
                 
             except:
                 pass
         order.price = price
         order.save()
         
     except:
         pass
     
     if orderitems:
         self.render("shop/settle.html", tmday = datetime.date.today() + datetime.timedelta(days=1), order  = order, orderitems = orderitems, distributions = distributions.values(), credit = credit)
Пример #6
0
url = 'amqp://' + setting.MQUSER + ':' + setting.MQPASSWORD + '@' + setting.MQSERVER + ':' + setting.MQPORT + '/%2f'

with rabbitpy.Connection(url) as conn:
    with conn.channel() as channel:
        logging.error('start process tasks...')
        queue = rabbitpy.Queue(channel, setting.MQQUEUENAME)
        try:
            for message in queue.consume_messages():
                try:
                    if message.properties['message_type'] == 'sms':
                        sms = simplejson.loads(message.body)
                        try:
                            logging.error(u'发送短信:(' + sms['mobile'] + u')' +
                                          sms['body'])
                            sendmsg(sms['mobile'], sms['body'], sms['isyzm'])
                        except Exception, e:
                            logging.error(e.message)

                    elif message.properties['message_type'] == 'email':
                        email = simplejson.loads(message.body)
                        sendemail(email['receiver'], email['subject'],
                                  email['body'])

                    elif message.properties['message_type'] == 'all_sms':
                        sms = simplejson.loads(message.body)
                        logging.error(u'群发短信:' + sms['body'])
                        try:
                            send_sms_for_all_users(sms['body'])
                        except Exception, e:
                            logging.error(e.message)