全部
常见问题
产品动态
精选推荐

标准版二开积分抵扣使其不同商品支持的积分抵扣数不同

管理 管理 编辑 删除

4c43620240527153826326.png

经常有客户反应,我这件商品利润大 想让用户多抵扣一点积分,这件商品没有利润不想让用户用积分抵扣,对于这种需求,最简单粗暴的方法就是把最高可抵扣积分数量放在商品里面来设置。

假设A商品利润空间大,我设置最高可抵扣50积分,B商品利润空间少,我设置可抵扣10积分或设置0积分不给抵扣

二开地方

dfcdf202405271540571739.png

代码:

/**
     * 使用积分
     * @param $useIntegral
     * @param $userInfo
     * @param $payPrice
     * @param $other
     * @return array
     */
    public function useIntegral(bool $useIntegral, $userInfo, string $payPrice, array $other, array $cartInfo = [])
    {
        /** @var UserBillServices $userBillServices */
        $userBillServices = app()->make(UserBillServices::class);
        // 可用积分
        $usable = bcsub((string)$userInfo['integral'], (string)$userBillServices->getBillSum(['uid' => $userInfo['uid'], 'is_frozen' => 1]), 0);

        $SurplusIntegral = $usable;
        if ($useIntegral && $userInfo['integral'] > 0 && $other['integralRatio'] > 0) {
            // 获取商品最高可抵扣积分数
            $integralMaxNum = 0;
            foreach ($cartInfo as $val) {
                $integralMaxNum = bcadd($integralMaxNum, bcmul($val['productInfo']['max_integral'], $val['cart_num']));
            }
            if ($integralMaxNum > 0 && $userInfo['integral'] > $integralMaxNum) {
                $integral = $integralMaxNum;
            } else {
                $integral = $userInfo['integral'];
            }
            if ($integralMaxNum <= 0) {
                // 给默认后台设置的抵扣积分
                $integral = sys_config('integral_max_num', 200);
            }
            $deductionPrice = (float)bcmul((string)$integral, (string)$other['integralRatio'], 2);
            if ($deductionPrice < $payPrice) {
                $payPrice = bcsub((string)$payPrice, (string)$deductionPrice, 2);
                $usedIntegral = $integral;
            } else {
                $deductionPrice = $payPrice;
                $usedIntegral = (int)ceil(bcdiv((string)$payPrice, (string)$other['integralRatio'], 2));
                $payPrice = 0;
            }
            $deductionPrice = $deductionPrice > 0 ? $deductionPrice : 0;
            $usedIntegral = $usedIntegral > 0 ? $usedIntegral : 0;
            $SurplusIntegral = (int)bcsub((string)$usable, $usedIntegral, 0);
        } else {
            $deductionPrice = 0;
            $usedIntegral = 0;
        }
        if ($payPrice <= 0) $payPrice = 0;
        return [$payPrice, $deductionPrice, $usedIntegral, $SurplusIntegral];
    }

云管家网络科技有限公司专注CRMEB商城系统二次开发、分销商城系统开发、城市代理开发等多种应用场景定制开发。



请登录后查看

云管家 最后编辑于2024-05-27 15:42:16

快捷回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
回复从新到旧

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest==1? '取消推荐': '推荐'}}
{{item.floor}}#
{{item.user_info.title}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

作者 管理员 企业

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}   {{itemc.ip_address}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
回复
回复
697
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

云管家 企业
金牌技术服务商:专注CRMEB产品的功能深度定制与开发。赵经理:17792727337(同微信)

回答

61

发布

9

经验

985

快速安全登录

使用微信扫码登录
{{item.label}} {{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
加精
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定

微信登录/注册

切换手机号登录

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

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 开源下载 CRMEB官方论坛 帮助文档
返回顶部 返回顶部
CRMEB客服