|
|
@@ -7,12 +7,12 @@ import org.springblade.client.entity.GoodsType;
|
|
|
import org.springblade.client.feign.ICorpsDescClient;
|
|
|
import org.springblade.client.feign.IGoodsDescClient;
|
|
|
import org.springblade.client.vo.GoodsDescVO;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tenant.annotation.NonDS;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.mocha.entity.PriceBank;
|
|
|
import org.springblade.mocha.mapper.PriceBankMapper;
|
|
|
-import org.springblade.mocha.service.IPriceBankService;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
@@ -20,45 +20,45 @@ import springfox.documentation.annotations.ApiIgnore;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
-import java.util.logging.Logger;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@NonDS
|
|
|
@ApiIgnore()
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
-public class PriceBankClient implements IPriceBankClient{
|
|
|
+public class PriceBankClient implements IPriceBankClient {
|
|
|
|
|
|
private final PriceBankMapper priceBankMapper;
|
|
|
private final IGoodsDescClient goodsDescClient;
|
|
|
private final ICorpsDescClient corpsDescClient;
|
|
|
+
|
|
|
/**
|
|
|
- *
|
|
|
- * @param itemId 商品id
|
|
|
- * @param price 价格
|
|
|
- * @param tenantId 租户id
|
|
|
- * @param corpId 供应商
|
|
|
- * @param specs 商品规格
|
|
|
- * @param billType 价格类型 XS 销售价格 CG 采购价格
|
|
|
- * @param tradeType 贸易类型 GN 国内 JK 进口 CK 出口
|
|
|
- * @param exchangeRate 汇率
|
|
|
- * @param greenback 美元价格
|
|
|
- * @param currency 币别
|
|
|
- * @param coefficient FOB系数
|
|
|
- * @param taxRate 税率
|
|
|
- * @param dateTime 有效期结束
|
|
|
- * @param purchaseAmount 采购金额
|
|
|
+ * @param itemId 商品id
|
|
|
+ * @param price 价格
|
|
|
+ * @param tenantId 租户id
|
|
|
+ * @param corpId 供应商
|
|
|
+ * @param specs 商品规格
|
|
|
+ * @param billType 价格类型 XS 销售价格 CG 采购价格
|
|
|
+ * @param tradeType 贸易类型 GN 国内 JK 进口 CK 出口
|
|
|
+ * @param exchangeRate 汇率
|
|
|
+ * @param greenback 美元价格
|
|
|
+ * @param currency 币别
|
|
|
+ * @param coefficient FOB系数
|
|
|
+ * @param taxRate 税率
|
|
|
+ * @param dateTime 有效期结束
|
|
|
+ * @param purchaseAmount 采购金额
|
|
|
* @param priorityReferrer 是否重点推荐
|
|
|
- * @param referrerReason 推荐理由
|
|
|
- * * @return
|
|
|
- * * 1.先根据商品id,商品规格,价格类型,租户id,供应商,贸易类型 查未删除的价格库数据
|
|
|
- * * 2.查到后先执行将历史价格依次更新操作 未查到暂不执行更新操作
|
|
|
- * * 3.查到将价格赋值到最新价格字段上 最新价格日期为当前时间 未查到暂不执行更新操作
|
|
|
- * * 4.修改价格库数据
|
|
|
+ * @param referrerReason 推荐理由
|
|
|
+ * * @return
|
|
|
+ * * 1.先根据商品id,商品规格,价格类型,租户id,供应商,贸易类型 查未删除的价格库数据
|
|
|
+ * * 2.查到后先执行将历史价格依次更新操作 未查到暂不执行更新操作
|
|
|
+ * * 3.查到将价格赋值到最新价格字段上 最新价格日期为当前时间 未查到暂不执行更新操作
|
|
|
+ * * 4.修改价格库数据
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping(UPDATE_PRICE)
|
|
|
@Override
|
|
|
- public int updatePrice(Long itemId, BigDecimal price, String tenantId, Long corpId,String specs, String billType, String tradeType,BigDecimal exchangeRate,
|
|
|
+ public int updatePrice(Long itemId, BigDecimal price, String tenantId, Long corpId, String specs, String billType, String tradeType, BigDecimal exchangeRate,
|
|
|
BigDecimal greenback,
|
|
|
String currency,
|
|
|
BigDecimal coefficient,
|
|
|
@@ -73,23 +73,23 @@ public class PriceBankClient implements IPriceBankClient{
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
try {
|
|
|
date = sdf.parse(dateTime);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
System.out.println("转换日期出错");
|
|
|
}
|
|
|
int flag = 0;
|
|
|
LambdaQueryWrapper<PriceBank> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(PriceBank::getBillType,billType);
|
|
|
- lambdaQueryWrapper.eq(PriceBank::getTradeType,tradeType);
|
|
|
- lambdaQueryWrapper.eq(PriceBank::getTenantId,tenantId);
|
|
|
- lambdaQueryWrapper.eq(PriceBank::getItemId,itemId);
|
|
|
- lambdaQueryWrapper.eq(PriceBank::getCorpId,corpId);
|
|
|
+ lambdaQueryWrapper.eq(PriceBank::getBillType, billType);
|
|
|
+ lambdaQueryWrapper.eq(PriceBank::getTradeType, tradeType);
|
|
|
+ lambdaQueryWrapper.eq(PriceBank::getTenantId, tenantId);
|
|
|
+ lambdaQueryWrapper.eq(PriceBank::getItemId, itemId);
|
|
|
+ lambdaQueryWrapper.eq(PriceBank::getCorpId, corpId);
|
|
|
PriceBank priceBank = priceBankMapper.selectOne(lambdaQueryWrapper);
|
|
|
//获取商品信息
|
|
|
R<GoodsDescVO> goodsDesc = goodsDescClient.selectGoodsMessage(itemId);
|
|
|
R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(corpId);
|
|
|
PriceBank bank = new PriceBank();
|
|
|
bank.setItemId(itemId);
|
|
|
- if (goodsDesc.isSuccess() && goodsDesc.getData() != null){
|
|
|
+ if (goodsDesc.isSuccess() && goodsDesc.getData() != null) {
|
|
|
bank.setCode(goodsDesc.getData().getCode());
|
|
|
bank.setCname(goodsDesc.getData().getCname());
|
|
|
bank.setEname(goodsDesc.getData().getEname());
|
|
|
@@ -111,26 +111,40 @@ public class PriceBankClient implements IPriceBankClient{
|
|
|
bank.setPurchaseAmount(purchaseAmount);
|
|
|
bank.setPriorityReferrer(priorityReferrer);
|
|
|
bank.setReferrerReason(referrerReason);
|
|
|
- if (corpMessage.isSuccess() && corpMessage.getData() != null){
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null) {
|
|
|
bank.setCorpName(corpMessage.getData().getCname());
|
|
|
}
|
|
|
GoodsType goodsType = goodsDescClient.goodTypeId(itemId);
|
|
|
- if (goodsType != null){
|
|
|
+ if (goodsType != null) {
|
|
|
bank.setGoodsTypeName(goodsType.getCname());
|
|
|
}
|
|
|
- if (priceBank != null){
|
|
|
- if (new Date().compareTo(priceBank.getPriceTime()) >0){
|
|
|
+ if (priceBank != null) {
|
|
|
+ if (new Date().compareTo(priceBank.getPriceTime()) > 0) {
|
|
|
priceBankMapper.updatePrice(priceBank.getId());//更新历史价格
|
|
|
}
|
|
|
bank.setId(priceBank.getId());
|
|
|
bank.setUpdateUser(SecureUtil.getUserId());
|
|
|
bank.setUpdateTime(new Date());
|
|
|
flag = priceBankMapper.updateById(bank);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
bank.setCreateUser(SecureUtil.getUserId());
|
|
|
bank.setCreateTime(new Date());
|
|
|
flag = priceBankMapper.insert(bank);
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过ids查看数据
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(SELECT_BY_ID)
|
|
|
+ @Override
|
|
|
+ public List<PriceBank> selectById(String ids) {
|
|
|
+ LambdaQueryWrapper<PriceBank> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(PriceBank::getIsDeleted, 0).eq(PriceBank::getTenantId, AuthUtil.getTenantId()).apply("find_in_set(id,'" + ids + "')");
|
|
|
+ return priceBankMapper.selectList(lambdaQueryWrapper);
|
|
|
+ }
|
|
|
}
|