|
@@ -15,7 +15,6 @@ import com.caimei.modules.user.dao.NewCmShopDao;
|
|
|
import com.caimei.modules.user.entity.CmUser;
|
|
|
import com.caimei.modules.user.entity.NewCmShop;
|
|
|
import com.caimei.utils.AppUtils;
|
|
|
-import com.thinkgem.jeesite.common.config.Global;
|
|
|
import com.thinkgem.jeesite.common.persistence.Page;
|
|
|
import com.thinkgem.jeesite.common.service.CrudService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -291,17 +290,20 @@ public class CmCouponService extends CrudService<CmCouponDao, CmCoupon> {
|
|
|
return couponsLogo;
|
|
|
}
|
|
|
|
|
|
+ public List<CmCoupon> findClubCouponList(Product product, Integer userId) {
|
|
|
+ List<CmCoupon> couponList = cmCouponDao.findClubCouponList(userId);
|
|
|
+ filterCoupon(product, couponList);
|
|
|
+ setCouponCopywriting(couponList);
|
|
|
+ return couponList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * 查询对应优惠券信息
|
|
|
+ * 过滤与商品不能使用优惠券
|
|
|
*
|
|
|
- * @param product 商品数据
|
|
|
- * @param type 优惠券类型: 1普通优惠券 2兑换券优惠券
|
|
|
- * @return
|
|
|
+ * @param product 商品数据
|
|
|
+ * @param couponList 优惠券集合
|
|
|
*/
|
|
|
- public List<CmCoupon> findProductCoupon(Product product, int type) {
|
|
|
- String wwwServer = Global.getConfig("wwwServer");
|
|
|
- product.setMainImage(AppUtils.getImageURL("product", product.getMainImage(), 0, wwwServer));
|
|
|
- List<CmCoupon> couponList = cmCouponDao.findAllValidCoupon(type);
|
|
|
+ private void filterCoupon(Product product, List<CmCoupon> couponList) {
|
|
|
if (couponList != null && couponList.size() > 0) {
|
|
|
Iterator<CmCoupon> iterator = couponList.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
@@ -323,6 +325,58 @@ public class CmCouponService extends CrudService<CmCouponDao, CmCoupon> {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<CmCoupon> findNotRedeemedCoupon(Product product) {
|
|
|
+ List<CmCoupon> couponList = cmCouponDao.findNotRedeemedCoupon();
|
|
|
+ filterCoupon(product, couponList);
|
|
|
+ setCouponCopywriting(couponList);
|
|
|
return couponList;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置优惠券文案相关
|
|
|
+ *
|
|
|
+ * @param couponList
|
|
|
+ */
|
|
|
+ public void setCouponCopywriting(List<CmCoupon> couponList) {
|
|
|
+ if (couponList != null && couponList.size() > 0) {
|
|
|
+ couponList.forEach(coupon -> {
|
|
|
+ String couponName = "¥" + coupon.getCouponAmount() + " 满" + coupon.getTouchPrice() + "可用";
|
|
|
+ if (coupon.getCouponType() == 0) {
|
|
|
+ coupon.setCouponName("活动券" + couponName);
|
|
|
+ if ("2".equals(coupon.getProductType())) {
|
|
|
+ List<Integer> productIdList = cmCouponDao.findAllProductId(coupon.getId());
|
|
|
+ coupon.setProductIdList(productIdList);
|
|
|
+ coupon.setCouponDesc("仅可购买指定商品");
|
|
|
+ } else {
|
|
|
+ coupon.setCouponDesc("全商城商品通用");
|
|
|
+ }
|
|
|
+ } else if (coupon.getCouponType() == 1) {
|
|
|
+ coupon.setCouponName("品类券" + couponName);
|
|
|
+ if ("1".equals(coupon.getCategoryType())) {
|
|
|
+ coupon.setCouponDesc("仅可购买产品类商品");
|
|
|
+ } else {
|
|
|
+ coupon.setCouponDesc("仅可购买仪器类商品");
|
|
|
+ }
|
|
|
+ } else if (coupon.getCouponType() == 2) {
|
|
|
+ coupon.setCouponName("用户专享券" + couponName);
|
|
|
+ coupon.setCouponDesc("全商城商品通用");
|
|
|
+ } else if (coupon.getCouponType() == 3) {
|
|
|
+ NewCmShop cmShop = newCmShopDao.get(coupon.getShopId().toString());
|
|
|
+ if (cmShop != null) {
|
|
|
+ String shopName = cmShop.getName();
|
|
|
+ if (shopName.length() > 10) {
|
|
|
+ shopName = shopName.substring(0, 9) + "...";
|
|
|
+ }
|
|
|
+ coupon.setCouponName("店铺券" + couponName);
|
|
|
+ coupon.setCouponDesc("仅可购买店铺【" + shopName + "】的商品");
|
|
|
+ }
|
|
|
+ } else if (coupon.getCouponType() == 4) {
|
|
|
+ coupon.setCouponName("新用户券" + couponName);
|
|
|
+ coupon.setCouponDesc("全商城商品通用");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|