优化代码,修复认证之后,免费下载次数不变问题

pull/10/head
youngS 4 years ago
parent 2e21465a1e
commit 7a0c8bfce3
  1. BIN
      fir_client/src/assets/pay/order-weixin.png
  2. BIN
      fir_client/src/assets/pay/pay-scan.png
  3. BIN
      fir_client/src/assets/pay/pay_alipay.png
  4. BIN
      fir_client/src/assets/pay/pay_selected.png
  5. BIN
      fir_client/src/assets/pay/pay_weixin.png
  6. 43
      fir_client/src/components/apps/FirApps.vue
  7. 38
      fir_client/src/components/user/FirUserOrders.vue
  8. 1
      fir_ser/api/utils/pay/ali.py
  9. 4
      fir_ser/api/utils/serializer.py
  10. 9
      fir_ser/api/utils/storage/caches.py
  11. 5
      fir_ser/api/views/order.py

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

@ -28,12 +28,10 @@
<div class="package-actions">
<el-radio v-model="default_price_radio" :label="packages.name" border>
<span>此套餐</span>
<span class="pay-current" v-if="default_price_radio === packages.name"/>
<span class="pay-current" v-if="default_price_radio === packages.name"
:style="{background:`url(${pay_image.selected}) right bottom/100% no-repeat`}"/>
</el-radio>
<!-- <button type="button" class="btn" @click="buy(packages)" :disabled="buy_button_disable">
购买
</button>-->
</div>
</div>
@ -44,9 +42,12 @@
:key="pay.name">
<span style="color: white">xxxxxxxxxxxxxx</span>
<span style="width: 160px; height: 45px">
<span class="pay-icon alipay" v-if="pay.type === 'ALI'"/>
<span class="pay-icon weixin" v-if="pay.type === 'WX'"/>
<span class="pay-current" v-if="default_pay_radio === pay.name"/>
<span class="pay-icon alipay" :style="{backgroundImage:`url(${pay_image.ali})`}"
v-if="pay.type === 'ALI'"/>
<span class="pay-icon" :style="{backgroundImage:`url(${pay_image.wx})`}"
v-if="pay.type === 'WX'"/>
<span class="pay-current" v-if="default_pay_radio === pay.name"
:style="{background:`url(${pay_image.selected}) right bottom/100% no-repeat` }"/>
</span>
</el-radio>
</div>
@ -543,6 +544,11 @@
show_buy_download_times: false,
data_package_prices: [],
buy_button_disable: true,
pay_image: {
'wx': require('@/assets/pay/pay_weixin.png'),
'ali': require('@/assets/pay/pay_alipay.png'),
'selected': require('@/assets/pay/pay_selected.png'),
}
}
}, methods: {
show_package_prices() {
@ -565,8 +571,12 @@
this.buy_button_disable = true;
my_order(res => {
if (res.code === 1000) {
this.$message.success("下订单成功,正在跳转支付页");
this.$router.push({name: 'FirUserOrders', params: {out_trade_no: res.data.out_trade_no}})
if (res.data && res.data.url) {
this.$message.success("下订单成功,正在跳转支付页");
this.$router.push({name: 'FirUserOrders', params: {out_trade_no: res.data.out_trade_no}})
} else {
this.$message.error("下订单异常,请联系管理员");
}
} else {
this.$message.error("异常" + res.msg);
this.buy_button_disable = false;
@ -1064,12 +1074,6 @@
}
/*/deep/ .el-dialog__body {*/
/* background-image: url("@/assets/b6.png");*/
/* border: 0;*/
/*}*/
.page-apps .card.app .action a, .page-apps .card.app .appname, .page-apps .card.app table tr td, .upload-modal .state-form .release-body .input-addon {
font-family: 'Open Sans', sans-serif
}
@ -1509,12 +1513,7 @@
z-index: 999;
}
.weixin {
background-image: url(https://img.jiguang.cn/app-portal/assets/img/account/pay_weixin.png);
}
.pay-current {
background: url(https://img.jiguang.cn/app-portal/assets/img/account/pay_selected.png) right bottom/100% no-repeat;
width: 18px;
height: 19px;
position: absolute;
@ -1531,8 +1530,4 @@
left: 15px;
}
.alipay {
background-image: url(https://img.jiguang.cn/app-portal/assets/img/account/pay_alipay.png);
}
</style>

@ -23,7 +23,7 @@
</div>
<div class="pay_wx">
<div>
<div class="icon-weixin"></div>
<div class="icon-weixin" :style="{background:`url(${pay_image.order_wx}) 0 0/100%`}"></div>
<vue-qr :margin="qrinfo.margin"
class="code-wrap"
:logoScale="qrinfo.logoScale"
@ -32,7 +32,8 @@
:text="pay_code_url" :size="266"
ref="qr">
</vue-qr>
<div class="tip-btn pay_wx"><span class="icon"/><span class="text">请使用微信扫码支付</span></div>
<div class="tip-btn pay_wx"><span class="icon" :style="{backgroundImage:`url(${pay_image.scan})`}"/><span
class="text">请使用微信扫码支付</span></div>
<p style="margin-top: 30px">支付完成之后请刷新该页面确认支付状态</p>
</div>
</div>
@ -255,6 +256,10 @@
return {
wx_pay: false,
pay_code_url: '',
pay_image: {
'scan': require('@/assets/pay/pay-scan.png'),
'order_wx': require('@/assets/pay/order-weixin.png'),
},
qrinfo: {
logoScale: 0.3,
logoCornerRadius: 12,
@ -293,19 +298,24 @@
my_order(res => {
if (res.code === 1000) {
let data = res.data;
if (data && data.type === 'WX') {
this.pay_code_url = data.url;
this.wx_pay = true;
this.$message.success("请用微信扫描支付");
} else if (data && data.type === 'ALI') {
let pay_url = data.url;
if (pay_url && pay_url.length > 10) {
this.$message.success("正在跳转支付宝支付平台");
window.location.href = pay_url
// window.open(pay_url, '_blank', '');
if (data && data.url) {
if (data && data.type === 'WX') {
this.pay_code_url = data.url;
this.wx_pay = true;
this.$message.success("请用微信扫描支付");
} else if (data && data.type === 'ALI') {
let pay_url = data.url;
if (pay_url && pay_url.length > 10) {
this.$message.success("正在跳转支付宝支付平台");
window.location.href = pay_url
// window.open(pay_url, '_blank', '');
}
} else {
this.$message.error("支付获取失败 " + res.msg)
}
} else {
this.$message.error("支付获取失败 " + res.msg)
this.$message.error("下订单异常,请联系管理员");
}
} else {
this.$message.error("失败了 " + res.msg)
@ -444,7 +454,6 @@
.icon-weixin {
width: 137px;
height: 35px;
background: url(https://img.jiguang.cn/app-portal/assets/img/account/order-weixin.png) 0 0/100%;
margin-left: 50px;
}
@ -465,7 +474,6 @@
.icon {
width: 26px;
height: 26px;
background-image: url(https://img.jiguang.cn/app-portal/assets/img/account/pay-scan.png);
background-size: 100%;
display: inline-block;
margin-right: 11px;

@ -75,7 +75,6 @@ class Alipay(object):
def update_order_status(self, out_trade_no):
data = self.alipay.api_alipay_trade_query(out_trade_no=out_trade_no)
# (0, '交易成功'), (1, '待支付'), (2, '订单已创建'), (3, '退费申请中'), (4, '已退费'), (5, '主动取消'), (6, '超时取消')
code = data.get("code", '')
logger.info("out_trade_no: %s info:%s" % (out_trade_no, data))
if code == '10000':

@ -5,7 +5,7 @@ from api.utils.TokenManager import DownloadToken
from api.utils.app.supersignutils import get_redirect_server_domain
from api.utils.storage.storage import Storage
from api.utils.utils import get_developer_udided, get_choices_dict
from api.utils.storage.caches import get_user_free_download_times
from api.utils.storage.caches import get_user_free_download_times, get_user_cert_auth_status
import os, json, logging
logger = logging.getLogger(__file__)
@ -64,7 +64,7 @@ class UserInfoSerializer(serializers.ModelSerializer):
free_download_times = serializers.SerializerMethodField()
def get_free_download_times(self, obj):
return get_user_free_download_times(obj.id)
return get_user_free_download_times(obj.id, auth_status=get_user_cert_auth_status(obj.id))
certification = serializers.SerializerMethodField()

@ -378,12 +378,17 @@ def add_user_download_times(user_id, download_times=0):
return False
def check_user_has_all_download_times(app_obj):
user_id = app_obj.user_id_id
def get_user_cert_auth_status(user_id):
user_cert_obj = UserCertificationInfo.objects.filter(user_id=user_id).first()
auth_status = False
if user_cert_obj and user_cert_obj.status == 1:
auth_status = True
return auth_status
def check_user_has_all_download_times(app_obj):
user_id = app_obj.user_id_id
auth_status = get_user_cert_auth_status(user_id)
return get_user_free_download_times(user_id, auth_status=auth_status) > 0 or check_user_can_download(user_id)

@ -140,16 +140,11 @@ class PriceView(APIView):
class PaySuccess(APIView):
# authentication_classes = [ExpiringTokenAuthentication]
def get(self, request):
alipay = Alipay()
# alipay.update_order_status('1202141610723105226256209')
print(request.META)
return Response(111)
# return HttpResponseRedirect(PAY_SUCCESS_URL)
def post(self, request, name):
pay_obj = get_pay_obj_form_name(name)
msg = 'failure'

Loading…
Cancel
Save