Пример #1
0
 public function syn_data()
 {
     set_time_limit(0);
     es_session::close();
     //同步,supplier_location表, deal表, youhui表, event表 , supplier 表
     //总数
     $page = intval($_REQUEST['p']) == 0 ? 1 : intval($_REQUEST['p']);
     if ($page == 1) {
         syn_dealing();
     }
     $page_size = 5;
     $location_total = M("SupplierLocation")->count();
     $deal_total = M("Deal")->count();
     $youhui_total = M("Youhui")->count();
     $event_total = M("Event")->count();
     $supplier_total = M("Supplier")->count();
     $count = max(array($location_total, $deal_total, $youhui_total, $event_total, $supplier_total));
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $location_list = M("SupplierLocation")->limit($limit)->findAll();
     foreach ($location_list as $v) {
         recount_supplier_data_count($v['id'], "tuan");
         recount_supplier_data_count($v['id'], "youhui");
         recount_supplier_data_count($v['id'], "daijin");
         recount_supplier_data_count($v['id'], "event");
         recount_supplier_data_count($v['id'], "shop");
         syn_supplier_location_match($v['id']);
     }
     $supplier_list = M("Supplier")->limit($limit)->findAll();
     foreach ($supplier_list as $v) {
         syn_supplier_match($v['id']);
     }
     $deal_list = M("Deal")->limit($limit)->findAll();
     foreach ($deal_list as $v) {
         syn_deal_match($v['id']);
     }
     $youhui_list = M("Youhui")->limit($limit)->findAll();
     foreach ($youhui_list as $v) {
         syn_youhui_match($v['id']);
     }
     $event_list = M("Event")->limit($limit)->findAll();
     foreach ($youhui_list as $v) {
         syn_event_match($v['id']);
     }
     if ($page * $page_size >= $count) {
         $this->assign("jumpUrl", U("Cache/index"));
         $ajax = intval($_REQUEST['ajax']);
         $data['status'] = 1;
         $data['info'] = "<div style='line-height:50px; text-align:center; color:#f30;'>同步成功</div><div style='text-align:center;'><input type='button' onclick='\$.weeboxs.close();' class='button' value='关闭' /></div>";
         header("Content-Type:text/html; charset=utf-8");
         exit(json_encode($data));
     } else {
         $total_page = ceil($count / $page_size);
         $data['status'] = 0;
         $data['info'] = "共" . $total_page . "页,当前第" . $page . "页,等待更新下一页记录";
         $data['url'] = U("Cache/syn_data", array("p" => $page + 1));
         header("Content-Type:text/html; charset=utf-8");
         exit(json_encode($data));
     }
 }
 public function update()
 {
     B('FilterString');
     $data = M(MODULE_NAME)->create();
     $log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("name");
     //开始验证有效性
     $this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
     if (!check_empty($data['name'])) {
         $this->error(L("LOCATION_NAME_EMPTY_TIP"));
     }
     if ($data['supplier_id'] == 0) {
         $this->error(L("SUPPLIER_NOT_EXIST"));
     }
     // 更新数据
     $list = M(MODULE_NAME)->save($data);
     if (false !== $list) {
         M("SupplierLocationAreaLink")->where("location_id=" . $data['id'])->delete();
         $area_ids = $_REQUEST['area_id'];
         foreach ($area_ids as $area_id) {
             $area_data['area_id'] = $area_id;
             $area_data['location_id'] = $data['id'];
             M("SupplierLocationAreaLink")->add($area_data);
         }
         M("SupplierLocationBrandLink")->where("location_id=" . $data['id'])->delete();
         $brand_ids = $_REQUEST['brand_id'];
         foreach ($brand_ids as $brand_id) {
             $brand_data['brand_id'] = $brand_id;
             $brand_data['location_id'] = $data['id'];
             M("SupplierLocationBrandLink")->add($brand_data);
         }
         M("DealCateTypeLocationLink")->where("location_id=" . $data['id'])->delete();
         foreach ($_REQUEST['deal_cate_type_id'] as $type_id) {
             $link_data = array();
             $link_data['deal_cate_type_id'] = $type_id;
             $link_data['location_id'] = $data['id'];
             M("DealCateTypeLocationLink")->add($link_data);
         }
         M("SupplierTagGroupPreset")->where("supplier_location_id=" . $data['id'])->delete();
         $group_ids = $_REQUEST['group_id'];
         foreach ($group_ids as $gid => $preset) {
             if (trim($preset) != '') {
                 $link['group_id'] = $gid;
                 $link['supplier_location_id'] = $data['id'];
                 $link['preset'] = trim($preset);
                 M("SupplierTagGroupPreset")->add($link);
             }
         }
         $show_group_ids = $_REQUEST['show_group_id'];
         $exist_tags_array = array("''");
         foreach ($show_group_ids as $gid => $row) {
             if (trim($row) != '') {
                 $show_tags_array = preg_split("[ |,]", $row);
                 foreach ($show_tags_array as $kk => $rr) {
                     $rs = explode("|", $rr);
                     $tag = trim($rs[0]);
                     $count = intval($rs[1]);
                     $exist_tags_array[] = "'" . $tag . "'";
                     $tag_rs = M("SupplierTag")->where("tag_name = '" . $tag . "' and supplier_location_id = " . $data['id'] . " and group_id = " . $gid)->find();
                     if ($tag_rs) {
                         $tag_rs['total_count'] = $count;
                         $GLOBALS['db']->query("update " . DB_PREFIX . "supplier_tag set total_count = " . $count . " where tag_name = '" . $tag . "' and supplier_location_id = " . $data['id'] . " and group_id = " . $gid);
                     } else {
                         if (trim($tag) != '') {
                             $tag_rs = array();
                             $tag_rs['tag_name'] = $tag;
                             $tag_rs['supplier_location_id'] = $data['id'];
                             $tag_rs['group_id'] = $gid;
                             $tag_rs['total_count'] = $count;
                             M("SupplierTag")->add($tag_rs);
                         }
                     }
                 }
             }
         }
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "supplier_tag where tag_name not in (" . implode(",", $exist_tags_array) . ") and supplier_location_id = " . $data['id']);
         syn_supplier_location_match($data['id']);
         clear_auto_cache("static_goods_info");
         //成功提示
         save_log($log_info . L("UPDATE_SUCCESS"), 1);
         $this->success(L("UPDATE_SUCCESS"));
     } else {
         //错误提示
         save_log($log_info . L("UPDATE_FAILED"), 0);
         $this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
     }
 }
 public function update()
 {
     B('FilterString');
     $data = M("SupplierSubmit")->getById(intval($_REQUEST['id']));
     if (!$data) {
         $this->error("非法的数据");
     }
     //已有商家,只同步一份管理员
     $user_info = M("User")->getById($data['user_id']);
     $account = M("SupplierAccount")->where("account_name='" . $user_info['merchant_name'] . "'")->find();
     $location_info = M("SupplierLocation")->getById($data['location_id']);
     if ($account && $location_info) {
         //已经绑定过商户
         if ($account['supplier_id'] != $location_info['supplier_id']) {
             $this->error("该会员已经是其他商户的管理员,请手动创建");
         }
     }
     $cate_config = unserialize($data['cate_config']);
     $data['deal_cate_id'] = $cate_config['deal_cate_id'];
     $data['deal_cate_type_list'] = $cate_config['deal_cate_type_id'];
     $data['area_list'] = unserialize($data['location_config']);
     if ($data['location_id'] == 0) {
         $supplier_id = intval($_REQUEST['supplier_id']);
         if ($supplier_id == 0) {
             //先创建商户
             $supplier_info['name'] = $data['name'];
             $supplier_info['bank_info'] = $data['h_bank_info'];
             $supplier_info['bank_user'] = $data['h_bank_user'];
             $supplier_info['bank_name'] = $data['h_bank_name'];
             $supplier_info['preview'] = $data['h_supplier_logo'];
             $supplier_id = M("Supplier")->add($supplier_info);
             $location_info['is_main'] = 1;
         }
         $location_info['name'] = $data['name'];
         $location_info['address'] = $data['address'];
         $location_info['tel'] = $data['tel'];
         $location_info['xpoint'] = $data['xpoint'];
         $location_info['ypoint'] = $data['ypoint'];
         $location_info['supplier_id'] = $supplier_id;
         $location_info['open_time'] = $data['open_time'];
         $location_info['city_id'] = $data['city_id'];
         $location_info['deal_cate_id'] = $data['deal_cate_id'];
         $location_info['preview'] = $data['h_supplier_image'];
         $location_info['is_effect'] = 1;
         $location_info['xpoint'] = !empty($data['xpoint']) ? $data['xpoint'] : '119.025595';
         $location_info['ypoint'] = !empty($data['ypoint']) ? $data['ypoint'] : '33.596043';
         $location_info['location'] = 'GeomFromText("POINT(' . $data['xpoint'] . ' ' . $data['ypoint'] . ')")';
         $location_info['location_id'] = M("SupplierLocation")->add($location_info);
         foreach ($data['deal_cate_type_list'] as $deal_cate_type_id) {
             $link = array();
             $link['location_id'] = $data['location_id'];
             $link['deal_cate_type_id'] = $deal_cate_type_id;
             M("DealCateTypeLocationLink")->add($link);
         }
         foreach ($data['area_list'] as $area_id) {
             $link = array();
             $link['location_id'] = $data['location_id'];
             $link['area_id'] = $area_id;
             M("SupplierLocationAreaLink")->add($link);
         }
         syn_supplier_location_match($data['location_id']);
     }
     if ($data['location_id'] > 0) {
         if ($account) {
             $id = $account['id'];
             $link = array();
             $link['account_id'] = $id;
             $link['location_id'] = $data['location_id'];
             $rs = M("SupplierAccountLocationLink")->add($link);
             if ($rs) {
                 //认领成功,并同步营业执照
                 $location_info['biz_license'] = $data['h_license'];
                 $location_info['biz_other_license'] = $data['h_other_license'];
                 M("SupplierLocation")->save($location_info);
                 $this->assign("jumpUrl", u("SupplierLocation/edit", array("id" => $data['location_id'])));
                 M("SupplierSubmit")->where("id=" . intval($_REQUEST['id']))->setField("is_publish", 1);
                 save_log($data['name'] . "审核成功", 1);
                 $this->success("审核成功");
             } else {
                 $this->error("该会员已经是该商户的管理员");
             }
         } else {
             //会员未绑定商户,或绑定的不是同名商户管理员,创建一个商户管理员
             $account['account_name'] = $user_info['user_name'];
             $account['account_password'] = $user_info['user_pwd'];
             $account['supplier_id'] = $location_info['supplier_id'];
             $account['is_effect'] = 1;
             $account['description'] = $data['h_faren'] . "电话:" . $data['h_tel'];
             $account['update_time'] = get_gmtime();
             $id = M("SupplierAccount")->add($account);
             if ($id) {
                 //添加成功
                 $link = array();
                 $link['account_id'] = $id;
                 $link['location_id'] = $data['location_id'];
                 M("SupplierAccountLocationLink")->add($link);
                 //认领成功
                 $location_info['biz_license'] = $data['h_license'];
                 $location_info['biz_other_license'] = $data['h_other_license'];
                 M("SupplierLocation")->save($location_info);
                 $this->assign("jumpUrl", u("SupplierLocation/edit", array("id" => $data['location_id'])));
                 M("SupplierSubmit")->where("id=" . intval($_REQUEST['id']))->setField("is_publish", 1);
                 save_log($data['name'] . "审核成功", 1);
                 $user_info['is_merchant'] = 1;
                 $user_info['merchant_name'] = $account['account_name'];
                 M("User")->save($user_info);
                 $this->success("审核成功");
             } else {
                 $account = M("SupplierAccount")->where("account_name='" . $user_info['user_name'] . "'")->find();
                 if ($account['supplier_id'] == $location_info['supplier_id']) {
                     $link = array();
                     $link['account_id'] = $account['id'];
                     $link['location_id'] = $data['location_id'];
                     M("SupplierAccountLocationLink")->add($link);
                     if (M()->getDbError() != '') {
                         $this->error("该会员已经认领了");
                     } else {
                         $location_info['biz_license'] = $data['h_license'];
                         $location_info['biz_other_license'] = $data['h_other_license'];
                         M("SupplierLocation")->save($location_info);
                         $this->assign("jumpUrl", u("SupplierLocation/edit", array("id" => $data['location_id'])));
                         M("SupplierSubmit")->where("id=" . intval($_REQUEST['id']))->setField("is_publish", 1);
                         save_log($data['name'] . "审核成功", 1);
                         $this->success("审核成功");
                     }
                 }
                 $this->error("该会员已有同名的商户管理员,请手动创建");
             }
         }
     }
 }
Пример #4
0
 public function update()
 {
     B('FilterString');
     $data = M("SupplierSubmit")->getById(intval($_REQUEST['id']));
     if (!$data) {
         $this->error("非法的数据");
     }
     $cate_config = unserialize($data['cate_config']);
     $data['deal_cate_id'] = $cate_config['deal_cate_id'];
     $data['deal_cate_type_list'] = $cate_config['deal_cate_type_id'];
     $data['area_list'] = unserialize($data['location_config']);
     if ($data['location_id'] == 0) {
         $supplier_id = intval($_REQUEST['supplier_id']);
         if ($supplier_id == 0) {
             //先创建商户
             $supplier_info['name'] = $data['name'];
             $supplier_info['bank_info'] = $data['h_bank_info'];
             $supplier_info['bank_user'] = $data['h_bank_user'];
             $supplier_info['bank_name'] = $data['h_bank_name'];
             $supplier_info['preview'] = $data['h_supplier_logo'];
             //公司信息
             $supplier_info['h_name'] = $data['h_name'];
             $supplier_info['h_faren'] = $data['h_faren'];
             $supplier_info['h_tel'] = $data['h_tel'];
             $supplier_id = M("Supplier")->add($supplier_info);
             $location_info['is_main'] = 1;
         }
         $location_info['name'] = $data['name'];
         $location_info['address'] = $data['address'];
         $location_info['tel'] = $data['tel'];
         $location_info['xpoint'] = $data['xpoint'];
         $location_info['ypoint'] = $data['ypoint'];
         $location_info['supplier_id'] = $supplier_id;
         $location_info['open_time'] = $data['open_time'];
         $location_info['city_id'] = $data['city_id'];
         $location_info['deal_cate_id'] = $data['deal_cate_id'];
         $location_info['preview'] = $data['h_supplier_image'];
         $location_info['biz_license'] = $data['h_license'];
         $location_info['biz_other_license'] = $data['h_other_license'];
         $location_info['is_effect'] = 1;
         $data['location_id'] = M("SupplierLocation")->add($location_info);
         foreach ($data['deal_cate_type_list'] as $deal_cate_type_id) {
             $link = array();
             $link['location_id'] = $data['location_id'];
             $link['deal_cate_type_id'] = $deal_cate_type_id;
             M("DealCateTypeLocationLink")->add($link);
         }
         foreach ($data['area_list'] as $area_id) {
             $link = array();
             $link['location_id'] = $data['location_id'];
             $link['area_id'] = $area_id;
             M("SupplierLocationAreaLink")->add($link);
         }
         syn_supplier_location_match($data['location_id']);
     }
     if ($data['location_id'] > 0) {
         //会员未绑定商户,或绑定的不是同名商户管理员,创建一个商户管理员
         $account['account_name'] = $data['account_name'];
         $account['account_password'] = $data['account_password'];
         $account['supplier_id'] = $location_info['supplier_id'];
         $account['is_effect'] = 1;
         $account['description'] = $data['h_name'] . " 法人:" . $data['h_faren'] . " 电话:" . $data['h_tel'];
         $account['update_time'] = NOW_TIME;
         $account['mobile'] = $data['account_mobile'];
         $account['is_main'] = 1;
         $account['allow_delivery'] = 1;
         $account['allow_charge'] = 1;
         $id = M("SupplierAccount")->add($account);
         if ($id) {
             //添加成功
             $link = array();
             $link['account_id'] = $id;
             $link['location_id'] = $data['location_id'];
             M("SupplierAccountLocationLink")->add($link);
             //认领成功
             $location_info['biz_license'] = $data['h_license'];
             $location_info['biz_other_license'] = $data['h_other_license'];
             M("SupplierLocation")->save($location_info);
             $this->assign("jumpUrl", u("SupplierLocation/edit", array("id" => $data['location_id'])));
             M("SupplierSubmit")->where("id=" . intval($_REQUEST['id']))->setField("is_publish", 1);
             save_log($data['name'] . "审核成功", 1);
             if ($data['user_id'] > 0) {
                 $user_info = M("User")->getById($data['user_id']);
                 $user_info['is_merchant'] = 1;
                 $user_info['merchant_name'] = $account['account_name'];
                 M("User")->save($user_info);
             }
             $this->success("审核成功");
         } else {
             $this->error("审核失败,请联系系统管理员");
         }
     }
 }
Пример #5
0
 public function update()
 {
     if (intval($_POST['id']) == 0) {
         showErr($GLOBALS['lang']['ERROR_TITLE'], 0, url("biz", "profile"));
         exit;
     }
     $id = intval($_POST['id']);
     $s_account_info = es_session::get("account_info");
     $location_ids = $s_account_info['location_ids'];
     $info = $GLOBALS['db']->getRow(" SELECT * FROM " . DB_PREFIX . "supplier_location WHERE id = " . intval($id) . " and id in (" . implode(",", $s_account_info['location_ids']) . ")");
     if (!$info) {
         showErr("门店不存在或者没有编辑该门店的权限");
     }
     $data['preview'] = str_replace(get_domain() . APP_ROOT, ".", addslashes(htmlspecialchars(trim($_POST['preview']))));
     $data['tags'] = addslashes(htmlspecialchars(trim($_POST['tags'])));
     $data['address'] = addslashes(htmlspecialchars(trim($_POST['address'])));
     $data['route'] = addslashes(htmlspecialchars(trim($_POST['route'])));
     $data['tel'] = addslashes(htmlspecialchars(trim($_POST['tel'])));
     $data['contact'] = addslashes(htmlspecialchars(trim($_POST['contact'])));
     $data['open_time'] = addslashes(htmlspecialchars(trim($_POST['open_time'])));
     $data['api_address'] = addslashes(htmlspecialchars(trim($_POST['api_address'])));
     $data['xpoint'] = $_POST['xpoint'];
     $data['ypoint'] = $_POST['ypoint'];
     $data['sms_content'] = addslashes(htmlspecialchars(trim($_POST['sms_content'])));
     $data['brief'] = addslashes(trim(replace_public($_POST['brief'])));
     $data['brief'] = valid_tag($data['brief']);
     $data['id'] = intval($_POST['id']);
     $data['seo_title'] = addslashes(htmlspecialchars(trim($_POST['seo_title'])));
     $data['seo_keyword'] = addslashes(htmlspecialchars(trim($_POST['seo_keyword'])));
     $data['seo_description'] = addslashes(htmlspecialchars(trim($_POST['seo_description'])));
     $rs = $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location", $data, "UPDATE", " id = " . intval($_POST['id']));
     if ($rs) {
         //更新统计
         syn_supplier_locationcount($data);
         syn_supplier_location_match($data['id']);
         $cache_id = md5("store" . "view" . $data['id']);
         $GLOBALS['tmpl']->clear_cache('store_view.html', $cache_id);
         showSuccess($GLOBALS['lang']['SUPPLIER_MODIFY_SUCCESS'], 0, url("biz", "profile#modify", array("id" => intval($_POST['id']))));
     }
 }