예제 #1
0
    def get(self, vendor_id, apply_id):
        logging.info("got vendor_id %r in uri", vendor_id)
        logging.info("got apply_id %r in uri", apply_id)

        _timestamp = time.time()
        json = {
            "_id": apply_id,
            "last_update_time": _timestamp,
            "review": True
        }
        apply_dao.apply_dao().update(json)

        self.check_apply(apply_id)
        self.counter_decrease(vendor_id, "activity_apply")

        self.finish("ok")
    def get(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)

        applys = apply_dao.apply_dao().query_by_order(order_id)
        for data in applys:
            try:
                data['note']
            except:
                data['note'] = ''

        self.render('wx/myorder-applys.html',
                vendor_id=vendor_id,
                applys=applys)
예제 #3
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)

        _array = apply_dao.apply_dao().query_by_activity(activity_id)
        for data in _array:
            _member = vendor_member_dao.vendor_member_dao().query_not_safe(
                vendor_id, data['account_id'])
            try:
                logging.info("got account_avatar %r",
                             _member['account_avatar'])
                data['account_avatar'] = _member['account_avatar']
            except:
                logging.warn("got account_avatar is null")

        docs_list = list(_array)
        logging.info("got json %r",
                     JSON.dumps(docs_list, default=json_util.default))
        self.write(JSON.dumps(docs_list, default=json_util.default))
        self.finish()
예제 #4
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()
예제 #5
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()
    def get(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)

        # order = order_dao.order_dao().query(order_id)
        order = self.get_symbol_object(order_id)
        logging.info("got order %r in uri", order)
        _activity = self.get_activity(order['item_id'])
        logging.info("got _activity %r", _activity)
        # FIXME, 将服务模板转为字符串,客户端要用
        _servTmpls = _activity['ext_fee_template']
        _activity['json_serv_tmpls'] = tornado.escape.json_encode(_servTmpls);
        # 按报名状况查询每个活动的当前状态:
        # 0: 报名中, 1: 已成行, 2: 已满员, 3: 已结束
        # @2016/06/06
        #
        # 当前时间大于活动结束时间 end_time, 已结束
        # 否则
        # member_max: 最大成行人数, member_min: 最小成行人数
        # 小于member_min, 报名中
        # 大于member_min,小于member_max,已成行
        # 大于等于member_max,已满员
        _now = time.time();
        _member_min = int(_activity['member_min'])
        _member_max = int(_activity['member_max'])
        if _now > _activity['end_time']:
            _activity['phase'] = '3'
        else:
            _applicant_num = apply_dao.apply_dao().count_by_activity(_activity['_id'])
            _activity['phase'] = '2' if _applicant_num >= _member_max else '1'
            _activity['phase'] = '0' if _applicant_num < _member_min else '1'
        # FIXME, 日期的格式化处理放在活动状态划分之后,不然修改了结束时间后就没法判断状态了
        # @2016/06/08
        _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
        # 价格转换成元
        # _activity['amount'] = float(_activity['amount']) / 100

        order_fees = []
        if order.has_key('ext_fees'):
            for ext_fee_id in order['ext_fees']:
                for template in _activity['ext_fee_template']:
                    if ext_fee_id == template['_id']:
                        # 价格转换成元
                        _fee = float(template['fee']) / 100
                        json = {"_id":ext_fee_id, "name":template['name'], "fee":_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

        # 这里改为从订单中取base_fees
        for base_fee in order['base_fees']:
            # 价格转换成元
            order['activity_amount'] = float(base_fee['fee']) / 100

        order['create_time'] = timestamp_datetime(order['create_time'])

        _old_applys = apply_dao.apply_dao().query_by_order(order_id)
        applyed = False
        if len(_old_applys) > 0:
            applyed = True

        self.render('wx/myorder-info.html',
                vendor_id=vendor_id,
                activity=_activity,
                order=order,
                applyed=applyed)