ol-4"> 633
+
632 634
 def room_goods_update(request):
633 635
     admin_id = request.POST.get('admin_id', '')
634 636
     room_id = request.POST.get('room_id', '')

+ 1 - 2
api/mini_views.py

@@ -64,6 +64,7 @@ def mini_login_api(request):
64 64
 
65 65
     return response(data=user.data)
66 66
 
67
+
67 68
 @logit(res=True)
68 69
 @transaction.atomic
69 70
 def mini_live_login_api(request):
@@ -112,7 +113,6 @@ def mini_live_login_api(request):
112 113
     # Store SessionKey
113 114
     store_session_key(appid=appid, secret=secret, session_key=session_key, unid=user.user_id, storage=RedisStorage(r))
114 115
 
115
-
116 116
     # Update live
117 117
     room = RoomInfo.objects.get(room_id=room_id)
118 118
     is_new = not RoomUserInfo.objects.filter(user_id=user.user_id).exists()
@@ -129,7 +129,6 @@ def mini_live_login_api(request):
129 129
     room_user.is_new = is_new
130 130
     room_user.save()
131 131
 
132
-
133 132
     return response(data=user.data)
134 133
 
135 134
 

+ 9 - 9
api/urls.py

@@ -4,8 +4,8 @@ from django.conf.urls import url
4 4
 from django_file_upload import views as file_views
5 5
 
6 6
 from api import admin_views, mini_views, oauth_views, pack_views
7
-from pay import views as pay_views
8 7
 from live import views as live_views
8
+from pay import views as pay_views
9 9
 
10 10
 
11 11
 urlpatterns = [
@@ -23,7 +23,7 @@ urlpatterns += [
23 23
     url(r'^pay/wx/notify_url$', pay_views.wx_notify_url_api, name='wx_notify_url_api'),  # 支付异步通知回调地址
24 24
 ]
25 25
 
26
-#直播相关
26
+# 直播相关
27 27
 urlpatterns += [
28 28
     url(r'^live/anchor/detail$', live_views.anchor_detail, name='anchor_detail'),   # 微信直播间列表
29 29
     url(r'^live/goods/detail$', live_views.room_goods_detail, name='room_goods_detail'),
@@ -55,15 +55,15 @@ urlpatterns += [
55 55
     url(r'^admin/live/room/list$', admin_views.live_room_list, name='live_room_list'),   # 直播间列表
56 56
 
57 57
     url(r'^admin/live/order/list$', admin_views.live_order_list, name='live_order_list'),   # 直播间订单列表
58
-    url(r'^admin/live/order/delivery$', admin_views.live_order_delivery, name='live_order_delivery'), # 直播间订单发货
58
+    url(r'^admin/live/order/delivery$', admin_views.live_order_delivery, name='live_order_delivery'),  # 直播间订单发货
59 59
 
60
-    url(r'^admin/room/goods/list$', admin_views.room_goods_list, name='room_goods_list'), # 直播间商品
61
-    url(r'^admin/room/goods/add$', admin_views.room_goods_add, name='room_goods_add'), #添加直播间商品
62
-    url(r'^admin/room/goods/publish$', admin_views.room_goods_publish, name='room_goods_publish'), #直播间商品上架
63
-    url(r'^admin/room/goods/off$', admin_views.room_goods_off, name='room_goods_off'), #直播间商品下架
64
-    url(r'^admin/room/goods/update$', admin_views.room_goods_update, name='room_goods_update'), #直播间商品库存更新
60
+    url(r'^admin/room/goods/list$', admin_views.room_goods_list, name='room_goods_list'),  # 直播间商品
61
+    url(r'^admin/room/goods/add$', admin_views.room_goods_add, name='room_goods_add'),  # 添加直播间商品
62
+    url(r'^admin/room/goods/publish$', admin_views.room_goods_publish, name='room_goods_publish'),  # 直播间商品上架
63
+    url(r'^admin/room/goods/off$', admin_views.room_goods_off, name='room_goods_off'),  # 直播间商品下架
64
+    url(r'^admin/room/goods/update$', admin_views.room_goods_update, name='room_goods_update'),  # 直播间商品库存更新
65 65
 
66
-    #微信直播 api
66
+    # 微信直播 api
67 67
     url(r'^admin/live/wx/room/list$', admin_views.fetch_wx_room_list, name='fetch_wx_room_list'),   # 微信直播间列表
68 68
 ]
69 69
 

+ 4 - 2
live/admin.py

@@ -1,6 +1,6 @@
1 1
 from django.contrib import admin
2 2
 
3
-from live.models import RoomGoodsInfo, RoomInfo, AnchorInfo, liveGoodsInfo, RoomOrderInfo, RoomUserInfo
3
+from live.models import AnchorInfo, RoomGoodsInfo, RoomInfo, RoomOrderInfo, RoomUserInfo, liveGoodsInfo
4 4
 
5 5
 
6 6
 class AnchorInfoAdmin(admin.ModelAdmin):
@@ -18,10 +18,12 @@ class liveGoodsInfoAdmin(admin.ModelAdmin):
18 18
 class RoomGoodsInfoAdmin(admin.ModelAdmin):
19 19
     list_display = ('room_id', 'anchor_id', 'goods_id', 'inventory', 'sale_infos', 'status', 'created_at', 'updated_at')
20 20
 
21
+
21 22
 class RoomOrderInfoAdmin(admin.ModelAdmin):
22 23
     list_display = ('order_id', 'anchor_id', 'room_id', 'goods_id', 'share_openid', 'user_id', 'total_fee', 'name', 'phone', 'address', 'tracking_number', 'pay_status', 'status', 'created_at', 'updated_at')
23 24
     readonly_fields_exclude = ('tracking_number', )
24 25
 
26
+
25 27
 class RoomUserInfoAdmin(admin.ModelAdmin):
26 28
     list_display = ('room_id', 'anchor_id', 'user_id', 'openid', 'share_openid', 'status', 'created_at', 'updated_at')
27 29
 
@@ -31,4 +33,4 @@ admin.site.register(RoomInfo, RoomInfoAdmin)
31 33
 admin.site.register(liveGoodsInfo, liveGoodsInfoAdmin)
32 34
 admin.site.register(RoomGoodsInfo, RoomGoodsInfoAdmin)
33 35
 admin.site.register(RoomOrderInfo, RoomOrderInfoAdmin)
34
-admin.site.register(RoomUserInfo, RoomUserInfoAdmin)
36
+admin.site.register(RoomUserInfo, RoomUserInfoAdmin)

+ 16 - 16
live/models.py

@@ -1,5 +1,3 @@
1
-import json
2
-
3 1
 from django.db import models
4 2
 from django.utils.translation import ugettext_lazy as _
5 3
 from django_models_ext import BaseModelMixin, upload_file_path, upload_file_url, upload_path
@@ -7,9 +5,9 @@ from jsonfield import JSONField
7 5
 from shortuuidfield import ShortUUIDField
8 6
 from TimeConvert import TimeConvert as tc
9 7
 
10
-from account.models import UserInfo
11 8
 from simditor.fields import RichTextField
12 9
 
10
+
13 11
 class AnchorInfo(BaseModelMixin):
14 12
     anchor_id = ShortUUIDField(_('anchor_id'), max_length=32, blank=True, help_text='主播唯一标识', unique=True)
15 13
     # 微信相关
@@ -20,14 +18,14 @@ class AnchorInfo(BaseModelMixin):
20 18
     anchor_name = models.CharField(_('anchor_name'), max_length=255, blank=True, help_text='主播姓名', db_index=True)
21 19
     anchor_avatar = models.ImageField(_('anchor_avatar'), upload_to=upload_path, help_text='主播头像')
22 20
     anchor_intro = RichTextField(_('anchor_intro'), blank=True, help_text='主播介绍')
23
-    
21
+
24 22
     class Meta:
25 23
         verbose_name = _('主播信息')
26 24
         verbose_name_plural = _('主播信息')
27 25
 
28 26
     def __unicode__(self):
29 27
         return self.pk
30
-    
28
+
31 29
     @property
32 30
     def anchor_avatar_path(self):
33 31
         return upload_file_path(self.anchor_avatar)
@@ -35,6 +33,7 @@ class AnchorInfo(BaseModelMixin):
35 33
     @property
36 34
     def anchor_avatar_url(self):
37 35
         return upload_file_url(self.anchor_avatar)
36
+
38 37
     @property
39 38
     def banner_path(self):
40 39
         return upload_file_path(self.banner)
@@ -57,8 +56,8 @@ class RoomInfo(BaseModelMixin):
57 56
 
58 57
     anchor_id = models.CharField(_('anchor_id'), blank=True, max_length=32, help_text='主播唯一标识')
59 58
     anchor_name = models.CharField(_('anchor_name'), blank=True, max_length=255, help_text='主播名称', db_index=True)
60
-    
61
-    # "goods": [          
59
+
60
+    # "goods": [
62 61
     #     {
63 62
     #         "cover_img": "http://mmbiz.qpic.cn/mmbiz_png/FVribAGdErI2PmyST9ZM0JLbNM48I7TH2FlrwYOlnYqGaej8qKubG1EvK0QIkkwqvicrYTzVtjKmSZSeY5ianc3mw/0?wx_fmt=png",
64 63
     #         "url": "pages/index/index.html",
@@ -74,7 +73,7 @@ class RoomInfo(BaseModelMixin):
74 73
 
75 74
     def __unicode__(self):
76 75
         return self.pk
77
-    
76
+
78 77
     @property
79 78
     def cover_img_path(self):
80 79
         return upload_file_path(self.cover_img)
@@ -82,7 +81,7 @@ class RoomInfo(BaseModelMixin):
82 81
     @property
83 82
     def cover_img_url(self):
84 83
         return upload_file_url(self.cover_img)
85
-    
84
+
86 85
     @property
87 86
     def share_img_path(self):
88 87
         return upload_file_path(self.share_img)
@@ -100,7 +99,7 @@ class RoomInfo(BaseModelMixin):
100 99
             'cover_img': self.wx_cover_img,
101 100
             'share_img': self.wx_share_img,
102 101
         }
103
-       
102
+
104 103
     @property
105 104
     def admindata(self):
106 105
         anchor = AnchorInfo.objects.get(anchor_id=self.anchor_id)
@@ -117,7 +116,7 @@ class RoomInfo(BaseModelMixin):
117 116
             'anchor_avatar': anchor.anchor_avatar_url
118 117
         }
119 118
 
120
-  
119
+
121 120
 class liveGoodsInfo(BaseModelMixin):
122 121
     goods_id = ShortUUIDField(_('goods_id'), max_length=32, blank=True, help_text='商品ID', unique=True)
123 122
 
@@ -161,7 +160,7 @@ class liveGoodsInfo(BaseModelMixin):
161 160
     @property
162 161
     def goods_img_url(self):
163 162
         return upload_file_url(self.goods_img)
164
-    
163
+
165 164
     @property
166 165
     def admindata(self):
167 166
         return {
@@ -179,7 +178,6 @@ class liveGoodsInfo(BaseModelMixin):
179 178
         }
180 179
 
181 180
 
182
-
183 181
 class RoomGoodsInfo(BaseModelMixin):
184 182
     PUBLISH = 0
185 183
     DRAFT = 1
@@ -205,7 +203,7 @@ class RoomGoodsInfo(BaseModelMixin):
205 203
 
206 204
     def __unicode__(self):
207 205
         return self.pk
208
-    
206
+
209 207
     @property
210 208
     def admindata(self):
211 209
         goods = liveGoodsInfo.objects.get(goods_id=self.goods_id)
@@ -230,6 +228,7 @@ class RoomGoodsInfo(BaseModelMixin):
230 228
             'sale_count': len(self.sale_infos),
231 229
         }
232 230
 
231
+
233 232
 class RoomUserInfo(BaseModelMixin):
234 233
     room_id = models.CharField(_('room_id'), max_length=32, help_text='房间唯一标识', db_index=True)
235 234
     anchor_id = models.CharField(_('anchor_id'), max_length=32, blank=True, help_text='主播唯一标识')
@@ -247,6 +246,7 @@ class RoomUserInfo(BaseModelMixin):
247 246
     def __unicode__(self):
248 247
         return self.pk
249 248
 
249
+
250 250
 class RoomOrderInfo(BaseModelMixin):
251 251
     """
252 252
     # Trade State of Wechat Query
@@ -279,7 +279,7 @@ class RoomOrderInfo(BaseModelMixin):
279 279
     share_openid = models.CharField(_('share_openid'), max_length=32, blank=True, help_text='转发用户 openid')
280 280
 
281 281
     amount = models.IntegerField(_('amount'), default=0, help_text='数量')
282
-    
282
+
283 283
     name = models.CharField(_('name'), max_length=255, blank=True, null=True, help_text='姓名')
284 284
     phone = models.CharField(_('phone'), max_length=255, blank=True, null=True, help_text='电话')
285 285
     province = models.CharField(_('province'), max_length=255, blank=True, null=True, help_text='省份')
@@ -344,4 +344,4 @@ class RoomOrderInfo(BaseModelMixin):
344 344
             'total_fee': self.total_fee,
345 345
             'pay_status': self.pay_status,
346 346
             'paid_at': tc.local_string(utc_dt=self.paid_at, format='%Y-%m-%d %H:%M'),
347
-        }
347
+        }

+ 1 - 0
live/tests.py

@@ -1,3 +1,4 @@
1 1
 from django.test import TestCase
2 2
 
3
+
3 4
 # Create your tests here.

+ 74 - 65
live/views.py

@@ -1,35 +1,34 @@
1
-from django.shortcuts import render
2
-from django_query import get_query_value
1
+from django.conf import settings
3 2
 from django.db import transaction
4
-from django_response import response
5 3
 from django.shortcuts import HttpResponse
6 4
 from django_logit import logit
5
+from django_query import get_query_value
6
+from django_response import response
7 7
 from pywe_exception import WeChatPayException
8 8
 from pywe_pay import WeChatPay
9 9
 from pywe_pay_notify import check_pay_notify
10 10
 from pywe_response import WXPAY_NOTIFY_FAIL, WXPAY_NOTIFY_SUCCESS
11 11
 from TimeConvert import TimeConvert as tc
12 12
 
13
-from django.conf import settings
14
-
15
-from live.models import liveGoodsInfo, RoomGoodsInfo, RoomOrderInfo, RoomInfo, AnchorInfo
16 13
 from account.models import UserInfo
17
-
14
+from live.models import AnchorInfo, RoomGoodsInfo, RoomInfo, RoomOrderInfo, liveGoodsInfo
18 15
 from utils.error.errno_utils import OrderStatusCode, UserStatusCode
19 16
 
17
+
20 18
 WECHAT = settings.WECHAT
21 19
 
20
+
22 21
 def anchor_detail(request):
23 22
     anchor_id = get_query_value(request, 'anchor_id', '')
24 23
 
25 24
     try:
26 25
         anchor = AnchorInfo.objects.get(anchor_id=anchor_id)
27
-    except:
26
+    except AnchorInfo.DoesNotExist:
28 27
         return response()
29
-    
28
+
30 29
     rooms = RoomInfo.objects.filter(anchor_id=anchor_id)
31 30
     rooms = [room.anchorData for room in rooms]
32
-    
31
+
33 32
     return response(200, 'Get Room Anchor Details Success', '获取主播详情成功', data={
34 33
         'anchor': {
35 34
             'anchor_id': anchor.anchor_id,
@@ -43,49 +42,50 @@ def anchor_detail(request):
43 42
 
44 43
 
45 44
 def room_goods_detail(request):
46
-  goods_id = get_query_value(request, 'goods_id', '')
47
-  room_id = get_query_value(request, 'room_id', '')
48
-  
49
-  # 校验直播间和商品
50
-  try:
51
-    room_goods_info = RoomGoodsInfo.objects.get(goods_id=goods_id, room_id=room_id)
52
-  except:
53
-    return response(400001, 'Room Goods Not Found', '直播间商品不存在')
54
-  
55
-  try:
56
-    goods_info = liveGoodsInfo.objects.get(goods_id=goods_id)
57
-  except:
58
-    return response(400001, 'Live Goods Not Found', '直播商品不存在')
59
-
60
-  return response(200, 'Get Room Goods Detail Success', '获取直播间商品成功', data={
45
+    goods_id = get_query_value(request, 'goods_id', '')
46
+    room_id = get_query_value(request, 'room_id', '')
47
+
48
+    # 校验直播间和商品
49
+    try:
50
+        room_goods_info = RoomGoodsInfo.objects.get(goods_id=goods_id, room_id=room_id)
51
+    except RoomGoodsInfo.DoesNotExist:
52
+        return response(400001, 'Room Goods Not Found', '直播间商品不存在')
53
+
54
+    try:
55
+        goods_info = liveGoodsInfo.objects.get(goods_id=goods_id)
56
+    except liveGoodsInfo.DoesNotExist:
57
+        return response(400001, 'Live Goods Not Found', '直播商品不存在')
58
+
59
+    return response(200, 'Get Room Goods Detail Success', '获取直播间商品成功', data={
61 60
         'goods_info': {
62
-          'goods_img': goods_info.goods_img_url,
63
-          'name': goods_info.name,
64
-          'price_type': goods_info.price_type,
65
-          'price': goods_info.price,
66
-          'price2': goods_info.price2,
67
-          'goods_status': room_goods_info.goods_status,
68
-          'inventory': room_goods_info.inventory,
61
+            'goods_img': goods_info.goods_img_url,
62
+            'name': goods_info.name,
63
+            'price_type': goods_info.price_type,
64
+            'price': goods_info.price,
65
+            'price2': goods_info.price2,
66
+            'goods_status': room_goods_info.goods_status,
67
+            'inventory': room_goods_info.inventory,
69 68
         },
70 69
         'anchor_id': room_goods_info.anchor_id,
71
-      })
70
+    })
71
+
72 72
 
73 73
 def room_anchor_details(request):
74 74
     room_id = request.POST.get('room_id', '')
75 75
 
76 76
     try:
77 77
         room = RoomInfo.objects.get(room_id=room_id)
78
-    except:
78
+    except RoomInfo.DoesNotExist:
79 79
         return response()
80
-    
80
+
81 81
     try:
82 82
         anchor = AnchorInfo.objects.get(anchor_id=room.anchor_id)
83
-    except:
83
+    except AnchorInfo.DoesNotExist:
84 84
         return response()
85
-    
85
+
86 86
     rooms = RoomInfo.objects.filter(anchor_id=room.anchor_id)
87 87
     rooms = [room.anchorData for room in rooms]
88
-    
88
+
89 89
     return response(200, 'Get Room Anchor Details Success', '获取主播详情成功', data={
90 90
         'anchor': {
91 91
             'anchor_id': anchor.anchor_id,
@@ -97,6 +97,7 @@ def room_anchor_details(request):
97 97
         'rooms': rooms
98 98
     })
99 99
 
100
+
100 101
 @logit
101 102
 def live_order_create(request):
102 103
     """ 订单创建 """
@@ -121,32 +122,34 @@ def live_order_create(request):
121 122
     # 用户校验
122 123
     try:
123 124
         user = UserInfo.objects.get(user_id=user_id, status=True)
124
-        user.consignee_name = name
125
-        user.consignee_phone = phone
126
-        user.consignee_province = province
127
-        user.consignee_city = city
128
-        user.consignee_county = county
129
-        user.consignee_address = address
130
-        user.save()
131 125
     except UserInfo.DoesNotExist:
132 126
         return response(UserStatusCode.USER_NOT_FOUND)
133 127
 
128
+    user.consignee_name = name
129
+    user.consignee_phone = phone
130
+    user.consignee_province = province
131
+    user.consignee_city = city
132
+    user.consignee_county = county
133
+    user.consignee_address = address
134
+    user.save()
135
+
134 136
     # 校验直播间和商品
135 137
     try:
136 138
         room_goods_info = RoomGoodsInfo.objects.get(goods_id=goods_id, room_id=room_id, anchor_id=anchor_id)
137
-    except:
139
+    except RoomGoodsInfo.DoesNotExist:
138 140
         return response(400001, 'Room Goods Not Found', description='直播间商品不存在')
139 141
 
140
-    #库存校验
142
+    # 库存校验
141 143
     if room_goods_info.inventory <= 0:
142 144
         return response(400001, 'Room Goods Not En', description='商品库存不足')
143 145
 
144 146
     # 金额校验
145 147
     try:
146 148
         goods_info = liveGoodsInfo.objects.get(goods_id=goods_id)
147
-        if amount * int(goods_info.price if goods_info.price_type == 1 else goods_info.price2) != total_fee:
148
-            return response(404091, 'FEE Check Fail', description='金额校验失败')
149
-    except:
149
+    except liveGoodsInfo.DoesNotExist:
150
+        return response(404091, 'FEE Check Fail', description='金额校验失败')
151
+
152
+    if amount * int(goods_info.price if goods_info.price_type == 1 else goods_info.price2) != total_fee:
150 153
         return response(404091, 'FEE Check Fail', description='金额校验失败')
151 154
 
152 155
     # 消库存
@@ -198,7 +201,6 @@ def live_order_create(request):
198 201
     order.save()
199 202
 
200 203
     wxpay_params = wxpay.jsapi.get_jsapi_params(prepay_id)
201
-    
202 204
 
203 205
     return response(200, 'Order Create Success', '订单创建成功', {
204 206
         'order_id': order.order_id,
@@ -206,6 +208,7 @@ def live_order_create(request):
206 208
         'wxpay_params': wxpay_params,
207 209
     })
208 210
 
211
+
209 212
 def live_order_cancel(request):
210 213
     user_id = request.POST.get('user_id', '')
211 214
     order_id = request.POST.get('order_id', '')
@@ -213,24 +216,26 @@ def live_order_cancel(request):
213 216
 
214 217
     try:
215 218
         order = RoomOrderInfo.objects.get(user_id=user_id, order_id=order_id, prepay_id=prepay_id)
216
-    except:
219
+    except RoomOrderInfo.DoesNotExist:
217 220
         return response(400001, 'Order Not Found', description='直播间订单不存在')
218
-    
221
+
219 222
     if order.pay_status == RoomOrderInfo.FAIL:
220 223
         return response(200, 'Order Cancel Success', '订单取消成功')
221
-    
224
+
222 225
     order.pay_status = RoomOrderInfo.FAIL
223 226
     order.save()
224
-    
227
+
225 228
     try:
226 229
         goods_info = RoomGoodsInfo.objects.get(room_id=order.room_id, goods_id=order.goods_id, anchor_id=order.anchor_id)
227
-        goods_info.inventory += order.amount
228
-        goods_info.save()
229
-    except:
230
+    except RoomGoodsInfo.DoesNotExist:
230 231
         return response(400001, 'Room Goods Not Found', description='直播间商品不存在')
231
-    
232
+
233
+    goods_info.inventory += order.amount
234
+    goods_info.save()
235
+
232 236
     return response(200, 'Order Cancel Success', '订单取消成功')
233 237
 
238
+
234 239
 def order_paid_success(order):
235 240
     if order.pay_status == RoomOrderInfo.PAID:
236 241
         return
@@ -241,11 +246,13 @@ def order_paid_success(order):
241 246
 
242 247
     try:
243 248
         goods_info = RoomGoodsInfo.objects.get(room_id=order.room_id, goods_id=order.goods_id, anchor_id=order.anchor_id)
244
-        goods_info.sale_infos += [order.order_id]
245
-        goods_info.save()
246
-    except:
249
+    except RoomGoodsInfo.DoesNotExist:
247 250
         return
248 251
 
252
+    goods_info.sale_infos += [order.order_id]
253
+    goods_info.save()
254
+
255
+
249 256
 def order_paid_fail(order):
250 257
     if order.pay_status == RoomGoodsInfo.FAIL:
251 258
         return
@@ -255,11 +262,13 @@ def order_paid_fail(order):
255 262
 
256 263
     try:
257 264
         goods_info = RoomGoodsInfo.objects.get(room_id=order.room_id, goods_id=order.goods_id, anchor_id=order.anchor_id)
258
-        goods_info.inventory += order.amount
259
-        goods_info.save()
260
-    except:
265
+    except RoomGoodsInfo.DoesNotExist:
261 266
         return
262 267
 
268
+    goods_info.inventory += order.amount
269
+    goods_info.save()
270
+
271
+
263 272
 @logit
264 273
 @transaction.atomic
265 274
 def notify_url_api(request):

+ 21 - 22
pay/views.py

@@ -17,12 +17,11 @@ from TimeConvert import TimeConvert as tc
17 17
 from account.models import UserInfo
18 18
 from goods.models import GoodsInfo, PackGoodsInfo, PackGoodsSaleInfo, PackInfo
19 19
 from kol.models import KOLInfo
20
-from pay.models import OrderInfo
20
+from live import views as live_views
21 21
 from live.models import RoomOrderInfo
22
+from pay.models import OrderInfo
22 23
 from utils.error.errno_utils import KOLStatusCode, OrderStatusCode, PackGoodsStatusCode, PackStatusCode, UserStatusCode
23 24
 
24
-from live import views as live_views
25
-
26 25
 
27 26
 WECHAT = settings.WECHAT
28 27
 
@@ -82,7 +81,7 @@ def wx_order_create_api(request):
82 81
         except GoodsInfo.DoesNotExist:
83 82
             continue
84 83
         amount = amount + good.price * g.get('num', 0)
85
-    
84
+
86 85
     if amount != total_fee:
87 86
         return response(OrderStatusCode.FEE_CHECK_FAIL)
88 87
 
@@ -145,6 +144,7 @@ def wx_order_create_api(request):
145 144
         'wxpay_params': wxpay_params,
146 145
     })
147 146
 
147
+
148 148
 def order_cancel(request):
149 149
     user_id = request.POST.get('user_id', '')
150 150
     order_id = request.POST.get('order_id', '')
@@ -152,15 +152,15 @@ def order_cancel(request):
152 152
 
153 153
     try:
154 154
         order = OrderInfo.objects.get(user_id=user_id, order_id=order_id, prepay_id=prepay_id)
155
-    except:
155
+    except OrderInfo.DoesNotExist:
156 156
         return response()
157
-    
157
+
158 158
     if order.pay_status == OrderInfo.FAIL:
159 159
         return response(200, 'Order Cancel Success', '订单取消成功')
160
-    
160
+
161 161
     order.pay_status = OrderInfo.FAIL
162 162
     order.save()
163
-    
163
+
164 164
     for g in order.goods_info:
165 165
         try:
166 166
             good = PackGoodsInfo.objects.get(pack_id=order.pack_id, good_id=g.get('good_id', ''))
@@ -168,9 +168,10 @@ def order_cancel(request):
168 168
             good.save()
169 169
         except PackGoodsInfo.DoesNotExist:
170 170
             continue
171
-    
171
+
172 172
     return response(200, 'Order Cancel Success', '订单取消成功')
173 173
 
174
+
174 175
 def order_paid_success(order):
175 176
     if order.pay_status == OrderInfo.PAID:
176 177
         return
@@ -218,22 +219,20 @@ def wx_notify_url_api(request):
218 219
     if not success:
219 220
         return HttpResponse(WXPAY_NOTIFY_FAIL)
220 221
 
221
-    #尖货接龙订单
222
+    # 尖货接龙订单
222 223
     try:
223 224
         order = OrderInfo.objects.select_for_update().get(order_id=notify_data.get('out_trade_no', ''), status=True)
224
-        order.notify_msg = request.body
225
-        order.transaction_id = notify_data.get('transaction_id', '')
226
-        order.save()
227
-
228
-        result_code = notify_data.get('result_code', '')
229
-        if result_code == 'SUCCESS':
230
-            order_paid_success(order)
231
-        else:
232
-            order_paid_fail(order)
233
-        
234
-        return HttpResponse(WXPAY_NOTIFY_SUCCESS)
235
-    except:
225
+    except OrderInfo.DoesNotExist:
236 226
         return HttpResponse(WXPAY_NOTIFY_FAIL)
237 227
 
228
+    order.notify_msg = request.body
229
+    order.transaction_id = notify_data.get('transaction_id', '')
230
+    order.save()
231
+
232
+    result_code = notify_data.get('result_code', '')
233
+    if result_code == 'SUCCESS':
234
+        order_paid_success(order)
235
+    else:
236
+        order_paid_fail(order)
238 237
 
239 238
     return HttpResponse(WXPAY_NOTIFY_SUCCESS)

kodo - Gogs: Go Git Service

Нет описания

Brightcells: 66a598b30c Makemigrations лет %!s(int64=8): %!d(string=назад)
..
0001_initial.py e184e7dd5b add api group_create/group_join лет %!s(int64=11): %!d(string=назад)
0002_groupinfo_session_id.py e184e7dd5b add api group_create/group_join лет %!s(int64=11): %!d(string=назад)
0003_groupinfo_admin_id.py 7e305483ab add api group_detail/group_lock/group_pass/group_refuse лет %!s(int64=11): %!d(string=назад)
0004_auto_20151216_2337.py 7467a3e68a add api group_update/group_remove лет %!s(int64=11): %!d(string=назад)
0005_groupuserinfo_current_id.py f587f0a48f user can just see photo after he joined the group & zh_Hans replace zh_CN in settings.py лет %!s(int64=10): %!d(string=назад)
0006_groupuserinfo_avatar.py 4afdb94e20 add avatar for GroupUserInfo лет %!s(int64=10): %!d(string=назад)
0007_auto_20160112_2040.py df1df69fe3 add api upgrade/splash лет %!s(int64=10): %!d(string=назад)
0008_photocommentinfo.py c72d89f6e5 add api comment_submit_api/comment_list_api/thumbup_submit_api/thumbup_list_api/thumbup_cancel_api лет %!s(int64=10): %!d(string=назад)
0009_photothumbupinfo.py c72d89f6e5 add api comment_submit_api/comment_list_api/thumbup_submit_api/thumbup_list_api/thumbup_cancel_api лет %!s(int64=10): %!d(string=назад)
0010_auto_20160120_1830.py a121b75ff2 add db_index=True for status field лет %!s(int64=10): %!d(string=назад)
0011_auto_20160302_2048.py da2a81fff1 add api pai2_home лет %!s(int64=10): %!d(string=назад)
0012_groupinfo_group_avatar.py da2a81fff1 add api pai2_home лет %!s(int64=10): %!d(string=назад)
0013_groupinfo_group_default_avatar.py f6a88c632b add group_default_avatar field for GroupInfo лет %!s(int64=10): %!d(string=назад)
0014_auto_20160308_2347.py ca727b0362 store/return w/h for photo лет %!s(int64=10): %!d(string=назад)
0015_groupphotoinfo_avatar.py 88049b12db store/return more field for photo лет %!s(int64=10): %!d(string=назад)
0016_auto_20160321_1535.py 537bd9bd41 add api group_quit_api лет %!s(int64=10): %!d(string=назад)
0017_groupphotoinfo_photo_from.py dbea356558 add photo_from field for GroupPhotoInfo and return photo_from for some api лет %!s(int64=10): %!d(string=назад)
0018_auto_20160417_2246.py d64b3c216b add and return photo_thumbnail2 relative лет %!s(int64=10): %!d(string=назад)
0019_auto_20160422_1322.py 102152ca4a add api lensman_photo_bought & modify api wx_order_create_api and adjust return field лет %!s(int64=10): %!d(string=назад)
0020_groupphotoinfo_session_id.py 102152ca4a add api lensman_photo_bought & modify api wx_order_create_api and adjust return field лет %!s(int64=10): %!d(string=назад)
0021_photocommentinfo_to_uid.py fa36c26ce4 extend param to_uid for comment_submit_api лет %!s(int64=10): %!d(string=назад)
0022_auto_20160901_1439.py 6199c8f7ad add api lensman_origin_wanted_api/lensman_origin_photo_upload_api лет %!s(int64=10): %!d(string=назад)
0023_groupinfo_group_initio.py e06dc10006 Make join session group by scan group qrcode fetch group photos initio лет %!s(int64=10): %!d(string=назад)
0024_auto_20161214_1329.py f724e0f9c0 Add tour guide apis лет %!s(int64=9): %!d(string=назад)
0025_auto_20161214_1659.py ad69866b26 Add tour guide's name and phone in GroupInfo лет %!s(int64=9): %!d(string=назад)
0026_auto_20161216_1301.py 034acddb68 Add total_persons for GroupInfo лет %!s(int64=9): %!d(string=назад)
0027_groupuserinfo_authority.py 88f0697a89 Add authority field for GroupUserInfo лет %!s(int64=9): %!d(string=назад)
0028_auto_20161220_1815.py 272f181c50 Makemigrations лет %!s(int64=9): %!d(string=назад)
0029_auto_20161224_1616.py 564ff620d7 Add unique_together = (('group_id', 'user_id'),) for GroupUserInfo лет %!s(int64=9): %!d(string=назад)
0030_groupinfo_gather_location.py 90d377ee6e Add gather location лет %!s(int64=9): %!d(string=назад)
0031_groupphotoinfo_photo_md5.py d824fbd441 Add photo_md5 for GroupPhotoInfo лет %!s(int64=9): %!d(string=назад)
0032_groupinfo_gather_screenshot.py e8cd9652b7 Add gather_screenshot for api tg_group_gather_start_api лет %!s(int64=9): %!d(string=назад)
0033_groupphotoinfo_photo_id.py 3c6e34823b Add photo_id for GroupPhotoInfo replaced pk лет %!s(int64=9): %!d(string=назад)
0034_auto_20170411_1156.py 14d5d63e3b Add nomark/origin price for GroupPhotoInfo лет %!s(int64=9): %!d(string=назад)
0035_groupuserinfo_admin_status.py 9e4ac4fd3b Add admin_status for GroupUserInfo лет %!s(int64=9): %!d(string=назад)
0036_groupphotoinfo_has_watermark.py 3b92e37156 Add field has_watermark for GroupPhotoInfo лет %!s(int64=9): %!d(string=назад)
0037_auto_20170821_1600.py bf678fc740 Add unique_together = (('session_id', 'group_from'),) лет %!s(int64=9): %!d(string=назад)
0038_auto_20170821_1608.py 7060597dd6 Add unique_together = (('group_id', 'user_id', 'photo_md5'),) for GroupPhotoInfo лет %!s(int64=9): %!d(string=назад)
0039_auto_20170821_1613.py 9f4c919c29 Add unique_together = (('photo_id', 'user_id'),) for PhotoThumbUpInfo лет %!s(int64=9): %!d(string=назад)
0040_auto_20170825_1342.py e5ad69259f Add unique_together = (('group_id', 'session_id', 'user_id', 'photo_id', 'lensman_photo_id'),) for GroupPhotoOrderInfo лет %!s(int64=9): %!d(string=назад)
0041_auto_20170825_1342.py e5ad69259f Add unique_together = (('group_id', 'session_id', 'user_id', 'photo_id', 'lensman_photo_id'),) for GroupPhotoOrderInfo лет %!s(int64=9): %!d(string=назад)
0042_groupphotoinfo_lensman_type.py a6195fa70d Add outtake lensman лет %!s(int64=9): %!d(string=назад)
0043_auto_20180101_2220.py 9bb56c50cc Makemigrations лет %!s(int64=8): %!d(string=назад)
0044_auto_20180103_0446.py a7cbbf15a7 Update max_length for CharField лет %!s(int64=8): %!d(string=назад)
0045_auto_20180930_1159.py 66a598b30c Makemigrations лет %!s(int64=8): %!d(string=назад)
__init__.py e184e7dd5b add api group_create/group_join лет %!s(int64=11): %!d(string=назад)
chengzhenyu/client - Gogs: Go Git Service

1 Коммиты (68d73d2d60d9c2f9c2a4b24309ef200fd9edde86)

Автор SHA1 Сообщение Дата
  chengzhenyu 4abc31b420 地理信息上传逻辑优化 лет %!s(int64=9): %!d(string=назад)