10], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'store_id' => 'Store ID', 'order_id' => 'Order ID', 'mall_order_id' => 'Mall Order Id', 'stage' => 'Stage', 'code' => 'Code', 'updated_at' => 'Updated At', 'created_at' => 'Created At', ]; } /** * 获取门店当前期数自提订单数量 * * @param integer $store_id * @return int */ public static function getStoreCount(int $store_id, string $stage) { return static::find() ->where(['store_id' => $store_id, 'stage' => $stage]) ->count(); } /** * 获取自提数据 * * @param integer $order_id * @return array */ public static function getPickupDataByOrderId(int $order_id) { return static::find() ->select('stage, code') ->where(['order_id' => $order_id]) ->asArray() ->one(); } /** * 通过主商城订单ID获取自提数据 * * @param integer $mall_order_id * @return array */ public static function getPickupDataByMallOrderId(int $mall_order_id) { return static::find() ->select('stage, code') ->where(['mall_order_id' => $mall_order_id]) ->asArray() ->one(); } /** * 添加自提订单 * * @param integer $mall_id * @param integer $store_id * @param integer $order_id * @param string $stage * @param string $code * @return static|false */ public static function addPickup( int $mall_id, int $store_id, int $order_id, int $mall_order_id, string $stage, string $code ) { $model = new static; if ( $model->load(compact('mall_id', 'store_id', 'order_id', 'mall_order_id', 'stage', 'code'), '') && $model->save() ) { return $model; } return false; } }