123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace refill;
- require_once (BASE_HELPER_PATH . '/icalc.php');
- use ICalc;
- use Exception;
- use Log;
- class CalcMerchantPrice implements ICalc
- {
- private $mPrice;
- public function __construct($mchid,$spec,$card_type,$quality,$policy,$other = [])
- {
- if(empty($other) || empty($other['product_code'])) {
- $pcode = '';
- }
- else {
- $pcode = $other['product_code'];
- }
- $price = $policy->price($mchid,$spec,$card_type,$quality,$pcode);
- if ($price === false) {
- throw new Exception("没有协商商品购买价格.");
- } else {
- $this->mPrice = $price;
- }
- }
- public function calc_vgoods_price($goods_info)
- {
- return round($this->mPrice,4);
- }
- public function calc_vorder_amount($order_info)
- {
- $num = $order_info['quantity'];
- return round($this->mPrice * $num,4);
- }
- public function calc_tips()
- {
- Log::record("没有实现该接口" . __FUNCTION__ ,Log::ERR);
- return [];
- }
- }
- class ZeroMerchantPrice implements ICalc
- {
- public function __construct($mchid,$amount,$card_type,$quality)
- {
- }
- public function calc_vgoods_price($goods_info)
- {
- return round(0,4);
- }
- public function calc_vorder_amount($order_info)
- {
- return round(0,4);
- }
- public function calc_tips()
- {
- Log::record("没有实现该接口" . __FUNCTION__ ,Log::ERR);
- return [];
- }
- }
|