Commit c9f16ff3 authored by libin's avatar libin

佣金明细

parent 5c86acef
package com.github.wxiaoqi.security.admin.vo;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -57,11 +58,27 @@ public class SellingWalletVo {
@ApiModelProperty("'类别:0-正;1-负(退款时)")
private Integer status;
@JSONField(serialize = false)
private Integer sourceId;
@JSONField(serialize = false)
private BigDecimal commissionnm;
/**
* 所获佣金
*/
private BigDecimal commission;
/**
* 订单状态
*/
private Integer sellerStatus;
/**
* 订单文案
*/
private String statusText;
/**
* 是否显示 默认false
*/
private Boolean isShow;
}
......@@ -105,22 +105,22 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
log.info("购买计算用户拥金----payOrderWater--------userId===" + userId + "---parentId===" + parentId);
Integer positionId = 6;
Integer level = 0;
AppUserPosition position=positionBiz.getExtract(parentId);
if (position!=null){
positionId=position.getId();
AppUserPosition position = positionBiz.getExtract(parentId);
if (position != null) {
positionId = position.getId();
}
AppUserPosition position1=positionBiz.getExtract(userId);
if (position!=null){
level=position1.getLevel();
AppUserPosition position1 = positionBiz.getExtract(userId);
if (position != null) {
level = position1.getLevel();
}
log.info("购买计算用户拥金----payOrderWater--------userId===" + userId + "---positionId===" + positionId+"---level==="+level);
if(level!=0){
log.info("购买计算用户拥金----payOrderWater--------userId===" + userId +"----无法享受拥金");
log.info("购买计算用户拥金----payOrderWater--------userId===" + userId + "---positionId===" + positionId + "---level===" + level);
if (level != 0) {
log.info("购买计算用户拥金----payOrderWater--------userId===" + userId + "----无法享受拥金");
return;
}
BigDecimal amount = new BigDecimal("0.00");
//商品类型
Integer orderType=0;
Integer orderType = 0;
for (OrderGoodsDTO goodsDto : goodsDTOList) {
//商品id
Integer goodId = goodsDto.getGoodId();
......@@ -164,11 +164,11 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
amount = amount.add(commission);
}
}
log.info("购买计算用户未入账----payOrderWater--------userId===" + parentId+"----amount===="+amount+"--orderType==="+orderType);
if(orderType==3){
log.info("购买计算用户未入账----payOrderWater--------userId===" + parentId + "----amount====" + amount + "--orderType===" + orderType);
if (orderType == 3) {
finishOrderWater(orderWaterDTO);
}else if(orderType==1||orderType==2){
myWaterBiz.updMyWalletUnbooked(parentId,amount,1);
} else if (orderType == 1 || orderType == 2) {
myWaterBiz.updMyWalletUnbooked(parentId, amount, 1);
}
}
......@@ -183,16 +183,16 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
List<AppUserSellingWater> list = getWaterList(orderId);
BigDecimal amount = new BigDecimal("0.00");
Integer userId = 0;
Integer orderType=0;
Integer orderType = 0;
if (list.size() > 0) {
for (AppUserSellingWater sellingWater : list) {
Integer id = sellingWater.getId();
orderType=sellingWater.getOrderType();
orderType = sellingWater.getOrderType();
userId = sellingWater.getUserId();
sellingWater.setWaiting(1);
updateById(sellingWater);
BigDecimal commission = sellingWater.getCommission();
log.info("订单完成计算用户拥金----finishOrderWater----id====" + id + "---commission==" + commission+"----orderType==="+orderType);
log.info("订单完成计算用户拥金----finishOrderWater----id====" + id + "---commission==" + commission + "----orderType===" + orderType);
amount = amount.add(commission);
}
......@@ -200,14 +200,14 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
int r = amount.compareTo(BigDecimal.ZERO);
//更新钱包
if (r == 1 && userId > 0) {
MyWalletDetail detail=new MyWalletDetail();
MyWalletDetail detail = new MyWalletDetail();
detail.setUserId(userId);
detail.setAmount(amount);
detail.setCono(orderId);
detail.setSource(1);
myWaterBiz.updMyWater(detail);
if(orderType==1||orderType==2){
myWaterBiz.updMyWalletUnbooked(userId,amount,2);
if (orderType == 1 || orderType == 2) {
myWaterBiz.updMyWalletUnbooked(userId, amount, 2);
}
}
......@@ -228,11 +228,11 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
BigDecimal amount = new BigDecimal("0.00");
BigDecimal unbooked = new BigDecimal("0.00");
Integer userId = 0;
Integer orderType=0;
Integer orderType = 0;
if (list.size() > 0) {
for (AppUserSellingWater sellingWater : list) {
Integer id = sellingWater.getId();
orderType=sellingWater.getOrderType();
orderType = sellingWater.getOrderType();
userId = sellingWater.getUserId();
sellingWater.setWaiting(1);
updateById(sellingWater);
......@@ -240,22 +240,22 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWater.setStatus(1);
insertSelective(sellingWater);
BigDecimal commission = sellingWater.getCommission();
log.info("订单完成计算用户拥金----refundOrderWater----id====" + id + "---commission==" + commission+"---orderType===="+orderType);
unbooked=unbooked.add(commission);
log.info("订单完成计算用户拥金----refundOrderWater----id====" + id + "---commission==" + commission + "---orderType====" + orderType);
unbooked = unbooked.add(commission);
}
log.info("订单完成计算用户拥金----refundOrderWater----orderId====" + orderId + "---amount==" + amount+"---unbooked==="+unbooked);
log.info("订单完成计算用户拥金----refundOrderWater----orderId====" + orderId + "---amount==" + amount + "---unbooked===" + unbooked);
int r = amount.compareTo(BigDecimal.ZERO);
//更新钱包
if (r == 1 && userId > 0) {
MyWalletDetail detail=new MyWalletDetail();
MyWalletDetail detail = new MyWalletDetail();
detail.setUserId(userId);
detail.setAmount(amount);
detail.setCono(orderId);
detail.setSource(1);
myWaterBiz.updMyWater(detail);
}
if(orderType==1||orderType==2){
myWaterBiz.updMyWalletUnbooked(userId,unbooked,2);
if (orderType == 1 || orderType == 2) {
myWaterBiz.updMyWalletUnbooked(userId, unbooked, 2);
}
}
......@@ -271,8 +271,8 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
}
public PageDataVO<UserIncomeBo> findMemberIdAndIncomeMapByMemberIds(Integer parentId,Integer pageNo,Integer pageSize) {
return PageDataVO.pageInfo(pageNo,pageSize,()->mapper.accquireIncomeByMemberIds(parentId));
public PageDataVO<UserIncomeBo> findMemberIdAndIncomeMapByMemberIds(Integer parentId, Integer pageNo, Integer pageSize) {
return PageDataVO.pageInfo(pageNo, pageSize, () -> mapper.accquireIncomeByMemberIds(parentId));
}
public SellingWalletPagVo findSellingWaterPageByWaiting(Integer waiting, Integer userId, Integer pageNo, Integer pageSize) {
......@@ -297,7 +297,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
return sellingWalletPagVo;
}
List<Integer> memberIds = appUserSellingWaters.stream().map(AppUserSellingWater::getSourceId).collect(Collectors.toList());
List<Integer> memberIds = appUserSellingWaters.stream().map(AppUserSellingWater::getSourceId).distinct().collect(Collectors.toList());
Map<Integer, AppUserLogin> userIdAndAppUserLoginMap = appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(memberIds);
Map<Integer, AppUserDetail> userIdAndAppUserDetailMap = appUserDetailBiz.findUserIdAndUserDetailMapByMemberIds(memberIds);
......@@ -341,14 +341,87 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
}
public void deleteByMemberIds(Collection<Integer> userIds) {
Example example = new Example(AppUserSellingWater.class);
Example example = new Example(AppUserSellingWater.class);
Example.Criteria criteria = example.createCriteria();
criteria.orIn("sourceId",userIds);
criteria.orIn("userId",userIds);
criteria.orIn("sourceId", userIds);
criteria.orIn("userId", userIds);
mapper.deleteByExample(example);
}
public SellingWalletPagVo findSellingWaterPageForAppByWaiting(Integer wating, Integer userId, Integer pageNo, Integer pageSize) {
return null;
SellingWalletPagVo sellingWalletPagVo = new SellingWalletPagVo();
PageDataVO<SellingWalletVo> pageDataVO = PageDataVO.pageInfo(pageNo, pageSize, () -> mapper.selectSellerWalterByUserIdAndWating(userId, wating));
List<SellingWalletVo> data = pageDataVO.getData();
if (CollectionUtils.isEmpty(data)) {
sellingWalletPagVo.setPageNum(pageNo);
sellingWalletPagVo.setPageSize(pageSize);
sellingWalletPagVo.setSellingWaters(Collections.EMPTY_LIST);
sellingWalletPagVo.setTotalCount(0);
sellingWalletPagVo.setTotalPage(0);
return sellingWalletPagVo;
}
List<Integer> memberIds = data.stream().map(SellingWalletVo::getSourceId).distinct().collect(Collectors.toList());
Map<Integer, AppUserLogin> userIdAndAppUserLoginMap = appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(memberIds);
Map<Integer, AppUserDetail> userIdAndAppUserDetailMap = appUserDetailBiz.findUserIdAndUserDetailMapByMemberIds(memberIds);
for (SellingWalletVo sellingWalletVo : data) {
String username = userIdAndAppUserLoginMap.get(sellingWalletVo.getSourceId()).getUsername();
sellingWalletVo.setUsername(username);
if (userIdAndAppUserDetailMap != null) {
AppUserDetail appUserDetail = userIdAndAppUserDetailMap.get(sellingWalletVo.getSourceId());
sellingWalletVo.setNickName(appUserDetail == null ? "" : appUserDetail.getNickname());
sellingWalletVo.setHeadUrl(appUserDetail == null ? "" : appUserDetail.getHeadimgurl());
}
//取消单
if (Objects.nonNull(sellingWalletVo.getSellerStatus())) {
sellingWalletVo.setStatusText(SellerWallterStatus.CANCEL.getText());
}else {
if (sellingWalletVo.getWaiting()==SellerWallterStatus.POST.getCode()){
sellingWalletVo.setSellerStatus(SellerWallterStatus.POST.getCode());
sellingWalletVo.setStatusText(SellerWallterStatus.POST.getText());
}
if (sellingWalletVo.getWaiting()==SellerWallterStatus.NO_POST.getCode()){
sellingWalletVo.setSellerStatus(SellerWallterStatus.NO_POST.getCode());
sellingWalletVo.setStatusText(SellerWallterStatus.NO_POST.getText());
}
}
}
sellingWalletPagVo.setPageNum(pageNo);
sellingWalletPagVo.setPageSize(pageSize);
sellingWalletPagVo.setSellingWaters(data);
sellingWalletPagVo.setTotalCount(pageDataVO.getTotalCount().intValue());
sellingWalletPagVo.setTotalPage(pageDataVO.getTotalPage());
return sellingWalletPagVo;
}
private enum SellerWallterStatus {
CANCEL(2, "取消订单"),
POST(1, "已入账"),
NO_POST(0, "未入账");
private int code;
private String text;
SellerWallterStatus(int code, String text) {
this.code = code;
this.text = text;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.bo.UserIncomeBo;
import com.github.wxiaoqi.security.admin.entity.AppUserSellingWater;
import com.github.wxiaoqi.security.admin.vo.SellingWalletVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
......@@ -20,4 +21,6 @@ public interface AppUserSellingWaterMapper extends Mapper<AppUserSellingWater> {
List<UserIncomeBo> accquireIncomeByMemberIds(@Param("parentId") Integer parentId);
BigDecimal selectTotalIncomeByUserId(@Param("userId") Integer userId);
List<SellingWalletVo> selectSellerWalterByUserIdAndWating(@Param("userId") Integer userId, @Param("wating") Integer wating);
}
......@@ -31,4 +31,26 @@ FROM
( SELECT IFNULL(SUM( commission ),0) AS upIncome FROM `app_user_selling_water` WHERE STATUS = 0 AND `user_id` = #{userId} ) AS `auswu`,
( SELECT IFNULL(SUM( commission ),0) AS `dowIncome` FROM `app_user_selling_water` WHERE STATUS = 1 AND `user_id` = #{userId} ) AS `auswd`;
</select>
<select id="selectSellerWalterByUserIdAndWating" resultType="com.github.wxiaoqi.security.admin.vo.SellingWalletVo">
SELECT
*
FROM
(
SELECT
ausw.*,
IFNULL( ausw.commission, 0 ) - IFNULL( auswt.commission, 0 ) AS `commissionnm`,
auswt.status AS sellerStatus,
IFNULL(auswt.status,0) AS `isShow`
FROM
( SELECT * FROM `app_user_selling_water` WHERE STATUS = 0 AND `user_id`=#{userId} <if test="wating!=null">
AND `waiting`=#{wating}
</if>) AS `ausw`
LEFT JOIN ( SELECT * FROM `app_user_selling_water` WHERE STATUS = 1 AND `user_id`=#{userId} <if
test="wating!=null">
AND `waiting`=#{wating}
</if>) AS `auswt` ON auswt.order_no = ausw.order_no
) AS `auswres`
ORDER BY crt_time DESC
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment