【程序目录】优惠券问题优化

This commit is contained in:
吴昊天 2023-01-04 14:46:29 +08:00
parent 571d4e6a4e
commit 9124e4cafc
4 changed files with 8 additions and 6 deletions

View File

@ -101,9 +101,11 @@ class StoreCouponIssueDao extends BaseDao
}])
->where('type', $type)
->when($type == 1, function ($query) use ($typeId) {
if ($typeId) $query->where('id', 'in', function ($query) use ($typeId) {
$query->name('store_coupon_product')->whereIn('category_id', $typeId)->field(['coupon_id'])->select();
})->whereOr('category_id', 'in', $typeId);
$query->where(function ($query) use ($typeId) {
$query->where('id', 'in', function ($query) use ($typeId) {
$query->name('store_coupon_product')->whereIn('category_id', $typeId)->field(['coupon_id'])->select();
})->whereOr('category_id', 'in', $typeId);
});
})
->when($type == 2, function ($query) use ($typeId) {
if ($typeId) $query->whereFindinSet('product_id', $typeId);

View File

@ -145,7 +145,7 @@ class StoreCouponUserServices extends BaseServices
case 1://品类券
/** @var StoreCategoryServices $storeCategoryServices */
$storeCategoryServices = app()->make(StoreCategoryServices::class);
$coupon_category = explode(',', $coupon['category_id']);
$coupon_category = explode(',', (string)$coupon['category_id']);
$category_ids = $storeCategoryServices->getAllById($coupon_category);
if ($category_ids) {
$cateIds = array_column($category_ids, 'id');

View File

@ -175,7 +175,7 @@ class StoreOrderComputedServices extends BaseServices
case 1://品类券
/** @var StoreCategoryServices $storeCategoryServices */
$storeCategoryServices = app()->make(StoreCategoryServices::class);
$coupon_category = explode(',', $couponInfo['category_id']);
$coupon_category = explode(',', (string)$couponInfo['category_id']);
$category_ids = $storeCategoryServices->getAllById($coupon_category);
if ($category_ids) {
$cateIds = array_column($category_ids, 'id');

View File

@ -650,7 +650,7 @@ class StoreOrderCreateServices extends BaseServices
case 1://品类券
/** @var StoreCategoryServices $storeCategoryServices */
$storeCategoryServices = app()->make(StoreCategoryServices::class);
$coupon_category = explode(',', $couponInfo['category_id']);
$coupon_category = explode(',', (string)$couponInfo['category_id']);
$category_ids = $storeCategoryServices->getAllById($coupon_category);
if ($category_ids) {
$cateIds = array_column($category_ids, 'id');