积分商品编辑规格里积分未会显问题处理

文件地址:app/services/product/sku/StoreProductAttrValueServices.php

方法名:getattr

替换此方法:

复制代码
public function getattr($attr, $id, $type)
    {
        $value = attr_format($attr)[1];
        $valueNew = [];
        $count = 0;
        if ($type == 2) {
            /** @var StoreBargainServices $storeBargainServices */
            $storeBargainServices = app()->make(StoreBargainServices::class);
            $min_price = $storeBargainServices->value(['id' => $id], 'min_price');
        } else {
            $min_price = 0;
        }
        $sukValueArr = $this->getSkuArray(['product_id' => $id, 'type' => $type], 'bar_code,code,cost,price,ot_price,stock,image as pic,weight,volume,brokerage,brokerage_two,quota,quota_show,settle_price,integral', 'suk');
        foreach ($value as $key => $item) {
            $detail = $item['detail'];
//            sort($item['detail'], SORT_STRING);
            $suk = implode(',', $item['detail']);
            $sukValue = $sukValueArr[$suk] ?? [];
            if ($sukValue) {
                foreach (array_values($detail) as $k => $v) {
                    $valueNew[$count]['value' . ($k + 1)] = $v;
                }
                $valueNew[$count]['detail'] = json_encode($detail);
                $valueNew[$count]['pic'] = $sukValue['pic'] ?? '';
                $valueNew[$count]['price'] = $sukValue['price'] ? floatval($sukValue['price']) : 0;
                $valueNew[$count]['integral'] = $sukValue['integral'] ?: 0;
                $valueNew[$count]['settle_price'] = $sukValue['cost'] ? floatval($sukValue['settle_price']) : 0;
                $valueNew[$count]['cost'] = $sukValue['cost'] ? floatval($sukValue['cost']) : 0;
                $valueNew[$count]['ot_price'] = isset($sukValue['ot_price']) ? floatval($sukValue['ot_price']) : 0;
                $valueNew[$count]['stock'] = $sukValue['stock'] ? intval($sukValue['stock']) : 0;
                $valueNew[$count]['quota'] = isset($sukValue['quota_show']) && $sukValue['quota_show'] ? intval($sukValue['quota_show']) : 0;
                $valueNew[$count]['code'] = $sukValue['code'] ?? '';
                $valueNew[$count]['bar_code'] = $sukValue['bar_code'] ?? '';
                $valueNew[$count]['weight'] = $sukValue['weight'] ? floatval($sukValue['weight']) : 0;
                $valueNew[$count]['volume'] = $sukValue['volume'] ? floatval($sukValue['volume']) : 0;
                $valueNew[$count]['brokerage'] = $sukValue['brokerage'] ? floatval($sukValue['brokerage']) : 0;
                $valueNew[$count]['brokerage_two'] = $sukValue['brokerage_two'] ? floatval($sukValue['brokerage_two']) : 0;
                switch ($type) {
                    case 1://秒杀
                        $valueNew[$count]['_checked'] = true;
                        break;
                    case 2://砍价
                        $valueNew[$count]['min_price'] = $min_price ? floatval($min_price) : 0;
                        $valueNew[$count]['opt'] = true;
                        break;
                    case 3://拼团
                        $valueNew[$count]['_checked'] = true;
                        break;
                    case 4://积分
                        $valueNew[$count]['integral'] = isset($sukValue['integral']) ? floatval($sukValue['integral']) : 0;
                        $valueNew[$count]['_checked'] = true;
                        break;
                    default:
                        $valueNew[$count]['_checked'] = false;
                        $valueNew[$count]['opt'] = false;
                        break;
                }
                $count++;
            }
        }
        return $valueNew;
    }
相关推荐
腾讯TNTWeb前端团队3 小时前
helux v5 发布了,像pinia一样优雅地管理你的react状态吧
前端·javascript·react.js
mghio5 小时前
Dubbo 中的集群容错
java·微服务·dubbo
范文杰6 小时前
AI 时代如何更高效开发前端组件?21st.dev 给了一种答案
前端·ai编程
拉不动的猪7 小时前
刷刷题50(常见的js数据通信与渲染问题)
前端·javascript·面试
拉不动的猪7 小时前
JS多线程Webworks中的几种实战场景演示
前端·javascript·面试
FreeCultureBoy7 小时前
macOS 命令行 原生挂载 webdav 方法
前端
uhakadotcom8 小时前
Astro 框架:快速构建内容驱动型网站的利器
前端·javascript·面试
uhakadotcom8 小时前
了解Nest.js和Next.js:如何选择合适的框架
前端·javascript·面试
uhakadotcom8 小时前
React与Next.js:基础知识及应用场景
前端·面试·github