Expand publishing and virtual product workflows
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.app.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
@@ -10,9 +11,17 @@ public class AppVirtualProduct extends BaseEntity
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
@Excel(name = "微信道具ID")
|
||||
private String productId;
|
||||
|
||||
@Excel(name = "价格", suffix = "分")
|
||||
private Integer priceFen;
|
||||
|
||||
@Excel(name = "道具名称")
|
||||
private String productName;
|
||||
|
||||
@Excel(name = "状态", readConverterExp = "0=停用,1=启用")
|
||||
private Integer status;
|
||||
|
||||
public Long getId()
|
||||
|
||||
@@ -1,14 +1,30 @@
|
||||
package com.ruoyi.app.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppVirtualProduct;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface AppVirtualProductMapper
|
||||
{
|
||||
AppVirtualProduct selectAppVirtualProductById(Long id);
|
||||
|
||||
List<AppVirtualProduct> selectAppVirtualProductList(AppVirtualProduct product);
|
||||
|
||||
AppVirtualProduct selectActiveByPrice(Integer priceFen);
|
||||
|
||||
AppVirtualProduct selectByProductId(String productId);
|
||||
|
||||
AppVirtualProduct selectByProductIdExcludeId(@Param("productId") String productId,
|
||||
@Param("excludeId") Long excludeId);
|
||||
|
||||
AppVirtualProduct selectByPriceExcludeId(@Param("priceFen") Integer priceFen,
|
||||
@Param("excludeId") Long excludeId);
|
||||
|
||||
int insertAppVirtualProduct(AppVirtualProduct product);
|
||||
|
||||
int updateAppVirtualProduct(AppVirtualProduct product);
|
||||
|
||||
int updateProductIdByPrice(AppVirtualProduct product);
|
||||
|
||||
int deleteAppVirtualProductByIds(Long[] ids);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.app.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppVirtualProduct;
|
||||
|
||||
/**
|
||||
* 虚拟支付道具管理服务。
|
||||
*/
|
||||
public interface IAppVirtualProductService
|
||||
{
|
||||
AppVirtualProduct selectAppVirtualProductById(Long id);
|
||||
|
||||
List<AppVirtualProduct> selectAppVirtualProductList(AppVirtualProduct product);
|
||||
|
||||
int insertAppVirtualProduct(AppVirtualProduct product);
|
||||
|
||||
int updateAppVirtualProduct(AppVirtualProduct product);
|
||||
|
||||
int deleteAppVirtualProductByIds(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.ruoyi.app.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppVirtualProduct;
|
||||
import com.ruoyi.app.mapper.AppVirtualProductMapper;
|
||||
import com.ruoyi.app.service.IAppVirtualProductService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 虚拟支付道具管理服务实现。
|
||||
*/
|
||||
@Service
|
||||
public class AppVirtualProductServiceImpl implements IAppVirtualProductService
|
||||
{
|
||||
@Autowired
|
||||
private AppVirtualProductMapper virtualProductMapper;
|
||||
|
||||
@Override
|
||||
public AppVirtualProduct selectAppVirtualProductById(Long id)
|
||||
{
|
||||
return virtualProductMapper.selectAppVirtualProductById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppVirtualProduct> selectAppVirtualProductList(AppVirtualProduct product)
|
||||
{
|
||||
return virtualProductMapper.selectAppVirtualProductList(product);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertAppVirtualProduct(AppVirtualProduct product)
|
||||
{
|
||||
normalizeAndValidate(product);
|
||||
product.setCreateTime(DateUtils.getNowDate());
|
||||
return virtualProductMapper.insertAppVirtualProduct(product);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateAppVirtualProduct(AppVirtualProduct product)
|
||||
{
|
||||
if (product.getId() == null || virtualProductMapper.selectAppVirtualProductById(product.getId()) == null)
|
||||
{
|
||||
throw new ServiceException("虚拟道具不存在");
|
||||
}
|
||||
normalizeAndValidate(product);
|
||||
product.setUpdateTime(DateUtils.getNowDate());
|
||||
return virtualProductMapper.updateAppVirtualProduct(product);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAppVirtualProductByIds(Long[] ids)
|
||||
{
|
||||
if (ids == null || ids.length == 0)
|
||||
{
|
||||
throw new ServiceException("请选择要删除的虚拟道具");
|
||||
}
|
||||
return virtualProductMapper.deleteAppVirtualProductByIds(ids);
|
||||
}
|
||||
|
||||
private void normalizeAndValidate(AppVirtualProduct product)
|
||||
{
|
||||
String productId = StringUtils.trim(product.getProductId());
|
||||
if (StringUtils.isEmpty(productId) || productId.length() > 64)
|
||||
{
|
||||
throw new ServiceException("微信道具ID需填写1至64个字符");
|
||||
}
|
||||
|
||||
String productName = StringUtils.trim(product.getProductName());
|
||||
if (StringUtils.isEmpty(productName) || productName.length() > 100)
|
||||
{
|
||||
throw new ServiceException("道具名称需填写1至100个字符");
|
||||
}
|
||||
if (product.getPriceFen() == null || product.getPriceFen() <= 0)
|
||||
{
|
||||
throw new ServiceException("价格必须大于0分");
|
||||
}
|
||||
if (virtualProductMapper.selectByProductIdExcludeId(productId, product.getId()) != null)
|
||||
{
|
||||
throw new ServiceException("微信道具ID已存在");
|
||||
}
|
||||
if (virtualProductMapper.selectByPriceExcludeId(product.getPriceFen(), product.getId()) != null)
|
||||
{
|
||||
throw new ServiceException("该价格档位已存在");
|
||||
}
|
||||
|
||||
product.setProductId(productId);
|
||||
product.setProductName(productName);
|
||||
if (product.getStatus() == null)
|
||||
{
|
||||
product.setStatus(1);
|
||||
}
|
||||
else if (product.getStatus() != 0 && product.getStatus() != 1)
|
||||
{
|
||||
throw new ServiceException("道具状态不正确");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,28 +13,80 @@
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectActiveByPrice" resultMap="AppVirtualProductResult">
|
||||
<sql id="selectAppVirtualProductVo">
|
||||
select id, product_id, price_fen, product_name, status, create_time, update_time
|
||||
from app_virtual_product
|
||||
</sql>
|
||||
|
||||
<select id="selectAppVirtualProductById" parameterType="Long" resultMap="AppVirtualProductResult">
|
||||
<include refid="selectAppVirtualProductVo" />
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectAppVirtualProductList" parameterType="AppVirtualProduct" resultMap="AppVirtualProductResult">
|
||||
<include refid="selectAppVirtualProductVo" />
|
||||
<where>
|
||||
<if test="productId != null and productId != ''">
|
||||
and product_id like concat('%', #{productId}, '%')
|
||||
</if>
|
||||
<if test="productName != null and productName != ''">
|
||||
and product_name like concat('%', #{productName}, '%')
|
||||
</if>
|
||||
<if test="priceFen != null">and price_fen = #{priceFen}</if>
|
||||
<if test="status != null">and status = #{status}</if>
|
||||
</where>
|
||||
order by price_fen asc, id asc
|
||||
</select>
|
||||
|
||||
<select id="selectActiveByPrice" resultMap="AppVirtualProductResult">
|
||||
<include refid="selectAppVirtualProductVo" />
|
||||
where price_fen = #{priceFen} and status = 1
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectByProductId" resultMap="AppVirtualProductResult">
|
||||
select id, product_id, price_fen, product_name, status, create_time, update_time
|
||||
from app_virtual_product
|
||||
<include refid="selectAppVirtualProductVo" />
|
||||
where product_id = #{productId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectByProductIdExcludeId" resultMap="AppVirtualProductResult">
|
||||
<include refid="selectAppVirtualProductVo" />
|
||||
where product_id = #{productId}
|
||||
<if test="excludeId != null">and id != #{excludeId}</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectByPriceExcludeId" resultMap="AppVirtualProductResult">
|
||||
<include refid="selectAppVirtualProductVo" />
|
||||
where price_fen = #{priceFen}
|
||||
<if test="excludeId != null">and id != #{excludeId}</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertAppVirtualProduct" parameterType="AppVirtualProduct" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into app_virtual_product(product_id, price_fen, product_name, status, create_time)
|
||||
values(#{productId}, #{priceFen}, #{productName}, #{status}, #{createTime})
|
||||
</insert>
|
||||
|
||||
<update id="updateAppVirtualProduct" parameterType="AppVirtualProduct">
|
||||
update app_virtual_product
|
||||
set product_id = #{productId},
|
||||
price_fen = #{priceFen},
|
||||
product_name = #{productName},
|
||||
status = #{status},
|
||||
update_time = #{updateTime}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateProductIdByPrice" parameterType="AppVirtualProduct">
|
||||
update app_virtual_product
|
||||
set product_id = #{productId}, product_name = #{productName}, status = 1, update_time = #{updateTime}
|
||||
where price_fen = #{priceFen}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAppVirtualProductByIds" parameterType="Long">
|
||||
delete from app_virtual_product where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user