partnerTool = new PartnerTools($this->onlineEnterpriseId); $this->customerData = $this->partnerTool->getCustomerDataByUserCenterId($this->onlineUserId); } /** * 获取账户信息 */ public function getCommissionPartnerData(){ if($this->customerData["isPartner"]==0){ parent::sendOutput('您还不是合伙人', ErrorCode::$paramError); } $data = $this->partnerTool->getPartnerData($this->customerData["id"],$this->onlineUserId); if(empty($data)){ parent::sendOutput('数据不存在', ErrorCode::$paramError); } parent::sendOutput($data); } /** * 获取分佣明细 */ public function getCommissionPartnerDetail(){ $params = $this->request->getRawJson(); if(empty($params)){ parent::sendOutput('参数为空', ErrorCode::$paramError); } $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $data = $this->partnerTool->getCommissionDetail($this->customerData["id"],$selectParams); parent::sendOutput($data); } /** * 获取分佣账户余额明细 */ public function getCommissionPartnerBalanceDetail(){ $params = $this->request->getRawJson(); if(empty($params)){ parent::sendOutput('参数为空', ErrorCode::$paramError); } $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $data = $this->partnerTool->getCommissionBalanceDetail($this->customerData["id"],$selectParams); parent::sendOutput($data); } public function partnerApplyCash(){ // $cache = Factory::cache('systask'); // $key = "partnercashcache".'::'.$this->enterpriseId; // $result = $this->cache->get($key); // if(!empty($result)){ // return ["code"=>-1,"msg"=>"操作频繁"]; // } // $this->cache->set($key,1,10); // [$money] = UtilService::getMore([ // ['money', 0, 'is_numeric', '请输入正确的提现金额'], // ], $request, true); // //缓存 // $redis = \think\facade\Cache::store('redis'); // $key = 'user_tixian_' . $request->user['uid']; // $bool = $redis->handler()->exists($key); // if ($bool) { // return app('json')->fail('您的操作过于频繁,请稍等再重试!'); // } // $redis->set($key,1,10);//30秒缓存 // $user = $request->user; // if(empty($user["openid"])){ // return app('json')->fail('您还未绑定微信'); // } // if(floatval($money)<=0){ // return app('json')->fail('请输入正确的提现金额'); // } // if(floatval($money)>$user["money"]){ // return app('json')->fail('您的余额不足,无法提现'); // } // if(empty($user["bank_type"]) || empty($user["bank_num"]) || empty($user["bank_name"])){ // return app('json')->fail('您还未绑定提现账户'); // } // if($user["bank_type"]!="alipay" && empty($user["bank_ad"])){ // return app('json')->fail('您还未绑定提现开户行'); // } // $sysData = (new SysModel)->where("id",1)->find(); // if(floatval($user["money"])fail("满{$sysData['tx_limit_money']}元,才可提现"); // } // //提现手续费 // $hand_money = $sysData["tx_process_per"] > 0 ? floatval($money) * $sysData["tx_process_per"] / 100 : 0; // $hand_money = num_min_format($hand_money); // $save=[]; // $save["uid"] = $user["uid"]; // $save["bank_type"] = $user["bank_type"]; // $save["bank_num"] = $user["bank_num"]; // $save["bank_name"] = $user["bank_name"]; // $save["bank_ad"] = $user["bank_ad"]; // $save["money"] = floatval($money); // $save["hand_money"] = ($sysData["tx_process_max"] > 0 && $hand_money > $sysData["tx_process_max"]) ? $sysData["tx_process_max"] : $hand_money; // $save["tx_money"] = $save["money"] - $save["hand_money"]; // $save["status"] = 0; // $save["time"] = time(); // try{ // Db::startTrans(); // //插入提现申请 // $tx_id = (new TxModel)->insertGetId($save); // if(empty($tx_id)){ // return app('json')->fail('提交失败'); // } // //更新提现账户余额并添加明细 // $r= (new UserDetailModel)->txApplyMoney($user["uid"],floatval($money),$tx_id); // if(!$r){ // (new TxModel)->where("id",$tx_id)->delete(); // return app('json')->fail('提交失败'); // } // Db::commit(); // $redis->delete($key); // return app('json')->success('提交成功,等待客服处理'); // } catch (DbException $db){ // Db::rollback(); // return app('json')->fail("订单生成失败"); // } } /** * 添加上下级关系 * @throws Exception */ public function relationshipBusinessman() { $params = $this->request->getRawJson(); if(empty($params)){ parent::sendOutput('参数为空', ErrorCode::$paramError); } $data = [ 'businessmanId' => getArrayItem($params, 'businessmanId'), 'source' => getArrayItem($params, 'source'), ]; foreach($data as $key => $value){ if(empty($value) && $value !== 0){ parent::sendOutput($key.'参数错误', ErrorCode::$paramError); } } $modelResult = $this->objMCommissionBusinessman->relationshipBusinessman($data); if(!$modelResult->isSuccess()){ parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode()); } parent::sendOutput($modelResult->getData()); } /** * 分销商详情 */ public function getInfoBusinessman() { $where['userCenterId'] = $this->onlineUserId; $modelResult = $this->objMCommissionBusinessman->getInfoBusinessman($where); if(!$modelResult->isSuccess()){ parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode()); } parent::sendOutput($modelResult->getData()); } /** * 查询分销商的所有下级 * @throws Exception */ public function getAllSub() { $params = $this->request->getRawJson(); if(empty($params)){ parent::sendOutput('参数为空', ErrorCode::$paramError); } $data = [ 'id' => isset($params['id']) ? $params['id'] : '', 'level' => isset($params['level']) ? $params['level'] : '', 'page' => isset($params['page']) ? $params['page'] : '', 'pageSize' => isset($params['pageSize']) ? $params['pageSize'] : '', ]; foreach($data as $key => $value){ if(empty($value) && $value !== 0){ parent::sendOutput($key.'参数错误', ErrorCode::$paramError); } } $pageParams = pageToOffset($params['page'],$params['pageSize']); $data['limit'] = $pageParams['limit']; $data['offset'] = $pageParams['offset']; $modelResult = $this->objMCommissionBusinessman->getAllSub($data); if(!$modelResult->isSuccess()){ parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode()); } $returnData = $modelResult->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], 'subTotal' => $returnData['subTotal'], 'businessmanTotal' => $returnData['businessmanTotal'], 'subBusinessmanTotal' => $returnData['subBusinessmanTotal'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } }