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

195 行
9.3 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Common\Model;
use Think\Model;
//[1.2.91]
class GoodsModel extends Model
{
protected $tableName = 'retail_goods';
// protected $fields = array(
// 'id', //int(11) NOT NULL AUTO_INCREMENT,
// 'good_image', //varchar(255) NOT NULL DEFAULT '' COMMENT '商品图片',
// 'goods_name', //varchar(255) DEFAULT NULL COMMENT '零售货物名称。',
// 'subheading', //varchar(255) DEFAULT NULL COMMENT '副标题',
// 'goods_class_id', //int(11) DEFAULT NULL COMMENT '货物所属类别id',
// 'good_number', //varchar(15) DEFAULT NULL COMMENT '货号',
// 'purch_price', //decimal(20,2) DEFAULT '0.00' COMMENT '成本价格',
// 'last_purch_price', //decimal(20,2) DEFAULT '0.00' COMMENT '当前进价',
// 'retail_price', //decimal(20,2) DEFAULT '0.00' COMMENT '零售价',
// 'plus_price', //decimal(20,2) DEFAULT NULL COMMENT 'plus会员价',
// 'vip_online_price', //decimal(10,2) DEFAULT NULL COMMENT '会员价(线上)',
// 'vip_online_integral', //int(11) DEFAULT NULL COMMENT '所需积分(线上)',
// 'vip_retail_price', //decimal(10,2) DEFAULT NULL COMMENT '会员价(线下)',
// 'vip_retail_integral', //int(11) DEFAULT NULL COMMENT '所需积分(线下)',
// 'online_price', //decimal(20,2) DEFAULT NULL COMMENT '小程序商城价格',
// 'vip_online_state', //varchar(255) DEFAULT '0' COMMENT 'vip是否打折 0关闭 1开启',
// 'vip_retail_state', //int(1) DEFAULT '0' COMMENT '允许vip线下积分抵现: 0不允许 1允许',
// 'addtime', //int(11) DEFAULT NULL COMMENT '添加时间',
// 'status', //int(1) DEFAULT NULL COMMENT '状态:0,正常,1,下架,2,删除。',
// 'goods_num', //decimal(11,3) DEFAULT '0.000' COMMENT '商品库存',
// 'goods_order', //int(11) DEFAULT '1' COMMENT '商品排序',
// 'more_num', //decimal(11,3) DEFAULT NULL COMMENT '商品超量;超过该字段的库存数量即为超量',
// 'less_num', //decimal(11,3) DEFAULT NULL COMMENT '库存预警',
// 'sell_num', //decimal(11,3) DEFAULT '0.000' COMMENT '出售数量',
// 'fictitious_num', //int(11) DEFAULT NULL COMMENT '虚拟销量',
// 'company', //varchar(255) DEFAULT '' COMMENT '单位',
// 'specifications', //varchar(255) DEFAULT '' COMMENT '规格',
// 'merchantid', //int(11) DEFAULT '0' COMMENT '商户id。',
// 'storeid', //int(11) DEFAULT NULL COMMENT '门店id',
// 'agoods_count', //varchar(4) DEFAULT '1' COMMENT '安卓所需字段',
// 'goods_code', //varchar(20) DEFAULT '' COMMENT '商品条码。',
// 'issellonline', //int(1) DEFAULT '0' COMMENT '是否在商城中出售:0,不在,1,在商城出售。',
// 'can_exchange_weigh', //tinyint(1) DEFAULT '1' COMMENT '该商品是否称重计价 1:不称重 2:称重',
// 'details', //text COMMENT '商品图文详情',
// 'pd_num', //varchar(11) DEFAULT '' COMMENT '盘点数量',
// 'supplier_id', //int(11) DEFAULT '0',
// 'cansplit', //tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否可拆分:0,不可以。1,可以。',
// 'splitgoodsid', //int(11) NOT NULL DEFAULT '0' COMMENT '拆分后的商品id',
// 'splitgoodsnum', //int(11) NOT NULL DEFAULT '0' COMMENT '拆分子商品的数量。',
// 'label_id', //int(11) DEFAULT '0' COMMENT '标签id 默认0:没有绑定',
// 'mgoodsid', //int(11) DEFAULT '0' COMMENT '调拨商户的商品id',
// 'msytype', //varchar(1) DEFAULT '1' COMMENT '1门店自己添加的 2 同步商户的 3门店进货',
// 'attribute', //tinyint(1) DEFAULT '1' COMMENT '是否开启sku 1不开启 2开启',
// 'usual', //tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否是常用商品:1,不是,2,是。',
// 'attributeid', //text COMMENT '商品使用的规格id,以英文逗号拼接完成',
// 'sync_two', //tinyint(1) DEFAULT '0' COMMENT '0未更新 1已更新',
// 'production_date', //varchar(15) DEFAULT NULL COMMENT '商品生产日期',
// 'shelf_life', //varchar(15) DEFAULT NULL COMMENT '商品到期日期',
// 'shop_mem_status', //tinyint(1) DEFAULT '2' COMMENT '是否开启商城会员价1.开启2.关闭',
// 'shop_mem_price', //decimal(10,2) DEFAULT NULL COMMENT '商城会员价格',
// 'store_mem_status', //tinyint(1) DEFAULT '2' COMMENT '是否开启店内会员价1.开启2关闭',
// 'store_mem_price', //decimal(10,2) DEFAULT NULL COMMENT '店内会员价格',
// 'integral_mem_status', //tinyint(1) DEFAULT '2' COMMENT '1开启积分 2关闭积分 购买获得积分',
// 'integral', //int(11) DEFAULT NULL COMMENT '会员消费送积分',
// 'plus_mem_status', //tinyint(1) DEFAULT '2' COMMENT '1开启 2关闭 plus会员价',
// 'limit_num', //int(11) DEFAULT '0' COMMENT '商城普通商品单笔限购 0不限 1,2,3...',
// 'goods_brand_id', //int(11) DEFAULT '0' COMMENT '商品品牌id',
// 'plu_code', //int(4) DEFAULT NULL,
// 'goods_yieldly_id', //int(10) DEFAULT '0' COMMENT '产地id',
// 'goods_image_id', //varchar(255) DEFAULT '0',
// 'source_type', //tinyint(1) DEFAULT '1' COMMENT '门店添加商品的操作 1门店后台 2门店收银端',
// 'integral_buy_status', //tinyint(1) DEFAULT '0' COMMENT '积分抵扣状态 0关闭 1开启',
// 'buy_integral', //int(11) DEFAULT '0' COMMENT '积分抵扣时应使用的积分',
// 'buy_integral_money', //decimal(10,2) DEFAULT '0.00' COMMENT '积分抵扣所需金额',
// );
/**
* 添加
* @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)
{
if(!isset($map['status'])){
$map['status'] = array('in','0,1');
}
$res = $this->where($map)->save($save);
return $res;
}
/**
* 获取一条
* @param $map
* @param string $field
* @return mixed
*/
public function getFind($map, $field = '*')
{
if(!isset($map['status'])){
$map['status'] = array('in','0,1');
}
$res = $this->field($field)->where($map)->find();
return $res;
}
/**
* @param $map
* @param string $field
* @param string $order
* @param string $page
* @return mixed
*/
public function getSelect($map, $field = '*', $order = 'id asc', $page = '')
{
if(!isset($map['status'])){
$map['status'] = array('in','0,1');
}
if ($page) {
$res = $this->field($field)->where($map)->order($order)->page($page)->select();
} else {
$res = $this->field($field)->where($map)->order($order)->select();
}
return $res;
}
/**
* 获去数量
* @param $map
* @return mixed
*/
public function getCount($map)
{
if(!isset($map['status'])){
$map['status'] = array('in','0,1');
}
$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;
}
public function getShoppingHostGoods($shopping_ids){
$goods = $this->alias('g')
->join("ls_retail_shopping as s on g.id=s.goods_id")
->join('ls_retail_host as h on h.goods_id=g.id AND h.type=2 AND h.starttime < ' . time() . ' AND h.endtime >' . time(), 'LEFT')
->field('h.status as h_status,s.sku_id,s.num,g.id,g.status,g.goods_name,g.goods_num,g.good_image,g.goods_image_id,g.good_number,g.purch_price,g.goods_class_id,g.online_price,g.vip_online_price,g.vip_online_integral,g.vip_online_state,g.label_id,g.shop_mem_status,g.shop_mem_price,g.issellonline,g.can_exchange_weigh,g.plus_mem_status,plus_price')
->where(array('s.id' => array('in', $shopping_ids)))
->select();
return $goods;
}
public function getFindField($map,$fields,$bol = false)
{
$fields = $fields?$fields:"*";
$res = $this->where($map)->getField($fields, $bol);
return $res;
}
}