From 5627daeb1ac1a29947e902f9a7efb6730ed98611 Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期五, 07 七月 2023 20:35:50 +0800
Subject: [PATCH] 管理台bug和用户端生日卡

---
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/AppErrorConstant.java                 |    4 
 ruoyi-modules/ruoyi-goods/src/main/resources/mapper/goods/GoodsMapper.xml                                    |    6 
 ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml                                    |    4 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java   |    1 
 ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/miniapp/AppActivityController.java        |    2 
 ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponRelUserMapper.xml                          |    2 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/AppBirthdayGiftVo.java                   |   23 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGetVo.java                      |    2 
 ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java                      |   26 
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/vo/MgtSelectGoodsPageVo.java            |    5 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGoodsListVo.java                |    5 
 ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/OBSUploadUtils.java                              |    3 
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/dto/MgtShopPageDto.java                         |    3 
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteOrderFallbackFactory.java        |    6 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/MemberGiftRecordServiceImpl.java      |   44 +
 ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml                                       |    3 
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/console/ShopController.java                 |   24 
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteShopService.java                 |   18 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/console/CouponController.java           |   16 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/birthday/BirthdayCardServiceImpl.java |  240 ++++++++
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteOrderService.java                |   11 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MerBirthdayGetVo.java                    |    1 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java         |   92 ++
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java                 |  136 ++--
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteShopFallbackFactory.java         |    5 
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteCouponService.java               |   11 
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java     |  156 +++++
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/coupon/CouponService.java                  |   11 
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java             |  311 +++++-----
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/AppBirthdayCardVo.java                   |   30 +
 ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml                                 |    2 
 ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberGiftRecordMapper.xml                       |    7 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/GeneratorMybatisPlus.java               |    6 
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/domain/pojo/order/OrderGoods.java                    |    3 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/pojo/member/MemberGiftRecord.java           |  130 ++++
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/ConsumerGoodsService.java              |   21 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponPageVo.java                     |    2 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/mapper/member/MemberGiftRecordMapper.java          |   16 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/member/MemberCouponService.java            |    6 
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/BirthdayGiftSendDto.java            |   41 +
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/birthday/BirthdayCardService.java          |   22 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/member/MemberGiftRecordService.java        |   28 +
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/concole/OrderController.java              |   17 
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCouponFallbackFactory.java       |    6 
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/miniapp/AppMemberController.java        |   61 ++
 45 files changed, 1,295 insertions(+), 274 deletions(-)

diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/AppErrorConstant.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/AppErrorConstant.java
index db79db6..d96ecdc 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/AppErrorConstant.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/AppErrorConstant.java
@@ -79,4 +79,8 @@
     String ACTIVITY_END = "活动已经结束";
 
     String ACTIVITY_GOODS_NULL = "商品已售罄";
+
+    String BIRTHDAY_NULL = "未填写生日";
+
+    String BIRTHDAY_ERROR = "只有生日当月领取";
 }
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/BirthdayGiftSendDto.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/BirthdayGiftSendDto.java
new file mode 100644
index 0000000..b1e4f39
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/BirthdayGiftSendDto.java
@@ -0,0 +1,41 @@
+package com.ruoyi.system.api.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @ClassName BirthdayGiftSendDto
+ * @Description TODO
+ * @Author jqs
+ * @Date 2023/7/7 14:48
+ * @Version 1.0
+ */
+@Data
+public class BirthdayGiftSendDto {
+
+    @ApiModelProperty(value = "用户id")
+    private Long userId;
+
+    @ApiModelProperty(value = "礼物类型1优惠券2商品3现金4实物")
+    private Integer giftType;
+
+    @ApiModelProperty(value = "礼物来源1平台2商户")
+    private Integer giftFrom;
+
+    @ApiModelProperty(value = "商户id")
+    private Long shopId;
+
+    @ApiModelProperty(value = "优惠券id")
+    private String couponId;
+
+    @ApiModelProperty(value = "优惠券数量")
+    private Integer couponNumber;
+
+    @ApiModelProperty(value = "商品id")
+    private String goodsId;
+
+    @ApiModelProperty(value = "商品数量")
+    private Integer goodsNumber;
+
+
+}
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/vo/MgtSelectGoodsPageVo.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/vo/MgtSelectGoodsPageVo.java
index 6dfd5f7..f21c596 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/vo/MgtSelectGoodsPageVo.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/vo/MgtSelectGoodsPageVo.java
@@ -25,7 +25,10 @@
     private String goodsNo;
 
     @ApiModelProperty(value = "商品类型1周期2服务3体验4单品")
-    private String goodsType;
+    private Integer goodsType;
+
+    @ApiModelProperty(value = "商品类型")
+    private String goodsTypeName;
 
     @ApiModelProperty(value = "商品售价")
     private BigDecimal salesPrice;
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCouponFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCouponFallbackFactory.java
index 70b3465..2faa3d3 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCouponFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteCouponFallbackFactory.java
@@ -1,6 +1,7 @@
 package com.ruoyi.system.api.factory;
 
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 import com.ruoyi.system.api.domain.vo.AppMemberCouponVo;
 import com.ruoyi.system.api.domain.vo.MerVerifyCouponGetVo;
 import com.ruoyi.system.api.service.RemoteCouponService;
@@ -39,6 +40,11 @@
                 return R.fail("获取核销优惠券失败:" + throwable.getMessage());
             }
 
+            @Override
+            public R sendCouponGift(List<BirthdayGiftSendDto> giftSendDtoList) {
+                return null;
+            }
+
 
         };
     }
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteOrderFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteOrderFallbackFactory.java
index aab7869..e57fde3 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteOrderFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteOrderFallbackFactory.java
@@ -1,6 +1,7 @@
 package com.ruoyi.system.api.factory;
 
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 import com.ruoyi.system.api.domain.dto.MerBaseDto;
 import com.ruoyi.system.api.domain.dto.MgtBasePlatformDto;
 import com.ruoyi.system.api.domain.vo.MgtBulletinBoardVo;
@@ -57,6 +58,11 @@
             public R<BigDecimal> getMemberUnpaidOrder(MerBaseDto merBaseDto) {
                 return R.fail("获取用户未结清金额失败:" + throwable.getMessage());
             }
+
+            @Override
+            public R sendGoodsGift(List<BirthdayGiftSendDto> giftSendDtoList) {
+                return null;
+            }
         };
     }
 }
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteShopFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteShopFallbackFactory.java
index 7a4fdb7..b012c43 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteShopFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteShopFallbackFactory.java
@@ -97,6 +97,11 @@
             public R<Integer> getUnReplaySuggestVo() {
                 return null;
             }
+
+            @Override
+            public R<Integer> getShopMarketingStatus(Long shopId) {
+                return null;
+            }
         };
     }
 }
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteCouponService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteCouponService.java
index 82f1dcf..849b0f9 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteCouponService.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteCouponService.java
@@ -2,6 +2,7 @@
 
 import com.ruoyi.common.core.constant.ServiceNameConstants;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 import com.ruoyi.system.api.domain.vo.AppMemberCouponVo;
 import com.ruoyi.system.api.domain.vo.MerVerifyCouponGetVo;
 import com.ruoyi.system.api.factory.RemoteCouponFallbackFactory;
@@ -38,4 +39,14 @@
      */
     @PostMapping("/coupon/getVerifyCoupon")
     public R<MerVerifyCouponGetVo> getVerifyCoupon(@RequestBody String verifyCoupon);
+
+    /**
+     * @description  发送用户优惠券礼物
+     * @author  jqs
+     * @date    2023/7/7 19:53
+     * @param giftSendDtoList
+     * @return  R
+     */
+    @PostMapping("/coupon/sendCouponGift")
+    public R sendCouponGift(@RequestBody List<BirthdayGiftSendDto> giftSendDtoList);
 }
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteOrderService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteOrderService.java
index f46ebec..d929ebc 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteOrderService.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteOrderService.java
@@ -2,6 +2,7 @@
 
 import com.ruoyi.common.core.constant.ServiceNameConstants;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 import com.ruoyi.system.api.domain.dto.MerBaseDto;
 import com.ruoyi.system.api.domain.dto.MgtBasePlatformDto;
 import com.ruoyi.system.api.domain.vo.AppOrderTotalVo;
@@ -55,4 +56,14 @@
      */
     @PostMapping("/order/getMemberUnpaidOrder")
     public R<BigDecimal> getMemberUnpaidOrder(@RequestBody MerBaseDto merBaseDto);
+
+    /**
+     * @description  发送用户商品礼物
+     * @author  jqs
+     * @date    2023/7/7 19:53
+     * @param giftSendDtoList
+     * @return  R
+     */
+    @PostMapping("/order/sendGoodsGift")
+    public R sendGoodsGift(@RequestBody List<BirthdayGiftSendDto> giftSendDtoList);
 }
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteShopService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteShopService.java
index 2ef5016..0939dad 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteShopService.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteShopService.java
@@ -97,7 +97,7 @@
      * @param shopTotalChangeDto
      * @return  R
      */
-    @PostMapping("/changeShopTotal")
+    @PostMapping("/shop/changeShopTotal")
     public R changeShopTotal(@RequestBody ShopTotalChangeDto shopTotalChangeDto);
 
     /**
@@ -107,7 +107,7 @@
      * @param userId
      * @return  R<MemberTaskSimpleVo>
      */
-    @PostMapping("/member/getLastMemberTask")
+    @PostMapping("/shop/getLastMemberTask")
     public R<MemberTaskSimpleVo> getLastMemberTask(@RequestBody Long userId);
 
     /**
@@ -116,7 +116,7 @@
      * @date    2023/7/3 17:26
      * @return  R<List<Long>>
      */
-    @PostMapping("/listShopIdByShopId")
+    @PostMapping("/shop/listShopIdByShopId")
     public R<List<Long>> listShopIdByShopId(@RequestBody Long shopId);
 
     /**
@@ -126,6 +126,16 @@
      * @param
      * @return  R<Integer>
      */
-    @PostMapping("/getUnReplaySuggestVo")
+    @PostMapping("/shop/getUnReplaySuggestVo")
     public R<Integer> getUnReplaySuggestVo();
+
+    /**
+     * @description  获取商户营销状态
+     * @author  jqs
+     * @date    2023/7/7 14:05
+     * @param shopId
+     * @return  R<Integer>
+     */
+    @PostMapping("/shop/getShopMarketingStatus")
+    public R<Integer> getShopMarketingStatus(@RequestBody Long shopId);
 }
diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java
index fd87234..29f5c50 100644
--- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java
+++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java
@@ -1,6 +1,10 @@
 package com.ruoyi.file.controller;
 
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.file.FileUtils;
+import com.ruoyi.file.service.ISysFileService;
 import com.ruoyi.file.utils.OBSUploadUtils;
+import com.ruoyi.system.api.domain.poji.sys.SysFile;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -8,10 +12,9 @@
 import org.springframework.web.bind.annotation.RequestPart;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
-import com.ruoyi.common.core.domain.R;
-import com.ruoyi.common.core.utils.file.FileUtils;
-import com.ruoyi.file.service.ISysFileService;
-import com.ruoyi.system.api.domain.poji.sys.SysFile;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 文件请求处理
@@ -67,4 +70,19 @@
         }
     }
 
+    @PostMapping("batchUploadOSS")
+    public R<List<String>> batchUploadOSS(@RequestPart("file") MultipartFile[] files) {
+        List<String> urls = new ArrayList<>();
+        for (MultipartFile file : files) {
+            try {
+                // 上传并返回访问地址
+                String url = OBSUploadUtils.uploadFile(file);
+                urls.add(url);
+            } catch (Exception e) {
+                log.error("上传文件失败", e);
+                return R.fail(e.getMessage());
+            }
+        }
+        return R.ok(urls);
+    }
 }
\ No newline at end of file
diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/OBSUploadUtils.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/OBSUploadUtils.java
index ad8a7ee..54fd586 100644
--- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/OBSUploadUtils.java
+++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/OBSUploadUtils.java
@@ -9,7 +9,6 @@
 import com.ruoyi.common.core.utils.uuid.IdUtils;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.util.Calendar;
 
@@ -64,7 +63,7 @@
             // 创建PutObject请求。
             result = ossClient.putObject(putObjectRequest);
             // 如果上传成功,则返回200。
-            System.out.println(result.getResponse().getStatusCode());
+            System.out.println(fileName + "上传返回" + result.getResponse().getStatusCode());
             return result.getResponse().getUri();
         } catch (OSSException oe) {
             System.out.println("Caught an OSSException, which means your request made it to OSS, "
diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/miniapp/AppActivityController.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/miniapp/AppActivityController.java
index 38f6285..7eb6f61 100644
--- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/miniapp/AppActivityController.java
+++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/miniapp/AppActivityController.java
@@ -85,4 +85,6 @@
         List<AppSimpleActivityGoodsVo> appSimpleGoodsVoList = goodsService.pageAppActivityGoods(page,appActivityGoodsPageDto);
         return R.ok(page.setRecords(appSimpleGoodsVoList));
     }
+
+
 }
diff --git a/ruoyi-modules/ruoyi-goods/src/main/resources/mapper/goods/GoodsMapper.xml b/ruoyi-modules/ruoyi-goods/src/main/resources/mapper/goods/GoodsMapper.xml
index 9d734ed..3c4e25e 100644
--- a/ruoyi-modules/ruoyi-goods/src/main/resources/mapper/goods/GoodsMapper.xml
+++ b/ruoyi-modules/ruoyi-goods/src/main/resources/mapper/goods/GoodsMapper.xml
@@ -417,6 +417,12 @@
             goods_name  goodsName,
             goods_no  goodsNo,
             goods_type  goodsType,
+            CASE goods_type
+            WHEN 1 THEN "周期"
+            WHEN 2 THEN "服务"
+            WHEN 3 THEN "体验"
+            WHEN 4 THEN "单品"
+            END goodsTypeName,
             sales_price  salesPrice
         FROM
             t_goods
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/console/CouponController.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/console/CouponController.java
index f6bd1ab..891e18b 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/console/CouponController.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/console/CouponController.java
@@ -2,7 +2,9 @@
 
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.member.service.coupon.CouponService;
 import com.ruoyi.member.service.member.MemberCouponService;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 import com.ruoyi.system.api.domain.vo.AppMemberCouponVo;
 import com.ruoyi.system.api.domain.vo.MerVerifyCouponGetVo;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -24,6 +26,8 @@
 @RequestMapping("/coupon")
 public class CouponController extends BaseController {
 
+    @Resource
+    private CouponService couponService;
 
     @Resource
     private MemberCouponService memberCouponService;
@@ -69,4 +73,16 @@
         return R.ok(verifyCouponGetVo);
     }
 
+    /**
+     * @description  发送用户优惠券礼物
+     * @author  jqs
+     * @date    2023/7/7 19:53
+     * @param giftSendDtoList
+     * @return  R
+     */
+    @PostMapping("/sendCouponGift")
+    public R sendCouponGift(@RequestBody List<BirthdayGiftSendDto> giftSendDtoList){
+        couponService.sendCouponGift(giftSendDtoList);
+        return R.ok();
+    }
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/miniapp/AppMemberController.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/miniapp/AppMemberController.java
index 53684eb..2dc3419 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/miniapp/AppMemberController.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/miniapp/AppMemberController.java
@@ -2,14 +2,20 @@
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.exception.ServiceException;
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.security.utils.SecurityUtils;
+import com.ruoyi.member.domain.vo.AppBirthdayCardVo;
 import com.ruoyi.member.domain.vo.AppSuggestPageVo;
 import com.ruoyi.member.domain.vo.AppUserInfoVo;
+import com.ruoyi.member.service.birthday.BirthdayCardService;
 import com.ruoyi.member.service.member.MemberService;
 import com.ruoyi.member.service.member.MemberSuggestService;
+import com.ruoyi.system.api.constant.AppErrorConstant;
 import com.ruoyi.system.api.domain.dto.AppEditUserDto;
 import com.ruoyi.system.api.domain.dto.AppSuggestPageDto;
 import com.ruoyi.system.api.domain.dto.AppUserSuggestDto;
+import com.ruoyi.system.api.domain.poji.member.Member;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -18,6 +24,7 @@
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -38,7 +45,8 @@
     @Resource
     private MemberSuggestService memberSuggestService;
 
-
+    @Resource
+    private BirthdayCardService birthdayCardService;
 
 
     @RequestMapping(value = "/getAppUserInfo", method = RequestMethod.POST)
@@ -78,4 +86,55 @@
         memberSuggestService.userSuggest(appUserSuggestDto);
         return R.ok();
     }
+
+    @RequestMapping(value = "/getUserBirthdayCard", method = RequestMethod.POST)
+    @ApiOperation(value = "获取用户生日卡信息")
+    public R<AppBirthdayCardVo> getUserBirthdayCard() {
+        Long userId = SecurityUtils.getUserId();
+        Member member = memberService.getByUserId(userId);
+        AppBirthdayCardVo appBirthdayCardVo = new AppBirthdayCardVo();
+        if(StringUtils.isNotBlank(member.getBirthday())){
+            appBirthdayCardVo.setHaveBirthdayFlag(1);
+            String birthday = member.getBirthday();
+            LocalDate today = LocalDate.now();
+            int birthdayMonth = Integer.parseInt(birthday.split("-")[1]);
+            int todayMonth = today.getMonthValue();
+            if (birthdayMonth == todayMonth) {
+                appBirthdayCardVo = birthdayCardService.getUserBirthdayCard(userId,member.getRelationShopId());
+                appBirthdayCardVo.setHaveBirthdayFlag(1);
+                appBirthdayCardVo.setInBirthdayFlag(1);
+            } else {
+                appBirthdayCardVo.setHaveBirthdayFlag(1);
+                appBirthdayCardVo.setInBirthdayFlag(0);
+            }
+        }else{
+            appBirthdayCardVo.setHaveBirthdayFlag(0);
+        }
+        return R.ok(appBirthdayCardVo);
+    }
+
+    @RequestMapping(value = "/getBirthdayGift", method = RequestMethod.POST)
+    @ApiOperation(value = "领取生日礼包")
+    public R<AppBirthdayCardVo> getBirthdayGift() {
+        Long userId = SecurityUtils.getUserId();
+        Member member = memberService.getByUserId(userId);
+        AppBirthdayCardVo appBirthdayCardVo = new AppBirthdayCardVo();
+        if(StringUtils.isNotBlank(member.getBirthday())){
+            appBirthdayCardVo.setHaveBirthdayFlag(1);
+            String birthday = member.getBirthday();
+            LocalDate today = LocalDate.now();
+            int birthdayMonth = Integer.parseInt(birthday.split("-")[1]);
+            int todayMonth = today.getMonthValue();
+            if (birthdayMonth == todayMonth) {
+                appBirthdayCardVo = birthdayCardService.getBirthdayGift(userId,member.getRelationShopId());
+                appBirthdayCardVo.setHaveBirthdayFlag(1);
+                appBirthdayCardVo.setInBirthdayFlag(1);
+            } else {
+                throw new ServiceException(AppErrorConstant.BIRTHDAY_ERROR);
+            }
+        }else{
+            throw new ServiceException(AppErrorConstant.BIRTHDAY_NULL);
+        }
+        return R.ok(appBirthdayCardVo);
+    }
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/pojo/member/MemberGiftRecord.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/pojo/member/MemberGiftRecord.java
new file mode 100644
index 0000000..05d69c7
--- /dev/null
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/pojo/member/MemberGiftRecord.java
@@ -0,0 +1,130 @@
+package com.ruoyi.member.domain.pojo.member;
+
+import com.baomidou.mybatisplus.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * <p>
+ * 生日卡
+ * </p>
+ *
+ * @author jqs
+ * @since 2023-07-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("t_member_gift_record")
+public class MemberGiftRecord extends Model<MemberGiftRecord> {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+    /**
+     * 删除标记
+     */
+    @TableField("del_flag")
+    private Integer delFlag;
+    /**
+     * 用户id
+     */
+    @TableField("user_id")
+    private Long userId;
+    /**
+     * 生日卡id
+     */
+    @TableField("card_id")
+    private Long cardId;
+    /**
+     * 礼品id
+     */
+    @TableField("gift_id")
+    private Long giftId;
+    /**
+     * 礼物来源1平台2商户
+     */
+    @TableField("gift_from")
+    private Integer giftFrom;
+    /**
+     * 商户id
+     */
+    @TableField("shop_id")
+    private Long shopId;
+    /**
+     * 礼物类型1优惠券2商品3现金4实物
+     */
+    @TableField("gift_type")
+    private Integer giftType;
+    /**
+     * 优惠券id
+     */
+    @TableField("coupon_id")
+    private String couponId;
+    /**
+     * 优惠券数量
+     */
+    @TableField("coupon_number")
+    private Integer couponNumber;
+    /**
+     * 商品id
+     */
+    @TableField("goods_id")
+    private String goodsId;
+    /**
+     * 商品数量
+     */
+    @TableField("goods_number")
+    private Integer goodsNumber;
+    /**
+     * 实物名称
+     */
+    @TableField("gift_name")
+    private String giftName;
+    /**
+     * 实物数量
+     */
+    @TableField("gift_number")
+    private Integer giftNumber;
+    /**
+     * 现金
+     */
+    private BigDecimal money;
+    /**
+     * 创建时间
+     */
+    @TableField("create_time")
+    private Date createTime;
+    /**
+     * 优惠券名称
+     */
+    @TableField("coupon_name")
+    private String couponName;
+    /**
+     * 商品名称
+     */
+    @TableField("goods_name")
+    private String goodsName;
+    /**
+     * 领取年份
+     */
+    @TableField("gift_year")
+    private String giftYear;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/AppBirthdayCardVo.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/AppBirthdayCardVo.java
new file mode 100644
index 0000000..a0e6600
--- /dev/null
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/AppBirthdayCardVo.java
@@ -0,0 +1,30 @@
+package com.ruoyi.member.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @ClassName AppBirthdayCardVo
+ * @Description TODO
+ * @Author jqs
+ * @Date 2023/7/7 10:22
+ * @Version 1.0
+ */
+@Data
+public class AppBirthdayCardVo {
+
+    @ApiModelProperty(value = "是否有生日0否1是")
+    private Integer haveBirthdayFlag;
+
+    @ApiModelProperty(value = "是否生日当月0否1是")
+    private Integer inBirthdayFlag;
+
+    @ApiModelProperty(value = "是否已领取礼物0否1是")
+    private Integer getGiftFlag;
+
+    @ApiModelProperty(value = "礼物列表")
+    private List<AppBirthdayGiftVo> birthdayGiftVoList;
+
+}
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/AppBirthdayGiftVo.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/AppBirthdayGiftVo.java
new file mode 100644
index 0000000..59c1920
--- /dev/null
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/AppBirthdayGiftVo.java
@@ -0,0 +1,23 @@
+package com.ruoyi.member.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @ClassName AppBirthdayGiftVo
+ * @Description TODO
+ * @Author jqs
+ * @Date 2023/7/7 10:25
+ * @Version 1.0
+ */
+@Data
+public class AppBirthdayGiftVo {
+
+
+    @ApiModelProperty(value = "礼物名称")
+    private String giftName;
+
+    @ApiModelProperty(value = "礼物数量")
+    private double giftNumber;
+}
+
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MerBirthdayGetVo.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MerBirthdayGetVo.java
index a152796..dee11b0 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MerBirthdayGetVo.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MerBirthdayGetVo.java
@@ -13,6 +13,7 @@
 @Data
 public class MerBirthdayGetVo {
 
+
     @ApiModelProperty(value = "生日卡状态1开启2关闭")
     private Integer cardStatus;
 
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGetVo.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGetVo.java
index 4e61339..40822ce 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGetVo.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGetVo.java
@@ -37,7 +37,7 @@
     private Date sendTime;
 
     @ApiModelProperty(value = "使用范围1.全场2.指定商品")
-    private String useScope;
+    private Integer useScope;
 
     @ApiModelProperty(value = "有效期类型1.时间段2.领取之日起")
     private Integer validTimeType;
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGoodsListVo.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGoodsListVo.java
index 1ea2d20..f660d82 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGoodsListVo.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponGoodsListVo.java
@@ -25,7 +25,10 @@
     private String goodsNo;
 
     @ApiModelProperty(value = "商品类型1周期2服务3体验4单品")
-    private String goodsType;
+    private Integer goodsType;
+
+    @ApiModelProperty(value = "商品类型1周期2服务3体验4单品")
+    private String goodsTypeName;
 
     @ApiModelProperty(value = "商品售价")
     private BigDecimal salesPrice;
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponPageVo.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponPageVo.java
index 919dc10..1fa13cd 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponPageVo.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/domain/vo/MgtCouponPageVo.java
@@ -24,7 +24,7 @@
     private String couponName;
 
     @ApiModelProperty("优惠券类型1.满减2.折扣3.代金4.商品")
-    private Integer couponType;
+    private String couponType;
 
     @ApiModelProperty(value = "使用限制")
     private String useLimit;
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/mapper/member/MemberGiftRecordMapper.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/mapper/member/MemberGiftRecordMapper.java
new file mode 100644
index 0000000..813bcbf
--- /dev/null
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/mapper/member/MemberGiftRecordMapper.java
@@ -0,0 +1,16 @@
+package com.ruoyi.member.mapper.member;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.member.domain.pojo.member.MemberGiftRecord;
+
+/**
+ * <p>
+ * 生日卡 Mapper 接口
+ * </p>
+ *
+ * @author jqs
+ * @since 2023-07-07
+ */
+public interface MemberGiftRecordMapper extends BaseMapper<MemberGiftRecord> {
+
+}
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/birthday/BirthdayCardService.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/birthday/BirthdayCardService.java
index 3ffd35c..2bff0e8 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/birthday/BirthdayCardService.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/birthday/BirthdayCardService.java
@@ -5,6 +5,7 @@
 import com.ruoyi.member.domain.dto.MgtBirthdayEditDto;
 import com.ruoyi.member.domain.dto.MgtBirthdayGetDto;
 import com.ruoyi.member.domain.pojo.birthday.BirthdayCard;
+import com.ruoyi.member.domain.vo.AppBirthdayCardVo;
 import com.ruoyi.member.domain.vo.MerBirthdayEditInfoVo;
 import com.ruoyi.member.domain.vo.MerBirthdayGetVo;
 import com.ruoyi.member.domain.vo.MgtBirthdayGetVo;
@@ -81,4 +82,25 @@
      * @return  void
      */
     void toggleMerBirthdayCard(MerBirthdayEditDto merBirthdayEditDto);
+
+    /**
+     * @description  获取用户生日礼物
+     * @author  jqs
+     * @date    2023/7/7 10:55
+     * @param shopId
+     * @return  AppBirthdayCardVo
+     */
+    AppBirthdayCardVo getUserBirthdayCard(Long userId,Long shopId);
+
+
+
+    /**
+     * @description  获取用户生日礼物
+     * @author  jqs
+     * @date    2023/7/7 10:55
+     * @param shopId
+     * @return  AppBirthdayCardVo
+     */
+    AppBirthdayCardVo getBirthdayGift(Long userId, Long shopId);
+
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/coupon/CouponService.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/coupon/CouponService.java
index 5c042f0..dffeb63 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/coupon/CouponService.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/coupon/CouponService.java
@@ -5,6 +5,7 @@
 import com.ruoyi.member.domain.pojo.coupon.Coupon;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.member.domain.vo.*;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 import com.ruoyi.system.api.domain.dto.MerBaseGetDto;
 import com.ruoyi.system.api.domain.dto.MerPageDto;
 import com.ruoyi.system.api.domain.dto.MgtBaseGetDto;
@@ -151,4 +152,14 @@
      * @return  void
      */
     void deleteMerCoupon(MerBaseGetDto merBaseGetDto);
+
+
+    /**
+     * @description  发送用户优惠券礼物
+     * @author  jqs
+     * @date    2023/7/7 19:54
+     * @param giftSendDtoList
+     * @return  void
+     */
+    void sendCouponGift(List<BirthdayGiftSendDto> giftSendDtoList);
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/MemberGiftRecordServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/MemberGiftRecordServiceImpl.java
new file mode 100644
index 0000000..d61970c
--- /dev/null
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/MemberGiftRecordServiceImpl.java
@@ -0,0 +1,44 @@
+package com.ruoyi.member.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ruoyi.member.domain.pojo.member.MemberGiftRecord;
+import com.ruoyi.member.mapper.member.MemberGiftRecordMapper;
+import com.ruoyi.member.service.member.MemberGiftRecordService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 生日卡 服务实现类
+ * </p>
+ *
+ * @author jqs
+ * @since 2023-07-07
+ */
+@Service
+public class MemberGiftRecordServiceImpl extends ServiceImpl<MemberGiftRecordMapper, MemberGiftRecord> implements MemberGiftRecordService {
+
+
+    /**
+     * @description  通过用户和日期获取礼物记录
+     * @author  jqs
+     * @date    2023/7/7 17:26
+     * @param userId
+     * @param giftYear
+     * @return  List<MemberGiftRecord>
+     */
+    @Override
+    public List<MemberGiftRecord> listByUserIdAndYear(Long userId, String giftYear){
+        LambdaQueryWrapper<MemberGiftRecord> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(MemberGiftRecord::getDelFlag,0);
+        queryWrapper.eq(MemberGiftRecord::getUserId,userId);
+        queryWrapper.eq(MemberGiftRecord::getGiftYear,giftYear);
+        return this.list(queryWrapper);
+    }
+
+
+
+
+}
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/birthday/BirthdayCardServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/birthday/BirthdayCardServiceImpl.java
index ef991e7..40fe121 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/birthday/BirthdayCardServiceImpl.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/birthday/BirthdayCardServiceImpl.java
@@ -2,26 +2,30 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.utils.bean.BeanUtils;
 import com.ruoyi.member.domain.dto.MerBirthdayEditDto;
 import com.ruoyi.member.domain.dto.MgtBirthdayEditDto;
 import com.ruoyi.member.domain.dto.MgtBirthdayGetDto;
 import com.ruoyi.member.domain.dto.MgtBirthdayGiftDto;
 import com.ruoyi.member.domain.pojo.birthday.BirthdayCard;
 import com.ruoyi.member.domain.pojo.birthday.BirthdayGift;
-import com.ruoyi.member.domain.vo.MerBirthdayEditInfoVo;
-import com.ruoyi.member.domain.vo.MerBirthdayGetVo;
-import com.ruoyi.member.domain.vo.MgtBirthdayGetVo;
-import com.ruoyi.member.domain.vo.MgtBirthdayGiftVo;
+import com.ruoyi.member.domain.pojo.member.MemberGiftRecord;
+import com.ruoyi.member.domain.vo.*;
 import com.ruoyi.member.mapper.birthday.BirthdayCardMapper;
 import com.ruoyi.member.service.birthday.BirthdayCardService;
 import com.ruoyi.member.service.birthday.BirthdayGiftService;
+import com.ruoyi.member.service.member.MemberGiftRecordService;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
+import com.ruoyi.system.api.service.RemoteCouponService;
+import com.ruoyi.system.api.service.RemoteOrderService;
+import com.ruoyi.system.api.service.RemoteShopService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.StringJoiner;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -39,6 +43,18 @@
 
     @Resource
     private BirthdayGiftService birthdayGiftService;
+
+    @Resource
+    private RemoteShopService remoteShopService;
+
+    @Resource
+    private MemberGiftRecordService memberGiftRecordService;
+
+    @Resource
+    private RemoteCouponService remoteCouponService;
+
+    @Resource
+    private RemoteOrderService remoteOrderService;
 
     /**
      * @description  平台编辑生日卡
@@ -394,4 +410,212 @@
         birthdayCard.setCardStatus(merBirthdayEditDto.getCardStatus());
         this.saveOrUpdate(birthdayCard);
     }
+
+    /**
+     * @description 获取用户生日礼物
+     * @author  jqs
+     * @date    2023/7/7 10:55
+     * @param shopId
+     * @return  AppBirthdayCardVo
+     */
+    @Override
+    public AppBirthdayCardVo getUserBirthdayCard(Long userId,Long shopId){
+        AppBirthdayCardVo appBirthdayCardVo = new AppBirthdayCardVo();
+        String currentYear = String.valueOf(LocalDate.now().getYear());
+        List<MemberGiftRecord> memberGiftRecordList = memberGiftRecordService.listByUserIdAndYear(userId,currentYear);
+        if(memberGiftRecordList!=null&&!memberGiftRecordList.isEmpty()){
+            List<AppBirthdayGiftVo> birthdayGiftVoList = memberGiftRecordList.stream().map(
+                    memberGiftRecord -> {
+                        AppBirthdayGiftVo appBirthdayGiftVo = new AppBirthdayGiftVo();
+                        switch (memberGiftRecord.getGiftType()) {
+                            case 1:
+                                // 礼物类型为1,即优惠券
+                                appBirthdayGiftVo.setGiftName(memberGiftRecord.getCouponName());
+                                appBirthdayGiftVo.setGiftNumber(memberGiftRecord.getCouponNumber());
+                                break;
+                            case 2:
+                                // 礼物类型为2,即商品
+                                appBirthdayGiftVo.setGiftName(memberGiftRecord.getGoodsName());
+                                appBirthdayGiftVo.setGiftNumber(memberGiftRecord.getGoodsNumber());
+                                break;
+                            case 3:
+                                // 礼物类型为3,即现金
+                                appBirthdayGiftVo.setGiftName("现金");
+                                appBirthdayGiftVo.setGiftNumber(memberGiftRecord.getMoney().doubleValue());
+                                break;
+                            case 4:
+                                // 礼物类型为4,即礼品
+                                appBirthdayGiftVo.setGiftName(memberGiftRecord.getCouponName());
+                                appBirthdayGiftVo.setGiftNumber(memberGiftRecord.getCouponNumber());
+                                break;
+                            default:
+                                break;
+                        }
+                        return appBirthdayGiftVo;
+                    }
+            ).collect(Collectors.toList());
+            appBirthdayCardVo.setGetGiftFlag(1);
+            appBirthdayCardVo.setBirthdayGiftVoList(birthdayGiftVoList);
+        }else{
+            appBirthdayCardVo.setGetGiftFlag(0);
+        }
+
+        return appBirthdayCardVo;
+    }
+
+    /**
+     * @description  获取用户生日礼物
+     * @author  jqs
+     * @date    2023/7/7 10:55
+     * @param shopId
+     * @return  AppBirthdayCardVo
+     */
+    @Override
+    public AppBirthdayCardVo getBirthdayGift(Long userId, Long shopId){
+        AppBirthdayCardVo appBirthdayCardVo = new AppBirthdayCardVo();
+        List<AppBirthdayGiftVo> birthdayGiftVoList = new ArrayList<>();
+        List<MemberGiftRecord> memberGiftRecordList = new ArrayList<>();
+        List<BirthdayGiftSendDto> sendGoodsList = new ArrayList<>();
+        List<BirthdayGiftSendDto> sendCouponList = new ArrayList<>();
+        AppBirthdayGiftVo appBirthdayGiftVo;
+        MemberGiftRecord memberGiftRecord;
+        BigDecimal winningProbability;
+        BigDecimal randomProbability;
+        BirthdayGiftSendDto birthdayGiftSendDto;
+        String currentYear = String.valueOf(LocalDate.now().getYear());
+        // 获取平台生日卡信息
+        BirthdayCard plBirthdayCard = birthdayCardMapper.getPlatformBirthdayCard(shopId);
+        // 如果生日卡存在
+        if (plBirthdayCard != null && plBirthdayCard.getCardStatus()==1) {
+            // 获取生日卡对应的生日礼物列表
+            List<BirthdayGift> birthdayGiftList = birthdayGiftService.listByCardId(plBirthdayCard.getCardId());
+            if(!birthdayGiftList.isEmpty()){
+                // 遍历生日礼物列表
+                for (BirthdayGift birthdayGift : birthdayGiftList) {
+                    winningProbability = birthdayGift.getWinningProbability();
+                    randomProbability = new BigDecimal(new Random().nextInt(100));
+                    if(winningProbability.compareTo(randomProbability)>0){
+                        appBirthdayGiftVo = new AppBirthdayGiftVo();
+                        memberGiftRecord = new MemberGiftRecord();
+                        birthdayGiftSendDto = new BirthdayGiftSendDto();
+                        BeanUtils.copyProperties(birthdayGift, memberGiftRecord);
+                        memberGiftRecord.setGiftFrom(1);
+                        memberGiftRecord.setGiftYear(currentYear);
+                        memberGiftRecord.setCreateTime(new Date());
+                        memberGiftRecord.setUserId(userId);
+                        birthdayGiftSendDto.setUserId(userId);
+                        birthdayGiftSendDto.setGiftFrom(1);
+                        birthdayGiftSendDto.setGiftType(birthdayGift.getGiftType());
+                        switch (birthdayGift.getGiftType()) {
+                            case 1:
+                                // 礼物类型为1,即优惠券
+                                appBirthdayGiftVo.setGiftName(birthdayGift.getCouponName());
+                                appBirthdayGiftVo.setGiftNumber(birthdayGift.getCouponNumber());
+                                birthdayGiftSendDto.setCouponId(birthdayGift.getCouponId());
+                                birthdayGiftSendDto.setCouponNumber(birthdayGift.getCouponNumber());
+                                sendGoodsList.add(birthdayGiftSendDto);
+                                break;
+                            case 2:
+                                // 礼物类型为2,即商品
+                                appBirthdayGiftVo.setGiftName(birthdayGift.getGoodsName());
+                                appBirthdayGiftVo.setGiftNumber(birthdayGift.getGoodsNumber());
+                                birthdayGiftSendDto.setGoodsId(birthdayGift.getGoodsId());
+                                birthdayGiftSendDto.setCouponNumber(birthdayGift.getGoodsNumber());
+                                sendCouponList.add(birthdayGiftSendDto);
+                                break;
+                            case 3:
+                                // 礼物类型为3,即现金
+                                appBirthdayGiftVo.setGiftName("现金");
+                                appBirthdayGiftVo.setGiftNumber(memberGiftRecord.getMoney().doubleValue());
+                                break;
+                            case 4:
+                                // 礼物类型为4,即礼品
+                                appBirthdayGiftVo.setGiftName(birthdayGift.getCouponName());
+                                appBirthdayGiftVo.setGiftNumber(birthdayGift.getCouponNumber());
+                                break;
+                            default:
+                                break;
+                        }
+                        birthdayGiftVoList.add(appBirthdayGiftVo);
+                        memberGiftRecordList.add(memberGiftRecord);
+                    }
+                }
+            }
+        }
+        //获取商户营销开关状态
+        Integer marketingStatus = remoteShopService.getShopMarketingStatus(shopId).getData();
+        if(marketingStatus>1){
+            //获取商户生日卡
+            LambdaQueryWrapper<BirthdayCard> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(BirthdayCard::getDelFlag,0);
+            queryWrapper.eq(BirthdayCard::getShopId,shopId);
+            BirthdayCard shopBirthdayCard = this.getOne(queryWrapper,false);
+            // 如果生日卡存在
+            if (shopBirthdayCard != null && shopBirthdayCard.getCardStatus()==1) {
+                // 获取生日卡对应的生日礼物列表
+                List<BirthdayGift> birthdayGiftList = birthdayGiftService.listByCardId(shopBirthdayCard.getCardId());
+                if(!birthdayGiftList.isEmpty()){
+                    // 遍历生日礼物列表
+                    for (BirthdayGift birthdayGift : birthdayGiftList) {
+                        winningProbability = birthdayGift.getWinningProbability();
+                        randomProbability = new BigDecimal(new Random().nextInt(100));
+                        if(winningProbability.compareTo(randomProbability)>0){
+                            appBirthdayGiftVo = new AppBirthdayGiftVo();
+                            memberGiftRecord = new MemberGiftRecord();
+                            birthdayGiftSendDto = new BirthdayGiftSendDto();
+                            BeanUtils.copyProperties(birthdayGift, memberGiftRecord);
+                            memberGiftRecord.setGiftFrom(2);
+                            memberGiftRecord.setShopId(shopId);
+                            memberGiftRecord.setGiftYear(currentYear);
+                            memberGiftRecord.setCreateTime(new Date());
+                            memberGiftRecord.setUserId(userId);
+                            birthdayGiftSendDto.setUserId(userId);
+                            birthdayGiftSendDto.setGiftFrom(2);
+                            birthdayGiftSendDto.setShopId(shopId);
+                            birthdayGiftSendDto.setGiftType(birthdayGift.getGiftType());
+                            switch (birthdayGift.getGiftType()) {
+                                case 1:
+                                    // 礼物类型为1,即优惠券
+                                    appBirthdayGiftVo.setGiftName(birthdayGift.getCouponName());
+                                    appBirthdayGiftVo.setGiftNumber(birthdayGift.getCouponNumber());
+                                    birthdayGiftSendDto.setCouponId(birthdayGift.getCouponId());
+                                    birthdayGiftSendDto.setCouponNumber(birthdayGift.getCouponNumber());
+                                    sendGoodsList.add(birthdayGiftSendDto);
+                                    break;
+                                case 2:
+                                    // 礼物类型为2,即商品
+                                    appBirthdayGiftVo.setGiftName(birthdayGift.getGoodsName());
+                                    appBirthdayGiftVo.setGiftNumber(birthdayGift.getGoodsNumber());
+                                    birthdayGiftSendDto.setGoodsId(birthdayGift.getGoodsId());
+                                    birthdayGiftSendDto.setCouponNumber(birthdayGift.getGoodsNumber());
+                                    sendCouponList.add(birthdayGiftSendDto);
+                                    break;
+                                case 3:
+                                    // 礼物类型为3,即现金
+                                    appBirthdayGiftVo.setGiftName("现金");
+                                    appBirthdayGiftVo.setGiftNumber(memberGiftRecord.getMoney().doubleValue());
+                                    break;
+                                case 4:
+                                    // 礼物类型为4,即礼品
+                                    appBirthdayGiftVo.setGiftName(birthdayGift.getCouponName());
+                                    appBirthdayGiftVo.setGiftNumber(birthdayGift.getCouponNumber());
+                                    break;
+                                default:
+                                    break;
+                            }
+                            birthdayGiftVoList.add(appBirthdayGiftVo);
+                            memberGiftRecordList.add(memberGiftRecord);
+                        }
+                    }
+                }
+            }
+        }
+        //发放奖品
+        remoteOrderService.sendGoodsGift(sendGoodsList);
+        remoteCouponService.sendCouponGift(sendCouponList);
+        //保存用户礼物记录
+        memberGiftRecordService.saveBatch(memberGiftRecordList);
+        appBirthdayCardVo.setBirthdayGiftVoList(birthdayGiftVoList);
+        return appBirthdayCardVo;
+    }
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java
index 941066d..dd43e02 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java
@@ -13,6 +13,7 @@
 import com.ruoyi.member.domain.pojo.coupon.CouponRelGoods;
 import com.ruoyi.member.domain.pojo.coupon.CouponRelUser;
 import com.ruoyi.member.domain.pojo.coupon.CouponTotal;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 import com.ruoyi.system.api.domain.dto.MerBaseGetDto;
 import com.ruoyi.system.api.domain.dto.MerPageDto;
 import com.ruoyi.system.api.domain.poji.member.MemberCoupon;
@@ -88,7 +89,7 @@
         List<MgtCouponPageVo> mgtCouponPageVoList = couponMapper.pageMgtCoupon(page, mgtCouponPageDto);
         //处理使用限制和有效期
         if(mgtCouponPageVoList!=null&&!mgtCouponPageVoList.isEmpty()){
-            Integer couponType;
+            String couponType;
             Integer validTimeType;
             Date validStartTime;
             Date validEndTime;
@@ -101,20 +102,10 @@
             for(MgtCouponPageVo mgtCouponPageVo : mgtCouponPageVoList){
                 //处理使用限制
                 couponType = mgtCouponPageVo.getCouponType();
-                switch (couponType){
-                    case 1:
-                        moneyThreshold = mgtCouponPageVo.getMoneyThreshold();
-                        discountMoney = mgtCouponPageVo.getDiscountMoney();
-                        useLimit = "满" + moneyThreshold.toString() + "减" + discountMoney.toString() + "元";
-                        break;
-                    case 2:
-                        break;
-                    case 3:
-                        break;
-                    case 4:
-                        break;
-                    default:
-                        break;
+                if(couponType.equals("满减")){
+                    moneyThreshold = mgtCouponPageVo.getMoneyThreshold();
+                    discountMoney = mgtCouponPageVo.getDiscountMoney();
+                    useLimit = "满" + moneyThreshold.toString() + "减" + discountMoney.toString() + "元";
                 }
                 mgtCouponPageVo.setUseLimit(useLimit);
                 //处理有效期
@@ -160,19 +151,20 @@
                         mgtCouponGoodsListVo.setGoodsId(goods.getGoodsId());
                         mgtCouponGoodsListVo.setGoodsName(goods.getGoodsName());
                         mgtCouponGoodsListVo.setGoodsNo(goods.getGoodsNo());
+                        mgtCouponGoodsListVo.setGoodsType(goods.getGoodsType());
                         //商品类型1周期2服务3体验4单品
                         switch (goods.getGoodsType()){
                             case 1:
-                                mgtCouponGoodsListVo.setGoodsType("周期");
+                                mgtCouponGoodsListVo.setGoodsTypeName("周期");
                                 break;
                             case 2:
-                                mgtCouponGoodsListVo.setGoodsType("服务");
+                                mgtCouponGoodsListVo.setGoodsTypeName("服务");
                                 break;
                             case 3:
-                                mgtCouponGoodsListVo.setGoodsType("体验");
+                                mgtCouponGoodsListVo.setGoodsTypeName("体验");
                                 break;
                             case 4:
-                                mgtCouponGoodsListVo.setGoodsType("单品");
+                                mgtCouponGoodsListVo.setGoodsTypeName("单品");
                                 break;
                             default:
                                 break;
@@ -544,19 +536,20 @@
                         mgtCouponGoodsListVo.setGoodsId(goods.getGoodsId());
                         mgtCouponGoodsListVo.setGoodsName(goods.getGoodsName());
                         mgtCouponGoodsListVo.setGoodsNo(goods.getGoodsNo());
+                        mgtCouponGoodsListVo.setGoodsType(goods.getGoodsType());
                         //商品类型1周期2服务3体验4单品
                         switch (goods.getGoodsType()){
                             case 1:
-                                mgtCouponGoodsListVo.setGoodsType("周期");
+                                mgtCouponGoodsListVo.setGoodsTypeName("周期");
                                 break;
                             case 2:
-                                mgtCouponGoodsListVo.setGoodsType("服务");
+                                mgtCouponGoodsListVo.setGoodsTypeName("服务");
                                 break;
                             case 3:
-                                mgtCouponGoodsListVo.setGoodsType("体验");
+                                mgtCouponGoodsListVo.setGoodsTypeName("体验");
                                 break;
                             case 4:
-                                mgtCouponGoodsListVo.setGoodsType("单品");
+                                mgtCouponGoodsListVo.setGoodsTypeName("单品");
                                 break;
                             default:
                                 break;
@@ -832,4 +825,57 @@
         coupon.setUpdateTime(new Date());
         this.saveOrUpdate(coupon);
     }
+
+    /**
+     * @description  发送用户优惠券礼物
+     * @author  jqs
+     * @date    2023/7/7 19:54
+     * @param giftSendDtoList
+     * @return  void
+     */
+    @Override
+    public void sendCouponGift(List<BirthdayGiftSendDto> giftSendDtoList){
+        Long userId = giftSendDtoList.get(0).getUserId();
+        Long shopId = giftSendDtoList.get(0).getShopId();
+        String couponId;
+        Coupon coupon;
+        List<MemberCoupon> memberCouponList = new ArrayList<>();
+        MemberCoupon memberCoupon;
+        String memberCouponId;
+        for(BirthdayGiftSendDto birthdayGiftSendDto : giftSendDtoList){
+            couponId = birthdayGiftSendDto.getCouponId();
+            coupon = this.getById(couponId);
+            memberCoupon = new MemberCoupon();
+            memberCouponId = IdUtils.simpleUUID();
+            memberCoupon.setId(memberCouponId);
+            memberCoupon.setDelFlag(0);
+            memberCoupon.setCouponId(couponId);
+            memberCoupon.setUserId(userId);
+            memberCoupon.setShopId(shopId);
+            memberCoupon.setCouponType(coupon.getCouponType());
+            memberCoupon.setCouponStatus(coupon.getCouponStatus());
+            memberCoupon.setCouponName(coupon.getCouponName());
+            memberCoupon.setSendType(coupon.getSendType());
+            memberCoupon.setSendTimeType(coupon.getSendTimeType());
+            memberCoupon.setSendTime(coupon.getSendTime());
+            memberCoupon.setMoneyThreshold(coupon.getMoneyThreshold());
+            memberCoupon.setDiscountMoney(coupon.getDiscountMoney());
+            memberCoupon.setDiscountPercent(coupon.getDiscountPercent());
+            memberCoupon.setUseScope(coupon.getUseScope());
+            memberCoupon.setValidTimeType(coupon.getValidTimeType());
+            memberCoupon.setValidStartTime(coupon.getValidStartTime());
+            memberCoupon.setValidEndTime(coupon.getValidEndTime());
+            memberCoupon.setValidDay(coupon.getValidDay());
+            memberCoupon.setReceiveTime(new Date());
+            //有效期处理1.时间段2.领取之日起
+            if(coupon.getValidTimeType()==1){
+                memberCoupon.setDeadlineTime(coupon.getValidEndTime());
+            }else if(coupon.getValidTimeType()==2){
+                memberCoupon.setDeadlineTime(DateUtils.addDays(new Date(),coupon.getValidDay()));
+            }
+            memberCoupon.setRelGoodsIds(coupon.getRelGoodsIds());
+            memberCouponList.add(memberCoupon);
+        }
+        memberCouponService.saveBatch(memberCouponList);
+    }
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java
index 16c5936..f5d5e86 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java
@@ -151,4 +151,5 @@
         Integer total = this.count(queryWrapper);
         return total;
     }
+
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/member/MemberCouponService.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/member/MemberCouponService.java
index 2c7f6b4..c70926b 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/member/MemberCouponService.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/member/MemberCouponService.java
@@ -1,7 +1,7 @@
 package com.ruoyi.member.service.member;
 
-import com.ruoyi.system.api.domain.poji.member.MemberCoupon;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.system.api.domain.poji.member.MemberCoupon;
 import com.ruoyi.system.api.domain.vo.AppMemberCouponVo;
 import com.ruoyi.system.api.domain.vo.MerVerifyCouponGetVo;
 
@@ -48,8 +48,10 @@
      * @author  jqs
      * @date    2023/6/29 11:43
      * @param userId
- * @param couponId
+     * @param couponId
      * @return  Integer
      */
     Integer totalMemberCouponByUserAndCoupon(Long userId,String couponId);
+
+
 }
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/member/MemberGiftRecordService.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/member/MemberGiftRecordService.java
new file mode 100644
index 0000000..72e3db3
--- /dev/null
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/member/MemberGiftRecordService.java
@@ -0,0 +1,28 @@
+package com.ruoyi.member.service.member;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.member.domain.pojo.member.MemberGiftRecord;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 生日卡 服务类
+ * </p>
+ *
+ * @author jqs
+ * @since 2023-07-07
+ */
+public interface MemberGiftRecordService extends IService<MemberGiftRecord> {
+
+
+    /**
+     * @description  通过用户和日期获取礼物记录
+     * @author  jqs
+     * @date    2023/7/7 17:26
+     * @param userId
+     * @param giftYear
+     * @return  List<MemberGiftRecord>
+     */
+    List<MemberGiftRecord> listByUserIdAndYear(Long userId,String giftYear);
+}
diff --git a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml
index cba2106..632a9a3 100644
--- a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml
+++ b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml
@@ -177,7 +177,7 @@
         tc.create_time  createTime
         FROM t_coupon tc
         LEFT JOIN t_coupon_total tct ON tc.coupon_id = tct.coupon_id
-        WHERE tc.del_flag = 0 AND tc.coupon_status = 2
+        WHERE tc.del_flag = 0 AND tc.audit_status = 2
         <if test="param.shopId==null">
             AND tc.coupon_from = 1
         </if>
diff --git a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponRelUserMapper.xml b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponRelUserMapper.xml
index 0469167..8161825 100644
--- a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponRelUserMapper.xml
+++ b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponRelUserMapper.xml
@@ -72,6 +72,6 @@
         FROM
             t_coupon_rel_user tcru
                 INNER JOIN t_member tm ON tm.user_id = tcru.user_id
-        WHERE tm.del_flag = 0 AND tcru.coupon_id = #{couponId}
+        WHERE tm.del_flag = 0 AND tcru.del_flag = 0 AND tcru.coupon_id = #{couponId}
     </select>
 </mapper>
diff --git a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberGiftRecordMapper.xml b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberGiftRecordMapper.xml
new file mode 100644
index 0000000..5798a9d
--- /dev/null
+++ b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberGiftRecordMapper.xml
@@ -0,0 +1,7 @@
+<?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.ruoyi.member.mapper.member.MemberGiftRecordMapper">
+
+
+
+</mapper>
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/concole/OrderController.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/concole/OrderController.java
index d22ed92..ccc0ce9 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/concole/OrderController.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/concole/OrderController.java
@@ -1,7 +1,9 @@
 package com.ruoyi.order.controller.concole;
 
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.order.service.order.ConsumerGoodsService;
 import com.ruoyi.order.service.order.OrderService;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 import com.ruoyi.system.api.domain.dto.MerBaseDto;
 import com.ruoyi.system.api.domain.dto.MgtBasePlatformDto;
 import com.ruoyi.system.api.domain.vo.AppOrderTotalVo;
@@ -30,6 +32,9 @@
 
     @Resource
     private OrderService orderService;
+
+    @Resource
+    private ConsumerGoodsService consumerGoodsService;
 
 
     @PostMapping("/getAppOrderTotal")
@@ -89,4 +94,16 @@
         return R.ok(unpaidMoney);
     }
 
+    /**
+     * @description  发送用户商品礼物
+     * @author  jqs
+     * @date    2023/7/7 19:53
+     * @param giftSendDtoList
+     * @return  R
+     */
+    @PostMapping("/sendGoodsGift")
+    public R sendGoodsGift(@RequestBody List<BirthdayGiftSendDto> giftSendDtoList){
+        consumerGoodsService.sendGoodsGift(giftSendDtoList);
+        return R.ok();
+    }
 }
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/domain/pojo/order/OrderGoods.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/domain/pojo/order/OrderGoods.java
index 663c98d..b64db03 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/domain/pojo/order/OrderGoods.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/domain/pojo/order/OrderGoods.java
@@ -62,6 +62,9 @@
      */
     @TableField("goods_price")
     private BigDecimal goodsPrice;
+
+    @TableField("goods_deposit")
+    private BigDecimal goodsDeposit;
     /**
      * 商品总价
      */
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java
index 84e8d05..b0155f3 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java
@@ -5,6 +5,7 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.order.domain.dto.*;
 import com.ruoyi.order.domain.pojo.order.ConsumerGoods;
 import com.ruoyi.order.domain.pojo.order.UserServiceRecord;
@@ -16,15 +17,22 @@
 import com.ruoyi.order.service.order.ConsumerGoodsService;
 import com.ruoyi.order.service.order.UserServiceRecordService;
 import com.ruoyi.system.api.constant.AppErrorConstant;
+import com.ruoyi.system.api.domain.dto.AppShopGoodsGetDto;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 import com.ruoyi.system.api.domain.dto.MemberTotalChangeDto;
 import com.ruoyi.system.api.domain.dto.ShopTotalChangeDto;
+import com.ruoyi.system.api.domain.poji.goods.Goods;
+import com.ruoyi.system.api.domain.poji.goods.GoodsFile;
+import com.ruoyi.system.api.domain.poji.goods.ShopGoods;
+import com.ruoyi.system.api.service.RemoteGoodsService;
 import com.ruoyi.system.api.service.RemoteMemberService;
 import com.ruoyi.system.api.service.RemoteShopService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -48,6 +56,9 @@
 
     @Resource
     private RemoteShopService remoteShopService;
+
+    @Resource
+    private RemoteGoodsService remoteGoodsService;
 
     /**
      * 获取用户服务
@@ -147,7 +158,7 @@
     }
 
     /**
-     * 确认商品次数
+     * 消费服务商品
      * @param merSureConsumerGoodsDto
      */
     @Override
@@ -286,4 +297,143 @@
     public MerMemberConsumerGoodsTotalVo getMemberConsumerGoodsTotalVo(Long userId, Long shopId){
         return consumerGoodsMapper.getMemberConsumerGoodsTotalVo(userId, shopId);
     }
+
+    /**
+     * @description  发放用户商品礼物
+     * @author  jqs
+     * @date    2023/7/7 18:51
+     * @param giftSendDtoList
+     * @return  void
+     */
+    @Override
+    public void sendGoodsGift(List<BirthdayGiftSendDto> giftSendDtoList){
+        // 使用StringJoiner拼接goodsId
+        StringJoiner goodsSj = new StringJoiner(",");
+        for (BirthdayGiftSendDto birthdayGiftSendDto : giftSendDtoList) {
+            goodsSj.add(birthdayGiftSendDto.getGoodsId());
+        }
+        String goodsIds = goodsSj.toString();
+        // 获取商品列表
+        List<Goods> goodsList = remoteGoodsService.listGoodsByGoodsId(goodsIds).getData();
+        // 初始化变量
+        List<ConsumerGoods> consumerGoodsList = new ArrayList<>();
+        Map<String, Goods> goodsMap = goodsList.stream()
+                .collect(Collectors.toMap(Goods::getGoodsId, Function.identity()));
+        ConsumerGoods consumerGoods;
+        String consumerGoodsId;
+        Goods goods;
+        String goodsId;
+        GoodsFile goodsFile;
+        AppShopGoodsGetDto appShopGoodsGetDto;
+        ShopGoods shopGoods = null;
+        // 遍历giftSendDtoList
+        for (BirthdayGiftSendDto birthdayGiftSendDto : giftSendDtoList) {
+            goodsId = birthdayGiftSendDto.getGoodsId();
+            goods = goodsMap.get(goodsId);
+            goodsFile = remoteGoodsService.getGoodsFile(goods.getGoodsId()).getData();
+            // 获取商户服务次数
+            if (birthdayGiftSendDto.getGiftFrom() == 2) {
+                appShopGoodsGetDto = new AppShopGoodsGetDto();
+                appShopGoodsGetDto.setGoodsId(goodsId);
+                appShopGoodsGetDto.setShopId(birthdayGiftSendDto.getShopId());
+                shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData();
+            }
+            // 根据goodsNumber创建ConsumerGoods对象并添加到列表中
+            for (int i = 0; i < birthdayGiftSendDto.getGoodsNumber(); i++) {
+                consumerGoods = new ConsumerGoods();
+                consumerGoodsId = IdUtils.simpleUUID();
+                consumerGoods.setConsumerGoodsId(consumerGoodsId);
+                consumerGoods.setDelFlag(0);
+                consumerGoods.setServiceStatus(1);
+                consumerGoods.setShopId(birthdayGiftSendDto.getShopId());
+                consumerGoods.setUserId(birthdayGiftSendDto.getUserId());
+                consumerGoods.setGoodsId(goodsId);
+                consumerGoods.setGoodsName(goods.getGoodsName());
+                consumerGoods.setCycleNumFlag(goods.getCycleNumFlag());
+                consumerGoods.setServiceNum(goods.getServiceNum());
+                consumerGoods.setUsedNum(0);
+                consumerGoods.setCreateTime(new Date());
+                consumerGoods.setGoodsType(goods.getGoodsType());
+                consumerGoods.setGoodsIntroduction(goods.getGoodsIntroduction());
+                consumerGoods.setGoodsPicture(goodsFile.getFileUrl());
+                consumerGoods.setGoodsNurses(goods.getGoodsNurses());
+                consumerGoods.setSourceFrom(3);
+                // 如果shopGoods不为空,则使用shopGoods的serviceNum
+                if (shopGoods != null) {
+                    consumerGoods.setServiceNum(shopGoods.getServiceNum());
+                }
+                consumerGoodsList.add(consumerGoods);
+            }
+        }
+        // 批量保存consumerGoodsList
+        this.saveBatchConsumerGoods(consumerGoodsList);
+    }
+
+
+    /**
+     * @description
+     * @author  jqs
+     * @date    2023/7/7 19:31
+     * @param consumerGoodsList
+     * @return  boolean
+     */
+    @Override
+    public boolean saveBatchConsumerGoods(List<ConsumerGoods> consumerGoodsList){
+        Integer serviceCount = 0;
+        Integer cycleService = 0;
+        Integer cyclePerson = 0;
+        Integer serviceService = 0;
+        Integer servicePerson = 0;
+        Integer experienceService = 0;
+        Integer experiencePerson = 0;
+        Long shopId = consumerGoodsList.get(0).getShopId();
+        Long userId = consumerGoodsList.get(0).getUserId();
+        MerMemberConsumerGoodsTotalVo memberConsumerGoodsTotalVo = this.getMemberConsumerGoodsTotalVo(userId, shopId);
+        for(ConsumerGoods consumerGoods : consumerGoodsList){
+            //处理商品服务次数
+            switch (consumerGoods.getGoodsType()) {
+                case 1:
+                    cycleService = cycleService + consumerGoods.getServiceNum();
+                    break;
+                case 2:
+                    serviceService = serviceService + consumerGoods.getServiceNum();
+                    break;
+                case 3:
+                    experienceService = experienceService + consumerGoods.getServiceNum();
+                    break;
+                default:
+                    break;
+            }
+        }
+        //判断是否加人
+        if (cycleService > 0 && memberConsumerGoodsTotalVo.getCycleOrder() == 0) {
+            cyclePerson = 1;
+        }
+        if (serviceService > 0 && memberConsumerGoodsTotalVo.getServiceOrder() == 0) {
+            servicePerson = 1;
+        }
+        if (experienceService > 0 && memberConsumerGoodsTotalVo.getExperienceOrder() == 0) {
+            experiencePerson = 1;
+        }
+        serviceCount = cycleService + serviceService + experienceService;
+        //更新商户和会员服务统计
+        MemberTotalChangeDto memberTotalChangeDto = new MemberTotalChangeDto();
+        memberTotalChangeDto.setUserId(userId);
+        memberTotalChangeDto.setTypeService(1);
+        memberTotalChangeDto.setServiceCount(serviceCount);
+        remoteMemberService.changeMemberTotal(memberTotalChangeDto);
+        ShopTotalChangeDto shopTotalChangeDto = new ShopTotalChangeDto();
+        shopTotalChangeDto.setShopId(shopId);
+        shopTotalChangeDto.setTypeCycleService(1);
+        shopTotalChangeDto.setCycleService(cycleService);
+        shopTotalChangeDto.setCyclePerson(cyclePerson);
+        shopTotalChangeDto.setTypeServiceService(1);
+        shopTotalChangeDto.setServiceService(serviceService);
+        shopTotalChangeDto.setServicePerson(servicePerson);
+        shopTotalChangeDto.setTypeExperienceService(1);
+        shopTotalChangeDto.setExperienceService(experienceService);
+        shopTotalChangeDto.setExperiencePerson(experiencePerson);
+        remoteShopService.changeShopTotal(shopTotalChangeDto);
+        return this.saveBatch(consumerGoodsList);
+    }
 }
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
index bde96b6..6ac5722 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -210,14 +210,14 @@
     }
 
     /**
-     * @description  抢购商品
-     * @author  jqs
-     * @date    2023/7/6 11:45
      * @param appPanicBuyDto
-     * @return  AppSureOrderVo
+     * @return AppSureOrderVo
+     * @description 抢购商品
+     * @author jqs
+     * @date 2023/7/6 11:45
      */
     @Override
-    public AppPanicBuyVo panicBuyGoods(AppPanicBuyDto appPanicBuyDto){
+    public AppPanicBuyVo panicBuyGoods(AppPanicBuyDto appPanicBuyDto) {
         Long userId = appPanicBuyDto.getUserId();
         AppPanicBuyVo appPanicBuyVo = new AppPanicBuyVo();
         String activityId = appPanicBuyDto.getActivityId();
@@ -238,13 +238,13 @@
         activityGoodsGetDto.setGoodsId(goodsId);
         activityGoodsGetDto.setUserId(userId);
         ActivityGoodsGetVo activityGoodsGetVo = remoteActivityService.getUserActivityGoods(activityGoodsGetDto).getData();
-        if(activityGoodsGetVo.getActivityStatus()==0){
+        if (activityGoodsGetVo.getActivityStatus() == 0) {
             throw new ServiceException(AppErrorConstant.ACTIVITY_NO_START);
         }
-        if(activityGoodsGetVo.getActivityStatus()==2){
+        if (activityGoodsGetVo.getActivityStatus() == 2) {
             throw new ServiceException(AppErrorConstant.ACTIVITY_END);
         }
-        if(activityGoodsGetVo.getAvailableBuyNum()<1){
+        if (activityGoodsGetVo.getAvailableBuyNum() < 1) {
             throw new ServiceException(AppErrorConstant.ACTIVITY_GOODS_NULL);
         }
         Goods goods = remoteGoodsService.getGoods(goodsId).getData();
@@ -295,11 +295,16 @@
      */
     @Override
     public AppPlaceOrderVo placeOrder(AppPlaceOrderDto appPlaceOrderDto) {
+        // 获取用户ID
         Long userId = appPlaceOrderDto.getUserId();
+        // 创建下单视图对象
         AppPlaceOrderVo appPlaceOrderVo = new AppPlaceOrderVo();
+        // 创建商品列表
         List<AppSureOrderGoodsVo> appSureOrderGoodsVoList = new ArrayList<>();
         AppSureOrderGoodsVo appSureOrderGoodsVo;
+        // 获取购买的商品列表
         List<AppBuyGoodsDto> appBuyGoodsDtoList = appPlaceOrderDto.getAppBuyGoodsDtoList();
+        // 初始化变量
         String goodsId;
         Integer buyNum;
         BigDecimal buyNumBig;
@@ -311,7 +316,9 @@
         BigDecimal goodsPrice;
         BigDecimal goodsTotalPrice;
         BigDecimal goodsRealPrice;
+        // 获取用户优惠券列表
         List<AppMemberCouponVo> appMemberCouponVoList = remoteCouponService.listVoMemberCouponByUserId(userId).getData();
+        // 将用户优惠券列表转换为Map,方便后续查找
         Map<String, AppMemberCouponVo> appMemberCouponVoMap = appMemberCouponVoList.stream().collect(Collectors.toMap(AppMemberCouponVo::getMemberCouponId, Function.identity()));
         AppMemberCouponVo appMemberCouponVo;
         Integer couponType;
@@ -324,45 +331,58 @@
         BigDecimal couponDiscount = new BigDecimal("0.00");
         BigDecimal orderPayDeposit = new BigDecimal("0.00");
         BigDecimal orderPayMoney = new BigDecimal("0.00");
+        // 创建订单ID和订单号
         String orderId = IdUtils.simpleUUID();
         String orderNo = CodeFactoryUtil.getShopOrderNo();
         OrderGoods orderGoods;
         String orderGoodsId;
+        // 创建商品类型集合,用于记录订单中所有商品的类型
         HashSet<String> goodsTypeSet = new HashSet<>();
+        // 遍历购买的商品列表
         for (AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList) {
             appSureOrderGoodsVo = new AppSureOrderGoodsVo();
             useCoupon = 0;
+            // 获取商品ID和优惠券ID
             goodsId = appBuyGoodsDto.getGoodsId();
             memberCouponId = appBuyGoodsDto.getMemberCouponId();
+            // 获取商品信息
             goods = remoteGoodsService.getGoods(goodsId).getData();
+            // 设置商品信息
             appSureOrderGoodsVo.setGoodsId(goodsId);
             appSureOrderGoodsVo.setGoodsName(goods.getGoodsName());
             appSureOrderGoodsVo.setGoodsIntroduction(goods.getGoodsIntroduction());
             appSureOrderGoodsVo.setGoodsType(goods.getGoodsType());
-            //商品图片
+            // 获取商品图片
             goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData();
             appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl());
+            // 获取购买数量
             buyNum = appBuyGoodsDto.getBuyNum();
             appSureOrderGoodsVo.setBuyNum(buyNum);
+            // 获取商品价格和服务数量
             goodsPrice = goods.getSalesPrice();
             serviceNum = goods.getServiceNum();
-            //商户定制价格
+            // 获取商户定制价格
             AppShopGoodsGetDto appShopGoodsGetDto = new AppShopGoodsGetDto();
             appShopGoodsGetDto.setGoodsId(goods.getGoodsId());
             appShopGoodsGetDto.setShopId(appPlaceOrderDto.getShopId());
             ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData();
+            // 如果商户定制价格存在,则使用商户定制价格和服务数量
             if (shopGoods != null) {
                 goodsPrice = shopGoods.getSalesPrice();
                 serviceNum = shopGoods.getServiceNum();
             }
             appSureOrderGoodsVo.setGoodsPrice(goodsPrice);
+            // 计算商品总价
             buyNumBig = BigDecimal.valueOf(buyNum);
             goodsTotalPrice = goodsPrice.multiply(buyNumBig);
             goodsRealPrice = goodsTotalPrice;
+            // 如果使用了优惠券,计算优惠后的价格
             if (memberCouponId != null) {
                 appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId);
+                // 如果优惠券适用于该商品
                 if (StringUtils.isBlank(appMemberCouponVo.getRelGoodsIds()) || appMemberCouponVo.getRelGoodsIds().contains(goodsId)) {
                     couponType = appMemberCouponVo.getCouponType();
+                    // 根据优惠券类型计算优惠后的价格
                     if (couponType == 1 && appMemberCouponVo.getMoneyThreshold() != null && appMemberCouponVo.getDiscountMoney() != null) {
                         moneyThreshold = appMemberCouponVo.getMoneyThreshold();
                         if (goodsTotalPrice.compareTo(moneyThreshold) >= 0) {
@@ -386,17 +406,19 @@
             appSureOrderGoodsVo.setGoodsTotalPrice(goodsTotalPrice);
             appSureOrderGoodsVo.setCouponDiscount(discountMoney);
             appSureOrderGoodsVo.setGoodsRealPrice(goodsRealPrice);
+            // 获取商品押金
             goodsDeposit = goods.getSubscription();
             if (goodsDeposit == null) {
                 goodsDeposit = new BigDecimal("0.00");
             }
             appSureOrderGoodsVo.setGoodsDeposit(goodsDeposit);
+            // 计算商品总数量、商品总价、优惠总金额、支付押金、支付金额
             goodsNum = goodsNum + buyNum;
             orderGoodsMoney = orderGoodsMoney.add(goodsTotalPrice);
             couponDiscount = couponDiscount.add(discountMoney);
             orderPayDeposit = orderPayDeposit.add(goodsDeposit);
             orderPayMoney = orderPayMoney.add(goodsRealPrice);
-            //创建OrderGoods
+            // 创建订单商品
             orderGoods = new OrderGoods();
             orderGoodsId = IdUtils.simpleUUID();
             orderGoods.setOrderGoodsId(orderGoodsId);
@@ -408,6 +430,7 @@
                 orderGoods.setCouponId(memberCouponId.toString());
             }
             orderGoods.setGoodsPrice(goodsPrice);
+            orderGoods.setGoodsDeposit(goodsDeposit);
             orderGoods.setGoodsTotalMoney(orderGoodsMoney);
             orderGoods.setGoodsReceivableMoney(goodsRealPrice);
             orderGoods.setCycleNumFlag(goods.getCycleNumFlag());
@@ -415,12 +438,14 @@
             orderGoods.setGoodsType(goods.getGoodsType());
             orderGoods.setGoodsName(goods.getGoodsName());
             orderGoods.setGoodsPicture(goodsFile.getFileUrl());
+            // 保存订单商品
             orderGoodsService.save(orderGoods);
-            //清空购物车
+            // 清空购物车
             AppShoppingCartDelDto appShoppingCartDelDto = new AppShoppingCartDelDto();
             appShoppingCartDelDto.setGoodsId(goodsId);
             appShoppingCartDelDto.setUserId(userId);
             remoteShoppingCartService.deleteShoppingCart(appShoppingCartDelDto);
+            // 记录商品类型
             if (goods.getGoodsType() == 1) {
                 goodsTypeSet.add("周期");
             } else if (goods.getGoodsType() == 2) {
@@ -431,10 +456,10 @@
                 goodsTypeSet.add("单品");
             }
         }
+        // 创建订单
         Order order = new Order();
         order.setOrderId(orderId);
         order.setDelFlag(0);
-        //为对接支付 直接付款成功
         order.setOrderStatus(1);
         order.setOrderNo(orderNo);
         order.setOrderFrom(1);
@@ -447,6 +472,7 @@
         order.setReceivableDeposit(orderPayDeposit);
         order.setChangeReceivableMoney(orderPayMoney);
         order.setPayType(appPlaceOrderDto.getPayType());
+        // 根据支付类型计算支付金额
         if (order.getPayType() == 1) {
             order.setPayMoney(orderPayMoney);
             order.setOnlinePayMoney(orderPayMoney);
@@ -463,8 +489,9 @@
         order.setOrderRemark(appPlaceOrderDto.getOrderRemark());
         order.setGoodsNum(goodsNum);
         order.setCreateTime(new Date());
+        // 保存订单
         this.save(order);
-        //更新用户商品类型
+        // 更新用户商品类型
         if (goodsTypeSet != null && goodsTypeSet.size() > 0) {
             AppMemberGoodsTypeDto appMemberGoodsTypeDto = new AppMemberGoodsTypeDto();
             appMemberGoodsTypeDto.setUserId(userId);
@@ -473,31 +500,33 @@
         }
         appPlaceOrderVo.setOrderId(orderId);
         appPlaceOrderVo.setOrderNo(orderNo);
-
-        //调用支付
-
-
+        // 调用支付
         return appPlaceOrderVo;
     }
 
     /**
-     * @description  创建活动订单
-     * @author  jqs
-     * @date    2023/7/6 17:59
      * @param appPlaceActivityDto
-     * @return  AppPlaceOrderVo
+     * @return AppPlaceOrderVo
+     * @description 创建活动订单
+     * @author jqs
+     * @date 2023/7/6 17:59
      */
     @Override
-    public AppPlaceOrderVo placeActivityOrder( AppPlaceActivityDto appPlaceActivityDto){
+    public AppPlaceOrderVo placeActivityOrder(AppPlaceActivityDto appPlaceActivityDto) {
         Long userId = appPlaceActivityDto.getUserId();
+        // 创建订单对象
         AppPlaceOrderVo appPlaceOrderVo = new AppPlaceOrderVo();
+        // 定义商品订单对象
         AppSureOrderGoodsVo appSureOrderGoodsVo;
+        // 获取活动ID,商品ID,购买数量
         String activityId = appPlaceActivityDto.getActivityId();
         String goodsId = appPlaceActivityDto.getGoodsId();
         Integer buyNum = appPlaceActivityDto.getBuyNum();
+        // 定义购买数量,服务数量,商品数量
         BigDecimal buyNumBig;
         Integer serviceNum;
         Integer goodsNum = 0;
+        // 定义商品,商品文件,商品价格,商品总价,商品实际价格,折扣金额,折扣百分比,商品押金,使用优惠券,订单商品金额,优惠券折扣,订单支付押金,订单支付金额
         Goods goods;
         GoodsFile goodsFile;
         BigDecimal goodsPrice;
@@ -511,25 +540,32 @@
         BigDecimal couponDiscount = new BigDecimal("0.00");
         BigDecimal orderPayDeposit = new BigDecimal("0.00");
         BigDecimal orderPayMoney = new BigDecimal("0.00");
+        // 创建活动商品对象,并设置活动ID,商品ID,用户ID
         ActivityGoodsGetDto activityGoodsGetDto = new ActivityGoodsGetDto();
         activityGoodsGetDto.setActivityId(activityId);
         activityGoodsGetDto.setGoodsId(goodsId);
         activityGoodsGetDto.setUserId(userId);
+        // 获取用户活动商品
         ActivityGoodsGetVo activityGoodsGetVo = remoteActivityService.getUserActivityGoods(activityGoodsGetDto).getData();
-        if(activityGoodsGetVo.getActivityStatus()==0){
+        // 检查活动状态
+        if (activityGoodsGetVo.getActivityStatus() == 0) {
             throw new ServiceException(AppErrorConstant.ACTIVITY_NO_START);
         }
-        if(activityGoodsGetVo.getActivityStatus()==2){
+        if (activityGoodsGetVo.getActivityStatus() == 2) {
             throw new ServiceException(AppErrorConstant.ACTIVITY_END);
         }
-        if(activityGoodsGetVo.getAvailableBuyNum()<1){
+        if (activityGoodsGetVo.getAvailableBuyNum() < 1) {
             throw new ServiceException(AppErrorConstant.ACTIVITY_GOODS_NULL);
         }
+        // 创建订单ID和订单号
         String orderId = IdUtils.simpleUUID();
         String orderNo = CodeFactoryUtil.getShopOrderNo();
+        // 创建订单商品对象和订单商品ID
         OrderGoods orderGoods;
         String orderGoodsId;
+        // 创建商品类型集合
         HashSet<String> goodsTypeSet = new HashSet<>();
+        // 创建商品订单对象,并设置商品ID,商品名称,商品介绍,商品类型
         appSureOrderGoodsVo = new AppSureOrderGoodsVo();
         useCoupon = 0;
         goodsId = appPlaceActivityDto.getGoodsId();
@@ -538,34 +574,38 @@
         appSureOrderGoodsVo.setGoodsName(goods.getGoodsName());
         appSureOrderGoodsVo.setGoodsIntroduction(goods.getGoodsIntroduction());
         appSureOrderGoodsVo.setGoodsType(goods.getGoodsType());
-        //商品图片
+        // 获取商品图片
         goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData();
         appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl());
-        buyNum = appPlaceActivityDto.getBuyNum();
+        // 设置购买数量,商品价格,服务数量
         appSureOrderGoodsVo.setBuyNum(buyNum);
         goodsPrice = goods.getSalesPrice();
         serviceNum = goods.getServiceNum();
-        //活动价格
+        // 获取活动价格
         goodsPrice = activityGoodsGetVo.getActivityPrice();
         appSureOrderGoodsVo.setGoodsPrice(goodsPrice);
+        // 计算商品总价,商品实际价格
         buyNumBig = BigDecimal.valueOf(buyNum);
         goodsTotalPrice = goodsPrice.multiply(buyNumBig);
         goodsRealPrice = goodsTotalPrice;
+        // 设置使用优惠券,商品总价,优惠券折扣,商品实际价格
         appSureOrderGoodsVo.setUseCoupon(useCoupon);
         appSureOrderGoodsVo.setGoodsTotalPrice(goodsTotalPrice);
         appSureOrderGoodsVo.setCouponDiscount(discountMoney);
         appSureOrderGoodsVo.setGoodsRealPrice(goodsRealPrice);
-        goodsDeposit = goods.getSubscription();
+        // 获取商品押金
+        goodsDeposit = activityGoodsGetVo.getActivitySubscription();
         if (goodsDeposit == null) {
             goodsDeposit = new BigDecimal("0.00");
         }
         appSureOrderGoodsVo.setGoodsDeposit(goodsDeposit);
+        // 计算商品数量,订单商品金额,优惠券折扣,订单支付押金,订单支付金额
         goodsNum = goodsNum + buyNum;
         orderGoodsMoney = orderGoodsMoney.add(goodsTotalPrice);
         couponDiscount = couponDiscount.add(discountMoney);
         orderPayDeposit = orderPayDeposit.add(goodsDeposit);
         orderPayMoney = orderPayMoney.add(goodsRealPrice);
-        //创建OrderGoods
+        // 创建订单商品,并设置订单商品ID,删除标志,订单ID,商品ID,购买数量,商品价格,商品押金,商品总金额,商品应收金额,周期数量标志,服务数量,商品类型,商品名称,商品图片
         orderGoods = new OrderGoods();
         orderGoodsId = IdUtils.simpleUUID();
         orderGoods.setOrderGoodsId(orderGoodsId);
@@ -574,6 +614,7 @@
         orderGoods.setGoodsId(goodsId);
         orderGoods.setBuyNum(buyNum);
         orderGoods.setGoodsPrice(goodsPrice);
+        orderGoods.setGoodsDeposit(goodsDeposit);
         orderGoods.setGoodsTotalMoney(orderGoodsMoney);
         orderGoods.setGoodsReceivableMoney(goodsRealPrice);
         orderGoods.setCycleNumFlag(goods.getCycleNumFlag());
@@ -581,12 +622,14 @@
         orderGoods.setGoodsType(goods.getGoodsType());
         orderGoods.setGoodsName(goods.getGoodsName());
         orderGoods.setGoodsPicture(goodsFile.getFileUrl());
+        // 保存订单商品
         orderGoodsService.save(orderGoods);
-        //清空购物车
+        // 清空购物车
         AppShoppingCartDelDto appShoppingCartDelDto = new AppShoppingCartDelDto();
         appShoppingCartDelDto.setGoodsId(goodsId);
         appShoppingCartDelDto.setUserId(userId);
         remoteShoppingCartService.deleteShoppingCart(appShoppingCartDelDto);
+        // 根据商品类型添加到商品类型集合中
         if (goods.getGoodsType() == 1) {
             goodsTypeSet.add("周期");
         } else if (goods.getGoodsType() == 2) {
@@ -596,11 +639,10 @@
         } else if (goods.getGoodsType() == 4) {
             goodsTypeSet.add("单品");
         }
-
+        // 创建订单,并设置订单ID,删除标志,订单状态,订单号,订单来源,店铺ID,用户ID,订单金额,优惠券金额,折扣金额,应收金额,应收押金,变动应收金额,支付类型
         Order order = new Order();
         order.setOrderId(orderId);
         order.setDelFlag(0);
-        //为对接支付 直接付款成功
         order.setOrderStatus(1);
         order.setOrderNo(orderNo);
         order.setOrderFrom(1);
@@ -613,6 +655,7 @@
         order.setReceivableDeposit(orderPayDeposit);
         order.setChangeReceivableMoney(orderPayMoney);
         order.setPayType(appPlaceActivityDto.getPayType());
+        // 根据支付类型设置订单支付金额,在线支付金额,订单支付金额,未支付金额,关闭标志
         if (order.getPayType() == 1) {
             order.setPayMoney(orderPayMoney);
             order.setOnlinePayMoney(orderPayMoney);
@@ -626,26 +669,25 @@
             appPlaceOrderVo.setUnpaidMoney(order.getReceivableMoney().subtract(order.getPayMoney()));
             order.setCloseFlag(0);
         }
+        // 设置订单备注,商品数量,创建时间
         order.setOrderRemark(appPlaceActivityDto.getOrderRemark());
         order.setGoodsNum(goodsNum);
         order.setCreateTime(new Date());
+        // 保存订单
         this.save(order);
-        //更新用户商品类型
+        // 更新用户商品类型
         if (goodsTypeSet != null && goodsTypeSet.size() > 0) {
             AppMemberGoodsTypeDto appMemberGoodsTypeDto = new AppMemberGoodsTypeDto();
             appMemberGoodsTypeDto.setUserId(userId);
             appMemberGoodsTypeDto.setGoodsTypeSet(goodsTypeSet);
             remoteMemberService.updateMemberGoodsType(appMemberGoodsTypeDto);
         }
+        // 设置订单ID和订单号
         appPlaceOrderVo.setOrderId(orderId);
         appPlaceOrderVo.setOrderNo(orderNo);
-
-        //调用支付
-
-
+        // 调用支付
         return appPlaceOrderVo;
     }
-
 
 
     /**
@@ -778,15 +820,15 @@
      * @return
      */
     @Override
-    public MerVerifyOrderVo verifyOrder(String orderId,Long shopId) {
+    public MerVerifyOrderVo verifyOrder(String orderId, Long shopId) {
         // 创建返回对象
         MerVerifyOrderVo merVerifyOrderVo = new MerVerifyOrderVo();
         // 根据订单ID获取订单信息
         Order order = this.getById(orderId);
-        if(order.getOrderStatus()!=2){
+        if (order.getOrderStatus() != 2) {
             throw new ServiceException(AppErrorConstant.VERIFY_USED);
         }
-        if(!order.getShopId().equals(shopId)){
+        if (!order.getShopId().equals(shopId)) {
             throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR);
         }
         // 根据订单ID获取订单商品列表
@@ -829,7 +871,7 @@
         Date nowTime = new Date();
         //更新订单信息
         Order order = this.getById(orderId);
-        if(order.getOrderStatus()!=2){
+        if (order.getOrderStatus() != 2) {
             throw new ServiceException(AppErrorConstant.VERIFY_USED);
         }
         order.setOrderStatus(3);
@@ -854,14 +896,7 @@
         ConsumerGoods consumerGoods;
         String consumerGoodsId;
         Goods goods;
-        Integer serviceCount = 0;
-        Integer cycleService = 0;
-        Integer cyclePerson = 0;
-        Integer serviceService = 0;
-        Integer servicePerson = 0;
-        Integer experienceService = 0;
-        Integer experiencePerson = 0;
-        MerMemberConsumerGoodsTotalVo memberConsumerGoodsTotalVo = consumerGoodsService.getMemberConsumerGoodsTotalVo(order.getUserId(), order.getShopId());
+        List<ConsumerGoods> consumerGoodsList = new ArrayList<>();
         for (AppUserOrderGoodsPageVo appUserOrderGoodsPageVo : appUserOrderGoodsPageVoList) {
             consumerGoods = new ConsumerGoods();
             goods = goodsMap.get(appUserOrderGoodsPageVo.getGoodsId());
@@ -884,35 +919,9 @@
             consumerGoods.setGoodsPicture(appUserOrderGoodsPageVo.getGoodsPicture());
             consumerGoods.setGoodsNurses(goods.getGoodsNurses());
             consumerGoods.setSourceFrom(1);
-            consumerGoodsService.save(consumerGoods);
-            //处理商品服务次数
-            if (consumerGoods.getCycleNumFlag() == 1) {
-                switch (goods.getGoodsType()) {
-                    case 1:
-                        cycleService = cycleService + appUserOrderGoodsPageVo.getServiceNum();
-                        break;
-                    case 2:
-                        serviceService = serviceService + appUserOrderGoodsPageVo.getServiceNum();
-                        break;
-                    case 3:
-                        experienceService = experienceService + appUserOrderGoodsPageVo.getServiceNum();
-                        break;
-                    default:
-                        break;
-                }
-            }
+            consumerGoodsList.add(consumerGoods);
         }
-        //判断是否加人
-        if (cycleService > 0 && memberConsumerGoodsTotalVo.getCycleOrder() == 0) {
-            cyclePerson = 1;
-        }
-        if (serviceService > 0 && memberConsumerGoodsTotalVo.getServiceOrder() == 0) {
-            servicePerson = 1;
-        }
-        if (experienceService > 0 && memberConsumerGoodsTotalVo.getExperienceOrder() == 0) {
-            experiencePerson = 1;
-        }
-        serviceCount = cycleService + serviceService + experienceService;
+        consumerGoodsService.saveBatchConsumerGoods(consumerGoodsList);
         //生成返回
         MerVerifyOrderVo merVerifyOrderVo = new MerVerifyOrderVo();
         merVerifyOrderVo.setOrderId(orderId);
@@ -932,24 +941,6 @@
         SysUser sysUser = remoteUserService.getSysUser(order.getUserId()).getData();
         merVerifyOrderVo.setUserName(sysUser.getNickName());
         merVerifyOrderVo.setUserMobile(sysUser.getPhonenumber());
-        //更新商户和会员服务统计
-        MemberTotalChangeDto memberTotalChangeDto = new MemberTotalChangeDto();
-        memberTotalChangeDto.setUserId(order.getUserId());
-        memberTotalChangeDto.setTypeService(1);
-        memberTotalChangeDto.setServiceCount(serviceCount);
-        remoteMemberService.changeMemberTotal(memberTotalChangeDto);
-        ShopTotalChangeDto shopTotalChangeDto = new ShopTotalChangeDto();
-        shopTotalChangeDto.setShopId(order.getShopId());
-        shopTotalChangeDto.setTypeCycleService(1);
-        shopTotalChangeDto.setCycleService(cycleService);
-        shopTotalChangeDto.setCyclePerson(cyclePerson);
-        shopTotalChangeDto.setTypeServiceService(1);
-        shopTotalChangeDto.setServiceService(serviceService);
-        shopTotalChangeDto.setServicePerson(servicePerson);
-        shopTotalChangeDto.setTypeExperienceService(1);
-        shopTotalChangeDto.setExperienceService(experienceService);
-        shopTotalChangeDto.setExperiencePerson(experiencePerson);
-        remoteShopService.changeShopTotal(shopTotalChangeDto);
         return merVerifyOrderVo;
     }
 
@@ -990,6 +981,9 @@
         ConsumerGoods consumerGoods;
         String consumerGoodsId;
         GoodsFile goodsFile;
+        AppShopGoodsGetDto appShopGoodsGetDto;
+        ShopGoods shopGoods;
+        List<ConsumerGoods> consumerGoodsList = new ArrayList<>();
         for (Goods goods : goodsList) {
             consumerGoods = new ConsumerGoods();
             consumerGoodsId = IdUtils.simpleUUID();
@@ -1004,6 +998,14 @@
             consumerGoods.setGoodsName(goods.getGoodsName());
             consumerGoods.setCycleNumFlag(goods.getCycleNumFlag());
             consumerGoods.setServiceNum(goods.getServiceNum());
+            appShopGoodsGetDto = new AppShopGoodsGetDto();
+            appShopGoodsGetDto.setGoodsId(goods.getGoodsId());
+            appShopGoodsGetDto.setShopId(memberCoupon.getShopId());
+            //获取商户服务次数
+            shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData();
+            if(shopGoods!=null){
+                consumerGoods.setServiceNum(shopGoods.getServiceNum());
+            }
             consumerGoods.setUsedNum(0);
             consumerGoods.setGoodsType(goods.getGoodsType());
             consumerGoods.setCreateTime(new Date());
@@ -1012,8 +1014,9 @@
             consumerGoods.setGoodsPicture(goodsFile.getFileUrl());
             consumerGoods.setGoodsNurses(goods.getGoodsNurses());
             consumerGoods.setSourceFrom(1);
-            consumerGoodsService.save(consumerGoods);
+            consumerGoodsList.add(consumerGoods);
         }
+        consumerGoodsService.saveBatchConsumerGoods(consumerGoodsList);
         return merVerifyCouponVo;
     }
 
@@ -1203,7 +1206,7 @@
             orderGoods.setGoodsName(goods.getGoodsName());
             orderGoods.setGoodsPicture(goodsFile.getFileUrl());
             orderGoodsService.save(orderGoods);
-            switch(orderGoods.getGoodsType()){
+            switch (orderGoods.getGoodsType()) {
                 case 1:
                     cycleMoney = cycleMoney.add(orderGoods.getGoodsReceivableMoney());
                     break;
@@ -1235,9 +1238,9 @@
         order.setReceivableMoney(orderPayMoney);
         order.setReceivableDeposit(new BigDecimal("0.00"));
         order.setPayType(1);
-        if(merNewOrderDto.getChangeMoney()!=null){
+        if (merNewOrderDto.getChangeMoney() != null) {
             order.setChangeReceivableMoney(merNewOrderDto.getChangeMoney());
-        }else{
+        } else {
             order.setChangeReceivableMoney(orderPayMoney);
         }
         order.setPayMoney(orderPayMoney);
@@ -1614,7 +1617,7 @@
             //处理商品信息
             List<MgtOrderGoodsPageVo> mgtOrderGoodsVoList;
             String goodsString;
-            for(MgtShopOrderPageVo entity : shopOrderPageVoList){
+            for (MgtShopOrderPageVo entity : shopOrderPageVoList) {
                 mgtOrderGoodsVoList = entity.getMgtOrderGoodsPageVoList();
                 goodsString = mgtOrderGoodsVoList.stream()
                         .map(goods -> goods.getGoodsName() + "*" + goods.getBuyNum())
@@ -2272,7 +2275,7 @@
      * @date 2023/6/27 11:10
      */
     @Override
-    public MerVerifyCouponVo verifyCoupon(String verifyCode,Long shopId) {
+    public MerVerifyCouponVo verifyCoupon(String verifyCode, Long shopId) {
         // 创建MerVerifyCouponVo对象
         MerVerifyCouponVo merVerifyCouponVo = new MerVerifyCouponVo();
         // 调用remoteCouponService的getVerifyCoupon方法获取MerVerifyCouponGetVo对象
@@ -2287,7 +2290,7 @@
         } else if (couponStatus != 0) {
             throw new ServiceException(AppErrorConstant.COUPON_NO_FIND);
         }
-        if(!memberCoupon.getShopId().equals(shopId)){
+        if (!memberCoupon.getShopId().equals(shopId)) {
             throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR);
         }
         List<Goods> goodsList = verifyCouponGetVo.getGoodsList();
@@ -2313,33 +2316,33 @@
     }
 
     /**
-     * @description  获取用户未支付金额
-     * @author  jqs
-     * @date    2023/6/29 18:00
      * @param merBaseDto
-     * @return  BigDecimal
+     * @return BigDecimal
+     * @description 获取用户未支付金额
+     * @author jqs
+     * @date 2023/6/29 18:00
      */
     @Override
-    public BigDecimal getMemberUnpaidOrder(MerBaseDto merBaseDto){
+    public BigDecimal getMemberUnpaidOrder(MerBaseDto merBaseDto) {
         BigDecimal unpaidMoney = orderMapper.getMemberUnpaidOrder(merBaseDto);
         return unpaidMoney;
     }
 
     /**
-     * @description  商户获取订单统计
-     * @author  jqs
-     * @date    2023/7/3 19:29
      * @param merTotalDto
-     * @return  MerOrderTotalVo
+     * @return MerOrderTotalVo
+     * @description 商户获取订单统计
+     * @author jqs
+     * @date 2023/7/3 19:29
      */
     @Override
-    public MerOrderTotalVo getMerOrderTotal(MerTotalDto merTotalDto){
-        if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){
+    public MerOrderTotalVo getMerOrderTotal(MerTotalDto merTotalDto) {
+        if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) {
             List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData();
             merTotalDto.setShopIdList(shopIdList);
             merTotalDto.setShopId(null);
         }
-        if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){
+        if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) {
             List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData();
             merTotalDto.setShopIdList(shopIdList);
             merTotalDto.setShopId(null);
@@ -2350,15 +2353,15 @@
 
 
     /**
-     * @description
-     * @author  jqs
-     * @date    2023/7/4 9:29
      * @param merTotalDto
-     * @return  MerOrderDistributionTotalVo
+     * @return MerOrderDistributionTotalVo
+     * @description
+     * @author jqs
+     * @date 2023/7/4 9:29
      */
     @Override
-    public MerOrderDistributionTotalVo MerOrderDistributionTotalVo(MerTotalDto merTotalDto){
-        if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){
+    public MerOrderDistributionTotalVo MerOrderDistributionTotalVo(MerTotalDto merTotalDto) {
+        if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) {
             List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData();
             merTotalDto.setShopIdList(shopIdList);
             merTotalDto.setShopId(null);
@@ -2419,15 +2422,15 @@
     }
 
     /**
-     * @description  商户获取销售占比统计
-     * @author  jqs
-     * @date    2023/7/4 13:58
      * @param merTotalDto
-     * @return  MerOrderTypeTotalVo
+     * @return MerOrderTypeTotalVo
+     * @description 商户获取销售占比统计
+     * @author jqs
+     * @date 2023/7/4 13:58
      */
     @Override
-    public MerOrderTypeTotalVo getMerOrderTypeTotal(MerTotalDto merTotalDto){
-        if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){
+    public MerOrderTypeTotalVo getMerOrderTypeTotal(MerTotalDto merTotalDto) {
+        if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) {
             List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData();
             merTotalDto.setShopIdList(shopIdList);
             merTotalDto.setShopId(null);
@@ -2470,15 +2473,15 @@
 
 
     /**
-     * @description  商户端获取销售排行
-     * @author  jqs
-     * @date    2023/7/4 14:23
      * @param merTotalDto
-     * @return  MerOrderGoodsRankVo
+     * @return MerOrderGoodsRankVo
+     * @description 商户端获取销售排行
+     * @author jqs
+     * @date 2023/7/4 14:23
      */
     @Override
-    public MerOrderGoodsRankVo getMerOrderGoodsRank(MerTotalDto merTotalDto){
-        if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){
+    public MerOrderGoodsRankVo getMerOrderGoodsRank(MerTotalDto merTotalDto) {
+        if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) {
             List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData();
             merTotalDto.setShopIdList(shopIdList);
             merTotalDto.setShopId(null);
@@ -2494,15 +2497,15 @@
 
 
     /**
-     * @description  商户端获取渠道排行
-     * @author  jqs
-     * @date    2023/7/4 14:51
      * @param merTotalDto
-     * @return  MerOrderFromRankVo
+     * @return MerOrderFromRankVo
+     * @description 商户端获取渠道排行
+     * @author jqs
+     * @date 2023/7/4 14:51
      */
     @Override
-    public MerOrderFromRankVo getMerOrderFromRank(MerTotalDto merTotalDto){
-        if(merTotalDto.getShopAllFlag()!=null&&merTotalDto.getShopAllFlag()==1){
+    public MerOrderFromRankVo getMerOrderFromRank(MerTotalDto merTotalDto) {
+        if (merTotalDto.getShopAllFlag() != null && merTotalDto.getShopAllFlag() == 1) {
             List<Long> shopIdList = remoteShopService.listShopIdByShopId(merTotalDto.getShopId()).getData();
             merTotalDto.setShopIdList(shopIdList);
             merTotalDto.setShopId(null);
@@ -2518,29 +2521,29 @@
     }
 
     /**
-     * @description  商户端订单管理统计
-     * @author  jqs
-     * @date    2023/7/4 16:27
      * @param merBaseDto
-     * @return  MerTotalOrderVo
+     * @return MerTotalOrderVo
+     * @description 商户端订单管理统计
+     * @author jqs
+     * @date 2023/7/4 16:27
      */
     @Override
-    public MerTotalOrderVo totalMerOrder(MerBaseDto merBaseDto){
+    public MerTotalOrderVo totalMerOrder(MerBaseDto merBaseDto) {
         return orderMapper.totalMerOrder(merBaseDto.getShopId());
     }
 
     /**
-     * @description  平台获取商户订单记录
-     * @author  jqs
-     * @date    2023/7/5 20:17
      * @param page
      * @param mgtShopAllOrderPageDto
-     * @return  List<MgtShopAllOrderPageVo>
+     * @return List<MgtShopAllOrderPageVo>
+     * @description 平台获取商户订单记录
+     * @author jqs
+     * @date 2023/7/5 20:17
      */
     @Override
-    public List<MgtShopAllOrderPageVo> pageMgtShopAllOrder(Page page, MgtShopAllOrderPageDto mgtShopAllOrderPageDto){
+    public List<MgtShopAllOrderPageVo> pageMgtShopAllOrder(Page page, MgtShopAllOrderPageDto mgtShopAllOrderPageDto) {
         List<MgtShopAllOrderPageVo> shopAllOrderPageVoList = orderMapper.pageMgtShopAllOrder(page, mgtShopAllOrderPageDto);
-        if(!shopAllOrderPageVoList.isEmpty()){
+        if (!shopAllOrderPageVoList.isEmpty()) {
             // 定义变量
             HashSet<Long> userIdSet = new HashSet<>();
             BigDecimal zeroBig = new BigDecimal("0.00");
@@ -2566,7 +2569,7 @@
                     if (userMap.get(mgtShopOrderPageVo.getUserId()) != null) {
                         userInfo = userMap.get(mgtShopOrderPageVo.getUserId()).getNickName();
                         mobile = userMap.get(mgtShopOrderPageVo.getUserId()).getUserMobile();
-                        if(StringUtils.isNotBlank(mobile)){
+                        if (StringUtils.isNotBlank(mobile)) {
                             userInfo = userInfo + "(" + mobile + ")";
                         }
                         mgtShopOrderPageVo.setUserInfo(userInfo);
@@ -2576,7 +2579,7 @@
             //处理商品信息
             List<MgtOrderGoodsPageVo> mgtOrderGoodsVoList;
             String goodsString;
-            for(MgtShopAllOrderPageVo entity : shopAllOrderPageVoList){
+            for (MgtShopAllOrderPageVo entity : shopAllOrderPageVoList) {
                 mgtOrderGoodsVoList = entity.getMgtOrderGoodsPageVoList();
                 goodsString = mgtOrderGoodsVoList.stream()
                         .map(goods -> goods.getGoodsName() + "*" + goods.getBuyNum())
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/ConsumerGoodsService.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/ConsumerGoodsService.java
index 731254b..cd88eed 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/ConsumerGoodsService.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/ConsumerGoodsService.java
@@ -11,6 +11,7 @@
 import com.ruoyi.order.domain.vo.MerConsumerGoodsListVo;
 import com.ruoyi.order.domain.vo.MerConsumerGoodsVo;
 import com.ruoyi.order.domain.vo.MerMemberConsumerGoodsTotalVo;
+import com.ruoyi.system.api.domain.dto.BirthdayGiftSendDto;
 
 import java.util.List;
 
@@ -46,7 +47,7 @@
     void sureMerConsumerGoods(MerSureConsumerGoodsDto merSureConsumerGoodsDto);
 
     /**
-     * 确认商品次数
+     * 消费服务商品
      * @param merSureConsumerGoodsDto
      */
     void useMerConsumerGoods(MerSureConsumerGoodsDto merSureConsumerGoodsDto);
@@ -68,4 +69,22 @@
      * @return  MerMemberConsumerGoodsTotalVo
      */
     MerMemberConsumerGoodsTotalVo getMemberConsumerGoodsTotalVo(Long userId, Long shopId);
+
+    /**
+     * @description  发放用户商品礼物
+     * @author  jqs
+     * @date    2023/7/7 18:51
+     * @param giftSendDtoList
+     * @return  void
+     */
+    void sendGoodsGift(List<BirthdayGiftSendDto> giftSendDtoList);
+
+    /**
+     * @description  
+     * @author  jqs
+     * @date    2023/7/7 19:34
+     * @param consumerGoodsList
+     * @return  boolean
+     */
+    boolean saveBatchConsumerGoods(List<ConsumerGoods> consumerGoodsList);
 }
diff --git a/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml b/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
index cf9518b..f7ccc18 100644
--- a/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
+++ b/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -1128,7 +1128,7 @@
         SELECT
         DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
         COUNT(DISTINCT order_id) AS mapValueFirst,
-        IFNULL(SUM(toc.order_money),0) AS mapValueSecond
+        IFNULL(SUM(order_money),0) AS mapValueSecond
         FROM t_order
         WHERE del_flag = 0 AND order_from = 2
         AND create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
@@ -1196,7 +1196,7 @@
             </foreach>
         </if>
         GROUP BY shop_id
-        ORDER BY COUNT(toc.order_id) DESC LIMIT 15
+        ORDER BY COUNT(order_id) DESC LIMIT 15
     </select>
 
     <select id="listPlTotalShopActivitySalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/console/ShopController.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/console/ShopController.java
index 5845baa..6daa718 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/console/ShopController.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/console/ShopController.java
@@ -246,4 +246,28 @@
         Integer count = shopSuggestService.getUnReplaySuggestVo();
         return R.ok(count);
     }
+
+    /**
+     * @description  获取商户营销状态
+     * @author  jqs
+     * @date    2023/7/7 14:05
+     * @param shopId
+     * @return  R<Integer>
+     */
+    @PostMapping("/getShopMarketingStatus")
+    public R<Integer> getShopMarketingStatus(@RequestBody Long shopId)
+    {
+        Shop shop = shopService.getByShopId(shopId);
+        Integer platformCouponFlag = shop.getPlatformCouponFlag();
+        Integer platformBirthdayFlag = shop.getPlatformBirthdayFlag();
+        Integer marketingStatus = 0;
+        if(platformCouponFlag==1&&platformBirthdayFlag==0){
+            marketingStatus = 1;
+        }else if(platformCouponFlag==0&&platformBirthdayFlag==1){
+            marketingStatus = 2;
+        }else if(platformCouponFlag==1&&platformBirthdayFlag==1){
+            marketingStatus = 3;
+        }
+        return R.ok(marketingStatus);
+    }
 }
diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/dto/MgtShopPageDto.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/dto/MgtShopPageDto.java
index 2af483d..5964b16 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/dto/MgtShopPageDto.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/dto/MgtShopPageDto.java
@@ -53,6 +53,9 @@
     @ApiModelProperty(value = "归属员工")
     private Long belongUserId;
 
+    @ApiModelProperty(value = "归属经销商id")
+    private Long belongShopId;
+
     @ApiModelProperty(value = "来源渠道")
     private String shopSource;
 
diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
index dfe1539..8e7a5cc 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
@@ -277,71 +277,85 @@
             }
         }
         if(newShop){
-            //商户账户信息初始化
-            ShopAccount shopAccount = new ShopAccount();
-            shopAccount.setShopId(shop.getShopId());
-            shopAccount.setDelFlag(0);
-            shopAccount.setTotalIncome(new BigDecimal("0"));
-            shopAccount.setTotalDisburse(new BigDecimal("0"));
-            shopAccount.setTotalRefund(new BigDecimal("0"));
-            shopAccount.setTotalProfitsharing(new BigDecimal("0"));
-            shopAccount.setTotalMoney(new BigDecimal("0"));
-            shopAccountService.save(shopAccount);
-            //商户认证信息初始化
-            String authId = IdUtils.simpleUUID();
-            ShopAuthentication shopAuthentication = new ShopAuthentication();
-            shopAuthentication.setAuthId(authId);
-            shopAuthentication.setDelFlag(0);
-            shopAuthentication.setShopId(shop.getShopId());
-            shopAuthenticationService.save(shopAuthentication);
-            //商户分成信息初始化
-            ShopProportion shopProportion = new ShopProportion();
-            shopProportion.setDelFlag(0);
-            shopProportion.setShopId(shop.getShopId());
-            shopProportion.setShopType(shop.getShopType());
-            shopProportion.setProportionPercent(new BigDecimal("100.00"));
-            shopProportion.setUpdateTime(new Date());
-            shopProportion.setUpdateUserId(mgtEditShopDto.getUserId());
-            shopProportionService.save(shopProportion);
-            //商户统计
-            ShopTotal shopTotal = new ShopTotal();
-            shopTotal.setShopId(shop.getShopId());
-            shopTotal.setDelFlag(0);
-            shopTotal.setLastPayMoney(zeroBig);
-            shopTotal.setTotalActivityCount(0);
-            shopTotal.setTotalOrder(0);
-            shopTotal.setTotalCycleOrder(0);
-            shopTotal.setTotalExperienceOrder(0);
-            shopTotal.setTotalServiceOrder(0);
-            shopTotal.setTotalGoodsOrder(0);
-            shopTotal.setTotalServiceCount(0);
-            shopTotal.setUsedServiceCount(0);
-            shopTotal.setUseableServiceCount(0);
-            shopTotal.setTotalCycleService(0);
-            shopTotal.setUsedCycleService(0);
-            shopTotal.setUseableCycleService(0);
-            shopTotal.setTotalCyclePerson(0);
-            shopTotal.setUseableCyclePerson(0);
-            shopTotal.setTotalServiceService(0);
-            shopTotal.setUsedServiceService(0);
-            shopTotal.setUseableServiceService(0);
-            shopTotal.setTotalServicePerson(0);
-            shopTotal.setUseableServicePerson(0);
-            shopTotal.setTotalExperienceService(0);
-            shopTotal.setUsedExperienceService(0);
-            shopTotal.setUseableExperienceService(0);
-            shopTotal.setTotalExperiencePerson(0);
-            shopTotal.setUseableExperiencePerson(0);
-            shopTotal.setTotalOrderMoney(zeroBig);
-            shopTotal.setTotalCycleMoney(zeroBig);
-            shopTotal.setTotalExperienceMoney(zeroBig);
-            shopTotal.setTotalServiceMoney(zeroBig);
-            shopTotal.setTotalGoodsMoney(zeroBig);
-            shopTotalService.save(shopTotal);
+            //生成商户关联记录
+            initNewShop(shop,mgtEditShopDto.getUserId());
         }
     }
 
     /**
+     * @description  商户关联类初始化
+     * @author  jqs
+     * @date    2023/7/7 11:25
+     * @param shop
+     * @param userId
+     * @return  void
+     */
+    private void initNewShop(Shop shop,Long userId){
+        BigDecimal zeroBig = new BigDecimal("0.00");
+        //商户账户信息初始化
+        ShopAccount shopAccount = new ShopAccount();
+        shopAccount.setShopId(shop.getShopId());
+        shopAccount.setDelFlag(0);
+        shopAccount.setTotalIncome(new BigDecimal("0"));
+        shopAccount.setTotalDisburse(new BigDecimal("0"));
+        shopAccount.setTotalRefund(new BigDecimal("0"));
+        shopAccount.setTotalProfitsharing(new BigDecimal("0"));
+        shopAccount.setTotalMoney(new BigDecimal("0"));
+        shopAccountService.save(shopAccount);
+        //商户认证信息初始化
+        String authId = IdUtils.simpleUUID();
+        ShopAuthentication shopAuthentication = new ShopAuthentication();
+        shopAuthentication.setAuthId(authId);
+        shopAuthentication.setDelFlag(0);
+        shopAuthentication.setShopId(shop.getShopId());
+        shopAuthenticationService.save(shopAuthentication);
+        //商户分成信息初始化
+        ShopProportion shopProportion = new ShopProportion();
+        shopProportion.setDelFlag(0);
+        shopProportion.setShopId(shop.getShopId());
+        shopProportion.setShopType(shop.getShopType());
+        shopProportion.setProportionPercent(new BigDecimal("100.00"));
+        shopProportion.setUpdateTime(new Date());
+        shopProportion.setUpdateUserId(userId);
+        shopProportionService.save(shopProportion);
+        //商户统计
+        ShopTotal shopTotal = new ShopTotal();
+        shopTotal.setShopId(shop.getShopId());
+        shopTotal.setDelFlag(0);
+        shopTotal.setLastPayMoney(zeroBig);
+        shopTotal.setTotalActivityCount(0);
+        shopTotal.setTotalOrder(0);
+        shopTotal.setTotalCycleOrder(0);
+        shopTotal.setTotalExperienceOrder(0);
+        shopTotal.setTotalServiceOrder(0);
+        shopTotal.setTotalGoodsOrder(0);
+        shopTotal.setTotalServiceCount(0);
+        shopTotal.setUsedServiceCount(0);
+        shopTotal.setUseableServiceCount(0);
+        shopTotal.setTotalCycleService(0);
+        shopTotal.setUsedCycleService(0);
+        shopTotal.setUseableCycleService(0);
+        shopTotal.setTotalCyclePerson(0);
+        shopTotal.setUseableCyclePerson(0);
+        shopTotal.setTotalServiceService(0);
+        shopTotal.setUsedServiceService(0);
+        shopTotal.setUseableServiceService(0);
+        shopTotal.setTotalServicePerson(0);
+        shopTotal.setUseableServicePerson(0);
+        shopTotal.setTotalExperienceService(0);
+        shopTotal.setUsedExperienceService(0);
+        shopTotal.setUseableExperienceService(0);
+        shopTotal.setTotalExperiencePerson(0);
+        shopTotal.setUseableExperiencePerson(0);
+        shopTotal.setTotalOrderMoney(zeroBig);
+        shopTotal.setTotalCycleMoney(zeroBig);
+        shopTotal.setTotalExperienceMoney(zeroBig);
+        shopTotal.setTotalServiceMoney(zeroBig);
+        shopTotal.setTotalGoodsMoney(zeroBig);
+        shopTotalService.save(shopTotal);
+    }
+
+    /**
      * @description  终止合作
      * @author  jqs
      * @date    2023/6/20 12:01
diff --git a/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml b/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml
index 7ac9ef6..845d2fa 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml
+++ b/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml
@@ -345,6 +345,9 @@
         <if test="param.belongUserId!=null and param.belongUserId!=''">
             AND ts.belong_user_id = #{param.belongUserId}
         </if>
+        <if test="param.belongShopId!=null and param.belongShopId!=''">
+            AND ts.belong_shop_id = #{param.belongShopId}
+        </if>
         <if test="param.shopSource!=null and param.shopSource!=''">
             AND ts.shop_source = #{param.shopSource}
         </if>
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/GeneratorMybatisPlus.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/GeneratorMybatisPlus.java
index e81574c..5a0ae4d 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/GeneratorMybatisPlus.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/GeneratorMybatisPlus.java
@@ -44,7 +44,7 @@
         DataSourceConfig dataSourceConfig = new DataSourceConfig();
         dataSourceConfig.setDbType(DbType.MYSQL);
         dataSourceConfig.setTypeConvert(new MySqlTypeConvert());
-        dataSourceConfig.setUrl("jdbc:mysql://47.109.78.184:10010/hrt_shop?tinyInt1isBit=false");
+        dataSourceConfig.setUrl("jdbc:mysql://47.109.78.184:10010/hrt_member?tinyInt1isBit=false");
         dataSourceConfig.setDriverName("com.mysql.cj.jdbc.Driver");
         dataSourceConfig.setUsername("root");
         dataSourceConfig.setPassword("hrt123456");
@@ -53,7 +53,7 @@
         // 包名配置
         PackageConfig packageConfig = new PackageConfig();
         // 父包和子包名分开处理
-        packageConfig.setParent("com.ruoyi.shop");
+        packageConfig.setParent("com.ruoyi.member");
         packageConfig.setController("app");
         packageConfig.setEntity("domain.pojo");
         packageConfig.setMapper("mapper");
@@ -74,7 +74,7 @@
         strategy.setControllerMappingHyphenStyle(true);
         //表和前缀处理
         String[] table = {
-                "t_shop_total"
+                "t_member_gift_record"
         };
         strategy.setInclude(table);
         String[] tablePre = new String[]{"t_"};

--
Gitblit v1.7.1