Commit 6b8be7da by 杨树贤

修改邀请逻辑

parent d7afcef3
<?php
namespace App\Http\Controllers;
use App\Services\AssistService;
use Illuminate\Http\Request;
/**
* 好友助力
* Class AssistsController
* @package App\Http\Controllers
*/
class AssistsController extends Controller
{
/**
* @var AssistService
*/
private $service;
/**
* AssistsController constructor.
* @param AssistService $service
*/
public function __construct(AssistService $service)
{
$this->service = $service;
}
/**
* 获取好友助力列表
* @param Request $request
* @return array
*/
public function index(Request $request)
{
$map = [
'user_id' => $request->user->user_id,
'is_api' => 1,
'exchange_id' => $request->get('exchange_id'),
];
$result = $this->service->getAssistList($map);
return $this->Export(0, 'ok', $result);
}
/**
* 添加好友助力
* 注意这个请求是助力者去请求的,不是被助力者,所以取出来的user_id其实是助力者的
* @param Request $request
* @return array
*/
public function store(Request $request)
{
$map = [
'assist_user_id' => $request->user->user_id,
'exchange_id' => $request->get('exchange_id'),
];
$result = $this->service->addAssist($map);
if ($result['errcode'] === self::SUCCESS) {
return $this->Export(0, 'ok');
} else {
return $this->Export(self::ASSIST_FAIL);
}
}
}
\ No newline at end of file
......@@ -35,6 +35,8 @@ class Controller extends BaseController
//红包兑换失败
const EXCHANGE_CODE_FAIL = 509006;
//好友助力失败
const ASSIST_FAIL = 509007;
public function Export($Errcode = 0, $ErrMsg = '', $dataArr = [])
{
......
......@@ -17,12 +17,12 @@ class ShareController extends Controller
$this->service = $service;
}
//回复报价的类型id
//分享的类型id
const INTEGRAL_TYPE_SHARE = 4;
public function store(Request $request)
{
$userId = $request->user->user_id;
$userId = $request->get('user_id');
$integralId = self::INTEGRAL_TYPE_SHARE;
$map = [
'user_id' => $userId,
......
<?php
namespace App\Services;
class AssistService
{
public function getAssistList($map = [])
{
$url = config('website.BaseUrl') . '/assists/list';
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
public function addAssist($map = [])
{
$url = config('website.BaseUrl') . '/assists/add';
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
}
\ No newline at end of file
......@@ -23,6 +23,9 @@ return [
509002 => '报价失败',
509003 => '上传商品失败',
509004 => '邀请好友失败',
509005 => '分享失败',
509006 => '兑换红包码失败',
509007 => '好友助力失败',
],
......
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