CouponRewardService.php 720 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace bizHd\promote\services;
  3. use bizHd\base\services\BaseService;
  4. use common\components\validate;
  5. use common\components\util;
  6. use Yii;
  7. class CouponRewardService extends BaseService
  8. {
  9. public static $baseFile = '\bizHd\promote\classes\CouponRewardClass';
  10. //发放奖品 ssh 2019,8.25
  11. public static function grantReward($data, $sjId)
  12. {
  13. validate::easyCheck(['id'], $data);
  14. $id = $data['id'];
  15. $reward = self::getById($id, true);
  16. if (empty($reward)) {
  17. util::fail('没有找到奖励');
  18. }
  19. if ($sjId != $reward['sjId']) {
  20. util::fail('无法操作');
  21. }
  22. if ($reward->status == 2) {
  23. util::fail('已经发放过了');
  24. }
  25. $reward->status = 2;
  26. $reward->save();
  27. return true;
  28. }
  29. }