|
@@ -1,6 +1,8 @@
|
|
|
<?php
|
|
|
|
|
|
require_once(BASE_PATH . '/control/signbase.php');
|
|
|
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
|
|
|
+require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
|
|
|
include(BASE_CONFIG_PATH . CONFIG_PREFIX . '/refill.ini.php');
|
|
|
require_once(BASE_HELPER_PATH . '/refill/ops/third_pcode.php');
|
|
|
|
|
@@ -68,4 +70,62 @@ class RemoteControl extends SignbaseControl
|
|
|
return $this->error(202,'异常,请看日志');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public function refillOp()
|
|
|
+ {
|
|
|
+ $pcode_checker = function ($pcode) {
|
|
|
+ $mod_third = Model('thrid_refill');
|
|
|
+ $product = $mod_third->getProduct(['system_code' => $pcode]);
|
|
|
+ return !empty($product);
|
|
|
+ };
|
|
|
+
|
|
|
+ $sn_maker = function () {
|
|
|
+ return mt_rand(1000, 9999)
|
|
|
+ . sprintf('%010d', time())
|
|
|
+ . sprintf('%06d', (float)microtime() * 1000000);
|
|
|
+ };
|
|
|
+
|
|
|
+ $params = $_REQUEST;
|
|
|
+ $product_code = $params['product_code'];
|
|
|
+ $card_no = $params['card_no'];
|
|
|
+ $mchid = $params['mch_id'];
|
|
|
+
|
|
|
+
|
|
|
+ if($pcode_checker($product_code) == false) {
|
|
|
+ return $this->error(203,"对应的产品编码{$product_code}不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ if (empty($merchant_info)) {
|
|
|
+ return $this->error(204,"用户不存在.");
|
|
|
+ }
|
|
|
+ if($merchant_info['manual_recharge'] != 1) {
|
|
|
+ return $this->error(205,"手动充值业务已被关闭,请联系管理员。");
|
|
|
+ }
|
|
|
+
|
|
|
+ $mch_order = $sn_maker();
|
|
|
+ $input = [
|
|
|
+ 'mchid' => $mchid,
|
|
|
+ 'buyer_id' => intval($merchant_info['admin_id']),
|
|
|
+ 'amount' => refill\util::ThirdRefillAmount,
|
|
|
+ 'mch_order' => $mch_order,
|
|
|
+ 'order_time' => time(),
|
|
|
+ 'notify_url' => "",
|
|
|
+ 'org_quality' => 1,
|
|
|
+ 'card_type' => mtopcard\ThirdRefillCard,
|
|
|
+ 'card_no' => $card_no,
|
|
|
+ 'product_code' => $product_code,
|
|
|
+ 'quantity' => 1,
|
|
|
+ 'third_card_type' => 1,
|
|
|
+ 'third_product_type' => mtopcard\ThirdOnlineProduct,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $state = refill\util::push_addthird($input);
|
|
|
+ if ($state) {
|
|
|
+ return $this->success(['order_sn' => $mch_order]);
|
|
|
+ } else {
|
|
|
+ return $this->error(206, "系统错误.");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|