-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchargesync.php
More file actions
50 lines (41 loc) · 1.75 KB
/
chargesync.php
File metadata and controls
50 lines (41 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* 付费平台记录同步
*/
require_once 'lib/WriteLog.lib.php';
require_once 'tasks/charge/ChargeDb.class.php';
$jsonCharge = isset($_POST['transdata'])?$_POST['transdata']:'';
// $jsonCharge = '{"amt":"1.0","merid":"1001","mername":"测试","appid":"1001","appname":"应用场景","chargepoint":"","chargepointname":"","operators":"","orderdate":"2012-11-01 23:32:50","orderid":"121101233244538","ordersatus":"202","paytype":"100000000016","paytypename":"短信","phone":"","province":"","reqOrderId":"123456789","sign":"…………….."}';
if (empty($jsonCharge)) {
$jsonCharge = file_get_contents("php://input");
}
Log::write('chargesync:: jsonCharge:'.$jsonCharge, 'debug');
if (empty($jsonCharge)) {
Log::write('chargesync:: charge is empty', 'error');
$result = array('resultCode'=>300);
echo json_encode($result);
exit();
}
$chargeDb = new ChargeDb();
$jsonCharge = stripslashes($jsonCharge);
$arrChargeRecord = json_decode($jsonCharge, true);
$chargeDb->setNChargeRecord($arrChargeRecord);
$bResult = $chargeDb->recordNCharge();
if (! $bResult) {
Log::write('chargesync:: recordNCharge failed', 'error');
$result = array('resultCode'=>300);
echo json_encode($result);
exit();
}
require_once 'tasks/Exorder/ExorderRecordDb.class.php';
$exorder = isset($arrChargeRecord['reqOrderId']) ? $arrChargeRecord['reqOrderId'] : '';
$resultCode = (int)(isset($arrChargeRecord['ordersatus']) ? $arrChargeRecord['ordersatus'] : 0);
if (! empty($exorder) && $resultCode == 200) {
$erDb = new ExorderRecordDb();
$bResult = $erDb->updateMobileExorder($exorder, 0);
if (! $bResult) {
Log::write('chargesync_qiku updateMobileExorder() failed,exorder is '.$exorder, 'debug');
}
}
$result = array('resultCode'=>200);
echo json_encode($result);