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 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); } }