Authored by Lixiaodi

增加日志

... ... @@ -42,4 +42,6 @@ public interface StorageDepositMapper {
int getDepositOffShelvesCount(@Param("uid") Integer uid, @Param("storageId") Integer storageId);
StorageDeposit selectByDepositCode(@Param("uid") int uid, @Param("depositCode")String depositCode);
List<StorageDeposit> getDepositOffs(@Param("uid") Integer uid, @Param("storageId") Integer storageId, @Param("count") Integer count);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
import lombok.ToString;
@ToString
public class StorageDeposit {
private Integer id;
... ...
package com.yohoufo.dal.order.model;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class StorageDepositCount {
private Integer productId;
... ...
... ... @@ -325,6 +325,11 @@
where owner_uid = #{uid} and status=1 and order_status=0 and del_status=0 and storage_id = #{storageId}
</select>
<select id="getDepositOffs" resultMap="BaseResultMap">
select * from storage_deposit
where owner_uid = #{uid} and storage_id = #{storageId} and status=1 and order_status=0 and del_status=0 limit 0, #{count}
</select>
<select id="selectByDepositCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from storage_deposit
where owner_uid = #{uid} and status = 1 and del_status= 0 AND deposit_code = #{depositCode,jdbcType=VARCHAR} limit 1
... ...
... ... @@ -23,11 +23,17 @@ public interface DepositService {
boolean changeSaleStatusOn(Integer uid, String depositCode, Integer skup);
// 下架
boolean changeSaleStatusOff(Integer uid, Integer skup);
// 批量上架
List<StorageDeposit> changeSaleStatusOnBatch(Integer uid, Integer storageId, List<Integer> skupList);
// 批量下架
List<Integer> changeSaleStatusOffBatch(Integer uid, List<Integer> skupList);
// 转卖
boolean changeOwner(Integer uid, Integer skup, long buyOrderCode, Integer newUid);
// 可上架数量
int getDepositOffShelvesCount(Integer uid, Integer storageId);
// 剩余存储天数
int getRemainDay(Integer uid, String depositCode);
}
... ...
... ... @@ -49,7 +49,9 @@ public class DepositServiceImpl implements DepositService {
return new ArrayList<>();
}
List<Integer> productIdList = storageDepositMapper.queryUserDepositProductId(uid, (page - 1) * limit, limit);
LOGGER.info("productIdList is {}", productIdList);
List<StorageDepositCount> countInfoList = storageDepositMapper.queryUserDepositProduct(uid, productIdList);
LOGGER.info("countInfoList is {}", countInfoList);
List<Integer> skupList = countInfoList.stream().map(StorageDepositCount::getSkup).collect(Collectors.toList());
List<SellerOrderGoods> goodsList = sellerOrderGoodsMapper.selectBySkups(skupList);
Map<Integer, StorageDepositCount> countInfoMap = countInfoList.stream().map(Function.identity()).collect(Collectors.toMap(StorageDepositCount::getProductId, Function.identity()));
... ... @@ -164,23 +166,57 @@ public class DepositServiceImpl implements DepositService {
// 上架
@Override
public boolean changeSaleStatusOn(Integer uid, String depositCode, Integer skup) {
LOGGER.info("changeSaleStatusOn uid {}, depositCode is {}, skup is {}", uid, depositCode, skup);
return storageDepositMapper.changeSaleStatusOn(uid, depositCode, skup) == 1;
}
// 下架
@Override
public boolean changeSaleStatusOff(Integer uid, Integer skup) {
LOGGER.info("changeSaleStatusOff uid {}, skup is {}", uid, skup);
return storageDepositMapper.changeSaleStatusOff(uid, skup) == 1;
}
// 批量上架
public List<StorageDeposit> changeSaleStatusOnBatch(Integer uid, Integer storageId, List<Integer> skupList) {
int count = skupList.size();
List<StorageDeposit> sdList = storageDepositMapper.getDepositOffs(uid, storageId, count);
List<StorageDeposit> successList = new ArrayList<>();
for (int i = 0; i < sdList.size(); i++) {
StorageDeposit sd = sdList.get(i);
if (changeSaleStatusOn(uid, sd.getDepositCode(), skupList.get(i))) {
LOGGER.info("changeSaleStatusOn success! uid {},depositeCode is {}, skup is {}", uid, sd.getDepositCode(), skupList.get(i));
sd.setNewSkup(skupList.get(i));
successList.add(sd);
}
}
return successList;
}
// 批量下架
public List<Integer> changeSaleStatusOffBatch(Integer uid, List<Integer> skupList) {
List<Integer> successList = new ArrayList<>();
for (Integer skup : skupList) {
if (changeSaleStatusOff(uid, skup)) {
LOGGER.info("changeSaleStatusOff success! uid {}, skup is {}", uid, skup);
successList.add(skup);
}
}
return successList;
}
// 转卖
@Override
public boolean changeOwner(Integer uid, Integer skup, long buyOrderCode, Integer newUid) {
LOGGER.info("changeOwner success! uid {}, skup is {}, buyOrderCode is {}, newUid is {}", uid, skup, buyOrderCode, newUid);
StorageDeposit sd = storageDepositMapper.queryByOwnerSkup(uid, skup);
if(sd==null) {
if (sd == null) {
return false;
}
if(storageDepositMapper.sale(uid, skup, buyOrderCode) == 0) {
if (storageDepositMapper.sale(uid, skup, buyOrderCode) == 0) {
return false;
}
LOGGER.info("sale success! uid {}, skup is {}, buyOrderCode is {}, newUid is {}", uid, skup, buyOrderCode, newUid);
sd.setId(null);
sd.setOwnerUid(newUid);
sd.setOrderCode(buyOrderCode);
... ... @@ -188,10 +224,11 @@ public class DepositServiceImpl implements DepositService {
sd.setStatus(1);
sd.setOrderStatus(0);
sd.setUpdateTime(0);
int now = (int) (System.currentTimeMillis()/1000);
int now = (int) (System.currentTimeMillis() / 1000);
sd.setCreateTime(now);
sd.setDepositStartTime(now);
sd.setDepositEndTime(now + DEPOSIT_MAX_TIME);
LOGGER.info("new owner record is sd", sd);
storageDepositMapper.insert(sd);
return true;
}
... ...