refactor(shop-coupon): migrate admin module to DI and release 0.266

This commit is contained in:
2026-02-14 00:05:23 +01:00
parent 88e5673569
commit 40e777afe6
40 changed files with 1668 additions and 426 deletions

View File

@@ -1,54 +0,0 @@
<?php
namespace admin\factory;
class ShopCoupon
{
static public function details( int $coupon_id )
{
global $mdb;
return $mdb -> get( 'pp_shop_coupon', '*', [ 'id' => $coupon_id ] );
}
public static function coupon_delete( $coupon_id )
{
global $mdb;
return $mdb -> delete( 'pp_shop_coupon', [ 'id' => $coupon_id ] );
}
public static function save( $coupon_id, $name, $status, $send, $used, $type, $amount, $one_time, $include_discounted_product, $categories )
{
global $mdb;
if ( !$coupon_id )
{
if ( $mdb -> insert( 'pp_shop_coupon', [
'name' => $name,
'status' => $status,
'used' => $used,
'type' => $type,
'amount' => $amount,
'one_time' => $one_time,
'send' => $send,
'include_discounted_product' => $include_discounted_product,
'categories' => $categories
] ) )
return $mdb -> id();
}
else
{
$mdb -> update( 'pp_shop_coupon', [
'name' => $name,
'status' => $status,
'used' => $used,
'type' => $type,
'amount' => $amount,
'one_time' => $one_time,
'send' => $send,
'include_discounted_product' => $include_discounted_product,
'categories' => $categories
], [
'id' => $coupon_id
] );
return true;
}
}
}