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

文件地址: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;
    }
相关推荐
南宫生9 分钟前
力扣-图论-70【算法学习day.70】
java·学习·算法·leetcode·图论
zfj32110 分钟前
java日志框架:slf4j、jul(java.util.logging)、 log4j、 logback
java·log4j·logback·java日志框架·slf4j·jul
程序猿阿伟17 分钟前
《探索 Apache Spark MLlib 与 Java 结合的卓越之道》
java·spark-ml·apache
一條狗22 分钟前
隨筆 20241224 ts寫入excel表
开发语言·前端·typescript
向阳121826 分钟前
sentinel来源访问控制(黑白名单)
java·sentinel
Takumilove26 分钟前
MQTT入门:在Spring Boot中建立连接及测试
java·spring boot·后端
小码快撩27 分钟前
vue应用移动端访问缓慢问题
前端·javascript·vue.js
低调之人31 分钟前
Fiddler勾选https后google浏览器网页访问不可用
前端·测试工具·https·fiddler·hsts
yayaya15235 分钟前
javaScriptBOM
开发语言·javascript·ecmascript
Riesenzahn36 分钟前
使用vue如何监听元素尺寸的变化?
前端·javascript