table('retail')->where(['contact_phone' => $contact_phone])->find(); if(!empty($retail)) { return [false, "此联系电话已申请过."]; } $id_card = $_POST['id_card']; if (!preg_match('#^\d{17}(\d|X)$#', $id_card)) { return [false, "身份证号格式错误."]; } $insert = [ 'channel_code' => $channel_code, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'applicant_name' => $applicant_name, 'contact_phone' => $contact_phone, 'id_card' => $id_card, 'create_time' => time(), 'retail_sn' => $this->make_sn() ]; return [true, $insert]; } public function retail_recordOp() { [$success, $params] = $this->check_params($_POST); if ($success === false) { return self::outerr(300, $params); } $resp = Model('')->table('retail')->insert($params); if ($resp) { $sapi = new sapi(); $body = ['pageId' => $_POST['pageId'], 'tid' => $_POST['tid'], 'lbid' => $_POST['lbid']]; $resp = $sapi->send($body); Log::record("sapi result {$resp}", Log::DEBUG); return self::outsuccess([]); } else { return self::outerr(301, "录入信息失败."); } } private function make_sn() { return 'CARD' . mt_rand(1000, 9999) . sprintf('%010d', time()) . sprintf('%06d', (float)microtime() * 1000000); } }