定制 khaleds/voucher 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

khaleds/voucher

Composer 安装命令:

composer require khaleds/voucher

包简介

Coupons and promotional codes generator for Laravel.

README 文档

README

enter image description here

Laravel Voucher Package

Coupons and voucher codes checker. you can create voucher with many conditions that fit your business.

Available Conditions

column description
code coupon or voucher code
is_available check if this voucher available or not
max_uses the max number of using this voucher
max_uses_user the max number of using this voucher per single user
starts_at start date for this voucher to be published
expires_at end date for this voucher to be closed

all of this conditions the package checking it .

what about you have a coupon for a specific users ,vendors or customers beside the other conditions ofcourse , or even i need to apply coupon for category , service or products all of them or specific ones ?

voucher_implementation_id ;) this forigen id related with table takes [class path,value as json]. you can add your voucher audience as a morph table in voucher_audiences that tacks which usable_type as a table name, usable_id as model id ,is_all bool that mean all records in this table and voucher_id . in the voucher_implementations table you can find the implementation record for each voucher the default one is applied . the default implementation just check for model table ,id or is_all check in voucher_audiences table

List of content

  • Installation
  • How Does It Work?
  • How to use
  • Advanced use

Installation

composer require khaleds/voucher

Migrate table

php artisan make:migration

Seeder

Add this to your DatabaseSeeder class in run method

	use Khaleds\Voucher\Seeder\VoucherImplementaionSeeder;
    
    $this->call(VoucherImplementaionSeeder::class);

How Does It Work?

Vouchers table

This table contain the voucher conditions like

column description
code coupon or voucher code
is_available check if this voucher available or not
max_uses the max number of using this voucher
max_uses_user the max number of using this voucher per single user
starts_at start date for this voucher to be published
expires_at end date for this voucher to be closed

Other columns

column description
discount_amount The amount to discount
is_fixed Whether or not the "discount_amount" is a percentage or a fixed price
max_uses Number of users that use this voucher
amount_cap Amount to apply it if the price greater than cap
uses The total number of uses for this voucher

If you want more condition like specific models or ids like i want this voucher for all accounts table or users table or the users with some ids you can do that in this table

Vouchers Audiences table

This table contain

column description
usable_type Table name
usable_id The id that you want to use voucher
voucher_id The voucher that you want to apply this condition on it
is_all If you want to make all users in this table can use the voucher

the relation is one to many so you can add many ids if you want per voucher

User Voucher table

This table contain the users that applied to the voucher added when you use function apply

How to use

you have 2 static classes

	// $code  : voucher code
	// model  : which model uses this voucher
	// amount : the amount that you want to apply voucher on it
	// return : voucher object if passed all conditions ex if not passed 
    VoucherFactory::get(string $code,Model $user,float $amount)->check()->get()
    
    // if you pass 0 that mean the voucher applied and not used
	// applay will add the model to voucher if passes the conditions and increment uses column
    VoucherFactory::get(string $code,Model $user,float $amount)->check()->apply(1)->get()

If you want to avoid all checks and apply the voucher

VoucherFactory::get(string $code,Model $user,float $amount)->apply(bool $is_used, string $code, Model $model))

Advanced use

what about you have an extra conditions like you want to add voucher with only country ,service , products or categories

Using

VoucherFactory::get(string $code,Model $user)->check()
// it tacks table name as a key and array of ids
->append(  
  [    
  "categories" => [1,2,3],  
  "products" => [1,2,3],  
  ]  
)
->apply(1)->get()

you just need to add your audiences in Vouchers Audiences table

if you want to overwrite the implementation class change the class path in voucher_implementations table and extend from DefaultVoucher class

khaleds/voucher 适用场景与选型建议

khaleds/voucher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 5, 最近一次更新时间为 2022 年 09 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 khaleds/voucher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 khaleds/voucher 我们能提供哪些服务?
定制开发 / 二次开发

基于 khaleds/voucher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-27