isJson()) { $data = [ 'site_id' => $this->site_id, 'bl_name' => input('bl_name', ''),//组合名称 'bl_price' => input('bl_price', ''),//商品组合价格 'shipping_fee_type' => input('shipping_fee_type', ''),//运费承担方式 1卖家承担运费 2买家承担运费 'status' => input('status', ''),//是否上下架 ]; $sku_ids = input('sku_ids', ''); $bundling_model = new BundlingModel(); $res = $bundling_model->addBundling($data, $sku_ids); return $res; } else { return $this->fetch('bundling/add'); } } /** * 编辑优惠套餐 */ public function edit() { $bl_id = input('bl_id', 0); $bundling_model = new BundlingModel(); if (request()->isJson()) { $data = [ 'bl_name' => input('bl_name', ''),//组合名称 'bl_price' => input('bl_price', ''),//商品组合价格 'shipping_fee_type' => input('shipping_fee_type', ''),//运费承担方式 1卖家承担运费 2买家承担运费 'status' => input('status', ''),//最大领取数量 ]; $sku_ids = input('sku_ids', ''); $condition = array ( ['bl_id', '=', $bl_id ], ['site_id', '=', $this->site_id ] ); $res = $bundling_model->editBundling($data, $sku_ids, $condition); return $res; } else { $condition = [ [ 'bl_id', '=', $bl_id ], [ 'site_id', '=', $this->site_id ] ]; $info_result = $bundling_model->getBundlingDetail($condition); $info = $info_result['data']; if (empty($info)) $this->error('未获取到活动数据', href_url('bundling://shop/bundling/lists')); $this->assign('info', $info); $this->assign('bl_id', $bl_id); return $this->fetch('bundling/edit'); } } /** * 优惠套餐详情 */ public function detail() { $bundling_id = input('bl_id', ''); $bundling_model = new BundlingModel(); $condition = [ [ 'bl_id', '=', $bundling_id ], [ 'site_id', '=', $this->site_id ] ]; $info = $bundling_model->getBundlingDetail($condition)[ 'data' ] ?? []; if (empty($info)) $this->error('未获取到活动数据', href_url('bundling://shop/bundling/lists')); $this->assign('info', $info); return $this->fetch('bundling/detail'); } /** * 优惠套餐列表 */ public function lists() { if (request()->isJson()) { $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); $bl_name = input('bl_name', ''); $status = input('status', ''); $condition = []; if ($status !== '') { $condition[] = [ 'status', '=', $status ]; } $condition[] = [ 'site_id', '=', $this->site_id ]; $condition[] = [ 'bl_name', 'like', '%' . $bl_name . '%' ]; $order = 'update_time desc'; $field = '*'; $bundling_model = new BundlingModel(); $res = $bundling_model->getBundlingPageList($condition, $page, $page_size, $order, $field); return $res; } else { return $this->fetch('bundling/lists'); } } /** * 删除优惠套餐 */ public function delete() { if (request()->isJson()) { $bl_id = input('bl_id', 0); $bundling_model = new BundlingModel(); $res = $bundling_model->deleteBundling($bl_id, $this->site_id); return $res; } } /** * 删除优惠套餐 */ public function deleteAll() { if (request()->isJson()) { $bl_id = input('bl_id', 0); $bundling_model = new BundlingModel(); foreach ($bl_id as $k => $v){ $res = $bundling_model->deleteBundling($v, $this->site_id); } return $res; } } }