getUser(); $detail=CommanderModel::getDetail($user['user_id']); if (empty($detail)) { return $this->renderError('您还不是团长'); } $settlement = $this->getSet(); $payType=$settlement['pay_type']; return $this->renderSuccess('', compact('detail','payType')); } //数据 public function index() { $user = $this->getUser(); $commander =CommanderModel::getDetail($user['user_id']); if (empty($commander)) { return $this->renderError('您还不是团长'); } return $this->renderSuccess('', compact('commander')); } /** * 我的订单列表 */ public function order($dataType) { $data = $this->postData(); $model = new OrderModel; $user = $this->getUser(); $list = $model->getList($user['user_id'], $dataType, $data); return $this->renderSuccess('', compact('list')); } /** * 提交申请 */ public function cashsubmit($data) { $user = $this->getUser(); $detail =CommanderModel::getDetail($user['user_id']); if (empty($detail)) { return $this->renderError('您还不是团长'); } $formData = json_decode(htmlspecialchars_decode($data), true); // 数据验证 $this->validation($detail, $formData); // 新增申请记录 $CashModel=new CashModel; $CashModel->save(array_merge($formData, [ 'user_id' => $user['user_id'], 'commander_id' => $detail['commander_id'], 'school_id' => $detail['school_id'], 'apply_status' => 10, 'app_id' => $user['app_id'], ])); // 冻结用户资金 if ( $detail->freezeMoney($formData['money'])) { return $this->renderSuccess('成功'); } return $this->renderError($detail->getError() ?: '提交失败'); } private function getSet() { //提现方式 10微信 20支付宝 30银行卡 $payType=['10','20','30']; $settlement=['pay_type'=>$payType,'min_money'=>0.01]; return $settlement; } /** * 数据验证 */ private function validation($detail, $data) { // 结算设置 $settlement = $this->getSet(); // 最低提现佣金 if ($data['money'] <= 0) { throw new BaseException(['msg' => '提现金额不正确']); } if ($detail['money'] <= 0) { throw new BaseException(['msg' => '当前用户没有可提现佣金']); } if ($data['money'] > $detail['money']) { throw new BaseException(['msg' => '提现金额不能大于可提现佣金']); } if ($data['money'] < $settlement['min_money']) { throw new BaseException(['msg' => '最低提现金额为' . $settlement['min_money']]); } if (!in_array($data['pay_type'], $settlement['pay_type'])) { throw new BaseException(['msg' => '提现方式不正确']); } if ($data['pay_type'] == '20') { if (empty($data['alipay_name']) || empty($data['alipay_account'])) { throw new BaseException(['msg' => '请补全提现信息']); } } elseif ($data['pay_type'] == '30') { if (empty($data['bank_name']) || empty($data['bank_account']) || empty($data['bank_card'])) { throw new BaseException(['msg' => '请补全提现信息']); } }elseif ($data['pay_type'] == '10') { //微信支付需要实名认证 $auth = UserAuth::detail($detail['user_id']); if(empty($auth)){ throw new BaseException(['msg' => '请先到个人中心->设置->实名认证']); }elseif(!empty($auth) && $auth["auth_status"] != 1){ throw new BaseException(['msg' => '您的实名认证还未审核通过']); } } } /** * 提现明细 */ public function cashlists($status = -1) { $postData = $this->postData(); $user = $this->getUser(); $user_id=$user['user_id']; $model = new CashModel; $status > -1 && $model = $model->where('apply_status', '=', $status); $list=$model->where('user_id', '=', $user_id)->order(['create_time' => 'desc']) ->paginate($postData); return $this->renderSuccess('', [ // 提现明细列表 'list' => $list ]); } /** * 结算订单列表 */ public function orderlists() { $user = $this->getUser(); $detail=CommanderModel::getDetail($user['user_id']); if (empty($detail)) { return $this->renderError('您还不是团长'); } $model = new StoreOrderModel; return $this->renderSuccess('', [ // 提现明细列表 'list' => $model->getSettled() ]); } /** * 我的外卖配送员列表 */ public function teamlists() { $user = $this->getUser(); $commander =CommanderModel::getDetail($user['user_id']); if (empty($commander)) { return $this->renderError('您还不是团长'); } $postData = $this->postData(); $postData["commander_id"] = $commander["commander_id"]; $model = new DeliverymanModel(); return $this->renderSuccess('', [ // 团长用户信息 'commander' =>$commander, // 我的团队列表 'list' => $model->getList($postData), ]); } /** * 添加配送员 */ public function add() { $postData = $this->postData(); if(empty($postData["user_id"])){ return $this->renderError('请输入用户小程序id'); } if(empty($postData["real_name"]) || empty($postData["mobile"])){ return $this->renderError('请填写姓名和手机号'); } $is_exsit = DeliverymanModel::isDeliveryman($postData["user_id"]); if($is_exsit){ return $this->renderError('该会员已成为配送员'); } $user = $this->getUser(); $commander =CommanderModel::getDetail($user['user_id']); if (empty($commander)) { return $this->renderError('您还不是团长'); } $postData["school_id"] = $commander["school_id"]; $postData["commander_id"] = $commander["commander_id"]; $model = new DeliverymanModel; // 新增记录 if ($model->add($postData["user_id"],$postData)) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } }