Просмотр исходного кода

/、credit

release_toaliyun_real
xhxu 4 лет назад
Родитель
Сommit
514100938e
6 измененных файлов: 102 добавлений и 189 удалений
  1. +1
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java
  2. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java
  3. +0
    -2
      mallinkService/src/main/java/com/iformall/mapper/WxCreditHistoryMapper.java
  4. +38
    -25
      mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java
  5. +9
    -0
      mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml
  6. +52
    -160
      mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml

+ 1
- 2
mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java Просмотреть файл

@@ -151,8 +151,7 @@ public class WxCreditHistoryController extends BaseController {
public ResultData getCreditSummary(@ModelAttribute WxCreditHistory wxCreditHistory) {
logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::getCreditSummary");
TenantEntity tenantInfo = getTenantInfo();
wxCreditHistory.setTenantId(tenantInfo.getFinalTenantId());
wxCreditHistory.setFinalTenantId(tenantInfo.getFinalTenantId());
wxCreditHistory.updateTenantInfo(tenantInfo);
return wxCreditHistoryService.getCreditSummary(wxCreditHistory);
}



+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java Просмотреть файл

@@ -63,5 +63,7 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S
@Param("tableIndex")Integer tableIndex,@Param("finalTableIndex")Integer finalTableIndex);

List<Long> findIdByFilter(WxCUserBasicInfoDto wxCUserBasicInfoDto);

long getTotalCreditAmount(@Param("tenantId")String tenantId, @Param("finalTenantId")String finalTenantId);
}


+ 0
- 2
mallinkService/src/main/java/com/iformall/mapper/WxCreditHistoryMapper.java Просмотреть файл

@@ -24,8 +24,6 @@ public interface WxCreditHistoryMapper extends CommonMapper<WxCreditHistory, Lon

int countList(WxCreditHistory wxCreditHistory);

long getTotalCreditAmount(WxCreditHistory wxCreditHistory);

long getIncrementCreditAmount(WxCreditHistory wxCreditHistory);

long getDecrementCreditAmount(WxCreditHistory wxCreditHistory);


+ 38
- 25
mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java Просмотреть файл

@@ -292,6 +292,33 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
}
return null;
}

private void handlerParam(WxCreditHistory wxCreditHistory){
String merchantName = StringUtils.trimToNull(wxCreditHistory.getMerchantName());
if(!StringUtils.isBlank(merchantName)) {
WxMerchant merchantQ = new WxMerchant();
merchantQ.updateTenantInfo(wxCreditHistory);
merchantQ.setName(merchantName);
List<Long> merchantIds = wxMerchantMapper.findIdList(merchantQ);
if (null != merchantIds && merchantIds.size() > 0 ) {
wxCreditHistory.setMerchantIds(merchantIds);
}
}

String name = StringUtils.trimToNull(wxCreditHistory.getName());
String phone = StringUtils.trimToNull(wxCreditHistory.getPhone());
if (StringUtils.isBlank(name) && StringUtils.isBlank(phone)) {
}else {
WxCUserBasicInfo biq = new WxCUserBasicInfo();
biq.setFinalTenantId(wxCreditHistory.getFinalTenantId());
biq.setName(name);
biq.setPhone(phone);
List<Long> cUserIds = wxCUserBasicInfoMapper.findIdList(biq);
if (null != cUserIds && cUserIds.size() > 0 ) {
wxCreditHistory.setCUserIds(cUserIds);
}
}
}
@Override
public PageInfo<WxCreditHistoryVo> findListMorePage(WxCreditHistory wxCreditHistory,Integer pageIndex, Integer pageSize) {
@@ -299,30 +326,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
tenantEntity.setTenantId(wxCreditHistory.getTenantId());
tenantEntity.setParentTenantId(wxCreditHistory.getParentTenantId());

String merchantName = StringUtils.trimToNull(wxCreditHistory.getMerchantName());
if(!StringUtils.isBlank(merchantName)) {
WxMerchant merchantQ = new WxMerchant();
merchantQ.updateTenantInfo(tenantEntity);
merchantQ.setName(merchantName);
List<Long> merchantIds = wxMerchantMapper.findIdList(merchantQ);
if (null != merchantIds && merchantIds.size() > 0 ) {
wxCreditHistory.setMerchantIds(merchantIds);
}
}
String name = StringUtils.trimToNull(wxCreditHistory.getName());
String phone = StringUtils.trimToNull(wxCreditHistory.getPhone());
if (StringUtils.isBlank(name) && StringUtils.isBlank(phone)) {
}else {
WxCUserBasicInfo biq = new WxCUserBasicInfo();
biq.setFinalTenantId(wxCreditHistory.getFinalTenantId());
biq.setName(name);
biq.setPhone(phone);
List<Long> cUserIds = wxCUserBasicInfoMapper.findIdList(biq);
if (null != cUserIds && cUserIds.size() > 0 ) {
wxCreditHistory.setCUserIds(cUserIds);
}
}
handlerParam(wxCreditHistory);

wxCreditHistory.setTenantId(wxCreditHistory.getFinalTenantId());
PageInfo<WxCreditHistory> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCreditHistoryMapper.findListMore(wxCreditHistory));
@@ -340,7 +344,16 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {

@Override
public ResultData getCreditSummary(WxCreditHistory wxCreditHistory) {
long totalCreditAmount = wxCreditHistoryMapper.getTotalCreditAmount(wxCreditHistory);
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setTenantId(wxCreditHistory.getTenantId());
tenantEntity.setParentTenantId(wxCreditHistory.getParentTenantId());

//获取所有会员的积分总量
long totalCreditAmount = wxCUserBasicInfoMapper.getTotalCreditAmount(tenantEntity.getTenantId(),tenantEntity.getFinalTenantId());

handlerParam(wxCreditHistory);
wxCreditHistory.setTenantId(wxCreditHistory.getFinalTenantId());

long incrementCreditAmount = wxCreditHistoryMapper.getIncrementCreditAmount(wxCreditHistory);
long decrementCreditAmount = wxCreditHistoryMapper.getDecrementCreditAmount(wxCreditHistory);
long peopleCount = wxCreditHistoryMapper.getPeopleCount(wxCreditHistory);


+ 9
- 0
mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml Просмотреть файл

@@ -557,6 +557,15 @@
</if>
</select>

<select id="getTotalCreditAmount" resultType="java.lang.Long">
SELECT SUM (wcubi.credit)
FROM wx_c_user_basic_info wcubi
where wcubi.`final_tenant_id` = #{finalTenantId}
<if test=" null != tenantId and '' != tenantId">
and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
</if>
</select>


<update id="incActRecordById" parameterType="java.util.HashMap">
UPDATE wx_c_user_basic_info set act_record = act_record +1 where id = #{id} and final_tenant_id = #{finalTenantId}


+ 52
- 160
mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml Просмотреть файл

@@ -26,83 +26,12 @@
</sql>

<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id ">
and `id` = #{id}
</if>
<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != cUserId ">
and `c_user_id` = #{cUserId}
</if>
<if test=" null != creditAmount ">
and `credit_amount` = #{creditAmount}
</if>
<if test=" null != creditNum ">
and `credit_num` = #{creditNum}
</if>
<if test=" null != creditType ">
and `credit_type` = #{creditType}
</if>
<if test=" null != receiptUrl ">
and `receipt_url` like concat('%', #{receiptUrl},'%')
</if>
<if test=" null != operatorType ">
and `operator_type` = #{operatorType}
</if>
<if test=" null != operatorId ">
and `operator_id` = #{operatorId}
</if>
<if test=" null != merchantId ">
and `merchant_id` = #{merchantId}
</if>
<if test=" null != couponId ">
and `coupon_id` = #{couponId}
</if>
<if test=" null != businessId ">
and `business_id` = #{businessId}
</if>
<if test=" null != spend ">
and `spend` = #{spend}
</if>
<if test=" null != changePurpose ">
and `change_purpose` = #{changePurpose}
</if>
<if test=" null != ticketNumber and ''!=ticketNumber ">
and ticket_number like concat('%', #{ticketNumber},'%')
</if>
<if test=" null != buserId ">
and `buser_id` = #{buserId}
</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</sql>

<sql id="customWhereConditions">
where 1 = 1
<if test=" null != name and '' != name">
and basic.nick_name like concat('%', #{name},'%')
</if>
<if test=" null != phone and '' != phone">
and basic.phone like concat('%', #{phone},'%')
</if>
<if test=" null != startTime ">
and credit.create_date &gt;= #{startTime}
</if>
<if test=" null != endTime">
and credit.create_date &lt; #{endTime}
</if>
<if test=" null != tenantId and '' != tenantId">
and credit.`tenant_id` = #{tenantId}
</if>
<if test=" null != operatorType ">
and credit.operator_type = #{operatorType}
</if>
@@ -118,17 +47,26 @@
<if test=" null != merchantId ">
and credit.merchant_id = #{merchantId}
</if>
<if test=" null != merchantName and ''!=merchantName ">
and merchant.name like concat('%', #{merchantName},'%')
</if>
<if test=" null != ticketNumber and ''!=ticketNumber ">
and credit.ticket_number like concat('%', #{ticketNumber},'%')
</if>
<if test=" null != buserId ">
and credit.buser_id = #{buserId}
</if>

<if test=" null != merchantIds ">
and credit.merchantId in
<foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")">
#{merchantIdItem}
</foreach>
</if>

<if test=" null != cUserIds ">
and credit.c_user_id in
<foreach collection="cUserIds" index="index" item="cUserIdItem" open="(" separator="," close=")">
#{cUserIdItem}
</foreach>
</if>
</sql>

<select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
@@ -136,58 +74,19 @@
</select>
<select id="findList" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_credit_history
select <include refid="allColumns" />
from wx_credit_history credit
where `tenant_id` = #{tenantId}
<include refid="dynamicWhereConditions" />
</select>


<select id="findListMore" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap">
SELECT
credit.id ,credit.tenant_id ,credit.c_user_id ,credit.credit_amount ,credit.credit_num,credit.create_date,credit.credit_type,credit.receipt_url ,
credit.operator_type,credit.operator_id,credit.merchant_id,credit.ticket_number,credit.change_purpose
FROM wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
<if test=" null != startTime ">
and credit.create_date &gt;= #{startTime}
</if>
<if test=" null != endTime">
and credit.create_date &lt; #{endTime}
</if>
<if test=" null != operatorType ">
and credit.operator_type = #{operatorType}
</if>
<if test=" null != operatorId ">
and credit.operator_id = #{operatorId}
</if>
<if test=" null != creditType ">
and credit.credit_type = #{creditType}
</if>
<if test=" null != cUserId ">
and credit.c_user_id = #{cUserId}
</if>
<if test=" null != merchantId ">
and credit.merchant_id = #{merchantId}
</if>
<if test=" null != ticketNumber and ''!=ticketNumber ">
and credit.ticket_number like concat('%', #{ticketNumber},'%')
</if>
<if test=" null != buserId ">
and credit.buser_id = #{buserId}
</if>
<if test=" null != merchantIds ">
and credit.merchantId in
<foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")">
#{merchantIdItem}
</foreach>
</if>
<if test=" null != cUserIds ">
and credit.c_user_id in
<foreach collection="cUserIds" index="index" item="cUserIdItem" open="(" separator="," close=")">
#{cUserIdItem}
</foreach>
</if>
<include refid="dynamicWhereConditions" />
ORDER BY credit.create_date DESC
<if test=" null != begin ">
limit #{begin}, #{limit}
@@ -253,38 +152,28 @@
</if>
</select>
<select id="getTotalCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory"
resultType="java.lang.Long">
select ifnull(sum(credit.amount),0) amount from (
select basic.credit as amount,credit.c_user_id from wx_credit_history credit
INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id
LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
<include refid="customWhereConditions"/>
group by credit.c_user_id
) credit
</select>
<select id="getIncrementCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory"
resultType="java.lang.Long">
select ifnull(sum(credit.credit_num),0) amount from wx_credit_history credit
INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id
LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
<include refid="customWhereConditions"/>
select ifnull(sum(credit.credit_num),0) amount
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
<include refid="dynamicWhereConditions"/>
and credit.credit_num>0
</select>
<select id="getDecrementCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory"
resultType="java.lang.Long">
select ABS(ifnull(sum(credit.credit_num),0)) amount from wx_credit_history credit
INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id
LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
<include refid="customWhereConditions"/>
select ABS(ifnull(sum(credit.credit_num),0)) amount
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
<include refid="dynamicWhereConditions"/>
and credit.credit_num &lt; 0
</select>

<select id="getAddCreditSummary" parameterType="com.iformall.domain.po.WxCreditHistory"
resultType="java.lang.Integer">
select ifnull(sum(credit.credit_num),0) amount from wx_credit_history credit
select ifnull(sum(credit.credit_num),0) amount
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
and credit.credit_num &gt; 0 and credit.c_user_id = #{cUserId}
<if test=" null != startTime ">
@@ -298,9 +187,11 @@

<select id="getLesCreditSummary" parameterType="com.iformall.domain.po.WxCreditHistory"
resultType="java.lang.Integer">
select ifnull(sum(credit.credit_num),0) amount from wx_credit_history credit
select ifnull(sum(credit.credit_num),0) amount
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
and credit.credit_num &lt; 0 and credit.c_user_id = #{cUserId}
and credit.credit_num &lt; 0
and credit.c_user_id = #{cUserId}
<if test=" null != startTime ">
and credit.create_date &gt;= #{startTime}
</if>
@@ -310,13 +201,10 @@
</select>
<select id="getPeopleCount" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Long">
select count(1) people from (
select count(*) people from wx_credit_history credit
INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id
LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id
<include refid="customWhereConditions"/>
group by credit.c_user_id
) credit
select count(distinct credit.c_user_id) people
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
<include refid="dynamicWhereConditions"/>
</select>
<delete id="deleteById" parameterType="java.util.HashMap">
@@ -345,9 +233,10 @@
) wm
left join
(
select credit.merchant_id,sum(credit.credit_num) sum_credit_num from wx_credit_history${shardFinalTableSuffix} credit
INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id
where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num &gt; 0
select credit.merchant_id,sum(credit.credit_num) sum_credit_num
from wx_credit_history${shardFinalTableSuffix} credit
where credit.merchant_id is not null
and credit.merchant_id != -1 and credit.credit_num &gt; 0
<if test=" null != startTime ">
and credit.create_date &gt;= #{startTime}
</if>
@@ -358,9 +247,10 @@
) a on a.merchant_id = wm.id
left join
(
select credit.merchant_id,sum(credit.credit_num) sum_credit_num from wx_credit_history${shardFinalTableSuffix} credit
INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id
where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num &lt; 0
select credit.merchant_id,sum(credit.credit_num) sum_credit_num
from wx_credit_history${shardFinalTableSuffix} credit
where credit.merchant_id is not null
and credit.merchant_id != -1 and credit.credit_num &lt; 0
<if test=" null != startTime ">
and credit.create_date &gt;= #{startTime}
</if>
@@ -371,9 +261,10 @@
) b on b.merchant_id = wm.id
left join
(
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id from wx_credit_history${shardFinalTableSuffix} credit
INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id
where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num &gt; 0
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id
from wx_credit_history${shardFinalTableSuffix} credit
where credit.merchant_id is not null
and credit.merchant_id != -1 and credit.credit_num &gt; 0
<if test=" null != startTime ">
and credit.create_date &gt;= #{startTime}
</if>
@@ -384,9 +275,10 @@
) c on c.merchant_id = wm.id
left join
(
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id from wx_credit_history${shardFinalTableSuffix} credit
INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id
where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num &lt; 0
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id
from wx_credit_history${shardFinalTableSuffix} credit
where credit.merchant_id is not null
and credit.merchant_id != -1 and credit.credit_num &lt; 0
<if test=" null != startTime ">
and credit.create_date &gt;= #{startTime}
</if>


Загрузка…
Отмена
Сохранить