红包活动,未选择默认消费补贴
This commit is contained in:
parent
be06847e9a
commit
2194197d6b
@ -84,11 +84,44 @@ class StoreActivityUserDao extends BaseDao
|
|||||||
return $data->value ?? 0;
|
return $data->value ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 用下面的 default()
|
||||||
|
* @param int $userId
|
||||||
|
* @param int $activityId
|
||||||
|
* @return StoreActivityUser|array|mixed|\think\Model|null
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
public function getOne(int $userId, int $activityId = 1)
|
public function getOne(int $userId, int $activityId = 1)
|
||||||
{
|
{
|
||||||
return StoreActivityUser::where('user_id', $userId)->where('activity_id', $activityId)->where('status', 1)->find();
|
return StoreActivityUser::where('user_id', $userId)->where('activity_id', $activityId)->where('status', 1)->find();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户参加的活动类型,默认为消费返利
|
||||||
|
* @param int $userId
|
||||||
|
* @param int $activityId
|
||||||
|
* @return StoreActivityUser|array|mixed|\think\Model|null
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function default(int $userId, int $activityId = 1)
|
||||||
|
{
|
||||||
|
$default = StoreActivityUser::where('user_id', $userId)->where('activity_id', $activityId)->where('status', 1)->find();
|
||||||
|
if (empty($default)) {
|
||||||
|
$couponId = StoreConsumption::where('type', StoreConsumption::TYPE_OWNER_CONSUMPTION)->value('coupon_id');
|
||||||
|
$default - new StoreActivityUser();
|
||||||
|
$default->user_id = $userId;
|
||||||
|
$default->activity_id = $activityId;
|
||||||
|
$default->value = $couponId;
|
||||||
|
$default->status = 1;
|
||||||
|
$default->save();
|
||||||
|
}
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户参与活动的状态
|
* 获取用户参与活动的状态
|
||||||
* @param int $userId 用户id
|
* @param int $userId 用户id
|
||||||
|
@ -79,7 +79,7 @@ class StoreConsumptionUserDao extends BaseDao
|
|||||||
*/
|
*/
|
||||||
public function promoter(int $userId, $groupOrder, int $spreadUserId)
|
public function promoter(int $userId, $groupOrder, int $spreadUserId)
|
||||||
{
|
{
|
||||||
$activityUser = (new StoreActivityUserDao())->getOne($userId);
|
$activityUser = (new StoreActivityUserDao())->default($userId);
|
||||||
$consumption = (new StoreConsumptionDao())->getOne($activityUser['value'] ?? 0);
|
$consumption = (new StoreConsumptionDao())->getOne($activityUser['value'] ?? 0);
|
||||||
//用户没有参加 消费金活动 或 已超过任务完成时间
|
//用户没有参加 消费金活动 或 已超过任务完成时间
|
||||||
$endTime = $this->getEndTime($activityUser['create_time'] ?? '2024-01-01 00:00:00');
|
$endTime = $this->getEndTime($activityUser['create_time'] ?? '2024-01-01 00:00:00');
|
||||||
@ -122,7 +122,7 @@ class StoreConsumptionUserDao extends BaseDao
|
|||||||
public function guest(int $userId, $groupOrder, int $spreadUserId)
|
public function guest(int $userId, $groupOrder, int $spreadUserId)
|
||||||
{
|
{
|
||||||
// 查询推荐人的消费金类型
|
// 查询推荐人的消费金类型
|
||||||
$spreadActivityUser = (new StoreActivityUserDao())->getOne($spreadUserId);
|
$spreadActivityUser = (new StoreActivityUserDao())->default($spreadUserId);
|
||||||
$endTime = $this->getEndTime($spreadActivityUser['create_time'] ?? '2024-01-01 00:00:00');
|
$endTime = $this->getEndTime($spreadActivityUser['create_time'] ?? '2024-01-01 00:00:00');
|
||||||
$spreadConsumption = (new StoreConsumptionDao())->getOne($spreadActivityUser['value'] ?? 0);
|
$spreadConsumption = (new StoreConsumptionDao())->getOne($spreadActivityUser['value'] ?? 0);
|
||||||
// 查询推荐人满足条件的有效订单
|
// 查询推荐人满足条件的有效订单
|
||||||
|
Loading…
x
Reference in New Issue
Block a user