dataLists(new MerchantLists()); } /** * @notes 商户申请列表 */ public function apply_lists() { $page_no = $this->request->get('page_no', 1); $page_size = $this->request->get('page_size', 15); $data = Db::name('user_auth_shop')->where('type', 1)->order('id desc')->page($page_no, $page_size)->select()->each(function ($item) { $data = Merchant::where('mer_id', $item['pid'])->find(); $item['merchant'] = $data; $item['apply_id'] = $item['id']; return $item; })->toArray(); $count = Db::name('user_auth_shop')->where('type', 1)->count(); return $this->success('请求成功', ['lists' => $data, 'count' => $count, 'page_no' => $page_no, 'page_size' => $page_size]); } /** * @notes 添加商户列表 * @return \think\response\Json * @author likeadmin * @date 2024/04/23 16:35 */ public function add() { $params = (new MerchantValidate())->post()->goCheck('add'); $result = MerchantLogic::add($params); if (true === $result) { return $this->success('添加成功', [], 1, 1); } return $this->fail(MerchantLogic::getError()); } /** * @notes 编辑商户列表 * @return \think\response\Json * @author likeadmin * @date 2024/04/23 16:35 */ public function edit() { $params = (new MerchantValidate())->post()->goCheck('edit'); $result = MerchantLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } return $this->fail(MerchantLogic::getError()); } /** * @notes 审核状态 * @return \think\response\Json * @author likeadmin * @date 2024/04/23 16:35 */ public function status() { $params = (new MerchantValidate())->post()->goCheck('status'); $result = MerchantLogic::status($params); if (true === $result && $params['status'] == 1) { return $this->success('审核成功', [], 1, 1); } if (true === $result && $params['status'] == -1) { return $this->success('驳回成功', [], 1, 1); } return $this->fail(MerchantLogic::getError()); } /** * @notes 删除商户列表 * @return \think\response\Json * @author likeadmin * @date 2024/04/23 16:35 */ public function delete() { $params = (new MerchantValidate())->post()->goCheck('delete'); MerchantLogic::delete($params); return $this->success('删除成功', [], 1, 1); } /** * @notes 设置余额 */ public function set_money() { $set_money = $this->request->post('set_money', 0); $id = $this->request->post('mer_id', 0); $type = $this->request->post('type', 1); $result = MerchantLogic::set_money($id, $set_money, $type); if (true === $result) { return $this->success('设置成功', [], 1, 1); } return $this->fail(MerchantLogic::getError()); } /** * @notes 获取商户列表详情 * @return \think\response\Json * @author likeadmin * @date 2024/04/23 16:35 */ public function detail() { $params = (new MerchantValidate())->goCheck('detail'); $result = MerchantLogic::detail($params); return $this->data($result); } /** * @notes 绑定用户 */ public function bind_user() { $params = $this->request->post(); if (!isset($params['mer_id']) && !isset($params['uid'])) { return $this->fail('参数错误'); } $find = Merchant::where('uid', $params['uid'])->find(); if ($find) { return $this->fail('该用户已绑定商户'); } $res = Merchant::where('mer_id', $params['mer_id'])->update(['uid' => $params['uid']]); if ($res) { return $this->success('绑定成功', [], 1, 1); } return $this->fail('绑定失败'); } /** * @notes 绑定银行卡 */ public function bind_bank() { $params = (new BankValidate())->post()->goCheck('BindBank'); $result = MerchantLogic::bind_bank($params); if (true === $result) { return $this->success('设置成功', [], 1, 1); } return $this->fail(MerchantLogic::getError()); } /** * @notes 绑定商品 */ public function bind_goods() { $params = (new MerchantValidate())->post()->goCheck('detail'); $result = MerchantLogic::bindGoods($params); if (true === $result) { return $this->success('绑定成功', [], 1, 1); } return $this->fail(MerchantLogic::getError()); } /** * @notes 商品列表 */ public function bind_goods_lists() { $mer_id = $this->request->get('mer_id'); $page_no = $this->request->get('page_no', 1); $page_size = $this->request->get('page_size', 15); if (empty($mer_id)) { return $this->fail('参数错误'); } $data = Db::name('merchant_bind_goods')->where('mer_id', $mer_id)->page($page_no, $page_size)->select()->each(function ($item) { $item['goods_info'] = Goods::where('id', $item['goods_id'])->with(['className', 'brandName', 'unitName', 'warehouseName'])->findOrEmpty(); $item['goods_info']['sys_labels_text'] = ''; return $item; })->toArray(); $count = Db::name('merchant_bind_goods')->where('mer_id', $mer_id)->count(); return $this->success('请求成功', ['lists' => $data, 'count' => $count, 'page_no' => $page_no, 'page_size' => $page_size]); } }