|
@@ -0,0 +1,133 @@
|
|
|
|
+package com.caimei365.manager.service.caimei.svip.impl;
|
|
|
|
+
|
|
|
|
+import com.caimei.utils.AppUtils;
|
|
|
|
+import com.caimei.utils.StringUtil;
|
|
|
|
+import com.caimei365.manager.dao.svip.CmSvipHistoryDao;
|
|
|
|
+import com.caimei365.manager.entity.PaginationVo;
|
|
|
|
+import com.caimei365.manager.entity.ResponseJson;
|
|
|
|
+import com.caimei365.manager.entity.caimei.svip.CmSku;
|
|
|
|
+import com.caimei365.manager.entity.caimei.svip.CmSvipHistory;
|
|
|
|
+import com.caimei365.manager.entity.caimei.svip.CmSvipPackage;
|
|
|
|
+import com.caimei365.manager.entity.caimei.svip.CmSvipProduct;
|
|
|
|
+import com.caimei365.manager.service.caimei.svip.CmSvipHistoryService;
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Description
|
|
|
|
+ *
|
|
|
|
+ * @author : Charles
|
|
|
|
+ * @date : 2023/4/7
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class CmSvipHistoryServiceImpl implements CmSvipHistoryService {
|
|
|
|
+
|
|
|
|
+ @Autowired private CmSvipHistoryDao historyDao;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<PaginationVo<CmSvipHistory>> memberList(CmSvipHistory vip, Integer pageNum, Integer pageSize) {
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<CmSvipHistory> historyList = historyDao.superFind(vip);
|
|
|
|
+ for (CmSvipHistory cmSvipHistory : historyList) {
|
|
|
|
+ CmSvipHistory vp = historyDao.findEndTime(cmSvipHistory.getUserId());
|
|
|
|
+ if (vp != null) {
|
|
|
|
+ cmSvipHistory.setStatus("1");
|
|
|
|
+ } else {
|
|
|
|
+ cmSvipHistory.setStatus("2");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ PaginationVo<CmSvipHistory> page = new PaginationVo<>(historyList);
|
|
|
|
+ return ResponseJson.success(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 超级会员优惠商品
|
|
|
|
+ *
|
|
|
|
+ * @param svipProduct
|
|
|
|
+ * @param pageNum
|
|
|
|
+ * @param pageSize
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<PaginationVo<CmSvipProduct>> findProductList(CmSvipProduct svipProduct, Integer pageNum, Integer pageSize) {
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<CmSvipProduct> svipProducts = historyDao.findProductList(svipProduct);
|
|
|
|
+// String wwwServer = Global.getConfig("wwwServer");
|
|
|
|
+ svipProducts.forEach(product -> {
|
|
|
|
+ CmSku sku = historyDao.findSku(product.getProductId());
|
|
|
|
+ CmSku skuPrice = historyDao.findSvipSku(product.getProductId());
|
|
|
|
+ if (null != skuPrice) {
|
|
|
|
+ product.setPriceType(skuPrice.getPriceType());
|
|
|
|
+ product.setDiscount(BigDecimal.valueOf(skuPrice.getDiscount()));
|
|
|
|
+ product.setDiscountPrice(BigDecimal.valueOf(skuPrice.getDiscountPrice()));
|
|
|
|
+ }
|
|
|
|
+ product.setPrice(BigDecimal.valueOf(sku.getPrice()));
|
|
|
|
+ if (StringUtil.isNotBlank(product.getProductImage())) {
|
|
|
|
+ product.setProductImage(AppUtils.getImageURL("product", product.getProductImage(), 0, "wwwServer"));
|
|
|
|
+ if (!product.getProductImage().contains("https")) {
|
|
|
|
+ product.setProductImage("https://admin.caimei365.com/" + product.getProductImage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ PaginationVo<CmSvipProduct> page = new PaginationVo<>(svipProducts);
|
|
|
|
+ return ResponseJson.success(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<CmSvipPackage> findPackage() {
|
|
|
|
+ // 1 套餐12 、2 套餐3月 、3 套餐1月
|
|
|
|
+ List<CmSvipPackage> aPackage = historyDao.findPackage();
|
|
|
|
+ CmSvipPackage vip = new CmSvipPackage();
|
|
|
|
+ for (CmSvipPackage cmSvipPackage : aPackage) {
|
|
|
|
+ if (cmSvipPackage.getDuration().equals("12")) {
|
|
|
|
+ vip.setPrice1(cmSvipPackage.getPrice());
|
|
|
|
+ }
|
|
|
|
+ if (cmSvipPackage.getDuration().equals("3")) {
|
|
|
|
+ vip.setPrice2(cmSvipPackage.getPrice());
|
|
|
|
+ }
|
|
|
|
+ if (cmSvipPackage.getDuration().equals("1")) {
|
|
|
|
+ vip.setPrice3(cmSvipPackage.getPrice());
|
|
|
|
+ }
|
|
|
|
+ vip.setProportion(cmSvipPackage.getProportion());
|
|
|
|
+ }
|
|
|
|
+ String price1 = strs(vip.getPrice1());
|
|
|
|
+ String price2 = strs(vip.getPrice2());
|
|
|
|
+ String price3 = strs(vip.getPrice3());
|
|
|
|
+ vip.setPrice1(price1);
|
|
|
|
+ vip.setPrice2(price2);
|
|
|
|
+ vip.setPrice3(price3);
|
|
|
|
+ return ResponseJson.success(vip);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更新超级会员套餐信息
|
|
|
|
+ *
|
|
|
|
+ * @param cmSvipPackage
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson updatePrice(CmSvipPackage cmSvipPackage) {
|
|
|
|
+ //1 套餐12,2 套餐3月,3 套餐1月
|
|
|
|
+ Double price1 = Double.valueOf(cmSvipPackage.getPrice1());
|
|
|
|
+ Double price2 = Double.valueOf(cmSvipPackage.getPrice2());
|
|
|
|
+ String p = cmSvipPackage.getProportion();
|
|
|
|
+ Integer proportion = Integer.valueOf(p);
|
|
|
|
+ historyDao.updatePrice(price1, 12, proportion);
|
|
|
|
+ historyDao.updatePrice(price2, 3, proportion);
|
|
|
|
+ return ResponseJson.success(1, "", null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static String strs(String str) {
|
|
|
|
+ if (str.indexOf(".") > 0) {
|
|
|
|
+ // 删掉尾数为0的字符
|
|
|
|
+ str = str.replaceAll("0+?$", "");
|
|
|
|
+ //结尾如果是小数点,则去掉
|
|
|
|
+ str = str.replaceAll("[.]$", "");
|
|
|
|
+ }
|
|
|
|
+ return str;
|
|
|
|
+ }
|
|
|
|
+}
|