Example #1
0
    def post(self, request, format=None):
        serializer = serializers.cancelorderSerializer(data=request.data)
        if serializer.is_valid():
            serializer.save()
            # 获取到传递的参数,房间信息
            outOrderId = request.data['outOrderId']
            reason = request.data['reason']

            # 固定数据,无需修改
            post_dict, APP_SECRET = support.post_fixed()
            '''请求的方法'''
            post_dict['method'] = "dfire.thirdpart.wm.order.cancel"
            del post_dict['entityId']
            post_dict['outOrderId'] = outOrderId
            post_dict['orderFrom'] = 118
            post_dict['reason'] = reason

            sorted_x = dict(sorted(post_dict.items(), key=lambda x: x[0]))
            res = APP_SECRET + ''.join([str(key) + str(sorted_x[key]) for key in sorted_x]) + APP_SECRET
            res = hashlib.sha1(res.encode("utf-8")).hexdigest()

            '''签名'''
            post_dict['sign'] = res.upper()
            print(post_dict)
            model = requests.post(url='http://open.2dfire.com/router',
                                  data={'method': post_dict['method'],
                                        'v': post_dict['v'],
                                        'timestamp': post_dict['timestamp'],
                                        'appKey': post_dict['appKey'],
                                        'sign': post_dict['sign'],
                                        'outOrderId': post_dict['outOrderId'],
                                        'orderFrom': post_dict['orderFrom'],
                                        'reason': post_dict['reason'],
                                        }).text
            return HttpResponse(model)
Example #2
0
 def post(self, request, format=None):
     serializer = serializers.OrderdatabydaySerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         # 获取到传递的参数,房间信息
         databyday = request.data['databyday']
         # databyday = databyday.replace('-','')
         '''查询cache中当天订单数据'''
         model = Myredis.getAllMenu('Orderdata', databyday)
         # print(model)
         if model == None:
             # 固定数据,无需修改
             post_dict, APP_SECRET = support.post_fixed()
             '''请求的方法'''
             post_dict['method'] = "dfire.shop.day.memu.data"
             post_dict['currDate'] = databyday
             curr_x = 'currDate'
             if len(databyday) == 6:
                 post_dict['method'] = "dfire.shop.month.memu.data"
                 post_dict['currMonth'] = databyday
                 del post_dict['currDate']
                 curr_x = 'currMonth'
             sorted_x = dict(sorted(post_dict.items(), key=lambda x: x[0]))
             res = APP_SECRET + ''.join(
                 [str(key) + str(sorted_x[key])
                  for key in sorted_x]) + APP_SECRET
             res = hashlib.sha1(res.encode("utf-8")).hexdigest()
             '''签名'''
             post_dict['sign'] = res.upper()
             model = requests.post(url='http://open.2dfire.com/router',
                                   data={
                                       'method': post_dict['method'],
                                       'v': post_dict['v'],
                                       'timestamp': post_dict['timestamp'],
                                       'appKey': post_dict['appKey'],
                                       'sign': post_dict['sign'],
                                       'entityId': post_dict['entityId'],
                                       curr_x: databyday,
                                   }).text
             Myredis.my_redis.hmset('Orderdata', {'databyday': model})
         return HttpResponse(model)