| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace common\logic\order\limit;
- use common\globals\GlobalInvoke;
- use Exception;
- use yii\helpers\Json;
- use common\logic\order\marketing\BaseMarketing;
- /**
- * 下单检测
- * @Author bing
- * @DateTime 2023-01-31 18:01:32
- * @copyright: Copyright (c) 2020 广东七件事集团
- */
- class CheckLimit extends BaseMarketing
- {
- public function execute($form)
- {
- }
- public static function compute($form)
- {
- $user_id = $form->user_id;
- foreach ($form->group_order_goods as $item) {
- $mch_id = $item['mch_order_info']['mch_id'];
- $mall_id = $item['mch_order_info']['mall_id'];
- $goods = $item['goods'];
- $goods_num = array_column($goods,'num','goods_id');
- $goods_ids = array_keys($goods);
- $attrs = [];
- foreach ($goods_ids as $goods_id) {
- foreach ($goods[$goods_id]['goods_details'] as $attr) {
- $attrs[$attr['goods_attr_id']] = $attr['num'];
- }
- }
- $order_check = GlobalInvoke::exec(GlobalInvoke::ORDERC_CHECK, $mall_id,
- ['mall_id' => $mall_id,'pay_money' => $item['mch_order_info']['total_pay_price'] ?? 0,'mch_id' => $mch_id,'goods_ids' => $goods_ids,
- 'user_id' => $user_id,'goods_num' => $goods_num, 'attrs' => $attrs, 'address_id' => $form->address_id]);
- if($order_check && $order_check['status'] === false){
- //下单检测失败
- $msg = $order_check['msg'] ?? '下单检测失败';
- $msg = $msg ? $msg : '下单检测失败';
- throw new Exception($msg);
- }
- if (!empty($order_check['checks'])) {
- foreach ($order_check['checks'] as $cKey => $cVal) {
- if (!empty($cVal['extra'])) {
- foreach ($cVal['extra'] as $eKey => $eVal) {
- foreach ($eVal as $exKey => $exVal) {
- $form->process_extra_data[$exKey][$eKey][] = $exVal;
- }
- }
- }
- }
- }
- }
- }
- }
|