Browse Source

[积分][修改]:整理积分数据

release_toaliyun_real
Stormeye Wu 6 years ago
parent
commit
a8a96a1382
3 changed files with 69 additions and 2 deletions
  1. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCreditHistoryMapper.java
  2. +19
    -1
      mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml
  3. +48
    -1
      mallinkSysAdmin/src/main/java/com/iformall/controller/sys/DataInitController.java

+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCreditHistoryMapper.java View File

@@ -33,5 +33,7 @@ public interface WxCreditHistoryMapper extends CommonMapper<WxCreditHistory, Lon


List<WxCreditHistory> findListAfter(Integer creditType, String dateTime); List<WxCreditHistory> findListAfter(Integer creditType, String dateTime);


int findMaxBefore(Long cUserId, String dateTime);

List<WxCreditHistory> findListByIds(@Param("userIds") List<Long> userIds); List<WxCreditHistory> findListByIds(@Param("userIds") List<Long> userIds);
} }

+ 19
- 1
mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml View File

@@ -121,6 +121,7 @@
<select id="findList" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap"> <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
<include refid="dynamicWhereConditions" /> <include refid="dynamicWhereConditions" />
order by create_date
</select> </select>


<select id="findListMore" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.WxCreditHistoryVo"> <select id="findListMore" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.WxCreditHistoryVo">
@@ -250,7 +251,24 @@
</select> </select>


<select id="findListAfter" resultMap="BaseResultMap"> <select id="findListAfter" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_credit_history where create_date > #{dateTime} and credit_type = #{creditType}
select c_user_id
from wx_credit_history
<where>
<if test=" null != dateTime ">
and create_date > #{dateTime}
</if>
<if test=" null != creditType ">
and credit_type = #{creditType}
</if>
</where>

group by c_user_id
</select>

<select id="findMaxBefore" resultType="java.lang.Integer">
select ifnull(max(credit_amount),0)
from wx_credit_history
where create_date &lt; #{dateTime} and c_user_id = #{cUserId}
</select> </select>


<select id="findListByIds" parameterType="java.util.List" resultMap="BaseResultMap"> <select id="findListByIds" parameterType="java.util.List" resultMap="BaseResultMap">


+ 48
- 1
mallinkSysAdmin/src/main/java/com/iformall/controller/sys/DataInitController.java View File

@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;


import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -115,7 +116,7 @@ public class DataInitController extends BaseController {
try { try {
MallUserInfo userInfo = getUser(); MallUserInfo userInfo = getUser();
if (userInfo.isFmSuperAdmin()) { if (userInfo.isFmSuperAdmin()) {
doFixCredit4CUserBasic();
doFixCreditHistory();
return new ResultData(); return new ResultData();
} }
} catch (Exception e) { } catch (Exception e) {
@@ -246,6 +247,52 @@ public class DataInitController extends BaseController {
}); });
} }


public void doFixCreditHistory() {
SimpleDateFormat dataFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateTime = "2019-09-16 22:00:00";
List<WxCreditHistory> cuUserList = creditHistoryMapper.findListAfter(null, null); // new ArrayList<>(); //
//cuUserList.add(new WxCreditHistory(){{
// setCUserId(262738733739016192L);
//}});
for (WxCreditHistory cuUser: cuUserList) {
//cuUserList.stream().forEach(cuUser->{
WxCreditHistory q = new WxCreditHistory();
q.setCUserId(cuUser.getCUserId());
List<WxCreditHistory> creditHistories = creditHistoryMapper.findList(q);
int amount = 0;
boolean isError = false;
for (WxCreditHistory creditHistory : creditHistories) {
int oldamount = amount;
if (creditHistory.getCreditType().equals(EnumScoreType.MEM_IMPORT.getCode())) {
amount = creditHistory.getCreditNum();
} else {
amount = amount + creditHistory.getCreditNum();
}
if (!creditHistory.getCreditAmount().equals(amount)) {
//log.error("credit hist err: {},{},{},{},{}", creditHistory.getId(), creditHistory.getCUserId(), creditHistory.getCreditAmount(), creditHistory.getCreditNum(), oldamount);
WxCreditHistory updateRecord = new WxCreditHistory();
updateRecord.setId(creditHistory.getId());
updateRecord.setCreditAmount(amount);
creditHistoryMapper.updateByPrimaryKeySelective(updateRecord);
isError = true;
}
}
if (isError) {
WxCUser cUser = new WxCUser();
cUser.setId(cuUser.getCUserId());
cUser.setCredit(amount);
cUserMapper.updateByPrimaryKeySelective(cUser);
WxCUserBasicInfo cUserBasicInfo = new WxCUserBasicInfo();
cUserBasicInfo.setId(cuUser.getCUserId());
cUserBasicInfo.setCredit(amount);
cUserBasicInfoMapper.updateByPrimaryKeySelective(cUserBasicInfo);
log.error("credit hist err: {}", cuUser.getCUserId());
}
//});

}
}

@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void doFixVerifyCredit() { public void doFixVerifyCredit() {
// 1 获取券码 // 1 获取券码


Loading…
Cancel
Save