bless
This commit is contained in:
@ -11,6 +11,7 @@ import com.alipay.api.response.*;
|
||||
import com.sczx.pay.alipay.po.RentRuleItem;
|
||||
import com.sczx.pay.alipay.service.ImageUploadService;
|
||||
import com.sczx.pay.alipay.service.ItemService;
|
||||
import com.sczx.pay.alipay.vo.AppItemSkuAttrVo;
|
||||
import com.sczx.pay.alipay.vo.OpenResponse;
|
||||
import com.sczx.pay.mapper.RentRuleItemMapper;
|
||||
import com.sczx.pay.utils.AlipayApiCallback;
|
||||
@ -139,8 +140,13 @@ public class ItemServiceImpl implements ItemService {
|
||||
// 设置价格单元
|
||||
model.setPriceUnit("元");
|
||||
|
||||
//sku_attrs
|
||||
model.setSkus(getItemSkus(param, model.getImageList(), model.getItemType()));
|
||||
|
||||
// 设置属性列表
|
||||
model.setAttrs(getItemAttrs(param, model.getImageList(), model.getItemType()));
|
||||
|
||||
|
||||
logger.info("属性列表:" + JSON.toJSONString(model));
|
||||
request.setBizModel(model);
|
||||
return alipaySdkUtil.execute(request);
|
||||
@ -345,6 +351,9 @@ public class ItemServiceImpl implements ItemService {
|
||||
// 起租天数
|
||||
appItemAttrVO.setAttrValue("1");
|
||||
break;
|
||||
case "lease_term_type":
|
||||
appItemAttrVO.setAttrValue("短租");
|
||||
break;
|
||||
case "item_fineness":
|
||||
// 商品成色
|
||||
appItemAttrVO.setAttrValue("secondHand");
|
||||
@ -368,4 +377,44 @@ public class ItemServiceImpl implements ItemService {
|
||||
}
|
||||
return attrs;
|
||||
}
|
||||
private List<ItemSkuCreateVO> getItemSkus(RentRuleItem param, List<String> imageList, String itemType) throws AlipayApiException {
|
||||
List<ItemSkuCreateVO> itemSkus = new ArrayList<>();
|
||||
|
||||
ItemSkuCreateVO sku = new ItemSkuCreateVO();
|
||||
|
||||
// 设置商家侧SKU ID,需要全局唯一
|
||||
sku.setOutSkuId(param.getOutItemId() + "_sku"); // 示例:基于outItemId生成
|
||||
|
||||
// 设置售卖状态
|
||||
sku.setSaleStatus("AVAILABLE");
|
||||
|
||||
// 设置SKU类型为租赁
|
||||
sku.setSkuType("RENT");
|
||||
|
||||
// 设置价格相关字段
|
||||
Long rentalPriceInCents = param.getRentalPrice().multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
|
||||
sku.setSalePrice(param.getRentalPrice().toString());
|
||||
sku.setOriginalPrice(rentalPriceInCents);
|
||||
|
||||
// 设置库存
|
||||
sku.setStockNum(String.valueOf(100L));
|
||||
|
||||
// 设置价格单元
|
||||
sku.setPriceUnit("元/日");
|
||||
|
||||
// 设置销售属性
|
||||
List<AppItemSkuAttrVo> skuAttrs = new ArrayList<>();
|
||||
|
||||
// 添加租赁商品属性
|
||||
AppItemSkuAttrVo rentCommodityAttr = new AppItemSkuAttrVo();
|
||||
rentCommodityAttr.setAttrKey("rent_commodity");
|
||||
rentCommodityAttr.setAttrValue("----");
|
||||
rentCommodityAttr.setAttrType("custom"); // 根据实际情况设置
|
||||
skuAttrs.add(rentCommodityAttr);
|
||||
|
||||
|
||||
itemSkus.add(sku);
|
||||
return itemSkus;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
39
src/main/java/com/sczx/pay/alipay/vo/AppItemSkuAttrVo.java
Normal file
39
src/main/java/com/sczx/pay/alipay/vo/AppItemSkuAttrVo.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.sczx.pay.alipay.vo;
|
||||
|
||||
import com.alipay.api.AlipayObject;
|
||||
import com.alipay.api.internal.mapping.ApiField;
|
||||
|
||||
public class AppItemSkuAttrVo
|
||||
extends AlipayObject
|
||||
{
|
||||
private static final long serialVersionUID = 8193327886322884429L;
|
||||
@ApiField("attr_key")
|
||||
private String attrKey;
|
||||
@ApiField("attr_value")
|
||||
private String attrValue;
|
||||
|
||||
public String getAttrType() {
|
||||
return attrType;
|
||||
}
|
||||
|
||||
public void setAttrType(String attrType) {
|
||||
this.attrType = attrType;
|
||||
}
|
||||
|
||||
@ApiField("attr_type")
|
||||
private String attrType;
|
||||
|
||||
public String getAttrKey() {
|
||||
return this.attrKey;
|
||||
}
|
||||
public void setAttrKey(String attrKey) {
|
||||
this.attrKey = attrKey;
|
||||
}
|
||||
|
||||
public String getAttrValue() {
|
||||
return this.attrValue;
|
||||
}
|
||||
public void setAttrValue(String attrValue) {
|
||||
this.attrValue = attrValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user