| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace addons\GroupBuy\common\logic\order\marketing;
- use addons\GroupBuy\common\models\GroupBuyActive;
- use common\enums\StatusEnum;
- use common\logic\order\marketing\BaseMarketing;
- /**
- * 检查活动免费开团
- */
- class GroupBuyActiveMarketing extends BaseMarketing
- {
- public function execute($form)
- {
- }
- /**
- * @param $item
- * @param $form
- * @param $extra
- *
- * @return mixed
- */
- public static function compute($item, &$form, &$extra = [])
- {
- // 不是团长
- if (empty($item['mch_order_info']['is_commander'])) {
- return $item;
- }
- // 开团是否免费
- if (
- !GroupBuyActive::find()
- ->where([
- 'id' => $form->data['active_id'],
- 'status' => StatusEnum::ENABLED,
- 'mall_id' => $form->mall_id,
- 'is_initiator_free' => StatusEnum::ENABLED
- ])
- ->exists()
- ) {
- return $item;
- }
- $item['mch_order_info']['pay_money'] = max(bcsub($item['mch_order_info']['pay_money'], $item['mch_order_info']['goods_price'], 2), 0);
- $item['mch_order_info']['group_buy_price'] = max(bcsub($item['mch_order_info']['group_buy_price'], $item['mch_order_info']['goods_price'], 2), 0);
- $item['mch_order_info']['is_free'] = 1; // 免费开团标识
- $form->marketing['deduct']['is_free_open_group'] = ['name' => '优惠金额', 'money' => $item['mch_order_info']['goods_price']];
- return $item;
- }
- }
|