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

44 行
1.9 KiB
PHP
可执行文件

<?php
namespace Common\Model;
//[1.2.41]
class RetailPromotionModel extends BaseModel
{
protected $tableName = 'retail_promotion';
const ID = 'id'; //int(10) unsigned NOT NULL AUTO_INCREMENT,
const STORE_ID = 'storeid'; //int(10) DEFAULT NULL COMMENT '门店id',
const MERCHANT_ID = 'merchantid'; //int(10) DEFAULT NULL COMMENT '商户id',
const NAME = 'name'; //varchar(50) DEFAULT NULL COMMENT '活动标识名称',
const START_TIME = 'start_time'; //varchar(20) DEFAULT NULL COMMENT '起始时间',
const END_TIME = 'end_time'; //varchar(20) DEFAULT NULL COMMENT '截止时间',
const ADD_TIME = 'addtime'; //varchar(20) DEFAULT NULL COMMENT '创建时间',
const STATUS = 'status'; //tinyint(1) DEFAULT '0' COMMENT '0 正常 1 删除',
const TYPE = 'type'; //tinyint(1) DEFAULT '0' COMMENT '0 下架中 1 上架中',
/**
* @param $goodsid 商品id
* @param $storeid 门店id
* @return array 返回当前商品的 促销 数组 没有返回空
*/
public function goodsFindPromotion($goodsid,$storeid){
$where=array();
$where[$this::STORE_ID] = $storeid;
$where[$this::STATUS] = 0;
$where[$this::TYPE] = 1;
$time = time();
$where[$this::START_TIME] = array('ELT',$time);
$where[$this::END_TIME] = array('EGT',$time);
$promotion_id = $this->where($where)->getField($this::ID);
if(!$promotion_id){
return array();
}
$retailPromotionGoods = D('RetailPromotionGoods');
$map = array();
$map[$retailPromotionGoods::PROMOTION_ID] = $promotion_id;
$map[$retailPromotionGoods::GOODS_ID] = $goodsid;
$map[$retailPromotionGoods::RESIDUE_SINGULAR] = array('gt',0);
$map[$retailPromotionGoods::STATUS] = 0;
$data = $retailPromotionGoods->getSelect($map,'*',$retailPromotionGoods::XCX_PRICE.' asc');
$data = $data?$data:array();
return $data;
}
}