<?php
$root = $_SERVER['DOCUMENT_ROOT']; // 获得当前站点的根目录
require_once $root . '/php/model/DB.php';
require_once $root . '/php/model/checkListEmpty.php';
class Goods
{
/**
* 上架商品
* 成功则返回 true
* 需要 post 参数:
* "category_id",
* "name",
* "goods_img",
* "intro",
* "shop_price",
* "sale_price",
* "goods_price",
* "inventor"
* @return bool
*/
public function putaway()
{
$flag=false;
$postData = [
"category_id",
"name",
"goods_img",
"intro",
"shop_price",
"sale_price",
"goods_price",
"inventor"
];
// var_dump(postIsSet($postData));
if (postIsSet($postData)["status"]) {
$category_id = $_POST["category_id"];
$name = $_POST["name"];
$goods_img = $_POST["goods_img"];
$intro = $_POST["intro"];
$deatail = $_POST["detail"] ?? " ";
$shop_price = $_POST["shop_price"];
$sale_price = $_POST["sale_price"];
$goods_price = $_POST["goods_price"];
$sale_num = $_POST["sale_num"] ?? 0;
$inventor = $_POST["inventor"];
$state = $_POST["state"] ?? 1;
$time = time();
$sql = "insert into goods (
category_id,
name,
goods_img,
intro,detail,
shop_price,
sale_price,
goods_price,
sale_num,
inventor,
state,
modtime)
values (
{$category_id},
'{$name}',
'{$goods_img}',
'{$intro}',
'{$deatail}',
{$shop_price},
{$sale_price},
{$goods_price},
{$sale_num},
{$inventor},
{$state},
'{$time}')
";
$mydb = new DB_connect();
$results = $mydb->query($sql);
if($results)
$flag=true;
}
return $flag;
}
/**
* 下架商品
* 成功则返回true
* 需要post参数
* "goods_id"
* @return bool
*/
public function soldout()
{
if(isset($_POST["goods_id"]))
{
$sql="update goods set state=3 where goods_id={$_POST["goods_id"]}";
// $sql="update goods set state=0 where goods_id=10";
$mydb = new DB_connect();
$results = $mydb->query($sql);
return $results;
}
}
/**
* 修改商品
* 成功放回 true
* 需要post参数
* "goods_id",
* "category_id",
* "name",
* "goods_img",
* "intro",
* "shop_price",
* "sale_price",
* "goods_price",
* "inventor",
* "state"
* @return bool
*/
public function modGoods()
{
$postData = [
"goods_id",
"category_id",
"name",
"goods_img",
"intro",
"shop_price",
"sale_price",
"goods_price",
"inventor",
"state"
];
if (postIsSet($postData)["status"]) {
$time = time();
$sql = "update goods set
category_id={$_POST["category_id"]},
name='{$_POST["name"]}',
goods_img='{$_POST["goods_img"]}',
intro='{$_POST["intro"]}',
detail='{$_POST["detail"]}',
shop_price={$_POST["shop_price"]},
sale_price={$_POST["sale_price"]},
goods_price={$_POST["goods_price"]},
inventor={$_POST["inventor"]},
state={$_POST["state"]},
modtime='{$time}'
where goods_id = {$_POST["goods_id"]}
";
}
$mydb = new DB_connect();
$results = $mydb->query($sql);
return $results;
}
public function addgoods()
{
if(isset($_POST["inventor"])&&isset($_POST["goods_id"]))
{
$sql = "update goods set inventor={$_POST["inventor"]} where goods_id = {$_POST["goods_id"]}";
}
$mydb = new DB_connect();
$results = $mydb->query($sql);
return $results;
}
/**
* 修改商品状态
* state: 1 在售 2缺货 3下架
* 需要参数
* "goods_id"
* "state"
* @return void
*/
public function modGoodsState()
{
$postData=["goods_id","state"];
if(postIsSet($postData)["status"])
{
$sql="update goods set state ={$_POST["state"]} where goods_id={$_POST["goods_id"]}";
}
$mydb = new DB_connect();
$results = $mydb->query($sql);
return $results;
}
/**
* 查找商品
* 需要查找参数
* @return mysqli_result 对象
*/
public function searchGoodsById($search)
{
if(isset($search))
{
$sql = "select
goods_id,goods.category_id,name,
goods_img,intro,
shop_price,sale_price,
goods_price,sale_num,
inventor,modtime,
state,category_name
from goods
LEFT JOIN category
on goods.category_id=category.category_id
where goods_id = {$search}
";
}
$mydb = new DB_connect();
$results = $mydb->query($sql);
return $results;
}
//根据商品名查询
public function searchGoodsByName($search)
{
if(isset($search))
{
$sql = "select
goods_id,goods.category_id,name,
goods_img,intro,
shop_price,sale_price,
goods_price,sale_num,
inventor,modtime,
state,category_name
from goods
LEFT JOIN category
on goods.category_id=category.category_id
where name like '{$search}%'
";
}
$mydb = new DB_connect();
$results = $mydb->query($sql);
return $results;
}
//根据类别查询
public function searchGoodsByCategory($search)
{
if(isset($search))
{
$sql = "select
goods_id,goods.category_id,name,
goods_img,intro,
shop_price,sale_price,
goods_price,sale_num,
inventor,modtime,
state,category_name
from goods
LEFT JOIN category
on goods.category_id=category.category_id
where category_name='{$search}'
";
// echo $sql;
}
$mydb = new DB_connect();
$results = $mydb->query($sql);
return $results;
}
/**
* 根据商品状态查找
* 1 在售 2缺货 3下架
* @param [int] $search
* @return mysqli_result 对象
*/
public function searchGoodsByState($search)
{
$sql = "select
goods_id,goods.category_id,name,
goods_img,intro,
shop_price,sale_price,
goods_price,sale_num,
inventor,modtime,
state,category_name
from goods
LEFT JOIN category
on goods.category_id=category.category_id
where state={$search}
";
$mydb = new DB_connect();
$results = $mydb->quer
没有合适的资源?快使用搜索试试~ 我知道了~
基于php与mysql实现的网络商城管理后台系统源码
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共185个文件
gif:75个
php:28个
js:26个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
温馨提示
基于php与mysql实现的网络商城管理后台系统源码
资源推荐
资源详情
资源评论
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 185 条
- 1
- 2
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- usstviking2022-06-15用户下载后在一定时间内未进行评价,系统默认好评。
![avatar](https://profile-avatar.csdnimg.cn/d5fa1452106248a4a63014172db25c5d_leavemyleave.jpg!1)
mYlEaVeiSmVp
- 粉丝: 1966
- 资源: 19万+
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)