全部
常见问题
产品动态
精选推荐
功能建议

分析中 已回复 待规划 {{opt.name}}
分析中 已回复 待规划
代客下单订单提交数据返回处理有误

管理 管理 编辑 删除

问题说明:代客下单订单提交数据返回处理有误

修改文件:app/services/order/cashier/CashierOrderServices.php

修改方法:computeOrder()

修改最后返回数据

public function computeOrder(int $uid = 0, int $storeId = 0, array $cartIds = [], bool $integral = false, bool $coupon = false, array $userInfo = [], int $coupon_id = 0, bool $new = false, array $cartGroup = [], int $addressId = 0, string $payType = 'yue', int $shippingType = 4, int $is_store_delivery_type = 0, array $addressInfo = [])
    {
        if (!$userInfo && $uid) {
            /** @var UserServices $userService */
            $userService = app()->make(UserServices::class);
            $userInfo = $userService->getUserInfo($uid);
            if (!$userInfo) {
                throw new ValidateException('用户不存在');
            }
            $userInfo = $userInfo->toArray();
        }
        $payPostage = 0;
        $storePostageDiscount = 0;
        $firstOrderPrice = 0;
        /** @var StoreOrderComputedServices $computeOrderService */
        $computeOrderService = app()->make(StoreOrderComputedServices::class);
        if ($cartGroup && $shippingType != 4) {
            $cartInfo = $cartGroup['cartInfo'];
            $priceGroup = $cartGroup['priceGroup'];
            $deduction = $cartGroup['deduction'];
            $other = $cartGroup['other'];
            $promotions = $other['promotions'] ?? [];
            $payPrice = (float)$priceGroup['totalPrice'];
            $payIntegral = (int)$priceGroup['totalIntegral'] ?? 0;
            $couponPrice = (float)$priceGroup['couponPrice'];
            $firstOrderPrice = (float)$priceGroup['firstOrderPrice'];

            $sumPrice = $priceGroup['sumPrice'];//获取订单原总金额
            $totalPrice = $priceGroup['totalPrice'];//获取订单svip、用户等级优惠之后总金额
			$settlePrice = $priceGroup['settlePrice'] ?? 0;//供应商商品结算金额
            $costPrice = $priceGroup['costPrice'];//获取订单成本价
            $vipPrice = $priceGroup['vipPrice'];//获取订单会员优惠金额
            $changePrice = (float)$priceGroup['changePrice'] ?? 0.00;
            $promotionsPrice = $computeOrderService->getOrderSumPrice($cartInfo, 'sum_promotions_price', false);//优惠活动优惠

            $addr = $cartGroup['addr'] ?? $addressInfo;
            $postage = $priceGroup;
            if($addressId && $addr && isset($addr['id']) && $addr['id'] != $addressId) {
                /** @var UserAddressServices $addressServices */
                $addressServices = app()->make(UserAddressServices::class);
                $addr = $addressServices->getAdderssCache($addressId);
                //改变地址重新计算邮费
                $postage = [];
            }

            $type = (int)$deduction['type'] ?? 0;
            $results = batch([
                'promotions' => function () use ($cartInfo, $type) {
                    $promotionsPrice = 0;
                    if ($type == 8) return $promotionsPrice;
                    foreach ($cartInfo as $key => $cart) {
                        if (isset($cart['sum_promotions_price']) && isset($cart['price_type']) && $cart['price_type'] == 'promotions') {
                            $promotionsPrice = bcadd((string)$promotionsPrice, (string)$cart['sum_promotions_price'], 2);
                        }
                    }
                    return $promotionsPrice;
                },
                'postage' => function () use ($uid, $shippingType, $payType, $cartInfo, $addr, $payPrice, $postage, $other, $type, $computeOrderService,$storeId,$is_store_delivery_type) {
                    return $computeOrderService->computedPayPostage($uid, $shippingType, $payType, $cartInfo, $addr, $payPrice, $postage, $other,$storeId,$is_store_delivery_type);
                },
            ]);

            [$p, $payPostage, $storePostageDiscount, $storeFreePostage, $isStoreFreePostage, $poorFreeShipping, $poorDeliveryPrice, $sameCityStoreFreePostage] = $results['postage'];

        } else {
            /** @var StoreCartServices $cartServices */
            $cartServices = app()->make(StoreCartServices::class);
            //获取购物车信息
            $cartGroup = $cartServices->getUserProductCartListV1($uid, $cartIds, $new, [], 4, $storeId, $coupon_id);
            $cartInfo = $cartGroup['valid'];
            if (!$cartInfo) {
                throw new ValidateException('购物车暂无货物!');
            }
            $deduction = $cartGroup['deduction'];
            $promotions = $cartGroup['promotions'] ?? [];
            $other = [
                'offlinePostage' => sys_config('offline_postage'),
                'integralRatio' => sys_config('integral_ratio'),
                'give_integral' => $cartGroup['giveIntegral'] ?? 0,
                'give_coupon' => $cartGroup['giveCoupon'] ?? [],
                'give_product' => $cartGroup['giveProduct'],
                'promotions' => $cartGroup['promotions']
            ];
            $reservationInfo = ['cart_num' => $cartInfo[0]['cart_num'] ?? 1, 'reservation_type' => 2, 'service_staff_id' => 0, 'real_name' => '', 'user_phone' => '', 'reservation_time' => '', 'reservation_time_id' => 0, 'reservation_show_time' => ''];
            if (($deduction['product_type'] ?? 0) == 6) {
                $reservationTime = $cartInfo[0]['reservation_time'] ?? '';
                $reservationTimeId = $cartInfo[0]['reservation_time_id'] ?? 0;
                $reservationTimeInfo = [];
                if ($reservationTimeId) {
                    /** @var StoreProductReservationTimeServices $reservationTimeServices */
                    $reservationTimeServices = app()->make(StoreProductReservationTimeServices::class);
                    $reservationTimeInfo = $reservationTimeServices->get(['id' => $reservationTimeId]);
                    if (!$reservationTimeInfo) {
                        throw new ValidateException('选择的时段无效');
                    }
                }
                $reservationInfo = [
                    'cart_num' => $cartInfo[0]['cart_num'] ?? 1,
                    'reservation_type' => $cartInfo[0]['reservation_type'] ?? 2,
                    'service_staff_id' => $cartInfo[0]['service_staff_id'] ?? 0,
                    'real_name' => $cartInfo[0]['real_name'] ?? '',
                    'user_phone' => $cartInfo[0]['user_phone'] ?? '',
                    'reservation_time' => $reservationTime,
                    'reservation_time_id' => $reservationTimeId,
                    'reservation_show_time' => $reservationTimeInfo['show_time'] ?? '',
                ];
            }
            $other['reservationInfo'] = $reservationInfo;
            $cartGroup['other'] = $other;
            $sumPrice = $computeOrderService->getOrderSumPrice($cartInfo, 'sum_price');//获取订单原总金额
            $totalPrice = $computeOrderService->getOrderSumPrice($cartInfo, 'pay_price', false);//获取订单svip、用户等级优惠之后总金额
			$settlePrice = (float)$computeOrderService->getOrderSumPrice($cartInfo, 'settle_price', false);//结算总价
            $costPrice = $computeOrderService->getOrderSumPrice($cartInfo, 'costPrice');//获取订单成本价
            $vipPrice = $computeOrderService->getOrderSumPrice($cartInfo, 'vip_truePrice');//获取订单会员优惠金额
            $promotionsPrice = $computeOrderService->getOrderSumPrice($cartInfo, 'sum_promotions_price', false);//优惠活动优惠
            $changePrice = (float)$computeOrderService->getOrderSumPrice($cartInfo, 'change_price', false);//获取改价优惠金额

            $payPrice = (float)$totalPrice;
            $couponPrice = floatval($cartGroup['couponPrice'] ?? 0);
			//合并赠品
			$cartInfo = array_merge($cartGroup['valid'], $cartGroup['giveCartList']);
        }
        $promotionsDetail = [];
        if ($promotions) {
            foreach ($promotions as $key => $value) {
                if (isset($value['details']['sum_promotions_price']) && $value['details']['sum_promotions_price']) {
                    $promotionsDetail[] = ['id' => $value['id'], 'name' => $value['name'], 'title' => $value['title'], 'desc' => $value['desc'], 'promotions_price' => $value['details']['sum_promotions_price'], 'promotions_type' => $value['promotions_type']];
                }
            }
            if ($promotionsDetail) {
                $typeArr = array_column($promotionsDetail, 'promotions_type');
                array_multisort($typeArr, SORT_ASC, $promotionsDetail);
            }
        }
        $is_cashier_yue_pay_verify = (int)sys_config('is_cashier_yue_pay_verify'); // 收银台余额支付是否需要验证【是/否】

        if ($firstOrderPrice < $payPrice) {//首单优惠金额
            $payPrice = bcsub((string)$payPrice, (string)$firstOrderPrice, 2);
        } else {
            $payPrice = 0;
        }
        $SurplusIntegral = $usedIntegral = 0;
        $deductionPrice = '0';
        //使用积分
        if ($userInfo && $integral && sys_config('integral_ratio_status', 0)) {
            [
                $payPrice,
                $deductionPrice,
                $usedIntegral,
                $SurplusIntegral
            ] = $computeOrderService->useIntegral(true, $userInfo, $payPrice, [
                'offlinePostage' => sys_config('offline_postage'),
                'integralRatio' => sys_config('integral_ratio')
            ]);
        }

        $payPrice = (float)bcadd((string)$payPrice, (string)$payPostage, 2);

        $yue_pay_status = (int)sys_config('balance_func_status') && (int)sys_config('yue_pay_status') == 1 ? (int)1 : (int)2;//余额支付 1 开启 2 关闭
        //验证门店是否开启使用余额支付
        if ($yue_pay_status == 1 && $storeId) {
            /** @var SystemStoreServices $systemStoreServices */
            $systemStoreServices = app()->make(SystemStoreServices::class);
            $storeInfo = $systemStoreServices->get((int)$storeId, ['id', 'use_system_money']);
            $yue_pay_status = $storeInfo['use_system_money'] ? $yue_pay_status : 2;
        }

        return [
            'payPrice' => floatval($payPrice),//支付金额
			'settlePrice' => floatval($settlePrice),//结算金额
            'vipPrice' => floatval($vipPrice),//会员优惠金额
            'totalPrice' => floatval($totalPrice),//会员优惠后订单金额
            'costPrice' => floatval($costPrice),//成本金额
            'sumPrice' => floatval($sumPrice),//订单总金额
            'firstOrderPrice' => floatval($firstOrderPrice),//首单优惠
            'couponPrice' => (float)$couponPrice,//优惠券金额
            'pay_postage' => (float)($payPostage ?? 0),
            'storePostageDiscount' => (float)($storePostageDiscount ?? 0),
            'promotionsPrice' => floatval($promotionsPrice),//优惠活动金额
            'promotionsDetail' => $promotionsDetail,//优惠
            'deductionPrice' => floatval($deductionPrice),//积分抵扣多少钱
            'surplusIntegral' => $SurplusIntegral,//抵扣了多少积分
            'usedIntegral' => $usedIntegral,//使用了多少积分
            'deduction' => $deduction,
            'changePrice' => $changePrice,
            'isStoreFreePostage' => $isStoreFreePostage ?? false,
            'storeFreePostage' => (float)($storeFreePostage ?? 0),
            'sameCityStoreFreePostage' => (float)($sameCityStoreFreePostage ?? 0),
            'poorFreeShipping' => (float)($poorFreeShipping ?? 0),//差多少包邮
            'poorDeliveryPrice' => (float)($poorDeliveryPrice ?? 0),//差多少起送
            'servicePrice' => 0.00,
            'cartInfo' => $cartInfo,//购物列表
            'is_cashier_yue_pay_verify' => $is_cashier_yue_pay_verify,//收银台余额支付验证 1 验证 0不验证
            'cartGroup' => $cartGroup,//计算结果
			'offline_pay_status' => (int)sys_config('offline_pay_status'),//线下支付1开启2关闭
            'yue_pay_status' => (int)$yue_pay_status,//余额支付 1 开启 2 关闭
            'ali_pay_status' => (int)sys_config('ali_pay_status'),//支付宝支付 1 开启 0 关闭
            'pay_weixin_open' => (int)sys_config('pay_weixin_open') ?? 0,//微信支付 1 开启 0 关闭
        ];
    }



{{voteData.voteSum}} 人已参与
支持
反对
请登录后查看

全 最后编辑于2026-01-23 15:28:51

快捷回复
回复
回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
排序 默认正序 回复倒序 点赞倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level || item.bbs_level }}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推荐': '推荐'}}
{{item.is_suggest == 1? '取消推荐': '推荐'}} 【已收集】
{{item.floor}}# 沙发 板凳 地板 {{item.floor}}# 【已收集】
{{item.user_info.title || '暂无简介'}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
打赏
已打赏¥{{item.reward_price}}
{{item.like_count}}
分享
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}
打赏
已打赏¥{{itemc.reward_price}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
收起 展开更多
查看更多
打赏
已打赏¥{{reward_price}}
25
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

快速安全登录

使用微信扫码登录
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定
打赏金额
当前余额:¥{{rewardUserInfo.reward_price}}
{{item.price}}元
请输入 0.1-{{reward_max_price}} 范围内的数值
打赏成功
¥{{price}}
完成 确认打赏

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服
CRMEB咨询热线 400-8888-794

扫码领取产品资料

功能清单
思维导图
安装教程
CRMEB开源商城下载 源码下载 CRMEB帮助文档 帮助文档
返回顶部 返回顶部
CRMEB客服