CouponRedeemCodes.php 934 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\api\model\coupon;
  3. use app\common\library\helper;
  4. use app\common\model\coupon\CouponRedeemCodes as RedeemCodesModel;
  5. /**
  6. * 优惠券生成兑换码记录模型
  7. * @package app\common\model
  8. */
  9. class CouponRedeemCodes extends RedeemCodesModel
  10. {
  11. /**
  12. * 批量添加兑换码
  13. * @param $data
  14. * @return bool
  15. * @throws \Exception
  16. */
  17. public function addBatch($data){
  18. $m = new self();
  19. $m->saveAll($data);
  20. return true;
  21. }
  22. /**
  23. * 校验码是否用过
  24. * @param $code
  25. * @return bool
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\DbException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. */
  30. public function checkExistedCode($code){
  31. $m = new self();
  32. if ($m->where('redeem_code',$code)->find()){
  33. return true;
  34. }
  35. return false;
  36. }
  37. }