model = model('Wxpay'); $this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("isClosureList", $this->model->getIsClosureList()); $this->view->assign("isdefaultList", $this->model->getIsdefaultList()); $this->view->assign("paymentMethodList", $this->model->getPaymentMethodList()); $this->view->assign("quartetIsSplitList", $this->model->getQuartetIsSplitList()); } /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法 * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ public function index($ids = '') { $this->assignconfig('data', ['fufenid' => $ids]); if ($this->request->isAjax()) { list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $wxpayIdList = FufenService::instance()->getFufenGroupModel()->column('wxpay_ids'); $whereCondition = [ 'fufen' => PayConstants::WXPAY_FUFEN_ON, 'status' => PayConstants::WXPAY_STATUS_ON, ]; if ($wxpayIdList) { $wxpayIds = []; foreach ($wxpayIdList as $ids) { $wxpayIds = array_merge($wxpayIds, explode(',', $ids)); } $whereCondition['id'] = ['not in', array_unique($wxpayIds)]; } $total = $this->model ->where($where) ->where($whereCondition) ->count(); $list = $this->model ->where($where) ->where($whereCondition) ->limit($offset, $limit) ->select(); return json(["total" => $total, "rows" => $list]); } return $this->view->fetch(); } /** * 批量关联 */ public function batch_relation() { $channelids = $this->request->param('wxpay_ids'); $fufenid = $this->request->param('fufen_id'); $action = $this->request->param('action'); $origin = FufenService::instance()->getFufenGroupModel()->where(['id' => $fufenid])->find(); $origin_array = explode(',', $origin['wxpay_ids']); $params = explode(',', $channelids); if ($action == 'add') { $update = array_unique(array_merge($origin_array, $params)); } else { $update = array_unique(array_diff($origin_array, $params)); } $update = array_filter($update, function($value){ return $value; }); if ($origin['channel_ids']) { $channels = explode(',', $origin['channel_ids']); foreach ($channels as $channel_id) { Redis::instance()->del(CacheConstants::getChannelWxpayIds($channel_id)); } } FufenService::instance()->getFufenGroupModel()->update(['wxpay_ids' => implode(',', $update)], ['id' => $fufenid]); $this->success(); } public function show($ids = '') { $this->assignconfig('data', ['fufenid' => $ids]); if ($this->request->isAjax()) { $wxpayIds = FufenService::instance()->getFufenGroupModel()->where('id', $ids)->value('wxpay_ids'); if ($wxpayIds) { $whereIds = [ 'id' => ['in', $wxpayIds], 'fufen' => PayConstants::WXPAY_FUFEN_ON, ]; list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $total = $this->model ->where($where) ->where($whereIds) ->count(); $list = $this->model ->where($where) ->where($whereIds) ->limit($offset, $limit) ->select(); return json(["total" => $total, "rows" => $list]); } else { return json(["total" => 0, "rows" => []]); } } return $this->view->fetch(); } }