Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b0756654e | |||
| a55a89cd11 | |||
| 25e16e41eb | |||
| cd6dd0280f | |||
| f89a84f3ef | |||
| 412c017c96 | |||
| d64f5b4bbb | |||
| 392da5a396 | |||
| 565c82305c | |||
| 6e329f4226 | |||
|
|
dab9156c8f | ||
|
|
419f7c9886 |
@@ -85,7 +85,11 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
log.info("c"+String.valueOf(product.getProductCategoryId()));
|
||||
log.info("d"+String.valueOf(product.getProductAttributeCategoryId()));
|
||||
product.setOriginalPrice(productParam.getPrice());
|
||||
|
||||
productMapper.insertAll(product);
|
||||
productParam.getSkuStockList().forEach(item->{
|
||||
item.setPrice(product.getPrice());
|
||||
});
|
||||
//根据促销类型设置价格:、阶梯价格、满减价格
|
||||
Long productId = product.getId();
|
||||
//会员价格
|
||||
|
||||
@@ -27,4 +27,8 @@ public interface OmsOrderItemMapper {
|
||||
int updateByPrimaryKeySelective(OmsOrderItem record);
|
||||
|
||||
int updateByPrimaryKey(OmsOrderItem record);
|
||||
|
||||
OmsOrderItem selectByOrderId(Long orderId);
|
||||
|
||||
OmsOrderItem getByOrderSn(String orderSn);
|
||||
}
|
||||
@@ -33,4 +33,5 @@ public interface OmsOrderMapper {
|
||||
int updateByPrimaryKey(OmsOrder record);
|
||||
|
||||
|
||||
PmsProduct selectAll(@Param("orderSn") String orderSn);}
|
||||
PmsProduct selectAll(@Param("orderSn") String orderSn);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.buy507.mall.model.PmsProductFullReduction;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
public interface PmsProductMapper {
|
||||
long countByExample(PmsProductExample example);
|
||||
@@ -23,7 +24,9 @@ public interface PmsProductMapper {
|
||||
|
||||
List<PmsProduct> selectByExample(PmsProductExample example);
|
||||
|
||||
// @Select("select * from pms_product where id = #{id}")
|
||||
PmsProduct selectByPrimaryKey(Long id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") PmsProduct record, @Param("example") PmsProductExample example);
|
||||
|
||||
int updateByExampleWithBLOBs(@Param("record") PmsProduct record, @Param("example") PmsProductExample example);
|
||||
@@ -40,7 +43,8 @@ public interface PmsProductMapper {
|
||||
|
||||
PmsProduct getProductByOrderSn(String orderSn);
|
||||
|
||||
PmsProduct getPrimaryKey(Long id);
|
||||
|
||||
|
||||
int insertAll(PmsProduct product);
|
||||
|
||||
|
||||
}
|
||||
@@ -29,4 +29,5 @@ public interface PmsSkuStockMapper {
|
||||
int updateByPrimaryKey(PmsSkuStock record);
|
||||
|
||||
List<PmsSkuStock> getPmsSkuStock(Long id);
|
||||
|
||||
}
|
||||
@@ -31,12 +31,23 @@ public enum MemberLevel {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static MemberLevel getMemberByInt(int value){
|
||||
for (MemberLevel memberLevel : MemberLevel.values()) {
|
||||
if(value == memberLevel.value){
|
||||
return memberLevel;
|
||||
// 获取根据 ordinal 映射的 MemberLevel
|
||||
public static MemberLevel fromOrdinal(int ordinal) {
|
||||
MemberLevel[] levels = MemberLevel.values();
|
||||
if (ordinal >= 0 && ordinal < levels.length) {
|
||||
return levels[ordinal-1];
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid ordinal: " + ordinal);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
// 根据 value 获取 MemberLevel
|
||||
public static MemberLevel fromValue(int value) {
|
||||
for (MemberLevel level : MemberLevel.values()) {
|
||||
if (level.getValue() == value) {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid value: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ public class OmsOrderItem implements Serializable {
|
||||
@ApiModelProperty(value = "商品销售属性:[{'key':'颜色','value':'颜色'},{'key':'容量','value':'4G'}]")
|
||||
private String productAttr;
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Long getId() {
|
||||
|
||||
@@ -664,7 +664,7 @@ public class PmsProduct implements Serializable {
|
||||
|
||||
public void setVipCenter(Integer vipCenter) {this.vipCenter = vipCenter;}
|
||||
|
||||
public Integer getintergrationPrice() {return intergrationPrice;}
|
||||
public Integer getIntergrationPrice() {return intergrationPrice;}
|
||||
|
||||
public void setIntergrationPrice(Integer intergrationPrice) {this.intergrationPrice = intergrationPrice;}
|
||||
|
||||
|
||||
@@ -361,6 +361,11 @@ public class UmsMemberAccountTransactionExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFlowTypeEqualTo(Integer value) {
|
||||
addCriterion("flow_type =", value, "flowType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTransactionStateNotEqualTo(Integer value) {
|
||||
addCriterion("transaction_state <>", value, "transactionState");
|
||||
return (Criteria) this;
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
id, order_id, order_sn, product_id, product_pic, product_name, product_brand, product_sn,
|
||||
product_price, product_quantity, product_sku_id, product_sku_code, product_category_id,
|
||||
sp1, sp2, sp3, promotion_name, promotion_amount, coupon_amount, integration_amount,
|
||||
real_amount, gift_integration, gift_growth, product_attr
|
||||
real_amount, gift_integration, gift_growth, product_attr,intergrationPrice,intergrationExchange
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.buy507.mall.model.OmsOrderItemExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@@ -508,4 +508,39 @@
|
||||
product_attr = #{productAttr,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
|
||||
<select id="selectByOrderId" resultType="com.buy507.mall.model.OmsOrderItem">
|
||||
select * from mall.oms_order_item where order_id = #{orderId}
|
||||
|
||||
</select>
|
||||
<select id="getByOrderSn" resultType="com.buy507.mall.model.OmsOrderItem">
|
||||
select id,
|
||||
order_id,
|
||||
order_sn,
|
||||
product_id,
|
||||
product_pic,
|
||||
product_name,
|
||||
product_brand,
|
||||
product_sn,
|
||||
product_price,
|
||||
product_quantity,
|
||||
product_sku_id,
|
||||
product_sku_code,
|
||||
product_category_id,
|
||||
promotion_name,
|
||||
promotion_amount,
|
||||
coupon_amount,
|
||||
integration_amount,
|
||||
real_amount,
|
||||
gift_integration,
|
||||
gift_growth,
|
||||
product_attr,
|
||||
sp1,
|
||||
sp2,
|
||||
sp3,
|
||||
intergrationPrice,
|
||||
intergrationExchange
|
||||
from oms_order_item
|
||||
where order_sn = #{orderSn}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -926,4 +926,5 @@
|
||||
JOIN oms_order o ON oi.order_sn = o.order_sn
|
||||
WHERE o.order_sn = #{orderSn}
|
||||
</select>
|
||||
<select id="getPnameByOrderSn" resultType="java.lang.String"></select>
|
||||
</mapper>
|
||||
@@ -112,7 +112,7 @@
|
||||
verify_status, sort, sale, price, promotion_price, gift_growth, gift_point, use_point_limit,
|
||||
sub_title, original_price, stock, low_stock, unit, weight, preview_status, service_ids,
|
||||
keywords, note, album_pics, detail_title, promotion_start_time, promotion_end_time,
|
||||
promotion_per_limit, promotion_type, brand_name, product_category_name, distribution_flag
|
||||
promotion_per_limit, promotion_type, brand_name, product_category_name, distribution_flag,vip_status,points_area_status,points_exchange_status,intergration_price
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
description, detail_desc, detail_html, detail_mobile_html
|
||||
@@ -336,6 +336,9 @@
|
||||
<if test="detailMobileHtml != null">
|
||||
detail_mobile_html,
|
||||
</if>
|
||||
<if test="intergrationPrice != null">
|
||||
intergration_price,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="brandId != null">
|
||||
@@ -461,6 +464,9 @@
|
||||
<if test="detailMobileHtml != null">
|
||||
#{detailMobileHtml,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="intergrationPrice != null">
|
||||
#{intergration_price},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.buy507.mall.model.PmsProductExample" resultType="java.lang.Long">
|
||||
@@ -934,11 +940,65 @@
|
||||
SELECT p.*
|
||||
FROM pms_product p
|
||||
WHERE p.product_sn = (
|
||||
SELECT oi.product_sn
|
||||
SELECT DISTINCT oi.product_sn
|
||||
FROM oms_order_item oi
|
||||
WHERE oi.order_sn = #{orderSn}
|
||||
LIMIT 1
|
||||
)
|
||||
AND oi.product_sn IS NOT NULL
|
||||
limit 1
|
||||
);
|
||||
</select>
|
||||
|
||||
<select id="getPrimaryKey" resultType="com.buy507.mall.model.PmsProduct">
|
||||
SELECT p.id,
|
||||
p.brand_id,
|
||||
p.product_category_id,
|
||||
p.feight_template_id,
|
||||
p.product_attribute_category_id,
|
||||
p.name,
|
||||
p.pic,
|
||||
p.product_sn,
|
||||
p.delete_status,
|
||||
p.publish_status,
|
||||
p.new_status,
|
||||
p.recommand_status,
|
||||
p.verify_status,
|
||||
p.sort,
|
||||
p.sale,
|
||||
p.price,
|
||||
p.promotion_price,
|
||||
p.gift_growth,
|
||||
p.gift_point,
|
||||
p.use_point_limit,
|
||||
p.sub_title,
|
||||
p.description,
|
||||
p.original_price,
|
||||
p.stock,
|
||||
p.low_stock,
|
||||
p.unit,
|
||||
p.weight,
|
||||
p.preview_status,
|
||||
p.service_ids,
|
||||
p.keywords,
|
||||
p.note,
|
||||
p.album_pics,
|
||||
p.detail_title,
|
||||
p.detail_desc,
|
||||
p.detail_html,
|
||||
p.detail_mobile_html,
|
||||
p.promotion_start_time,
|
||||
p.promotion_end_time,
|
||||
p.promotion_per_limit,
|
||||
p.promotion_type,
|
||||
p.brand_name,
|
||||
p.product_category_name,
|
||||
p.distribution_flag,
|
||||
p.vip_status,
|
||||
p.points_area_status,
|
||||
p.points_exchange_status,
|
||||
p.intergration_price
|
||||
FROM pms_product p
|
||||
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertAll" useGeneratedKeys="true" parameterType="com.buy507.mall.model.PmsProduct">
|
||||
|
||||
@@ -341,4 +341,5 @@
|
||||
on ppa.id=ppav.product_attribute_id
|
||||
where pst.product_id=#{id,jdbcType=BIGINT}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -109,10 +109,10 @@
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
insert into ums_member_account_transaction (member_id, order_id, revenue_amount,
|
||||
transaction_state, remarks, commission_ratio, transfer_payment_time, revenue_points)
|
||||
transaction_state, remarks, commission_ratio, transfer_payment_time, revenue_points, flow_type)
|
||||
values (#{memberId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, #{revenueAmount,jdbcType=DECIMAL},
|
||||
#{transactionState,jdbcType=INTEGER}, #{remarks,jdbcType=VARCHAR}, #{commissionRatio,jdbcType=INTEGER},
|
||||
#{transferPaymentTime,jdbcType=TIMESTAMP}, #{revenuePoints,jdbcType=INTEGER})
|
||||
#{transferPaymentTime,jdbcType=TIMESTAMP}, #{revenuePoints,jdbcType=INTEGER}, #{flowType,jdbcType=INTEGER})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.buy507.mall.model.UmsMemberAccountTransaction">
|
||||
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
<!-- 微信小程序支付 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
@@ -95,24 +95,24 @@ public class HomeController {
|
||||
@RequestMapping(value = "/getVipProductList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<PmsProduct>> getVipProductList(){
|
||||
List<PmsProduct> productList = homeService.getVipProductList();
|
||||
return CommonResult.success(productList);
|
||||
List<PmsProduct> vipProductList = homeService.getVipProductList();
|
||||
return CommonResult.success(vipProductList);
|
||||
}
|
||||
|
||||
@ApiOperation("获取积分专区商品")
|
||||
@RequestMapping(value = "/getPointProductList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<PmsProduct>> getPointProductList(){
|
||||
List<PmsProduct> productList = homeService.getPointProductList();
|
||||
return CommonResult.success(productList);
|
||||
List<PmsProduct> pointProductList = homeService.getPointProductList();
|
||||
return CommonResult.success(pointProductList);
|
||||
}
|
||||
|
||||
@ApiOperation("获取积分兑换专区")
|
||||
@RequestMapping(value = "/getPointExchangeProductList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<PmsProduct>> getPointExchangeProductList(){
|
||||
List<PmsProduct> productList = homeService.getPointExchangeProductList();
|
||||
return CommonResult.success(productList);
|
||||
List<PmsProduct> pointExchangeProductList = homeService.getPointExchangeProductList();
|
||||
return CommonResult.success(pointExchangeProductList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,28 @@ public class OrderItemResult {
|
||||
@ApiModelProperty(value = "商品SKU属性3")
|
||||
private String sp3;
|
||||
|
||||
@ApiModelProperty("积分价格")
|
||||
private Integer intergrationPrice;
|
||||
|
||||
@ApiModelProperty("积分兑换专区")
|
||||
private Integer intergrationExchange;
|
||||
|
||||
public Integer getIntergrationPrice() {
|
||||
return intergrationPrice;
|
||||
}
|
||||
|
||||
public void setIntergrationPrice(Integer intergrationPrice) {
|
||||
this.intergrationPrice = intergrationPrice;
|
||||
}
|
||||
|
||||
public Integer getIntergrationExchange() {
|
||||
return intergrationExchange;
|
||||
}
|
||||
|
||||
public void setIntergrationExchange(Integer intergrationExchange) {
|
||||
this.intergrationExchange = intergrationExchange;
|
||||
}
|
||||
|
||||
public Long getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
@@ -113,6 +113,38 @@ public class OrderResult {
|
||||
@ApiModelProperty(value = "快速排队订单还剩邀请成功的人数")
|
||||
private Integer invitedCount;
|
||||
|
||||
@ApiModelProperty(value = "积分价格")
|
||||
private Integer intergrationPrice;
|
||||
|
||||
@ApiModelProperty(value = "积分兑换专区")
|
||||
private Integer intergrationExchange;
|
||||
|
||||
@ApiModelProperty(value = "订单类型")
|
||||
private Integer orderType;
|
||||
|
||||
public Integer getOrderType() {
|
||||
return orderType;
|
||||
}
|
||||
|
||||
public void setOrderType(Integer orderType) {
|
||||
this.orderType = orderType;
|
||||
}
|
||||
|
||||
public Integer getIntergrationExchange() {
|
||||
return intergrationExchange;
|
||||
}
|
||||
|
||||
public void setIntergrationExchange(Integer intergrationExchange) {
|
||||
this.intergrationExchange = intergrationExchange;
|
||||
}
|
||||
|
||||
public Integer getIntergrationPrice() {
|
||||
return intergrationPrice;
|
||||
}
|
||||
|
||||
public void setIntergrationPrice(Integer intergrationPrice) {
|
||||
this.intergrationPrice = intergrationPrice;
|
||||
}
|
||||
|
||||
public Long getOrderId() {
|
||||
return orderId;
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.buy507.mall.model.SmsCoupon;
|
||||
import com.buy507.mall.model.SmsCouponProductRelation;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
public class ProductDetailResult {
|
||||
private Long id;
|
||||
@@ -153,6 +154,52 @@ public class ProductDetailResult {
|
||||
|
||||
private int applauseRate;
|
||||
|
||||
@Transient
|
||||
@ApiModelProperty(value = "积分专区状态")
|
||||
private Integer pointsAreaStatus;
|
||||
|
||||
@Transient
|
||||
@ApiModelProperty(value = "积分兑换专区状态")
|
||||
private Integer pointsExchangeStatus;
|
||||
|
||||
@ApiModelProperty(value = "会员中心:1->店长; 2->代理; 3->市代理")
|
||||
private Integer vipCenter;
|
||||
|
||||
@ApiModelProperty(value = "商品积分价格")
|
||||
private Integer intergrationPrice;
|
||||
|
||||
public Integer getPointsAreaStatus() {
|
||||
return pointsAreaStatus;
|
||||
}
|
||||
|
||||
public void setPointsAreaStatus(Integer pointsAreaStatus) {
|
||||
this.pointsAreaStatus = pointsAreaStatus;
|
||||
}
|
||||
|
||||
public Integer getPointsExchangeStatus() {
|
||||
return pointsExchangeStatus;
|
||||
}
|
||||
|
||||
public void setPointsExchangeStatus(Integer pointsExchangeStatus) {
|
||||
this.pointsExchangeStatus = pointsExchangeStatus;
|
||||
}
|
||||
|
||||
public Integer getVipCenter() {
|
||||
return vipCenter;
|
||||
}
|
||||
|
||||
public void setVipCenter(Integer vipCenter) {
|
||||
this.vipCenter = vipCenter;
|
||||
}
|
||||
|
||||
public Integer getIntergrationPrice() {
|
||||
return intergrationPrice;
|
||||
}
|
||||
|
||||
public void setIntergrationPrice(Integer intergrationPrice) {
|
||||
this.intergrationPrice = intergrationPrice;
|
||||
}
|
||||
|
||||
List<ProductAttributeResult> specList;
|
||||
|
||||
List<ProductAttributeResult> specChildList;
|
||||
|
||||
@@ -14,6 +14,16 @@ public class ProductSkuResult {
|
||||
|
||||
private String pic;
|
||||
|
||||
private Integer intergrationPrice;
|
||||
|
||||
public Integer getIntergrationPrice() {
|
||||
return intergrationPrice;
|
||||
}
|
||||
|
||||
public void setIntergrationPrice(Integer intergrationPrice) {
|
||||
this.intergrationPrice = intergrationPrice;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -1,66 +1,26 @@
|
||||
package com.buy507.mall.portal.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.buy507.mall.mapper.CmsSubjectMapper;
|
||||
import com.buy507.mall.mapper.PmsCommentMapper;
|
||||
import com.buy507.mall.mapper.PmsCommentReplayMapper;
|
||||
import com.buy507.mall.mapper.PmsProductAttributeMapper;
|
||||
import com.buy507.mall.mapper.PmsProductAttributeValueMapper;
|
||||
import com.buy507.mall.mapper.PmsProductCategoryMapper;
|
||||
import com.buy507.mall.mapper.PmsProductFullReductionMapper;
|
||||
import com.buy507.mall.mapper.PmsProductMapper;
|
||||
import com.buy507.mall.mapper.PmsSkuStockMapper;
|
||||
import com.buy507.mall.mapper.SmsFlashPromotionMapper;
|
||||
import com.buy507.mall.mapper.SmsFlashPromotionSessionMapper;
|
||||
import com.buy507.mall.mapper.SmsHomeAdvertiseMapper;
|
||||
import com.buy507.mall.model.CmsSubject;
|
||||
import com.buy507.mall.model.CmsSubjectExample;
|
||||
import com.buy507.mall.model.PmsComment;
|
||||
import com.buy507.mall.model.PmsCommentReplay;
|
||||
import com.buy507.mall.model.PmsProduct;
|
||||
import com.buy507.mall.model.PmsProductAttribute;
|
||||
import com.buy507.mall.model.PmsProductAttributeExample;
|
||||
import com.buy507.mall.model.PmsProductAttributeValue;
|
||||
import com.buy507.mall.model.PmsProductAttributeValueExample;
|
||||
import com.buy507.mall.model.PmsProductCategory;
|
||||
import com.buy507.mall.model.PmsProductCategoryExample;
|
||||
import com.buy507.mall.model.PmsProductExample;
|
||||
import com.buy507.mall.model.PmsProductFullReduction;
|
||||
import com.buy507.mall.model.PmsSkuStock;
|
||||
import com.buy507.mall.model.PmsSkuStockExample;
|
||||
import com.buy507.mall.model.SmsFlashPromotion;
|
||||
import com.buy507.mall.model.SmsFlashPromotionExample;
|
||||
import com.buy507.mall.model.SmsFlashPromotionSession;
|
||||
import com.buy507.mall.model.SmsFlashPromotionSessionExample;
|
||||
import com.buy507.mall.model.SmsHomeAdvertise;
|
||||
import com.buy507.mall.model.SmsHomeAdvertiseExample;
|
||||
import com.buy507.mall.model.UmsMember;
|
||||
import com.buy507.mall.mapper.*;
|
||||
import com.buy507.mall.model.*;
|
||||
import com.buy507.mall.portal.dao.HomeDao;
|
||||
import com.buy507.mall.portal.domain.FlashPromotionProduct;
|
||||
import com.buy507.mall.portal.domain.HomeContentResult;
|
||||
import com.buy507.mall.portal.domain.HomeFlashPromotion;
|
||||
import com.buy507.mall.portal.domain.MemberProductCollection;
|
||||
import com.buy507.mall.portal.domain.ProductAttributeResult;
|
||||
import com.buy507.mall.portal.domain.ProductCategoryOptions;
|
||||
import com.buy507.mall.portal.domain.ProductDetailResult;
|
||||
import com.buy507.mall.portal.domain.ProductSkuResult;
|
||||
import com.buy507.mall.portal.domain.*;
|
||||
import com.buy507.mall.portal.repository.MemberProductCollectionRepository;
|
||||
import com.buy507.mall.portal.service.HomeService;
|
||||
import com.buy507.mall.portal.service.PortalCommonService;
|
||||
import com.buy507.mall.portal.service.UmsMemberService;
|
||||
import com.buy507.mall.portal.util.DateUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页内容管理Service实现类
|
||||
@@ -134,9 +94,9 @@ public class HomeServiceImpl implements HomeService {
|
||||
for (PmsProduct product : PointAreaProductList) {
|
||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
for (PmsProduct product : pointsExchangeProductList) {
|
||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
// for (PmsProduct product : pointsExchangeProductList) {
|
||||
// product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
// }
|
||||
for (PmsProduct product : allProductList) {
|
||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
@@ -430,10 +390,15 @@ public class HomeServiceImpl implements HomeService {
|
||||
}
|
||||
List<PmsSkuStock> list = skuStockMapper.selectByExample(example);
|
||||
ProductSkuResult skuResult = new ProductSkuResult();
|
||||
|
||||
PmsProduct product = productMapper.selectByPrimaryKey(productId);
|
||||
|
||||
if(product.getPointsExchangeStatus() == 1){
|
||||
skuResult.setIntergrationPrice(product.getIntergrationPrice());
|
||||
}
|
||||
for (PmsSkuStock stock : list) {
|
||||
BeanUtils.copyProperties(stock, skuResult);
|
||||
}
|
||||
|
||||
//根据会员等级显示不同的商品价格
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
if (member != null) {
|
||||
|
||||
@@ -241,6 +241,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
orderResult.setPayAmount(order.getPayAmount());
|
||||
orderResult.setOrderStatus(order.getStatus());
|
||||
orderResult.setDeliveryType(order.getDeliveryType());
|
||||
|
||||
|
||||
if (order.getStatus() == 0) {
|
||||
orderResult.setOrderStatusName("待付款");
|
||||
if (order.getPayType() != null && order.getPayType() == 3) {
|
||||
@@ -294,10 +296,17 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
orderItemExample.createCriteria().andOrderIdEqualTo(order.getId());
|
||||
orderItemList = orderItemMapper.selectByExample(orderItemExample);
|
||||
orderResult.setProductsNum(orderItemList.size());
|
||||
|
||||
PmsProduct product = productMapper.getProductByOrderSn(order.getOrderSn());
|
||||
OmsOrderItem orderItem1 = orderItemMapper.selectByOrderId(order.getId());
|
||||
orderResult.setProductsNum(orderItem1.getProductQuantity());
|
||||
orderResult.setIntergrationPrice(product.getIntergrationPrice());
|
||||
orderResult.setIntergrationExchange(product.getPointsExchangeStatus());
|
||||
orderItemResultList = new ArrayList<>();
|
||||
for (OmsOrderItem orderItem : orderItemList) {
|
||||
orderItemResult = new OrderItemResult();
|
||||
orderItemResult.setProductQuantity(orderItem.getProductQuantity());
|
||||
orderItemResult.setIntergrationPrice(product.getIntergrationPrice());
|
||||
orderItemResult.setIntergrationExchange(product.getPointsExchangeStatus());
|
||||
orderItemResult.setOrderId(order.getId());
|
||||
orderItemResult.setOrderSn(order.getOrderSn());
|
||||
orderItemResult.setProductBrand(orderItem.getProductBrand());
|
||||
@@ -327,39 +336,39 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
OrderResult orderResult = new OrderResult();
|
||||
OmsOrder order = orderMapper.selectByPrimaryKey(orderId);
|
||||
//删除状态:0->未删除;1->已删除
|
||||
if(order != null && order.getMemberId().equals(loginMember.getId()) && order.getDeleteStatus() == 0) {
|
||||
if (order != null && order.getMemberId().equals(loginMember.getId()) && order.getDeleteStatus() == 0) {
|
||||
orderResult.setOrderId(order.getId());
|
||||
orderResult.setOrderSn(order.getOrderSn());
|
||||
orderResult.setCreateTime(order.getCreateTime());
|
||||
orderResult.setPayAmount(order.getPayAmount());
|
||||
orderResult.setOrderStatus(order.getStatus());
|
||||
orderResult.setDeliveryType(order.getDeliveryType());
|
||||
if(order.getStatus() == 0) {
|
||||
if (order.getStatus() == 0) {
|
||||
orderResult.setOrderStatusName("待付款");
|
||||
if(order.getPayType() != null && order.getPayType() == 3) {
|
||||
if (order.getPayType() != null && order.getPayType() == 3) {
|
||||
orderResult.setOrderStatusName("已付款待审核");
|
||||
}
|
||||
}
|
||||
if(order.getStatus() == 1) {
|
||||
if (order.getStatus() == 1) {
|
||||
orderResult.setOrderStatusName("待发货");
|
||||
}
|
||||
if(order.getStatus() == 2) {
|
||||
if (order.getStatus() == 2) {
|
||||
// 提货方式:0->自提;1->物流
|
||||
if(order.getDeliveryType() == 0) {
|
||||
if (order.getDeliveryType() == 0) {
|
||||
orderResult.setOrderStatusName("待提货");
|
||||
} else {
|
||||
orderResult.setOrderStatusName("待收货");
|
||||
}
|
||||
}
|
||||
if(order.getStatus() == 3) {
|
||||
if (order.getStatus() == 3) {
|
||||
orderResult.setOrderStatusName("交易完成");
|
||||
if(order.getCommentTime() == null) {
|
||||
if (order.getCommentTime() == null) {
|
||||
orderResult.setCommentStatus(0); //未评价
|
||||
} else {
|
||||
orderResult.setCommentStatus(1); //已评价
|
||||
}
|
||||
}
|
||||
if(order.getStatus() == 4) {
|
||||
if (order.getStatus() == 4) {
|
||||
orderResult.setOrderStatusName("交易关闭");
|
||||
orderResult.setOrderStatus(4);
|
||||
}
|
||||
@@ -368,18 +377,24 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
orderResult.setNote(order.getNote());
|
||||
orderResult.setDeliveryCompany(order.getDeliveryCompany());
|
||||
orderResult.setDeliverySn(order.getDeliverySn());
|
||||
orderResult.setPaymentTime(order.getPaymentTime());
|
||||
orderResult.setOrderType(order.getOrderType());
|
||||
orderResult.setPaymentTime(new Date());
|
||||
|
||||
// 获取商品信息,判断是否是积分专区商品
|
||||
PmsProduct product = productMapper.getProductByOrderSn((order.getOrderSn()));
|
||||
PmsProduct product = productMapper.getProductByOrderSn(order.getOrderSn());
|
||||
System.out.println("hello");
|
||||
boolean isPointsExchangeStatus = product != null && product.getPointsExchangeStatus() == 1;
|
||||
|
||||
//支付类型: 0->未支付;1->支付宝;2->微信; 3->线下支付; 4->积分支付
|
||||
//判断是否为积分专区商品
|
||||
if(isPointsExchangeStatus) {
|
||||
orderResult.setPayType(4); // 设置为积分支付
|
||||
orderResult.setPayTypeName("积分支付");
|
||||
}else {
|
||||
if (isPointsExchangeStatus) {
|
||||
orderResult.setIntergrationPrice(product.getIntergrationPrice());
|
||||
orderResult.setIntergrationExchange(product.getPointsExchangeStatus());
|
||||
orderResult.setPayType(order.getPayType());
|
||||
if (order.getPayType() == 0) {
|
||||
orderResult.setPayTypeName("未支付");
|
||||
}
|
||||
} else {
|
||||
// 如果不是积分兑换专区商品,则继续使用其他支付方式
|
||||
if (order.getPayType() != null) {
|
||||
orderResult.setPayType(order.getPayType());
|
||||
@@ -415,13 +430,14 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
orderResult.setDeliveryTime(order.getDeliveryTime());
|
||||
orderResult.setReceiveTime(order.getReceiveTime());
|
||||
orderResult.setCommentTime(order.getCommentTime());
|
||||
orderResult.setOrderStatus(0);
|
||||
|
||||
//0->不开发票;1->电子发票;2->纸质发票
|
||||
if(order.getBillType() != null) {
|
||||
if (order.getBillType() != null) {
|
||||
orderResult.setBillType(order.getBillType());
|
||||
if(order.getBillType() == 1) {
|
||||
if (order.getBillType() == 1) {
|
||||
orderResult.setBillTypeName("电子发票");
|
||||
} else if(order.getBillType() == 2) {
|
||||
} else if (order.getBillType() == 2) {
|
||||
orderResult.setBillTypeName("纸质发票");
|
||||
} else {
|
||||
orderResult.setBillTypeName("不开发票");
|
||||
@@ -447,7 +463,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
OrderItemResult orderItemResult = null;
|
||||
orderResult.setProductsNum(orderItemList.size());
|
||||
List<OrderItemResult> orderItemResultList = new ArrayList<>();
|
||||
for(OmsOrderItem orderItem : orderItemList) {
|
||||
for (OmsOrderItem orderItem : orderItemList) {
|
||||
orderItemResult = new OrderItemResult();
|
||||
orderItemResult.setOrderId(order.getId());
|
||||
orderItemResult.setOrderSn(order.getOrderSn());
|
||||
@@ -457,6 +473,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
orderItemResult.setProductPic(orderItem.getProductPic());
|
||||
orderItemResult.setProductPrice(orderItem.getProductPrice());
|
||||
orderItemResult.setProductQuantity(orderItem.getProductQuantity());
|
||||
orderItemResult.setIntergrationPrice(product.getIntergrationPrice());
|
||||
orderItemResult.setIntergrationExchange(product.getPointsExchangeStatus());
|
||||
orderItemResult.setSp1(orderItem.getSp1());
|
||||
orderItemResult.setSp2(orderItem.getSp2());
|
||||
orderItemResult.setSp3(orderItem.getSp3());
|
||||
@@ -704,6 +722,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
for (OmsOrderItem orderItem : orderItemList) {
|
||||
orderItem.setOrderId(order.getId());
|
||||
orderItem.setOrderSn(order.getOrderSn());
|
||||
|
||||
orderItemMapper.insert(orderItem);
|
||||
}
|
||||
|
||||
@@ -733,34 +752,34 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
*/
|
||||
public CommonResult createOrder(OrderParam orderParam) {
|
||||
//orderParam.setSkuId(98L);
|
||||
if(orderParam.getSkuId() == null) {
|
||||
if (orderParam.getSkuId() == null) {
|
||||
return CommonResult.validateFailed("商品SKU不能为空");
|
||||
}
|
||||
|
||||
if(orderParam.getDeliveryType() == null || (orderParam.getDeliveryType() != 0 && orderParam.getDeliveryType() != 1) ) {
|
||||
if (orderParam.getDeliveryType() == null || (orderParam.getDeliveryType() != 0 && orderParam.getDeliveryType() != 1)) {
|
||||
return CommonResult.validateFailed("提货方式不能为空");
|
||||
}
|
||||
|
||||
if(orderParam.getMemberReceiveAddressId() == null) {
|
||||
if (orderParam.getMemberReceiveAddressId() == null) {
|
||||
return CommonResult.validateFailed("会员收货地址不能为空");
|
||||
}
|
||||
|
||||
UmsMemberReceiveAddress address = memberReceiveAddressMapper.selectOneById(orderParam.getMemberReceiveAddressId());
|
||||
if(address == null) {
|
||||
if (address == null) {
|
||||
return CommonResult.validateFailed("未查询到会员收货地址");
|
||||
}
|
||||
if(orderParam.getQuantity() == null) {
|
||||
if (orderParam.getQuantity() == null) {
|
||||
return CommonResult.validateFailed("商品数量不能为空");
|
||||
}
|
||||
if(orderParam.getQuantity() <= 0) {
|
||||
if (orderParam.getQuantity() <= 0) {
|
||||
return CommonResult.validateFailed("商品数量错误");
|
||||
}
|
||||
PmsSkuStock skuStock = skuStockMapper.selectByPrimaryKey(orderParam.getSkuId());
|
||||
if(skuStock == null) {
|
||||
if (skuStock == null) {
|
||||
return CommonResult.validateFailed("未查询到商品信息");
|
||||
}
|
||||
|
||||
PmsProduct product = productMapper.selectByPrimaryKey(skuStock.getProductId());
|
||||
PmsProduct product = productMapper.getPrimaryKey(skuStock.getProductId());
|
||||
|
||||
|
||||
// 判断商品是否属于积分兑换区
|
||||
@@ -771,7 +790,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
if (isPointsExchangeStatus) {
|
||||
// 积分兑换专区商品,设置积分价格
|
||||
//获取商品的积分价格
|
||||
BigDecimal pointsPrice = new BigDecimal(product.getintergrationPrice());
|
||||
BigDecimal pointsPrice = new BigDecimal(product.getIntergrationPrice());
|
||||
// 积分兑换商品的总金额
|
||||
totalPointsAmount = pointsPrice.multiply(new BigDecimal(orderParam.getQuantity()));
|
||||
}
|
||||
@@ -782,12 +801,12 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if(product != null) {
|
||||
if (product != null) {
|
||||
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(memberService.getCurrentMember().getId());
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
|
||||
if(discount != null) {
|
||||
if (discount != null) {
|
||||
price = skuStock.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
@@ -795,7 +814,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
BigDecimal zero = new BigDecimal(0);
|
||||
totalAmount = price.multiply(new BigDecimal(orderParam.getQuantity()));
|
||||
|
||||
if(orderParam.getIntegration() == null) {
|
||||
if (orderParam.getIntegration() == null) {
|
||||
orderParam.setIntegration(zero);
|
||||
}
|
||||
|
||||
@@ -804,7 +823,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
//flag = -1,表示integration小于0;flag = 0,表示integration等于0;flag = 1,表示integration大于0;
|
||||
//int integerationFlag = orderParam.getIntegration().compareTo(new BigDecimal(0)); //mcoo
|
||||
int integerationFlag = 0;
|
||||
if(integerationFlag == 1) {
|
||||
if (integerationFlag == 1) {
|
||||
int flag = member.getBalance().compareTo(orderParam.getIntegration());
|
||||
//flag = -1,表示balance小于integration;flag = 0,表示balance等于integration;flag = 1,表示balance大于integration;
|
||||
/*if(flag == -1) {
|
||||
@@ -812,9 +831,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
}*/
|
||||
}
|
||||
|
||||
while(true) {
|
||||
while (true) {
|
||||
long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
|
||||
if(redisLock.lock(String.valueOf(skuStock.getProductId()), String.valueOf(time))) {
|
||||
if (redisLock.lock(String.valueOf(skuStock.getProductId()), String.valueOf(time))) {
|
||||
|
||||
//重新查询获取最新的数据
|
||||
skuStock = skuStockMapper.selectByPrimaryKey(orderParam.getSkuId());
|
||||
@@ -837,13 +856,13 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
order.setTotalAmount(totalAmount); // 订单总金额
|
||||
order.setIntegrationAmount(zero); // 积分部分金额设为零
|
||||
order.setIntegrationAmount(orderParam.getIntegration() == null ? zero : orderParam.getIntegration());
|
||||
if(integerationFlag == 1) {
|
||||
if (integerationFlag == 1) {
|
||||
int flag = orderParam.getIntegration().compareTo(totalAmount);
|
||||
BigDecimal integeration = new BigDecimal(0);
|
||||
//flag = -1,表示integration小于totalAmount;flag = 0,表示integration等于totalAmount;flag = 1,表示integration大于totalAmount;
|
||||
//如果传入的积分小于实际支付金额,用实际支付金额减去抵扣积分。
|
||||
//如果传入的积分等于或者大于实际支付金额,表示全额抵扣
|
||||
if(flag == -1) {
|
||||
if (flag == -1) {
|
||||
order.setPayAmount(totalAmount.subtract(orderParam.getIntegration())); //实际支付金额
|
||||
order.setIntegrationAmount(orderParam.getIntegration());
|
||||
integeration = orderParam.getIntegration();
|
||||
@@ -1329,6 +1348,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
public CommonResult pointPayment(Long orderId) {
|
||||
|
||||
OmsOrder order = orderMapper.selectByPrimaryKey(orderId);
|
||||
PmsProduct product1 = productMapper.getProductByOrderSn(order.getOrderSn());
|
||||
OmsOrderItem orderItem1 = orderItemMapper.selectByOrderId(orderId);
|
||||
if (order == null) {
|
||||
return CommonResult.validateFailed("未查询到订单信息");
|
||||
}
|
||||
@@ -1340,14 +1361,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
// 判断是否使用积分支付
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(currentMember.getId());
|
||||
|
||||
BigDecimal zero = new BigDecimal(0);
|
||||
// 只要订单的支付金额为0,即表示使用积分支付
|
||||
int flag = order.getPayAmount().compareTo(zero);
|
||||
if (flag == 0) { // 如果实际支付金额为0,表示使用积分支付
|
||||
if (product1.getPointsExchangeStatus() == 1) {
|
||||
|
||||
// 获取积分兑换价格
|
||||
// 使用订单中的积分字段
|
||||
BigDecimal totalPointsAmount = order.getIntegrationAmount();
|
||||
BigDecimal totalPointsAmount = BigDecimal.valueOf((long) product1.getIntergrationPrice() * orderItem1.getProductQuantity());
|
||||
// 获取当前用户积分
|
||||
BigDecimal memberPoints = BigDecimal.valueOf(member.getIntegration());
|
||||
|
||||
@@ -1355,133 +1373,160 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
if (memberPoints.compareTo(totalPointsAmount) < 0) {
|
||||
return CommonResult.validateFailed("积分不足,无法完成兑换");
|
||||
}
|
||||
// BigDecimal zero = new BigDecimal(0);
|
||||
// // 只要订单的支付金额为0,即表示使用积分支付
|
||||
// int flag = order.getPayAmount().compareTo(zero);
|
||||
// if (flag == 0) { // 如果实际支付金额为0,表示使用积分支付
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
// 扣除用户积分,并记录积分变动
|
||||
// 扣除积分
|
||||
member.setIntegration(memberPoints.subtract(totalPointsAmount).intValue());
|
||||
// 冻结积分
|
||||
member.setFreeze(member.getFreeze().add(totalPointsAmount));
|
||||
// member.setFreeze(member.getFreeze().add(totalPointsAmount));
|
||||
memberMapper.updateByPrimaryKey(member);
|
||||
|
||||
// 支付方式:0->未支付;1->支付宝;2->微信;3->线下支付;4->积分支付支付
|
||||
// 支付方式为0才允许支付
|
||||
if (order.getPayType() != 0) {
|
||||
return CommonResult.validateFailed("订单已支付");
|
||||
}
|
||||
|
||||
// 更新订单状态为已支付
|
||||
// 设置为余额支付
|
||||
order.setPayType(4);
|
||||
// 设置订单状态为已支付
|
||||
order.setStatus(2);
|
||||
order.setPaymentTime(new Date());
|
||||
orderMapper.updateByPrimaryKey(order);
|
||||
|
||||
if (flag == 0) {
|
||||
//写入会员交易记录表
|
||||
DmsMemberTradeRecord tradeRecord = new DmsMemberTradeRecord();
|
||||
tradeRecord.setMemberId(member.getId());
|
||||
//积分购物
|
||||
tradeRecord.setItemType(ItemType.IntegralShopping);
|
||||
tradeRecord.setNote("积分抵扣");
|
||||
tradeRecord.setTitle("积分抵扣");
|
||||
tradeRecord.setValue(totalPointsAmount);
|
||||
//收支类型:0->收入;1->支出
|
||||
tradeRecord.setType(1);
|
||||
tradeRecord.setCreateTime(new Date());
|
||||
memberTradeRecordMapper.insert(tradeRecord);
|
||||
// 处理库存、分销等后续操作
|
||||
executorService.execute(() -> {
|
||||
// 处理库存
|
||||
updateStock(orderId);
|
||||
});
|
||||
|
||||
while (true) {
|
||||
long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
|
||||
if (redisLock.lock(String.valueOf(member.getId()), String.valueOf(time))) {
|
||||
member = memberMapper.selectByPrimaryKey(member.getId());
|
||||
//修改冻结金额,增加冻结资金
|
||||
member.setFreeze(member.getFreeze().add(order.getIntegrationAmount()));
|
||||
memberMapper.updateByPrimaryKey(member);
|
||||
redisLock.unlock(String.valueOf(member.getId()), String.valueOf(time));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return CommonResult.validateFailed("无效订单");
|
||||
}
|
||||
|
||||
//插入流水表
|
||||
//插入流水表积分
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setMemberId(member.getId());
|
||||
accountTransaction.setOrderId(orderId);
|
||||
accountTransaction.setFlowType(2);
|
||||
accountTransaction.setTransferPaymentTime(order.getPaymentTime());
|
||||
accountTransaction.setRevenuePoints(totalPointsAmount.intValue());
|
||||
accountTransaction.setRevenuePoints(-totalPointsAmount.intValue());
|
||||
PmsProduct pmsProduct = orderMapper.selectAll(order.getOrderSn());
|
||||
accountTransaction.setRemarks( "商品名称" + pmsProduct.getName());
|
||||
accountTransaction.setRemarks("商品名称" + pmsProduct.getName());
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
Date date = new Date();
|
||||
// 返还积分金额到前端
|
||||
return CommonResult.success(totalPointsAmount, "支付成功");
|
||||
|
||||
//支付方式:0->未支付;1->支付宝;2->微信;3->线下支付;4->余额支付
|
||||
order.setPayType(4);
|
||||
// 支付方式:0->未支付;1->支付宝;2->微信;3->线下支付;4->积分支付支付
|
||||
// 支付方式为0才允许支付
|
||||
// if (order.getPayType() != 0) {
|
||||
// return CommonResult.validateFailed("订单已支付");
|
||||
// }
|
||||
|
||||
//提货方式:0->自提;1->物流
|
||||
if (order.getDeliveryType() == 0) {
|
||||
//订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单
|
||||
order.setStatus(2);
|
||||
} else {
|
||||
//订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单
|
||||
order.setStatus(1);
|
||||
}
|
||||
|
||||
order.setModifyTime(date);
|
||||
order.setPaymentTime(date);
|
||||
orderMapper.updateByPrimaryKey(order);
|
||||
// if (product1.getPointsExchangeStatus() == 1) {
|
||||
// //写入会员交易记录表
|
||||
// DmsMemberTradeRecord tradeRecord = new DmsMemberTradeRecord();
|
||||
// tradeRecord.setMemberId(member.getId());
|
||||
// //积分购物
|
||||
// tradeRecord.setItemType(ItemType.IntegralShopping);
|
||||
// tradeRecord.setNote("积分抵扣");
|
||||
// tradeRecord.setTitle("积分抵扣");
|
||||
// tradeRecord.setValue(totalPointsAmount);
|
||||
// //收支类型:0->收入;1->支出
|
||||
// tradeRecord.setType(1);
|
||||
// tradeRecord.setCreateTime(new Date());
|
||||
// memberTradeRecordMapper.insert(tradeRecord);
|
||||
//
|
||||
// while (true) {
|
||||
// long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
|
||||
// if (redisLock.lock(String.valueOf(member.getId()), String.valueOf(time))) {
|
||||
// member = memberMapper.selectByPrimaryKey(member.getId());
|
||||
// //修改冻结金额,增加冻结资金
|
||||
// member.setFreeze(member.getFreeze().add(order.getIntegrationAmount()));
|
||||
// memberMapper.updateByPrimaryKey(member);
|
||||
// redisLock.unlock(String.valueOf(member.getId()), String.valueOf(time));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// return CommonResult.validateFailed("无效订单");
|
||||
// }
|
||||
//
|
||||
// Date date = new Date();
|
||||
//
|
||||
// //支付方式:0->未支付;1->支付宝;2->微信;3->线下支付;4->余额支付
|
||||
// order.setPayType(4);
|
||||
//
|
||||
// //提货方式:0->自提;1->物流
|
||||
// if (order.getDeliveryType() == 0) {
|
||||
// //订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单
|
||||
// order.setStatus(2);
|
||||
// } else {
|
||||
// //订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单
|
||||
// order.setStatus(1);
|
||||
// }
|
||||
//
|
||||
// order.setModifyTime(date);
|
||||
// order.setPaymentTime(date);
|
||||
// orderMapper.updateByPrimaryKey(order);
|
||||
|
||||
//修改商品库存信息需要加锁,影响前台响应,所以用线程来处理
|
||||
executorService.execute(new Runnable() {
|
||||
// //修改商品库存信息需要加锁,影响前台响应,所以用线程来处理
|
||||
// executorService.execute(new Runnable() {
|
||||
//
|
||||
// @Override
|
||||
// public void run() {
|
||||
// //库存变动
|
||||
// //查询订单商品项
|
||||
// OmsOrderItemExample example = new OmsOrderItemExample();
|
||||
// example.createCriteria().andOrderIdEqualTo(order.getId());
|
||||
// List<OmsOrderItem> orderItemList = orderItemMapper.selectByExample(example);
|
||||
// PmsSkuStock skuStock = null;
|
||||
// PmsProduct product = null;
|
||||
// for (OmsOrderItem orderItem : orderItemList) {
|
||||
// while (true) {
|
||||
// long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
|
||||
// if (redisLock.lock(orderItem.getProductId().toString(), String.valueOf(time))) {
|
||||
// skuStock = skuStockMapper.selectByPrimaryKey(orderItem.getProductSkuId());
|
||||
// if (skuStock != null) {
|
||||
// skuStock.setLockStock(skuStock.getLockStock() - orderItem.getProductQuantity());
|
||||
// skuStock.setStock(skuStock.getStock() - orderItem.getProductQuantity());
|
||||
// skuStock.setSale((skuStock.getSale() == null ? 0 : skuStock.getSale()) + orderItem.getProductQuantity());
|
||||
// skuStockMapper.updateByPrimaryKey(skuStock);
|
||||
// }
|
||||
//
|
||||
// product = productMapper.selectByPrimaryKey(orderItem.getProductId());
|
||||
// if (product != null) {
|
||||
// product.setStock(product.getStock() - orderItem.getProductQuantity());
|
||||
// product.setSale((product.getSale() == null ? 0 : product.getSale()) + orderItem.getProductQuantity());
|
||||
// productMapper.updateByPrimaryKey(product);
|
||||
// }
|
||||
// redisLock.unlock(orderItem.getProductId().toString(), String.valueOf(time));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//库存变动
|
||||
//查询订单商品项
|
||||
OmsOrderItemExample example = new OmsOrderItemExample();
|
||||
example.createCriteria().andOrderIdEqualTo(order.getId());
|
||||
List<OmsOrderItem> orderItemList = orderItemMapper.selectByExample(example);
|
||||
PmsSkuStock skuStock = null;
|
||||
PmsProduct product = null;
|
||||
for (OmsOrderItem orderItem : orderItemList) {
|
||||
while (true) {
|
||||
long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
|
||||
if (redisLock.lock(orderItem.getProductId().toString(), String.valueOf(time))) {
|
||||
skuStock = skuStockMapper.selectByPrimaryKey(orderItem.getProductSkuId());
|
||||
if (skuStock != null) {
|
||||
skuStock.setLockStock(skuStock.getLockStock() - orderItem.getProductQuantity());
|
||||
skuStock.setStock(skuStock.getStock() - orderItem.getProductQuantity());
|
||||
skuStock.setSale((skuStock.getSale() == null ? 0 : skuStock.getSale()) + orderItem.getProductQuantity());
|
||||
skuStockMapper.updateByPrimaryKey(skuStock);
|
||||
}
|
||||
|
||||
product = productMapper.selectByPrimaryKey(orderItem.getProductId());
|
||||
if (product != null) {
|
||||
product.setStock(product.getStock() - orderItem.getProductQuantity());
|
||||
product.setSale((product.getSale() == null ? 0 : product.getSale()) + orderItem.getProductQuantity());
|
||||
productMapper.updateByPrimaryKey(product);
|
||||
}
|
||||
redisLock.unlock(orderItem.getProductId().toString(), String.valueOf(time));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
boolean distributionFlag = true;
|
||||
OmsOrderItemExample example = new OmsOrderItemExample();
|
||||
example.createCriteria().andOrderIdEqualTo(order.getId());
|
||||
List<OmsOrderItem> orderItemList = orderItemMapper.selectByExample(example);
|
||||
PmsProduct product = null;
|
||||
for (OmsOrderItem orderItem : orderItemList) {
|
||||
product = productMapper.selectByPrimaryKey(orderItem.getProductId());
|
||||
if (product.getDistributionFlag().equals(0)) { //分销标志(0->不参与;1->参与)
|
||||
distributionFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//分销处理
|
||||
if (distributionFlag) {
|
||||
distributeSender.sendMessage(order.getId());
|
||||
}
|
||||
// boolean distributionFlag = true;
|
||||
// OmsOrderItemExample example = new OmsOrderItemExample();
|
||||
// example.createCriteria().andOrderIdEqualTo(order.getId());
|
||||
// List<OmsOrderItem> orderItemList = orderItemMapper.selectByExample(example);
|
||||
// PmsProduct product = null;
|
||||
// for (OmsOrderItem orderItem : orderItemList) {
|
||||
// product = productMapper.selectByPrimaryKey(orderItem.getProductId());
|
||||
// if (product.getDistributionFlag().equals(0)) { //分销标志(0->不参与;1->参与)
|
||||
// distributionFlag = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //分销处理
|
||||
// if (distributionFlag) {
|
||||
// distributeSender.sendMessage(order.getId());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return CommonResult.success(null, "支付成功");
|
||||
}
|
||||
@@ -1525,20 +1570,68 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setMemberId(member.getId());
|
||||
accountTransaction.setOrderId(orderId);
|
||||
accountTransaction.setFlowType(1);
|
||||
accountTransaction.setTransferPaymentTime(orderResult.getPaymentTime());
|
||||
accountTransaction.setRevenueAmount(payAmount.negate());
|
||||
PmsProduct pmsProduct = orderMapper.selectAll(orderResult.getOrderSn());
|
||||
accountTransaction.setRemarks( "商品名称" + pmsProduct.getName());
|
||||
OmsOrderItem orderItem = orderItemMapper.getByOrderSn(orderResult.getOrderSn());
|
||||
accountTransaction.setRemarks("商品名称" + orderItem.getProductName());
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
PmsProduct pmsProduct = orderMapper.selectAll(orderResult.getOrderSn());
|
||||
if (pmsProduct.getVipStatus() == 1) {
|
||||
//增加基金现金
|
||||
BigDecimal fundCash = payAmount.multiply(new BigDecimal("0.05"));
|
||||
umsDevelopmentFundMapper.updateCash(fundCash);
|
||||
}
|
||||
|
||||
//如果是积分专区的商品则进行积分专区相对应的逻辑
|
||||
if (pmsProduct.getPointsAreaStatus() == 1) {
|
||||
//奖励积分是购买的价格的100%
|
||||
int rewardPoints = payAmount.intValue();
|
||||
// 增加用户积分
|
||||
if (member != null) {
|
||||
|
||||
if (member.getIntegration() == null) {
|
||||
member.setIntegration(rewardPoints);
|
||||
} else {
|
||||
member.setIntegration(member.getIntegration() + rewardPoints);
|
||||
}
|
||||
|
||||
// 更新用户积分
|
||||
memberMapper.updateByPrimaryKey(member);
|
||||
//增加基金积分
|
||||
int fundPoints = (int) (rewardPoints * 0.05);
|
||||
umsDevelopmentFundMapper.updatePoints(fundPoints);
|
||||
//插入流水表积分
|
||||
UmsMemberAccountTransaction transaction = new UmsMemberAccountTransaction();
|
||||
transaction.setMemberId(member.getId());
|
||||
transaction.setOrderId(orderId);
|
||||
transaction.setFlowType(2);
|
||||
transaction.setTransferPaymentTime(orderResult.getPaymentTime());
|
||||
transaction.setRevenuePoints(rewardPoints);
|
||||
transaction.setRemarks("购买商品返还积分:" + pmsProduct.getName());
|
||||
umsMemberAccountTransactionMapper.insert(transaction);
|
||||
}
|
||||
}
|
||||
// 更新订单状态为已支付
|
||||
OmsOrder order = orderMapper.selectByPrimaryKey(orderId);
|
||||
|
||||
// 设置为余额支付
|
||||
order.setPayType(5);
|
||||
// 设置订单状态为已支付
|
||||
order.setStatus(2);
|
||||
order.setPaymentTime(new Date());
|
||||
orderMapper.updateByPrimaryKey(order);
|
||||
//如果积分专区则需要积分分润
|
||||
if (pmsProduct.getPointsAreaStatus() == 1) {
|
||||
//积分分润逻辑
|
||||
memberPointsSplitProfitService.pointsSplit(order);
|
||||
}
|
||||
//如果会员专区专区则需要判断升级和金额分润
|
||||
if (pmsProduct.getVipStatus() == 1) {
|
||||
//升级现金分润逻辑
|
||||
memberSplitProfitService.updateOderAndMemberInfo(order);
|
||||
}
|
||||
|
||||
// 处理库存、分销等后续操作
|
||||
executorService.execute(() -> {
|
||||
@@ -1550,7 +1643,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
}
|
||||
|
||||
/**
|
||||
*处理库存的逻辑
|
||||
* 处理库存的逻辑
|
||||
*/
|
||||
private void updateStock(Long orderId) {
|
||||
// 查询订单商品信息,进行库存更新等操作
|
||||
@@ -1568,8 +1661,6 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 微信预支付
|
||||
*
|
||||
@@ -1983,9 +2074,19 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
// 更新用户积分
|
||||
memberMapper.updateByPrimaryKey(member);
|
||||
//增加基金积分
|
||||
int fundPoints = (int)(rewardPoints * 0.05);
|
||||
int fundPoints = (int) (rewardPoints * 0.05);
|
||||
umsDevelopmentFundMapper.updatePoints(fundPoints);
|
||||
|
||||
//插入流水表积分
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setMemberId(member.getId());
|
||||
accountTransaction.setOrderId(order.getId());
|
||||
accountTransaction.setFlowType(2);
|
||||
accountTransaction.setTransferPaymentTime(order.getPaymentTime());
|
||||
accountTransaction.setRevenuePoints(rewardPoints);
|
||||
accountTransaction.setRemarks("购买商品返还积分:" + pmsProduct.getName());
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//积分分润逻辑
|
||||
memberPointsSplitProfitService.pointsSplit(order);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
|
||||
//获取默认会员等级并设置
|
||||
UmsMemberLevelExample levelExample = new UmsMemberLevelExample();
|
||||
levelExample.createCriteria().andDefaultStatusEqualTo(0);
|
||||
levelExample.createCriteria().andDefaultStatusEqualTo(1);
|
||||
List<UmsMemberLevel> memberLevelList = memberLevelMapper.selectByExample(levelExample);
|
||||
if (!CollectionUtils.isEmpty(memberLevelList)) {
|
||||
umsMember.setMemberLevelId(memberLevelList.get(0).getId());
|
||||
@@ -516,6 +516,8 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
public MemberInfoResult getMemberInfo() {
|
||||
UmsMember loginMember = getCurrentMember();
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(loginMember.getId());
|
||||
MemberLevel memberLevel = MemberLevel.fromOrdinal(loginMember.getMemberLevelId().intValue());
|
||||
member.setMemberLevel(memberLevel);
|
||||
DmsTeamTotalConsume teamTotalConsume = teamTotalConsumeMapper.selectOneByMemberId(loginMember.getId());
|
||||
|
||||
OmsOrderExample example = new OmsOrderExample();
|
||||
@@ -529,6 +531,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
BigDecimal totalIncome = BigDecimal.ZERO;
|
||||
accountTransactionExample.createCriteria()
|
||||
.andTransactionStateEqualTo(UmsMemberAccountTransaction.TRANSACTION_STATE_YES)
|
||||
.andFlowTypeEqualTo(1)
|
||||
.andMemberIdEqualTo(member.getId());
|
||||
|
||||
List<UmsMemberAccountTransaction> totalList = umsMemberAccountTransactionMapper.selectByExample(accountTransactionExample);
|
||||
@@ -546,6 +549,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
accountTransactionExample.createCriteria()
|
||||
.andTransferPaymentTimeBetween(DateUtil.beginOfDay(nowTime) ,nowTime)
|
||||
.andTransactionStateEqualTo(UmsMemberAccountTransaction.TRANSACTION_STATE_YES)
|
||||
.andFlowTypeEqualTo(1)
|
||||
.andMemberIdEqualTo(member.getId());
|
||||
List<UmsMemberAccountTransaction> todayIncomeList = umsMemberAccountTransactionMapper.selectByExample(accountTransactionExample);
|
||||
if(todayIncomeList!= null && !todayIncomeList.isEmpty()){
|
||||
@@ -566,7 +570,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
result.setNickname(member.getNickname() == null ? "" : member.getNickname());
|
||||
result.setHeadPicture(member.getIcon() == null ? "" :member.getIcon());
|
||||
result.setGender(member.getGender());
|
||||
result.setMemberLevel(member.getMemberLevel().getValue()-1);
|
||||
result.setMemberLevel(member.getMemberLevel().getValue());
|
||||
result.setMemberId(loginMember.getId());
|
||||
result.setRealName(member.getRealName());
|
||||
result.setDetailAddress(member.getDetailAddress());
|
||||
@@ -924,7 +928,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
String withdrawMultipleStr = commonService.getDictionaryValue(Constants.D_WITHDRAW_MULTIPLE);
|
||||
double withdrawMultiple = Double.valueOf(withdrawMultipleStr);
|
||||
if(applyParam.getValue() % withdrawMultiple != 0) {
|
||||
return CommonResult.validateFailed("提现积分必须是" + withdrawMultipleStr + "的倍数");
|
||||
return CommonResult.validateFailed("提现金额必须是" + withdrawMultipleStr + "的倍数");
|
||||
}
|
||||
|
||||
BigDecimal withdraw = new BigDecimal(applyParam.getValue());
|
||||
@@ -933,7 +937,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
//flag = -1,表示balance小于withdraw;flag = 0,表示balance等于withdraw;flag = 1,表示balance大于withdraw;
|
||||
int flag = member.getBalance().compareTo(withdraw);
|
||||
if(flag == -1) {
|
||||
return CommonResult.validateFailed("积分不足,不能提现");
|
||||
return CommonResult.validateFailed("余额不足,不能提现");
|
||||
}
|
||||
|
||||
while(true) {
|
||||
@@ -943,7 +947,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
//flag = -1,表示balance小于withdraw;flag = 0,表示balance等于withdraw;flag = 1,表示balance大于withdraw;
|
||||
flag = member.getBalance().compareTo(withdraw);
|
||||
if(flag == -1) {
|
||||
return CommonResult.validateFailed("积分不足,不能提现");
|
||||
return CommonResult.validateFailed("余额不足,不能提现");
|
||||
}
|
||||
member.setBalance(member.getBalance().subtract(withdraw)); //修改余额值
|
||||
member.setFreeze(member.getFreeze().add(withdraw)); //修改冻结值
|
||||
|
||||
@@ -83,6 +83,7 @@ public class VipCenterServiceImpl implements VipCenterService {
|
||||
//返回订单id
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("orderId", order.getId());
|
||||
result.put("orderType", order.getOrderType());
|
||||
return CommonResult.success(result, "下单成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ becomeVipAmount: 899
|
||||
# 同等级分润比例
|
||||
sameLevelProfit: 10
|
||||
#店长升级金额
|
||||
storeManagerAmount: 1000
|
||||
storeManagerAmount: 10000
|
||||
#代理升级金额
|
||||
agentAmount: 1000
|
||||
agentAmount: 50000
|
||||
#市代理升级金额
|
||||
cityAgentAmount: 1000
|
||||
cityAgentAmount: 100000
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
<select id="selectMemberTeamList" parameterType="java.lang.Long" resultType="com.buy507.mall.portal.domain.TeamMemberResult">
|
||||
SELECT
|
||||
(SELECT nickname FROM ums_member m where m.id = tl.member_id) as username,
|
||||
tl.member_id as memberId,
|
||||
IFNULL((SELECT total FROM dms_team_member_number tmn where tmn.member_id = tl.member_id), 0) as teamNum,
|
||||
(SELECT value FROM dms_team_total_consume ttc where ttc.member_id = tl.member_id) as teamConsume
|
||||
(SELECT nickname FROM ums_member m where m.id = ur.member_id) as username,
|
||||
ur.member_id as memberId,
|
||||
IFNULL((SELECT total FROM dms_team_member_number tmn where tmn.member_id = ur.member_id), 0) as teamNum,
|
||||
(SELECT value FROM dms_team_total_consume ttc where ttc.member_id = ur.member_id) as teamConsume
|
||||
FROM
|
||||
dms_team_level tl
|
||||
ums_member_relation_tree ur
|
||||
WHERE
|
||||
tl.parent_id = #{member_id}
|
||||
ur.higher_level_id = #{member_id}
|
||||
</select>
|
||||
|
||||
<select id="selectMemberWithdrawApplyList" parameterType="java.lang.Long" resultType="java.util.HashMap">
|
||||
|
||||
Reference in New Issue
Block a user