Commit 993f9f8c by 杨树贤

确认兑换接口

parent 939b4129
......@@ -25,6 +25,9 @@ class Controller extends BaseController
const CAN_NOT_ASSIST = 109009;
//助力类型不能是话费的兑换
const EXCHANGE_TYPE_ERROR = 109011;
//助力人数不足
const ASSIST_NO_ENOUGH = 109012;
//不能助力了(助力人数已满或者用户已经助力过)
const CAN_NOT_INVITE_MYSELF = 109010;
......@@ -57,6 +60,9 @@ class Controller extends BaseController
//好友助力失败
const ASSIST_FAIL = 509007;
//确认兑换失败
const EXCHANGE_CONFIRM_FAILED = 509008;
public function Export($Errcode = 0, $ErrMsg = '', $dataArr = [])
{
......
......@@ -103,19 +103,37 @@ class UserExchangesController extends Controller
*/
public function confirm(Request $request, UserExchangeService $service)
{
$userId = $request->user->user_id;
$exchangeId = $request->get('exchange_id');
if (empty($exchangeId)) {
return $this->Export(self::INVALID_PARAMETER);
}
return $this->Export(0, 'ok');
//
// $result = $service->confirmExchange($exchangeId);
// if ($result['errcode'] == 0) {
// return $this->Export($result['errcode'], 'ok');
// } else {
// return $this->Export($result['errcode'], '确认兑换失败');
// }
//判断是否可以兑换
$redis = new RedisModel();
$user = json_decode($redis->hget('ic_user', $userId), true);
//未认证的用户不可兑换
if (isset($user['auth_type'])) {
if ($user['auth_type'] == 0) {
return $this->Export(self::CAN_NOT_EXCHANGE);
}
} else {
return $this->Export(self::CAN_NOT_EXCHANGE);
}
//好友助力需要满足两人
$assists = json_decode($redis->hget('ic_welfare_assists', $exchangeId), true);
$assistsCount = $assists ? count($assists) : 0;
if ($assistsCount < 2) {
return $this->Export(self::ASSIST_NO_ENOUGH);
}
$result = $service->confirmExchange($exchangeId,$userId);
if ($result['errcode'] == 0) {
return $this->Export(0, 'ok');
} else {
return $this->Export(self::EXCHANGE_CONFIRM_FAILED);
}
}
}
\ No newline at end of file
......@@ -65,4 +65,17 @@ class UserExchangeService
return $exchangeStatus;
}
public function confirmExchange($exchangeId,$userId)
{
$url = config('website.BaseUrl') . '/user_exchanges/exchange/confirm';
$map = [
'exchange_id' => $exchangeId,
'user_id' => $userId,
];
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ return [
109009 => '助力人数已满或者您已经助力过',
109010 => '自己不能邀请自己',
109011 => '助力类型只允许用于微信转账',
109012 => '助力人数不足',
109100 => '今天已经兑换过了,请明天再来吧',
109101 => '兑换名额被抢光了',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment