|
@@ -14,6 +14,34 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
parent::__construct($cfgs);
|
|
|
}
|
|
|
|
|
|
+ public function goods($quality, int $amount, int $card_type, $regin_no, $other)
|
|
|
+ {
|
|
|
+ [$goods_id, $price] = parent::goods($quality, $amount, $card_type, $regin_no, $other);
|
|
|
+ if ($goods_id <= 0) return [0, 0];
|
|
|
+
|
|
|
+ $store_id = $this->mStoreID;
|
|
|
+ $pcode = $other['product_code'];
|
|
|
+ $thrid_refill = Model('thrid_refill');
|
|
|
+ $product = $thrid_refill->getProviderProduct($store_id, $goods_id, $pcode);
|
|
|
+ if (empty($product)) {
|
|
|
+ Log::record("cannot find provider's produce where name={$this->mName}, goods_id = {$goods_id} pcode={$pcode}", Log::ERR);
|
|
|
+ return [0, 0];
|
|
|
+ } else {
|
|
|
+ return [$goods_id, ncPriceFormat($product['channel_amount'])];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getProductAmount($sys_pcode)
|
|
|
+ {
|
|
|
+ $thrid_refill = Model('thrid_refill');
|
|
|
+ $product = $thrid_refill->getProduct(['system_code' => $sys_pcode]);
|
|
|
+ if (empty($product)) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return $product['refill_amount'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private function req_params(int $phone, int $amount, string $order_sn)
|
|
|
{
|
|
|
$params['mId'] = config::MCH_ID;
|
|
@@ -29,7 +57,12 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
|
|
|
public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
|
|
|
{
|
|
|
+ $amount = $this->getProductAmount($params['product_code']);
|
|
|
+ if(empty($amount)) {
|
|
|
+ return [false, '产品未开启', false];
|
|
|
+ }
|
|
|
$params = $this->req_params($card_no, $amount, $params['order_sn']);
|
|
|
+
|
|
|
$sign = $this->sign($params);
|
|
|
$params['sign'] = $sign;
|
|
|
|