Esempio n. 1
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)
Esempio n. 2
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) 
Esempio n. 3
0
def answer_list(request, question_id, mark):
    """
    根据mark返回答案列表,仅接受ajax请求
    :param request:
    :param question_id:
    :param mark:
    :return:
    """
    if request.is_ajax():
        try:
            answers_obj = api_list.get_question_detail(request, question_id, 0, 0, mark)
            if answers_obj['error'] == 0:
                process_answers(answers_obj['answerList']);
                template = loader.get_template('question/answerList.html')
                context = RequestContext(request, {'answers': answers_obj['answerList']})
                next_page_url = ''  # for next page ajax loading
                if int(answers_obj['mark']) > 0:
                    next_page_url = reverse('question:answer_list',
                                            kwargs = {'question_id' : question_id, 'mark' : answers_obj['mark']})
                response_json = {'html':template.render(context), 'mark':answers_obj['mark'], 'url':next_page_url}
                return HttpResponse(json.dumps(response_json), content_type="application/json")
            else:
                return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, answers_obj)
        except Exception as e:
            return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, e)
    return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, "not ajax")
Esempio n. 4
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)
Esempio n. 5
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 )
Esempio n. 6
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)
Esempio n. 7
0
def sendCode(request):
   if request.is_ajax(): #仅接受ajax请求
       try:
          response_json = {'error':0}
          return HttpResponse(json.dumps(response_json), content_type="application/json")
       except Exception as e:
          return response_data_utils.error_response(request, None, __name__, e)
   return response_data_utils.error_response(request, None,  __name__, " not ajax")
Esempio n. 8
0
def search(request, keyword):
  search_json = api_list.search(request, keyword)
  try:
    if search_json == None or search_json == "" or search_json['error'] != 0:
      return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, search_json)
    process_search_data(search_json)
    next_request_url = reverse('search:question_list', kwargs = {"keyword":keyword, "mark":search_json['mark']})
    meta_data = response_data_utils.pack_data(request, {'search':search_json, 'url':next_request_url, 'keyword':keyword })
    return render(request, 'search/search.html', meta_data)
  except Exception,e:
    return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, e)
Esempio n. 9
0
def index(request):
    try:
        feed_obj = api_list.get_product_feeds(request)
        nav_list = static_data.get_nav_data() 
        if feed_obj['error'] == 0 :
            process_feed_data(feed_obj)
            next_request_url = reverse('feed:feed_list', kwargs ={"categoryid" : 0, "mark": feed_obj['mark']}) 
            meta = response_data_utils.pack_data(request, {'feeds' : feed_obj['feedList'],'nav_list' : nav_list , 'url' : next_request_url, "nav": "index"})
            return render(request, 'feed/feeds.html', meta)
        else:
            return response_data_utils.error_response(request, None, __name__, feed_obj)
    except Exception,e:
        return response_data_utils.error_response(request, None, __name__, e)
Esempio n. 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) 
Esempio n. 11
0
def get(request):
    #response  = HttpResponse("{\"error\":0}",content_type="application/json")
    #return response
    is_ajax = request.is_ajax()
    session = request.REQUEST.get("session")
    if not session:
        session = request.COOKIES.get("session")
    score = request.REQUEST.get("score")
    if not score:
       return HttpResponse("{\"error\":1,\"errorString\":\"没有积分\"}",content_type="application/json")

    game_uri = 'http://m.fenpuwang.com/game/makeup/1/?score=' + str(score)
    authuri = weixin_auth_utils.build_auth_uri(game_uri)
    is_ajax = request.is_ajax()
    if not session:
        response_json = {'error': 2,"authuri":authuri}
        print response_json
        response = HttpResponse(json.dumps(response_json), content_type="application/json")
        return write_show_result_cookie(response, 1 , score);

    if is_ajax and session:
        result = api_list.get_game_result(request, session, score)
        response_json = json.dumps(result)
        return HttpResponse(response_json,content_type="application/json")
    else:
        return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, "not ajax") 
Esempio n. 12
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)
Esempio n. 13
0
def question_list(request, keyword, mark):
  if request.is_ajax() == False: #仅接受ajax请求
    return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__ , "not ajax") 
  try:
    search_json = api_list.search(request, keyword, 2, 10, mark) 
    if search_json['error'] != 0:
      return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, search_json)
    process_search_data(search_json)
    template = loader.get_template("lists/question_topic_list.html")
    context = RequestContext(request, {'question_topic_list':search_json['searchContentList']})
    next_request_url = reverse('search:question_list', kwargs = {"keyword":keyword, "mark":search_json['mark']})
    if search_json['mark'] == 0 or search_json['mark'] == "0":
      next_request_url = "" 
    response_json = {'html':template.render(context), 'mark':search_json['mark'], 'url':next_request_url}
    return HttpResponse(json.dumps(response_json), content_type="application/json") 
  except Exception as e:
    return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, e)
Esempio n. 14
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)
Esempio n. 15
0
def new_topic_list(request,mark=0,order=0):                  #kim
    is_ajax = request.is_ajax()
    new_topic_result = api_list.get_feature_topic_list(request,mark,order)
    if new_topic_result and new_topic_result['error']!=0: 
        response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__,new_topic_result) 
    try:
        if is_ajax:
            process_topic_data(new_topic_result)
            next_request_url = ""
            if str(new_topic_result['mark']) != "0":
                next_request_url = reverse('topic:new_topic_list',kwargs={"mark":new_topic_result['mark']})
            meta_data = {'newTopicList':new_topic_result['featureTopicList'],'url':next_request_url }
            context = RequestContext(request, meta_data)
            template = loader.get_template('topic/topic_new.html')
            response_json = {'html':template.render(context), 'url':next_request_url}
            return HttpResponse(json.dumps(response_json), content_type="application/json")
    except Exception,e:
        return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__,e) 
Esempio n. 16
0
def feed_list(request, categoryid, mark):
    if request.is_ajax(): #仅接受ajax请求
        try:
            feed_obj = api_list.get_product_feeds(request, categoryid, 20, mark)
            if feed_obj['error'] == 0:
                process_feed_data(feed_obj)
                template = loader.get_template('feed/feedList.html')
                context = RequestContext(request, {'feeds': feed_obj['feedList']})
                next_request_url = ""
                if str(feed_obj['mark']) != "0":
                    next_request_url = reverse('feed:feed_list', kwargs ={"categoryid" : categoryid, "mark" : feed_obj['mark']})
                response_json = {'html':template.render(context), 'url':next_request_url}
                return HttpResponse(json.dumps(response_json), content_type="application/json")
            else:
                return response_data_utils.error_response(request, None, __name__, feed_obj)
        except Exception as e:
            return response_data_utils.error_response(request, None, __name__, e)
	return response_data_utils.error_response(request, None,  __name__, " not ajax")
Esempio n. 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)
Esempio n. 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)
Esempio n. 19
0
def open_bonus(request, activity_id):
    is_ajax = request.is_ajax()
    session = request.REQUEST.get("session")
    if not session:
        session = request.COOKIES.get("session")
    if is_ajax and session:
        result = api_list.open_bonus(request, session, activity_id)
        response_json = json.dumps(result)
        return HttpResponse(response_json, content_type="application/json")
    else:
        return response_data_utils.error_response(request, "服务器忙,请稍后重试!",
                                                  __name__, "not ajax")
Esempio n. 20
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)
Esempio n. 21
0
def change(request, sessionKey = '', mark = 0):
    is_ajax = request.is_ajax()
    if not is_ajax:
       sessionKey = request.META.get("HTTP_SESSIONKEY")
    if not sessionKey:
       sessionKey = request.REQUEST.get("sessionKey")
    if not sessionKey:
       return response_data_utils.error_response(request, None,  __name__, " not find sessionKey")
    channel = request.REQUEST.get("channel")
    udid = request.REQUEST.get("UDID")
    union_key = ""
    if channel and udid  and channel == "360super" :
        union_key = channel + udid

    try:
        change_info = None
        if not is_ajax:
            change_info = api_list.get_user_change_info(request, sessionKey)
        logs = api_list.get_user_change_log(request, sessionKey, union_key, mark)
        exchange_code_url = reverse("ucenter:exchangeCode")
        if logs['error'] == 0:
           next_page_url = ''  # for next page ajax loading
           if int(logs['mark']) > 0:
               next_page_url = reverse('ucenter:change_log_list', kwargs ={"sessionKey": sessionKey, "mark": logs['mark']})
           process_log_data(logs["userChangeLogList"])
           meta_data = {'change_info' : change_info,'userChangeLogList' : logs["userChangeLogList"], 'url':next_page_url,'session':sessionKey,"exchange_code_url":exchange_code_url}
           if is_ajax:
              context = RequestContext(request, meta_data)
              template = loader.get_template('ucenter/change_log_list.html')
              response_json = {'html':template.render(context), 'url':next_page_url}
              return HttpResponse(json.dumps(response_json), content_type="application/json")
           else:
              meta_data = response_data_utils.pack_data(request, meta_data)
              return render(request, 'ucenter/change.html', meta_data)
        else:
           return response_data_utils.error_response(request, "找不到这个页面!",  __name__, logs)
    except Exception as e:
        print e
        return response_data_utils.error_response(request,"找不到这个页面!", __name__, e)
Esempio n. 22
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)
Esempio n. 23
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)
Esempio n. 24
0
def productlist_by_category(request,
                            type=0,
                            category_id=0,
                            order=5,
                            filter=0,
                            mark=0):
    is_ajax = request.is_ajax()
    try:
        products_result = api_list.get_product_by_category(
            request, type, order, category_id, filter, 10, mark)
        if products_result['error'] == 0:
            process_product_data(products_result)
            next_request_url = ""
            if str(products_result['mark']) != "0":
                next_request_url = reverse('products:query_by_all',
                                           kwargs={
                                               "type": type,
                                               "category_id": category_id,
                                               "order": order,
                                               "filter": filter,
                                               "mark": products_result['mark']
                                           })
            meta_data = {
                'productList': products_result["productList"],
                'url': next_request_url,
                'nav': 'products'
            }
            if is_ajax:
                context = RequestContext(request, meta_data)
                template = loader.get_template('products/product_list.html')
                response_json = {
                    'html': template.render(context),
                    'url': next_request_url
                }
                return HttpResponse(json.dumps(response_json),
                                    content_type="application/json")
            else:
                meta_data = dict(
                    meta_data.items() + {
                        "type": type,
                        "category_id": category_id,
                        "order": str(order),
                        "filter": filter
                    }.items())
                meta_data = response_data_utils.pack_data(request, meta_data)
                return render(request, 'products/products.html', meta_data)
    except Exception, e:
        return response_data_utils.error_response(request, "该分类下没有产品!",
                                                  __name__, e)
Esempio n. 25
0
def index(request):
    try:
        feed_obj = api_list.get_product_feeds(request)
        nav_list = static_data.get_nav_data()
        if feed_obj['error'] == 0:
            process_feed_data(feed_obj)
            next_request_url = reverse('feed:feed_list',
                                       kwargs={
                                           "categoryid": 0,
                                           "mark": feed_obj['mark']
                                       })
            meta = response_data_utils.pack_data(
                request, {
                    'feeds': feed_obj['feedList'],
                    'nav_list': nav_list,
                    'url': next_request_url,
                    "nav": "index"
                })
            return render(request, 'feed/feeds.html', meta)
        else:
            return response_data_utils.error_response(request, None, __name__,
                                                      feed_obj)
    except Exception, e:
        return response_data_utils.error_response(request, None, __name__, e)
Esempio n. 26
0
def new_question_list(request,mark):                     
    question_new_json = api_list.get_question_new(request,mark)
    try:
        if question_new_json and question_new_json['error']==0:
            process_question_time(question_new_json)
            next_page_url=""
            if question_new_json['mark']!=0:
                next_page_url = reverse("question:question_list_new",kwargs={'mark':question_new_json['mark']})
            meta_data = {'questionNew':question_new_json['questionList'],'url':next_page_url}
            template = loader.get_template("question/questionNew.html")
            context = RequestContext(request,meta_data)
            response_json = {'html':template.render(context),'url':next_page_url}
            response_json = json.dumps(response_json)
            return HttpResponse(response_json,content_type="application/json")
    except Exception,e:
        return response_data_utils.error_response(request,None, __name__, e)
Esempio n. 27
0
def alipay_order(request):
    session = request.REQUEST.get('session')
    order_id = request.REQUEST.get('orderId')
    user_agent = request.META.get('HTTP_USER_AGENT')
    is_mm = None
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
        is_mm = 1
    order_info = api_list.get_product_order(request, session, order_id)
    meta_data = {"is_mm": is_mm}
    if order_info and order_info.get("productOrder"):
        product_order = order_info.get("productOrder") 
        paymentHTML = product_order.get("webPayInfo"); 
        meta_data['paymentHTML'] = paymentHTML
        return render(request, 'order/order_ali_pay.html', meta_data)
    else:
        return response_data_utils.error_response(request, order_info.get("errorString"), __name__, order_info)
Esempio n. 28
0
def alipay_order(request):
    session = request.REQUEST.get('session')
    order_id = request.REQUEST.get('orderId')
    user_agent = request.META.get('HTTP_USER_AGENT')
    is_mm = None
    user_agent = user_agent.lower()
    if "micromessenger" in user_agent:
        is_mm = 1
    order_info = api_list.get_product_order(request, session, order_id)
    meta_data = {"is_mm": is_mm}
    if order_info and order_info.get("productOrder"):
        product_order = order_info.get("productOrder")
        paymentHTML = product_order.get("webPayInfo")
        meta_data['paymentHTML'] = paymentHTML
        return render(request, 'order/order_ali_pay.html', meta_data)
    else:
        return response_data_utils.error_response(
            request, order_info.get("errorString"), __name__, order_info)
Esempio n. 29
0
def ajax_exists_qualification(request):
    session = request.REQUEST.get('session')
    if not session:
        session = request.COOKIES.get("session")
    product_uri = 'http://m.fenpuwang.com/products/'
    authuri = weixin_auth_utils.build_auth_uri(product_uri)
    is_ajax = request.is_ajax()
    if not session:
        response_json = {'error': 2, "authuri": authuri}
        print response_json
        return HttpResponse(json.dumps(response_json),
                            content_type="application/json")
    if not is_ajax:
        return response_data_utils.error_response(request, "非ajax!", __name__,
                                                  "no ajax")
    response_json = api_list.exists_qualification(request, session)
    print response_json
    return HttpResponse(json.dumps(response_json),
                        content_type="application/json")
Esempio n. 30
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 "============="
Esempio n. 31
0
def topic_list(request, mark=0):
    is_ajax = request.is_ajax()
    try:
        topic_result = api_list.get_feature_topic_list(request, mark)
        if topic_result['error'] == 0 :
            process_topic_data(topic_result)
            next_request_url = ""
            if str(topic_result['mark']) != "0":
                next_request_url = reverse('topic:topic_list', kwargs ={"mark":topic_result['mark']})
            meta_data = {'featureTopicList' : topic_result["featureTopicList"], 'url':next_request_url ,'nav':'topic'}
            if is_ajax:
                context = RequestContext(request, meta_data)
                template = loader.get_template('topic/topic_list.html')
                response_json = {'html':template.render(context), 'url':next_request_url}
                return HttpResponse(json.dumps(response_json), content_type="application/json")
            else:
                meta_data = response_data_utils.pack_data(request, meta_data)
                return render(request, 'topic/topic_index.html', meta_data)
    except Exception,e:
        return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, e)
Esempio n. 32
0
def product_list(request, keyword, type, mark):
   is_ajax = request.is_ajax()
   try:
      search_result = api_list.search(request, keyword, 1, 10, mark)
      if search_result['error'] == 0 :
          process_search_data(search_result)
          next_request_url = ""
          if str(search_result['mark']) != "0":
              next_request_url = reverse('search:product_list', kwargs ={"type":type, "keyword":keyword,  "mark":search_result['mark']})
          meta_data = {'productList' : search_result["productList"], 'url':next_request_url, "keyword":keyword, 'from': 'search' }
          if is_ajax:
             context = RequestContext(request, meta_data)
             template = loader.get_template('products/product_effect_list.html')
             response_json = {'html':template.render(context), 'url':next_request_url}
             return HttpResponse(json.dumps(response_json), content_type="application/json")
          else:
             meta_data = response_data_utils.pack_data(request, meta_data)
             return render(request, 'products/products.html', meta_data)
   except Exception,e:
     return response_data_utils.error_response(request,"服务器忙,请稍后重试!", __name__, e)
Esempio n. 33
0
def question_list(request,mark=0):                                     
    is_ajax = request.is_ajax()
    question_list_json = api_list.get_product_feeds(request,0,20,mark)
    try:
        if question_list_json and question_list_json['error']==0:
            process_question_time(question_list_json)
            next_page_url = ""
            if question_list_json['mark']!=0:
                next_page_url = reverse("question:question_list_choice",kwargs={'mark':question_list_json['mark']})
            meta_data = {'questionList':question_list_json['feedList'],'url':next_page_url, 'nav':'question'}
            if is_ajax:
                template = loader.get_template("question/questionList.html")
                context = RequestContext(request,meta_data)
                response_json = {'html':template.render(context),'url':next_page_url}
                response_json = json.dumps(response_json)
                return HttpResponse(response_json,content_type="application/json")
            else:
                meta_data = response_data_utils.pack_data(request,meta_data)
                return render(request,'question/questionIndex.html',meta_data) 
    except Exception,e:
        return response_data_utils.error_response(request,None, __name__, e)
Esempio n. 34
0
           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)
    
    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":
Esempio n. 35
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)
Esempio n. 36
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)
Esempio n. 37
0
            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)

    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={})