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

冻结积分后使用问题

管理 管理 编辑 删除

问题说明:积分冻结后积分展示有误,商品抵扣有误

修改文件:app\model\user\UserBill

修改方法:searchIsFrozenAttr()

    public function searchIsFrozenAttr($query, $value)
    {
        if ($value) {
            $query->where('frozen_time', '>', time());
        } else {
            $query->where('frozen_time', '<=', time());
        }
    }


修改文件:app\services\user\UserSignServices

修改方法:signUser()

public function signUser(int $uid, $sign, $integral, $all)
    {
        /** @var UserServices $userServices */
        $userServices = app()->make(UserServices::class);
        $user = $userServices->getUserCacheInfo($uid);
        if (!$user) {
            throw new ValidateException('数据不存在');
        }
        $data = ['uid' => $user['uid'], 'nickname' => $user['nickname'], 'phone' => $user['phone'], 'now_money' => $user['now_money'], 'integral' => $user['integral'], 'is_promoter' => $user['is_promoter'] ?? 0];
        //是否统计签到
        if ($sign || $all) {
            $data['sum_sgin_day'] = $this->getSignSumDay($uid);
            $data['is_day_sgin'] = $this->getIsSign($uid);
            $data['is_YesterDay_sgin'] = $this->getIsSign($uid, 'yesterday');
            if (!$data['is_day_sgin'] && !$data['is_YesterDay_sgin']) {
                $data['sign_num'] = 0;
            }
        }
        /** @var UserIntegralServices $userIntegralServices */
        $userIntegralServices = app()->make(UserIntegralServices::class);
        [$clear_integral, $clear_time] = $userIntegralServices->getUserClearIntegral($uid, $user);
        $data['clear_integral'] = $clear_integral;
        $data['clear_time'] = $clear_time;
        //是否统计积分使用情况
        if ($integral || $all) {
            /** @var UserBillServices $userBill */
            $userBill = app()->make(UserBillServices::class);
            $data['sum_integral'] = intval($userBill->getRecordCount($uid, 'integral', [], '', true));
            $data['deduction_integral'] = intval($userBill->getRecordCount($uid, 'integral') ?? 0);
            $data['today_integral'] = intval($userBill->getRecordCount($uid, 'integral', [], 'today', true));

            $data['frozen_integral'] = $userBill->getBillSum(['uid' => $uid, 'category' => 'integral', 'pm' => 1, 'is_frozen' => 1]);
            $data['integral'] = bcsub((string)$user['integral'],(string)$data['frozen_integral'],0);
            $data['integral_effective_status'] = (int)sys_config('integral_effective_status');
            $data['clear_end'] = '';
            if ($data['integral_effective_status']) {
                [$clear_end, $start, $end] = $userIntegralServices->getTime();
                $data['clear_end'] = date('Y-m-d', $clear_end);
            }
        }
        if (!$user['is_promoter']) {
            $data['is_promoter'] = (int)sys_config('store_brokerage_statu') == 2;
        }
        return $data;
    }


修改文件:app\services\user\UserServices

修改方法:personalHome()

public function personalHome(array $user, $tokenData)
    {
        $uid = (int)$user['uid'];
        /** @var StoreCouponUserServices $storeCoupon */
        $storeCoupon = app()->make(StoreCouponUserServices::class);
        /** @var UserMoneyServices $userMoneyServices */
        $userMoneyServices = app()->make(UserMoneyServices::class);
        /** @var UserExtractServices $userExtract */
        $userExtract = app()->make(UserExtractServices::class);
        /** @var StoreOrderServices $storeOrder */
        $storeOrder = app()->make(StoreOrderServices::class);
        /** @var UserLevelServices $userLevel */
        $userLevel = app()->make(UserLevelServices::class);
        /** @var StoreServiceServices $storeService */
        $storeService = app()->make(StoreServiceServices::class);
        /** @var WechatUserServices $wechatUser */
        $wechatUser = app()->make(WechatUserServices::class);
        /** @var UserRelationServices $productRelation */
        $productRelation = app()->make(UserRelationServices::class);
        /** @var SystemMessageServices $systemMessageServices */
        $systemMessageServices = app()->make(SystemMessageServices::class);
        /** @var DiyServices $diyServices */
        $diyServices = app()->make(DiyServices::class);
        /** @var AgentLevelServices $agentLevelServices */
        $agentLevelServices = app()->make(AgentLevelServices::class);
        /** @var StoreProductLogServices $storeProductLogServices */
        $storeProductLogServices = app()->make(StoreProductLogServices::class);
        //是否存在核销码
        if (!$user['bar_code']) {
            $bar_code = $this->getBarCode();
            $this->dao->update($uid, ['bar_code' => $bar_code], 'uid');
            $user['bar_code'] = $bar_code;
        }
        //获取配置参数
        $configData = SystemConfigService::more([
            'member_card_status',
            'brokerage_func_status',
            'store_brokerage_statu',
            'store_brokerage_price',
            'member_func_status',
            'recharge_switch',
            'extract_time',
            'balance_func_status',
            'invoice_func_status',
            'special_invoice_status',
            'user_extract_bank_status',
            'user_extract_wechat_status',
            'user_extract_alipay_status',
            'user_extract_balance_status',
            'level_activate_status'
        ]);
        //看付费会员是否开启
        $user['is_open_member'] = $user['svip_open'] = !!($configData['member_card_status'] ?? 0);
        $user['agent_level_name'] = '';
        //分销等级信息
        if ($user['agent_level']) {
            $levelInfo = $agentLevelServices->getLevelInfo((int)$user['agent_level'], 'id,name');
            $user['agent_level_name'] = $levelInfo && $levelInfo['name'] ? $levelInfo['name'] : '';
        }
        $wechatUserInfo = $wechatUser->getOne(['uid' => $uid, 'user_type' => $tokenData['type']], 'uid,is_complete');
        $user['is_complete'] = $wechatUserInfo['is_complete'] ?? 0;
        $user['couponCount'] = $storeCoupon->getUserValidCouponCount((int)$uid);
        $user['like'] = $productRelation->getUserCount($uid, 0, 'like');
        $user['collectProductCount'] = $productRelation->getUserCount($uid, 0, 'collect', 'product');
        $user['collectVideoCount'] = 0;
        if (sys_config('video_func_status', 1)) {
            $user['collectVideoCount'] = $productRelation->getUserCount($uid, 0, 'collect', 'video');
        }
        $user['orderStatusNum'] = $storeOrder->getOrderData($uid);
        $user['notice'] = 0;
        $user['recharge'] = $userMoneyServices->getRechargeSum($uid);//累计充值
        $user['orderStatusSum'] = (float)$userMoneyServices->sum(['uid' => $uid, 'pm' => 0, 'status' => 1], 'number', true);
        $user['extractTotalPrice'] = $userExtract->getExtractSum(['uid' => $uid, 'status' => 1]);//累计提现
        $user['extractPrice'] = $user['brokerage_price'];//可提现
        $user['statu'] = (int)($configData['store_brokerage_statu'] ?? 0);
        $orderStatusSum = (float)$storeOrder->sum(['pid' => 0, 'paid' => 1, 'refund_status' => [0, 3], 'uid' => $user['uid'], 'is_del' => 0], 'pay_price', true);//累计有效消费
        $user['spread_status'] = ($configData['brokerage_func_status'] ?? 1) && $this->checkUserPromoter($user['uid'], $user, $orderStatusSum);
        if (!$user['is_promoter'] && $user['spread_status']) {
            $this->dao->update($uid, ['is_promoter' => 1], 'uid');
            $user['is_promoter'] = 1;
        }
        if ($user['statu'] == 3) {
            $storeBrokeragePrice = $configData['store_brokerage_price'] ?? 0;
            $user['promoter_price'] = bcsub((string)$storeBrokeragePrice, (string)$user['orderStatusSum'], 2);
        }
        /** @var UserBrokerageServices $userBrokerageServices */
        $userBrokerageServices = app()->make(UserBrokerageServices::class);
        $user['broken_commission'] = max($userBrokerageServices->getUserFrozenPrice($uid), 0);
        $user['commissionCount'] = max(bcsub((string)$user['brokerage_price'], (string)$user['broken_commission'], 2), 0);
        $user['spread_user_count'] = $this->dao->count(['spread_uid' => $uid]);
        $user['spread_order_count'] = $storeOrder->count(['type' => 0, 'paid' => 1, 'refund_status' => [0, 3], 'is_del' => 0, 'is_system_del' => 0, 'spread_or_uid' => $uid]);
        //用户等级信息
        $userLevelInfo = $userLevel->homeGetUserLevel((int)$user['uid'], $user);
        $user = array_merge($user, $userLevelInfo);
        $user['yesterDay'] = $userBrokerageServices->getUsersBokerageSum(['uid' => $uid, 'pm' => 1], 'yesterday');
        $user['recharge_switch'] = (int)($configData['recharge_switch'] ?? 0);//充值开关
        $user['adminid'] = $storeService->checkoutIsService(['uid' => $uid, 'status' => 1, 'customer' => 1]);
        $user['broken_day'] = (int)($configData['extract_time'] ?? 0);//佣金冻结时间
        $user['balance_func_status'] = (int)($configData['balance_func_status'] ?? 0);
        $user['invioce_func'] = !!($configData['invoice_func_status'] ?? 0);
        $user['special_invoice'] = $user['invioce_func'] && ($configData['special_invoice_status'] ?? 0);
        $user['pay_vip_status'] = $user['is_ever_level'] || ($user['is_money_level'] && $user['overdue_time'] > time());
        $user['member_style'] = (int)$diyServices->getColorChange('member');
        if ($user['is_ever_level']) {
            $user['vip_status'] = 1;//永久会员
        } else {
            if (!$user['is_money_level'] && $user['overdue_time'] && $user['overdue_time'] < time()) {
                $user['vip_status'] = -1;//开通过已过期
            } else if (!$user['overdue_time'] && !$user['is_money_level']) {
                $user['vip_status'] = 2;//没有开通过
            } else if ($user['is_money_level'] && $user['overdue_time'] && $user['overdue_time'] > time()) {
                $user['vip_status'] = 3;//开通了,没有到期
            }
        }
        $user['service_num'] = $systemMessageServices->getUserMessageNum($uid);
        $user['is_agent_level'] = ($configData['brokerage_func_status'] ?? 1) && $agentLevelServices->count(['status' => 1, 'is_del' => 0]);
        $user['visit_num'] = $storeProductLogServices->getDistinctCount(['uid' => $uid, 'type' => 'visit'], 'product_id');
        $user['user_extract_bank_status'] = (int)($configData['user_extract_bank_status'] ?? 1);
        $user['user_extract_wechat_status'] = (int)($configData['user_extract_wechat_status'] ?? 1);
        $user['user_extract_alipay_status'] = (int)($configData['user_extract_alipay_status'] ?? 1);
        $user['user_extract_balance_status'] = (int)($configData['user_extract_balance_status'] ?? 1);
        //是否享受新人专享
        /** @var StoreNewcomerServices $newcomerServices */
        $newcomerServices = app()->make(StoreNewcomerServices::class);
        $user['newcomer_status'] = $newcomerServices->checkUserNewcomer($uid);
        $user['level_activate_status'] = $configData['level_activate_status'];
        $user['member_func_status'] = $configData['member_func_status'];
        $extendInfo = SystemConfigService::get('user_extend_info', []);
        $user['register_extend_info'] = [];
        if (!$user['level_activate_status'] || $user['level_status']) {//不需要激活,用户激活状态默认为1
            $user['level_status'] = 1;
        } else {
            $user['level_status'] = 0;
        }
        /** @var UserBillServices $userBill */
        $userBill = app()->make(UserBillServices::class);
        $user['integral'] = bcsub((string)$user['integral'],(string)$userBill->getBillSum(['uid' => $uid, 'category' => 'integral', 'pm' => 1, 'is_frozen' => 1]),0);
        if ($extendInfo) {
            foreach ($extendInfo as $item) {
                if (isset($item['use']) && $item['use'] && isset($item['user_show']) && $item['user_show']) $user['register_extend_info'][] = $item;
            }
        }
        if (isset($user['extend_info']) && $user['extend_info']) {
            $default = $this->defaultExtendInfo;
            $params = array_column($default, 'param');
            $sex = $this->rSex;
            foreach ($user['extend_info'] as &$info) {
                if (isset($info['param']) && in_array($info['param'], $params)) {
                    if ($info['param'] == 'sex') {
                        $info['value'] = $sex[$user['sex']] ?? 0;
                    } elseif ($info['param'] == 'birthday') {
                        $info['value'] = ($user['birthday'] ?? '') ? date('Y-m-d', $user['birthday']) : '';
                    } elseif ($info['param'] == 'address') {
                        $info['value'] = $user['addres'] ?? '';
                    } else {
                        $info['value'] = $user[$info['param']] ?? '';
                    }
                }
            }
        }

        $user['is_default_avatar'] = $user['avatar'] == sys_config('h5_avatar') ? 1 : 0;
        $user['promoter_status'] = app()->make(SystemUserApplyServices::class)->value(['uid' => $user['uid'], 'is_del' => 0, 'type' => 0], 'status') ?? -1;
        return $user;
    }


修改文件:app\services\order\StoreOrderComputedServices

修改方法:useIntegral()

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

        $deductionPrice = 0;
        $usedIntegral = 0;
        if ($userInfo && $useIntegral && $usable > 0 && $payPrice) {
			$integralMaxType = sys_config('integral_max_type', 1);//积分抵用上限类型1:积分、2:订单金额比例
			if ($integralMaxType == 1) {//最多抵用积分
				$integralMaxNum = sys_config('integral_max_num', 200);
				if ($integralMaxNum > 0 && $usable > $integralMaxNum) {
					$integral = $integralMaxNum;
				} else {
					$integral = $usable;
				}
				$deductionPrice = (float)bcmul((string)$integral, (string)$other['integralRatio'], 2);
				if ($deductionPrice < $payPrice) {
					$payPrice = bcsub((string)$payPrice, (string)$deductionPrice, 2);
					$usedIntegral = $integral;
				} else {
					if ($other['integralRatio']) {
						$deductionPrice = $payPrice;
						$usedIntegral = (int)ceil(bcdiv((string)$payPrice, (string)$other['integralRatio'], 2));
					}
					$payPrice = 0;
				}
			} else {//最高抵用比率
				$integralMaxRate = sys_config('integral_max_rate', 0);
				$deductionPrice = (float)bcmul((string)$usable, (string)$other['integralRatio'], 2);
				if ($integralMaxRate > 0 && $integralMaxRate <= 100) {
					$integralMaxPrice = (float)bcmul((string)$payPrice, (string)bcdiv((string)$integralMaxRate, '100', 2), 2);
				} else {
					$integralMaxPrice = $payPrice;
				}
				$deductionPrice = min($deductionPrice, $integralMaxPrice);
				$payPrice = bcsub((string)$payPrice, (string)$deductionPrice, 2);
				$usedIntegral = ceil(bcdiv((string)$deductionPrice, (string)$other['integralRatio'], 2));
			}
            if ($payPrice <= 0) $payPrice = 0;
        }
        $SurplusIntegral = (int)bcsub((string)$usable, $usedIntegral, 0);
        return [$payPrice, $deductionPrice, $usedIntegral, $SurplusIntegral];
    }


修改文件:app\services\order\StoreOrderServices

修改方法:getOrderConfirmData()


public function getOrderConfirmData(array $user, $cartId, bool $new, int $addressId, int $shipping_type = 1, int $store_id = 0, int $coupon_id = 0)
    {
        $addr = $data = [];
        $uid = (int)$user['uid'];
        /** @var UserAddressServices $addressServices */
        $addressServices = app()->make(UserAddressServices::class);
        if ($addressId) {
            $addr = $addressServices->getAdderssCache($addressId);
        }
        //没传地址id或地址已删除未找到 ||获取默认地址
        if (!$addr) {
            $addr = $addressServices->getUserDefaultAddressCache($uid);
        }
        $data['upgrade_addr'] = 0;
        if ($addr) {
            $addr = is_object($addr) ? $addr->toArray() : $addr;
            if (isset($addr['upgrade']) && $addr['upgrade'] == 0) {
                $data['upgrade_addr'] = 1;
            }
        } else {
            $addr = [];
        }
        if ($store_id) {
            /** @var SystemStoreServices $storeServices */
            $storeServices = app()->make(SystemStoreServices::class);
            $storeServices->getStoreInfo($store_id);
        }
        /** @var StoreCartServices $cartServices */
        $cartServices = app()->make(StoreCartServices::class);
        //获取购物车信息
        $cartGroup = $cartServices->getUserProductCartListV1($uid, $cartId, $new, $addr, $shipping_type, $store_id, $coupon_id);
        $storeFreePostage = floatval(sys_config('store_free_postage')) ?: 0;//满额包邮金额
        $data['storeFreePostage'] = $storeFreePostage;
        $validCartInfo = $cartGroup['valid'];
        $giveCartList = $cartGroup['giveCartList'] ?? [];
        /** @var StoreOrderComputedServices $computedServices */
        $computedServices = app()->make(StoreOrderComputedServices::class);
        $priceGroup = $computedServices->getOrderPriceGroup($uid, $validCartInfo, $addr, $storeFreePostage);
        $priceGroup['couponPrice'] = $cartGroup['couponPrice'] ?? 0;
		$priceGroup['useCoupon'] = $cartGroup['useCoupon'] ?? [];
        $priceGroup['firstOrderPrice'] = $cartGroup['firstOrderPrice'] ?? 0;
        $validCartInfo = array_merge($priceGroup['cartInfo'] ?? $validCartInfo, $giveCartList);
        $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']
        ];
        $deduction = $cartGroup['deduction'];
        $data['product_type'] = $deduction['product_type'] ?? 0;
        $data['valid_count'] = count($validCartInfo);
        $data['addressInfo'] = $addr;
        $data['type'] = $deduction['type'] ?? 0;
        $data['activity_id'] = $deduction['activity_id'] ?? 0;
        $data['seckill_id'] = $deduction['type'] == 1 ? $deduction['activity_id'] : 0;
        $data['bargain_id'] = $deduction['type'] == 2 ? $deduction['activity_id'] : 0;
        $data['combination_id'] = $deduction['type'] == 3 ? $deduction['activity_id'] : 0;
		$data['storeIntegralId'] = $deduction['type'] == 4 ? $deduction['activity_id'] : 0;
		$data['discount_id'] = $deduction['type'] == 5 ? $deduction['activity_id'] : 0;
        $data['luck_record_id'] = $deduction['type'] == 8 ? $deduction['activity_id'] : 0;
		$data['newcomer_id'] = $deduction['type'] == 7 ? $deduction['activity_id'] : 0;
        $data['collate_code_id'] = $deduction['type'] == 9 || $deduction['type'] == 10 ? $deduction['collate_code_id'] : 0;
        $data['deduction'] = in_array($deduction['product_type'], [1, 2]) || $deduction['activity_id'] > 0;
        $data['cartInfo'] = array_merge($cartGroup['cartInfo'], $giveCartList);
        // $data['giveCartInfo'] = $giveCartList;
        $data['custom_form'] = [];
        if (isset($cartGroup['cartInfo'][0]['productInfo']['system_form_id']) && $cartGroup['cartInfo'][0]['productInfo']['system_form_id']) {
			/** @var SystemFormServices $systemFormServices */
			$systemFormServices = app()->make(SystemFormServices::class);
			$formInfo = $systemFormServices->value(['id' => $cartGroup['cartInfo'][0]['productInfo']['system_form_id']], 'value');
			if ($formInfo) {
				$data['custom_form'] = is_string($formInfo) ? json_decode($formInfo, true) : $formInfo;
			}
        }
        $data['give_integral'] = $other['give_integral'];
        $data['give_coupon'] = [];
        if ($other['give_coupon']) {
            /** @var StoreCouponIssueServices $couponIssueService */
            $couponIssueService = app()->make(StoreCouponIssueServices::class);
            $data['give_coupon'] = $couponIssueService->getColumn([['id', 'IN', $other['give_coupon']]], 'id,coupon_title');
        }
        $data['priceGroup'] = $priceGroup;
        $data['orderKey'] = $this->cacheOrderInfo($uid, $validCartInfo, $priceGroup, $other, $addr, $cartGroup['invalid'] ?? [], $deduction);

		$userInfo = ['uid' => $user['uid'], 'nickname' => $user['nickname'], 'phone' => $user['phone'], 'now_money' => $user['now_money'], 'integral' => $user['integral']];
		$userInfo['vip'] = isset($priceGroup['vipPrice']) && $priceGroup['vipPrice'] > 0;
		$userInfo['vip_id'] = 0;
		$userInfo['discount'] = 0;
		//用户等级是否开启
		if (sys_config('member_func_status', 1)) {
			/** @var UserLevelServices $levelServices */
			$levelServices = app()->make(UserLevelServices::class);
			$userLevel = $levelServices->getUerLevelInfoByUid($uid);
			if ($userInfo['vip'] || $userLevel) {
				$userInfo['vip'] = true;
				$userInfo['vip_id'] = $userLevel['id'] ?? 0;
				$userInfo['discount'] = $userLevel['discount'] ?? 0;
			}
		}
		$userInfo['real_name'] = isset($user['real_name']) && $user['real_name'] ? $user['real_name'] : $user['nickname'];
		$userInfo['record_pone'] = isset($user['record_phone']) && $user['record_phone'] ?  $user['record_phone'] : $user['phone'];
        /** @var UserBillServices $userBill */
        $userBill = app()->make(UserBillServices::class);
        $userInfo['integral'] = bcsub((string)$userInfo['integral'], (string)$userBill->getBillSum(['uid' => $userInfo['uid'], 'category' => 'integral', 'pm' => 1, 'is_frozen' => 1]), 0);
        $data['userInfo'] = $userInfo;

		$data['offlinePostage'] = $other['offlinePostage'];
        $data['integralRatio'] = $other['integralRatio'];
		$data['integral_ratio_status'] = (int)sys_config('integral_ratio_status', 1);
        $data['store_func_status'] = (int)(sys_config('store_func_status', 1));//门店是否开启
        $data['store_self_mention'] = false;//门店核销
        $data['store_delivery_status'] = false;//门店配送
        if ($data['store_func_status']) {
            //门店核销是否开启
            /** @var SystemStoreServices $systemStoreServices */
            $systemStoreServices = app()->make(SystemStoreServices::class);
            $data['store_self_mention'] = sys_config('store_self_mention') && $systemStoreServices->count(['type' => 0, 'delivery_type' => [1, 3]]);
            $data['store_delivery_status'] = !!$systemStoreServices->count(['type' => 0, 'delivery_type' => [1, 2]]);
        }
        $data['store_func_status'] = $data['store_func_status'] && ($data['store_self_mention'] || $data['store_delivery_status']);

        $data['system_store'] = [];//门店信息
        /** @var UserInvoiceServices $userInvoice */
        $userInvoice = app()->make(UserInvoiceServices::class);
        $invoice_func = $userInvoice->invoiceFuncStatus();
        $data['invoice_func'] = $invoice_func['invoice_func'];
        $data['special_invoice'] = $invoice_func['special_invoice'];
		/** @var UserServices $userServices */
		$userServices = app()->make(UserServices::class);
		$data['svip_status'] = $svip_status = $userServices->checkUserIsSvip($uid);
		$svip_price = 0.00;
		//开启付费会员 且用户不是付费会员 //计算 开通付费会员节省金额
		if (sys_config('member_card_status', 1) && !$svip_status) {
			$payPrice = $cartServices->getPayPrice((string)$priceGroup['totalPrice'], (string)($priceGroup['couponPrice'] ?? 0), (string)($priceGroup['firstOrderPrice'] ?? 0));
			[$vipPayPrice, $payPostage, $storePostageDiscount] = $cartServices->computeUserVipCart($uid, $cartId, $shipping_type, $new, $store_id, false, $coupon_id, $addr);
			$svip_price = (float)max(bcadd((string)bcsub((string)$payPrice, (string)$vipPayPrice, 2), (string)$storePostageDiscount, 2), 0);
		}
		$data['svip_price'] = $svip_price;
        /** @var UserBillServices $userBillServices */
        $userBillServices = app()->make(UserBillServices::class);
        $data['usable_integral'] = bcsub((string)$user['integral'], (string)$userBillServices->getBillSum(['uid' => $user['uid'],'category' => 'integral', 'pm' => 1, 'is_frozen' => 1]), 0);
        $data['integral_open'] = sys_config('integral_ratio', 0) > 0;
        return $data;
    }


修改文件:app\services\activity\lottery\LuckLotteryServices

修改方法:getLotteryNum()

public function getLotteryNum(int $uid, int $lottery_id, array $userInfo = [], array $lottery = [])
    {
        /** @var UserServices $userServices */
        $userServices = app()->make(UserServices::class);
        if (!$userInfo) {
            $userInfo = $userServices->getUserInfo($uid);
        }
        if (!$userInfo) {
            throw new ValidateException('用户不存在');
        }
        if (!$lottery) {
            $lottery = $this->dao->getLottery($lottery_id, '*', [], true);
        }
        if (!$lottery) {
            throw new ValidateException('该活动已经下架,请持续关注');
        }
        //抽奖类型:1:积分2:余额3:下单支付成功4:订单评价5:拉新人
        switch ($lottery['factor']) {
            case 1:
                /** @var UserBillServices $userBillServices */
                $userBillServices = app()->make(UserBillServices::class);
                $usable_integral = bcsub((string)$userInfo['integral'], (string)$userBillServices->getBillSum(['uid' => $userInfo['uid'],'category' => 'integral', 'pm' => 1, 'is_frozen' => 1]), 0);
                return $usable_integral > 0 && $lottery['factor_num'] > 0 ? floor($usable_integral / $lottery['factor_num']) : 0;
                break;
            case 2:
                return $userInfo['now_money'] > 0 && $lottery['factor_num'] > 0 ? floor($userInfo['now_money'] / $lottery['factor_num']) : 0;
                break;
            case 3:
                return $this->getCacheLotteryNum($uid, 'order');
                break;
            case 4:
                return $this->getCacheLotteryNum($uid, 'comment');
                break;
            case 5:
                return $userInfo['spread_lottery'] ?? 0;
                break;
            default:
                throw new ValidateException('暂未有该类型活动');
                break;
        }
    }


修改文件:app\services\order\StoreOrderCreateServices

修改方法:deductIntegral()

public function deductIntegral(array $userInfo, bool $useIntegral, array $priceData, int $uid, string $key)
    {
        $res2 = true;
        if (sys_config('integral_ratio_status', 1) && $userInfo && $useIntegral && $userInfo['integral'] > 0) {
            /** @var UserServices $userServices */
            $userServices = app()->make(UserServices::class);
            if (!$priceData['SurplusIntegral'] && $priceData['usedIntegral'] >= $userInfo['integral']) {
                $integral = 0;
            } else {
                $integral = bcsub((string)$userInfo['integral'], (string)$priceData['usedIntegral']);
            }
            $res2 = false !== $userServices->update($uid, ['integral' => $integral]);
            /** @var UserBillServices $userBillServices */
            $userBillServices = app()->make(UserBillServices::class);
            $res3 = $userBillServices->income('deduction', $uid, [
                'number' => (int)$priceData['usedIntegral'],
                'deductionPrice' => $priceData['deduction_price']
            ], $integral, $key);

            $res2 = $res2 && false != $res3;
        }
        if (!$res2) {
            throw new ValidateException('使用积分抵扣失败!');
        }
    }


请登录后查看

全 最后编辑于2024-12-11 11:19:30

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

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

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推荐': '推荐'}}
{{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.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
184
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

快速安全登录

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

微信登录/注册

切换手机号登录

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

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

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 源码下载 CRMEB帮助文档 帮助文档
返回顶部 返回顶部
CRMEB客服