소스 검색

添加优惠券日志接口

liu 1 년 전
부모
커밋
7258c7ee7c

+ 6 - 0
db/insert_241014.sql

@@ -0,0 +1,6 @@
+-- 创建站点表
+CREATE TABLE rider_station
+(
+    id           INT PRIMARY KEY,
+    station_name VARCHAR(100)
+);

+ 19 - 0
db/insert_241021.sql

@@ -0,0 +1,19 @@
+DROP TABLE IF EXISTS `tb_coupon_log`;
+CREATE TABLE `tb_coupon_log`
+(
+    `id`                 int(11) NOT NULL AUTO_INCREMENT,
+    `coupon_id`          int(11) NULL DEFAULT NULL COMMENT '优惠券id',
+    `content`            varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '内容',
+    `create_time`        datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
+    `create_sys_user_id` int(11) NULL DEFAULT NULL COMMENT '创建人',
+    `coupon_name`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券名称',
+    `coupon_picture`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券图片',
+    `end_date`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '有效期天数',
+    `min_money`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券可使用订单最低金额',
+    `goods_type`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '优惠券可使用商品类型',
+    `need_integral`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '购买此优惠券需要积分数',
+    `money`              decimal(10, 2) NULL DEFAULT NULL COMMENT '优惠券金额',
+    `shop_id`            int(11) NULL DEFAULT NULL COMMENT '所属商铺 0为总后台发布的优惠券',
+    `state`              int(11) NULL DEFAULT NULL COMMENT '状态:0-待审核,1-发布,2-撤销',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

+ 1 - 1
src/main/java/com/sqx/modules/app/entity/UserMoneyDetails.java

@@ -125,7 +125,7 @@ public class UserMoneyDetails implements Serializable {
      * 订单号
      */
     @TableField(exist = false)
-    private BigDecimal orderNumber;
+    private String orderNumber;
 
     /**
      * 订单号

+ 2 - 3
src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java

@@ -175,7 +175,7 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao
             TbIndent tbIndent = tbIndentService.getOne(wrapperTBI);
             if (ObjectUtils.isNotEmpty(tbIndent)) {
                 wrapper.eq(TbIndentSmsSendLog::getSuccessFlag,"1");
-                wrapper.eq(TbIndentSmsSendLog::getOrderId,tbIndent.getOrderId());
+                wrapper.eq(TbIndentSmsSendLog::getOrderId,tbIndent.getIndentId());
                 List<TbIndentSmsSendLog> list = smsSendLogService.list(wrapper);
                 Double smsMoneyTotal=smsMoney*list.size();
                 BigDecimal decimal = new BigDecimal(smsMoneyTotal).setScale(2, BigDecimal.ROUND_DOWN);
@@ -201,8 +201,7 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao
 //        总数
         iPage.setTotal(total);
         PageUtils pageUtils = new PageUtils(iPage);
-        List<?> list = pageUtils.getList();
-        System.out.println("list = " + list);
+
         return pageUtils;
     }
 

+ 3 - 3
src/main/java/com/sqx/modules/coupon/controller/CouponController.java

@@ -53,10 +53,10 @@ public class CouponController extends AbstractController {
     }
 
     @ApiOperation("删除发布的优惠券")
-    @PostMapping(value = "deleteCoupon")
-    public Result deleteCoupon(Long couponId){
+        @PostMapping(value = "deleteCoupon")
+    public Result deleteCoupon(Long couponId,Integer sysUserId){
 
-        return tbCouponService.deleteCoupon(couponId);
+        return tbCouponService.deleteCoupon(couponId,sysUserId);
     }
 
     @ApiOperation("修改优惠券信息")

+ 26 - 0
src/main/java/com/sqx/modules/coupon/controller/CouponLogController.java

@@ -0,0 +1,26 @@
+package com.sqx.modules.coupon.controller;
+
+import com.sqx.common.utils.Result;
+import com.sqx.modules.coupon.service.TbCouponLogService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@Api(value = "管理端-优惠券记录", tags = {"管理端-优惠券记录"})
+@RequestMapping(value = "/admin/couponLog")
+public class CouponLogController {
+
+    @Autowired
+    private TbCouponLogService tbCouponLogService;
+
+
+    @ApiOperation("查看优惠券日志记录")
+    @GetMapping(value = "selectCouponLog")
+    public Result selectCouponLog(Integer page, Integer limit){
+        return tbCouponLogService.selectCouponLog(page, limit);
+    }
+}

+ 13 - 0
src/main/java/com/sqx/modules/coupon/dao/TbCouponLogDao.java

@@ -0,0 +1,13 @@
+package com.sqx.modules.coupon.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sqx.modules.coupon.entity.TbCoupon;
+import com.sqx.modules.coupon.entity.TbCouponLog;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface TbCouponLogDao extends BaseMapper<TbCouponLog> {
+    IPage<TbCouponLog> selectCouponLogPage(Page<TbCouponLog> pages);
+}

+ 66 - 0
src/main/java/com/sqx/modules/coupon/entity/TbCouponLog.java

@@ -0,0 +1,66 @@
+package com.sqx.modules.coupon.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class TbCouponLog {
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.AUTO)
+
+    @ApiModelProperty("平台优惠券记录表")
+    private Long id;
+
+    @ApiModelProperty("优惠券id")
+    private Long couponId;
+
+    @ApiModelProperty("内容")
+    private String content;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+
+    @ApiModelProperty("创建人")
+    private Integer createSysUserId;
+
+    @ApiModelProperty("优惠券名称")
+    private String couponName;
+
+    @ApiModelProperty("优惠券图片")
+    private String couponPicture;
+
+    @ApiModelProperty("有效期天数")
+    private Integer endDate;
+
+    @ApiModelProperty("优惠券可使用订单最低金额")
+    private BigDecimal minMoney;
+
+    @ApiModelProperty("优惠券可使用商品类型")
+    private String goodsType;
+
+    @ApiModelProperty("购买此优惠券需要积分数")
+    private Integer needIntegral;
+
+
+    @ApiModelProperty("优惠券金额")
+    private BigDecimal money;
+
+
+    @ApiModelProperty("所属商铺 0为总后台发布的优惠券")
+    private Long shopId;
+
+    @ApiModelProperty("状态:0-待审核,1-发布,2-撤销")
+    private Integer state;
+
+    @ApiModelProperty("用户名")
+    @TableField(exist = false)
+    private String username;
+
+}

+ 9 - 0
src/main/java/com/sqx/modules/coupon/service/TbCouponLogService.java

@@ -0,0 +1,9 @@
+package com.sqx.modules.coupon.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.sqx.common.utils.Result;
+import com.sqx.modules.coupon.entity.TbCouponLog;
+
+public interface TbCouponLogService extends IService<TbCouponLog> {
+    Result selectCouponLog(Integer page, Integer limit);
+}

+ 1 - 1
src/main/java/com/sqx/modules/coupon/service/TbCouponService.java

@@ -11,7 +11,7 @@ public interface TbCouponService extends IService<TbCoupon> {
 
     Result issueCoupon(TbCoupon tbCoupon);
 
-    Result deleteCoupon(Long couponId);
+    Result deleteCoupon(Long couponId,Integer sysUserId);
 
     Result seleteAllCoupon(Integer page, Integer limit,Long shopId,String shopName);
 

+ 27 - 0
src/main/java/com/sqx/modules/coupon/service/impl/TbCouponLogServiceImpl.java

@@ -0,0 +1,27 @@
+package com.sqx.modules.coupon.service.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sqx.common.utils.PageUtils;
+import com.sqx.common.utils.Result;
+import com.sqx.modules.coupon.dao.TbCouponLogDao;
+import com.sqx.modules.coupon.entity.TbCoupon;
+import com.sqx.modules.coupon.entity.TbCouponLog;
+import com.sqx.modules.coupon.service.TbCouponLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class TbCouponLogServiceImpl extends ServiceImpl<TbCouponLogDao,TbCouponLog> implements TbCouponLogService {
+
+    @Autowired
+    private TbCouponLogDao tbCouponLogDao;
+
+    @Override
+    public Result selectCouponLog(Integer page, Integer limit) {
+        Page<TbCouponLog> pages = new Page<>(page, limit);
+        PageUtils pageUtils = new PageUtils(tbCouponLogDao.selectCouponLogPage(pages));
+        return Result.success().put("data", pageUtils);
+
+    }
+}

+ 77 - 11
src/main/java/com/sqx/modules/coupon/service/impl/TbCouponServiceImpl.java

@@ -11,11 +11,16 @@ import com.sqx.common.utils.Result;
 import com.sqx.modules.coupon.dao.TbCouponDao;
 import com.sqx.modules.coupon.dao.TbCouponUserDao;
 import com.sqx.modules.coupon.entity.TbCoupon;
+import com.sqx.modules.coupon.entity.TbCouponLog;
+import com.sqx.modules.coupon.service.TbCouponLogService;
 import com.sqx.modules.coupon.service.TbCouponService;
 import com.sqx.modules.datacentre.entity.SysUserShop;
+import com.sqx.modules.sys.entity.SysUserEntity;
 import com.sqx.modules.sys.entity.SysUserRoleEntity;
 import com.sqx.modules.sys.service.SysUserRoleService;
+import com.sqx.modules.sys.service.SysUserService;
 import org.checkerframework.checker.units.qual.A;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -36,6 +41,12 @@ public class TbCouponServiceImpl extends ServiceImpl<TbCouponDao, TbCoupon> impl
     @Autowired
     private SysUserRoleService sysUserRoleService;
 
+    @Autowired
+    private TbCouponLogService tbCouponLogService;
+
+    @Autowired
+    private SysUserService sysUserService;
+
     @Override
     public Result seleteAllCoupon(Integer page, Integer limit,Long shopId,String shopName) {
         if(page == null || limit==null){
@@ -51,25 +62,53 @@ public class TbCouponServiceImpl extends ServiceImpl<TbCouponDao, TbCoupon> impl
 
     @Override
     public Result issueCoupon(TbCoupon tbCoupon) {
-        Integer sysUserId = tbCoupon.getSysUserId();
+        Long shopId = tbCoupon.getShopId();
+        if (shopId==0) {
+            Integer sysUserId = tbCoupon.getSysUserId();
 //        判断是否是超级管理员
-        LambdaQueryWrapper<SysUserRoleEntity> wrapper=new LambdaQueryWrapper<>();
-        wrapper.eq(SysUserRoleEntity::getRoleId,3)
-                        .eq(SysUserRoleEntity::getUserId,sysUserId);
-        SysUserRoleEntity sysUserRoleEntity = sysUserRoleService.getOne(wrapper);
-        if (ObjectUtils.isEmpty(sysUserRoleEntity)) {
-            tbCoupon.setState(0);
+            LambdaQueryWrapper<SysUserRoleEntity> wrapper=new LambdaQueryWrapper<>();
+            wrapper.eq(SysUserRoleEntity::getRoleId,3)
+                    .eq(SysUserRoleEntity::getUserId,sysUserId);
+            SysUserRoleEntity sysUserRoleEntity = sysUserRoleService.getOne(wrapper);
+            if (ObjectUtils.isEmpty(sysUserRoleEntity)) {
+                tbCoupon.setState(0);
+            }else {
+                tbCoupon.setState(1);
+            }
+            tbCoupon.setDeleteFlag(0);
+            tbCouponDao.insert(tbCoupon);
+
+            TbCouponLog tbCouponLog = new TbCouponLog();
+            BeanUtils.copyProperties(tbCoupon,tbCouponLog);
+            tbCouponLog.setContent("添加优惠券");
+            tbCouponLog.setCreateTime(new Date());
+            tbCouponLog.setCreateSysUserId(sysUserId);
+            tbCouponLogService.save(tbCouponLog);
+
         }else {
-            tbCoupon.setState(1);
+            tbCoupon.setDeleteFlag(0);
+            tbCouponDao.insert(tbCoupon);
         }
 
-        tbCoupon.setDeleteFlag(0);
-        tbCouponDao.insert(tbCoupon);
+
         return Result.success();
     }
 
     @Override
     public Result updateCoupon(TbCoupon tbCoupon) {
+        Long shopId = tbCoupon.getShopId();
+        if (shopId==0) {
+            Integer sysUserId = tbCoupon.getSysUserId();
+
+            TbCouponLog tbCouponLog = new TbCouponLog();
+            BeanUtils.copyProperties(tbCoupon,tbCouponLog);
+            tbCouponLog.setContent("修改优惠券");
+            tbCouponLog.setCreateTime(new Date());
+            tbCouponLog.setCreateSysUserId(sysUserId);
+            tbCouponLogService.save(tbCouponLog);
+
+        }
+
         tbCouponDao.updateById(tbCoupon);
         return Result.success();
     }
@@ -128,6 +167,18 @@ public class TbCouponServiceImpl extends ServiceImpl<TbCouponDao, TbCoupon> impl
         }
         tbCoupon.setState(state);
         tbCouponDao.updateById(tbCoupon);
+
+        TbCouponLog tbCouponLog = new TbCouponLog();
+        BeanUtils.copyProperties(tbCoupon,tbCouponLog);
+        if (state==1) {
+            tbCouponLog.setContent("发布优惠券");
+        }else {
+            tbCouponLog.setContent("撤销优惠券");
+        }
+        tbCouponLog.setCreateTime(new Date());
+        tbCouponLog.setCreateSysUserId(sysUserId);
+        tbCouponLogService.save(tbCouponLog);
+
         return Result.success();
     }
 
@@ -150,10 +201,25 @@ public class TbCouponServiceImpl extends ServiceImpl<TbCouponDao, TbCoupon> impl
     }
 
     @Override
-    public Result deleteCoupon(Long couponId) {
+    public Result deleteCoupon(Long couponId,Integer sysUserId) {
+        TbCoupon tbCoupon = tbCouponDao.selectById(couponId);
+        if (ObjectUtils.isEmpty(tbCoupon)) {
+            return Result.error("无该优惠券");
+        }
+        Long shopId = tbCoupon.getShopId();
+        if (shopId==0) {
+            TbCouponLog tbCouponLog = new TbCouponLog();
+            BeanUtils.copyProperties(tbCoupon,tbCouponLog);
+            tbCouponLog.setContent("删除优惠券");
+            tbCouponLog.setCreateTime(new Date());
+            tbCouponLog.setCreateSysUserId(sysUserId);
+            tbCouponLogService.save(tbCouponLog);
+
+        }
         tbCouponDao.deleteById(couponId);
         return Result.success();
     }
 
 
+
 }

+ 0 - 4
src/main/java/com/sqx/modules/order/entity/TbOrder.java

@@ -282,10 +282,6 @@ public class TbOrder implements Serializable {
     @ApiModelProperty("站点名称")
     private String stationName;
 
-    @ApiModelProperty("是否发送成功 1发送成功 0发送失败")
-    @TableField(exist = false)
-    private String successFlag;
-
     @ApiModelProperty("超时时间")
     private Long timeOut;
 

+ 0 - 20
src/main/java/com/sqx/modules/order/service/impl/AppAppOrderServiceImpl.java

@@ -1493,26 +1493,6 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     @Override
     public Result selectOrderById(Long orderId) {
         TbOrder tbOrder = appOrderDao.selectByOrderId(orderId);
-//        短信的orderId对应骑手订单id
-        LambdaQueryWrapper<TbIndent> wrapperTBI=new LambdaQueryWrapper<>();
-        wrapperTBI.eq(TbIndent::getOrderId,tbOrder.getOrderId());
-        TbIndent tbIndent = tbIndentService.getOne(wrapperTBI);
-        if (ObjectUtils.isNotEmpty(tbIndent)) {
-            //        只能单独去搜索短信发送结果
-            LambdaQueryWrapper<TbIndentSmsSendLog> wrapper=new LambdaQueryWrapper<>();
-            wrapper.eq(TbIndentSmsSendLog::getOrderId,tbIndent.getIndentId())
-                    .eq(TbIndentSmsSendLog::getSuccessFlag,"1");
-            List<TbIndentSmsSendLog> list = smsSendLogService.list(wrapper);
-            //        只要有发送成功记录就是成功
-            if (list.size()>0) {
-                tbOrder.setSuccessFlag("1");
-            }else {
-                tbOrder.setSuccessFlag("0");
-            }
-        }else {
-            tbOrder.setSuccessFlag("0");
-        }
-
 
         int i = appOrderDao.selectCountOrderByTime(tbOrder.getPayTime(), tbOrder.getShopId());
         tbOrder.setCountOrder(i);

+ 14 - 0
src/main/resources/mapper/coupon/TbCouponLogMapper.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sqx.modules.coupon.dao.TbCouponLogDao">
+
+    <select id="selectCouponLogPage" resultType="com.sqx.modules.coupon.entity.TbCouponLog">
+        SELECT
+            tcl.*,
+            su.username
+        FROM
+            `tb_coupon_log` tcl
+                LEFT JOIN sys_user su ON su.user_id = tcl.create_sys_user_id
+        ORDER BY create_time DESC
+    </select>
+</mapper>