You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.4 KiB
48 lines
1.4 KiB
<?php
|
|
/**
|
|
*
|
|
*/
|
|
include_once(SERVER_ROOT."/model/mBase.php");
|
|
|
|
|
|
class mGoods extends mBase {
|
|
private $obj;
|
|
private $goods;
|
|
|
|
public function __construct() {
|
|
$this->obj = new dGoods();
|
|
$this->goods = 'goods_list';
|
|
}
|
|
|
|
public function addGoods($goods_id, $goods_name, $goods_price, $sku_id, $sku_name, $shop_id, $uid) {
|
|
$data = array();
|
|
$data['goods_name'] = $goods_name;
|
|
$data['goods_price'] = $goods_price;
|
|
$data['sku_name'] = $sku_name;
|
|
|
|
$info = $this->getGoods($uid, $shop_id, $goods_id, $sku_id);
|
|
if ($info) {
|
|
return $this->updateGoodsById($info['id'], $data);
|
|
}
|
|
|
|
$data['goods_id'] = $goods_id;
|
|
$data['sku_id'] = $sku_id;
|
|
$data['shop_id'] = $shop_id;
|
|
$data['uid'] = $uid;
|
|
|
|
return $this->obj->insert($this->goods, $data);
|
|
}
|
|
|
|
public function getGoods($uid, $shop_id, $goods_id, $sku_id) {
|
|
return $this->obj->select($this->goods, array('sql'=>'`uid`=? and `shop_id`=? and `goods_id`=? and `sku_id`=?', 'vals'=>array($uid, $shop_id, $goods_id, $sku_id)));
|
|
}
|
|
|
|
public function getGoodsByGoodsids($goods_ids) {
|
|
return $this->obj->selectIn($this->goods, array('goods_id'=>$goods_ids));
|
|
}
|
|
|
|
public function updateGoodsById($id, $data) {
|
|
return $this->obj->update($this->goods, $data, array('sql'=>'`id`=?', 'vals'=>array($id)));
|
|
}
|
|
|
|
}
|