CouponDetailService.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\admin\service\coupon;
  3. use app\model\CouponDetail;
  4. use app\model\SysSerial;
  5. use support\exception\BusinessException;
  6. class CouponDetailService
  7. {
  8. /**
  9. * @Desc 手动发券
  10. * @Author Gorden
  11. * @Date 2024/8/27 9:57
  12. *
  13. * @param $params
  14. * @return void
  15. * @throws BusinessException
  16. */
  17. public static function customSendCoupon($params)
  18. {
  19. try {
  20. CouponDetail::insert([
  21. 'coupon_detail_id' => 'CUDT' . date("ymdHi") . random_string(4, 'up'),
  22. 'join_detail_coupon_id' => $params['coupon_id'],
  23. 'join_coupon_detail_member_id' => $params['member_id'],
  24. 'coupon_detail_status' => 'ACTIVED',
  25. 'coupon_detail_gain_datetime' => $params['coupon_detail_gain_datetime'],
  26. 'coupon_detail_deadline_datetime' => $params['coupon_detail_deadline_datetime'],
  27. 'coupon_detail_extend_json'=>json_encode(['gettype'=>'SEND']),
  28. 'coupon_detail_addtimes' => time(),
  29. ]);
  30. } catch (\Exception $e) {
  31. throw new BusinessException('写入优惠券失败');
  32. }
  33. }
  34. }