Quellcode durchsuchen

会员卡管理

hanfucheng vor 4 Monaten
Ursprung
Commit
5f2830927c

+ 66 - 0
qmjszx-admin/src/main/java/beilv/web/controller/carinformation/cardAppController.java

@@ -0,0 +1,66 @@
+package beilv.web.controller.carinformation;
+
+import beilv.cardpurchaserecord.domain.CardPurchaseRecord;
+import beilv.cardpurchaserecord.service.ICardPurchaseRecordService;
+import beilv.carinformation.domain.CarInformation;
+import beilv.carinformation.service.ICarInformationService;
+import beilv.common.core.controller.BaseController;
+import beilv.common.core.domain.AjaxResult;
+import beilv.system.service.ISysMemberService;
+import beilv.usermembershipcard.domain.UserMembershipCard;
+import beilv.usermembershipcard.service.IUserMembershipCardService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * 会员卡AppController
+ *
+ * @author ruoyi
+ * @date 2025-01-02
+ */
+@Controller
+@RequestMapping("/app-api/cardApp")
+public class cardAppController extends BaseController {
+
+    @Autowired
+    private ICarInformationService carInformationService;
+
+    @Autowired
+    private ICardPurchaseRecordService cardPurchaseRecordService;
+
+    @Autowired
+    private IUserMembershipCardService userMembershipCardService;
+
+    @Autowired
+    private ISysMemberService iSysMemberService;
+    /**
+     * 查询卡种信息列表
+     */
+    @PostMapping("/cardInformationlist")
+    @ResponseBody
+    public AjaxResult cardInformationlist(@RequestBody CarInformation carInformation) {
+        return AjaxResult.success(carInformationService.selectCarInformationList(carInformation));
+    }
+
+    /**
+     * 新增保存购卡记录
+     */
+    @PostMapping("/addCard")
+    @ResponseBody
+    public AjaxResult addCard(@RequestBody CardPurchaseRecord cardPurchaseRecord) {
+        return toAjax(cardPurchaseRecordService.insertCardPurchaseRecord(cardPurchaseRecord));
+    }
+
+    /**
+     * 查询用户会员卡列表
+     */
+    @PostMapping("/getUserCardList")
+    @ResponseBody
+    public AjaxResult getUserCardList(@RequestBody UserMembershipCard userMembershipCard) {
+        return AjaxResult.success(userMembershipCardService.selectUserMembershipCardList(userMembershipCard));
+    }
+}

+ 53 - 23
qmjszx-admin/src/main/resources/templates/information/add.html

@@ -3,22 +3,19 @@
 <head>
     <th:block th:include="include :: header('新增卡种信息')" />
     <th:block th:include="include :: datetimepicker-css" />
+    <th:block th:include="include :: bootstrap-fileinput-css"/>
 </head>
 <body class="white-bg">
     <div class="wrapper wrapper-content animated fadeInRight ibox-content">
         <form class="form-horizontal m" id="form-information-add">
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">名称:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">名称:</label>
+                    <div class="col-sm-4">
                         <input name="name" class="form-control" type="text" maxlength="20" required>
                     </div>
-                </div>
-            </div>
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">类型:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">类型:</label>
+                    <div class="col-sm-4">
                         <select name="type" class="form-control" th:with="type=${@dict.getType('site_type')}" required>
                             <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                         </select>
@@ -27,42 +24,45 @@
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">可用次数:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">可用次数:</label>
+                    <div class="col-sm-4">
                         <input name="totalNumber" class="form-control" type="number" min="0" step="1" maxlength="8" required>
                     </div>
-                </div>
-            </div>
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">原价格:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">原价格:</label>
+                    <div class="col-sm-4">
                         <input name="originalPrice" class="form-control" type="number" min="0" step="0.01" maxlength="8" required>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">会员价格:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">会员价格:</label>
+                    <div class="col-sm-4">
                         <input name="memberPrice" class="form-control" type="number" min="0" step="0.01" maxlength="8" required>
                     </div>
+                    <label class="col-sm-2 control-label is-required">单次积分:</label>
+                    <div class="col-sm-4">
+                        <input name="point" class="form-control" type="number" min="0" step="1" maxlength="8" required>
+                    </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">单次积分:</label>
+                    <label class="col-sm-2 control-label">使用规则:</label>
                     <div class="col-sm-8">
-                        <input name="point" class="form-control" type="number" min="0" step="1" maxlength="8" required>
+                        <input name="notes" class="form-control" type="hidden" maxlength="255">
+                        <div class="summernote" id = "notes"></div>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label">使用规则:</label>
+                    <label class="col-sm-2 control-label is-required">图片:</label>
                     <div class="col-sm-8">
-                        <input name="notes" class="form-control" type="hidden" maxlength="255">
-                        <div class="summernote" id = "notes"></div>
+                        <input type="hidden" name="file">
+                        <div class="file-loading">
+                            <input class="form-control file-upload" id="file" name="file" type="file">
+                        </div>
                     </div>
                 </div>
             </div>
@@ -71,6 +71,7 @@
     <th:block th:include="include :: footer" />
     <th:block th:include="include :: datetimepicker-js" />
     <th:block th:include="include :: summernote-js"/>
+    <th:block th:include="include :: bootstrap-fileinput-js"/>
     <th:block th:include="include :: summernote-css"/>
     <script th:inline="javascript">
         var prefix = ctx + "information"
@@ -96,6 +97,35 @@
             autoclose: true
         });
 
+        $(".file-upload").fileinput({
+            uploadUrl: ctx + 'common/upload',
+            maxFileCount: 1,
+            allowedFileExtensions:['jpg','png'],
+            maxFileSize: 10240,
+            multiple: true,
+        }).on('fileuploaded', function (event, data, previewId, index) {
+            var inputName = event.currentTarget.id;
+            var existingValue = $("input[name='" + inputName + "']").val();
+            var newValue = data.response.url;
+
+            // 如果已经存在值,则在后面加上逗号分隔的新值
+            if (existingValue) {
+                $("input[name='" + inputName + "']").val(existingValue + ',' + newValue);
+            } else {
+                $("input[name='" + inputName + "']").val(newValue);
+            }
+        }).on('fileremoved', function (event, id, index) {
+            var inputName = event.currentTarget.id;
+            var existingValue = $("input[name='" + inputName + "']").val();
+            var fileUrls = existingValue.split(',');
+
+            // 移除对应的文件路径
+            fileUrls.splice(index, 1);
+
+            // 重新拼接文件路径
+            $("input[name='" + inputName + "']").val(fileUrls.join(','));
+        });
+
         $(function () {
             $('.summernote').summernote({
                 lang: 'zh-CN',

+ 65 - 23
qmjszx-admin/src/main/resources/templates/information/edit.html

@@ -3,6 +3,7 @@
 <head>
     <th:block th:include="include :: header('修改卡种信息')" />
     <th:block th:include="include :: datetimepicker-css" />
+    <th:block th:include="include :: bootstrap-fileinput-css"/>
 </head>
 <body class="white-bg">
     <div class="wrapper wrapper-content animated fadeInRight ibox-content">
@@ -10,16 +11,12 @@
             <input name="id" th:field="*{id}" type="hidden">
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">名称:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">名称:</label>
+                    <div class="col-sm-4">
                         <input name="name" th:field="*{name}" class="form-control" type="text" maxlength="20">
                     </div>
-                </div>
-            </div>
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">类型:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">类型:</label>
+                    <div class="col-sm-4">
                         <select name="type" class="form-control" th:with="type=${@dict.getType('site_type')}">
                             <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
                         </select>
@@ -28,42 +25,45 @@
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">可用次数:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">可用次数:</label>
+                    <div class="col-sm-4">
                         <input name="totalNumber" th:field="*{totalNumber}" class="form-control" type="number" min="0" step="1" maxlength="8">
                     </div>
-                </div>
-            </div>
-            <div class="col-xs-12">
-                <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">原价格:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">原价格:</label>
+                    <div class="col-sm-4">
                         <input name="originalPrice" th:field="*{originalPrice}" class="form-control" type="number" min="0" step="0.01" maxlength="8">
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">会员价格:</label>
-                    <div class="col-sm-8">
+                    <label class="col-sm-2 control-label is-required">会员价格:</label>
+                    <div class="col-sm-4">
                         <input name="memberPrice" th:field="*{memberPrice}" class="form-control" type="number" min="0" step="0.01" maxlength="8">
                     </div>
+                    <label class="col-sm-2 control-label is-required">单次积分:</label>
+                    <div class="col-sm-4">
+                        <input name="point" th:field="*{point}" class="form-control" type="number" min="0" step="1" maxlength="8">
+                    </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">单次积分:</label>
+                    <label class="col-sm-2 control-label is-required">使用规则:</label>
                     <div class="col-sm-8">
-                        <input name="point" th:field="*{point}" class="form-control" type="number" min="0" step="1" maxlength="8">
+                        <input name="notes" th:field="*{notes}" class="form-control" type="hidden" maxlength="255">
+                        <div class="summernote" id="notes"></div>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">使用规则:</label>
+                    <label class="col-sm-2 control-label">图片:</label>
                     <div class="col-sm-8">
-                        <input name="notes" th:field="*{notes}" class="form-control" type="hidden" maxlength="255">
-                        <div class="summernote" id="notes"></div>
+                        <input type="hidden" name="file" th:field="*{file}">
+                        <div class="file-loading">
+                            <input class="form-control file-upload" id="file" name="file" type="file">
+                        </div>
                     </div>
                 </div>
             </div>
@@ -73,6 +73,7 @@
     <th:block th:include="include :: datetimepicker-js" />
     <th:block th:include="include :: summernote-js"/>
     <th:block th:include="include :: summernote-css"/>
+    <th:block th:include="include :: bootstrap-fileinput-js"/>
     <script th:inline="javascript">
         var prefix = ctx + "information";
         $("#form-information-edit").validate({
@@ -97,6 +98,47 @@
             autoclose: true
         });
 
+        $(".file-upload").each(function (i) {
+            var inputName = this.id;
+            var val = $("input[name='" + inputName + "']").val();
+
+            // 将已上传的图片路径分割成数组
+            var initialPreview = val ? val.split(',') : [];
+
+            $(this).fileinput({
+                'uploadUrl': ctx + 'common/upload',
+                initialPreviewAsData: true,
+                initialPreview: initialPreview,
+                maxFileCount: 1,
+                allowedFileExtensions: ['jpg', 'png'],
+                maxFileSize: 10240,
+                multiple: true,
+            }).on('fileuploaded', function (event, data, previewId, index) {
+                var inputName = event.currentTarget.id;
+                var existingValue = $("input[name='" + inputName + "']").val();
+                var newValue = data.response.url;
+
+                // 如果已经存在值,则在后面加上逗号分隔的新值
+                if (existingValue) {
+                    $("input[name='" + inputName + "']").val(existingValue + ',' + newValue);
+                } else {
+                    $("input[name='" + inputName + "']").val(newValue);
+                }
+            }).on('fileremoved', function (event, id, index) {
+                var inputName = event.currentTarget.id;
+                var existingValue = $("input[name='" + inputName + "']").val();
+                var fileUrls = existingValue.split(',');
+
+                // 移除对应的文件路径
+                fileUrls.splice(index, 1);
+
+                // 重新拼接文件路径
+                $("input[name='" + inputName + "']").val(fileUrls.join(','));
+            });
+
+            $(this).fileinput('_initFileActions');
+        });
+
         $(function() {
             $('.summernote').each(function(i) {
                 console.log($('#' + this.id))

+ 7 - 3
qmjszx-business/src/main/java/beilv/cardpurchaserecord/service/impl/CardPurchaseRecordServiceImpl.java

@@ -6,7 +6,7 @@ import beilv.cardpurchaserecord.service.ICardPurchaseRecordService;
 import beilv.common.core.text.Convert;
 import beilv.common.utils.DateUtils;
 import beilv.common.utils.ShiroUtils;
-import beilv.common.utils.uuid.IdUtils;
+import beilv.common.utils.StringUtils;
 import beilv.system.service.ISysDictDataService;
 import beilv.usermembershipcard.domain.UserMembershipCard;
 import beilv.usermembershipcard.mapper.UserMembershipCardMapper;
@@ -71,7 +71,9 @@ public class CardPurchaseRecordServiceImpl implements ICardPurchaseRecordService
 
 
         //新增购卡记录
-        cardPurchaseRecord.setCreateBy(ShiroUtils.getUserId().toString());
+        if (StringUtils.isEmpty(cardPurchaseRecord.getCreateBy())) {
+            cardPurchaseRecord.setCreateBy(ShiroUtils.getUserId().toString());
+        }
         cardPurchaseRecord.setCreateTime(DateUtils.getNowDate());
         cardPurchaseRecord.setType("1");
         cardPurchaseRecord.setTime(DateUtils.getNowDate());
@@ -82,7 +84,9 @@ public class CardPurchaseRecordServiceImpl implements ICardPurchaseRecordService
         userMembershipCard.setUserId(cardPurchaseRecord.getUserId());
         userMembershipCard.setRecordId(cardPurchaseRecord.getId().toString());
         userMembershipCard.setRemainingNumber(cardPurchaseRecord.getTotalNumber());
-        userMembershipCard.setCreateBy(ShiroUtils.getUserId().toString());
+        if (StringUtils.isEmpty(cardPurchaseRecord.getCreateBy())) {
+            userMembershipCard.setCreateBy(ShiroUtils.getUserId().toString());
+        }
         userMembershipCard.setCreateTime(DateUtils.getNowDate());
         userMembershipCard.setState("3");
         userMembershipCard.setVersion("0");

+ 11 - 0
qmjszx-business/src/main/java/beilv/carinformation/domain/CarInformation.java

@@ -82,6 +82,17 @@ public class CarInformation extends BaseEntity {
     @Excel(name = "卡种状态")
     private String cardStateLabel;
 
+    //图片
+    private String file;
+
+    public String getFile() {
+        return file;
+    }
+
+    public void setFile(String file) {
+        this.file = file;
+    }
+
     public BigDecimal getOriginalPrice() {
         return originalPrice;
     }

+ 5 - 1
qmjszx-business/src/main/resources/mapper/card/CarInformationMapper.xml

@@ -19,10 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="createTime"    column="create_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
+        <result property="file"    column="file"    />
     </resultMap>
 
     <sql id="selectCarInformationVo">
-        select id, name, type, total_number, original_price,member_price, point, expiration_date, notes, card_state, create_by, create_time, update_by, update_time from card_information
+        select id, name, type, total_number, original_price,member_price, point, expiration_date, notes,file, card_state, create_by, create_time, update_by, update_time from card_information
     </sql>
 
     <select id="selectCarInformationList" parameterType="CarInformation" resultMap="CarInformationResult">
@@ -59,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="expirationDate != null">expiration_date,</if>
             <if test="notes != null">notes,</if>
             <if test="cardState != null">card_state,</if>
+            <if test="file != null">file,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
@@ -75,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="expirationDate != null">#{expirationDate},</if>
             <if test="notes != null">#{notes},</if>
             <if test="cardState != null">#{cardState},</if>
+            <if test="file != null">#{file},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
@@ -94,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="expirationDate != null">expiration_date = #{expirationDate},</if>
             <if test="notes != null">notes = #{notes},</if>
             <if test="cardState != null">card_state = #{cardState},</if>
+            <if test="file != null">file = #{file},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>