Commit 9e518365 by 杨树贤

初步完成邀请好友接口

parent 26c3091d
......@@ -22,6 +22,9 @@ class Controller extends BaseController
//上传商品
const UPLOAD_GOODS_FAIL = 509003;
//添加好友邀请失败
const INVITE_FAIL = 509004;
public function Export($Errcode = 0, $ErrMsg = '', $dataArr = [])
{
......
<?php
namespace App\Http\Controllers;
use App\Services\InviteService;
use App\Services\OfferService;
use Illuminate\Http\Request;
class InvitesController extends Controller
{
private $service;
public function __construct(InviteService $service)
{
$this->service = $service;
}
//回复报价的类型id
const INTEGRAL_TYPE_INVITE = 1;
public function index(Request $request)
{
$map = [
'user_id' => $request->user->user_id,
];
$result = $this->service->getInviteList($map);
return $this->Export(0, 'ok', $result);
}
public function store(Request $request)
{
$userId = $request->user->user_id;
$invitedUserId = $request->get('invited_user_id');
$map = [
'user_id' => $userId,
'invited_user_id' => $invitedUserId,
];
$result = $this->service->addInvite($map);
if ($result['errcode'] === self::SUCCESS) {
return $this->Export(0, 'ok');
} else {
return $this->Export(self::INVITE_FAIL);
}
}
}
\ No newline at end of file
<?php
namespace App\Http\Transformers;
class InviteTransformer
{
public function transform($data = [])
{
if (isset($data['data']) && is_array($data['data'])) {
}
return $data;
}
}
\ No newline at end of file
<?php
namespace App\Services;
class InviteService
{
public function getInviteList($map = [])
{
$url = config('website.BaseUrl') . '/invite/list';
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
public function addInvite($map = [])
{
$url = config('website.BaseUrl') . '/integral_bills/add';
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
return $result;
}
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ return [
509001 => '签到失败',
509002 => '报价失败',
509003 => '上传商品失败',
509004 => '邀请好友失败',
],
......
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