批量发布商品+转派初版

This commit is contained in:
kuang.yifei@iwhalecloud.com 2022-05-31 23:27:30 +08:00
parent 24a4872ccf
commit ca4773db99
11 changed files with 90 additions and 87 deletions

View File

@ -68,6 +68,7 @@ public class GoodsController extends BaseController {
goodsService.addGoods(goods);
return AjaxResult.success("新增成功");
}catch (Exception e){
e.printStackTrace();
logger.error(e.getMessage());
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
}

View File

@ -108,6 +108,16 @@ public class OrderController extends BaseController {
od.setRevTime(new Date());
orderDetailService.insertOrderDetail(od);
// 批量生成订单商品
request.getGoodsList().forEach(goods->{
OrderGoods orderGoods = new OrderGoods();
orderGoods.setGoodsId(goods.getGoodsStandardId());
orderGoods.setGoodsNum(goods.getNum());
orderGoods.setOrderId(od.getId());
orderGoods.setServerGoodsNum(0);
orderGoodsService.insertOrderGoods(orderGoods);
});
String leaderTeamMoney = assignWorker.getLeaderTeamMoney();
String leaderTeamRate = assignWorker.getLeaderTeamRate();
// 派单师傅的钱

View File

@ -1,6 +1,7 @@
package com.ghy.goods.mapper;
import com.ghy.goods.domain.GoodsArea;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -16,6 +17,6 @@ public interface GoodsAreaMapper {
* @param areas 区域集合id
* @return 批量insert成功条数
*/
int batchInsert(List<GoodsArea> areas);
int batchInsert(@Param("areas") List<GoodsArea> areas);
}

View File

@ -18,7 +18,7 @@ public interface GoodsImgsMapper {
* @param goodsImgs 商品图片信息
* @return 成功条数
*/
int batchInsert(Collection<GoodsImgs> goodsImgs);
int batchInsert(@Param("goodsImgs") List<GoodsImgs> goodsImgs);
/**
* 批量修改商品图片

View File

@ -2,6 +2,7 @@ package com.ghy.goods.mapper;
import com.ghy.goods.domain.GoodsStandard;
import com.ghy.goods.request.AppGoodsRequest;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
@ -34,7 +35,7 @@ public interface GoodsStandardMapper {
* @param goodsStandardList 批量添加商品规格
* @return 添加成功条数
*/
int batchInsert(List<GoodsStandard> goodsStandardList);
int batchInsert(@Param("goodsStandards") List<GoodsStandard> goodsStandardList);
/**
* @param request 校验的商品数量

View File

@ -17,7 +17,7 @@ public interface GoodsImgsService {
* @param goodsImgs 商品图片信息
* @return
*/
int batchInsert(Collection<GoodsImgs> goodsImgs);
int batchInsert(List<GoodsImgs> goodsImgs);
/**
* 批量编辑商品图片信息

View File

@ -4,6 +4,7 @@ import com.ghy.goods.domain.GoodsArea;
import com.ghy.goods.mapper.GoodsAreaMapper;
import com.ghy.goods.service.GoodsAreaService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

View File

@ -23,8 +23,7 @@ public class GoodsImgsServiceImpl implements GoodsImgsService {
GoodsImgsMapper goodsImgsMapper;
@Override
public int batchInsert(Collection<GoodsImgs> goodsImgs) {
if (CollectionUtils.isEmpty(goodsImgs)) return 0;
public int batchInsert(List<GoodsImgs> goodsImgs) {
return goodsImgsMapper.batchInsert(goodsImgs);
}

View File

@ -24,18 +24,11 @@
</where>
</select>
<insert id="batchInsert" parameterType="com.ghy.goods.domain.GoodsArea" useGeneratedKeys="true" keyProperty="goodsAreaId">
<foreach collection="array" item="areas">
INSERT INTO goods_imgs(
<if test="goodsImgsId != null and goodsImgsId != 0">goods_imgs_id,</if>
<if test="goodsId != null and goodsId != 0">goods_id,</if>
<if test="imgUrl != null and imgUrl != ''">img_url</if>
)
VALUES(
<if test="goodsImgsId != null and goodsImgsId != 0">#{goodsImgsId},</if>
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
<if test="imgUrl != null and imgUrl != ''">#{imgUrl}</if>
);
<insert id="batchInsert" parameterType="list" >
INSERT INTO goods_area ( goods_id,country_area_id)
VALUES
<foreach collection="areas" item="area">
(#{area.goodsId},#{area.countryAreaId})
</foreach>
</insert>

View File

@ -3,10 +3,10 @@
<mapper namespace="com.ghy.goods.mapper.GoodsImgsMapper">
<resultMap id="GoodsImgsResult" type="com.ghy.goods.domain.GoodsImgs">
<result property="goodsImgsId" column="goods_imgs_id" />
<result property="goodsId" column="goods_id" />
<result property="imgUrl" column="img_url" />
<result property="imgType" column="img_type" />
<result property="goodsImgsId" column="goods_imgs_id"/>
<result property="goodsId" column="goods_id"/>
<result property="imgUrl" column="img_url"/>
<result property="imgType" column="img_type"/>
</resultMap>
<sql id="selectGoodsImgs">
@ -22,7 +22,9 @@
</delete>
<delete id="deleteByGoodsId">
DELETE FROM goods_imgs WHERE goods_id = #{goodsId}
DELETE
FROM goods_imgs
WHERE goods_id = #{goodsId}
</delete>
<select id="selectByGoodsId" resultMap="GoodsImgsResult">
@ -34,22 +36,25 @@
</where>
</select>
<insert id="batchInsert" parameterType="com.ghy.goods.domain.GoodsImgs" useGeneratedKeys="true" keyProperty="goodsImgsId">
<foreach collection="array" item="goodsImgs">
INSERT INTO goods_imgs(
<if test="goodsImgsId != null and goodsImgsId != 0">goods_imgs_id,</if>
<if test="goodsId != null and goodsId != 0">goods_id,</if>
<if test="imgUrl != null and imgUrl != ''">img_url,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time)
VALUES(
<if test="goodsImgsId != null and goodsImgsId != 0">#{goodsImgsId},</if>
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
<if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate());
<insert id="batchInsert" parameterType="list">
INSERT INTO
goods_imgs
(
goods_id,
img_url,
remark,
create_by,
create_time
)
VALUES
<foreach collection="goodsImgs" item="goodsImg">
(
#{goodsImg.goodsId},
#{goodsImg.imgUrl},
#{goodsImg.remark},
#{goodsImg.createBy},
sysdate()
)
</foreach>
</insert>

View File

@ -3,31 +3,43 @@
<mapper namespace="com.ghy.goods.mapper.GoodsStandardMapper">
<resultMap id="GoodsStandardResult" type="com.ghy.goods.domain.GoodsStandard">
<result property="goodsStandardId" column="goods_standard_id" />
<result property="goodsStandardName" column="goods_standard_name"/>
<result property="goodsId" column="goods_id" />
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
<result property="goodsPrice" column="goods_price"/>
<result property="discountPrice" column="discount_price"/>
<result property="groupPrice" column="group_price"/>
<result property="goodsNum" column="goods_num"/>
<result property="saleNum" column="sale_num"/>
<result property="status" column="status"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="goodsStandardId" column="goods_standard_id"/>
<result property="goodsStandardName" column="goods_standard_name"/>
<result property="goodsId" column="goods_id"/>
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
<result property="goodsPrice" column="goods_price"/>
<result property="discountPrice" column="discount_price"/>
<result property="groupPrice" column="group_price"/>
<result property="goodsNum" column="goods_num"/>
<result property="saleNum" column="sale_num"/>
<result property="status" column="status"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectGoodsStandard">
SELECT goods_standard_id, goods_standard_name, goods_id, dept_goods_category_id, goods_price,
discount_price, group_price, goods_num, create_by, create_time, sale_num, status, update_by, update_time,
SELECT goods_standard_id,
goods_standard_name,
goods_id,
dept_goods_category_id,
goods_price,
discount_price,
group_price,
goods_num,
create_by,
create_time,
sale_num,
status,
update_by,
update_time,
remark
FROM goods_standard
</sql>
<select id="selectById" resultMap="GoodsStandardResult">
<include refid="selectGoodsStandard"/>
<where>
@ -54,39 +66,19 @@
</where>
</select>
<insert id="batchInsert" parameterType="com.ghy.goods.domain.GoodsStandard" useGeneratedKeys="true" keyProperty="goodsStandardId">
<foreach collection="array" item="goodsStandardList">
INSERT INTO goods_standard(
<if test="goodsStandardName != null and goodsStandardName != 0">goods_standard_name,</if>
<if test="goodsId != null and goodsId != 0">goods_id,</if>
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">dept_goods_category_id</if>
<if test="goodsPrice != null and goodsPrice != 0">goods_price,</if>
<if test="discountPrice != null and discountPrice != 0">discount_price,</if>
<if test="groupPrice != null and groupPrice != 0">group_price,</if>
<if test="goodsNum != null and goodsNum != 0">goods_num,</if>
<if test="saleNum != null and saleNum != 0">sale_num,</if>
<if test="status != null and status != 0">status,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
<insert id="batchInsert" parameterType="list">
INSERT INTO goods_standard (
goods_standard_name, goods_id, dept_goods_category_id, goods_price, discount_price, group_price, goods_num,
sale_num, status, remark, create_by, create_time )
VALUES
<foreach collection="goodsStandards" item="goodsStandard">
(
#{goodsStandard.goodsStandardName}, #{goodsStandard.goodsId}, #{goodsStandard.deptGoodsCategoryId}, #{goodsStandard.goodsPrice}, #{goodsStandard.discountPrice},
#{goodsStandard.groupPrice}, #{goodsStandard.goodsNum}, #{goodsStandard.saleNum}, #{goodsStandard.status}, #{goodsStandard.remark}, #{goodsStandard.createBy}, sysdate()
)
VALUES(
<if test="goodsStandardName != null and goodsStandardName != 0">#{goodsStandardName},</if>
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">#{deptGoodsCategoryId}</if>
<if test="goodsPrice != null and goodsPrice != 0">#{goodsPrice},</if>
<if test="discountPrice != null and discountPrice != 0">#{discountPrice},</if>
<if test="groupPrice != null and groupPrice != 0">#{groupPrice},</if>
<if test="goodsNum != null and goodsNum != 0">#{goodsNum},</if>
<if test="saleNum != null and saleNum != 0">#{saleNum},</if>
<if test="status != null">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
);
</foreach>
</insert>
<select id="checkStore" resultMap="GoodsStandardResult">
<include refid="selectGoodsStandard"/>
where goods_standard_id = #{goodsStandardId}