feat : auto coupon
This commit is contained in:
@@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Coupon;
|
||||
|
||||
use App\Amqp\Producer\CouponAutoDispenseProducer;
|
||||
use App\Constants\Common\CouponCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\CouponDispenseLog;
|
||||
@@ -23,8 +24,12 @@ use App\Model\Sku;
|
||||
use App\Service\Admin\BaseService;
|
||||
use App\Service\ServiceTrait\Admin\CouponDispenseTrait;
|
||||
use Exception;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class DispenseAddService extends BaseService
|
||||
{
|
||||
@@ -96,8 +101,15 @@ class DispenseAddService extends BaseService
|
||||
*/
|
||||
private int $claimRule;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private int $dispenseId;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
@@ -109,14 +121,18 @@ class DispenseAddService extends BaseService
|
||||
$this->checkClaimRuleData();
|
||||
|
||||
Db::transaction(function () {
|
||||
$dispenseId = $this->addMasterTableInformation();
|
||||
$this->dispenseId = $this->addMasterTableInformation();
|
||||
|
||||
$this->addSubTableInformation($dispenseId);
|
||||
$this->addSubTableInformation($this->dispenseId);
|
||||
});
|
||||
|
||||
if ($this->claimRule == CouponCode::DISPENSE_CLAIM_RULE_POST_ACCOUNT) {
|
||||
//todo mq发放优惠券
|
||||
echo 1;
|
||||
//mq发放优惠券
|
||||
$message = new CouponAutoDispenseProducer([
|
||||
'coupon_dispense_id' => $this->dispenseId,
|
||||
]);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$producer->produce($message);
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
|
||||
Reference in New Issue
Block a user