30 changed files with 835 additions and 59 deletions
@ -0,0 +1,34 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbag; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:06 |
||||
|
*/ |
||||
|
@ApiModel(value = "礼包信息", description = "礼包信息") |
||||
|
@TableName("applet_giftbag") |
||||
|
@Data |
||||
|
public class AppletGiftBag { |
||||
|
private String id; |
||||
|
private String sid = UUID.randomUUID().toString(); |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
private String remarks; |
||||
|
private String isEnable; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date dateStart; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date dateEnd; |
||||
|
private String name; |
||||
|
private String price; |
||||
|
private String iconUrl; |
||||
|
private String isGrounding; |
||||
|
private String isRecommend; |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbag; |
||||
|
|
||||
|
import com.yxt.common.core.dto.Dto; |
||||
|
import com.yxt.yyth.api.appletgiftbag.GiftBagGoods; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:13 |
||||
|
*/ |
||||
|
@ApiModel(value = "礼包信息 数据传输对象", description = "礼包信息 数据传输对象") |
||||
|
@Data |
||||
|
public class AppletGiftBagDto implements Dto { |
||||
|
|
||||
|
private String sid; |
||||
|
private String remarks; |
||||
|
private String dateStart; |
||||
|
private String dateEnd; |
||||
|
private String name; |
||||
|
private String price; |
||||
|
private String iconUrl; |
||||
|
private String isGrounding; |
||||
|
private String isRecommend; |
||||
|
//商品sid
|
||||
|
private List<GiftBagGoods> goods = new ArrayList<>(); |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbag; |
||||
|
|
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import com.yxt.yyth.api.appletgiftbag.GiftBagGoods; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author Administrator |
||||
|
* @description |
||||
|
* @date 2023/11/22 11:15 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class AppletGiftBagInitVo implements Vo { |
||||
|
private String sid; |
||||
|
private String remarks; |
||||
|
private String dateStart; |
||||
|
private String dateEnd; |
||||
|
private String name; |
||||
|
private String price; |
||||
|
private String iconUrl; |
||||
|
private String isRecommend; |
||||
|
//商品sid
|
||||
|
private List<GiftBagGoods> goods = new ArrayList<>(); |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbag; |
||||
|
|
||||
|
import com.yxt.common.core.query.Query; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:31 |
||||
|
*/ |
||||
|
@ApiModel(value = "礼包信息 查询条件", description = "礼包信息 查询条件") |
||||
|
@Data |
||||
|
public class AppletGiftBagQuery implements Query { |
||||
|
private String name; |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbag; |
||||
|
|
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:12 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ApiModel(value = "礼包信息 视图数据对象", description = "礼包信息 视图数据对象") |
||||
|
@NoArgsConstructor |
||||
|
public class AppletGiftBagVo implements Vo { |
||||
|
private String sid; |
||||
|
private String name; |
||||
|
private String dateStart; |
||||
|
private String dateEnd; |
||||
|
private String boundary; |
||||
|
private String boundaryPrice; |
||||
|
private String iconUrl; |
||||
|
private String isEnable; |
||||
|
private String isGrounding; |
||||
|
private String isRecommend; |
||||
|
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbag; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author Administrator |
||||
|
* @description |
||||
|
* @date 2023/11/22 11:08 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class GiftBagGoods { |
||||
|
private String goodsSid; |
||||
|
private String goodsNumber; |
||||
|
private String name; //商品名
|
||||
|
private String unitName; //单位
|
||||
|
private String price; //商品单价
|
||||
|
// private String price; //商品单价
|
||||
|
// private String price; //商品单价
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbaggoods; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:06 |
||||
|
*/ |
||||
|
@ApiModel(value = "礼包包含商品信息", description = "礼包包含商品信息") |
||||
|
@TableName("applet_giftbag_goods") |
||||
|
@Data |
||||
|
public class AppletGiftBagGoods { |
||||
|
private String id; |
||||
|
private String sid = UUID.randomUUID().toString(); |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
private String remarks; |
||||
|
private String giftbagSid; |
||||
|
private String goodsSid; |
||||
|
private String goodsNumber; |
||||
|
// private String isGrounding;
|
||||
|
private double price; |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbaggoods; |
||||
|
|
||||
|
import com.yxt.common.core.dto.Dto; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:13 |
||||
|
*/ |
||||
|
@ApiModel(value = "礼包包含商品信息 数据传输对象", description = "礼包包含商品信息 数据传输对象") |
||||
|
@Data |
||||
|
public class AppletGiftBagGoodsDto implements Dto { |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbaggoods; |
||||
|
|
||||
|
import com.yxt.common.core.query.Query; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:31 |
||||
|
*/ |
||||
|
@ApiModel(value = "礼包包含商品信息 查询条件", description = "礼包包含商品信息 查询条件") |
||||
|
@Data |
||||
|
public class AppletGiftBagGoodsQuery implements Query { |
||||
|
|
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package com.yxt.yyth.api.appletgiftbaggoods; |
||||
|
|
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:12 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ApiModel(value = "礼包包含商品信息 视图数据对象", description = "礼包包含商品信息 视图数据对象") |
||||
|
@NoArgsConstructor |
||||
|
public class AppletGiftBagGoodsVo implements Vo { |
||||
|
private String goodsName; |
||||
|
private double goodsNumber; |
||||
|
private String picUrl; |
||||
|
private String goodsSid; |
||||
|
private String price; |
||||
|
private String unitName; |
||||
|
private String remarks; |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.yxt.yyth.biz.appletgiftbag; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
|
import com.yxt.yyth.api.appletgiftbag.AppletGiftBag; |
||||
|
import com.yxt.yyth.api.appletgiftbag.AppletGiftBagVo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:03 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface AppletGiftBagMapper extends BaseMapper<AppletGiftBag> { |
||||
|
|
||||
|
|
||||
|
IPage<AppletGiftBagVo> giftBagListPage(IPage<AppletGiftBag> page, @Param(Constants.WRAPPER) QueryWrapper<AppletGiftBag> qw); |
||||
|
List<AppletGiftBagVo> giftBagList(); |
||||
|
|
||||
|
int saveBags(@Param("bags") List<AppletGiftBag> bags); |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.yxt.yyth.biz.appletgiftbag.AppletGiftBagMapper"> |
||||
|
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
|
<!-- ${ew.customSqlSegment} --> |
||||
|
|
||||
|
<insert id="saveBags" parameterType="java.util.List"> |
||||
|
insert into lpk_giftbag(sid,createTime,`name`,dateStart,dateEnd) |
||||
|
values |
||||
|
<foreach collection="bags" item="item" index="index" separator=","> |
||||
|
(#{item.sid},#{item.createTime},#{item.name},#{item.dateStart},#{item.dateEnd}) |
||||
|
</foreach> |
||||
|
</insert> |
||||
|
|
||||
|
<select id="giftBagListPage" resultType="com.yxt.yyth.api.appletgiftbag.AppletGiftBagVo"> |
||||
|
select |
||||
|
sid, |
||||
|
`name`, |
||||
|
date_format(dateStart, '%Y-%m-%d') as dateStart, |
||||
|
date_format(dateEnd, '%Y-%m-%d') as dateEnd, |
||||
|
price, |
||||
|
iconUrl, |
||||
|
isEnable, |
||||
|
isGrounding, |
||||
|
isRecommend |
||||
|
from lpk_giftbag |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
<select id="giftBagList" resultType="com.yxt.yyth.api.appletgiftbag.AppletGiftBagVo"> |
||||
|
select |
||||
|
* |
||||
|
from lpk_giftbag |
||||
|
where isGrounding=1 |
||||
|
</select> |
||||
|
</mapper> |
@ -0,0 +1,61 @@ |
|||||
|
package com.yxt.yyth.biz.appletgiftbag; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.yyth.api.appletgiftbag.AppletGiftBagDto; |
||||
|
import com.yxt.yyth.api.appletgiftbag.AppletGiftBagQuery; |
||||
|
import com.yxt.yyth.api.appletgiftbag.AppletGiftBagVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:03 |
||||
|
*/ |
||||
|
|
||||
|
@Api(tags = "小程序礼包信息") |
||||
|
@RestController |
||||
|
@RequestMapping("appletgiftbag") |
||||
|
public class AppletGiftBagRest { |
||||
|
|
||||
|
@Autowired |
||||
|
AppletGiftBagService AppletGiftBagService; |
||||
|
|
||||
|
|
||||
|
@ApiOperation("礼包信息列表") |
||||
|
@PostMapping("/giftBagListPage") |
||||
|
public ResultBean<PagerVo<AppletGiftBagVo>> giftBagListPage(@RequestBody PagerQuery<AppletGiftBagQuery> pq) { |
||||
|
return AppletGiftBagService.giftBagListPage(pq); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("保存修改") |
||||
|
@PostMapping("/saveGiftBag") |
||||
|
public ResultBean<String> saveGiftBag(@RequestBody AppletGiftBagDto dto) { |
||||
|
return AppletGiftBagService.saveGiftBag(dto); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("礼包初始化") |
||||
|
@GetMapping("/giftBagInit/{sid}") |
||||
|
public ResultBean giftBagInit(@PathVariable String sid) { |
||||
|
return AppletGiftBagService.giftBagInit(sid); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("删除礼包") |
||||
|
@DeleteMapping("/deleteBag/{sid}") |
||||
|
public ResultBean deleteBag(@PathVariable("sid") String sid) { |
||||
|
return AppletGiftBagService.deleteBag(sid); |
||||
|
} |
||||
|
@ApiOperation("礼包信息列表") |
||||
|
@GetMapping("/giftBagList") |
||||
|
public ResultBean giftBagList() { |
||||
|
return AppletGiftBagService.giftBagList(); |
||||
|
} |
||||
|
@GetMapping("/isGrounding/{sid}/{state}") |
||||
|
@ApiOperation(value = "设置是否上下架") |
||||
|
public ResultBean isGrounding(@PathVariable("sid")String sid,@PathVariable("state") String state) { |
||||
|
return AppletGiftBagService.isGrounding(sid, state); |
||||
|
} |
||||
|
} |
@ -0,0 +1,195 @@ |
|||||
|
package com.yxt.yyth.biz.appletgiftbag; |
||||
|
|
||||
|
import cn.hutool.core.bean.BeanUtil; |
||||
|
import cn.hutool.core.date.DateTime; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.yxt.common.base.config.component.FileUploadComponent; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.base.utils.PagerUtil; |
||||
|
import com.yxt.common.base.utils.StringUtils; |
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.yyth.api.appletgiftbag.*; |
||||
|
import com.yxt.yyth.api.appletgiftbaggoods.AppletGiftBagGoods; |
||||
|
import com.yxt.yyth.api.appletgiftbag.GiftBagGoods; |
||||
|
import com.yxt.yyth.api.lpkgoods.LpkGoods; |
||||
|
import com.yxt.yyth.biz.appletgiftbaggoods.AppletGiftBagGoodsService; |
||||
|
import com.yxt.yyth.biz.lpkgoods.LpkGoodsService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Collections; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:03 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class AppletGiftBagService extends MybatisBaseService<AppletGiftBagMapper, AppletGiftBag> { |
||||
|
|
||||
|
@Autowired |
||||
|
private FileUploadComponent fileUploadComponent; |
||||
|
@Autowired |
||||
|
private AppletGiftBagGoodsService appletGiftBagGoodsService; |
||||
|
@Autowired |
||||
|
private LpkGoodsService lpkGoodsService; |
||||
|
|
||||
|
public ResultBean<PagerVo<AppletGiftBagVo>> giftBagListPage(PagerQuery<AppletGiftBagQuery> pq) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
AppletGiftBagQuery query = pq.getParams(); |
||||
|
QueryWrapper<AppletGiftBag> qw = new QueryWrapper<>(); |
||||
|
qw.eq("1", "1"); |
||||
|
if (StringUtils.isNotBlank(query.getName())) { |
||||
|
qw.like("name", query.getName()); |
||||
|
} |
||||
|
qw.orderByDesc("isRecommend"); |
||||
|
qw.orderByDesc("createTime"); |
||||
|
IPage<AppletGiftBag> page = PagerUtil.queryToPage(pq); |
||||
|
IPage<AppletGiftBagVo> pagging = baseMapper.giftBagListPage(page, qw); |
||||
|
PagerVo<AppletGiftBagVo> p = PagerUtil.pageToVo(pagging, null); |
||||
|
List<AppletGiftBagVo> records = pagging.getRecords(); |
||||
|
records.removeAll(Collections.singleton(null)); |
||||
|
if (!records.isEmpty()) { |
||||
|
for (AppletGiftBagVo record : records) { |
||||
|
if (StringUtils.isNotBlank(record.getIconUrl())) { |
||||
|
record.setIconUrl(fileUploadComponent.getUrlPrefix() + record.getIconUrl()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return rb.success().setData(p); |
||||
|
} |
||||
|
|
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public ResultBean<String> saveGiftBag(AppletGiftBagDto dto) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
String sid = ""; |
||||
|
if (StringUtils.isNotBlank(dto.getSid())) { |
||||
|
sid = dto.getSid(); |
||||
|
appletGiftBagGoodsService.deleteGoodsByBagSid(dto.getSid()); |
||||
|
AppletGiftBag AppletGiftBag = fetchBySid(dto.getSid()); |
||||
|
BeanUtil.copyProperties(dto, AppletGiftBag, "id", "sid"); |
||||
|
AppletGiftBag.setCreateTime(new DateTime()); |
||||
|
if (StringUtils.isNotBlank(dto.getIconUrl())) { |
||||
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
||||
|
String path = dto.getIconUrl().substring(urlPrefix.length()); |
||||
|
AppletGiftBag.setIconUrl(path); |
||||
|
} |
||||
|
baseMapper.updateById(AppletGiftBag); |
||||
|
if (!dto.getGoods().isEmpty()) { |
||||
|
List<GiftBagGoods> goodsList = dto.getGoods(); |
||||
|
for (GiftBagGoods goods : goodsList) { |
||||
|
AppletGiftBagGoods AppletGiftBagGoods = new AppletGiftBagGoods(); |
||||
|
AppletGiftBagGoods.setCreateTime(new DateTime()); |
||||
|
AppletGiftBagGoods.setGoodsSid(goods.getGoodsSid()); |
||||
|
AppletGiftBagGoods.setGiftbagSid(AppletGiftBag.getSid()); |
||||
|
AppletGiftBagGoods.setGoodsNumber(goods.getGoodsNumber()); |
||||
|
AppletGiftBagGoods.setPrice(0); |
||||
|
appletGiftBagGoodsService.insert(AppletGiftBagGoods); |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
AppletGiftBag AppletGiftBag = new AppletGiftBag(); |
||||
|
sid = AppletGiftBag.getSid(); |
||||
|
BeanUtil.copyProperties(dto, AppletGiftBag, "id", "sid"); |
||||
|
AppletGiftBag.setCreateTime(new DateTime()); |
||||
|
if (StringUtils.isNotBlank(dto.getIconUrl())) { |
||||
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
||||
|
String path = dto.getIconUrl().substring(urlPrefix.length()); |
||||
|
AppletGiftBag.setIconUrl(path); |
||||
|
} |
||||
|
baseMapper.insert(AppletGiftBag); |
||||
|
if (!dto.getGoods().isEmpty()) { |
||||
|
List<GiftBagGoods> goodsList = dto.getGoods(); |
||||
|
for (GiftBagGoods goods : goodsList) { |
||||
|
AppletGiftBagGoods AppletGiftBagGoods = new AppletGiftBagGoods(); |
||||
|
AppletGiftBagGoods.setCreateTime(new DateTime()); |
||||
|
AppletGiftBagGoods.setGoodsSid(goods.getGoodsSid()); |
||||
|
AppletGiftBagGoods.setGiftbagSid(AppletGiftBag.getSid()); |
||||
|
AppletGiftBagGoods.setGoodsNumber(goods.getGoodsNumber()); |
||||
|
appletGiftBagGoodsService.insert(AppletGiftBagGoods); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return rb.success().setData(sid); |
||||
|
} |
||||
|
|
||||
|
public ResultBean giftBagInit(String sid) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
AppletGiftBagInitVo vo = new AppletGiftBagInitVo(); |
||||
|
AppletGiftBag entity = fetchBySid(sid); |
||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
||||
|
if (null != entity) { |
||||
|
BeanUtil.copyProperties(entity, vo); |
||||
|
if (null != entity.getDateStart()) { |
||||
|
vo.setDateStart(sdf.format(entity.getDateStart())); |
||||
|
} |
||||
|
if (null != entity.getDateEnd()) { |
||||
|
vo.setDateEnd(sdf.format(entity.getDateEnd())); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(entity.getIconUrl())) { |
||||
|
vo.setIconUrl(fileUploadComponent.getUrlPrefix() + entity.getIconUrl()); |
||||
|
} |
||||
|
List<GiftBagGoods> goods = new ArrayList<>(); |
||||
|
List<AppletGiftBagGoods> records = appletGiftBagGoodsService.getRecordsByBagSid(sid); |
||||
|
if (!records.isEmpty()) { |
||||
|
for (AppletGiftBagGoods record : records) { |
||||
|
GiftBagGoods bagGoods = new GiftBagGoods(); |
||||
|
if (StringUtils.isNotBlank(record.getGoodsNumber())) { |
||||
|
bagGoods.setGoodsNumber(record.getGoodsNumber()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(record.getGoodsSid())) { |
||||
|
bagGoods.setGoodsSid(record.getGoodsSid()); |
||||
|
LpkGoods lpkGoods = lpkGoodsService.fetchBySid(record.getGoodsSid()); |
||||
|
if (null != lpkGoods) { |
||||
|
if (StringUtils.isNotBlank(lpkGoods.getName())) { |
||||
|
bagGoods.setName(lpkGoods.getName()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(lpkGoods.getUnitName())) { |
||||
|
bagGoods.setUnitName(lpkGoods.getUnitName()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(lpkGoods.getPrice())) { |
||||
|
bagGoods.setPrice(lpkGoods.getPrice()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
goods.add(bagGoods); |
||||
|
} |
||||
|
} |
||||
|
vo.setGoods(goods); |
||||
|
} |
||||
|
return rb.success().setData(vo); |
||||
|
} |
||||
|
|
||||
|
public ResultBean deleteBag(String sid) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
AppletGiftBag AppletGiftBag = fetchBySid(sid); |
||||
|
if (null != AppletGiftBag) { |
||||
|
baseMapper.deleteById(AppletGiftBag.getId()); |
||||
|
appletGiftBagGoodsService.deleteGoodsByBagSid(sid); |
||||
|
} |
||||
|
return rb.success(); |
||||
|
} |
||||
|
|
||||
|
public ResultBean giftBagList() { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
List<AppletGiftBagVo> pagging = baseMapper.giftBagList(); |
||||
|
return rb.success().setData(pagging); |
||||
|
} |
||||
|
public ResultBean isGrounding(String sid,String state) { |
||||
|
ResultBean rb = new ResultBean().fail(); |
||||
|
AppletGiftBag bag=baseMapper.selectOne(new QueryWrapper<AppletGiftBag>().eq("sid",sid)); |
||||
|
bag.setIsGrounding(state); |
||||
|
baseMapper.updateById(bag); |
||||
|
return rb.success().setMsg("修改成功"); |
||||
|
} |
||||
|
|
||||
|
public int saveBags(List<AppletGiftBag> bags) { |
||||
|
return baseMapper.saveBags(bags); |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.yxt.yyth.biz.appletgiftbaggoods; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.yxt.yyth.api.appletgiftbaggoods.AppletGiftBagGoods; |
||||
|
import com.yxt.yyth.api.appletgiftbaggoods.AppletGiftBagGoodsVo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.apache.ibatis.annotations.Select; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:03 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface AppletGiftBagGoodsMapper extends BaseMapper<AppletGiftBagGoods> { |
||||
|
|
||||
|
|
||||
|
int deleteGoodsByBagSid(@Param("sid") String sid); |
||||
|
|
||||
|
@Select("select goods.name as goodsName,bads.goodsNumber ,bads.goodsSid,goods.picUrl,goods.price,goods.unitName,goods.remarks " + |
||||
|
" from lpk_giftbag_goods bads left join lpk_goods goods on goods.sid =bads.goodsSid where bads.giftbagSid=#{sid}") |
||||
|
List<AppletGiftBagGoodsVo> getGoodsByBagSid(String sid); |
||||
|
|
||||
|
List<AppletGiftBagGoods> getRecordsByBagSid(@Param("sid") String sid); |
||||
|
|
||||
|
int saveBagGoods(@Param("bagGoods") List<AppletGiftBagGoods> bagGoods); |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.yxt.yyth.biz.appletgiftbaggoods.AppletGiftBagGoodsMapper"> |
||||
|
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
|
<!-- ${ew.customSqlSegment} --> |
||||
|
|
||||
|
<delete id="deleteGoodsByBagSid"> |
||||
|
DELETE |
||||
|
FROM lpk_giftbag_goods |
||||
|
WHERE giftbagSid = #{sid} |
||||
|
</delete> |
||||
|
<select id="getRecordsByBagSid" resultType="com.yxt.yyth.api.appletgiftbaggoods.AppletGiftBagGoods"> |
||||
|
select * |
||||
|
from lpk_giftbag_goods |
||||
|
WHERE giftbagSid = #{sid} |
||||
|
</select> |
||||
|
<insert id="saveBagGoods" parameterType="java.util.List"> |
||||
|
insert into lpk_giftbag_goods(sid,createTime,giftbagSid,goodsSid,goodsNumber) |
||||
|
values |
||||
|
<foreach collection="bagGoods" item="item" index="index" separator=","> |
||||
|
(#{item.sid},#{item.createTime},#{item.giftbagSid},#{item.goodsSid},#{item.goodsNumber}) |
||||
|
</foreach> |
||||
|
</insert> |
||||
|
</mapper> |
@ -0,0 +1,24 @@ |
|||||
|
package com.yxt.yyth.biz.appletgiftbaggoods; |
||||
|
|
||||
|
import io.swagger.annotations.Api; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:03 |
||||
|
*/ |
||||
|
|
||||
|
@Api(tags = "礼包包含商品信息") |
||||
|
@RestController |
||||
|
@RequestMapping("appletgiftbaggoods") |
||||
|
public class AppletGiftBagGoodsRest { |
||||
|
|
||||
|
@Autowired |
||||
|
AppletGiftBagGoodsService appletGiftBagGoodsService; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.yxt.yyth.biz.appletgiftbaggoods; |
||||
|
|
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.yyth.api.appletgiftbaggoods.AppletGiftBagGoods; |
||||
|
import com.yxt.yyth.api.appletgiftbaggoods.AppletGiftBagGoodsVo; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/11/21 15:03 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class AppletGiftBagGoodsService extends MybatisBaseService<AppletGiftBagGoodsMapper, AppletGiftBagGoods> { |
||||
|
|
||||
|
public int deleteGoodsByBagSid(String sid) { |
||||
|
return baseMapper.deleteGoodsByBagSid(sid); |
||||
|
} |
||||
|
|
||||
|
public List<AppletGiftBagGoods> getRecordsByBagSid(String sid) { |
||||
|
return baseMapper.getRecordsByBagSid(sid); |
||||
|
} |
||||
|
|
||||
|
public List<AppletGiftBagGoodsVo> getGoodsByBagSid(String sid) { |
||||
|
return baseMapper.getGoodsByBagSid(sid); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public int saveBagGoods(List<AppletGiftBagGoods> bagGoods) { |
||||
|
return baseMapper.saveBagGoods(bagGoods); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue