Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-10-22 18:03:35 +08:00
commit 00331148f3
5 files changed
+158 -57

No files matched your search

@@ -28,12 +28,14 @@ import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
import com.bsd.pjcloud.hard.mapper.order.HardParentCarMapper;
import com.bsd.pjcloud.hard.service.HardCarService;
import com.bsd.pjcloud.hard.service.HardSpuService;
import com.bsd.pjcloud.supermarket.api.feign.RemoteMallProductService;
import com.bsd.pjcloud.supermarket.api.feign.RemoteShopSkuService;
import com.bsd.pjcloud.supermarket.api.feign.RemoteShopSpuService;
import com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketUnitSkuService;
import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity;
import com.bsd.pjcloud.supermarket.vo.app.ShopSpuDetailAppVo;
import com.bsd.pjcloud.supermarket.vo.erp.SmErpUnitWithSpuVo;
import com.bsd.pjcloud.supermarket.vo.mall.MallProductDetailAppVo;
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -68,6 +70,7 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
private final RemoteSupermarketUnitSkuService supermarketUnitSkuService;
private final RemoteShopSkuService remoteShopSkuService;
private final RemoteShopSpuService remoteShopSpuService;
private final RemoteMallProductService remoteMallProductService;
@Override
public Page<HardCarVo> pageJoin(Page page, HardCarDto dto) {
@@ -416,6 +419,38 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
baseMapper.insert(carObjectList);
return;
}
// 共富商城
if (ObjectUtil.equals(sysType, HardTypeEnum.FARMER)) {
List<HardCarEntity> carObjectList = new ArrayList<>();
List<MallProductDetailAppVo> spuList = remoteMallProductService.getDetailByIds(productIds).getData();
for (HardCreateCarDto v : productList) {
HardCarEntity item = HardCarEntity.builder().parentCarId(parentCarId).build();
spuList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
Integer price = getSupermarket(spu);
int totalPrice = 0;
if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) {
// 按数量
totalPrice = v.getProductCount() * price;
} else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) {
// 按重量
totalPrice = v.getProductWeight().multiply(BigDecimal.valueOf(price)).setScale(0, RoundingMode.CEILING).intValue();
}
item.setProductId(spu.getId());
item.setProductName(spu.getTitle());
item.setProductPrice(price);
item.setProductPic(spu.getCoverImage());
item.setTotalPrice((long) totalPrice);
if (ObjectUtil.isNotEmpty(v.getProductNature())) {
item.setProductNature(v.getProductNature().getType());
}
item.setProductCount(v.getProductCount());
item.setProductWeight(v.getProductWeight());
carObjectList.add(item);
});
}
baseMapper.insert(carObjectList);
return;
}
}
@Override
@@ -461,6 +496,21 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
});
}
}
// 共富商城
if (ObjectUtil.equals(sysType, HardTypeEnum.FARMER)) {
List<MallProductDetailAppVo> supList = remoteMallProductService.getDetailByIds(productIds).getData();
for (HardCreateCarDto v : list) {
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
str.append(spu.getTitle()).append("x");
if (ObjectUtil.equals(spu.getProductNature(), HardProductNatureEnum.DEFAULT.getType())) {
str.append(v.getProductCount());
} else if (ObjectUtil.equals(spu.getProductNature(), HardProductNatureEnum.WEIGHT.getType())) {
str.append(v.getProductWeight()).append("/kg");
}
str.append(";");
});
}
}
return str.toString();
}
@@ -65,9 +65,11 @@ import com.bsd.pjcloud.hard.api.vo.wechat.WechatMicropayVo;
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
import com.bsd.pjcloud.hard.service.*;
import com.bsd.pjcloud.supermarket.api.feign.RemoteMallProductService;
import com.bsd.pjcloud.supermarket.api.feign.RemoteShopSkuService;
import com.bsd.pjcloud.supermarket.api.feign.RemoteShopSpuService;
import com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketSpuService;
import com.bsd.pjcloud.supermarket.dto.MallProductStockChangeDTO;
import com.bsd.pjcloud.supermarket.dto.SkuStockChangeDTO;
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO;
import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity;
@@ -150,6 +152,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
private final RemoteSupermarketSpuService supermarketSpuService;
private final RemoteShopSkuService remoteShopSkuService;
private final RemoteActCancelService remoteActCancelService;
private final RemoteMallProductService remoteMallProductService;
private final HardManagerMapper hardManagerMapper;
@@ -670,8 +673,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
entity.setProductCount(v.getProductCount());
return entity;
}).toList();
HardTypeEnum hardType = ObjectUtil.equals(dto.getWalletType(), WalletTypeEnum.EAT) ? HardTypeEnum.CANTEEN : HardTypeEnum.SUPERMARKET;
String subject = hardCarService.computerCarSubject(hardType, dto.getOrderType(), carListDto);
String subject = hardCarService.computerCarSubject(dto.getHardType(), dto.getOrderType(), carListDto);
// 添加硬件订单
HardOrderEntity orderObj = HardOrderEntity.builder()
.userId(dto.getUserId())
@@ -1305,6 +1307,53 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
log.info("扣减智能柜库存成功|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(list));
return;
}
// 共富商城
if (ObjectUtil.equals(HardOrderTypeEnum.FARMER, orderTypeEnum)) {
// 查询购物车
List<HardCarEntity> carList = hardCarService.getByParentCarId(order.getParentCarId());
// 扣件库存
MallProductStockChangeDTO dto = new MallProductStockChangeDTO();
dto.setDeviceType(0);
List<MallProductStockChangeDTO.Item> itemList = carList.stream().map(v -> {
MallProductStockChangeDTO.Item item = new MallProductStockChangeDTO.Item();
item.setId(v.getProductId());
item.setProductType(1);
if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) {
// 按数量
int prouctCount = v.getProductCount();
// 如果退款购物车数组里有,就用退款购物车的数量
if (ObjectUtil.isNotEmpty(refundCarList)) {
HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null);
if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) {
prouctCount = refundCarTarget.getProductCount();
}
}
double count = BigDecimal.valueOf(prouctCount).multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue();
item.setIncrCount(count);
} else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) {
// 按重量
BigDecimal productWeight = v.getProductWeight();
// 如果退款购物车数组里有,就用退款购物车的数量
if (ObjectUtil.isNotEmpty(refundCarList)) {
HardCarEntity refundCarTarget = refundCarList.stream().filter(i -> ObjectUtil.equals(i.getProductId(), v.getProductId())).findFirst().orElse(null);
if (ObjectUtil.isNotEmpty(refundCarTarget) && ObjectUtil.isNotEmpty(refundCarTarget.getProductCount())) {
productWeight = refundCarTarget.getProductWeight();
}
}
double weight = productWeight.multiply(BigDecimal.valueOf(base)).setScale(2, RoundingMode.HALF_UP).doubleValue();
item.setIncrCount(weight);
}
return item;
}).toList();
dto.setItems(itemList);
R<Boolean> updateSkuStockRes = remoteMallProductService.deductStock(dto);
if (updateSkuStockRes.getCode() != 0 || !updateSkuStockRes.getData()) {
log.info("|{}|{},失败,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto));
throw new RuntimeException(CarErrorMsg + "错误");
}
log.info("|{}|{},成功,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(dto));
return;
}
}
// 发送mq消息
@@ -399,7 +399,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
WalletTransactionSumAndCountDto walletDto = new WalletTransactionSumAndCountDto();
walletDto.setDeptIds(deptIds);
walletDto.setBizTypes(List.of(WalletBizEnum.RETURN_CANTEEN.getCode()));
walletDto.setType(WalletTransactionSumAndCountDto.TYPE_EXPENSE);
// walletDto.setType(WalletTransactionSumAndCountDto.TYPE_EXPENSE);
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
walletDto.setCreateTimeList(dto.getCreateTimeList());
}
@@ -1,3 +1,4 @@
com.bsd.pjcloud.supermarket.api.feign.RemoteMallProductService
com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketCategoryService
com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketSpuService
com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketUnitSkuService
@@ -194,20 +194,50 @@
</select>
<select id="selectTotalBalance" resultType="java.lang.Long">
SELECT SUM(latest_balance.balance)
FROM (
SELECT DISTINCT a.user_id,
m.wallet_type_id,
FIRST_VALUE(a.balance) OVER (
PARTITION BY a.user_id, m.wallet_type_id
ORDER BY a.create_time DESC
) as balance
SELECT
SUM(a.balance)
FROM wallet_transaction a
INNER JOIN wallet_manage m
ON a.wallet_id = m.id
LEFT JOIN wallet_manage m on a.wallet_id = m.id
<where>
a.del_flag = '0'
AND DATE_FORMAT(a.create_time, '%Y-%m') &lt;= #{dto.walletRecordMonth}
a.del_flag = 0
<if test="dto.walletRecordMonth != null">
AND a.create_time = (
SELECT MAX(sub.create_time)
FROM wallet_transaction sub
LEFT JOIN wallet_manage wallet on wallet.id = sub.wallet_id
WHERE sub.user_id = a.user_id
AND DATE_FORMAT(sub.create_time, '%Y-%m') &lt;= #{dto.walletRecordMonth}
<if test="dto.userId != null">
AND sub.user_id = #{dto.userId}
</if>
<if test="dto.userIds != null and dto.userIds.size() != 0">
and sub.user_id in
<foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
<choose>
<when test="dto.isInclude != null and dto.isInclude == true">
and wallet.dept_id IN
</when>
<when test="dto.isInclude != null and dto.isInclude == false">
and wallet.dept_id NOT IN
</when>
<otherwise>
and wallet.dept_id IN
</otherwise>
</choose>
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.walletTypeId != null">
AND wallet.wallet_type_id = #{dto.walletTypeId}
</if>
limit 1
)
</if>
<if test="dto.userId != null">
AND a.user_id = #{dto.userId}
</if>
@@ -237,52 +267,22 @@
</foreach>
</if>
</where>
) latest_balance
</select>
<!-- SELECT-->
<!-- SUM(a.balance)-->
<!-- SELECT SUM(latest_balance.balance)-->
<!-- FROM (-->
<!-- SELECT DISTINCT a.user_id,-->
<!-- m.wallet_type_id,-->
<!-- FIRST_VALUE(a.balance) OVER (-->
<!-- PARTITION BY a.user_id, m.wallet_type_id-->
<!-- ORDER BY a.create_time DESC-->
<!-- ) as balance-->
<!-- FROM wallet_transaction a-->
<!-- LEFT JOIN wallet_manage m on a.wallet_id = m.id-->
<!-- INNER JOIN wallet_manage m-->
<!-- ON a.wallet_id = m.id-->
<!-- <where>-->
<!-- a.del_flag = 0-->
<!-- <if test="dto.walletRecordMonth != null">-->
<!-- AND a.create_time = (-->
<!-- SELECT MAX(sub.create_time)-->
<!-- FROM wallet_transaction sub-->
<!-- LEFT JOIN wallet_manage wallet on wallet.id = sub.wallet_id-->
<!-- WHERE sub.user_id = a.user_id-->
<!-- AND DATE_FORMAT(sub.create_time, '%Y-%m') &lt;= #{dto.walletRecordMonth}-->
<!-- <if test="dto.userId != null">-->
<!-- AND sub.user_id = #{dto.userId}-->
<!-- </if>-->
<!-- <if test="dto.userIds != null and dto.userIds.size() != 0">-->
<!-- and sub.user_id in-->
<!-- <foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">-->
<!-- #{v}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="dto.deptIds != null and dto.deptIds.size() != 0">-->
<!-- <choose>-->
<!-- <when test="dto.isInclude != null and dto.isInclude == true">-->
<!-- and wallet.dept_id IN-->
<!-- </when>-->
<!-- <when test="dto.isInclude != null and dto.isInclude == false">-->
<!-- and wallet.dept_id NOT IN-->
<!-- </when>-->
<!-- <otherwise>-->
<!-- and wallet.dept_id IN-->
<!-- </otherwise>-->
<!-- </choose>-->
<!-- <foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">-->
<!-- #{v}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="dto.walletTypeId != null">-->
<!-- AND wallet.wallet_type_id = #{dto.walletTypeId}-->
<!-- </if>-->
<!-- )-->
<!-- </if>-->
<!-- a.del_flag = '0'-->
<!-- AND DATE_FORMAT(a.create_time, '%Y-%m') &lt;= #{dto.walletRecordMonth}-->
<!-- <if test="dto.userId != null">-->
<!-- AND a.user_id = #{dto.userId}-->
<!-- </if>-->
@@ -312,4 +312,5 @@
<!-- </foreach>-->
<!-- </if>-->
<!-- </where>-->
<!-- ) latest_balance-->
</mapper>