src/Biz/OrderFacade/Command/Deduct/PickCouponCommand.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\OrderFacade\Command\Deduct;
use Biz\Coupon\Service\CouponService;
use Biz\OrderFacade\Command\Command;
use Biz\OrderFacade\Product\Product;
class PickCouponCommand extends Command
{
public function execute(Product $product, $params = array())
{
if (!empty($params['couponCode'])) {
$checkData = $this->getCouponService()->checkCoupon($params['couponCode'], $product->targetId, $product->targetType);
if (isset($checkData['useable']) && $checkData['useable'] == 'no') {
return;
}
$coupon = $this->getCouponService()->getCouponByCode($params['couponCode']);
if ($product->promotionPrice) {
$coupon['deduct_amount'] = $this->getCouponService()->getDeductAmount($coupon, $product->promotionPrice);
} else {
$coupon['deduct_amount'] = $this->getCouponService()->getDeductAmount($coupon, $product->originPrice);
}
$deduct = array(
'deduct_amount' => $coupon['deduct_amount'],
'deduct_type' => 'coupon',
'deduct_id' => $coupon['id'],
'snapshot' => array(
'couponCode' => $coupon['code'],
),
);
$product->pickedDeducts[] = $deduct;
}
}
/**
* @return CouponService
*/
private function getCouponService()
{
return $this->biz->service('Coupon:CouponService');
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。