Пример #1
0
def root():
    """手机站 - 售后服务列表"""

    if not check_login():
        session['weixin_login_url'] = request.url
        return redirect(url_for('api.weixin.login'))
    uid = get_uid()

    params = request.args.to_dict()
    params['uid'] = uid
    _data = AfterSalesStaticMethodsService.aftersales(params)
    paging_url = url_for('mobile.aftersales.paging', **request.args)

    aftersales_status_text = {}
    for aftersale in _data['aftersales']:
        status_text, action_code = AfterSalesStaticMethodsService.aftersale_status_text_and_action_code(
            aftersale)
        aftersales_status_text[aftersale.aftersales_id] = status_text

    data = {
        'aftersales': _data['aftersales'],
        'paging_url': paging_url,
        'aftersales_status_text': aftersales_status_text
    }
    return render_template('mobile/aftersales/index.html.j2', **data)
Пример #2
0
def index():
    """ 售后服务列表 """

    resjson.action_code = 13

    if not check_login():
        return resjson.print_json(resjson.NOT_LOGIN)
    uid = get_uid()

    args = request.args
    p = toint(args.get('p', '1'))
    ps = toint(args.get('ps', '10'))

    if p <= 0 or ps <= 0:
        return resjson.print_json(resjson.PARAM_ERROR)

    params = {'uid': uid, 'p': p, 'ps': ps}
    _data = AfterSalesStaticMethodsService.aftersales(params)

    aftersales_status_text = {}
    for aftersale in _data['aftersales']:
        status_text, action_code = AfterSalesStaticMethodsService.aftersale_status_text_and_action_code(
            aftersale)
        aftersales_status_text[aftersale.aftersales_id] = status_text

    data = {
        'aftersales': _data['aftersales'],
        'aftersales_status_text': aftersales_status_text
    }
    return resjson.print_json(0, u'ok', data)
Пример #3
0
def refunds_amount():
    """获取退款金额"""
    resjson.action_code = 11

    if not check_login():
        return resjson.print_json(resjson.NOT_LOGIN)
    uid = get_uid()

    og_id = toint(request.args.get('og_id', '0'))
    quantity = toint(request.args.get('quantity', '0'))
    if og_id <= 0 or quantity <= 0:
        return resjson.print_json(resjson.PARAM_ERROR)

    order_goods = OrderGoods.query.get(og_id)
    if not order_goods:
        return resjson.print_json(resjson.PARAM_ERROR)

    order = Order.query.filter(Order.order_id == order_goods.order_id).filter(
        Order.uid == uid).first()
    if not order:
        return resjson.print_json(resjson.PARAM_ERROR)

    refunds_amount = AfterSalesStaticMethodsService.refunds_amount(
        order_goods=order_goods, quantity=quantity)

    return resjson.print_json(0, u'ok', {'refunds_amount': refunds_amount})
Пример #4
0
def detail(aftersales_id):
    """pc站 - 售后服务详情"""

    if not check_login():
        session['weixin_login_url'] = request.url
        return redirect(url_for('api.weixin.login_qrcode'))
    uid = get_uid()

    aftersales = Aftersales.query.filter(
        Aftersales.aftersales_id == aftersales_id).filter(
            Aftersales.uid == uid).first()
    if not aftersales:
        return redirect(url_for('pc.index.pagenotfound'))

    logs       = AftersalesLogs.query.\
                            filter(AftersalesLogs.aftersales_id == aftersales.aftersales_id).\
                            order_by(AftersalesLogs.al_id.desc()).all()

    logs_time = {}
    for log in logs:
        logs_time[log.al_type] = log.add_time

    status_text, action_code = AfterSalesStaticMethodsService.aftersale_status_text_and_action_code(
        aftersales)
    #回寄地址信息
    aftersales_service = {}
    if aftersales.check_status == 2:
        ss = SysSetting.query.filter(
            SysSetting.key == 'config_aftersales_service').first()
        if not ss:
            return redirect(url_for('pc.index.servererror'))

        try:
            aftersales_service = json.loads(ss.value)
        except Exception as e:
            return redirect(url_for('pc.index.servererror'))
    #换货收货地址
    address = None
    if aftersales.aftersales_type == 3:
        address = AftersalesAddress.query.filter(
            AftersalesAddress.aftersales_id == aftersales_id).first()

    data = {
        'aftersales': aftersales,
        'logs': logs,
        'logs_time': logs_time,
        'status_text': status_text,
        'action_code': action_code,
        'aftersales_service': aftersales_service,
        'aftersales_address': address
    }

    return render_template('pc/aftersales/detail.html.j2', **data)
Пример #5
0
def return_goods():
    """寄回商品"""
    resjson.action_code = 12

    if not check_login():
        return resjson.print_json(resjson.NOT_LOGIN)
    uid = get_uid()

    aftersales_id = toint(request.form.get('aftersales_id', '0'))
    return_shipping_sn = request.form.get('return_shipping_sn', '').strip()
    current_time = current_timestamp()

    if aftersales_id <= 0 or return_shipping_sn == '':
        return resjson.print_json(resjson.PARAM_ERROR)

    aftersales = Aftersales.query.\
                    filter(Aftersales.aftersales_id == aftersales_id).\
                    filter(Aftersales.uid == uid).first()
    if not aftersales:
        return resjson.print_json(10, _(u'售后不存在'))

    if aftersales.aftersales_type not in [2, 3]:
        return resjson.print_json(11, _(u'售后类型错误'))

    if aftersales.return_status != 1:
        return resjson.print_json(12, _(u'寄回状态错误'))

    data = {'return_shipping_sn': return_shipping_sn, 'return_status': 2}
    model_update(aftersales, data)

    content = _(u'快递单号:%s,我们收到退货/换货商品后,需要1-3个工作日处理,请耐心等待。' %
                return_shipping_sn)
    AfterSalesStaticMethodsService.add_log(aftersales_id,
                                           content,
                                           6,
                                           current_time,
                                           commit=True)

    return resjson.print_json(0, u'ok')
Пример #6
0
def detail():
    """ 售后服务详情 """

    resjson.action_code = 14

    if not check_login():
        return resjson.print_json(resjson.NOT_LOGIN)
    uid = get_uid()

    aftersales_id = toint(request.args.get('aftersales_id', '0'))
    if aftersales_id <= 0:
        return resjson.print_json(resjson.PARAM_ERROR)

    aftersales = Aftersales.query.filter(
        Aftersales.aftersales_id == aftersales_id).filter(
            Aftersales.uid == uid).first()
    if not aftersales:
        return resjson.print_json(resjson.SYSTEM_PAGE_NOT_FOUND)

    log = AftersalesLogs.query.\
            filter(AftersalesLogs.aftersales_id == aftersales.aftersales_id).\
            order_by(AftersalesLogs.al_id.desc()).first()

    status_text, action_code = AfterSalesStaticMethodsService.aftersale_status_text_and_action_code(
        aftersales)

    aftersales_service = {}
    if aftersales.check_status == 2:
        ss = SysSetting.query.filter(
            SysSetting.key == 'config_aftersales_service').first()
        if ss:
            try:
                aftersales_service = json.loads(ss.value)
            except Exception as e:
                aftersales_service = {}

    address = AftersalesAddress.query.filter(
        AftersalesAddress.aftersales_id == aftersales_id).first()

    data = {
        'aftersales': aftersales,
        'log': log,
        'status_text': status_text,
        'action_code': action_code,
        'aftersales_service': aftersales_service,
        'address': address
    }
    return resjson.print_json(0, u'ok', data)
Пример #7
0
def detail(aftersales_id):
    """手机站 - 售后服务详情"""

    if not check_login():
        session['weixin_login_url'] = request.url
        return redirect(url_for('api.weixin.login'))
    uid = get_uid()

    aftersales = Aftersales.query.filter(
        Aftersales.aftersales_id == aftersales_id).filter(
            Aftersales.uid == uid).first()
    if not aftersales:
        return redirect(url_for('mobile.index.pagenotfound'))

    log = AftersalesLogs.query.\
            filter(AftersalesLogs.aftersales_id == aftersales.aftersales_id).\
            order_by(AftersalesLogs.al_id.desc()).first()

    status_text, action_code = AfterSalesStaticMethodsService.aftersale_status_text_and_action_code(
        aftersales)

    aftersales_service = {}
    if aftersales.check_status == 2:
        ss = SysSetting.query.filter(
            SysSetting.key == 'config_aftersales_service').first()
        if ss:
            try:
                aftersales_service = json.loads(ss.value)
            except Exception as e:
                aftersales_service = {}

    address = AftersalesAddress.query.filter(
        AftersalesAddress.aftersales_id == aftersales_id).first()

    data = {
        'aftersales': aftersales,
        'log': log,
        'status_text': status_text,
        'action_code': action_code,
        'aftersales_service': aftersales_service,
        'address': address
    }
    return render_template('mobile/aftersales/detail.html.j2', **data)