|
@@ -7,31 +7,47 @@ class retailControl extends vbaseControl
|
|
parent::__construct();
|
|
parent::__construct();
|
|
}
|
|
}
|
|
|
|
|
|
- public function retail_recordOp()
|
|
|
|
|
|
+ private function check_params($params)
|
|
{
|
|
{
|
|
- $channel_code = $_POST['channel_code'];
|
|
|
|
|
|
+ $channel_code = $params['channel_code'];
|
|
if(empty($channel_code)) {
|
|
if(empty($channel_code)) {
|
|
- return self::outerr(300,"渠道信息有误.");
|
|
|
|
|
|
+ return [false, "渠道信息有误."];
|
|
}
|
|
}
|
|
- $province = $_POST['province'] ?? '';
|
|
|
|
- $city = $_POST['city'] ?? '';
|
|
|
|
- $area = $_POST['area'] ?? '';
|
|
|
|
- $address = $_POST['address'] ?? '';
|
|
|
|
|
|
+ $province = $params['province'] ?? '';
|
|
|
|
+ $city = $params['city'] ?? '';
|
|
|
|
+ $area = $params['area'] ?? '';
|
|
|
|
+ $address = $params['address'] ?? '';
|
|
if(empty($province) || empty($city) || empty($area) || empty($address)) {
|
|
if(empty($province) || empty($city) || empty($area) || empty($address)) {
|
|
- return self::outerr(300,"地址信息有误.");
|
|
|
|
|
|
+ return [false, "地址信息有误."];
|
|
}
|
|
}
|
|
|
|
|
|
- $applicant_name = $_POST['applicant_name'];
|
|
|
|
- $contact_phone = $_POST['contact_phone'];
|
|
|
|
|
|
+ $applicant_name = $params['applicant_name'];
|
|
|
|
+ $contact_phone = $params['contact_phone'];
|
|
if(empty($applicant_name) || empty($contact_phone)) {
|
|
if(empty($applicant_name) || empty($contact_phone)) {
|
|
- return self::outerr(300,"联系人信息有误.");
|
|
|
|
|
|
+ return [false, "联系人信息有误."];
|
|
|
|
+ }
|
|
|
|
+ if(!preg_match('/^1\d{10}$/', $contact_phone)) {
|
|
|
|
+ return [false, "联系人电话格式有误."];
|
|
|
|
+ }
|
|
|
|
+ $retail = Model('')->table('retail')->where(['contact_phone' => $contact_phone])->find();
|
|
|
|
+ if(!empty($retail)) {
|
|
|
|
+ return [false, "此联系电话已申请过."];
|
|
}
|
|
}
|
|
|
|
|
|
- $params = [
|
|
|
|
|
|
+ $insert = [
|
|
'channel_code' => $channel_code, 'province' => $province, 'city' => $city, 'area' => $area,
|
|
'channel_code' => $channel_code, 'province' => $province, 'city' => $city, 'area' => $area,
|
|
'address' => $address, 'applicant_name' => $applicant_name, 'contact_phone' => $contact_phone,
|
|
'address' => $address, 'applicant_name' => $applicant_name, 'contact_phone' => $contact_phone,
|
|
'create_time' => time(), 'retail_sn' => $this->make_sn()
|
|
'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);
|
|
$resp = Model('')->table('retail')->insert($params);
|
|
if ($resp) {
|
|
if ($resp) {
|