/** * @brief 处理curd动作 * @return String */ public function curd() { $action = $this->id; $controller = $this->controller; $curdinfo = $this->initinfo(); if (is_array($curdinfo)) { $modelName = $curdinfo['model']; $key = $curdinfo['key']; $actions = $curdinfo['actions']; switch ($action) { case 'add': case 'upd': if (method_exists($controller, 'getValidate')) { $validate = $controller->getValidate(); } else { $validate = null; } if ($validate != null) { $formValidate = new IFormValidation($validate); $data = $formValidate->run(); } $model = new IModel($modelName); if (isset($data) && $data !== null) { $model->setData($data[$modelName]); if ($action = 'add') { $flag = $model->add(); } else { $flag = $model->upd("{$key} = '" . IReq::get($key) . "'"); } } if (isset($flag) && $flag) { $_GET['action'] = $actions['success']; } else { $_GET['action'] = $actions['fail']; } $controller->run(); return true; case 'del': $model = new IModel($modelName); $flag = $model->del("{$key} = '" . IReq::get($key) . "'"); if ($flag) { $_GET['action'] = $actions['success']; } else { $_GET['action'] = $actions['fail']; } $controller->run(); return true; case 'get': $model = new IModel($modelName); $rs = $model->getObj("{$key} = '" . IReq::get($key) . "'"); echo JSON::encode($rs); return false; } } }
/** * @brief 删除登记的到货通知邮件 */ function notify_del() { $notify_ids = IFilter::act(IReq::get('check'), 'int'); if ($notify_ids) { $ids = join(',', $notify_ids); $tb_notify = new IModel('notify_registry'); $where = "id in (" . $ids . ")"; $tb_notify->del($where); } $this->redirect('notify_list'); }
function registry_del() { $ids = IFilter::act(IReq::get('id'), 'int'); if (empty($ids)) { $this->redirect('registry_list', false); Util::showMessage('请选择要删除的邮箱'); exit; } if (is_array($ids)) { $ids = join(',', $ids); } $registryObj = new IModel('email_registry'); $registryObj->del('id in (' . $ids . ')'); $this->redirect('registry_list'); }
/** * 退订,并记录退订理由 * @param string $email * @param string $content 退订理由 * @static */ public static function unsubscribe($email, $content) { $email = addslashes($email); $tb = new IModel("email_registry"); $re = $tb->query("email = '{$email}' AND flag=1"); if (!$re) { return array('flag' => false, 'data' => '你还没有订阅'); } $re = end($re); /* $re['content'] = htmlspecialchars($content,ENT_QUOTES); $re['flag'] = 0; $tb->setData($re); $tb->update("id={$re['id']}"); */ $tb->del("id={$re['id']}"); return array('flag' => true, 'data' => 'success'); }
/** * @brief 删除品牌 */ function brand_del() { $brand_id = (int) IReq::get('bid'); if ($brand_id) { $tb_brand = new IModel('brand'); $where = "id=" . $brand_id; if ($tb_brand->del($where)) { $this->brand_list(); } else { $this->brand_list(); $msg = "没有找到相关分类记录!"; Util::showMessage($msg); } } else { $this->brand_list(); $msg = "没有找到相关品牌记录!"; Util::showMessage($msg); } }
/** * @brief 删除与商品相关表中的数据 */ public function del($goods_id) { //删除推荐类商品 $tb_commend_goods = new IModel('commend_goods'); $commend_goods_info = $tb_commend_goods->query('goods_id = ' . $goods_id); if (count($commend_goods_info) > 0) { $tb_commend_goods->del('goods_id = ' . $goods_id); } //删除商品公用属性 $tb_goods_attribute = new IModel('goods_attribute'); $goods_attribute_info = $tb_goods_attribute->query('goods_id = ' . $goods_id); if (count($goods_attribute_info) > 0) { $tb_goods_attribute->del('goods_id = ' . $goods_id); } //删除相册商品关系表 $tb_goods_relation = new IModel('goods_photo_relation'); $goods_relation_info = $tb_goods_relation->query('goods_id = ' . $goods_id); if (count($goods_relation_info) > 0) { $tb_goods_relation->del('goods_id = ' . $goods_id); } //删除货品表 $tb_products = new IModel('products'); $products_info = $tb_products->query('goods_id = ' . $goods_id); if (count($products_info) > 0) { $tb_products->del('goods_id = ' . $goods_id); } //删除会员价格表 $tb_group_price = new IModel('group_price'); $group_price_info = $tb_group_price->query('goods_id = ' . $goods_id); if (count($group_price_info) > 0) { $tb_group_price->del('goods_id = ' . $goods_id); } //删除扩展商品分类表 $tb_cate_extend = new IModel('category_extend'); $cate_extend_info = $tb_cate_extend->query('goods_id=' . $goods_id); if (count($cate_extend_info) > 0) { $tb_cate_extend->del('goods_id=' . $goods_id); } //删除商品表 $tb_goods = new IModel('goods'); $tb_goods->del('id=' . $goods_id); }
/** * @brief 执行密码修改重置操作 */ function do_restore_password() { $hash = IFilter::act(IReq::get("hash")); if (!$hash) { IError::show(403, "找不到校验码"); } $tb = new IModel("find_password"); $addtime = time() - 3600 * 72; $where = " `hash`='{$hash}' AND addtime > {$addtime} "; $where .= $this->user['user_id'] ? " and user_id = " . $this->user['user_id'] : ""; $row = $tb->getObj($where); if (!$row) { IError::show(403, "校验码已经超时"); } //开始修改密码 $pwd = IReq::get("password"); $repwd = IReq::get("repassword"); if ($pwd == null || strlen($pwd) < 6 || $repwd != $pwd) { IError::show(403, "新密码至少六位,且两次输入的密码应该一致。"); } $pwd = md5($pwd); $tb_user = new IModel("user"); $tb_user->setData(array("password" => $pwd)); $re = $tb_user->update("id='{$row['user_id']}'"); if ($re !== false) { $message = "修改密码成功"; $tb->del("`hash`='{$hash}'"); $this->redirect("/site/success/message/" . urlencode($message)); exit; } IError::show(403, "密码修改失败,请重试"); }
public function takeself_operate() { $id = IFilter::act(IReq::get('id')); if (is_array($id)) { $id = join(',', $id); } if ($id) { $takeself = new IModel('takeself'); $takeself->del('id in(' . $id . ')'); $this->redirect('takeself_list'); } else { $this->redirect('takeself_list', false); Util::showMessage('请选择要操作的选项'); } }
/** * 查询删除 */ function search_del() { $id = IFilter::act(IReq::get('id'), 'int'); //生成search对象 $tb_search = new IModel('search'); if (!empty($id)) { if (is_array($id) && isset($id[0]) && $id[0] != '') { $id_str = join(',', $id); $where = ' id in (' . $id_str . ')'; } else { $where = 'id = ' . $id; } $tb_search->del($where); } else { Util::showMessage('请选择要删除的数据'); } $this->redirect("search_list"); }
/** * 物流公司回收站彻底删除 * */ public function freight_recycle_del() { $id = IReq::get('id'); if (!empty($id)) { $obj = new IModel('freight_company'); $obj->setData(array('is_del' => 0)); if (is_array($id) && isset($id[0]) && $id[0] != '') { $id_str = join(',', $id); $where = ' id in (' . $id_str . ')'; } else { $where = 'id = ' . $id; } $obj->del($where); $this->redirect('freight_recycle'); } else { $this->redirect('freight_recycle', false); Util::showMessage('请选择要删除的物流公司'); } }
/** * @brief 删除商品分类 */ function category_del() { $category_id = IFilter::act(IReq::get('cid'), 'int'); if ($category_id) { $tb_category = new IModel('category'); $catRow = $tb_category->getObj('parent_id = ' . $category_id); //要删除的分类下还有子节点 if (!empty($catRow)) { $this->category_list(); Util::showMessage('无法删除此分类,此分类下还有子分类'); exit; } $tb_category_extend = new IModel('category_extend'); $cate_ext = $tb_category_extend->getObj('category_id = ' . $category_id); //要删除的分类下还有商品 if (!empty($cate_ext)) { $this->category_list(); Util::showMessage('此分类下还有商品,请先删除商品!'); exit; } if ($tb_category->del('id = ' . $category_id)) { //更新缓存 $cacheObj = new ICache('file'); $cacheObj->del('goodsCategory'); $this->category_list(); } else { $this->category_list(); $msg = "没有找到相关分类记录!"; Util::showMessage($msg); } } else { $this->category_list(); $msg = "没有找到相关分类记录!"; Util::showMessage($msg); } }
public function expresswaybill_del() { $id = intval(IReq::get('id')); $expressObj = new IModel('expresswaybill'); $expressObj->del('id = ' . $id); $this->redirect('print_template/tab_index/3'); }
/** * @brief 商户的回收站删除动作 */ public function seller_recycle_del() { $id = IFilter::act(IReq::get('id'), 'int'); $sellerDB = new IModel('seller'); $goodsDB = new IModel('goods'); $merch_ship_infoDB = new IModel('merch_ship_info'); $specDB = new IModel('spec'); if (is_array($id)) { $id = join(",", $id); } $sellerDB->del('id in (' . $id . ')'); $goodsDB->del('seller_id in (' . $id . ')'); $merch_ship_infoDB->del('seller_id in (' . $id . ')'); $specDB->del('seller_id in (' . $id . ')'); $this->redirect('seller_recycle_list'); }
/** * @brief 把订单商品同步到order_goods表中 * @param $order_id 订单ID * @param $goodsInfo 商品和货品信息(购物车数据结构,countSum 最终生成的格式) */ public function insertOrderGoods($order_id, $goodsResult = array()) { $orderGoodsObj = new IModel('order_goods'); //清理旧的关联数据 $orderGoodsObj->del('order_id = ' . $order_id); $goodsArray = array('order_id' => $order_id); if (isset($goodsResult['goodsList'])) { foreach ($goodsResult['goodsList'] as $key => $val) { //拼接商品名称和规格数据 $specArray = array('name' => $val['name'], 'goodsno' => $val['goods_no'], 'value' => ''); if (isset($val['spec_array'])) { $spec = block::show_spec($val['spec_array']); foreach ($spec as $skey => $svalue) { $specArray['value'] .= $skey . ':' . $svalue . ','; } $specArray['value'] = trim($specArray['value'], ','); } $goodsArray['product_id'] = $val['product_id']; $goodsArray['goods_id'] = $val['goods_id']; $goodsArray['img'] = $val['img']; $goodsArray['goods_price'] = $val['sell_price']; $goodsArray['real_price'] = $val['sell_price'] - $val['reduce']; $goodsArray['goods_nums'] = $val['count']; $goodsArray['goods_weight'] = $val['weight']; $goodsArray['goods_array'] = IFilter::addSlash(JSON::encode($specArray)); $goodsArray['seller_id'] = $val['seller_id']; $orderGoodsObj->setData($goodsArray); $orderGoodsObj->add(); } } }
/** * @brief 删除与商品相关表中的数据 */ public function del($goods_id) { $goodsWhere = " id = '{$goods_id}' "; if ($this->seller_id) { $goodsWhere .= " and seller_id = " . $this->seller_id; } //图片清理 $tb_photo_relation = new IModel('goods_photo_relation'); $photoMD5Data = $tb_photo_relation->query('goods_id = ' . $goods_id); $tb_photo = new IModel('goods_photo'); foreach ($photoMD5Data as $key => $md5) { //图片是否被其他商品共享占用 $isUserd = $tb_photo_relation->getObj('photo_id = "' . $md5['photo_id'] . '" and goods_id != ' . $goods_id); if (!$isUserd) { $imgData = $tb_photo->getObj('id = "' . $md5['photo_id'] . '"'); isset($imgData['img']) ? IFile::unlink($imgData['img']) : ""; $tb_photo->del('id = "' . $md5['photo_id'] . '"'); } } $tb_photo_relation->del('goods_id = ' . $goods_id); //删除商品表 $tb_goods = new IModel('goods'); $goodsRow = $tb_goods->getObj($goodsWhere, "content"); if (isset($goodsRow['content']) && $goodsRow['content']) { } $tb_goods->del($goodsWhere); }
/** * @brief 删除登记的到货通知邮件 */ function notify_del() { $notify_ids = IReq::get('check', 'post'); if ($notify_ids && is_array($notify_ids)) { $notify_ids = IFilter::act($notify_ids, 'int'); $ids = implode(',', $notify_ids); if ($ids) { $tb_notify = new IModel('notify_registry'); $where = "id in (" . $ids . ")"; $tb_notify->del($where); } } $this->redirect('notify_list'); }
function navigation_recycle_del() { $ad_id = $this->admin['admin_id']; $data['ad_id'] = $ad_id; $this->setRenderData($data); //post数据 $id = IFilter::act(IReq::get('id'), 'int'); //生成order对象 $tb_order = new IModel('quick_naviga'); if (!empty($id)) { if (is_array($id) && isset($id[0]) && $id[0] != '') { $id_str = join(',', $id); $where = ' id in (' . $id_str . ')'; } else { $where = 'id = ' . $id; } $tb_order->del($where); $this->redirect('navigation_recycle'); } else { $this->redirect('navigation_recycle', false); Util::showMessage('请选择要删除的数据'); } }
function spec_photo_del() { $id = IReq::get('id', 'post'); if (isset($id[0]) && $id[0] != '') { $obj = new IModel('spec_photo'); $id_str = ''; foreach ($id as $rs) { if ($id_str != '') { $id_str .= ','; } $id_str .= $rs; $photoRow = $obj->getObj('id = ' . $rs, 'address'); if (file_exists($photoRow['address'])) { unlink($photoRow['address']); } } $where = ' id in (' . $id_str . ')'; $obj->del($where); $this->redirect('spec_photo'); } else { $this->redirect('spec_photo', false); Util::showMessage('请选择要删除的id值'); } }
public function update_commend() { $data = IFilter::act(IReq::get('data')); //key => 商品ID或货品ID ; value => commend值 1~4 if (!$data) { die(JSON::encode(array('result' => 'fail', 'data' => '商品数据不存在'))); } $goodsCommendDB = new IModel('commend_goods'); //清理旧的commend数据 $goodsIdArray = array_keys($data); $goodsCommendDB->del("goods_id in (" . join(',', $goodsIdArray) . ")"); //插入新的commend数据 foreach ($data as $id => $commend) { foreach ($commend as $k => $value) { if ($value > 0) { $goodsCommendDB->setData(array('commend_id' => $value, 'goods_id' => $id)); $goodsCommendDB->add(); } } } die(JSON::encode(array('result' => 'success'))); }
/** * @brief 彻底删除会员 */ function member_del() { $user_ids = IReq::get('check'); $user_ids = is_array($user_ids) ? $user_ids : array($user_ids); $user_ids = IFilter::act($user_ids, 'int'); if ($user_ids) { $ids = implode(',', $user_ids); if ($ids) { $tb_member = new IModel('member'); $where = "user_id in (" . $ids . ")"; $tb_member->del($where); $tb_user = new IModel('user'); $where = "id in (" . $ids . ")"; $tb_user->del($where); $logObj = new log('db'); $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "删除了用户", "被删除的用户ID为:" . $ids)); } } $this->redirect('member_list'); }
static function get_order_pri_num_del($ogid) { $total = 0; $goods_id = ''; $p_id = ''; $number = ''; //先根据ogid查询出order_goods单价和数量,然后从order表总价格中删除 $query = new IQuery('order_goods'); $query->where = 'id = ' . $ogid; $order_goods_info = $query->find(); if (count($order_goods_info) > 0) { $order_id = $order_goods_info[0]['order_id']; $goods_price = $order_goods_info[0]['goods_price']; $real_price = $order_goods_info[0]['real_price']; $goods_nums = $order_goods_info[0]['goods_nums']; $number = $goods_nums; $goods_id = $order_goods_info[0]['goods_id']; $p_id = $order_goods_info[0]['product_id']; $tb_order = new IModel('order'); $tb_order->setData(array('payable_amount' => 'payable_amount-' . $goods_price * $goods_nums, 'real_amount' => 'real_amount-' . $real_price * $goods_nums, 'order_amount' => 'order_amount-' . $real_price * $goods_nums)); $arr = array('payable_amount', 'real_amount', 'order_amount'); $tb_order->update('id=' . $order_id, $arr); } $islog = 0; $tb_order_goods = new IModel('order_goods'); if ($tb_order_goods->del('id=' . $ogid)) { $islog = 1; } //修改goods表中数量,获得goods表的对象 $tb_goods = new IModel('goods'); $tb_goods->setData(array('store_nums' => 'store_nums+' . $number)); $grr = array('store_nums'); $tb_goods->update('id=' . $goods_id, $grr); //判断p_id是否有值如果有则修改products中的数量 if ($p_id != 0) { $tb_products = new IModel('products'); $tb_products->setData(array('store_nums' => 'store_nums+' . $number)); $prr = array('store_nums'); $tb_products->update('id=' . $p_id, $prr); } return $islog; }
function withdraw_del() { $id = IReq::get('id'); if (!empty($id)) { $id = IFilter::act($id, 'int'); $withdrawObj = new IModel('withdraw'); if (is_array($id)) { $idStr = join(',', $id); $where = ' id in (' . $idStr . ')'; } else { $where = 'id = ' . $id; } $withdrawObj->del($where); $this->redirect('withdraw_recycle'); } else { $this->redirect('withdraw_recycle', false); Util::showMessage('请选择要删除的数据'); } }
/** * @brief 删除与商品相关表中的数据 */ public function del($goods_id) { $goodsWhere = " id = '{$goods_id}' "; if ($this->seller_id) { $goodsWhere .= " and seller_id = " . $this->seller_id; } //删除商品表 $tb_goods = new IModel('goods'); if (!$tb_goods->del($goodsWhere)) { return; } }
function clear_log() { $type = IReq::get('type'); $month = intval(IReq::get('month')); if (!$month) { die('请填写要清理日志的月份'); } $diffSec = 3600 * 24 * 30 * $month; $lastTime = strtotime(date('Y-m')) - $diffSec; $dateStr = date('Y-m', $lastTime); switch ($type) { case "account": $logObj = new IModel('account_log'); $logObj->del("time <= '{$dateStr}'"); $this->redirect('account_list'); break; case "operation": $logObj = new IModel('log_operation'); $logObj->del("datetime <= '{$dateStr}'"); $this->redirect('operation_list'); break; default: die('缺少类别参数'); } }
public static function del_cat($id) { $id = intval($id); $tb_help_category = new IModel("help_category"); $tb_help_category->del("id={$id}"); return array('flag' => true); }
function favorite_del() { $user_id = $this->user['user_id']; $id = IReq::get('id'); if (!empty($id)) { $id = IFilter::act($id, 'int'); $favoriteObj = new IModel('favorite'); if (is_array($id)) { $idStr = join(',', $id); $where = 'user_id = ' . $user_id . ' and id in (' . $idStr . ')'; } else { $where = 'user_id = ' . $user_id . ' and id = ' . $id; } $favoriteObj->del($where); $this->redirect('favorite'); } else { $this->redirect('favorite', false); Util::showMessage('请选择要删除的数据'); } }
public function bill_del() { $id = IFilter::act(IReq::get('id'), 'int'); if ($id) { $billDB = new IModel('bill'); $billDB->del('id = ' . $id . ' and seller_id = ' . $this->seller['seller_id'] . ' and is_pay = 0'); } $this->redirect('bill_list'); }
/** * @brief 删除咨询信息 */ function message_del() { $refer_ids = IReq::get('check'); $refer_ids = is_array($refer_ids) ? $refer_ids : array($refer_ids); if ($refer_ids) { $ids = implode(',', $refer_ids); if ($ids) { $tb_refer = new IModel('message'); $where = "id in (" . $ids . ")"; $tb_refer->del($where); } } $this->message_list(); }
/** * @brief 商品属性添加/修改 * @param array $attribute 表字段 数组格式,如Array ([name] => Array ( [0] => '' ) * [show_type] => Array ( [0] => '' ) * [value] => Array ( [0] => '' ) * [is_seach] => Array ( [0] => 1 )) * @param int $model_id 模型编号 */ public function attribute_update($attribute, $model_id) { //初始化attribute商品模型属性表类对象 $attributeObj = new IModel('attribute'); $len = count($attribute['name']); $ids = ""; for ($i = 0; $i < $len; $i++) { if (isset($attribute['name'][$i]) && isset($attribute['value'][$i])) { $options = str_replace(',', ',', $attribute['value'][$i]); $type = isset($attribute['is_search'][$i]) ? $attribute['is_search'][$i] : 0; //设置商品模型扩展属性 字段赋值 $filedData = array("model_id" => intval($model_id), "type" => IFilter::act($attribute['show_type'][$i]), "name" => $attribute['name'][$i], "value" => rtrim($options, ','), "search" => IFilter::act($type)); $attributeObj->setData($filedData); $id = intval($attribute['id'][$i]); if ($id) { //更新商品模型扩展属性 $attributeObj->update("id = " . $id); } else { //新增商品模型扩展属性 $id = $attributeObj->add(); } $ids .= $id . ','; } } if ($ids) { $ids = trim($ids, ','); //删除商品模型扩展属性 $where = "model_id = {$model_id} and id not in (" . $ids . ") "; $attributeObj->del($where); } }
/** * @brief 把订单商品同步到order_goods表中 * @param $order_id 订单ID * @param $goodsInfo 商品和货品信息(购物车数据结构,countSum 最终生成的格式) */ public function insertOrderGoods($order_id, $goodsResult = array()) { $orderGoodsObj = new IModel('order_goods'); //清理旧的关联数据 $orderGoodsObj->del('order_id = ' . $order_id); $goodsArray = array('order_id' => $order_id); $findType = array('goods' => 'goodsList', 'product' => 'productList'); foreach ($findType as $key => $list) { if (isset($goodsResult[$list]) && count($goodsResult[$list]) > 0) { foreach ($goodsResult[$list] as $k => $val) { //拼接商品名称和规格数据 $specArray = array('name' => $val['name'], 'value' => ''); if ($key == 'product') { $goodsArray['product_id'] = $val['id']; $goodsArray['goods_id'] = $val['goods_id']; $spec = block::show_spec($val['spec_array']); foreach ($spec as $skey => $svalue) { $specArray['value'] .= $skey . ':' . $svalue . ' , '; } } else { $goodsArray['goods_id'] = $val['id']; $goodsArray['product_id'] = 0; } $goodsArray['img'] = $val['img']; $goodsArray['goods_price'] = $val['sell_price']; $goodsArray['real_price'] = $val['sell_price'] - $val['reduce']; $goodsArray['goods_nums'] = $val['count']; $goodsArray['goods_weight'] = $val['weight']; $goodsArray['goods_array'] = JSON::encode($specArray); $orderGoodsObj->setData($goodsArray); $orderGoodsObj->add(); } } } }