Explorar o código

后台镜像店铺订单数据,店铺信息

zoujiajian hai 1 ano
pai
achega
8891393889

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/mapper/GoodsDonMapper.java

@@ -30,4 +30,7 @@ public interface GoodsDonMapper extends BaseMapper<GoodsDon> {
 
 	@Select("select g.id, g.title from (select distinct goods_id from order_don where status not in ('close','noPayment') and yhs_id = #{yhsId}) o inner join goods_don g on g.id = o.goods_id and g.type = 1")
 	List<GoodsDon> getYhShopDistributeGoodsDetail(Long yhsId);
+
+	@Select("select g.id, g.title from (select distinct o.goods_id from order_don o inner join user_mirror_shop_order_relate uor on uor.order_id = o.id where o.status not in ('close','noPayment') and uor.mp_id = #{yhsId}) o inner join goods_don g on g.id = o.goods_id")
+	List<GoodsDon> getUserMirrorShopShopDistributeGoodsDetail(Long id);
 }

+ 13 - 0
netflix-dao/src/main/java/com/cyksj/mapper/mirrorshop/UserMirrorShopApplyRecordMapper.java

@@ -0,0 +1,13 @@
+package com.cyksj.mapper.mirrorshop;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.UserMirrorShopApplyRecord;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: UserMirrorShopApplyRecordMapper
+ * 创建者: JavaZou
+ * 创建时间:2024/11/7 16:15
+ */
+public interface UserMirrorShopApplyRecordMapper extends BaseMapper<UserMirrorShopApplyRecord> {
+}

+ 9 - 0
netflix-dao/src/main/java/com/cyksj/mapper/mirrorshop/UserMirrorShopDistributeWaitingSendPointsMapper.java

@@ -1,7 +1,13 @@
 package com.cyksj.mapper.mirrorshop;
 
+import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.cyksj.model.entity.UserMirrorShopDistributeWaitingSendPoints;
+import com.cyksj.model.views.YhShopBrokenLineCpsUserWMoneyView;
+import com.cyksj.model.views.YhShopUserWMoneyStatisticsDataView;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 项目名: yhlxj2
@@ -10,4 +16,7 @@ import com.cyksj.model.entity.UserMirrorShopDistributeWaitingSendPoints;
  * 创建时间:2024/10/18 11:59
  */
 public interface UserMirrorShopDistributeWaitingSendPointsMapper extends BaseMapper<UserMirrorShopDistributeWaitingSendPoints> {
+	YhShopBrokenLineCpsUserWMoneyView getWMoneyStatisticsDataView(@Param("yhShopUserId") long yhShopUserId, @Param("first") DateTime first, @Param("end") DateTime end, @Param("today") Boolean today);
+
+	List<YhShopUserWMoneyStatisticsDataView> getWMoneyStatisticsDate(@Param("yhShopUserId") long yhShopUserId, @Param("first") DateTime first, @Param("end") DateTime end, @Param("today") Boolean today);
 }

+ 60 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/UserMirrorShopApplyRecord.java

@@ -0,0 +1,60 @@
+package com.cyksj.model.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: UserMirrorShopApplyRecord
+ * 创建者: JavaZou
+ * 创建时间:2024/11/7 16:14
+ */
+
+@Getter
+@Setter
+public class UserMirrorShopApplyRecord extends BaseEntity{
+	/**
+	 * 店主id
+	 */
+	private Long userId;
+
+	/**
+	 * 店铺名称
+	 */
+	private String name;
+
+	/**
+	 * 自定义id
+	 */
+	private String customId;
+
+	/**
+	 * 是否审核通过
+	 */
+	private YhShopApplyRecord.Status verifyStatus;
+
+	/**
+	 * 审核失败原因
+	 */
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
+	private String reason;
+
+	private Date verifyTime;
+
+	@Getter
+	public enum Status {
+		verify("审核中"),
+		modify("申请修改"),
+		success("审核通过"),
+		fail("审核失败");
+		String desc;
+
+		Status(String desc) {
+			this.desc = desc;
+		}
+	}
+}

+ 39 - 0
netflix-dao/src/main/java/com/cyksj/model/request/UserMirrorShopApplyMoneyReq.java

@@ -0,0 +1,39 @@
+package com.cyksj.model.request;
+
+import com.cyksj.model.entity.UserMirrorShopDistributeMoneyApply;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: UserMirrorShopApplyMoneyReq
+ * 创建者: JavaZou
+ * 创建时间:2024/11/7 16:27
+ */
+@Getter
+@Setter
+public class UserMirrorShopApplyMoneyReq {
+
+	private String account;
+
+	private UserMirrorShopDistributeMoneyApply.Type type;
+
+	private String realName;
+
+	/**
+	 * true提现所有积分金额
+	 */
+	private Boolean isTakeAll;
+
+	/**
+	 * 钱包地址
+	 */
+	private String walletAddr;
+
+	/**
+	 * 备注
+	 */
+	private String remark;
+
+	private Long userId;
+}

+ 55 - 0
netflix-dao/src/main/java/com/cyksj/model/views/UserMirrorShopDsOrderDetailView.java

@@ -0,0 +1,55 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.SearchBean;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: UserMirrorShopDsOrderDetailView
+ * 创建者: JavaZou
+ * 创建时间:2024/11/7 16:01
+ */
+@Getter
+@Setter
+@SearchBean(tables = "(select o.id,o.user_id,o.goods_id,o.sku_id,o.money,o.refund_money,o.coupon_money,o.created_time from order_don o inner join user_mirror_shop_order_relate uor on uor.order_id = o.id where :yhs_id: and o.status not in ('close','noPayment') :time:) od" +
+		" left join goods_don g on g.id = od.goods_id" +
+		" inner join yh_shop_distribute_waiting_send_points dp on dp.order_id = od.id")
+public class UserMirrorShopDsOrderDetailView {
+
+	@DbField("select nickname from user where id = od.user_id limit 1")
+	private String nickname;
+
+	@JsonIgnore
+	@DbField("g.id")
+	private Long goodsId;
+
+	@DbField("g.title")
+	private String title;
+
+	@DbField("select spec_val from goods_don_sku where id = od.sku_id limit 1")
+	private String specVal;
+
+	@DbField("cast(od.money/100 as decimal(10,2))")
+	private BigDecimal money;
+
+//	@DbField("od.coupon_money")
+//	private BigDecimal couponMoney;
+
+	@DbField("TRUNCATE(dp.money/100,2)")
+	private BigDecimal reMoney = BigDecimal.ZERO;
+
+	@DbField("if(send_status = 'success',TRUNCATE(dp.refund_money/100,2),0)")
+	private BigDecimal rdMoney;
+
+	@DbField("dp.send_status")
+	private String sendStatus;
+
+	@DbField("od.created_time")
+	private Date createdTime;
+}

+ 40 - 0
netflix-dao/src/main/java/com/cyksj/model/views/UserMirrorShopDsOrderStatisticsView.java

@@ -0,0 +1,40 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: UserMirrorShopDsOrderStatisticsView
+ * 创建者: JavaZou
+ * 创建时间:2024/11/7 15:57
+ */
+@Getter
+@Setter
+@SearchBean(tables = "(select o.id,o.user_id,o.goods_id,o.money,o.refund_money,o.status from order_don o inner join user_mirror_shop_order_relate uor on uor.order_id = o.id where :yhs_id: and o.status not in ('close','noPayment') :time:) od left join goods_don g on g.id = od.goods_id" +
+		" inner join yh_shop_distribute_waiting_send_points dp on dp.order_id = od.id",
+		groupBy = "od.goods_id,g.title")
+public class UserMirrorShopDsOrderStatisticsView {
+
+	@DbField("g.title")
+	private String title;
+
+	@DbField("cast(sum(od.money)/100 as decimal(10,2))")
+	private BigDecimal distributeOrderMoney;
+
+	@DbField("count(od.id)")
+	private Integer orders;
+
+	@DbField("TRUNCATE(sum(if(dp.send_status != 'close',dp.money,0))/100,2)")
+	private BigDecimal takeMoney;
+
+	@DbField("count(if(od.status = 'refund',1,NULL))")
+	private Integer refundOrders;
+
+	@DbField("cast(sum(ifnull(od.refund_money,0))/100 as decimal(10,2))")
+	private BigDecimal refundMoney;
+}

+ 77 - 0
netflix-dao/src/main/resources/mapper/UserMirrorShopDistributeWaitingSendPointsMapper.xml

@@ -0,0 +1,77 @@
+<?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.cyksj.mapper.mirrorshop.UserMirrorShopDistributeWaitingSendPointsMapper">
+
+
+    <select id="getWMoneyStatisticsDataView"
+            resultType="com.cyksj.model.views.YhShopBrokenLineCpsUserWMoneyView">
+        select min(curdate) as firstDate,
+        max(curdate) as lastDate from (select
+        <if test="today">
+            date_format(send_time, '%H') as `curdate`
+        </if>
+        <if test="!today">
+            date_format(send_time, '%Y-%m-%d') `curdate`
+        </if>
+        from `user_mirror_shop_distribute_waiting_send_points`
+        where shop_user_id = #{yhShopUserId}
+        and send_status = 'waiting'
+        <choose>
+            <when test="today">
+                <if test="first != null">
+                    and send_time >= #{first}
+                </if>
+                <if test="end != null">
+                    and send_time &lt;= #{end}
+                </if>
+                group by date_format(send_time, '%H')
+            </when>
+            <otherwise>
+                <if test="first != null">
+                    and date_format(send_time, '%Y-%m-%d') >= #{first}
+                </if>
+                <if test="end != null">
+                    and date_format(send_time, '%Y-%m-%d') &lt; #{end}
+                </if>
+                group by date_format(send_time, '%Y-%m-%d')
+            </otherwise>
+        </choose>
+        )s
+    </select>
+
+    <select id="getWMoneyStatisticsDate" resultType="com.cyksj.model.views.YhShopUserWMoneyStatisticsDataView">
+        select
+        <if test="today">
+            date_format(send_time, '%H') as `hour`,
+        </if>
+        <if test="!today">
+            date_format(send_time, '%Y-%m-%d') `date`,
+        </if>
+        TRUNCATE(sum(money)/ 100,2) money
+        from `user_mirror_shop_distribute_waiting_send_points`
+        where shop_user_id = #{yhShopUserId}
+        and send_status = 'waiting'
+        <choose>
+            <when test="today">
+                <if test="first != null">
+                    and send_time >= #{first}
+                </if>
+                <if test="end != null">
+                    and send_time &lt;= #{end}
+                </if>
+                group by date_format(send_time, '%H')
+                order by date_format(send_time, '%H')
+            </when>
+            <otherwise>
+                <if test="first != null">
+                    and date_format(send_time, '%Y-%m-%d') >= #{first}
+                </if>
+                <if test="end != null">
+                    and date_format(send_time, '%Y-%m-%d') &lt; #{end}
+                </if>
+                group by date_format(send_time, '%Y-%m-%d')
+                order by date_format(send_time, '%Y-%m-%d')
+            </otherwise>
+        </choose>
+    </select>
+</mapper>

+ 13 - 0
netflix-service/src/main/java/com/cyksj/service/mirrorshop/CmsUserMirrorShopService.java

@@ -1,6 +1,13 @@
 package com.cyksj.service.mirrorshop;
 
+import cn.hutool.core.date.DateTime;
+import com.cyksj.dto.Result;
 import com.cyksj.model.entity.User;
+import com.cyksj.model.request.UserMirrorShopApplyMoneyReq;
+import com.cyksj.model.views.YhShopBrokenLineCpsUserWMoneyView;
+import com.cyksj.model.views.YhShopUserWMoneyStatisticsDataView;
+
+import java.util.List;
 
 /**
  * 项目名: yhlxj2
@@ -14,4 +21,10 @@ public interface CmsUserMirrorShopService {
 	String yhShopManageRedirect(long userId);
 
 	User login(Integer type, String login, String code);
+
+	YhShopBrokenLineCpsUserWMoneyView getWMoneyStatisticsDate(long yhShopUserId, DateTime first, DateTime end);
+
+	List<YhShopUserWMoneyStatisticsDataView> getWMoneyStatisticsDataView(long yhShopUserId, DateTime first, DateTime end);
+
+	Result<String> applyMoney(UserMirrorShopApplyMoneyReq applyMoneyReq);
 }

+ 42 - 0
netflix-service/src/main/java/com/cyksj/service/mirrorshop/impl/CmsUserMirrorShopServiceImpl.java

@@ -1,22 +1,32 @@
 package com.cyksj.service.mirrorshop.impl;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.SmsUtil;
 import com.cyksj.common.util.StringUtil;
+import com.cyksj.dto.Result;
 import com.cyksj.mapper.UserMapper;
+import com.cyksj.mapper.mirrorshop.UserMirrorShopDistributeWaitingSendPointsMapper;
 import com.cyksj.mapper.mirrorshop.UserMirrorShopMapper;
 import com.cyksj.model.entity.User;
 import com.cyksj.model.entity.UserMirrorShop;
+import com.cyksj.model.request.UserMirrorShopApplyMoneyReq;
+import com.cyksj.model.views.YhShopBrokenLineCpsUserWMoneyView;
+import com.cyksj.model.views.YhShopUserWMoneyStatisticsDataView;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.mail.MailService;
 import com.cyksj.service.mirrorshop.CmsUserMirrorShopService;
+import com.cyksj.service.pay.TransferFuncService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 项目名: yhlxj2
  * 文件名: CmsUserMirrorShopServiceImpl
@@ -35,6 +45,10 @@ public class CmsUserMirrorShopServiceImpl implements CmsUserMirrorShopService {
 
 	private final RedisService redisService;
 
+	private final UserMirrorShopDistributeWaitingSendPointsMapper userMirrorShopDistributeWaitingSendPointsMapper;
+
+	private final TransferFuncService transferFuncService;
+
 	@Override
 	public void getLoginCode(Integer type, String login, Integer cid) {
 		if (type > 2) {
@@ -146,4 +160,32 @@ public class CmsUserMirrorShopServiceImpl implements CmsUserMirrorShopService {
 		redisService.del(CACHE_LOGIN_KEY);
 		return user;
 	}
+
+	@Override
+	public YhShopBrokenLineCpsUserWMoneyView getWMoneyStatisticsDate(long yhShopUserId, DateTime first, DateTime end) {
+		boolean today = isToday(first, end);
+		return userMirrorShopDistributeWaitingSendPointsMapper.getWMoneyStatisticsDataView(yhShopUserId, first, end, today);
+	}
+
+	@Override
+	public List<YhShopUserWMoneyStatisticsDataView> getWMoneyStatisticsDataView(long yhShopUserId, DateTime first, DateTime end) {
+		boolean today = isToday(first, end);
+		return userMirrorShopDistributeWaitingSendPointsMapper.getWMoneyStatisticsDate(yhShopUserId, first, end, today);
+	}
+
+	@Override
+	public Result<String> applyMoney(UserMirrorShopApplyMoneyReq applyMoneyReq) {
+		return transferFuncService.userMirrorShopDistributeApply(applyMoneyReq);
+	}
+
+
+	public boolean isToday(DateTime first, DateTime end) {
+		boolean today = false;
+		if (first != null && end != null) {
+			if (DateUtil.beginOfDay(DateTime.now()).equals(first) && (DateUtil.beginOfDay(DateUtil.offsetDay(DateTime.now(), 1)).equals(end) || DateUtil.endOfDay(DateTime.now()).equals(end))) {
+				today = true;
+			}
+		}
+		return today;
+	}
 }

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/pay/TransferFuncService.java

@@ -4,6 +4,7 @@ import com.alipay.api.AlipayResponse;
 import com.cyksj.dto.Result;
 import com.cyksj.model.request.ApplyMoneyReq;
 import com.cyksj.model.request.TransferAccountsReq;
+import com.cyksj.model.request.UserMirrorShopApplyMoneyReq;
 import com.cyksj.model.request.YhShopApplyMoneyReq;
 
 /*
@@ -31,4 +32,6 @@ public interface TransferFuncService {
 	AlipayResponse transferAccounts(TransferAccountsReq transferAccountsReq) throws Exception;
 
 	Result<String> subApplyMoney(ApplyMoneyReq applyMoneyReq) throws Exception;
+
+	Result<String> userMirrorShopDistributeApply(UserMirrorShopApplyMoneyReq applyMoneyReq);
 }

+ 118 - 0
netflix-service/src/main/java/com/cyksj/service/pay/impl/TransferFuncServiceImpl.java

@@ -29,11 +29,13 @@ import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.manage.distribute.DistributeMoneyApplyMapper;
 import com.cyksj.mapper.manage.distribute.DistributePointsExchangeMoneyMapper;
 import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
+import com.cyksj.mapper.mirrorshop.UserMirrorShopDistributeMoneyApplyMapper;
 import com.cyksj.mapper.shop.YhShopDistributeMoneyApplyMapper;
 import com.cyksj.mapper.shop.YhShopMapper;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.request.ApplyMoneyReq;
 import com.cyksj.model.request.TransferAccountsReq;
+import com.cyksj.model.request.UserMirrorShopApplyMoneyReq;
 import com.cyksj.model.request.YhShopApplyMoneyReq;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.distribute.UserDistributeReturnMoneyDetailService;
@@ -84,6 +86,8 @@ public class TransferFuncServiceImpl implements TransferFuncService {
 
 	private final UserDistributeReturnMoneyDetailService userDistributeReturnMoneyDetailService;
 
+	private final UserMirrorShopDistributeMoneyApplyMapper userMirrorShopDistributeMoneyApplyMapper;
+
 	@Override
 	public Result distributeApply(ApplyMoneyReq applyMoneyReq) throws Exception {
 		applyMoneyReq.setMType(DistributeMoneyApply.MType.ds);
@@ -166,6 +170,120 @@ public class TransferFuncServiceImpl implements TransferFuncService {
 		return commonApplyMoney(applyMoneyReq);
 	}
 
+	@Override
+	public Result<String> userMirrorShopDistributeApply(UserMirrorShopApplyMoneyReq applyMoneyReq) {
+		String type = "mirrorShop";
+		String key = String.format(RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getName(), DateTime.now().toDateStr(), type, applyMoneyReq.getUserId());
+		if (!redisService.setNx(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout())) {
+			throw BusinessRuntimeException.getInstance("每天仅可提现一次");
+		}
+		try {
+			Result result = userMirrorShopApplyMoney(applyMoneyReq);
+			if (result.isFlag()) {
+				redisService.set(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout());
+			} else {
+				redisService.del(key);
+			}
+			return result;
+		} catch (Exception e) {
+			redisService.del(key);
+			throw BusinessRuntimeException.getInstance(StringUtil.getErrorMsg(e));
+		}
+	}
+
+	private Result userMirrorShopApplyMoney(UserMirrorShopApplyMoneyReq applyMoneyReq) throws Exception {
+		Long userId = applyMoneyReq.getUserId();
+		User user = userMapper.selectById(userId);
+		if (user == null) {
+			throw BusinessRuntimeException.getInstance("请先授权登录");
+		}
+		Boolean isTakeAll = applyMoneyReq.getIsTakeAll();
+		UserMirrorShopDistributeMoneyApply.Type type = applyMoneyReq.getType();
+		if (type == null) type = UserMirrorShopDistributeMoneyApply.Type.zfb;
+		if (type == UserMirrorShopDistributeMoneyApply.Type.zfb) {
+			if (ObjectUtil.hasEmpty(applyMoneyReq.getAccount(), applyMoneyReq.getRealName())) {
+				throw BusinessRuntimeException.getInstance("必填项不能为空");
+			}
+			if (applyMoneyReq.getAccount().length() > 255 || applyMoneyReq.getRealName().length() > 32) {
+				throw BusinessRuntimeException.getInstance("请输入正确的账户信息");
+			}
+		}
+		if (type == UserMirrorShopDistributeMoneyApply.Type.usdt) {
+			if (StrUtil.isEmpty(applyMoneyReq.getWalletAddr())) {
+				throw BusinessRuntimeException.getInstance("USDT提现钱包地址不能为空");
+			}
+			if (applyMoneyReq.getWalletAddr().length() > 1000) {
+				throw BusinessRuntimeException.getInstance("请输入正确的钱包地址");
+			}
+			if (StrUtil.isNotBlank(applyMoneyReq.getRemark()) && applyMoneyReq.getRemark().length() > 512) {
+				throw BusinessRuntimeException.getInstance("备注过多");
+			}
+			isTakeAll = true;
+
+		}
+		UserMirrorShopDistributeMoneyApply distributeMoneyApply = null;
+
+		BigDecimal needApplyMoney = user.getMpMoney();
+		BigDecimal fourHundred = BigDecimal.valueOf(4 * 10000);
+		if (isTakeAll == null || !isTakeAll) {
+			if (needApplyMoney.compareTo(fourHundred) > 0) {
+				needApplyMoney = fourHundred;
+			}
+		}
+		Integer update = userMapper.subUserMirrorShopMoney(user.getId(), user.getMpMoney(), needApplyMoney);
+		if (update == 1) {
+			distributeMoneyApply = Optional.ofNullable(distributeMoneyApply).orElse(new UserMirrorShopDistributeMoneyApply());
+			distributeMoneyApply.setUserId(userId);
+			distributeMoneyApply.setMoney(needApplyMoney);
+			distributeMoneyApply.setAccount(applyMoneyReq.getAccount());
+			distributeMoneyApply.setRealName(applyMoneyReq.getRealName());
+			distributeMoneyApply.setWalletAddr(applyMoneyReq.getWalletAddr());
+			distributeMoneyApply.setRemark(applyMoneyReq.getRemark());
+			distributeMoneyApply.setType(applyMoneyReq.getType());
+			if (isTakeAll != null && isTakeAll) {
+				distributeMoneyApply.setVerifyStatus(UserMirrorShopDistributeMoneyApply.Status.verifying);
+			} else {
+				TransferAccountsReq req = new TransferAccountsReq();
+				req.setMoney(needApplyMoney);
+				req.setAccount(applyMoneyReq.getAccount());
+				req.setName(applyMoneyReq.getRealName());
+				req.setChannelType(2);
+				req.setUserId(userId);
+				req.setRemark("镜像小店提现");
+				AlipayResponse alipayResponse = transferAccounts(req);
+				if (alipayResponse.isSuccess()) {
+					distributeMoneyApply.setVerifyStatus(UserMirrorShopDistributeMoneyApply.Status.success);
+				} else {
+					distributeMoneyApply.setVerifyStatus(UserMirrorShopDistributeMoneyApply.Status.fail);
+					distributeMoneyApply.setReason(alipayResponse.getSubMsg());
+					userBenefitsService.addMpMoney(userId, distributeMoneyApply.getMoney());
+					if (StrUtil.equals(alipayResponse.getSubCode(), "SECURITY_CHECK_FAILED")) {
+						return GatewayResponse.FAIL.newBuilder().setMsg("当前支付宝提现人数较多,请稍后再试").toResult();
+					}
+					if (alipayResponse.getSubMsg().contains("冻结")) {
+						return GatewayResponse.FAIL.newBuilder().setMsg("目前财务清账中,48小时后可提现").toResult();
+					}
+					if (alipayResponse.getSubMsg().contains("余额不足")) {
+						return GatewayResponse.FAIL.newBuilder().setMsg("转账失败,请联系客服").toResult();
+					}
+					return GatewayResponse.FAIL.newBuilder().setMsg(alipayResponse.getSubMsg()).toResult();
+				}
+			}
+			try {
+				userMirrorShopDistributeMoneyApplyMapper.insert(distributeMoneyApply);
+				//大额提现 超过400
+				if (envCommonService.isPrdEnv() && distributeMoneyApply.getVerifyStatus() == UserMirrorShopDistributeMoneyApply.Status.verifying && distributeMoneyApply.getMoney().compareTo(fourHundred) > 0) {
+					SmsUtil.sendLuoKey2Msg(Constant.ZK_MOBILE, "镜像小店有大额提现申请【银河录像局】");
+				}
+			} catch (Exception e) {
+				userBenefitsService.addMpMoney(userId, distributeMoneyApply.getMoney());
+				return GatewayResponse.FAIL.newBuilder().setMsg("网络错误,请重试").toResult();
+			}
+			return GatewayResponse.SUCCESS.newBuilder().toResult(distributeMoneyApply);
+		}
+		throw BusinessRuntimeException.getInstance("系统异常,请重新提交提现申请");
+	}
+
 	private AlipayRequest aliPayTransferAccountsRequest(String donNo, String account, String name, BigDecimal money, String remark) {
 		//支付宝转账
 		AlipayFundTransUniTransferRequest transUniTransferRequest = new AlipayFundTransUniTransferRequest();

+ 127 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/mirrorshop/manage/CmsUserMirrorShopController.java

@@ -0,0 +1,127 @@
+package com.cyksj.web.controller.manage.mirrorshop.manage;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.dto.Result;
+import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.mirrorshop.UserMirrorShopApplyRecordMapper;
+import com.cyksj.mapper.mirrorshop.UserMirrorShopMapper;
+import com.cyksj.model.entity.UserMirrorShop;
+import com.cyksj.model.entity.UserMirrorShopApplyRecord;
+import com.cyksj.model.entity.YhShopApplyRecord;
+import com.cyksj.model.request.UserMirrorShopApplyMoneyReq;
+import com.cyksj.service.mirrorshop.CmsUserMirrorShopService;
+import com.cyksj.web.util.StpUserMirrorShopManageUser;
+import com.cyksj.web.util.StpYhShopManageUser;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.util.MapUtils;
+import lombok.RequiredArgsConstructor;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: CmsUserMirrorShopController
+ * 创建者: JavaZou
+ * 创建时间:2024/11/7 16:10
+ */
+@RestController
+@RequestMapping("/mirrorShop/manage")
+@RequiredArgsConstructor
+public class CmsUserMirrorShopController {
+	private final BeanSearcher beanSearcher;
+
+	private final HttpServletRequest request;
+
+	private final UserMirrorShopMapper userMirrorShopMapper;
+
+	private final UserMirrorShopApplyRecordMapper userMirrorShopApplyRecordMapper;
+
+	private final CmsUserMirrorShopService cmsUserMirrorShopService;
+
+	/**
+	 * 店铺 信息详情
+	 */
+	@GetMapping("/get/shop/detail/data")
+	public Result<UserMirrorShop> getShopDetail() {
+		long yhShopUserId = StpUserMirrorShopManageUser.getLoginIdAsLong();
+		UserMirrorShop detailView = beanSearcher.searchFirst(UserMirrorShop.class, MapUtils.flatBuilder(request.getParameterMap())
+				.field(UserMirrorShop::getUserId, yhShopUserId)
+				.build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(detailView);
+	}
+
+	/**
+	 * 设置联系方式
+	 */
+	@PutMapping("/set/shop/contact")
+	public Result<String> setShopContact(@RequestBody UserMirrorShop yhShop) {
+		long userId = StpUserMirrorShopManageUser.getLoginIdAsLong();
+		String contact = yhShop.getContact();
+		UserMirrorShop userMirrorShop = userMirrorShopMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShop.class)
+				.eq(UserMirrorShop::getUserId, userId).last("limit 1"));
+		if (userMirrorShop == null) {
+			throw BusinessRuntimeException.getInstance("店铺不存在");
+		}
+		userMirrorShop.setContact(contact);
+		userMirrorShopMapper.updateById(userMirrorShop);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+
+	/**
+	 * 申请修改
+	 */
+	@PutMapping("/update/shop")
+	@Transactional(rollbackFor = Throwable.class)
+	public Result<String> updateShop(@RequestBody YhShopApplyRecord record) {
+		long userId = StpUserMirrorShopManageUser.getLoginIdAsLong();
+		UserMirrorShop userMirrorShop = userMirrorShopMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShop.class)
+				.eq(UserMirrorShop::getUserId, userId).last("limit 1"));
+		String name = record.getName();
+		if (userMirrorShop == null) {
+			throw BusinessRuntimeException.getInstance("店铺不存在");
+		}
+		if (StrUtil.isEmpty(name)) {
+			throw BusinessRuntimeException.getInstance("请输入申请修改的店铺名");
+		}
+		//是否存在正在修改的提交记录
+		UserMirrorShopApplyRecord userMirrorShopApplyRecord = userMirrorShopApplyRecordMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShopApplyRecord.class)
+				.eq(UserMirrorShopApplyRecord::getUserId, userId)
+				.eq(UserMirrorShopApplyRecord::getVerifyStatus, YhShopApplyRecord.Status.verify).last("limit 1"));
+
+		if (userMirrorShopApplyRecord != null) {
+			throw BusinessRuntimeException.getInstance("您提交的修改申请正在审核中..");
+		}
+		//三个月可修改一次
+		Integer count = userMirrorShopApplyRecordMapper.selectCount(Wrappers.lambdaQuery(UserMirrorShopApplyRecord.class)
+				.eq(UserMirrorShopApplyRecord::getUserId, userId)
+				.isNull(UserMirrorShopApplyRecord::getCustomId)
+				.ge(UserMirrorShopApplyRecord::getCreatedTime, DateUtil.offsetMonth(DateTime.now(), -3)));
+		if (count > 0) {
+			throw BusinessRuntimeException.getInstance("近三个月只可修改一次");
+		}
+		userMirrorShopApplyRecord = new UserMirrorShopApplyRecord();
+		userMirrorShopApplyRecord.setVerifyStatus(YhShopApplyRecord.Status.verify);
+		userMirrorShopApplyRecord.setName(name);
+		userMirrorShopApplyRecord.setUserId(userId);
+		userMirrorShopApplyRecordMapper.insert(userMirrorShopApplyRecord);
+
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 申请 提现
+	 */
+	@PostMapping("/apply/money")
+	public Result<String> yhShopApplyMoney(@RequestBody UserMirrorShopApplyMoneyReq applyMoneyReq) throws Exception {
+		long userId = StpYhShopManageUser.getLoginIdAsLong();
+		applyMoneyReq.setUserId(userId);
+		return cmsUserMirrorShopService.applyMoney(applyMoneyReq);
+	}
+}

+ 158 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/mirrorshop/manage/CmsUserMirrorShopDataController.java

@@ -1,10 +1,168 @@
 package com.cyksj.web.controller.manage.mirrorshop.manage;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.dto.Result;
+import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.GoodsDonMapper;
+import com.cyksj.mapper.mirrorshop.UserMirrorShopMapper;
+import com.cyksj.model.entity.*;
+import com.cyksj.model.views.*;
+import com.cyksj.service.mirrorshop.CmsUserMirrorShopService;
+import com.cyksj.web.util.StpUserMirrorShopManageUser;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.SearchResult;
+import com.ejlchina.searcher.util.MapBuilder;
+import com.ejlchina.searcher.util.MapUtils;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Optional;
+
 /**
  * 项目名: yhlxj2
  * 文件名: CmsUserMirrorShopDataController
  * 创建者: JavaZou
  * 创建时间:2024/11/7 12:03
  */
+@RestController
+@RequestMapping("/mirrorShop/manage/data")
+@RequiredArgsConstructor
 public class CmsUserMirrorShopDataController {
+	private final UserMirrorShopMapper userMirrorShopMapper;
+
+	private final BeanSearcher beanSearcher;
+
+	private final HttpServletRequest request;
+
+	private final CmsUserMirrorShopService cmsUserMirrorShopService;
+
+	private final GoodsDonMapper goodsDonMapper;
+
+
+
+	/**
+	 * 店铺分销平台数据详情
+	 */
+	@GetMapping("/get/distribute/detail/data")
+	public Result<YhShopUserDistributeDetailView> getDistributeDetail() {
+		long yhShopUserId = StpUserMirrorShopManageUser.getLoginIdAsLong();
+		User user = beanSearcher.searchFirst(User.class, MapUtils.builder().field(User::getId, yhShopUserId).onlySelect(User::getYhsMoney).build());
+		BigDecimal wApplyMoney = user.getMpMoney().divide(BigDecimal.valueOf(100));
+		//已提现
+		Number gotApplyMoney = beanSearcher.searchSum(UserMirrorShopDistributeMoneyApply.class, MapUtils.builder()
+				.field(UserMirrorShopDistributeMoneyApply::getUserId, yhShopUserId)
+				.field(UserMirrorShopDistributeMoneyApply::getVerifyStatus, YhShopDistributeMoneyApply.Status.success.name())
+				.build(), "money");
+		Number reMoneyPoints = beanSearcher.searchSum(UserMirrorShopDistributeWaitingSendPoints.class, MapUtils.builder().field(UserMirrorShopDistributeWaitingSendPoints::getShopUserId, yhShopUserId).field(UserMirrorShopDistributeWaitingSendPoints::getSendStatus, UserMirrorShopDistributeWaitingSendPoints.Status.success.name()).build(), "money");
+		Number wMoneyPoints = beanSearcher.searchSum(UserMirrorShopDistributeWaitingSendPoints.class, MapUtils.builder().field(UserMirrorShopDistributeWaitingSendPoints::getShopUserId, yhShopUserId).field(UserMirrorShopDistributeWaitingSendPoints::getSendStatus, UserMirrorShopDistributeWaitingSendPoints.Status.waiting.name()).build(), "money");
+
+		YhShopUserDistributeDetailView detailView = new YhShopUserDistributeDetailView();
+		detailView.setWMoney(BigDecimal.valueOf(wMoneyPoints.doubleValue()).divide(BigDecimal.valueOf(100)));
+		detailView.setReMoney(BigDecimal.valueOf(reMoneyPoints.doubleValue()).divide(BigDecimal.valueOf(100)));
+
+		detailView.setWApplyMoney(wApplyMoney);
+		detailView.setGotApplyMoney(BigDecimal.valueOf(gotApplyMoney.doubleValue()).divide(BigDecimal.valueOf(100)));
+		return GatewayResponse.SUCCESS.newBuilder().toResult(detailView);
+	}
+
+
+
+	/**
+	 * 店铺待入账数据统计
+	 */
+	@GetMapping("/get/wMoney/statisticsData")
+	public Result<YhShopBrokenLineCpsUserWMoneyView> getWMoneyStatisticsDataView(Long firstDate, Long lastDate) {
+		long yhShopUserId = StpUserMirrorShopManageUser.getLoginIdAsLong();
+		DateTime first = null;
+		DateTime end = null;
+		if (firstDate != null) {
+			first = DateUtil.date(firstDate);
+		}
+		if (lastDate != null) {
+			end = DateUtil.date(lastDate);
+		}
+		YhShopBrokenLineCpsUserWMoneyView brokenLineCpsUserWMoneyView = Optional.ofNullable(cmsUserMirrorShopService.getWMoneyStatisticsDate(yhShopUserId, first, end)).orElse(new YhShopBrokenLineCpsUserWMoneyView());
+		List<YhShopUserWMoneyStatisticsDataView> dataView = cmsUserMirrorShopService.getWMoneyStatisticsDataView(yhShopUserId, first, end);
+		brokenLineCpsUserWMoneyView.setDataView(dataView);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(brokenLineCpsUserWMoneyView);
+	}
+
+	/**
+	 * 店铺分销订单收入统计
+	 */
+	@GetMapping("/get/distribute/orders/statisticsData")
+	public Result<SearchResult<UserMirrorShopDsOrderStatisticsView>> getUserDistributeOrdersStatisticsView(Long firstDate, Long lastDate) {
+		long yhShopUserId = StpUserMirrorShopManageUser.getLoginIdAsLong();
+		UserMirrorShop yhShop = userMirrorShopMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShop.class)
+				.eq(UserMirrorShop::getUserId, yhShopUserId).last("limit 1"));
+		String first = null;
+		String end = null;
+		String timeSql = StrUtil.EMPTY;
+		if (firstDate != null) {
+			first = DateUtil.format(DateTime.of(firstDate), "yyyy-MM-dd HH:mm:ss");
+			timeSql += String.format(" and o.created_time >= '%s'", first);
+		}
+		if (lastDate != null) {
+			end = DateUtil.format(DateTime.of(lastDate), "yyyy-MM-dd HH:mm:ss");
+			timeSql += String.format(" and o.created_time < '%s'", end);
+		}
+		MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
+		builder.put("yhs_id", String.format("uor.mp_id = %s", yhShop.getId()));
+		if (StrUtil.isNotEmpty(timeSql)) {
+			builder.put("time", timeSql);
+		}
+		SearchResult<UserMirrorShopDsOrderStatisticsView> search = beanSearcher.search(UserMirrorShopDsOrderStatisticsView.class, builder.build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
+	}
+
+	/**
+	 * 店铺分销订单收入详细
+	 */
+	@GetMapping("/get/distribute/orders/detail/data")
+	public Result<SearchResult<UserMirrorShopDsOrderDetailView>> getUserDistributeOrdersDetailView(Long firstDate, Long lastDate) {
+		long yhShopUserId = StpUserMirrorShopManageUser.getLoginIdAsLong();
+		UserMirrorShop yhShop = userMirrorShopMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShop.class)
+				.eq(UserMirrorShop::getUserId, yhShopUserId).last("limit 1"));
+		String first = null;
+		String end = null;
+		String timeSql = StrUtil.EMPTY;
+		if (firstDate != null) {
+			first = DateUtil.format(DateTime.of(firstDate), "yyyy-MM-dd HH:mm:ss");
+			timeSql += String.format(" and o.created_time >= '%s'", first);
+		}
+		if (lastDate != null) {
+			end = DateUtil.format(DateTime.of(lastDate), "yyyy-MM-dd HH:mm:ss");
+			timeSql += String.format(" and o.created_time < '%s'", end);
+		}
+		MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
+		builder.put("yhs_id", String.format("uor.mp_id = %s", yhShop.getId()));
+		if (StrUtil.isNotEmpty(timeSql)) {
+			builder.put("time", timeSql);
+		}
+		SearchResult<UserMirrorShopDsOrderDetailView> search = beanSearcher.search(UserMirrorShopDsOrderDetailView.class, builder.build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
+	}
+
+	/**
+	 * 店铺分销商品列表
+	 */
+	@GetMapping("/get/orders/goods")
+	public Result<List<GoodsDon>> getGoodsList() {
+		long yhShopUserId = StpUserMirrorShopManageUser.getLoginIdAsLong();
+		UserMirrorShop yhShop = userMirrorShopMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShop.class)
+				.eq(UserMirrorShop::getUserId, yhShopUserId).last("limit 1"));
+		if (yhShop == null) {
+			return GatewayResponse.SUCCESS.newBuilder().toResult();
+		}
+		List<GoodsDon> goodsDons = goodsDonMapper.getUserMirrorShopShopDistributeGoodsDetail(yhShop.getId());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDons);
+	}
 }