|
@@ -125,6 +125,85 @@ class refillControl extends merchantControl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private function check_third($params)
|
|
|
|
+ {
|
|
|
|
+ if(empty($params['product_code'])) {
|
|
|
|
+ return [false,'参数没有包含product_code'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $pcode = $params['product_code'];
|
|
|
|
+ if($this->check_pcode($pcode)) {
|
|
|
|
+ return [false,"对应的产品编码{$pcode}"];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(empty($params['quantity']) || intval($params['quantity']) < 1) {
|
|
|
|
+ return [false,"购买数量参数不存在,或者小于0"];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(empty($params['notifyurl'])) {
|
|
|
|
+ return [false,'参数没有包含notifyurl'];
|
|
|
|
+ }
|
|
|
|
+ if(empty($params['order_sn'])) {
|
|
|
|
+ return [false,'参数没有包含贵方唯一订单号:order_sn'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return [true,""];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function check_pcode($pcode)
|
|
|
|
+ {
|
|
|
|
+ $mod_third = Model('thrid_refill');
|
|
|
|
+ $product = $mod_third->getProduct(['system_code' => $pcode]);
|
|
|
|
+ return !empty($product);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function add_thirdOp()
|
|
|
|
+ {
|
|
|
|
+ [$success,$error] = $this->check_third($_GET);
|
|
|
|
+ if($success === false) {
|
|
|
|
+ return self::outerr(201,$error);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $amount = refill\util::ThirdRefillAmount;
|
|
|
|
+ $notify_url = $_GET['notifyurl'];
|
|
|
|
+ $mch_order = $_GET['order_sn']; //对方的order编号
|
|
|
|
+
|
|
|
|
+ $product_code = $_GET['product_code'];
|
|
|
|
+ $card_no = $_GET['cardno'] ?? '';
|
|
|
|
+ $quantity = $_GET['quantity'];
|
|
|
|
+ $third_card_type = $_GET['card_type'] ?? 1;
|
|
|
|
+
|
|
|
|
+ //三方充值没有质量
|
|
|
|
+ $quality = 1;
|
|
|
|
+ $card_type = mtopcard\ThirdRefillCard;
|
|
|
|
+
|
|
|
|
+ if(!$this->check_mchorder($this->mchid(),$mch_order)) {
|
|
|
|
+ return self::outerr(205,"客户订单号重复或者为空.");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $params = ['mchid' => $this->mchid(),
|
|
|
|
+ 'buyer_id' => $this->adminid(),
|
|
|
|
+ 'amount' => $amount,
|
|
|
|
+ 'mch_order' => $mch_order,
|
|
|
|
+ 'notify_url' => $notify_url,
|
|
|
|
+ 'org_quality' => $quality,
|
|
|
|
+ 'card_type' => $card_type,
|
|
|
|
+ 'card_no' => $card_no,
|
|
|
|
+ 'product_code' => $product_code,
|
|
|
|
+ 'quantity' => $quantity,
|
|
|
|
+ 'third_card_type' => $third_card_type
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $state = refill\util::push_addthird($params);
|
|
|
|
+ if ($state === true) {
|
|
|
|
+ return self::outsuccess(['state' => true]);
|
|
|
|
+ } else {
|
|
|
|
+ $code = $state;
|
|
|
|
+ return self::outerr($code, '提交失败');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
private function can_refill($cardno)
|
|
private function can_refill($cardno)
|
|
{
|
|
{
|
|
$card_info = refill\util::read_card($cardno);
|
|
$card_info = refill\util::read_card($cardno);
|