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

153 行
8.2 KiB
PHP
可执行文件

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

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

<?php
namespace Common\Model;
use Think\Model;
//[1.8.4]
/**
* 商品出售记录表
* Class RetailSellModel
* @package Common\Model
*/
class RetailSellModel extends BaseModel
{
protected $tableName = 'retail_sell';
const ID = 'id';
const BILL_ID = 'bill_id'; //int(11) DEFAULT NULL COMMENT 'bill表id',
const GOODS_ID = 'goods_id'; //int(11) DEFAULT '0' COMMENT '商品id',
const PAY_TYPE = 'pay_type'; //varchar(255) DEFAULT '0' COMMENT '支付类型 1现金 2银行卡 3微信 4支付宝 5会员余额 6小程序微信 7其他 8组合',
const PRICE = 'price'; //decimal(11,2) DEFAULT '0.00' COMMENT '实际售价(单个)',
const NUM = 'num'; //decimal(11,3) DEFAULT '0.000' COMMENT '一次订单的销售数量(退货数量)',
const ALL_MONEY = 'all_money'; //decimal(11,2) DEFAULT '0.00' COMMENT '总价(总退款)',
const USE_INTEGRAL = 'use_integral'; //varchar(16) DEFAULT '0' COMMENT '会员卡买单消费积分(单个)',
const ADD_TIME = 'add_time'; //varchar(255) DEFAULT NULL COMMENT '添加时间',
const TYPE = 'type'; //tinyint(1) DEFAULT '2' COMMENT '应用类型 1商城 2店内',
const STORE_ID = 'store_id'; //int(11) DEFAULT '0' COMMENT '门店id',
const MERCHANT_ID = 'merchant_id'; //int(11) DEFAULT '0' COMMENT '商户id',
const GOODS_CLASS_ID = 'goods_class_id'; //int(11) DEFAULT '0' COMMENT '商品类别id',
const GOODS_NAME = 'goods_name'; //varchar(255) DEFAULT '' COMMENT '品名',
const PRICING_METHOD = 'pricing_method'; //tinyint(1) DEFAULT '1' COMMENT '商品计价方式 1:计量 2称重',
const PURCHASE_PRICE = 'purchase_price'; //decimal(10,2) DEFAULT '0.00' COMMENT '成本价',
const ORIGINAL_PRICE = 'original_price'; //decimal(10,2) DEFAULT '0.00' COMMENT '原价(零售价)',
const GOODS_IMG_ID = 'goods_img_id'; //varchar(255) DEFAULT NULL COMMENT '图片id',
const REFUND_NUM = 'refund_num'; //decimal(11,3) DEFAULT '0.000' COMMENT '该商品退款数量',
const VIP_DISCOUNT = 'vip_discount'; //decimal(3,2) DEFAULT '1.00' COMMENT '折扣:不打折商品为1,打折商品展示折扣。',
const CASHIER_MANUAL_DIS = 'cashier_manual_discount'; //decimal(3,2) DEFAULT '1.00' COMMENT '折扣:不打折商品为1,打折商品展示折扣。',
const CASHIER_MANUAL_DIS_MONEY = 'cashier_manual_discount_money'; //decimal(5,2) DEFAULT '0.00'
const ATTRIBUTE_STATE = 'attribute_state'; //tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否开启规格 默认不开启 :1 不开启;2:开启',
const SELL_TYPE = 'sell_type'; //tinyint(1) NOT NULL DEFAULT '1' COMMENT '销售状态:1,销售,2,退款 ',
const GOODS_TYPE = 'goods_type'; //tinyint(1) DEFAULT '1' COMMENT '1普通商品 2无码商品',
const VID = 'vid'; //int(11) DEFAULT NULL COMMENT '会员id',
const VIP_PRICE = 'vip_price'; //decimal(11,2) DEFAULT NULL COMMENT '会员价',
const PLUS_VIP_PRICE = 'plus_vip_price'; //decimal(11,2) DEFAULT NULL COMMENT 'plus会员价。',
const UID = 'uid'; //int(11) DEFAULT NULL COMMENT '小程序用户id',
const SKU_JSON_INFO = 'sku_json_info'; //varchar(1000) COMMENT '新规格',
const SELL_NUMBER = 'sell_number'; //decimal(10,3) DEFAULT '1.000' COMMENT '实际售出数量',
const PAY_STATE = 'pay_state'; //tinyint(1) DEFAULT '1' COMMENT '0未支付 1已支付',
const GET_INTEGRAL = 'get_integral'; //decimal(20,0) DEFAULT '0' COMMENT '获得的积分',
const VIP_LESS_MONEY = 'vip_less_money'; //decimal(10,2) DEFAULT '0.00' COMMENT '会员价优惠价格',
const CASHIER_DIS_MONEY = 'cashier_dis_money'; //decimal(10,2) DEFAULT '0.00' COMMENT '收银员打折金额',
const COUPON_MONEY = 'coupon_money'; //decimal(10,2) DEFAULT '0.00' COMMENT '优惠券优惠金额',
const INTEGRAL_DIS_MONEY = 'integral_dis_money'; //decimal(10,2) DEFAULT '0.00' COMMENT '积分抵扣金额或者抵扣积分的金额',
const VIP_DIS_MONEY = 'vip_dis_money'; //decimal(10,2) DEFAULT '0.00' COMMENT '会员打折优惠金额',
const SMALL_CHANGES_MONEY = 'small_changes_money'; //decimal(10,2) DEFAULT '0.00' COMMENT '抹零优惠金额',
const WAIT_REFUND_NUM = 'wait_refund_num'; //decimal(10,3) DEFAULT '0.000' COMMENT '正在申请退款的数量',
const SELL_ID = 'sell_id'; //int(11) DEFAULT '0' COMMENT '当该数据为退款订单时的原sell表id',
const CASHIER_ID = 'cashier_id'; //int(11) DEFAULT '0' COMMENT '收银员id',
const REFUND_MONEY = 'refund_money'; //decimal(11,2) DEFAULT '0.00' COMMENT '退款金额',
const GUIDE_ROYALTY = 'guide_royalty'; //decimal(11,2) DEFAULT '0.00' COMMENT '导购员的提成',
const INTEGRAL_MARKETING = 'integral_marketing'; //积分营销 1基于订单 2基于商品
const MEM_INTEGRAL = 'mem_integral'; //购买单个商品所需的积分
const SUPPLIER_JSON = 'supplier_json'; //商品隶属的供货商json字符串
const PURCHASE_ID_STR = 'purchase_id_str'; //采购单id , 拼接
const COMPANY = 'company'; //单位
const GOODS_GIFTS_ID = 'goods_gifts_id'; // 赠品表ID
const GOODS_GIFTS_TYPE = 'goods_gifts_type'; // 1=手动赠送,2=促销赠送
const SERIAL_NUMBER_STATE = 'serial_number_state'; //串号状态 0关闭 1开启
const SKU_ID = 'sku_id';
const CODE_PRICE_STATE = 'code_price_state';
/**
* @param $map 查询条件
* @param string $field 需要获取的字段
* @param string $order 排序
* @param string $alias1 sell表别名
* @param string $alias2 goods表别名
* @param string $page 页码及条数
* @return mixed
*/
public function getSelectAndGoods($map, $field = '', $order = '', $alias1 = 's', $alias2 = 'g', $page = '')
{
if ($order == '') {
$order = $alias1 . '.id asc';
}
if ($field == '') {
$field = $alias1 . '.*,' . $alias2 . '.*';
}
if ($page) {
$res = $this->alias($alias1)
->join('ls_retail_goods as ' . $alias2 . ' on ' . $alias1 . '.' . $this::GOODS_ID . '=' . $alias2 . '.id', 'LEFT')
->field($field)
->where($map)
->order($order)
->page($page)
->select();
} else {
$res = $this->alias($alias1)
->join('ls_retail_goods as ' . $alias2 . ' on ' . $alias1 . '.' . $this::GOODS_ID . '=' . $alias2 . '.id', 'LEFT')
->field($field)
->where($map)
->order($order)
->select();
}
return $res;
}
/**
* 活动所需
* @param array $map 查询条件
* @param string $field 需要获取的字段
* @return array $find
*/
public function getFindActivityAndGoods($map, $field)
{
$find = $this->alias('s')
->join('ls_retail_goods as g on s.' . $this::GOODS_ID . '=g.id')
->field($field)
->where($map)
->select();
return $find;
}
//汇总
public function sellSummary($where, $fields)
{
$list = $this->alias('s')
->join('ls_retail_store_sale_goods as g on s.goods_id=g.goods_id and s.sku_id=g.sku_id', 'LEFT')
->join('ls_retail_goods_class as c on c.id=g.goods_class_id', 'LEFT')
->where($where)
->field($fields)
->select();
return $list;
}
/**
* 与订单的关联查询
* @param $fields
* @param $where
* @return mixed
*/
public function sellOrderInfo($fields,$where)
{
$info = $this->alias('s')
->join('ls_retail_bill_order as b on s.bill_id=b.id')
->field($fields)
->where($where)
->find();
return $info;
}
}