Browse Source

Merge remote-tracking branch 'origin/developerB' into developer

huangzhiguo 2 years ago
parent
commit
badad6de1e

+ 14 - 0
src/main/java/com/caimei/modules/order/controller/OrganizeOrderController.java

@@ -200,4 +200,18 @@ public class OrganizeOrderController {
         }
         return JsonModel.newInstance().success(map);
     }
+
+    /**
+     * 保存支付凭证
+     * @param voucher
+     * @return
+     */
+    @PostMapping(value = "/saveVoucher")
+    public JsonModel saveVoucher(@RequestBody Voucher voucher) {
+        if (null == voucher.getOrderId()) {
+            return JsonModel.newInstance().error(-1,null,"订单Id不能为空");
+        }
+        newOrderService.saveVoucher(voucher);
+        return JsonModel.newInstance().success();
+    }
 }

+ 5 - 0
src/main/java/com/caimei/modules/order/dao/NewOrderDao.java

@@ -2,6 +2,7 @@ package com.caimei.modules.order.dao;
 
 import com.caimei.modules.order.entity.*;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
@@ -55,6 +56,10 @@ public interface NewOrderDao {
 
     List<String> findVocherImage(Integer id);
 
+    void insertVoucher(Voucher voucher);
+
+    void insertVoucherImage(@Param("voucherId") Integer voucherId, @Param("img") String img);
+
     Double findWaitPay(Integer orderId);
 
     Integer findCountDeliver(Integer orderId);

+ 2 - 0
src/main/java/com/caimei/modules/order/service/NewOrderService.java

@@ -16,4 +16,6 @@ public interface NewOrderService {
     ResponseJson checkReceipt(Double amount, Integer orderId);
 
     List<Voucher> findVoucher(Integer orderId);
+
+    void saveVoucher(Voucher voucher);
 }

+ 11 - 0
src/main/java/com/caimei/modules/order/service/impl/NewOrderServiceImpl.java

@@ -1,6 +1,7 @@
 package com.caimei.modules.order.service.impl;
 
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.caimei.modules.club.entity.Page;
 import com.caimei.modules.order.dao.*;
 import com.caimei.modules.order.entity.*;
@@ -133,4 +134,14 @@ public class NewOrderServiceImpl implements NewOrderService {
         voucher.forEach(v -> v.setImages(newOrderDao.findVocherImage(v.getId())));
         return voucher;
     }
+
+    @Override
+    public void saveVoucher(Voucher voucher) {
+        // 保存线下支付凭证记录
+        newOrderDao.insertVoucher(voucher);
+        // 保存线下支付凭证图
+        for (String str: voucher.getImages()) {
+            newOrderDao.insertVoucherImage(voucher.getId(), str);
+        }
+    }
 }

+ 93 - 0
src/main/java/com/caimei/modules/shiro/controller/MallUserController.java

@@ -0,0 +1,93 @@
+package com.caimei.modules.shiro.controller;
+
+import com.caimei.modules.club.entity.Page;
+import com.caimei.modules.shiro.dao.MallUserDao;
+import com.caimei.modules.shiro.entity.CmMallAdminUser;
+import com.caimei.modules.shiro.service.MallUserService;
+import com.caimei.utils.JsonModel;
+import com.caimei.utils.ResponseJson;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/5/25
+ */
+@RestController
+@RequestMapping("/other/user")
+public class MallUserController {
+
+    @Autowired private MallUserService mallUserService;
+    @Resource
+    private MallUserDao mallUserDao;
+
+    /**
+     * 后台用户列表
+     * @param page
+     * @param cmMallAdminUser
+     * @return
+     */
+    @GetMapping(value = "/getMallUserInfo")
+    public ResponseJson<Page<CmMallAdminUser>> getMallUserInfo(Page page, CmMallAdminUser cmMallAdminUser) {
+        Page<CmMallAdminUser> mallUserInfo = mallUserService.getMallUserInfo(page, cmMallAdminUser);
+        return ResponseJson.success(mallUserInfo);
+    }
+
+    /**
+     * 修改上下线状态
+     * @param status
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/updateUser")
+    public ResponseJson updateUser(Integer status, Integer id) {
+        if (null == status) {
+            return ResponseJson.error(-1,"状态不能为空",null);
+        }
+        if (null == id) {
+            return ResponseJson.error(-1,"用户Id不能为空",null);
+        }
+        mallUserService.updateUser(status, id);
+        return ResponseJson.success();
+    }
+    /**
+     * 用户信息回显
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/mallUserById/{id}")
+    public ResponseJson getMallUserById(@PathVariable("id") Integer id) {
+
+        CmMallAdminUser mallUserById = mallUserService.getMallUserById(id);
+        return ResponseJson.success(mallUserById);
+    }
+
+    /**
+     * 保存用户信息
+     * @param cmMallAdminUser
+     * @return
+     */
+    @PostMapping(value = "/saveUser")
+    public ResponseJson saveUser(CmMallAdminUser cmMallAdminUser) {
+        if (StringUtils.isEmpty(cmMallAdminUser.getPassword())) {
+            return ResponseJson.error(-1,"密码不能为空",null);
+        }
+        if (StringUtils.isEmpty(cmMallAdminUser.getOldPassword())) {
+            return ResponseJson.error(-1,"请确认密码",null);
+        }
+        if (!cmMallAdminUser.getPassword().equals(cmMallAdminUser.getOldPassword())) {
+            return ResponseJson.error(-1,"两次密码不一致",null);
+        }
+        Integer repeat = mallUserDao.getRepeat(cmMallAdminUser.getAccount(), null);
+        if (null != repeat) {
+            return ResponseJson.error(-1,"用户名已存在,请勿重复添加",null);
+        }
+        mallUserService.saveUser(cmMallAdminUser);
+        return ResponseJson.success();
+    }
+}

+ 54 - 0
src/main/java/com/caimei/modules/shiro/dao/MallUserDao.java

@@ -0,0 +1,54 @@
+package com.caimei.modules.shiro.dao;
+
+import com.caimei.modules.shiro.entity.CmMallAdminUser;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/5/25
+ */
+@Mapper
+public interface MallUserDao {
+    /**
+     * 后台用户集合
+     * @param cmMallAdminUser
+     * @return
+     */
+    List<CmMallAdminUser> getMallUserInfo(CmMallAdminUser cmMallAdminUser);
+
+    /**
+     * 获取用户信息
+     * @param id
+     * @return
+     */
+    CmMallAdminUser getMallUserById(@Param("id") Integer id);
+
+    /**
+     * 修改用户上下线
+     * @param status
+     * @param id
+     */
+    void updateUser(@Param("status") Integer status, @Param("id") Integer id);
+    /**
+     * 获取相同用户名的用户
+     * @return
+     */
+    Integer getRepeat(@Param("account") String account,@Param("id") String id);
+
+    /**
+     * 添加组织后台用户
+     * @param cmMallAdminUser
+     */
+    void insertMallUser(CmMallAdminUser cmMallAdminUser);
+
+    /**
+     * 修改组织后台用户
+     * @param cmMallAdminUser
+     */
+    void updateMallUser(CmMallAdminUser cmMallAdminUser);
+}

+ 36 - 0
src/main/java/com/caimei/modules/shiro/entity/CmMallAdminUser.java

@@ -8,13 +8,49 @@ import java.util.Set;
 @Data
 public class CmMallAdminUser {
     private Integer id;
+    /**
+     * 登录名
+     */
     private String account;
+    /**
+     * 账号名称
+     */
     private String accountName;
+    /**
+     * 密码
+     */
     private String password;
+    /**
+     * 组织Id
+     */
     private Integer organizeId;
+    /**
+     * 排序
+     */
     private String salt;
+    /**
+     * 添加时间
+     */
     private Date addTime;
+    /**
+     * 更新时间
+     */
     private Date updateTime;
     private Set<Role> roles;
+    /**
+     * 确认密码
+     */
     private String oldPassword;
+    /**
+     * 0 有效  其它无效
+     */
+    private String delFlag;
+    /**
+     * 人员类型:1 管理员 2普通人员
+     */
+    private Integer personnelType;
+    /**
+     * 状态 1 已上线 2 已下线
+     */
+    private Integer status;
 }

+ 39 - 0
src/main/java/com/caimei/modules/shiro/service/MallUserService.java

@@ -0,0 +1,39 @@
+package com.caimei.modules.shiro.service;
+
+import com.caimei.modules.club.entity.Page;
+import com.caimei.modules.shiro.entity.CmMallAdminUser;
+import com.caimei.utils.ResponseJson;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/5/25
+ */
+public interface MallUserService {
+    /**
+     * 后台用户信息集合
+     * @param cmMallAdminUser
+     * @return
+     */
+    Page<CmMallAdminUser> getMallUserInfo(Page page, CmMallAdminUser cmMallAdminUser);
+
+    /**
+     * 修改用户上下线状态
+     * @param status
+     * @param id
+     */
+    void updateUser(Integer status,  Integer id);
+    /**
+     * 获取用户信息
+     * @param id
+     * @return
+     */
+    CmMallAdminUser getMallUserById(Integer id);
+
+    /**
+     * 保存用户信息
+     * @param cmMallAdminUser
+     */
+    void saveUser(CmMallAdminUser cmMallAdminUser);
+}

+ 94 - 0
src/main/java/com/caimei/modules/shiro/service/impl/MallUserServiceImpl.java

@@ -0,0 +1,94 @@
+package com.caimei.modules.shiro.service.impl;
+
+import com.caimei.modules.club.entity.Page;
+import com.caimei.modules.shiro.dao.MallUserDao;
+import com.caimei.modules.shiro.entity.CmMallAdminUser;
+import com.caimei.modules.shiro.service.MallUserService;
+import com.caimei.utils.MD5Util;
+import com.github.pagehelper.PageHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/5/25
+ */
+@Service
+public class MallUserServiceImpl implements MallUserService {
+
+    @Autowired private MallUserDao mallUserDao;
+
+    /**
+     * 后台用户信息集合
+     *
+     * @param cmMallAdminUser
+     * @return
+     */
+    @Override
+    public Page<CmMallAdminUser> getMallUserInfo(Page page, CmMallAdminUser cmMallAdminUser) {
+        PageHelper.startPage(page.getIndex(),page.getPageSize());
+        List<CmMallAdminUser> mallUser = mallUserDao.getMallUserInfo(cmMallAdminUser);
+        return new Page<>(mallUser);
+    }
+
+    /**
+     * 修改用户上下线状态
+     * @param status
+     * @param id
+     */
+    @Override
+    public void updateUser(Integer status,  Integer id) {
+        mallUserDao.updateUser(status, id);
+    }
+
+    /**
+     * 获取用户信息
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public CmMallAdminUser getMallUserById(Integer id) {
+        CmMallAdminUser mallUserById = mallUserDao.getMallUserById(id);
+        // 确认密码
+        mallUserById.setOldPassword(mallUserById.getPassword());
+        return mallUserById;
+    }
+
+    /**
+     * 保存用户信息
+     *
+     * @param cmMallAdminUser
+     */
+    @Override
+    public void saveUser(CmMallAdminUser cmMallAdminUser) {
+
+        // 密码添加  随机盐
+        UUID uuid = UUID.randomUUID();
+        String[] split = uuid.toString().split("-");
+        String newPassword = cmMallAdminUser.getPassword() + split[0];
+        String s = MD5Util.md5(newPassword);
+        cmMallAdminUser.setPassword(s);
+        cmMallAdminUser.setSalt(split[0]);
+        cmMallAdminUser.setPersonnelType(2);
+        cmMallAdminUser.setUpdateTime(new Date());
+        if (null == cmMallAdminUser.getId()) {
+            // 添加组织后台用户信息
+            cmMallAdminUser.setAddTime(new Date());
+            cmMallAdminUser.setDelFlag("0");
+
+            mallUserDao.insertMallUser(cmMallAdminUser);
+        } else {
+            // 修改组织后台用户信息
+            mallUserDao.updateMallUser(cmMallAdminUser);
+        }
+    }
+
+
+}

+ 94 - 0
src/main/resources/mapper/MallUserMapper.xml

@@ -0,0 +1,94 @@
+<?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.caimei.modules.shiro.dao.MallUserDao">
+    <select id="getMallUserInfo" resultType="com.caimei.modules.shiro.entity.CmMallAdminUser">
+        SELECT
+        id,
+        organizeID as organizeId,
+        status,
+        account,
+        accountName,
+        addTime,
+        updateTime
+        FROM cm_mall_admin_user
+        <where>
+            organizeID = #{organizeId} and delFlag = 0 and personnelType = 0
+            <if test="account != null and account != ''">
+                and account like concat('%',#{account},'%')
+            </if>
+            <if test="accountName != null and accountName !=''">
+                and accountName like concat('%',#{accountName},'%')
+            </if>
+            <if test="status != null and status != ''">
+                and status = #{status}
+            </if>
+            <if test="startTime != null and startTime != ''">
+                and addTime <![CDATA[ >= ]]> #{startTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                and addTime <![CDATA[ <= ]]> #{endTime}
+            </if>
+        </where>
+    </select>
+    <select id="getMallUserById" resultType="com.caimei.modules.shiro.entity.CmMallAdminUser">
+        SELECT
+            id,
+            organizeID,
+            account,
+            accountName,
+            password,
+            salt,
+            addTime,
+            updateTime
+        FROM cm_mall_admin_user
+        where id = #{id}
+    </select>
+    <update id="updateUser">
+        update cm_mall_admin_user
+        set status = #{validFlag}
+        where id = #{id}
+    </update>
+    <select id="getRepeat" resultType="java.lang.Integer">
+        select id from cm_mall_admin_user where account =#{account}
+        <if test="id != null and id != ''">
+            and  id != #{id}
+        </if>
+        limit 1
+    </select>
+    <insert id="insertMallUser">
+        INSERT INTO cm_mall_admin_user(account, accountName, PASSWORD, salt, organizeID, status, personnelType, ADDTIME, updateTime, delFlag)
+        VALUES(#{account}, #{accountName}, #{password}, #{salt}, #{organizeId}, #{status}, #{personnelType}, #{addTime}, #{updateTime}, #{delFlag})
+    </insert>
+    <update id="updateMallUser">
+        update cm_mall_admin_user
+        <set>
+            <if test="account != null and account != ''">
+                account = #{account},
+            </if>
+            <if test="accountName != null and accountName != ''">
+                accountName = #{accountName},
+            </if>
+            <if test="password != null and password != ''">
+                password = #{password},
+            </if>
+            <if test="organizeId != null and organizeId != ''">
+                organizeID = #{organizeId},
+            </if>
+            <if test="status != null and status != ''">
+                status = #{status},
+            </if>
+            <if test="personnelType != null and personnelType != ''">
+                personnelType = #{personnelType},
+            </if>
+            <if test="updateTime != null and updateTime != ''">
+                updateTime = #{updateTime},
+            </if>
+            <if test="salt != null and salt != ''">
+                salt = #{salt}
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+</mapper>

+ 9 - 1
src/main/resources/mapper/NewOrderMapper.xml

@@ -712,6 +712,14 @@
         where voucherId = #{id}
     </select>
 
+    <insert id="insertVoucher" keyProperty="id" keyColumn="id" parameterType="com.caimei.modules.order.entity.Voucher" useGeneratedKeys="true">
+        insert into cm_order_payment_voucher (orderId, remarks, addtime)
+        values (#{orderId},#{remarks},now())
+    </insert>
+    <insert id="insertVoucherImage">
+        insert into cm_voucher_image (voucherId, image)
+        values (#{voucherId},#{img})
+    </insert>
     <select id="findWaitPay" resultType="java.lang.Double">
         SELECT ifnull((SELECT payTotalFee FROM cm_order WHERE orderId = #{orderId}) - ifnull(SUM(receiptAmount),0),0)
         FROM cm_discern_receipt cdr
@@ -729,4 +737,4 @@
     <select id="findOrderStatus" resultType="java.lang.String">
         select status from cm_order where orderId = #{orderId}
     </select>
-</mapper>
+</mapper>