Exemplo n.º 1
0
    //添加地址并使用
    $name = $_REQUEST['name'];
    $tel = $_REQUEST['tel'];
    $province = $_REQUEST['province'];
    $city = $_REQUEST['city'];
    $country = $_REQUEST['country'];
    $detail_address = $_REQUEST['detail_address'];
    $time = date('Y-m-d H:i:s', time());
    $Mysql = new MySqlHelper();
    //检查是否已经存在默认地址;
    $sqlcheck = "SELECT id FROM sh_store_address where userid={$userID} AND delstate='N' AND state='ON'";
    $datacheck = $Mysql->FetchData($sqlcheck);
    $flag = count($datacheck);
    //如果存在默认地址,则设置为普通地址,如果不存在默认地址,则设置成默认地址。
    if ($flag > 0) {
        $state = 'OFF';
    } else {
        $state = 'ON';
    }
    $sqlinaddress = "INSERT INTO sh_store_address  (userid,provinceid,cityid,countyid,detailaddress,createtime,tel,`name`,state) VALUES ({$userID},{$province},{$city},{$country},'{$detail_address}','{$time}','{$tel}','{$name}','{$state}')";
    $row = $Mysql->ExecuteSql($sqlinaddress);
    $sqlsearchid = "SELECT id FROM sh_store_address WHERE userid={$userID} ORDER BY createtime  DESC  LIMIT 1";
    $datasearchid = $Mysql->FetchData($sqlsearchid);
    if ($row > 0) {
        echo json_encode(array("code" => "200", "mess" => $datasearchid[0][0]));
        return;
    } else {
        echo json_encode(array("code" => "110", "mess" => '添加失败!'));
        return;
    }
}
Exemplo n.º 2
0
 $dataInfo = $Mysql->FetchData($sqlInfo);
 if ($dataInfo[0]['state'] != 'ON') {
     echo json_encode(array("code" => "110", "mess" => '该商品已经下架!'));
     return;
 }
 if ($dataInfo[0]['dnum'] < $sdnum) {
     echo json_encode(array("code" => "110", "mess" => '库存量不足!'));
     return;
 }
 $price = $dataInfo[0]['dprice'];
 $totalmoney = $price * $sdnum + $expressprice;
 $time = date("Y-m-d H:i:s", time());
 $Mysql->Query("BEGIN");
 $sqlInToOrder = "INSERT INTO sh_store_order (userid,ordertime,paystate,deliverstate,orderstate,money,discountmoney,countmoney,realpay,paytype,remarks,address,phone,`name`,expressPrice,ordernum) SELECT {$userID},'{$time}','N', 'NOT','PRE',{$totalmoney},0,{$totalmoney},0,4,'{$remarks}',concat(ar2.areaname,ar1.areaname,ar.areaname,a.detailaddress) AS address,a.tel,a.`name`,{$expressprice},'{$orderNum}' FROM sh_store_address a JOIN sh_store_area ar  ON a.countyid=ar.areaid  JOIN sh_store_area ar1 ON a.cityid=ar1.areaid JOIN sh_store_area ar2 ON a.provinceid=ar2.areaid WHERE id={$addressId} AND a.userid={$userID} AND delstate='N' limit 1";
 //new Log("","ssss".$sqlInToOrder);
 $effectRow = $Mysql->ExecuteSql($sqlInToOrder);
 if ($effectRow > 0) {
     $sqlSearchOrderId = "SELECT orderid FROM sh_store_order WHERE ordernum='{$orderNum}' LIMIT 1 ";
     //new Log(""," ad".$sqlSearchOrderId);
     $dataTableSearchOID = $Mysql->FetchData($sqlSearchOrderId);
     $row = count($dataTableSearchOID);
     if ($row == 1) {
         $orderId = $dataTableSearchOID[0][0];
         //插入订单详细信息到sh_store_order_detail表
         $sqlInToOrderDetail = "INSERT INTO sh_store_order_detail  (goodsid,price,orderid,num) values ({$gdetailid},{$price},{$orderId},{$sdnum})  ";
         //new Log("","详细".$sqlInToOrderDetail);
         $effectDetailRows = $Mysql->ExecuteSql($sqlInToOrderDetail);
         if ($effectDetailRows > 0) {
             //订单提交成功时,减少商品库存量
             $Order = new Order();
             $numUpResult = $Order->updateNums($orderId);
Exemplo n.º 3
0
    $num = $_REQUEST['num'];
    $sql = "UPDATE sh_store_cart SET snum={$num} WHERE gdetailid={$id} AND userid=" . $userID;
    $Mysql = new MySqlHelper();
    $row = $Mysql->ExecuteSql($sql);
    if ($row > 0) {
        echo json_encode(array("code" => "200", "mess" => "修改成功!"));
        return;
    } else {
        echo json_encode(array("code" => "110", "mess" => "修改失败!"));
        return;
    }
} elseif ($m == 'CHECK') {
    $strid = $_REQUEST['strid'];
    $flag = false;
    if ($strid != '') {
        $strid = substr($strid, 0, -1);
        $flag = true;
    } else {
        $strid = 0;
    }
    $sql = "update sh_store_cart set checkstate=CASE WHEN  gdetailid  in ({$strid})  THEN 'ON' ELSE 'OFF'  END  WHERE userid={$userID}";
    $Mysql = new MySqlHelper();
    $row = $Mysql->ExecuteSql($sql);
    if ($row > 0) {
        echo json_encode(array("code" => "200", "mess" => "修改成功!"));
        return;
    } else {
        echo json_encode(array("code" => "110", "mess" => $strid));
        return;
    }
}
Exemplo n.º 4
0
function test()
{
    $Mysql = new MySqlHelper();
    return $row2 = $Mysql->ExecuteSql("INSERT INTO test  (datatime,znum,onenum) VALUES ('2015-12-29',2,6)");
}
Exemplo n.º 5
0
 public function updateNums($orderid = 0)
 {
     $Mysql = new MySqlHelper();
     $where = '';
     //两个条件满足一个就可以更改,orderid优先
     if ($orderid < 1) {
         return false;
     }
     if ($orderid > 0) {
         $where = " where o.orderid={$orderid} ";
     }
     $sqlInfo = "SELECT d.goodsid,d.num FROM sh_store_order o JOIN sh_store_order_detail d ON o.orderid=d.orderid " . $where;
     new Log("", "" . $sqlInfo);
     $dataInfo = $Mysql->FetchData($sqlInfo);
     $row = count($dataInfo);
     if ($row > 0) {
         foreach ($dataInfo as $Items) {
             $upsql = "UPDATE sh_store_goods_detail SET dnum =dnum-" . $Items['num'] . " ,salenum =salenum+" . $Items['num'] . " WHERE detailid=" . $Items['goodsid'];
             $upRow = $Mysql->ExecuteSql($upsql);
             if ($upRow < 1) {
                 new Log("", "更改商品数量失败,sql===" . $upsql);
                 return false;
             }
         }
         return true;
     } else {
         return false;
     }
 }