HigoMarketing.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace common\logic\order\marketing;
  3. use common\enums\AddonsEnum;
  4. use common\models\mall\MallAddons;
  5. /**
  6. * Class FullReduceMarketing
  7. * 满减计算
  8. * @Author: lun
  9. * @DateTime: 2021/9/30 0030 14:53
  10. * @Copyright: copyright (c) 2021 广东七件事集团
  11. * @package common\logic\order\marketing
  12. */
  13. class HigoMarketing extends BaseMarketing
  14. {
  15. public function execute($form)
  16. {
  17. }
  18. /**
  19. * 满减计算
  20. * @Author: lun
  21. * @DateTime: 2021/10/6 0006 10:55
  22. * @Copyright: copyright (c) 2021 广东七件事集团
  23. * @param $item
  24. * @param $form
  25. * @return mixed
  26. */
  27. public static function compute($item, &$form, &$extra = [])
  28. {
  29. try {
  30. // 检测是否有安装嗨购应用
  31. if (MallAddons::isInstall($item['mch_order_info']['mall_id'], AddonsEnum::ADDONS_NAME_HI_GO)) {
  32. $mch_arr = [];
  33. foreach ($item['goods'] as $goods) {
  34. foreach ($goods['goods_details'] as $v) {
  35. if (isset($v['mch_id']) && $v['mch_id'] > 0) {
  36. $mch_arr[] = $v['mch_id'];
  37. break;
  38. }
  39. }
  40. }
  41. if (count($mch_arr) > 0) {
  42. $marketing = new \addons\HiGo\common\logic\order\HigoMchMarketing();
  43. } else {
  44. $marketing = new \addons\HiGo\common\logic\order\HigoMarketing();
  45. }
  46. $item = $marketing::compute($item, $form, $extra);
  47. if ($item == false) throw new \Exception($marketing::getStaticError());
  48. }
  49. return $item;
  50. } catch (\Exception $e) {
  51. self::setStaticError($e->getMessage());
  52. return false;
  53. }
  54. }
  55. }