批量发布商品+转派初版

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); goodsService.addGoods(goods);
return AjaxResult.success("新增成功"); return AjaxResult.success("新增成功");
}catch (Exception e){ }catch (Exception e){
e.printStackTrace();
logger.error(e.getMessage()); logger.error(e.getMessage());
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e)); return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
} }

View File

@ -108,6 +108,16 @@ public class OrderController extends BaseController {
od.setRevTime(new Date()); od.setRevTime(new Date());
orderDetailService.insertOrderDetail(od); 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 leaderTeamMoney = assignWorker.getLeaderTeamMoney();
String leaderTeamRate = assignWorker.getLeaderTeamRate(); String leaderTeamRate = assignWorker.getLeaderTeamRate();
// 派单师傅的钱 // 派单师傅的钱

View File

@ -1,6 +1,7 @@
package com.ghy.goods.mapper; package com.ghy.goods.mapper;
import com.ghy.goods.domain.GoodsArea; import com.ghy.goods.domain.GoodsArea;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -16,6 +17,6 @@ public interface GoodsAreaMapper {
* @param areas 区域集合id * @param areas 区域集合id
* @return 批量insert成功条数 * @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 商品图片信息 * @param goodsImgs 商品图片信息
* @return 成功条数 * @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.domain.GoodsStandard;
import com.ghy.goods.request.AppGoodsRequest; import com.ghy.goods.request.AppGoodsRequest;
import org.apache.ibatis.annotations.Param;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -34,7 +35,7 @@ public interface GoodsStandardMapper {
* @param goodsStandardList 批量添加商品规格 * @param goodsStandardList 批量添加商品规格
* @return 添加成功条数 * @return 添加成功条数
*/ */
int batchInsert(List<GoodsStandard> goodsStandardList); int batchInsert(@Param("goodsStandards") List<GoodsStandard> goodsStandardList);
/** /**
* @param request 校验的商品数量 * @param request 校验的商品数量

View File

@ -17,7 +17,7 @@ public interface GoodsImgsService {
* @param goodsImgs 商品图片信息 * @param goodsImgs 商品图片信息
* @return * @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.mapper.GoodsAreaMapper;
import com.ghy.goods.service.GoodsAreaService; import com.ghy.goods.service.GoodsAreaService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;

View File

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

View File

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

View File

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

View File

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