Merge pull request 'main-cx' (#15) from main-cx into main

Reviewed-on: #15
This commit is contained in:
2025-02-26 10:36:15 +08:00
16 changed files with 460 additions and 200 deletions

View File

@@ -84,7 +84,7 @@ public class PmsProductServiceImpl implements PmsProductService {
log.info("b"+String.valueOf(productParam.getProductAttributeCategoryId())); log.info("b"+String.valueOf(productParam.getProductAttributeCategoryId()));
log.info("c"+String.valueOf(product.getProductCategoryId())); log.info("c"+String.valueOf(product.getProductCategoryId()));
log.info("d"+String.valueOf(product.getProductAttributeCategoryId())); log.info("d"+String.valueOf(product.getProductAttributeCategoryId()));
productMapper.insertSelective(product); productMapper.insertAll(product);
//根据促销类型设置价格:、阶梯价格、满减价格 //根据促销类型设置价格:、阶梯价格、满减价格
Long productId = product.getId(); Long productId = product.getId();
//会员价格 //会员价格

View File

@@ -27,4 +27,6 @@ public interface OmsOrderItemMapper {
int updateByPrimaryKeySelective(OmsOrderItem record); int updateByPrimaryKeySelective(OmsOrderItem record);
int updateByPrimaryKey(OmsOrderItem record); int updateByPrimaryKey(OmsOrderItem record);
OmsOrderItem selectByOrderId(Long orderId);
} }

View File

@@ -7,6 +7,7 @@ import com.buy507.mall.model.PmsProductFullReduction;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface PmsProductMapper { public interface PmsProductMapper {
long countByExample(PmsProductExample example); long countByExample(PmsProductExample example);
@@ -23,7 +24,9 @@ public interface PmsProductMapper {
List<PmsProduct> selectByExample(PmsProductExample example); List<PmsProduct> selectByExample(PmsProductExample example);
// @Select("select * from pms_product where id = #{id}")
PmsProduct selectByPrimaryKey(Long id); PmsProduct selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") PmsProduct record, @Param("example") PmsProductExample example); int updateByExampleSelective(@Param("record") PmsProduct record, @Param("example") PmsProductExample example);
int updateByExampleWithBLOBs(@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 getProductByOrderSn(String orderSn);
PmsProduct getPrimaryKey(Long id);
int insertAll(PmsProduct product);
} }

View File

@@ -29,4 +29,5 @@ public interface PmsSkuStockMapper {
int updateByPrimaryKey(PmsSkuStock record); int updateByPrimaryKey(PmsSkuStock record);
List<PmsSkuStock> getPmsSkuStock(Long id); List<PmsSkuStock> getPmsSkuStock(Long id);
} }

View File

@@ -69,6 +69,8 @@ public class OmsOrderItem implements Serializable {
@ApiModelProperty(value = "商品销售属性:[{'key':'颜色','value':'颜色'},{'key':'容量','value':'4G'}]") @ApiModelProperty(value = "商品销售属性:[{'key':'颜色','value':'颜色'},{'key':'容量','value':'4G'}]")
private String productAttr; private String productAttr;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Long getId() { public Long getId() {

View File

@@ -664,7 +664,7 @@ public class PmsProduct implements Serializable {
public void setVipCenter(Integer vipCenter) {this.vipCenter = vipCenter;} 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;} public void setIntergrationPrice(Integer intergrationPrice) {this.intergrationPrice = intergrationPrice;}

View File

@@ -89,7 +89,7 @@
id, order_id, order_sn, product_id, product_pic, product_name, product_brand, product_sn, 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, product_price, product_quantity, product_sku_id, product_sku_code, product_category_id,
sp1, sp2, sp3, promotion_name, promotion_amount, coupon_amount, integration_amount, 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> </sql>
<select id="selectByExample" parameterType="com.buy507.mall.model.OmsOrderItemExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.buy507.mall.model.OmsOrderItemExample" resultMap="BaseResultMap">
select select
@@ -508,4 +508,9 @@
product_attr = #{productAttr,jdbcType=VARCHAR} product_attr = #{productAttr,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<select id="selectByOrderId" resultType="com.buy507.mall.model.OmsOrderItem">
select * from mall.oms_order_item where order_id = #{orderId}
</select>
</mapper> </mapper>

View File

@@ -112,7 +112,7 @@
verify_status, sort, sale, price, promotion_price, gift_growth, gift_point, use_point_limit, 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, 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, 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>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
description, detail_desc, detail_html, detail_mobile_html description, detail_desc, detail_html, detail_mobile_html
@@ -336,6 +336,9 @@
<if test="detailMobileHtml != null"> <if test="detailMobileHtml != null">
detail_mobile_html, detail_mobile_html,
</if> </if>
<if test="intergrationPrice != null">
intergration_price,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="brandId != null"> <if test="brandId != null">
@@ -461,6 +464,9 @@
<if test="detailMobileHtml != null"> <if test="detailMobileHtml != null">
#{detailMobileHtml,jdbcType=LONGVARCHAR}, #{detailMobileHtml,jdbcType=LONGVARCHAR},
</if> </if>
<if test="intergrationPrice != null">
#{intergration_price},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.buy507.mall.model.PmsProductExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.buy507.mall.model.PmsProductExample" resultType="java.lang.Long">
@@ -934,10 +940,118 @@
SELECT p.* SELECT p.*
FROM pms_product p FROM pms_product p
WHERE p.product_sn = ( WHERE p.product_sn = (
SELECT oi.product_sn SELECT DISTINCT oi.product_sn
FROM oms_order_item oi FROM oms_order_item oi
WHERE oi.order_sn = #{orderSn} WHERE oi.order_sn = #{orderSn}
LIMIT 1 AND oi.product_sn IS NOT NULL
) limit 1
);
</select> </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">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
INSERT INTO pms_product
SET
brand_id = #{brandId},
product_category_id = #{productCategoryId},
feight_template_id = #{feightTemplateId},
product_attribute_category_id = #{productAttributeCategoryId},
name = #{name},
pic = #{pic},
product_sn = #{productSn},
delete_status = #{deleteStatus},
publish_status = #{publishStatus},
new_status = #{newStatus},
vip_status = #{vipStatus},
points_area_status = #{pointsAreaStatus},
points_exchange_status = #{pointsExchangeStatus},
recommand_status = #{recommandStatus},
verify_status = #{verifyStatus},
sort = #{sort},
sale = #{sale},
price = #{price},
promotion_price = #{promotionPrice},
gift_growth = #{giftGrowth},
gift_point = #{giftPoint},
use_point_limit = #{usePointLimit},
sub_title = #{subTitle},
original_price = #{originalPrice},
stock = #{stock},
low_stock = #{lowStock},
unit = #{unit},
weight = #{weight},
preview_status = #{previewStatus},
service_ids = #{serviceIds},
keywords = #{keywords},
note = #{note},
album_pics = #{albumPics},
detail_title = #{detailTitle},
promotion_start_time = #{promotionStartTime},
promotion_end_time = #{promotionEndTime},
promotion_per_limit = #{promotionPerLimit},
promotion_type = #{promotionType},
brand_name = #{brandName},
product_category_name = #{productCategoryName},
description = #{description},
detail_desc = #{detailDesc},
detail_html = #{detailHtml},
detail_mobile_html = #{detailMobileHtml},
intergration_price = #{intergrationPrice};
</insert>
</mapper> </mapper>

View File

@@ -341,4 +341,5 @@
on ppa.id=ppav.product_attribute_id on ppa.id=ppav.product_attribute_id
where pst.product_id=#{id,jdbcType=BIGINT} where pst.product_id=#{id,jdbcType=BIGINT}
</select> </select>
</mapper> </mapper>

View File

@@ -95,24 +95,24 @@ public class HomeController {
@RequestMapping(value = "/getVipProductList", method = RequestMethod.GET) @RequestMapping(value = "/getVipProductList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public CommonResult<List<PmsProduct>> getVipProductList(){ public CommonResult<List<PmsProduct>> getVipProductList(){
List<PmsProduct> productList = homeService.getVipProductList(); List<PmsProduct> vipProductList = homeService.getVipProductList();
return CommonResult.success(productList); return CommonResult.success(vipProductList);
} }
@ApiOperation("获取积分专区商品") @ApiOperation("获取积分专区商品")
@RequestMapping(value = "/getPointProductList", method = RequestMethod.GET) @RequestMapping(value = "/getPointProductList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public CommonResult<List<PmsProduct>> getPointProductList(){ public CommonResult<List<PmsProduct>> getPointProductList(){
List<PmsProduct> productList = homeService.getPointProductList(); List<PmsProduct> pointProductList = homeService.getPointProductList();
return CommonResult.success(productList); return CommonResult.success(pointProductList);
} }
@ApiOperation("获取积分兑换专区") @ApiOperation("获取积分兑换专区")
@RequestMapping(value = "/getPointExchangeProductList", method = RequestMethod.GET) @RequestMapping(value = "/getPointExchangeProductList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public CommonResult<List<PmsProduct>> getPointExchangeProductList(){ public CommonResult<List<PmsProduct>> getPointExchangeProductList(){
List<PmsProduct> productList = homeService.getPointExchangeProductList(); List<PmsProduct> pointExchangeProductList = homeService.getPointExchangeProductList();
return CommonResult.success(productList); return CommonResult.success(pointExchangeProductList);
} }

View File

@@ -39,6 +39,28 @@ public class OrderItemResult {
@ApiModelProperty(value = "商品SKU属性3") @ApiModelProperty(value = "商品SKU属性3")
private String sp3; 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() { public Long getOrderId() {
return orderId; return orderId;
} }

View File

@@ -113,6 +113,27 @@ public class OrderResult {
@ApiModelProperty(value = "快速排队订单还剩邀请成功的人数") @ApiModelProperty(value = "快速排队订单还剩邀请成功的人数")
private Integer invitedCount; private Integer invitedCount;
@ApiModelProperty(value = "积分价格")
private Integer intergrationPrice;
@ApiModelProperty(value = "积分兑换专区")
private Integer intergrationExchange;
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() { public Long getOrderId() {
return orderId; return orderId;

View File

@@ -13,6 +13,7 @@ import com.buy507.mall.model.SmsCoupon;
import com.buy507.mall.model.SmsCouponProductRelation; import com.buy507.mall.model.SmsCouponProductRelation;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.springframework.data.annotation.Transient;
public class ProductDetailResult { public class ProductDetailResult {
private Long id; private Long id;
@@ -153,6 +154,52 @@ public class ProductDetailResult {
private int applauseRate; 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> specList;
List<ProductAttributeResult> specChildList; List<ProductAttributeResult> specChildList;

View File

@@ -14,6 +14,16 @@ public class ProductSkuResult {
private String pic; private String pic;
private Integer intergrationPrice;
public Integer getIntergrationPrice() {
return intergrationPrice;
}
public void setIntergrationPrice(Integer intergrationPrice) {
this.intergrationPrice = intergrationPrice;
}
public Long getId() { public Long getId() {
return id; return id;
} }

View File

@@ -1,66 +1,26 @@
package com.buy507.mall.portal.service.impl; package com.buy507.mall.portal.service.impl;
import java.math.BigDecimal; import com.buy507.mall.mapper.*;
import java.util.ArrayList; import com.buy507.mall.model.*;
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.portal.dao.HomeDao; import com.buy507.mall.portal.dao.HomeDao;
import com.buy507.mall.portal.domain.FlashPromotionProduct; import com.buy507.mall.portal.domain.*;
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.repository.MemberProductCollectionRepository; import com.buy507.mall.portal.repository.MemberProductCollectionRepository;
import com.buy507.mall.portal.service.HomeService; import com.buy507.mall.portal.service.HomeService;
import com.buy507.mall.portal.service.PortalCommonService; import com.buy507.mall.portal.service.PortalCommonService;
import com.buy507.mall.portal.service.UmsMemberService; import com.buy507.mall.portal.service.UmsMemberService;
import com.buy507.mall.portal.util.DateUtil; import com.buy507.mall.portal.util.DateUtil;
import com.github.pagehelper.PageHelper; 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实现类 * 首页内容管理Service实现类
@@ -134,9 +94,9 @@ public class HomeServiceImpl implements HomeService {
for (PmsProduct product : PointAreaProductList) { for (PmsProduct product : PointAreaProductList) {
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP)); product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
} }
for (PmsProduct product : pointsExchangeProductList) { // for (PmsProduct product : pointsExchangeProductList) {
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP)); // product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
} // }
for (PmsProduct product : allProductList) { for (PmsProduct product : allProductList) {
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP)); product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
} }
@@ -430,11 +390,16 @@ public class HomeServiceImpl implements HomeService {
} }
List<PmsSkuStock> list = skuStockMapper.selectByExample(example); List<PmsSkuStock> list = skuStockMapper.selectByExample(example);
ProductSkuResult skuResult = new ProductSkuResult(); ProductSkuResult skuResult = new ProductSkuResult();
PmsProduct product = productMapper.selectByPrimaryKey(productId);
if(product.getPointsExchangeStatus() == 1){
skuResult.setIntergrationPrice(product.getIntergrationPrice());
}
for (PmsSkuStock stock : list) { for (PmsSkuStock stock : list) {
BeanUtils.copyProperties(stock, skuResult); BeanUtils.copyProperties(stock, skuResult);
} }
//根据会员等级显示不同的商品价格
//根据会员等级显示不同的商品价格
UmsMember member = memberService.getCurrentMember(); UmsMember member = memberService.getCurrentMember();
if (member != null) { if (member != null) {
BigDecimal discount = commonService.getDiscount(member.getId()); BigDecimal discount = commonService.getDiscount(member.getId());

View File

@@ -241,6 +241,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
orderResult.setPayAmount(order.getPayAmount()); orderResult.setPayAmount(order.getPayAmount());
orderResult.setOrderStatus(order.getStatus()); orderResult.setOrderStatus(order.getStatus());
orderResult.setDeliveryType(order.getDeliveryType()); orderResult.setDeliveryType(order.getDeliveryType());
if (order.getStatus() == 0) { if (order.getStatus() == 0) {
orderResult.setOrderStatusName("待付款"); orderResult.setOrderStatusName("待付款");
if (order.getPayType() != null && order.getPayType() == 3) { if (order.getPayType() != null && order.getPayType() == 3) {
@@ -294,10 +296,17 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
orderItemExample.createCriteria().andOrderIdEqualTo(order.getId()); orderItemExample.createCriteria().andOrderIdEqualTo(order.getId());
orderItemList = orderItemMapper.selectByExample(orderItemExample); orderItemList = orderItemMapper.selectByExample(orderItemExample);
orderResult.setProductsNum(orderItemList.size()); 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<>(); orderItemResultList = new ArrayList<>();
for (OmsOrderItem orderItem : orderItemList) { for (OmsOrderItem orderItem : orderItemList) {
orderItemResult = new OrderItemResult(); orderItemResult = new OrderItemResult();
orderItemResult.setProductQuantity(orderItem.getProductQuantity());
orderItemResult.setIntergrationPrice(product.getIntergrationPrice());
orderItemResult.setIntergrationExchange(product.getPointsExchangeStatus());
orderItemResult.setOrderId(order.getId()); orderItemResult.setOrderId(order.getId());
orderItemResult.setOrderSn(order.getOrderSn()); orderItemResult.setOrderSn(order.getOrderSn());
orderItemResult.setProductBrand(orderItem.getProductBrand()); orderItemResult.setProductBrand(orderItem.getProductBrand());
@@ -371,14 +380,19 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
orderResult.setPaymentTime(order.getPaymentTime()); orderResult.setPaymentTime(order.getPaymentTime());
// 获取商品信息,判断是否是积分专区商品 // 获取商品信息,判断是否是积分专区商品
PmsProduct product = productMapper.getProductByOrderSn((order.getOrderSn())); PmsProduct product = productMapper.getProductByOrderSn(order.getOrderSn());
System.out.println("hello");
boolean isPointsExchangeStatus = product != null && product.getPointsExchangeStatus() == 1; boolean isPointsExchangeStatus = product != null && product.getPointsExchangeStatus() == 1;
//支付类型: 0->未支付1->支付宝2->微信; 3->线下支付; 4->积分支付 //支付类型: 0->未支付1->支付宝2->微信; 3->线下支付; 4->积分支付
//判断是否为积分专区商品 //判断是否为积分专区商品
if(isPointsExchangeStatus) { if(isPointsExchangeStatus) {
orderResult.setPayType(4); // 设置为积分支付 orderResult.setIntergrationPrice(product.getIntergrationPrice());
orderResult.setPayTypeName("积分支付"); orderResult.setIntergrationExchange(product.getPointsExchangeStatus());
orderResult.setPayType(order.getPayType());
if (order.getPayType() == 0) {
orderResult.setPayTypeName("未支付");
}
}else { }else {
// 如果不是积分兑换专区商品,则继续使用其他支付方式 // 如果不是积分兑换专区商品,则继续使用其他支付方式
if (order.getPayType() != null) { if (order.getPayType() != null) {
@@ -415,6 +429,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
orderResult.setDeliveryTime(order.getDeliveryTime()); orderResult.setDeliveryTime(order.getDeliveryTime());
orderResult.setReceiveTime(order.getReceiveTime()); orderResult.setReceiveTime(order.getReceiveTime());
orderResult.setCommentTime(order.getCommentTime()); orderResult.setCommentTime(order.getCommentTime());
orderResult.setOrderStatus(0);
//0->不开发票1->电子发票2->纸质发票 //0->不开发票1->电子发票2->纸质发票
if(order.getBillType() != null) { if(order.getBillType() != null) {
@@ -457,6 +472,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
orderItemResult.setProductPic(orderItem.getProductPic()); orderItemResult.setProductPic(orderItem.getProductPic());
orderItemResult.setProductPrice(orderItem.getProductPrice()); orderItemResult.setProductPrice(orderItem.getProductPrice());
orderItemResult.setProductQuantity(orderItem.getProductQuantity()); orderItemResult.setProductQuantity(orderItem.getProductQuantity());
orderItemResult.setIntergrationPrice(product.getIntergrationPrice());
orderItemResult.setIntergrationExchange(product.getPointsExchangeStatus());
orderItemResult.setSp1(orderItem.getSp1()); orderItemResult.setSp1(orderItem.getSp1());
orderItemResult.setSp2(orderItem.getSp2()); orderItemResult.setSp2(orderItem.getSp2());
orderItemResult.setSp3(orderItem.getSp3()); orderItemResult.setSp3(orderItem.getSp3());
@@ -704,6 +721,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
for (OmsOrderItem orderItem : orderItemList) { for (OmsOrderItem orderItem : orderItemList) {
orderItem.setOrderId(order.getId()); orderItem.setOrderId(order.getId());
orderItem.setOrderSn(order.getOrderSn()); orderItem.setOrderSn(order.getOrderSn());
orderItemMapper.insert(orderItem); orderItemMapper.insert(orderItem);
} }
@@ -760,7 +778,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
return CommonResult.validateFailed("未查询到商品信息"); return CommonResult.validateFailed("未查询到商品信息");
} }
PmsProduct product = productMapper.selectByPrimaryKey(skuStock.getProductId()); PmsProduct product = productMapper.getPrimaryKey(skuStock.getProductId());
// 判断商品是否属于积分兑换区 // 判断商品是否属于积分兑换区
@@ -771,7 +789,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
if (isPointsExchangeStatus) { if (isPointsExchangeStatus) {
// 积分兑换专区商品,设置积分价格 // 积分兑换专区商品,设置积分价格
//获取商品的积分价格 //获取商品的积分价格
BigDecimal pointsPrice = new BigDecimal(product.getintergrationPrice()); BigDecimal pointsPrice = new BigDecimal(product.getIntergrationPrice());
// 积分兑换商品的总金额 // 积分兑换商品的总金额
totalPointsAmount = pointsPrice.multiply(new BigDecimal(orderParam.getQuantity())); totalPointsAmount = pointsPrice.multiply(new BigDecimal(orderParam.getQuantity()));
} }
@@ -1329,6 +1347,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
public CommonResult pointPayment(Long orderId) { public CommonResult pointPayment(Long orderId) {
OmsOrder order = orderMapper.selectByPrimaryKey(orderId); OmsOrder order = orderMapper.selectByPrimaryKey(orderId);
PmsProduct product1 = productMapper.getProductByOrderSn(order.getOrderSn());
OmsOrderItem orderItem1 = orderItemMapper.selectByOrderId(orderId);
if (order == null) { if (order == null) {
return CommonResult.validateFailed("未查询到订单信息"); return CommonResult.validateFailed("未查询到订单信息");
} }
@@ -1340,14 +1360,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
// 判断是否使用积分支付 // 判断是否使用积分支付
UmsMember member = memberMapper.selectByPrimaryKey(currentMember.getId()); UmsMember member = memberMapper.selectByPrimaryKey(currentMember.getId());
BigDecimal zero = new BigDecimal(0); if(product1.getPointsExchangeStatus() == 1) {
// 只要订单的支付金额为0即表示使用积分支付
int flag = order.getPayAmount().compareTo(zero);
if (flag == 0) { // 如果实际支付金额为0表示使用积分支付
// 获取积分兑换价格 // 获取积分兑换价格
// 使用订单中的积分字段 // 使用订单中的积分字段
BigDecimal totalPointsAmount = order.getIntegrationAmount(); BigDecimal totalPointsAmount = BigDecimal.valueOf((long) product1.getIntergrationPrice() * orderItem1.getProductQuantity());
// 获取当前用户积分 // 获取当前用户积分
BigDecimal memberPoints = BigDecimal.valueOf(member.getIntegration()); BigDecimal memberPoints = BigDecimal.valueOf(member.getIntegration());
@@ -1355,133 +1372,159 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
if (memberPoints.compareTo(totalPointsAmount) < 0) { if (memberPoints.compareTo(totalPointsAmount) < 0) {
return CommonResult.validateFailed("积分不足,无法完成兑换"); 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.setIntegration(memberPoints.subtract(totalPointsAmount).intValue());
// 冻结积分 // 冻结积分
member.setFreeze(member.getFreeze().add(totalPointsAmount)); // member.setFreeze(member.getFreeze().add(totalPointsAmount));
memberMapper.updateByPrimaryKey(member); memberMapper.updateByPrimaryKey(member);
// 更新订单状态为已支付
// 设置为余额支付
order.setPayType(4);
// 设置订单状态为已支付
order.setStatus(2);
order.setPaymentTime(new Date());
orderMapper.updateByPrimaryKey(order);
// 处理库存、分销等后续操作
executorService.execute(() -> {
// 处理库存
updateStock(orderId);
});
// 返还积分金额到前端
return CommonResult.success(totalPointsAmount, "支付成功");
// 支付方式0->未支付1->支付宝2->微信3->线下支付4->积分支付支付 // 支付方式0->未支付1->支付宝2->微信3->线下支付4->积分支付支付
// 支付方式为0才允许支付 // 支付方式为0才允许支付
if (order.getPayType() != 0) { // if (order.getPayType() != 0) {
return CommonResult.validateFailed("订单已支付"); // return CommonResult.validateFailed("订单已支付");
} // }
if (flag == 0) { // if (product1.getPointsExchangeStatus() == 1) {
//写入会员交易记录表 // //写入会员交易记录表
DmsMemberTradeRecord tradeRecord = new DmsMemberTradeRecord(); // DmsMemberTradeRecord tradeRecord = new DmsMemberTradeRecord();
tradeRecord.setMemberId(member.getId()); // tradeRecord.setMemberId(member.getId());
//积分购物 // //积分购物
tradeRecord.setItemType(ItemType.IntegralShopping); // tradeRecord.setItemType(ItemType.IntegralShopping);
tradeRecord.setNote("积分抵扣"); // tradeRecord.setNote("积分抵扣");
tradeRecord.setTitle("积分抵扣"); // tradeRecord.setTitle("积分抵扣");
tradeRecord.setValue(totalPointsAmount); // tradeRecord.setValue(totalPointsAmount);
//收支类型0->收入1->支出 // //收支类型0->收入1->支出
tradeRecord.setType(1); // tradeRecord.setType(1);
tradeRecord.setCreateTime(new Date()); // tradeRecord.setCreateTime(new Date());
memberTradeRecordMapper.insert(tradeRecord); // 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("无效订单");
// }
//
// //插入流水表
// UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
// accountTransaction.setMemberId(member.getId());
// accountTransaction.setOrderId(orderId);
// accountTransaction.setTransferPaymentTime(order.getPaymentTime());
// accountTransaction.setRevenuePoints(totalPointsAmount.intValue());
// PmsProduct pmsProduct = orderMapper.selectAll(order.getOrderSn());
// accountTransaction.setRemarks( "商品名称" + pmsProduct.getName());
// umsMemberAccountTransactionMapper.insert(accountTransaction);
//
// 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);
while (true) { // //修改商品库存信息需要加锁,影响前台响应,所以用线程来处理
long time = System.currentTimeMillis() + RedisLock.TIMEOUT; // executorService.execute(new Runnable() {
if (redisLock.lock(String.valueOf(member.getId()), String.valueOf(time))) { //
member = memberMapper.selectByPrimaryKey(member.getId()); // @Override
//修改冻结金额,增加冻结资金 // public void run() {
member.setFreeze(member.getFreeze().add(order.getIntegrationAmount())); // //库存变动
memberMapper.updateByPrimaryKey(member); // //查询订单商品项
redisLock.unlock(String.valueOf(member.getId()), String.valueOf(time)); // OmsOrderItemExample example = new OmsOrderItemExample();
break; // 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;
// }
// }
// }
// }
// });
} else { // boolean distributionFlag = true;
return CommonResult.validateFailed("无效订单"); // OmsOrderItemExample example = new OmsOrderItemExample();
} // example.createCriteria().andOrderIdEqualTo(order.getId());
// List<OmsOrderItem> orderItemList = orderItemMapper.selectByExample(example);
//插入流水表 // PmsProduct product = null;
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction(); // for (OmsOrderItem orderItem : orderItemList) {
accountTransaction.setMemberId(member.getId()); // product = productMapper.selectByPrimaryKey(orderItem.getProductId());
accountTransaction.setOrderId(orderId); // if (product.getDistributionFlag().equals(0)) { //分销标志0->不参与1->参与)
accountTransaction.setTransferPaymentTime(order.getPaymentTime()); // distributionFlag = false;
accountTransaction.setRevenuePoints(totalPointsAmount.intValue()); // }
PmsProduct pmsProduct = orderMapper.selectAll(order.getOrderSn()); // }
accountTransaction.setRemarks( "商品名称" + pmsProduct.getName()); //
umsMemberAccountTransactionMapper.insert(accountTransaction); // //分销处理
// if (distributionFlag) {
Date date = new Date(); // distributeSender.sendMessage(order.getId());
// }
//支付方式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() {
@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());
}
} }
return CommonResult.success(null, "支付成功"); return CommonResult.success(null, "支付成功");
} }
@@ -1531,6 +1574,29 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
accountTransaction.setRemarks( "商品名称" + pmsProduct.getName()); accountTransaction.setRemarks( "商品名称" + pmsProduct.getName());
umsMemberAccountTransactionMapper.insert(accountTransaction); umsMemberAccountTransactionMapper.insert(accountTransaction);
//如果是积分专区的商品则进行积分专区相对应的逻辑
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);
// //积分分润逻辑
// memberPointsSplitProfitService.pointsSplit(order);
}
}
// 更新订单状态为已支付 // 更新订单状态为已支付
OmsOrder order = orderMapper.selectByPrimaryKey(orderId); OmsOrder order = orderMapper.selectByPrimaryKey(orderId);
// 设置为余额支付 // 设置为余额支付