getContext()->getRequest();
$admin_id = $this->getContext()->getStorage()->read('admin_id');
$id = intval($request->getParameter("id")); // 商品id
$url = $request->getParameter("url"); // 路径
$sql = "select status from lkt_product_list where id = '$id'";
$r = $db->select($sql);
if($r[0]->status == 0){
$sa= $db->select("select id from lkt_group_product where product_id = $id and recycle = 0 and g_status < 3");//查询该商品是否正在参加拼团活动
if($sa){
header("Content-type:text/html;charset=utf-8");
echo "";
return;
}
$saa = $db->select("select id from lkt_order_details where p_id = $id and (r_status = 1 or r_status = 2 or r_status = 4 or r_status = 9 or r_status = 10 )");//查询该商品是否有未完成订单
if($saa){
header("Content-type:text/html;charset=utf-8");
echo "";
return;
}
$sql = "update lkt_product_list set status = 1 where id = '$id'";
$rr = $db->update($sql);
if($rr > 0){
$db->admin_record($admin_id,' 商品id为 '.$id.' 下架成功',3);
header("Content-type:text/html;charset=utf-8");
echo "";
return;
}else{
$db->admin_record($admin_id,' 商品id为 '.$id.' 下架失败',3);
header("Content-type:text/html;charset=utf-8");
echo "";
return;
}
}else{
$sql = "update lkt_product_list set status = 0 where id = '$id'";
$rr = $db->update($sql);
if($rr > 0){
$db->admin_record($admin_id,' 商品id为 '.$id.' 上架成功',3);
header("Content-type:text/html;charset=utf-8");
echo "";
return;
}else{
$db->admin_record($admin_id,' 商品id为 '.$id.' 上架失败',3);
header("Content-type:text/html;charset=utf-8");
echo "";
return;
}
}
}
public function execute() {
}
public function getRequestMethods(){
return Request :: NONE;
}
}
?>