处理skus
This commit is contained in:
@ -70,15 +70,6 @@ public class ItemController {
|
|||||||
return itemService.createRentItem(request);
|
return itemService.createRentItem(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/rent/test/create")
|
|
||||||
public OpenResponse<String> rentTestCreate(@RequestBody String request) {
|
|
||||||
return itemService.createStringRentItem(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "/rent/string")
|
|
||||||
public OpenResponse<String> rentStringCreate(@RequestBody String request) {
|
|
||||||
return itemService.stringRentItem(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "/rent/modify")
|
@PostMapping(value = "/rent/modify")
|
||||||
public OpenResponse<String> modifyCreate(@RequestBody String request) {
|
public OpenResponse<String> modifyCreate(@RequestBody String request) {
|
||||||
|
|||||||
@ -25,8 +25,7 @@ public interface ItemService {
|
|||||||
* 创建租赁类(实物)商品
|
* 创建租赁类(实物)商品
|
||||||
*/
|
*/
|
||||||
OpenResponse<String> createRentItem(RentRuleItem param);
|
OpenResponse<String> createRentItem(RentRuleItem param);
|
||||||
OpenResponse<String> createStringRentItem(String param);
|
|
||||||
OpenResponse<String> stringRentItem(String param);
|
|
||||||
OpenResponse<String> modifyItem(String param);
|
OpenResponse<String> modifyItem(String param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -134,7 +134,6 @@ public class ItemServiceImpl implements ItemService {
|
|||||||
AlipayOpenAppItemCreateModel model = new AlipayOpenAppItemCreateModel();
|
AlipayOpenAppItemCreateModel model = new AlipayOpenAppItemCreateModel();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 设置平台类目
|
// 设置平台类目
|
||||||
model.setCategoryId("C001684401");
|
model.setCategoryId("C001684401");
|
||||||
// 设置商品名称由品牌、型号、电池规格、租赁类型、套餐名称拼接
|
// 设置商品名称由品牌、型号、电池规格、租赁类型、套餐名称拼接
|
||||||
@ -152,6 +151,7 @@ public class ItemServiceImpl implements ItemService {
|
|||||||
rentRuleItemvo.setImage(imgStr);
|
rentRuleItemvo.setImage(imgStr);
|
||||||
// 设置商品模版类型
|
// 设置商品模版类型
|
||||||
model.setItemType("2");
|
model.setItemType("2");
|
||||||
|
//sku_attrs
|
||||||
|
|
||||||
// 设置价格单元
|
// 设置价格单元
|
||||||
model.setPriceUnit("元");
|
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
|
@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();
|
Long rentalPriceInCents = param.getRentalPrice().multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
|
||||||
sku.setSalePrice(param.getRentalPrice().toString());
|
// sku.setSalePrice(rentalPriceInCents.toString());
|
||||||
// 设置原价为租赁价格的1.2倍
|
// // 设置原价为租赁价格的1.2倍
|
||||||
Long originalPriceInCents = new BigDecimal(rentalPriceInCents)
|
// Long originalPriceInCents = new BigDecimal(rentalPriceInCents)
|
||||||
.multiply(new BigDecimal("1.2"))
|
// .multiply(new BigDecimal("1.2"))
|
||||||
.setScale(0, BigDecimal.ROUND_HALF_UP)
|
// .setScale(0, BigDecimal.ROUND_HALF_UP)
|
||||||
.longValue();
|
// .longValue();
|
||||||
sku.setOriginalPrice(originalPriceInCents);
|
// sku.setOriginalPrice(originalPriceInCents);
|
||||||
|
|
||||||
// 设置库存
|
// 设置库存
|
||||||
sku.setStockNum(String.valueOf(100L));
|
sku.setStockNum(String.valueOf(100L));
|
||||||
@ -638,14 +521,15 @@ public class ItemServiceImpl implements ItemService {
|
|||||||
|
|
||||||
// 创建时段价格列表根据基础价格创建3个时段价格
|
// 创建时段价格列表根据基础价格创建3个时段价格
|
||||||
List<RentCommodityConfig.DurationPrice> durationPriceList = new ArrayList<>();
|
List<RentCommodityConfig.DurationPrice> durationPriceList = new ArrayList<>();
|
||||||
RentCommodityConfig.DurationPrice durationPrice = new RentCommodityConfig.DurationPrice();
|
|
||||||
for(int i = 1; i < 4; i++){
|
for(int i = 1; i < 4; i++){
|
||||||
|
RentCommodityConfig.DurationPrice durationPrice = new RentCommodityConfig.DurationPrice();
|
||||||
String val = i + "";
|
String val = i + "";
|
||||||
durationPrice.setDuration(val);
|
durationPrice.setDuration(val);
|
||||||
durationPrice.setTotalOriginalPrice(param.getRentalPrice()
|
durationPrice.setTotalSalePrice(param.getRentalPrice()
|
||||||
.multiply(new BigDecimal(val))
|
.multiply(new BigDecimal(val))
|
||||||
.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
|
.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
|
||||||
durationPrice.setTotalSalePrice(new BigDecimal(originalPriceInCents)
|
durationPrice.setTotalOriginalPrice(param.getRentalPrice()
|
||||||
.multiply(new BigDecimal(val))
|
.multiply(new BigDecimal(val))
|
||||||
.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
|
.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
|
||||||
durationPriceList.add(durationPrice);
|
durationPriceList.add(durationPrice);
|
||||||
|
|||||||
Reference in New Issue
Block a user