huangzhiguo 2 سال پیش
والد
کامیت
8d7b1b2e07

+ 62 - 0
src/main/java/com/caimei365/manager/config/utils/DateUtil.java

@@ -0,0 +1,62 @@
+package com.caimei365.manager.config.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+public class DateUtil {
+    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+    private static Calendar calendar = Calendar.getInstance();
+
+    /*
+    输入日期字符串比如201703,返回当月第一天的Date
+    */
+    public static Date getMinDay(String month) {
+        try {
+            Date nowDate = sdf.parse(month);
+            calendar = Calendar.getInstance();
+            calendar.setTime(nowDate);
+            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
+            return calendar.getTime();
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /*
+    输入日期字符串,返回下个月1号0点
+    */
+    public static Date getMaxDay(String month) {
+        try {
+            Date nowDate = sdf.parse(month);
+            calendar = Calendar.getInstance();
+            calendar.setTime(nowDate);
+            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+            calendar.add(Calendar.DAY_OF_MONTH,1);
+            return calendar.getTime();
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 返回现在时间yyyy-mm格式
+     * @return
+     */
+    public static String getNowMonth(){
+        Date date = new Date();
+        String format = new SimpleDateFormat("yyyy-MM").format(date);
+        return format;
+    }
+
+//    public static void main(String[] args) throws ParseException {
+//        String month = "2020-02";
+//        System.out.println(getMinDateMonth(month));
+//        System.out.println(getMaxDateMonth(month));
+//    }
+
+
+}

+ 39 - 13
src/main/java/com/caimei365/manager/controller/caimei/svip/CmSvipHistoryApi.java

@@ -102,16 +102,42 @@ public class CmSvipHistoryApi {
         return historyService.couponList(cmVipCoupon, pageNum, pageSize);
     }
 
-    @RequestMapping(value = "form")
-    public Map<String, Object> form(CmVipCoupon cmVipCoupon) {
-//        cmVipCoupon.setEndTime(cmVipCoupon.getEndTime());
-        // 设置4张券的表单
-        /*SvipCouponForm svipcouponForm = cmVipCouponService.setSvipcouponForms(cmVipCoupon);
-        List<String> useDateList = cmVipCouponService.getAllUseDateList();
-        return "modules/svip/cmSvipCouponForm";*/
-        return null;
+    /**
+     * 编辑超级会员优惠券  |  超级会员专属优惠券配置
+     * @param id
+     * @param configure
+     * @return
+     */
+    @GetMapping(value = "/svipCoupon")
+    public ResponseJson<Map<String, Object>> formSvipCoupon(Integer id, Integer configure) {
+        if (null == configure) {
+            return ResponseJson.error(-1,"优惠券类型不能为空",null);
+        }
+        return historyService.cmVipCouponForm(id,configure);
+    }
+
+    /**
+     * 保存超级会员优惠券 | 保存专属优惠券配置
+     * @param svipcouponForm
+     * @return
+     */
+    @PostMapping("/saveVipCoupon")
+    public ResponseJson saveVipCoupon(@RequestBody SvipCouponForm svipcouponForm) {
+        return historyService.saveVipCoupon(svipcouponForm);
     }
 
+    /**
+     * 删除优惠券
+     * @param id
+     * @return
+     */
+    @PostMapping("/delCoupon/{id}")
+    public ResponseJson delCoupon(@PathVariable("id") Integer id) {
+        if (null == id) {
+            return ResponseJson.error(-1,"参数不能能为空",null);
+        }
+        return historyService.delCoupon(id);
+    }
     /**
      * 关闭超级会员专属优惠券
      * @param id
@@ -224,15 +250,15 @@ public class CmSvipHistoryApi {
 
     /**
      * 保存超级会员商品
-     * @param productId
+     * @param cmSvipProduct
      * @return
      */
-    @PostMapping("/saveSvipProduct/{productId}")
-    public ResponseJson saveSvipProduct(@PathVariable("productId") Integer productId) {
-        if (null == productId) {
+    @PostMapping("/saveSvipProduct")
+    public ResponseJson saveSvipProduct(@RequestBody CmSvipProduct cmSvipProduct) {
+        if (null == cmSvipProduct.getProductId()) {
             return ResponseJson.error(-1, "商品id为空", null);
         }
-        return historyService.saveSvipProduct(productId);
+        return historyService.saveSvipProduct(cmSvipProduct);
     }
 
     /**

+ 37 - 0
src/main/java/com/caimei365/manager/dao/svip/CmSvipHistoryDao.java

@@ -94,6 +94,7 @@ public interface CmSvipHistoryDao {
     void updateAssociateByDelFlag(String couponId);
 
     void updateVipCouponMonth(CmVipCoupon cmVipCoupon);
+    void insertVipCouponMonth(CmVipCoupon cmVipCoupon);
 
     void deleteByMonthId(String montId);
 
@@ -116,8 +117,44 @@ public interface CmSvipHistoryDao {
      */
     List<CmVipCoupon> findCouponList(CmVipCoupon cmVipCoupon);
 
+    List<CmCouponAssociate> findByProductType(String couponId);
+
+    NewCmShop getShopInfoByShopId(Integer shopId);
+
     List<String> getBindCoupons(String montId);
 
+    /**
+     * 专属优惠券配置
+     * @return
+     */
+    List<CmCoupon> selconfigure();
+
+    /**
+     * 获取专属优惠券时间
+     * @return
+     */
+    CmVipCoupon selMonthTime();
+
+    /**
+     * 新增vip优惠券月份关系
+     * @param relation
+     */
+    void insertVipCouponRelation(CmVipCouponRelation relation);
+
+    /**
+     * 删除优惠券
+     * @param id
+     */
+    void delCoupon(@Param("id") Integer id);
+    void delSvipCoupon(@Param("id") Integer id);
+    void delSvipProduct(@Param("id") Integer id);
+
+    /**
+     * 修改vip优惠券月份关系
+     * @param relation
+     */
+    /*void updateVipCouponRelation(CmVipCouponRelation relation);*/
+
     List<CmCoupon> getCouponListByIds(@Param("bindCoupons") List<String> bindCoupons,@Param("couponType") String couponType,@Param("status") String status);
 
     /**

+ 4 - 0
src/main/java/com/caimei365/manager/entity/caimei/svip/CmCoupon.java

@@ -173,4 +173,8 @@ public class CmCoupon {
      * 删除标记
      */
     private String delFlag;
+    /**
+     * 商品回显
+     */
+    private List<CmCouponAssociate> associateList;
 }

+ 2 - 2
src/main/java/com/caimei365/manager/entity/caimei/svip/CmCouponAssociate.java

@@ -49,11 +49,11 @@ public class CmCouponAssociate {
     /**
      * 商品名称
      */
-    private String productName;
+    private String name;
     /**
      * 商品图片
      */
-    private String image;
+    private String mainImage;
     /**
      * 供应商名称
      */

+ 4 - 0
src/main/java/com/caimei365/manager/entity/caimei/svip/CmVipCoupon.java

@@ -35,4 +35,8 @@ public class CmVipCoupon {
     private String endDate;
     /** 优惠券类型 */
     private String couponType;
+    /**
+     * 专属优惠券配置 1是、0否
+     */
+    private Integer configure;
 }

+ 29 - 0
src/main/java/com/caimei365/manager/entity/caimei/svip/CmVipCouponRelation.java

@@ -0,0 +1,29 @@
+package com.caimei365.manager.entity.caimei.svip;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/4/18
+ */
+@Data
+public class CmVipCouponRelation {
+
+    private Integer id;
+    /**
+     * 优惠券id
+     */
+    private String couponId;
+    /**
+     * 优惠券id
+     */
+    private String montId;
+    private Date updateTime;
+    private String delFlag;
+}

+ 33 - 0
src/main/java/com/caimei365/manager/entity/caimei/svip/SvipCouponForm.java

@@ -0,0 +1,33 @@
+package com.caimei365.manager.entity.caimei.svip;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/4/18
+ */
+@Data
+public class SvipCouponForm {
+
+    private String id;
+    /**
+     * 月份
+     */
+    private String month;
+    /**
+     * 结束时间
+     */
+    private String endMonth;
+    /**
+     * 专属优惠券配置  1是、0否
+     */
+    private Integer configure;
+
+    private String status;
+
+    private ArrayList<CmCoupon> coupons;
+}

+ 19 - 4
src/main/java/com/caimei365/manager/service/caimei/svip/CmSvipHistoryService.java

@@ -61,10 +61,25 @@ public interface CmSvipHistoryService {
 
     /**
      * 编辑超级会员优惠券
-     * @param cmVipCoupon
+     * @param id
+     * @param configure
+     * @return
+     */
+    ResponseJson<Map<String, Object>> cmVipCouponForm(Integer id,Integer configure);
+
+    /**
+     * 保存超级会员优惠券
+     * @param svipcouponForm
+     * @return
+     */
+    ResponseJson saveVipCoupon(SvipCouponForm svipcouponForm);
+
+    /**
+     * 删除优惠券
+     * @param id
      * @return
      */
-    Map<String, Object> cmVipCouponForm(CmVipCoupon cmVipCoupon);
+    ResponseJson delCoupon(Integer id);
 
     /**
      * 关闭超级会员专属优惠券
@@ -129,10 +144,10 @@ public interface CmSvipHistoryService {
 
     /**
      * 保存超级会员商品
-     * @param productId
+     * @param cmSvipProduct
      * @return
      */
-    ResponseJson saveSvipProduct(Integer productId);
+    ResponseJson saveSvipProduct(CmSvipProduct cmSvipProduct);
 
     /**
      * 删除超级会员商品

+ 2 - 2
src/main/java/com/caimei365/manager/service/caimei/svip/impl/CmCouponService.java

@@ -69,8 +69,8 @@ public class CmCouponService {
         List<Integer> associateIds = historyDao.findByCouponId(cmCoupon.getId());
         if (0 == cmCoupon.getCouponType()) {
             //活动券
-            if (StringUtils.isNotBlank(cmCoupon.getProductInfo())) {
-                List<CmCouponAssociate> associateList = JSON.parseArray(cmCoupon.getProductInfo(), CmCouponAssociate.class);
+            if (null != cmCoupon.getAssociateList()) {
+                List<CmCouponAssociate> associateList = cmCoupon.getAssociateList();
                 associateList.forEach(a -> {
                     if (a.getId() == null) {
                         a.setDelFlag("0");

+ 245 - 13
src/main/java/com/caimei365/manager/service/caimei/svip/impl/CmSvipHistoryServiceImpl.java

@@ -3,7 +3,7 @@ package com.caimei365.manager.service.caimei.svip.impl;
 import com.caimei.utils.AppUtils;
 import com.caimei.utils.MathUtil;
 import com.caimei.utils.StringUtil;
-import com.caimei.utils.StringUtils;
+import com.caimei365.manager.config.utils.DateUtil;
 import com.caimei365.manager.config.utils.UploadPicUtils;
 import com.caimei365.manager.dao.svip.CmSvipHistoryDao;
 import com.caimei365.manager.entity.PaginationVo;
@@ -16,6 +16,7 @@ import com.caimei365.manager.service.SendSmsService;
 import com.caimei365.manager.service.caimei.svip.CmSvipHistoryService;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -252,19 +253,234 @@ public class CmSvipHistoryServiceImpl implements CmSvipHistoryService {
 
     /**
      * 编辑超级会员优惠券
-     *
-     * @param cmVipCoupon
+     * @param id
+     * @param configure
      * @return
      */
     @Override
-    public Map<String, Object> cmVipCouponForm(CmVipCoupon cmVipCoupon) {
+    public ResponseJson<Map<String, Object>> cmVipCouponForm(Integer id,Integer configure) {
         Map<String, Object> map = new HashMap<>();
-//        SvipCouponForm svipcouponForm = cmVipCouponService.setSvipcouponForms(cmVipCoupon);
-        List<String> useDateList = historyDao.getAllUseDateList();
-//        map.put("svipcouponForm", svipcouponForm);
-        map.put("useDateList", useDateList);
+        CmVipCoupon vipCoupon = null;
+        List<CmCoupon> couponList = null;
+        // 初始化优惠券信息
+        SvipCouponForm svipcouponForm = new SvipCouponForm();
+        if ( 1 == configure) {
+            // 专属优惠券配置
+            couponList = historyDao.selconfigure();
+            // 专属优惠券配置
+            CmVipCoupon cmVipCoupon = historyDao.selMonthTime();
+            // 开始时间
+            if (null != cmVipCoupon) {
+                svipcouponForm.setMonth(cmVipCoupon.getUseTime());
+                svipcouponForm.setId(cmVipCoupon.getId());
+            }
+        } else {
+            // 编辑优惠券
+            if (null == id) {
+                return ResponseJson.error(-1,"id不能为空",null);
+            }
+            vipCoupon = get(id.toString());
+            if (null != vipCoupon.getCouponList()) {
+                couponList = vipCoupon.getCouponList();
+            }
+            // 开始时间
+            svipcouponForm.setId(id.toString());
+            svipcouponForm.setMonth(vipCoupon.getUseTime());
+            svipcouponForm.setEndMonth(vipCoupon.getEndTime());
+            List<String> useDateList = historyDao.getAllUseDateList();
+            map.put("useDateList", useDateList);
+        }
+        ArrayList<CmCoupon> arr = new ArrayList<>();
+        // 设置券信息
+        if (null != couponList){
+            for (int i = 0; i < couponList.size(); i++) {
+                CmCoupon cmCoupon = new CmCoupon();
+                cmCoupon.setId(couponList.get(i).getId());
+                cmCoupon.setCouponAmount(couponList.get(i).getCouponAmount());
+                cmCoupon.setTouchPrice(couponList.get(i).getTouchPrice());
+                cmCoupon.setCouponType(couponList.get(i).getCouponType());
+                cmCoupon.setCategoryType(couponList.get(i).getCategoryType());
+                cmCoupon.setProductType(couponList.get(i).getProductType());
+                cmCoupon.setShopId(couponList.get(i).getShopId());
+                if (couponList.get(i).getCouponType() == 0) {
+                    // 活动券,查询活动商品
+                    if ("2".equals(couponList.get(i).getProductType())) {
+                        List<CmCouponAssociate> associateList = findByProductType(couponList.get(i));
+                        if (associateList.size() > 0) {
+                            cmCoupon.setAssociateList(associateList);
+                        } else {
+                            cmCoupon.setAssociateList(new ArrayList<>());
+                        }
+                    } else {
+                        cmCoupon.setAssociateList(new ArrayList<>());
+                    }
+                }
+                if (couponList.get(i).getCouponType() == 3) {
+                    // 店铺券
+                    NewCmShop shop = historyDao.getShopInfoByShopId(couponList.get(i).getShopId());
+                    cmCoupon.setShopName(shop.getName());
+                    cmCoupon.setShop(shop);
+                }
+                arr.add(cmCoupon);
+            }
+
+        }
+        svipcouponForm.setCoupons(arr);
+        map.put("svipcouponForm", svipcouponForm);
+
+        return ResponseJson.success(map);
+    }
+
+    public List<CmCouponAssociate> findByProductType(CmCoupon cmCoupon) {
+        List<CmCouponAssociate> associateList = historyDao.findByProductType(cmCoupon.getId());
+        if (associateList != null && associateList.size() > 0) {
+            associateList.forEach(item -> {
+                item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, "https://www.caimei365.com/"));
+            });
+        }
+        return associateList;
+    }
+
+    /**
+     * 保存超级会员优惠券
+     *
+     * @param svipcouponForm
+     * @return
+     */
+    @Override
+    public ResponseJson saveVipCoupon(SvipCouponForm svipcouponForm) {
+        CmVipCoupon cmVipCoupon = new CmVipCoupon();
+        cmVipCoupon.setId(svipcouponForm.getId());
+        if (1 == svipcouponForm.getConfigure()) {
+            cmVipCoupon.setUseTime(countMonth(new SimpleDateFormat("yyyy-MM").format(new Date())));
+            svipcouponForm.setMonth(new SimpleDateFormat("yyyy-MM").format(new Date()));
+            cmVipCoupon.setStatus("1");
+            cmVipCoupon.setDelFlag("1");
+        } else {
+            cmVipCoupon.setUseTime(svipcouponForm.getMonth());
+            cmVipCoupon.setStatus("1");
+            cmVipCoupon.setDelFlag("0");
+        }
+        cmVipCoupon.setUpdateTime(new Date());
+        setVipCouponStatus(cmVipCoupon);
+        // 解析 svipcouponForm -> 组装 CmCoupon 列表 保存
+        boolean flag = false;
+        if(StringUtils.isNotBlank(cmVipCoupon.getId())){
+            // 修改
+            historyDao.updateVipCouponMonth(cmVipCoupon);
+        } else {
+            // 新增
+            flag = true;
+            historyDao.insertVipCouponMonth(cmVipCoupon);
+        }
+        Date beginTime = DateUtil.getMinDay(svipcouponForm.getMonth());
+        // 结束时间为一个季度
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
+        Date dateMonth = null;
+        try {
+            dateMonth = dateFormat.parse(svipcouponForm.getMonth());
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(dateMonth);
+        calendar.add(Calendar.MONTH,2);
+        Date time = calendar.getTime();
+        String format = dateFormat.format(time);
+        Date endTime = DateUtil.getMaxDay(format);
+
+        /*
+         * 券信息
+         */
+        if (null != svipcouponForm.getCoupons()) {
+            List<CmCoupon> coupons = svipcouponForm.getCoupons();
+            coupons.forEach(cp -> {
+                cp.setName("超级会员优惠券"+svipcouponForm.getMonth());
+                cp.setStartDate(beginTime);
+                cp.setEndDate(endTime);
+                cp.setStatus("1");
+                cp.setDelFlag("0");
+                cp.setVipFlag(1);
+                if (1 == svipcouponForm.getConfigure()) {
+                    cp.setConfigure(1);
+                }
+                // 0活动券 1品类券 3店铺券
+                if (0 == cp.getCouponType()){
+                    cp.setCouponType(0);
+//                    cp.setProductType(svipcouponForm.getProductType1());
+                    if ("2".equals(cp.getProductType())){
+                        // 指定商品
+                        cp.setProductInfo(cp.getProductInfo());
+                    }
+                } else if (1==cp.getCouponType()) {
+                    cp.setCategoryType(cp.getCategoryType());
+                    cp.setCouponType(1);
+                } else if (3==cp.getCouponType()) {
+                    cp.setShopId(cp.getShopId());
+                    cp.setCouponType(3);
+                }
 
-        return map;
+                cmCouponService.save(cp);
+
+            });
+        }
+        /*coupon1.setName("超级会员优惠券"+svipcouponForm.getMonth());
+        coupon1.setStartDate(beginTime);
+        coupon1.setEndDate(endTime);
+        coupon1.setCouponAmount(svipcouponForm.getCouponAmount1());
+        coupon1.setTouchPrice(svipcouponForm.getTouchPrice1());
+        coupon1.setStatus("1");
+        coupon1.setVipFlag(1);
+        // 0活动券 1品类券 3店铺券
+        if ("0".equals(svipcouponForm.getCouponType1())){
+            coupon1.setCouponType(0);
+            coupon1.setProductType(svipcouponForm.getProductType1());
+            if ("2".equals(svipcouponForm.getProductType1())){
+                // 指定商品
+                coupon1.setProductInfo(svipcouponForm.getProductInfo1());
+            }
+        } else if ("1".equals(svipcouponForm.getCouponType1())) {
+            coupon1.setCategoryType(svipcouponForm.getCategoryType1());
+            coupon1.setCouponType(1);
+        } else if ("3".equals(svipcouponForm.getCouponType1())) {
+            coupon1.setShopId(svipcouponForm.getShopId1());
+            coupon1.setCouponType(3);
+        }*/
+        /*
+         * vip优惠券月份关系
+         */
+        CmVipCouponRelation relation = new CmVipCouponRelation();
+        for (int i = 0; i < svipcouponForm.getCoupons().size() ; i++) {
+            relation.setMontId(cmVipCoupon.getId());
+            relation.setCouponId(svipcouponForm.getCoupons().get(i).getId());
+            relation.setUpdateTime(new Date());
+            relation.setDelFlag("0");
+            if (flag) {
+                // 新增
+                historyDao.insertVipCouponRelation(relation);
+            }
+            /*else {
+                // 修改
+                historyDao.updateVipCouponRelation(relation);
+            }*/
+        }
+
+
+        return ResponseJson.success();
+    }
+
+    /**
+     * 删除优惠券
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public ResponseJson delCoupon(Integer id) {
+        historyDao.delCoupon(id);
+        historyDao.delSvipCoupon(id);
+        historyDao.delSvipProduct(id);
+        return ResponseJson.success();
     }
 
     /**
@@ -448,13 +664,12 @@ public class CmSvipHistoryServiceImpl implements CmSvipHistoryService {
     /**
      * 保存超级会员商品
      *
-     * @param productId
+     * @param cmSvipProduct
      * @return
      */
     @Override
-    public ResponseJson saveSvipProduct(Integer productId) {
-        CmSvipProduct cmSvipProduct = new CmSvipProduct();
-        cmSvipProduct.setProductId(productId);
+    public ResponseJson saveSvipProduct(CmSvipProduct cmSvipProduct) {
+        cmSvipProduct.setProductId(cmSvipProduct.getProductId());
         //保存/修改同步处理cm_svip_product_sku表数据
         if (null == cmSvipProduct.getId()) {
             cmSvipProduct.setSort(1);
@@ -698,4 +913,21 @@ public class CmSvipHistoryServiceImpl implements CmSvipHistoryService {
         cmVipCoupon.setEndDate(endDate);
         return cmVipCoupon;
     }
+    public String countMonth(String countMonth) {
+        String year = countMonth.substring(0,countMonth.length() - 2);
+        String month = countMonth.substring(countMonth.length() - 2);
+        if (month.equals("02") || month.equals("03") || month.equals("04")) {
+            month = "02";
+        }
+        if (month.equals("05") || month.equals("06") || month.equals("07")) {
+            month = "05";
+        }
+        if (month.equals("08") || month.equals("09") || month.equals("10")) {
+            month = "08";
+        }
+        if (month.equals("11") || month.equals("12") || month.equals("1")) {
+            month = "11";
+        }
+        return year + month;
+    }
 }

+ 14 - 3
src/main/java/com/caimei365/manager/service/caimei/user/impl/CmBehaviorRecordServiceImpl.java

@@ -94,8 +94,16 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
             }
         }
         cmBehaviorRecord.setLabels(labels);
-        List<CmBehaviorRecord> listToday = cmBehaviorRecordDao.findListToday(cmBehaviorRecord);
-        listToday.forEach(t -> {
+
+        List<CmBehaviorRecord> list = null;
+        if (cmBehaviorRecord.getTodayType() == 0) {
+            // 当天数据
+            list = cmBehaviorRecordDao.findListToday(cmBehaviorRecord);
+        } else {
+            // 过往数据
+            list = cmBehaviorRecordDao.findList(cmBehaviorRecord);
+        }
+        list.forEach(t -> {
             if ("0".equals(t.getAccessClient())) {
                 t.setAccessClient("网站");
             } else {
@@ -109,8 +117,11 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
             } else {
                 t.setAccessClient("供应商");
             }
+            // 总时长
+            String time = calculationTime(t.getAccessDuration());
+            t.setAccessDuration(time);
         });
-        return listToday;
+        return list;
     }
 
     /**

+ 72 - 0
src/main/resources/mapper/svip/CmSvipHistoryDao.xml

@@ -384,6 +384,10 @@
         UPDATE cm_svip_coupon_month SET useTime=#{useTime}, updateTime=#{updateTime}, status=#{status}, delFlag=#{delFlag}
         WHERE id=#{id}
     </update>
+    <insert id="insertVipCouponMonth" parameterType="com.caimei365.manager.entity.caimei.svip.CmVipCoupon" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO cm_svip_coupon_month (useTime, updateTime, status,delFlag)
+        VALUES (#{useTime}, #{updateTime}, #{status}, #{delFlag})
+    </insert>
     <delete id="deleteByMonthId">
         UPDATE cm_svip_coupon SET delFlag=1 WHERE montId = #{montId}
     </delete>
@@ -542,6 +546,74 @@
         </where>
         ORDER BY cs.useTime DESC
     </select>
+    <select id="findByProductType" resultType="com.caimei365.manager.entity.caimei.svip.CmCouponAssociate">
+        SELECT
+            cca.id,
+            cca.couponId,
+            cca.productId,
+            cca.pcStatus,
+            cca.appletsStatus,
+            cca.sort,
+            cca.addTime,
+            cca.delFlag,
+            s.name AS shopName,
+            p.name,
+            p.mainImage
+        FROM
+            cm_coupon_product cca
+                LEFT JOIN product p ON cca.productId = p.productID
+                LEFT JOIN shop s ON p.shopID = s.shopID
+        WHERE
+            cca.couponId = #{couponId}
+          AND delFlag = 0
+        ORDER BY
+            - sort DESC
+    </select>
+    <select id="getShopInfoByShopId" resultType="com.caimei365.manager.entity.caimei.svip.NewCmShop">
+        SELECT
+            s.shopID,
+            s.userID,
+            IFNULL(s.name, u.name) AS name,
+            IFNULL(s.sname, u.realName) AS sname,
+            IFNULL(s.contractMobile, u.bindMobile) AS contractMobile,
+            IFNULL(s.linkMan, u.userName) AS linkMan
+        FROM shop s
+                 LEFT JOIN USER u ON u.`shopID` = s.`shopID`
+        WHERE s.shopID = #{shopId}
+        LIMIT 1
+    </select>
+    <select id="selconfigure" resultType="com.caimei365.manager.entity.caimei.svip.CmCoupon">
+        SELECT <include refid="cmCouponColumns"/> FROM cm_coupon a WHERE delFlag = 0 and configure = 1
+    </select>
+    <select id="selMonthTime" resultType="com.caimei365.manager.entity.caimei.svip.CmVipCoupon">
+        SELECT cscm.useTime, cscm.id
+        FROM cm_coupon a
+         LEFT JOIN cm_svip_coupon csc ON a.id = csc.couponId
+         LEFT JOIN cm_svip_coupon_month cscm ON csc.montId = cscm.id WHERE a.delFlag = 0 AND a.configure = 1 LIMIT 1
+    </select>
+    <insert id="insertVipCouponRelation">
+        INSERT INTO cm_svip_coupon (couponId, montId, updateTime, delFlag)
+        VALUES (#{couponId}, #{montId}, #{updateTime}, #{delFlag})
+    </insert>
+    <!--<update id="updateVipCouponRelation">
+        UPDATE cm_svip_coupon SET couponId=#{couponId}, montId=#{montId}, updateTime=#{updateTime}, delFlag=#{delFlag}
+        WHERE id=#{id}
+    </update>-->
+    <update id="delCoupon">
+        update cm_coupon
+        set delFlag = 1
+        where id = #{id}
+    </update>
+    <update id="delSvipCoupon">
+        update cm_svip_coupon
+        set delFlag = 1
+        where id = #{id}
+    </update>
+    <update id="delSvipProduct">
+        update cm_coupon_product
+        set delFlag = 1
+        where id = #{id}
+    </update>
     <select id="getBindCoupons" resultType="java.lang.String">
         SELECT couponId from cm_svip_coupon  WHERE montId = #{montId} AND delFlag=0
     </select>