feat : coupon

This commit is contained in:
2025-02-27 15:32:36 +08:00
parent 81bc1d5456
commit d046b34cea
11 changed files with 338 additions and 17 deletions

View File

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace App\Model;
use App\Constants\Common\CouponCode;
use Hyperf\Collection\Collection;
use Hyperf\DbConnection\Model\Model;
/**
@@ -55,6 +57,15 @@ class CouponDispenseLog extends Model
return $this->find($id);
}
/**
* @param array $ids
* @return array
*/
public function getListByIds(array $ids): array
{
return $this->whereIn('id',$ids)->get()->toArray();
}
/**
* @param int $id
* @param int $receiveCount
@@ -64,6 +75,30 @@ class CouponDispenseLog extends Model
{
return $this->where('id', $id)->increment('receive_count' , $receiveCount);
}
/**
* @return array
*/
public function getNoReceiveCount(): array
{
$all = $this
->where('claim_rule',CouponCode::DISPENSE_CLAIM_RULE_HOME_POPUPS)
->whereColumn('total_count','!=','receive_count')
->where('appoint_group',CouponCode::DISPENSE_APPOINT_GROUP_ALL_PEOPLE)
->pluck('id')
->toArray();
$appoint = $this
->where('claim_rule',CouponCode::DISPENSE_CLAIM_RULE_HOME_POPUPS)
->where('appoint_group','!=',CouponCode::DISPENSE_APPOINT_GROUP_ALL_PEOPLE)
->pluck('id')
->toArray();
return [
'all' => $all,
'appoint' => $appoint
];
}
}