Withdrawal.php
2.92 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Created by PhpStorm.
* User: scott
* Date: 3/30/20
* Time: 3:24 PM
*/
class Withdrawal
{
const STATUS_WAIT_APPROVE = 1;//待审核
const STATUS_APPROVE = 2;//通过
const STATUS_REJECT = 3;//拒绝
/**
* @param $id
* @return bool
*/
static function rejectWithdrawal($id)
{
$res = pdo_update('cjdc_withdrawal', array('state'=> self::STATUS_REJECT, 'sh_time' => date('Y-m-d H:i:s')), array('id' => $id));
return $res;
}
/**
* @param $storeId
* @param $status
* @return bool
*/
static function getWithdrawalMoney($uniacid, $storeId, $status)
{
return pdo_get('cjdc_withdrawal', array('store_id' => $storeId,'uniacid' => $uniacid, 'state '=> $status ), array('sum(tx_cost) as tx_cost'));
}
/**
* 提现中的金额
* @param $storeId
* @return bool
*/
static function getWithdrawalingMoney($uniacid, $storeId)
{
return self::getWithdrawalMoney($uniacid, $storeId, self::STATUS_WAIT_APPROVE);
}
/**
* @param $storeId
* @return bool
*/
static function getWithdrawaledMoney($uniacid, $storeId)
{
return self::getWithdrawalMoney($uniacid, $storeId, self::STATUS_APPROVE);
}
/**
* 计算商店商品收入金额,非退款的金额
* @param $uniacid
* @param $storeId
* @return bool
*/
static function storeOrdersAmount($uniacid, $storeId)
{
//cjdc_order_price_stat
$where = " where a.uniacid=:uniacid and a.store_id=:store_id and a.pay_type in (1,2) and a.state in (4,5,10)";
$selectSQL = "select sum(ops.pay_price) as 'pay_price',sum(ops.goods_price) as goods_price, sum(ops.service_fee) as service_fee, sum(ops.wx_pay_fee) as wx_pay_fee ".
" from ". tablename("cjdc_order") ." as a".
" left join ". tablename("cjdc_order_price_stat") ." as ops on ops.order_id = a.id".
$where;
$params = [':uniacid' => $uniacid, ':store_id' => $storeId];
$totalAmount = pdo_fetch($selectSQL, $params);
return $totalAmount;
}
/**
* 未结算的金额
* @param $uniacid
* @param $storeId
* @return bool
*/
static function storeOnWayAmount($uniacid, $storeId)
{
$where = " where a.uniacid=:uniacid and a.store_id=:store_id and a.pay_type in (1,2) and a.state in (2,3,8) ";
$selectSQL = "select sum(ops.pay_price) as 'pay_price',sum(ops.goods_price) as goods_price, sum(ops.service_fee) as service_fee, sum(ops.wx_pay_fee) as wx_pay_fee ".
" from ". tablename("cjdc_order") ." as a".
" left join ". tablename("cjdc_order_price_stat") ." as ops on ops.order_id = a.id".
$where;
$params = [':uniacid' => $uniacid, ':store_id' => $storeId];
$totalAmount = pdo_fetch($selectSQL, $params);
return $totalAmount;
}
}