query()->insertGetId($data); // 返回结果 return $id; } /** * 添加数据 * */ public function edit($id,$data) { // 更新时间 $data['update_time'] = time(); // 写入数据表 $result = $this->query()->where(['id'=>$id])->update($data); // 返回结果 return $result; } /** * 查询多个优惠券的商品范围列表 * * @param array $couponIds 适用产品的列表 * */ public function getProductList($couponIds) { // 写入数据表 $result = $this->query()->whereIn('coupon_id',$couponIds)->get(['coupon_id','product_id'])->toArray(); // 返回结果 return $result; } /** * 查询单个优惠券的商品范围 * * @param array $couponId 优惠券的 * */ public function getProducts($couponId) { // 写入数据表 $result = $this->query()->where([['coupon_id','=',$couponId]])->pluck('product_id')->toArray(); // 返回结果 return $result; } }