推广部分大改

This commit is contained in:
liuyingfang
2023-07-21 19:30:00 +08:00
parent bfba38e27b
commit d4fe97d570
25 changed files with 805 additions and 58 deletions

View File

@@ -4,13 +4,17 @@ import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.app.MainPageService;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.merchantProfit.MerchantProfitService;
import cn.pluss.platform.userApp.UserAppService;
import cn.pluss.platform.vo.MerchantProfitVO;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@RestController
@@ -25,6 +29,8 @@ public class MainPageController {
@Autowired
private MainPageService agentStaffMainPageService;
@Resource
private MerchantProfitService merchantProfitService;
/**
* @page 商户推广
@@ -37,12 +43,35 @@ public class MainPageController {
UserApp userApp = userAppService.queryUserAppByToken();
Map<String, Object> resultMap;
if ("agent_staff".equals(userApp.getUserType())) {
resultMap = agentStaffMainPageService.getSpreadData(userApp.getUserId() + "");
} else {
resultMap = promoterMainPageService.getSpreadData(userApp.getUserId() + "");
}
resultMap = promoterMainPageService.getSpreadData(userApp.getUserId() + "");
return ResultGenerator.genSuccessResult(resultMap);
}
@GetMapping("/userApp/modifyFee")
public Result<Object> modifyFee(@RequestParam("id") Integer id, @RequestParam("fee") BigDecimal fee){
UserApp result = userAppService.queryUserBaseInfoByToken();
promoterMainPageService.modifyFee(result.getUserId(), id, fee);
return ResultGenerator.genSuccessResult();
}
/**
* 团队管理
* @param name
* @param page
* @param size
* @param typeCode
* @return
*/
@GetMapping("/userApp/teamControl")
public Result<Object> teamControl(String name,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer size,
@RequestParam("typeCode") String typeCode){
UserApp result = userAppService.queryUserBaseInfoByToken();
Map<String, Object> merchantProfitVOS = merchantProfitService.teamList(typeCode, result.getUserId(),
page,size,name);
return ResultGenerator.genSuccessResult(merchantProfitVOS);
}
}

View File

@@ -383,14 +383,16 @@ public class UserAppController {
QueryWrapper<UserPromotion> QueryWrapper = new QueryWrapper<>();
QueryWrapper.eq("user_id", result.getUserId());
UserPromotion userPromotion = userPromotionService.getOne(QueryWrapper);
if (userPromotion== null) {
MsgException.checkBlank("", "用户状态异常");
}
result.setTypeCode(userPromotion == null?"null":userPromotion.getTypeCode());
result.setMinFee(userPromotion == null?"null":userPromotion.getCurrentFee());
if("promoter".equals(result.getUserType())) {
if (userPromotion == null) {
MsgException.checkBlank("", "用户状态异常");
}
result.setTypeCode(userPromotion == null ? "null" : userPromotion.getTypeCode());
result.setMinFee(userPromotion == null ? "null" : userPromotion.getCurrentFee());
result.setMaxFee("0.32");
result.setIsExtend(userPromotion.getIsExtend());
result.setMaxFee("0.32");
result.setIsExtend(userPromotion.getIsExtend());
}
return ResultGenerator.genSuccessResult(result);
}

View File

@@ -0,0 +1,47 @@
package cn.pluss.platform.util;
import java.math.BigDecimal;
import static java.math.BigDecimal.ROUND_DOWN;
public class N {
public static final int SCALE = 6;
public static final boolean isZero(BigDecimal num) {
return num == null || BigDecimal.ZERO.compareTo(num) == 0;
}
public static final boolean isNull(BigDecimal num) {
return num == null;
}
public static final boolean eq(BigDecimal n1, BigDecimal n2) {
return (!isNull(n1) && !isNull(n2) && n1.compareTo(n2) == 0);//n1==n2
}
public static final boolean gt(BigDecimal n1, BigDecimal n2) {
return (!isNull(n1) && !isNull(n2) && n1.compareTo(n2) > 0);//n1>n2
}
public static final boolean egt(BigDecimal n1, BigDecimal n2) {
return (!isNull(n1) && !isNull(n2) && n1.compareTo(n2) >= 0);
}
public static final BigDecimal mul(BigDecimal b1, BigDecimal b2) {
if (isNull(b1) || isNull(b2))
throw new IllegalArgumentException();
return b1.multiply(b2).setScale(SCALE, ROUND_DOWN);
}
public static final BigDecimal div(BigDecimal b1, BigDecimal b2) {
if (isNull(b1) || isZero(b2))
throw new IllegalArgumentException();
return b1.divide(b2, SCALE, ROUND_DOWN);
}
}

View File

@@ -135,7 +135,7 @@ public interface MerchantOrderMapper extends BaseMapper<MerchantOrder> {
Double queryMerchantOrderEnterFeeByTime(Map map);
Double queryMerchantOrderShareMoneyByTime(Map map);
BigDecimal queryMerchantOrderMoneyByTime(Map map);
/**
*
* queryMerchantOrderPageShuju:(最新统计订单方法). <br/>
@@ -235,6 +235,7 @@ public interface MerchantOrderMapper extends BaseMapper<MerchantOrder> {
"WHERE merchantCode = #{merchantCode} AND createDate = #{date} AND `status` IN (1, 2)")
Map<String, Object> getConsumeFee(@Param("merchantCode") String merchantCode, @Param("date") String date);
Map<String, Object> querySumCount(Map<String, Object> params);
/**
@@ -427,5 +428,23 @@ public interface MerchantOrderMapper extends BaseMapper<MerchantOrder> {
@Select("SELECT * FROM tb_pluss_merchant_order WHERE mercOrderNo = #{mercOrderNo} limit 1")
MerchantOrder getByMercOrderNo(String mercOrderNo);
@Select("SELECT count(0)\n" +
"FROM tb_pluss_merchant_order mo\n" +
"LEFT JOIN tb_pluss_user_app ua ON ua.merchantCode = mo.merchantCode\n" +
"WHERE\n" +
" ua.userId = #{userId} ")
Integer getCountUser(@Param("userId") Long userId);
@Select("SELECT IFNULL(SUM(consumeFee - refundAmt),0) FROM tb_pluss_merchant_order WHERE merchantCode=#{merchantCode} AND `status` = 1")
BigDecimal getAmountData(@Param("merchantCode") String merchantCode);
/**
* 昨日收款
* @param startDate
* @param endDate
* @return
*/
@Select("SELECT IFNULL(SUM(consumeFee - refundAmt),0) FROM tb_pluss_merchant_order WHERE merchantCode=#{merchantCode} AND `status` = 1 AND transDt >= #{startDate} AND transDt <= #{endDate}")
BigDecimal getPlatformAmtYestday(@Param("merchantCode") String merchantCode,@Param("startDate") Date startDate, @Param("endDate") Date endDate);
}

View File

@@ -1,7 +1,9 @@
package cn.pluss.platform.mapper;
import cn.pluss.platform.dto.MerchantFeeDTO;
import cn.pluss.platform.entity.MerchantChannelStatus;
import cn.pluss.platform.entity.MerchantProfit;
import cn.pluss.platform.vo.MerchantProfitVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -67,5 +69,64 @@ public interface MerchantProfitMapper extends BaseMapper<MerchantProfit> {
Map<String, BigDecimal> getProfitAmtCount(MerchantProfit condition);
/**
* 今日收益
* @param userId
* @return
*/
@Select("SELECT\n" +
"\tsum( t.price ) \n" +
"FROM\n" +
"\ttb_pluss_merchant_profit t \n" +
"WHERE\n" +
"\tt.type = 5 \n" +
"\tAND t.userId = #{userId} \n" +
"\tAND date_format( `t`.`createDt`, '%Y-%m-%d' ) = date_format(( curdate() - INTERVAL 0 DAY ), '%Y-%m-%d' );")
BigDecimal getTodaySum(@Param("userId")String userId);
/**
* 直属商户交易金额
* @return
*/
@Select("SELECT\n" +
"\tsum( o.consumeFee ) \n" +
"FROM\n" +
"\ttb_pluss_merchant_order o\n" +
"\tLEFT JOIN tb_pluss_merchant_base_info b ON o.merchantCode = b.merchantCode\n" +
"\tLEFT JOIN tb_pluss_user_promotion p ON b.userId = p.user_id \n" +
"WHERE\n" +
"\to.`status` = 1 \n" +
"\tAND p.parent_user_id = #{userId}")
BigDecimal getConsumeFee(@Param("userId") String userId);
/**
* 团队总交易金额
* @param userId
* @return
*/
BigDecimal getConsumeFeeTeam(@Param("userId") String userId);
/**
* 团队总交易金额(今日)
* @param userId
* @return
*/
BigDecimal getConsumeFeeTeamToday(@Param("userId") String userId);
List<MerchantProfitVO> getTeamList(@Param("typeCode") String typeCode, @Param("userId") Long userId,
@Param("page") Integer page, @Param("size") Integer size, @Param("userName") String userName);
@Select("SELECT\n" +
"\tcount(*) \n" +
"FROM\n" +
"\ttb_pluss_user_promotion \n" +
"WHERE\n" +
"\tparent_user_id = #{userId}\n" +
"\tAND type_code = #{typeCode}")
Integer getCountChild( @Param("userId") Long userId,@Param("typeCode") String typeCod);
List<MerchantChannelStatus> getChannelStatus(@Param("merchantCode") String merchantCode);
}

View File

@@ -45,6 +45,7 @@ public interface UserAppMapper extends BaseMapper<UserApp> {
MerchSummaryVO selectBillCountAndTotalFee(@Param("condition") MerchSearchDTO condition);
Integer queryUserAppPageCount(Map<String, Object> map);
Integer queryUserPageCount(Map<String, Object> map);
List<UserInfoVO> queryUserInfoVOPage(Map<String, Object> map);

View File

@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.List;
@Mapper
@@ -31,4 +32,14 @@ public interface UserPromotionMapper extends BaseMapper<UserPromotion> {
"WHERE\n" +
"\tP.user_id = #{userId}")
UserPromotion selectByUserId(@Param("userId") String userId);
UserPromotion selectByPrimaryKey(Long userId);
@Select("select max(current_fee) from tb_pluss_user_promotion where parent_user_id=#{id}")
BigDecimal selectMaxFeeByUserId(@Param("id")String id);
@Select(" select *\n" +
" from tb_pluss_user_promotion\n" +
" where user_id = #{userId}" +
" limit 1 ")
UserPromotion getOne(@Param("userId") Long userId);
int updateByPrimaryKey(UserPromotion record);
}

View File

@@ -2981,4 +2981,18 @@
#{item}
</foreach>
</select>
<select id="queryMerchantOrderMoneyByTime" resultType="java.math.BigDecimal">
SELECT sum(consumeFee) from tb_pluss_merchant_order
<where>
<if test="startTime != null">
and transDt &gt;= #{startTime}
</if>
<if test="endTime!= null">
and transDt &lt;= #{endTime}
</if>
AND merchantCode = #{merchantCode}
AND status = 1
</where>
</select>
</mapper>

View File

@@ -248,14 +248,19 @@
<select id="queryMerchantProfitPage" parameterType="java.util.Map"
resultType="cn.pluss.platform.entity.MerchantProfit">
SELECT
profit.*,
ua.userType
u.loginName as childLoginName,
u.trueName as childtrueName,
p.type_code ,
t.loginName as userLoginName,
t.trueName as usertrueName,
profit.*
FROM
tb_pluss_merchant_profit profit
LEFT JOIN tb_pluss_merchant_order merchantOrder ON profit.orderNumber = merchantOrder.orderNumber
LEFT JOIN tb_pluss_user_app ua ON ua.userId = profit.userId
LEFT JOIN tb_pluss_user_promotion p ON profit.userId = p.parent_user_id
LEFT JOIN tb_pluss_user_info u ON p.user_id = u.id
left join tb_pluss_user_info t on profit.userId=t.id
<where>
and merchantOrder.status = 1
profit.userId=#{userId}
<if test="id!= null">
and profit.id = #{id}
</if>
@@ -346,7 +351,6 @@
<if test="merchantParentPhone!= null">
and profit.merchantParentPhone = #{merchantParentPhone}
</if>
</where>
order by id desc limit #{pageSize} offset #{offset}
</select>
@@ -555,7 +559,7 @@
<select id="queryMerchantProfitSumPrice" parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(price) from tb_pluss_merchant_profit profit
<where>
WHERE profit.type = 5
<if test="id!= null">
and profit.id = #{id}
</if>
@@ -565,9 +569,6 @@
<if test="userId!= null">
and profit.userId = #{userId}
</if>
<if test="type!= null">
and profit.type = #{type}
</if>
<if test="price!= null">
and profit.price = #{price}
</if>
@@ -658,7 +659,7 @@
<if test="recordDateEnd != null">
and profit.recordDate &lt;= #{recordDateEnd}
</if>
</where>
</select>
@@ -865,4 +866,71 @@
</foreach>
GROUP BY userId
</select>
<select id="getConsumeFeeTeam" resultType="java.math.BigDecimal">
SELECT
SUM(v.consumeFee)
FROM
(
SELECT
@ids AS _ids,
( SELECT @ids := GROUP_CONCAT( user_id ) FROM tb_pluss_user_promotion WHERE FIND_IN_SET( parent_user_id, @ids ) ) AS cids,
@l := @l + 1 AS LEVEL
FROM
tb_pluss_user_promotion,
( SELECT @ids := #{userId}, @l := 0 ) b
WHERE @ids IS NOT NULL ) ID,
tb_pluss_user_promotion p
LEFT JOIN tb_pluss_merchant_base_info b ON b.userId = p.user_id
LEFT JOIN tb_pluss_merchant_order v ON v.merchantCode = b.merchantCode
WHERE
FIND_IN_SET( p.user_id, ID._ids )
AND v.status = 1
</select>
<select id="getConsumeFeeTeamToday" resultType="java.math.BigDecimal">
SELECT
SUM(v.consumeFee)
FROM
(
SELECT
@ids AS _ids,
( SELECT @ids := GROUP_CONCAT( user_id ) FROM tb_pluss_user_promotion WHERE FIND_IN_SET( parent_user_id, @ids ) ) AS cids,
@l := @l + 1 AS LEVEL
FROM
tb_pluss_user_promotion,
( SELECT @ids := #{userId}, @l := 0 ) b
WHERE @ids IS NOT NULL ) ID,
tb_pluss_user_promotion p
LEFT JOIN tb_pluss_merchant_base_info b ON b.userId = p.user_id
LEFT JOIN tb_pluss_merchant_order v ON v.merchantCode = b.merchantCode
WHERE
FIND_IN_SET( p.user_id, ID._ids )
AND v.status = 1
AND date_format( `v`.`transDt`, '%Y-%m-%d' ) = date_format(( curdate() - INTERVAL 0 DAY ), '%Y-%m-%d' )
</select>
<select id="getTeamList" resultType="cn.pluss.platform.vo.MerchantProfitVO">
SELECT
ua.userId,
ua.userName,
ui.phone,
up.current_fee,
up.type_code,
ua.merchantCode,
ua.createDt
FROM
tb_pluss_user_promotion up
LEFT JOIN tb_pluss_user_app ua ON ua.userId = up.user_id
LEFT JOIN tb_pluss_user_info ui ON ui.id = ua.userId
WHERE
up.parent_user_id = #{userId}
AND up.type_code = #{typeCode}
order by ua.userId ASC limit #{page}, #{size}
</select>
<select id="getChannelStatus" resultType="cn.pluss.platform.entity.MerchantChannelStatus">
SELECT
`status`, authorizationStatus,remark,virChannelFlag
FROM
tb_pluss_merchant_channel_status
WHERE merchantCode = #{merchantCode}
</select>
</mapper>

View File

@@ -239,6 +239,202 @@
</where>
</select>
<select id="queryUserPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) from tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_info ui ON ua.userId = ui.id
<where>
<if test="phone != null">
and ui.phone = #{phone}
</if>
<if test="id!= null">
and ua.id = #{id}
</if>
<if test="userId!= null">
and ua.userId = #{userId}
</if>
<if test="logo!= null">
and ua.logo = #{logo}
</if>
<if test="level!= null">
and ua.level = #{level}
</if>
<if test="userType!= null">
and ua.userType = #{userType}
</if>
<if test="createDt!= null">
and ua.createDt = #{createDt}
</if>
<if test="stTime!= null">
and ua.createDt &gt;= #{stTime}
</if>
<if test="enTime!= null">
and ua.createDt &lt;= #{enTime}
</if>
<if test="status!= null">
and ua.status = #{status}
</if>
<if test="certnum!= null">
and ua.certnum = #{certnum}
</if>
<if test="certBacKPhoto!= null">
and ua.certBacKPhoto = #{certBacKPhoto}
</if>
<if test="handCertPhoto!= null">
and ua.handCertPhoto = #{handCertPhoto}
</if>
<if test="bankName!= null">
and ua.bankName = #{bankName}
</if>
<if test="bankAddress!= null">
and ua.bankAddress = #{bankAddress}
</if>
<if test="bankBranch!= null">
and ua.bankBranch = #{bankBranch}
</if>
<if test="bankNo!= null">
and ua.bankNo = #{bankNo}
</if>
<if test="bankPhoto!= null">
and ua.bankPhoto = #{bankPhoto}
</if>
<if test="merchantCode!= null">
and ua.merchantCode = #{merchantCode}
</if>
<if test="fansProfit!= null">
and ua.fansProfit = #{fansProfit}
</if>
<if test="extendProfit!= null">
and ua.extendProfit = #{extendProfit}
</if>
<if test="cashProfit!= null">
and ua.cashProfit = #{cashProfit}
</if>
<if test="userName!= null">
and ua.userName = #{userName}
</if>
<if test="staffType!= null">
and ua.staffType = #{staffType}
</if>
<if test="parentId!= null">
and ua.parentId = #{parentId}
</if>
<if test="inviteNum!= null">
and ua.inviteNum = #{inviteNum}
</if>
<if test="bankStatus!= null">
and ua.bankStatus = #{bankStatus}
</if>
<if test="merchantStatus!= null">
and ua.merchantStatus = #{merchantStatus}
</if>
<if test="certReason!= null">
and ua.certReason = #{certReason}
</if>
<if test="bankReason!= null">
and ua.bankReason = #{bankReason}
</if>
<if test="merchantReason!= null">
and ua.merchantReason = #{merchantReason}
</if>
<if test="certPeriod!= null">
and ua.certPeriod = #{certPeriod}
</if>
<if test="certStartTime!= null">
and ua.certStartTime = #{certStartTime}
</if>
<if test="bankAddressCode!= null">
and ua.bankAddressCode = #{bankAddressCode}
</if>
<if test="merchantName!= null">
and ua.merchantName = #{merchantName}
</if>
<if test="merchantAddress!= null">
and ua.merchantAddress = #{merchantAddress}
</if>
<if test="merchantDetailAddress!= null">
and ua.merchantDetailAddress = #{merchantDetailAddress}
</if>
<if test="contactName!= null">
and ua.contactName = #{contactName}
</if>
<if test="contactPhone!= null">
and ua.contactPhone = #{contactPhone}
</if>
<if test="productDesc!= null">
and ua.productDesc = #{productDesc}
</if>
<if test="bussAuthNum!= null">
and ua.bussAuthNum = #{bussAuthNum}
</if>
<if test="bussAuthPeriod!= null">
and ua.bussAuthPeriod = #{bussAuthPeriod}
</if>
<if test="storeId!= null">
and ua.storeId = #{storeId}
</if>
<if test="appAuthToken!= null">
and ua.appAuthToken = #{appAuthToken}
</if>
<if test="tradeMoney!= null">
and ua.tradeMoney = #{tradeMoney}
</if>
<if test="authCount!= null">
and ua.authCount = #{authCount}
</if>
<if test="subMchId!= null">
and ua.subMchId = #{subMchId}
</if>
<if test="aisleSwitch!= null">
and ua.aisleSwitch = #{aisleSwitch}
</if>
<if test="unionpay!= null">
and ua.unionpay = #{unionpay}
</if>
<if test="mccCode!= null">
and ua.mccCode = #{mccCode}
</if>
<if test="contactEmail!= null">
and ua.contactEmail = #{contactEmail}
</if>
<if test="mccName!= null">
and ua.mccName = #{mccName}
</if>
<if test="leshuaLicenseName!= null">
and ua.leshuaLicenseName = #{leshuaLicenseName}
</if>
<if test="aliAccount!= null">
and ua.aliAccount = #{aliAccount}
</if>
<if test="aliName!= null">
and ua.aliName = #{aliName}
</if>
<if test="aliSignUrl!= null">
and ua.aliSignUrl = #{aliSignUrl}
</if>
<if test="wechatSignUrl!= null">
and ua.wechatSignUrl = #{wechatSignUrl}
</if>
<if test="token!= null">
and ua.token = #{token}
</if>
<if test="endTime!= null">
and ua.createDt <![CDATA[>=]]> #{startTime}
</if>
<if test="endTime!= null">
and ua.createDt <![CDATA[<=]]> #{endTime}
</if>
<if test="isVoice!= null">
and ua.isVoice = #{isVoice}
</if>
<if test="parentIdList!= null">
and ua.parentId in
<foreach collection="parentIdList" item="item" open="(" close=")" index="index" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="queryUserInfoVOPage" parameterType="java.util.Map" resultMap="userInfoVO">
SELECT DISTINCT SQL_CALC_FOUND_ROWS
ua.id,

View File

@@ -3,21 +3,38 @@
<mapper namespace="cn.pluss.platform.mapper.UserPromotionMapper">
<!-- 通用查询映射结果 -->
<!-- <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.UserVoice">-->
<!-- <id column="id" property="id" />-->
<!-- <result column="userId" property="userId" />-->
<!-- <result column="paySuccess" property="paySuccess" />-->
<!-- <result column="payCancel" property="payCancel" />-->
<!-- <result column="memberCharge" property="memberCharge" />-->
<!-- <result column="memberConsume" property="memberConsume" />-->
<!-- <result column="deliveryOrder" property="deliveryOrder" />-->
<!-- <result column="storeOrder" property="storeOrder" />-->
<!-- <result column="urge" property="urge" />-->
<!-- </resultMap>-->
<resultMap id="BaseResultMap" type="cn.pluss.platform.entity.UserPromotion">
<id column="id" property="userId" jdbcType="VARCHAR" />
<result column="user_id" property="userId" />
<result column="type_code" property="typeCode" />
<result column="current_fee" property="currentFee" />
<result column="parent_user_id" property="parentUserId" />
<result column="create_time" property="createTime" />
<result column="is_extend" property="isExtend" />
<result column="update_time" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
user_id, type_code, current_fee, parent_user_id, is_extend, create_time, update_time
</sql>
<update id="updateByPrimaryKey">
update tb_pluss_user_promotion
set type_code = #{typeCode,jdbcType=VARCHAR},
current_fee = #{currentFee,jdbcType=DECIMAL},
parent_user_id = #{parentUserId,jdbcType=VARCHAR},
is_extend = #{isExtend,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where user_id = #{userId,jdbcType=INTEGER}
</update>
<select id="selectListByUserId" resultType="cn.pluss.platform.entity.UserProfit">
SELECT * FROM tb_pluss_user_promotion WHERE `user_id` IN
<foreach open="(" separator="," close=")" collection="userIdList" item="item">
#{item}
</foreach>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap">
select *
from tb_pluss_user_promotion
where user_id = #{userId}
</select>
</mapper>

View File

@@ -81,6 +81,10 @@ public class MerchantProfit {
@TableField(exist = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
//订单支付时间
@TableField(exist = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date transDt;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@TableField(select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
@@ -115,6 +119,9 @@ public class MerchantProfit {
@TableField(exist = false)
private String userType;
@TableField(exist = false)
private String type_code;
public MerchantProfit(UserApp userApp, UserApp profitUserApp, MerchantOrder order,BigDecimal profitAmt,BigDecimal profitRate,String type,String orderType) {
this.userId = profitUserApp.getUserId();
//V2.0模式

View File

@@ -0,0 +1,60 @@
package cn.pluss.platform.vo;
import cn.pluss.platform.entity.MerchantChannelStatus;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @author 团队管理
*/
@Data
public class MerchantProfitVO {
private String userName;
private String phone;
/**
* 费率
*/
private String current_fee;
/**
* 角色
*/
private String type_code;
/**
* userId
*/
private String userId;
/**
*总交易金额
*/
private BigDecimal consumeFee = BigDecimal.ZERO;
/**
* 本月交易金额
*/
private BigDecimal currentMonth = BigDecimal.ZERO;
/**
* 昨日收款
*/
private BigDecimal yestedayConsumeFee = BigDecimal.ZERO;
/**
*昨日收款笔数
*/
private Integer countNum = 0;
/**
* 商户号
*/
private String merchantCode;
/**
* 入网时间
*/
private String createDt;
private String statusD1 = "0";
private String statusD0 = "0";
private String authorizationStatus = "0";
private String remarkD1;
private String remarkD0;
}

View File

@@ -24,7 +24,7 @@ public class SpreadData {
private String userId;
/**
* 直属商户交易
* 银收客
*/
private BigDecimal ownAmt;

View File

@@ -1,5 +1,6 @@
package cn.pluss.platform.app;
import java.math.BigDecimal;
import java.util.Map;
/**
@@ -21,4 +22,6 @@ public interface MainPageService {
* @return 推广数据
*/
Map<String, Object> getSpreadData(String userId);
void modifyFee(Long userId, Integer id, BigDecimal fee);
}

View File

@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -93,6 +94,12 @@ public class AgentStaffMainPageServiceImpl implements MainPageService {
return resultMap;
}
@Override
public void modifyFee(Long userId, Integer id, BigDecimal fee) {
}
@Override
public Map<String, Object> getHomeData(String userId) {
return null;

View File

@@ -1,14 +1,19 @@
package cn.pluss.platform.app.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.pluss.platform.app.MainPageService;
import cn.pluss.platform.entity.MerchantOrderStatistics;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.entity.UserPromotion;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.mapper.MerchantProfitMapper;
import cn.pluss.platform.mapper.UserPromotionMapper;
import cn.pluss.platform.merchantOrder.MerchantOrderStatisticsService;
import cn.pluss.platform.merchantProfit.MerchantProfitService;
import cn.pluss.platform.userApp.UserAppService;
import cn.pluss.platform.util.DateUtils;
import cn.pluss.platform.util.N;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.vo.MerchantOrderStatisticsVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -17,11 +22,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.baomidou.mybatisplus.core.toolkit.StringPool.N;
/**
* 推广者的主页面信息查询实现类
*/
@@ -36,6 +45,10 @@ public class PromoterMainPageServiceImpl implements MainPageService {
@Autowired
@Lazy
private MerchantOrderStatisticsService mosService;
@Resource
private MerchantProfitMapper merchantProfitMapper;
@Resource
private UserPromotionMapper userPromotionMapper;
@Override
public Map<String, Object> getSpreadData(String userId) {
@@ -63,7 +76,7 @@ public class PromoterMainPageServiceImpl implements MainPageService {
Map<String, Object> queryMap = new HashMap<>();
queryMap.put("userId", userId);
queryMap.put("status", 1);
// 累计总分润
// 累计总收益
promoteFee = merchantProfitService.queryMerchantProfitSumPrice(queryMap);
if (promoteFee == null) {
promoteFee = 0d;
@@ -74,6 +87,8 @@ public class PromoterMainPageServiceImpl implements MainPageService {
queryMap.put("retype", "1");
totalOrderCount = merchantProfitService.queryMerchantProfitPageCount(queryMap);
todayProfit = merchantProfitService.queryMerchantProfitSumPrice(queryMap);
//今日收益
BigDecimal todaySum = merchantProfitMapper.getTodaySum(userId);
//今日新增商户数
QueryWrapper<UserApp> queryWrapper = new QueryWrapper<>();
@@ -81,11 +96,26 @@ public class PromoterMainPageServiceImpl implements MainPageService {
queryWrapper.in("merchantAuditStatus", 3, 4);
queryWrapper.between("createDt", DateUtils.getDayBegin(), DateUtils.getDayEnd());
Integer newMerchantCount = userAppService.getUserAppWithChannelStatus(queryWrapper);
//直属商户交易
BigDecimal consumeFee = merchantProfitMapper.getConsumeFee(userId);
//团队商户交易
BigDecimal consumeFeeTeam = merchantProfitMapper.getConsumeFeeTeam(userId);
//今日收款
BigDecimal consumeFeeTeamToday = merchantProfitMapper.getConsumeFeeTeamToday(userId);
//总商户数
Integer countChildAll = merchantProfitMapper.getCountChild(Long.valueOf(userId), "MC");
resultMap.put("promoteFee", promoteFee + "");
resultMap.put("totalOrderCount", totalOrderCount + "");
resultMap.put("newMerchantCount", newMerchantCount + "");
resultMap.put("todayProfit", todayProfit == null? "0.00": todayProfit + "");
resultMap.put("todaySum", todaySum);
resultMap.put("consumeFee", consumeFee);
resultMap.put("consumeFeeTeam", consumeFeeTeam);
resultMap.put("consumeFeeTeamToday", consumeFeeTeamToday);
resultMap.put("countChildAll", countChildAll);
String currentMonth = DateUtil.format(new Date(), "yyyy-MM");
MerchantOrderStatistics directTotalCurrentMonth = mosService.getDirectTotal(queryUserApp.getUserId() + "", currentMonth);
@@ -107,6 +137,69 @@ public class PromoterMainPageServiceImpl implements MainPageService {
return resultMap;
}
@Override
public void modifyFee(Long userId, Integer id, BigDecimal fee) {
QueryWrapper<UserPromotion> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id",id);
UserPromotion promotion = userPromotionMapper.selectOne(queryWrapper);
if(ObjectUtil.isEmpty(promotion)){
throw new MsgException("费率信息不存在");
}
UserPromotion userPromotion = userPromotionMapper.selectByPrimaryKey(userId);
if(ObjectUtil.isEmpty(userPromotion)){
throw new MsgException("父级机构信息异常");
}
Boolean flag=true;
switch (userPromotion.getTypeCode()){
case "MG":
if(promotion.getTypeCode().equals("FO")){
flag=false;
}
break;
case "FO":
if(promotion.getTypeCode().equals("SO")){
flag=false;
}
break;
case "SO" :
if(promotion.getTypeCode().equals("AG")){
flag=false;
}
break;
case "AG":
if(promotion.getTypeCode().equals("FB")){
flag=false;
}
break;
case "FB":
if(promotion.getTypeCode().equals("SB")){
flag=false;
}
break;
}
if(flag){
throw new MsgException("当前用户权限不足");
}
if(cn.pluss.platform.util.N.gt(new BigDecimal(userPromotion.getCurrentFee()),fee)){
throw new MsgException("修改费率不允许小于上级费率");
}
BigDecimal lowFee=userPromotionMapper.selectMaxFeeByUserId(id.toString());
if(ObjectUtil.isNotEmpty(lowFee)&&cn.pluss.platform.util.N.gt(fee,lowFee)){
throw new MsgException("修改费率不允许小于下级最大费率");
}
promotion.setCurrentFee(String.valueOf(fee));
promotion.setUpdateTime(new Date());
int i = userPromotionMapper.updateByPrimaryKey(promotion);
if (i < 1){
throw new MsgException("修改失败");
}
}
@Override
public Map<String, Object> getHomeData(String userId) {
return null;

View File

@@ -1178,7 +1178,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
UserApp ua = uaService.getOne(new LambdaQueryWrapper<UserApp>().eq(UserApp::getUserId, bankCardDTO.getUserId()));
MerchantChannelStatus mcs = mcsService.getByMerchantCodeAndChannelType(ua.getMerchantCode(), bankCardDTO.getChannelType());
MerchantChannelStatus mcs = mcsService.getByMerchantCodeAndChannelTypeNew(ua.getMerchantCode(), bankCardDTO.getChannelType());
MsgException.checkNull(mcs, "商户还未进件");

View File

@@ -38,6 +38,14 @@ public interface MerchantChannelStatusService extends IService<MerchantChannelSt
return getOne(qWrapper);
}
default MerchantChannelStatus getByMerchantCodeAndChannelTypeNew(String merchantCode, String channelType) {
LambdaQueryWrapper<MerchantChannelStatus> qWrapper = Wrappers.lambdaQuery();
qWrapper.eq(MerchantChannelStatus::getVirChannelFlag, channelType);
qWrapper.eq(MerchantChannelStatus::getMerchantCode, merchantCode);
qWrapper.eq(MerchantChannelStatus::getStatus,3);
return getOne(qWrapper);
}
/**
* 进件请求前参数校验

View File

@@ -565,6 +565,26 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
// 手续费
BigDecimal totalCommission = getTotalCommission(totalConsumeFee, totalRefundConsumeFee, totalEnterFee);
//日账单
HashMap<String, Object> mapToday = new HashMap<>();
mapToday.put("startTime", DateUtils.getDayBegin());
mapToday.put("endTime", DateUtils.getDayEnd());
mapToday.put("merchantCode", merchantOrder.getMerchantCode());
BigDecimal today = merchantOrderMapper.queryMerchantOrderMoneyByTime(mapToday);
//周账单
HashMap<String, Object> mapWeek = new HashMap<>();
mapWeek.put("startTime", DateUtils.getBeginDayOfWeek());
mapWeek.put("endTime", DateUtils.getEndDayOfWeek());
mapWeek.put("merchantCode", merchantOrder.getMerchantCode());
BigDecimal week = merchantOrderMapper.queryMerchantOrderMoneyByTime(mapWeek);
//月账单
HashMap<String, Object> mapMonth = new HashMap<>();
mapMonth.put("startTime", DateUtils.getBeginDayOfMonth());
mapMonth.put("endTime", DateUtils.getEndDayOfMonth());
mapMonth.put("merchantCode", merchantOrder.getMerchantCode());
BigDecimal month = merchantOrderMapper.queryMerchantOrderMoneyByTime(mapMonth);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("orderNum", consumeCount == null ? 0 : consumeCount);
resultMap.put("returnOrderNum", refundCount == null ? 0 : refundCount);
@@ -573,6 +593,9 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
resultMap.put("totalReceiveFee", totalConsumeFee);
resultMap.put("commission", totalCommission);
resultMap.put("returnMoney", totalRefundConsumeFee);
resultMap.put("today", today);
resultMap.put("week", week);
resultMap.put("month",month);
return resultMap;
}

View File

@@ -4,9 +4,11 @@ import cn.pluss.platform.entity.MerchantOrder;
import cn.pluss.platform.entity.MerchantProfit;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.mapper.MerchantProfitMapper;
import cn.pluss.platform.vo.MerchantProfitVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
@@ -89,5 +91,9 @@ public interface MerchantProfitService extends IService<MerchantProfit> {
* @param orderNumber
*/
void sendProfitMessage(UserApp userApp, BigDecimal profitMoney, String orderNumber);
Map<String, Object> teamList(String typeCode, Long userId, Integer page,Integer size,String name);
Map<String, Object> merchantListData(Long userId);
}

View File

@@ -16,6 +16,7 @@ import cn.pluss.platform.userAssess.UserAssessService;
import cn.pluss.platform.userRewardFlow.UserRewardFlowService;
import cn.pluss.platform.util.DateUtils;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.vo.MerchantProfitVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -52,6 +53,10 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
@Autowired
private UserAssessService userAssessService;
@Resource
private MerchantProfitMapper merchantProfitMapper;
@Resource
private MerchantOrderMapper mapperOrderMapper;
@Override
@Transactional(rollbackFor = RuntimeException.class, propagation = Propagation.NESTED)
@@ -100,6 +105,80 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
}
}
@Override
public Map<String, Object> teamList(String typeCode, Long userId,Integer page,Integer size,
String name) {
page = page-1;
switch (typeCode){
case "AG":
typeCode = "FB";
break;
case "FB":
typeCode = "SB";
break;
case "SB":
typeCode = "";
break;
case "MC":
break;
default:
throw new MsgException("身份错误");
}
List<MerchantProfitVO> teamList = merchantProfitMapper.getTeamList(typeCode, userId, page,size,name);
Integer countChild = merchantProfitMapper.getCountChild(userId, typeCode);
//商户列表
if ("MC".equals(typeCode)) {
for (MerchantProfitVO values : teamList) {
if (values.getMerchantCode() != null) {
String merchantCode = values.getMerchantCode();
List<MerchantChannelStatus> channelStatus = merchantProfitMapper.getChannelStatus(merchantCode);
if (channelStatus != null) {
for (MerchantChannelStatus valuesStatus : channelStatus) {
if ("D1".equals(valuesStatus.getVirChannelFlag())) {
values.setStatusD1(valuesStatus.getStatus());
values.setRemarkD1(valuesStatus.getStatus());
values.setAuthorizationStatus(valuesStatus.getAuthorizationStatus());
}
if ("D0".equals(valuesStatus.getVirChannelFlag())) {
values.setStatusD0(valuesStatus.getStatus());
values.setRemarkD0(valuesStatus.getStatus());
}
}
}
Integer countUser = mapperOrderMapper.getCountUser(Long.valueOf(values.getUserId()));
if (countUser > 0) {
values.setCountNum(countUser);
values.setConsumeFee(mapperOrderMapper.getAmountData(values.getMerchantCode()));
values.setYestedayConsumeFee(mapperOrderMapper.getPlatformAmtYestday(values.getMerchantCode(),
DateUtils.getBeginDayOfYesterday(), DateUtils.getEndDayOfYesterDay()));
}
}
}
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("total", countChild);
hashMap.put("teamList", teamList);
return hashMap;
}
//团队管理
for (MerchantProfitVO values : teamList) {
values.setYestedayConsumeFee(mapperOrderMapper.getPlatformAmtYestday(values.getMerchantCode(),
DateUtils.getBeginDayOfMonth(), DateUtils.getEndDayOfMonth()));
values.setConsumeFee(mapperOrderMapper.getAmountData(values.getMerchantCode()));
}
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("total", countChild);
hashMap.put("teamList", teamList);
return hashMap;
}
@Override
public Map<String, Object> merchantListData(Long userId) {
return null;
}
/**
* 分润创建2.0模式
*

View File

@@ -242,7 +242,7 @@ public class UserAppServiceImpl extends ServiceImpl<UserAppMapper, UserApp> impl
long pageSize = ((Integer) map.get("pageSize")).longValue();
Page<UserInfoVO> pageResult = new Page<>(page, pageSize);
pageResult.setRecords(result);
Long count = baseMapper.queryUserAppPageCount(map).longValue();
Long count = baseMapper.queryUserPageCount(map).longValue();
pageResult.setTotal(count);
if (result.isEmpty()) {

View File

@@ -352,21 +352,10 @@ public abstract class BaseUserInfoService extends ServiceImpl<UserInfoMapper, Us
MsgException.checkNull(checkUserInfo, "无此用户!");
QueryWrapper<UserPromotion> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", checkUserInfo.getId());
UserPromotion promotion= userPromotionMapper.selectOne(queryWrapper);
if(ObjectUtil.isEmpty(promotion)){
MsgException.checkNull(null,"用户状态错误");
}
if("MG".equals(promotion.getTypeCode())||"FO".equals(promotion.getTypeCode())||"SO".equals(promotion.getTypeCode())){
MsgException.checkNull(null,"此用户不允许登录");
}
// 原则上不能以原密码进行对比,这里只是给后台登录页面一个方便
if (password.equalsIgnoreCase(checkUserInfo.getPassword())) {
UserApp queryUserApp;
queryUserApp = userAppMapper.selectUserApp(new QueryWrapper<>().eq("ua.userId", checkUserInfo.getId()));
log.error("=====================queryUserApp=====================" + JSON.toJSONString(queryUserApp));
String genRandomNum = StringUtil.genRandomNum(6) + StringUtil.getBillno() + StringUtil.genRandomNum(6);
UserApp uApp = new UserApp();
uApp.setToken(genRandomNum);
@@ -396,6 +385,19 @@ public abstract class BaseUserInfoService extends ServiceImpl<UserInfoMapper, Us
UserApp queryUserApp = new UserApp().setUserId(checkUserInfo.getId());
queryUserApp = userAppMapper.selectOne(new QueryWrapper<>(queryUserApp));
if ("promoter".equals(queryUserApp.getUserType())){
QueryWrapper<UserPromotion> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", checkUserInfo.getId());
UserPromotion promotion= userPromotionMapper.selectOne(queryWrapper);
if(ObjectUtil.isEmpty(promotion)){
MsgException.checkNull(null,"用户状态错误");
}
if("MG".equals(promotion.getTypeCode())||"FO".equals(promotion.getTypeCode())||"SO".equals(promotion.getTypeCode())){
MsgException.checkNull(null,"此用户不允许登录");
}
}
// TODO 去掉该用户只能登录一个设备
//String genRandomNum = StringUtil.genRandomNum(6) + StringUtil.getBillno() + StringUtil.genRandomNum(6);
String genRandomNum = loginName;

View File

@@ -207,13 +207,7 @@
$.alert("两次的密码必须相同!", "系统提示");
return;
}
if(typeCode==''){
$.alert("类型错误")
}
if(currentFee==''){
$.alert("费率错误")
}
$.showLoading("提交中...")
$.ajax({
url: ctx + '/merchant/goRegister',