This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Esun_CustomerCoupon::configuration"
title="Customer Coupon Configuration" sortOrder="90"/>
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid"
type="Esun\CustomerCoupon\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid"/>
<type name="Magento\SalesRule\Controller\Adminhtml\Promo\Quote\Generate">
<plugin name="esun_customer_coupon_generate_for_customers"
type="Esun\CustomerCoupon\Plugin\GenerateAssignedCouponsPlugin" sortOrder="10"/>
</type>
</config>
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="adminhtml_promo_quote_edit_tab_coupons_form_prepare_form">
<observer name="esun_customer_coupon_add_customer_select"
instance="Esun\CustomerCoupon\Observer\AddCustomerSelectToCouponForm"/>
</event>
</config>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="esun_customer_coupon" frontName="esun_customer_coupon">
<module name="Esun_CustomerCoupon" before="Magento_Backend"/>
</route>
</router>
</config>
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="esun" translate="label" sortOrder="300">
<label>Esun</label>
</tab>
<section id="esun_customer_coupon" translate="label" type="text" sortOrder="360"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Customer Coupons</label>
<tab>esun</tab>
<resource>Esun_CustomerCoupon::configuration</resource>
<group id="registration_subscription" translate="label" type="text" sortOrder="10"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Registration Subscription Coupon</label>
<field id="rule_id" translate="label comment" type="select" sortOrder="10"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Cart Price Rule</label>
<comment>Selecting a rule enables the reward. Only active rules that allow auto-generated coupons are listed. Configure the $299 minimum, $24 fixed discount, usage limits and stacking behavior on the Cart Price Rule itself.</comment>
<source_model>Esun\CustomerCoupon\Model\Config\Source\AutoGeneratedCartRule</source_model>
</field>
</group>
</section>
</system>
</config>
@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="esun_customer_coupon" resource="default" engine="innodb"
comment="Customer Assigned Coupon">
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true"
comment="Entity ID"/>
<column xsi:type="int" name="coupon_id" unsigned="true" nullable="false"
comment="Coupon ID"/>
<column xsi:type="int" name="rule_id" unsigned="true" nullable="false"
comment="Sales Rule ID"/>
<column xsi:type="int" name="customer_id" unsigned="true" nullable="false"
comment="Customer ID"/>
<column xsi:type="varchar" name="source" nullable="true" length="64"
comment="Assignment Source"/>
<column xsi:type="timestamp" name="assigned_at" nullable="false" default="CURRENT_TIMESTAMP"
on_update="false" comment="Assigned At"/>
<column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP"
on_update="false" comment="Created At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
<constraint xsi:type="unique" referenceId="ESUN_CUSTOMER_COUPON_COUPON_ID_UNQ">
<column name="coupon_id"/>
</constraint>
<constraint xsi:type="unique" referenceId="ESUN_CUSTOMER_COUPON_CUSTOMER_ID_SOURCE_UNQ">
<column name="customer_id"/>
<column name="source"/>
</constraint>
<constraint xsi:type="foreign" referenceId="ESUN_CUSTOMER_COUPON_COUPON_ID_SALESRULE_COUPON_COUPON_ID"
table="esun_customer_coupon" column="coupon_id"
referenceTable="salesrule_coupon" referenceColumn="coupon_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="ESUN_CUSTOMER_COUPON_RULE_ID_SALESRULE_RULE_ID"
table="esun_customer_coupon" column="rule_id"
referenceTable="salesrule" referenceColumn="rule_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="ESUN_CUSTOMER_COUPON_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID"
table="esun_customer_coupon" column="customer_id"
referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
<index referenceId="ESUN_CUSTOMER_COUPON_CUSTOMER_ID_COUPON_ID" indexType="btree">
<column name="customer_id"/>
<column name="coupon_id"/>
</index>
<index referenceId="ESUN_CUSTOMER_COUPON_RULE_ID" indexType="btree">
<column name="rule_id"/>
</index>
</table>
</schema>
@@ -0,0 +1,27 @@
{
"esun_customer_coupon": {
"column": {
"entity_id": true,
"coupon_id": true,
"rule_id": true,
"customer_id": true,
"source": true,
"assigned_at": true,
"created_at": true
},
"constraint": {
"PRIMARY": true,
"ESUN_CUSTOMER_COUPON_COUPON_ID_UNQ": true,
"ESUN_CUSTOMER_COUPON_CUSTOMER_ID_SOURCE_UNQ": true,
"ESUN_CUSTOMER_COUPON_COUPON_ID_SALESRULE_COUPON_COUPON_ID": true,
"ESUN_CUSTOMER_COUPON_RULE_ID_SALESRULE_RULE_ID": true,
"ESUN_CUSTOMER_COUPON_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID": true,
"ESUN_CUSTOMER_COUPON_COUPON_ID": true,
"ESUN_CUSTOMER_COUPON_CUSTOMER_ID_SOURCE": true
},
"index": {
"ESUN_CUSTOMER_COUPON_CUSTOMER_ID_COUPON_ID": true,
"ESUN_CUSTOMER_COUPON_RULE_ID": true
}
}
}
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Esun\CustomerCoupon\Api\CouponNotifierInterface"
type="Esun\CustomerCoupon\Model\Notification\NullCouponNotifier"/>
<type name="Magento\SalesRule\Model\ValidateCouponCode">
<plugin name="esun_customer_coupon_validate_assignee"
type="Esun\CustomerCoupon\Plugin\ValidateAssignedCouponPlugin" sortOrder="20"/>
</type>
</config>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Customer\Controller\Account\CreatePost">
<plugin name="esun_redirect_after_registration_coupon_grant"
type="Esun\CustomerCoupon\Plugin\RedirectAfterRegistrationCouponGrant"
sortOrder="20"/>
</type>
</config>
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="customer_register_success">
<observer name="esun_customer_coupon_registration_subscription"
instance="Esun\CustomerCoupon\Observer\GrantRegistrationSubscriptionCoupon"/>
</event>
</config>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="customer_coupon" frontName="customer-coupon">
<module name="Esun_CustomerCoupon"/>
</route>
</router>
</config>
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Esun_CustomerCoupon">
<sequence>
<module name="Magento_SalesRule"/>
<module name="Magento_Customer"/>
<module name="Magento_Newsletter"/>
<module name="Magento_Checkout"/>
<module name="Esun_Cart"/>
<module name="Esun_PromotionPopup"/>
</sequence>
</module>
</config>