| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <?php
- /**
- * api新分销商合伙人Controller
- * Created by PhpStorm.
- * User: haoren
- * Date: 2020/07/22
- * Time: 15:00
- */
- namespace JinDouYun\Controller\NewCommission;
- use Exception;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use Util\Common\PartnerTools;
- use JinDouYun\Model\Customer\MCustomer;
- class ApiNewCommissionPartner extends BaseController
- {
-
- private $customerData;
- private $partnerTool;
- public function __construct($isCheckAcl = false, $isMustLogin = true, $checkToken=true)
- {
- parent::__construct($isCheckAcl, $isMustLogin, $checkToken);
- $this->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 getPartnerApplyCashList(){
- $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"])<floatval($sysData["tx_limit_money"]) || floatval($money)<floatval($sysData["tx_limit_money"])){
- // return app('json')->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);
- }
- }
|