Commit 460c0b41 authored by pengfei's avatar pengfei

add 增加拼单申请团长接口

parent e7c5b626
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/20 3:11 下午
*/
namespace Validate;
class ColonelApplyValidate extends BaseValidate
{
protected $rule = [
'phone' => 'isMobile',
'contact_name' => 'require',
];
protected $message = [
'phone' => '请输入正确的手机号',
'contact_name' => '联系人不能为空'
];
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/20 2:38 下午
*/
namespace App\Models\marketing\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class PindanActivityColonelApply extends MysqlBase
{
const TABLE_NAME = 'pindan_activity_colonel_apply';
const CONFIG_INDEX = 'marketing';
const PRIMARY_KEY = 'colonel_apply_id';
public static function insertRecord(array $colums)
{
return self::insert($colums);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/20 2:06 下午
*/
use App\Base\Base;
use App\Services\marketing\ColonelService;
use \Validate\ColonelApplyValidate;
class ColonelController extends Base
{
/**
* Notes: 申请成为团长
* User: pengfei@yidian-inc.com
* Date: 2021/8/20 3:21 下午
* @throws \App\Exception\custom\MarketingException
* @throws \App\Exception\custom\ParamException
*/
public function applyAction()
{
$params = $this->params;
(new ColonelApplyValidate())->validate();
$applyId = ColonelService::apply($params);
return $this->success(['result' => ['applyId' => $applyId]]);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/20 2:23 下午
*/
namespace App\Services\marketing;
use App\Exception\custom\MarketingException;
use App\Models\marketing\mysql\PindanActivityColonelApply;
class ColonelService
{
/**
* Notes: 申请成为团长
* User: pengfei@yidian-inc.com
* Date: 2021/8/20 3:38 下午
* @param array $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
*/
public static function apply(array $params)
{
$colonelData = [
'phone' => $params['phone'],
'contact_name' => $params['contact_name'],
'take_place_name' => $params['take_place_name'],
'take_place_pic' => $params['take_place_pic'] ?? '',
'longitude' => $params['longitude'] ?? 0,
'latitude' => $params['latitude'] ?? 0,
'location' => $params['location'] ?? '',
'address' => $params['address'] ?? '',
'province' => $params['province'] ?? '',
'city' => $params['city'] ?? '',
'area' => $params['area'] ?? '',
];
try {
if (!$applyId = PindanActivityColonelApply::insertRecord($colonelData)) {
throw new MarketingException(['cus'=>5]);
}
return $applyId;
} catch (\MarketingException $e) {
throw new MarketingException(['cus'=>5]);
}
}
}
\ No newline at end of file
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 to comment