Authored by Lixiaodi

修改bug

... ... @@ -45,7 +45,7 @@
select id, product_id, color_id, color_name, goods_name, color_image, is_default
from goods
where product_id in
<foreach item="item" index="index" collection="productIds" open="(" separator="," close=")">
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
... ...
... ... @@ -54,14 +54,9 @@
sale_time = #{saleTime,jdbcType=INTEGER},
min_price = #{minPrice,jdbcType=DECIMAL},
max_price = #{maxPrice,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
shelve_time = #{shelveTime,jdbcType=INTEGER},
edit_time = #{editTime,jdbcType=INTEGER},
shelve_status = #{shelveStatus,jdbcType=INTEGER},
storage = #{storage,jdbcType=INTEGER},
key_words = #{keyWords,jdbcType=VARCHAR},
del_status = #{delStatus,jdbcType=INTEGER}
update_time = unix_timestamp(),
edit_time = unix_timestamp(),
key_words = #{keyWords,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
... ... @@ -82,10 +77,10 @@
select id, product_name, product_code, max_sort_id, mid_sort_id, brand_id, series_id,
gender, sale_time, min_price, max_price, create_time, update_time, shelve_time, edit_time,
shelve_status, storage, key_words, del_status
from product where 1=1 and <include refid="pageCondition" /> order by product.id desc limit #{start},#{rows}
from product where 1=1 <include refid="pageCondition" /> order by product.id desc limit #{start},#{rows}
</select>
<select id="selectCount" resultMap="java.lang.Integer">
select count(*) from product where 1=1 and <include refid="pageCondition" />
<select id="selectCount" resultType="java.lang.Integer">
select count(*) from product where 1=1 <include refid="pageCondition" />
</select>
<sql id="pageCondition" >
... ... @@ -112,7 +107,7 @@
<select id="selectSkuPage" resultMap="BaseResultMap">
select distinct p.id from product p <include refid="skuPageCondition" /> order by p.id desc limit #{start},#{rows}
</select>
<select id="selectSkuCount" resultMap="java.lang.Integer">
<select id="selectSkuCount" resultType="java.lang.Integer">
select count(*) from (select distinct p.id from product p <include refid="skuPageCondition" /> ) sub
</select>
... ...
... ... @@ -55,7 +55,7 @@
</select>
<select id="selectMinPriceByProductIdList" resultMap="BaseResultMap">
select product_id, min(price) as price,
select product_id, min(price) as price
from storage_price where product_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
... ... @@ -78,7 +78,7 @@
<include refid="skupPageCondition" /> order by id desc limit #{start},#{rows}
</select>
<select id="selectCount" resultMap="BaseResultMap">
<select id="selectCount" resultType="java.lang.Integer">
select count(*)
from storage_price where storage_id = #{storageId}
<include refid="skupPageCondition" />
... ...
... ... @@ -73,14 +73,17 @@ public class ProductServiceImpl implements IProductService {
List<GoodsImages> goodsImagesList = getGoodsImagesFromBo(bo);
Integer productId;
Integer goodsId;
int now = (int) (System.currentTimeMillis() / 1000);
// 新增
if (bo.getId() == null || bo.getId() < 1) {
product.setShelveTime(0);
product.setEditTime(0);
product.setStorage(0);
if (productMapper.insert(product) == 0) {
return new ApiResponse<Void>(500, "创建商品失败");
}
productId = product.getId();
goods.setProductId(productId);
goodsMapper.insert(goods);
if (goodsMapper.insert(goods) == 0) {
return new ApiResponse<Void>(500, "创建商品颜色失败");
}
... ... @@ -98,6 +101,8 @@ public class ProductServiceImpl implements IProductService {
for (Storage s : storageList) {
s.setProductId(productId);
s.setGoodsId(goodsId);
s.setCreateTime(now);
s.setUpdateTime(0);
storageMapper.insert(s);
}
if (bo.getEditImage() != null && bo.getEditImage() == 1) {
... ... @@ -142,6 +147,7 @@ public class ProductServiceImpl implements IProductService {
private Goods getGoodsFromBo(ProductRequestBo bo) {
Goods g = new Goods();
BeanUtils.copyProperties(bo, g);
g.setId(bo.getGoodsId());
g.setIsDefault("Y");
if (CollectionUtils.isNotEmpty(bo.getImageUrlList())) {
g.setColorImage(bo.getImageUrlList().get(0));
... ... @@ -247,7 +253,8 @@ public class ProductServiceImpl implements IProductService {
ProductEditResponceBo bo = new ProductEditResponceBo();
BeanUtils.copyProperties(product, bo);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
bo.setSaleTime(sdf.format(product.getSaleTime() * 1000L));
bo.setSaleTime(sdf.format((product.getSaleTime() == null || product.getSaleTime() == 0) ? ""
: sdf.format(product.getSaleTime() * 1000L)));
bo.setGender(new Integer(product.getGender()));
bo.setMinPrice(product.getMinPrice().toString());
bo.setMaxPrice(product.getMaxPrice().toString());
... ... @@ -413,10 +420,10 @@ public static void main(String[] args) {
}
List<Storage> aStorageList = storageMap.get(goods.getId());
int countStock = 0;
if(CollectionUtils.isNotEmpty(aStorageList)) {
for(Storage s : aStorageList) {
countStock += s.getStorageNum();
}
respBo.setStorage(countStock);
List<ProductResponceBo> skuList = new ArrayList<>();
respBo.setSkuList(skuList);
//respBo
... ... @@ -433,6 +440,8 @@ public static void main(String[] args) {
skuList.add(skuBo);
}
}
respBo.setStorage(countStock);
}
}
PageResponseBO<ProductResponceBo> pageBo = new PageResponseBO<>(count, boList, bo.getPage(), bo.getRows());
return new ApiResponse<>(pageBo);
... ... @@ -461,7 +470,8 @@ public static void main(String[] args) {
b.setSellerUid(sp.getSellerUid());
b.setCurrentPrice(sp.getPrice().toString());
b.setStatus(sp.getStatus());
b.setSkupCreateTime(sdf.format(sp.getCreateTime() * 1000L));
b.setSkupCreateTime((sp.getCreateTime() == null || sp.getCreateTime() == 0) ? ""
: sdf.format(sp.getCreateTime() * 1000L));
boList.add(b);
});
}
... ...