def get(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        _account_id = self.get_secure_cookie("account_id")

        _customer_profile = vendor_member_dao.vendor_member_dao().query_not_safe(vendor_id, _account_id)
        if not _customer_profile:
            _customer_profile = {"crets":0}
        else:
            try:
                _customer_profile['crets']
            except:
                _customer_profile['crets'] = 0

        _before = time.time()
        _crets = cret_dao.cret_dao().query_pagination_by_account(vendor_id, _account_id, _before, PAGE_SIZE_LIMIT)
        for _cret in _crets:
            _cret['create_time'] = timestamp_friendly_date(_cret['create_time'])
            _activity = activity_dao.activity_dao().query(_cret['activity_id'])
            _cret['activity_title'] = _activity['title']
            _cret['activity_bk_img_url'] = _activity['bk_img_url']

        self.render('wx/my-certs.html',
                vendor_id=vendor_id,
                crets=_crets,
                customer_profile=_customer_profile)
Пример #2
0
    def get(self, vendor_id, activity_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got activity_id %r in uri", activity_id)

        _account_id = self.get_argument("account_id", "")
        logging.info("got _account_id %r", _account_id)

        # 一个活动分享,只能获取一次积分奖励
        points_logs = self.get_points_log(_account_id, activity_id,
                                          "share_activity")
        if len(points_logs) == 0:
            _activity = activity_dao.activity_dao().query(activity_id)
            _bonus_template = bonus_template_dao.bonus_template_dao().query(
                activity_id)
            points = int(_bonus_template['activity_shared'])
            # 修改个人积分信息
            bonus_points = {
                'club_id': vendor_id,
                'account_id': _account_id,
                '_type': 'share_activity',
                'item_type': 'activity',
                'item_id': activity_id,
                'item_name': _activity['title'],
                'points': points,
                'order_id': DEFAULT_USER_ID
            }
            self.create_points(bonus_points)
            # self.points_increase(vendor_id, _account_id, bonus_points)

        _json = {'rs': 'success'}
        logging.info("got result code>>>>>>>>>>>>>>>>>>> %r", _json)
        self.write(_json)
        self.finish()
Пример #3
0
    def get(self, club_id, product_id):
        logging.info(self.request)
        logging.info("got product_id %r in uri", product_id)

        # club
        url = API_DOMAIN + "/api/clubs/"+club_id
        http_client = HTTPClient()
        response = http_client.fetch(url, method="GET")
        logging.info("got response %r", response.body)
        rs = json_decode(response.body)
        club = rs['rs']

        _activity = activity_dao.activity_dao().query(product_id)
        # 金额转换成元 默认将第一个基本服务的费用显示为活动价格
        # _activity['amount'] = float(_activity['amount']) / 100
        if not _activity['base_fee_template']:
            _activity['amount'] = 0
        else:
            for base_fee_template in _activity['base_fee_template']:
                base_fee_template['fee'] = float(base_fee_template['fee']) / 100
                _activity['amount'] = float(base_fee_template['fee']) / 100
        logging.info("got _activity response %r", _activity)

        self.render('eshop/place-order-success.html',
                API_DOMAIN=API_DOMAIN,
                club=club,
                activity=_activity)
    def get(self, vender_id):
        account_id = self.get_argument("account_id")
        logging.info("got _account_id %r", account_id)
        sBefore = self.get_argument("before", "")
        if sBefore != "":
            iBefore = float(datetime_timestamp(sBefore))
        else:
            iBefore = time.time()
        logging.info("got iBefore>>>> %r in uri", iBefore)
        _orders = order_dao.order_dao().query_pagination_by_account(
            account_id, iBefore, PAGE_SIZE_LIMIT)
        for order in _orders:
            _activity = activity_dao.activity_dao().query(order['activity_id'])
            order['activity_title'] = _activity['title']
            order['create_time'] = timestamp_datetime(order['create_time'])
            logging.info("got activity_title %r", order['activity_title'])
            order['activity_begin_time'] = timestamp_datetime(
                _activity['begin_time'])
            order['activity_distance'] = _activity['distance']
            order['activity_status'] = _activity['status']

            order_fees = []
            for ext_fee_id in order['ext_fees']:
                for template in _activity['ext_fee_template']:
                    if ext_fee_id == template['_id']:
                        json = {
                            "_id": ext_fee_id,
                            "name": template['name'],
                            "fee": template['fee']
                        }
                        order_fees.append(json)
                        break
            order['fees'] = order_fees

            order_insurances = []
            for insurance_id in order['insurances']:
                _insurance = insurance_template_dao.insurance_template_dao(
                ).query(insurance_id)
                order_insurances.append(_insurance)
            order['insurances'] = order_insurances

            _cret = cret_dao.cret_dao().query_by_account(
                order['activity_id'], order['account_id'])
            if _cret:
                logging.info("got _cret_id %r", _cret['_id'])
                order['cret_id'] = _cret['_id']
            else:
                order['cret_id'] = None

        _json = json_encode(_orders)
        self.write(_json)
        self.finish()
    def get(self, vendor_id, cret_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got cret_id %r in uri", cret_id)

        _cret = cret_dao.cret_dao().query(cret_id)
        _customer_profile = vendor_member_dao.vendor_member_dao().query_not_safe(vendor_id, _cret['account_id'])
        _activity = activity_dao.activity_dao().query(_cret['activity_id'])
        _cret['activity_title'] = _activity['title']

        self.render('wx/cert-info.html',
                vendor_id=vendor_id,
                cret=_cret,
                profile=_customer_profile)
Пример #6
0
    def get(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        #sBefore = self.get_argument("before", "") #格式 2016-06-01 22:36
        #sLimit = self.get_argument("limit", "")
        #_array = activity_dao.activity_dao().query_by_popular(vendor_id, sBefore, sLimit)
        _array = activity_dao.activity_dao().query_by_popular(vendor_id)
        for _activity in _array:
            _activity['begin_time'] = timestamp_friendly_date(
                float(_activity['begin_time']))  # timestamp -> %m月%d 星期%w
            _activity['end_time'] = timestamp_friendly_date(
                float(_activity['end_time']))  # timestamp -> %m月%d 星期%w

        docs_list = list(_array)
        self.write(JSON.dumps(docs_list, default=json_util.default))
        self.finish()
Пример #7
0
    def get(self, vendor_id, activity_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got activity_id %r in uri", activity_id)

        activity = activity_dao.activity_dao().query(activity_id)

        # 金额转换成元
        # activity['amount'] = float(activity['amount']) / 100
        for base_fee_template in activity['base_fee_template']:
            base_fee_template['fee'] = float(base_fee_template['fee']) / 100
        for ext_fee_template in activity['ext_fee_template']:
            ext_fee_template['fee'] = float(ext_fee_template['fee']) / 100

        self.write(JSON.dumps(activity, default=json_util.default))
        self.finish()
    def post(self, vendor_id, order_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got order_id %r in uri", order_id)
        _content = self.get_argument("content", "")
        _score = self.get_argument("score", "")
        if _score :
            _score = int(_score)
        else :
            _score = 0

        order = order_dao.order_dao().query(order_id)
        activity_id = order['activity_id']
        activity = activity_dao.activity_dao().query(activity_id)
        triprouter_id = activity['triprouter']

        # 更新订单状态
        json = {'_id':order_id, 'status': ORDER_STATUS_BF_COMMENT}
        order_dao.order_dao().update(json)

        # 创建新的评论
        _id = str(uuid.uuid1()).replace('-', '')
        json = {"_id":_id, "vendor_id":vendor_id,
                "content":_content, "score":_score,
                 "activity":activity_id, "triprouter":triprouter_id}
        evaluation_dao.evaluation_dao().create(json)
        logging.info("create eval _id %r", _id)

        # 更新线路表的评分 先取出该线路的所有评分算平均值后更新
        triprouter = trip_router_dao.trip_router_dao().query(triprouter_id)
        evaluations = evaluation_dao.evaluation_dao().query_by_triprouter(triprouter_id)

        total_score = 0
        total_time = 0

        for evaluation in evaluations:
            total_score = total_score + evaluation['score']
            total_time = total_time + 1
        new_score = math.ceil(float(total_score) / total_time)
        logging.info("create new score %r", new_score)

        _json = {"_id":triprouter_id, "score":int(new_score)}

        trip_router_dao.trip_router_dao().update(_json)

        self.redirect('/bf/wx/vendors/' + vendor_id + '/pc')
Пример #9
0
    def get(self, vendor_id):
        logging.info("GET %r", self.request.uri)

        before = float(self.get_argument("before", ""))
        # limit = int(self.get_argument("limit", ""))
        _array = activity_dao.activity_dao().query_pagination_by_status(
                vendor_id, ACTIVITY_STATUS_COMPLETED, before, PAGE_SIZE_LIMIT)
        categorys = category_dao.category_dao().query_by_vendor(vendor_id)

        for _activity in _array:
            _activity['begin_time'] = timestamp_date(float(_activity['begin_time'])) # timestamp -> %m月%d 星期%w
            _activity['end_time'] = timestamp_date(float(_activity['end_time'])) # timestamp -> %m月%d 星期%w
            for category in categorys:
                if category['_id'] == _activity['category']:
                    _activity['category'] = category['title']
                    break
        docs_list = list(_array)
        self.write(JSON.dumps(docs_list, default=json_util.default))
        self.finish()
Пример #10
0
    def get(self, vendor_id, trip_router_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        ops = self.get_ops_info()

        categorys = category_dao.category_dao().query_by_vendor(vendor_id)
        activitys = activity_dao.activity_dao().query_by_triprouter(trip_router_id)
        triprouter = trip_router_dao.trip_router_dao().query(trip_router_id)
        for activity in activitys:
            activity['begin_time'] = timestamp_date(float(activity['begin_time'])) # timestamp -> %m/%d/%Y
            for category in categorys:
                if category['_id'] == activity['category']:
                    activity['category'] = category['title']
                    break

        counter = self.get_counter(vendor_id)
        self.render('vendor/trip-router-activitylist.html',
                vendor_id=vendor_id,
                ops=ops,
                counter=counter,
                triprouter=triprouter,
                activitys=activitys)
Пример #11
0
    def get(self, vendor_id, triprouter_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got triprouter_id %r in uri", triprouter_id)

        _triprouter = trip_router_dao.trip_router_dao().query(triprouter_id)

        # 详细介绍 判断是否有article_id
        try:
            _triprouter['article_id']
        except:
            _triprouter['article_id'] = ''

        if (_triprouter['article_id'] != ''):

            url = "http://" + STP + "/blogs/my-articles/" + _triprouter[
                'article_id'] + "/paragraphs"
            http_client = HTTPClient()
            response = http_client.fetch(url, method="GET")
            logging.info("got response %r", response.body)
            _paragraphs = json_decode(response.body)

            _triprouter_desc = ""
            for _paragraph in _paragraphs:
                if _paragraph["type"] == 'raw':
                    _triprouter_desc = _paragraph['content']
                    break
            _triprouter_desc = _triprouter_desc.replace('&', "").replace(
                'mdash;', "").replace('<p>', "").replace("</p>", " ").replace(
                    "<section>", "").replace("</section>",
                                             " ").replace("\n", " ")
            _triprouter['desc'] = _triprouter_desc + '...'

        else:
            _triprouter['desc'] = '...'

        # 相关活动
        categorys = category_dao.category_dao().query_by_vendor(vendor_id)
        activitys = activity_dao.activity_dao().query_by_triprouter(
            triprouter_id)
        for activity in activitys:
            activity['begin_time'] = timestamp_date(
                float(activity['begin_time']))  # timestamp -> %m/%d/%Y
            activity['end_time'] = timestamp_date(float(
                activity['end_time']))  # timestamp -> %m/%d/%Y
            for category in categorys:
                if category['_id'] == activity['category']:
                    activity['category'] = category['title']
                    break

        wx_app_info = vendor_wx_dao.vendor_wx_dao().query(vendor_id)
        wx_app_id = wx_app_info['wx_app_id']
        logging.info("got wx_app_id %r in uri", wx_app_id)
        wx_app_secret = wx_app_info['wx_app_secret']
        wx_notify_domain = wx_app_info['wx_notify_domain']

        logging.info("------------------------------------uri: " +
                     self.request.uri)
        _access_token = getAccessTokenByClientCredential(
            wx_app_id, wx_app_secret)
        _jsapi_ticket = getJsapiTicket(_access_token)
        _sign = Sign(_jsapi_ticket, wx_notify_domain + self.request.uri).sign()
        logging.info("------------------------------------nonceStr: " +
                     _sign['nonceStr'])
        logging.info("------------------------------------jsapi_ticket: " +
                     _sign['jsapi_ticket'])
        logging.info("------------------------------------timestamp: " +
                     str(_sign['timestamp']))
        logging.info("------------------------------------url: " +
                     _sign['url'])
        logging.info("------------------------------------signature: " +
                     _sign['signature'])

        # _logined = False
        # wechat_open_id = self.get_secure_cookie("wechat_open_id")
        # if wechat_open_id:
        #     _logined = True

        _account_id = self.get_secure_cookie("account_id")

        self.render('wx/triprouter-info.html',
                    vendor_id=vendor_id,
                    triprouter=_triprouter,
                    activitys=activitys,
                    wx_app_id=wx_app_secret,
                    wx_notify_domain=wx_notify_domain,
                    sign=_sign,
                    account_id=_account_id)
Пример #12
0
    def get(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        # _session_ticket = self.get_secure_cookie("session_ticket")

        _keys = self.get_argument("keysValue", "")
        _type = self.get_argument("searchType", "")

        if (_type == 'order'):
            _array = order_dao.order_dao().query_by_order_keys(
                vendor_id, _keys)
        elif (_type == 'title'):
            _array = apply_dao.apply_dao().query_by_title_keys(
                vendor_id, _keys)
        elif (_type == 'nickname'):
            _array = order_dao.order_dao().query_by_nickname_keys(
                vendor_id, _keys)
        elif (_type == 'date'):
            keys_array = _keys.split('~')
            begin_keys = float(date_timestamp(keys_array[0]))
            end_keys = float(date_timestamp(keys_array[1]))
            logging.info("got begin_keys>>>>>>>>>>> %r in uri", begin_keys)
            logging.info("got end_keys>>>>>>>>>>> %r in uri", end_keys)
            _array = order_dao.order_dao().query_by_time_keys(
                vendor_id, begin_keys, end_keys)
        else:
            _array = []

        if (_array):
            for order in _array:
                _activity = activity_dao.activity_dao().query(
                    order['activity_id'])
                order['activity_title'] = _activity['title']
                # order['activity_amount'] = _activity['amount']
                if not order['base_fees']:
                    order['activity_amount'] = 0
                else:
                    for base_fee in order['base_fees']:
                        # 价格转换成元
                        order['activity_amount'] = float(base_fee['fee']) / 100

                logging.info("got activity_title %r", order['activity_title'])
                order['create_time'] = timestamp_datetime(order['create_time'])

                customer_profile = vendor_member_dao.vendor_member_dao(
                ).query_not_safe(vendor_id, order['account_id'])

                if (customer_profile):
                    try:
                        customer_profile['account_nickname']
                    except:
                        customer_profile['account_nickname'] = ''
                    try:
                        customer_profile['account_avatar']
                    except:
                        customer_profile['account_avatar'] = ''

                    order['account_nickname'] = customer_profile[
                        'account_nickname']
                    order['account_avatar'] = customer_profile[
                        'account_avatar']
                else:
                    order['account_nickname'] = ''
                    order['account_avatar'] = ''

                try:
                    order['bonus']
                except:
                    order['bonus'] = 0
                # 价格转换成元
                order['bonus'] = float(order['bonus']) / 100
                try:
                    order['prepay_id']
                except:
                    order['prepay_id'] = ''
                try:
                    order['transaction_id']
                except:
                    order['transaction_id'] = ''
                try:
                    order['payed_total_fee']
                except:
                    order['payed_total_fee'] = 0

                for ext_fee in order['ext_fees']:
                    # 价格转换成元
                    ext_fee['fee'] = float(ext_fee['fee']) / 100

                for insurance in order['insurances']:
                    # 价格转换成元
                    insurance['fee'] = float(insurance['fee']) / 100

                for _voucher in order['vouchers']:
                    # 价格转换成元
                    _voucher['fee'] = float(_voucher['fee']) / 100

                _cret = cret_dao.cret_dao().query_by_account(
                    order['activity_id'], order['account_id'])
                if _cret:
                    logging.info("got _cret_id %r", _cret['_id'])
                    order['cret_id'] = _cret['_id']
                else:
                    order['cret_id'] = None

                # order['activity_amount'] = float(_activity['amount']) / 100
                if not order['base_fees']:
                    order['activity_amount'] = 0
                else:
                    for base_fee in order['base_fees']:
                        # 价格转换成元
                        order['activity_amount'] = float(base_fee['fee']) / 100

                order['total_amount'] = float(order['total_amount']) / 100
                order['payed_total_fee'] = float(
                    order['payed_total_fee']) / 100

        _json = json_encode(_array)
        logging.info("got _json %r", _json)
        self.write(JSON.dumps(_json, default=json_util.default))
        self.finish()
Пример #13
0
    def get(self, vendor_id):
        logging.info("got vendor_id %r in uri", vendor_id)

        # _session_ticket = self.get_secure_cookie("session_ticket")

        _keys = self.get_argument("keysValue", "")
        _type = self.get_argument("searchType", "")

        if (_type == 'title'):
            _array = apply_dao.apply_dao().query_by_title_keys(
                vendor_id, _keys)
        elif (_type == 'nickname'):
            _array = apply_dao.apply_dao().query_by_nickname_keys(
                vendor_id, _keys)
        elif (_type == 'date'):
            keys_array = _keys.split('~')
            begin_keys = float(date_timestamp(keys_array[0]))
            end_keys = float(date_timestamp(keys_array[1]))
            _array = apply_dao.apply_dao().query_by_time_keys(
                vendor_id, begin_keys, end_keys)
            logging.info("got begin_keys--------- %r in uri", begin_keys)
            logging.info("got end_keys--------- %r in uri", end_keys)
        else:
            _array = []

        if (_array):
            for _apply in _array:
                _activity = activity_dao.activity_dao().query(
                    _apply['activity_id'])
                _apply['activity_title'] = _activity['title']
                logging.info("got activity_title %r", _apply['activity_title'])
                _apply['create_time'] = timestamp_datetime(
                    _apply['create_time'])

                customer_profile = vendor_member_dao.vendor_member_dao(
                ).query_not_safe(vendor_id, _apply['account_id'])

                if (customer_profile):
                    try:
                        customer_profile['account_nickname']
                    except:
                        customer_profile['account_nickname'] = ''
                    try:
                        customer_profile['account_avatar']
                    except:
                        customer_profile['account_avatar'] = ''

                    _apply['account_nickname'] = customer_profile[
                        'account_nickname']
                    _apply['account_avatar'] = customer_profile[
                        'account_avatar']
                else:
                    _apply['account_nickname'] = ''
                    _apply['account_avatar'] = ''

                if _apply['gender'] == 'male':
                    _apply['gender'] = u'男'
                else:
                    _apply['gender'] = u'女'

        _json = json_encode(_array)
        logging.info("got _json %r", _json)
        self.write(JSON.dumps(_json, default=json_util.default))
        self.finish()
Пример #14
0
    def get(self, vendor_id, activity_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got activity_id %r in uri", activity_id)

        access_token = self.get_access_token()

        # utf8,gbk,gb2312
        _unicode = 'utf8'
        _file = xlwt.Workbook(encoding=_unicode)  # Workbook

        activity = activity_dao.activity_dao().query(activity_id)
        for base_fee in activity['base_fee_template']:
            _table = _file.add_sheet(base_fee['name'])  # new sheet

            # column names
            rownum = 0
            _table.write(rownum, 0, unicode(u'姓名').encode(_unicode))
            _table.write(rownum, 1, unicode(u'性别').encode(_unicode))
            _table.write(rownum, 2, unicode(u'身份证号码').encode(_unicode))
            _table.write(rownum, 3, unicode(u'电话号码').encode(_unicode))
            _table.write(rownum, 4, unicode(u'身高cm').encode(_unicode))
            _table.write(rownum, 5, unicode(u'备注').encode(_unicode))
            _table.write(rownum, 6, unicode(u'报名时间').encode(_unicode))

            # table
            rownum = 1
            params = {
                "filter": "item",
                "item_id": activity_id,
                "page": 1,
                "limit": 200
            }
            url = url_concat(API_DOMAIN + "/api/applies", params)
            http_client = HTTPClient()
            headers = {"Authorization": "Bearer " + access_token}
            response = http_client.fetch(url, method="GET", headers=headers)
            logging.info("got response.body %r", response.body)
            data = json_decode(response.body)
            rs = data['rs']
            applies = rs['data']

            for _apply in applies:
                if base_fee['name'] == _apply['group_name']:
                    # 下单时间,timestamp -> %m月%d 星期%w
                    _apply['create_time'] = timestamp_datetime(
                        float(_apply['create_time']))
                    if _apply['gender'] == 'male':
                        _apply['gender'] = u'男'
                    else:
                        _apply['gender'] = u'女'

                    _table.write(rownum, 0, _apply['real_name'])
                    _table.write(rownum, 1, _apply['gender'])
                    _table.write(rownum, 2, _apply['id_code'])
                    _table.write(rownum, 3, _apply['phone'])
                    _table.write(rownum, 4, _apply['height'])
                    _table.write(rownum, 5, _apply['note'])
                    _table.write(rownum, 6, _apply['create_time'])
                    rownum = rownum + 1

        _file.save('static/report/' + activity_id + '.xls')  # Save file
        self.finish(
            JSON.dumps("http://riding.time2box.com/static/report/" +
                       activity_id + ".xls"))