问题说明:单店模式-添加商品优惠券,一次性添加两个商品时,领取优惠券后,在优惠券列表不显示商品
解决方法:
修改文件:app/services/product/product/StoreProductServices.php
修改方法: getGoodsList()
public function getGoodsList(array $where, int $uid, int $promotions_type = 0, bool $isEntryRules = true)
{
$appendWhere = [];
if (isset($where['coupon_id']) && $where['coupon_id']) {
$isEntryRules = false;
/** @var StoreCouponIssueServices $couponIssueService */
$couponIssueService = app()->make(StoreCouponIssueServices::class);
$where['relation_id'] = $couponIssueService->value(['id' => $where['coupon_id']], 'relation_id');
$where['is_delivery_type'] = true;
}
//进店规则查询商品
if ($isEntryRules) {
$appendWhere = $this->getWhereByEntryRules($uid);
if (isset($appendWhere['relation_id']) && isset($where['ids']) && $where['ids']) {//单店模式 商品列表diy选择商品ID
//处理成适用门店
$ids = $this->dao->getColumn(['is_verify' => 1, 'is_show' => 1, 'is_del' => 0, 'pid' => $where['ids'], 'type' => 1, 'relation_id' => $appendWhere['relation_id']], 'id');
if (!$ids) {
return [];
}
$where['ids'] = $ids;
}
}
$where = array_merge($where, $appendWhere);
$where['is_verify'] = 1;
$where['is_show'] = 1;
$where['is_del'] = 0;
$collate_code_id = 0;
if (isset($where['collate_code_id'])) {
$collate_code_id = $where['collate_code_id'];
}
if (isset($where['store_name']) && $where['store_name']) {
/** @var UserSearchServices $userSearchServices */
$userSearchServices = app()->make(UserSearchServices::class);
$searchIds = $userSearchServices->vicSearch($uid, $where['store_name'], $where);
if ($searchIds) {//之前查询结果记录
$where['ids'] = $searchIds;
unset($where['store_name']);
}
}
$promotionsWhere = [];
$list = [];
//优惠活动凑单
if (isset($where['promotions_id']) && $where['promotions_id']) {
/** @var StorePromotionsServices $storePromotionsServices */
$storePromotionsServices = app()->make(StorePromotionsServices::class);
$promotionsWhere = $storePromotionsServices->collectProductById((int)$where['promotions_id']);
unset($where['promotions_id']);
} else if (isset($where['promotions_type']) && $where['promotions_type']) {
/** @var StorePromotionsServices $storePromotionsServices */
$storePromotionsServices = app()->make(StorePromotionsServices::class);
$promotionsWhere = $storePromotionsServices->collectProductByType([(int)$where['promotions_type']]);
unset($where['promotions_type']);
}
if (!$promotionsWhere || (isset($promotionsWhere['ids']) && $promotionsWhere['ids'])) {
$where = array_merge($where, $promotionsWhere);
unset($where['promotions_id']);
if (isset($where['productId']) && $where['productId'] != '') {
$where['ids'] = is_string($where['productId']) ? stringToIntArray($where['productId']) : $where['productId'];
$where['ids'] = array_unique(array_map('intval', $where['ids']));
unset($where['productId']);
}
$where['is_vip_product'] = 0;
$discount = 100;
$level_name = '';
if (!$promotions_type && $uid) {
/** @var UserServices $user */
$user = app()->make(UserServices::class);
$userInfo = $user->getUserCacheInfo($uid);
$is_vip = $userInfo['is_money_level'] ?? 0;
$where['is_vip_product'] = $is_vip ? -1 : 0;
//用户等级是否开启
/** @var SystemUserLevelServices $systemLevel */
$systemLevel = app()->make(SystemUserLevelServices::class);
$levelInfo = $systemLevel->getLevelCache((int)($userInfo['level'] ?? 0));
if (sys_config('member_func_status', 1) && $levelInfo) {
$discount = $levelInfo['discount'] ?? 100;
}
$level_name = $levelInfo['name'] ?? '';
}
[$page, $limit] = $this->getPageValue();
$field = ['id,relation_id,type,pid,delivery_type,product_type,store_name,cate_id,image,IFNULL(sales, 0) + IFNULL(ficti, 0) as sales,price,stock,activity,ot_price,spec_type,recommend_image,unit_name,is_vip,vip_price,is_presale_product,is_vip_product,system_form_id,system_form_type,is_presale_product,presale_start_time,presale_end_time,is_limit,limit_num,video_open,video_link,freight,star,store_label_id,brand_id'];
$list = $this->dao->getSearchList($where, $page, $limit, $field, '', ['couponId']);
if ($list) {
/** @var MemberCardServices $memberCardService */
$memberCardService = app()->make(MemberCardServices::class);
$vipStatus = $memberCardService->isOpenMemberCardCache('vip_price') && sys_config('svip_price_status', 1);
/** @var SystemFormServices $systemFormServices */
$systemFormServices = app()->make(SystemFormServices::class);
$systemForms = $systemFormServices->getColumn([['id', 'in', array_unique(array_column($list, 'system_form_id'))], ['is_del', '=', 0]], 'id,value', 'id');
/** @var StoreProductLabelServices $storeProductLabelServices */
$storeProductLabelServices = app()->make(StoreProductLabelServices::class);
foreach ($list as &$item) {
$minData = $this->getMinPrice($uid, $item, $discount);
$item['price_type'] = $minData['price_type'] ?? '';
$item['level_name'] = $level_name;
$item['vip_price'] = $item['level_price'] = 0.00;
if ($item['price_type'] == 'member') {
$item['vip_price'] = $minData['vip_price'] ?? 0;
if (!$item['is_vip'] || !$vipStatus) {
$item['vip_price'] = 0;
}
} else {
$item['level_price'] = $minData['vip_price'] ?? 0;
}
$custom_form = $systemForms[$item['system_form_id']]['value'] ?? [];
$item['custom_form'] = is_string($custom_form) ? json_decode($custom_form, true) : $custom_form;
$item['cart_button'] = $item['product_type'] > 0 || $item['is_presale_product'] || $item['system_form_id'] ? 0 : 1;
$item['presale_pay_status'] = $this->checkPresaleProductPay((int)$item['id'], $item);
if (!$item['video_open']) {
$item['video_link'] = '';
}
$item['store_label'] = [];
if ($item['store_label_id']) {
$item['store_label'] = $storeProductLabelServices->getLabelCache($item['store_label_id'], ['id', 'label_name', 'style_type', 'color', 'bg_color', 'border_color', 'icon']);
}
if (isset($item['brand_id']) && $item['brand_id']) {
$item['brand_name'] = $this->productIdByBrandName((int)$item['id'], $item);
}
$item['activity'] = [];
if (isset($item['couponId'])) {
$item['checkCoupon'] = (bool)count($item['couponId']);
unset($item['couponId']);
} else {
$item['checkCoupon'] = false;
}
}
// if (!$collate_code_id) {
// $list = $this->getActivityList($list);
// }
$list = $this->getProduceOtherList($list, $uid, isset($where['status']) && !!$where['status'], $collate_code_id);
$list = $this->getProductPromotions($list, $promotions_type ? [$promotions_type] : []);
}
}
return $list;
}
