定制 remp/crm-gifts-module 二次开发

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

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

remp/crm-gifts-module

Composer 安装命令:

composer require remp/crm-gifts-module

包简介

CRM Gifts Module

README 文档

README

This module provides gift option to SalesFunnelModule.

Installing module

We recommend using Composer for installation and update management.

composer require remp/crm-gifts-module

Enabling module

Add installed extension to your app/config/config.neon file:

extensions:
	- Crm\GiftsModule\DI\GiftsModuleExtension

Run service commands to generate CRM internals:

php bin/command.php phinx:migrate
php bin/command.php user:generate_access
php bin/command.php api:generate_access
php bin/command.php application:seed

SalesFunnelModule integration

  1. Add to your sales funnel payment_metadata fields (have to be sent together with other required sales funnel's fields; see SalesFunnelModule README):

    • payment_metadata[gift] (boolean) - if true, indicates that this purchase is gift.
    • payment_metadata[gift_email] (string) - email of customer for which is gift purchased. This can be email of existing or new customer. Gift process handles creation of new accounts.
    • payment_metadata[gift_starts_at] (string) - date when should gifted subscription start. Use DateTimeInterface::RFC3339.

    All three fields are mandatory.

  2. Put php bin/command.php gifts:activate_purchased_gift_coupons into cron. We recommend running it every 5 to 10 minutes.

  3. Create event listeners for these NotificationEvents if you want to inform customers about gift related events:

    • created_payment_gift_coupon - emitted when payment for gift subscription for confirmed (paid). Send to donor.
    • welcome_email_gift_coupon - emitted when gift subscription was created (gift subscription is created by command from previous step at gift_starts_at datetime) and donee's account was created in CRM. Send to donee (email from gift_email field).
    • new_subscription_gift - emitted when gift subscription was created (gift subscription is created by command from previous step at gift_starts_at datetime) and donee's account already existed in CRM. Send to donee (email from gift_email field).
  4. Set gift coupon attachment which should be attached to notification event sent to donor. See application config gift_subscription_coupon_attachment, can be found in web administration under category Subscriptions.

How it works

  1. PaymentItemContainerReadyEventHandler listens to PaymentItemContainerReadyEvent.

    • If payment_metadata contains valid gift fields (see above), it switches SubscriptionTypePaymentItem to GiftPaymentItem.
  2. CreateGiftCouponNewPaymentEventHandler listens to NewPaymentEvent (payment is created; not paid).

    • If payment_meta contains valid gift fields, it removes subscription_type_id from Payment (to prevent creation of subscription for donor's account).
    • Afterwords it creates payment_gift_coupons entry from gift fields.
      • This is created before payment is confirmed for legacy reasons. This helps helpdesk to search and to pair payment with gifts.
  3. GiftPaymentStatusChangeHandler listens to PaymentChangeStatusEvent.

    • If payment is PAID and it is gift subscription purchase (payment's meta contains gift === 1), NotificationEvent(created_payment_gift_coupon) with coupon attached (see integration) is emitted.
  4. Command php bin/command.php gifts:activate_purchased_gift_coupons is running in background and activating gift subscriptions when time >= gift_starts_at.

    • Donee account:
      • If account with gift_email exists, it is used for gift.
      • Otherwise new account is created with user.source = PaymentGiftCouponsRepository::USER_SOURCE_GIFT_COUPON.
    • New subscription is attached to donee's account with subscription.type = SubscriptionsRepository::TYPE_GIFT.
    • You can configure subscription extension method by calling setExtendMethod in your configuration file like this:
    activatePurchasedGiftCouponsCommand:
    	setup:
    		- setExtendMethod('extend_same_content_access')
  5. SendWelcomeEmailHandler listens to UserRegisteredEvent.

    • If created user has source === PaymentGiftCouponsRepository::USER_SOURCE_GIFT_COUPON, NotificationEvent(welcome_email_gift_coupon) is emitted.
  6. SubscriptionsStartsEventHandler listens to SubscriptionStartsEvent.

    • If subscription has type === SubscriptionsRepository::TYPE_GIFT and account wasn't created in last 15 minutes (by command), NotificationEvent(new_subscription_gift) is emitted.

Notification email after the payment

Both of the following options require REMP Mailer integration, or other custom implementation handling NotificationEvent.

Default email

If you want to just use the defaults provided by the module, you can enable the event handler responsible for sending the notification email. In one of your custom (internal) modules, add this snippet:

<?php

namespace Crm\FooModule;

class FooModule extends CrmModule
{
    public function registerEventHandlers(\League\Event\Emitter\Emitter $emitter)
    {
        // ...
        $emitter->addListener(
            \Crm\PaymentsModule\Events\PaymentChangeStatusEvent::class,
            $this->getInstance(\Crm\GiftsModule\Events\GiftPaymentStatusChangeHandler::class)
        );
        // ...
    }
    // ...
}

GiftsModule will try to send an email with template code created_payment_gift_coupon. You can use these variables in your template:

  • variable_symbol (string)
  • donated_to_email (string)
  • gift_starts_at (RFC3339-formatted string)

You can also configure gift_subscription_coupon_attachment option in the CRM admin configuration. If it's present, the email will use the attachment provided in the config (e.g. with PDF coupon). The attachment is static and not personalized.

ScenariosModule

If you don't want to use the defaults, you can configure custom scenario to send the emails.

To differentiate gift emails from the regular ones, you need to add a scenario condition that matches your implementation. The two most common are:

  • Payment - Payment has items of type. Use this if you create the gift payment manually when you create the payment (e.g. in sales funnels). You can then make a condition to send payments with gift items different email.
  • Order - Has product with template name. Use this if you use our ProductsModule (eshop) to sell your gift subscriptions. If you use it, you probably separated your gift subscriptions with their own shop template. You can use it to differentiate these type of orders.

You're free to extend the scenario and your own conditions. Read more in the ScenariosModule README.

DataProviders

SubscriptionFormDataProvider - validation within subscription's update form

SubscriptionFormDataProvider was added to validate update of start time for gifted subscriptions against parent payment's paid_at date. For accounting reasons, the subscription must not start before the payment confirmation date.

remp/crm-gifts-module 适用场景与选型建议

remp/crm-gifts-module 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.96k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 12 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 remp/crm-gifts-module 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 16.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 7
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-02