stanley-king 1 mesiac pred
rodič
commit
fc9f8df2cb

+ 10 - 4
helper/refill/CalcMerchantPrice.php

@@ -107,19 +107,25 @@ class CalcMerchantMixedPrice implements ICalc
 
 class ZeroMerchantPrice implements ICalc
 {
-    public function __construct($mchid,$amount,$card_type,$quality)
-    {
+    private $mMchAmount;
+    private $mQuantity;
 
+    public function __construct(order $order)
+    {
+        $this->mMchAmount = $order->mch_amount();
+        $quantity = $order->quantity();
+        $quantity = intval($quantity);
+        $this->mQuantity = $quantity <= 0 ? 1 : $quantity;
     }
 
     public function calc_vgoods_price($goods_info)
     {
-        return round(0,4);
+        return round($this->mMchAmount / $this->mQuantity,4);
     }
 
     public function calc_vorder_amount($order_info)
     {
-        return round(0,4);
+        return round($this->mMchAmount,4);
     }
 
     public function calc_tips()

+ 1 - 13
helper/refill/RefillBase.php

@@ -362,19 +362,7 @@ class RefillBase
         $buyer_id = $order->buyer_id();
         $minfo = new member_info($order->buyer_id());
 
-
-//        try
-//        {
-//            $calc = $this->getMerchantPriceCalc($order);
-//            $mch_price = $calc->calc_vgoods_price([]);
-//            $mch_amount = $mch_price * $order->quantity();
-//        }
-//        catch (Exception $ex) {
-//            $mch_price = 0.00;
-//            $mch_amount = 0.00;
-//        }
-
-        $calc = new ZeroMerchantPrice($order->mchid(), $order->spec(), $order->card_type(),$order->cur_quality());
+        $calc = new ZeroMerchantPrice($order);
         $mch_amount = $calc->calc_vgoods_price([]);
 
         $input['goods_id'] = ZERO_GOODS_ID;