فهرست منبع

小程序增加流水查询接口

Memory_LG 3 هفته پیش
والد
کامیت
b1091ad3c0

+ 23 - 0
qmjszx-admin/src/main/java/beilv/web/controller/carinformation/CardAppController.java

@@ -20,6 +20,7 @@ import beilv.usermembershipcard.service.IUserMembershipCardService;
 import beilv.vipCard.domain.VipCard;
 import beilv.vipCard.service.IVipCardService;
 import beilv.vipCardAmountLog.domain.VipCardAmountLog;
+import beilv.vipCardAmountLog.service.IVipCardAmountLogService;
 import beilv.vipCardLog.domain.VipCardLog;
 import beilv.vipCardLog.service.IVipCardLogService;
 import beilv.wx.pay.controller.WxPayController;
@@ -36,6 +37,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.temporal.ChronoUnit;
+import java.util.HashMap;
 
 import static beilv.competition.domain.Constant.ORDER_QUEUE;
 
@@ -74,6 +76,9 @@ public class CardAppController extends BaseController {
     @Autowired
     private WxPayController payController;
 
+    @Autowired
+    private IVipCardAmountLogService amountLogService;
+
     /**
      * 新增充值记录
      */
@@ -374,4 +379,22 @@ public class CardAppController extends BaseController {
             return toAjax(0);
         }
     }
+
+    /**
+     * 查询流水
+     * userId
+     * amount_type
+     */
+    @PostMapping("/selectPointsTransactionHistory")
+    @ResponseBody
+    public AjaxResult selectPointsTransactionHistory(@RequestBody VipCardAmountLog amountLog){
+        HashMap<String, Object> result = new HashMap<>();
+        result.put("historyList",amountLogService.selectVipCardAmountLogListAndOrderInfo(amountLog));
+        if("1".equals(amountLog.getAmountType())){
+            result.put("balance", vipCardService.selectVipCardByUserId(amountLog.getUserId()).getBalance());
+        }else if("2".equals(amountLog.getAmountType())){
+            result.put("score", vipCardService.selectVipCardByUserId(amountLog.getUserId()).getScore());
+        }
+        return AjaxResult.success(result);
+    }
 }

+ 3 - 0
qmjszx-business/src/main/java/beilv/vipCardAmountLog/mapper/VipCardAmountLogMapper.java

@@ -3,6 +3,7 @@ package beilv.vipCardAmountLog.mapper;
 import beilv.vipCardAmountLog.domain.VipCardAmountLog;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 会员卡金额流水Mapper接口
@@ -58,4 +59,6 @@ public interface VipCardAmountLogMapper {
      * @return 结果
      */
     public int deleteVipCardAmountLogByIds(String[] ids);
+
+    List<Map<String, Object>> selectVipCardAmountLogListAndOrderInfo(VipCardAmountLog amountLog);
 }

+ 3 - 0
qmjszx-business/src/main/java/beilv/vipCardAmountLog/service/IVipCardAmountLogService.java

@@ -3,6 +3,7 @@ package beilv.vipCardAmountLog.service;
 import beilv.vipCardAmountLog.domain.VipCardAmountLog;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 会员卡金额流水Service接口
@@ -58,4 +59,6 @@ public interface IVipCardAmountLogService {
      * @return 结果
      */
     public int deleteVipCardAmountLogById(String id);
+
+    List<Map<String, Object>> selectVipCardAmountLogListAndOrderInfo(VipCardAmountLog amountLog);
 }

+ 17 - 0
qmjszx-business/src/main/java/beilv/vipCardAmountLog/service/impl/VipCardAmountLogServiceImpl.java

@@ -1,14 +1,19 @@
 package beilv.vipCardAmountLog.service.impl;
 
+import beilv.common.core.domain.entity.SysDictData;
 import beilv.common.core.text.Convert;
+import beilv.common.utils.CacheUtils;
 import beilv.common.utils.DateUtils;
+import beilv.common.utils.DictUtils;
 import beilv.vipCardAmountLog.domain.VipCardAmountLog;
 import beilv.vipCardAmountLog.mapper.VipCardAmountLogMapper;
 import beilv.vipCardAmountLog.service.IVipCardAmountLogService;
+import org.apache.commons.collections4.MapUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 会员卡金额流水Service业务层处理
@@ -88,4 +93,16 @@ public class VipCardAmountLogServiceImpl implements IVipCardAmountLogService {
     public int deleteVipCardAmountLogById(String id) {
         return vipCardAmountLogMapper.deleteVipCardAmountLogById(id);
     }
+
+    @Override
+    public List<Map<String, Object>> selectVipCardAmountLogListAndOrderInfo(VipCardAmountLog amountLog) {
+        List<Map<String, Object>> maps = vipCardAmountLogMapper.selectVipCardAmountLogListAndOrderInfo(amountLog);
+        Map<String, String> orderType = DictUtils.getDictCacheToMap("order_type");
+        Map<String, String> paymentType = DictUtils.getDictCacheToMap("payment_type");
+        maps.forEach(map->{
+            map.put("orderTypeLabel", MapUtils.getString(orderType, MapUtils.getString(map,"orderType")));
+            map.put("paymentTypeLabel", MapUtils.getString(paymentType, MapUtils.getString(map,"paymentType")));
+        });
+        return maps;
+    }
 }

+ 26 - 0
qmjszx-business/src/main/resources/mapper/vipCardAmountLog/VipCardAmountLogMapper.xml

@@ -34,9 +34,12 @@
     <select id="selectVipCardAmountLogList" parameterType="VipCardAmountLog" resultMap="VipCardAmountLogResult">
         <include refid="selectVipCardAmountLogVo"/>
         <where>
+            <if test="userId != null  and userId != ''">and user_id = #{userId}</if>
+            <if test="amountType != null  and amountType != ''">and amount_type = #{amountType}</if>
             <if test="userName != null  and userName != ''">and user_name like concat('%', #{userName}, '%')</if>
             <if test="vipCardId != null  and vipCardId != ''">and vip_card_id like concat('%', #{vipCardId}, '%')</if>
         </where>
+        order by create_time desc
     </select>
 
     <select id="selectVipCardAmountLogById" parameterType="String" resultMap="VipCardAmountLogResult">
@@ -101,4 +104,27 @@
         </foreach>
     </delete>
 
+    <select id="selectVipCardAmountLogListAndOrderInfo" parameterType="VipCardAmountLog" resultType="map">
+        select
+        a.id,
+        a.order_id orderId,
+        a.create_time createTime,
+        a.current_amount currentAmount,
+        a.operation_amount operationAmount,
+        a.remaining_amount remainingAmount,
+        b.order_type orderType,
+        b.bus_id busId,
+        b.payment_type paymentType,
+        b.payment_id paymentId
+        from beilv_vip_card_amount_log a
+        left join beilv_vip_card_log b on a.order_id = b.id
+        <where>
+            <if test="userId != null  and userId != ''">and a.user_id = #{userId}</if>
+            <if test="amountType != null  and amountType != ''">and a.amount_type = #{amountType}</if>
+            <if test="userName != null  and userName != ''">and a.user_name like concat('%', #{userName}, '%')</if>
+            <if test="vipCardId != null  and vipCardId != ''">and a.vip_card_id like concat('%', #{vipCardId}, '%')</if>
+        </where>
+        order by a.create_time desc
+    </select>
+
 </mapper>

+ 57 - 95
qmjszx-common/src/main/java/beilv/common/utils/DictUtils.java

@@ -1,21 +1,20 @@
 package beilv.common.utils;
 
+import beilv.common.constant.Constants;
+import beilv.common.core.domain.entity.SysDictData;
+import org.springframework.stereotype.Component;
+
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.springframework.stereotype.Component;
-import beilv.common.constant.Constants;
-import beilv.common.core.domain.entity.SysDictData;
-
 /**
  * 字典工具类
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class DictUtils
-{
+public class DictUtils {
     /**
      * 分隔符
      */
@@ -23,36 +22,33 @@ public class DictUtils
 
     /**
      * 设置字典缓存
-     * 
-     * @param key 参数键
+     *
+     * @param key       参数键
      * @param dictDatas 字典数据列表
      */
-    public static void setDictCache(String key, List<SysDictData> dictDatas)
-    {
+    public static void setDictCache(String key, List<SysDictData> dictDatas) {
         CacheUtils.put(getCacheName(), getCacheKey(key), dictDatas);
     }
 
     /**
      * 获取字典缓存
-     * 
+     *
      * @param key 参数键
      * @return dictDatas 字典数据列表
      */
-    public static List<SysDictData> getDictCache(String key)
-    {
+    public static List<SysDictData> getDictCache(String key) {
         Object cacheObj = CacheUtils.get(getCacheName(), getCacheKey(key));
-        if (StringUtils.isNotNull(cacheObj))
-        {
+        if (StringUtils.isNotNull(cacheObj)) {
             return StringUtils.cast(cacheObj);
         }
         return null;
     }
 
-    public static Map<String, String> getDictCacheToMap(String key){
+    public static Map<String, String> getDictCacheToMap(String key) {
         List<SysDictData> dictCache = getDictCache(key);
         Map<String, String> result = new HashMap<>();
 
-        dictCache.forEach(sysdictData->{
+        dictCache.forEach(sysdictData -> {
             result.put(sysdictData.getDictValue(), sysdictData.getDictLabel());
         });
         return result;
@@ -60,15 +56,13 @@ public class DictUtils
 
     /**
      * 根据字典类型和字典值获取字典标签
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictValue 字典值
      * @return 字典标签
      */
-    public static String getDictLabel(String dictType, String dictValue)
-    {
-        if (StringUtils.isEmpty(dictValue))
-        {
+    public static String getDictLabel(String dictType, String dictValue) {
+        if (StringUtils.isEmpty(dictValue)) {
             return StringUtils.EMPTY;
         }
         return getDictLabel(dictType, dictValue, SEPARATOR);
@@ -76,15 +70,13 @@ public class DictUtils
 
     /**
      * 根据字典类型和字典标签获取字典值
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictLabel 字典标签
      * @return 字典值
      */
-    public static String getDictValue(String dictType, String dictLabel)
-    {
-        if (StringUtils.isEmpty(dictLabel))
-        {
+    public static String getDictValue(String dictType, String dictLabel) {
+        if (StringUtils.isEmpty(dictLabel)) {
             return StringUtils.EMPTY;
         }
         return getDictValue(dictType, dictLabel, SEPARATOR);
@@ -92,40 +84,30 @@ public class DictUtils
 
     /**
      * 根据字典类型和字典值获取字典标签
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictValue 字典值
      * @param separator 分隔符
      * @return 字典标签
      */
-    public static String getDictLabel(String dictType, String dictValue, String separator)
-    {
+    public static String getDictLabel(String dictType, String dictValue, String separator) {
         StringBuilder propertyString = new StringBuilder();
         List<SysDictData> datas = getDictCache(dictType);
-        if (StringUtils.isNull(datas))
-        {
+        if (StringUtils.isNull(datas)) {
             return StringUtils.EMPTY;
         }
-        if (StringUtils.containsAny(dictValue, separator))
-        {
-            for (SysDictData dict : datas)
-            {
-                for (String value : dictValue.split(separator))
-                {
-                    if (value.equals(dict.getDictValue()))
-                    {
+        if (StringUtils.containsAny(dictValue, separator)) {
+            for (SysDictData dict : datas) {
+                for (String value : dictValue.split(separator)) {
+                    if (value.equals(dict.getDictValue())) {
                         propertyString.append(dict.getDictLabel()).append(separator);
                         break;
                     }
                 }
             }
-        }
-        else
-        {
-            for (SysDictData dict : datas)
-            {
-                if (dictValue.equals(dict.getDictValue()))
-                {
+        } else {
+            for (SysDictData dict : datas) {
+                if (dictValue.equals(dict.getDictValue())) {
                     return dict.getDictLabel();
                 }
             }
@@ -135,40 +117,30 @@ public class DictUtils
 
     /**
      * 根据字典类型和字典标签获取字典值
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictLabel 字典标签
      * @param separator 分隔符
      * @return 字典值
      */
-    public static String getDictValue(String dictType, String dictLabel, String separator)
-    {
+    public static String getDictValue(String dictType, String dictLabel, String separator) {
         StringBuilder propertyString = new StringBuilder();
         List<SysDictData> datas = getDictCache(dictType);
-        if (StringUtils.isNull(datas))
-        {
+        if (StringUtils.isNull(datas)) {
             return StringUtils.EMPTY;
         }
-        if (StringUtils.containsAny(dictLabel, separator))
-        {
-            for (SysDictData dict : datas)
-            {
-                for (String label : dictLabel.split(separator))
-                {
-                    if (label.equals(dict.getDictLabel()))
-                    {
+        if (StringUtils.containsAny(dictLabel, separator)) {
+            for (SysDictData dict : datas) {
+                for (String label : dictLabel.split(separator)) {
+                    if (label.equals(dict.getDictLabel())) {
                         propertyString.append(dict.getDictValue()).append(separator);
                         break;
                     }
                 }
             }
-        }
-        else
-        {
-            for (SysDictData dict : datas)
-            {
-                if (dictLabel.equals(dict.getDictLabel()))
-                {
+        } else {
+            for (SysDictData dict : datas) {
+                if (dictLabel.equals(dict.getDictLabel())) {
                     return dict.getDictValue();
                 }
             }
@@ -182,16 +154,13 @@ public class DictUtils
      * @param dictType 字典类型
      * @return 字典值
      */
-    public static String getDictValues(String dictType)
-    {
+    public static String getDictValues(String dictType) {
         StringBuilder propertyString = new StringBuilder();
         List<SysDictData> datas = getDictCache(dictType);
-        if (StringUtils.isNull(datas))
-        {
+        if (StringUtils.isNull(datas)) {
             return StringUtils.EMPTY;
         }
-        for (SysDictData dict : datas)
-        {
+        for (SysDictData dict : datas) {
             propertyString.append(dict.getDictValue()).append(SEPARATOR);
         }
         return StringUtils.stripEnd(propertyString.toString(), SEPARATOR);
@@ -203,16 +172,13 @@ public class DictUtils
      * @param dictType 字典类型
      * @return 字典值
      */
-    public static String getDictLabels(String dictType)
-    {
+    public static String getDictLabels(String dictType) {
         StringBuilder propertyString = new StringBuilder();
         List<SysDictData> datas = getDictCache(dictType);
-        if (StringUtils.isNull(datas))
-        {
+        if (StringUtils.isNull(datas)) {
             return StringUtils.EMPTY;
         }
-        for (SysDictData dict : datas)
-        {
+        for (SysDictData dict : datas) {
             propertyString.append(dict.getDictLabel()).append(SEPARATOR);
         }
         return StringUtils.stripEnd(propertyString.toString(), SEPARATOR);
@@ -220,40 +186,36 @@ public class DictUtils
 
     /**
      * 删除指定字典缓存
-     * 
+     *
      * @param key 字典键
      */
-    public static void removeDictCache(String key)
-    {
+    public static void removeDictCache(String key) {
         CacheUtils.remove(getCacheName(), getCacheKey(key));
     }
 
     /**
      * 清空字典缓存
      */
-    public static void clearDictCache()
-    {
+    public static void clearDictCache() {
         CacheUtils.removeAll(getCacheName());
     }
 
     /**
      * 获取cache name
-     * 
+     *
      * @return 缓存名
      */
-    public static String getCacheName()
-    {
+    public static String getCacheName() {
         return Constants.SYS_DICT_CACHE;
     }
 
     /**
      * 设置cache key
-     * 
+     *
      * @param configKey 参数键
      * @return 缓存键key
      */
-    public static String getCacheKey(String configKey)
-    {
+    public static String getCacheKey(String configKey) {
         return Constants.SYS_DICT_KEY + configKey;
     }
 }