1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?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,2);
- }
- public function calc_vorder_amount($order_info)
- {
- $num = $order_info['quantity'];
- return round($this->mPrice * $num,2);
- }
- 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,2);
- }
- public function calc_vorder_amount($order_info)
- {
- return round(0,2);
- }
- public function calc_tips()
- {
- Log::record("没有实现该接口" . __FUNCTION__ ,Log::ERR);
- return [];
- }
- }
|