张延森 2 jaren geleden
bovenliggende
commit
31d5381557

+ 16
- 8
src/main/java/com/yunzhi/marketing/broker/controller/BkAccountRecordController.java Bestand weergeven

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.marketing.base.BaseController;
7 7
 import com.yunzhi.marketing.base.ResponseBean;
8
+import com.yunzhi.marketing.common.StringUtils;
8 9
 import io.swagger.annotations.Api;
9 10
 import io.swagger.annotations.ApiOperation;
10 11
 import io.swagger.annotations.ApiParam;
@@ -20,6 +21,8 @@ import com.yunzhi.marketing.broker.service.IBkAccountRecordService;
20 21
 import com.yunzhi.marketing.broker.entity.BkAccountRecord;
21 22
 import org.springframework.web.bind.annotation.RestController;
22 23
 
24
+import javax.servlet.http.HttpServletRequest;
25
+
23 26
 /**
24 27
  * <p>
25 28
     * 经纪人佣金流水 前端控制器
@@ -31,7 +34,7 @@ import org.springframework.web.bind.annotation.RestController;
31 34
 
32 35
 @Api(tags = "经纪人佣金流水")
33 36
 @RestController
34
-@RequestMapping("/")
37
+@RequestMapping("/api")
35 38
 public class BkAccountRecordController extends BaseController {
36 39
 
37 40
     private final Logger logger = LoggerFactory.getLogger(BkAccountRecordController.class);
@@ -46,17 +49,22 @@ public class BkAccountRecordController extends BaseController {
46 49
      * @param pageSize
47 50
      * @return
48 51
      */
49
-    @RequestMapping(value="/bkAccountRecord",method= RequestMethod.GET)
52
+    @RequestMapping(value="/wx/bkAccountRecord",method= RequestMethod.GET)
50 53
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51 54
     public ResponseBean bkAccountRecordList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
55
+                                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
56
+                                            @ApiParam("收支类型") @RequestParam(value ="chargeCode", required = false) String chargeCode,
57
+                                            HttpServletRequest request) throws Exception{
53 58
 
54
-		    IPage<BkAccountRecord> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<BkAccountRecord> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
59
+        String personId = getPersonId(request);
60
+        IPage<BkAccountRecord> pg = new Page<>(pageNum, pageSize);
61
+        QueryWrapper<BkAccountRecord> queryWrapper = new QueryWrapper<>();
62
+        queryWrapper.eq("person_id", personId);
63
+        queryWrapper.eq(!StringUtils.isEmpty(chargeCode),"charge_code", chargeCode);
64
+        queryWrapper.orderByDesc("create_date");
57 65
 
58
-            IPage<BkAccountRecord> result = iBkAccountRecordService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
66
+        IPage<BkAccountRecord> result = iBkAccountRecordService.page(pg, queryWrapper);
67
+        return ResponseBean.success(result);
60 68
     }
61 69
 
62 70
     /**

+ 39
- 2
src/main/java/com/yunzhi/marketing/broker/controller/BkInviteRecordController.java Bestand weergeven

@@ -1,15 +1,52 @@
1 1
 package com.yunzhi.marketing.broker.controller;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.marketing.base.BaseController;
7
+import com.yunzhi.marketing.base.ResponseBean;
8
+import com.yunzhi.marketing.broker.entity.BkInviteRecord;
3 9
 import com.yunzhi.marketing.broker.service.IBkInviteRecordService;
10
+import com.yunzhi.marketing.common.StringUtils;
4 11
 import io.swagger.annotations.Api;
12
+import io.swagger.annotations.ApiOperation;
13
+import io.swagger.annotations.ApiParam;
5 14
 import org.springframework.beans.factory.annotation.Autowired;
6 15
 import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RequestMethod;
17
+import org.springframework.web.bind.annotation.RequestParam;
7 18
 import org.springframework.web.bind.annotation.RestController;
8 19
 
20
+import javax.servlet.http.HttpServletRequest;
21
+
9 22
 @Api(tags = "经济人邀请记录对象功能接口")
10 23
 @RestController
11
-@RequestMapping("/")
12
-public class BkInviteRecordController {
24
+@RequestMapping("/api")
25
+public class BkInviteRecordController extends BaseController {
13 26
     @Autowired
14 27
     private IBkInviteRecordService bkInviteRecordService;
28
+
29
+    /**
30
+     * 分页查询列表
31
+     * @param pageNum
32
+     * @param pageSize
33
+     * @return
34
+     */
35
+    @RequestMapping(value="/wx/bkInviteRecord",method= RequestMethod.GET)
36
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
37
+    public ResponseBean bkInviteRecordList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
38
+                                           @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
39
+                                           @ApiParam("是否已付佣金") @RequestParam(value ="isPayed", required = false) Boolean isPayed,
40
+                                           HttpServletRequest request) throws Exception{
41
+
42
+        String personId = getPersonId(request);
43
+        IPage<BkInviteRecord> pg = new Page<>(pageNum, pageSize);
44
+        QueryWrapper<BkInviteRecord> queryWrapper = new QueryWrapper<>();
45
+        queryWrapper.eq("person_id", personId);
46
+        queryWrapper.gt(null != isPayed && isPayed, "referral_fee", 0);
47
+        queryWrapper.orderByDesc("create_date");
48
+
49
+        IPage<BkInviteRecord> result = bkInviteRecordService.page(pg, queryWrapper);
50
+        return ResponseBean.success(result);
51
+    }
15 52
 }

+ 3
- 0
src/main/java/com/yunzhi/marketing/entity/TaPerson.java Bestand weergeven

@@ -387,4 +387,7 @@ public class TaPerson implements Serializable {
387 387
 
388 388
     @ApiModelProperty("待结算佣金")
389 389
     private Integer unsettledCommission;
390
+
391
+    @ApiModelProperty("推荐佣金")
392
+    private Integer referralFee;
390 393
 }

+ 71
- 24
src/main/java/com/yunzhi/marketing/xlk/service/impl/ChannelCustomerServiceImpl.java Bestand weergeven

@@ -196,12 +196,29 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
196 196
         // 渠道推荐的客户
197 197
         if ("report".equals(params.getType())) {
198 198
             ChannelCustomer customer = channelCustomerMapper.selectById(params.getId());
199
+            TaBuilding building = taBuildingMapper.selectById(customer.getBuildingId());
199 200
 
200 201
             customerVisit.setBuildingId(customer.getBuildingId());
201 202
             customerVisit.setRecommendPerson(customer.getRecommendPerson());
202 203
             TaPerson recommendPerson = taPersonMapper.getById(customer.getRecommendPerson());
203 204
             if (null != recommendPerson) {
204 205
                 customerVisit.setRecommendName(recommendPerson.getName());
206
+
207
+                boolean isBroker = CommConstant.PERSON_BROKER.equals(customer.getRecommendPersonType());
208
+                if (isBroker) {
209
+                    // 生成节点变更通知
210
+                    BkNotice changeNotice = new BkNotice();
211
+                    changeNotice.setOrgId(building.getOrgId().toString());
212
+                    changeNotice.setInstitutionId(building.getInstitutionId());
213
+                    changeNotice.setBuildingId(building.getBuildingId());
214
+                    changeNotice.setBuildingName(building.getBuildingName());
215
+                    changeNotice.setPersonId(recommendPerson.getPersonId());
216
+                    changeNotice.setPersonName(StringUtils.ifNull(recommendPerson.getName(), recommendPerson.getNickname()));
217
+                    changeNotice.setCustomerId(customer.getCustomerId());
218
+                    changeNotice.setCustomerName(customer.getName());
219
+                    changeNotice.setNoticeType(CommConstant.NOTICE_TYPE_STATUS_CHANGE);
220
+                    changeNotice.setContent("状态 到访");
221
+                }
205 222
             }
206 223
             customerVisit.setRealtyConsultant(params.getRealtyConsultant());
207 224
             TaPerson channelPerson = taPersonMapper.getById(params.getRealtyConsultant());
@@ -216,7 +233,6 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
216 233
             queryWrapper.eq(TaRecommendCustomer::getBuildingId,customer.getBuildingId());
217 234
             TaRecommendCustomer recommendCustomer = taRecommendCustomerMapper.selectOne(queryWrapper);
218 235
             if (null == recommendCustomer) {
219
-                TaBuilding building = taBuildingMapper.selectById(customer.getBuildingId());
220 236
                 // 进业务客户表
221 237
                 TaRecommendCustomer taRecommendCustomer = new TaRecommendCustomer();
222 238
                 taRecommendCustomer.setName(customerVisit.getName());
@@ -267,6 +283,8 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
267 283
             } else {
268 284
                 return ResponseBean.error("该客户已到访", ResponseBean.ERROR_UNAVAILABLE);
269 285
             }
286
+
287
+
270 288
         }else if ("customer".equals(params.getType())) {
271 289
             // 置业顾问 经纪人推荐的客户
272 290
             TaRecommendCustomer taRecommendCustomer = taRecommendCustomerMapper.selectById(params.getId());
@@ -370,21 +388,50 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
370 388
         taRecommendCustomer.setRealtyConsultant(customerPreparatory.getRealtyConsultant());
371 389
         taRecommendCustomerMapper.updateById(taRecommendCustomer);
372 390
 
391
+        TaBuilding taBuilding = taBuildingMapper.selectById(taRecommendCustomer.getBuildingId());
392
+        if (taBuilding == null) {
393
+            return ResponseBean.error("校验客户及楼盘信息异常", ResponseBean.ERROR_UNAVAILABLE);
394
+        }
395
+        customerPreparatory.setBuildingId(taRecommendCustomer.getBuildingId());
396
+
397
+        // 推荐人
398
+        customerPreparatory.setRecommendPerson(taRecommendCustomer.getRecommendPerson());
399
+        TaPerson recommendPerson = taPersonMapper.getById(taRecommendCustomer.getRecommendPerson());
400
+        if (null != recommendPerson) {
401
+            customerPreparatory.setRecommendName(recommendPerson.getName());
402
+        }
403
+
373 404
         LambdaQueryWrapper<ChannelCustomer> channelCustomerLambdaQueryWrapper = new LambdaQueryWrapper<>();
374 405
         channelCustomerLambdaQueryWrapper.eq(ChannelCustomer::getCustomerId,params.getCustomerId());
375 406
         ChannelCustomer customer = channelCustomerMapper.selectOne(channelCustomerLambdaQueryWrapper);
376 407
         if (null != customer) {
377 408
             customer.setPreparatoryDate(LocalDateTime.now());
378 409
             channelCustomerMapper.updateById(customer);
410
+
411
+            boolean isBroker = CommConstant.PERSON_BROKER.equals(customer.getRecommendPersonType());
412
+            if (isBroker) {
413
+                // 生成节点变更通知
414
+                BkNotice changeNotice = new BkNotice();
415
+                changeNotice.setOrgId(taBuilding.getOrgId().toString());
416
+                changeNotice.setInstitutionId(taBuilding.getInstitutionId());
417
+                changeNotice.setBuildingId(taBuilding.getBuildingId());
418
+                changeNotice.setBuildingName(taBuilding.getBuildingName());
419
+                changeNotice.setPersonId(recommendPerson.getPersonId());
420
+                changeNotice.setPersonName(StringUtils.ifNull(recommendPerson.getName(), recommendPerson.getNickname()));
421
+                changeNotice.setCustomerId(customer.getCustomerId());
422
+                changeNotice.setCustomerName(customer.getName());
423
+                changeNotice.setNoticeType(CommConstant.NOTICE_TYPE_STATUS_CHANGE);
424
+                changeNotice.setContent("状态 认筹");
425
+            }
379 426
         }
380 427
 
381 428
         customerPreparatory.setCreateDate(LocalDateTime.now());
382
-        customerPreparatory.setBuildingId(taRecommendCustomer.getBuildingId());
383
-        customerPreparatory.setRecommendPerson(taRecommendCustomer.getRecommendPerson());
384
-        TaPerson recommendPerson = taPersonMapper.getById(taRecommendCustomer.getRecommendPerson());
385
-        if (null != recommendPerson) {
386
-            customerPreparatory.setRealtyConsultantName(recommendPerson.getName());
387
-        }
429
+//        customerPreparatory.setBuildingId(taRecommendCustomer.getBuildingId());
430
+//        customerPreparatory.setRecommendPerson(taRecommendCustomer.getRecommendPerson());
431
+//        TaPerson recommendPerson = taPersonMapper.getById(taRecommendCustomer.getRecommendPerson());
432
+//        if (null != recommendPerson) {
433
+//            customerPreparatory.setRealtyConsultantName(recommendPerson.getName());
434
+//        }
388 435
         customerPreparatory.setRealtyConsultant(taRecommendCustomer.getRealtyConsultant());
389 436
         TaPerson channelPerson = taPersonMapper.getById(taRecommendCustomer.getRealtyConsultant());
390 437
         if (null != channelPerson) {
@@ -394,7 +441,7 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
394 441
         customerPreparatory.setCustomerId(taRecommendCustomer.getCustomerId());
395 442
         if (StringUtils.isEmpty(customerPreparatory.getCustomerPreparatoryId())) {
396 443
             customerPreparatoryMapper.insert(customerPreparatory);
397
-        }else {
444
+        } else {
398 445
             customerPreparatoryMapper.updateById(customerPreparatory);
399 446
         }
400 447
 
@@ -571,6 +618,19 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
571 618
                 if (null != params.getTotalCommission() && params.getTotalCommission() > 0) {
572 619
                     processCommission(params, customer, recommendPerson, bizType, taBuilding);
573 620
                 }
621
+                // 生成节点变更通知
622
+                BkNotice changeNotice = new BkNotice();
623
+                changeNotice.setOrgId(taBuilding.getOrgId().toString());
624
+                changeNotice.setInstitutionId(taBuilding.getInstitutionId());
625
+                changeNotice.setBuildingId(taBuilding.getBuildingId());
626
+                changeNotice.setBuildingName(taBuilding.getBuildingName());
627
+                changeNotice.setPersonId(recommendPerson.getPersonId());
628
+                changeNotice.setPersonName(StringUtils.ifNull(recommendPerson.getName(), recommendPerson.getNickname()));
629
+                changeNotice.setCustomerId(customer.getCustomerId());
630
+                changeNotice.setCustomerName(customer.getName());
631
+                changeNotice.setNoticeType(CommConstant.NOTICE_TYPE_STATUS_CHANGE);
632
+                changeNotice.setContent(String.format("状态 %s", getStatusDesc(bizType)));
633
+                bkNoticeMapper.insert(changeNotice);
574 634
             }
575 635
 
576 636
             channelCustomerMapper.updateById(customer);
@@ -638,21 +698,6 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
638 698
             bkAccountRecordMapper.insert(bkAccountRecord);
639 699
         }
640 700
 
641
-        // 生成节点变更通知
642
-        BkNotice changeNotice = new BkNotice();
643
-        changeNotice.setOrgId(taBuilding.getOrgId().toString());
644
-        changeNotice.setInstitutionId(taBuilding.getInstitutionId());
645
-        changeNotice.setBuildingId(taBuilding.getBuildingId());
646
-        changeNotice.setBuildingName(taBuilding.getBuildingName());
647
-        changeNotice.setPersonId(recommendPerson.getPersonId());
648
-        changeNotice.setPersonName(StringUtils.ifNull(recommendPerson.getName(), recommendPerson.getNickname()));
649
-        changeNotice.setCustomerId(customer.getCustomerId());
650
-        changeNotice.setCustomerName(customer.getName());
651
-        changeNotice.setNoticeType(CommConstant.NOTICE_TYPE_STATUS_CHANGE);
652
-        changeNotice.setContent(String.format("状态 %s", getStatusDesc(bizType)));
653
-        bkNoticeMapper.insert(changeNotice);
654
-
655
-
656 701
         // 生成成交喜报
657 702
         BkNotice bkNotice = bkNoticeMapper.getByPerson(CommConstant.NOTICE_TYPE_DEAL, recommendPerson.getName(), customer.getCustomerId());
658 703
         if (null == bkNotice) {
@@ -696,9 +741,11 @@ public class ChannelCustomerServiceImpl extends ServiceImpl<ChannelCustomerMappe
696 741
         BkAgentRule agentRule = bkAgentRuleMapper.getByCity(taBuilding.getCityId());
697 742
         if (null == agentRule) return;
698 743
 
744
+        // 记录明细
699 745
         bkInviteRecord.setReferralFee(agentRule.getReferralFee());
700 746
         bkInviteRecordMapper.updateById(bkInviteRecord);
701
-
747
+        // 累积总额
748
+        taPersonMapper.setFieldIncrement(personId, "referral_fee", agentRule.getReferralFee());
702 749
     }
703 750
 
704 751
     private String getStatusDesc(String bizType) {