Example #1
0
def ajax_submit_order(request) :
    is_ajax = request.is_ajax()
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    response_json = {'error':1, "errorString": "没有选择商品" }
    if authuri:
        response_json = {'error':2, "errorString": "需要重新授权", "authuri":authuri }
        return HttpResponse(json.dumps(response_json), content_type="application/json")
    contact = request.REQUEST.get('contact')
    contactPhone =request.REQUEST.get('contactPhone')
    address = request.REQUEST.get('address')
    remark = request.REQUEST.get('remark')
    cartInfo = request.REQUEST.get('cartInfo')
    payment = request.REQUEST.get('payment')
    orderId = request.REQUEST.get('orderId')
    if not cartInfo:
        response_data_utils.error_log(request, "没有选择商品!", __name__, "没有选择商品")
        return HttpResponse(json.dumps(response_json), content_type="application/json")
    try:
       cart_dict = json.loads(cartInfo)
       if not cart_dict:
          response_data_utils.error_log(request, "没有选择商品!", __name__, "没有选择商品")
          return HttpResponse(json.dumps(response_json), content_type="application/json")
    except Exception,e:
       response_data_utils.error_log(request, "没有选择商品" , __name__ , e)
       return HttpResponse(json.dumps(response_json), content_type="application/json")
Example #2
0
def ajax_order_list(request,mark=0):                                                         #kim                                     
    is_ajax = request.is_ajax()
    if not is_ajax:
        return response_data_utils.error_response(request, "非法请求!",__name__, "not ajax")
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri:
        return response_data_utils.error_response(request, "非法请求!",__name__, "not ajax", session)
    try: 
        order_list_result = api_list.list_my_product_order(request,session,mark)          
        if not order_list_result or order_list_result["error"]!=0:
            return response_data_utils.error_response(request,"服务器忙,请稍后重试!",__name__,order_list_result, session)    
        process_order_detail(order_list_result)
        next_request_url = ""
        if str(order_list_result['mark']) != "0":
           next_request_url = reverse('order:ajax_order_list', kwargs ={"mark":order_list_result['mark']})
        meta_data = {'url':next_request_url, "order_list":order_list_result["productOrderList"], "from_ajax":1}
        context = RequestContext(request, meta_data)
        template = loader.get_template('order/orders_list.html')
        response_json = {'html':template.render(context), 'url':next_request_url}
        return HttpResponse(json.dumps(response_json), content_type="application/json")
    except Exception,e:
        print e
        return response_data_utils.error_response(request, "推荐产品不存在!",__name__, e, session)
Example #3
0
def order_pay_result(request, order_id, pay_status=0):
    user_info = weixin_auth_utils.get_user_info(request)
    session = user_info.get('session')
    if not order_id:
        return response_data_utils.error_response(request, "找不到对应的订单!", __name__)
    meta_data = {'paySuccess':pay_status, 'order_id':order_id}
    return weixin_auth_utils.fp_render(request,'order/order_pay_result.html',meta_data, session)
Example #4
0
def question_details(request, question_id):
    dp = request.REQUEST.get('dp')
    #微信中用户信息获取及授权处理
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')

    user_agent = request.META.get('HTTP_USER_AGENT')
 
    is_mm = None
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
      is_mm = 1

    if authuri and is_mm == 1 and dp != None and dp != "":
      return HttpResponseRedirect(authuri)

    if dp != "" and dp != None:
      api_list.bind_user(request, session, dp)
    else:
      dp = None
    # end 
    try:
        question_obj = api_list.get_question_detail(request, question_id, 1, 1, 0)
        if question_obj['error'] == 0:
            process_question_data(question_obj)
            next_page_url = ''  # for next page ajax loading
            if int(question_obj['mark']) > 0:
                next_page_url = reverse('question:answer_list', kwargs = {'question_id' : question_id, 'mark' : question_obj['mark']})
            meta_data = response_data_utils.pack_data(request, {'navTitle':'问答详情', 'question':question_obj, 'question_id':question_id, 'url' : next_page_url})
            return weixin_auth_utils.fp_render(request, 'question/question.html', meta_data, session)
        else:
            return response_data_utils.error_response(request, "找不到这个问题!",  __name__, question_obj, session)
    except Exception as e:
        return response_data_utils.error_response(request,"找不到这个问题!", __name__, e, session)
Example #5
0
def submit_order(request) :
    #return render(request, 'order/choice_bank.html', {})
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri:
        return HttpResponseRedirect(authuri)
    contact = request.REQUEST.get('contact')
    contactPhone =request.REQUEST.get('contactPhone')
    address = request.REQUEST.get('address')
    remark = request.REQUEST.get('remark')
    cartInfo = request.REQUEST.get('cartInfo')
    payment = request.REQUEST.get('payment')
    orderId = request.REQUEST.get('orderId')
    if not orderId:
       if not cartInfo:
           return response_data_utils.error_response(request, "没有选择商品!", __name__, "没有选择商品", session)
       try:
           cart_dict = json.loads(cartInfo)
           if not cart_dict:
               return response_data_utils.error_response(request, "没有选择商品!", __name__, "没有选择商品", session)
       except Exception,e:
           print e
           return response_data_utils.error_response(request, "没有选择商品!", __name__, "没有选择商品", session)
    
       result = api_list.submit_order(request, session, cartInfo , contact,  address,  contactPhone, remark)
       orderId = 0
       if result and result.get("orderId"):
           orderId = result.get("orderId")
       else:
           return response_data_utils.error_response(request, result.get("errorString"), __name__, result, session)
Example #6
0
def to_pay_order(rquest):
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri:
        return HttpResponseRedirect(authuri)
    payment = request.REQUEST.get('payment')
    orderId = request.REQUEST.get('orderId')
    if not orderId:
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!", __name__, result, session)
    if orderId == 0:
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!", __name__, result, session)

    order_info = api_list.get_product_order(request, session, orderId) 
    if not order_info or order_info["error"]!=0:
        return response_data_utils.error_response(request, "找不到对应的订单!", __name__, order_info, session)

    meta_data = {"order_id": orderId}
    if order_info and order_info.get("productOrder"):
        product_order = order_info.get("productOrder") 
        meta_data["goods_num"] = product_order.get("goodsNum")
        meta_data["total_fee"] = product_order.get("totalFee")

    if payment == "0":
        alipay_url = reverse("order:alipay_order",kwargs={})
        return HttpResponseRedirect(alipay_url + "?orderId=" + str(orderId) +"&session=" + session )
    elif payment == "1":
        meta_data["navTitle"] = "选择银行"
        meta_data["search_btn"] = 1
        return weixin_auth_utils.fp_render(request,'order/choice_bank.html',meta_data, session)
    elif payment == "2": 
        wxpay_url = reverse("order:wxpay_order",kwargs={})
        return HttpResponseRedirect(wxpay_url + "?orderId=" + str(orderId) +"&session=" + session )
Example #7
0
def order_list(request):  #kim
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    # session = '10E5C27B3AA37718CFF61A6CA32135196E4636F6500251D3801C302B9F68B58F'
    if authuri:
        return HttpResponseRedirect(authuri)
    order_list_result = api_list.list_my_product_order(request, session)
    if not order_list_result or order_list_result["error"] != 0:
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!",
                                                  __name__, order_list_result,
                                                  session)
    try:
        process_order_detail(order_list_result)
        next_request_url = ""
        if str(order_list_result['mark']) != "0":
            next_request_url = reverse(
                'order:ajax_order_list',
                kwargs={"mark": order_list_result['mark']})
        meta_data = {
            'url': next_request_url,
            "nav": "order",
            "order_list": order_list_result["productOrderList"]
        }
        return weixin_auth_utils.fp_render(request, 'order/orders.html',
                                           meta_data, session)
    except Exception, e:
        print e
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!",
                                                  __name__, e, session)
Example #8
0
def set_contact(request):                                      
    is_mm = 0
    if request.META.get('HTTP_USER_AGENT').lower().find("micromessenger") != -1:
      is_mm = 1

    #return render(request,'cart/setcontact.html',{})
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri and is_mm == 1:
        return HttpResponseRedirect(authuri)
    num = request.REQUEST.getlist('num')
    total_num =request.REQUEST.get('total_fee')
    goods_ids = request.REQUEST.getlist('goods_id')
    orderId = request.REQUEST.get('orderId')
    if not total_num:
        return response_data_utils.error_response(request,"非法请求", __name__, "非法请求", session)
    readonly = None

    if orderId:
      readonly = 1
    else:
      orderId = ''
    result = []
    for m in range(len(num)):
        result.append({'goodsId': goods_ids[m], 'num': num[m]})
    cartInfo = json.dumps(result)
    api_list.update_shopping_cart(request,session,cartInfo)
    meta_data = {'search_btn':1,'cartInfo': cartInfo,'contact': clean_none(user_info.get("contact")),'orderId': orderId, 'readonly': readonly, \
	'address': clean_none(user_info.get("address")),'contactPhone': clean_none(user_info.get("contactPhone")),\
	'total_num': total_num,'navTitle':'支付','wxpayShow':is_mm}
    return weixin_auth_utils.fp_render(request,'cart/setcontact.html',meta_data, session) 
Example #9
0
def topic_info(request, topic_id):
    dp = request.REQUEST.get('dp')
    #微信中用户信息获取及授权处理
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    user_agent = request.META.get('HTTP_USER_AGENT')
    is_mm = None
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
      is_mm = 1

    if authuri and is_mm == 1 and dp != None and dp != "":
      return HttpResponseRedirect(authuri)
    from_user_name = None;
    if dp != "" and dp != None:
      api_list.bind_user(request, session, dp)
      from_user_info = api_list.get_user_info_by_uid(request, dp)
      if from_user_info != None:
        from_user_name = from_user_info.get("userInfo").get('userName')
    # end 
    try:
        topic_json = api_list.get_feature_topic_info(request, topic_id)
        if topic_json == None or topic_json == "" or topic_json['error'] != 0:
          return response_data_utils.error_response(request,"找不到这个专题", __name__, topic_json, session)
        uid = request.GET.get('dp')
        bottom_download = request.GET.get('bottom_download')
        process_topic_data(topic_json)
        process_topic_url(uid, topic_json)
        topic_comments_json = topic_comments(request,topic_id)
        next_page_url = reverse("topic:topic_info_comments",kwargs={"topic_id":topic_id,"mark":topic_comments_json["mark"]})
        meta = response_data_utils.pack_data(request, {'featureTopic': topic_json['featureTopic'],'commentsTopic':topic_comments_json,'nav':'topic','navTitle':'笔记详情','bottom_download':bottom_download, 'fromUserName':from_user_name,'url':next_page_url})
        return weixin_auth_utils.fp_render(request,'topic/topic.html', meta, session)
    except Exception,e:
       return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, e, session) 
Example #10
0
def set_contact(request):
    is_mm = 0
    if request.META.get('HTTP_USER_AGENT').lower().find(
            "micromessenger") != -1:
        is_mm = 1

    #return render(request,'cart/setcontact.html',{})
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri and is_mm == 1:
        return HttpResponseRedirect(authuri)
    num = request.REQUEST.getlist('num')
    total_num = request.REQUEST.get('total_fee')
    goods_ids = request.REQUEST.getlist('goods_id')
    orderId = request.REQUEST.get('orderId')
    if not total_num:
        return response_data_utils.error_response(request, "非法请求", __name__,
                                                  "非法请求", session)
    readonly = None

    if orderId:
        readonly = 1
    else:
        orderId = ''
    result = []
    for m in range(len(num)):
        result.append({'goodsId': goods_ids[m], 'num': num[m]})
    cartInfo = json.dumps(result)
    api_list.update_shopping_cart(request, session, cartInfo)
    meta_data = {'search_btn':1,'cartInfo': cartInfo,'contact': clean_none(user_info.get("contact")),'orderId': orderId, 'readonly': readonly, \
 'address': clean_none(user_info.get("address")),'contactPhone': clean_none(user_info.get("contactPhone")),\
 'total_num': total_num,'navTitle':'支付','wxpayShow':is_mm}
    return weixin_auth_utils.fp_render(request, 'cart/setcontact.html',
                                       meta_data, session)
Example #11
0
def cart_index(request):
    #return render(request,'cart/cart.html',{})
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri:
        return HttpResponseRedirect(authuri)
    item_list_json = api_list.get_shopping_cart(request, session)
    try:
        if item_list_json and item_list_json['error'] == 0:
            process_cartinfo_data(item_list_json)
            meta_data = {
                'search_btn': 1,
                'navTitle': '购物车',
                'cart_info_list': item_list_json['validCartItemList'],
                'invalid_cart_info_list': item_list_json['invalidCartItemList']
            }
            if len(item_list_json['validCartItemList']) == 0 and len(
                    item_list_json['invalidCartItemList']) == 0:
                return response_data_utils.error_response(
                    request, "您的购物车空空如也", __name__, "购物车为空")
            meta_data = response_data_utils.pack_data(request, meta_data)
            return weixin_auth_utils.fp_render(request, 'cart/cart.html',
                                               meta_data, session)
    except Exception, e:
        return response_data_utils.error_response(request, None, __name__, e,
                                                  session)
Example #12
0
def order_detail(request, order_id):  #kim
    user_agent = request.META.get('HTTP_USER_AGENT')
    is_mm = 0
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
        is_mm = 1

    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    #session = '10E5C27B3AA37718CFF61A6CA32135196E4636F6500251D3801C302B9F68B58F'
    if authuri:
        return HttpResponseRedirect(authuri)
    order_detail_result = api_list.get_product_order(request, session,
                                                     order_id)
    # cart_num = api_list.get_goods_num_in_cart(request)
    if not order_detail_result or order_detail_result["error"] != 0:
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!",
                                                  __name__,
                                                  order_detail_result, session)
    try:
        process_order_detail(order_detail_result)
        meta_data = {
            "order": order_detail_result,
            'navTitle': '订单详情',
            'search_btn': 1,
            'is_mm': is_mm
        }
        return weixin_auth_utils.fp_render(request, 'order/order.html',
                                           meta_data, session)
    except Exception, e:
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!",
                                                  __name__, e, session)
Example #13
0
def order_pay_result(request, order_id, pay_status=0):
    user_info = weixin_auth_utils.get_user_info(request)
    session = user_info.get('session')
    if not order_id:
        return response_data_utils.error_response(request, "找不到对应的订单!",
                                                  __name__)
    meta_data = {'paySuccess': pay_status, 'order_id': order_id}
    return weixin_auth_utils.fp_render(request, 'order/order_pay_result.html',
                                       meta_data, session)
Example #14
0
def topic_info(request, topic_id):
    dp = request.REQUEST.get('dp')
    #微信中用户信息获取及授权处理
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    user_agent = request.META.get('HTTP_USER_AGENT')
    is_mm = None
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
        is_mm = 1

    if authuri and is_mm == 1 and dp != None and dp != "":
        return HttpResponseRedirect(authuri)
    from_user_name = None
    if dp != "" and dp != None:
        api_list.bind_user(request, session, dp)
        from_user_info = api_list.get_user_info_by_uid(request, dp)
        if from_user_info != None:
            from_user_name = from_user_info.get("userInfo").get('userName')
    # end
    try:
        topic_json = api_list.get_feature_topic_info(request, topic_id)
        if topic_json == None or topic_json == "" or topic_json['error'] != 0:
            return response_data_utils.error_response(request, "找不到这个专题",
                                                      __name__, topic_json,
                                                      session)
        uid = request.GET.get('dp')
        bottom_download = request.GET.get('bottom_download')
        process_topic_data(topic_json)
        process_topic_url(uid, topic_json)
        topic_comments_json = topic_comments(request, topic_id)
        next_page_url = reverse("topic:topic_info_comments",
                                kwargs={
                                    "topic_id": topic_id,
                                    "mark": topic_comments_json["mark"]
                                })
        meta = response_data_utils.pack_data(
            request, {
                'featureTopic': topic_json['featureTopic'],
                'commentsTopic': topic_comments_json,
                'nav': 'topic',
                'navTitle': '笔记详情',
                'bottom_download': bottom_download,
                'fromUserName': from_user_name,
                'url': next_page_url
            })
        return weixin_auth_utils.fp_render(request, 'topic/topic.html', meta,
                                           session)
    except Exception, e:
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!",
                                                  __name__, e, session)
Example #15
0
def cart_index(request):
    #return render(request,'cart/cart.html',{})
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri:
        return HttpResponseRedirect(authuri)
    item_list_json = api_list.get_shopping_cart(request,session)
    try:
        if item_list_json and item_list_json['error']==0:
            process_cartinfo_data(item_list_json)
            meta_data = {'search_btn':1,'navTitle':'购物车', 'cart_info_list':item_list_json['validCartItemList'],'invalid_cart_info_list':item_list_json['invalidCartItemList']}
            if len(item_list_json['validCartItemList']) == 0 and len(item_list_json['invalidCartItemList']) == 0:
                return response_data_utils.error_response(request,"您的购物车空空如也", __name__, "购物车为空")
            meta_data = response_data_utils.pack_data(request,meta_data)
            return weixin_auth_utils.fp_render(request,'cart/cart.html',meta_data, session) 
    except Exception,e:
        return response_data_utils.error_response(request,None, __name__, e, session)
Example #16
0
def album_detail(request, albumId):  #kim
    dp = request.REQUEST.get('dp')
    #微信中用户信息获取及授权处理
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    user_agent = request.META.get('HTTP_USER_AGENT')

    is_mm = None
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
        is_mm = 1

    if authuri and is_mm == 1 and dp != None and dp != "":
        return HttpResponseRedirect(authuri)

    if dp != "" and dp != None:
        api_list.bind_user(request, session, dp)
    else:
        dp = None
    # end
    album_info = api_list.get_list_product_album_info(request, albumId)
    cart_num_json = api_list.get_goods_num_in_cart(request, session)
    cartNum = 0
    if not album_info and album_info["error"] != 0:
        return response_data_utils.error_response(request, "合集产品不存在!",
                                                  __name__, e, session)
    if cart_num_json and cart_num_json["error"] == 0:
        cartNum = cart_num_json["totalNum"]
    try:
        if album_info and album_info["error"] == 0:
            meta_data = {
                "cartNum": cartNum,
                "album_description": album_info["album"],
                "album_info": album_info["albumInfos"],
                "navTitle": album_info["album"]["title"]
            }
            return render(request, "products/album_info.html", meta_data)
    except Exception, e:
        print "============="
        print e
        print "============="
Example #17
0
def ajax_order_list(request, mark=0):  #kim
    is_ajax = request.is_ajax()
    if not is_ajax:
        return response_data_utils.error_response(request, "非法请求!", __name__,
                                                  "not ajax")
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri:
        return response_data_utils.error_response(request, "非法请求!", __name__,
                                                  "not ajax", session)
    try:
        order_list_result = api_list.list_my_product_order(
            request, session, mark)
        if not order_list_result or order_list_result["error"] != 0:
            return response_data_utils.error_response(request, "服务器忙,请稍后重试!",
                                                      __name__,
                                                      order_list_result,
                                                      session)
        process_order_detail(order_list_result)
        next_request_url = ""
        if str(order_list_result['mark']) != "0":
            next_request_url = reverse(
                'order:ajax_order_list',
                kwargs={"mark": order_list_result['mark']})
        meta_data = {
            'url': next_request_url,
            "order_list": order_list_result["productOrderList"],
            "from_ajax": 1
        }
        context = RequestContext(request, meta_data)
        template = loader.get_template('order/orders_list.html')
        response_json = {
            'html': template.render(context),
            'url': next_request_url
        }
        return HttpResponse(json.dumps(response_json),
                            content_type="application/json")
    except Exception, e:
        print e
        return response_data_utils.error_response(request, "推荐产品不存在!",
                                                  __name__, e, session)
Example #18
0
def order_list(request):                                                         #kim                                     
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
   # session = '10E5C27B3AA37718CFF61A6CA32135196E4636F6500251D3801C302B9F68B58F'
    if authuri:
        return HttpResponseRedirect(authuri)
    order_list_result = api_list.list_my_product_order(request,session)          
    if not order_list_result or order_list_result["error"]!=0:
        return response_data_utils.error_response(request,"服务器忙,请稍后重试!",__name__,order_list_result, session)    
    try:
        process_order_detail(order_list_result)
        next_request_url = ""
        if str(order_list_result['mark']) != "0":
           next_request_url = reverse('order:ajax_order_list', kwargs ={"mark":order_list_result['mark']})
        meta_data = {'url':next_request_url, "nav":"order","order_list":order_list_result["productOrderList"]}
        return weixin_auth_utils.fp_render(request,'order/orders.html',meta_data, session)
    except Exception,e:
        print e
        return response_data_utils.error_response(request,"服务器忙,请稍后重试!",__name__, e, session)
Example #19
0
def to_pay_order(rquest):
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri:
        return HttpResponseRedirect(authuri)
    payment = request.REQUEST.get('payment')
    orderId = request.REQUEST.get('orderId')
    if not orderId:
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!",
                                                  __name__, result, session)
    if orderId == 0:
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!",
                                                  __name__, result, session)

    order_info = api_list.get_product_order(request, session, orderId)
    if not order_info or order_info["error"] != 0:
        return response_data_utils.error_response(request, "找不到对应的订单!",
                                                  __name__, order_info,
                                                  session)

    meta_data = {"order_id": orderId}
    if order_info and order_info.get("productOrder"):
        product_order = order_info.get("productOrder")
        meta_data["goods_num"] = product_order.get("goodsNum")
        meta_data["total_fee"] = product_order.get("totalFee")

    if payment == "0":
        alipay_url = reverse("order:alipay_order", kwargs={})
        return HttpResponseRedirect(alipay_url + "?orderId=" + str(orderId) +
                                    "&session=" + session)
    elif payment == "1":
        meta_data["navTitle"] = "选择银行"
        meta_data["search_btn"] = 1
        return weixin_auth_utils.fp_render(request, 'order/choice_bank.html',
                                           meta_data, session)
    elif payment == "2":
        wxpay_url = reverse("order:wxpay_order", kwargs={})
        return HttpResponseRedirect(wxpay_url + "?orderId=" + str(orderId) +
                                    "&session=" + session)
Example #20
0
def submit_order(request):
    #return render(request, 'order/choice_bank.html', {})
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    if authuri:
        return HttpResponseRedirect(authuri)
    contact = request.REQUEST.get('contact')
    contactPhone = request.REQUEST.get('contactPhone')
    address = request.REQUEST.get('address')
    remark = request.REQUEST.get('remark')
    cartInfo = request.REQUEST.get('cartInfo')
    payment = request.REQUEST.get('payment')
    orderId = request.REQUEST.get('orderId')
    if not orderId:
        if not cartInfo:
            return response_data_utils.error_response(request, "没有选择商品!",
                                                      __name__, "没有选择商品",
                                                      session)
        try:
            cart_dict = json.loads(cartInfo)
            if not cart_dict:
                return response_data_utils.error_response(
                    request, "没有选择商品!", __name__, "没有选择商品", session)
        except Exception, e:
            print e
            return response_data_utils.error_response(request, "没有选择商品!",
                                                      __name__, "没有选择商品",
                                                      session)

        result = api_list.submit_order(request, session, cartInfo, contact,
                                       address, contactPhone, remark)
        orderId = 0
        if result and result.get("orderId"):
            orderId = result.get("orderId")
        else:
            return response_data_utils.error_response(
                request, result.get("errorString"), __name__, result, session)
Example #21
0
def order_detail(request,order_id):                                            #kim
    user_agent = request.META.get('HTTP_USER_AGENT')
    is_mm = 0
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
      is_mm = 1

    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    #session = '10E5C27B3AA37718CFF61A6CA32135196E4636F6500251D3801C302B9F68B58F'
    if authuri:
        return HttpResponseRedirect(authuri)
    order_detail_result = api_list.get_product_order(request, session, order_id)
   # cart_num = api_list.get_goods_num_in_cart(request)
    if not order_detail_result or order_detail_result["error"]!=0:
        return response_data_utils.error_response(request,"服务器忙,请稍后重试!",__name__,order_detail_result, session)
    try:
        process_order_detail(order_detail_result)
        meta_data = {"order":order_detail_result, 'navTitle':'订单详情','search_btn':1 , 'is_mm':is_mm}
        return weixin_auth_utils.fp_render(request,'order/order.html',meta_data, session)
    except Exception,e:
        return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, e, session)
Example #22
0
def ajax_submit_order(request):
    is_ajax = request.is_ajax()
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')
    response_json = {'error': 1, "errorString": "没有选择商品"}
    if authuri:
        response_json = {
            'error': 2,
            "errorString": "需要重新授权",
            "authuri": authuri
        }
        return HttpResponse(json.dumps(response_json),
                            content_type="application/json")
    contact = request.REQUEST.get('contact')
    contactPhone = request.REQUEST.get('contactPhone')
    address = request.REQUEST.get('address')
    remark = request.REQUEST.get('remark')
    cartInfo = request.REQUEST.get('cartInfo')
    payment = request.REQUEST.get('payment')
    orderId = request.REQUEST.get('orderId')
    if not cartInfo:
        response_data_utils.error_log(request, "没有选择商品!", __name__, "没有选择商品")
        return HttpResponse(json.dumps(response_json),
                            content_type="application/json")
    try:
        cart_dict = json.loads(cartInfo)
        if not cart_dict:
            response_data_utils.error_log(request, "没有选择商品!", __name__,
                                          "没有选择商品")
            return HttpResponse(json.dumps(response_json),
                                content_type="application/json")
    except Exception, e:
        response_data_utils.error_log(request, "没有选择商品", __name__, e)
        return HttpResponse(json.dumps(response_json),
                            content_type="application/json")
Example #23
0
def product_detail(request, product_id):
    #微信中用户信息获取及授权处理
    dp = request.REQUEST.get('dp')
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')

    user_agent = request.META.get('HTTP_USER_AGENT')

    is_mm = 0
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
        is_mm = 1

    if authuri and is_mm == 1 and dp != None and dp != "":
        return HttpResponseRedirect(authuri)
    from_user_name = None
    if dp != "" and dp != None:
        api_list.bind_user(request, session, dp)
        from_user_info = api_list.get_user_info_by_uid(request, dp)
        if from_user_info != None:
            from_user_name = from_user_info.get("userInfo").get('userName')
    # end

    has_product_info = 1
    try:
        product_json = api_list.get_product_info_by_id(request, product_id)
        question_json = api_list.get_related_question_by_product_id(
            request, product_id, 0)
        cart_num_json = api_list.get_goods_num_in_cart(request, session)
        if product_json == None or product_json == "" or product_json[
                'error'] != 0:
            return response_data_utils.error_response(request, "找不到这个产品!",
                                                      __name__, product_json)
        product_json["mark"] = 0
        if question_json and question_json['error'] == 0 and question_json.get(
                "contentList"):
            product_json["contentList"] = question_json["contentList"]
            product_json["mark"] = question_json["mark"]
            product_json["totalNumber"] = question_json["totalNumber"]

        product_json["cartNum"] = 0
        if cart_num_json and cart_num_json['error'] == 0:
            product_json["cartNum"] = cart_num_json["totalNum"]
        process_product_data(product_json)
        next_request_url = reverse('product:question_list',
                                   kwargs={
                                       "product_id": product_id,
                                       "mark": product_json['mark']
                                   })
        meta = response_data_utils.pack_data(
            request, {
                'navTitle': '产品详情',
                'product': product_json,
                'url': next_request_url,
                'fromUserName': from_user_name,
                'is_mm': is_mm
            })
        return weixin_auth_utils.fp_render(request, 'product/product.html',
                                           meta, session)
    except Exception, e:
        print e
        return response_data_utils.error_response(request, "找不到这个产品!",
                                                  __name__, e, session)
Example #24
0
def products_recommend(request):  #kim
    dp = request.REQUEST.get('dp')
    #微信中用户信息获取及授权处理
    user_info = weixin_auth_utils.get_user_info(request)
    authuri = user_info.get('redirect')
    session = user_info.get('session')

    user_agent = request.META.get('HTTP_USER_AGENT')

    is_mm = None
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
        is_mm = 1

    if authuri and is_mm == 1 and dp != None and dp != "":
        return HttpResponseRedirect(authuri)

    if dp != "" and dp != None:
        api_list.bind_user(request, session, dp)
    else:
        dp = None
    # end

    flash_activity = api_list.get_flash_banner(request)
    products_feature_result = api_list.get_feature_product_list(request)
    cart_num_json = api_list.get_goods_num_in_cart(request, session)
    album_list = api_list.get_list_product_album(request)
    if (not flash_activity) or flash_activity['error'] != 0:
        return response_data_utils.error_response(request, "秒杀产品不存在", __name__,
                                                  flash_activity, session)
    if (not products_feature_result) or products_feature_result['error'] != 0:
        return response_data_utils.error_response(request, "推荐产品不存在", __name__,
                                                  products_feature_result,
                                                  session)
    if (not album_list) or album_list["error"] != 0:
        return response_data_utils.error_response(request, "产品合集不存在", __name__,
                                                  album_list, session)
    try:
        process_products_feature(products_feature_result)
        next_request_url = ""
        if str(products_feature_result['mark']) != "0":
            next_request_url = reverse(
                'products:products_recommend_list',
                kwargs={"mark": products_feature_result['mark']})

        cartNum = 0
        if cart_num_json and cart_num_json['error'] == 0:
            cartNum = cart_num_json["totalNum"]
        if album_list and album_list["error"] == 0:
            for letter in album_list["result"]:
                if letter["type"] == 0:
                    album_list_little = letter["albums"]
                if letter["type"] == 1:
                    album_list_more = letter["albums"]
        meta_data = {
            'cartNum': cartNum,
            'url': next_request_url,
            'nav': 'products',
            "flash_activity": flash_activity.get('activityList'),
            "products_feature_list":
            products_feature_result.get('productList'),
            "album_list_little": album_list_little,
            "album_list_more": album_list_more
        }
        meta_data = response_data_utils.pack_data(request, meta_data)
        return weixin_auth_utils.fp_render(request,
                                           'products/products_recommend.html',
                                           meta_data, session)
    except Exception, e:
        return response_data_utils.error_response(request, "推荐产品不存在!",
                                                  __name__, e, session)