Finance.php 1.26 KB
<?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);
	}

}