insertAll($data); } /** * @param $couponId * @return int * @throws DbException * @author xaboy * @day 2020-05-13 */ public function clear($couponId) { return StoreCouponProduct::getDB()->where('coupon_id', $couponId)->delete(); } /** * @param $productId * @return array * @author xaboy * @day 2020/6/1 */ public function productByCouponId($productId) { return StoreCouponProduct::getDB()->whereIn('product_id', $productId)->column('coupon_id'); } public function search(array $where) { return StoreCouponProduct::getDB()->when(isset($where['coupon_id']), function ($query) use ($where) { return $query->where('coupon_id', $where['coupon_id']); }); } }