|
|
@@ -0,0 +1,63 @@
|
|
|
+package com.jzg.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.jzg.entity.PartnerPartnerAccount;
|
|
|
+import com.jzg.entity.PartnerPremiumDetails;
|
|
|
+import com.jzg.mapper.PartnerPartnerAccountMapper;
|
|
|
+import com.jzg.mapper.PartnerPremiumDetailsMapper;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/extractFee")
|
|
|
+public class ExtractFeeController {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PartnerPremiumDetailsMapper partnerPremiumDetailsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PartnerPartnerAccountMapper partnerPartnerAccountMapper;
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("save")
|
|
|
+ public void distribution(@RequestParam String orderNo){
|
|
|
+ List<PartnerPremiumDetails> partnerPremiumDetails = partnerPremiumDetailsMapper.selectList(new LambdaQueryWrapper<PartnerPremiumDetails>()
|
|
|
+ .eq(PartnerPremiumDetails::getCompanyId,orderNo));
|
|
|
+ for (PartnerPremiumDetails detail : partnerPremiumDetails) {
|
|
|
+ PartnerPartnerAccount account1 = partnerPartnerAccountMapper.selectOne(new LambdaQueryWrapper<PartnerPartnerAccount>()
|
|
|
+ .eq(PartnerPartnerAccount::getUserId, detail.getUserId()).eq(PartnerPartnerAccount::getGrade,detail.getSource()));
|
|
|
+ if (Objects.isNull(account1)){
|
|
|
+ PartnerPartnerAccount account = new PartnerPartnerAccount();
|
|
|
+ account.setUserId(detail.getUserId());
|
|
|
+ account.setSumPremium(detail.getSumpremium());
|
|
|
+ account.setExtractFee(detail.getExtractFee());
|
|
|
+ account.setHistoryFee(new BigDecimal("0"));
|
|
|
+ account.setCashFee(detail.getExtractFee());
|
|
|
+ account.setCreateTime(LocalDateTime.now());
|
|
|
+ account.setGrade(detail.getSource());
|
|
|
+ partnerPartnerAccountMapper.insert(account);
|
|
|
+ }else {
|
|
|
+ account1.setSumPremium(account1.getSumPremium().add(detail.getSumpremium()));
|
|
|
+ account1.setExtractFee(account1.getExtractFee().add(detail.getExtractFee()));
|
|
|
+ account1.setCashFee(account1.getCashFee().add(detail.getExtractFee()));
|
|
|
+ partnerPartnerAccountMapper.updateById(account1);
|
|
|
+ }
|
|
|
+ detail.setStatus(1);
|
|
|
+ partnerPremiumDetailsMapper.updateById(detail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|