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