Commit 6d0028ca authored by shiyu's avatar shiyu

bug修复

parent 0fb417cc
......@@ -6,16 +6,18 @@ import java.text.DecimalFormat;
public class PriceUtil {
public static String convertPriceFenToYuan(Long rawPrice) {
BigDecimal price = new BigDecimal((rawPrice.doubleValue() / 100));
price = price.setScale(2, BigDecimal.ROUND_HALF_UP);
return price.toString();
BigDecimal price = new BigDecimal(String.valueOf(rawPrice.doubleValue() / 100));
DecimalFormat df = new DecimalFormat("#0.00");
String str = df.format(price);
return new BigDecimal(str).stripTrailingZeros().toString();
}
public static String convertPriceByTwo(int price){
double num = (double)price / 100;
BigDecimal bigDecimal = new BigDecimal(String.valueOf(num));
DecimalFormat df = new DecimalFormat("#0.00");
return df.format(bigDecimal);
String str = df.format(bigDecimal);
return new BigDecimal(str).stripTrailingZeros().toString();
}
public static Long convertPriceFromStr(String price){
......@@ -27,7 +29,8 @@ public class PriceUtil {
public static String convertDoubleToString(Double price){
BigDecimal bigDecimal = new BigDecimal(String.valueOf( price / 100));
DecimalFormat df = new DecimalFormat("#0.00");
return df.format(bigDecimal);
String str = df.format(bigDecimal);
return new BigDecimal(str).stripTrailingZeros().toString();
}
......@@ -38,7 +41,13 @@ public class PriceUtil {
}
public static void main(String[] args) {
System.out.println(convertPriceFenToYuan(3980L));
System.out.println(UUID.fastUUID().toString(true));
String num = "3.0000";
BigDecimal bigDecimal = new BigDecimal(num);
DecimalFormat df = new DecimalFormat("#0.00");
String a = df.format(bigDecimal);
System.out.println(new BigDecimal(a).stripTrailingZeros().toString());
}
}
......@@ -21,6 +21,11 @@ public class SupplierItemRequestDto extends BaseRequestDto implements Entity {
*/
private Long supplierId;
/**
* 库存
*/
private Integer stock;
/**
* 商品名称
*/
......@@ -47,4 +52,9 @@ public class SupplierItemRequestDto extends BaseRequestDto implements Entity {
* 逻辑删除
*/
private Boolean isDeleted;
/**
* 分销分享记录id
*/
private String shareRecordId;
}
......@@ -70,6 +70,7 @@ public class DistributionOrderDaoImpl implements DistributionOrderDao {
JdbcHelper.ifPresent(dto.getSellerId(), criteria::andSellerIdEqualTo);
JdbcHelper.ifPresent(dto.getState(), criteria::andStateEqualTo);
JdbcHelper.ifPresent(dto.getDistributionOrderId(), criteria::andDistributionOrderIdEqualTo);
example.setOrderByClause("create_time desc");
PageHelper.startPage(dto.getPage(), dto.getLimit());
return distributionOrderMapper.selectByExample(example);
......
......@@ -29,12 +29,14 @@ public class SupplierItemDaoImpl implements SupplierItemDao {
if (StringUtils.hasLength(dto.getName())) {
criteria.andNameLike("%" + dto.getName() + "%");
}
JdbcHelper.ifPresent(dto.getStock(), criteria::andStockGreaterThan);
JdbcHelper.ifPresent(dto.getIsOnSale(), criteria::andIsOnSaleEqualTo);
JdbcHelper.ifPresent(dto.getIsDeleted(), criteria::andIsDeletedEqualTo);
PageHelper.startPage(dto.getPage(), dto.getLimit());
return supplierItemMapper.selectByExampleWithBLOBs(supplierItemExample);
}
@Override
public SupplierItem findById(long itemId) {
SupplierItemExample supplierItemExample = new SupplierItemExample();
......
......@@ -39,6 +39,7 @@ public class SupplierItemVo implements Entity {
/**
* 分销价格,要除以100
* 给分销商的价格
*/
private String distributionPrice;
......@@ -47,6 +48,11 @@ public class SupplierItemVo implements Entity {
*/
private String supplyPrice;
/**
* 售价,要除以100
*/
private String salePrice;
/**
* 库存
*/
......
......@@ -563,8 +563,10 @@ public class UserServiceImpl implements UserService {
try {
CloudServerResponse<CommunityUserAttributeDO> response = communityAttributeReadService.getCommunityUserAttributeByUserId(dto.getUserId());
if (response.isSuccess()) {
if (response.getResult() != null) {
user.setProfile(response.getResult().getSignature());
}
}
} catch (Exception e) {
logger.error(">>>>>>>>> 调用社区用户查询接口获取用户签名出错:{}", e);
}
......
......@@ -13,6 +13,7 @@ import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto;
import com.wwdz.ch.wx.entity.vo.distribution.SupplierItemVo;
import com.wwdz.ch.wx.service.distribution.SupplierItemService;
import com.xxdxxs.utils.EntityMapper;
import com.xxdxxs.utils.StringUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
......@@ -73,6 +74,10 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItemVo.setSupplyPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getSupplyPrice()));
supplierItemVo.setDistributionPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getDistributionPrice()));
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
if (StringUtils.hasLength(dto.getShareRecordId())) {
DistributorShareRecord distributorShareRecord = distributorShareRecordDao.findById(dto.getShareRecordId());
supplierItemVo.setSalePrice(PriceUtil.convertPriceFenToYuan(distributorShareRecord.getPrice()));
}
return Result.success(supplierItemVo);
} catch (Exception e) {
logger.error("供应商商品详情查询失败 error : {}", e);
......
......@@ -29,4 +29,5 @@ public interface SupplierItemService {
*/
Result reduceStock(long itemId, int stock);
}
......@@ -39,4 +39,5 @@ public class SupplierItemController {
return supplierItemService.findDetail(dto);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment