Browse Source
Makes autocontinue flag. When autoconnect service is enabled, end anough money, then connect last service tariff
devel
Makes autocontinue flag. When autoconnect service is enabled, end anough money, then connect last service tariff
devel
7 changed files with 120 additions and 120 deletions
-
3abonapp/locale/ru/LC_MESSAGES/django.po
-
34abonapp/migrations/0008_auto_20181115_1206.py
-
36abonapp/models.py
-
24abonapp/templates/abonapp/service.html
-
83forward_pay.php
-
31periodic.py
-
17tariff_app/migrations/0003_auto_20181115_1206.py
@ -0,0 +1,34 @@ |
|||
# Generated by Django 2.1 on 2018-11-15 12:06 |
|||
|
|||
from django.conf import settings |
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
|
|||
|
|||
def fill_last_tariff(apps, _): |
|||
Abon = apps.get_model('abonapp', 'Abon') |
|||
for abon in Abon.objects.exclude(current_tariff=None): |
|||
abon.last_connected_tariff = abon.current_tariff.tariff |
|||
abon.save(update_fields=('last_connected_tariff',)) |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('tariff_app', '0003_auto_20181115_1206'), |
|||
('abonapp', '0007_auto_20181101_1545'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='abon', |
|||
name='last_connected_tariff', |
|||
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='tariff_app.Tariff', verbose_name='Last connected service'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='abonlog', |
|||
name='author', |
|||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL), |
|||
), |
|||
migrations.RunPython(fill_last_tariff) |
|||
] |
|||
@ -1,83 +0,0 @@ |
|||
#!/usr/bin/env php
|
|||
<?php |
|||
|
|||
define("API_AUTH_SECRET", "secret"); |
|||
define("SERVER_DOMAIN", 'http://localhost:8000'); |
|||
define('N', ' |
|||
'); |
|||
|
|||
|
|||
function calc_hash($str) |
|||
{ |
|||
$hash = bin2hex(mhash(MHASH_SHA256,$str)); |
|||
return $hash; |
|||
} |
|||
|
|||
|
|||
function make_sign($data) |
|||
{ |
|||
asort($data, SORT_STRING); |
|||
array_push($data, API_AUTH_SECRET); |
|||
$str_to_hash = join('_', $data); |
|||
return calc_hash($str_to_hash); |
|||
} |
|||
|
|||
|
|||
function send_to($data) |
|||
{ |
|||
$sign = make_sign($data); |
|||
$data['sign'] = $sign; |
|||
$url_params = http_build_query($data); |
|||
$r = file_get_contents(SERVER_DOMAIN."/abons/api/duplicate_pay/?".$url_params); |
|||
return $r; |
|||
} |
|||
|
|||
|
|||
|
|||
function forward_pay_request($act, $pay_account, $service_id, $trade_point, $receipt_num, $pay_id, $pay_amount) |
|||
{ |
|||
require('./users_uname_pk_pairs.php'); |
|||
|
|||
// $user_id_pairs
|
|||
|
|||
if($act == 1) |
|||
{ |
|||
$pay = [ |
|||
"ACT" => 1, |
|||
"PAY_ACCOUNT" => $user_id_pairs[$pay_account] |
|||
]; |
|||
return send_to($pay); |
|||
}else if($act == 4) |
|||
{ |
|||
$pay = [ |
|||
"ACT" => 4, |
|||
"PAY_ACCOUNT" => $user_id_pairs[$pay_account], |
|||
"TRADE_POINT" => $trade_point, |
|||
"RECEIPT_NUM" => $receipt_num, |
|||
"PAY_ID" => $pay_id, |
|||
"PAY_AMOUNT" => $pay_amount, |
|||
"SERVICE_ID" => $service_id |
|||
]; |
|||
return send_to($pay); |
|||
}else if($act == 7) |
|||
{ |
|||
$pay = [ |
|||
"ACT" => 7, |
|||
"PAY_ID" => $pay_id, |
|||
"SERVICE_ID" => $service_id |
|||
]; |
|||
return send_to($pay); |
|||
} |
|||
|
|||
} |
|||
|
|||
# Request
|
|||
echo forward_pay_request(1, '1234', null, null, null, null, null); |
|||
|
|||
# Add cash
|
|||
echo forward_pay_request('4', '1234', 'mypaysrv', '3432', '289473', '897879-989-68669', '1'); |
|||
|
|||
# check cash
|
|||
echo forward_pay_request(7, null, 'mypaysrv', null, null, '897879-989-68669', null); |
|||
|
|||
?>
|
|||
@ -0,0 +1,17 @@ |
|||
# Generated by Django 2.1 on 2018-11-15 12:06 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('tariff_app', '0002_auto_20180807_1548'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterModelOptions( |
|||
name='periodicpay', |
|||
options={'ordering': ('-id',), 'verbose_name': 'Periodic pay', 'verbose_name_plural': 'Periodic pays'}, |
|||
), |
|||
] |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue