基于mall4j产品的二开项目后端
lee
2024-12-18 921461a3f906d74403aeb6a27051deb77eca10fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.yami.shop.systemtest.data;
 
import com.yami.shop.bean.model.Product;
import com.yami.shop.bean.model.Sku;
import com.yami.shop.bean.param.ProductParam;
import com.yami.shop.systemtest.base.BaseTest;
import com.yami.shop.systemtest.constants.Constant;
import com.yami.shop.systemtest.util.HttpUtil;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 商品数据,为啥叫商品数据不叫商品测试呢,因为这个商品在订单里面都会用到
 *
 */
public class ProductData {
 
    public static Long getProduct(double price,double deliveryAmount) {
        String url = Constant.SHOP_URL + "/prod/prod";
        return HttpUtil.post(url, getProductParam(price, deliveryAmount), Long.class);
    }
 
 
    public static ProductParam getProductParam(double price,double deliveryAmount){
        ProductParam productParam = new ProductParam();
        productParam.setCategoryId(107L);
        productParam.setShopCategoryId(197L);
        productParam.setDeliveryAmount(deliveryAmount);
        productParam.setPrice(price);
        // 实体商品
        productParam.setMold(0);
        productParam.setProdName("接口测试商品");
        productParam.setProdNameCn("接口测试商品");
        productParam.setProdNameEn("en");
        productParam.setPic("/test.png");
        productParam.setImgs("/test.png");
        productParam.setOriPrice(0d);
 
        // 配送方式
        Product.DeliveryModeVO deliveryModeVO = new Product.DeliveryModeVO();
        deliveryModeVO.setHasShopDelivery(true);
        deliveryModeVO.setHasUserPickUp(true);
        deliveryModeVO.setHasCityDelivery(true);
        productParam.setDeliveryModeVo(deliveryModeVO);
 
        List<Sku> skuList = new ArrayList<>();
        Sku sku = new Sku();
        sku.setPrice(price);
        sku.setStocks(100);
        skuList.add(sku);
 
        productParam.setSkuList(skuList);
 
        return productParam;
    }
 
}