'ID', 'mall_id' => 'Mall ID', 'item_id' => 'Item ID', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 判断当前用户是否购买过当前商品 * @param int $mall_id * @param int $user_id * @param int $order_id * @param int $goods_id * @return bool */ public static function isBuyCurrentGoods(int $mall_id, int $user_id, int $order_id, int $goods_id) { return OrderDetail::find()->where(['mall_id' => $mall_id]) ->andWhere(['user_id' => $user_id]) ->andWhere(['<>', 'order_id', $order_id]) ->andWhere(['goods_id' => $goods_id]) ->andWhere(['order_status' => [ 1, 2, 3, 4, -1, -2, -5 ]]) ->andWhere(['status' => StatusEnum::ENABLED]) ->count() > 0; } /** * @param int $mall_id * @param int $goods_id * @return bool */ public static function isAloneSetting(int $mall_id, int $goods_id) { return self::find()->where(['mall_id' => $mall_id]) ->andWhere(['item_id' => $goods_id]) ->andWhere(['status' => StatusEnum::ENABLED])->count() > 0; } }