|
|
|
|
@ -134,7 +134,6 @@ public class ItemServiceImpl implements ItemService {
|
|
|
|
|
AlipayOpenAppItemCreateModel model = new AlipayOpenAppItemCreateModel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置平台类目
|
|
|
|
|
model.setCategoryId("C001684401");
|
|
|
|
|
// 设置商品名称由品牌、型号、电池规格、租赁类型、套餐名称拼接
|
|
|
|
|
@ -152,6 +151,7 @@ public class ItemServiceImpl implements ItemService {
|
|
|
|
|
rentRuleItemvo.setImage(imgStr);
|
|
|
|
|
// 设置商品模版类型
|
|
|
|
|
model.setItemType("2");
|
|
|
|
|
//sku_attrs
|
|
|
|
|
|
|
|
|
|
// 设置价格单元
|
|
|
|
|
model.setPriceUnit("元");
|
|
|
|
|
@ -189,123 +189,6 @@ public class ItemServiceImpl implements ItemService {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public OpenResponse<String> createStringRentItem(String param) {
|
|
|
|
|
return AlipayApiTemplate.execute(new AlipayApiCallback<String, AlipayOpenAppItemCreateResponse>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public AlipayOpenAppItemCreateResponse process() throws AlipayApiException {
|
|
|
|
|
|
|
|
|
|
// 构造请求参数以调用接口
|
|
|
|
|
AlipayOpenAppItemCreateRequest request = new AlipayOpenAppItemCreateRequest();
|
|
|
|
|
AlipayOpenAppItemCreateModel model = new AlipayOpenAppItemCreateModel();
|
|
|
|
|
|
|
|
|
|
// 设置商品模版类型
|
|
|
|
|
model.setItemType("2");
|
|
|
|
|
|
|
|
|
|
// 设置平台类目
|
|
|
|
|
model.setCategoryId("C001684401");
|
|
|
|
|
|
|
|
|
|
// 设置导购描述
|
|
|
|
|
model.setDesc("小刀B01_6050_日租套餐F");
|
|
|
|
|
|
|
|
|
|
// 设置商品主图
|
|
|
|
|
model.setHeadImg("A*FSHAQ5xsdMgAAAAAZ8AAAAgAeuN1AQ");
|
|
|
|
|
|
|
|
|
|
// 设置商家侧商品id
|
|
|
|
|
model.setOutItemId("dd202509020004");
|
|
|
|
|
model.setBusinessModel("0");
|
|
|
|
|
|
|
|
|
|
// // 设置商品详情页URL
|
|
|
|
|
model.setPath("alipays://platformapi/startapp?appId=2021004169641281&page=pages/home/main");
|
|
|
|
|
//model.setItemDetailsPageModel("1");
|
|
|
|
|
// 设置商品售卖状态
|
|
|
|
|
model.setSaleStatus("AVAILABLE");
|
|
|
|
|
|
|
|
|
|
// 设置sku数组
|
|
|
|
|
List<ItemSkuCreateVO> skus = new ArrayList<ItemSkuCreateVO>();
|
|
|
|
|
ItemSkuCreateVO skus0 = new ItemSkuCreateVO();
|
|
|
|
|
skus0.setOutSkuId("dd202509020004_sku");
|
|
|
|
|
skus0.setSaleStatus("AVAILABLE");
|
|
|
|
|
|
|
|
|
|
List<ItemSkuAttrVO> skuAttrs = new ArrayList<ItemSkuAttrVO>();
|
|
|
|
|
ItemSkuAttrVO skuAttrs0 = new ItemSkuAttrVO();
|
|
|
|
|
skuAttrs0.setAttrKey("rent_commodity");
|
|
|
|
|
skuAttrs0.setAttrValue("{\"name\":\"租完归还\",\"description\":\"套餐说明\",\"custom_lease\":\"1\",\"slope_formula\":\"DEFAULT_SLOPE_FORMULA\",\"durationUnit\":\"天\",\"buyoutPrice\":\"4\",\"priceUnit\":\"元\"}");
|
|
|
|
|
skuAttrs0.setAttrType("custom");
|
|
|
|
|
|
|
|
|
|
skuAttrs.add(skuAttrs0);
|
|
|
|
|
|
|
|
|
|
skus0.setOriginalPrice(100L);
|
|
|
|
|
skus0.setSalePrice("4");
|
|
|
|
|
skus0.setSkuAttrs(skuAttrs);
|
|
|
|
|
skus0.setStockNum("9999");
|
|
|
|
|
skus.add(skus0);
|
|
|
|
|
model.setSkus(skus);
|
|
|
|
|
|
|
|
|
|
List<AppItemAttrVO> attrs = new ArrayList<AppItemAttrVO>();
|
|
|
|
|
AppItemAttrVO attrs0 = new AppItemAttrVO();
|
|
|
|
|
attrs0.setAttrKey("lease_term_type");
|
|
|
|
|
attrs0.setAttrValue("短租");
|
|
|
|
|
|
|
|
|
|
AppItemAttrVO attrs1 = new AppItemAttrVO();
|
|
|
|
|
attrs1.setAttrKey("item_fineness");
|
|
|
|
|
attrs1.setAttrValue("wholeNew");
|
|
|
|
|
|
|
|
|
|
attrs.add(attrs0);
|
|
|
|
|
attrs.add(attrs1);
|
|
|
|
|
|
|
|
|
|
// 设置商品名称
|
|
|
|
|
model.setTitle("小刀B01_6050_日租套餐F");
|
|
|
|
|
request.setBizModel(model);
|
|
|
|
|
|
|
|
|
|
logger.info("属性列表:" + JSON.toJSONString(model));
|
|
|
|
|
return alipaySdkUtil.execute(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getData(AlipayOpenAppItemCreateResponse response) {
|
|
|
|
|
//rentRuleItemMapper.updateItemIdByOutItemId(response.getOutItemId(), response.getItemId());
|
|
|
|
|
return response.getItemId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getApiName() {
|
|
|
|
|
return "alipay.open.app.item.create";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public OpenResponse<String> stringRentItem(String param) {
|
|
|
|
|
return AlipayApiTemplate.execute(new AlipayApiCallback<String, AlipayOpenAppItemCreateResponse>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public AlipayOpenAppItemCreateResponse process() throws AlipayApiException {
|
|
|
|
|
|
|
|
|
|
AlipayOpenAppItemCreateModel itemCreateRequest = JSON.parseObject(param, AlipayOpenAppItemCreateModel.class);
|
|
|
|
|
|
|
|
|
|
// 构造请求参数以调用接口
|
|
|
|
|
AlipayOpenAppItemCreateRequest request = new AlipayOpenAppItemCreateRequest();
|
|
|
|
|
AlipayOpenAppItemCreateModel model = itemCreateRequest;
|
|
|
|
|
|
|
|
|
|
logger.info("属性列表:" + JSON.toJSONString(model));
|
|
|
|
|
request.setBizModel(model);
|
|
|
|
|
return alipaySdkUtil.execute(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getData(AlipayOpenAppItemCreateResponse response) {
|
|
|
|
|
//rentRuleItemMapper.updateItemIdByOutItemId(response.getOutItemId(), response.getItemId());
|
|
|
|
|
return response.getItemId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getApiName() {
|
|
|
|
|
return "alipay.open.app.item.create";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -605,13 +488,13 @@ public class ItemServiceImpl implements ItemService {
|
|
|
|
|
|
|
|
|
|
// 设置价格相关字段
|
|
|
|
|
Long rentalPriceInCents = param.getRentalPrice().multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
|
|
|
|
|
sku.setSalePrice(param.getRentalPrice().toString());
|
|
|
|
|
// 设置原价为租赁价格的1.2倍
|
|
|
|
|
Long originalPriceInCents = new BigDecimal(rentalPriceInCents)
|
|
|
|
|
.multiply(new BigDecimal("1.2"))
|
|
|
|
|
.setScale(0, BigDecimal.ROUND_HALF_UP)
|
|
|
|
|
.longValue();
|
|
|
|
|
sku.setOriginalPrice(originalPriceInCents);
|
|
|
|
|
// sku.setSalePrice(rentalPriceInCents.toString());
|
|
|
|
|
// // 设置原价为租赁价格的1.2倍
|
|
|
|
|
// Long originalPriceInCents = new BigDecimal(rentalPriceInCents)
|
|
|
|
|
// .multiply(new BigDecimal("1.2"))
|
|
|
|
|
// .setScale(0, BigDecimal.ROUND_HALF_UP)
|
|
|
|
|
// .longValue();
|
|
|
|
|
// sku.setOriginalPrice(originalPriceInCents);
|
|
|
|
|
|
|
|
|
|
// 设置库存
|
|
|
|
|
sku.setStockNum(String.valueOf(100L));
|
|
|
|
|
@ -638,14 +521,15 @@ public class ItemServiceImpl implements ItemService {
|
|
|
|
|
|
|
|
|
|
// 创建时段价格列表根据基础价格创建3个时段价格
|
|
|
|
|
List<RentCommodityConfig.DurationPrice> durationPriceList = new ArrayList<>();
|
|
|
|
|
RentCommodityConfig.DurationPrice durationPrice = new RentCommodityConfig.DurationPrice();
|
|
|
|
|
|
|
|
|
|
for(int i = 1; i < 4; i++){
|
|
|
|
|
RentCommodityConfig.DurationPrice durationPrice = new RentCommodityConfig.DurationPrice();
|
|
|
|
|
String val = i + "";
|
|
|
|
|
durationPrice.setDuration(val);
|
|
|
|
|
durationPrice.setTotalOriginalPrice(param.getRentalPrice()
|
|
|
|
|
durationPrice.setTotalSalePrice(param.getRentalPrice()
|
|
|
|
|
.multiply(new BigDecimal(val))
|
|
|
|
|
.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
|
|
durationPrice.setTotalSalePrice(new BigDecimal(originalPriceInCents)
|
|
|
|
|
durationPrice.setTotalOriginalPrice(param.getRentalPrice()
|
|
|
|
|
.multiply(new BigDecimal(val))
|
|
|
|
|
.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
|
|
durationPriceList.add(durationPrice);
|
|
|
|
|
|