123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- /**
- * Created by PhpStorm.
- * User: XiaoMing
- * Date: 2019/12/24
- * Time: 14:43
- */
- namespace Jobs\Model\MTopic\Market;
- use Jobs\Dao\DCoupon;
- use Jobs\Dao\DUserCoupon;
- use Mall\Framework\Core\StatusCode;
- class MGrantCoupon
- {
- use MCoupon;
- private $objDUserCoupon;
- private $objDCoupon;
- private $onlineEnterpriseId;
- /**
- * MGrantCoupon constructor.
- * @throws \Exception
- */
- public function __construct()
- {
- echo '定向发放优惠券:' . date('Y-d-d H:i:s') . ': ';
- $this->objDUserCoupon = new DUserCoupon();
- $this->objDCoupon = new DCoupon();
- $this->objDUserCoupon->setSearchIndex('user_coupon_search')->setType('user_coupon');;
- }
- /**
- * @param $params
- * @throws \Exception
- */
- public function push($params)
- {
- $this->onlineEnterpriseId = $params['enterpriseId'];
- // 计算分表
- $this->objDUserCoupon->setTable($this->objDUserCoupon->get_Table() . '_' . $params['enterpriseId']);
- $this->objDCoupon->setTable($this->objDCoupon->get_Table() . '_' . $params['enterpriseId']);
- $extends = '';
- if (!empty($params['customerId'])) {
- $extends = ' AND FIND_IN_SET(' . $params['customerId'] . ',customerIds)';
- }
- $coupon = self::selectCoupon($this->objDCoupon, ['grantType' => StatusCode::$grantType['grant']], $extends);
- $checkCoupon = self::checkCoupon($this->objDUserCoupon, $coupon, $params);
- self::add($this->objDUserCoupon, $checkCoupon, $params);
- self::receiveNumIncr($this->objDCoupon, $checkCoupon, $params);
- }
- }
|