123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <?php
- namespace app\api\controller;
- use think\facade\Lang;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 用户提现账户控制器
- */
- class Memberbank extends MobileMember
- {
- public function initialize()
- {
- parent::initialize();
- Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberbank.lang.php');
- }
- /**
- * @api {POST} api/memberbank/bank_list 获取用户提现账户
- * @apiVersion 1.0.0
- * @apiGroup Memberbank
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {String} result.bank_list 提现账户
- * @apiSuccess {String} result.bank_list.memberbank_id ID
- * @apiSuccess {String} result.bank_list.memberbank_type 类型bank银行 alipay支付宝
- * @apiSuccess {String} result.bank_list.memberbank_truename 收款人姓名
- * @apiSuccess {String} result.bank_list.memberbank_name 收款银行
- * @apiSuccess {String} result.bank_list.memberbank_no 收款账户
- */
- public function bank_list()
- {
- $memberbank_model = model('memberbank');
- $bank_list = $memberbank_model->getMemberbankList(array('member_id' => $this->member_info['member_id']));
- $member_wxinfo = unserialize($this->member_info['member_wxinfo']);
- if (!empty($member_wxinfo) && is_array($member_wxinfo) && isset($member_wxinfo['member_wxopenid']) && $member_wxinfo['member_wxopenid']) {
- if (empty($bank_list)) {
- $bank_list = array();
- }
- $bank_list[] = array('memberbank_id' => -1, 'memberbank_type' => 'weixin', 'memberbank_no' => $member_wxinfo['nickname'], 'member_wxinfo' => $member_wxinfo);
- }
- ds_json_encode(10000, '', array('bank_list' => $bank_list));
- }
- /**
- * @api {POST} api/memberbank/bank_info 获取提现账户
- * @apiVersion 1.0.0
- * @apiGroup Memberbank
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {String} memberbank_id 提现账户ID
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {String} result.bank_info 提现账户信息
- * @apiSuccess {String} result.bank_info.memberbank_id ID
- * @apiSuccess {String} result.bank_info.memberbank_type 类型bank银行 alipay支付宝
- * @apiSuccess {String} result.bank_info.memberbank_truename 收款人姓名
- * @apiSuccess {String} result.bank_info.memberbank_name 收款银行
- * @apiSuccess {String} result.bank_info.memberbank_no 收款账户
- */
- public function bank_info()
- {
- $memberbank_id = intval(input('post.memberbank_id'));
- $memberbank_model = model('memberbank');
- $condition = array();
- $condition[] = array('memberbank_id', '=', $memberbank_id);
- $bank_info = $memberbank_model->getMemberbankInfo($condition);
- if (!empty($memberbank_id) && $bank_info['member_id'] == $this->member_info['member_id']) {
- ds_json_encode(10000, '', array('bank_info' => $bank_info));
- } else {
- ds_json_encode(10001, lang('memberbank_does_not_exist'));
- }
- }
- /**
- * @api {POST} api/memberbank/bank_del 删除提现账户
- * @apiVersion 1.0.0
- * @apiGroup Memberbank
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {String} memberbank_id 提现账户ID
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- */
- public function bank_del()
- {
- $memberbank_id = intval(input('post.memberbank_id'));
- $memberbank_model = model('memberbank');
- $condition = array();
- $condition[] = array('memberbank_id', '=', $memberbank_id);
- $condition[] = array('member_id', '=', $this->member_info['member_id']);
- $memberbank_model->delMemberbank($condition);
- ds_json_encode(10000, '', 1);
- }
- /**
- * @api {POST} api/memberbank/bank_add 新增提现账户
- * @apiVersion 1.0.0
- * @apiGroup Memberbank
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {String} memberbank_type 类型bank银行 alipay支付宝
- * @apiParam {String} memberbank_truename 收款人姓名
- * @apiParam {String} memberbank_name 收款银行
- * @apiParam {String} memberbank_no 收款账户
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- */
- public function bank_add()
- {
- $memberbank_model = model('memberbank');
- $data = array(
- 'member_id' => $this->member_info['member_id'],
- 'memberbank_type' => input('post.memberbank_type'),
- 'memberbank_truename' => input('post.memberbank_truename'),
- 'memberbank_name' => input('post.memberbank_name'),
- 'memberbank_no' => input('post.memberbank_no'),
- );
- $memberbank_validate = ds_validate('memberbank');
- if (!$memberbank_validate->scene('add')->check($data)) {
- ds_json_encode(10001, $memberbank_validate->getError());
- }
- $result = $memberbank_model->addMemberbank($data);
- if ($result) {
- ds_json_encode(10000, '', array('memberbank_id' => $result));
- } else {
- ds_json_encode(10001, lang('ds_common_op_fail'));
- }
- }
- /**
- * @api {POST} api/memberbank/bank_edit 编辑提现账户
- * @apiVersion 1.0.0
- * @apiGroup Memberbank
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {String} memberbank_id 提现账户ID
- * @apiParam {String} memberbank_type 类型bank银行 alipay支付宝
- * @apiParam {String} memberbank_truename 收款人姓名
- * @apiParam {String} memberbank_name 收款银行
- * @apiParam {String} memberbank_no 收款账户
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- */
- public function bank_edit()
- {
- $memberbank_id = intval(input('post.memberbank_id'));
- $memberbank_model = model('memberbank');
- //验证提现账户是否为本人
- $memberbank_info = $memberbank_model->getOneMemberbank($memberbank_id);
- if ($memberbank_info['member_id'] != $this->member_info['member_id']) {
- ds_json_encode(10001, lang('param_error'));
- }
- $data = array(
- 'memberbank_type' => input('post.memberbank_type'),
- 'memberbank_truename' => input('post.memberbank_truename'),
- 'memberbank_name' => input('post.memberbank_name'),
- 'memberbank_no' => input('post.memberbank_no'),
- );
- $memberbank_validate = ds_validate('memberbank');
- if (!$memberbank_validate->scene('edit')->check($data)) {
- ds_json_encode(10001, $memberbank_validate->getError());
- }
- $result = $memberbank_model->editMemberbank($data, array('memberbank_id' => $memberbank_id, 'member_id' => $this->member_info['member_id']));
- if ($result) {
- ds_json_encode(10000, '', 1);
- } else {
- ds_json_encode(10001, lang('ds_common_op_fail'));
- }
- }
- }
|