CheckLimit.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace common\logic\order\limit;
  3. use common\globals\GlobalInvoke;
  4. use Exception;
  5. use yii\helpers\Json;
  6. use common\logic\order\marketing\BaseMarketing;
  7. /**
  8. * 下单检测
  9. * @Author bing
  10. * @DateTime 2023-01-31 18:01:32
  11. * @copyright: Copyright (c) 2020 广东七件事集团
  12. */
  13. class CheckLimit extends BaseMarketing
  14. {
  15. public function execute($form)
  16. {
  17. }
  18. public static function compute($form)
  19. {
  20. $user_id = $form->user_id;
  21. foreach ($form->group_order_goods as $item) {
  22. $mch_id = $item['mch_order_info']['mch_id'];
  23. $mall_id = $item['mch_order_info']['mall_id'];
  24. $goods = $item['goods'];
  25. $goods_num = array_column($goods,'num','goods_id');
  26. $goods_ids = array_keys($goods);
  27. $attrs = [];
  28. foreach ($goods_ids as $goods_id) {
  29. foreach ($goods[$goods_id]['goods_details'] as $attr) {
  30. $attrs[$attr['goods_attr_id']] = $attr['num'];
  31. }
  32. }
  33. $order_check = GlobalInvoke::exec(GlobalInvoke::ORDERC_CHECK, $mall_id,
  34. ['mall_id' => $mall_id,'pay_money' => $item['mch_order_info']['total_pay_price'] ?? 0,'mch_id' => $mch_id,'goods_ids' => $goods_ids,
  35. 'user_id' => $user_id,'goods_num' => $goods_num, 'attrs' => $attrs, 'address_id' => $form->address_id]);
  36. if($order_check && $order_check['status'] === false){
  37. //下单检测失败
  38. $msg = $order_check['msg'] ?? '下单检测失败';
  39. $msg = $msg ? $msg : '下单检测失败';
  40. throw new Exception($msg);
  41. }
  42. if (!empty($order_check['checks'])) {
  43. foreach ($order_check['checks'] as $cKey => $cVal) {
  44. if (!empty($cVal['extra'])) {
  45. foreach ($cVal['extra'] as $eKey => $eVal) {
  46. foreach ($eVal as $exKey => $exVal) {
  47. $form->process_extra_data[$exKey][$eKey][] = $exVal;
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }