Finance.php
1.26 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
51
52
53
54
55
56
57
<?php
defined('IN_IA') or exit('Access Denied');
class Finance
{
/**
* 平台服务费 ,以元为单位
* @param $storeId 预留
* @param $price
* @return int
*/
static function platformServiceFee($price, $storeId = 0)
{
if ($price <=0) {
return 0;
} elseif($price > 0 and $price < 30) {
return 0;
} elseif ($price >= 30) {
return 1;
}
}
static function wxPayFee()
{
return 0.006;
}
/**
* @param $postData
* @return bool
*/
static function addOrderPriceStat($postData)
{
$tt = time();
$postData['created_at'] = $tt;
$postData['updated_at'] = $tt;
$postData['wx_pay_fee'] = $postData['pay_price'] * self::wxPayFee();
$postData['service_fee'] = self::platformServiceFee($postData['pay_price']);
return pdo_insert('cjdc_order_price_stat', $postData);
}
/**
* @param $storeId
* @param $orderId
* @param $orderType
* @param $refundPrice
* @return bool
*/
static function updateOrderPriceStat($storeId, $orderId, $refundPrice, $orderType = '')
{
$tt = time();
$updateData = ['refund_price' => $refundPrice, 'refund_time' => $tt,'updated_at' => $tt];
$condition = ['store_id' => $storeId, 'order_id' => $orderId, 'refund_price' => 0];
return pdo_update('cjdc_order_price_stat', $updateData, $condition);
}
}