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

102 行
3.2 KiB
PHP
可执行文件

<?php
/*
* 商户成本价模型 - 数据对象模型
*/
namespace Common\Model;
use Think\Model;
//[1.5.46]
class CostPriceRecordModel extends Model
{
protected $tableName = 'retail_cost_price_record';
protected $fields = array(
'id', //int(11) NOT NULL AUTO_INCREMENT,,
'merchant_id', //int(11) DEFAULT '0' COMMENT '商户id',
'cost_price', //decimal(10,2) DEFAULT '0.00' COMMENT '进价平均值',
'goods_id', //int(11) DEFAULT '0' COMMENT '商户商品id',
'sku_id', //int(11) DEFAULT '0' COMMENT '规格id',
'purchase_price', //decimal(10,2) DEFAULT '0.00' COMMENT '当前进价',
'goods_class_id', //int(11) DEFAULT '0' COMMENT '分类id',
'attribute_state', //tinyint(1) DEFAULT '1' COMMENT '1无规格 2规格商品',
'pricing_method', //tinyint(1) DEFAULT '1' COMMENT '1不称重 2称重',
'add_time', //varchar(10) DEFAULT '' COMMENT '添加时间',
'type', //1入库 2退货出库 3调价单修改
);
/*
* 查询信息
* @param $where 查询条件
*/
public function getFind($where)
{
$success = $this->where($where)->find();
return $success;
}
/*
* 查询某个字段
* @param $where 条件
* @param $field 查询的字段
* @param $state 单个还是数组
*/
public function getFindField($where,$field,$state=false)
{
$field = $field?$field:'id';
$success = $this->where($where)->getField($field,$state);
return $success;
}
/*
* 查询某些字段
* @param $where 条件
* @param $fields 查询的字段
*/
public function getFindFields($where,$fields)
{
$fields = $fields?$fields:'*';
$success = $this->field($fields)->where($where)->select();
return $success;
}
/*
* 查询信息
*/
public function getSelect($where,$limit,$field,$order)
{
$field = $field?$field:"*";
$order = $order?$order:'addtime desc';
if(!$limit || $limit == ''){
$success = $this->field($field)->where($where)->order($order)->select();
}else{
$success = $this->field($field)->where($where)->limit($limit)->order($order)->select();
}
return $success;
}
/**
* 统计数量(count)
* @param $where 查询条件
*
*/
public function getCount($where)
{
$success = $this->where($where)->count();
return $success;
}
/*
* 添加
* @param $data 添加的信息
*/
public function addData($data)
{
if(!$data){
$res['status'] = 0;
$res['msg'] = '添加信息缺失';
}else{
$success = $this->add($data);
if($success){
$res['status'] = 1;
$res['data'] = $success;
$res['msg'] = '操作成功';
}else{
$res['status'] = 0;
$res['msg'] = '操作失败';
}
}
return $res;
}
}