|
|
@@ -2,8 +2,14 @@ package org.springblade.mocha.feign;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.client.entity.CorpsDesc;
|
|
|
+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.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;
|
|
|
@@ -12,7 +18,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.logging.Logger;
|
|
|
|
|
|
@NonDS
|
|
|
@ApiIgnore()
|
|
|
@@ -21,6 +29,8 @@ import java.util.Date;
|
|
|
public class PriceBankClient implements IPriceBankClient{
|
|
|
|
|
|
private final PriceBankMapper priceBankMapper;
|
|
|
+ private final IGoodsDescClient goodsDescClient;
|
|
|
+ private final ICorpsDescClient corpsDescClient;
|
|
|
/**
|
|
|
*
|
|
|
* @param itemId 商品id
|
|
|
@@ -35,6 +45,10 @@ public class PriceBankClient implements IPriceBankClient{
|
|
|
* @param currency 币别
|
|
|
* @param coefficient FOB系数
|
|
|
* @param taxRate 税率
|
|
|
+ * @param dateTime 有效期结束
|
|
|
+ * @param purchaseAmount 采购金额
|
|
|
+ * @param priorityReferrer 是否重点推荐
|
|
|
+ * @param referrerReason 推荐理由
|
|
|
* * @return
|
|
|
* * 1.先根据商品id,商品规格,价格类型,租户id,供应商,贸易类型 查未删除的价格库数据
|
|
|
* * 2.查到后先执行将历史价格依次更新操作 未查到暂不执行更新操作
|
|
|
@@ -48,7 +62,19 @@ public class PriceBankClient implements IPriceBankClient{
|
|
|
BigDecimal greenback,
|
|
|
String currency,
|
|
|
BigDecimal coefficient,
|
|
|
- BigDecimal taxRate) {
|
|
|
+ BigDecimal taxRate,
|
|
|
+ String dateTime,
|
|
|
+ BigDecimal purchaseAmount,
|
|
|
+ Integer priorityReferrer,
|
|
|
+ String referrerReason) {
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ try {
|
|
|
+ date = sdf.parse(dateTime);
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println("转换日期出错");
|
|
|
+ }
|
|
|
int flag = 0;
|
|
|
LambdaQueryWrapper<PriceBank> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper.eq(PriceBank::getBillType,billType);
|
|
|
@@ -73,6 +99,42 @@ public class PriceBankClient implements IPriceBankClient{
|
|
|
bank.setUpdateUser(SecureUtil.getUserId());
|
|
|
bank.setUpdateTime(new Date());
|
|
|
flag = priceBankMapper.updateById(bank);
|
|
|
+ }else {
|
|
|
+ //获取商品信息
|
|
|
+ R<GoodsDescVO> goodsDesc = goodsDescClient.selectGoodsMessage(itemId);
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(corpId);
|
|
|
+ if (goodsDesc.isSuccess() && goodsDesc.getData() != null){
|
|
|
+ PriceBank bank = new PriceBank();
|
|
|
+ bank.setItemId(itemId);
|
|
|
+ bank.setCode(goodsDesc.getData().getCode());
|
|
|
+ bank.setCname(goodsDesc.getData().getCname());
|
|
|
+ bank.setSpecs(goodsDesc.getData().getTypeno());
|
|
|
+ bank.setCorpId(corpId);
|
|
|
+ bank.setCurrency(currency);
|
|
|
+ bank.setCoefficient(coefficient);
|
|
|
+ bank.setBillType(billType);
|
|
|
+ bank.setTradeType(tradeType);
|
|
|
+ bank.setEndTime(date);
|
|
|
+ bank.setPrice(price);
|
|
|
+ bank.setPriceTime(new Date());
|
|
|
+ bank.setExchangeRate(exchangeRate);
|
|
|
+ bank.setGreenback(greenback);
|
|
|
+ bank.setTaxRate(taxRate);
|
|
|
+ bank.setGoodTypeId(Long.valueOf(goodsDesc.getData().getGoodsTypeId()));
|
|
|
+ bank.setPurchaseAmount(purchaseAmount);
|
|
|
+ bank.setPriorityReferrer(priorityReferrer);
|
|
|
+ bank.setReferrerReason(referrerReason);
|
|
|
+ bank.setCreateUser(SecureUtil.getUserId());
|
|
|
+ bank.setCreateTime(new Date());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null){
|
|
|
+ bank.setCorpName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ GoodsType goodsType = goodsDescClient.goodTypeId(itemId);
|
|
|
+ if (goodsType != null){
|
|
|
+ bank.setGoodsTypeName(goodsType.getCname());
|
|
|
+ }
|
|
|
+ flag = priceBankMapper.insert(bank);
|
|
|
+ }
|
|
|
}
|
|
|
return flag;
|
|
|
}
|