12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- /**
- * 在线支付发放优惠券
- * Created by PhpStorm.
- * User: XiaoMing
- * Date: 2019/12/24
- * Time: 9:43
- */
- namespace Jobs\Model\MTopic\Market;
- use Mall\Framework\Core\StatusCode;
- use Jobs\Dao\DCoupon;
- use Jobs\Dao\DUserCoupon;
- class MOnlinePayCoupon
- {
- use MCoupon;
- private $objDUserCoupon;
- private $objDCoupon;
- private $onlineEnterpriseId;
- /**
- * MUserCoupon 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
- * @return bool
- * @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=' AND mustCondition<=' . $params['payAmount'];
- $coupon = self::selectCoupon($this->objDCoupon,['grantType'=>StatusCode::$grantType['onlinePay']],$extends);
- $checkCoupon = self::checkCoupon($this->objDUserCoupon,$coupon,$params);
- self::add($this->objDUserCoupon,$checkCoupon,$params);
- self::receiveNumIncr($this->objDCoupon,$checkCoupon,$params);
- }
- }
|