fixbug encourage money

master
kira 6 years ago
parent 79cfa5085f
commit a3bf49708c

@ -85,6 +85,7 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
@Override @Override
public JSONObject takeEncourageMoney(String orderId, String visitorOpenId) { public JSONObject takeEncourageMoney(String orderId, String visitorOpenId) {
logger.info("=====takeEncourageMoney+" + orderId);
JSONObject config = currentEncourageConfig(); JSONObject config = currentEncourageConfig();
if (config != null) { if (config != null) {
if (customerEncourageMoneyAccessLogMapper.findByOrderId(orderId) != null) { if (customerEncourageMoneyAccessLogMapper.findByOrderId(orderId) != null) {
@ -239,16 +240,22 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
Date toDate = config.getDate("to_date"); Date toDate = config.getDate("to_date");
status.put("to", DateFormatUtils.format(toDate, "MM-dd")); status.put("to", DateFormatUtils.format(toDate, "MM-dd"));
JSONObject member = customerMembershipMapper.findByPaymentOpenId(openid); JSONObject member = customerMembershipMapper.findByPaymentOpenId(openid);
JSONObject use = customerEncourageMoneyAccessLogMapper.sumMoney(member.getString("memeber_id"),config.getString("event_id"));
BigDecimal balance = BigDecimal.ZERO;
if(use!=null){
balance = use.getBigDecimal("use_amount");
}
member.put("used_amount",balance.setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
if (member != null) { if (member != null) {
status.put("member_info", member); status.put("member_info", member);
List<JSONObject> balanceLogs = customerMembershipMapper.listEncourageBalanceHistory(fromDate, toDate, member.getString("member_id")); List<JSONObject> balanceLogs = customerMembershipMapper.listEncourageBalanceHistory(fromDate, toDate, member.getString("member_id"));
status.put("logs", balanceLogs); status.put("logs", balanceLogs);
BigDecimal usedAmount = customerEncourageMoneyUseLogMapper.sumUsed(member.getString("member_id"), fromDate, toDate); // BigDecimal usedAmount = customerEncourageMoneyUseLogMapper.sumUsed(member.getString("member_id"), fromDate, toDate);
member.put("used_amount", usedAmount); // member.put("used_amount", usedAmount);
} else { } else {
member = new JSONObject(); member = new JSONObject();
member.put("encourage_balance", 0); member.put("encourage_balance", 0);
member.put("used_amount", 0); // member.put("used_amount", 0);
} }
status.put("member", member); status.put("member", member);
return status; return status;

@ -31,4 +31,7 @@ public interface CustomerEncourageMoneyAccessLogMapper {
PageList<JSONObject> list(JSONObject params, PageBounds pageBounds); PageList<JSONObject> list(JSONObject params, PageBounds pageBounds);
List<JSONObject> analysisByDate(@Param("event_id") String eventId); List<JSONObject> analysisByDate(@Param("event_id") String eventId);
JSONObject sumMoney(@Param("memberId") String memberId,@Param("eventId")String eventId);
} }

@ -34,4 +34,7 @@ public interface CustomerEncourageMoneyUseLogMapper {
List<JSONObject> analysisByDate(@Param("event_id") String eventId); List<JSONObject> analysisByDate(@Param("event_id") String eventId);
List<String> listUnsettled(); List<String> listUnsettled();
JSONObject sumMoney(@Param("memberId") String memberId,@Param("eventId")String eventId);
} }

@ -42,4 +42,7 @@
GROUP BY access_date GROUP BY access_date
ORDER BY access_date DESC ORDER BY access_date DESC
</select> </select>
<select id="sumMoney" resultType="com.alibaba.fastjson.JSONObject">
select sum(actural_amount) actural_amount from cus_encourage_money_access_log where member_id = #{memberId} and event_id = #{eventId};
</select>
</mapper> </mapper>

@ -43,4 +43,7 @@
INNER JOIN pmt_orders o ON o.order_id=u.order_id AND o.status>4 INNER JOIN pmt_orders o ON o.order_id=u.order_id AND o.status>4
WHERE u.transaction_id is null WHERE u.transaction_id is null
</select> </select>
<select id="sumMoney" resultType="com.alibaba.fastjson.JSONObject">
select sum(use_amount) use_amount from cus_encourage_money_use_log where member_id = #{memberId} and event_id = #{eventId} and transaction_id is not null
</select>
</mapper> </mapper>
Loading…
Cancel
Save