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

文件地址: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;
    }
相关推荐
刚刚好ā几秒前
uni-app跳转外部链接方式汇总--超全
前端·vue.js·uni-app·vue·webview
米二7 分钟前
java基础面试题
java·面试
shaoweijava8 分钟前
靓车汽车销售网站(源码+数据库+报告)
java·数据库·spring boot·mysql·汽车
《源码好优多》10 分钟前
基于Java Springboot汽车4s店管理系统
java·spring boot·汽车
H愚公移山H21 分钟前
Spring Cloud Alibaba [Gateway]网关。
java·gateway·springcloud
天蓝蓝2352822 分钟前
Lucene数据写入流程
java·mybatis·lucene
栽树先生~29 分钟前
解决IntelliJ IDEA的Plugins无法访问Marketplace去下载插件
java·ide·intellij-idea
江河湖海33 分钟前
以Java为例,实现一个简单的命令行图书管理系统,包括添加图书、删除图书、查找图书等功能。
java·开发语言·策略模式
冰零(lane)37 分钟前
状态模式之状态机
java·设计模式·状态模式
刽子手发艺40 分钟前
JWT介绍、测试案例 以及实际开发中的使用
java·后端