update:
1. add merchant upgrade api 2. add platform product default price
This commit is contained in:
4
doc/sql/pending/20260511.sql
Normal file
4
doc/sql/pending/20260511.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
alter table public.merchant_catalog
|
||||
add sell_price decimal(10, 2) default 0 not null;
|
||||
|
||||
comment on column public.merchant_catalog.sell_price is '销售价格';
|
||||
@@ -46,6 +46,13 @@ public class MarketMerchantController {
|
||||
return R.status(applicationService.applyMerchant(AuthUtil.getUserId(), request.getType(), request.getStoreName(), request.getCompanyName(), request.getBusinessLicense(), request.getBusinessLicenseUrl(), request.getLegalPerson()));
|
||||
}
|
||||
|
||||
@PostMapping("/merchant-upgrade-apply")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "自营商家升级认证提交")
|
||||
public R upgradeMerchant(@RequestBody @Valid UpgradeMerchantRequest request) {
|
||||
return R.status(applicationService.upgradeMerchant(AuthUtil.getUserId(), request.getCompanyName(), request.getBusinessLicense(), request.getBusinessLicenseUrl(), request.getLegalPerson()));
|
||||
}
|
||||
|
||||
@GetMapping("/merchant-audit-status")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "审核状态查询")
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.springblade.modules.api.request;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UpgradeMerchantRequest implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotEmpty(message = "企业名称不能为空")
|
||||
private String companyName;
|
||||
|
||||
@NotEmpty(message = "营业执照不能为空")
|
||||
private String businessLicense;
|
||||
|
||||
@NotEmpty(message = "请上传营业执照")
|
||||
private String businessLicenseUrl;
|
||||
|
||||
@NotEmpty(message = "法人不能为空")
|
||||
private String legalPerson;
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
<result column="detail_image_urls" property="detailImageUrls" typeHandler="org.springblade.common.handler.PgStringArrayToListTypeHandler"/>
|
||||
<result column="thumb_image_url" property="thumbImageUrl"/>
|
||||
<result column="cost_price" property="costPrice"/>
|
||||
<result column="sale_price" property="salePrice"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_dept" property="createDept"/>
|
||||
|
||||
@@ -97,6 +97,11 @@ public class MerchantCatalogEntity extends BaseEntity {
|
||||
*/
|
||||
@Schema(description = "成本价(进货价, 单位为现金券)")
|
||||
private BigDecimal costPrice;
|
||||
/**
|
||||
* 销售价(当商品类型为平台商品时,统一销售价格)
|
||||
*/
|
||||
@Schema(description = "销售价(当商品类型为平台商品时,统一销售价格)")
|
||||
private BigDecimal salePrice;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@@ -62,4 +62,6 @@ public interface IMarketMerchantApplicationService extends BaseService<MarketMer
|
||||
Integer merchantType(Long userId);
|
||||
|
||||
Boolean checkAvailable(String storeName);
|
||||
|
||||
Boolean upgradeMerchant(Long userId, String companyName, String businessLicense, String businessLicenseUrl, String legalPerson);
|
||||
}
|
||||
|
||||
@@ -137,6 +137,16 @@ public class MarketMerchantApplicationServiceImpl extends BaseServiceImpl<Market
|
||||
if (!checkAvailable(storeName)) {
|
||||
throw new ServiceException("店名不用");
|
||||
}
|
||||
Integer merchantTypeCode = MarketInfoCache.checkMerchantType(userId);
|
||||
MerchantType userType = MerchantType.fromCode(merchantTypeCode);
|
||||
if (userType != MerchantType.UNREVIEWED) {
|
||||
throw new ServiceException("您已经是入驻商家了");
|
||||
}
|
||||
MerchantType applyType = MerchantType.fromCode(type);
|
||||
if (applyType == MerchantType.UNREVIEWED) {
|
||||
throw new ServiceException("无效申请类型");
|
||||
}
|
||||
|
||||
MarketMerchantApplicationEntity application = new MarketMerchantApplicationEntity();
|
||||
MarketMerchantApplicationEntity userApplication = getByUserId(userId);
|
||||
application.setStoreName(storeName);
|
||||
@@ -150,7 +160,7 @@ public class MarketMerchantApplicationServiceImpl extends BaseServiceImpl<Market
|
||||
application.setUserId(userId);
|
||||
application.setUserAccount(userService.getById(userId).getAccount());
|
||||
}
|
||||
switch (MerchantType.fromCode(type)) {
|
||||
switch (applyType) {
|
||||
case UNREVIEWED -> throw new ServiceException("无效类型");
|
||||
case ENTERPRISE -> {
|
||||
application.setType(MerchantType.ENTERPRISE.getCode());
|
||||
@@ -218,4 +228,33 @@ public class MarketMerchantApplicationServiceImpl extends BaseServiceImpl<Market
|
||||
}
|
||||
return !exists(Wrappers.lambdaQuery(MarketMerchantApplicationEntity.class).eq(MarketMerchantApplicationEntity::getStoreName, storeName).eq(MarketMerchantApplicationEntity::getIsDeleted, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean upgradeMerchant(Long userId, String companyName, String businessLicense, String businessLicenseUrl, String legalPerson) {
|
||||
if (Objects.isNull(userId) || StringUtil.isAnyBlank(companyName, businessLicense, businessLicenseUrl, legalPerson)) {
|
||||
throw new ServiceException("无效参数");
|
||||
}
|
||||
Integer merchantTypeCode = MarketInfoCache.checkMerchantType(userId);
|
||||
MerchantType userType = MerchantType.fromCode(merchantTypeCode);
|
||||
if (userType != MerchantType.INDIVIDUAL) {
|
||||
throw new ServiceException("您还不是个人商家");
|
||||
}
|
||||
MarketMerchantApplicationEntity application = new MarketMerchantApplicationEntity();
|
||||
MarketMerchantApplicationEntity userApplication = getByUserId(userId);
|
||||
|
||||
if (userApplication.getType() != MerchantType.ENTERPRISE.getCode()){
|
||||
application.setType(MerchantType.ENTERPRISE.getCode());
|
||||
}else {
|
||||
if (userApplication.getStatus() != MerchantAuditStatus.REJECTED.getCode()) {
|
||||
throw new ServiceException("请勿重复提交申请");
|
||||
}
|
||||
application.setId(userApplication.getId());
|
||||
application.setStatus(MerchantAuditStatus.PENDING.getCode());
|
||||
}
|
||||
application.setCompanyName(companyName);
|
||||
application.setBusinessLicense(businessLicense);
|
||||
application.setBusinessLicenseUrl(businessLicenseUrl);
|
||||
application.setLegalPerson(legalPerson);
|
||||
return saveOrUpdate(application);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,14 +246,13 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
||||
if (Objects.isNull(num) || num < 1) {
|
||||
throw new IllegalArgumentException("无效数量");
|
||||
}
|
||||
if (Objects.isNull(price) || price.compareTo(BigDecimal.ZERO) < 1 || Objects.isNull(giftAmount) || giftAmount.compareTo(BigDecimal.ZERO) < 1) {
|
||||
throw new ServiceException("无效参数");
|
||||
}
|
||||
|
||||
|
||||
MerchantCatalogEntity catalog = catalogService.getById(productId);
|
||||
if (Objects.isNull(catalog)) {
|
||||
throw new ServiceException("无效商品");
|
||||
}
|
||||
BigDecimal finalPrice = BigDecimal.ZERO;
|
||||
Integer merchantType = MarketInfoCache.checkMerchantType(userId);
|
||||
MerchantType userType = MerchantType.fromCode(merchantType);
|
||||
if (userType.getCode() == MerchantType.UNREVIEWED.getCode()) {
|
||||
@@ -268,12 +267,17 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
||||
MerchantProductType currentType = MerchantProductType.fromCode(catalog.getType());
|
||||
switch (currentType) {
|
||||
case PLATFORM -> {
|
||||
finalPrice = finalPrice.add(catalog.getSalePrice());
|
||||
BigDecimal totalAmount = catalog.getCostPrice().multiply(BigDecimal.valueOf(num));
|
||||
if (!cashCouponService.deductCashCoupon(new MarketCashCouponApiDTO(userId, totalAmount, MarketBusinessModule.MERCHANT_PURCHASING, null, "", String.format("采购商品 [%s],编号 [%d],数量 [%d]", catalog.getProductName(), catalog.getId(), num)))) {
|
||||
throw new ServiceException("扣除现金券失败");
|
||||
}
|
||||
}
|
||||
case MERCHANT -> {
|
||||
if (Objects.isNull(price) || price.compareTo(BigDecimal.ZERO) < 1 || Objects.isNull(giftAmount) || giftAmount.compareTo(BigDecimal.ZERO) < 1) {
|
||||
throw new ServiceException("无效参数");
|
||||
}
|
||||
finalPrice = finalPrice.add(price);
|
||||
if (userType.getCode() != MerchantType.ENTERPRISE.getCode()) {
|
||||
throw new ServiceException("无法添加该类型商品");
|
||||
}
|
||||
@@ -318,7 +322,7 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
||||
inventory.setGiftType(MerchantGiftType.BENEFIT_POINT.getCode());
|
||||
|
||||
}
|
||||
inventory.setUnitPrice(price);
|
||||
inventory.setUnitPrice(finalPrice);
|
||||
inventory.setUnitGiftAmount(giftAmount);
|
||||
inventory.setStock(num);
|
||||
inventory.setStatus(MerchantProductStatus.ON_SHELF.getCode());
|
||||
|
||||
Reference in New Issue
Block a user