提交 c7620757 authored 作者: zgy's avatar zgy

商品管理功能优化

上级 c1c2fc75
...@@ -211,4 +211,11 @@ public class TbCfStationItemController extends ApiBaseAction { ...@@ -211,4 +211,11 @@ public class TbCfStationItemController extends ApiBaseAction {
tbCfStationItemService.importShopifyProducts(multipartFile); tbCfStationItemService.importShopifyProducts(multipartFile);
return R.ok(); return R.ok();
} }
@RequestMapping("/queryCreator")
@ResponseBody
public R queryCreator() {
List<SysUserEntity> userList = tbCfStationItemService.queryCreator();
return R.ok().put("list", userList);
}
} }
package com.platform.controller.test;
import com.platform.utils.IdUtil;
/**
* @Auther: wudepeng
* @Date: 2020/04/08
* @Description:
*/
public class MainTest {
public static void main(String[] args) {
for (int i = 0; i <10 ; i++) {
Thread thread=new Thread(()->{
String uuid = IdUtil.createIdbyUUID();
System.out.println(uuid);
});
thread.start();
}
}
}
...@@ -5,11 +5,11 @@ import java.math.BigDecimal; ...@@ -5,11 +5,11 @@ import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
* 实体 * 商品规格表实体
* 表名 tb_cf_item_skus * 表名 tb_cf_item_skus
* *
* @author lipengjun * @author lipengjun
* @date 2019-12-26 20:47:21 * @date 2020-04-08 13:45:07
*/ */
public class TbCfItemSkusEntity implements Serializable { public class TbCfItemSkusEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -22,14 +22,18 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -22,14 +22,18 @@ public class TbCfItemSkusEntity implements Serializable {
* 商品ID * 商品ID
*/ */
private String itemId; private String itemId;
/**
* 数量
*/
private Integer skuCount;
/** /**
* 规格名称 * 规格名称
*/ */
private String skuName; private String skuName;
/**
* 商品规格图片
*/
private String skuImg;
/**
* 商品规格编码
*/
private String skuCode;
/** /**
* 规格描述 * 规格描述
*/ */
...@@ -42,6 +46,10 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -42,6 +46,10 @@ public class TbCfItemSkusEntity implements Serializable {
* 属性IDS * 属性IDS
*/ */
private String optionIds; private String optionIds;
/**
* 数量
*/
private Integer skuCount;
/** /**
* 排序号 * 排序号
*/ */
...@@ -72,7 +80,6 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -72,7 +80,6 @@ public class TbCfItemSkusEntity implements Serializable {
public String getId() { public String getId() {
return id; return id;
} }
/** /**
* 设置:商品ID * 设置:商品ID
*/ */
...@@ -86,7 +93,6 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -86,7 +93,6 @@ public class TbCfItemSkusEntity implements Serializable {
public String getItemId() { public String getItemId() {
return itemId; return itemId;
} }
/** /**
* 设置:规格名称 * 设置:规格名称
*/ */
...@@ -100,7 +106,32 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -100,7 +106,32 @@ public class TbCfItemSkusEntity implements Serializable {
public String getSkuName() { public String getSkuName() {
return skuName; return skuName;
} }
/**
* 设置:商品规格图片
*/
public void setSkuImg(String skuImg) {
this.skuImg = skuImg;
}
/**
* 获取:商品规格图片
*/
public String getSkuImg() {
return skuImg;
}
/**
* 设置:商品规格编码
*/
public void setSkuCode(String skuCode) {
this.skuCode = skuCode;
}
/**
* 获取:商品规格编码
*/
public String getSkuCode() {
return skuCode;
}
/** /**
* 设置:规格描述 * 设置:规格描述
*/ */
...@@ -114,7 +145,6 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -114,7 +145,6 @@ public class TbCfItemSkusEntity implements Serializable {
public String getSkuDesc() { public String getSkuDesc() {
return skuDesc; return skuDesc;
} }
/** /**
* 设置:价格 * 设置:价格
*/ */
...@@ -128,7 +158,6 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -128,7 +158,6 @@ public class TbCfItemSkusEntity implements Serializable {
public BigDecimal getSkuPrice() { public BigDecimal getSkuPrice() {
return skuPrice; return skuPrice;
} }
/** /**
* 设置:属性IDS * 设置:属性IDS
*/ */
...@@ -142,7 +171,6 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -142,7 +171,6 @@ public class TbCfItemSkusEntity implements Serializable {
public String getOptionIds() { public String getOptionIds() {
return optionIds; return optionIds;
} }
/** /**
* 设置:数量 * 设置:数量
*/ */
...@@ -156,7 +184,6 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -156,7 +184,6 @@ public class TbCfItemSkusEntity implements Serializable {
public Integer getSkuCount() { public Integer getSkuCount() {
return skuCount; return skuCount;
} }
/** /**
* 设置:排序号 * 设置:排序号
*/ */
...@@ -170,7 +197,6 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -170,7 +197,6 @@ public class TbCfItemSkusEntity implements Serializable {
public Integer getOrderNum() { public Integer getOrderNum() {
return orderNum; return orderNum;
} }
/** /**
* 设置:删除标记 * 设置:删除标记
*/ */
...@@ -184,7 +210,6 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -184,7 +210,6 @@ public class TbCfItemSkusEntity implements Serializable {
public Integer getDelFlag() { public Integer getDelFlag() {
return delFlag; return delFlag;
} }
/** /**
* 设置:创建时间 * 设置:创建时间
*/ */
...@@ -198,7 +223,6 @@ public class TbCfItemSkusEntity implements Serializable { ...@@ -198,7 +223,6 @@ public class TbCfItemSkusEntity implements Serializable {
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* 设置:更新时间 * 设置:更新时间
*/ */
......
...@@ -11,6 +11,15 @@ public class TbCfStationItemEntityExtends extends TbCfStationItemEntity implemen ...@@ -11,6 +11,15 @@ public class TbCfStationItemEntityExtends extends TbCfStationItemEntity implemen
private String goodtype; private String goodtype;
private String itemDesc; private String itemDesc;
private BigDecimal discountPrice; private BigDecimal discountPrice;
private String uname;
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
@Override @Override
public BigDecimal getDiscountPrice() { public BigDecimal getDiscountPrice() {
......
...@@ -2,6 +2,7 @@ package com.platform.service; ...@@ -2,6 +2,7 @@ package com.platform.service;
import com.platform.entity.ItemDescSkus; import com.platform.entity.ItemDescSkus;
import com.platform.entity.ItemInfo; import com.platform.entity.ItemInfo;
import com.platform.entity.SysUserEntity;
import com.platform.entity.TbCfStationItemEntity; import com.platform.entity.TbCfStationItemEntity;
import com.platform.utils.R; import com.platform.utils.R;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -96,4 +97,5 @@ public interface TbCfStationItemService { ...@@ -96,4 +97,5 @@ public interface TbCfStationItemService {
void importExcel(MultipartFile multipartFile); void importExcel(MultipartFile multipartFile);
R importShopifyProducts(MultipartFile multipartFile); R importShopifyProducts(MultipartFile multipartFile);
List<SysUserEntity> queryCreator();
} }
...@@ -46,6 +46,8 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService { ...@@ -46,6 +46,8 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
@Autowired @Autowired
private TbCfOptionDao tbCfOptionDao; private TbCfOptionDao tbCfOptionDao;
@Autowired
private SysUserDao sysUserDao;
@Override @Override
public ItemInfo queryItemInfoById(String itemId) { public ItemInfo queryItemInfoById(String itemId) {
//查询商品主体信息 //查询商品主体信息
...@@ -438,5 +440,10 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService { ...@@ -438,5 +440,10 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
return null; return null;
} }
@Override
public List<SysUserEntity> queryCreator() {
return sysUserDao.queryList(null);
}
} }
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="itemId" column="item_id"/> <result property="itemId" column="item_id"/>
<result property="skuName" column="sku_name"/> <result property="skuName" column="sku_name"/>
<result property="skuImg" column="sku_img"/>
<result property="skuCode" column="sku_code"/>
<result property="skuDesc" column="sku_desc"/> <result property="skuDesc" column="sku_desc"/>
<result property="skuPrice" column="sku_price"/> <result property="skuPrice" column="sku_price"/>
<result property="optionIds" column="option_ids"/> <result property="optionIds" column="option_ids"/>
...@@ -22,6 +24,8 @@ ...@@ -22,6 +24,8 @@
`id`, `id`,
`item_id`, `item_id`,
`sku_name`, `sku_name`,
`sku_img`,
`sku_code`,
`sku_desc`, `sku_desc`,
`sku_price`, `sku_price`,
`option_ids`, `option_ids`,
...@@ -39,6 +43,8 @@ ...@@ -39,6 +43,8 @@
`id`, `id`,
`item_id`, `item_id`,
`sku_name`, `sku_name`,
`sku_img`,
`sku_code`,
`sku_desc`, `sku_desc`,
`sku_price`, `sku_price`,
`option_ids`, `option_ids`,
...@@ -83,6 +89,8 @@ ...@@ -83,6 +89,8 @@
`id`, `id`,
`item_id`, `item_id`,
`sku_name`, `sku_name`,
`sku_img`,
`sku_code`,
`sku_desc`, `sku_desc`,
`sku_price`, `sku_price`,
`option_ids`, `option_ids`,
...@@ -95,6 +103,8 @@ ...@@ -95,6 +103,8 @@
#{id}, #{id},
#{itemId}, #{itemId},
#{skuName}, #{skuName},
#{skuImg},
#{skuCode},
#{skuDesc}, #{skuDesc},
#{skuPrice}, #{skuPrice},
#{optionIds}, #{optionIds},
...@@ -108,15 +118,17 @@ ...@@ -108,15 +118,17 @@
<update id="update" parameterType="com.platform.entity.TbCfItemSkusEntity"> <update id="update" parameterType="com.platform.entity.TbCfItemSkusEntity">
update tb_cf_item_skus update tb_cf_item_skus
<set> <set>
<if test="itemId != null">`item_id` = #{itemId},</if> <if test="itemId != null">`item_id` = #{itemId}, </if>
<if test="skuName != null">`sku_name` = #{skuName},</if> <if test="skuName != null">`sku_name` = #{skuName}, </if>
<if test="skuDesc != null">`sku_desc` = #{skuDesc},</if> <if test="skuImg != null">`sku_img` = #{skuImg}, </if>
<if test="skuPrice != null">`sku_price` = #{skuPrice},</if> <if test="skuCode != null">`sku_code` = #{skuCode}, </if>
<if test="optionIds != null">`option_ids` = #{optionIds},</if> <if test="skuDesc != null">`sku_desc` = #{skuDesc}, </if>
<if test="skuCount != null">`sku_count` = #{skuCount},</if> <if test="skuPrice != null">`sku_price` = #{skuPrice}, </if>
<if test="orderNum != null">`order_num` = #{orderNum},</if> <if test="optionIds != null">`option_ids` = #{optionIds}, </if>
<if test="delFlag != null">`del_flag` = #{delFlag},</if> <if test="skuCount != null">`sku_count` = #{skuCount}, </if>
<if test="createTime != null">`create_time` = #{createTime},</if> <if test="orderNum != null">`order_num` = #{orderNum}, </if>
<if test="delFlag != null">`del_flag` = #{delFlag}, </if>
<if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="updateTime != null">`update_time` = #{updateTime}</if> <if test="updateTime != null">`update_time` = #{updateTime}</if>
</set> </set>
where id = #{id} where id = #{id}
......
...@@ -130,13 +130,15 @@ ...@@ -130,13 +130,15 @@
i.creator, i.creator,
d.descripition_name dname, d.descripition_name dname,
t.goodstwotype_title title, t.goodstwotype_title title,
o.goodstype_title goodtype o.goodstype_title goodtype,
u.user_name uname
FROM FROM
tb_cf_station_item i tb_cf_station_item i
left JOIN tb_cf_goodstype o ON o.goodstype_id = i.item_category left JOIN tb_cf_goodstype o ON o.goodstype_id = i.item_category
left JOIN tb_cf_goodstwotype t ON i.item_categorytwo=t.goodstwotype_id left JOIN tb_cf_goodstwotype t ON i.item_categorytwo=t.goodstwotype_id
left JOIN tb_cf_descripiton d ON i.item_descrition_id=d.descripition_id left JOIN tb_cf_descripiton d ON i.item_descrition_id=d.descripition_id
left JOIN tb_cf_express_template e ON i.item_descrition_id = e.template_id left JOIN tb_cf_express_template e ON i.item_descrition_id = e.template_id
left join sys_user u on i.creator=u.user_id
WHERE 1=1 and i.enable_flag!=0 WHERE 1=1 and i.enable_flag!=0
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND item_name LIKE concat('%',#{name},'%') or item_id LIKE concat('%',#{name},'%') AND item_name LIKE concat('%',#{name},'%') or item_id LIKE concat('%',#{name},'%')
...@@ -156,6 +158,12 @@ ...@@ -156,6 +158,12 @@
<if test="typeThree != null and typeThree.trim() != ''"> <if test="typeThree != null and typeThree.trim() != ''">
AND item_descrition_id=#{typeThree} AND item_descrition_id=#{typeThree}
</if> </if>
<if test="supplier != null and supplier.trim() != ''">
AND supplier=#{supplier}
</if>
<if test="creator != null and creator.trim() != ''">
AND creator=#{creator}
</if>
<choose> <choose>
<when test="sidx != null and sidx.trim() != ''"> <when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order} order by ${sidx} ${order}
...@@ -203,6 +211,12 @@ ...@@ -203,6 +211,12 @@
<if test="typeThree != null and typeThree.trim() != ''"> <if test="typeThree != null and typeThree.trim() != ''">
AND item_descrition_id=#{typeThree} AND item_descrition_id=#{typeThree}
</if> </if>
<if test="supplier != null and supplier.trim() != ''">
AND supplier=#{supplier}
</if>
<if test="creator != null and creator.trim() != ''">
AND creator=#{creator}
</if>
</select> </select>
<insert id="save" parameterType="com.platform.entity.TbCfStationItemEntity"> <insert id="save" parameterType="com.platform.entity.TbCfStationItemEntity">
...@@ -269,7 +283,7 @@ ...@@ -269,7 +283,7 @@
<if test="itemCategory != null">`item_category` = #{itemCategory},</if> <if test="itemCategory != null">`item_category` = #{itemCategory},</if>
`item_price` = #{itemPrice}, `item_price` = #{itemPrice},
<if test="discountPrice != null">`discount_price` = #{discountPrice},</if> <if test="discountPrice != null">`discount_price` = #{discountPrice},</if>
<if test="costPrice != null">`cost_price` = #{costPrice}, </if> <if test="costPrice != null">`cost_price` = #{costPrice},</if>
<if test="itemUrl != null">`item_url` = #{itemUrl},</if> <if test="itemUrl != null">`item_url` = #{itemUrl},</if>
<if test="itemImg != null">`item_img` = #{itemImg},</if> <if test="itemImg != null">`item_img` = #{itemImg},</if>
<if test="itemTags != null">`item_tags` = #{itemTags},</if> <if test="itemTags != null">`item_tags` = #{itemTags},</if>
......
package test; //package test;
//
import org.junit.Test; //import org.junit.Test;
import org.junit.runner.RunWith; //import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration; //import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; //import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
//
import java.util.concurrent.*; //import java.util.concurrent.*;
//
/** ///**
* 并发测试 // * 并发测试
* // *
* @author 爱酱油不爱醋 // * @author 爱酱油不爱醋
* @version 1.0 // * @version 1.0
*/ // */
@RunWith(SpringJUnit4ClassRunner.class) //@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:/applicationContext-test.xml"}) //@ContextConfiguration(locations = {"classpath*:/applicationContext-test.xml"})
public class ConcurrencyApi { //public class ConcurrencyApi {
//
private final int corePoolSize = 15; // private final int corePoolSize = 15;
//
private final int maximumPoolSize = 35; // private final int maximumPoolSize = 35;
//
@Test // @Test
public void test() { // public void test() {
ExecutorService executor = Executors.newCachedThreadPool(); // ExecutorService executor = Executors.newCachedThreadPool();
int i = 0; // int i = 0;
while (true) { // while (true) {
RunningTest test = new RunningTest(i); // test.RunningTest test = new test.RunningTest(i);
executor.submit(test); // executor.submit(test);
System.out.println("正在执行的线程编号:" + i); // System.out.println("正在执行的线程编号:" + i);
i++; // i++;
} // }
//
} // }
//
//
} //}
package test; //package test;
//
import cn.hutool.core.lang.Console; //import cn.hutool.core.lang.Console;
import cn.hutool.core.util.IdUtil; //import cn.hutool.core.util.IdUtil;
import cn.hutool.http.HttpRequest; //import cn.hutool.http.HttpRequest;
import com.platform.controller.api.ProductExitException; //import com.platform.controller.api.ProductExitException;
import com.platform.dao.*; //import com.platform.dao.*;
import com.platform.entity.*; //import com.platform.entity.*;
import com.platform.utils.OssUtil; //import com.platform.utils.OssUtil;
import net.sf.json.JSONArray; //import net.sf.json.JSONArray;
import net.sf.json.JSONObject; //import net.sf.json.JSONObject;
import org.junit.Test; //import org.junit.Test;
import org.junit.runner.RunWith; //import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; //import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; //import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
//
import java.io.ByteArrayOutputStream; //import java.io.ByteArrayOutputStream;
import java.io.IOException; //import java.io.IOException;
import java.io.InputStream; //import java.io.InputStream;
import java.math.BigDecimal; //import java.math.BigDecimal;
import java.net.HttpURLConnection; //import java.net.HttpURLConnection;
import java.net.URL; //import java.net.URL;
import java.util.Arrays; //import java.util.Arrays;
import java.util.Date; //import java.util.Date;
import java.util.List; //import java.util.List;
//
/** ///**
* @author 爱酱油不爱醋 // * @author 爱酱油不爱醋
* @version 1.0 // * @version 1.0
*/ // */
@RunWith(SpringJUnit4ClassRunner.class) //@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:/applicationContext-test.xml"}) //@ContextConfiguration(locations = {"classpath*:/applicationContext-test.xml"})
public class TestApi { //public class TestApi {
//
@Autowired // @Autowired
private TbCfStationItemDao tbCfStationItemDao; // private TbCfStationItemDao tbCfStationItemDao;
@Autowired // @Autowired
private TbCfItemDescDao tbCfItemDescDao; // private TbCfItemDescDao tbCfItemDescDao;
@Autowired // @Autowired
private TbCfItemSkusDao tbCfItemSkusDao; // private TbCfItemSkusDao tbCfItemSkusDao;
@Autowired // @Autowired
private TbCfCategoryDao tbCfCategoryDao; // private TbCfCategoryDao tbCfCategoryDao;
@Autowired // @Autowired
private TbCfOptionDao tbCfOptionDao; // private TbCfOptionDao tbCfOptionDao;
@Autowired // @Autowired
private TbCfGoodstypeDao tbCfGoodstypeDao; // private TbCfGoodstypeDao tbCfGoodstypeDao;
@Autowired // @Autowired
private TbProductMissDao tbProductMissDao; // private TbProductMissDao tbProductMissDao;
@Autowired // @Autowired
private TbCategoryTemplateDao tbCategoryTemplateDao; // private TbCategoryTemplateDao tbCategoryTemplateDao;
@Autowired // @Autowired
private TbCfGoodstwotypeDao tbCfGoodstwotypeDao; // private TbCfGoodstwotypeDao tbCfGoodstwotypeDao;
@Autowired // @Autowired
private TbCfDescripitonDao tbCfDescripitonDao; // private TbCfDescripitonDao tbCfDescripitonDao;
//
/** // /**
* 接口数据版本号 // * 接口数据版本号
*/ // */
private final String VERSION = "2020-01"; // private final String VERSION = "2020-01";
/** // /**
* 接口路径 // * 接口路径
*/ // */
private final String API_URL = "https://mollykitty.myshopify.com/admin/api/" + VERSION + "/products.json"; // private final String API_URL = "https://mollykitty.myshopify.com/admin/api/" + VERSION + "/products.json";
//
@Test // @Test
public void host() { // public void host() {
String link = API_URL + "?limit=250&page_info=eyJwcm9kdWN0X3R5cGUiOiJXb21lbiIsImxhc3RfaWQiOjQ0OTc2Nzg5NTg2ODksImxhc3RfdmFsdWUiOiJDYXN1YWwgU2xpbSBTd2VhdGVycyIsImRpcmVjdGlvbiI6Im5leHQifQ"; // String link = API_URL + "?limit=250&page_info=eyJwcm9kdWN0X3R5cGUiOiJXb21lbiIsImxhc3RfaWQiOjQ0OTc2Nzg5NTg2ODksImxhc3RfdmFsdWUiOiJDYXN1YWwgU2xpbSBTd2VhdGVycyIsImRpcmVjdGlvbiI6Im5leHQifQ";
Console.error(link); // Console.error(link);
link = HttpRequest.get(link) // link = HttpRequest.get(link)
.header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=") // .header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=")
.execute().header("link") // .execute().header("link")
.split(",")[1]; // .split(",")[1];
Console.error(link); // Console.error(link);
link = link.substring(2, link.indexOf(">")); // link = link.substring(2, link.indexOf(">"));
Console.log("链接:" + link); // Console.log("链接:" + link);
} // }
//
/** // /**
* 测试分类的商品数量 // * 测试分类的商品数量
*/ // */
@Test // @Test
public void testCount() { // public void testCount() {
List<String> list = Arrays.asList("Men", "Women", "Children", "Afri Home", "Cosmetics", "Hair", "Sportswear", "Electronics"); // List<String> list = Arrays.asList("Men", "Women", "Children", "Afri Home", "Cosmetics", "Hair", "Sportswear", "Electronics");
for (String product_type : list) { // for (String product_type : list) {
String link = "https://mollykitty.myshopify.com/admin/api/" + VERSION + "/products/count.json" + "?&product_type=" + product_type; // String link = "https://mollykitty.myshopify.com/admin/api/" + VERSION + "/products/count.json" + "?&product_type=" + product_type;
System.out.println(link); // System.out.println(link);
link = HttpRequest.get(link) // link = HttpRequest.get(link)
.header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=") // .header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=")
.execute().body(); // .execute().body();
System.err.println(product_type + ":" + link); // System.err.println(product_type + ":" + link);
} // }
} // }
//
/** // /**
* 测试第一次连接时的返回 // * 测试第一次连接时的返回
*/ // */
@Test // @Test
public void getLink() { // public void getLink() {
String link = API_URL + "?&product_type=" + "Men" + "&limit=250"; // String link = API_URL + "?&product_type=" + "Men" + "&limit=250";
String headerLink = HttpRequest.get(link) // String headerLink = HttpRequest.get(link)
.header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=") // .header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=")
.execute().header("link"); // .execute().header("link");
headerLink = headerLink.split(";")[0].replaceAll("<", "").replaceAll(">", ""); // headerLink = headerLink.split(";")[0].replaceAll("<", "").replaceAll(">", "");
System.err.println(headerLink); // System.err.println(headerLink);
} // }
//
/** // /**
* 连接测试 // * 连接测试
*/ // */
@Test // @Test
public void linkTest() { // public void linkTest() {
String link = "https://mollykitty.myshopify.com/admin/api/2020-01/products.json?vendor=%E6%B3%B0%E9%82%A6%E6%9C%8D%E9%A5%B0&limit=100&vendor=戴菊"; // String link = "https://mollykitty.myshopify.com/admin/api/2020-01/products.json?vendor=%E6%B3%B0%E9%82%A6%E6%9C%8D%E9%A5%B0&limit=100&vendor=戴菊";
link = HttpRequest.get(link) // link = HttpRequest.get(link)
.header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=") // .header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=")
.execute().body(); // .execute().body();
//
JSONObject json = JSONObject.fromObject(link); // JSONObject json = JSONObject.fromObject(link);
JSONArray productArr = json.getJSONArray("products"); // JSONArray productArr = json.getJSONArray("products");
for (int j = 0; j < productArr.size(); j++) { // for (int j = 0; j < productArr.size(); j++) {
JSONObject product = productArr.getJSONObject(j); // JSONObject product = productArr.getJSONObject(j);
//
String tags = product.getString("tags"); // String tags = product.getString("tags");
String[] s = tags.split(","); // String[] s = tags.split(",");
if (s.length > 1) { // if (s.length > 1) {
for (String i : s) { // for (String i : s) {
if (i.contains("#")) { // if (i.contains("#")) {
System.out.println(i); // System.out.println(i);
String three = i.replaceAll("#", ""); // String three = i.replaceAll("#", "");
System.out.println(three); // System.out.println(three);
} // }
} // }
} else { // } else {
//
} // }
//
JSONArray variantsArr = product.getJSONArray("variants"); // JSONArray variantsArr = product.getJSONArray("variants");
for (int i = 0; i < variantsArr.size(); i++) { // for (int i = 0; i < variantsArr.size(); i++) {
JSONObject variantsObj = variantsArr.getJSONObject(i); // JSONObject variantsObj = variantsArr.getJSONObject(i);
String compare_at_price = variantsObj.getString("compare_at_price"); // String compare_at_price = variantsObj.getString("compare_at_price");
if (!"null".equals(compare_at_price)) { // if (!"null".equals(compare_at_price)) {
System.out.println(compare_at_price); // System.out.println(compare_at_price);
} // }
} // }
//
} // }
//
//
} // }
//
/** // /**
* 导入商品 // * 导入商品
*/ // */
@Test // @Test
public void test() { // public void test() {
String link = ""; // String link = "";
// 这个请求需要密钥,可以先拿着账号密码去浏览器请求一遍,F12 获取 token 复制粘贴即可 // // 这个请求需要密钥,可以先拿着账号密码去浏览器请求一遍,F12 获取 token 复制粘贴即可
String result = HttpRequest.get(link) // String result = HttpRequest.get(link)
.header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=") // .header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=")
.execute().body(); // .execute().body();
JSONObject jsonObject = JSONObject.fromObject(result); // JSONObject jsonObject = JSONObject.fromObject(result);
String headerLink = HttpRequest.get(link) // String headerLink = HttpRequest.get(link)
.header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=") // .header("Authorization", "Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA=")
.execute().header("link"); // .execute().header("link");
headerLink = headerLink.split(";")[0].replaceAll("<", "").replaceAll(">", ""); // headerLink = headerLink.split(";")[0].replaceAll("<", "").replaceAll(">", "");
} // }
//
/** // /**
* 通过URL获取网络图片 // * 通过URL获取网络图片
* 获取网络图片流 // * 获取网络图片流
* // *
* @param url 传入的 URL 必须是以 http:// 开头的,因为我们使用了 HttpURLConnection // * @param url 传入的 URL 必须是以 http:// 开头的,因为我们使用了 HttpURLConnection
* @return 输入流 // * @return 输入流
*/ // */
public static InputStream getImageStream(String url) { // public static InputStream getImageStream(String url) {
try { // try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); // HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setReadTimeout(5000); // connection.setReadTimeout(5000);
connection.setConnectTimeout(5000); // connection.setConnectTimeout(5000);
connection.setRequestMethod("GET"); // connection.setRequestMethod("GET");
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { // if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
return connection.getInputStream(); // return connection.getInputStream();
} // }
} catch (IOException e) { // } catch (IOException e) {
System.out.println("获取网络图片出现异常,图片路径为:" + url); // System.out.println("获取网络图片出现异常,图片路径为:" + url);
e.printStackTrace(); // e.printStackTrace();
} // }
return null; // return null;
} // }
//
/** // /**
* 将 InputStream 流转换为 byte[] // * 将 InputStream 流转换为 byte[]
* // *
* @param input InputStream // * @param input InputStream
* @return byte[] // * @return byte[]
* @throws IOException IO流异常 // * @throws IOException IO流异常
*/ // */
public static byte[] toByteArray(InputStream input) throws IOException { // public static byte[] toByteArray(InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream(); // ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[1024 * 4]; // byte[] buffer = new byte[1024 * 4];
int n = 0; // int n = 0;
while (-1 != (n = input.read(buffer))) { // while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n); // output.write(buffer, 0, n);
} // }
return output.toByteArray(); // return output.toByteArray();
} // }
//
//
} //}
...@@ -289,13 +289,29 @@ ...@@ -289,13 +289,29 @@
<i-input v-model="q.code" @on-enter="query" placeholder="商品编号" style="width:160px"> <i-input v-model="q.code" @on-enter="query" placeholder="商品编号" style="width:160px">
</i-input> </i-input>
</span> </span>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
<span> <span>
商品名称: 商品名称:
<i-input v-model="q.name" @on-enter="query" placeholder="商品名称" style="width:160px"> <i-input v-model="q.name" @on-enter="query" placeholder="商品名称" style="width:160px">
</i-input> </i-input>
</span> &nbsp;&nbsp;
<span>
供应商:
<i-input v-model="q.supplier" @on-enter="query" placeholder="供应商" style="width:160px">
</i-input>
</span> </span>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
<span>
创建人:
<i-select v-model="q.creator" @on-enter="query"
placeholder="创建人" style="width:160px">
<i-option v-for="(el,i) in creatorList" :key='i'
:value="el.userId">{{el.userName}}
</i-option>
</i-select>
</span>
&nbsp;&nbsp;&nbsp;
<span> <span>
一级分类: 一级分类:
<i-select v-model="q.itemCategory" @on-enter="query" <i-select v-model="q.itemCategory" @on-enter="query"
......
...@@ -19,7 +19,8 @@ $(function () { ...@@ -19,7 +19,8 @@ $(function () {
{label: '商品二级分类', name: 'title', index: 'title', width: 80}, {label: '商品二级分类', name: 'title', index: 'title', width: 80},
{label: '商品三级分类', name: 'dname', index: 'itemDescritionId', width: 80}, {label: '商品三级分类', name: 'dname', index: 'itemDescritionId', width: 80},
{label: '状态', name: 'enableFlag', index: 'enable_flag', width: 60, formatter: itemStatusFormat}, {label: '状态', name: 'enableFlag', index: 'enable_flag', width: 60, formatter: itemStatusFormat},
{label: '创建日期', name: 'createTime', index: 'create_time', width: 80} {label: '创建日期', name: 'createTime', index: 'create_time', width: 80},
{label: '创建人', name: 'uname', index: 'uname', width: 80}
] ]
}); });
}); });
...@@ -34,6 +35,8 @@ let vm = new Vue({ ...@@ -34,6 +35,8 @@ let vm = new Vue({
Goodstype: null, Goodstype: null,
Goodstype2: null, Goodstype2: null,
uploadList: [], uploadList: [],
uploadList1: [],
creatorList: [],
Goodstype3: null, Goodstype3: null,
handleCreateSelect: null, handleCreateSelect: null,
ruleValidate: { ruleValidate: {
...@@ -45,7 +48,9 @@ let vm = new Vue({ ...@@ -45,7 +48,9 @@ let vm = new Vue({
name: '', name: '',
code: '', code: '',
status: '', status: '',
itemCategory: '' supplier: '',
itemCategory: '',
creator:''
}, },
...@@ -144,7 +149,6 @@ let vm = new Vue({ ...@@ -144,7 +149,6 @@ let vm = new Vue({
this.$set(vm.tbCfStationItem, 'tree', this.attrItem) this.$set(vm.tbCfStationItem, 'tree', this.attrItem)
let _this = this let _this = this
vm.tbCfStationItem.itemImg = vm.uploadList.map(res => res).join(';'); vm.tbCfStationItem.itemImg = vm.uploadList.map(res => res).join(';');
;
vm.tbCfStationItem.itemDesc = encodeURI(UE.getEditor('itemDesc').getContent()); // 富文本取值 vm.tbCfStationItem.itemDesc = encodeURI(UE.getEditor('itemDesc').getContent()); // 富文本取值
vm.tbCfStationItem.itemDesc = vm.tbCfStationItem.itemDesc.replace(/&nbsp;/g, " "); vm.tbCfStationItem.itemDesc = vm.tbCfStationItem.itemDesc.replace(/&nbsp;/g, " ");
...@@ -288,7 +292,9 @@ let vm = new Vue({ ...@@ -288,7 +292,9 @@ let vm = new Vue({
'name': vm.q.name.trim(), 'name': vm.q.name.trim(),
'code': vm.q.code.trim(), 'code': vm.q.code.trim(),
'status': vm.q.status.trim(), 'status': vm.q.status.trim(),
'itemCategory': vm.q.itemCategory.trim() 'supplier': vm.q.supplier.trim(),
'itemCategory': vm.q.itemCategory.trim(),
'creator': vm.q.creator.trim(),
}, },
page: page page: page
}).trigger("reloadGrid"); }).trigger("reloadGrid");
...@@ -299,7 +305,9 @@ let vm = new Vue({ ...@@ -299,7 +305,9 @@ let vm = new Vue({
name: '', name: '',
code: '', code: '',
status: '', status: '',
itemCategory: '' supplier: '',
itemCategory: '',
creator: ''
}; };
vm.reload(); vm.reload();
}, },
...@@ -600,9 +608,12 @@ let vm = new Vue({ ...@@ -600,9 +608,12 @@ let vm = new Vue({
} }
$.get('../tbcfgoodstype/queryAll', res => { $.get('../tbcfgoodstype/queryAll', res => {
this.Goodstype = res.list; this.Goodstype = res.list;
console.log('一级分类', this.Goodstype)
}) })
$.get('../tbcfstationitem/queryCreator', res => {
let parse = JSON.parse(res);
this.creatorList = parse.list;
console.log('用户', this.creatorList)
})
//获取默认规格 //获取默认规格
$.get('../tbcategorytemplate/queryAll', res => { $.get('../tbcategorytemplate/queryAll', res => {
let _res = JSON.parse(res) let _res = JSON.parse(res)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论