| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\plugins\food\models;
- use Yii;
- use Codeception\PHPUnit\ResultPrinter\HTML;
- /**
- * This is the model class for table "{{%food_order}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $user_id
- * @property string $order_no
- * @property string $total_price
- * @property string $pay_price
- * @property string $name
- * @property string $mobile
- * @property string $remark
- * @property integer $is_pay
- * @property integer $pay_type
- * @property integer $pay_time
- * @property integer $is_comment
- * @property integer $created_at
- * @property integer $is_delete
- * @property integer $is_price
- * @property integer $parent_id
- * @property string $coupon_sub_price
- * @property string $content
- * @property string $before_update_price
- * @property string $discount
- * @property integer $user_coupon_id
- * @property integer $parent_id_1
- * @property integer $parent_id_2
- * @property integer $is_sale
- * @property string $words
- * @property integer $is_recycle
- * @property string $seller_comments
- * @property string $alipay_trade_no
- * @property string $table_num
- * @property integer $is_use_platform_mch
- */
- class FoodOrder extends \yii\db\ActiveRecord
- {
- /**
- * 订单来源 公众号或网站
- */
- const ORDER_SOURCE_WEB = 1;
- /**
- * 订单来源 app
- */
- const ORDER_SOURCE_APP = 2;
- /**
- * 订单来源 小程序
- */
- const ORDER_SOURCE_MINI = 3;
- /**
- * 是否支付:已支付
- */
- const IS_PAY_TRUE = 1;
- /**
- * 是否支付:未支付
- */
- const IS_PAY_FALSE = 0;
- /**
- * 支付方式:未支付
- */
- const PAY_TYPE_UNPAID = 0;
- /**
- * 支付方式:微信支付
- */
- const PAY_TYPE_WECHAT = 1;
- /**
- * 支付方式:货到付款
- */
- const PAY_TYPE_COD = 2;
- /**
- * 支付方式:余额支付
- */
- const PAY_TYPE_BALANCE_PAID = 3;
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%food_order}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['store_id', 'user_id', 'order_no'], 'required'],
- [['store_id', 'user_id', 'is_pay', 'pay_type', 'pay_time',
- 'is_comment', 'created_at', 'is_delete', 'parent_id', 'user_coupon_id', 'parent_id_1',
- 'parent_id_2', 'is_use_platform_mch'], 'integer'],
- [['total_price', 'pay_price', 'coupon_sub_price','discount'], 'number'],
- [['order_no', 'name', 'mobile', 'alipay_trade_no', 'table_num'], 'string', 'max' => 255],
- [['remark'], 'string', 'max' => 1000],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'store_id' => 'Store ID',
- 'user_id' => '用户id',
- 'order_no' => '订单号',
- 'total_price' => '订单总费用(包含运费)',
- 'pay_price' => '实际支付总费用(含运费)',
- 'name' => '收货人姓名',
- 'mobile' => '收货人手机',
- 'remark' => '订单备注',
- 'is_pay' => '支付状态:0=未支付,1=已支付',
- 'pay_type' => '支付方式:1=微信支付',
- 'pay_time' => '支付时间',
- 'is_comment' => '是否已评价:0=未评价,1=已评价',
- 'created_at' => 'Addtime',
- 'is_delete' => 'Is Delete',
- 'parent_id' => '用户上级ID',
- 'coupon_sub_price' => '优惠券抵消金额',
- 'discount' => '会员折扣',
- 'user_coupon_id' => '使用的优惠券ID',
- 'parent_id_1' => '用户上二级ID',
- 'parent_id_2' => '用户上三级ID',
- 'words' => '商家留言',
- 'alipay_trade_no' => '支付宝订单号',
- 'is_use_platform_mch' => '供应链系统下单时是否使用平台商户号,1使用,0未使用',
- ];
- }
- public function getOrderDetail()
- {
- return $this->hasMany(FoodOrderDetail::className(), ['order_id' => 'id'])->alias('od')
- ->leftJoin(['g' => FoodGoods::tableName()], 'g.id=od.goods_id')->select(['od.*', 'g.name', 'g.attr goods_attr', 'g.cost_price']);
- }
- public function getDetail()
- {
- return $this->hasMany(FoodOrderDetail::className(), ['order_id' => 'id']);
- }
- public function getGoods()
- {
- return $this->hasMany(FoodGoods::className(), ['id' => 'goods_id'])->alias('g')
- ->viaTable(FoodOrderDetail::tableName() . ' od', ['order_id' => 'id']);
- }
- }
|