Commit 2facb1b3 authored by pengfei's avatar pengfei

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

parents 90a1496f d0399d86
...@@ -22,4 +22,9 @@ class MarketingOnlineStatusValidate extends BaseValidate ...@@ -22,4 +22,9 @@ class MarketingOnlineStatusValidate extends BaseValidate
"marketing_type" => "marketing_type 不能为空", "marketing_type" => "marketing_type 不能为空",
"online_status" => "online_status 不能为空", "online_status" => "online_status 不能为空",
]; ];
public function sceneYingxiao()
{
return $this->only(['marketing_id','online_status']);
}
} }
\ No newline at end of file
...@@ -14,6 +14,8 @@ class Marketing extends MysqlBase ...@@ -14,6 +14,8 @@ class Marketing extends MysqlBase
const MARKETING_TYPE_TUANGOU = 2; const MARKETING_TYPE_TUANGOU = 2;
const MARKETING_TYPE_MIAOSHA = 3; const MARKETING_TYPE_MIAOSHA = 3;
const MARKETING_TYPE_PINDAN = 4; const MARKETING_TYPE_PINDAN = 4;
const MARKETING_TYPE_LIEBIAN = 5;
const MARKETING_TYPE_TUANZHANG = 6;
const ONLINE_STATUS_QIDONG = 1; const ONLINE_STATUS_QIDONG = 1;
const ONLINE_STATUS_GUANBI = 2; const ONLINE_STATUS_GUANBI = 2;
...@@ -125,6 +127,10 @@ class Marketing extends MysqlBase ...@@ -125,6 +127,10 @@ class Marketing extends MysqlBase
$data['online_status'] = $where['online_status']; $data['online_status'] = $where['online_status'];
} }
if (!empty($where['marketing_type'])) {
$data['marketing_type'] = $where['marketing_type'];
}
return $data; return $data;
} }
} }
...@@ -210,8 +210,21 @@ class ColonelController extends Base ...@@ -210,8 +210,21 @@ class ColonelController extends Base
*/ */
public function bill_infoAction() public function bill_infoAction()
{ {
(new ColonelCenterValidate())->validate();
$params = $this->params; $params = $this->params;
$data = PindanActivityInviteOrderService::getPayInfoList($params); $data = PindanActivityInviteOrderService::getPayInfoList($params);
return $this->success(["result" => $data]); return $this->success(["result" => $data]);
} }
/**
* 团长分销,下单记录
* @throws \App\Exception\custom\ParamException
*/
public function invite_order_recordAction()
{
(new ColonelCenterValidate())->validate();
$params = $this->params;
$data = PindanActivityInviteOrderService::getInviteOrderRecord($params);
return $this->success(["result" => $data]);
}
} }
...@@ -155,4 +155,25 @@ class MarketingController extends Base ...@@ -155,4 +155,25 @@ class MarketingController extends Base
$this->success(); $this->success();
} }
/**
* 切换活动状态
* @throws \App\Exception\custom\ParamException
*/
public function toogle_yingxiao_online_statusAction()
{
(new MarketingOnlineStatusValidate())->scene('yingxiao')->validate();
$res = MarketingService::toogleOnlineStatus($this->params['marketing_id'],$this->params['online_status']);
$this->success(['result' => $res]);
}
/**
* 营销中心-活动列表
* @throws Exception
*/
public function yingxiao_listAction()
{
$lists = MarketingService::yingxiaoList($this->params);
$this->success(['result' => $lists]);
}
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
namespace App\Services\marketing; namespace App\Services\marketing;
use Api\PhpServices\Ksy\Ks3Api; use Api\PhpServices\Ksy\Ks3Api;
use Api\PhpUtils\Http\Request;
use App\Models\goods\mysql\Ota; use App\Models\goods\mysql\Ota;
use App\Models\goods\mysql\PindanGoodsSku; use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\marketing\mysql\Marketing; use App\Models\marketing\mysql\Marketing;
...@@ -145,6 +146,47 @@ class MarketingService ...@@ -145,6 +146,47 @@ class MarketingService
} }
} }
/**
* 营销中心-活动列表
* @param $params
* @return array
*/
public static function yingxiaoList($params)
{
$where["marketing_type"] = [Marketing::MARKETING_TYPE_LIEBIAN, Marketing::MARKETING_TYPE_TUANZHANG];
$where['ORDER'] = ["create_time" => "DESC"];
$lists = Marketing::getRecords($where);
if ($lists && is_array($lists)) {
$capitalPoolIds = array_column($lists, 'capital_pool_id');
//获取资金池列表信息
$url = config('interface', 'coupon.capitalpool.fetch_map_capitalpool');
$capitalPoolList = (new Request())->get($url, ["capital_pool_ids" => $capitalPoolIds]);
$capitalPoolList = $capitalPoolList['response']['result'] ?: [];
$poolTotal = $poolUsed = $poolLock = 0;
foreach ($lists as &$val) {
if($capitalPoolList[$val['capital_pool_id']]) {
$val['capital_pool'] = $capitalPoolList[$val['capital_pool_id']];
$poolTotal += $val['capital_pool']['capital_pool_total'];
$poolUsed += $val['capital_pool']['capital_pool_used'];
$poolLock += $val['capital_pool']['capital_pool_lock'];
}else {
$val['capital_pool'] = [];
}
$val['online_status_desc'] = Marketing::$onlineStatusDesc[$val['online_status']];
}
unset($val);
}
$poolbalance = $poolTotal - $poolUsed - $poolLock;
$poolAnalysis = ['total'=>$poolTotal,'used'=>$poolUsed,'lock'=>$poolLock,'balance'=>$poolbalance];
return ['anlysis'=>$poolAnalysis,'list' => $lists];
}
/** /**
* 分销活动列表 * 分销活动列表
* @param $params * @param $params
...@@ -830,6 +872,24 @@ class MarketingService ...@@ -830,6 +872,24 @@ class MarketingService
Marketing::updateRecord($marketingParams, ["marketing_id" => $marketingId, "marketing_type" => $marketingType]); Marketing::updateRecord($marketingParams, ["marketing_id" => $marketingId, "marketing_type" => $marketingType]);
} }
/**
* 切换活动状态
* @param $marketingId
* @param $onlineStatus
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public static function toogleOnlineStatus($marketingId,$onlineStatus)
{
if(!in_array($onlineStatus,array_keys(Marketing::$onlineStatusDesc))) {
return 0;
}
$data = [
'online_status' => $onlineStatus,
];
return Marketing::updateRecord($data, ["marketing_id" => $marketingId]);
}
/** /**
* 分销活动详情 * 分销活动详情
* @param $params * @param $params
......
...@@ -7,6 +7,7 @@ use App\Models\marketing\mysql\ColonelDistributorColonel; ...@@ -7,6 +7,7 @@ use App\Models\marketing\mysql\ColonelDistributorColonel;
use App\Models\marketing\mysql\ColonelDistributorInviteOrder; use App\Models\marketing\mysql\ColonelDistributorInviteOrder;
use App\Models\marketing\mysql\ColonelDistributorInviteOrderNum; use App\Models\marketing\mysql\ColonelDistributorInviteOrderNum;
use App\Models\marketing\mysql\ColonelDistributorPayInfo; use App\Models\marketing\mysql\ColonelDistributorPayInfo;
use App\Services\user\UserService;
class PindanActivityInviteOrderService class PindanActivityInviteOrderService
{ {
...@@ -211,4 +212,67 @@ class PindanActivityInviteOrderService ...@@ -211,4 +212,67 @@ class PindanActivityInviteOrderService
} }
return array_values($res); return array_values($res);
} }
/**
* 团长分销,下单记录
* @param array $params
* @return array
*/
public static function getInviteOrderRecord($params = [])
{
$userId = $params["user_id"];
$lastId = empty($params["last_id"]) ? "" : $params["last_id"];
$limit = empty($params["page_size"]) ? 10 : $params["page_size"];
$hour = date("H");
if ($hour < 10 && $hour > 0) {
$date = date("Y-m-d", strtotime("-1 day"));
} elseif ($hour > 16) {
$date = date("Y-m-d");
} else {
$date = date("Y-m-d");
}
$secondDay = date("Y-m-d", strtotime("$date +1 day"));
$startTime = $date." 16:00:00";
$endTime = $secondDay." 10:00:00";
$where = [];
$where["colonel_user_id"] = $userId;
$where["create_time[>]"] = $startTime;
$where["create_time[<]"] = $endTime;
$where["LIMIT"] = $limit;
$where["ORDER"] = ["invite_order_id" => "DESC"];
if (!empty($lastId)) {
$where["invite_order_id[<]"] = $lastId;
}
$list = ColonelDistributorInviteOrder::select(["invite_order_id", "user_id", "is_refund"], $where, []);
if (!empty($list)) {
$userIds = array_unique(array_column($list, "user_id"));
$userList = UserService::userWechatBind(["user_id"=>$userIds]);
if (!empty($userList)) {
$userList = array_column($userList, null, "user_id");
}
$count = count($list);
foreach ($list as $key => $item) {
if (!empty($userList[$item["user_id"]])) {
$list[$key]["user_nick"] = $userList[$item["user_id"]]["user_nick"];
$list[$key]["user_avatar"] = $userList[$item["user_id"]]["user_avatar"];
} else {
$list[$key]["user_nick"] = "";
$list[$key]["user_avatar"] = "";
}
$lastId = $item["invite_order_id"];
}
if ($count < $limit) {
$lastId = "-1";
}
} else {
$lastId = "-1";
}
return ["list" => $list, "last_id" => $lastId];
}
} }
\ 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