文件
mashangyoujiu/Application/Common/Model/SkuGoodsModel.class.php

143 行
4.1 KiB
PHP
可执行文件

<?php
namespace Common\Model;
use Think\Model;
//[1.1.86]
class SkuGoodsModel extends Model
{
protected $tableName = 'retail_sku_goods';
protected $fields = array(
'id', //int(11) NOT NULL AUTO_INCREMENT,
'storeid', //int(11) DEFAULT '0' COMMENT '门店id',
'goods_id', //int(11) DEFAULT '0' COMMENT '商品id',
'sku_id_list', //varchar(255) DEFAULT NULL COMMENT '规格id拼接',
'purch_price', //decimal(10,2) DEFAULT '0.00' COMMENT '成本价',
'last_purch_price', //decimal(10,2) DEFAULT '0.00' COMMENT '最后一次进价',
'online_price', //decimal(10,2) DEFAULT NULL COMMENT '商城价',
'retail_price', //decimal(10,2) DEFAULT NULL COMMENT '门店价',
'goods_img', //varchar(255) DEFAULT NULL COMMENT '规格图片',
'goods_num', //int(11) DEFAULT '0' COMMENT '商品库存',
'sku_num', //decimal(10,3) DEFAULT '1.000' COMMENT '规格基数',
'shop_mem_price', //decimal(10,2) DEFAULT NULL COMMENT '商城会员价格',
'store_mem_price', //decimal(10,2) DEFAULT NULL COMMENT '店内会员价格',
'plus_price', //decimal(10,2) DEFAULT NULL COMMENT 'plus会员价',
'addtime', //varchar(20) DEFAULT NULL COMMENT '添加时间',
'status', //tinyint(1) DEFAULT '1' COMMENT '0不启用 1启用',
'state', //tinyint(1) DEFAULT '0' COMMENT '0正常 1删除',
'type', //varchar(255) DEFAULT '1' COMMENT '1单选 2多选',
'sku_code', //varchar(255) DEFAULT NULL COMMENT '商品规格条码',
'pd_num', //varchar(11) DEFAULT '' COMMENT '盘点数量',
'goods_img_id', //varchar(255) DEFAULT '0' COMMENT '图片id',
);
/**
* 添加
* @param $data
* @return mixed
*/
public function addOrder($data)
{
$res = $this->add($data);
return $res;
}
/**
* 更新
* @param $map
* @param $save
* @return mixed
*/
public function updateOrder($map, $save)
{
$map['state'] = 0;
$res = $this->where($map)->save($save);
return $res;
}
/**
* 获取一条
* @param $map
* @param string $fields
* @param $bol
* @return mixed
*/
public function getFind($map, $fields = '*')
{
$map['state'] = 0;
$res = $this->field($fields)->where($map)->find();
return $res;
}
/**
* 获取某字段
* @param $map
* @param string $fields
* @param $bol
* @return mixed
*/
public function getFindField($map, $fields = 'id', $bol = false)
{
$map['state'] = 0;
$res = $this->where($map)->getField($fields, $bol);
return $res;
}
/**
* @param $map
* @param string $field
* @param string $order
* @param string $page
* @return mixed
*/
public function getSelect($map, $field = '*', $order = 'id asc', $page = '')
{
$map['state'] = 0;
if ($page) {
$res = $this->field($field)->where($map)->page($page)->select();
} else {
$res = $this->field($field)->where($map)->select();
}
return $res;
}
/**
* 获去数量
* @param $map
* @return mixed
*/
public function getCount($map)
{
$map['state'] = 0;
$res = $this->where($map)->count();
return $res;
}
/**
* 某个字段向上增加
* @param $map 条件
* @param $key 字段名
* @param $val 增加的值
* @return mixed
*/
public function toSetInc($map, $key, $val)
{
$res = $this->where($map)->setInc($key, $val);
return $res;
}
/**
* 某个字段向下加减少
* @param $map 条件
* @param $key 字段名
* @param $val 减少的值
* @return mixed
*/
public function toSetDec($map, $key, $val)
{
$res = $this->where($map)->setDec($key, $val);
return $res;
}
}