| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * Created by PhpStorm.
- * Member: tianyi
- * Date: 2018/4/11
- * Time: 17:42
- */
- try {
- $phone = safeCheck($_POST["phone"], 0);
- $wxopenid = safeCheck($_POST["wxopenid"], 0);
- $name = safeCheck($_POST["name"], 0);
- $sex = safeCheck($_POST["sex"], 0);
- $province = safeCheck($_POST["province"], 0);
- $city = safeCheck($_POST["city"], 0);
- $detailaddress = safeCheck($_POST["detailaddress"], 0);
- $hangye = safeCheck($_POST["hangye"], 0);
- $province = ($province > 0) ? $province : 0;
- $city = ($city > 0) ? $city : 0;
- $hangye = ($hangye > 0) ? $hangye : 0;
- //检查
- if (!ParamCheck::is_mobile($phone)) {
- echo action_msg('电话号码格式错误', 101);
- exit;
- }
- if (empty($name)) {
- echo action_msg('请填写姓名', 102);
- exit;
- }
- if (!in_array($sex, array(0, 1))) {
- echo action_msg('性别错误', 103);
- exit;
- }
- if (empty($wxopenid)) {
- echo action_msg('微信opeid不能为空', 104);
- exit;
- }
- if (empty($province)) {
- echo action_msg('请填写省份', 105);
- exit;
- }
- // if (empty($city)) {
- // echo action_msg('请填写城市', 106);
- // exit;
- // }
- if (empty($hangye)) {
- echo action_msg('请选择行业', 107);
- exit;
- }
- //添加不存在的客户
- $guest = Common_guest::getInfoByPhone($phone);
- if (empty($guest)) {
- //增加新用户
- $attr['phone'] = $phone;
- $attr['wxopenid'] = $wxopenid;
- $attr['name'] = $name;
- $attr['sex'] = $sex;
- $attr['province'] = $province;
- $attr['city'] = $city;
- $attr['detailaddress'] = $detailaddress;
- $attr['hangye_id'] = $hangye;
- $id = Common_guest::add($attr);
- if (empty($id)) {
- echo action_msg('新增普通客户失败', 103);
- exit;
- }
- } else {
- $id = $guest['id'];
- }
- $ret = Common_guest::getPassInfo($id);
- echo action_msg($ret, 200);
- } catch (MyException $e) {
- echo action_msg($e->getMessage(), $e->getCode());
- }
- ?>
|