100
|
101
|
|
101
|
102
|
group_id = models.CharField(_(u'group_id'), max_length=255, blank=True, null=True, help_text=u'群组唯一标识', db_index=True)
|
102
|
|
- user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识')
|
|
103
|
+ user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
|
103
|
104
|
current_id = models.IntegerField(_(u'current_id'), default=-1, help_text=u'当前群组照片ID')
|
104
|
105
|
nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户群组昵称')
|
105
|
106
|
avatar = models.CharField(_(u'avatar'), max_length=255, blank=True, null=True, help_text=u'用户头像')
|
|
|
@@ -137,7 +138,7 @@ class GroupPhotoInfo(CreateUpdateMixin):
|
137
|
138
|
)
|
138
|
139
|
|
139
|
140
|
group_id = models.CharField(_(u'group_id'), max_length=255, blank=True, null=True, help_text=u'群组唯一标识', db_index=True)
|
140
|
|
- user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识')
|
|
141
|
+ user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
|
141
|
142
|
nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户群组昵称')
|
142
|
143
|
avatar = models.CharField(_(u'avatar'), max_length=255, blank=True, null=True, help_text=u'用户头像')
|
143
|
144
|
|
|
|
@@ -157,8 +158,13 @@ class GroupPhotoInfo(CreateUpdateMixin):
|
157
|
158
|
|
158
|
159
|
comment_num = models.IntegerField(_(u'comment_num'), default=0, help_text=u'照片评论数量')
|
159
|
160
|
thumbup_num = models.IntegerField(_(u'thumbup_num'), default=0, help_text=u'照片点赞数量')
|
|
161
|
+
|
160
|
162
|
photo_from = models.IntegerField(_(u'photo_from'), choices=PHOTO_FROM, default=APP_GROUP, help_text=u'照片来源')
|
161
|
163
|
|
|
164
|
+ session_id = models.CharField(_(u'session_id'), max_length=255, blank=True, null=True, help_text=u'照片组唯一标识,同 PhotosInfo 表', db_index=True)
|
|
165
|
+ lensman_id = models.CharField(_(u'lensman_id'), max_length=255, blank=True, null=True, help_text=u'摄影师唯一标识,同 PhotosInfo 表', db_index=True)
|
|
166
|
+ lensman_photo_id = models.CharField(_(u'lensman_photo_id'), max_length=255, blank=True, null=True, help_text=u'摄影师照片唯一标识,同 PhotosInfo 表', db_index=True)
|
|
167
|
+
|
162
|
168
|
class Meta:
|
163
|
169
|
verbose_name = _(u'groupphotoinfo')
|
164
|
170
|
verbose_name_plural = _(u'groupphotoinfo')
|
|
|
@@ -183,6 +189,7 @@ class GroupPhotoInfo(CreateUpdateMixin):
|
183
|
189
|
group = GroupInfo.objects.get(group_id=self.group_id)
|
184
|
190
|
except GroupInfo.DoesNotExist:
|
185
|
191
|
group = None
|
|
192
|
+ porder = get_lensman_order_record(self.pk, user_id) if self.photo_from == GroupPhotoInfo.SESSION_GROUP else {}
|
186
|
193
|
return {
|
187
|
194
|
'group_id': group and group.group_id,
|
188
|
195
|
'group_name': group and group.group_name,
|
|
|
@@ -206,13 +213,51 @@ class GroupPhotoInfo(CreateUpdateMixin):
|
206
|
213
|
'thumbup': get_group_photo_thumbup_flag(self.pk, user_id),
|
207
|
214
|
'thumbup_num': self.thumbup_num,
|
208
|
215
|
'photo_from': self.photo_from,
|
|
216
|
+ 'porder': porder,
|
209
|
217
|
'created_at': self.created_at.replace(microsecond=0),
|
210
|
218
|
}
|
211
|
219
|
|
212
|
220
|
|
|
221
|
+class GroupPhotoOrderInfo(CreateUpdateMixin):
|
|
222
|
+ group_id = models.CharField(_(u'group_id'), max_length=255, blank=True, null=True, help_text=u'群组唯一标识', db_index=True)
|
|
223
|
+ user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
|
|
224
|
+ photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'照片唯一标识', db_index=True)
|
|
225
|
+
|
|
226
|
+ m_photo_path = models.CharField(_(u'm_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,控制器上传,无水印')
|
|
227
|
+ l_photo_path = models.CharField(_(u'l_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,美化大图')
|
|
228
|
+ r_photo_path = models.CharField(_(u'r_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,高清大图')
|
|
229
|
+
|
|
230
|
+ class Meta:
|
|
231
|
+ verbose_name = _(u'groupphotoorderinfo')
|
|
232
|
+ verbose_name_plural = _(u'groupphotoorderinfo')
|
|
233
|
+
|
|
234
|
+ def __unicode__(self):
|
|
235
|
+ return unicode(self.pk)
|
|
236
|
+
|
|
237
|
+ @property
|
|
238
|
+ def m_photo_url(self):
|
|
239
|
+ return img_url(self.m_photo_path)
|
|
240
|
+
|
|
241
|
+ @property
|
|
242
|
+ def l_photo_url(self):
|
|
243
|
+ return img_url(self.l_photo_path)
|
|
244
|
+
|
|
245
|
+ @property
|
|
246
|
+ def r_photo_url(self):
|
|
247
|
+ return img_url(self.r_photo_path)
|
|
248
|
+
|
|
249
|
+ @property
|
|
250
|
+ def porder_info(self):
|
|
251
|
+ return {
|
|
252
|
+ 'm_photo_url': self.m_photo_url,
|
|
253
|
+ 'l_photo_url': self.l_photo_url,
|
|
254
|
+ 'r_photo_url': self.r_photo_url,
|
|
255
|
+ }
|
|
256
|
+
|
|
257
|
+
|
213
|
258
|
class PhotoCommentInfo(CreateUpdateMixin):
|
214
|
259
|
photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'飞图唯一标识', db_index=True)
|
215
|
|
- user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识')
|
|
260
|
+ user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
|
216
|
261
|
nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户群组昵称')
|
217
|
262
|
avatar = models.CharField(_(u'avatar'), max_length=255, blank=True, null=True, help_text=u'用户头像')
|
218
|
263
|
comment = models.TextField(_(u'comment'), blank=True, null=True, help_text=u'用户评论')
|
|
|
@@ -237,7 +282,7 @@ class PhotoCommentInfo(CreateUpdateMixin):
|
237
|
282
|
|
238
|
283
|
class PhotoThumbUpInfo(CreateUpdateMixin):
|
239
|
284
|
photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'飞图唯一标识', db_index=True)
|
240
|
|
- user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识')
|
|
285
|
+ user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
|
241
|
286
|
nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户群组昵称')
|
242
|
287
|
avatar = models.CharField(_(u'avatar'), max_length=255, blank=True, null=True, help_text=u'用户头像')
|
243
|
288
|
thumbup = models.BooleanField(_(u'thumbup'), default=True, help_text=u'用户点赞', db_index=True)
|
|
|
@@ -26,9 +26,10 @@ from utils.redis.rkeys import (
|
26
|
26
|
GROUP_USERS_QUIT_SET,
|
27
|
27
|
)
|
28
|
28
|
from utils.redis.rkeys import GROUP_LAST_PHOTO_PK
|
29
|
|
-from utils.redis.rkeys import LESMAN_PHOTO_PRICE, LESMAN_PHOTO_HAGGLE_TIMES
|
|
29
|
+from utils.redis.rkeys import LENSMAN_PHOTO_PRICE, LENSMAN_PHOTO_HAGGLE_TIMES
|
30
|
30
|
from utils.redis.rgroup import set_group_info, get_group_info, set_group_users_info, get_group_users_info
|
31
|
31
|
from utils.redis.rgroup import set_group_photo_thumbup_flag, del_group_photo_thumbup_flag, get_group_photo_thumbup_flag
|
|
32
|
+from utils.redis.rorder import get_lensman_order_record
|
32
|
33
|
|
33
|
34
|
from utils.sql.raw import PAI2_HOME_API
|
34
|
35
|
|
|
|
@@ -902,7 +903,10 @@ def pai2_home_api(request):
|
902
|
903
|
'created_at': row[21],
|
903
|
904
|
} for row in rows]
|
904
|
905
|
|
905
|
|
- [row.update({'thumbup': get_group_photo_thumbup_flag(row['photo_id'], user_id)}) for row in rows]
|
|
906
|
+ [row.update({
|
|
907
|
+ 'thumbup': get_group_photo_thumbup_flag(row['photo_id'], user_id),
|
|
908
|
+ 'porder': get_lensman_order_record(row['photo_id'], user_id) if row['photo_from'] == GroupPhotoInfo.SESSION_GROUP else {}
|
|
909
|
+ }) for row in rows]
|
906
|
910
|
|
907
|
911
|
return JsonResponse({
|
908
|
912
|
'status': 200,
|
|
|
@@ -914,7 +918,7 @@ def pai2_home_api(request):
|
914
|
918
|
})
|
915
|
919
|
|
916
|
920
|
|
917
|
|
-def lesman_photo_price(request):
|
|
921
|
+def lensman_photo_price(request):
|
918
|
922
|
"""
|
919
|
923
|
摄影师照片价格获取
|
920
|
924
|
:param request:
|
|
|
@@ -925,22 +929,22 @@ def lesman_photo_price(request):
|
925
|
929
|
photo_type = request.POST.get('photo_type', 'nomark') # nomark for 去除水印, origin for 获取高清图
|
926
|
930
|
|
927
|
931
|
# 处理价格逻辑
|
928
|
|
- lesman_photo_price_key = LESMAN_PHOTO_PRICE % (user_id, photo_id, photo_type)
|
929
|
|
- lesman_photo_haggle_times_key = LESMAN_PHOTO_HAGGLE_TIMES % (user_id, photo_id, photo_type)
|
|
932
|
+ lensman_photo_price_key = LENSMAN_PHOTO_PRICE % (user_id, photo_id, photo_type)
|
|
933
|
+ lensman_photo_haggle_times_key = LENSMAN_PHOTO_HAGGLE_TIMES % (user_id, photo_id, photo_type)
|
930
|
934
|
# Redis 获取存储的价格
|
931
|
|
- price = float(r.get(lesman_photo_price_key) or 0)
|
|
935
|
+ price = float(r.get(lensman_photo_price_key) or 0)
|
932
|
936
|
if price:
|
933
|
|
- haggle_times = int(r.get(lesman_photo_haggle_times_key) or 0)
|
|
937
|
+ haggle_times = int(r.get(lensman_photo_haggle_times_key) or 0)
|
934
|
938
|
# 砍价逻辑
|
935
|
|
- if haggle_times < settings.LESMAN_PHOTO_HAGGLE_MAX_TIMES:
|
|
939
|
+ if haggle_times < settings.LENSMAN_PHOTO_HAGGLE_MAX_TIMES:
|
936
|
940
|
price -= random.choice([0.5, 1])
|
937
|
|
- r.incr(lesman_photo_haggle_times_key)
|
|
941
|
+ r.incr(lensman_photo_haggle_times_key)
|
938
|
942
|
else:
|
939
|
943
|
# 获取摄影师定价
|
940
|
944
|
# TODO, 此处需要完整的摄影师定价
|
941
|
945
|
price = 9.9 if photo_type == 'origin' else 6.6
|
942
|
946
|
|
943
|
|
- r.set(lesman_photo_price_key, price)
|
|
947
|
+ r.set(lensman_photo_price_key, price)
|
944
|
948
|
|
945
|
949
|
return JsonResponse({
|
946
|
950
|
'status': 200,
|
|
|
@@ -951,6 +955,24 @@ def lesman_photo_price(request):
|
951
|
955
|
})
|
952
|
956
|
|
953
|
957
|
|
|
958
|
+def lensman_photo_bought(request):
|
|
959
|
+ """
|
|
960
|
+ 摄影师照片已购买
|
|
961
|
+ :param request:
|
|
962
|
+ :return:
|
|
963
|
+ """
|
|
964
|
+ user_id = request.POST.get('user_id', '')
|
|
965
|
+ photo_id = request.POST.get('photo_id', '')
|
|
966
|
+
|
|
967
|
+ return JsonResponse({
|
|
968
|
+ 'status': 200,
|
|
969
|
+ 'message': u'获取购买数据成功',
|
|
970
|
+ 'data': {
|
|
971
|
+ 'porder': get_lensman_order_record(photo_id, user_id)
|
|
972
|
+ }
|
|
973
|
+ })
|
|
974
|
+
|
|
975
|
+
|
954
|
976
|
def group_detail(request, group_id):
|
955
|
977
|
return render(request, 'page/download.html', {})
|
956
|
978
|
|
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
2
|
+from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+from django.db import models, migrations
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+ dependencies = [
|
|
10
|
+ ('message', '0004_systemmessagedeleteinfo'),
|
|
11
|
+ ]
|
|
12
|
+
|
|
13
|
+ operations = [
|
|
14
|
+ migrations.AlterField(
|
|
15
|
+ model_name='usermessageinfo',
|
|
16
|
+ name='group_id',
|
|
17
|
+ field=models.CharField(max_length=255, blank=True, help_text='\u7fa4\u7ec4\u552f\u4e00\u6807\u8bc6', null=True, verbose_name='group_id', db_index=True),
|
|
18
|
+ ),
|
|
19
|
+ migrations.AlterField(
|
|
20
|
+ model_name='usermessageinfo',
|
|
21
|
+ name='photo_id',
|
|
22
|
+ field=models.CharField(max_length=255, blank=True, help_text='\u98de\u56fe\u552f\u4e00\u6807\u8bc6', null=True, verbose_name='photo_id', db_index=True),
|
|
23
|
+ ),
|
|
24
|
+ ]
|
|
|
@@ -42,8 +42,8 @@ class UserMessageInfo(CreateUpdateMixin):
|
42
|
42
|
|
43
|
43
|
to_uid = models.CharField(_(u'to_uid'), max_length=255, blank=True, null=True, help_text=u'接收消息用户唯一标识', db_index=True)
|
44
|
44
|
|
45
|
|
- group_id = models.CharField(_(u'group_id'), max_length=255, blank=True, null=True, help_text=u'群组唯一标识')
|
46
|
|
- photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'飞图唯一标识')
|
|
45
|
+ group_id = models.CharField(_(u'group_id'), max_length=255, blank=True, null=True, help_text=u'群组唯一标识', db_index=True)
|
|
46
|
+ photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'飞图唯一标识', db_index=True)
|
47
|
47
|
|
48
|
48
|
msg_type = models.CharField(_(u'msg_type'), max_length=255, default='system', help_text=u'消息类型', db_index=True)
|
49
|
49
|
msg_title = models.CharField(_(u'msg_title'), max_length=255, blank=True, null=True, help_text=u'消息标题')
|
|
|
@@ -1,4 +1,3 @@
|
1
|
|
-#!/usr/bin/env python
|
2
|
1
|
# -*- coding: utf-8 -*-
|
3
|
2
|
|
4
|
3
|
from django.db import models
|
|
|
@@ -69,7 +69,6 @@ MIDDLEWARE_CLASSES += ('multidomain.middleware.DomainMiddleware', )
|
69
|
69
|
|
70
|
70
|
URL_CONFIG = (
|
71
|
71
|
# (r'^(.+\.)?xfoto\.com\.cn', 'pai2.urls_www'),
|
72
|
|
- (r'^(.+\.)?api\.xfoto\.com\.cn', 'pai2.urls_api'),
|
73
|
72
|
(r'^(.+\.)?api\.pai\.ai', 'pai2.urls_api'),
|
74
|
73
|
)
|
75
|
74
|
|
|
|
@@ -250,7 +249,7 @@ PAI2_HOME_MAX_ROWS = 400 # 首页照片最大数量, PAI2_HOME_PER_PAGE * PAI2_
|
250
|
249
|
GROUP_PER_PAGE = 20 # 群组每页数量
|
251
|
250
|
|
252
|
251
|
# 价格设置
|
253
|
|
-LESMAN_PHOTO_HAGGLE_MAX_TIMES = 3 # 摄影师照片最大砍价次数
|
|
252
|
+LENSMAN_PHOTO_HAGGLE_MAX_TIMES = 3 # 摄影师照片最大砍价次数
|
254
|
253
|
|
255
|
254
|
# 订单设置
|
256
|
255
|
ORDER_NUM_PER_PAGE = 10 # 订单每页数量
|
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
2
|
+from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+from django.db import models, migrations
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+ dependencies = [
|
|
10
|
+ ('pay', '0003_auto_20160417_1544'),
|
|
11
|
+ ]
|
|
12
|
+
|
|
13
|
+ operations = [
|
|
14
|
+ migrations.AddField(
|
|
15
|
+ model_name='orderinfo',
|
|
16
|
+ name='group_id',
|
|
17
|
+ field=models.CharField(max_length=255, blank=True, help_text='\u7fa4\u7ec4\u552f\u4e00\u6807\u8bc6', null=True, verbose_name='group_id', db_index=True),
|
|
18
|
+ ),
|
|
19
|
+ migrations.AddField(
|
|
20
|
+ model_name='orderinfo',
|
|
21
|
+ name='lensman_photo_id',
|
|
22
|
+ field=models.CharField(max_length=255, blank=True, help_text='\u6444\u5f71\u5e08\u7167\u7247\u552f\u4e00\u6807\u8bc6\uff0c\u540c PhotosInfo \u8868', null=True, verbose_name='lensman_photo_id', db_index=True),
|
|
23
|
+ ),
|
|
24
|
+ migrations.AddField(
|
|
25
|
+ model_name='orderinfo',
|
|
26
|
+ name='photo_id',
|
|
27
|
+ field=models.CharField(max_length=255, blank=True, help_text='\u98de\u56fe\u552f\u4e00\u6807\u8bc6', null=True, verbose_name='photo_id', db_index=True),
|
|
28
|
+ ),
|
|
29
|
+ migrations.AddField(
|
|
30
|
+ model_name='orderinfo',
|
|
31
|
+ name='photo_type',
|
|
32
|
+ field=models.IntegerField(default=0, help_text='\u8d2d\u4e70\u7167\u7247\u7c7b\u578b', verbose_name='photo_type', choices=[(0, '\u53bb\u9664\u6c34\u5370'), (1, '\u83b7\u53d6\u9ad8\u6e05\u56fe')]),
|
|
33
|
+ ),
|
|
34
|
+ ]
|
|
|
@@ -8,8 +8,18 @@ from shortuuidfield import ShortUUIDField
|
8
|
8
|
|
9
|
9
|
from pai2.basemodels import CreateUpdateMixin
|
10
|
10
|
|
|
11
|
+from group.models import GroupPhotoInfo
|
|
12
|
+
|
11
|
13
|
|
12
|
14
|
class OrderInfo(CreateUpdateMixin):
|
|
15
|
+ NOMARK = 0
|
|
16
|
+ ORIGIN = 1
|
|
17
|
+
|
|
18
|
+ PHOTO_TYPE = (
|
|
19
|
+ (NOMARK, u'去除水印'),
|
|
20
|
+ (ORIGIN, u'获取高清图'),
|
|
21
|
+ )
|
|
22
|
+
|
13
|
23
|
"""
|
14
|
24
|
# Trade State of Wechat Query
|
15
|
25
|
SUCCESS ——— 支付成功
|
|
|
@@ -35,6 +45,12 @@ class OrderInfo(CreateUpdateMixin):
|
35
|
45
|
|
36
|
46
|
order_id = ShortUUIDField(_(u'order_id'), max_length=255, help_text=u'订单唯一标识', db_index=True)
|
37
|
47
|
|
|
48
|
+ group_id = models.CharField(_(u'group_id'), max_length=255, blank=True, null=True, help_text=u'群组唯一标识', db_index=True)
|
|
49
|
+ photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'飞图唯一标识', db_index=True)
|
|
50
|
+ lensman_photo_id = models.CharField(_(u'lensman_photo_id'), max_length=255, blank=True, null=True, help_text=u'摄影师照片唯一标识,同 PhotosInfo 表', db_index=True)
|
|
51
|
+
|
|
52
|
+ photo_type = models.IntegerField(_('photo_type'), choices=PHOTO_TYPE, default=NOMARK, help_text=u'购买照片类型')
|
|
53
|
+
|
38
|
54
|
from_uid = models.CharField(_(u'from_uid'), max_length=255, help_text=u'付款用户唯一标识', db_index=True)
|
39
|
55
|
to_lid = models.CharField(_(u'to_lid'), max_length=255, blank=True, null=True, help_text=u'收款摄影师唯一标识', db_index=True)
|
40
|
56
|
to_uid = models.CharField(_(u'to_uid'), max_length=255, blank=True, null=True, help_text=u'收款用户唯一标识', db_index=True)
|
|
|
@@ -54,11 +70,17 @@ class OrderInfo(CreateUpdateMixin):
|
54
|
70
|
def __unicode__(self):
|
55
|
71
|
return u'{0.pk}'.format(self)
|
56
|
72
|
|
57
|
|
- @property
|
58
|
|
- def data(self):
|
|
73
|
+ def data(self, user_id=None):
|
|
74
|
+ try:
|
|
75
|
+ group_photo = GroupPhotoInfo.objects.get(pk=self.photo_id)
|
|
76
|
+ except GroupPhotoInfo.DoesNotExist:
|
|
77
|
+ group_photo = {}
|
59
|
78
|
return {
|
60
|
79
|
'order_id': self.order_id,
|
61
|
80
|
'from_uid': self.from_uid,
|
|
81
|
+ 'group_id': self.group_id,
|
|
82
|
+ 'photo_id': self.photo_id,
|
|
83
|
+ 'group_photo_info': group_photo and group_photo.photo_info(user_id),
|
62
|
84
|
'to_lid': self.to_lid,
|
63
|
85
|
'to_uid': self.to_uid,
|
64
|
86
|
'body': self.body,
|
|
|
@@ -5,13 +5,18 @@ from django.db import transaction
|
5
|
5
|
from django.http import JsonResponse
|
6
|
6
|
from django.shortcuts import HttpResponse
|
7
|
7
|
|
|
8
|
+from group.models import GroupPhotoInfo, GroupPhotoOrderInfo
|
8
|
9
|
from pay.models import OrderInfo
|
|
10
|
+from photo.models import PhotosInfo
|
9
|
11
|
|
10
|
12
|
from utils.page_utils import pagination
|
11
|
13
|
|
12
|
|
-from utils.error.errno_utils import OrderStatusCode
|
|
14
|
+from utils.error.errno_utils import GroupPhotoStatusCode, OrderStatusCode
|
13
|
15
|
from utils.error.response_utils import response
|
14
|
16
|
|
|
17
|
+from utils.redis.rkeys import LENSMAN_PHOTO_PRICE
|
|
18
|
+from utils.redis.rorder import set_lensman_order_record
|
|
19
|
+
|
15
|
20
|
from logit import logit
|
16
|
21
|
|
17
|
22
|
from TimeConvert import TimeConvert as tc
|
|
|
@@ -20,6 +25,7 @@ from wechatpy import WeChatPay, WeChatPayException
|
20
|
25
|
import xmltodict
|
21
|
26
|
|
22
|
27
|
|
|
28
|
+r = settings.REDIS_CACHE
|
23
|
29
|
WECHAT = settings.WECHAT
|
24
|
30
|
|
25
|
31
|
|
|
|
@@ -31,13 +37,33 @@ def wx_order_create_api(request):
|
31
|
37
|
:param request:
|
32
|
38
|
:return:
|
33
|
39
|
"""
|
34
|
|
- from_uid = request.POST.get('from_uid', '')
|
35
|
|
- to_lid = request.POST.get('to_lid', '')
|
36
|
|
- to_uid = request.POST.get('to_uid', '')
|
|
40
|
+ # from_uid = request.POST.get('from_uid', '')
|
|
41
|
+ # to_lid = request.POST.get('to_lid', '')
|
|
42
|
+ # to_uid = request.POST.get('to_uid', '')
|
|
43
|
+
|
|
44
|
+ group_id = request.POST.get('group_id', '')
|
|
45
|
+ user_id = request.POST.get('user_id', '')
|
|
46
|
+ photo_id = request.POST.get('photo_id', '')
|
|
47
|
+ photo_type = request.POST.get('photo_type', 'nomark') # nomark for 去除水印, origin for 获取高清图
|
|
48
|
+
|
|
49
|
+ # 群组照片校验
|
|
50
|
+ try:
|
|
51
|
+ group_photo = GroupPhotoInfo.objects.get(pk=photo_id)
|
|
52
|
+ except GroupPhotoInfo.DoesNotExist:
|
|
53
|
+ return response(GroupPhotoStatusCode.GROUP_PHOTO_NOT_FOUND)
|
37
|
54
|
|
38
|
55
|
body = request.POST.get('body', '') # 商品描述
|
39
|
56
|
total_fee = int(request.POST.get('total_fee', 0)) # 总金额,单位分
|
40
|
57
|
|
|
58
|
+ # 金额校验
|
|
59
|
+ # if float(r.get(LENSMAN_PHOTO_PRICE % (user_id, photo_id, photo_type)) or 0) != total_fee:
|
|
60
|
+ # return response(OrderStatusCode.FEE_CHECK_FAIL)
|
|
61
|
+
|
|
62
|
+ # 获取 from_uid, to_lid, to_uid
|
|
63
|
+ from_uid = user_id
|
|
64
|
+ to_lid = group_photo.lensman_id
|
|
65
|
+ to_uid = '' if group_photo.lensman_id else group_photo.user_id
|
|
66
|
+
|
41
|
67
|
# JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付,统一下单接口trade_type的传参可参考这里
|
42
|
68
|
trade_type = request.POST.get('trade_type', '')
|
43
|
69
|
|
|
|
@@ -48,6 +74,10 @@ def wx_order_create_api(request):
|
48
|
74
|
|
49
|
75
|
# 生成订单
|
50
|
76
|
order = OrderInfo.objects.create(
|
|
77
|
+ group_id=group_id,
|
|
78
|
+ photo_id=photo_id,
|
|
79
|
+ lensman_photo_id=group_photo.lensman_photo_id,
|
|
80
|
+ photo_type=1 if photo_type == 'origin' else 0,
|
51
|
81
|
from_uid=from_uid,
|
52
|
82
|
to_lid=to_lid,
|
53
|
83
|
to_uid=to_uid,
|
|
|
@@ -93,6 +123,16 @@ def order_paid_success(order):
|
93
|
123
|
order.paid_at = tc.utc_datetime()
|
94
|
124
|
order.save()
|
95
|
125
|
|
|
126
|
+ porder, created = GroupPhotoOrderInfo.objects.get_or_create(group_id=order.group_id, photo_id=order.group_id, user_id=order.from_uid)
|
|
127
|
+ photo = PhotosInfo.objects.get(photo_id=order.lensman_photo_id)
|
|
128
|
+ if order.photo_type == OrderInfo.NOMARK:
|
|
129
|
+ porder.m_photo_path = photo.m_photo_path
|
|
130
|
+ elif order.photo_type == OrderInfo.ORIGIN:
|
|
131
|
+ porder.r_photo_path = photo.r_photo_path
|
|
132
|
+ porder.save()
|
|
133
|
+
|
|
134
|
+ set_lensman_order_record(porder)
|
|
135
|
+
|
96
|
136
|
|
97
|
137
|
def order_paid_fail(order):
|
98
|
138
|
if order.pay_status == OrderInfo.FAIL:
|
|
|
@@ -177,7 +217,7 @@ def wx_order_list_api(request):
|
177
|
217
|
|
178
|
218
|
orders = OrderInfo.objects.filter(from_uid=user_id).order_by('-pk')
|
179
|
219
|
orders, left = pagination(orders, page, num)
|
180
|
|
- orders = [order.data for order in orders]
|
|
220
|
+ orders = [order.data(user_id) for order in orders]
|
181
|
221
|
|
182
|
222
|
return JsonResponse({
|
183
|
223
|
'status': 200,
|
|
|
@@ -212,7 +252,7 @@ def wx_order_detail_api(request):
|
212
|
252
|
'status': 200,
|
213
|
253
|
'message': u'获取订单详情成功',
|
214
|
254
|
'data': {
|
215
|
|
- 'order': order.data,
|
|
255
|
+ 'order': order.data(user_id),
|
216
|
256
|
},
|
217
|
257
|
})
|
218
|
258
|
|
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
2
|
+from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+from django.db import models, migrations
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+ dependencies = [
|
|
10
|
+ ('photo', '0006_auto_20160120_1830'),
|
|
11
|
+ ]
|
|
12
|
+
|
|
13
|
+ operations = [
|
|
14
|
+ migrations.AlterField(
|
|
15
|
+ model_name='photosinfo',
|
|
16
|
+ name='l_photo_path',
|
|
17
|
+ field=models.CharField(help_text='\u7167\u7247\u5b58\u653e\u8def\u5f84\uff0c\u7f8e\u5316\u5927\u56fe', max_length=255, null=True, verbose_name='l_photo_path', blank=True),
|
|
18
|
+ ),
|
|
19
|
+ migrations.AlterField(
|
|
20
|
+ model_name='photosinfo',
|
|
21
|
+ name='m_photo_path',
|
|
22
|
+ field=models.CharField(help_text='\u7167\u7247\u5b58\u653e\u8def\u5f84\uff0c\u63a7\u5236\u5668\u4e0a\u4f20\uff0c\u65e0\u6c34\u5370', max_length=255, null=True, verbose_name='m_photo_path', blank=True),
|
|
23
|
+ ),
|
|
24
|
+ migrations.AlterField(
|
|
25
|
+ model_name='photosinfo',
|
|
26
|
+ name='p_photo_path',
|
|
27
|
+ field=models.CharField(help_text='\u7167\u7247\u5b58\u653e\u8def\u5f84\uff0c\u63a7\u5236\u5668\u4e0a\u4f20\uff0c\u6709\u6c34\u5370\uff0c\u670d\u52a1\u5668\u6dfb\u52a0', max_length=255, null=True, verbose_name='p_photo_path', blank=True),
|
|
28
|
+ ),
|
|
29
|
+ migrations.AlterField(
|
|
30
|
+ model_name='photosinfo',
|
|
31
|
+ name='r_photo_path',
|
|
32
|
+ field=models.CharField(help_text='\u7167\u7247\u5b58\u653e\u8def\u5f84\uff0c\u9ad8\u6e05\u5927\u56fe', max_length=255, null=True, verbose_name='r_photo_path', blank=True),
|
|
33
|
+ ),
|
|
34
|
+ ]
|
|
|
@@ -34,10 +34,10 @@ class PhotosInfo(CreateUpdateMixin):
|
34
|
34
|
lensman_id = models.CharField(_(u'lensman_id'), max_length=255, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True)
|
35
|
35
|
session_id = models.CharField(_(u'session_id'), max_length=255, blank=True, null=True, help_text=u'照片组唯一标识', db_index=True)
|
36
|
36
|
photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'照片唯一标识', db_index=True, unique=True)
|
37
|
|
- p_photo_path = models.CharField(_(u'p_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径')
|
38
|
|
- m_photo_path = models.CharField(_(u'm_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径')
|
39
|
|
- l_photo_path = models.CharField(_(u'l_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径')
|
40
|
|
- r_photo_path = models.CharField(_(u'r_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径')
|
|
37
|
+ p_photo_path = models.CharField(_(u'p_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,控制器上传,有水印,服务器添加')
|
|
38
|
+ m_photo_path = models.CharField(_(u'm_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,控制器上传,无水印')
|
|
39
|
+ l_photo_path = models.CharField(_(u'l_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,美化大图')
|
|
40
|
+ r_photo_path = models.CharField(_(u'r_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,高清大图')
|
41
|
41
|
|
42
|
42
|
class Meta:
|
43
|
43
|
verbose_name = _('photosinfo')
|
|
|
@@ -234,6 +234,9 @@ def session_join_api(request):
|
234
|
234
|
photo_thumbnail2_w=photo_thumbnail2_w,
|
235
|
235
|
photo_thumbnail2_h=photo_thumbnail2_h,
|
236
|
236
|
photo_from=GroupPhotoInfo.SESSION_GROUP,
|
|
237
|
+ session_id=photo.session_id,
|
|
238
|
+ lensman_id=photo.lensman_id,
|
|
239
|
+ lensman_photo_id=photo.photo_id,
|
237
|
240
|
)
|
238
|
241
|
|
239
|
242
|
# 设置群组最后一张照片PK
|
|
|
@@ -69,6 +69,7 @@ class OrderStatusCode(BaseStatusCode):
|
69
|
69
|
WX_ORDER_PAYING = StatusCodeField(404003, u'WX Order Paying', description=u'订单支付中')
|
70
|
70
|
WX_ORDER_PAY_FAIL = StatusCodeField(404009, u'WX Order Pay Fail', description=u'微信支付失败')
|
71
|
71
|
SIGN_CHECK_FAIL = StatusCodeField(404010, u'Sign Check Fail', description=u'签名校验失败')
|
|
72
|
+ FEE_CHECK_FAIL = StatusCodeField(404011, u'FEE Check Fail', description=u'金额校验失败')
|
72
|
73
|
NO_DETAIL_PERMISSION = StatusCodeField(404015, u'No Detail Permission', description=u'没有详情权限')
|
73
|
74
|
|
74
|
75
|
|
|
|
@@ -19,8 +19,9 @@ GROUP_PHOTO_THUMB_UP = 'group:photo:thumb:up:%s:%s' # STRING,群组照片用
|
19
|
19
|
GROUP_LAST_PHOTO_PK = 'group:last:photo:pk:%s' # STRING,群组最后一张照片PK,group_id
|
20
|
20
|
|
21
|
21
|
# 摄影师照片相关
|
22
|
|
-LESMAN_PHOTO_PRICE = 'lesman:photo:price:%s:%s:%s' # STRING,摄影师照片价格,photo_id、user_id、photo_type
|
23
|
|
-LESMAN_PHOTO_HAGGLE_TIMES = 'lesman:photo:haggle:times:%s:%s:%s' # STRING,摄影师照片价格,photo_id、user_id、photo_type
|
|
22
|
+LENSMAN_PHOTO_PRICE = 'lensman:photo:price:%s:%s:%s' # STRING,摄影师照片价格,photo_id、user_id、photo_type
|
|
23
|
+LENSMAN_PHOTO_HAGGLE_TIMES = 'lensman:photo:haggle:times:%s:%s:%s' # STRING,摄影师照片价格,photo_id、user_id、photo_type
|
|
24
|
+LENSMAN_PHOTO_ORDER_RECORD = 'lensman:photo:order:record:%s:%s' # STRING,摄影师照片购买记录,photo_id、user_id
|
24
|
25
|
|
25
|
26
|
# 系统消息相关
|
26
|
27
|
SYSTEM_MESSAGE_DELETED_INFO = 'system:message:deleted:info:%s' # STRING,系统消息删除信息,user_id
|
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+from django.conf import settings
|
|
4
|
+from django.core.serializers.json import DjangoJSONEncoder
|
|
5
|
+
|
|
6
|
+from utils.redis.rkeys import LENSMAN_PHOTO_ORDER_RECORD
|
|
7
|
+
|
|
8
|
+import json
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+r = settings.REDIS_CACHE
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+# 摄影师照片购买记录相关
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+def set_lensman_order_record(porder):
|
|
18
|
+ """ 设置摄影师照片购买记录 """
|
|
19
|
+ porder_info = porder.porder_info
|
|
20
|
+ r.setex(LENSMAN_PHOTO_ORDER_RECORD % (porder.photo_id, porder.user_id), settings.REDIS_EXPIRED_MONTH, json.dumps(porder_info, cls=DjangoJSONEncoder))
|
|
21
|
+ return porder_info
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+def set_lensman_order_record_by_id(photo_id, user_id):
|
|
25
|
+ """ 设置摄影师照片购买记录 """
|
|
26
|
+ from group.models import GroupPhotoOrderInfo
|
|
27
|
+ try:
|
|
28
|
+ porder = GroupPhotoOrderInfo.objects.get(photo_id=photo_id, user_id=user_id)
|
|
29
|
+ except GroupPhotoOrderInfo.DoesNotExist:
|
|
30
|
+ return {}
|
|
31
|
+ return set_lensman_order_record(porder)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+def get_lensman_order_record(photo_id, user_id):
|
|
35
|
+ """ 获取摄影师照片购买记录 """
|
|
36
|
+ return json.loads(r.get(LENSMAN_PHOTO_ORDER_RECORD % (photo_id, user_id)) or '{}') or set_lensman_order_record_by_id(photo_id, user_id)
|