Commit d3eaaf86 by 林冲

Merge branch 'v5.7.9' into 'master'

上线合并

See merge request !27
2 parents 9d4915ae 254d2799
Showing 62 changed files with 995 additions and 260 deletions
......@@ -12,7 +12,7 @@
<name>rpc-dj-smartcarlife-api</name>
<properties>
<deploy.scanPackage>cn.com.glsx.dj.smartcarlife.remote</deploy.scanPackage>
<smartcarlife.api.version>5.8.0-SNAPSHOT</smartcarlife.api.version>
<smartcarlife.api.version>5.7.9-SNAPSHOT</smartcarlife.api.version>
<shopamll.api.version>5.6.4-SNAPSHOT</shopamll.api.version>
</properties>
<dependencies>
......
......@@ -120,10 +120,10 @@ public class GoodsInfoDTO extends GoodsInfo {
private Boolean isScrmSyncUpdate;
@ApiModelProperty(notes = "第三方名称")
@ApiModelProperty(notes = "供应商名称(sku)")
private String thirdPartyName;
@ApiModelProperty(notes = "第三方编码")
@ApiModelProperty(notes = "供应商编码(sku)")
private String thirdPartyCode;
@ApiModelProperty(notes = "供应商名称")
......
package cn.com.glsx.dj.smartcarlife.dto;
import cn.com.glsx.dj.smartcarlife.model.MerchantGoodsStockReduceRecord;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
......@@ -9,6 +10,7 @@ import lombok.ToString;
import lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@AllArgsConstructor
......@@ -67,4 +69,8 @@ public class MerchantGoodsStockReduceRecordDTO extends MerchantGoodsStockReduceR
private String specificationData;
private String specificationTypeSequence;
@ApiModelProperty(notes = "支付时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date successDate;
}
......@@ -108,4 +108,7 @@ public class PurchaseOrderPageDTO extends PurchaseOrder {
* 采购订单商品信息列表
*/
private List<OrderGoodsDTO> purchaseOrderGoodsList;
@ApiModelProperty(notes = "供应商名称,模糊搜索")
private String thirdPartyName;
}
......@@ -206,6 +206,17 @@ public class StockFlowDTO implements Serializable {
@ApiModelProperty(notes = "下单门店-查询条件")
private String orderMerchantName;
/**
* 使用门店
*/
private String storeUsage;
/**
* 支付时间
*/
@ApiModelProperty(notes = "支付时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date successDate;
/**
* 将统一出入库类型编码(flowTypes)转换为各自的入库/出库子类型列表
......
......@@ -67,6 +67,9 @@ public class UpgradeGoodsDTO extends UpgradeGoods {
@ApiModelProperty(notes = "升级商品别名")
private String upgradeGoodsAlias;
@ApiModelProperty(notes = "产品别名(来自采购上架信息)")
private String purchaseGoodsName;
private Boolean needReview;
private Byte orderType;
......@@ -180,12 +183,19 @@ public class UpgradeGoodsDTO extends UpgradeGoods {
@ApiModelProperty(notes = "sku适用区域列表")
private List<UpgradeGoodsAreaDTO> upgradeGoodsAreaList;
@ApiModelProperty(notes = "供货商ID")
@ApiModelProperty(notes = "供应商ID(已废弃,改用providerIds多选)")
@Deprecated
private Integer providerId;
@ApiModelProperty(notes = "供货商名称")
@ApiModelProperty(notes = "供应商ID列表(多选)")
private List<Integer> providerIds;
@ApiModelProperty(notes = "供应商名称 / 分割")
private String providerName;
@ApiModelProperty(notes = "供应商名称集合")
private List<String> providerNameList;
@ApiModelProperty(notes = "基础场景编码,前端传新场景值,后端转换为历史sceneType")
private String baseSceneCode;
......
package cn.com.glsx.dj.smartcarlife.dto.goods;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import javax.persistence.Column;
import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
public class UpgradeGoodsProviderRefDTO implements Serializable {
@ApiModelProperty(notes = "升级商品ID")
private Integer upgradeGoodsId;
@ApiModelProperty("供应商名称")
private String providerName;
}
......@@ -31,4 +31,10 @@ public class MerchantPaymentChannelAccountDTO extends MerchantPaymentChannelAcco
@ApiModelProperty(notes = "提现状态((1:未签约,2:已签约))")
private Byte withdrawSignStatus;
@ApiModelProperty(notes = "在实际分账配置里的商户类型")
private Byte targetMerchantType;
@ApiModelProperty(notes = "在实际分账配置里的分配对象级别")
private Byte targetMerchantLevel;
}
......@@ -79,6 +79,9 @@ public class PurchaseGoodsInfoDTO extends PurchaseGoodsInfo {/**
@ApiModelProperty(notes = "第三方编码")
private String thirdPartyCode;
@ApiModelProperty(notes = "供应商名称")
private String thirdPartyName;
private List<Integer> notInIds;
}
......@@ -18,6 +18,21 @@ public class PurchaseOrderGoodsExportDTO implements Serializable{
private String upgradeGoodsName;
/**
* 产品别名
*/
private String purchaseGoodsName;
/**
* 供应商名称
*/
private String thirdPartyName;
/**
* 供应商编码
*/
private String thirdPartyCode;
/**
* 多规格商品规格数据(不同规格按“/”分隔)
*/
private String specificationData;
......
......@@ -7,6 +7,7 @@ import lombok.experimental.SuperBuilder;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
......@@ -37,6 +38,7 @@ public class DivisionRuleTest implements Serializable {
/**
* 商品品类组规则id
*/
@Deprecated
@Column(name = "goods_type_group_division_id")
private Integer goodsTypeGroupDivisionId;
......@@ -55,6 +57,7 @@ public class DivisionRuleTest implements Serializable {
/**
* 财务结算规则
*/
@Deprecated
@Column(name = "settle_rule_id")
private Integer settleRuleId;
......@@ -71,11 +74,29 @@ public class DivisionRuleTest implements Serializable {
private String orderCode;
/**
* 测试订单金额
*/
@Column(name = "order_money")
private BigDecimal orderMoney;
/**
* 测试进度
*/
@Column(name = "progress")
private Byte progress;
/**
* 子测试进度
*/
@Column(name = "sub_progress")
private Byte subProgress;
/**
* 分账测试状态标识(Y测试通过,N测试中未通过)
*/
@Column(name = "test_flag")
private String testFlag;
/**
* 创建人
*/
......
......@@ -47,7 +47,25 @@ public class DivisionRuleTestMerchantDivision implements Serializable {
*/
@Column(name = "merchant_name")
private String merchantName;
/**
* 分配对象类型(1:平台方;2:服务商;3:4s店)
*/
@Column(name = "target_merchant_type")
private Byte targetMerchantType;
/**
* 分配对象级别(1:门店;2:上级),默认门店
*/
@Column(name = "target_merchant_level")
private Byte targetMerchantLevel;
/**
* 分配金额
*/
@Column(name = "distribution_money")
private BigDecimal distributionMoney;
/**
* 分账金额
*/
......
......@@ -84,6 +84,12 @@ public class PurchaseGoodsInfo implements Serializable{
private Byte suitCarType;
/**
* 产品别名
*/
@Column(name = "purchase_goods_name")
private String purchaseGoodsName;
/**
* 创建人
*/
@Column(name = "created_by")
......
......@@ -108,6 +108,27 @@ public class PurchaseOrderDeliveryDetail implements Serializable{
private String upgradeGoodsName;
/**
* 产品别名
*/
@ApiModelProperty(notes = "产品别名")
@Column(name = "purchase_goods_name")
private String purchaseGoodsName;
/**
* 供应商编码
*/
@ApiModelProperty(notes = "供应商编码")
@Column(name = "third_party_code")
private String thirdPartyCode;
/**
* 供应商名称
*/
@ApiModelProperty(notes = "供应商名称")
@Column(name = "third_party_name")
private String thirdPartyName;
/**
* 发货数量
*/
@ApiModelProperty(notes = "发货数量", required = true)
......
......@@ -97,7 +97,28 @@ public class PurchaseOrderGoods implements Serializable{
private String upgradeGoodsName;
/**
* 多规格商品规格数据(不同规格按“/”分隔)
* 产品别名
*/
@ApiModelProperty(notes = "产品别名")
@Column(name = "purchase_goods_name")
private String purchaseGoodsName;
/**
* 供应商编码
*/
@ApiModelProperty(notes = "供应商编码")
@Column(name = "third_party_code")
private String thirdPartyCode;
/**
* 供应商名称
*/
@ApiModelProperty(notes = "供应商名称")
@Column(name = "third_party_name")
private String thirdPartyName;
/**
* 多规格商品规格数据(不同规格按"/"分隔)
*/
@ApiModelProperty(notes = "规格")
@Column(name = "specification_data")
......
package cn.com.glsx.dj.smartcarlife.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
@Table(name = "dj_car_life_upgrade_goods_provider_ref")
public class UpgradeGoodsProviderRef implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@ApiModelProperty(notes = "升级商品ID")
@Column(name = "upgrade_goods_id")
private Integer upgradeGoodsId;
@ApiModelProperty(notes = "供应商ID")
@Column(name = "provider_id")
private Integer providerId;
@Column(name = "created_by")
private String createdBy;
@Column(name = "created_date")
private Date createdDate;
@Column(name = "updated_by")
private String updatedBy;
@Column(name = "updated_date")
private Date updatedDate;
@Column(name = "deleted_flag")
private String deletedFlag;
}
package cn.com.glsx.dj.smartcarlife.remote;
import cn.com.glsx.dj.smartcarlife.dto.DivisionRuleTestDTO;
import cn.com.glsx.dj.smartcarlife.dto.settleDistribution.MerchantDivisionRuleProcessDTO;
import cn.com.glsx.framework.core.annotation.*;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
......@@ -33,4 +34,14 @@ public interface DivisionRuleTestRemote {
@ApiParam(name = "orderCode", notes = "测试订单号", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("分账测试信息")
RpcResponse<DivisionRuleTestDTO> getDTOByOrderCode(@NotNull String orderCode);
@ApiMethod("重新测试")
@ApiParam(name="record",notes="分账规则测试记录",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)
@ApiResponse("返回分账规则测试记录")
RpcResponse<MerchantDivisionRuleProcessDTO> retest(@NotNull DivisionRuleTestDTO record);
@ApiMethod("更新主测试进度")
@ApiParam(name="record",notes="分账规则测试记录",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)
@ApiResponse("返回更新结果")
RpcResponse<Boolean> updateMainProgress(@NotNull DivisionRuleTestDTO record);
}
......@@ -12,8 +12,8 @@ import javax.validation.constraints.NotNull;
@ApiService(value = "分账规则分组测试接口", owner = "caiym", protocol = ApiService.ProtocolEnum.dubbo, version = "1.0.0")
public interface GroupDivisionRuleTestRemote {
@ApiMethod("获取分账分组规则测试进度")
@ApiParam(name = "groupRuleId", notes = "分账分组规则id", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("分账分组规则测试进度")
RpcResponse<MerchantDivisionRuleProcessDTO> refreshGroupTestProcess(@NotNull Integer groupRuleId);
@ApiMethod("获取分账规则测试进度")
@ApiParam(name = "divisionRuleId", notes = "分账规则id", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("分账规则测试进度")
RpcResponse<MerchantDivisionRuleProcessDTO> refreshGroupTestProcess(@NotNull Integer divisionRuleId);
}
......@@ -16,7 +16,7 @@
<skipTests>true</skipTests>
<shopmall.api.version>5.6.4-SNAPSHOT</shopmall.api.version>
<stoassistant.api.version>5.6.4-SNAPSHOT</stoassistant.api.version>
<smartcarlife.api.version>5.8.0-SNAPSHOT</smartcarlife.api.version>
<smartcarlife.api.version>5.7.9-SNAPSHOT</smartcarlife.api.version>
<sale.api.version>5.8.0-SNAPSHOT</sale.api.version>
</properties>
<dependencies>
......
......@@ -13,4 +13,6 @@ public interface DivisionRuleTestMapper extends OreMapper<DivisionRuleTest> {
List<DivisionRuleTestDTO> list(DivisionRuleTest record);
DivisionRuleTestDTO getSubOrdersAndCategroyById(Integer id);
int clearOrder(DivisionRuleTest record);
}
\ No newline at end of file
......@@ -9,7 +9,6 @@ import java.util.List;
@Mapper
public interface GroupDivisionRuleTestMapper extends OreMapper<GroupDivisionRuleTest> {
int updateToMarkTested(GroupDivisionRuleTest record);
List<GroupDivisionRuleTestDTO> listGroupDivisionRuleTest(GroupDivisionRuleTestDTO dto);
......
......@@ -20,4 +20,6 @@ public interface MerchantDistributionRuleMapper extends OreMapper<MerchantDistri
List<MerchantDistributionRuleDTO> selectByRuleType2(Integer goodsTypeGroupRuleId);
int updateShopInfo(MerchantDistributionRuleDTO dto);
List<MerchantDistributionRuleDTO> listDistrictMerchant(MerchantDistributionRuleDTO dto);
}
\ No newline at end of file
package cn.com.glsx.dj.smartcarlife.mapper;
import cn.com.glsx.dj.smartcarlife.dto.goods.UpgradeGoodsProviderRefDTO;
import cn.com.glsx.dj.smartcarlife.model.UpgradeGoodsProviderRef;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper
public interface UpgradeGoodsProviderRefMapper extends OreMapper<UpgradeGoodsProviderRef> {
List<UpgradeGoodsProviderRef> findByUpgradeGoodsId(@Param("upgradeGoodsId") Integer upgradeGoodsId);
List<UpgradeGoodsProviderRef> findByUpgradeGoodsIds(@Param("upgradeGoodsIds") List<Integer> upgradeGoodsIds);
/**
* 返回 upgrade_goods_id → provider_id 列表的映射(用于填充 DTO.providerIds)
*/
List<UpgradeGoodsProviderRef> listProviderIdsByUpgradeGoodsIds(@Param("upgradeGoodsIds") List<Integer> upgradeGoodsIds);
/**
* 返回 upgrade_goods_id → "供应商A/供应商B" 的映射(用于填充 DTO.providerName)
*/
List<UpgradeGoodsProviderRefDTO> listProviderNamesByUpgradeGoodsIds(@Param("upgradeGoodsIds") List<Integer> upgradeGoodsIds);
int deleteByUpgradeGoodsId(@Param("upgradeGoodsId") Integer upgradeGoodsId);
/**
* 单个商品获取供应商名称
* @param upgradeGoodsId
* @return
*/
UpgradeGoodsProviderRefDTO findProviderNameByUpgradeGoodsId(@Param("upgradeGoodsId") Integer upgradeGoodsId);
}
package cn.com.glsx.dj.smartcarlife.remote;
import javax.validation.constraints.NotNull;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.glsx.dj.smartcarlife.dto.DivisionRuleTestDTO;
import cn.com.glsx.dj.smartcarlife.dto.settleDistribution.MerchantDivisionRuleProcessDTO;
import cn.com.glsx.dj.smartcarlife.service.merchantSettleDistribution.DivisionRuleTestService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
......@@ -54,4 +57,25 @@ public class DivisionRuleTestRemoteImpl implements DivisionRuleTestRemote {
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<MerchantDivisionRuleProcessDTO> retest(DivisionRuleTestDTO record) {
try{
return RpcResponse.success(divisionRuleTestService.retest(record));
}catch(RpcServiceException e){
logger.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Boolean> updateMainProgress(@NotNull DivisionRuleTestDTO record) {
try{
divisionRuleTestService.updateMainProgress(record);
return RpcResponse.success(true);
}catch(RpcServiceException e){
logger.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
}
......@@ -15,9 +15,9 @@ public class GroupDivisionRuleTestRemoteImpl implements GroupDivisionRuleTestRem
private GroupDivisionRuleTestService groupDivisionRuleTestService;
@Override
public RpcResponse<MerchantDivisionRuleProcessDTO> refreshGroupTestProcess(Integer groupRuleId) {
public RpcResponse<MerchantDivisionRuleProcessDTO> refreshGroupTestProcess(Integer divisionRuleId) {
try{
return RpcResponse.success(groupDivisionRuleTestService.refreshGroupTestProcess(groupRuleId, true));
return RpcResponse.success(groupDivisionRuleTestService.refreshGroupTestProcess(divisionRuleId, true));
}catch(RpcServiceException e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
......
......@@ -15,10 +15,7 @@ import cn.com.glsx.dj.smartcarlife.mapper.UpgradeGoodsMapper;
import cn.com.glsx.dj.smartcarlife.model.*;
import cn.com.glsx.dj.smartcarlife.service.common.GoodsOperationLogService;
import cn.com.glsx.dj.smartcarlife.service.common.UpdateOperationLogService;
import cn.com.glsx.dj.smartcarlife.service.goods.GoodsProviderService;
import cn.com.glsx.dj.smartcarlife.service.goods.GoodsSpecificationPermutationService;
import cn.com.glsx.dj.smartcarlife.service.goods.MerchantGoodsInfoService;
import cn.com.glsx.dj.smartcarlife.service.goods.UpgradeGoodsCarTypeConfigService;
import cn.com.glsx.dj.smartcarlife.service.goods.*;
import cn.com.glsx.dj.smartcarlife.vo.GoodsExportVO;
import cn.com.glsx.framework.core.beans.BaseModel;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
......@@ -106,6 +103,9 @@ public class BaseGoodsService {
@Autowired
private GoodsOperationLogService goodsOperationLogService;
@Autowired
private UpgradeGoodsProviderRefService upgradeGoodsProviderRefService;
public List<BaseGoodsDTO> list(BaseGoodsDTO record) {
RpcAssert.assertNotNull(record, DefaultErrorEnum.DATA_NULL, "BaseGoodsDTO not be null");
try {
......@@ -251,21 +251,40 @@ public class BaseGoodsService {
record.setSpecificationPermutationList(goodsSpecificationPermutationService.listByBaseGoodsId(baseGoodsId));
// 关联升级商品
List<UpgradeGoodsDTO> upgradeGoodsDTOList = upgradeGoodsService.listByBaseGoodsId(baseGoodsId, null);
upgradeGoodsDTOList.forEach(i -> {
i.setUpgradeGoodsServiceItemsList(upgradeGoodsServiceItemsRelationService.getByUpgradeGoodsId(i.getId()));
if (i.getId() != null) {
MerchantGoodsInfoDTO condition = MerchantGoodsInfoDTO.builder().upgradeGoodsId(i.getId())
//查询供应商
Map<Integer, List<Integer>> refsMap = new HashMap<>();
if(CollectionUtils.isNotEmpty(upgradeGoodsDTOList)){
List<Integer> upgradeGoodsIds = upgradeGoodsDTOList.stream()
.map(UpgradeGoodsDTO::getId)
.filter(Objects::nonNull)
.collect(Collectors.toList());
List<UpgradeGoodsProviderRef> providerRefs = upgradeGoodsProviderRefService.findByUpgradeGoodsIds(upgradeGoodsIds);
if(CollectionUtils.isNotEmpty(providerRefs)){
refsMap = providerRefs.stream()
.collect(Collectors.groupingBy(
UpgradeGoodsProviderRef::getUpgradeGoodsId,
Collectors.mapping(UpgradeGoodsProviderRef::getProviderId, Collectors.toList())
));
}
}
for (UpgradeGoodsDTO upgradeGoodsDTO : upgradeGoodsDTOList) {
Integer upgradeGoodsDTOId = upgradeGoodsDTO.getId();
upgradeGoodsDTO.setUpgradeGoodsServiceItemsList(upgradeGoodsServiceItemsRelationService.getByUpgradeGoodsId(upgradeGoodsDTOId));
if (upgradeGoodsDTOId != null) {
MerchantGoodsInfoDTO condition = MerchantGoodsInfoDTO.builder().upgradeGoodsId(upgradeGoodsDTOId)
.statusList(Arrays.asList(
CarLifeEnum.MerchantGoodsStatus.WAIT_AUDIT.getValue(),
CarLifeEnum.MerchantGoodsStatus.ON_SHELF.getValue(),
CarLifeEnum.MerchantGoodsStatus.DRAFT.getValue()
)).deletedFlag(BaseModel.DeletedFlagEnum.N.name()).build();
List<MerchantGoodsInfo> merchantGoodsInfos = merchantGoodsInfoService.listByCondition(condition);
i.setMerchantGoodsInfos(merchantGoodsInfos);
upgradeGoodsDTO.setMerchantGoodsInfos(merchantGoodsInfos);
i.setCarTypeConfigList(upgradeGoodsCarTypeConfigService.listByUpgradeGoodsId(i.getId()));
upgradeGoodsDTO.setCarTypeConfigList(upgradeGoodsCarTypeConfigService.listByUpgradeGoodsId(upgradeGoodsDTOId));
upgradeGoodsDTO.setProviderIds(refsMap.get(upgradeGoodsDTOId));
}
});
}
//设置sku是否已上架
setMerchantGoodsExist(upgradeGoodsDTOList);
record.setUpgradeGoodsList(upgradeGoodsDTOList);
......@@ -316,17 +335,6 @@ public class BaseGoodsService {
}
}
private void fillGoodsInfoProviderName(GoodsInfoDTO goodsInfo) {
if (goodsInfo == null || goodsInfo.getProviderId() == null) {
return;
}
GoodsProvider provider = goodsProviderService.getById(goodsInfo.getProviderId());
if (provider != null) {
goodsInfo.setProviderName(provider.getProviderName());
}
}
public GoodsMixDTO getByBaseGoodsIdPage(GoodsGetByBaseGoodsIdDTO request) {
RpcAssert.assertNotNull(request.getId(), DefaultErrorEnum.DATA_NULL, "baseGoodsId not be null");
try {
......@@ -344,7 +352,7 @@ public class BaseGoodsService {
GoodsMixDTO record = new GoodsMixDTO();
BeanUtils.copyProperties(baseGoodsInfo, record);
record.getGoodsInfo().setProviderName(baseGoodsInfo.getGoodsInfo().getProviderName());
//record.getGoodsInfo().setProviderName(baseGoodsInfo.getGoodsInfo().getProviderName());
//关联规格类型
record.setGoodsSpecificationNameList(goodsSpecificationService.listByBaseGoodsId(request.getId()));
......@@ -651,7 +659,6 @@ public class BaseGoodsService {
goodsDTO.setId(baseGoods.getId());
// 记录操作日志
BaseGoodsDTO baseGoodsDTO = thiz.getByBaseGoodsId(baseGoods.getId());
fillGoodsInfoProviderName(baseGoodsDTO.getGoodsInfo());
goodsOperationLogService.logAdd(baseGoodsDTO.getGoodsInfo(), baseGoodsDTO.getId(), baseGoodsDTO.getCommodityCode(), null, GoodsOperationLogService.GoodsType.BASE, goodsDTO.getCreatedBy());
//新增升级商品
......@@ -690,8 +697,6 @@ public class BaseGoodsService {
newBaseGoods.getGoodsInfo().setConvertedValue(goodsDTO.getBaseGoodsDTO().getGoodsInfo().getConvertedValue());
}
}
fillGoodsInfoProviderName(oldBaseGoods.getGoodsInfo());
fillGoodsInfoProviderName(newBaseGoods.getGoodsInfo());
goodsOperationLogService.logUpdate(oldBaseGoods.getGoodsInfo(), newBaseGoods.getGoodsInfo(), newBaseGoods.getId(), newBaseGoods.getCommodityCode(), null, GoodsOperationLogService.GoodsType.BASE, goodsDTO.getUpdatedBy());
List<UpgradeGoodsDTO> upgradeGoodsDTOS = goodsDTO.getGoodsSpecificationList().stream().map(i -> {
......@@ -702,7 +707,6 @@ public class BaseGoodsService {
encryptData(upgradeGoodsDTO);
return upgradeGoodsDTO;
}).collect(Collectors.toList());
log.info("BaseGoodsService.insertOrUpdate -> updateUpgradeGoods, goodsId:{}, goodsCode:{}, scrmSyncUpdate:{}, upgradeGoodsSize:{}",
goodsDTO.getId(), goodsDTO.getGoodsCode(), goodsDTO.getScrmSyncUpdate(),
CollectionUtils.isEmpty(upgradeGoodsDTOS) ? 0 : upgradeGoodsDTOS.size());
......
......@@ -4,6 +4,7 @@ import cn.com.glsx.dj.smartcarlife.constant.CommonConstants;
import cn.com.glsx.dj.smartcarlife.dto.GoodsOrderDTO;
import cn.com.glsx.dj.smartcarlife.dto.GoodsSubOrderDTO;
import cn.com.glsx.dj.smartcarlife.dto.SceneMerchantRefDTO;
import cn.com.glsx.dj.smartcarlife.dto.goods.MerchantGoodsInfoDTO;
import cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum;
import cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum.OrderOperStatus;
import cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum.OrderType;
......@@ -13,15 +14,15 @@ import cn.com.glsx.dj.smartcarlife.mapper.GoodsOrderMapper;
import cn.com.glsx.dj.smartcarlife.mapper.GoodsSubOrderMapper;
import cn.com.glsx.dj.smartcarlife.model.GoodsOrderCustomer;
import cn.com.glsx.dj.smartcarlife.model.GoodsSubOrder;
import cn.com.glsx.dj.smartcarlife.model.MerchantGoodsInfo;
import cn.com.glsx.dj.smartcarlife.model.ServiceMerchant;
import cn.com.glsx.dj.smartcarlife.response.MerchantCarBrandResponse;
import cn.com.glsx.dj.smartcarlife.service.merchantSettleDistribution.RuleTestGoodService;
import cn.com.glsx.dj.smartcarlife.service.goods.MerchantGoodsInfoService;
import cn.com.glsx.framework.core.beans.BaseModel.DeletedFlagEnum;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.oreframework.distribute.lock.annotation.GlsxDistributeLockable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -58,17 +59,14 @@ public class GoodsOrderTestService {
private MerchantCarBrandManager merchantCarBrandManager;
@Autowired
private GoodsSubOrderService goodsSubOrderService;
@Autowired(required = false)
private PayOrderService payOrderService;
@Autowired
private RuleTestGoodService ruleTestGoodService;
@Autowired
private SceneMerchantRefService sceneMerchantRefService;
@Autowired
private Environment env;
@Autowired
private GoodsOrderCustomerService goodsOrderCustomerService;
@Autowired
private MerchantGoodsInfoService merchantGoodsInfoService;
public GoodsOrderDTO getNotFinishTestOrder(Integer merchantId){
RpcAssert.assertNotNull(merchantId, DefaultErrorEnum.DATA_NULL, "merchantId must not ne null");
......@@ -97,7 +95,7 @@ public class GoodsOrderTestService {
RpcAssert.assertNotNull(record.getMerchantId(), DefaultErrorEnum.DATA_NULL, "GoodsOrderDTO.merchantId must not ne null");
RpcAssert.assertNotEmpty(record.getEmployeeName(), DefaultErrorEnum.DATA_NULL, "GoodsOrderDTO.employeeName must not ne null");
RpcAssert.assertNotNull(record.getSource(), DefaultErrorEnum.DATA_NULL, "GoodsOrderDTO.source must not ne null");
RpcAssert.assertIsTrue(record.getTestUpgradeGoodsId() != null || record.getTestGoodsType() != null || StringUtils.isNotBlank(record.getTestPackageCode()) || StringUtils.isNotBlank(record.getTestMerchantGoodsCode()), DefaultErrorEnum.DATA_NULL, "record.getTestGoodsType() or getTestUpgradeGoodsId not be null or testPackageCode not be blank");
RpcAssert.assertNotEmpty(record.getTestMerchantGoodsCode(), DefaultErrorEnum.DATA_NULL, "TestMerchantGoodsCode not be blank");
RpcAssert.assertNotEmpty(record.getUpdatedBy(), DefaultErrorEnum.DATA_NULL, "GoodsOrderDTO.updatedBy must not ne null");
RpcAssert.assertNotNull(record.getSceneType(), DefaultErrorEnum.DATA_NULL,"record.getSceneType() not be null");
RpcAssert.assertNotNull(record.getBaseSceneCode(), DefaultErrorEnum.DATA_NULL,"record.getBaseSceneCode() not be null");
......@@ -105,10 +103,11 @@ public class GoodsOrderTestService {
RpcAssert.assertNotEmpty(record.getPayOrder().getPaymentChannelId(), DefaultErrorEnum.DATA_NULL,"record.getPayOrder().getPaymentChannelId() not be empty");
RpcAssert.assertNotEmpty(record.getPayOrder().getPaymentChannelName(), DefaultErrorEnum.DATA_NULL,"record.getPayOrder().getPaymentChannelName() not be empty");
try{
List<Integer> testGoodsMerchantGoodsIds = ruleTestGoodService.getTestGoodsMerchantGoodsId(record.getTestPackageCode(), record.getTestUpgradeGoodsId(), record.getTestGoodsType(), record.getSceneType(), record.getBaseSceneCode(),record.getTestMerchantGoodsCode());
if(CollectionUtils.isEmpty(testGoodsMerchantGoodsIds)){
throw new RpcServiceException("未配置测试商品");
}
List<MerchantGoodsInfo> merchantGoodsInfoList = merchantGoodsInfoService.listByCondition(MerchantGoodsInfoDTO.builder()
.merchantGoodsCode(record.getTestMerchantGoodsCode()).build());
if (CollectionUtils.isEmpty(merchantGoodsInfoList)) {
throw new RpcServiceException(DefaultErrorEnum.DATA_INVALID, "找不到该测试上架商品,merchantGoodsCode:"+record.getTestMerchantGoodsCode());
}
SceneMerchantRefDTO yqServiceMerchantRef = sceneMerchantRefService.getYqServiceMerchantRef(record.getMerchantId(), record.getSceneType().intValue());
if(yqServiceMerchantRef == null){
throw new RpcServiceException("商户尚未绑定园区店");
......@@ -139,33 +138,20 @@ public class GoodsOrderTestService {
record.setOperStatus(OrderOperStatus.CONFIRM_UPGRADED.getValue());
record.setUpdatedDate(now);
List<GoodsSubOrderDTO> subOrderList = new ArrayList<>();
BigDecimal totalPriceBudget = new BigDecimal(env.getProperty("settledistribution.testgoods.upgradePrice", "3.5"));
BigDecimal goodsCostBudget = new BigDecimal(env.getProperty("settledistribution.testgoods.shopPrice", "1"));
BigDecimal usedTotalPrice = BigDecimal.ZERO;
BigDecimal usedGoodsCost = BigDecimal.ZERO;
int size = testGoodsMerchantGoodsIds.size();
final BigDecimal NORMAL_SUB_TOTAL_PRICE = totalPriceBudget.divide(BigDecimal.valueOf(size), 2, BigDecimal.ROUND_HALF_UP);
final BigDecimal NORMAL_SUB_GOODS_COST = goodsCostBudget.divide(BigDecimal.valueOf(size), 2, BigDecimal.ROUND_HALF_UP);
for (int i = 0; i < size; i++) {
Integer testGoodsMerchantGoodsId = testGoodsMerchantGoodsIds.get(i);
GoodsSubOrderDTO subOrder = new GoodsSubOrderDTO();
subOrder.setOrderType(OrderType.NORMAL_TEST.getValue());
subOrder.setMerchantGoodsId(testGoodsMerchantGoodsId);
if (i == size - 1) {
subOrder.setTotalPrice(totalPriceBudget.subtract(usedTotalPrice));
subOrder.setUpgradeShopPrice(goodsCostBudget.subtract(usedGoodsCost));
}else{
usedTotalPrice = usedTotalPrice.add(NORMAL_SUB_TOTAL_PRICE);
subOrder.setTotalPrice(NORMAL_SUB_TOTAL_PRICE);
usedGoodsCost = usedGoodsCost.add(NORMAL_SUB_GOODS_COST);
subOrder.setUpgradeShopPrice(NORMAL_SUB_GOODS_COST);
}
subOrder.setFinalPrice(subOrder.getTotalPrice());
subOrder.setGoodsSource(record.getGoodsSource());
subOrderList.add(subOrder);
}
MerchantGoodsInfo testMerchantGoodsInfo = merchantGoodsInfoList.get(0);
List<GoodsSubOrderDTO> subOrderList = new ArrayList<>();
GoodsSubOrderDTO subOrder = new GoodsSubOrderDTO();
subOrder.setOrderType(OrderType.NORMAL_TEST.getValue());
subOrder.setMerchantGoodsId(testMerchantGoodsInfo.getId());
subOrder.setTotalPrice(totalPriceBudget);
subOrder.setUpgradeShopPrice(goodsCostBudget);
subOrder.setFinalPrice(subOrder.getTotalPrice());
subOrder.setGoodsSource(record.getGoodsSource());
subOrderList.add(subOrder);
record.setSubOrderList(subOrderList);
BigDecimal totalPrice = goodsSubOrderService.insertList(record.getSubOrderList(), record.getOrderCode(), record.getUpdatedBy(), record.getSource(), record.getMerchantId(), record.getSelectPayType());
record.setTotalPrice(totalPrice);
......@@ -186,14 +172,6 @@ public class GoodsOrderTestService {
.orderCode(record.getOrderCode()).customerName("分账测试").createdBy(CommonConstants.DEFAULT_UPDATE_BY).updatedBy(CommonConstants.DEFAULT_UPDATE_BY).build();
record.setCustomer(goodsOrderCustomer);
goodsOrderCustomerService.insertByOrderInfo(record);
//TODO 确认分账测试订单不创建支付订单是否可以
// PayOrderDTO payOrder = new PayOrderDTO();
// payOrder.setOrderCode(record.getOrderCode());
// payOrder.setPayType(record.getSelectPayType());
// payOrder.setCreatedBy(record.getUpdatedBy());
// payOrder.setPaymentChannelId(record.getPayOrder().getPaymentChannelId());
// payOrder.setPaymentChannelName(record.getPayOrder().getPaymentChannelName());
// payOrderService.createPayOrder(payOrder);
return record;
}catch(RpcServiceException e){
throw e;
......
......@@ -323,6 +323,8 @@ public class IncrementalRuleMergeService {
}
if (source.getMultiPlatformMerchantFlag() != null) {
target.setMultiPlatformMerchantFlag(source.getMultiPlatformMerchantFlag());
target.setDjzhySubMerchantId(source.getDjzhySubMerchantId());
target.setDjzhySubMerchantName(source.getDjzhySubMerchantName());
if (CarLifeEnum.Flag.N.name().equals(source.getMultiPlatformMerchantFlag())) {
//开启多平台分账=关闭,清空字段
target.setDjzhySubMerchantId(null);
......
......@@ -23,8 +23,8 @@ import cn.com.glsx.dj.smartcarlife.manager.MailManager;
import cn.com.glsx.dj.smartcarlife.mapper.OrderDivisionMapper;
import cn.com.glsx.dj.smartcarlife.model.*;
import cn.com.glsx.dj.smartcarlife.service.merchant.YseMerchantRefBatchEffectService;
import cn.com.glsx.dj.smartcarlife.service.merchant.YseMerchantRefService;
import cn.com.glsx.dj.smartcarlife.service.merchantSettleDistribution.DivisionRuleAutoService;
import cn.com.glsx.dj.smartcarlife.service.merchantSettleDistribution.DivisionRuleTestService;
import cn.com.glsx.dj.smartcarlife.service.merchantSettleDistribution.MerchantDistributionService;
import cn.com.glsx.dj.smartcarlife.service.merchantSettleDistribution.MerchantDivisionRuleService;
import cn.com.glsx.dj.smartcarlife.service.merchantSettleDistribution.OrderExpenseCategoryCalculatedService;
......@@ -103,10 +103,6 @@ public class OrderDivisionService {
@Autowired
private WaitInputOrderService waitInputOrderService;
@Autowired
private MerchantSettleAccountRuleService merchantSettleAccountRuleService;
@Autowired
private YseMerchantRefService yseMerchantRefService;
@Autowired
private YseMerchantRefBatchEffectService yseMerchantRefBatchEffectService;
@Autowired
private DivisionRuleAutoService divisionRuleAutoService;
......@@ -120,6 +116,8 @@ public class OrderDivisionService {
private TaskExecutor taskExecutor;
@Autowired
private OnlineStatementAccountTradeDetailService onlineStatementAccountTradeDetailService;
@Autowired
private DivisionRuleTestService divisionRuleTestService;
private void setDivisionDate(OrderDivision d){
if(d == null || d.getSettleTimeType() == null || d.getSettleTime() == null){
......@@ -150,6 +148,43 @@ public class OrderDivisionService {
@GlsxDistributeLockable(name="'OrderDivisionService_' + #orderDTO.orderCode",timeoutException=RpcServiceException.class)
@Transactional(propagation=Propagation.REQUIRED,rollbackFor=RpcServiceException.class)
public OrderDivision saveTestOrderDivision(GoodsOrderDTO orderDTO){
RpcAssert.assertNotNull(orderDTO, DefaultErrorEnum.DATA_NULL,"orderDTO not be null");
log.info("OrderDivisionService saveTestOrderDivision:{}",orderDTO.getOrderCode());
RpcAssert.assertNotEmpty(orderDTO.getSubOrderList(), DefaultErrorEnum.DATA_NULL,"orderDTO.getSubOrderList() not be empty");
PayOrder payOrder = payOrderService.getByOrderCode(orderDTO.getOrderCode());
RpcAssert.assertNotNull(payOrder, DefaultErrorEnum.DATA_NULL,"orderDTO.getPayOrder() not be null");
RpcAssert.assertIsTrue(payOrder.getPayStatus() == PayStatus.PAYED.getValue(),
DefaultErrorEnum.DATA_INVALID, String.format("orderDTO.getPayOrder().getPayStatus() must be %d",PayStatus.PAYED.getValue()));
log.info("订单分账主链开始组装分账结果,orderCode={}, payOrderId={}, 支付方式={}, 子订单数={}",
orderDTO.getOrderCode(), payOrder.getId(), payOrder.getPayType(),
orderDTO.getSubOrderList() == null ? null : orderDTO.getSubOrderList().size());
log.info("-- 保存订单分账 by snapshot, orderCode:"+orderDTO.getOrderCode());
try{
OrderDivision oldDivision = thiz.getBaseByOrderCode(orderDTO.getOrderCode());
if(oldDivision != null){
if(DivisionStatus.IN_DIVISION.getValue() == oldDivision.getDivisionStatus()){
return oldDivision;
}
if(DivisionStatus.DIVISION_SUCCESS.getValue() == oldDivision.getDivisionStatus()){
return oldDivision;
}
OrderDivision orderDivision = OrderDivision.builder().id(oldDivision.getId()).deletedFlag(DeletedFlagEnum.D.name()).build();
orderDivisionMapper.updateByPrimaryKeySelective(orderDivision);
}
return thiz.saveTestOrderDivision(orderDTO, payOrder);
}catch(RpcServiceException e){
throw e;
}catch(Exception e){
log.error(e.getMessage(),e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR,e.getMessage());
}finally {
ThreadLocalUtil.removeEffectRecord();
}
}
@GlsxDistributeLockable(name="'OrderDivisionService_' + #orderDTO.orderCode",timeoutException=RpcServiceException.class)
@Transactional(propagation=Propagation.REQUIRED,rollbackFor=RpcServiceException.class)
public OrderDivision saveOrderDivision(GoodsOrderDTO orderDTO){
log.info("OrderDivisionService saveOrderDivision");
RpcAssert.assertNotNull(orderDTO, DefaultErrorEnum.DATA_NULL,"orderDTO not be null");
......@@ -321,6 +356,62 @@ public class OrderDivisionService {
@GlsxDistributeLockable(name="'OrderDivisionService_' + #orderDTO.orderCode",timeoutException=RpcServiceException.class)
@Transactional(propagation= Propagation.REQUIRED,rollbackFor=RpcServiceException.class)
public OrderDivision saveTestOrderDivision(GoodsOrderDTO orderDTO, PayOrder payOrder) {
try{
RpcAssert.assertNotNull(orderDTO, DefaultErrorEnum.DATA_NULL, "orderDTO not be null");
DivisionRuleTestDTO divisionRuleTest = divisionRuleTestService.getDTOByOrderCode(orderDTO.getOrderCode());
RpcAssert.assertNotNull(divisionRuleTest, DefaultErrorEnum.DATA_NULL, "divisionRuleTest not be null");
RpcAssert.assertNotNull(divisionRuleTest.getTestMerchantDivisions(), DefaultErrorEnum.DATA_NULL, "testMerchantDivisions not be null");
MerchantDivisionRuleDTO divisionRule = merchantDivisionRuleService.getById(divisionRuleTest.getDivisionRuleId());
RpcAssert.assertNotNull(divisionRule, DefaultErrorEnum.DATA_NULL, "divisionRule not be null");
OrderDivision orderDivision = thiz.initOrderDivision(divisionRule, orderDTO, payOrder);
List<MerchantDistribution> merchantDistributions = merchantDistributionService.saveTestOrderMerchantDistributions(orderDivision,divisionRuleTest.getTestMerchantDivisions());
thiz.compileOrderDivision(orderDivision, merchantDistributions);
//异常分账
if(thiz.isOrderException(orderDivision, null, merchantDistributions)){
thiz.dealExceptionOrderDivision(orderDTO, orderDivision, merchantDistributions);
}
// 已存在分账记录则修改分账方式为线下分账,且不发起分账
OrderDivisionDTO tradeNoExistDivision = getDetailByTradeNo(payOrder.getTradeNo());
if (tradeNoExistDivision != null) {
orderDivision.setDivisionType(DivisionType.OFFLINE.getValue());
}
thiz.save2DB(orderDivision);
final Boolean isOnlinePay = StringUtils.isNotBlank(payOrder.getPaymentChannelId())
&& CollectionUtils.isNotEmpty(paymentChannelService.listPaymentChannel(
PaymentChannel.builder().paymentChannelId(payOrder.getPaymentChannelId()).build()));
if(tradeNoExistDivision == null
&& isOnlinePay
&& (DivisionType.OFFLINE.getValue() == orderDivision.getDivisionType()
|| (orderDivision.getSettleTimeType() != null
&& orderDivision.getSettleTimeType() == SettleTimeType.INTERVAL.getValue()
&& orderDivision.getSettleTime() != null
&& orderDivision.getSettleTime() == 0))){
// 事务提交后执行
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
try {
log.info("特殊订单线下对账分账事务提交完成,开始发起分账请求,orderCode={}, payOrderId={}", orderDTO.getOrderCode(), payOrder.getId());
// 银盛线下收款或立即分账则发起分账
thiz.divisionRequest(orderDivision.getPayOrderId(),false);
log.info("特殊订单线下对账分账事务提交后分账请求完成,orderCode={}, payOrderId={}", orderDTO.getOrderCode(), payOrder.getId());
} catch (Exception e) {
log.error("divisionRequest error:{}", e);
}
}
});
}
return orderDivision;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
@GlsxDistributeLockable(name="'OrderDivisionService_' + #orderDTO.orderCode",timeoutException=RpcServiceException.class)
@Transactional(propagation= Propagation.REQUIRED,rollbackFor=RpcServiceException.class)
public OrderDivision saveOrderDivision(GoodsOrderDTO orderDTO, PayOrder payOrder, MerchantSettleAccountRuleDTO accountRule,
MerchantDivisionRuleDTO divisionRule, List<OrderExpenseCategoryCalculatedDTO> profitExpenseCategoryCalculateds) {
try{
......@@ -652,7 +743,7 @@ public class OrderDivisionService {
orderDivision.setFeeMerchantId(orderDivision.getRealityPlatformMerchantId());
orderDivision.setDivisionType(DivisionType.OFFLINE.getValue());
final String paymentChannelId = orderDivision.getPaymentChannelId();
final Boolean isOnlinePay = StringUtils.isNotBlank(paymentChannelId);
final boolean isOnlinePay = StringUtils.isNotBlank(paymentChannelId);
if(isOnlinePay){
orderDivision.setDivisionStatus(DivisionStatus.WAITING.getValue());
}
......
......@@ -10,6 +10,7 @@ import cn.com.glsx.dj.smartcarlife.dto.MerchantReconciliationRuleDTO;
import cn.com.glsx.dj.smartcarlife.dto.MerchantSettleAccountRuleDTO;
import cn.com.glsx.dj.smartcarlife.dto.merchantEffectRule.MerchantRuleEffectRecordDTO;
import cn.com.glsx.dj.smartcarlife.enums.*;
import cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum.OrderType;
import cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum.ReportType;
import cn.com.glsx.dj.smartcarlife.enums.vd.PayeeEnum;
import cn.com.glsx.dj.smartcarlife.model.*;
......@@ -238,6 +239,11 @@ public class OrderTotalReportService {
return;
}
thiz.checkForHandleOrderUpgrade(goodsOrderDTO);
if(Objects.equals(OrderType.NORMAL_TEST.getValue(), goodsOrderDTO.getOrderType()) ||
Objects.equals(OrderType.ABNORMAL_TEST.getValue(), goodsOrderDTO.getOrderType())) {
orderDivisionService.saveTestOrderDivision(goodsOrderDTO);
return;
}
log.info("订单升级后基础校验通过,准备进入财务/分账/对账主链,orderCode={}, 子订单数={}, 是否重算={}",
orderCode, goodsOrderDTO.getSubOrderList() == null ? null : goodsOrderDTO.getSubOrderList().size(), reCal);
boolean offlinePlatformOrder = isOfflinePlatformOrder(goodsOrderDTO);
......
......@@ -126,6 +126,9 @@ public class PurchaseOrderDeliveryDetailService {
detailDTO.setType(orderGoods.getType());
detailDTO.setUpgradeGoodsName(orderGoods.getUpgradeGoodsName());
detailDTO.setDeliveryRemark(orderGoods.getDeliveryRemark());
detailDTO.setPurchaseGoodsName(orderGoods.getPurchaseGoodsName());
detailDTO.setThirdPartyCode(orderGoods.getThirdPartyCode());
detailDTO.setThirdPartyName(orderGoods.getThirdPartyName());
BigDecimal conversionValue = orderGoods.getConversionValue();
final List<Integer> FILM_COUPON_TYPES = JSONArray.parseArray(Optional.ofNullable(env.getProperty("dj.goods.filmCouponTypes")).orElse(CommonConstants.DEFAULT_FILM_GOOD_TYPES), Integer.class);
......
......@@ -702,8 +702,10 @@ public class PurchaseOrderService {
dto.setContactName(order.getContactName());
dto.setContactPhone(order.getContactPhone());
if (Objects.nonNull(order.getProvinceName())){
dto.setContactAddress(order.getProvinceName().concat(order.getCityName())
.concat(order.getAreaName()).concat(order.getContactAddress()));
dto.setContactAddress(StringUtils.defaultString(order.getProvinceName())
.concat(StringUtils.defaultString(order.getCityName()))
.concat(StringUtils.defaultString(order.getAreaName()))
.concat(StringUtils.defaultString(order.getContactAddress())));
}else {
dto.setContactAddress(order.getContactAddress());
}
......@@ -774,6 +776,9 @@ public class PurchaseOrderService {
exportDTO.setInventoryTotal(goods.getGoodsNumber()+"件");
exportDTO.setPurchaseNumberStr(goods.getPurchaseNumber()+"件");
exportDTO.setInputNumberStr(goods.getInputNumber()+"件");
exportDTO.setPurchaseGoodsName(goods.getPurchaseGoodsName());
exportDTO.setThirdPartyName(goods.getThirdPartyName());
exportDTO.setThirdPartyCode(goods.getThirdPartyCode());
if (list.contains(goods.getGoodsType()) && Objects.nonNull(goods.getConversionValue())) {
exportDTO.setGoodsNumberStr(goods.getGoodsNumber()+"卷");
exportDTO.setInventoryTotal(goods.getConversionValue().multiply(BigDecimal.valueOf(goods.getGoodsNumber()))+"米");
......@@ -885,6 +890,8 @@ public class PurchaseOrderService {
//自采入库价格在页面手动输入 不需要用升级商品的采购价
// orderGoods.setUpgradePurchasePrice(upgradeGoods.getPurchasePrice());
orderGoods.setType(upgradeGoods.getType());
orderGoods.setThirdPartyCode(upgradeGoods.getThirdPartyCode());
orderGoods.setThirdPartyName(upgradeGoods.getThirdPartyName());
//自建商品暂时没有部位和对应的扣减值
// orderGoods.setUpgradeGoodsPosition(upgradeGoods.getPosition());
// orderGoods.setPositionDeductionValue(upgradeGoods.getDeductionStandard());
......@@ -1171,8 +1178,10 @@ public class PurchaseOrderService {
dto.setContactName(order.getContactName());
dto.setContactPhone(order.getContactPhone());
if (Objects.nonNull(order.getProvinceName())){
dto.setContactAddress(order.getProvinceName().concat(order.getCityName())
.concat(order.getAreaName()).concat(order.getContactAddress()));
dto.setContactAddress(StringUtils.defaultString(order.getProvinceName())
.concat(StringUtils.defaultString(order.getCityName()))
.concat(StringUtils.defaultString(order.getAreaName()))
.concat(StringUtils.defaultString(order.getContactAddress())));
}else {
dto.setContactAddress(order.getContactAddress());
}
......
......@@ -353,6 +353,9 @@ public class PurchaseShoppingCarService {
orderGoods.setSpecificationData(UpgradeGoodsService.getFormatSpecificationData(upgradeGoods.getSpecificationData(), "/"));
}
orderGoods.setType(upgradeGoods.getType());
orderGoods.setPurchaseGoodsName(upgradeGoods.getPurchaseGoodsName());
orderGoods.setThirdPartyCode(upgradeGoods.getThirdPartyCode());
orderGoods.setThirdPartyName(upgradeGoods.getThirdPartyName());
}
@GlsxDistributeLockable(name="'PurchaseShoppingCarService_' + #record.merchantId",timeoutException=RpcServiceException.class)
......
......@@ -14,17 +14,14 @@ import cn.com.glsx.dj.smartcarlife.mapper.MerchantGoodsAreaMapper;
import cn.com.glsx.dj.smartcarlife.mapper.MerchantPackageAreaMapper;
import cn.com.glsx.dj.smartcarlife.mapper.UpgradeGoodsAreaMapper;
import cn.com.glsx.dj.smartcarlife.mapper.UpgradeGoodsMapper;
import cn.com.glsx.dj.smartcarlife.mapper.UpgradeGoodsProviderRefMapper;
import cn.com.glsx.dj.smartcarlife.model.*;
import cn.com.glsx.dj.smartcarlife.model.UpgradeGoodsArea;
import cn.com.glsx.dj.smartcarlife.dto.ProductNoticeEvent;
import cn.com.glsx.dj.smartcarlife.dto.ProductNoticeDTO;
import cn.com.glsx.dj.smartcarlife.service.common.GoodsOperationLogService;
import cn.com.glsx.dj.smartcarlife.service.common.UpdateOperationLogService;
import cn.com.glsx.dj.smartcarlife.service.goods.GoodsProviderService;
import cn.com.glsx.dj.smartcarlife.service.goods.MerchantGoodsInfoService;
import cn.com.glsx.dj.smartcarlife.service.goods.MerchantGoodsRefService;
import cn.com.glsx.dj.smartcarlife.service.goods.MerchantPackageGoodsInfoService;
import cn.com.glsx.dj.smartcarlife.service.goods.UpgradeGoodsCarTypeConfigService;
import cn.com.glsx.dj.smartcarlife.service.goods.*;
import cn.com.glsx.dj.smartcarlife.strategy.GoodsReviewUpdateBaseGoodsStatus;
import cn.com.glsx.dj.smartcarlife.util.CommonUtil;
import cn.com.glsx.dj.smartcarlife.vo.GoodsExportVO;
......@@ -118,24 +115,26 @@ public class UpgradeGoodsService {
@Autowired
private MerchantPackageGoodsInfoService merchantPackageGoodsInfoService;
@Autowired
private UpgradeGoodsProviderRefService upgradeGoodsProviderRefService;
// ===================== 通知辅助方法 =====================
/**
* 查询供应商名称:goodsCode -> GoodsInfo.providerId -> GoodsProvider.providerName
* 查询供应商名称:SKU升级商品ID -> 关系表 -> GoodsProvider.providerName
*/
private String buildSupplierName(String goodsCode) {
private String buildSupplierName(Integer upgradeGoodsId) {
try {
if (StringUtils.isBlank(goodsCode)) {
if (upgradeGoodsId == null) {
return null;
}
GoodsInfo goodsInfo = goodsInfoService.getByGoodsCode(goodsCode);
if (goodsInfo == null || goodsInfo.getProviderId() == null) {
UpgradeGoodsProviderRefDTO ref = upgradeGoodsProviderRefService.findProviderNameByUpgradeGoodsId(upgradeGoodsId);
if (Objects.isNull(ref)) {
return null;
}
GoodsProvider provider = goodsProviderService.getById(goodsInfo.getProviderId());
return provider != null ? provider.getProviderName() : null;
return ref.getProviderName();
} catch (Exception e) {
log.warn("查询供应商名称失败 goodsCode={}", goodsCode, e);
log.warn("查询供应商名称失败 upgradeGoodsId={}", upgradeGoodsId, e);
return null;
}
}
......@@ -155,7 +154,7 @@ public class UpgradeGoodsService {
.productCode(event.getType())
.productName(event.getUpgradeGoodsName())
.skuInfo(event.getCommodityCode())
.supplierName(buildSupplierName(event.getGoodsCode()))
.supplierName(buildSupplierName(event.getUpgradeGoodsId()))
.operatingCost(event.getOperatingCost())
.oldOperatingCost(event.getOldOperatingCost())
.newOperatingCost(event.getNewOperatingCost())
......@@ -770,7 +769,7 @@ public class UpgradeGoodsService {
}
//一码一名校验
if (StringUtils.isNotBlank(upgradeGoods.getUpgradeGoodsName()) && StringUtils.isNotBlank(dto.getType())) {
if (StringUtils.isNotBlank(upgradeGoods.getUpgradeGoodsName()) && StringUtils.isNotBlank(upgradeGoods.getType())) {
productTemplateService.checkUpgradeGoodsUnique(upgradeGoods.getUpgradeGoodsName(), upgradeGoods.getType(), upgradeGoods.getId(), upgradeGoods.getCreatedDate());
}
......@@ -791,12 +790,14 @@ public class UpgradeGoodsService {
// ---------- 插入适用区域 ----------
List<UpgradeGoodsArea> areaList = saveAreaSimple(upgradeGoods.getId(), dto.getUpgradeGoodsAreaList(), createBy, true);
// ---------- 保存供应商关系 ----------
upgradeGoodsProviderRefService.saveProviderRefs(upgradeGoods.getId(), dto.getProviderIds(), createBy,true);
// ---------- 收集通知事件(仅 D+ 来源且上架时) ----------
if (!scrmSyncUpdate && Objects.equals(upgradeGoods.getOnShelfStatus(), ProductStatusEnum.ON_SHELF.getCode())) {
events.add(buildListedEvent(upgradeGoods, areaList, createBy));
}
fillUpgradeGoodsProviderName(dto);
// 记录操作日志
goodsOperationLogService.logAdd(dto, upgradeGoods.getBaseGoodsId(), upgradeGoods.getCommodityCode(), upgradeGoods.getType(), GoodsOperationLogService.GoodsType.UPGRADE, createBy);
if (CollectionUtils.isNotEmpty(dto.getUpgradeGoodsServiceItemsList())){
......@@ -822,7 +823,25 @@ public class UpgradeGoodsService {
}
return events;
}
/**
* 填充sku供应商名称
* @param upgradeGoodsDTO
*/
private void fillUpgradeGoodsProviderName( UpgradeGoodsDTO upgradeGoodsDTO) {
if (Objects.isNull(upgradeGoodsDTO) || CollectionUtils.isEmpty(upgradeGoodsDTO.getProviderIds())) {
return;
}
List<GoodsProvider> providers = goodsProviderService.listByIds(upgradeGoodsDTO.getProviderIds());
if(CollectionUtils.isNotEmpty(providers)){
upgradeGoodsDTO.setProviderName(providers.stream()
.map(GoodsProvider::getProviderName)
.filter(StringUtils::isNotBlank) // 过滤空白字符串
.collect(Collectors.joining("/")));
}
}
@GlsxDistributeLockable(name="'UpgradeGoodsService_' + #baseGoodsId",timeoutException=RpcServiceException.class)
@Transactional(propagation=Propagation.REQUIRED, rollbackFor=RpcServiceException.class)
public void updateUpgradeGoods(List<UpgradeGoodsDTO> toLinkGoodsList,GoodsNewDTO goodsDTO){
......@@ -997,6 +1016,8 @@ public class UpgradeGoodsService {
/*}*/
// productTemplateId 不为空,说明之前已保存过关联关系,不重复处理
upgradeGoodsMapper.updateByPrimaryKeySelective(item);
// ---------- 更新供应商关系 ----------
upgradeGoodsProviderRefService.saveProviderRefs(item.getId(), item.getProviderIds(), updateBy,false);
// 记录操作日志
if (CollectionUtils.isNotEmpty(oldUpgradeGoodsList) && oldUpgradeGoodsList.stream().map(UpgradeGoodsDTO::getId).collect(Collectors.toList()).contains(item.getId())) {
UpgradeGoodsDTO upgradeGoodsDTO =
......@@ -1005,6 +1026,9 @@ public class UpgradeGoodsService {
if (item.getAttribute() == null) {
item.setAttribute(upgradeGoodsDTO.getAttribute());
}
//填充供应商名称
fillUpgradeGoodsProviderName(upgradeGoodsDTO);
fillUpgradeGoodsProviderName(item);
goodsOperationLogService.logUpdate(upgradeGoodsDTO, item, item.getBaseGoodsId(), item.getCommodityCode(), item.getType(), GoodsOperationLogService.GoodsType.UPGRADE, updateBy);
}
......@@ -1163,6 +1187,8 @@ public class UpgradeGoodsService {
upgradeGoodsServiceItemsRelationService.deleteByUpgradeGoodsId(id,updateBy);
//删除关联适用区域
upgradeGoodsAreaService.deleteByUpgradeGoodsId(id, updateBy);
//删除供应商关系
upgradeGoodsProviderRefService.deleteByUpgradeGoodsId(id);
}catch (RpcServiceException rpcServiceException){
throw rpcServiceException;
}catch (Exception e) {
......@@ -1353,6 +1379,8 @@ public class UpgradeGoodsService {
upgradeGoodsMapper.insertSelective(upgradeGoodsDTO);
// 保存适用区域
saveAreaSimple(upgradeGoodsDTO.getId(), upgradeGoodsDTO.getUpgradeGoodsAreaList(), oprBy, true);
// 保存供应商关系
upgradeGoodsProviderRefService.saveProviderRefs(upgradeGoodsDTO.getId(), upgradeGoodsDTO.getProviderIds(), oprBy,true);
if (CollectionUtils.isNotEmpty(upgradeGoodsDTO.getUpgradeGoodsServiceItemsList())){
upgradeGoodsDTO.getUpgradeGoodsServiceItemsList().forEach(i->{
i.setUpgradeGoodsId(upgradeGoodsDTO.getId());
......@@ -1435,6 +1463,8 @@ public class UpgradeGoodsService {
upgradeGoodsCarTypeConfigService.updateBatch(upgradeGoodsDTO.getId(), upgradeGoodsDTO.getCarTypeConfigList(), upgradeGoodsDTO.getUpdatedBy());
// 保存适用区域(先删后插)
saveAreaSimple(upgradeGoodsDTO.getId(), upgradeGoodsDTO.getUpgradeGoodsAreaList(), upgradeGoodsDTO.getUpdatedBy(), false);
// // 保存供应商关系
upgradeGoodsProviderRefService.saveProviderRefs(upgradeGoodsDTO.getId(), upgradeGoodsDTO.getProviderIds(), upgradeGoodsDTO.getUpdatedBy(),false);
}
......
......@@ -291,7 +291,7 @@ public class GoodsOperationLogService {
private String normalizeForLog(String fieldName, Object val) {
if (val == null) return "";
if (val instanceof Collection) {
List<Map<String, Object>> normalized = new ArrayList<>();
List<Object> normalized = new ArrayList<>();
for (Object item : (Collection<?>) val) {
if (item == null) {
normalized.add(Collections.emptyMap());
......@@ -302,6 +302,8 @@ public class GoodsOperationLogService {
} else {
if ("goodsPositionList".equals(fieldName)) {
normalized.add(stripGoodsPositionFields(item));
} else if ("upgradeGoodsAreaList".equals(fieldName)) {
normalized.add(stripUpgradeGoodsAreaFields(item));
} else {
normalized.add(stripSystemFields(item));
}
......@@ -338,6 +340,34 @@ public class GoodsOperationLogService {
return result;
}
/**
* 适用区域专用剥离:仅保留 cityName 和 provinceName 的值
*/
private List<String> stripUpgradeGoodsAreaFields(Object obj) {
List<String> areaValues = new ArrayList<>();
try {
Field provinceNameField = findField(obj.getClass(), "provinceName");
if (provinceNameField != null) {
provinceNameField.setAccessible(true);
Object pName = provinceNameField.get(obj);
if (pName != null) {
areaValues.add(String.valueOf(pName));
}
}
Field cityNameField = findField(obj.getClass(), "cityName");
if (cityNameField != null) {
cityNameField.setAccessible(true);
Object cName = cityNameField.get(obj);
if (cName != null) {
areaValues.add(String.valueOf(cName));
}
}
} catch (Exception e) {
log.error("解析适用区域字段失败", e);
}
return areaValues;
}
private Field findField(Class<?> clazz, String fieldName) {
while (clazz != null && clazz != Object.class) {
try {
......
......@@ -28,7 +28,7 @@ public enum GoodsTrackedFieldEnum {
THIRD_LEVEL_GOODS_TYPE_NAME("thirdLevelGoodsTypeName", "商品分类名(三级)"),
BRAND_MERCHANT_CODE("brandMerchantCode", "品牌商编号"),
BRAND_MERCHANT_NAME("brandMerchantName", "品牌商名称"),
PROVIDER_NAME("providerName", "供应商"),
//PROVIDER_NAME("providerName", "供应商"),
// GOODS_CODE("goodsCode", "产品编号"),
// SAP_CODE("sapCode", "SAP编号"),
// THUMB_URL("thumbUrl", "商品缩略图"),
......@@ -65,6 +65,7 @@ public enum GoodsTrackedFieldEnum {
SUPPLY_SOURCE("supplySource", "供应来源(1-原厂、2-集采、3-店采)"),
REMARK("remark", "备注"),
UPGRADE_GOODS_AREA_LIST("upgradeGoodsAreaList", "适用区域"),
PROVIDER_NAME("providerName", "供应商"),
;
private final String fieldName;
......
......@@ -119,6 +119,8 @@ public class MerchantGoodsInfoService {
private CreateBusinessProductService createBusinessProductService;
@Autowired
private MerchantGoodsInventoryTypeRefService merchantGoodsInventoryTypeRefService;
@Autowired
private UpgradeGoodsProviderRefService upgradeGoodsProviderRefService;
public String createMerchantGoodsCode(){
return "MG" + DateUtils.formatDate(new Date(), "yyyyMMddHHmmss") + RandomUtils.nextInt(10000, 100000);
......@@ -1560,20 +1562,21 @@ public class MerchantGoodsInfoService {
log.warn("calculateOperationCost no sku, request={}", request);
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "当前产品未查询到可计算运营成本的SKU");
}
Set<Integer> providerIds = skuList.stream().map(UpgradeGoodsDTO::getProviderId).filter(Objects::nonNull).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(providerIds)) {
//查询sku的供应商
List<UpgradeGoodsProviderRef> providerRefs = upgradeGoodsProviderRefService.findByUpgradeGoodsIds(matchedUpgradeGoodsIds);
if (CollectionUtils.isEmpty(providerRefs)) {
log.warn("calculateOperationCost no provider, commodityCode={}", request.getCommodityCode());
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "当前产品未配置供货商,无法计算运营成本");
}
log.info("calculateOperationCost providerIds={}, sku={}",
providerIds, skuList.stream().collect(Collectors.toMap(UpgradeGoods::getId, UpgradeGoods::getOperationCost, (p1, p2) -> p2)));
providerRefs.stream().map(UpgradeGoodsProviderRef::getProviderId).collect(Collectors.toList()), skuList.stream().collect(Collectors.toMap(UpgradeGoods::getId, UpgradeGoods::getOperationCost, (p1, p2) -> p2)));
BigDecimal totalCost = skuList.stream()
.map(UpgradeGoodsDTO::getOperationCost)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal avgCost = totalCost.divide(BigDecimal.valueOf(providerIds.size()), 2, RoundingMode.HALF_UP);
BigDecimal avgCost = totalCost.divide(BigDecimal.valueOf(providerRefs.size()), 2, RoundingMode.HALF_UP);
response.setOperationCost(avgCost);
response.setProviderCount(providerIds.size());
response.setProviderCount(providerRefs.size());
response.setSkuCount(skuList.size());
return response;
} catch (RpcServiceException e) {
......
......@@ -82,6 +82,9 @@ public class ProductManagerService {
@Autowired
private GoodsProviderService goodsProviderService;
@Autowired
private UpgradeGoodsProviderRefService upgradeGoodsProviderRefService;
public void checkAddOrUpdateProduct(ProductManagerAddOrUpdateDTO record) {
Integer goodsType = record.getGoodsInfo().getGoodsType();
List<Integer> extendedInsuranceTypeIdList = CommonUtil.convert2Integer(env.getProperty("smartcarlife.goodsType.extendedInsurance", "155").split(","));//延保类
......@@ -131,7 +134,9 @@ public class ProductManagerService {
//保存素材
GoodsInfoDTO goodsInfoDTO = record.getGoodsInfo();
goodsInfoDTO.setGoodsSource(GoodsSource.DJ.getValue());
goodsInfoService.addGoods(goodsInfoDTO);
//供应商已迁移至sku
goodsInfoDTO.setProviderId(null);
goodsInfoService.addGoods(goodsInfoDTO);
//保存基础、升级商品信息
record.getUpgradeGoods().setGoodsCode(goodsInfoDTO.getGoodsCode());
record.getUpgradeGoods().setUpdatedBy(record.getUpgradeGoods().getCreatedBy());
......@@ -167,8 +172,9 @@ public class ProductManagerService {
//保存素材
GoodsInfoDTO goodsInfoDTO = record.getGoodsInfo();
// 捕获更新前的旧状态,以便记录包含 SPU 和 Material 信息的完整日志
BaseGoodsDTO oldBaseGoods = baseGoodsService.getByBaseGoodsId(record.getUpgradeGoods().getId());
goodsInfoService.updateGoods(goodsInfoDTO);
BaseGoodsDTO oldBaseGoods = baseGoodsService.getByBaseGoodsId(record.getUpgradeGoods().getId());
goodsInfoDTO.setProviderId(null);
goodsInfoService.updateGoods(goodsInfoDTO);
//保存基础、升级商品信息
record.getUpgradeGoods().setGoodsCode(goodsInfoDTO.getGoodsCode());
record.getUpgradeGoods().setUpdatedBy(record.getUpgradeGoods().getCreatedBy());
......@@ -322,27 +328,29 @@ public class ProductManagerService {
* @param records
*/
private void fillProviderName(List<BaseGoodsDTO> records) {
List<Integer> providerIds = records.stream()
List<Integer> upgradeGoodsIds = records.stream()
.filter(Objects::nonNull)
.map(BaseGoodsDTO::getGoodsInfo)
.map(BaseGoodsDTO::getUpgradeGoodsList)
.filter(CollectionUtils::isNotEmpty)
.flatMap(List::stream)
.filter(Objects::nonNull)
.map(GoodsInfoDTO::getProviderId)
.map(UpgradeGoodsDTO::getId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(providerIds)) {
List<GoodsProvider> providers = goodsProviderService.listByIds(providerIds);
if (CollUtil.isNotEmpty(providers)) {
Map<Integer, String> providerNameMap = new HashMap<>();
for (GoodsProvider provider : providers) {
if (provider != null && provider.getId() != null) {
providerNameMap.put(provider.getId(), provider.getProviderName());
}
}
if(CollectionUtils.isEmpty(upgradeGoodsIds)){
return;
}
if (CollUtil.isNotEmpty(upgradeGoodsIds)) {
List<UpgradeGoodsProviderRefDTO> upgradeGoodsProviderRefDTOS = upgradeGoodsProviderRefService.listProviderNamesByUpgradeGoodsIds(upgradeGoodsIds);
if(CollectionUtils.isNotEmpty(upgradeGoodsProviderRefDTOS)){
Map<Integer, String> goodsProviderMap = upgradeGoodsProviderRefDTOS.stream()
.collect(Collectors.toMap(UpgradeGoodsProviderRefDTO::getUpgradeGoodsId, UpgradeGoodsProviderRefDTO::getProviderName));
for (BaseGoodsDTO record : records) {
if (record.getGoodsInfo() != null && record.getGoodsInfo().getProviderId() != null
&& providerNameMap.containsKey(record.getGoodsInfo().getProviderId())) {
record.getGoodsInfo().setProviderName(providerNameMap.get(record.getGoodsInfo().getProviderId()));
if(CollectionUtils.isNotEmpty(record.getUpgradeGoodsList())){
record.getUpgradeGoodsList().forEach(dto ->{
dto.setProviderName(goodsProviderMap.get(dto.getId()));
});
}
}
}
......@@ -381,15 +389,9 @@ public class ProductManagerService {
Page<BaseGoodsDTO> baseGoodsDTOS = baseGoodsService.spuPage(pagination);
List<BaseGoodsDTO> records = baseGoodsDTOS.getResult();
if (CollUtil.isNotEmpty(records)) {
//查询产品供应商信息
Map<Integer, String> providerNameMap = getIntegerStringMap(records);
//构建buildUpgradeGoodsList
Map<String, List<UpgradeGoodsDTO>> upgradeGoodsDTOSMap = buildUpgradeGoodsList(pagination, records);
for (BaseGoodsDTO record : records) {
if (MapUtil.isNotEmpty(providerNameMap) && providerNameMap.containsKey(record.getGoodsInfo().getProviderId())) {
record.getGoodsInfo().setProviderName(providerNameMap.get(record.getGoodsInfo().getProviderId()));
}
if (MapUtil.isNotEmpty(upgradeGoodsDTOSMap) && upgradeGoodsDTOSMap.containsKey(record.getGoodsCode())) {
record.setUpgradeGoodsList(upgradeGoodsDTOSMap.get(record.getGoodsCode()));
}
......@@ -471,24 +473,7 @@ public class ProductManagerService {
Map<Integer, List<UpgradeGoodsAreaDTO>> areaMap =
areaList.stream().collect(Collectors.groupingBy(UpgradeGoodsArea::getUpgradeGoodsId));
// 批量查询供应商名称
List<Integer> providerIds = records.stream()
.map(GoodsSkuDTO::getProviderId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
Map<Integer, String> providerNameMap = new java.util.HashMap<>();
if (CollUtil.isNotEmpty(providerIds)) {
List<GoodsProvider> providers = goodsProviderService.listByIds(providerIds);
if (CollUtil.isNotEmpty(providers)) {
providerNameMap = providers.stream().collect(Collectors.toMap(GoodsProvider::getId, GoodsProvider::getProviderName));
}
}
for (GoodsSkuDTO record : records) {
if (record.getProviderId() != null && MapUtil.isNotEmpty(providerNameMap) && providerNameMap.containsKey(record.getProviderId())) {
record.setProviderName(providerNameMap.get(record.getProviderId()));
}
if (record.getUpgradeGoodsId() != null && MapUtil.isNotEmpty(carTypeMap) && carTypeMap.containsKey(record.getUpgradeGoodsId())) {
record.setCarTypeConfigList(carTypeMap.get(record.getUpgradeGoodsId()));
}
......@@ -615,7 +600,8 @@ public class ProductManagerService {
goodsInfoDTO.setSupplierName("广联直营");
goodsInfoDTO.setThumbUrl(env.getProperty("partner.goods.default.img"));
goodsInfoDTO.setGoodsSource(GoodsSource.DJ.getValue());
goodsInfoDTO.setProviderId(null);
goods.setShoppingMallFlag((byte)0);
}
goodsInfoDTO.setGoodsName(scrmRecord.getGoodsName());
......
package cn.com.glsx.dj.smartcarlife.service.goods;
import cn.com.glsx.dj.smartcarlife.dto.goods.UpgradeGoodsProviderRefDTO;
import cn.com.glsx.dj.smartcarlife.mapper.UpgradeGoodsProviderRefMapper;
import cn.com.glsx.dj.smartcarlife.model.UpgradeGoodsProviderRef;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class UpgradeGoodsProviderRefService {
@Autowired
private UpgradeGoodsProviderRefMapper upgradeGoodsProviderRefMapper;
public void deleteByUpgradeGoodsId(Integer upgradeGoodsId) {
if(Objects.isNull(upgradeGoodsId)){
return;
}
upgradeGoodsProviderRefMapper.deleteByUpgradeGoodsId(upgradeGoodsId);
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public void saveProviderRefs(Integer upgradeGoodsId, List<Integer> providerIds, String operator,boolean isNew) {
RpcAssert.assertNotEmpty(providerIds, DefaultErrorEnum.DATA_NULL, "providerIds list not null");
RpcAssert.assertNotNull(upgradeGoodsId, DefaultErrorEnum.DATA_NULL, "upgradeGoodsId list not null");
if(!isNew){
List<UpgradeGoodsProviderRef> refs = upgradeGoodsProviderRefMapper.findByUpgradeGoodsId(upgradeGoodsId);
Set<Integer> existingSet = new HashSet<>();
if (CollectionUtils.isNotEmpty(refs)) {
existingSet = refs.stream().map(UpgradeGoodsProviderRef::getProviderId).collect(Collectors.toSet());
}
Set<Integer> newSet = new HashSet<>(providerIds);
if (existingSet.equals(newSet)) {
return;
}
upgradeGoodsProviderRefMapper.deleteByUpgradeGoodsId(upgradeGoodsId);
}
// 2. 批量插入新关联
List<UpgradeGoodsProviderRef> refs =new ArrayList<>();
Date now = new Date();
for (Integer providerId : providerIds) {
UpgradeGoodsProviderRef ref = UpgradeGoodsProviderRef.builder()
.upgradeGoodsId(upgradeGoodsId)
.providerId(providerId)
.createdBy(operator)
.createdDate(now)
.updatedBy(operator)
.updatedDate(now)
.deletedFlag("N")
.build();
refs.add(ref);
}
upgradeGoodsProviderRefMapper.insertList(refs);
}
/**
* 批量查询sku关联供应商
* @param upgradeGoodsIds
* @return
*/
public List<UpgradeGoodsProviderRef> findByUpgradeGoodsIds(List<Integer> upgradeGoodsIds) {
return upgradeGoodsProviderRefMapper.findByUpgradeGoodsIds(upgradeGoodsIds);
}
/**
* 批量查询sku关联供应商名称
* @param upgradeGoodsIds
* @return
*/
public List<UpgradeGoodsProviderRefDTO> listProviderNamesByUpgradeGoodsIds(List<Integer> upgradeGoodsIds){
if(CollectionUtils.isEmpty(upgradeGoodsIds)){
return new ArrayList<>();
}
return upgradeGoodsProviderRefMapper.listProviderNamesByUpgradeGoodsIds(upgradeGoodsIds);
}
/**
* 批量查询sku关联供应商名称
* @param upgradeGoodsId
* @return
*/
public UpgradeGoodsProviderRefDTO findProviderNameByUpgradeGoodsId(Integer upgradeGoodsId){
if(Objects.isNull(upgradeGoodsId)){
return new UpgradeGoodsProviderRefDTO();
}
return upgradeGoodsProviderRefMapper.findProviderNameByUpgradeGoodsId(upgradeGoodsId);
}
}
......@@ -265,7 +265,7 @@ public class DivisionRuleAutoService {
MerchantDivisionRuleProcessDTO processDTO = MerchantDivisionRuleProcessDTO.builder().notInForceAccountMerchantMap(new HashMap<>()).divisionRuleTestMap(new TreeMap<>()).build();
return processDTO;
}
return groupDivisionRuleTestService.refreshTestProcess(record.getGoodsTypeGroupDivisionRules(),changeAddNew);
return groupDivisionRuleTestService.refreshTestProcess(record,changeAddNew);
}
}
package cn.com.glsx.dj.smartcarlife.service.merchantSettleDistribution;
import cn.com.glsx.dj.smartcarlife.mapper.DivisionRuleTestMerchantDivisionMapper;
import cn.com.glsx.dj.smartcarlife.model.BaseGoodsMerchantRef;
import cn.com.glsx.dj.smartcarlife.model.DivisionRuleTestMerchantDivision;
import cn.com.glsx.framework.core.beans.BaseModel;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
......@@ -8,6 +9,8 @@ import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import cn.com.glsx.scrm.equity.enums.DeleteFlagEnum;
import lombok.extern.slf4j.Slf4j;
import tk.mybatis.mapper.entity.Example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
......@@ -28,6 +31,28 @@ public class DivisionRuleTestMerchantDivisionService {
private DivisionRuleTestMerchantDivisionMapper divisionRuleTestMerchantDivisionMapper;
@Transactional(propagation= Propagation.REQUIRED,rollbackFor=RpcServiceException.class)
public void saveTestMerchantDivisionBatch(List<DivisionRuleTestMerchantDivision> list,String updatedBy){
RpcAssert.assertNotEmpty(list, DefaultErrorEnum.DATA_NULL,"list not be empty");
RpcAssert.assertNotEmpty(updatedBy, DefaultErrorEnum.DATA_NULL,"updatedBy not be empty");
try{
Date now = new Date();
list.forEach(record ->{
record.setUpdatedBy(updatedBy);
record.setUpdatedDate(now);
record.setCreatedBy(record.getUpdatedBy());
record.setCreatedDate(now);
record.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
});
divisionRuleTestMerchantDivisionMapper.insertList(list);
}catch (RpcServiceException e) {
throw e;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
@Transactional(propagation= Propagation.REQUIRED,rollbackFor=RpcServiceException.class)
public void saveTestMerchantDivision(DivisionRuleTestMerchantDivision record){
RpcAssert.assertNotEmpty(record.getUpdatedBy(), DefaultErrorEnum.DATA_NULL,"record.getUpdatedBy() not be empty");
try{
......@@ -44,13 +69,10 @@ public class DivisionRuleTestMerchantDivisionService {
record.setCreatedBy(record.getUpdatedBy());
record.setCreatedDate(now);
record.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
try{
divisionRuleTestMerchantDivisionMapper.insertUseGeneratedKeys(record);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR);
}
divisionRuleTestMerchantDivisionMapper.insertUseGeneratedKeys(record);
}
}catch (RpcServiceException e) {
throw e;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
......@@ -78,4 +100,23 @@ public class DivisionRuleTestMerchantDivisionService {
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR);
}
}
@Transactional(propagation= Propagation.REQUIRED,rollbackFor=RpcServiceException.class)
public void deleteByDivisionRuleTestId(Integer divisionRuleTestId,String updatedBy) {
RpcAssert.assertNotNull(divisionRuleTestId, DefaultErrorEnum.DATA_NULL,"divisionRuleTestId not be null");
RpcAssert.assertNotEmpty(updatedBy, DefaultErrorEnum.DATA_NULL,"updatedBy not be null");
try{
DivisionRuleTestMerchantDivision r = new DivisionRuleTestMerchantDivision();
r.setDeletedFlag(BaseModel.DeletedFlagEnum.D.name());
r.setUpdatedBy(updatedBy);
r.setUpdatedDate(new Date());
Example example = new Example(DivisionRuleTestMerchantDivision.class);
example.createCriteria().andEqualTo("divisionRuleTestId", divisionRuleTestId)
.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
divisionRuleTestMerchantDivisionMapper.updateByExampleSelective(r, example);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR);
}
}
}
......@@ -582,4 +582,19 @@ public class MerchantDistributionRuleService {
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, e.getMessage());
}
}
public List<MerchantDistributionRuleDTO> listDistrictMerchant(Integer divisionRuleId,Byte ruleType){
RpcAssert.assertNotNull(divisionRuleId, DefaultErrorEnum.DATA_NULL, "divisionRuleId must not be null");
RpcAssert.assertNotNull(ruleType, DefaultErrorEnum.DATA_NULL, "ruleType must not be null");
try {
MerchantDistributionRuleDTO condition = MerchantDistributionRuleDTO.builder()
.divisionRuleId(divisionRuleId).ruleType(ruleType)
.build();
return merchantDistributionRuleMapper.listDistrictMerchant(condition);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, e.getMessage());
}
}
}
......@@ -5,6 +5,7 @@ import cn.com.glsx.dj.smartcarlife.constant.SmartCarLifeConstants;
import cn.com.glsx.dj.smartcarlife.dto.*;
import cn.com.glsx.dj.smartcarlife.enums.*;
import cn.com.glsx.dj.smartcarlife.mapper.MerchantDistributionMapper;
import cn.com.glsx.dj.smartcarlife.model.DivisionRuleTestMerchantDivision;
import cn.com.glsx.dj.smartcarlife.model.GoodsSubOrder;
import cn.com.glsx.dj.smartcarlife.model.MerchantDistribution;
import cn.com.glsx.dj.smartcarlife.model.MerchantExpenseDistribution;
......@@ -45,7 +46,7 @@ public class MerchantDistributionService {
private MerchantExpenseDistributionService merchantExpenseDistributionService;
@Autowired
private GoodsSubOrderService goodsSubOrderService;
public List<MerchantDistribution> listBase(MerchantDistribution condition){
RpcAssert.assertNotNull(condition, DefaultErrorEnum.DATA_NULL,"MerchantDistribution not be null");
try{
......@@ -56,6 +57,39 @@ public class MerchantDistributionService {
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public List<MerchantDistribution> saveTestOrderMerchantDistributions(final OrderDivision orderDivision,
final List<DivisionRuleTestMerchantDivision> merchantDivisionList) {
try {
log.info("开始保存测试商户分账结果,orderCode={}, orderDivisionId={}",orderDivision.getOrderCode(),orderDivision.getId());
List<MerchantDistribution> merchantDistributions = merchantDivisionList.stream().map(m ->{
return MerchantDistribution.builder()
.orderCode(orderDivision.getOrderCode())
.divisionOrderCode(orderDivision.getDivisionOrderCode())
.ruleType(DistributionRuleTypeEnum.ACTUAL_DISTRIBUTE.getValue())
.targetMerchantType(m.getTargetMerchantType())
.targetMerchantLevel(m.getTargetMerchantLevel())
.merchantId(m.getMerchantId()).merchantName(m.getMerchantName())
.realityMerchantId(m.getMerchantId()).realityMerchantName(m.getMerchantName())
.divisionType(orderDivision.getDivisionType())
.shouldDivisionMoney(m.getDistributionMoney()).divisionMoney(m.getDistributionMoney())
.build();
}).collect(Collectors.toList());
for (MerchantDistribution merchantDistribution : merchantDistributions) {
merchantDistribution.setUpdatedBy(CommonConstants.DEFAULT_UPDATE_BY);
thiz.saveMerchantDistribution2DB(merchantDistribution);
}
log.info("商户分账结果保存完成,orderCode={}, orderDivisionId={},结果条数={}",
orderDivision.getOrderCode(),orderDivision.getId(),
merchantDistributions == null ? 0 : merchantDistributions.size());
return merchantDistributions;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
/**
* 商户分账记录,包含实际分账和费用归属分账
*
......
......@@ -4,11 +4,9 @@ import cn.com.glsx.dj.smartcarlife.constant.CommonConstants;
import cn.com.glsx.dj.smartcarlife.dto.GoodsTypeGroupRelationDTO;
import cn.com.glsx.dj.smartcarlife.dto.MerchantDistributionRuleDTO;
import cn.com.glsx.dj.smartcarlife.dto.MerchantGoodsTypeGroupDivisionRuleDTO;
import cn.com.glsx.dj.smartcarlife.dto.settleDistribution.GroupDivisionRuleTestDTO;
import cn.com.glsx.dj.smartcarlife.enums.*;
import cn.com.glsx.dj.smartcarlife.mapper.MerchantGoodsTypeGroupDivisionRuleMapper;
import cn.com.glsx.dj.smartcarlife.model.GoodsTypeGroupRelation;
import cn.com.glsx.dj.smartcarlife.model.GroupDivisionRuleTest;
import cn.com.glsx.dj.smartcarlife.model.MerchantDistributionRule;
import cn.com.glsx.dj.smartcarlife.model.MerchantGoodsTypeGroupDivisionRule;
import cn.com.glsx.dj.smartcarlife.service.GoodsTypeGroupRelationService;
......@@ -45,9 +43,6 @@ public class MerchantGoodsTypeGroupDivisionRuleService {
private GoodsTypeGroupRelationService goodsTypeGroupRelationService;
@Autowired
private MerchantDistributionRuleService merchantDistributionRuleService;
@Autowired
private GroupDivisionRuleTestService groupDivisionRuleTestService;
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public void copyData(Integer oldDivisionRuleId,Integer newDivisionRuleId,Map<Integer,Integer> goodsTypeGroupMap) {
......@@ -480,24 +475,8 @@ public class MerchantGoodsTypeGroupDivisionRuleService {
if (Objects.equals(goodsTypeGroupDivisionId, id)) {
continue;
}
// 同步标记相同分账方关联品类的 group_division_rule_test 为已测试
if (StringUtils.isNotBlank(paymentChannelId)) {
GroupDivisionRuleTest testRecord = GroupDivisionRuleTest.builder()
.groupDivisionRuleId(goodsTypeGroupDivisionId)
.paymentChannelId(paymentChannelId)
.updatedBy(updateBy)
.build();
groupDivisionRuleTestService.updateToMarkTested(testRecord);
log.info("groupRule更新testFlag, 测试通过,相同参与分账方的分组也校验是否通过,更新其为已测试, goodsTypeGroupDivisionId:{}, paymentChannelId:{}", goodsTypeGroupDivisionId, paymentChannelId);
}
GroupDivisionRuleTestDTO groupDivisionRuleTestDTO = GroupDivisionRuleTestDTO.builder().groupDivisionRuleId(goodsTypeGroupDivisionId)
.testFlag(CarLifeEnum.Flag.N.name()).build();
List<GroupDivisionRuleTestDTO> notTestedGroups = groupDivisionRuleTestService.listGroupDivisionRuleTest(groupDivisionRuleTestDTO);
if (CollectionUtils.isEmpty(notTestedGroups)) {
log.info("groupRule更新testFlag, 测试通过,相同参与分账方的分组也通过,更新其为已测试, goodsTypeGroupDivisionId:{}", goodsTypeGroupDivisionId);
merchantGoodsTypeGroupDivisionRuleMapper.updateTestFlag(goodsTypeGroupDivisionId, CarLifeEnum.Flag.Y.name(), CommonConstants.DEFAULT_UPDATE_BY);
}
log.info("groupRule更新testFlag, 测试通过,相同参与分账方的分组也通过,更新其为已测试, goodsTypeGroupDivisionId:{}", goodsTypeGroupDivisionId);
merchantGoodsTypeGroupDivisionRuleMapper.updateTestFlag(goodsTypeGroupDivisionId, CarLifeEnum.Flag.Y.name(), CommonConstants.DEFAULT_UPDATE_BY);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
......
......@@ -60,7 +60,6 @@
<result column="scrm_flag" property="scrmFlag"/>
<result column="scrm_service_code" property="scrmServiceCode"/>
<result column="provider_id" property="providerId"/>
<result column="provider_name" property="providerName" />
<result column="accessory_type" property="accessoryType"/>
</association>
<collection property="upgradeGoodsList" javaType="java.util.List" ofType="cn.com.glsx.dj.smartcarlife.dto.UpgradeGoodsDTO">
......@@ -164,8 +163,6 @@
<result column="brandMerchantCode" property="brandMerchantCode"/>
<result column="brandMerchantName" property="brandMerchantName"/>
<result column="accessoryType" property="accessoryType"/>
<result column="providerId" property="providerId"/>
<result column="providerId" property="providerId"/>
</association>
</resultMap>
......@@ -248,11 +245,9 @@
gi.scrm_flag,
gi.scrm_service_code,
gi.accessory_type,
gp.provider_name,
bg.specification_type
from dj_car_life_base_goods bg
left join dj_car_life_goods_info gi on gi.goods_code = bg.goods_code and gi.deleted_flag = 'N'
left join dj_car_life_goods_provider gp on gp.id = gi.provider_id
where bg.id = #{id}
and bg.deleted_flag = 'N'
</select>
......@@ -646,6 +641,7 @@
left join dj_car_life_goods_info gi on gi.goods_code=bg.goods_code and gi.deleted_flag='N' and gi.`status` = 1
<!-- 仅用做查询条件使用 -->
left join dj_car_life_upgrade_goods ug on ug.base_goods_id=bg.id and ug.deleted_flag='N'
left join dj_car_life_upgrade_goods_provider_ref ugpr on ug.id = ugpr.upgrade_goods_id and ugpr.deleted_flag = 'N'
<include refid="listWithPageCondition"/>
GROUP BY bg.id
order by bg.updated_date desc
......@@ -668,6 +664,7 @@
from dj_car_life_base_goods bg
left join dj_car_life_goods_info gi on gi.goods_code=bg.goods_code and gi.deleted_flag='N' and gi.`status` = 1
left join dj_car_life_upgrade_goods ug on ug.base_goods_id=bg.id and ug.deleted_flag='N'
left join dj_car_life_upgrade_goods_provider_ref ugpr on ug.id = ugpr.upgrade_goods_id and ugpr.deleted_flag = 'N'
<include refid="listWithPageCondition"/>
</select>
......@@ -713,7 +710,7 @@
a.warning_value as warningValue,
a.warning_value_max as warningValueMax,
GROUP_CONCAT(d.series_name SEPARATOR '/') as carTypeStr,
c.provider_id as providerId,
GROUP_CONCAT(distinct gp.provider_name SEPARATOR '/') as providerName,
a.created_date as createdDate,
a.updated_date as updatedDate,
b.specification_type AS specificationType,
......@@ -722,6 +719,8 @@
from dj_car_life_upgrade_goods a
left join dj_car_life_base_goods b on a.goods_code = b.goods_code and b.deleted_flag = 'N'
left join dj_car_life_goods_info c on c.goods_code = a.goods_code and c.deleted_flag = 'N'
left join dj_car_life_upgrade_goods_provider_ref ugpr on ugpr.upgrade_goods_id = a.id and ugpr.deleted_flag = 'N'
left join dj_car_life_goods_provider gp on gp.id = ugpr.provider_id and gp.deleted_flag = 'N'
left join dj_car_life_upgrade_goods_car_type_config d on d.deleted_flag = 'N'
and d.upgrade_goods_id = a.id
and d.deleted_flag = 'N'
......@@ -772,7 +771,7 @@
</foreach>
</if>
<if test="providerIds != null and providerIds.size() > 0">
and c.provider_id in
and ugpr.provider_id in
<foreach collection="providerIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
......@@ -813,7 +812,6 @@
b.brand_merchant_name as brandMerchantName,
IF(a.specification_type = 2, CONCAT('X', a.upgrade_goods_num), '-') as spuSpecificationData,
b.accessory_type as accessoryType,
b.provider_id as providerId,
CASE
WHEN price.min_price IS NULL OR price.max_price IS NULL THEN '0'
WHEN price.min_price = price.max_price THEN CAST(price.min_price AS CHAR)
......@@ -831,6 +829,7 @@
WHERE deleted_flag = 'N'
GROUP BY goods_code) price ON price.goods_code = a.goods_code
left join dj_car_life_upgrade_goods c on c.goods_code = a.goods_code and c.deleted_flag = 'N'
left join dj_car_life_upgrade_goods_provider_ref ugpr on ugpr.upgrade_goods_id = c.id and ugpr.deleted_flag = 'N'
where a.deleted_flag = 'N'
<if test="goodsSource != null">
and b.goods_source = #{goodsSource}
......@@ -839,7 +838,7 @@
and (a.commodity_code = #{commodityCode} or c.commodity_code=#{commodityCode})
</if>
<if test="providerIds != null and providerIds.size() > 0">
and b.provider_id in
and ugpr.provider_id in
<foreach collection="providerIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
......@@ -973,7 +972,7 @@
and ug.third_party_code like concat('%',#{thirdPartyCode},'%')
</if>
<if test="providerIds != null and providerIds.size() > 0">
and gi.provider_id in
and ugpr.provider_id in
<foreach collection="providerIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
......
......@@ -7,13 +7,14 @@
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
<result column="goods_type_group_division_id" jdbcType="INTEGER" property="goodsTypeGroupDivisionId" />
<result column="payment_channel_id" jdbcType="VARCHAR" property="paymentChannelId" />
<result column="payment_channel_name" jdbcType="VARCHAR" property="paymentChannelName" />
<result column="settle_rule_id" jdbcType="INTEGER" property="settleRuleId" />
<result column="division_rule_id" jdbcType="INTEGER" property="divisionRuleId" />
<result column="order_code" jdbcType="VARCHAR" property="orderCode" />
<result column="order_money" property="orderMoney"/>
<result column="progress" jdbcType="TINYINT" property="progress" />
<result column="sub_progress" jdbcType="TINYINT" property="subProgress" />
<result column="test_flag" property="testFlag"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
......@@ -24,8 +25,8 @@
<!--x
WARNING - @mbg.generated
-->
id, merchant_id, goods_type_group_division_id, payment_channel_id, payment_channel_name, settle_rule_id, division_rule_id,
order_code, sub_progress, created_by, created_date, updated_by, updated_date, deleted_flag
id, merchant_id, payment_channel_id, payment_channel_name, division_rule_id,
order_code,order_money, progress,sub_progress,test_flag, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<resultMap extends="BaseResultMap" id="DTOResultMap" type="cn.com.glsx.dj.smartcarlife.dto.DivisionRuleTestDTO">
......@@ -44,6 +45,9 @@
<result column="dcldrtmd_order_code" property="orderCode" jdbcType="VARCHAR" />
<result column="dcldrtmd_merchant_id" property="merchantId" jdbcType="INTEGER" />
<result column="dcldrtmd_merchant_name" property="merchantName" jdbcType="VARCHAR" />
<result column="dcldrtmd_target_merchant_type" property="targetMerchantType"/>
<result column="dcldrtmd_target_merchant_level" property="targetMerchantLevel"/>
<result column="dcldrtmd_distribution_money" property="distributionMoney"/>
<result column="dcldrtmd_division_money" property="divisionMoney" jdbcType="DECIMAL" />
<result column="dcldrtmd_confirm_division_money" property="confirmDivisionMoney" jdbcType="DECIMAL" />
</collection>
......@@ -63,10 +67,13 @@
<select id="list" parameterType="cn.com.glsx.dj.smartcarlife.model.DivisionRuleTest" resultMap="DTOResultMap">
select
dcldrt.id, dcldrt.division_rule_id, goods_type_group_division_id, dcldrt.payment_channel_id, dcldrt.payment_channel_name, dclpc.pay_platform, settle_rule_id,
division_rule_id, dcldrt.order_code, sub_progress, dcldrt.merchant_id,
dcldrt.id, dcldrt.division_rule_id, dcldrt.payment_channel_id, dcldrt.payment_channel_name, dclpc.pay_platform,
dcldrt.order_code,dcldrt.order_money, progress,sub_progress, dcldrt.merchant_id,
dcldrt.test_flag,
dcldrtmd.id as dcldrtmd_id, dcldrtmd.division_rule_test_id as dcldrtmd_division_rule_test_id, dcldrtmd.order_code as dcldrtmd_order_code,
dcldrtmd.merchant_id as dcldrtmd_merchant_id, dcldrtmd.merchant_name as dcldrtmd_merchant_name, dcldrtmd.division_money as dcldrtmd_division_money,
dcldrtmd.merchant_id as dcldrtmd_merchant_id, dcldrtmd.merchant_name as dcldrtmd_merchant_name,
dcldrtmd.target_merchant_type as dcldrtmd_target_merchant_type,dcldrtmd.target_merchant_level as dcldrtmd_target_merchant_level,
dcldrtmd.distribution_money as dcldrtmd_distribution_money,dcldrtmd.division_money as dcldrtmd_division_money,
dcldrtmd.confirm_division_money as dcldrtmd_confirm_division_money,
dclgso.upgrade_goods_name as testGoodsName, dclgso.upgrade_goods_commodity_code as testGoodsCommodityCode, dclgso.upgrade_goods_type_name as testGoodsTypeName,
dclgso.upgrade_price as testGoodsPrice, dclgso.upgrade_shop_price as testGoodsShopPrice, dclpo.out_trade_no
......@@ -78,8 +85,8 @@
left join dj_car_life_payment_channel dclpc on dclpc.payment_channel_id = dcldrt.payment_channel_id and dclpc.deleted_flag = 'N'
<where>
dcldrt.deleted_flag = 'N'
<if test="goodsTypeGroupDivisionId != null">
and dcldrt.goods_type_group_division_id = #{goodsTypeGroupDivisionId}
<if test="divisionRuleId != null">
and dcldrt.division_rule_id = #{divisionRuleId}
</if>
<if test="paymentChannelId != null and paymentChannelId != ''">
and dcldrt.payment_channel_id = #{paymentChannelId}
......@@ -92,22 +99,15 @@
</select>
<select id="getSubOrdersAndCategroyById" resultMap="DTOResultMap">
select dcldrt.id,
goods_type_group_division_id,
dcldrt.payment_channel_id,
dcldrt.payment_channel_name,
settle_rule_id,
division_rule_id,
dcldrt.order_code,
dcldrt.order_money,
progress,
sub_progress,
dcldrt.test_flag,
dcldrt.merchant_id,
(select category_type
from dj_car_life_goods_type_group_relation dclgtgr
left join dj_car_life_merchant_goods_type_group_division_rule dclmgtgdr
on dclgtgr.goods_type_group_rule_id = dclmgtgdr.goods_type_group_id and
dclmgtgdr.deleted_flag = 'N'
where dclgtgr.deleted_flag = 'N'
and dclmgtgdr.id = dcldrt.goods_type_group_division_id
limit 1) as category_type,
dclgso.package_code,
dclgso.package_name,
dclgso.upgrade_goods_name,
......@@ -126,4 +126,10 @@
where dcldrt.deleted_flag = 'N'
and dcldrt.id = #{id}
</select>
<update id="clearOrder" parameterType="cn.com.glsx.dj.smartcarlife.model.DivisionRuleTest">
update dj_car_life_division_rule_test
set order_code=null,order_money=null,updated_by = #{updatedBy} ,updated_date=now()
where id = #{id}
</update>
</mapper>
\ No newline at end of file
......@@ -10,6 +10,9 @@
<result column="order_code" property="orderCode" jdbcType="VARCHAR" />
<result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
<result column="merchant_name" property="merchantName" jdbcType="VARCHAR" />
<result column="target_merchant_type" property="targetMerchantType"/>
<result column="target_merchant_level" property="targetMerchantLevel"/>
<result column="distribution_money" property="distributionMoney"/>
<result column="division_money" property="divisionMoney" jdbcType="DECIMAL" />
<result column="confirm_division_money" property="confirmDivisionMoney" jdbcType="DECIMAL" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
......@@ -22,7 +25,8 @@
<!--
WARNING - @mbg.generated
-->
id, division_rule_test_id, order_code, merchant_id, merchant_name, division_money,
confirm_division_money, created_by, created_date, updated_by, updated_date, deleted_flag
id, division_rule_test_id, order_code, merchant_id, merchant_name,target_merchant_type,target_merchant_level,
distribution_money, division_money,confirm_division_money,
created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
</mapper>
\ No newline at end of file
......@@ -1350,7 +1350,7 @@
and gso2.upgrade_goods_name like CONCAT('%', #{upgradeGoodsName}, '%') limit 1
)
</if>
order by po.success_date desc
order by go.install_upgrade_time desc
</select>
<select id="listWithPageByShop" parameterType="cn.com.glsx.dj.smartcarlife.dto.GoodsOrderProfitAllocationDTO" resultMap="VoResultMap">
......
......@@ -74,6 +74,22 @@
</where>
</select>
<select id="listDistrictMerchant" parameterType="cn.com.glsx.dj.smartcarlife.dto.MerchantDistributionRuleDTO" resultMap="DTOResultMap">
select
DISTINCT mdr.merchant_id,merchant_name,target_merchant_type,target_merchant_level
from dj_car_life_merchant_distribution_rule mdr
left join dj_car_life_merchant_goods_type_group_division_rule mgtgdr on mgtgdr.id=mdr.goods_type_group_rule_id and mgtgdr.deleted_flag='N'
<where>
mdr.deleted_flag='N'
<if test="divisionRuleId != null">
and mgtgdr.division_rule_id = #{divisionRuleId}
</if>
<if test="ruleType != null">
and mdr.rule_type = #{ruleType}
</if>
</where>
</select>
<update id="updateShopInfo" parameterType="cn.com.glsx.dj.smartcarlife.dto.MerchantDistributionRuleDTO">
update dj_car_life_merchant_distribution_rule a,dj_car_life_merchant_goods_type_group_division_rule b
set a.target_merchant_level = #{targetMerchantLevel},a.merchant_id=#{merchantId}, a.merchant_name=#{merchantName},
......
......@@ -1175,8 +1175,8 @@
on mpgi.package_code = mgi.package_code and mgi.deleted_flag = 'N'
left join dj_car_life_upgrade_goods ug on ug.id = mgi.upgrade_goods_id and ug.deleted_flag = 'N'
left join dj_car_life_base_goods bg on bg.id = ug.base_goods_id and bg.deleted_flag = 'N'
left join dj_car_life_goods_info gi on gi.goods_code = ug.goods_code and gi.deleted_flag = 'N'
left join dj_car_life_goods_position_relation gpr
left join dj_car_life_goods_info gi on gi.goods_code = ug.goods_code and gi.deleted_flag = 'N'
left join dj_car_life_goods_position_relation gpr
on gpr.goods_code = gi.goods_code and gpr.deleted_flag = 'N' and gpr.position = mgi.position
left join dj_car_life_merchant_goods_ref mgr on mgr.deleted_flag = 'N' and mgr.package_code = mpgi.package_code
left join dj_car_life_scene_merchant_ref smr
......@@ -1334,12 +1334,8 @@
ug.commodity_code as commodityCode,
ug.upgrade_goods_name as upgradeGoodsName,
ug.operation_cost as operationCost,
ug.applicable_area as applicableArea,
gi.provider_id as providerId,
gp.provider_name as providerName
ug.applicable_area as applicableArea
from dj_car_life_upgrade_goods ug
left join dj_car_life_goods_info gi on gi.goods_code = ug.goods_code and gi.deleted_flag = 'N'
left join dj_car_life_goods_provider gp on gp.id = gi.provider_id and gp.deleted_flag = 'N'
where ug.deleted_flag = 'N'
<if test="upgradeGoodsIdList != null and upgradeGoodsIdList.size() > 0">
and ug.id in
......
......@@ -56,7 +56,8 @@
GROUP_CONCAT(distinct gp.provider_name SEPARATOR "/") as providerNames
from dj_car_life_upgrade_goods ug
left join dj_car_life_goods_info gi on gi.goods_code=ug.goods_code
left join dj_car_life_goods_provider gp on gp.id=gi.provider_id and gp.deleted_flag='N'
left join dj_car_life_upgrade_goods_provider_ref ugpr on ugpr.upgrade_goods_id=ug.id and ugpr.deleted_flag='N'
left join dj_car_life_goods_provider gp on gp.id=ugpr.provider_id and gp.deleted_flag='N'
<where>
ug.deleted_flag='N' and gi.deleted_flag='N'
and ug.product_template_id in
......
......@@ -17,6 +17,9 @@
<result column="allocate_order_goods_id" property="allocateOrderGoodsId"/>
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="upgrade_goods_name" jdbcType="VARCHAR" property="upgradeGoodsName" />
<result column="purchase_goods_name" jdbcType="VARCHAR" property="purchaseGoodsName" />
<result column="third_party_code" jdbcType="VARCHAR" property="thirdPartyCode" />
<result column="third_party_name" jdbcType="VARCHAR" property="thirdPartyName" />
<result column="purchase_number" jdbcType="DECIMAL" property="purchaseNumber" />
<result column="stock_num" jdbcType="DECIMAL" property="stockNum" />
<result column="put_status" property="putStatus" jdbcType="TINYINT" />
......@@ -32,7 +35,7 @@
WARNING - @mbg.generated
-->
id, order_delivery_id, order_code, goods_code, goods_name, goods_type, goods_type_name,
upgrade_goods_id,purchase_order_goods_id, allocate_order_goods_id, type, upgrade_goods_name, purchase_number, stock_num, put_status, delivery_remark, created_by,
upgrade_goods_id,purchase_order_goods_id, allocate_order_goods_id, type, upgrade_goods_name, purchase_goods_name, third_party_code, third_party_name, purchase_number, stock_num, put_status, delivery_remark, created_by,
created_date, updated_by, updated_date, deleted_flag
</sql>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.smartcarlife.dto.PurchaseOrderDeliveryDetailDTO" extends="BaseResultMap">
......@@ -124,7 +127,7 @@
<select id="list" parameterType="cn.com.glsx.dj.smartcarlife.dto.PurchaseOrderDeliveryDetailDTO" resultMap="DTOResultMap">
select
dclpodd.id, dclpodd.order_delivery_id, dclpodd.order_code, dclpodd.goods_code, dclpodd.goods_name, dclpodd.goods_type, dclpodd.purchase_order_goods_id, dclpodd.allocate_order_goods_id,
dclpodd.goods_type_name, dclpodd.upgrade_goods_id, dclpodd.type, dclpodd.upgrade_goods_name, dclpodd.purchase_number,
dclpodd.goods_type_name, dclpodd.upgrade_goods_id, dclpodd.type, dclpodd.upgrade_goods_name, dclpodd.purchase_goods_name, dclpodd.third_party_code, dclpodd.third_party_name, dclpodd.purchase_number,
dclpodd.stock_num, dclpodd.put_status,
dclpod.delivery_company, dclpod.delivery_number, dclpod.delivery_date,
dclpod.order_type, dclpod.contact_name, dclpod.contact_phone, dclpod.contact_address, dclpod.upload_file,
......
......@@ -70,6 +70,9 @@
<result column="detail_specification_data" jdbcType="VARCHAR" property="specificationData" />
<result column="detail_conversion_value" jdbcType="VARCHAR" property="conversionValue" />
<result column="order_type" jdbcType="INTEGER" property="orderType" />
<result column="detail_purchase_goods_name" jdbcType="VARCHAR" property="purchaseGoodsName" />
<result column="detail_third_party_code" jdbcType="VARCHAR" property="thirdPartyCode" />
<result column="detail_third_party_name" jdbcType="VARCHAR" property="thirdPartyName" />
</collection>
</resultMap>
......@@ -110,6 +113,9 @@
dd.purchase_order_goods_id as detail_purchase_order_goods_id,
dd.allocate_order_goods_id as detail_allocate_order_goods_id,
dd.delivery_remark as detail_delivery_remark,
dd.purchase_goods_name as detail_purchase_goods_name,
dd.third_party_code as detail_third_party_code,
dd.third_party_name as detail_third_party_name,
dclpog.specification_data as detail_specification_data
from (select id,
order_code,
......@@ -170,6 +176,9 @@
dd.stock_num as detail_stock_num,
dd.purchase_order_goods_id as detail_purchase_order_goods_id,
dd.allocate_order_goods_id as detail_allocate_order_goods_id,
dd.purchase_goods_name as detail_purchase_goods_name,
dd.third_party_code as detail_third_party_code,
dd.third_party_name as detail_third_party_name,
if(main.order_type = 1, sar.remark, po.remark) as purchase_order_remark,
concat(ifnull(if(main.order_type = 1, sar.remark, po.remark), ''), ifnull(dd.delivery_remark, '')) as detail_delivery_remark,
if(main.order_type = 1, sad.specification_data, dclpog.specification_data) as detail_specification_data,
......
......@@ -16,6 +16,9 @@
<result column="upgrade_goods_id" jdbcType="INTEGER" property="upgradeGoodsId" />
<result column="upgrade_goods_commodity_code" jdbcType="VARCHAR" property="upgradeGoodsCommodityCode" />
<result column="upgrade_goods_name" jdbcType="VARCHAR" property="upgradeGoodsName" />
<result column="purchase_goods_name" jdbcType="VARCHAR" property="purchaseGoodsName" />
<result column="third_party_code" jdbcType="VARCHAR" property="thirdPartyCode" />
<result column="third_party_name" jdbcType="VARCHAR" property="thirdPartyName" />
<result column="specification_data" jdbcType="VARCHAR" property="specificationData" />
<result column="upgrade_purchase_price" jdbcType="DECIMAL" property="upgradePurchasePrice" />
<result column="upgrade_goods_position" jdbcType="INTEGER" property="upgradeGoodsPosition" />
......@@ -49,7 +52,7 @@
WARNING - @mbg.generated
-->
id, order_code, goods_code, goods_name, goods_type, goods_type_name, thumb_url, conversion_value,
upgrade_goods_id, upgrade_goods_commodity_code, upgrade_goods_name, specification_data, upgrade_purchase_price,
upgrade_goods_id, upgrade_goods_commodity_code, upgrade_goods_name, purchase_goods_name, third_party_code, third_party_name, specification_data, upgrade_purchase_price,
upgrade_goods_position, position_deduction_value, type, goods_number, goods_total_price, delivery_status,
purchase_number, input_number, put_yq_merchant_id, put_yq_merchant_name, put_merchant_id,
put_merchant_name, shipper_uuid, shipper, allocate_date, refund_status, shopping_car_id, delivery_remark,
......@@ -127,6 +130,9 @@
<result column="od_delivery_company" property="deliveryCompany" jdbcType="VARCHAR" />
<result column="od_delivery_date" property="deliveryDate" jdbcType="TIMESTAMP" />
<result column="shipping_warehouse_name" property="shippingWarehouseName" jdbcType="VARCHAR" />
<result column="detail_purchase_goods_name" jdbcType="VARCHAR" property="purchaseGoodsName" />
<result column="detail_third_party_code" jdbcType="VARCHAR" property="thirdPartyCode" />
<result column="detail_third_party_name" jdbcType="VARCHAR" property="thirdPartyName" />
</collection>
</resultMap>
......@@ -177,6 +183,7 @@
dclpog.created_by, dclpog.created_date, dclpog.updated_by, dclpog.updated_date, dclpog.deleted_flag,
dclpog.put_yq_merchant_id, dclpog.put_yq_merchant_name, dclpog.put_merchant_id,dclpog.put_merchant_name,dclpog.remark,
dclpog.refund_status,
dclpog.purchase_goods_name,dclpog.third_party_code,dclpog.third_party_name,
dclug.type as type,dclug.entity_card_flag
from dj_car_life_purchase_order_goods dclpog
left join dj_car_life_upgrade_goods dclug on dclug.id = dclpog.upgrade_goods_id and dclug.deleted_flag ='N'
......@@ -200,6 +207,7 @@
dclpog.created_by, dclpog.created_date, dclpog.updated_by, dclpog.updated_date, dclpog.deleted_flag,
dclpog.put_yq_merchant_id, dclpog.put_yq_merchant_name, dclpog.put_merchant_id,dclpog.put_merchant_name,
dclpog.refund_status,
dclpog.purchase_goods_name,dclpog.third_party_code,dclpog.third_party_name,
dclug.type as type,dclug.entity_card_flag
from dj_car_life_purchase_order_goods dclpog
left join dj_car_life_upgrade_goods dclug on dclug.id = dclpog.upgrade_goods_id and dclug.deleted_flag ='N'
......@@ -273,6 +281,7 @@
dclpog.created_by, dclpog.created_date, dclpog.updated_by, dclpog.updated_date, dclpog.deleted_flag,
dclpog.put_yq_merchant_id, dclpog.put_yq_merchant_name, dclpog.put_merchant_id,dclpog.put_merchant_name,
dclpog.refund_status,dclpog.remark,dclpog.shopping_car_id, dclpog.delivery_status,
dclpog.purchase_goods_name,dclpog.third_party_code,dclpog.third_party_name,
dclug.type as type,dclug.entity_card_flag
from dj_car_life_purchase_order_goods dclpog
left join dj_car_life_upgrade_goods dclug on dclug.id = dclpog.upgrade_goods_id
......@@ -404,7 +413,10 @@
od.id as od_id, od.delivery_date as od_delivery_date, od.delivery_company as od_delivery_company, od.delivery_number as od_delivery_number, od.shipping_warehouse_name,od.upload_file,
/*发货单商品详情信息*/
dd.id as dd_id, dd.order_delivery_id as dd_order_delivery_id, dd.purchase_number as dd_purchase_number, dd.upgrade_goods_id as dd_upgrade_goods_id,
dd.purchase_order_goods_id as dd_purchase_order_goods_id
dd.purchase_order_goods_id as dd_purchase_order_goods_id,
dd.purchase_goods_name as detail_purchase_goods_name,
dd.third_party_code as detail_third_party_code,
dd.third_party_name as detail_third_party_name
from
(
select
......@@ -420,7 +432,7 @@
og.id , og.goods_name , og.goods_code, og.goods_type , og.goods_type_name , og.type ,
og.upgrade_goods_id , og.upgrade_goods_name , og.goods_number , og.purchase_number , og.shipper_uuid, og.shipper , og.goods_total_price ,
og.conversion_value , og.specification_data , og.refund_status ,og.remark ,og.shopping_car_id, og.delivery_status, og.delivery_remark,
og.allocate_date,og.sign_status,
og.allocate_date,og.sign_status, og.purchase_goods_name, og.third_party_code, og.third_party_name,
(
select max(reviewed_date) from dj_car_life_purchase_order_audit_detail ad where ad.order_code = po.order_code
) as max_review_date
......@@ -593,6 +605,12 @@
<if test="merchantName != null and merchantName !=''">
and po.merchant_name like CONCAT('%', #{merchantName}, '%')
</if>
<if test="thirdPartyName != null and thirdPartyName !=''">
and og.third_party_name like CONCAT('%', #{thirdPartyName}, '%')
</if>
<if test="thirdPartyCode != null and thirdPartyCode !=''">
and og.third_party_code like CONCAT('%', #{thirdPartyCode}, '%')
</if>
<if test="yqMerchantIds != null and yqMerchantIds.size()>0">
and po.merchant_id in
<foreach collection="yqMerchantIds" item="item" open="(" separator="," close=")" >
......
......@@ -71,6 +71,9 @@
<result column="pog_remark" property="remark"/>
<result column="refund_status" property="refundStatus"/>
<result column="shopping_car_id" property="shoppingCarId"/>
<result column="third_party_name" property="thirdPartyName" jdbcType="VARCHAR"/>
<result column="third_party_code" property="thirdPartyCode" jdbcType="VARCHAR"/>
<result column="purchase_goods_name" property="purchaseGoodsName" jdbcType="VARCHAR"/>
</collection>
</resultMap>
......@@ -498,7 +501,8 @@
dclpog.upgrade_goods_id, dclpog.upgrade_goods_name, dclpog.type, dclpog.specification_data, dclpog.goods_name,
dclpog.goods_type, dclpog.goods_type_name, dclpog.goods_number, dclpog.conversion_value, dclpog.purchase_number,
dclpog.input_number, dclpog.goods_total_price,dclpog.remark as pog_remark,dclpog.refund_status,
dclpog.shopping_car_id
dclpog.shopping_car_id,
dclpog.third_party_name, dclpog.third_party_code, dclpog.purchase_goods_name
from dj_car_life_purchase_order po
left join dj_car_life_purchase_order_goods dclpog on dclpog.order_code = po.order_code and dclpog.deleted_flag = 'N'
<where>
......
......@@ -29,6 +29,9 @@
<result column="ug_commodity_code" property="commodityCode"/>
<result column="ug_type" property="type"/>
<result column="ug_status" property="status"/>
<result column="pgi_purchase_goods_name" property="purchaseGoodsName"/>
<result column="ug_third_party_name" property="thirdPartyName"/>
<result column="ug_third_party_code" property="thirdPartyCode"/>
<result column="specification_data" jdbcType="VARCHAR" property="specificationData" />
<result column="base_goods_name" jdbcType="VARCHAR" property="baseGoodsName" />
<result column="specification_type" property="specificationType" />
......@@ -69,7 +72,7 @@
<!-- 购物车信息 -->
psc.id, psc.merchant_id, psc.merchant_name, psc.upgrade_goods_id, psc.goods_number,psc.selected_flag,psc.car_type_md5_code,
<!-- 升级商品信息 -->
ug.id as ug_id,ug.upgrade_goods_name as ug_upgrade_goods_name, ug.specification_data, dclbg.base_goods_name,
ug.id as ug_id,ug.upgrade_goods_name as ug_upgrade_goods_name, ug.third_party_name as ug_third_party_name, ug.third_party_code as ug_third_party_code, ug.specification_data, dclbg.base_goods_name,
dclbg.specification_type, ug.stock as ug_stock,
ug.position as ug_position,ug.commodity_code as ug_commodity_code,
gpr.deduction_standard as ug_deduction_standard,ug.type as ug_type,
......@@ -79,7 +82,7 @@
gi.goods_type as gi_goods_type,gi.goods_type_name as gi_goods_type_name,
gi.converted_value as gi_converted_value,gi.goods_name as gi_goods_name,
<!-- 采购上架信息 -->
pgi.purchase_price as pgi_purchase_price,pgi.suit_car_type as pgi_suit_car_type,
pgi.purchase_price as pgi_purchase_price,pgi.purchase_goods_name as pgi_purchase_goods_name,pgi.suit_car_type as pgi_suit_car_type,
<!-- 适用车型 -->
pogct.brand_id, pogct.brand_name, pogct.child_id, pogct.child_name,
pogct.series_id, pogct.series_name,pogct.car_type_id, pogct.car_type_name
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.com.glsx.dj.smartcarlife.mapper.UpgradeGoodsProviderRefMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.smartcarlife.model.UpgradeGoodsProviderRef" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="upgrade_goods_id" property="upgradeGoodsId" jdbcType="INTEGER" />
<result column="provider_id" property="providerId" jdbcType="INTEGER" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, upgrade_goods_id, provider_id, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<select id="findByUpgradeGoodsId" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from dj_car_life_upgrade_goods_provider_ref
where deleted_flag = 'N' and upgrade_goods_id = #{upgradeGoodsId}
</select>
<select id="findByUpgradeGoodsIds" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from dj_car_life_upgrade_goods_provider_ref
where deleted_flag = 'N'
and upgrade_goods_id in
<foreach item="item" collection="upgradeGoodsIds" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="listProviderIdsByUpgradeGoodsIds" resultMap="BaseResultMap">
select upgrade_goods_id, provider_id
from dj_car_life_upgrade_goods_provider_ref
where deleted_flag = 'N'
and upgrade_goods_id in
<foreach item="item" collection="upgradeGoodsIds" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="listProviderNamesByUpgradeGoodsIds" resultType="cn.com.glsx.dj.smartcarlife.dto.goods.UpgradeGoodsProviderRefDTO">
select
ugpr.upgrade_goods_id AS upgradeGoodsId,
GROUP_CONCAT(distinct gp.provider_name SEPARATOR '/') as providerName
from
dj_car_life_upgrade_goods_provider_ref ugpr
left join dj_car_life_goods_provider gp on gp.id = ugpr.provider_id and gp.deleted_flag = 'N'
where ugpr.deleted_flag = 'N'
and ugpr.upgrade_goods_id in
<foreach item="item" collection="upgradeGoodsIds" index="index" separator="," open="(" close=")">
#{item}
</foreach>
group by ugpr.upgrade_goods_id
</select>
<select id="findProviderNameByUpgradeGoodsId" resultType="cn.com.glsx.dj.smartcarlife.dto.goods.UpgradeGoodsProviderRefDTO">
select
ugpr.upgrade_goods_id AS upgradeGoodsId,
GROUP_CONCAT(distinct gp.provider_name SEPARATOR '/') as providerName
from
dj_car_life_upgrade_goods_provider_ref ugpr
left join dj_car_life_goods_provider gp on gp.id = ugpr.provider_id and gp.deleted_flag = 'N'
where ugpr.deleted_flag = 'N'
and ugpr.upgrade_goods_id = #{upgradeGoodsId}
</select>
<update id="deleteByUpgradeGoodsId">
update dj_car_life_upgrade_goods_provider_ref
set deleted_flag = 'D'
where upgrade_goods_id = #{upgradeGoodsId} and deleted_flag = 'N'
</update>
</mapper>
......@@ -26,16 +26,6 @@
id, division_rule_id, group_division_rule_id, payment_channel_id, payment_channel_name, test_flag,
created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<update id="updateToMarkTested">
update dj_car_life_group_division_rule_test
set test_flag = 'Y',
updated_by = #{updatedBy},
updated_date = now()
where group_division_rule_id = #{groupDivisionRuleId}
and payment_channel_id = #{paymentChannelId}
and deleted_flag = 'N'
</update>
<select id="listGroupDivisionRuleTest" resultMap="DTOResultMap">
select
......
......@@ -13,6 +13,7 @@
<result column="last_on_shelf_time" property="lastOnShelfTime" jdbcType="TIMESTAMP" />
<result column="shelf_source" property="shelfSource" jdbcType="TINYINT" />
<result column="suit_car_type" property="suitCarType" jdbcType="TINYINT" />
<result column="purchase_goods_name" property="purchaseGoodsName" jdbcType="VARCHAR" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
......@@ -54,6 +55,7 @@
<result column="ug_upgrade_goods_name" property="upgradeGoodsName" />
<result column="ug_service_years" property="serviceYears" />
<result column="ug_third_party_code" property="thirdPartyCode" />
<result column="ug_third_party_name" property="thirdPartyName" />
<result column="ug_entity_card_flag" property="entityCardFlag" />
<result column="ug_min_suit_car_price" property="minSuitCarPrice" />
<result column="ug_max_suit_car_price" property="maxSuitCarPrice" />
......@@ -87,8 +89,8 @@
<!--
WARNING - @mbg.generated
-->
id, purchase_goods_code, upgrade_goods_id, purchase_price, status, last_on_shelf_time,
shelf_source, suit_car_type, created_by, created_date, updated_by, updated_date,
id, purchase_goods_code, upgrade_goods_id, purchase_price, status, last_on_shelf_time,
shelf_source, suit_car_type, purchase_goods_name, created_by, created_date, updated_by, updated_date,
deleted_flag
</sql>
<select id="list" parameterType="cn.com.glsx.dj.smartcarlife.dto.purchageGoods.PurchaseGoodsInfoDTO" resultMap="DTOResultMap">
......@@ -104,14 +106,14 @@
select
<!-- 采购上架商品信息 -->
pgi.id, pgi.purchase_goods_code, pgi.upgrade_goods_id, pgi.purchase_price, pgi.status, pgi.last_on_shelf_time,
pgi.shelf_source, pgi.suit_car_type, pgi.created_by, pgi.created_date, pgi.updated_by, pgi.updated_date,
pgi.shelf_source, pgi.suit_car_type, pgi.purchase_goods_name, pgi.created_by, pgi.created_date, pgi.updated_by, pgi.updated_date,
<!-- 升级商品信息 -->
ug.base_goods_id as ug_base_goods_id,ug.id as ug_id,
ug.upgrade_goods_name as ug_upgrade_goods_name,ug.type as ug_type,ug.commodity_code as ug_commodity_code,
ug.specification_data as ug_specification_data,ug.stock as ug_stock,ug.upgrade_price as ug_upgrade_price,
ug.warranty_period as ug_warranty_period,ug.position as ug_position,ug.purchase_price as ug_purchase_price,
ug.warning_value as ug_warning_value,ug.service_years as ug_service_years,ug.warning_value_max as ug_warning_value_max,
ug.third_party_code as ug_third_party_code,ug.entity_card_flag as ug_entity_card_flag,
ug.third_party_code as ug_third_party_code,ug.third_party_name as ug_third_party_name,ug.entity_card_flag as ug_entity_card_flag,
ug.min_suit_car_price as ug_min_suit_car_price,
ug.max_suit_car_price as ug_max_suit_car_price,
ug.kilometers as ug_kilometers,
......@@ -205,7 +207,10 @@
and bg.commodity_code = #{baseCommodityCode}
</if>
<if test="thirdPartyCode != null and thirdPartyCode !=''">
and ug.third_party_code = #{thirdPartyCode}
and ug.third_party_code like concat('%', #{thirdPartyCode}, '%')
</if>
<if test="thirdPartyName != null and thirdPartyName !=''">
and ug.third_party_name like concat('%', #{thirdPartyName}, '%')
</if>
</where>
</sql>
......
  • @wangxw1
    commented
    Master

    代码审查报告

    一、关键问题与优化建议(Top 3)

    1. 【严重】Dubbo 服务提供者 Remote 接口已有请求参数发生变更

    • 问题描述:在 GroupDivisionRuleTestRemote.java 中,已有接口方法 refreshGroupTestProcess 的参数名从 groupRuleId 变更为 divisionRuleId。根据审查规则,此行为被视为危险实现。
    • 影响分析:Dubbo 接口是跨服务通信的契约。直接修改已有方法的参数名及业务语义,会导致尚未更新 API 依赖的消费端(Consumer)仍传入 groupRuleId 的值,而提供端(Provider)将其作为 divisionRuleId 处理。这会引发严重的数据错乱(查询到错误的分账规则)或业务逻辑异常。
    • 优化建议:严禁直接修改已发布的 Dubbo 接口方法签名及参数语义。建议采用以下方式之一平滑过渡:
      1. 新增一个方法(如 refreshGroupTestProcessByDivisionRuleId),并在旧方法上添加 @Deprecated 注解,旧方法内部可做兼容处理或直接抛出明确的废弃异常。
      2. 如果必须修改,需确保所有消费端与提供端强一致同步发布(风险极高,不推荐)。

    2. 【健壮性】分账测试金额分配存在出现负数的风险

    • 问题描述:在 DivisionRuleTestService.java 的 saveTestMerchantDivision 方法中,计算剩余分配金额的逻辑为:BigDecimal remainDistributionMoney = totalPrice.subtract(platformDistributionMoney);。其中 platformDistributionMoney 默认取配置值 0.5。
    • 影响分析:如果测试订单的 totalPrice(总金额)小于平台分配金额(0.5),remainDistributionMoney 将变为负数。后续在平分金额时(avgDistributionMoney),会导致其他商户分配到负数金额。这可能引发后续资金校验失败、数据库插入异常(若字段无符号)或分账系统崩溃。
    • 优化建议:在进行减法运算前,增加对总金额的保底校验。 java BigDecimal platformDistributionMoney = new BigDecimal(OrePropertyConfigurer.getString("division.test.platform.distribution.money","0.5")); if (totalPrice.compareTo(platformDistributionMoney) < 0) { throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "订单总金额不足以支付平台基础分账金额"); }

    3. 【可维护性】代码中硬编码了特定环境的业务主键(GoodsCode)

    • 问题描述:在 DivisionRuleTestService.java 的 createTestOrder 方法中,存在硬编码的默认后备值:goodsOrder.setTestMerchantGoodsCode(OrePropertyConfigurer.getString("division.rule.test.merchant.goods.code", "MG2023091516425389165"));。
    • 影响分析:MG2023091516425389165 明显是某个特定环境(如测试环境或生产环境)的商品编码。如果配置中心缺失该配置(如在新部署的私有化环境或开发人员本地环境),系统将默认使用该硬编码值。若该库中不存在此商品,将导致晦涩的报错(“找不到该测试上架商品”),极大地增加了排查成本和环境迁移成本。
    • 优化建议:移除业务主键的硬编码默认值,改为强制要求配置,若无配置则抛出明确的异常。 java String testGoodsCode = OrePropertyConfigurer.getString("division.rule.test.merchant.goods.code"); if (StringUtils.isBlank(testGoodsCode)) { throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "未配置分账测试商品编码(division.rule.test.merchant.goods.code)"); } goodsOrder.setTestMerchantGoodsCode(testGoodsCode);

    二、评分明细

    • 功能实现的正确性与健壮性 (32/40分)
      • 扣分原因:触犯了重要规则“Dubbo服务提供者Remote接口中的已有请求参数变更视为危险实现”,接口兼容性遭到破坏(扣5分);金额分配逻辑在极端情况下(总金额<0.5)缺乏边界保护,可能产生负数金额(扣3分)。代码中未发现 MyBatis 使用子查询的情况。
    • 安全性与潜在风险 (30/30分)
      • 得分原因:未发现 SQL 注入、越权、敏感日志打印等明显的安全漏洞。分布式锁 @GlsxDistributeLockable 和 @Transactional 事务注解使用规范,保证了并发安全。
    • 最佳实践与可维护性 (16/20分)
      • 扣分原因:代码中出现了业务主键的硬编码(扣2分);部分方法(如 saveTestMerchantDivision)过于庞大,圈复杂度较高,建议后续进行适当拆分提取(扣2分)。
    • 性能与资源利用 (5/5分)
      • 得分原因:集合遍历、流处理(Stream API)使用得当,CollectionUtils.isNotEmpty 校验前置,避免了无效的 DB 查询和空指针计算,性能表现良好。
    • 提交信息质量 (4/5分)
      • 得分原因:Commit 信息描述了具体修复的 Bug 和新增的特性(如“添加分账规则测试主进度更新功能”),具备一定的可追溯性;但属于多人合并提交,格式稍显杂乱(扣1分)。

    总分:87分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!