123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace refill\rsanfang;
- require_once(BASE_HELPER_RAPI_PATH . '/rsanfang/config.php');
- use refill;
- class RefillPhone extends refill\IRefillThird
- {
- public function __construct($cfgs)
- {
- parent::__construct($cfgs);
- }
- private function getProductCode($goods_id, $sys_pcode)
- {
- $thrid_refill = Model('thrid_refill');
- $store_id = $this->mStoreID;
- $product = $thrid_refill->getProviderProduct($store_id, $goods_id, $sys_pcode);
- if (empty($product)) {
- return false;
- } else {
- return $product['channel_code'];
- }
- }
- //启用主动查询功能
- public function callback() {
- return false;
- }
- public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
- {
- $order_sn = $params['order_sn'];
- $goods_id = intval($params['goods_id']);
- $channel_code = $this->getProductCode($goods_id, $params['product_code']);
- if (empty($channel_code)) {
- return [false, '产品有误', false];
- }
- $mchid = $params['mchid'];
- $times = config::getTimes($channel_code);
- if($times <= 0) {
- return [false, '产品有误', false];
- }
- $model_merchant = Model('merchant');
- $data = [
- 'query_total_times' => ['exp', "query_total_times+$times"],
- 'query_left_times' => ['exp', "query_left_times+$times"]
- ];
- $ret = $model_merchant->editMerchant($data, ['mchid' => $mchid]);
- if($ret) {
- return [true, $order_sn, false];
- } else {
- return [true, '更新数据库出错', false];
- }
- }
- public function query($refill_info): array
- {
- $order_sn = $refill_info['order_sn'];
- $ch_trade_no = $refill_info['ch_trade_no'];
- if ($order_sn == $ch_trade_no) {
- return [true, ORDER_STATE_SUCCESS, ''];
- } else {
- return [true, ORDER_STATE_SEND, ''];
- }
- }
- public function balance(): array
- {
- return [true, 0];
- }
- }
|