postData(); $SupplierModel = new SupplierModel; $list = $SupplierModel->supplierList($param); $store_open = SettingModel::getStoreOpen(); return $this->renderSuccess('', compact('list','store_open')); } //店铺列表 public function getLists() { $param = $this->postData(); $is_add = 0;//默认未添加群 // 当前用户信息 $user = $this->getUser(); if(!empty($param["source"]) && $param["source"] == 1){ //来自于点击企业微信客服的链接 $save_data=[ "shop_supplier_id"=>$param["shop_supplier_id"], "user_id"=>$user["user_id"], "app_id"=>$user["app_id"], ]; $model = new GroupModel; $user_group = $model->add($save_data); if($user_group){ $is_add = 1; } }else{ //来自于扫码 $where=[ "shop_supplier_id"=>$param["shop_supplier_id"], "user_id"=>$user["user_id"] ]; $user_group = GroupModel::detailByCondition($where); if(!empty($user_group)){ $is_add = 1; } } $SupplierModel = new SupplierModel; $result = $SupplierModel->getLists($param["shop_supplier_id"]); $list=$result["list"]; $index=$result["index"]; $data = PlusSettingModel::getItem('basic'); return $this->renderSuccess('', compact('list','index','data','is_add')); } //店铺列表 public function category() { $category = CategoryModel::getALL()->toArray(); $category = array_merge([['category_id' => 0, 'name' => '全部']], $category); return $this->renderSuccess('', compact('category')); } /** * 供应商中心主页 */ public function index() { $data = $this->postData(); $supplier = new SupplierModel; $user = $this->getUser(false); //获取店铺信息 $detail = $supplier->getDetail($data, $user); if (!$detail) { return $this->renderError('店铺不存在'); } //banner图 $AdModel = new AdModel; $adList = $AdModel->getIndex(['shop_supplier_id' => $data['shop_supplier_id'], 'status' => 1], 5); //优惠券 $dataCoupon['shop_supplier_id'] = $data['shop_supplier_id']; $model = new CouponModel; $couponList = $model->getWaitList($dataCoupon, $user, 1); // 访问记录 (new VisitModel())->addVisit($user, $detail, $data['visitcode'], null); //直播列表 $model = new RoomModel(); $liveList = $model->getStoreList($this->postData()); //是否显示直播 $liv_status = SettingModel::getItem('live'); //是否开启客服 $service_open = SettingModel::getSysConfig()['service_open']; //店铺客服信息 $mp_service = ServiceModel::detail($data['shop_supplier_id']); // 会员卡数量 $card_num = CardrModel::getCardCount(); //获取门店信息 $store_setting = SettingModel::getItem("store"); $store_id = ''; //展示门店的信息 if(!empty($store_setting) &&!empty($store_setting["store_type"]) && $store_setting["store_type"] == 1){ $store_id = storeModel::getStoreIdBySupplierId($data['shop_supplier_id']); } return $this->renderSuccess('', compact('detail', 'couponList', 'adList', 'liveList', 'liv_status', 'service_open', 'mp_service', 'card_num', 'store_id')); } //成交数据 public function tradeData($url = '') { $data = $this->postData(); $user = $this->getUser(); $data['shop_supplier_id'] = $this->getSupplierUser($user)['shop_supplier_id']; if (!$data['shop_supplier_id'] > 0) { return $this->renderError('您还未开通店铺'); } $is_open = SettingModel::getItem('live')['is_open']; //累积成交笔数 $totalCount = OrderModel::getTotalPayOrder($data['shop_supplier_id']); //今日成交笔数 $todayCount = OrderModel::getTodayPayOrder($data['shop_supplier_id']); //累积领取 $supplier = SupplierModel::detail($data['shop_supplier_id']); // 客服消息 $msg_count = ChatModel::getNoReadCount($this->getSupplierUser($user)['supplier_user_id']); $member=MemberModel::supplierDetail([ 'shop_supplier_id'=>$data['shop_supplier_id'], 'is_expire'=>0 ]); return $this->renderSuccess('', compact('totalCount', 'todayCount', 'supplier', 'is_open', 'msg_count','member')); } /** * 付押金 */ public function deposit() { // 用户信息 $user = $this->getUser(); $supplier = SupplierModel::detail($this->getSupplierUser($user)['shop_supplier_id'], ['category']); // 类目 $category = $supplier['category']; if ($this->request->isGet()) { // 返回结算信息 return $this->renderSuccess('', compact('category')); } $params = $this->request->param(); $plans = (new MemberPlanModel())->detail($params['plan_id']); $result=['data'=>['order_id'=>0]]; if ($plans['price'] > 0){ $memberService = new MemberService(); $result = $memberService->createOrder($supplier['shop_supplier_id'], $params['plan_id'], $user); if (!$result['status']){ return $this->renderError($result['msg'] ?: '创建订单失败'); } } // 生成订单 $model = new DepositOrderModel; $order_id = $model->createOrder($user, $supplier,$result); if (!$order_id) { return $this->renderError($model->getError() ?: '创建订单失败'); } // 在线支付 //$payment = DepositOrderModel::onOrderPayment($user, $model, $params['pay_type'], $params['pay_source']); // 返回结算信息 return $this->renderSuccess('', [ 'order_id' => $order_id, // 订单id ]); } /** * 立即支付 */ public function pay($order_id) { // 用户信息 $user = $this->getUser(); // 获取订单详情 $model = DepositOrderModel::getUserOrderDetail($order_id, $user['user_id']); $params = $this->postData(); if ($this->request->isGet()) { // 开启的支付类型 $payTypes = AppModel::getPayType($model['app_id'], $params['pay_source']); // 支付金额 $payPrice = $model['pay_price']; $balance = $user['balance']; return $this->renderSuccess('', compact('payTypes', 'payPrice', 'balance')); } // 订单支付事件 if ($model['pay_status'] != 10) { return $this->renderError($model->getError() ?: '订单已支付'); } // 构建微信支付请求 $DepositOrderModel = new DepositOrderModel; $payInfo = $DepositOrderModel->OrderPay($params, $model, $user); if (!$payInfo) { return $this->renderError($DepositOrderModel->getError() ?: '订单支付失败'); } // 支付状态提醒 return $this->renderSuccess('', [ 'order_id' => $order_id, // 订单id 'pay_type' => $payInfo['payType'], // 支付方式 'payment' => $payInfo['payment'], // 微信支付参数 'order_type' => OrderTypeEnum::CASH, //订单类型 'use_balance' => $payInfo['use_balance']// 是否使用余额 ]); } //店铺数据 public function storedata() { $user = $this->getUser(); $shop_supplier_id = $this->getSupplierUser($user)['shop_supplier_id']; //成交量 $order = (new OrderService($shop_supplier_id))->getData(); // 访问量 $visit = (new UserService($shop_supplier_id))->getData(); //订单结算 $ordersettle = (new OrderSettledModel())->getList($shop_supplier_id, $this->postData()); return $this->renderSuccess('', compact('order', 'visit', 'ordersettle')); } /** * 详情 */ public function settledetail($settled_id) { $model = OrderSettledModel::detail($settled_id); $order = OrderModel::detail($model['order_id']); return $this->renderSuccess('', compact('model', 'order')); } public function editPass() { // 用户信息 $user = $this->getUser(); $model = UserModel::detail(['user_id' => $user['user_id']]); if ($this->request->isGet()) { return $this->renderSuccess('', compact('model')); } if ($model->editPass($this->postData())) { return $this->renderSuccess('修改成功'); } else { return $this->renderError($model->getError() ?: '修改失败'); } } public function refundDeposit() { $data = $this->postData(); $model = new DepositRefundModel; $shop_supplier=SupplierModel::detail($data['shop_supplier_id']); if(!$shop_supplier){ return $this->renderError('店铺不存在'); } if ($shop_supplier['status']==10){ return $this->renderError('退还押金申请中,不能重复申请'); } $data['deposit_money']=$shop_supplier['deposit_money']; if($model->add($data)){ return $this->renderSuccess('提交成功'); }else{ return $this->renderError($model->getError() ?: '提交失败'); } } }