Commit 6f42d1d9 authored by luhongguang's avatar luhongguang

Merge branch 'colonel' of https://git.yidian-inc.com:8021/bp/goods into colonel

parents 5d81489c 356401b9
......@@ -7,7 +7,7 @@
namespace Validate;
class ColonelAddPoint extends BaseValidate
class ColonelAddPointValidate extends BaseValidate
{
protected $rule = [
'colonel_apply_id' => 'require',
......
......@@ -10,12 +10,18 @@ class ColonelConfigValidate extends BaseValidate
];
protected $message = [
'phone' => 'date 参数不能为空',
'config' => 'config 参数不能为空'
'date' => 'date 参数不能为空',
'config' => 'config 参数不能为空',
'marketing_id' => 'marketing_id 参数不能为空',
];
public function sceneDate()
{
return $this->only(["date"])->append("date", "require");
}
public function sceneAdd()
{
return $this->only(["date","config","marketing_id"])->append("marketing_id", "require");
}
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ use \Validate\ColonelApplyValidate;
use \Validate\ColonelConfigValidate;
use \Validate\ColonelAuditValidate;
use \Validate\ColonelCenterValidate;
use \Validate\ColonelAddPoint;
use \Validate\ColonelAddPointValidate;
use \App\Services\marketing\PindanActivityColonelConfigService;
use \App\Services\marketing\PindanActivityInviteOrderService;
use \App\Services\user\UserService;
......@@ -55,7 +55,7 @@ class ColonelController extends Base
*/
public function add_configAction()
{
(new ColonelConfigValidate())->validate();
(new ColonelConfigValidate())->scene('add')->validate();
$params = $this->params;
PindanActivityColonelConfigService::editColonelConfig($params);
......@@ -135,7 +135,7 @@ class ColonelController extends Base
public function manage_add_apply_pointAction()
{
$params = $this->params;
(new ColonelAddPoint())->validate();
(new ColonelAddPointValidate())->validate();
$takePlaceId = ColonelService::handleAddTaskPlace($params);
return $this->success(['result' => ['take_place_id' => $takePlaceId]]);
}
......
......@@ -30,19 +30,19 @@ class ColonelService
throw new MarketingException(MarketingException::COLONEL_APPLY_EXIST);
}
$colonelData = [
'user_id' => $params['user_id'],
'user_id' => $params['user_id'],
'life_account_id' => MarketingService::getPublicLifeAccountId(),
'phone' => $params['phone'],
'contact_name' => $params['contact_name'],
'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'] ?? '',
'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 (!empty($colonelData['take_place_name'])) {
......@@ -66,10 +66,10 @@ class ColonelService
*/
public static function isApply(int $userId): array
{
$applyInfo = ColonelDistributorColonelApply::getRecord(['user_id' => $userId],['colonel_apply_id','audit_status']);
$applyInfo = ColonelDistributorColonelApply::getRecord(['user_id' => $userId], ['colonel_apply_id','audit_status']);
return [
'is_apply' => !empty($applyInfo) ? 1 : 0,
'audit_status' => $applyInfo['audit_status']
// -1.未申请 0.未审核 1.审核通过 2.审核未通过
'apply_status' => isset($applyInfo['audit_status']) ? intval($applyInfo['audit_status']) : -1
];
}
......@@ -88,7 +88,7 @@ class ColonelService
if (empty($result['count'])) {
return $result;
}
$userMap = self::getUserMap(array_column($result['result'], 'user_id'));
$userMap = self::getUserMap(array_column($result['result'], 'user_id'));
$takePlaceMap = self::getColonelTakePlaceMap(array_column($result['result'], 'colonel_apply_id'));
foreach ($result['result'] as &$applyVal) {
$applyVal['user_avatar'] = !empty($userMap[$applyVal['user_id']]['user_avatar']) ? $userMap[$applyVal['user_id']]['user_avatar'] : '';
......@@ -124,9 +124,9 @@ class ColonelService
$incomeMap = PindanActivityInviteOrderService::incomeStatistics(["user_ids" => $userIds]);
foreach ($result['result'] as &$colonelVal) {
$userId = $colonelVal['user_id'];
$colonelVal['user_avatar'] = !empty($userMap[$userId]['user_avatar']) ? $userMap[$userId]['user_avatar'] : '';
$colonelVal['user_avatar'] = !empty($userMap[$userId]['user_avatar']) ? $userMap[$userId]['user_avatar'] : '';
$colonelVal['yesterday_income'] = !empty($incomeMap[$userId]['yesterday_reward']) ? $incomeMap[$userId]['yesterday_reward'] : 0;
$colonelVal['total_income'] = !empty($incomeMap[$userId]['all_reward']) ? $incomeMap[$userId]['all_reward'] : 0;
$colonelVal['total_income'] = !empty($incomeMap[$userId]['all_reward']) ? $incomeMap[$userId]['all_reward'] : 0;
}
unset($colonelVal);
return $result;
......@@ -245,13 +245,13 @@ class ColonelService
{
// 入库团长表
$colonelData = [
'user_id' => $applyInfo['user_id'],
'user_id' => $applyInfo['user_id'],
'colonel_apply_id' => $applyInfo['colonel_apply_id'],
'take_place_id' => 0,
'life_account_id' => $applyInfo['life_account_id'],
'phone' => $applyInfo['phone'],
'contact_name' => $applyInfo['contact_name'],
'colonel_source' => ColonelDistributorColonel::COLONEL_SOURCE_APPLY
'take_place_id' => 0,
'life_account_id' => $applyInfo['life_account_id'],
'phone' => $applyInfo['phone'],
'contact_name' => $applyInfo['contact_name'],
'colonel_source' => ColonelDistributorColonel::COLONEL_SOURCE_APPLY
];
return ColonelDistributorColonel::insertRecord($colonelData);
}
......@@ -291,7 +291,7 @@ class ColonelService
*/
private static function getPageParams(array $params = []): array
{
$params['page'] = !empty($params['page']) ? $params['page'] : 1;
$params['page'] = !empty($params['page']) ? $params['page'] : 1;
$params['page_size'] = !empty($params['page_size']) ? $params['page_size'] : 20;
return $params;
}
......
......@@ -21,6 +21,7 @@ class PindanActivityColonelConfigService
$date = $params["date"];
$type = empty($params["type"]) ? ColonelDistributorConfig::TYPE_COLONEL : $params["type"];
$configList = $params["config"];
$marketingId = $params["marketing_id"];
if (empty($configList)) {
throw new MarketingException(['cus' => MarketingException::COLONEL_CONFIG_NULL]);
......@@ -29,28 +30,25 @@ class PindanActivityColonelConfigService
if (count($configList) > 6) {
throw new MarketingException(['cus' => MarketingException::COLONEL_LEVEL_SIX]);
}
ColonelDistributorConfig::beginTransaction();
$idRes = ColonelDistributorConfig::getRecord(["date" => $date, "type" => $type], ["colonel_config_id"]);
$idRes = ColonelDistributorConfig::getRecord(["date" => $date, "type" => $type, "marketing_id" => $marketingId], ["colonel_config_id"]);
if (!empty($idRes)) {
ColonelDistributorConfig::save([
"marketing_id" => $marketingId,
"date" => $date,
"type" => $type,
"data" => $configList,
], $idRes["colonel_config_id"]);
], ["colonel_config_id" => $idRes["colonel_config_id"]]);
} else {
ColonelDistributorConfig::save([
"marketing_id" => $marketingId,
"date" => $date,
"type" => $type,
"data" => $configList,
]);
}
if (!ColonelDistributorConfig::commit()) {
ColonelDistributorConfig::rollback();
throw new MarketingException(["cus" => 5]);
}
return true;
}
......
......@@ -192,6 +192,10 @@ class UserService
if (!empty($params['user_id'])) {
$data['user_id'] = $params['user_id'];
}
if (!empty($params['phone'])) {
$data['phone'] = $params['phone'];
}
$userList = UserWechatBind::getRecords($data);
return $userList;
......
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