diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index c40d2ed..0ec945e 100755 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -1325,7 +1325,7 @@ class ProductRepository extends BaseRepository public function apiProductDetail($where, int $productType, ?int $activityId, $userInfo = null) { - $field = 'is_show,product_id,mer_id,image,slider_image,store_name,store_info,unit_name,price,cost,ot_price,stock,sales,video_link,is_hot,product_type,extension_type,old_product_id,rate,guarantee_template_id,temp_id,once_max_count,pay_limit,once_min_count,integral_rate,delivery_way,delivery_free,type,cate_id,svip_price_type,svip_price,mer_svip_status,mer_form_id,normal_intergal_one,normal_intergal_two,normal_diamond_one,normal_diamond_two,hot_intergal_one,hot_intergal_two,hot_diamond_one,hot_diamond_two,hot_intergal_rate,hot_intergal_total'; + $field = 'is_show,product_id,mer_id,image,slider_image,store_name,store_info,unit_name,price,cost,ot_price,stock,sales,video_link,is_hot,product_type,extension_type,old_product_id,rate,guarantee_template_id,temp_id,once_max_count,pay_limit,once_min_count,integral_rate,delivery_way,delivery_free,type,cate_id,svip_price_type,svip_price,mer_svip_status,mer_form_id,normal_integral_one,normal_integral_two,normal_diamond_one,normal_diamond_two,hot_integral_one,hot_integral_two,hot_diamond_one,hot_diamond_two,hot_integral_rate,hot_integral_total'; $with = [ 'attr', 'attrValue', diff --git a/app/common/repositories/user/UserAssetsLogRepository.php b/app/common/repositories/user/UserAssetsLogRepository.php index d4f0538..dce7b32 100644 --- a/app/common/repositories/user/UserAssetsLogRepository.php +++ b/app/common/repositories/user/UserAssetsLogRepository.php @@ -270,29 +270,36 @@ class UserAssetsLogRepository extends BaseRepository continue; } - // 先创建一条记录 - $hotData = array( - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'product_id' => $productItem['product_id'], - 'create_time' => date('Y-m-d H:i:s') - ); - $hotRepository->create($hotData); + $item = $hotRepository->getWhere(['product_id' => $productItem['product_id'], 'uid' => $order['uid']]); + if($item){ + $item['total'] += $product['hot_integral_total'] * $productItem['product_num']; + }else{ + // 先创建一条记录 + $hotData = array( + 'uid' => $order['uid'], + 'product_id' => $productItem['product_id'], + 'total' => $product['hot_integral_total'] * $productItem['product_num'], + 'create_time' => date('Y-m-d H:i:s') + ); + $hotRepository->create($hotData); + } // 计算每个购买当前爆单商品的积分数据 $profit = $productItem['total_price'] - $productItem['cost']; - $list = $hotRepository->getList(['status' => 0, 'product_id' => $productItem['product_id']]); + $where = array(); + $where[] = array('product_id', '=', $productItem['product_id']); + $where[] = array('total', '>', 'current'); + $list = $hotRepository->getList($where); - $max = $product['hot_integral_total']; $logList = array(); foreach ($list as $item){ $tmp = array('integral' => $this->_getValue($profit * $product['hot_integral_rate'] / 100 / count($list))); - if($max - $item['total'] < $tmp['integral']){ - $tmp['integral'] = $max - $item['total']; + if($item['total'] - $item['current'] < $tmp['integral']){ + $tmp['integral'] = $item['total'] - $item['current']; $item['status'] = 1; } $this->userAssetsRepository->updateAssets($item['uid'], $tmp); - $item['total'] += $tmp['integral']; + $item['current'] += $tmp['integral']; $item->save(); $logList[] = array( 'uid' => $item['uid'],