Compare commits
37 Commits
2b5f4c3c5e
...
main-cx
| Author | SHA1 | Date | |
|---|---|---|---|
| 565c82305c | |||
| 6e329f4226 | |||
| fdec029158 | |||
|
|
dab9156c8f | ||
|
|
419f7c9886 | ||
| 153dc8751e | |||
| 0a2e13c428 | |||
| 39553dd80e | |||
| 873360a300 | |||
| d2b590a414 | |||
| 46c7576ba9 | |||
| ac6ad6533a | |||
| 13374f4249 | |||
| 3e6b15eade | |||
| 6939311e6f | |||
| 88d7814ad4 | |||
| 416f1d4558 | |||
| 24c4d039b4 | |||
| 9fa3789b8e | |||
| c4cb4a5a4a | |||
| 5c5a9cba80 | |||
| 9b6a3a3fdb | |||
| 6225d23311 | |||
| 10d3387b91 | |||
| 246785dfd8 | |||
| 4dd372831b | |||
| 68a2e24223 | |||
| d1c461e02d | |||
| c572ec0f84 | |||
| 305497c55f | |||
| 6ed1e2ebda | |||
| 0b4ce84d7f | |||
| 72a723a7f1 | |||
| dddb336586 | |||
| 5f49434239 | |||
| 5bd4ab7d2e | |||
| 4edd8ea7e5 |
@@ -66,6 +66,7 @@
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>1.18.20</version>
|
||||
</dependency>
|
||||
|
||||
<!-- poi excel -->
|
||||
@@ -95,7 +96,8 @@
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -138,32 +138,6 @@ public class PmsProductController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("批量设为积分专区")
|
||||
@RequestMapping(value = "/update/integrationStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult updateIntegrationStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("pointsAreaStatus") Integer pointsAreaStatus) {
|
||||
int count = productService.updatepointsAreaStatus(ids, pointsAreaStatus);
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count);
|
||||
} else {
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("批量设为积分兑换专区")
|
||||
@RequestMapping(value = "/update/integrationExchangeStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult updateIntegrationExchangeStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("pointsExchangeStatus") Integer pointsExchangeStatus) {
|
||||
int count = productService.updatepointsExchangeStatus(ids, pointsExchangeStatus);
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count);
|
||||
} else {
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改删除状态")
|
||||
@RequestMapping(value = "/update/deleteStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
|
||||
@@ -60,17 +60,6 @@ public interface PmsProductService {
|
||||
*/
|
||||
int updateNewStatus(List<Long> ids, Integer newStatus);
|
||||
|
||||
/**
|
||||
*批量设为积分专区
|
||||
*/
|
||||
int updatepointsAreaStatus(List<Long> ids, Integer pointsAreaStatus);
|
||||
|
||||
/**
|
||||
* 批量设为积分兑换专区
|
||||
*/
|
||||
int updatepointsExchangeStatus(List<Long> ids, Integer pointsExchangeStatus);
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除商品
|
||||
*/
|
||||
|
||||
@@ -13,4 +13,6 @@ public interface UmsMemberLevelService {
|
||||
* @param defaultStatus 是否为默认会员
|
||||
*/
|
||||
List<UmsMemberLevel> list(Integer defaultStatus);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.buy507.mall.mapper.UmsMemberAccountTransactionMapper;
|
||||
import com.buy507.mall.model.*;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
@@ -24,10 +27,6 @@ import com.buy507.mall.dto.MemberWithdrawApplyResult;
|
||||
import com.buy507.mall.mapper.DmsMemberTradeRecordMapper;
|
||||
import com.buy507.mall.mapper.DmsMemberWithdrawApplyMapper;
|
||||
import com.buy507.mall.mapper.UmsMemberMapper;
|
||||
import com.buy507.mall.model.DmsMemberTradeRecord;
|
||||
import com.buy507.mall.model.DmsMemberWithdrawApply;
|
||||
import com.buy507.mall.model.ItemType;
|
||||
import com.buy507.mall.model.UmsMember;
|
||||
import com.buy507.mall.service.DmsMemberWithdrawApplyService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
||||
@@ -48,6 +47,9 @@ public class DmsMemberWithdrawApplyServiceImpl implements DmsMemberWithdrawApply
|
||||
|
||||
@Autowired
|
||||
private RedisLock redisLock;
|
||||
|
||||
@Autowired
|
||||
private UmsMemberAccountTransactionMapper accountTransactionMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -88,6 +90,15 @@ public class DmsMemberWithdrawApplyServiceImpl implements DmsMemberWithdrawApply
|
||||
member = memberMapper.selectByPrimaryKey(member.getId());
|
||||
member.setFreeze(member.getFreeze().subtract(withdrawApply.getValue())); //修改冻结值
|
||||
memberMapper.updateByPrimaryKey(member);
|
||||
|
||||
// 写入会员流水记录表
|
||||
UmsMemberAccountTransaction memberTransaction = new UmsMemberAccountTransaction();
|
||||
memberTransaction.setMemberId(member.getId());
|
||||
memberTransaction.setRevenueAmount(withdrawApply.getValue()); // 提现金额
|
||||
memberTransaction.setRemarks("提现"); // 备注
|
||||
memberTransaction.setCreateTime(DateUtil.date()); // 提现时间
|
||||
accountTransactionMapper.insert(memberTransaction); // 保存流水记录
|
||||
|
||||
redisLock.unlock(String.valueOf(member.getId()), String.valueOf(time));
|
||||
break;
|
||||
}
|
||||
@@ -95,7 +106,7 @@ public class DmsMemberWithdrawApplyServiceImpl implements DmsMemberWithdrawApply
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -84,7 +84,8 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
log.info("b"+String.valueOf(productParam.getProductAttributeCategoryId()));
|
||||
log.info("c"+String.valueOf(product.getProductCategoryId()));
|
||||
log.info("d"+String.valueOf(product.getProductAttributeCategoryId()));
|
||||
productMapper.insertSelective(product);
|
||||
product.setOriginalPrice(productParam.getPrice());
|
||||
productMapper.insertAll(product);
|
||||
//根据促销类型设置价格:、阶梯价格、满减价格
|
||||
Long productId = product.getId();
|
||||
//会员价格
|
||||
@@ -264,26 +265,6 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
return productMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
//积分区域
|
||||
@Override
|
||||
public int updatepointsAreaStatus(List<Long> ids, Integer pointsAreaStatus) {
|
||||
PmsProduct record = new PmsProduct();
|
||||
record.setPointsAreaStatus(pointsAreaStatus);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return productMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
//积分兑换区域
|
||||
@Override
|
||||
public int updatepointsExchangeStatus(List<Long> ids, Integer pointsExchangeStatus) {
|
||||
PmsProduct record = new PmsProduct();
|
||||
record.setPointsExchangeStatus(pointsExchangeStatus);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return productMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int updateDeleteStatus(List<Long> ids, Integer deleteStatus) {
|
||||
|
||||
@@ -27,4 +27,6 @@ public interface OmsOrderItemMapper {
|
||||
int updateByPrimaryKeySelective(OmsOrderItem record);
|
||||
|
||||
int updateByPrimaryKey(OmsOrderItem record);
|
||||
|
||||
OmsOrderItem selectByOrderId(Long orderId);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -43,6 +43,13 @@ public interface UmsDevelopmentFundMapper {
|
||||
*/
|
||||
@Update("update ums_development_fund set cash_total = cash_total + #{fundCash}")
|
||||
void updateCash(BigDecimal fundCash);
|
||||
|
||||
/**
|
||||
* 发展基金
|
||||
* @return
|
||||
*/
|
||||
@Select("select id, cash_total, points_total, updated_at from ums_development_fund")
|
||||
UmsDevelopmentFund selectAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,5 +27,9 @@ public interface UmsMemberMapper {
|
||||
int updateByPrimaryKeySelective(UmsMember record);
|
||||
|
||||
int updateByPrimaryKey(UmsMember record);
|
||||
|
||||
|
||||
/**
|
||||
*修改用户会员等级
|
||||
*/
|
||||
int upgradeMember(@Param("memberId") Long memberId, @Param("newMemberLevelId") Long newMemberLevelId);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.buy507.mall.model.UmsMemberRelationTree;
|
||||
import com.buy507.mall.model.UmsMemberRelationTreeExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
public interface UmsMemberRelationTreeMapper {
|
||||
long countByExample(UmsMemberRelationTreeExample example);
|
||||
@@ -27,4 +28,7 @@ public interface UmsMemberRelationTreeMapper {
|
||||
int updateByPrimaryKeySelective(UmsMemberRelationTree record);
|
||||
|
||||
int updateByPrimaryKey(UmsMemberRelationTree record);
|
||||
|
||||
@Select("select * from ums_member_relation_tree where member_id = #{currentUserId}")
|
||||
UmsMemberRelationTree findByMemberId(Long currentUserId);
|
||||
}
|
||||
@@ -7,15 +7,16 @@ package com.buy507.mall.model;
|
||||
*/
|
||||
public enum MemberLevel {
|
||||
/**普通用户**/
|
||||
Member(0),
|
||||
Member(1),
|
||||
/**vip会员**/
|
||||
Consumer(1),
|
||||
Consumer(2),
|
||||
/**店长**/
|
||||
Partner(2),
|
||||
Partner(3),
|
||||
/**代理**/
|
||||
Diamond(3),
|
||||
Diamond(4),
|
||||
/** 市代 **/
|
||||
OneDiamond(4),
|
||||
OneDiamond(5),
|
||||
|
||||
TwoDiamond(6), //中级合作商
|
||||
ThreeDiamond(7), //高级合作商
|
||||
FourDiamond(8); //特级合作商
|
||||
|
||||
@@ -45,7 +45,7 @@ public class OmsOrder implements Serializable {
|
||||
@ApiModelProperty(value = "管理员后台调整订单使用的折扣金额")
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
@ApiModelProperty(value = "支付方式:0->未支付;1->支付宝;2->微信;3->线下支付")
|
||||
@ApiModelProperty(value = "支付方式:0->未支付;1->支付宝;2->微信;3->线下支付;4->积分支付;5—>余额支付")
|
||||
private Integer payType;
|
||||
|
||||
@ApiModelProperty(value = "订单来源:0->PC订单;1->app订单")
|
||||
@@ -54,7 +54,7 @@ public class OmsOrder implements Serializable {
|
||||
@ApiModelProperty(value = "订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "订单类型:0->正常订单;1->秒杀订单")
|
||||
@ApiModelProperty(value = "订单类型:0->正常订单;1->秒杀订单;3->虚拟订单")
|
||||
private Integer orderType;
|
||||
|
||||
@ApiModelProperty(value = "提货方式:0->自提;1->物流")
|
||||
|
||||
@@ -62,13 +62,15 @@ public class OmsOrderItem implements Serializable {
|
||||
@ApiModelProperty(value = "该商品经过优惠后的分解金额")
|
||||
private BigDecimal realAmount;
|
||||
|
||||
private Integer giftIntegration;
|
||||
private BigDecimal giftIntegration;
|
||||
|
||||
private Integer giftGrowth;
|
||||
|
||||
@ApiModelProperty(value = "商品销售属性:[{'key':'颜色','value':'颜色'},{'key':'容量','value':'4G'}]")
|
||||
private String productAttr;
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Long getId() {
|
||||
@@ -239,11 +241,11 @@ public class OmsOrderItem implements Serializable {
|
||||
this.realAmount = realAmount;
|
||||
}
|
||||
|
||||
public Integer getGiftIntegration() {
|
||||
public BigDecimal getGiftIntegration() {
|
||||
return giftIntegration;
|
||||
}
|
||||
|
||||
public void setGiftIntegration(Integer giftIntegration) {
|
||||
public void setGiftIntegration(BigDecimal giftIntegration) {
|
||||
this.giftIntegration = giftIntegration;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,8 +157,7 @@ public class PmsProduct implements Serializable {
|
||||
|
||||
@Transient
|
||||
private SmsCoupon smsCoupon;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "评论信息")
|
||||
@Transient
|
||||
private List<PmsComment> pmsComment;
|
||||
@@ -175,17 +174,24 @@ public class PmsProduct implements Serializable {
|
||||
@ApiModelProperty(value = "好评比例")
|
||||
private PmsComment commentBiLi;
|
||||
|
||||
// 会员专区状态
|
||||
@Transient
|
||||
@ApiModelProperty(value = "会员专区状态")
|
||||
private Integer vipStatus;
|
||||
|
||||
// 积分专区状态
|
||||
@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 List<PmsProductAttribute> getProductAttribute() {
|
||||
return productAttribute;
|
||||
@@ -654,6 +660,14 @@ public class PmsProduct implements Serializable {
|
||||
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;}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -36,6 +36,38 @@ public class UmsDevelopmentFund implements Serializable {
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
public Integer getPointsTotal() {
|
||||
return pointsTotal;
|
||||
}
|
||||
|
||||
public void setPointsTotal(Integer pointsTotal) {
|
||||
this.pointsTotal = pointsTotal;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public BigDecimal getCashTotal() {
|
||||
return cashTotal;
|
||||
}
|
||||
|
||||
public void setCashTotal(BigDecimal cashTotal) {
|
||||
this.cashTotal = cashTotal;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UmsDevelopmentFund{" +
|
||||
|
||||
@@ -68,29 +68,18 @@ public class UmsMember implements Serializable {
|
||||
@ApiModelProperty(value = "分销实体店状态(0->未开店;1->已开店)")
|
||||
private StoreStatus storeStatus;
|
||||
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
@ApiModelProperty(value = "余额")
|
||||
private BigDecimal balance;
|
||||
|
||||
/**
|
||||
* 冻结余额
|
||||
*/
|
||||
@ApiModelProperty(value = "冻结余额")
|
||||
private BigDecimal freeze;
|
||||
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String detailAddress;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
@ApiModelProperty(value = "真实姓名")
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 排队状态
|
||||
*/
|
||||
@ApiModelProperty(value = "排队状态:0->未排队;1->排队中")
|
||||
private Integer orderStatus;
|
||||
|
||||
|
||||
@@ -41,6 +41,20 @@ public class UmsMemberAccountTransaction implements Serializable {
|
||||
@ApiModelProperty(value = "转账时间")
|
||||
private Date transferPaymentTime;
|
||||
|
||||
@ApiModelProperty(value = "进账积分")
|
||||
private Integer revenuePoints;
|
||||
|
||||
public Integer getFlowType() {
|
||||
return flowType;
|
||||
}
|
||||
|
||||
public void setFlowType(Integer flowType) {
|
||||
this.flowType = flowType;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "流水类型")
|
||||
private Integer flowType;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Long getId() {
|
||||
@@ -83,6 +97,14 @@ public class UmsMemberAccountTransaction implements Serializable {
|
||||
this.transactionState = transactionState;
|
||||
}
|
||||
|
||||
public Integer getRevenuePoints() {
|
||||
return revenuePoints;
|
||||
}
|
||||
|
||||
public void setRevenuePoints(Integer revenuePoints) {
|
||||
this.revenuePoints = revenuePoints;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
@@ -117,21 +139,18 @@ public class UmsMemberAccountTransaction implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", memberId=").append(memberId);
|
||||
sb.append(", orderId=").append(orderId);
|
||||
sb.append(", revenueAmount=").append(revenueAmount);
|
||||
sb.append(", transactionState=").append(transactionState);
|
||||
sb.append(", remarks=").append(remarks);
|
||||
sb.append(", commissionRatio=").append(commissionRatio);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", transferPaymentTime=").append(transferPaymentTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
return "UmsMemberAccountTransaction{" +
|
||||
"id=" + id +
|
||||
", memberId=" + memberId +
|
||||
", orderId=" + orderId +
|
||||
", revenueAmount=" + revenueAmount +
|
||||
", transactionState=" + transactionState +
|
||||
", remarks='" + remarks + '\'' +
|
||||
", commissionRatio=" + commissionRatio +
|
||||
", createTime=" + createTime +
|
||||
", transferPaymentTime=" + transferPaymentTime +
|
||||
", revenuePoints=" + revenuePoints +
|
||||
", flowType=" + flowType +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.buy507.mall.model;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -44,9 +45,12 @@ public class UmsMemberLevel implements Serializable {
|
||||
@ApiModelProperty(value = "注释")
|
||||
private String note;
|
||||
|
||||
@ApiModelProperty(value = "提成比例")
|
||||
@ApiModelProperty(value = "现金提成比例")
|
||||
private Integer commissionRatio;
|
||||
|
||||
@ApiModelProperty(value = "积分提成比例")
|
||||
private Integer pointsRatio;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Long getId() {
|
||||
@@ -161,28 +165,32 @@ public class UmsMemberLevel implements Serializable {
|
||||
this.commissionRatio = commissionRatio;
|
||||
}
|
||||
|
||||
public Integer getPointsRatio() {
|
||||
return pointsRatio;
|
||||
}
|
||||
|
||||
public void setPointsRatio(Integer pointsRatio) {
|
||||
this.pointsRatio = pointsRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", name=").append(name);
|
||||
sb.append(", growthPoint=").append(growthPoint);
|
||||
sb.append(", defaultStatus=").append(defaultStatus);
|
||||
sb.append(", freeFreightPoint=").append(freeFreightPoint);
|
||||
sb.append(", commentGrowthPoint=").append(commentGrowthPoint);
|
||||
sb.append(", priviledgeFreeFreight=").append(priviledgeFreeFreight);
|
||||
sb.append(", priviledgeSignIn=").append(priviledgeSignIn);
|
||||
sb.append(", priviledgeComment=").append(priviledgeComment);
|
||||
sb.append(", priviledgePromotion=").append(priviledgePromotion);
|
||||
sb.append(", priviledgeMemberPrice=").append(priviledgeMemberPrice);
|
||||
sb.append(", priviledgeBirthday=").append(priviledgeBirthday);
|
||||
sb.append(", note=").append(note);
|
||||
sb.append(", commissionRatio=").append(commissionRatio);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
return "UmsMemberLevel{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", growthPoint=" + growthPoint +
|
||||
", defaultStatus=" + defaultStatus +
|
||||
", freeFreightPoint=" + freeFreightPoint +
|
||||
", commentGrowthPoint=" + commentGrowthPoint +
|
||||
", priviledgeFreeFreight=" + priviledgeFreeFreight +
|
||||
", priviledgeSignIn=" + priviledgeSignIn +
|
||||
", priviledgeComment=" + priviledgeComment +
|
||||
", priviledgePromotion=" + priviledgePromotion +
|
||||
", priviledgeMemberPrice=" + priviledgeMemberPrice +
|
||||
", priviledgeBirthday=" + priviledgeBirthday +
|
||||
", note='" + note + '\'' +
|
||||
", commissionRatio=" + commissionRatio +
|
||||
", pointsRatio=" + pointsRatio +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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,9 @@
|
||||
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>
|
||||
</mapper>
|
||||
@@ -148,7 +148,7 @@
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.buy507.mall.model.OmsOrder">
|
||||
<insert id="insert" useGeneratedKeys="true" parameterType="com.buy507.mall.model.OmsOrder">
|
||||
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
|
||||
@@ -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
|
||||
@@ -234,6 +234,15 @@
|
||||
<if test="newStatus != null">
|
||||
new_status,
|
||||
</if>
|
||||
<if test="vipStatus != null">
|
||||
vip_status,
|
||||
</if>
|
||||
<if test="pointsAreaStatus != null">
|
||||
points_area_status,
|
||||
</if>
|
||||
<if test="pointsExchangeStatus != null">
|
||||
points_exchange_status,
|
||||
</if>
|
||||
<if test="recommandStatus != null">
|
||||
recommand_status,
|
||||
</if>
|
||||
@@ -327,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">
|
||||
@@ -452,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">
|
||||
@@ -925,10 +940,118 @@
|
||||
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">
|
||||
<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>
|
||||
@@ -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)
|
||||
transaction_state, remarks, commission_ratio, transfer_payment_time, revenue_points)
|
||||
values (#{memberId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, #{revenueAmount,jdbcType=DECIMAL},
|
||||
#{transactionState,jdbcType=INTEGER}, #{remarks,jdbcType=VARCHAR}, #{commissionRatio,jdbcType=INTEGER},
|
||||
#{transferPaymentTime,jdbcType=TIMESTAMP})
|
||||
#{transferPaymentTime,jdbcType=TIMESTAMP}, #{revenuePoints,jdbcType=INTEGER})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.buy507.mall.model.UmsMemberAccountTransaction">
|
||||
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
|
||||
|
||||
@@ -558,6 +558,10 @@
|
||||
select u.phone from ums_member u
|
||||
where u.phone=#{phone,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<update id="upgradeMember">
|
||||
UPDATE ums_member
|
||||
SET member_level_id = #{newMemberLevelId}
|
||||
WHERE id = #{memberId}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -141,7 +141,7 @@
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update ums_member_relation_tree
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>1.18.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -3,12 +3,7 @@ package com.buy507.mall.portal.controller;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.buy507.mall.common.api.CommonResult;
|
||||
import com.buy507.mall.model.PmsProduct;
|
||||
@@ -96,4 +91,30 @@ public class HomeController {
|
||||
return CommonResult.success(productSku);
|
||||
}
|
||||
|
||||
@ApiOperation("获取会员专区商品")
|
||||
@RequestMapping(value = "/getVipProductList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<PmsProduct>> getVipProductList(){
|
||||
List<PmsProduct> vipProductList = homeService.getVipProductList();
|
||||
return CommonResult.success(vipProductList);
|
||||
}
|
||||
|
||||
@ApiOperation("获取积分专区商品")
|
||||
@RequestMapping(value = "/getPointProductList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<PmsProduct>> getPointProductList(){
|
||||
List<PmsProduct> pointProductList = homeService.getPointProductList();
|
||||
return CommonResult.success(pointProductList);
|
||||
}
|
||||
|
||||
@ApiOperation("获取积分兑换专区")
|
||||
@RequestMapping(value = "/getPointExchangeProductList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<PmsProduct>> getPointExchangeProductList(){
|
||||
List<PmsProduct> pointExchangeProductList = homeService.getPointExchangeProductList();
|
||||
return CommonResult.success(pointExchangeProductList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.buy507.mall.portal.controller;
|
||||
|
||||
import com.buy507.mall.common.api.CommonResult;
|
||||
import com.buy507.mall.portal.domain.WithdrawApplyParam;
|
||||
import com.buy507.mall.portal.service.MyWalletService;
|
||||
import com.buy507.mall.portal.service.UmsMemberService;
|
||||
import com.buy507.mall.portal.vo.WalletCashVo;
|
||||
import com.buy507.mall.portal.vo.WalletPointsVo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/wallet")
|
||||
public class MyWalletController {
|
||||
|
||||
@Autowired
|
||||
private MyWalletService myWalletService;
|
||||
|
||||
@Autowired
|
||||
private UmsMemberService memberService;
|
||||
|
||||
|
||||
@ApiOperation("获取现金余额和流水")
|
||||
@GetMapping("/balance")
|
||||
public CommonResult<WalletCashVo> getBalance(@RequestParam Long userId){
|
||||
WalletCashVo walletCashVo = myWalletService.getBalanceAndCashFlow(userId);
|
||||
return CommonResult.success(walletCashVo);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取积分余额和流水")
|
||||
@GetMapping("/points")
|
||||
public CommonResult<WalletPointsVo> getIntegration(@RequestParam Long userId){
|
||||
WalletPointsVo walletPointsVo = myWalletService.getIntegrationAndPointsFlow(userId);
|
||||
return CommonResult.success(walletPointsVo);
|
||||
}
|
||||
|
||||
@ApiOperation("会员提现申请")
|
||||
@PostMapping(value = "/withdraw")
|
||||
public CommonResult withdrawApply(@RequestBody WithdrawApplyParam applyParam) {
|
||||
return memberService.withdrawApply(applyParam);
|
||||
}
|
||||
}
|
||||
@@ -137,11 +137,19 @@ public class OmsPortalOrderController {
|
||||
|
||||
@ApiOperation("积分支付")
|
||||
@ApiImplicitParam(name = "orderId", value = "订单ID", paramType = "query")
|
||||
@RequestMapping(value = "/pointPayment", method = RequestMethod.POST)
|
||||
public CommonResult pointPayment(@RequestParam Long orderId) {
|
||||
return portalOrderService.pointPayment(orderId);
|
||||
}
|
||||
|
||||
@ApiOperation("余额支付")
|
||||
@ApiImplicitParam(name = "orderId", value = "订单ID", paramType = "query")
|
||||
@RequestMapping(value = "/balancePayment", method = RequestMethod.POST)
|
||||
public CommonResult balancePayment(@RequestParam Long orderId) {
|
||||
return portalOrderService.balancePayment(orderId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation("微信预支付")
|
||||
@ApiImplicitParam(name = "orderId", value = "订单ID", paramType = "query")
|
||||
@RequestMapping(value = "/wxPrePay", method = RequestMethod.POST)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.buy507.mall.portal.controller;
|
||||
|
||||
import com.buy507.mall.common.api.CommonResult;
|
||||
import com.buy507.mall.model.UmsDevelopmentFund;
|
||||
import com.buy507.mall.portal.domain.*;
|
||||
import com.buy507.mall.portal.service.UmsMemberService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -89,7 +90,14 @@ public class UmsMemberController {
|
||||
MemberInfoResult result = memberService.getMemberInfo();
|
||||
return CommonResult.success(result);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取发展基金")
|
||||
@RequestMapping(value = "/getDevelopmentFund", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<UmsDevelopmentFund> getDevelopmentFund() {
|
||||
UmsDevelopmentFund result = memberService.getDevelopmentFund();
|
||||
return CommonResult.success(result);
|
||||
}
|
||||
|
||||
@ApiOperation("修改会员昵称")
|
||||
@RequestMapping(value = "/updateMemberNickname", method = RequestMethod.POST)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.buy507.mall.portal.controller;
|
||||
|
||||
import com.buy507.mall.common.api.CommonResult;
|
||||
import com.buy507.mall.model.OmsOrder;
|
||||
import com.buy507.mall.portal.domain.OrderParam;
|
||||
import com.buy507.mall.portal.service.VipCenterService;
|
||||
import com.buy507.mall.portal.vo.OmsOrderDTO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/vip")
|
||||
public class VipController {
|
||||
|
||||
@Autowired
|
||||
private VipCenterService vipCenterService;
|
||||
|
||||
@ApiOperation("查询升级权限金额")
|
||||
@RequestMapping(value = "/getUpgradeAmount", method = RequestMethod.GET)
|
||||
public CommonResult<BigDecimal> getUpgradeAmount(@RequestParam Long memberLevelId){
|
||||
BigDecimal amount = vipCenterService.getUpgradeAmount(memberLevelId);
|
||||
return CommonResult.success(amount);
|
||||
}
|
||||
|
||||
@ApiOperation("创建购买权益订单")
|
||||
@RequestMapping(value = "/createUpgradeOrder", method = RequestMethod.POST)
|
||||
public CommonResult createUpgradeOrder(@RequestBody OmsOrderDTO param){
|
||||
try {
|
||||
return vipCenterService.createUpgradeOrder(param);
|
||||
} catch (Exception e) {
|
||||
return CommonResult.failed("createOrder fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,5 +39,35 @@ public interface HomeDao {
|
||||
/*
|
||||
* 获取所有商品信息按销量排序
|
||||
*/
|
||||
List<PmsProduct> getAllPioductList();
|
||||
List<PmsProduct> getAllPioductList();
|
||||
|
||||
/**
|
||||
* 获取会员专区
|
||||
*/
|
||||
List<PmsProduct> getProductVipStatus(@Param("offset") Integer offset,@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 获取积分专区
|
||||
*/
|
||||
List<PmsProduct> getProductpointSareaStatus(@Param("offset") Integer offset,@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 获取积分兑换专区
|
||||
*/
|
||||
List<PmsProduct> getProductpointsExchangeStatus(@Param("offset") Integer offset,@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 获取会员专区详情
|
||||
*/
|
||||
List<PmsProduct> getVipStatusList();
|
||||
|
||||
/**
|
||||
*获取积分专区商品
|
||||
*/
|
||||
List<PmsProduct> getPointStatusList();
|
||||
|
||||
/**
|
||||
*获取积分兑换专区商品
|
||||
*/
|
||||
List<PmsProduct> getPointExchangeProductList();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.buy507.mall.portal.dao;
|
||||
|
||||
import com.buy507.mall.portal.vo.TransactionCashVo;
|
||||
import com.buy507.mall.portal.vo.TransactionPointsVo;
|
||||
import com.buy507.mall.portal.vo.WalletCashVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MyWalletMapper {
|
||||
/**
|
||||
* 获取用户现金余额
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Select("SELECT balance FROM ums_member WHERE id = #{userId}")
|
||||
BigDecimal getBalance(Long userId);
|
||||
|
||||
/**
|
||||
* 获取用户现金流水
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Select("SELECT revenue_amount, remarks, transfer_payment_time FROM ums_member_account_transaction " +
|
||||
"WHERE member_id = #{userId} And flow_type = 1 ORDER BY transfer_payment_time DESC")
|
||||
List<TransactionCashVo> getCashFlow(Long userId);
|
||||
|
||||
/**
|
||||
* 获取用户积分余额
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Select("SELECT integration FROM ums_member WHERE id = #{userId}")
|
||||
Integer getIntegration(Long userId);
|
||||
|
||||
/**
|
||||
* 获取用户积分流水
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Select("SELECT revenue_points, remarks, transfer_payment_time FROM ums_member_account_transaction " +
|
||||
"WHERE member_id = #{userId} And flow_type = 2 ORDER BY transfer_payment_time DESC")
|
||||
List<TransactionPointsVo> getPointsFlow(Long userId);
|
||||
}
|
||||
@@ -27,6 +27,12 @@ public class HomeContentResult {
|
||||
private List<PmsProduct> hotProductList;
|
||||
//推荐专题
|
||||
private List<CmsSubject> subjectList;
|
||||
//会员专区
|
||||
private List<PmsProduct> vipProductList;
|
||||
//积分专区
|
||||
private List<PmsProduct> pointsAreaProductList;
|
||||
//积分兑换专区
|
||||
private List<PmsProduct> pointsExchangeProductList;
|
||||
//查询所有商品按销量排序
|
||||
private List<PmsProduct> allProductList;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,29 @@ 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;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class OrderResult {
|
||||
@ApiModelProperty(value = "支付时间")
|
||||
private Date paymentTime;
|
||||
|
||||
@ApiModelProperty(value = "支付类型: 1->支付宝;2->微信;3->线下支付;4->积分支付")
|
||||
@ApiModelProperty(value = "支付类型: 1->支付宝;2->微信;3->线下支付;4->积分支付; 5->余额支付")
|
||||
private Integer payType;
|
||||
|
||||
@ApiModelProperty(value = "支付类型名称")
|
||||
@@ -113,6 +113,27 @@ public class OrderResult {
|
||||
@ApiModelProperty(value = "快速排队订单还剩邀请成功的人数")
|
||||
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() {
|
||||
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;
|
||||
@@ -152,7 +153,53 @@ public class ProductDetailResult {
|
||||
private int countComent;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,21 @@ public interface HomeService {
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取会员专区商品
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
List<PmsProduct> getVipProductList();
|
||||
|
||||
ProductDetailResult getProductInfo(Long productId);
|
||||
|
||||
ProductSkuResult getProductSku(Long productId, String sp1, String sp2, String sp3);
|
||||
|
||||
List<PmsProduct> getProductList(Long brandId, Long categoryId, String sortType, Integer pageSize, Integer pageNum);
|
||||
|
||||
List<PmsProduct> getPointProductList();
|
||||
|
||||
List<PmsProduct> getPointExchangeProductList();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.buy507.mall.model.UmsMember;
|
||||
public interface MemberCommissionService {
|
||||
/**
|
||||
* 开始冻结金额到账,等级升级
|
||||
* @param order
|
||||
* @param currentMember
|
||||
*/
|
||||
void computeCommission(UmsMember currentMember);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.buy507.mall.portal.service;
|
||||
|
||||
import com.buy507.mall.portal.vo.WalletCashVo;
|
||||
import com.buy507.mall.portal.vo.WalletPointsVo;
|
||||
|
||||
public interface MyWalletService {
|
||||
|
||||
/**
|
||||
* 获取现金余额和流水
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
WalletCashVo getBalanceAndCashFlow(Long userId);
|
||||
|
||||
/**
|
||||
* 获取积分余额和流水
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
WalletPointsVo getIntegrationAndPointsFlow(Long userId);
|
||||
}
|
||||
@@ -80,12 +80,17 @@ public interface OmsPortalOrderService {
|
||||
CommonResult confirmReceiving(Long orderId);
|
||||
|
||||
/**
|
||||
* 余额支付
|
||||
* 积分支付
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
CommonResult pointPayment(Long orderId);
|
||||
|
||||
/**
|
||||
* 余额支付
|
||||
*/
|
||||
CommonResult balancePayment(Long orderId);
|
||||
|
||||
|
||||
/**
|
||||
* 微信预支付
|
||||
* @param orderId
|
||||
|
||||
@@ -13,7 +13,7 @@ public interface PortalCommonService {
|
||||
|
||||
/**
|
||||
* 获取会员的折扣
|
||||
* @param member
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getDiscount(Long memberId);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.buy507.mall.portal.service;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.buy507.mall.model.UmsDevelopmentFund;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@@ -185,4 +186,10 @@ public interface UmsMemberService {
|
||||
* @return
|
||||
*/
|
||||
CommonResult<Map<String, Object>> personalTeam();
|
||||
|
||||
/**
|
||||
* 查询发展基金
|
||||
* @return
|
||||
*/
|
||||
UmsDevelopmentFund getDevelopmentFund();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.buy507.mall.portal.service;
|
||||
|
||||
import com.buy507.mall.common.api.CommonResult;
|
||||
import com.buy507.mall.model.OmsOrder;
|
||||
import com.buy507.mall.portal.domain.OrderParam;
|
||||
import com.buy507.mall.portal.vo.OmsOrderDTO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public interface VipCenterService {
|
||||
|
||||
/**
|
||||
* 查询升级权限金额
|
||||
* @param memberLevelId
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getUpgradeAmount(Long memberLevelId);
|
||||
|
||||
/**
|
||||
* 创建购买权益订单
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
CommonResult createUpgradeOrder(OmsOrderDTO param);
|
||||
}
|
||||
@@ -1,298 +1,288 @@
|
||||
package com.buy507.mall.portal.service.impl;
|
||||
|
||||
import com.buy507.mall.mapper.*;
|
||||
import com.buy507.mall.model.*;
|
||||
import com.buy507.mall.portal.dao.HomeDao;
|
||||
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;
|
||||
|
||||
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.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.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;
|
||||
|
||||
/**
|
||||
* 首页内容管理Service实现类
|
||||
*/
|
||||
@Service
|
||||
public class HomeServiceImpl implements HomeService {
|
||||
@Autowired
|
||||
private SmsHomeAdvertiseMapper advertiseMapper;
|
||||
@Autowired
|
||||
private HomeDao homeDao;
|
||||
@Autowired
|
||||
private SmsFlashPromotionMapper flashPromotionMapper;
|
||||
@Autowired
|
||||
private SmsFlashPromotionSessionMapper promotionSessionMapper;
|
||||
@Autowired
|
||||
private PmsProductMapper productMapper;
|
||||
@Autowired
|
||||
private PmsProductCategoryMapper productCategoryMapper;
|
||||
@Autowired
|
||||
private CmsSubjectMapper subjectMapper;
|
||||
@Autowired
|
||||
private PmsCommentReplayMapper pmsCommentReplayMapper;
|
||||
@Autowired
|
||||
private PmsCommentMapper pmsCommentMapper;
|
||||
|
||||
@Autowired
|
||||
private PmsProductFullReductionMapper pmsProductFullReductionMapper;
|
||||
@Autowired
|
||||
private SmsHomeAdvertiseMapper advertiseMapper;
|
||||
@Autowired
|
||||
private HomeDao homeDao;
|
||||
@Autowired
|
||||
private SmsFlashPromotionMapper flashPromotionMapper;
|
||||
@Autowired
|
||||
private SmsFlashPromotionSessionMapper promotionSessionMapper;
|
||||
@Autowired
|
||||
private PmsProductMapper productMapper;
|
||||
@Autowired
|
||||
private PmsProductCategoryMapper productCategoryMapper;
|
||||
@Autowired
|
||||
private CmsSubjectMapper subjectMapper;
|
||||
@Autowired
|
||||
private PmsCommentReplayMapper pmsCommentReplayMapper;
|
||||
@Autowired
|
||||
private PmsCommentMapper pmsCommentMapper;
|
||||
|
||||
@Autowired
|
||||
private PmsProductAttributeMapper pmsProductAttributeMapper;
|
||||
|
||||
@Autowired
|
||||
private PmsProductAttributeValueMapper productAttributeValueMapper;
|
||||
|
||||
@Autowired
|
||||
private MemberProductCollectionRepository productCollectionRepository;
|
||||
|
||||
@Autowired
|
||||
private PmsSkuStockMapper skuStockMapper;
|
||||
|
||||
@Autowired
|
||||
private UmsMemberService memberService;
|
||||
|
||||
@Autowired
|
||||
@Autowired
|
||||
private PmsProductFullReductionMapper pmsProductFullReductionMapper;
|
||||
|
||||
@Autowired
|
||||
private PmsProductAttributeMapper pmsProductAttributeMapper;
|
||||
|
||||
@Autowired
|
||||
private PmsProductAttributeValueMapper productAttributeValueMapper;
|
||||
|
||||
@Autowired
|
||||
private MemberProductCollectionRepository productCollectionRepository;
|
||||
|
||||
@Autowired
|
||||
private PmsSkuStockMapper skuStockMapper;
|
||||
|
||||
@Autowired
|
||||
private UmsMemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private PortalCommonService commonService;
|
||||
|
||||
@Override
|
||||
public HomeContentResult content() {
|
||||
|
||||
HomeContentResult result = new HomeContentResult();
|
||||
//获取首页广告
|
||||
result.setAdvertiseList(getHomeAdvertiseList());
|
||||
//获取推荐品牌
|
||||
result.setBrandList(homeDao.getRecommendBrandList(0,4));
|
||||
//获取秒杀信息
|
||||
result.setHomeFlashPromotion(getHomeFlashPromotion());
|
||||
|
||||
List<PmsProduct> newProductList = homeDao.getNewProductList(0, 4);
|
||||
List<PmsProduct> hotProductList = homeDao.getHotProductList(0, 4);
|
||||
List<PmsProduct> allProductList = homeDao.getAllPioductList();
|
||||
|
||||
//根据会员等级显示不同的商品价格
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
if(member != null) {
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
if(discount != null) {
|
||||
for(PmsProduct product : newProductList) {
|
||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
for(PmsProduct product : hotProductList) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取新品推荐
|
||||
result.setNewProductList(newProductList);
|
||||
//获取人气推荐
|
||||
result.setHotProductList(hotProductList);
|
||||
//获取推荐专题
|
||||
//result.setSubjectList(homeDao.getRecommendSubjectList(0,4));
|
||||
//获取上次所有商品,按销量排序
|
||||
result.setAllProductList(allProductList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PmsProduct> recommendProductList(Integer pageSize, Integer pageNum) {
|
||||
// TODO: 2019/1/29 暂时默认推荐所有商品
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria()
|
||||
.andDeleteStatusEqualTo(0)
|
||||
.andPublishStatusEqualTo(1);
|
||||
return productMapper.selectByExample(example);
|
||||
}
|
||||
@Override
|
||||
public HomeContentResult content() {
|
||||
|
||||
@Override
|
||||
public List<ProductCategoryOptions> getProductCateList() {
|
||||
PmsProductCategoryExample example = new PmsProductCategoryExample();
|
||||
example.createCriteria()
|
||||
.andShowStatusEqualTo(1);
|
||||
example.setOrderByClause("sort desc");
|
||||
List<PmsProductCategory> productCategories = productCategoryMapper.selectByExample(example);
|
||||
|
||||
List<ProductCategoryOptions> options = new ArrayList<>();
|
||||
for(PmsProductCategory category : productCategories) {
|
||||
//我们这里最大的根节点ID是0,所以找出所有parent id为0的节点,然后调用我们的递归算法
|
||||
if(category.getParentId().equals(0L)){
|
||||
options.add(recursionCategory(category, productCategories));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
private ProductCategoryOptions recursionCategory(PmsProductCategory category, List<PmsProductCategory> list) {
|
||||
List<ProductCategoryOptions> childList = new ArrayList<>();
|
||||
// 为每一个父节点增加子树(List形式,没有则为空的list)
|
||||
ProductCategoryOptions node = new ProductCategoryOptions();
|
||||
node.setId(category.getId());
|
||||
node.setName(category.getName());
|
||||
node.setLevel(category.getLevel());
|
||||
node.setIcon(category.getIcon());
|
||||
node.setPid(category.getParentId());
|
||||
for (PmsProductCategory childCategory : list){
|
||||
//如果子节点的pid等于父节点的ID,则说明是父子关系
|
||||
if(childCategory.getParentId().equals(category.getId())){
|
||||
// 继续调用递归算法,将当前作为父节点,继续找他的子节点,反复执行。
|
||||
childList.add(recursionCategory(childCategory, list));
|
||||
}
|
||||
}
|
||||
|
||||
// 当遍历完成,返回调用的节点
|
||||
if(!childList.isEmpty()) {
|
||||
node.setChildren(childList);
|
||||
} else {
|
||||
node.setChildren(null);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
HomeContentResult result = new HomeContentResult();
|
||||
//获取首页广告
|
||||
result.setAdvertiseList(getHomeAdvertiseList());
|
||||
//获取推荐品牌
|
||||
result.setBrandList(homeDao.getRecommendBrandList(0, 4));
|
||||
//获取秒杀信息
|
||||
result.setHomeFlashPromotion(getHomeFlashPromotion());
|
||||
|
||||
@Override
|
||||
public List<CmsSubject> getSubjectList(Long cateId, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
CmsSubjectExample example = new CmsSubjectExample();
|
||||
CmsSubjectExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andShowStatusEqualTo(1);
|
||||
if(cateId!=null){
|
||||
criteria.andCategoryIdEqualTo(cateId);
|
||||
}
|
||||
return subjectMapper.selectByExample(example);
|
||||
}
|
||||
List<PmsProduct> VipProductList = homeDao.getProductVipStatus(0, 4);
|
||||
List<PmsProduct> PointAreaProductList = homeDao.getProductpointSareaStatus(0, 4);
|
||||
List<PmsProduct> pointsExchangeProductList = homeDao.getProductpointsExchangeStatus(0, 4);
|
||||
List<PmsProduct> allProductList = homeDao.getAllPioductList();
|
||||
|
||||
private HomeFlashPromotion getHomeFlashPromotion() {
|
||||
HomeFlashPromotion homeFlashPromotion = new HomeFlashPromotion();
|
||||
//获取当前秒杀活动
|
||||
Date now = new Date();
|
||||
SmsFlashPromotion flashPromotion = getFlashPromotion(now);
|
||||
if (flashPromotion != null) {
|
||||
//获取当前秒杀场次
|
||||
SmsFlashPromotionSession flashPromotionSession = getFlashPromotionSession(now);
|
||||
if (flashPromotionSession != null) {
|
||||
homeFlashPromotion.setStartTime(flashPromotionSession.getStartTime());
|
||||
homeFlashPromotion.setEndTime(flashPromotionSession.getEndTime());
|
||||
homeFlashPromotion.setName(flashPromotion.getTitle());
|
||||
//获取下一个秒杀场次
|
||||
SmsFlashPromotionSession nextSession = getNextFlashPromotionSession(homeFlashPromotion.getStartTime());
|
||||
if(nextSession!=null){
|
||||
homeFlashPromotion.setNextStartTime(nextSession.getStartTime());
|
||||
homeFlashPromotion.setNextEndTime(nextSession.getEndTime());
|
||||
}
|
||||
//获取秒杀商品
|
||||
List<FlashPromotionProduct> flashProductList = homeDao.getFlashProductList(flashPromotion.getId(), flashPromotionSession.getId());
|
||||
homeFlashPromotion.setProductList(flashProductList);
|
||||
}
|
||||
}
|
||||
return homeFlashPromotion;
|
||||
}
|
||||
//根据会员等级显示不同的商品价格
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
if (member != null) {
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
if (discount != null) {
|
||||
for (PmsProduct product : VipProductList) {
|
||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
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 : allProductList) {
|
||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取下一个场次信息
|
||||
private SmsFlashPromotionSession getNextFlashPromotionSession(Date date) {
|
||||
SmsFlashPromotionSessionExample sessionExample = new SmsFlashPromotionSessionExample();
|
||||
sessionExample.createCriteria()
|
||||
.andStartTimeGreaterThan(date);
|
||||
sessionExample.setOrderByClause("start_time asc");
|
||||
List<SmsFlashPromotionSession> promotionSessionList = promotionSessionMapper.selectByExample(sessionExample);
|
||||
if (!CollectionUtils.isEmpty(promotionSessionList)) {
|
||||
return promotionSessionList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//获取会员商品
|
||||
result.setVipProductList(VipProductList);
|
||||
//获取积分专区商品
|
||||
result.setPointsAreaProductList(PointAreaProductList);
|
||||
//获取积分兑换商品
|
||||
result.setPointsExchangeProductList(pointsExchangeProductList);
|
||||
//获取推荐专题
|
||||
//result.setSubjectList(homeDao.getRecommendSubjectList(0,4));
|
||||
//获取上次所有商品,按销量排序
|
||||
result.setAllProductList(allProductList);
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<SmsHomeAdvertise> getHomeAdvertiseList() {
|
||||
SmsHomeAdvertiseExample example = new SmsHomeAdvertiseExample();
|
||||
example.createCriteria().andTypeEqualTo(1).andStatusEqualTo(1);
|
||||
example.setOrderByClause("sort desc");
|
||||
return advertiseMapper.selectByExample(example);
|
||||
}
|
||||
@Override
|
||||
public List<PmsProduct> recommendProductList(Integer pageSize, Integer pageNum) {
|
||||
// TODO: 2019/1/29 暂时默认推荐所有商品
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria()
|
||||
.andDeleteStatusEqualTo(0)
|
||||
.andPublishStatusEqualTo(1);
|
||||
return productMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
//根据时间获取秒杀活动
|
||||
private SmsFlashPromotion getFlashPromotion(Date date) {
|
||||
Date currDate = DateUtil.getDate(date);
|
||||
SmsFlashPromotionExample example = new SmsFlashPromotionExample();
|
||||
example.createCriteria()
|
||||
.andStatusEqualTo(1)
|
||||
.andStartDateLessThanOrEqualTo(currDate)
|
||||
.andEndDateGreaterThanOrEqualTo(currDate);
|
||||
List<SmsFlashPromotion> flashPromotionList = flashPromotionMapper.selectByExample(example);
|
||||
if (!CollectionUtils.isEmpty(flashPromotionList)) {
|
||||
return flashPromotionList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public List<ProductCategoryOptions> getProductCateList() {
|
||||
PmsProductCategoryExample example = new PmsProductCategoryExample();
|
||||
example.createCriteria()
|
||||
.andShowStatusEqualTo(1);
|
||||
example.setOrderByClause("sort desc");
|
||||
List<PmsProductCategory> productCategories = productCategoryMapper.selectByExample(example);
|
||||
|
||||
//根据时间获取秒杀场次
|
||||
private SmsFlashPromotionSession getFlashPromotionSession(Date date) {
|
||||
Date currTime = DateUtil.getTime(date);
|
||||
SmsFlashPromotionSessionExample sessionExample = new SmsFlashPromotionSessionExample();
|
||||
sessionExample.createCriteria()
|
||||
.andStartTimeLessThanOrEqualTo(currTime)
|
||||
.andEndTimeGreaterThanOrEqualTo(currTime);
|
||||
List<SmsFlashPromotionSession> promotionSessionList = promotionSessionMapper.selectByExample(sessionExample);
|
||||
if (!CollectionUtils.isEmpty(promotionSessionList)) {
|
||||
return promotionSessionList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//获取商品详情
|
||||
List<ProductCategoryOptions> options = new ArrayList<>();
|
||||
for (PmsProductCategory category : productCategories) {
|
||||
//我们这里最大的根节点ID是0,所以找出所有parent id为0的节点,然后调用我们的递归算法
|
||||
if (category.getParentId().equals(0L)) {
|
||||
options.add(recursionCategory(category, productCategories));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
*获取会员专区商品
|
||||
*/
|
||||
@Override
|
||||
public List<PmsProduct> getVipProductList() {
|
||||
return homeDao.getVipStatusList();
|
||||
}
|
||||
|
||||
/**
|
||||
*获取积分专区商品
|
||||
*/
|
||||
@Override
|
||||
public List<PmsProduct> getPointProductList() {
|
||||
return homeDao.getPointStatusList();
|
||||
}
|
||||
|
||||
/**
|
||||
*获取积分兑换专区
|
||||
*/
|
||||
@Override
|
||||
public List<PmsProduct> getPointExchangeProductList() {
|
||||
return homeDao.getPointExchangeProductList();
|
||||
}
|
||||
private ProductCategoryOptions recursionCategory(PmsProductCategory category, List<PmsProductCategory> list) {
|
||||
List<ProductCategoryOptions> childList = new ArrayList<>();
|
||||
// 为每一个父节点增加子树(List形式,没有则为空的list)
|
||||
ProductCategoryOptions node = new ProductCategoryOptions();
|
||||
node.setId(category.getId());
|
||||
node.setName(category.getName());
|
||||
node.setLevel(category.getLevel());
|
||||
node.setIcon(category.getIcon());
|
||||
node.setPid(category.getParentId());
|
||||
for (PmsProductCategory childCategory : list) {
|
||||
//如果子节点的pid等于父节点的ID,则说明是父子关系
|
||||
if (childCategory.getParentId().equals(category.getId())) {
|
||||
// 继续调用递归算法,将当前作为父节点,继续找他的子节点,反复执行。
|
||||
childList.add(recursionCategory(childCategory, list));
|
||||
}
|
||||
}
|
||||
|
||||
// 当遍历完成,返回调用的节点
|
||||
if (!childList.isEmpty()) {
|
||||
node.setChildren(childList);
|
||||
} else {
|
||||
node.setChildren(null);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CmsSubject> getSubjectList(Long cateId, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
CmsSubjectExample example = new CmsSubjectExample();
|
||||
CmsSubjectExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andShowStatusEqualTo(1);
|
||||
if (cateId != null) {
|
||||
criteria.andCategoryIdEqualTo(cateId);
|
||||
}
|
||||
return subjectMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
private HomeFlashPromotion getHomeFlashPromotion() {
|
||||
HomeFlashPromotion homeFlashPromotion = new HomeFlashPromotion();
|
||||
//获取当前秒杀活动
|
||||
Date now = new Date();
|
||||
SmsFlashPromotion flashPromotion = getFlashPromotion(now);
|
||||
if (flashPromotion != null) {
|
||||
//获取当前秒杀场次
|
||||
SmsFlashPromotionSession flashPromotionSession = getFlashPromotionSession(now);
|
||||
if (flashPromotionSession != null) {
|
||||
homeFlashPromotion.setStartTime(flashPromotionSession.getStartTime());
|
||||
homeFlashPromotion.setEndTime(flashPromotionSession.getEndTime());
|
||||
homeFlashPromotion.setName(flashPromotion.getTitle());
|
||||
//获取下一个秒杀场次
|
||||
SmsFlashPromotionSession nextSession = getNextFlashPromotionSession(homeFlashPromotion.getStartTime());
|
||||
if (nextSession != null) {
|
||||
homeFlashPromotion.setNextStartTime(nextSession.getStartTime());
|
||||
homeFlashPromotion.setNextEndTime(nextSession.getEndTime());
|
||||
}
|
||||
//获取秒杀商品
|
||||
List<FlashPromotionProduct> flashProductList = homeDao.getFlashProductList(flashPromotion.getId(), flashPromotionSession.getId());
|
||||
homeFlashPromotion.setProductList(flashProductList);
|
||||
}
|
||||
}
|
||||
return homeFlashPromotion;
|
||||
}
|
||||
|
||||
//获取下一个场次信息
|
||||
private SmsFlashPromotionSession getNextFlashPromotionSession(Date date) {
|
||||
SmsFlashPromotionSessionExample sessionExample = new SmsFlashPromotionSessionExample();
|
||||
sessionExample.createCriteria()
|
||||
.andStartTimeGreaterThan(date);
|
||||
sessionExample.setOrderByClause("start_time asc");
|
||||
List<SmsFlashPromotionSession> promotionSessionList = promotionSessionMapper.selectByExample(sessionExample);
|
||||
if (!CollectionUtils.isEmpty(promotionSessionList)) {
|
||||
return promotionSessionList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<SmsHomeAdvertise> getHomeAdvertiseList() {
|
||||
SmsHomeAdvertiseExample example = new SmsHomeAdvertiseExample();
|
||||
example.createCriteria().andTypeEqualTo(1).andStatusEqualTo(1);
|
||||
example.setOrderByClause("sort desc");
|
||||
return advertiseMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
//根据时间获取秒杀活动
|
||||
private SmsFlashPromotion getFlashPromotion(Date date) {
|
||||
Date currDate = DateUtil.getDate(date);
|
||||
SmsFlashPromotionExample example = new SmsFlashPromotionExample();
|
||||
example.createCriteria()
|
||||
.andStatusEqualTo(1)
|
||||
.andStartDateLessThanOrEqualTo(currDate)
|
||||
.andEndDateGreaterThanOrEqualTo(currDate);
|
||||
List<SmsFlashPromotion> flashPromotionList = flashPromotionMapper.selectByExample(example);
|
||||
if (!CollectionUtils.isEmpty(flashPromotionList)) {
|
||||
return flashPromotionList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//根据时间获取秒杀场次
|
||||
private SmsFlashPromotionSession getFlashPromotionSession(Date date) {
|
||||
Date currTime = DateUtil.getTime(date);
|
||||
SmsFlashPromotionSessionExample sessionExample = new SmsFlashPromotionSessionExample();
|
||||
sessionExample.createCriteria()
|
||||
.andStartTimeLessThanOrEqualTo(currTime)
|
||||
.andEndTimeGreaterThanOrEqualTo(currTime);
|
||||
List<SmsFlashPromotionSession> promotionSessionList = promotionSessionMapper.selectByExample(sessionExample);
|
||||
if (!CollectionUtils.isEmpty(promotionSessionList)) {
|
||||
return promotionSessionList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//获取商品详情
|
||||
@Override
|
||||
public ProductDetailResult getProductInfo(Long productId) {
|
||||
PmsProduct product = productMapper.selectByPrimaryKey(productId);
|
||||
@@ -301,15 +291,15 @@ public class HomeServiceImpl implements HomeService {
|
||||
List<String> result = Arrays.asList(detailResult.getAlbumPics().toString().split(","));
|
||||
detailResult.setListAlbumPics(result);
|
||||
detailResult.setAlbumPics(null);
|
||||
PmsProductFullReduction ppFullReduction =(PmsProductFullReduction)pmsProductFullReductionMapper.getPmsProductFullReduction(productId);
|
||||
PmsProductFullReduction ppFullReduction = (PmsProductFullReduction) pmsProductFullReductionMapper.getPmsProductFullReduction(productId);
|
||||
detailResult.setPmsProductFullReduction(ppFullReduction);//满减商品
|
||||
|
||||
|
||||
UmsMember currentMember = memberService.getCurrentMember();//获取用户信息
|
||||
if(currentMember == null) {
|
||||
if (currentMember == null) {
|
||||
detailResult.setWhetherTheCollection(0);//默认商品未收藏,1代表收藏
|
||||
} else {
|
||||
for(MemberProductCollection scproduct:productCollectionRepository.findByMemberId(currentMember.getId())){
|
||||
if(productId==scproduct.getProductId()){
|
||||
for (MemberProductCollection scproduct : productCollectionRepository.findByMemberId(currentMember.getId())) {
|
||||
if (productId == scproduct.getProductId()) {
|
||||
detailResult.setWhetherTheCollection(1);
|
||||
}
|
||||
}
|
||||
@@ -323,19 +313,19 @@ public class HomeServiceImpl implements HomeService {
|
||||
List<ProductAttributeResult> specChildList = new ArrayList<>();
|
||||
ProductAttributeResult spec = null;
|
||||
ProductAttributeResult specChild = null;
|
||||
String array [] = null;
|
||||
|
||||
for(PmsProductAttribute attribute : attributeList) {
|
||||
String array[] = null;
|
||||
|
||||
for (PmsProductAttribute attribute : attributeList) {
|
||||
spec = new ProductAttributeResult();
|
||||
spec.setId(attribute.getId());
|
||||
spec.setName(attribute.getName());
|
||||
specList.add(spec);
|
||||
|
||||
|
||||
//属性录入方式:0->手工录入;1->从列表中选取
|
||||
//是否支持手动新增;0->不支持;1->支持
|
||||
if(1 == attribute.getInputType() && 0 == attribute.getHandAddStatus()) {
|
||||
if (1 == attribute.getInputType() && 0 == attribute.getHandAddStatus()) {
|
||||
array = attribute.getInputList().split(",");
|
||||
for(int i=0; i<array.length; i++) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
specChild = new ProductAttributeResult();
|
||||
specChild.setPid(attribute.getId());
|
||||
specChild.setName(array[i]);
|
||||
@@ -345,9 +335,9 @@ public class HomeServiceImpl implements HomeService {
|
||||
PmsProductAttributeValueExample attributeValueExample = new PmsProductAttributeValueExample();
|
||||
attributeValueExample.createCriteria().andProductIdEqualTo(product.getId()).andProductAttributeIdEqualTo(attribute.getId());
|
||||
List<PmsProductAttributeValue> attributeValueList = productAttributeValueMapper.selectByExample(attributeValueExample);
|
||||
for(PmsProductAttributeValue value : attributeValueList) {
|
||||
for (PmsProductAttributeValue value : attributeValueList) {
|
||||
array = value.getValue().split(",");
|
||||
for(String s : array) {
|
||||
for (String s : array) {
|
||||
specChild = new ProductAttributeResult();
|
||||
specChild.setPid(attribute.getId());
|
||||
specChild.setName(s);
|
||||
@@ -356,31 +346,31 @@ public class HomeServiceImpl implements HomeService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
detailResult.setSpecList(specList);
|
||||
detailResult.setSpecChildList(specChildList);
|
||||
List<PmsComment> pmsComment =(List<PmsComment>) pmsCommentMapper.getPmsComment(productId);//评论基础信息
|
||||
if(pmsComment.size()>0){
|
||||
int i=pmsCommentMapper.getCountComment(productId);//评论总数
|
||||
int j=pmsCommentMapper.getApplauseCount(productId)*100/i;//好评率 好评数除以评论 总数 默认好评为大于等于2星
|
||||
detailResult.setCountComent(i);
|
||||
detailResult.setApplauseRate(j);
|
||||
for(int a=0;a<pmsComment.size();a++){
|
||||
List<PmsCommentReplay> pcr =(List<PmsCommentReplay>) pmsCommentReplayMapper.getPmsCommentReplay(pmsComment.get(a).getId());
|
||||
pmsComment.get(a).setPmsCommentReplay(pcr);//评论回复 逐个添加
|
||||
List<PmsComment> pmsComment = (List<PmsComment>) pmsCommentMapper.getPmsComment(productId);//评论基础信息
|
||||
if (pmsComment.size() > 0) {
|
||||
int i = pmsCommentMapper.getCountComment(productId);//评论总数
|
||||
int j = pmsCommentMapper.getApplauseCount(productId) * 100 / i;//好评率 好评数除以评论 总数 默认好评为大于等于2星
|
||||
detailResult.setCountComent(i);
|
||||
detailResult.setApplauseRate(j);
|
||||
for (int a = 0; a < pmsComment.size(); a++) {
|
||||
List<PmsCommentReplay> pcr = (List<PmsCommentReplay>) pmsCommentReplayMapper.getPmsCommentReplay(pmsComment.get(a).getId());
|
||||
pmsComment.get(a).setPmsCommentReplay(pcr);//评论回复 逐个添加
|
||||
}
|
||||
detailResult.setPmsComment(pmsComment);
|
||||
}
|
||||
detailResult.setPmsComment(pmsComment);
|
||||
}
|
||||
|
||||
|
||||
//根据会员等级显示不同的商品价格
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
if(member != null) {
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
if(discount != null) {
|
||||
detailResult.setPrice(detailResult.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
|
||||
if (member != null) {
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
if (discount != null) {
|
||||
detailResult.setPrice(detailResult.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
|
||||
return detailResult;
|
||||
}
|
||||
|
||||
@@ -389,79 +379,84 @@ public class HomeServiceImpl implements HomeService {
|
||||
PmsSkuStockExample example = new PmsSkuStockExample();
|
||||
PmsSkuStockExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andProductIdEqualTo(productId);
|
||||
if(!StringUtils.isEmpty(sp1)) { //mcoooo
|
||||
if (!StringUtils.isEmpty(sp1)) { //mcoooo
|
||||
criteria.andSp1EqualTo(sp1);
|
||||
}
|
||||
if(!StringUtils.isEmpty(sp2)) { //mcoooo
|
||||
if (!StringUtils.isEmpty(sp2)) { //mcoooo
|
||||
criteria.andSp2EqualTo(sp2);
|
||||
}
|
||||
if(!StringUtils.isEmpty(sp3)) {
|
||||
if (!StringUtils.isEmpty(sp3)) {
|
||||
criteria.andSp3EqualTo(sp3);
|
||||
}
|
||||
List<PmsSkuStock> list = skuStockMapper.selectByExample(example);
|
||||
ProductSkuResult skuResult = new ProductSkuResult();
|
||||
for(PmsSkuStock stock : list) {
|
||||
|
||||
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) {
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
if(discount != null) {
|
||||
skuResult.setPrice(skuResult.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
|
||||
if (member != null) {
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
if (discount != null) {
|
||||
skuResult.setPrice(skuResult.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
|
||||
return skuResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PmsProduct> getProductList(Long brandId, Long categoryId, String sortType,
|
||||
Integer pageSize, Integer pageNum) {
|
||||
Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
PmsProductExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andDeleteStatusEqualTo(0);
|
||||
if(brandId != null) {
|
||||
if (brandId != null) {
|
||||
criteria.andBrandIdEqualTo(brandId);
|
||||
}
|
||||
if(categoryId != null) {
|
||||
if (categoryId != null) {
|
||||
criteria.andProductCategoryIdEqualTo(categoryId);
|
||||
}
|
||||
|
||||
|
||||
//综合排序
|
||||
if("1".equals(sortType)) {
|
||||
if ("1".equals(sortType)) {
|
||||
example.setOrderByClause("id asc");
|
||||
}
|
||||
//销量
|
||||
if("2".equals(sortType)) {
|
||||
if ("2".equals(sortType)) {
|
||||
example.setOrderByClause("sale desc");
|
||||
}
|
||||
//价格升序
|
||||
if("3".equals(sortType)) {
|
||||
if ("3".equals(sortType)) {
|
||||
example.setOrderByClause("price asc");
|
||||
}
|
||||
//价格降序
|
||||
if("4".equals(sortType)) {
|
||||
if ("4".equals(sortType)) {
|
||||
example.setOrderByClause("price desc");
|
||||
}
|
||||
|
||||
|
||||
List<PmsProduct> productList = productMapper.selectByExample(example);
|
||||
|
||||
|
||||
//根据会员等级显示不同的商品价格
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
if(member != null) {
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
if(discount != null) {
|
||||
for(PmsProduct product : productList) {
|
||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (member != null) {
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
if (discount != null) {
|
||||
for (PmsProduct product : productList) {
|
||||
product.setPrice(product.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return productList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
package com.buy507.mall.portal.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.buy507.mall.mapper.*;
|
||||
import com.buy507.mall.model.*;
|
||||
import com.buy507.mall.portal.service.MemberCommissionService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MemberPointsSplitProfitService{
|
||||
|
||||
@Resource
|
||||
private UmsMemberMapper memberMapper;
|
||||
/**
|
||||
* 会员分成流水
|
||||
*/
|
||||
@Resource
|
||||
private UmsMemberAccountTransactionMapper umsMemberAccountTransactionMapper;
|
||||
|
||||
/**
|
||||
* 会员上下关系
|
||||
*/
|
||||
@Resource
|
||||
private UmsMemberRelationTreeMapper umsMemberRelationTreeMapper;
|
||||
/**
|
||||
* 会员等级
|
||||
*/
|
||||
@Resource
|
||||
private UmsMemberLevelMapper umsMemberLevelMapper;
|
||||
|
||||
@Autowired
|
||||
private OmsOrderMapper orderMapper;
|
||||
|
||||
@Value("${becomeVipAmount}")
|
||||
private String becomeVipAmount;
|
||||
|
||||
@Value("${sameLevelProfit}")
|
||||
private String sameLevelProfit;
|
||||
|
||||
/**
|
||||
* 积分分润入口
|
||||
* @param order
|
||||
*/
|
||||
public void pointsSplit(OmsOrder order) {
|
||||
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(order.getMemberId());
|
||||
//找到上级会员
|
||||
UmsMember higherLevelMember = this.findInOrderQueueMember(member.getId());;
|
||||
if(higherLevelMember != null){
|
||||
//进行订单分润
|
||||
this.splitProfitFroMember(member, higherLevelMember, order);
|
||||
}
|
||||
//计算会员等级
|
||||
UmsMemberRelationTree relationTree = this.getUpLevelRelationTreeById(member.getId());
|
||||
if(relationTree == null){
|
||||
return;
|
||||
}
|
||||
//上级为空或者为普通用户
|
||||
UmsMember higherMember = memberMapper.selectByPrimaryKey(relationTree.getHigherLevelId());
|
||||
if(higherMember == null && higherMember.getMemberLevel().equals(MemberLevel.Member)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为订单上级进行分润
|
||||
* @param member
|
||||
* @param higherLevelMember
|
||||
* @param order
|
||||
*/
|
||||
private void splitProfitFroMember(UmsMember member, UmsMember higherLevelMember, OmsOrder order) {
|
||||
|
||||
//新订单及直属上级分润,返回的分润金额
|
||||
Integer revenuePoints = this.newMemberSplitProfit(member, higherLevelMember, order);
|
||||
|
||||
UmsMember moreHigherMember = new UmsMember();
|
||||
//如果上级是vip会员
|
||||
if(higherLevelMember.getMemberLevel().equals(MemberLevel.Consumer)) {
|
||||
moreHigherMember = this.findNextHigherLevelMemberByType(higherLevelMember.getId(), MemberLevel.Consumer);
|
||||
}
|
||||
//没有更高的上级退出分润
|
||||
if(moreHigherMember == null){
|
||||
return;
|
||||
}
|
||||
//给三个级别代理分润
|
||||
this.twoLevelSplitProfit(higherLevelMember, moreHigherMember, order, revenuePoints);
|
||||
|
||||
this.threeLevelSplitProfit(higherLevelMember, moreHigherMember, order, revenuePoints);
|
||||
|
||||
this.fourLevelSplitProfit(higherLevelMember, moreHigherMember, order, revenuePoints);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询到下一个级别的上级会员
|
||||
* @param id
|
||||
* @param consumer
|
||||
* @return
|
||||
*/
|
||||
private UmsMember findNextHigherLevelMemberByType(Long id, MemberLevel consumer) {
|
||||
//找到上级
|
||||
UmsMember moreHigherMember = this.findInOrderQueueMember(id);
|
||||
if(moreHigherMember == null){
|
||||
return null;
|
||||
}
|
||||
while (moreHigherMember != null){
|
||||
if(moreHigherMember.getMemberLevel().getValue() > consumer.getValue()){
|
||||
return moreHigherMember;
|
||||
}
|
||||
moreHigherMember = this.findInOrderQueueMember(moreHigherMember.getId());
|
||||
if(moreHigherMember == null){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return moreHigherMember;
|
||||
}
|
||||
|
||||
/**
|
||||
* 寻找上级
|
||||
*/
|
||||
private UmsMember findInOrderQueueMember(Long id) {
|
||||
UmsMemberRelationTree relationTree = this.getUpLevelRelationTreeById(id);
|
||||
if(relationTree == null){
|
||||
return null;
|
||||
}
|
||||
UmsMember higherMember = memberMapper.selectByPrimaryKey(relationTree.getHigherLevelId());
|
||||
if(higherMember == null){
|
||||
return null;
|
||||
}
|
||||
return higherMember;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员分润
|
||||
* @param currentMember
|
||||
* @param higherLevelMember
|
||||
* @param order
|
||||
*/
|
||||
private Integer newMemberSplitProfit(UmsMember currentMember, UmsMember higherLevelMember, OmsOrder order){
|
||||
|
||||
//直推会员分润比例
|
||||
String ratio = "0."+ 3;
|
||||
|
||||
Integer revenuePoints = order.getPayAmount().multiply(new BigDecimal(ratio)).intValue();
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setMemberId(higherLevelMember.getId());
|
||||
accountTransaction.setOrderId(order.getId());
|
||||
accountTransaction.setRemarks("直推VIP积分分润");
|
||||
accountTransaction.setTransactionState(UmsMemberAccountTransaction.TRANSACTION_STATE_YES);
|
||||
accountTransaction.setRevenuePoints(revenuePoints);
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(2);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
log.info("new Account Transaction {}" , JSONUtil.toJsonStr(accountTransaction));
|
||||
|
||||
//会员积分到账
|
||||
higherLevelMember.setIntegration(revenuePoints + (higherLevelMember.getIntegration() == null ? 0 : higherLevelMember.getIntegration()));
|
||||
memberMapper.updateByPrimaryKey(higherLevelMember);
|
||||
|
||||
|
||||
return revenuePoints;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 二级店长分润
|
||||
* @param lowerMember
|
||||
* @param higherMember
|
||||
* @param order
|
||||
*/
|
||||
private void twoLevelSplitProfit(UmsMember lowerMember, UmsMember higherMember, OmsOrder order,
|
||||
Integer revenuePoints){
|
||||
//先判断是否为店长
|
||||
if(higherMember.getMemberLevel().equals(MemberLevel.Partner)){
|
||||
//上下级关系
|
||||
if(higherMember.getMemberLevel().getValue() > lowerMember.getMemberLevel().getValue()){
|
||||
|
||||
UmsMemberLevel lowerLevel = umsMemberLevelMapper.selectByPrimaryKey(lowerMember.getMemberLevelId());
|
||||
UmsMemberLevel higherLevel = umsMemberLevelMapper.selectByPrimaryKey(higherMember.getMemberLevelId());
|
||||
|
||||
Integer profitRatio = 0;
|
||||
if(higherLevel.getPointsRatio() != null && lowerLevel.getPointsRatio() != null){
|
||||
profitRatio = higherLevel.getPointsRatio() - lowerLevel.getPointsRatio();
|
||||
}
|
||||
String ratioStr = profitRatio < 10 ? "0.0" + profitRatio : "0."+profitRatio;
|
||||
//计算上级的分积分分润
|
||||
Integer pointsCommission = order.getPayAmount().multiply(new BigDecimal(ratioStr)).intValue();
|
||||
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setCommissionRatio(profitRatio);
|
||||
accountTransaction.setMemberId(higherMember.getId());
|
||||
accountTransaction.setOrderId(order.getId());
|
||||
accountTransaction.setRemarks("二级店长上级积分分润");
|
||||
accountTransaction.setRevenuePoints(pointsCommission);
|
||||
//即时到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(2);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
higherMember.setIntegration(pointsCommission + (higherMember.getIntegration() == null ? 0 : higherMember.getIntegration()));
|
||||
memberMapper.updateByPrimaryKeySelective(higherMember);
|
||||
|
||||
//查询上级
|
||||
UmsMember next = this.findInOrderQueueMember(higherMember.getId());
|
||||
|
||||
if(next != null){
|
||||
if (next.getMemberLevel().equals(higherMember.getMemberLevel())){
|
||||
twoLevelSplitProfit(higherMember, next, order, pointsCommission);
|
||||
}else {
|
||||
threeLevelSplitProfit(higherMember, next, order, pointsCommission);
|
||||
fourLevelSplitProfit(higherMember, next, order, pointsCommission);
|
||||
}
|
||||
}
|
||||
//平级关系
|
||||
}else if(lowerMember.getMemberLevel().equals(lowerMember.getMemberLevel())){
|
||||
Integer pointsCommission = revenuePoints * (new BigDecimal("0."+sameLevelProfit)).intValue();
|
||||
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setCommissionRatio(Integer.valueOf(sameLevelProfit));
|
||||
accountTransaction.setMemberId(higherMember.getId());
|
||||
accountTransaction.setOrderId(order.getId());
|
||||
accountTransaction.setRemarks("二级店长平级积分分润");
|
||||
accountTransaction.setRevenuePoints(pointsCommission);
|
||||
//即时到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(2);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
higherMember.setIntegration(pointsCommission + (higherMember.getIntegration() == null ? 0 : higherMember.getIntegration()));
|
||||
memberMapper.updateByPrimaryKeySelective(higherMember);
|
||||
|
||||
//查询比当前级别大的会员
|
||||
UmsMember next = this.findNextHigherLevelMemberByType(higherMember.getId(), MemberLevel.Partner);
|
||||
if(next != null){
|
||||
threeLevelSplitProfit(higherMember, next, order, pointsCommission);
|
||||
fourLevelSplitProfit(higherMember, next, order, pointsCommission);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 三级代理分润
|
||||
* @param lowerMember
|
||||
* @param higherMember
|
||||
* @param order
|
||||
*/
|
||||
private void threeLevelSplitProfit(UmsMember lowerMember, UmsMember higherMember, OmsOrder order, Integer revenuePoints){
|
||||
if(higherMember.getMemberLevel().equals(MemberLevel.Diamond)){
|
||||
//上下级关系
|
||||
if(higherMember.getMemberLevel().getValue() > lowerMember.getMemberLevel().getValue()){
|
||||
|
||||
UmsMemberLevel lowerLevel = umsMemberLevelMapper.selectByPrimaryKey(lowerMember.getMemberLevelId());
|
||||
UmsMemberLevel higherLevel = umsMemberLevelMapper.selectByPrimaryKey(higherMember.getMemberLevelId());
|
||||
|
||||
Integer profitRatio = 0;
|
||||
if(higherLevel.getPointsRatio() != null && lowerLevel.getPointsRatio() != null){
|
||||
profitRatio = higherLevel.getPointsRatio() - lowerLevel.getPointsRatio();
|
||||
}
|
||||
|
||||
String ratioStr = profitRatio < 10 ? "0.0" + profitRatio : "0."+profitRatio;
|
||||
//计算上级的分积分分润
|
||||
Integer pointsCommission = order.getPayAmount().multiply(new BigDecimal(ratioStr)).intValue();
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setCommissionRatio(profitRatio);
|
||||
accountTransaction.setMemberId(higherMember.getId());
|
||||
accountTransaction.setOrderId(order.getId());
|
||||
accountTransaction.setRemarks("三级代理上级积分分润");
|
||||
accountTransaction.setRevenuePoints(pointsCommission);
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(2);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
higherMember.setIntegration(pointsCommission + (higherMember.getIntegration() == null ? 0 : higherMember.getIntegration()));
|
||||
memberMapper.updateByPrimaryKeySelective(higherMember);
|
||||
|
||||
//查询上级
|
||||
UmsMember next = this.findInOrderQueueMember(higherMember.getId());
|
||||
|
||||
if(next != null){
|
||||
if (next.getMemberLevel().equals(higherMember.getMemberLevel())){
|
||||
threeLevelSplitProfit(higherMember, next, order, pointsCommission);
|
||||
}else {
|
||||
fourLevelSplitProfit(higherMember, next, order, pointsCommission);
|
||||
}
|
||||
}
|
||||
//平级关系
|
||||
}else if(lowerMember.getMemberLevel().equals(lowerMember.getMemberLevel())){
|
||||
Integer pointsCommission = revenuePoints * (new BigDecimal("0."+sameLevelProfit)).intValue();
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setCommissionRatio(Integer.valueOf(sameLevelProfit));
|
||||
accountTransaction.setMemberId(higherMember.getId());
|
||||
accountTransaction.setOrderId(order.getId());
|
||||
accountTransaction.setRemarks("三级代理平级积分分润");
|
||||
accountTransaction.setRevenuePoints(pointsCommission);
|
||||
//24小时后到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.tomorrow());
|
||||
accountTransaction.setFlowType(2);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
higherMember.setIntegration(pointsCommission + (higherMember.getIntegration() == null ? 0 : higherMember.getIntegration()));
|
||||
memberMapper.updateByPrimaryKeySelective(higherMember);
|
||||
|
||||
UmsMember next = this.findNextHigherLevelMemberByType(higherMember.getId(), MemberLevel.Diamond);
|
||||
if(next != null){
|
||||
fourLevelSplitProfit(higherMember, next, order, pointsCommission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 四级市代分润
|
||||
* @param lowerMember
|
||||
* @param higherMember
|
||||
* @param order
|
||||
*/
|
||||
private void fourLevelSplitProfit(UmsMember lowerMember, UmsMember higherMember, OmsOrder order, Integer revenuePoints){
|
||||
if(higherMember.getMemberLevel().equals(MemberLevel.OneDiamond)){
|
||||
//上下级关系
|
||||
if(higherMember.getMemberLevel().getValue() > lowerMember.getMemberLevel().getValue()){
|
||||
|
||||
UmsMemberLevel lowerLevel = umsMemberLevelMapper.selectByPrimaryKey(lowerMember.getMemberLevelId());
|
||||
UmsMemberLevel higherLevel = umsMemberLevelMapper.selectByPrimaryKey(higherMember.getMemberLevelId());
|
||||
|
||||
Integer profitRatio = 0;
|
||||
if(higherLevel.getPointsRatio() != null && lowerLevel.getPointsRatio() != null){
|
||||
profitRatio = higherLevel.getPointsRatio() - lowerLevel.getPointsRatio();
|
||||
}
|
||||
String ratioStr = profitRatio < 10 ? "0.0" + profitRatio : "0."+profitRatio;
|
||||
//计算上级的分积分分润
|
||||
Integer pointsCommission = order.getPayAmount().multiply(new BigDecimal(ratioStr)).intValue();
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setCommissionRatio(profitRatio);
|
||||
accountTransaction.setMemberId(higherMember.getId());
|
||||
accountTransaction.setOrderId(order.getId());
|
||||
accountTransaction.setRemarks("四级市代理上级积分分润");
|
||||
accountTransaction.setRevenuePoints(pointsCommission);
|
||||
//24小时后到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(2);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
higherMember.setIntegration(pointsCommission + (higherMember.getIntegration() == null ? 0 : higherMember.getIntegration()));
|
||||
memberMapper.updateByPrimaryKeySelective(higherMember);
|
||||
|
||||
//查询上级
|
||||
UmsMember next = this.findInOrderQueueMember(higherMember.getId());
|
||||
|
||||
if(next != null && next.getMemberLevel().equals(higherMember.getMemberLevel())){
|
||||
fourLevelSplitProfit(higherMember, next, order, pointsCommission);
|
||||
}
|
||||
//平级关系
|
||||
}else if(lowerMember.getMemberLevel().equals(lowerMember.getMemberLevel())){
|
||||
Integer pointsCommission = revenuePoints * (new BigDecimal("0."+sameLevelProfit)).intValue();
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setCommissionRatio(Integer.valueOf(sameLevelProfit));
|
||||
accountTransaction.setMemberId(higherMember.getId());
|
||||
accountTransaction.setOrderId(order.getId());
|
||||
accountTransaction.setRemarks("四级市代理平级积分分润");
|
||||
accountTransaction.setFlowType(2);
|
||||
accountTransaction.setRevenuePoints(pointsCommission);
|
||||
|
||||
//会员金额到账
|
||||
higherMember.setIntegration(pointsCommission + (higherMember.getIntegration() == null ? 0 : higherMember.getIntegration()));
|
||||
memberMapper.updateByPrimaryKeySelective(higherMember);
|
||||
|
||||
//24小时后到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.tomorrow());
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员的上级关系
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private UmsMemberRelationTree getUpLevelRelationTreeById(Long id) {
|
||||
UmsMemberRelationTree relationTree = null;
|
||||
UmsMemberRelationTreeExample relationTreeExample = new UmsMemberRelationTreeExample();
|
||||
relationTreeExample.createCriteria().andMemberIdEqualTo(id);
|
||||
List<UmsMemberRelationTree> relationTreeList = umsMemberRelationTreeMapper.selectByExample(relationTreeExample);
|
||||
if(!relationTreeList.isEmpty()) {
|
||||
//找到上级关系
|
||||
relationTree = relationTreeList.get(0);
|
||||
}
|
||||
return relationTree;
|
||||
}
|
||||
}
|
||||
@@ -63,42 +63,6 @@ public class MemberSplitProfitService{
|
||||
|
||||
public void updateOderAndMemberInfo(OmsOrder order) {
|
||||
|
||||
/*UmsMember member = memberMapper.selectByPrimaryKey(order.getMemberId());
|
||||
//找到上级会员
|
||||
UmsMember higherLevelMember = this.findInOrderQueueMember(member.getId());;
|
||||
*
|
||||
* 先验证该订单是否是五联单加速,如果不是则普通计算上级提成
|
||||
* 如果是提成,则全额给上级
|
||||
|
||||
|
||||
|
||||
boolean splitForFiveQueue = false; //是否加速完成
|
||||
//在此判断是否是首单新用户
|
||||
UmsMemberOrderQueueExample orderQueueExample1 = new UmsMemberOrderQueueExample();
|
||||
orderQueueExample1.createCriteria().andMemberIdEqualTo(order.getMemberId());
|
||||
long memberOrderCount = umsMemberOrderQueueMapper.countByExample(orderQueueExample1);
|
||||
if(memberOrderCount == 1){
|
||||
splitForFiveQueue = fiveQuickQueueBusiness(order, member, higherLevelMember);
|
||||
}
|
||||
|
||||
//未进行满5联单分润,开始进行普通分润流程
|
||||
if(!splitForFiveQueue && higherLevelMember != null){
|
||||
//进行订单分润
|
||||
this.splitProfitFroMember(member, higherLevelMember, order);
|
||||
}
|
||||
|
||||
//计算会员等级
|
||||
UmsMemberRelationTree relationTree = this.getUpLevelRelationTreeById(member.getId());
|
||||
if(relationTree == null){
|
||||
return;
|
||||
}
|
||||
//上级为空或者为普通用户
|
||||
UmsMember higherMember = memberMapper.selectByPrimaryKey(relationTree.getHigherLevelId());
|
||||
if(higherMember == null && higherMember.getMemberLevel().equals(MemberLevel.Member)){
|
||||
return;
|
||||
}
|
||||
memberCommissionService.computeCommission(higherMember);*/
|
||||
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(order.getMemberId());
|
||||
//找到上级会员
|
||||
UmsMember higherLevelMember = this.findInOrderQueueMember(member.getId());;
|
||||
@@ -211,6 +175,7 @@ public class MemberSplitProfitService{
|
||||
accountTransaction.setRemarks("会员此订单退出队列到账");
|
||||
accountTransaction.setRevenueAmount(orderQueue.getOrderAmount());
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(1);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//出局后订单状态置为2
|
||||
@@ -280,10 +245,6 @@ public class MemberSplitProfitService{
|
||||
if(higherQueue != null){
|
||||
return splitMark;
|
||||
}
|
||||
//添加帮助加速的订单号
|
||||
/*UmsMemberOrderQueue orderQ = umsMemberOrderQueueMapper.selectByExample(orderQueueExample);
|
||||
orderQ.setAccelerateOrderId(higherQueue.getOrderId());
|
||||
umsMemberOrderQueueMapper.updateByPrimaryKeySelective(orderQ);*/
|
||||
|
||||
//查找上级还有多少下级(查看同级别的用户)
|
||||
UmsMemberRelationTreeExample umrtExample = new UmsMemberRelationTreeExample();
|
||||
@@ -335,6 +296,7 @@ public class MemberSplitProfitService{
|
||||
accountTransaction.setRevenueAmount(higherQueue.getOrderAmount());
|
||||
//即时到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(1);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//快速出局后将订单状态置为2
|
||||
@@ -431,16 +393,6 @@ public class MemberSplitProfitService{
|
||||
umsMemberOrderQueueMapper.insert(record);
|
||||
log.info("new Order Queue {}" , JSONUtil.toJsonStr(record));
|
||||
|
||||
/*UmsMemberLevel higherLevel = umsMemberLevelMapper.selectByPrimaryKey(higherLevelMember.getMemberLevelId());
|
||||
//直推会员分润
|
||||
String ratio = "0."+higherLevel.getCommissionRatio();
|
||||
BigDecimal revenueAmount = order.getPayAmount().multiply(new BigDecimal(ratio)).setScale(2, RoundingMode.HALF_UP);
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setCommissionRatio(higherLevel.getCommissionRatio());*/
|
||||
|
||||
//UmsMemberLevel higherLevel = umsMemberLevelMapper.selectByPrimaryKey(higherLevelMember.getMemberLevelId());
|
||||
//直推会员分润
|
||||
//String ratio = "0."+higherLevel.getCommissionRatio(); mcoo Integer()
|
||||
String ratio = "0."+ 2;
|
||||
BigDecimal revenueAmount = order.getPayAmount().multiply(new BigDecimal(ratio)).setScale(2, RoundingMode.HALF_UP);
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
@@ -452,6 +404,7 @@ public class MemberSplitProfitService{
|
||||
accountTransaction.setRevenueAmount(revenueAmount);
|
||||
//
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(1);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
log.info("new Account Transaction {}" , JSONUtil.toJsonStr(accountTransaction));
|
||||
|
||||
@@ -495,6 +448,7 @@ public class MemberSplitProfitService{
|
||||
accountTransaction.setRevenueAmount(payAmountPercent);
|
||||
//即时到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(1);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
@@ -524,6 +478,7 @@ public class MemberSplitProfitService{
|
||||
accountTransaction.setRevenueAmount(tenPercent);
|
||||
//即时到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(1);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
@@ -570,6 +525,7 @@ public class MemberSplitProfitService{
|
||||
accountTransaction.setRemarks("三级代理上级分润");
|
||||
accountTransaction.setRevenueAmount(payAmountPercent);
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(1);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
@@ -597,6 +553,7 @@ public class MemberSplitProfitService{
|
||||
accountTransaction.setRevenueAmount(tenPercent);
|
||||
//24小时后到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.tomorrow());
|
||||
accountTransaction.setFlowType(1);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
@@ -641,6 +598,7 @@ public class MemberSplitProfitService{
|
||||
accountTransaction.setRevenueAmount(payAmountPercent);
|
||||
//24小时后到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.date());
|
||||
accountTransaction.setFlowType(1);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
|
||||
//会员金额到账
|
||||
@@ -670,6 +628,7 @@ public class MemberSplitProfitService{
|
||||
|
||||
//24小时后到账
|
||||
accountTransaction.setTransferPaymentTime(DateUtil.tomorrow());
|
||||
accountTransaction.setFlowType(1);
|
||||
umsMemberAccountTransactionMapper.insert(accountTransaction);
|
||||
}
|
||||
}
|
||||
@@ -688,14 +647,6 @@ public class MemberSplitProfitService{
|
||||
if(higherMember == null){
|
||||
return null;
|
||||
}
|
||||
/* if(higherMember.getOrderStatus() == 0){
|
||||
UmsMember nextMember = this.findInOrderQueueMember(higherMember.getId());
|
||||
if(nextMember != null){
|
||||
return nextMember;
|
||||
}
|
||||
}else if(higherMember.getOrderStatus() == 1){
|
||||
return higherMember;
|
||||
}*/
|
||||
if( higherMember.getOrderStatus() == 1){
|
||||
return higherMember;
|
||||
}
|
||||
@@ -715,7 +666,4 @@ public class MemberSplitProfitService{
|
||||
}
|
||||
return relationTree;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.buy507.mall.portal.service.impl;
|
||||
|
||||
import com.buy507.mall.portal.dao.MyWalletMapper;
|
||||
import com.buy507.mall.portal.service.MyWalletService;
|
||||
import com.buy507.mall.portal.vo.WalletCashVo;
|
||||
import com.buy507.mall.portal.vo.WalletPointsVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MyWalletServiceImpl implements MyWalletService {
|
||||
|
||||
@Autowired
|
||||
private MyWalletMapper myWalletMapper;
|
||||
|
||||
/**
|
||||
* 获取现金余额和流水
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public WalletCashVo getBalanceAndCashFlow(Long userId) {
|
||||
|
||||
WalletCashVo walletCashVo = new WalletCashVo();
|
||||
//获取现金余额
|
||||
walletCashVo.setBalance(myWalletMapper.getBalance(userId));
|
||||
//获取现金流水
|
||||
walletCashVo.setCashVoList(myWalletMapper.getCashFlow(userId));
|
||||
|
||||
return walletCashVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分余额和流水
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public WalletPointsVo getIntegrationAndPointsFlow(Long userId) {
|
||||
WalletPointsVo walletPointsVo = new WalletPointsVo();
|
||||
|
||||
//获取积分余额
|
||||
walletPointsVo.setIntegration(myWalletMapper.getIntegration(userId));
|
||||
//获取积分流水
|
||||
walletPointsVo.setPointsVoList(myWalletMapper.getPointsFlow(userId));
|
||||
|
||||
return walletPointsVo;
|
||||
}
|
||||
}
|
||||
@@ -144,6 +144,18 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
@Autowired
|
||||
private UmsDevelopmentFundMapper umsDevelopmentFundMapper;
|
||||
|
||||
@Autowired
|
||||
private UmsMemberRelationTreeMapper memberRelationTreeMapper;
|
||||
|
||||
@Autowired
|
||||
private UmsMemberLevelMapper memberLevelMapper;
|
||||
|
||||
@Autowired
|
||||
private MemberPointsSplitProfitService memberPointsSplitProfitService;
|
||||
|
||||
@Autowired
|
||||
private UmsMemberAccountTransactionMapper umsMemberAccountTransactionMapper;
|
||||
|
||||
|
||||
@Value("${kuaidi100.url}")
|
||||
private String KUAIDI100_URL;
|
||||
@@ -229,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) {
|
||||
@@ -282,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());
|
||||
@@ -359,14 +380,19 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
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;
|
||||
|
||||
//支付类型: 0->未支付;1->支付宝;2->微信; 3->线下支付; 4->积分支付
|
||||
//判断是否为积分专区商品
|
||||
if(isPointsExchangeStatus) {
|
||||
orderResult.setPayType(4); // 设置为积分支付
|
||||
orderResult.setPayTypeName("积分支付");
|
||||
orderResult.setIntergrationPrice(product.getIntergrationPrice());
|
||||
orderResult.setIntergrationExchange(product.getPointsExchangeStatus());
|
||||
orderResult.setPayType(order.getPayType());
|
||||
if (order.getPayType() == 0) {
|
||||
orderResult.setPayTypeName("未支付");
|
||||
}
|
||||
}else {
|
||||
// 如果不是积分兑换专区商品,则继续使用其他支付方式
|
||||
if (order.getPayType() != null) {
|
||||
@@ -403,6 +429,7 @@ 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) {
|
||||
@@ -445,6 +472,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());
|
||||
@@ -590,7 +619,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
orderItem.setSp3(cartItem.getSp3());
|
||||
orderItem.setPromotionName("无优惠");
|
||||
orderItem.setPromotionAmount(zero);
|
||||
orderItem.setGiftIntegration(0);
|
||||
orderItem.setGiftIntegration(zero);
|
||||
orderItem.setGiftGrowth(0);
|
||||
orderItem.setCouponAmount(zero);
|
||||
orderItem.setIntegrationAmount(zero);
|
||||
@@ -692,6 +721,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
for (OmsOrderItem orderItem : orderItemList) {
|
||||
orderItem.setOrderId(order.getId());
|
||||
orderItem.setOrderSn(order.getOrderSn());
|
||||
|
||||
orderItemMapper.insert(orderItem);
|
||||
}
|
||||
|
||||
@@ -748,10 +778,21 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
return CommonResult.validateFailed("未查询到商品信息");
|
||||
}
|
||||
|
||||
PmsProduct product = new PmsProduct();
|
||||
PmsProduct product = productMapper.getPrimaryKey(skuStock.getProductId());
|
||||
|
||||
// 判断商品是否属于积分兑换区
|
||||
boolean isPointsExchangeStatus = product.getPointsExchangeStatus() == 1;
|
||||
|
||||
// 判断商品是否属于积分兑换区
|
||||
boolean isPointsExchangeStatus = product.getPointsExchangeStatus() == 1;
|
||||
BigDecimal totalPointsAmount = new BigDecimal(0);
|
||||
BigDecimal price = new BigDecimal(skuStock.getPrice().doubleValue());
|
||||
|
||||
if (isPointsExchangeStatus) {
|
||||
// 积分兑换专区商品,设置积分价格
|
||||
//获取商品的积分价格
|
||||
BigDecimal pointsPrice = new BigDecimal(product.getIntergrationPrice());
|
||||
// 积分兑换商品的总金额
|
||||
totalPointsAmount = pointsPrice.multiply(new BigDecimal(orderParam.getQuantity()));
|
||||
}
|
||||
|
||||
//判断商品是否都有库存 (库存 - 锁定库存 = 真实库存)
|
||||
if ((skuStock.getStock() - skuStock.getLockStock()) < orderParam.getQuantity()) {
|
||||
@@ -762,9 +803,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
if(product != null) {
|
||||
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(memberService.getCurrentMember().getId());
|
||||
|
||||
BigDecimal discount = commonService.getDiscount(member.getId());
|
||||
BigDecimal price = new BigDecimal(skuStock.getPrice().doubleValue());
|
||||
|
||||
if(discount != null) {
|
||||
price = skuStock.getPrice().multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
@@ -773,24 +813,6 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
BigDecimal zero = new BigDecimal(0);
|
||||
totalAmount = price.multiply(new BigDecimal(orderParam.getQuantity()));
|
||||
|
||||
// 如果是积分兑换区商品
|
||||
if (isPointsExchangeStatus) {
|
||||
// 直接使用积分支付,不进行实际支付金额的处理
|
||||
BigDecimal integrationAmount = totalAmount;
|
||||
// 确保会员有足够的积分
|
||||
if (member.getIntegration() < integrationAmount.intValue()) {
|
||||
return CommonResult.validateFailed("积分不足,无法兑换");
|
||||
}
|
||||
|
||||
// 冻结会员积分
|
||||
member.setIntegration(member.getIntegration() - integrationAmount.intValue()); // 扣除积分
|
||||
member.setFreeze(member.getFreeze().add(new BigDecimal(integrationAmount.intValue()))); // 冻结积分
|
||||
memberMapper.updateByPrimaryKey(member);
|
||||
|
||||
totalAmount = zero; // 设置支付金额为零
|
||||
orderParam.setIntegration(integrationAmount); // 设置积分金额
|
||||
}
|
||||
|
||||
if(orderParam.getIntegration() == null) {
|
||||
orderParam.setIntegration(zero);
|
||||
}
|
||||
@@ -831,6 +853,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
//生成订单信息
|
||||
OmsOrder order = new OmsOrder();
|
||||
order.setTotalAmount(totalAmount); // 订单总金额
|
||||
order.setIntegrationAmount(zero); // 积分部分金额设为零
|
||||
order.setIntegrationAmount(orderParam.getIntegration() == null ? zero : orderParam.getIntegration());
|
||||
if(integerationFlag == 1) {
|
||||
int flag = orderParam.getIntegration().compareTo(totalAmount);
|
||||
@@ -932,7 +955,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
orderItem.setSp3(skuStock.getSp3());
|
||||
orderItem.setPromotionName("无优惠");
|
||||
orderItem.setPromotionAmount(new BigDecimal(0));
|
||||
orderItem.setGiftIntegration(0);
|
||||
//积分价格
|
||||
orderItem.setGiftIntegration(totalPointsAmount);
|
||||
orderItem.setGiftGrowth(0);
|
||||
orderItem.setCouponAmount(new BigDecimal(0));
|
||||
orderItem.setIntegrationAmount(new BigDecimal(0));
|
||||
@@ -947,6 +971,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
|
||||
result.put("orderId", order.getId());
|
||||
result.put("totalAmount", order.getPayAmount());
|
||||
if (isPointsExchangeStatus) {
|
||||
result.put("pointsPrice", totalPointsAmount);
|
||||
}
|
||||
}
|
||||
|
||||
return CommonResult.success(result, "下单成功");
|
||||
@@ -1317,9 +1344,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult balancePayment(Long orderId) {
|
||||
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("未查询到订单信息");
|
||||
}
|
||||
@@ -1328,123 +1357,285 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
return CommonResult.validateFailed("未查询到订单信息");
|
||||
}
|
||||
|
||||
// 支付方式:0->未支付;1->支付宝;2->微信;3->线下支付;4->余额支付
|
||||
// 支付方式为0才允许支付
|
||||
if (order.getPayType() != 0) {
|
||||
return CommonResult.validateFailed("订单已支付");
|
||||
}
|
||||
|
||||
// 判断是否使用积分支付
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(currentMember.getId());
|
||||
|
||||
//如果实际支付金额等于0表示积分支付
|
||||
//如果不是使用积分支付,返回错误信息
|
||||
BigDecimal zero = new BigDecimal(0);
|
||||
int flag = order.getPayAmount().compareTo(zero);
|
||||
//flag = -1,表示PayAmount小于zero;flag = 0,表示PayAmount等于zero;flag = 1,表示PayAmount大于zero;
|
||||
if (flag == 0) {
|
||||
if(product1.getPointsExchangeStatus() == 1) {
|
||||
|
||||
//写入会员交易记录表
|
||||
DmsMemberTradeRecord tradeRecord = new DmsMemberTradeRecord();
|
||||
tradeRecord.setMemberId(member.getId());
|
||||
tradeRecord.setItemType(ItemType.IntegralShopping); //积分购物
|
||||
tradeRecord.setNote("积分抵扣");
|
||||
tradeRecord.setTitle("积分抵扣");
|
||||
tradeRecord.setValue(order.getIntegrationAmount());
|
||||
tradeRecord.setType(1); //收支类型:0->收入;1->支出
|
||||
tradeRecord.setCreateTime(new Date());
|
||||
memberTradeRecordMapper.insert(tradeRecord);
|
||||
// 获取积分兑换价格
|
||||
// 使用订单中的积分字段
|
||||
BigDecimal totalPointsAmount = BigDecimal.valueOf((long) product1.getIntergrationPrice() * orderItem1.getProductQuantity());
|
||||
// 获取当前用户积分
|
||||
BigDecimal memberPoints = BigDecimal.valueOf(member.getIntegration());
|
||||
|
||||
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;
|
||||
}
|
||||
// 判断用户积分是否足够
|
||||
if (memberPoints.compareTo(totalPointsAmount) < 0) {
|
||||
return CommonResult.validateFailed("积分不足,无法完成兑换");
|
||||
}
|
||||
// BigDecimal zero = new BigDecimal(0);
|
||||
// // 只要订单的支付金额为0,即表示使用积分支付
|
||||
// int flag = order.getPayAmount().compareTo(zero);
|
||||
// if (flag == 0) { // 如果实际支付金额为0,表示使用积分支付
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
} else {
|
||||
return CommonResult.validateFailed("无效订单");
|
||||
}
|
||||
// 扣除用户积分,并记录积分变动
|
||||
// 扣除积分
|
||||
member.setIntegration(memberPoints.subtract(totalPointsAmount).intValue());
|
||||
// 冻结积分
|
||||
// member.setFreeze(member.getFreeze().add(totalPointsAmount));
|
||||
memberMapper.updateByPrimaryKey(member);
|
||||
|
||||
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.setPayType(4);
|
||||
// 设置订单状态为已支付
|
||||
order.setStatus(2);
|
||||
} else {
|
||||
//订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单
|
||||
order.setStatus(1);
|
||||
order.setPaymentTime(new Date());
|
||||
orderMapper.updateByPrimaryKey(order);
|
||||
|
||||
// 处理库存、分销等后续操作
|
||||
executorService.execute(() -> {
|
||||
// 处理库存
|
||||
updateStock(orderId);
|
||||
});
|
||||
|
||||
// 返还积分金额到前端
|
||||
return CommonResult.success(totalPointsAmount, "支付成功");
|
||||
|
||||
// 支付方式:0->未支付;1->支付宝;2->微信;3->线下支付;4->积分支付支付
|
||||
// 支付方式为0才允许支付
|
||||
// if (order.getPayType() != 0) {
|
||||
// return CommonResult.validateFailed("订单已支付");
|
||||
// }
|
||||
|
||||
|
||||
// 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("无效订单");
|
||||
// }
|
||||
//
|
||||
// //插入流水表
|
||||
// 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);
|
||||
|
||||
// //修改商品库存信息需要加锁,影响前台响应,所以用线程来处理
|
||||
// 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, "支付成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额支付
|
||||
*/
|
||||
@Override
|
||||
public CommonResult balancePayment(Long orderId) {
|
||||
// 获取订单详情
|
||||
OrderResult orderResult = getMemberOrderDetailInfo(orderId);
|
||||
if (orderResult == null) {
|
||||
return CommonResult.validateFailed("未查询到订单信息");
|
||||
}
|
||||
|
||||
order.setModifyTime(date);
|
||||
order.setPaymentTime(date);
|
||||
// 获取订单的支付金额
|
||||
BigDecimal payAmount = orderResult.getPayAmount();
|
||||
if (payAmount == null || payAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return CommonResult.validateFailed("无效的支付金额");
|
||||
}
|
||||
|
||||
// 获取当前用户信息
|
||||
UmsMember currentMember = memberService.getCurrentMember();
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(currentMember.getId());
|
||||
|
||||
// 获取用户余额
|
||||
BigDecimal currentBalance = member.getBalance();
|
||||
|
||||
// 判断余额是否足够支付
|
||||
if (currentBalance.compareTo(payAmount) < 0) {
|
||||
return CommonResult.validateFailed("余额不足,无法支付");
|
||||
}
|
||||
|
||||
// 扣除余额
|
||||
member.setBalance(currentBalance.subtract(payAmount));
|
||||
|
||||
// 更新用户余额
|
||||
memberMapper.updateByPrimaryKey(member);
|
||||
|
||||
//插入流水表
|
||||
UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction();
|
||||
accountTransaction.setMemberId(member.getId());
|
||||
accountTransaction.setOrderId(orderId);
|
||||
accountTransaction.setTransferPaymentTime(orderResult.getPaymentTime());
|
||||
accountTransaction.setRevenueAmount(payAmount.negate());
|
||||
PmsProduct pmsProduct = orderMapper.selectAll(orderResult.getOrderSn());
|
||||
accountTransaction.setRemarks( "商品名称" + pmsProduct.getName());
|
||||
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);
|
||||
// 设置为余额支付
|
||||
order.setPayType(5);
|
||||
// 设置订单状态为已支付
|
||||
order.setStatus(2);
|
||||
order.setPaymentTime(new 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理库存、分销等后续操作
|
||||
executorService.execute(() -> {
|
||||
// 处理库存
|
||||
updateStock(orderId);
|
||||
});
|
||||
|
||||
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, "支付成功");
|
||||
}
|
||||
|
||||
/**
|
||||
*处理库存的逻辑
|
||||
*/
|
||||
private void updateStock(Long orderId) {
|
||||
// 查询订单商品信息,进行库存更新等操作
|
||||
OmsOrderItemExample example = new OmsOrderItemExample();
|
||||
example.createCriteria().andOrderIdEqualTo(orderId);
|
||||
List<OmsOrderItem> orderItemList = orderItemMapper.selectByExample(example);
|
||||
for (OmsOrderItem orderItem : orderItemList) {
|
||||
PmsSkuStock skuStock = skuStockMapper.selectByPrimaryKey(orderItem.getProductSkuId());
|
||||
if (skuStock != null) {
|
||||
// 更新库存
|
||||
skuStock.setStock(skuStock.getStock() - orderItem.getProductQuantity());
|
||||
skuStockMapper.updateByPrimaryKey(skuStock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 微信预支付
|
||||
*
|
||||
@@ -1830,6 +2021,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
if (list != null && !list.isEmpty()) {
|
||||
OmsOrder order = list.get(0);
|
||||
|
||||
// 获取下单用户信息
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(order.getMemberId());
|
||||
//获取订单实付金额
|
||||
BigDecimal payAmount = order.getPayAmount();
|
||||
//获取商品信息
|
||||
@@ -1844,8 +2037,6 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
if (pmsProduct.getPointsAreaStatus() == 1) {
|
||||
//奖励积分是购买的价格的100%
|
||||
int rewardPoints = order.getPayAmount().intValue();
|
||||
// 获取用户信息
|
||||
UmsMember member = memberMapper.selectByPrimaryKey(order.getMemberId());
|
||||
// 增加用户积分
|
||||
if (member != null) {
|
||||
|
||||
@@ -1860,6 +2051,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
//增加基金积分
|
||||
int fundPoints = (int)(rewardPoints * 0.05);
|
||||
umsDevelopmentFundMapper.updatePoints(fundPoints);
|
||||
|
||||
//积分分润逻辑
|
||||
memberPointsSplitProfitService.pointsSplit(order);
|
||||
}
|
||||
}
|
||||
//订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单
|
||||
@@ -1877,12 +2071,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
||||
order.setPaymentTime(date);
|
||||
orderMapper.updateByPrimaryKey(order);
|
||||
|
||||
|
||||
/**
|
||||
* 会员分润,升级逻辑
|
||||
*/
|
||||
//会员现金分润,升级逻辑
|
||||
memberSplitProfitService.updateOderAndMemberInfo(order);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class PortalCommonServiceImpl implements PortalCommonService {
|
||||
|
||||
/**
|
||||
* 获取会员的折扣
|
||||
* @param member
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -566,7 +566,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());
|
||||
result.setMemberLevel(member.getMemberLevel().getValue()-1);
|
||||
result.setMemberId(loginMember.getId());
|
||||
result.setRealName(member.getRealName());
|
||||
result.setDetailAddress(member.getDetailAddress());
|
||||
@@ -622,10 +622,6 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
result.setInviter(memberMapper.selectByPrimaryKey(teamLevel.getParentId()).getNickname());
|
||||
}
|
||||
|
||||
/*查询发展基金*/
|
||||
BigDecimal totalCash = umsDevelopmentFundMapper.getTotalCash();
|
||||
Integer totalPoints = umsDevelopmentFundMapper.getTotalPoints();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -862,6 +858,12 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现申请列表
|
||||
* @param pageSize
|
||||
* @param pageNum
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MemberWithdrawApplyResult> getWithdrawApply(Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
@@ -870,6 +872,11 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员提现申请
|
||||
* @param applyParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult withdrawApply(WithdrawApplyParam applyParam) {
|
||||
|
||||
@@ -911,7 +918,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
}
|
||||
|
||||
if(applyParam.getValue() <= 0) {
|
||||
return CommonResult.validateFailed("提现积分无效");
|
||||
return CommonResult.validateFailed("提现无效");
|
||||
}
|
||||
|
||||
String withdrawMultipleStr = commonService.getDictionaryValue(Constants.D_WITHDRAW_MULTIPLE);
|
||||
@@ -1301,6 +1308,17 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
||||
return CommonResult.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询发展基金
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public UmsDevelopmentFund getDevelopmentFund() {
|
||||
UmsDevelopmentFund developmentFund = new UmsDevelopmentFund();
|
||||
developmentFund = umsDevelopmentFundMapper.selectAll();
|
||||
return developmentFund;
|
||||
}
|
||||
|
||||
private Map<String, Object> getOrderInfoByDate(DateTime begin, DateTime end, UmsMember currentMember, List<Long> teamIdList) {
|
||||
|
||||
Map<String, Object> infoMap = new HashMap<>();
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.buy507.mall.portal.service.impl;
|
||||
|
||||
import cn.hutool.db.sql.Order;
|
||||
import com.buy507.mall.common.api.CommonResult;
|
||||
import com.buy507.mall.mapper.OmsOrderMapper;
|
||||
import com.buy507.mall.model.MemberLevel;
|
||||
import com.buy507.mall.model.OmsOrder;
|
||||
import com.buy507.mall.portal.domain.OrderParam;
|
||||
import com.buy507.mall.portal.domain.OrderResult;
|
||||
import com.buy507.mall.portal.service.RedisService;
|
||||
import com.buy507.mall.portal.service.VipCenterService;
|
||||
import com.buy507.mall.portal.vo.OmsOrderDTO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class VipCenterServiceImpl implements VipCenterService {
|
||||
|
||||
//店长升级金额
|
||||
@Value("${storeManagerAmount}")
|
||||
private BigDecimal storeManagerAmount;
|
||||
|
||||
//代理升级金额
|
||||
@Value("${agentAmount}")
|
||||
private BigDecimal agentAmount;
|
||||
|
||||
//市代理升级金额
|
||||
@Value("${cityAgentAmount}")
|
||||
private BigDecimal cityAgentAmount;
|
||||
|
||||
@Value("${redis.key.prefix.orderId}")
|
||||
private String REDIS_KEY_PREFIX_ORDER_ID;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private OmsOrderMapper orderMapper;
|
||||
|
||||
@Override
|
||||
public BigDecimal getUpgradeAmount(Long memberLevelId) {
|
||||
BigDecimal amount = null;
|
||||
if (MemberLevel.Partner.getValue() == memberLevelId){
|
||||
amount = storeManagerAmount;
|
||||
}
|
||||
if (MemberLevel.Diamond.getValue() == memberLevelId){
|
||||
amount = agentAmount;
|
||||
}
|
||||
if (MemberLevel.OneDiamond.getValue() == memberLevelId){
|
||||
amount = cityAgentAmount;
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建购买权益订单
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult createUpgradeOrder(OmsOrderDTO param) {
|
||||
if (param == null){
|
||||
return CommonResult.validateFailed("订单数据为空");
|
||||
}else {
|
||||
//创建权益订单
|
||||
OmsOrder order = new OmsOrder();
|
||||
BeanUtils.copyProperties(param, order);
|
||||
order.setOrderSn(generateUpgradeOrderSn(param)); //生成orderSn
|
||||
order.setCreateTime(new Date()); //创建订单时间
|
||||
order.setStatus(0); //订单状态--未支付
|
||||
order.setOrderType(3); //订单类型--虚拟订单
|
||||
orderMapper.insert(order);
|
||||
|
||||
//返回订单id
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("orderId", order.getId());
|
||||
return CommonResult.success(result, "下单成功");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成18位订单编号:8位日期+2位订单类型+2位支付方式+6位以上自增id
|
||||
*/
|
||||
private String generateUpgradeOrderSn(OmsOrderDTO param) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
String key = REDIS_KEY_PREFIX_ORDER_ID + date;
|
||||
Long increment = redisService.increment(key, 1);
|
||||
sb.append(date);
|
||||
sb.append(String.format("%02d", param.getOrderType()));
|
||||
sb.append(String.format("%02d", param.getPayType()));
|
||||
String incrementStr = increment.toString();
|
||||
if (incrementStr.length() <= 6) {
|
||||
sb.append(String.format("%06d", increment));
|
||||
} else {
|
||||
sb.append(incrementStr);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.buy507.mall.portal.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class OmsOrderDTO {
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Long memberId;
|
||||
|
||||
@ApiModelProperty(value = "用户帐号")
|
||||
private String memberUsername;
|
||||
|
||||
@ApiModelProperty(value = "应付金额(实际支付金额)")
|
||||
private BigDecimal payAmount;
|
||||
|
||||
@ApiModelProperty(value = "支付方式:0->未支付;1->支付宝;2->微信;3->线下支付;4->积分支付;5—>余额支付")
|
||||
private Integer payType;
|
||||
|
||||
@ApiModelProperty(value = "订单类型:0->正常订单;1->秒杀订单;3->虚拟订单")
|
||||
private Integer orderType;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.buy507.mall.portal.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TransactionCashVo implements Serializable {
|
||||
|
||||
//现金数额
|
||||
private Integer revenueAmount;
|
||||
|
||||
//备注
|
||||
private String remarks;
|
||||
|
||||
//时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date transferPaymentTime;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.buy507.mall.portal.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TransactionPointsVo implements Serializable {
|
||||
//积分数额
|
||||
private Integer revenuePoints;
|
||||
|
||||
//备注
|
||||
private String remarks;
|
||||
|
||||
//时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date transferPaymentTime;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.buy507.mall.portal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WalletCashVo {
|
||||
|
||||
// 余额现金
|
||||
private BigDecimal balance;
|
||||
|
||||
//现金流水
|
||||
private List<TransactionCashVo> cashVoList;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.buy507.mall.portal.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WalletPointsVo {
|
||||
// 余额积分
|
||||
private Integer integration;
|
||||
|
||||
//积分流水
|
||||
private List<TransactionPointsVo> pointsVoList;
|
||||
}
|
||||
@@ -104,4 +104,10 @@ alipay:
|
||||
# 成为vip金额
|
||||
becomeVipAmount: 899
|
||||
# 同等级分润比例
|
||||
sameLevelProfit: 10
|
||||
sameLevelProfit: 10
|
||||
#店长升级金额
|
||||
storeManagerAmount: 1000
|
||||
#代理升级金额
|
||||
agentAmount: 1000
|
||||
#市代理升级金额
|
||||
cityAgentAmount: 1000
|
||||
@@ -8,6 +8,9 @@ mybatis:
|
||||
mapper-locations:
|
||||
- classpath:dao/*.xml
|
||||
- classpath*:com/**/mapper/*.xml
|
||||
configuration:
|
||||
#开启驼峰命名
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
jwt:
|
||||
tokenHeader: Authorization #JWT存储的请求头
|
||||
|
||||
@@ -61,11 +61,6 @@
|
||||
WHERE
|
||||
hp.recommend_status = 1
|
||||
AND p.publish_status = 1
|
||||
AND (
|
||||
p.vip_status = 1 OR
|
||||
p.points_area_status = 1 OR
|
||||
p.points_exchange_status = 1
|
||||
)
|
||||
ORDER BY
|
||||
hp.sort DESC
|
||||
LIMIT #{offset}, #{limit};
|
||||
@@ -83,5 +78,56 @@
|
||||
hs.sort DESC
|
||||
LIMIT #{offset}, #{limit};
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getProductVipStatus" resultType="com.buy507.mall.model.PmsProduct">
|
||||
SELECT *
|
||||
FROM
|
||||
pms_product
|
||||
WHERE
|
||||
vip_status = 1
|
||||
LIMIT #{offset}, #{limit};
|
||||
</select>
|
||||
|
||||
<select id="getProductpointSareaStatus" resultType="com.buy507.mall.model.PmsProduct">
|
||||
SELECT *
|
||||
FROM
|
||||
pms_product
|
||||
WHERE
|
||||
points_area_status = 1
|
||||
LIMIT #{offset}, #{limit};
|
||||
</select>
|
||||
|
||||
<select id="getProductpointsExchangeStatus" resultType="com.buy507.mall.model.PmsProduct">
|
||||
|
||||
SELECT *
|
||||
FROM
|
||||
pms_product
|
||||
WHERE
|
||||
points_exchange_status = 1
|
||||
LIMIT #{offset}, #{limit};
|
||||
</select>
|
||||
|
||||
<select id="getVipStatusList" resultType="com.buy507.mall.model.PmsProduct">
|
||||
SELECT *
|
||||
FROM
|
||||
pms_product
|
||||
WHERE
|
||||
vip_status = 1
|
||||
</select>
|
||||
|
||||
<select id="getPointStatusList" resultType="com.buy507.mall.model.PmsProduct">
|
||||
SELECT *
|
||||
FROM
|
||||
pms_product
|
||||
WHERE
|
||||
points_area_status = 1
|
||||
</select>
|
||||
|
||||
<select id="getPointExchangeProductList" resultType="com.buy507.mall.model.PmsProduct">
|
||||
SELECT *
|
||||
FROM
|
||||
pms_product
|
||||
WHERE
|
||||
points_exchange_status = 1
|
||||
</select>
|
||||
</mapper>
|
||||
5
mall-portal/src/main/resources/dao/MyWalletMapper.xml
Normal file
5
mall-portal/src/main/resources/dao/MyWalletMapper.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.buy507.mall.portal.dao.MyWalletMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user