jiangqs
2023-08-06 beeda8df0023376dbb2021148a021731dc4aedb0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.ruoyi.shop.service.impl.shop;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.shop.domain.dto.MgtShopProportionEditDto;
import com.ruoyi.shop.domain.pojo.shop.ShopAuthentication;
import com.ruoyi.shop.domain.pojo.shop.ShopProportion;
import com.ruoyi.shop.mapper.shop.ShopProportionMapper;
import com.ruoyi.shop.service.shop.ShopProportionService;
import org.springframework.stereotype.Service;
 
import java.util.Date;
 
/**
 * <p>
 * 商户分成 服务实现类
 * </p>
 *
 * @author jqs
 * @since 2023-05-25
 */
@Service
public class ShopProportionServiceImpl extends ServiceImpl<ShopProportionMapper, ShopProportion> implements ShopProportionService {
 
 
    /**
     * @description  修改商户分成
     * @author  jqs
     * @date    2023/6/8 9:52
     * @param mgtShopProportionEditDto
     * @return  void
     */
    @Override
    public void editMgtShopProportion(MgtShopProportionEditDto mgtShopProportionEditDto){
        //删除旧分成
        ShopProportion shopProportionOld = this.getById(mgtShopProportionEditDto.getProportionId());
        if(shopProportionOld!=null){
            shopProportionOld.setDelFlag(1);
            shopProportionOld.setUpdateUserId(mgtShopProportionEditDto.getUserId());
            shopProportionOld.setUpdateTime(new Date());
            this.saveOrUpdate(shopProportionOld);
        }
        //创建新分成
        ShopProportion shopProportionNew = new ShopProportion();
        shopProportionNew.setDelFlag(0);
        shopProportionNew.setShopId(shopProportionOld.getShopId());
        shopProportionNew.setShopType(shopProportionOld.getShopType());
        shopProportionNew.setProportionPercent(mgtShopProportionEditDto.getProportionPercent());
        shopProportionNew.setUpdateTime(new Date());
        shopProportionNew.setUpdateUserId(mgtShopProportionEditDto.getUserId());
        this.saveOrUpdate(shopProportionNew);
    }
 
    @Override
    public ShopProportion getByShopId(Long shopId) {
        LambdaQueryWrapper<ShopProportion> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ShopProportion::getShopId, shopId)
                .eq(ShopProportion::getDelFlag, 0)
                .last(" limit 1 ");
        return this.getOne(queryWrapper);
    }
}