Commit cf35a832 by huluobin

update

parent fadc8d90
...@@ -61,6 +61,7 @@ import org.springframework.scheduling.annotation.EnableAsync; ...@@ -61,6 +61,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -670,4 +671,36 @@ public class Test { ...@@ -670,4 +671,36 @@ public class Test {
marketService.calcOrderAmount(13659); marketService.calcOrderAmount(13659);
} }
@org.junit.Test
public void duplicateCouponFix() {
List<OrderManage> orderManageList = orderManageMapper.selectBatchIds(Lists.newArrayList("13711,13744,13766,13921".split(",")));
orderManageList.forEach(orderManage -> {
BigDecimal discountAmount = orderManage.getDiscountPrice();
Integer payUser = orderManage.getPayUser();
Integer orderId = orderManage.getId();
marketService.calcOrderAmount(orderManage.getId());
CustomerBalanceRecord customerBalanceRecord = customerBalanceRecordMapper.selectOne(new LambdaQueryWrapper<CustomerBalanceRecord>()
.eq(CustomerBalanceRecord::getCustomerId, payUser)
.eq(CustomerBalanceRecord::getOrderId, orderId));
if (customerBalanceRecord != null && customerBalanceRecord.getCurrentBalance() > 0) {
customerBalanceRecord.setOrderAmount(customerBalanceRecord.getOrderAmount() + (discountAmount.intValue() * 100));
customerBalanceRecord.setCurrentBalance(customerBalanceRecord.getCurrentBalance() - (discountAmount.intValue() * 100));
customerBalanceRecordMapper.updateById(customerBalanceRecord);
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>()
.eq(CustomerBalance::getCustomerId, payUser));
customerBalance.setTotalExpenditure(customerBalance.getTotalExpenditure() + (discountAmount.intValue() * 100));
customerBalance.setBalance(customerBalance.getBalance() - (discountAmount.intValue() * 100));
customerBalanceMapper.updateById(customerBalance);
}
});
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment