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
package com.matrix.system.shopXcx.api.tools;
 
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.system.shopXcx.api.service.WxShopMemberDayService;
import com.matrix.system.shopXcx.bean.ShopOrder;
import com.matrix.system.shopXcx.dao.ShopCouponRecordDao;
import com.matrix.system.shopXcx.dao.ShopOrderDao;
import com.matrix.system.shopXcx.dao.ShopSkuDao;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.List;
 
/**
 * @author jyy
 */
@Service("wxShopCouponUtil")
public class WxShopCouponUtil {
    @Autowired
    private ShopOrderDao shopOrderDao;
    @Autowired
    private RedisUserLoginUtils redisUserLoginUtils;
    @Autowired
    private ShopCouponRecordDao shopCouponRecordDao;
    @Autowired
    private ShopSkuDao shopSkuDao;
    @Autowired
    private WxShopMemberDayService wxShopMemberDayService;
    @Autowired
    private WxShopOrderUtil wxShopOrderUtil;
 
    /**
     * 根据用户ID验证是否是新人
     * @param userId 用户ID
     * @return true = 新人
     */
    public boolean verifyIsNewPeople(Long userId) {
        ShopOrder orderParam = new ShopOrder();
        orderParam.setPayResult(ShopOrder.ORDER_WX_STATUS_PAY_SUCCESS);
        orderParam.setUserId(userId);
        List<ShopOrder> orderList = shopOrderDao.selectByModel(orderParam);
        //如果存在付款成功的订单
        if (CollectionUtils.isNotEmpty(orderList)) {
            return false;
        }
        return true;
    }
 
    public Double processOrderMoney(Double orderMoney) {
        DecimalFormat decimalFormat = new DecimalFormat("0.#");
        decimalFormat.setRoundingMode(RoundingMode.DOWN);
        String moneyStr = decimalFormat.format(orderMoney);
        return Double.valueOf(moneyStr);
    }
 
}