当前位置: 首页 > news >正文

多商户商品下单限购问题修复

问题: 当商品设置限购为 1 时,够买数量未超过限购,但是还是提示超出限购数量

修复方法:

修改代码路径:

app\common\repositories\store\order\StoreOrderCreateRepository.php
修改代码一: i s p a y s = a r r a y u n i q u e ( a r r a y c o l u m n ( is_pays = array_unique(array_column( ispays=arrayunique(arraycolumn(merchantCart[‘list’],‘is_pay’));
if ( count($is_pays) > 1 || $is_pays[0] == 1) throw new ValidateException(‘存在已购买商品请重新添加购物车’);
// 获取每个商品的ID数组
p r o d u c t i d s = a r r a y c o l u m n ( product_ids = array_column( productids=arraycolumn(merchantCart[‘list’],‘product_id’);
n u m d a t a = a r r a y c o l u m n ( num_data = array_column( numdata=arraycolumn(merchantCart[‘list’],‘cart_num’);
i d n u m = [ ] ; / / 获取每个商品 I D 出现的次数及购买数量,作为验证限购数量使用 f o r e a c h ( id_num = []; // 获取每个商品ID出现的次数及购买数量,作为验证限购数量使用 foreach ( idnum=[];//获取每个商品ID出现的次数及购买数量,作为验证限购数量使用foreach(product_ids as $key => $value) {
i d n u m [ id_num[ idnum[value] = isset( i d n u m [ id_num[ idnum[value]) ? i d n u m [ id_num[ idnum[value] + n u m d a t a [ num_data[ numdata[key] : n u m d a t a [ num_data[ numdata[key];
}
c o u n t L i s t = c o u n t ( countList = count( countList=count(merchantCart[‘list’]);
修改后的样子:在这里插入图片描述
修改代码二:

$count = i d n u m [ id_num[ idnum[cart[‘product_id’]];
if (($count) > $cart[‘product’][‘once_max_count’]) {
throw new ValidateException(‘[超出限购总数:’ . c a r t [ ′ p r o d u c t ′ ] [ ′ o n c e m a x c o u n t ′ ] . ′ ] ′ . m b s u b s t r ( cart['product']['once_max_count'] . ']' . mb_substr( cart[product][oncemaxcount].].mbsubstr(cart[‘product’][‘store_name’], 0, 10) . ‘…’);
}
$pay_count = s t o r e O r d e r R e p o s i t o r y − > g e t M a x C o u n t N u m b e r ( storeOrderRepository->getMaxCountNumber( storeOrderRepository>getMaxCountNumber(cart[‘uid’], c a r t [ ′ p r o d u c t i d ′ ] ) ; i f ( ( cart['product_id']); if (( cart[productid]);if((count + $pay_count) > $cart[‘product’][‘once_max_count’]) {
throw new ValidateException(‘[超出限购总数:’ . c a r t [ ′ p r o d u c t ′ ] [ ′ o n c e m a x c o u n t ′ ] . ′ ] ′ . m b s u b s t r ( cart['product']['once_max_count'] . ']' . mb_substr( cart[product][oncemaxcount].].mbsubstr(cart[‘product’][‘store_name’], 0, 10) . ‘…’);
}
修改后的样子:在这里插入图片描述
最后:修改完了需要重启swoole服务

http://www.lryc.cn/news/430438.html

相关文章:

  • eNSP 华为ACL配置
  • 实现高效研发运营一体化:深度落地DevOps解决方案的探索与实践
  • Milvus向量数据库-磁盘索引简介
  • Web漏洞介绍和Sql注入漏洞
  • 【Eureka】Eureka 介绍与实战
  • 密码管理系统的自动化与集成:重塑安全与效率的双重飞跃
  • Outlook如何精确搜索邮件?
  • MambaCSR: 使用SSM的双交错扫描压缩图像超分辨率
  • 【C++】深入解析C/C++内存管理:new与delete的使用及原理
  • 递归--数据结构--黑马
  • 【3.1】贪心算法-解分发饼干
  • 解决 Error running ‘Application‘: Command line is too long.
  • 衡量与归因将是Netflix程序化广告业务的首要任务
  • 关于如何在已有qt项目中添加该项目的单元测试工程
  • 深度剖析数字媒体产业链的无限潜力与创新生态
  • 集团数字化转型方案(十二)
  • Andrid异步更新UI:Handler(二)深入了解:Message你真的会创建?它是如何子线程和主线程通知?
  • 2025计算机毕设50条小众好做的Java题目【计算机毕设选题推荐】
  • day06_算法训练
  • @SpringBootTest单元测试中报错:无法自动装配,找不到 ‘XXX‘ 类型的 Bean
  • nodemon学习(一)简介、安装、配置、使用
  • 【Qt从摄像头视频中获取数据】
  • 视频截取中的UI小组件
  • java设计模式--结构型模式
  • 消息中间件:Kafka消息丢失与堆积问题分析与解决方案
  • mac终端代理配置指南
  • mbedTLS生成客户端,服务端密钥及CA证书
  • 如何有效应对突发技术故障:以网易云音乐为例
  • 上传文件到github仓库
  • clip-path实现图片边角的裁剪