企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
文件路径:shop/controllers/Seller/Promotion/GroupBuyCtl.php 一、团购列表【方法:index();】 1.套餐过期时间及备注 ~~~ if (!$this->selfSupportFlag) //普通店铺 { $com_flag = $this->comboFlag; if ($this->comboFlag)//套餐可用 { //店铺套餐信息 $combo_row = $this->groupBuyQuotaModel->getGroupBuyQuotaByShopID(Perm::$shopId); } } ~~~ 2.团购类型【全部、线上团、虚拟团】 3.活动状态 ~~~ $cond_row['shop_id'] = Perm::$shopId; //团购类型 if (request_int('type')) { $cond_row['groupbuy_type'] = request_int('type'); } //活动状态 if (request_int('state')) { //groupbuy_state--团购状态 1.审核中 2.正常 3.结束 4.审核失败 5.管理员关闭 $cond_row['groupbuy_state'] = request_int('state'); } //团购活动列表 $data = $this->groupBuyBaseModel->getGroupBuyGoodsList($cond_row, array('groupbuy_id' => 'DESC'), $page, $rows); ~~~ 二、新增(虚拟)团购【方法:add();addVr();】 1.团购活动开始时间:不得小于当前时间,且小于团购套餐结束时间 2.团购活动结束时间:不得小于当前时间,且小于团购套餐结束时间 3.团购商品:选择商品 通过AJAX获得店铺所有商品,并且判断商品是否已经参加过其他团购活动 ~~~ $(".btn_show_search_goods").on('click', function() { $('.search-goods-list').show(); $('.btn_search_goods').click(); }); //搜索店铺商品 $('.btn_search_goods').on('click', function() { var url = "index.php?ctl=Seller_Promotion_GroupBuy&met=getShopGoods&typ=e"; var key = $("#key").val(); url = key ? url + "&goods_name=" + key : url; $('.search-goods-list-bd').load(url); }); ~~~ 4.提交 新增团购活动提交时进行表单验证:`$('#form').validator({})` 参数:group_id -> 用于判断当前活动是修改还是添加 ~~~ $group_info = $this->groupBuyBaseModel->getOneByWhere(['groupbuy_id'=>$group_id]); $this->groupBuyBaseModel->sql->startTransactionDb(); if($group_info) { //编辑活动 $field_row['groupbuy_state'] = 1; $status_flag = $this->groupBuyBaseModel->editGroupBuy($group_id, $field_row); } else { //添加活动 $status_flag = $this->groupBuyBaseModel->addGroupBuy($field_row, true); } ~~~ 三、套餐管理【方法:combo();】 1.店铺已有套餐列表 `$data = $this->shopCostModel->listByWhere($cond_row,$order_row,$page, $rows);` 2.提交 (1)购买套餐提交表单验证:`$('#form').validator({})` (2)在店铺的账期结算中扣除相关费用并且在paycenter中添加交易记录 ~~~ $flag = $this->shopCostModel->addCost($field_row, true); //记录到店铺费用表 $combo_row = $this->groupBuyQuotaModel->getGroupBuyQuotaByShopID(Perm::$shopId);//根据店铺id号查找店铺购买套餐情况 if ($combo_row) { //1、原套餐已经过期,更新套餐开始时间和结束时间 if (strtotime($combo_row['combo_endtime']) < time()) { $field['combo_starttime'] = get_date_time(); $field['combo_endtime'] = date('Y-m-d H:i:s', strtotime("+$days days")); } elseif ((time() >= strtotime($combo_row['combo_starttime'])) && (time() <= strtotime($combo_row['combo_endtime']))) { //2、原套餐尚未过期,只需更新结束时间 $field['combo_endtime'] = date('Y-m-d H:i:s', strtotime("+$days days", strtotime($combo_row['combo_endtime']))); } $op_flag = $this->groupBuyQuotaModel->renewGroupBuyCombo($combo_row['combo_id'], $field); } else { //记录不存在,添加套餐 $field['combo_starttime'] = get_date_time(); $field['combo_endtime'] = date('Y-m-d H:i:s', strtotime("+$days days")); $field['shop_id'] = Perm::$shopId; $field['shop_name'] = $this->shopInfo['shop_name']; $field['user_id'] = Perm::$userId; $field['user_nickname'] = Perm::$row['user_account']; $op_flag = $this->groupBuyQuotaModel->addGroupBuyCombo($field, true); } //在paycenter中添加交易记录 $rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Pay_Pay&met=addCombo&typ=json', $url), $formvars); ~~~