64], [['consignee', 'phone'], 'string', 'max' => 20], [['province', 'city', 'area'], 'string', 'max' => 10], [['payment_sn'], 'string', 'max' => 120], [['remarks'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'id', 'user_id' => '用户id', 'order_sn' => '订单号', 'invoice_id' => '发票单号', 'status' => '状态', 'type' => '类型', 'goods_count' => '商品数量', 'goods_amount' => '商品金额', 'shipping_amount' => '物流金额', 'shipping_type' => '物流类型', 'consignee' => '收件人', 'phone' => '手机号码', 'province' => '省份', 'city' => '城市', 'area' => '区域', 'taking_site' => '自提点', 'pay_type' => '支付方式', 'pay_at' => '支付时间', 'payment_sn' => '付款单号', 'payment_amount' => '支付金额', 'receivables' => '应收款', 'remarks' => '备注', 'discount_amount' => '折扣金额', 'discount_description' => '折扣说明', 'updated_at' => '更新时间', 'created_at' => '创建时间', 'address' => '详细地址', ]; } public function beforeSave($insert) { if ($this->status === self::STATUS_UNCONFIRMED && $this->type == self::TYPE_SHOPPING) { $this->shipping_amount = $this->countShippingAmount(); $this->receivables = $this->goods_amount + $this->shipping_amount; $this->payment_amount = $this->receivables - $this->discount_amount; } return parent::beforeSave($insert); } /** * @author linyao * @email 602604991@qq.com * @created Nov 8, 2019 * * 行为存储创建时间和更新时间 */ public function behaviors() { return [ [ 'class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at', 'value' => function () { return time(); }, ], ]; } }