|
|
@@ -6,9 +6,11 @@ import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.hisStore.domain.FsStoreProductAttrScrm;
|
|
|
import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
|
|
|
+import com.fs.hisStore.domain.FsStoreProductPurchaseLimitScrm;
|
|
|
import com.fs.hisStore.domain.FsStoreProductScrm;
|
|
|
import com.fs.hisStore.service.IFsStoreProductAttrScrmService;
|
|
|
import com.fs.hisStore.service.IFsStoreProductAttrValueScrmService;
|
|
|
+import com.fs.hisStore.service.IFsStoreProductPurchaseLimitScrmService;
|
|
|
import com.fs.hisStore.service.IFsStoreProductScrmService;
|
|
|
import com.fs.hisStore.vo.FsStoreProductListVO;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
@@ -35,6 +37,9 @@ public class StoreProductController extends AppBaseController {
|
|
|
@Autowired
|
|
|
private IFsStoreProductAttrScrmService attrService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreProductPurchaseLimitScrmService purchaseLimitService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询本公司下的商城产品列表
|
|
|
*/
|
|
|
@@ -71,6 +76,7 @@ public class StoreProductController extends AppBaseController {
|
|
|
*/
|
|
|
@ApiOperation("查看商品详情")
|
|
|
@GetMapping("/{productId}")
|
|
|
+ @Login
|
|
|
public R getInfo(@PathVariable("productId") Long productId,
|
|
|
@RequestParam("companyId") Long companyId,
|
|
|
@RequestParam("companyUserId") Long companyUserId) {
|
|
|
@@ -86,10 +92,33 @@ public class StoreProductController extends AppBaseController {
|
|
|
// 查询商品规格属性值
|
|
|
List<FsStoreProductAttrScrm> productAttr=attrService.selectFsStoreProductAttrByProductId(product.getProductId());
|
|
|
List<FsStoreProductAttrValueScrm> productValues=attrValueService.selectFsStoreProductAttrValueByProductId(product.getProductId());
|
|
|
-
|
|
|
+ // 查询限购信息
|
|
|
+ Integer remainingPurchaseLimit = null; // 剩余可购买数量
|
|
|
+ Integer purchasedNum = 0; // 已购买数量
|
|
|
+ if (product.getPurchaseLimit() != null && product.getPurchaseLimit() > 0) {
|
|
|
+ // 商品有限购,查询用户是否购买过
|
|
|
+ String userId = getUserId();
|
|
|
+ if (StringUtils.isNotEmpty(userId)) {
|
|
|
+ FsStoreProductPurchaseLimitScrm purchaseLimit = purchaseLimitService.selectByProductIdAndUserId(
|
|
|
+ product.getProductId(), Long.parseLong(userId));
|
|
|
+ if (purchaseLimit != null) {
|
|
|
+ purchasedNum = purchaseLimit.getNum();
|
|
|
+ }
|
|
|
+ // 计算剩余可购买数量
|
|
|
+ remainingPurchaseLimit = product.getPurchaseLimit() - purchasedNum;
|
|
|
+ if (remainingPurchaseLimit < 0) {
|
|
|
+ remainingPurchaseLimit = 0;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 未登录用户,剩余可购买数量等于限购数量
|
|
|
+ remainingPurchaseLimit = product.getPurchaseLimit();
|
|
|
+ }
|
|
|
+ }
|
|
|
return R.ok().put("product", product)
|
|
|
.put("productAttr",productAttr)
|
|
|
- .put("productValues",productValues);
|
|
|
+ .put("productValues",productValues)
|
|
|
+ .put("remainingPurchaseLimit", remainingPurchaseLimit) // 剩余可购买数量
|
|
|
+ .put("purchasedNum", purchasedNum);
|
|
|
}
|
|
|
|
|
|
/**
|