修改我的医生,新增优惠卷过期
This commit is contained in:
@@ -2,8 +2,15 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\UserCouponExpiredDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\Coupon;
|
||||
use App\Model\UserCoupon;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* 优惠卷
|
||||
@@ -76,6 +83,8 @@ class CouponService extends BaseService
|
||||
* @param string $patient_id
|
||||
* @param int $coupon_client 使用平台(1:小程序)
|
||||
* @return bool
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function DistributeCoupon(int $distribution_object,string $user_id,string $patient_id,int $coupon_client = 1): bool
|
||||
{
|
||||
@@ -113,8 +122,22 @@ class CouponService extends BaseService
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = UserCoupon::addUserCoupon($data);
|
||||
if (empty($res)){
|
||||
$user_coupon = UserCoupon::addUserCoupon($data);
|
||||
if (empty($user_coupon)){
|
||||
return false;
|
||||
}
|
||||
|
||||
// 添加用户优惠卷自动过期队列
|
||||
// 添加自动完成队列
|
||||
$data = array();
|
||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
|
||||
$time = $data['valid_end_time'] - time();
|
||||
$message = new UserCouponExpiredDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user