|
@@ -215,6 +215,110 @@ class refillControl extends merchantControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function check_electirc($params)
|
|
|
+ {
|
|
|
+ if(empty($params['notifyurl'])) {
|
|
|
+ return [false,'参数没有包含notifyurl'];
|
|
|
+ }
|
|
|
+ if(empty($params['order_sn'])) {
|
|
|
+ return [false,'参数没有包含贵方唯一订单号:order_sn'];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($params['amount']) || intval($params['amount']) <= 0) {
|
|
|
+ return [false,'参数没有包含充值金额:amount'];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($params['company_type']) || !in_array($params['company_type'],mtopcard\ElectricCompanyTypes)) {
|
|
|
+ return [false,'没有电卡类型参数(nation,south)'];
|
|
|
+ }
|
|
|
+ if(empty($params['use_type']) || !in_array($params['use_type'],mtopcard\ElectricUseTypes)) {
|
|
|
+ return [false,"没有电卡用途参数(home,commerce,pedlar)"];
|
|
|
+ }
|
|
|
+ if(empty($params['province']) || !array_key_exists($params['province'],mtopcard\ProvinceList)) {
|
|
|
+ return [false,"请传入省份"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if($params['company_type'] === 'south')
|
|
|
+ {
|
|
|
+ $card_id = $params['card_id'];
|
|
|
+ if(empty($card_id) || strlen($card_id) != mtopcard\CardidVerifyLength || !mtopcard\is_alpha($card_id)) {
|
|
|
+ return [false,"请传入正确的身份证后6位"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true,""];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function add_electricOp()
|
|
|
+ {
|
|
|
+ [$success,$error] = $this->check_electirc($_GET);
|
|
|
+ if($success === false) {
|
|
|
+ return self::outerr(201,$error);
|
|
|
+ }
|
|
|
+
|
|
|
+ $notify_url = $_GET['notifyurl'];
|
|
|
+ $mch_order = $_GET['order_sn']; //对方的order编号
|
|
|
+
|
|
|
+ $card_no = $_GET['cardno'] ?? '';
|
|
|
+
|
|
|
+ $quantity = 1;
|
|
|
+ $third_card_type = mtopcard\ThirdCardElect;
|
|
|
+ $company_type = $_GET['company_type'];
|
|
|
+ $use_type = $_GET['use_type'];
|
|
|
+ $province = intval($_GET['province']);
|
|
|
+ $amount = intval($_GET['amount']);
|
|
|
+
|
|
|
+ if($company_type == 'nation') {
|
|
|
+ $card_id = '';
|
|
|
+ } else {
|
|
|
+ $card_id = $_GET['card_id'] ?? '';
|
|
|
+ }
|
|
|
+
|
|
|
+// $product_code = mtopcard\electric_product_code($company_type,$use_type,$amount);
|
|
|
+ $product_code = 'XYZ100744';
|
|
|
+ $amount = refill\util::ThirdRefillAmount;
|
|
|
+
|
|
|
+
|
|
|
+ //三方充值没有质量
|
|
|
+ $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,
|
|
|
+
|
|
|
+ 'company_type' => $company_type,
|
|
|
+ 'use_type' => $use_type,
|
|
|
+ 'province' => $province,
|
|
|
+ 'card_id' => $card_id
|
|
|
+ ];
|
|
|
+
|
|
|
+ refill\util::push_queue_order($this->mchid(),$mch_order,ORDER_STATE_QUEUE);
|
|
|
+ Model('refill_order')->add_detail($this->mchid(),$mch_order,$params,ORDER_STATE_QUEUE);
|
|
|
+
|
|
|
+ $state = refill\util::push_addthird($params);
|
|
|
+ if ($state === true) {
|
|
|
+ return self::outsuccess(['state' => true]);
|
|
|
+ } else {
|
|
|
+ refill\util::del_queue_order($this->mchid(),$mch_order);
|
|
|
+ Model('refill_order')->del_detail($this->mchid(),$mch_order);
|
|
|
+ return self::outerr(208, '提交失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private function can_refill($cardno)
|
|
|
{
|