yshop1.3版本发布及其导出最新sql
This commit is contained in:
28
README.md
28
README.md
@ -72,28 +72,28 @@ yshop基于当前流行技术组合: SpringBoot2+Jpa+MybatisPlus+SpringSecurit
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/194017_9207632f_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/194030_70f5ce92_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1121/230257_5844f5f1_477893.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/194114_cd0b06ce_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/194130_abb4f788_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1121/230051_971db503_477893.png "/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1121/230342_f379583e_477893.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/194147_63de73f4_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1121/230224_5f0dec5d_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/194207_7b3b1f53_477893.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/194217_3f47214f_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1121/230424_f01fca77_477893.png"/></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/201443_df1cc3a6_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/201540_ef6123a9_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1121/231156_df0430c8_477893.jpeg"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1121/231246_797725e6_477893.jpeg"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/201601_acd0ccd3_477893.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1121/231335_7d732dbd_477893.jpeg"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2019/1107/201622_f913b59c_477893.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -127,10 +127,14 @@ yshop基于当前流行技术组合: SpringBoot2+Jpa+MybatisPlus+SpringSecurit
|
||||
|
||||
|
||||
#### 项目发布明细
|
||||
1.0版本
|
||||
1.1版本新增积分与优惠券抵扣
|
||||
1.2版本分销功能已经发布
|
||||
1.2.1增加了未付款订单取消功能库存销量退出、优惠券、积分功能,个人中心增加了积分流水
|
||||
|
||||
- 1.0版本
|
||||
- 1.1版本新增积分与优惠券抵扣
|
||||
- 1.2版本分销功能已经发布
|
||||
- 1.2.1增加了未付款订单取消功能库存销量退出、优惠券、积分功能,个人中心增加了积分流水
|
||||
- 1.3版本新增拼团功能,已经发布
|
||||
- 1.4版本规划:补充公众号功能、新增redisson队列、发布mpvue小程序
|
||||
|
||||
|
||||
#### 反馈交流
|
||||
- QQ交流群:907721261
|
||||
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
|
||||
<modules>
|
||||
<module>yshop-common</module>
|
||||
|
BIN
poster.jpg
Normal file
BIN
poster.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
521
sql/yxshop.sql
521
sql/yxshop.sql
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -21,18 +21,18 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-tools</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-mp</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
|
||||
<!--jwt-->
|
||||
|
@ -0,0 +1,119 @@
|
||||
package co.yixiang.modules.activity.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import co.yixiang.common.entity.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团产品表
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "YxStoreCombination对象", description = "拼团产品表")
|
||||
public class YxStoreCombination extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
|
||||
@ApiModelProperty(value = "推荐图")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "活动标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "活动属性")
|
||||
private String attr;
|
||||
|
||||
@ApiModelProperty(value = "参团人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
|
||||
@ApiModelProperty(value = "推荐")
|
||||
private Integer isHost;
|
||||
|
||||
@ApiModelProperty(value = "产品状态")
|
||||
private Integer isShow;
|
||||
|
||||
private Integer isDel;
|
||||
|
||||
private Integer combination;
|
||||
|
||||
@ApiModelProperty(value = "商户是否可用1可用0不可用")
|
||||
private Integer merUse;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮1是0否")
|
||||
private Integer isPostage;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "拼团内容")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "拼团开始时间")
|
||||
private Integer startTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团结束时间")
|
||||
private Integer stopTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团订单有效时间")
|
||||
private Integer effectiveTime;
|
||||
|
||||
@ApiModelProperty(value = "拼图产品成本")
|
||||
private Integer cost;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browse;
|
||||
|
||||
@ApiModelProperty(value = "单位名")
|
||||
private String unitName;
|
||||
|
||||
private Date endTimeDate;
|
||||
|
||||
private Date startTimeDate;
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package co.yixiang.modules.activity.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import co.yixiang.common.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团表
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "YxStorePink对象", description = "拼团表")
|
||||
public class YxStorePink extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "订单id 生成")
|
||||
private String orderId;
|
||||
|
||||
@ApiModelProperty(value = "订单id 数据库")
|
||||
private Integer orderIdKey;
|
||||
|
||||
@ApiModelProperty(value = "购买商品个数")
|
||||
private Integer totalNum;
|
||||
|
||||
@ApiModelProperty(value = "购买总金额")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
@ApiModelProperty(value = "拼团产品id")
|
||||
private Integer cid;
|
||||
|
||||
@ApiModelProperty(value = "产品id")
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty(value = "拼图总人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "拼团产品单价")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private String addTime;
|
||||
|
||||
private String stopTime;
|
||||
|
||||
@ApiModelProperty(value = "团长id 0为团长")
|
||||
private Integer kId;
|
||||
|
||||
@ApiModelProperty(value = "是否发送模板消息0未发送1已发送")
|
||||
private Integer isTpl;
|
||||
|
||||
@ApiModelProperty(value = "是否退款 0未退款 1已退款")
|
||||
private Integer isRefund;
|
||||
|
||||
@ApiModelProperty(value = "状态1进行中2已完成3未完成")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package co.yixiang.modules.activity.mapper;
|
||||
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreProductQueryVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import co.yixiang.modules.activity.entity.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.web.param.YxStoreCombinationQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团产品表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-19
|
||||
*/
|
||||
@Repository
|
||||
public interface YxStoreCombinationMapper extends BaseMapper<YxStoreCombination> {
|
||||
|
||||
@Update("update yx_store_combination set stock=stock-#{num}, sales=sales+#{num}" +
|
||||
" where id=#{combinationId}")
|
||||
int decStockIncSales(@Param("num") int num,@Param("combinationId") int combinationId);
|
||||
|
||||
@Update("update yx_store_combination set stock=stock+#{num}, sales=sales-#{num}" +
|
||||
" where id=#{combinationId}")
|
||||
int incStockDecSales(@Param("num") int num,@Param("combinationId") int combinationId);
|
||||
|
||||
@Select("SELECT c.id,c.effective_time as effectiveTime,c.image,c.people,c.price," +
|
||||
"c.title,c.unit_name as unitName,s.price as productPrice FROM yx_store_combination c " +
|
||||
"INNER JOIN yx_store_product s ON s.id=c.product_id " +
|
||||
" WHERE c.is_show = 1 AND c.is_del = 0 AND c.start_time < unix_timestamp(now()) " +
|
||||
" AND c.stop_time > unix_timestamp(now()) ORDER BY c.sort desc,c.id desc")
|
||||
List<YxStoreCombinationQueryVo> getCombList(Page page);
|
||||
|
||||
@Select("SELECT c.id,c.effective_time as effectiveTime,c.image,c.people,c.price,c.browse," +
|
||||
"c.description,c.image,c.images,c.info,c.is_postage as isPostage,c.postage," +
|
||||
"c.product_id as productId,c.sales,c.start_time as startTime" +
|
||||
",c.stock,c.stop_time stopTime," +
|
||||
"c.title,c.unit_name as unitName,s.price as productPrice FROM yx_store_combination c " +
|
||||
"INNER JOIN yx_store_product s ON s.id=c.product_id " +
|
||||
" WHERE c.is_show = 1 AND c.is_del = 0 AND c.id = #{id} ")
|
||||
YxStoreCombinationQueryVo getCombDetail(int id);
|
||||
|
||||
@Select("SELECT c.id,c.image,c.price,c.title as storeName,c.is_show as isShow,c.cost," +
|
||||
"c.is_postage as isPostage,c.postage,c.sales,c.stock,c.is_del as isDel" +
|
||||
" FROM yx_store_combination c " +
|
||||
" WHERE c.id = #{id} ")
|
||||
YxStoreProductQueryVo combinatiionInfo(int id);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxStoreCombinationQueryVo getYxStoreCombinationById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param page
|
||||
* @param yxStoreCombinationQueryParam
|
||||
* @return
|
||||
*/
|
||||
IPage<YxStoreCombinationQueryVo> getYxStoreCombinationPageList(@Param("page") Page page, @Param("param") YxStoreCombinationQueryParam yxStoreCombinationQueryParam);
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package co.yixiang.modules.activity.mapper;
|
||||
|
||||
import co.yixiang.modules.activity.web.dto.PinkDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import co.yixiang.modules.activity.entity.YxStorePink;
|
||||
import co.yixiang.modules.activity.web.param.YxStorePinkQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStorePinkQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-19
|
||||
*/
|
||||
@Repository
|
||||
public interface YxStorePinkMapper extends BaseMapper<YxStorePink> {
|
||||
|
||||
@Select("SELECT p.id,p.uid,p.people,p.price,p.stop_time as stopTime,u.nickname,u.avatar" +
|
||||
" FROM yx_store_pink p INNER JOIN yx_user u ON u.uid=p.uid" +
|
||||
" WHERE stop_time > unix_timestamp(now()) AND p.cid = #{cid} AND p.k_id = 0 " +
|
||||
"AND p.is_refund = 0 ORDER BY p.add_time DESC")
|
||||
List<PinkDTO> getPinks(int cid);
|
||||
|
||||
//<![CDATA[ >= ]]>
|
||||
@Select("SELECT p.id,u.nickname,u.avatar" +
|
||||
" FROM yx_store_pink p RIGHT JOIN yx_user u ON u.uid=p.uid" +
|
||||
" where p.status= 2 AND p.uid <> ${uid} " +
|
||||
"AND p.is_refund = 0")
|
||||
List<PinkDTO> getPinkOkList(int uid);
|
||||
|
||||
@Select("SELECT p.id,p.uid,p.people,p.price,p.stop_time as stopTime,u.nickname,u.avatar" +
|
||||
" FROM yx_store_pink p LEFT JOIN yx_user u ON u.uid=p.uid" +
|
||||
" where p.k_id= ${kid} " +
|
||||
"AND p.is_refund = 0")
|
||||
List<PinkDTO> getPinkMember(int kid);
|
||||
|
||||
@Select("SELECT p.id,p.uid,p.people,p.price,p.stop_time as stopTime,u.nickname,u.avatar" +
|
||||
" FROM yx_store_pink p LEFT JOIN yx_user u ON u.uid=p.uid" +
|
||||
" where p.id= ${id} ")
|
||||
PinkDTO getPinkUserOne(int id);
|
||||
|
||||
@Select("select IFNULL(sum(total_num),0) from yx_store_pink " +
|
||||
"where status=2 and is_refund=0")
|
||||
int sumNum();
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxStorePinkQueryVo getYxStorePinkById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param page
|
||||
* @param yxStorePinkQueryParam
|
||||
* @return
|
||||
*/
|
||||
IPage<YxStorePinkQueryVo> getYxStorePinkPageList(@Param("page") Page page, @Param("param") YxStorePinkQueryParam yxStorePinkQueryParam);
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package co.yixiang.modules.activity.mapping;
|
||||
|
||||
import co.yixiang.mapper.EntityMapper;
|
||||
import co.yixiang.modules.activity.entity.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-10-19
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface StoreCombationMap extends EntityMapper<YxStoreCombinationQueryVo, YxStoreCombination> {
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package co.yixiang.modules.activity.mapping;
|
||||
|
||||
import co.yixiang.mapper.EntityMapper;
|
||||
import co.yixiang.modules.activity.entity.YxStorePink;
|
||||
import co.yixiang.modules.activity.web.vo.YxStorePinkQueryVo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-10-19
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface StorePinkMap extends EntityMapper<YxStorePinkQueryVo, YxStorePink> {
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package co.yixiang.modules.activity.service;
|
||||
|
||||
import co.yixiang.modules.activity.entity.YxStoreCombination;
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.modules.activity.web.dto.StoreCombinationDTO;
|
||||
import co.yixiang.modules.activity.web.param.YxStoreCombinationQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团产品表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-19
|
||||
*/
|
||||
public interface YxStoreCombinationService extends BaseService<YxStoreCombination> {
|
||||
|
||||
YxStoreCombinationQueryVo getCombinationT(int id);
|
||||
void decStockIncSales(int num,int combinationId);
|
||||
|
||||
void incStockDecSales(int num,int combinationId);
|
||||
|
||||
YxStoreCombination getCombination(int id);
|
||||
|
||||
boolean judgeCombinationStock(int combinationId,int cartNum);
|
||||
|
||||
List<YxStoreCombinationQueryVo> getList(int page, int limit);
|
||||
|
||||
StoreCombinationDTO getDetail(int id,int uid);
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxStoreCombinationQueryVo getYxStoreCombinationById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param yxStoreCombinationQueryParam
|
||||
* @return
|
||||
*/
|
||||
Paging<YxStoreCombinationQueryVo> getYxStoreCombinationPageList(YxStoreCombinationQueryParam yxStoreCombinationQueryParam) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package co.yixiang.modules.activity.service;
|
||||
|
||||
import co.yixiang.modules.activity.entity.YxStorePink;
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.modules.activity.web.dto.PinkDTO;
|
||||
import co.yixiang.modules.activity.web.dto.PinkInfoDTO;
|
||||
import co.yixiang.modules.activity.web.param.YxStorePinkQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStorePinkQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-19
|
||||
*/
|
||||
public interface YxStorePinkService extends BaseService<YxStorePink> {
|
||||
|
||||
void orderPinkFailAfter(int uid,int pid);
|
||||
|
||||
void removePink(int uid,int cid,int pinkId);
|
||||
|
||||
int surplusPeople(YxStorePink pink);
|
||||
|
||||
List<YxStorePinkQueryVo> handPinkAll(List<YxStorePink> pinkAll);
|
||||
|
||||
YxStorePinkQueryVo handPinkT(YxStorePink pinkT);
|
||||
|
||||
YxStorePink getCurrentPink(int id,int uid);
|
||||
|
||||
String getCurrentPinkOrderId(int id,int uid);
|
||||
|
||||
PinkInfoDTO pinkInfo(int id, int uid);
|
||||
|
||||
PinkDTO getPinkUserOneT(int id);
|
||||
|
||||
void setPinkStopTime(List<Integer> idAll);
|
||||
|
||||
boolean getPinkStatus(List<Integer> idAll);
|
||||
|
||||
int pinkFail(List<YxStorePink> pinkAll,YxStorePink pinkT,int pinkBool);
|
||||
|
||||
int pinkComplete(List<Integer> uidAll,List<Integer> idAll,int uid,YxStorePink pinkT);
|
||||
|
||||
List<YxStorePink> getPinkMember(int kid);
|
||||
|
||||
YxStorePink getPinkUserOne(int id);
|
||||
|
||||
Map<String,Object> getPinkMemberAndPinK(YxStorePink pink);
|
||||
|
||||
int pinkIngCount(int id);
|
||||
|
||||
void createPink(YxStoreOrderQueryVo order);
|
||||
|
||||
int getIsPinkUid(int id,int uid);
|
||||
|
||||
int getPinkOkSumTotalNum();
|
||||
|
||||
List<String> getPinkOkList(int uid);
|
||||
|
||||
int getPinkPeople(int kid,int people);
|
||||
|
||||
Map<String,Object> getPinkAll(int cid, boolean isAll);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxStorePinkQueryVo getYxStorePinkById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param yxStorePinkQueryParam
|
||||
* @return
|
||||
*/
|
||||
Paging<YxStorePinkQueryVo> getYxStorePinkPageList(YxStorePinkQueryParam yxStorePinkQueryParam) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
package co.yixiang.modules.activity.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.activity.entity.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.mapper.YxStoreCombinationMapper;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
import co.yixiang.modules.activity.web.dto.PinkDTO;
|
||||
import co.yixiang.modules.activity.web.dto.StoreCombinationDTO;
|
||||
import co.yixiang.modules.activity.web.param.YxStoreCombinationQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductReplyService;
|
||||
import co.yixiang.utils.SecurityUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团产品表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-19
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombinationMapper, YxStoreCombination> implements YxStoreCombinationService {
|
||||
|
||||
@Autowired
|
||||
private YxStoreCombinationMapper yxStoreCombinationMapper;
|
||||
|
||||
@Autowired
|
||||
private YxStoreProductReplyService replyService;
|
||||
|
||||
@Autowired
|
||||
private YxStorePinkService storePinkService;
|
||||
|
||||
/**
|
||||
* 减库存增加销量
|
||||
* @param num
|
||||
* @param combinationId
|
||||
*/
|
||||
@Override
|
||||
public void decStockIncSales(int num, int combinationId) {
|
||||
yxStoreCombinationMapper.decStockIncSales(num,combinationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加库存 减少销量
|
||||
* @param num
|
||||
* @param combinationId
|
||||
*/
|
||||
@Override
|
||||
public void incStockDecSales(int num, int combinationId) {
|
||||
yxStoreCombinationMapper.incStockDecSales(num,combinationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreCombination getCombination(int id) {
|
||||
QueryWrapper<YxStoreCombination> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("id",id).eq("is_del",0).eq("is_show",1);
|
||||
return yxStoreCombinationMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断库存是否足够
|
||||
* @param combinationId
|
||||
* @param cartNum
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean judgeCombinationStock(int combinationId, int cartNum) {
|
||||
YxStoreCombinationQueryVo queryVo = getYxStoreCombinationById(combinationId);
|
||||
if(queryVo.getStock() > cartNum){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreCombinationQueryVo getCombinationT(int id) {
|
||||
return yxStoreCombinationMapper.getCombDetail(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoreCombinationDTO getDetail(int id,int uid) {
|
||||
YxStoreCombinationQueryVo storeCombinationQueryVo = yxStoreCombinationMapper
|
||||
.getCombDetail(id);
|
||||
if(ObjectUtil.isNull(storeCombinationQueryVo)){
|
||||
throw new ErrorRequestException("拼团不存在或已下架");
|
||||
}
|
||||
|
||||
|
||||
StoreCombinationDTO storeCombinationDTO = new StoreCombinationDTO();
|
||||
|
||||
storeCombinationDTO.setStoreInfo(storeCombinationQueryVo);
|
||||
|
||||
storeCombinationDTO.setReply(replyService
|
||||
.getReply(storeCombinationQueryVo.getProductId()));
|
||||
int replyCount = replyService.productReplyCount(storeCombinationQueryVo.getProductId());
|
||||
storeCombinationDTO.setReplyCount(replyCount);
|
||||
storeCombinationDTO.setReplyChance(replyService.doReply(storeCombinationQueryVo.getProductId()
|
||||
,replyCount));
|
||||
Map<String,Object> map = storePinkService.getPinkAll(id,true);
|
||||
storeCombinationDTO.setPindAll((List<Integer>)map.get("pindAll"));
|
||||
storeCombinationDTO.setPink((List<PinkDTO> )map.get("list"));
|
||||
storeCombinationDTO.setPinkOkList(storePinkService.getPinkOkList(uid));
|
||||
storeCombinationDTO.setPinkOkSum(storePinkService.getPinkOkSumTotalNum());
|
||||
|
||||
return storeCombinationDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团列表
|
||||
* @param page
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<YxStoreCombinationQueryVo> getList(int page, int limit) {
|
||||
Page<YxStoreCombination> pageModel = new Page<>(page, limit);
|
||||
return yxStoreCombinationMapper.getCombList(pageModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreCombinationQueryVo getYxStoreCombinationById(Serializable id){
|
||||
return yxStoreCombinationMapper.getYxStoreCombinationById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<YxStoreCombinationQueryVo> getYxStoreCombinationPageList(YxStoreCombinationQueryParam yxStoreCombinationQueryParam) throws Exception{
|
||||
Page page = setPageParam(yxStoreCombinationQueryParam,OrderItem.desc("create_time"));
|
||||
IPage<YxStoreCombinationQueryVo> iPage = yxStoreCombinationMapper.getYxStoreCombinationPageList(page,yxStoreCombinationQueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,593 @@
|
||||
package co.yixiang.modules.activity.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.activity.entity.YxStorePink;
|
||||
import co.yixiang.modules.activity.mapper.YxStoreCombinationMapper;
|
||||
import co.yixiang.modules.activity.mapper.YxStorePinkMapper;
|
||||
import co.yixiang.modules.activity.mapping.StorePinkMap;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
import co.yixiang.modules.activity.web.dto.PinkDTO;
|
||||
import co.yixiang.modules.activity.web.dto.PinkInfoDTO;
|
||||
import co.yixiang.modules.activity.web.param.YxStorePinkQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo;
|
||||
import co.yixiang.modules.activity.web.vo.YxStorePinkQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.order.entity.YxStoreOrder;
|
||||
import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||
import co.yixiang.modules.order.web.param.RefundParam;
|
||||
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-19
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, YxStorePink> implements YxStorePinkService {
|
||||
|
||||
@Autowired
|
||||
private YxStorePinkMapper yxStorePinkMapper;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCombinationService combinationService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreOrderService storeOrderService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCombinationMapper yxStoreCombinationMapper;
|
||||
|
||||
@Autowired
|
||||
private YxUserService userService;
|
||||
|
||||
@Autowired
|
||||
private StorePinkMap pinkMap;
|
||||
|
||||
|
||||
/**
|
||||
* 取消拼团
|
||||
* @param uid
|
||||
* @param cid
|
||||
* @param pinkId
|
||||
*/
|
||||
@Override
|
||||
public void removePink(int uid, int cid, int pinkId) {
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("id",pinkId).eq("uid",uid)
|
||||
.eq("cid",cid).eq("k_id",0).eq("is_refund",0)
|
||||
.eq("status",1).gt("stop_time",OrderUtil.getSecondTimestampTwo());
|
||||
YxStorePink pink = yxStorePinkMapper.selectOne(wrapper);
|
||||
|
||||
Map<String, Object> map = getPinkMemberAndPinK(pink);
|
||||
List<YxStorePink> pinkAll = (List<YxStorePink>)map.get("pinkAll");
|
||||
YxStorePink pinkT = (YxStorePink)map.get("pinkT");
|
||||
List<Integer> idAll = (List<Integer>)map.get("idAll");
|
||||
List<Integer> uidAll = (List<Integer>)map.get("uidAll");
|
||||
int count = (int)map.get("count");
|
||||
if(count < 1){
|
||||
pinkComplete(uidAll,idAll,uid,pinkT);
|
||||
|
||||
throw new ErrorRequestException("拼团已完成,无法取消");
|
||||
}
|
||||
|
||||
RefundParam param = new RefundParam();
|
||||
param.setUni(pinkT.getOrderId());
|
||||
param.setText("拼团取消开团");
|
||||
storeOrderService.orderApplyRefund(param,pinkT.getUid());
|
||||
orderPinkFailAfter(pinkT.getUid(),pinkT.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算还差几人拼团
|
||||
* @param pink
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int surplusPeople(YxStorePink pink) {
|
||||
List<YxStorePink> listT = new ArrayList<>();
|
||||
if(pink.getKId() > 0){
|
||||
listT = getPinkMember(pink.getKId());
|
||||
}else{
|
||||
listT = getPinkMember(pink.getId());
|
||||
}
|
||||
|
||||
return pink.getPeople() - (listT.size() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理团员
|
||||
* @param pinkAll
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<YxStorePinkQueryVo> handPinkAll(List<YxStorePink> pinkAll) {
|
||||
|
||||
List<YxStorePinkQueryVo> list = pinkMap.toDto(pinkAll);
|
||||
for (YxStorePinkQueryVo queryVo : list) {
|
||||
YxUserQueryVo userQueryVo = userService.getYxUserById(queryVo.getUid());
|
||||
queryVo.setAvatar(userQueryVo.getAvatar());
|
||||
queryVo.setNickname(userQueryVo.getNickname());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理团长
|
||||
* @param pinkT
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public YxStorePinkQueryVo handPinkT(YxStorePink pinkT) {
|
||||
YxStorePinkQueryVo pinkQueryVo = pinkMap.toDto(pinkT);
|
||||
YxUserQueryVo userQueryVo = userService.getYxUserById(pinkQueryVo.getUid());
|
||||
pinkQueryVo.setAvatar(userQueryVo.getAvatar());
|
||||
pinkQueryVo.setNickname(userQueryVo.getNickname());
|
||||
|
||||
return pinkQueryVo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCurrentPinkOrderId(int id, int uid) {
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("id",id).eq("uid",uid);
|
||||
YxStorePink pink = yxStorePinkMapper.selectOne(wrapper);
|
||||
if(ObjectUtil.isNull(pink)){
|
||||
QueryWrapper<YxStorePink> wrapperT = new QueryWrapper<>();
|
||||
wrapperT.eq("k_id",id).eq("uid",uid);
|
||||
pink = yxStorePinkMapper.selectOne(wrapperT);
|
||||
if(ObjectUtil.isNull(pink)) return "";
|
||||
}
|
||||
return pink.getOrderId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前拼团数据
|
||||
* @param id
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public YxStorePink getCurrentPink(int id, int uid) {
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("id",id).eq("uid",uid);
|
||||
YxStorePink pink = yxStorePinkMapper.selectOne(wrapper);
|
||||
if(ObjectUtil.isNull(pink)){
|
||||
QueryWrapper<YxStorePink> wrapperT = new QueryWrapper<>();
|
||||
wrapperT.eq("k_id",id).eq("uid",uid);
|
||||
pink = yxStorePinkMapper.selectOne(wrapperT);
|
||||
if(ObjectUtil.isNull(pink)) pink.setOrderId("");
|
||||
}
|
||||
return pink;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团明细
|
||||
* @param id
|
||||
* @param uid
|
||||
*/
|
||||
@Override
|
||||
public PinkInfoDTO pinkInfo(int id, int uid) {
|
||||
PinkDTO pinkDTO = getPinkUserOneT(id);
|
||||
if(ObjectUtil.isNull(pinkDTO)) throw new ErrorRequestException("拼团不存在");
|
||||
|
||||
PinkInfoDTO infoDTO = new PinkInfoDTO();
|
||||
|
||||
YxStorePink pink = getPinkUserOne(id);
|
||||
if(pink.getIsRefund() > 0){
|
||||
throw new ErrorRequestException("订单已退款");
|
||||
}
|
||||
|
||||
int isOk = 0;//判断拼团是否完成
|
||||
int userBool = 0;//判断当前用户是否在团内 0未在 1在
|
||||
int pinkBool = 0;//判断拼团是否成功 0未 1是 -1结束
|
||||
|
||||
Map<String, Object> map = getPinkMemberAndPinK(pink);
|
||||
List<YxStorePink> pinkAll = (List<YxStorePink>)map.get("pinkAll");
|
||||
YxStorePink pinkT = (YxStorePink)map.get("pinkT");
|
||||
List<Integer> idAll = (List<Integer>)map.get("idAll");
|
||||
List<Integer> uidAll = (List<Integer>)map.get("uidAll");
|
||||
int count = (int)map.get("count");
|
||||
if(count <= 0) count = 0;
|
||||
if(pinkT.getStatus() == 2){
|
||||
pinkBool = 1;
|
||||
isOk = 1;
|
||||
|
||||
}else if(pinkT.getStatus() == 3){
|
||||
pinkBool = -1;
|
||||
isOk = 0;
|
||||
}else{
|
||||
if(count < 1){//组团完成
|
||||
isOk = 1;
|
||||
pinkBool = pinkComplete(uidAll,idAll,uid,pinkT);
|
||||
}else{
|
||||
pinkBool = pinkFail(pinkAll,pinkT,pinkBool);
|
||||
}
|
||||
}
|
||||
|
||||
//团员
|
||||
if(ObjectUtil.isNotNull(pinkAll)){
|
||||
for (YxStorePink storePink : pinkAll) {
|
||||
if(storePink.getUid() == uid) userBool = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//团长
|
||||
if(pinkT.getUid() == uid) userBool = 1;
|
||||
|
||||
YxStoreCombinationQueryVo storeCombinationQueryVo = yxStoreCombinationMapper
|
||||
.getCombDetail(pink.getCid());
|
||||
if(ObjectUtil.isNull(storeCombinationQueryVo)) throw new ErrorRequestException("拼团不存在或已下架");
|
||||
|
||||
YxUserQueryVo userInfo = userService.getYxUserById(uid);
|
||||
|
||||
infoDTO.setCount(count);
|
||||
infoDTO.setCurrentPinkOrder(getCurrentPinkOrderId(id,uid));
|
||||
infoDTO.setIsOk(isOk);
|
||||
infoDTO.setPinkAll(handPinkAll(pinkAll));
|
||||
infoDTO.setPinkBool(pinkBool);
|
||||
infoDTO.setPinkT(handPinkT(pinkT));
|
||||
infoDTO.setStoreCombination(storeCombinationQueryVo);
|
||||
infoDTO.setUserBool(userBool);
|
||||
infoDTO.setUserInfo(userInfo);
|
||||
|
||||
return infoDTO;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PinkDTO getPinkUserOneT(int id) {
|
||||
return yxStorePinkMapper.getPinkUserOne(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int pinkIngCount(int id) {
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("id",id).eq("status",1);
|
||||
return yxStorePinkMapper.selectCount(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团的团员
|
||||
* @param kid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<YxStorePink> getPinkMember(int kid) {
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("k_id",kid).eq("is_refund",0).orderByAsc("id");
|
||||
return yxStorePinkMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一条拼团数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public YxStorePink getPinkUserOne(int id) {
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("id",id);
|
||||
return yxStorePinkMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团人数完成时,判断全部人都是未退款状态
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean getPinkStatus(List<Integer> idAll) {
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.in("id",idAll).eq("is_refund",0);
|
||||
int count = yxStorePinkMapper.selectCount(wrapper);
|
||||
if(count == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置结束时间
|
||||
* @param idAll
|
||||
*/
|
||||
@Override
|
||||
public void setPinkStopTime(List<Integer> idAll) {
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.in("id",idAll);
|
||||
|
||||
YxStorePink storePink = new YxStorePink();
|
||||
storePink.setStopTime(OrderUtil.getSecondTimestampTwo()+"");
|
||||
storePink.setStatus(2);
|
||||
|
||||
yxStorePinkMapper.update(storePink,wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团完成更改数据写入内容
|
||||
* @param uidAll
|
||||
* @param idAll
|
||||
* @param uid
|
||||
* @param pinkT
|
||||
*/
|
||||
@Override
|
||||
public int pinkComplete(List<Integer> uidAll,List<Integer> idAll,int uid,
|
||||
YxStorePink pinkT) {
|
||||
boolean pinkStatus = getPinkStatus(idAll);
|
||||
int pinkBool = 6;
|
||||
if(!pinkStatus){
|
||||
setPinkStopTime(idAll);//更改状态
|
||||
if(uidAll.contains(uid)){
|
||||
pinkBool = 1;
|
||||
}else{
|
||||
pinkBool = 3;
|
||||
}
|
||||
//todo 模板消息
|
||||
}
|
||||
|
||||
return pinkBool;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团失败退款之后
|
||||
* @param uid
|
||||
* @param pid
|
||||
*/
|
||||
@Override
|
||||
public void orderPinkFailAfter(int uid, int pid) {
|
||||
YxStorePink yxStorePink = new YxStorePink();
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("id",pid);
|
||||
yxStorePink.setStatus(3);
|
||||
yxStorePink.setStopTime(OrderUtil.getSecondTimestampTwo()+"");
|
||||
yxStorePinkMapper.update(yxStorePink,wrapper);
|
||||
|
||||
QueryWrapper<YxStorePink> wrapperT = new QueryWrapper<>();
|
||||
wrapperT.eq("k_id",pid);
|
||||
yxStorePinkMapper.update(yxStorePink,wrapperT);
|
||||
//todo 模板消息
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团失败 退款
|
||||
* @param pinkAll 拼团数据,不包括团长
|
||||
* @param pinkT 团长数据
|
||||
* @param pinkBool
|
||||
*/
|
||||
@Override
|
||||
public int pinkFail(List<YxStorePink> pinkAll, YxStorePink pinkT,int pinkBool) {
|
||||
int now = OrderUtil.getSecondTimestampTwo();
|
||||
|
||||
//拼团时间超时 退款
|
||||
if(Integer.valueOf(pinkT.getStopTime()) < now){
|
||||
pinkBool = -1;
|
||||
pinkAll.add(pinkT);
|
||||
for (YxStorePink storePink : pinkAll) {
|
||||
RefundParam param = new RefundParam();
|
||||
param.setUni(storePink.getOrderId());
|
||||
param.setText("拼团时间超时");
|
||||
storeOrderService.orderApplyRefund(param,storePink.getUid());
|
||||
orderPinkFailAfter(pinkT.getUid(),storePink.getId());
|
||||
}
|
||||
}
|
||||
|
||||
return pinkBool;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参团人和团长和拼团总人数
|
||||
* @param pink
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getPinkMemberAndPinK(YxStorePink pink) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
//查找拼团团员和团长
|
||||
List<YxStorePink> pinkAll = null;
|
||||
YxStorePink pinkT = null;
|
||||
List<Integer> idAll = new ArrayList<>();
|
||||
List<Integer> uidAll = new ArrayList<>();
|
||||
int count = 0;
|
||||
if(pink.getKId() > 0){
|
||||
pinkAll = getPinkMember(pink.getKId());
|
||||
pinkT = getPinkUserOne(pink.getKId());
|
||||
}else{
|
||||
pinkAll = getPinkMember(pink.getId());
|
||||
pinkT = pink;
|
||||
}
|
||||
//收集拼团用户id和拼团id
|
||||
for (YxStorePink storePink : pinkAll) {
|
||||
idAll.add(storePink.getId());
|
||||
uidAll.add(storePink.getUid());
|
||||
}
|
||||
idAll.add(pinkT.getId());
|
||||
uidAll.add(pinkT.getUid());
|
||||
//还差几人
|
||||
count = pinkT.getPeople() - (pinkAll.size() + 1);
|
||||
|
||||
map.put("pinkAll",pinkAll);
|
||||
map.put("pinkT",pinkT);
|
||||
map.put("count",count);
|
||||
map.put("idAll",idAll);
|
||||
map.put("uidAll",uidAll);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建拼团
|
||||
* @param order
|
||||
*/
|
||||
@Override
|
||||
public void createPink(YxStoreOrderQueryVo order) {
|
||||
YxStoreCombinationQueryVo combinationQueryVo = combinationService
|
||||
.getYxStoreCombinationById(order.getCombinationId());
|
||||
order = storeOrderService.handleOrder(order);
|
||||
if(ObjectUtil.isNotNull(combinationQueryVo)){
|
||||
YxStorePink storePink = new YxStorePink();
|
||||
storePink.setUid(order.getUid());
|
||||
storePink.setOrderId(order.getOrderId());
|
||||
storePink.setOrderIdKey(order.getId());
|
||||
storePink.setTotalNum(order.getTotalNum());
|
||||
storePink.setTotalPrice(order.getPayPrice());
|
||||
storePink.setKId(0);
|
||||
List<YxStoreCartQueryVo> cartInfo = order.getCartInfo();
|
||||
for (YxStoreCartQueryVo queryVo : cartInfo) {
|
||||
storePink.setCid(queryVo.getCombinationId());
|
||||
storePink.setPid(queryVo.getProductId());
|
||||
storePink.setPrice(queryVo.getProductInfo().getPrice());
|
||||
}
|
||||
storePink.setPeople(combinationQueryVo.getPeople());
|
||||
storePink.setStopTime(OrderUtil.getSecondTimestampTwo()
|
||||
+(combinationQueryVo.getEffectiveTime()*3600)+"");
|
||||
storePink.setAddTime(OrderUtil.getSecondTimestampTwo()+"");
|
||||
if(order.getPinkId() > 0){
|
||||
if(getIsPinkUid(order.getPinkId(),order.getUid()) > 0) return;
|
||||
storePink.setKId(order.getPinkId());
|
||||
storePink.setStopTime("0");
|
||||
save(storePink);
|
||||
|
||||
//处理拼团完成
|
||||
Map<String, Object> map = getPinkMemberAndPinK(storePink);
|
||||
YxStorePink pinkT = (YxStorePink)map.get("pinkT");
|
||||
if(pinkT.getStatus() == 1){
|
||||
int count = (int)map.get("count");
|
||||
if(count == 0){//处理成功
|
||||
pinkComplete((List<Integer>)map.get("uidAll"),
|
||||
(List<Integer>)map.get("idAll"),order.getUid(),
|
||||
pinkT);
|
||||
}else{
|
||||
pinkFail((List<YxStorePink>)map.get("pinkAll"),pinkT,0);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
save(storePink);
|
||||
//pink_id更新到order表
|
||||
YxStoreOrder yxStoreOrder = new YxStoreOrder();
|
||||
yxStoreOrder.setPinkId(storePink.getId());
|
||||
yxStoreOrder.setId(order.getId());
|
||||
storeOrderService.updateById(yxStoreOrder);
|
||||
}
|
||||
|
||||
//todo 模板消息
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户是否在团内
|
||||
* @param id
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getIsPinkUid(int id, int uid) {
|
||||
QueryWrapper<YxStorePink> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("is_refund",0).eq("uid",uid).and(
|
||||
i->i.eq("k_id",id).or().eq("id",id));
|
||||
return yxStorePinkMapper.selectCount(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团完成的商品总件数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getPinkOkSumTotalNum() {
|
||||
return yxStorePinkMapper.sumNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团完成的用户
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPinkOkList(int uid) {
|
||||
List<String> list = new ArrayList<>();
|
||||
List<PinkDTO> pinkDTOList = yxStorePinkMapper.getPinkOkList(uid);
|
||||
for (PinkDTO pinkDTO : pinkDTOList) {
|
||||
list.add(pinkDTO.getNickname()+"拼团成功");
|
||||
}
|
||||
//list = pinkDTOList.stream().map(PinkDTO::getNickname).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPinkPeople(int kid, int people) {
|
||||
QueryWrapper<YxStorePink> wrapper= new QueryWrapper<>();
|
||||
wrapper.eq("k_id",kid).eq("is_refund",0);
|
||||
int count = yxStorePinkMapper.selectCount(wrapper) + 1;
|
||||
return people - count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取团长拼团数据
|
||||
* @param cid
|
||||
* @param isAll
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String,Object> getPinkAll(int cid, boolean isAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
List<PinkDTO> list = yxStorePinkMapper.getPinks(cid);
|
||||
if(isAll){
|
||||
List<Integer> pindAll = new ArrayList<>();
|
||||
for (PinkDTO pinkDTO : list) {
|
||||
pinkDTO.setCount(String.valueOf(getPinkPeople(pinkDTO.getId()
|
||||
,pinkDTO.getPeople())));
|
||||
Date date = DateUtil.parse(OrderUtil.stampToDate(pinkDTO.getStopTime()));
|
||||
System.out.println(date);
|
||||
pinkDTO.setH(String.valueOf(DateUtil.hour(date,true)));
|
||||
pinkDTO.setI(String.valueOf(DateUtil.minute(date)));
|
||||
pinkDTO.setS(String.valueOf(DateUtil.second(date)));
|
||||
pindAll.add(pinkDTO.getId());
|
||||
}
|
||||
|
||||
map.put("pindAll",pindAll);
|
||||
|
||||
}
|
||||
|
||||
map.put("list",list);
|
||||
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStorePinkQueryVo getYxStorePinkById(Serializable id){
|
||||
return yxStorePinkMapper.getYxStorePinkById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<YxStorePinkQueryVo> getYxStorePinkPageList(YxStorePinkQueryParam yxStorePinkQueryParam) throws Exception{
|
||||
Page page = setPageParam(yxStorePinkQueryParam,OrderItem.desc("create_time"));
|
||||
IPage<YxStorePinkQueryVo> iPage = yxStorePinkMapper.getYxStorePinkPageList(page,yxStorePinkQueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,289 @@
|
||||
package co.yixiang.modules.activity.web.controller;
|
||||
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.common.web.param.IdParam;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.activity.entity.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.entity.YxStorePink;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
import co.yixiang.modules.activity.web.param.YxStoreCombinationQueryParam;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
import co.yixiang.modules.user.entity.YxSystemAttachment;
|
||||
import co.yixiang.modules.user.service.YxSystemAttachmentService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.utils.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-19
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@Api(value = "拼团", tags = "拼团", description = "拼团")
|
||||
public class StoreCombinationController extends BaseController {
|
||||
|
||||
private final YxStoreCombinationService storeCombinationService;
|
||||
private final YxStorePinkService storePinkService;
|
||||
private final YxSystemConfigService systemConfigService;
|
||||
private final YxUserService yxUserService;
|
||||
private final YxSystemAttachmentService systemAttachmentService;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String path;
|
||||
|
||||
|
||||
/**
|
||||
* 拼团产品列表
|
||||
*/
|
||||
@GetMapping("/combination/list")
|
||||
@ApiOperation(value = "拼团产品列表",notes = "拼团产品列表",response = YxStoreCombinationQueryVo.class)
|
||||
public ApiResult<Object> getList(@RequestParam(value = "page",defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit",defaultValue = "10") int limit){
|
||||
|
||||
return ApiResult.ok(storeCombinationService.getList(page,limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团产品详情
|
||||
*/
|
||||
@GetMapping("/combination/detail/{id}")
|
||||
@ApiOperation(value = "拼团产品详情",notes = "拼团产品详情",response = YxStoreCombinationQueryVo.class)
|
||||
public ApiResult<Object> detail(@PathVariable Integer id){
|
||||
if(ObjectUtil.isNull(id)) return ApiResult.fail("参数有误");
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
return ApiResult.ok(storeCombinationService.getDetail(id,uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团明细
|
||||
*/
|
||||
@GetMapping("/combination/pink/{id}")
|
||||
@ApiOperation(value = "拼团明细",notes = "拼团明细")
|
||||
public ApiResult<Object> pink(@PathVariable Integer id){
|
||||
if(ObjectUtil.isNull(id)) return ApiResult.fail("参数有误");
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
return ApiResult.ok(storePinkService.pinkInfo(id,uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团海报
|
||||
*/
|
||||
@PostMapping("/combination/poster")
|
||||
@ApiOperation(value = "拼团海报",notes = "拼团海报")
|
||||
public ApiResult<Object> poster(@RequestBody String jsonStr){
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
Integer pinkId = jsonObject.getInteger("id");
|
||||
if(ObjectUtil.isNull(pinkId)) return ApiResult.fail("参数有误");
|
||||
|
||||
String siteUrl = systemConfigService.getData("site_url");
|
||||
if(StrUtil.isEmpty(siteUrl)){
|
||||
return ApiResult.fail("未配置h5地址");
|
||||
}
|
||||
String apiUrl = systemConfigService.getData("api_url");
|
||||
if(StrUtil.isEmpty(siteUrl)){
|
||||
return ApiResult.fail("未配置api地址");
|
||||
}
|
||||
YxStorePink storePink = storePinkService.getPinkUserOne(pinkId);
|
||||
if(ObjectUtil.isNull(storePink)) return ApiResult.fail("拼团不存在");
|
||||
YxStoreCombinationQueryVo storeCombination = storeCombinationService.getCombinationT(storePink.getCid());
|
||||
if(ObjectUtil.isNull(storeCombination)) return ApiResult.fail("拼团产品不存在");
|
||||
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
YxUserQueryVo userInfo = yxUserService.getYxUserById(uid);
|
||||
String name = pinkId+"_"+uid + "_"+userInfo.getIsPromoter()+"_pink_share_wap.jpg";
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String fileDir = path+"qrcode"+ File.separator;
|
||||
String qrcodeUrl = "";
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
//生成二维码
|
||||
//String fileDir = path+"qrcode"+File.separator;
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
QrCodeUtil.generate(siteUrl+"/activity/group_rule/"+pinkId+"?spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
|
||||
systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
|
||||
fileDir+name,"qrcode/"+name);
|
||||
|
||||
qrcodeUrl = fileDir+name;
|
||||
}else{
|
||||
qrcodeUrl = attachment.getAttDir();
|
||||
}
|
||||
|
||||
String spreadPicName = pinkId+"_"+uid + "_"+userInfo.getIsPromoter()+"_pink_user_spread.jpg";
|
||||
String spreadPicPath = fileDir+spreadPicName;
|
||||
|
||||
YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName);
|
||||
String spreadUrl = "";
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream("poster.jpg");
|
||||
InputStream streamT = getClass().getClassLoader()
|
||||
.getResourceAsStream("simsunb.ttf");
|
||||
File newFile = new File("poster.jpg");
|
||||
File newFileT = new File("simsunb.ttf");
|
||||
try {
|
||||
FileUtils.copyInputStreamToFile(stream, newFile);
|
||||
FileUtils.copyInputStreamToFile(streamT, newFileT);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(ObjectUtil.isNull(attachmentT)){
|
||||
try {
|
||||
|
||||
//第一步标题
|
||||
Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT);
|
||||
Font f= font.deriveFont(Font.PLAIN,40);
|
||||
//font.
|
||||
ImgUtil.pressText(//
|
||||
newFile,
|
||||
FileUtil.file(spreadPicPath),
|
||||
storeCombination.getTitle(),
|
||||
Color.BLACK,
|
||||
f, //字体
|
||||
0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
-480, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
|
||||
);
|
||||
|
||||
Font f2= font.deriveFont(Font.PLAIN,45);
|
||||
//第2步价格
|
||||
ImgUtil.pressText(//
|
||||
FileUtil.file(spreadPicPath),
|
||||
FileUtil.file(spreadPicPath),
|
||||
storePink.getTotalPrice().toString(),
|
||||
Color.RED,
|
||||
f2, //字体
|
||||
-160, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
-380, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
|
||||
);
|
||||
|
||||
Font f3= font.deriveFont(Font.PLAIN,30);
|
||||
//第3步几人团
|
||||
ImgUtil.pressText(//
|
||||
FileUtil.file(spreadPicPath),
|
||||
FileUtil.file(spreadPicPath),
|
||||
storePink.getPeople()+"人团",
|
||||
Color.WHITE,
|
||||
f3, //字体
|
||||
90, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
-385, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
|
||||
);
|
||||
|
||||
//第4步介绍
|
||||
String pro = "原价¥"+storeCombination.getProductPrice()+" 还差"
|
||||
+storePinkService.surplusPeople(storePink)+"人拼团成功";
|
||||
ImgUtil.pressText(//
|
||||
FileUtil.file(spreadPicPath),
|
||||
FileUtil.file(spreadPicPath),
|
||||
pro,
|
||||
Color.BLACK,
|
||||
f3, //字体
|
||||
-50, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
-300, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
|
||||
);
|
||||
|
||||
//第5步商品图片
|
||||
//下载图片
|
||||
String picImage = fileDir+pinkId+"_pink_image.jpg";
|
||||
HttpUtil.downloadFile(storeCombination.getImage(),
|
||||
FileUtil.file(picImage));
|
||||
|
||||
ImgUtil.scale(
|
||||
FileUtil.file(picImage),
|
||||
FileUtil.file(picImage),
|
||||
0.5f//缩放比例
|
||||
);
|
||||
|
||||
ImgUtil.pressImage(
|
||||
FileUtil.file(spreadPicPath),
|
||||
FileUtil.file(spreadPicPath),
|
||||
ImgUtil.read(FileUtil.file(picImage)), //水印图片
|
||||
0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
-80, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f
|
||||
);
|
||||
|
||||
ImgUtil.pressImage(
|
||||
FileUtil.file(spreadPicPath),
|
||||
FileUtil.file(spreadPicPath),
|
||||
ImgUtil.read(FileUtil.file(qrcodeUrl)), //水印图片
|
||||
0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
390, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f
|
||||
);
|
||||
|
||||
systemAttachmentService.attachmentAdd(spreadPicName,
|
||||
String.valueOf(FileUtil.size(new File(spreadPicPath))),
|
||||
spreadPicPath,"qrcode/"+spreadPicName);
|
||||
|
||||
spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir();
|
||||
}
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("url",spreadUrl);
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消开团
|
||||
*/
|
||||
@PostMapping("/combination/remove")
|
||||
@ApiOperation(value = "取消开团",notes = "取消开团")
|
||||
public ApiResult<Object> remove(@RequestBody String jsonStr){
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
Integer pinkId = jsonObject.getInteger("id");
|
||||
Integer cId = jsonObject.getInteger("cid");
|
||||
if(ObjectUtil.isNull(pinkId) || ObjectUtil.isNull(cId)) return ApiResult.fail("参数有误");
|
||||
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
storePinkService.removePink(uid,cId,pinkId);
|
||||
|
||||
return ApiResult.ok("ok");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package co.yixiang.modules.activity.web.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName PinkDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/19
|
||||
**/
|
||||
@Data
|
||||
public class PinkDTO implements Serializable {
|
||||
private Integer id;
|
||||
private Integer uid;
|
||||
private Integer people;
|
||||
private Double price;
|
||||
private String stopTime;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
|
||||
|
||||
private String count;
|
||||
private String h;
|
||||
private String i;
|
||||
private String s;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package co.yixiang.modules.activity.web.dto;
|
||||
|
||||
import co.yixiang.modules.activity.entity.YxStorePink;
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo;
|
||||
import co.yixiang.modules.activity.web.vo.YxStorePinkQueryVo;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName PinkInfoDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/20
|
||||
**/
|
||||
@Data
|
||||
public class PinkInfoDTO implements Serializable {
|
||||
private Integer count;
|
||||
private String currentPinkOrder;
|
||||
private Integer isOk = 0;
|
||||
private List<YxStorePinkQueryVo> pinkAll;
|
||||
private Integer pinkBool = 0;
|
||||
private YxStorePinkQueryVo pinkT;
|
||||
private YxStoreCombinationQueryVo storeCombination;
|
||||
private String storeCombinationHost;
|
||||
private Integer userBool = 0;
|
||||
private YxUserQueryVo userInfo;
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package co.yixiang.modules.activity.web.dto;
|
||||
|
||||
import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreProductReplyQueryVo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团产品表 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-11-19
|
||||
*/
|
||||
@Data
|
||||
public class StoreCombinationDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<PinkDTO> pink;
|
||||
|
||||
private List<Integer> pindAll;
|
||||
|
||||
private List<String> pinkOkList;
|
||||
|
||||
private Integer pinkOkSum;
|
||||
|
||||
private YxStoreProductReplyQueryVo reply;
|
||||
|
||||
private Integer replyCount = 0;
|
||||
|
||||
private String replyChance;
|
||||
private YxStoreCombinationQueryVo storeInfo;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package co.yixiang.modules.activity.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import co.yixiang.common.web.param.QueryParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团产品表 查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-11-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="YxStoreCombinationQueryParam对象", description="拼团产品表查询参数")
|
||||
public class YxStoreCombinationQueryParam extends QueryParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package co.yixiang.modules.activity.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import co.yixiang.common.web.param.QueryParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团表 查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-11-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="YxStorePinkQueryParam对象", description="拼团表查询参数")
|
||||
public class YxStorePinkQueryParam extends QueryParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
package co.yixiang.modules.activity.web.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团产品表 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-11-19
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "YxStoreCombinationQueryVo对象", description = "拼团产品表查询参数")
|
||||
public class YxStoreCombinationQueryVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
|
||||
@ApiModelProperty(value = "推荐图")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String images;
|
||||
|
||||
private List<String> sliderImageArr;
|
||||
|
||||
public List<String> getSliderImageArr() {
|
||||
if(StrUtil.isNotEmpty(images)){
|
||||
return Arrays.asList(images.split(","));
|
||||
}else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "活动标题")
|
||||
private String title;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "参团人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "价格")
|
||||
private BigDecimal price;
|
||||
|
||||
private BigDecimal productPrice;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
private Integer combination;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮1是0否")
|
||||
private Integer isPostage;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "拼团内容")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "拼团开始时间")
|
||||
private Integer startTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团结束时间")
|
||||
private Integer stopTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团订单有效时间")
|
||||
private Integer effectiveTime;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browse;
|
||||
|
||||
@ApiModelProperty(value = "单位名")
|
||||
private String unitName;
|
||||
|
||||
private Date endTimeDate;
|
||||
|
||||
private Date startTimeDate;
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package co.yixiang.modules.activity.web.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼团表 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-11-19
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "YxStorePinkQueryVo对象", description = "拼团表查询参数")
|
||||
public class YxStorePinkQueryVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer uid;
|
||||
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "订单id 生成")
|
||||
private String orderId;
|
||||
|
||||
@ApiModelProperty(value = "订单id 数据库")
|
||||
private Integer orderIdKey;
|
||||
|
||||
@ApiModelProperty(value = "购买商品个数")
|
||||
private Integer totalNum;
|
||||
|
||||
@ApiModelProperty(value = "购买总金额")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
@ApiModelProperty(value = "拼团产品id")
|
||||
private Integer cid;
|
||||
|
||||
@ApiModelProperty(value = "产品id")
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty(value = "拼图总人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "拼团产品单价")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private String addTime;
|
||||
|
||||
private String stopTime;
|
||||
|
||||
@ApiModelProperty(value = "团长id 0为团长")
|
||||
private Integer kId;
|
||||
|
||||
@ApiModelProperty(value = "是否发送模板消息0未发送1已发送")
|
||||
private Integer isTpl;
|
||||
|
||||
@ApiModelProperty(value = "是否退款 0未退款 1已退款")
|
||||
private Integer isRefund;
|
||||
|
||||
@ApiModelProperty(value = "状态1进行中2已完成3未完成")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -26,6 +26,8 @@ import java.util.List;
|
||||
*/
|
||||
public interface YxStoreOrderService extends BaseService<YxStoreOrder> {
|
||||
|
||||
YxStoreOrder getOrderPink(int pid,int uid,int type);
|
||||
|
||||
void regressionCoupon(YxStoreOrderQueryVo order);
|
||||
|
||||
void regressionStock(YxStoreOrderQueryVo order);
|
||||
|
@ -3,6 +3,8 @@ package co.yixiang.modules.order.service.impl;
|
||||
import cn.hutool.core.util.*;
|
||||
import co.yixiang.common.constant.CacheKey;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
import co.yixiang.modules.monitor.service.RedisService;
|
||||
import co.yixiang.modules.order.entity.YxStoreOrder;
|
||||
import co.yixiang.modules.order.entity.YxStoreOrderCartInfo;
|
||||
@ -134,12 +136,26 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
@Autowired
|
||||
private YxStoreCouponUserMapper yxStoreCouponUserMapper;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCombinationService combinationService;
|
||||
|
||||
@Autowired
|
||||
private YxStorePinkService pinkService;
|
||||
|
||||
// @Autowired
|
||||
// private DelayJobService delayJobService;
|
||||
|
||||
|
||||
@Value("${job.unpayorder}")
|
||||
private String overtime;
|
||||
// @Value("${job.unpayorder}")
|
||||
// private String overtime;
|
||||
|
||||
@Override
|
||||
public YxStoreOrder getOrderPink(int pid, int uid,int type) {
|
||||
QueryWrapper<YxStoreOrder> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("is_del",0).eq("uid",uid).eq("pink_id",pid);
|
||||
if(type == 0) wrapper.eq("refund_status",0);
|
||||
return yxStoreOrderMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退回优惠券
|
||||
@ -551,10 +567,25 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
}else if(order.getStatus() == 0){
|
||||
//todo 拼团
|
||||
//todo 店铺核销
|
||||
statusDTO.set_class("state-nfh");
|
||||
statusDTO.set_msg("商家未发货,请耐心等待");
|
||||
statusDTO.set_type("1");
|
||||
statusDTO.set_title("未发货");
|
||||
if(order.getPinkId() > 0){
|
||||
if(pinkService.pinkIngCount(order.getPinkId()) > 0){
|
||||
statusDTO.set_class("state-nfh");
|
||||
statusDTO.set_msg("待其他人参加拼团");
|
||||
statusDTO.set_type("1");
|
||||
statusDTO.set_title("拼团中");
|
||||
}else{
|
||||
statusDTO.set_class("state-nfh");
|
||||
statusDTO.set_msg("商家未发货,请耐心等待");
|
||||
statusDTO.set_type("1");
|
||||
statusDTO.set_title("未发货");
|
||||
}
|
||||
}else{
|
||||
statusDTO.set_class("state-nfh");
|
||||
statusDTO.set_msg("商家未发货,请耐心等待");
|
||||
statusDTO.set_type("1");
|
||||
statusDTO.set_title("未发货");
|
||||
}
|
||||
|
||||
}else if(order.getStatus() == 1){
|
||||
statusDTO.set_class("state-ysh");
|
||||
statusDTO.set_msg("服务商已发货");
|
||||
@ -610,6 +641,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
|
||||
|
||||
//todo 拼团
|
||||
pinkService.createPink(orderInfo);
|
||||
|
||||
//todo 模板消息推送
|
||||
}
|
||||
|
||||
@ -692,6 +725,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public YxStoreOrder createOrder(int uid, String key, OrderParam param) {
|
||||
YxUserQueryVo userInfo = userService.getYxUserById(uid);
|
||||
if(ObjectUtil.isNull(userInfo)) throw new ErrorRequestException("用户不存在");
|
||||
@ -716,17 +750,22 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
Integer totalNum = 0;
|
||||
Integer gainIntegral = 0;
|
||||
List<String> cartIds = new ArrayList<>();
|
||||
int combinationId = 0;
|
||||
|
||||
for (YxStoreCartQueryVo cart : cartInfo) {
|
||||
combinationId = cart.getCombinationId();
|
||||
cartIds.add(cart.getId().toString());
|
||||
totalNum += cart.getCartNum();
|
||||
//计算积分
|
||||
BigDecimal cartInfoGainIntegral = BigDecimal.ZERO;
|
||||
if(cart.getProductInfo().getGiveIntegral().intValue() > 0){
|
||||
cartInfoGainIntegral = NumberUtil.mul(cart.getCartNum(),cart.
|
||||
getProductInfo().getGiveIntegral());
|
||||
if(combinationId == 0 ){//拼团等活动不参与积分
|
||||
if(cart.getProductInfo().getGiveIntegral().intValue() > 0){
|
||||
cartInfoGainIntegral = NumberUtil.mul(cart.getCartNum(),cart.
|
||||
getProductInfo().getGiveIntegral());
|
||||
}
|
||||
gainIntegral = NumberUtil.add(gainIntegral,cartInfoGainIntegral).intValue();
|
||||
}
|
||||
gainIntegral = NumberUtil.add(gainIntegral,cartInfoGainIntegral).intValue();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -745,6 +784,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
int useIntegral = param.getUseIntegral().intValue();
|
||||
|
||||
boolean deduction = false;//todo 拼团等
|
||||
//拼团等不参与抵扣
|
||||
if(combinationId > 0) deduction = true;
|
||||
if(deduction){
|
||||
couponId = 0;
|
||||
useIntegral = 0;
|
||||
@ -828,8 +869,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
storeOrder.setUseIntegral(BigDecimal.valueOf(usedIntegral));
|
||||
storeOrder.setGainIntegral(BigDecimal.valueOf(gainIntegral));
|
||||
storeOrder.setMark(param.getMark());
|
||||
storeOrder.setCombinationId(0);
|
||||
storeOrder.setPinkId(0);
|
||||
storeOrder.setCombinationId(combinationId);
|
||||
storeOrder.setPinkId(param.getPinkId());
|
||||
storeOrder.setSeckillId(0);
|
||||
storeOrder.setBargainId(0);
|
||||
storeOrder.setCost(BigDecimal.valueOf(cacheDTO.getPriceGroup().getCostPrice()));
|
||||
@ -843,8 +884,13 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
|
||||
//减库存加销量
|
||||
for (YxStoreCartQueryVo cart : cartInfo) {
|
||||
productService.decProductStock(cart.getCartNum(),cart.getProductId(),
|
||||
cart.getProductAttrUnique());
|
||||
if(combinationId > 0){
|
||||
combinationService.decStockIncSales(cart.getCartNum(),combinationId);
|
||||
}else {
|
||||
productService.decProductStock(cart.getCartNum(),cart.getProductId(),
|
||||
cart.getProductAttrUnique());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//保存购物车商品信息
|
||||
@ -901,6 +947,15 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
Double payPostage = cacheDTO.getPriceGroup().getStorePostage();
|
||||
|
||||
boolean deduction = false;//todo 拼团等
|
||||
int combinationId = 0;
|
||||
List<YxStoreCartQueryVo> cartInfo = cacheDTO.getCartInfo();
|
||||
for (YxStoreCartQueryVo cart : cartInfo) {
|
||||
combinationId = cart.getCombinationId();
|
||||
}
|
||||
//拼团等不参与抵扣
|
||||
if(combinationId > 0) deduction = true;
|
||||
|
||||
|
||||
if(deduction){
|
||||
couponId = 0;
|
||||
useIntegral = 0;
|
||||
|
@ -7,6 +7,7 @@ import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.common.web.param.IdParam;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
import co.yixiang.modules.order.entity.YxStoreOrder;
|
||||
import co.yixiang.modules.order.entity.YxStoreOrderCartInfo;
|
||||
import co.yixiang.modules.order.service.YxStoreOrderCartInfoService;
|
||||
@ -66,6 +67,7 @@ public class StoreOrderController extends BaseController {
|
||||
private final YxStoreOrderStatusService orderStatusService;
|
||||
private final YxStoreCouponUserService couponUserService;
|
||||
private final YxSystemConfigService systemConfigService;
|
||||
private final YxStorePinkService storePinkService;
|
||||
|
||||
|
||||
/**
|
||||
@ -99,6 +101,15 @@ public class StoreOrderController extends BaseController {
|
||||
other.setIntegralRatio(systemConfigService.getData("integral_ratio"));
|
||||
|
||||
//todo 拼团 砍价 秒杀
|
||||
int combinationId = 0;
|
||||
if(cartId.split(",").length == 1){
|
||||
YxStoreCartQueryVo cartQueryVo = cartService.getYxStoreCartById(Integer
|
||||
.valueOf(cartId));
|
||||
combinationId = cartQueryVo.getCombinationId();
|
||||
}
|
||||
|
||||
//拼团砍价类产品不参与抵扣
|
||||
if(combinationId > 0) confirmOrderDTO.setDeduction(true);
|
||||
|
||||
confirmOrderDTO.setAddressInfo(addressService.getUserDefaultAddress(uid));
|
||||
|
||||
@ -309,11 +320,32 @@ public class StoreOrderController extends BaseController {
|
||||
String useIntegral = jsonObject.getString("useIntegral");
|
||||
//todo 砍价
|
||||
//todo 拼团
|
||||
if(ObjectUtil.isNotNull(jsonObject.getInteger("pinkId"))){
|
||||
int pinkId = jsonObject.getInteger("pinkId");
|
||||
YxStoreOrder yxStoreOrder = storeOrderService.getOrderPink(pinkId,uid,1);
|
||||
if(storePinkService.getIsPinkUid(pinkId,uid) > 0){
|
||||
map.put("status","ORDER_EXIST");
|
||||
OrderExtendDTO orderExtendDTO = new OrderExtendDTO();
|
||||
orderExtendDTO.setOrderId(yxStoreOrder.getOrderId());
|
||||
map.put("result",orderExtendDTO);
|
||||
return ApiResult.ok(map,"订单生成失败,你已经在该团内不能再参加了");
|
||||
}
|
||||
YxStoreOrder yxStoreOrderT = storeOrderService.getOrderPink(pinkId,uid,0);
|
||||
if(ObjectUtil.isNotNull(yxStoreOrderT)){
|
||||
map.put("status","ORDER_EXIST");
|
||||
OrderExtendDTO orderExtendDTO = new OrderExtendDTO();
|
||||
orderExtendDTO.setOrderId(yxStoreOrder.getOrderId());
|
||||
map.put("result",orderExtendDTO);
|
||||
return ApiResult.ok(map,"订单生成失败,你已经参加该团了,请先支付订单");
|
||||
}
|
||||
|
||||
}
|
||||
ComputeDTO computeDTO = storeOrderService.computedOrder(uid,key,
|
||||
Integer.valueOf(couponId),
|
||||
Integer.valueOf(useIntegral),
|
||||
Integer.valueOf(shippingType));
|
||||
|
||||
|
||||
map.put("result",computeDTO);
|
||||
map.put("status","NONE");
|
||||
return ApiResult.ok(map);
|
||||
|
@ -22,7 +22,7 @@ public class OrderParam implements Serializable {
|
||||
@NotBlank(message="请选择支付方式")
|
||||
private String payType;
|
||||
private String phone;
|
||||
private Integer pinkId;
|
||||
private Integer pinkId = 0;
|
||||
private String realName;
|
||||
private Integer seckillId;
|
||||
private Integer shippingType;
|
||||
|
@ -106,6 +106,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/register/verify").anonymous()
|
||||
.antMatchers("/register").anonymous()
|
||||
.antMatchers("/user/activity").anonymous()
|
||||
.antMatchers("/combination/list").anonymous()
|
||||
//微信相关
|
||||
.antMatchers("/wechat/config").anonymous()
|
||||
.antMatchers("/wechat/auth").anonymous()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package co.yixiang.modules.shop.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import co.yixiang.common.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -21,118 +22,118 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="YxStoreProduct对象", description="商品表")
|
||||
@ApiModel(value = "YxStoreProduct对象", description = "商品表")
|
||||
public class YxStoreProduct extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "商品id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)")
|
||||
private Integer merId;
|
||||
@ApiModelProperty(value = "商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)")
|
||||
private Integer merId;
|
||||
|
||||
@ApiModelProperty(value = "商品图片")
|
||||
private String image;
|
||||
@ApiModelProperty(value = "商品图片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String sliderImage;
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String sliderImage;
|
||||
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String storeName;
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty(value = "商品简介")
|
||||
private String storeInfo;
|
||||
@ApiModelProperty(value = "商品简介")
|
||||
private String storeInfo;
|
||||
|
||||
@ApiModelProperty(value = "关键字")
|
||||
private String keyword;
|
||||
@ApiModelProperty(value = "关键字")
|
||||
private String keyword;
|
||||
|
||||
@ApiModelProperty(value = "产品条码(一维码)")
|
||||
private String barCode;
|
||||
@ApiModelProperty(value = "产品条码(一维码)")
|
||||
private String barCode;
|
||||
|
||||
@ApiModelProperty(value = "分类id")
|
||||
private String cateId;
|
||||
@ApiModelProperty(value = "分类id")
|
||||
private String cateId;
|
||||
|
||||
@ApiModelProperty(value = "商品价格")
|
||||
private BigDecimal price;
|
||||
@ApiModelProperty(value = "商品价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "会员价格")
|
||||
private BigDecimal vipPrice;
|
||||
@ApiModelProperty(value = "会员价格")
|
||||
private BigDecimal vipPrice;
|
||||
|
||||
@ApiModelProperty(value = "市场价")
|
||||
private BigDecimal otPrice;
|
||||
@ApiModelProperty(value = "市场价")
|
||||
private BigDecimal otPrice;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "单位名")
|
||||
private String unitName;
|
||||
@ApiModelProperty(value = "单位名")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "状态(0:未上架,1:上架)")
|
||||
private Integer isShow;
|
||||
@ApiModelProperty(value = "状态(0:未上架,1:上架)")
|
||||
private Integer isShow;
|
||||
|
||||
@ApiModelProperty(value = "是否热卖")
|
||||
private Integer isHot;
|
||||
@ApiModelProperty(value = "是否热卖")
|
||||
private Integer isHot;
|
||||
|
||||
@ApiModelProperty(value = "是否优惠")
|
||||
private Integer isBenefit;
|
||||
@ApiModelProperty(value = "是否优惠")
|
||||
private Integer isBenefit;
|
||||
|
||||
@ApiModelProperty(value = "是否精品")
|
||||
private Integer isBest;
|
||||
@ApiModelProperty(value = "是否精品")
|
||||
private Integer isBest;
|
||||
|
||||
@ApiModelProperty(value = "是否新品")
|
||||
private Integer isNew;
|
||||
@ApiModelProperty(value = "是否新品")
|
||||
private Integer isNew;
|
||||
|
||||
@ApiModelProperty(value = "产品描述")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "产品描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Integer addTime;
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Integer addTime;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮")
|
||||
private Integer isPostage;
|
||||
@ApiModelProperty(value = "是否包邮")
|
||||
private Integer isPostage;
|
||||
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
private Integer isDel;
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
private Integer isDel;
|
||||
|
||||
@ApiModelProperty(value = "商户是否代理 0不可代理1可代理")
|
||||
private Integer merUse;
|
||||
@ApiModelProperty(value = "商户是否代理 0不可代理1可代理")
|
||||
private Integer merUse;
|
||||
|
||||
@ApiModelProperty(value = "获得积分")
|
||||
private BigDecimal giveIntegral;
|
||||
@ApiModelProperty(value = "获得积分")
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
@ApiModelProperty(value = "成本价")
|
||||
private BigDecimal cost;
|
||||
@ApiModelProperty(value = "成本价")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "秒杀状态 0 未开启 1已开启")
|
||||
private Integer isSeckill;
|
||||
@ApiModelProperty(value = "秒杀状态 0 未开启 1已开启")
|
||||
private Integer isSeckill;
|
||||
|
||||
@ApiModelProperty(value = "砍价状态 0未开启 1开启")
|
||||
private Integer isBargain;
|
||||
@ApiModelProperty(value = "砍价状态 0未开启 1开启")
|
||||
private Integer isBargain;
|
||||
|
||||
@ApiModelProperty(value = "是否优品推荐")
|
||||
private Integer isGood;
|
||||
@ApiModelProperty(value = "是否优品推荐")
|
||||
private Integer isGood;
|
||||
|
||||
@ApiModelProperty(value = "虚拟销量")
|
||||
private Integer ficti;
|
||||
@ApiModelProperty(value = "虚拟销量")
|
||||
private Integer ficti;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browse;
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browse;
|
||||
|
||||
@ApiModelProperty(value = "产品二维码地址(用户小程序海报)")
|
||||
private String codePath;
|
||||
@ApiModelProperty(value = "产品二维码地址(用户小程序海报)")
|
||||
private String codePath;
|
||||
|
||||
@ApiModelProperty(value = "淘宝京东1688类型")
|
||||
private String soureLink;
|
||||
@ApiModelProperty(value = "淘宝京东1688类型")
|
||||
private String soureLink;
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public interface YxStoreCartService extends BaseService<YxStoreCart> {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxStoreCartQueryVo getYxStoreCartById(Serializable id) throws Exception;
|
||||
YxStoreCartQueryVo getYxStoreCartById(Serializable id);
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package co.yixiang.modules.shop.service.impl;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.activity.entity.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.mapper.YxStoreCombinationMapper;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.shop.entity.YxStoreCart;
|
||||
import co.yixiang.modules.shop.entity.YxStoreProductAttrValue;
|
||||
import co.yixiang.modules.shop.mapper.YxStoreCartMapper;
|
||||
@ -60,6 +63,12 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
@Autowired
|
||||
private YxStoreProductAttrService productAttrService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCombinationService storeCombinationService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCombinationMapper storeCombinationMapper;
|
||||
|
||||
@Autowired
|
||||
private CartMap cartMap;
|
||||
|
||||
@ -137,10 +146,15 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
List<YxStoreCartQueryVo> invalid = new ArrayList<>();
|
||||
|
||||
for (YxStoreCart storeCart : carts) {
|
||||
YxStoreProductQueryVo storeProduct = productService
|
||||
.getYxStoreProductById(storeCart.getProductId());
|
||||
YxStoreProductQueryVo storeProduct = null;
|
||||
if(storeCart.getCombinationId() > 0){
|
||||
storeProduct = storeCombinationMapper.combinatiionInfo(storeCart.getCombinationId());
|
||||
}else{
|
||||
storeProduct = productService
|
||||
.getYxStoreProductById(storeCart.getProductId());
|
||||
}
|
||||
|
||||
YxStoreCartQueryVo storeCartQueryVo = cartMap.toDto(storeCart);
|
||||
//System.out.println(storeProduct);
|
||||
storeCartQueryVo.setProductInfo(storeProduct);
|
||||
if(ObjectUtil.isNull(storeProduct)){
|
||||
YxStoreCart yxStoreCart = new YxStoreCart();
|
||||
@ -158,7 +172,6 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
invalid.add(storeCartQueryVo);
|
||||
}else{
|
||||
storeProduct.setAttrInfo(productAttrValue);
|
||||
//todo 秒杀 砍价 拼团
|
||||
|
||||
//todo 设置真实价格
|
||||
storeCartQueryVo.setTruePrice(productAttrValue.getPrice()
|
||||
@ -173,6 +186,7 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
valid.add(storeCartQueryVo);
|
||||
}
|
||||
}else{
|
||||
|
||||
storeCartQueryVo.setTruePrice(storeProduct.getPrice()
|
||||
.doubleValue());
|
||||
//todo 设置会员价
|
||||
@ -207,16 +221,27 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
@Override
|
||||
public int addCart(int uid, int productId, int cartNum, String productAttrUnique,
|
||||
String type, int isNew, int combinationId, int seckillId, int bargainId) {
|
||||
YxStoreProductQueryVo productQueryVo = productService
|
||||
.getYxStoreProductById(productId);
|
||||
if(ObjectUtil.isNull(productQueryVo)){
|
||||
throw new ErrorRequestException("该产品已下架或删除");
|
||||
//todo 拼团
|
||||
if(combinationId > 0){
|
||||
boolean isStock = storeCombinationService.judgeCombinationStock(combinationId
|
||||
,cartNum);
|
||||
if(!isStock) throw new ErrorRequestException("该产品库存不足");
|
||||
|
||||
YxStoreCombination storeCombination = storeCombinationService.getCombination(combinationId);
|
||||
if(ObjectUtil.isNull(storeCombination)) throw new ErrorRequestException("该产品已下架或删除");
|
||||
}else{
|
||||
YxStoreProductQueryVo productQueryVo = productService
|
||||
.getYxStoreProductById(productId);
|
||||
if(ObjectUtil.isNull(productQueryVo)){
|
||||
throw new ErrorRequestException("该产品已下架或删除");
|
||||
}
|
||||
|
||||
int stock = productService.getProductStock(productId,productAttrUnique);
|
||||
if(stock < cartNum){
|
||||
throw new ErrorRequestException("该产品库存不足"+cartNum);
|
||||
}
|
||||
}
|
||||
|
||||
int stock = productService.getProductStock(productId,productAttrUnique);
|
||||
if(stock < cartNum){
|
||||
throw new ErrorRequestException("该产品库存不足"+cartNum);
|
||||
}
|
||||
|
||||
QueryWrapper<YxStoreCart> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("uid",uid).eq("type",type).eq("is_pay",0).eq("is_del",0)
|
||||
@ -265,7 +290,7 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreCartQueryVo getYxStoreCartById(Serializable id) throws Exception{
|
||||
public YxStoreCartQueryVo getYxStoreCartById(Serializable id){
|
||||
return yxStoreCartMapper.getYxStoreCartById(id);
|
||||
}
|
||||
|
||||
|
@ -91,9 +91,14 @@ public class YxStoreProductReplyServiceImpl extends BaseServiceImpl<YxStoreProdu
|
||||
public YxStoreProductReplyQueryVo handleReply(YxStoreProductReplyQueryVo replyQueryVo) {
|
||||
YxStoreCartQueryVo cartInfo = JSONObject.parseObject(replyQueryVo.getCartInfo()
|
||||
,YxStoreCartQueryVo.class);
|
||||
if(ObjectUtil.isNotEmpty(cartInfo.getProductInfo().getAttrInfo())){
|
||||
replyQueryVo.setSuk(cartInfo.getProductInfo().getAttrInfo().getSuk());
|
||||
if(ObjectUtil.isNotNull(cartInfo)){
|
||||
if(ObjectUtil.isNotNull(cartInfo.getProductInfo())){
|
||||
if(ObjectUtil.isNotNull(cartInfo.getProductInfo().getAttrInfo())){
|
||||
replyQueryVo.setSuk(cartInfo.getProductInfo().getAttrInfo().getSuk());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal star = NumberUtil.add(replyQueryVo.getProductScore(),
|
||||
replyQueryVo.getServiceScore());
|
||||
|
||||
|
@ -65,19 +65,31 @@ public class StoreCartController extends BaseController {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
int cartNum = Integer.valueOf(jsonObject.get("cartNum").toString());
|
||||
if(ObjectUtil.isNull(jsonObject.get("cartNum")) || ObjectUtil.isNull(jsonObject.get("productId"))){
|
||||
ApiResult.fail("参数有误");
|
||||
}
|
||||
int cartNum = jsonObject.getInteger("cartNum");
|
||||
if(cartNum <= 0){
|
||||
ApiResult.fail("购物车数量必须大于0");
|
||||
}
|
||||
int isNew = Integer.valueOf(jsonObject.get("new").toString());
|
||||
int productId = Integer.valueOf(jsonObject.get("productId").toString());
|
||||
int isNew = 1;
|
||||
if(ObjectUtil.isNotNull(jsonObject.get("new"))){
|
||||
isNew = jsonObject.getInteger("new");
|
||||
}
|
||||
int productId = jsonObject.getInteger("productId");
|
||||
if(productId <= 0){
|
||||
ApiResult.fail("产品参数有误");
|
||||
}
|
||||
String uniqueId = jsonObject.get("uniqueId").toString();
|
||||
|
||||
//拼团
|
||||
int combinationId = 0;
|
||||
if(ObjectUtil.isNotNull(jsonObject.get("combinationId"))){
|
||||
combinationId = jsonObject.getInteger("combinationId");
|
||||
}
|
||||
|
||||
map.put("cartId",storeCartService.addCart(uid,productId,cartNum,uniqueId
|
||||
,"product",isNew,0,0,0));
|
||||
,"product",isNew,combinationId,0,0));
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ public class YxStoreCartQueryVo implements Serializable {
|
||||
|
||||
private YxStoreProductQueryVo productInfo;
|
||||
|
||||
|
||||
private Double costPrice;
|
||||
|
||||
private Double truePrice;
|
||||
|
@ -9,6 +9,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -52,7 +53,12 @@ public class YxStoreProductQueryVo implements Serializable {
|
||||
|
||||
public List<String> getSliderImageArr() {
|
||||
//Arrays.asList(sliderImage.split(","));
|
||||
return Arrays.asList(sliderImage.split(","));
|
||||
if(StrUtil.isNotEmpty(sliderImage)){
|
||||
return Arrays.asList(sliderImage.split(","));
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
private YxStoreProductAttrValue attrInfo;
|
||||
|
@ -6,7 +6,7 @@ spring:
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://localhost:3306/yshop?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
||||
username: yshop
|
||||
password: yshoP@2019#yx
|
||||
password:
|
||||
|
||||
# 初始化配置
|
||||
initial-size: 3
|
||||
@ -48,7 +48,7 @@ spring:
|
||||
database: 0
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password: yshop2019@yxtw
|
||||
password:
|
||||
#连接超时时间
|
||||
timeout: 5000
|
||||
|
||||
|
@ -53,13 +53,13 @@ wx:
|
||||
mp:
|
||||
configs:
|
||||
- appId: wxc061dee8806ff712
|
||||
secret: 1dc5b2871d0d5ebd0f1ec7ddb856f805
|
||||
secret:
|
||||
token: yshop
|
||||
aesKey: yYuBUkC8BXImCXyu7O6hkzLj4TC5nxsWPfL4CQAZPNY
|
||||
pay:
|
||||
appId: wxc061dee8806ff712
|
||||
mchId: 1493624002
|
||||
mchKey: dayouqiantuhupeng8638004yixiangt
|
||||
mchId:
|
||||
mchKey:
|
||||
subAppId:
|
||||
subMchId:
|
||||
keyPath:
|
||||
|
@ -0,0 +1,18 @@
|
||||
<?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="co.yixiang.modules.activity.mapper.YxStoreCombinationMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, product_id, mer_id, image, images, title, attr, people, info, price, sort, sales, stock, add_time, is_host, is_show, is_del, combination, mer_use, is_postage, postage, description, start_time, stop_time, effective_time, cost, browse, unit_name, end_time_date, start_time_date
|
||||
</sql>
|
||||
|
||||
<select id="getYxStoreCombinationById" resultType="co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_store_combination where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getYxStoreCombinationPageList" resultType="co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_store_combination
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,18 @@
|
||||
<?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="co.yixiang.modules.activity.mapper.YxStorePinkMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, uid, order_id, order_id_key, total_num, total_price, cid, pid, people, price, add_time, stop_time, k_id, is_tpl, is_refund, status
|
||||
</sql>
|
||||
|
||||
<select id="getYxStorePinkById" resultType="co.yixiang.modules.activity.web.vo.YxStorePinkQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_store_pink where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getYxStorePinkPageList" resultType="co.yixiang.modules.activity.web.vo.YxStorePinkQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_store_pink
|
||||
</select>
|
||||
|
||||
</mapper>
|
BIN
yshop-api/src/main/resources/poster.jpg
Normal file
BIN
yshop-api/src/main/resources/poster.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
@ -41,13 +41,13 @@ public class CodeGenerator {
|
||||
|
||||
// ############################ 配置部分 start ############################
|
||||
// 模块名称
|
||||
private static final String MODULE_NAME = "user";
|
||||
private static final String MODULE_NAME = "activity";
|
||||
// 作者
|
||||
private static final String AUTHOR = "hupeng";
|
||||
// 生成的表名称
|
||||
private static final String TABLE_NAME = "yx_system_attachment";
|
||||
private static final String TABLE_NAME = "yx_store_pink";
|
||||
// 主键数据库列名称
|
||||
private static final String PK_ID_COLUMN_NAME = "att_id";
|
||||
private static final String PK_ID_COLUMN_NAME = "id";
|
||||
// 代码生成策略 true:All/false:SIMPLE
|
||||
private static final boolean GENERATOR_STRATEGY = true;
|
||||
// 分页列表查询是否排序 true:有排序参数/false:无
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -159,7 +159,7 @@ public class OrderUtil {
|
||||
}
|
||||
|
||||
//todo 订单类型
|
||||
public static String orderType(int pink_id){
|
||||
public static String orderType(int pinkId){
|
||||
return "普通订单";
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
|
||||
<!--模板引擎-->
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-generator</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>co.yixiang</groupId>
|
||||
@ -32,12 +32,12 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-tools</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-mp</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
|
||||
<!--jwt-->
|
||||
|
@ -53,8 +53,8 @@ public class YxStoreCombination implements Serializable {
|
||||
private String attr;
|
||||
|
||||
// 参团人数
|
||||
@Column(name = "people",nullable = false,insertable = false)
|
||||
@Min(value = 1,message = "拼团人数必须大于0")
|
||||
@Column(name = "people",nullable = false)
|
||||
@Min(value = 2,message = "拼团人数必须大于1")
|
||||
private Integer people;
|
||||
|
||||
// 简介
|
||||
@ -63,16 +63,16 @@ public class YxStoreCombination implements Serializable {
|
||||
private String info;
|
||||
|
||||
// 价格
|
||||
@Column(name = "price",nullable = false,insertable = false)
|
||||
@Column(name = "price",nullable = false)
|
||||
@Min(value = 0,message = "拼团价必须大于0")
|
||||
private BigDecimal price;
|
||||
|
||||
// 排序
|
||||
@Column(name = "sort",nullable = false,insertable = false)
|
||||
@Column(name = "sort",nullable = false)
|
||||
private Integer sort;
|
||||
|
||||
// 销量
|
||||
@Column(name = "sales",nullable = false,insertable = false)
|
||||
@Column(name = "sales",nullable = false)
|
||||
private Integer sales;
|
||||
|
||||
// 库存
|
||||
@ -102,11 +102,11 @@ public class YxStoreCombination implements Serializable {
|
||||
private Integer merUse;
|
||||
|
||||
// 是否包邮1是0否
|
||||
@Column(name = "is_postage",nullable = false,insertable = false)
|
||||
@Column(name = "is_postage",nullable = false)
|
||||
private Integer isPostage;
|
||||
|
||||
// 邮费
|
||||
@Column(name = "postage",nullable = false,insertable = false)
|
||||
@Column(name = "postage",nullable = false)
|
||||
private BigDecimal postage;
|
||||
|
||||
// 拼团内容
|
||||
|
@ -12,4 +12,9 @@ public interface YxStorePinkRepository extends JpaRepository<YxStorePink, Intege
|
||||
int countByCid(int cid);
|
||||
|
||||
int countByCidAndKId(int cid,int kid);
|
||||
|
||||
int countByKId(int kid);
|
||||
|
||||
YxStorePink findByOrderIdKey(int id);
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package co.yixiang.modules.activity.rest;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.modules.activity.domain.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreCombinationQueryCriteria;
|
||||
@ -44,6 +45,7 @@ public class YxStoreCombinationController {
|
||||
@PutMapping(value = "/yxStoreCombination")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTORECOMBINATION_ALL','YXSTORECOMBINATION_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody YxStoreCombination resources){
|
||||
//if(ObjectUtil.isNotNull(resources)) throw new BadRequestException("演示环境禁止操作");
|
||||
if(ObjectUtil.isNotNull(resources.getStartTimeDate())){
|
||||
resources.setStartTime(OrderUtil.
|
||||
dateToTimestamp(resources.getStartTimeDate()));
|
||||
@ -65,6 +67,7 @@ public class YxStoreCombinationController {
|
||||
@ApiOperation(value = "开启关闭")
|
||||
@PostMapping(value = "/yxStoreCombination/onsale/{id}")
|
||||
public ResponseEntity onSale(@PathVariable Integer id,@RequestBody String jsonStr){
|
||||
//if(id > 0) throw new BadRequestException("演示环境禁止操作");
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
int status = Integer.valueOf(jsonObject.get("status").toString());
|
||||
//System.out.println(status);
|
||||
@ -77,6 +80,7 @@ public class YxStoreCombinationController {
|
||||
@DeleteMapping(value = "/yxStoreCombination/{id}")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTORECOMBINATION_ALL','YXSTORECOMBINATION_DELETE')")
|
||||
public ResponseEntity delete(@PathVariable Integer id){
|
||||
//if(id > 0) throw new BadRequestException("演示环境禁止操作");
|
||||
YxStoreCombination combination = new YxStoreCombination();
|
||||
combination.setIsDel(1);
|
||||
yxStoreCombinationService.update(combination);
|
||||
|
@ -17,7 +17,7 @@ import io.swagger.annotations.*;
|
||||
* @author hupeng
|
||||
* @date 2019-11-18
|
||||
*/
|
||||
@Api(tags = "YxStorePink管理")
|
||||
@Api(tags = "拼团记录管理")
|
||||
@RestController
|
||||
@RequestMapping("api")
|
||||
public class YxStorePinkController {
|
||||
@ -25,8 +25,8 @@ public class YxStorePinkController {
|
||||
@Autowired
|
||||
private YxStorePinkService yxStorePinkService;
|
||||
|
||||
@Log("查询YxStorePink")
|
||||
@ApiOperation(value = "查询YxStorePink")
|
||||
@Log("查询记录")
|
||||
@ApiOperation(value = "查询记录")
|
||||
@GetMapping(value = "/yxStorePink")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTOREPINK_ALL','YXSTOREPINK_SELECT')")
|
||||
public ResponseEntity getYxStorePinks(YxStorePinkQueryCriteria criteria, Pageable pageable){
|
||||
|
@ -17,6 +17,8 @@ import java.util.List;
|
||||
//@CacheConfig(cacheNames = "yxStorePink")
|
||||
public interface YxStorePinkService {
|
||||
|
||||
int countPeople(int id);
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria
|
||||
|
@ -23,6 +23,14 @@ public class YxStorePinkDTO implements Serializable {
|
||||
// 订单id 数据库
|
||||
private Integer orderIdKey;
|
||||
|
||||
private String title;
|
||||
|
||||
private String nickname;
|
||||
|
||||
private String avatar;
|
||||
|
||||
private Integer countPeople;
|
||||
|
||||
// 购买商品个数
|
||||
private Integer totalNum;
|
||||
|
||||
|
@ -10,4 +10,6 @@ import co.yixiang.annotation.Query;
|
||||
*/
|
||||
@Data
|
||||
public class YxStorePinkQueryCriteria{
|
||||
@Query
|
||||
private Integer kId;
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
package co.yixiang.modules.activity.service.impl;
|
||||
|
||||
import co.yixiang.modules.activity.domain.YxStorePink;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreCombinationDTO;
|
||||
import co.yixiang.modules.shop.service.YxUserService;
|
||||
import co.yixiang.modules.shop.service.dto.YxUserDTO;
|
||||
import co.yixiang.utils.ValidationUtil;
|
||||
import co.yixiang.modules.activity.repository.YxStorePinkRepository;
|
||||
import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
@ -11,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@ -30,13 +36,47 @@ public class YxStorePinkServiceImpl implements YxStorePinkService {
|
||||
@Autowired
|
||||
private YxStorePinkRepository yxStorePinkRepository;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCombinationService combinationService;
|
||||
|
||||
@Autowired
|
||||
private YxUserService userService;
|
||||
|
||||
@Autowired
|
||||
private YxStorePinkMapper yxStorePinkMapper;
|
||||
|
||||
/**
|
||||
* 参与拼团的人
|
||||
* @param id id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int countPeople(int id) {
|
||||
return yxStorePinkRepository.countByKId(id) + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(YxStorePinkQueryCriteria criteria, Pageable pageable){
|
||||
Page<YxStorePink> page = yxStorePinkRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(yxStorePinkMapper::toDto));
|
||||
criteria.setKId(0);
|
||||
Page<YxStorePink> page = yxStorePinkRepository
|
||||
.findAll((root, criteriaQuery, criteriaBuilder)
|
||||
-> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
List<YxStorePinkDTO> storePinkDTOS = yxStorePinkMapper.toDto(page.getContent());
|
||||
for (YxStorePinkDTO storePinkDTO : storePinkDTOS) {
|
||||
YxStoreCombinationDTO combinationDTO = combinationService
|
||||
.findById(storePinkDTO.getCid());
|
||||
YxUserDTO userDTO = userService.findById(storePinkDTO.getUid());
|
||||
|
||||
storePinkDTO.setAvatar(userDTO.getAvatar());
|
||||
storePinkDTO.setNickname(userDTO.getNickname());
|
||||
storePinkDTO.setTitle(combinationDTO.getTitle());
|
||||
storePinkDTO.setCountPeople(countPeople(storePinkDTO.getId()));
|
||||
}
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",storePinkDTOS);
|
||||
map.put("totalElements",page.getTotalElements());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,6 +14,8 @@ import java.util.List;
|
||||
//@CacheConfig(cacheNames = "yxStoreOrder")
|
||||
public interface YxStoreOrderService {
|
||||
|
||||
String orderType(int id,int pinkId,int combinationId);
|
||||
|
||||
void refund(YxStoreOrder resources);
|
||||
|
||||
/**
|
||||
|
@ -2,8 +2,12 @@ package co.yixiang.modules.shop.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.exception.EntityExistException;
|
||||
import co.yixiang.modules.activity.domain.YxStorePink;
|
||||
import co.yixiang.modules.activity.repository.YxStorePinkRepository;
|
||||
import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
import co.yixiang.modules.shop.domain.YxStoreOrder;
|
||||
import co.yixiang.modules.shop.domain.YxStoreOrderStatus;
|
||||
import co.yixiang.modules.shop.domain.YxUserBill;
|
||||
@ -63,6 +67,9 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
@Autowired
|
||||
private YxUserBillService yxUserBillService;
|
||||
|
||||
@Autowired
|
||||
private YxStorePinkRepository storePinkRepository;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refund(YxStoreOrder resources) {
|
||||
@ -104,6 +111,34 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
yxStoreOrderStatusService.create(storeOrderStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String orderType(int id,int pinkId, int combinationId) {
|
||||
String str = "[普通订单]";
|
||||
if(pinkId > 0 || combinationId > 0){
|
||||
YxStorePink storePink = storePinkRepository.findByOrderIdKey(id);
|
||||
if(ObjectUtil.isNull(storePink)) {
|
||||
str = "[拼团订单]";
|
||||
}else{
|
||||
switch (storePink.getStatus()){
|
||||
case 1:
|
||||
str = "[拼团订单]正在进行中";
|
||||
break;
|
||||
case 2:
|
||||
str = "[拼团订单]已完成";
|
||||
break;
|
||||
case 3:
|
||||
str = "[拼团订单]未完成";
|
||||
break;
|
||||
default:
|
||||
str = "[拼团订单]历史订单";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(YxStoreOrderQueryCriteria criteria, Pageable pageable){
|
||||
|
||||
@ -139,8 +174,8 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
,yxStoreOrder.getPaid());
|
||||
yxStoreOrderDTO.setPayTypeName(payTypeName);
|
||||
|
||||
String orderType = OrderUtil.orderType(1);
|
||||
yxStoreOrderDTO.setPinkName(orderType);
|
||||
yxStoreOrderDTO.setPinkName(orderType(yxStoreOrder.getId()
|
||||
,yxStoreOrder.getPinkId(),yxStoreOrder.getCombinationId()));
|
||||
|
||||
List<StoreOrderCartInfo> cartInfos = yxStoreOrderCartInfoRepository
|
||||
.findByOid(yxStoreOrder.getId());
|
||||
|
@ -94,7 +94,7 @@ public class MenuController {
|
||||
@DeleteMapping(value = "/menus/{id}")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_DELETE')")
|
||||
public ResponseEntity delete(@PathVariable Long id){
|
||||
// if(id>0) throw new BadRequestException("演示环境禁止操作");
|
||||
//if(id>0) throw new BadRequestException("演示环境禁止操作");
|
||||
List<Menu> menuList = menuService.findByPid(id);
|
||||
Set<Menu> menuSet = new HashSet<>();
|
||||
menuSet.add(menuService.findOne(id));
|
||||
|
@ -68,7 +68,7 @@ public class YxSystemConfigController {
|
||||
@PutMapping(value = "/yxSystemConfig")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSYSTEMCONFIG_ALL','YXSYSTEMCONFIG_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody YxSystemConfig resources){
|
||||
// if(ObjectUtil.isNotNull(resources)) throw new BadRequestException("演示环境禁止操作");
|
||||
//if(ObjectUtil.isNotNull(resources)) throw new BadRequestException("演示环境禁止操作");
|
||||
yxSystemConfigService.update(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
|
||||
<!--邮件依赖-->
|
||||
|
Reference in New Issue
Block a user