浏览代码

门店查看详情,门店查看任务量,门店核销 接口开发

lazhaoqian 4 年之前
父节点
当前提交
7b2c0a67b2
共有 24 个文件被更改,包括 642 次插入31 次删除
  1. 0 1
      sailun-allsteel-app-rest/src/main/java/io/platform/app/web/controller/HomePageController.java
  2. 122 0
      sailun-allsteel-app-rest/src/main/java/io/platform/app/web/controller/MyAppController.java
  3. 118 0
      sailun-allsteel-app-rest/src/main/java/io/platform/app/web/remote/MyAppRemote.java
  4. 4 0
      sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/dto/StoreAgentBrandLvDto.java
  5. 12 0
      sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/dto/StoreBasicInfoDto.java
  6. 13 3
      sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/dto/StoreWriteOffCouponDto.java
  7. 7 0
      sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/service/client/api/StoreAgentBrandLvServiceClient.java
  8. 7 0
      sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/service/client/api/StoreBasicInfoServiceClient.java
  9. 1 1
      sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/service/client/api/StoreWriteOffCouponServiceClient.java
  10. 15 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/entity/StoreBasicInfo.java
  11. 54 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/entity/StoreBrandTask.java
  12. 6 5
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/entity/StoreWriteOffCoupon.java
  13. 7 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/mapper/StoreAgentBrandLvMapper.java
  14. 14 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/mapper/StoreBasicInfoMapper.java
  15. 9 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/service/StoreAgentBrandLvService.java
  16. 17 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/service/StoreBasicInfoService.java
  17. 36 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/service/StoreWriteOffCouponService.java
  18. 9 0
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/service/client/impl/StoreAgentBrandLvServiceClientImpl.java
  19. 38 3
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/service/client/impl/StoreBasicInfoServiceClientImpl.java
  20. 59 14
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/service/client/impl/StoreWriteOffCouponServiceClientImpl.java
  21. 14 2
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/mybatis/store/StoreAgentBrandLvMapper.xml
  22. 37 2
      sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/mybatis/store/StoreBasicInfoMapper.xml
  23. 22 0
      sailun-allsteel-common/src/main/java/io/platform/base/dto/SettlementCenteDto.java
  24. 21 0
      sailun-allsteel-common/src/main/java/io/platform/base/dto/StoreTaskStatistics.java

+ 0 - 1
sailun-allsteel-app-rest/src/main/java/io/platform/app/web/controller/HomePageController.java

@@ -1,7 +1,6 @@
 package io.platform.app.web.controller;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import io.platform.app.web.query.ScanRecordQuery;
 import io.platform.app.web.remote.HomePageRemote;
 import io.platform.base.common.constant.enums.LV_ENUNS;
 import io.platform.base.common.exception.RRException;

+ 122 - 0
sailun-allsteel-app-rest/src/main/java/io/platform/app/web/controller/MyAppController.java

@@ -0,0 +1,122 @@
+package io.platform.app.web.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.platform.app.web.remote.MyAppRemote;
+import io.platform.base.common.utils.ExecuteResult;
+import io.platform.base.common.utils.R;
+import io.platform.base.common.utils.StringUtils;
+import io.platform.config.annotation.FuncLogAnno;
+import io.platform.store.dto.StoreBasicInfoDto;
+import io.platform.store.dto.StoreWriteOffCouponDto;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * app我的页面接口
+ */
+@RestController
+@RequestMapping("/myapp")
+@Api(tags = "APP我的页面")
+public class MyAppController {
+    @Autowired
+    private MyAppRemote myAppRemote;
+
+    @PostMapping("/selectStore")
+    @ApiOperation("查询门店信息接口")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId",value = "门店ID",required = true)
+    })
+    @FuncLogAnno(functionName = "查询门店信息接口")
+    public R selectStore(@RequestBody Map<String,Object> map){
+        if (map.size()<1){
+            return R.error("参数不能为空");
+        }
+        if (StringUtils.isNullOrEmpty(map.get("storeId").toString())){
+            return R.error("门店ID不能为空");
+        }
+        Long storeId = Long.valueOf(map.get("storeId").toString());
+        return R.ok().put("data",myAppRemote.selectStore(storeId));
+    }
+    @PostMapping("/storeSettlementCenter")
+    @ApiOperation("门店查看结算中心")
+    @FuncLogAnno(functionName ="门店查看结算中心")
+    public R storeSettlementCenter(@RequestBody Map<String,Object> map){
+        if (map.size()<1){
+            return R.error("参数不能为空");
+        }
+        if (StringUtils.isNullOrEmpty(map.get("storeId").toString())){
+            return R.error("门店ID不能为空");
+        }
+        Long storeId = Long.valueOf(map.get("storeId").toString());
+        return R.ok().put("data",myAppRemote.storeSettlementCenter(storeId));
+    }
+    /**
+     * 我的核销接口
+     */
+    @PostMapping("storeCancel")
+    @ApiOperation("门店我的核销接口")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId", value = "门店ID",required = true),
+            @ApiImplicitParam(name = "amount",value = "核销金额",required = true),
+            @ApiImplicitParam(name = "brandCode",value = "品牌名称",required = true),
+            @ApiImplicitParam(name = "kunnr",value = "经销商编号",required = true)
+    })
+    @FuncLogAnno(functionName = "门店核销接口")
+    public R storeCancel(@RequestBody List<StoreWriteOffCouponDto> storeWriteOffCouponDtoList){
+        if (storeWriteOffCouponDtoList.size()<0){
+            return R.error("参数不能为空");
+        }
+        ExecuteResult<StoreWriteOffCouponDto> result = myAppRemote.storeCancel(storeWriteOffCouponDtoList);
+        if (result.isSuccess()){
+            return R.ok().put("data",result.getResult());
+        }else {
+            return R.error(result.getErrorMessages().get(0));
+        }
+
+    }
+    @PostMapping("/storeSelectCoupon")
+    @ApiOperation("门店查询核销接口")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId",value = "门店Id",required = true),
+            @ApiImplicitParam(name = "size",value = "条数",required = true),
+            @ApiImplicitParam(name = "current",value = "当前页",required = true)
+    })
+    @FuncLogAnno(functionName = "门店查询核销接口")
+    public R storeSelectCoupon(@RequestBody StoreWriteOffCouponDto storeWriteOffCouponDto){
+        if (storeWriteOffCouponDto.getStoreId()==null){
+            return R.error("门店ID不能为空");
+        }
+        Page page = new Page();
+        if (storeWriteOffCouponDto.getSize() != null){
+            page.setSize(storeWriteOffCouponDto.getSize());
+        }
+        if (storeWriteOffCouponDto.getCurrent() != null){
+            page.setCurrent(storeWriteOffCouponDto.getCurrent());
+        }
+        return R.ok().put("data",myAppRemote.storeSelectCoupon(page,storeWriteOffCouponDto).getRecords());
+
+    }
+    @PostMapping("/storeBrandTask")
+    @ApiOperation("门店品牌任务完成量统计接口")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId",value = "门店Id",required = true)
+    })
+    @FuncLogAnno(functionName = "门店品牌任务完成量统计接口")
+    public R storeBrandTask(@RequestBody Map<String,Object> map){
+        if (map.size()<1){
+            return R.error("参数不能为空");
+        }
+        if (StringUtils.isNullOrEmpty(map.get("storeId").toString())){
+            return R.error("门店ID不能为空");
+        }
+        Long storeId = Long.valueOf(map.get("storeId").toString());
+        return R.ok().put("data",myAppRemote.storeBrandTask(storeId));
+    }
+}

+ 118 - 0
sailun-allsteel-app-rest/src/main/java/io/platform/app/web/remote/MyAppRemote.java

@@ -0,0 +1,118 @@
+package io.platform.app.web.remote;
+
+import com.alibaba.dubbo.config.annotation.Reference;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.platform.base.common.utils.ExecuteResult;
+import io.platform.base.dto.SettlementCenteDto;
+import io.platform.base.dto.StoreTaskStatistics;
+import io.platform.homepage.dto.ConfigBrandDto;
+import io.platform.homepage.service.client.api.ConfigBrandServiceClient;
+import io.platform.store.dto.StoreAgentBrandLvDto;
+import io.platform.store.dto.StoreBasicInfoDto;
+import io.platform.store.dto.StoreWriteOffCouponDto;
+import io.platform.store.service.client.api.StoreAgentBrandLvLogServiceClient;
+import io.platform.store.service.client.api.StoreAgentBrandLvServiceClient;
+import io.platform.store.service.client.api.StoreBasicInfoServiceClient;
+import io.platform.store.service.client.api.StoreWriteOffCouponServiceClient;
+import org.apache.zookeeper.Op;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service("myAppRemote")
+public class MyAppRemote {
+
+    @Reference(check = false)
+    private StoreWriteOffCouponServiceClient storeWriteOffCouponServiceClient;
+    @Reference(check = false)
+    private StoreBasicInfoServiceClient storeBasicInfoServiceClient;
+    @Reference(check = false)
+    private StoreAgentBrandLvServiceClient storeAgentBrandLvServiceClient;
+    @Reference(check = false)
+    private  ConfigBrandServiceClient configBrandServiceClient;
+
+
+    /**
+     * 获取门店信息
+     *
+     * @param storeId
+     * @return
+     */
+    public StoreBasicInfoDto selectStore(Long storeId) {
+        StoreBasicInfoDto storeBasicInfoDto = storeBasicInfoServiceClient.queryObject(storeId);
+        StoreBasicInfoDto basicInfoDto = storeAgentBrandLvServiceClient.selectStoreMoney(storeId);
+        if (null != basicInfoDto) {
+            storeBasicInfoDto.setBlockMoney(basicInfoDto.getBlockMoney());
+            storeBasicInfoDto.setUsableMoney(basicInfoDto.getUsableMoney());
+            storeBasicInfoDto.setAllBlockMoney(basicInfoDto.getAllBlockMoney());
+        }
+        return storeBasicInfoDto;
+    }
+
+    /**
+     * 门店查看结算中心
+     *
+     * @param storeId
+     * @return
+     */
+    public List<SettlementCenteDto> storeSettlementCenter(Long storeId) {
+        List<String> storeAgents = storeAgentBrandLvServiceClient.getStoreAgents(storeId);
+        List<SettlementCenteDto> list = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(storeAgents)){
+            SettlementCenteDto settlementCenteDto = new SettlementCenteDto();
+            for (String string : storeAgents) {
+                Map<String,Object> storeMap = new HashMap<>();
+                storeMap.put("STORE_ID",storeId);
+                storeMap.put("AGENT_ID",string);
+                List<StoreAgentBrandLvDto> agentBrandLv = storeAgentBrandLvServiceClient.queryList(storeMap);
+                if (CollectionUtils.isNotEmpty(agentBrandLv)){
+                    settlementCenteDto.setAgentName(agentBrandLv.get(0).getAgentName());
+                    for (StoreAgentBrandLvDto storeAgentBrandLvDto : agentBrandLv) {
+                        Map<String,Object> brandMap = new HashMap<>();
+                        brandMap.put("BRAND_CODE",storeAgentBrandLvDto.getBrandCode());
+                        List<ConfigBrandDto> configBrandDtos = configBrandServiceClient.queryList(brandMap);
+                        if (CollectionUtils.isNotEmpty(configBrandDtos)){
+                            storeAgentBrandLvDto.setLogoUrl(configBrandDtos.get(0).getLogoUrl());
+                        }
+                    }
+                    settlementCenteDto.setList(Collections.singletonList(agentBrandLv));
+                    list.add(settlementCenteDto);
+                }
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 门店核销
+     *
+     * @param storeWriteOffCouponDtoList
+     * @return
+     */
+    public ExecuteResult<StoreWriteOffCouponDto> storeCancel(List<StoreWriteOffCouponDto> storeWriteOffCouponDtoList) {
+        return storeWriteOffCouponServiceClient.save(storeWriteOffCouponDtoList);
+    }
+
+    /**
+     * 门店端核销查询
+     *
+     * @param page
+     * @param storeWriteOffCouponDto
+     * @return
+     */
+    public Page<StoreWriteOffCouponDto> storeSelectCoupon(Page page, StoreWriteOffCouponDto storeWriteOffCouponDto) {
+        return storeWriteOffCouponServiceClient.getPage(page, storeWriteOffCouponDto);
+    }
+
+    /**
+     * 门店查询品牌任务量
+     *
+     * @param storId
+     * @return
+     */
+    public List<StoreTaskStatistics> storeBrandTask(Long storId) {
+        return storeBasicInfoServiceClient.storeBrandTask(storId);
+    }
+}

+ 4 - 0
sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/dto/StoreAgentBrandLvDto.java

@@ -91,6 +91,10 @@ private static final long serialVersionUID = 5454155825314635342L;
      * 更新时间       db_column: UPDATED_TIME
      */
     private java.util.Date updatedTime;
+    /**
+     * 品牌图片链接
+     */
+    private String logoUrl;
     //columns END
 
 }

+ 12 - 0
sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/dto/StoreBasicInfoDto.java

@@ -131,6 +131,18 @@ private static final long serialVersionUID = 5454155825314635342L;
      * 最后更新时间       db_column: UPDATE_TIME
      */
     private java.util.Date updateTime;
+    /**
+     * 品牌冻结金额
+     */
+    private Long blockMoney;
+    /**
+     * 品牌可用金额
+     */
+    private Long usableMoney;
+    /**
+     * 总待核销金额
+     */
+    private Long allBlockMoney;
     //columns END
 
 }

+ 13 - 3
sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/dto/StoreWriteOffCouponDto.java

@@ -2,6 +2,8 @@ package io.platform.store.dto;
 
 import lombok.Data;
 
+import java.util.Date;
+
 @Data
 public class StoreWriteOffCouponDto  implements java.io.Serializable{
 private static final long serialVersionUID = 5454155825314635342L;
@@ -62,7 +64,7 @@ private static final long serialVersionUID = 5454155825314635342L;
     /**
      * b2bAuditTime       db_column: B2B_AUDIT_TIME
      */
-    private Object b2bAuditTime;
+    private Date b2bAuditTime;
     /**
      * b2bAuditUser       db_column: B2B_AUDIT_USER
      */
@@ -72,9 +74,17 @@ private static final long serialVersionUID = 5454155825314635342L;
      */
     private java.util.Date createTime;
     /**
-     * useTime       db_column: USE_TIME
+     * 条数
+     */
+    private Long size;
+    /**
+     * 当前页
+     */
+    private Long current;
+    /**
+     * 核销审核状态
      */
-    private java.util.Date useTime;
+    private Long status;
     //columns END
 
 }

+ 7 - 0
sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/service/client/api/StoreAgentBrandLvServiceClient.java

@@ -7,6 +7,7 @@ import io.platform.store.dto.StoreAgentBrandLvDto;
 import java.util.List;
 import java.util.Map;
 import io.platform.base.common.utils.ExecuteResult;
+import io.platform.store.dto.StoreBasicInfoDto;
 
 
 public interface StoreAgentBrandLvServiceClient{
@@ -49,4 +50,10 @@ public interface StoreAgentBrandLvServiceClient{
          * @return
          */
         List<String> getStoreAgents(Long storeId);
+        /**
+         * 查询门店总的可用金额,总的冻结金额,总的待核销金额
+         * @param storeId
+         * @return
+         */
+        public StoreBasicInfoDto selectStoreMoney(Long storeId);
 }

+ 7 - 0
sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/service/client/api/StoreBasicInfoServiceClient.java

@@ -2,6 +2,7 @@
 package io.platform.store.service.client.api;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.platform.base.dto.StoreTaskStatistics;
 import io.platform.store.dto.StoreBasicInfoDto;
 
 import java.util.List;
@@ -43,5 +44,11 @@ public interface StoreBasicInfoServiceClient{
          */
         Page<StoreBasicInfoDto>getPage(Page<StoreBasicInfoDto>page,StoreBasicInfoDto storeBasicInfoDto);
 
+        /**
+         * 查询门店品牌任务量
+         * @return
+         */
+        List<StoreTaskStatistics> storeBrandTask(Long storId);
+
 
 }

+ 1 - 1
sailun-allsteel-bus-provider/saillun-allsteel-bus-api/src/main/java/io/platform/store/service/client/api/StoreWriteOffCouponServiceClient.java

@@ -25,7 +25,7 @@ public interface StoreWriteOffCouponServiceClient{
         /**
          * 保存对象
          */
-        ExecuteResult<String> save(StoreWriteOffCouponDto storeWriteOffCouponDto);
+        ExecuteResult<StoreWriteOffCouponDto> save(List<StoreWriteOffCouponDto> storeWriteOffCouponDtoList);
         /**
          * 更新对象
          */

+ 15 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/entity/StoreBasicInfo.java

@@ -205,6 +205,21 @@ public class StoreBasicInfo extends Model<StoreBasicInfo>  implements Serializab
      */
     @TableField("UPDATE_TIME")
     private java.util.Date updateTime;
+    @TableField(exist = false)
+    /**
+     * 品牌冻结金额
+     */
+    private Long blockMoney;
+    @TableField(exist = false)
+    /**
+     * 品牌可用金额
+     */
+    private Long usableMoney;
+    @TableField(exist = false)
+    /**
+     * 总待核销金额
+     */
+    private Long allBlockMoney;
 //columns END
 
 }

+ 54 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/entity/StoreBrandTask.java

@@ -0,0 +1,54 @@
+package io.platform.store.biz.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class StoreBrandTask implements Serializable {
+    private static final long serialVersionUID = 5454155825314635342L;
+    /**
+     * 门店ID
+     */
+    private Long storeId;
+    /**
+     * 门店名称
+     */
+    private String storeName;
+    /**
+     * 经销商编号
+     */
+    private String agentId;
+    /**
+     * 经销商名称
+     */
+    private String  agentName;
+    /**
+     * 门店品牌
+     */
+    private String brand;
+    /**
+     * 门店月度任务量
+     */
+    private  Long  lvcount;
+    /**
+     * 门店季度任务量
+     */
+    private  Long  quarterCount;
+    /**
+     * 门店月度扫码量
+     */
+    private  Long  monthScan;
+    /**
+     * 门店季度扫码量
+     */
+    private  Long  quarterScan;
+    /**
+     * 门店月度剩余任务量
+     */
+    private  Long  monthLeftNum;
+    /**
+     * 门店季度任务剩余量
+     */
+    private  Long  quarterLeftNum;
+}

+ 6 - 5
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/entity/StoreWriteOffCoupon.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 
 import java.io.Serializable;
+import java.util.Date;
+
 import lombok.Data;
 
 @Data
@@ -102,7 +104,7 @@ public class StoreWriteOffCoupon extends Model<StoreWriteOffCoupon>  implements
      * b2bAuditTime       db_column: B2B_AUDIT_TIME
      */
     @TableField("B2B_AUDIT_TIME")
-    private Object b2bAuditTime;
+    private Date b2bAuditTime;
 
     /**
      * b2bAuditUser       db_column: B2B_AUDIT_USER
@@ -115,12 +117,11 @@ public class StoreWriteOffCoupon extends Model<StoreWriteOffCoupon>  implements
      */
     @TableField("CREATE_TIME")
     private java.util.Date createTime;
-
     /**
-     * useTime       db_column: USE_TIME
+     * STATUS   核销审核状态
      */
-    @TableField("USE_TIME")
-    private java.util.Date useTime;
+    @TableField("STATUS")
+    private Long status;
 //columns END
 
 }

+ 7 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/mapper/StoreAgentBrandLvMapper.java

@@ -1,6 +1,7 @@
 package io.platform.store.biz.mapper;
 
 import io.platform.base.common.BaseMapper;
+import io.platform.store.biz.entity.StoreBasicInfo;
 import org.apache.ibatis.annotations.Mapper;
 import io.platform.store.biz.entity.StoreAgentBrandLv;
 import org.apache.ibatis.annotations.Param;
@@ -37,4 +38,10 @@ public interface StoreAgentBrandLvMapper extends BaseMapper<StoreAgentBrandLv>{
      * @return
      */
     List<String> getStoreAgents(@Param("storeId")Long storeId);
+    /**
+     * 查询门店总的可用金额,总的冻结金额,总的待核销金额
+     * @param storeId
+     * @return
+     */
+    StoreBasicInfo selectStoreMoney(@Param("storeId") Long storeId);
 }

+ 14 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/mapper/StoreBasicInfoMapper.java

@@ -1,6 +1,8 @@
 package io.platform.store.biz.mapper;
 
+import cn.hutool.core.date.DateTime;
 import io.platform.base.common.BaseMapper;
+import io.platform.store.biz.entity.StoreBrandTask;
 import org.apache.ibatis.annotations.Mapper;
 import io.platform.store.biz.entity.StoreBasicInfo;
 import org.apache.ibatis.annotations.Param;
@@ -23,4 +25,16 @@ public interface StoreBasicInfoMapper extends BaseMapper<StoreBasicInfo>{
      */
     void updateStoreIntegral(@Param("storeId") Long storeId,
                              @Param("storeIntegral") Long storeIntegral);
+    /**
+     * 查询门店品牌任务量
+     * @param storeId
+     * @param brand
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    StoreBrandTask storeBrandTask(@Param("storeId") Long storeId,
+                                  @Param("brand") String brand,
+                                  @Param("startTime")DateTime startTime,
+                                  @Param("endTime") DateTime endTime);
 }

+ 9 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/service/StoreAgentBrandLvService.java

@@ -3,6 +3,7 @@ package io.platform.store.biz.service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import io.platform.store.biz.entity.StoreBasicInfo;
 import io.platform.store.biz.mapper.StoreAgentBrandLvMapper;
 import io.platform.store.biz.entity.StoreAgentBrandLv;
 
@@ -54,4 +55,12 @@ public class StoreAgentBrandLvService extends ServiceImpl<StoreAgentBrandLvMappe
     public List<String> getStoreAgents(Long storeId) {
         return this.baseMapper.getStoreAgents(storeId);
     }
+    /**
+     * 查询门店总的可用金额,总的冻结金额,总的待核销金额
+     * @param storeId
+     * @return
+     */
+    public StoreBasicInfo selectStoreMoney(Long storeId){
+        return this.baseMapper.selectStoreMoney(storeId);
+    }
 }

+ 17 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/service/StoreBasicInfoService.java

@@ -1,8 +1,10 @@
 
 package io.platform.store.biz.service;
 
+import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import io.platform.store.biz.entity.StoreBrandTask;
 import io.platform.store.biz.mapper.StoreBasicInfoMapper;
 import io.platform.store.biz.entity.StoreBasicInfo;
 
@@ -19,6 +21,21 @@ public class StoreBasicInfoService extends ServiceImpl<StoreBasicInfoMapper,Stor
     }
 
     /**
+     * 查询门店品牌任务量
+     * @param storeId
+     * @param brand
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public StoreBrandTask storeBrandTask(Long storeId,
+                                         String brand,
+                                         DateTime startTime,
+                                         DateTime endTime){
+        return baseMapper.storeBrandTask(storeId,brand,startTime,endTime);
+    }
+
+    /**
      * 根据门店ID与冻结状态查询门店信息
      * @param storeId
      * @param status

+ 36 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/biz/service/StoreWriteOffCouponService.java

@@ -3,19 +3,55 @@ package io.platform.store.biz.service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import io.platform.base.common.utils.ExecuteResult;
+import io.platform.store.biz.entity.StoreAgentBrandLv;
+import io.platform.store.biz.entity.StoreBasicInfo;
 import io.platform.store.biz.mapper.StoreWriteOffCouponMapper;
 import io.platform.store.biz.entity.StoreWriteOffCoupon;
 
+import io.platform.store.dto.StoreWriteOffCouponDto;
+import io.platform.utils.IdUtil;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
 @Service("storeWriteOffCouponService")
 public class StoreWriteOffCouponService extends ServiceImpl<StoreWriteOffCouponMapper,StoreWriteOffCoupon>{
 
+    @Resource
+    private StoreBasicInfoService storeBasicInfoService;
+    @Resource
+    private StoreAgentBrandLvService storeAgentBrandLvService;
+
+
     public List<StoreWriteOffCoupon> selectByMap(Map<String, Object> map) {
         return baseMapper.selectByMap(map);
     }
 
+    /**
+     * 门店核销
+     * @param storeWriteOffCoupon
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public StoreWriteOffCoupon storeCancel(StoreWriteOffCoupon storeWriteOffCoupon, StoreAgentBrandLv storeAgentBrandLv) {
+        //保存核销记录
+        storeWriteOffCoupon.setBrandName(storeAgentBrandLv.getBrand());
+        storeWriteOffCoupon.setCouponCode(IdUtil.createIdByTime());
+        storeWriteOffCoupon.setStatus(0L);
+        storeWriteOffCoupon.setB2bStatus(0L);
+        storeWriteOffCoupon.setCreateTime(new Date());
+        boolean save = this.save(storeWriteOffCoupon);
+        //保存核销记录
+        //修改门店经销商对应关系中间表记录
+        storeAgentBrandLv .setUsableMoney(storeAgentBrandLv.getUsableMoney()-storeWriteOffCoupon.getAmount()); //门店品牌对应的品牌的可用金额 = 原先的可用金额减去核销的金额
+        storeAgentBrandLv.setAllBlockMoney(storeAgentBrandLv.getAllBlockMoney() + storeWriteOffCoupon.getAmount());//门店品牌总待核销金额 = 原先的总核销 + 核销金额
+        boolean b = storeAgentBrandLvService.updateById(storeAgentBrandLv);
+        return storeWriteOffCoupon;
+    }
+
 }

+ 9 - 0
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/service/client/impl/StoreAgentBrandLvServiceClientImpl.java

@@ -9,8 +9,10 @@ import io.platform.base.common.BaseServiceClient;
 import io.platform.base.common.utils.ExecuteResult;
 
 import io.platform.store.biz.entity.StoreAgentBrandLv;
+import io.platform.store.biz.entity.StoreBasicInfo;
 import io.platform.store.biz.service.StoreAgentBrandLvService;
 import io.platform.store.dto.StoreAgentBrandLvDto;
+import io.platform.store.dto.StoreBasicInfoDto;
 import io.platform.store.service.client.api.StoreAgentBrandLvServiceClient;
 
 import org.slf4j.Logger;
@@ -154,6 +156,13 @@ public class StoreAgentBrandLvServiceClientImpl extends BaseServiceClient<StoreA
         return this.storeAgentBrandLvService.getStoreAgents(storeId);
     }
 
+    @Override
+    public StoreBasicInfoDto selectStoreMoney(Long storeId) {
+        StoreBasicInfo storeBasicInfo = storeAgentBrandLvService.selectStoreMoney(storeId);
+        StoreBasicInfoDto storeBasicInfoDto = new StoreBasicInfoDto();
+        BeanUtils.copyProperties(storeBasicInfo,storeBasicInfoDto);
+        return storeBasicInfoDto;
+    }
 
 
 }

+ 38 - 3
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/service/client/impl/StoreBasicInfoServiceClientImpl.java

@@ -1,14 +1,21 @@
 
 package io.platform.store.service.client.impl;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.dubbo.config.annotation.Service;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 
 import io.platform.base.common.BaseServiceClient;
 import io.platform.base.common.utils.ExecuteResult;
 
+import io.platform.base.dto.StoreTaskStatistics;
+import io.platform.store.biz.entity.StoreAgentBrandLv;
 import io.platform.store.biz.entity.StoreBasicInfo;
+import io.platform.store.biz.entity.StoreBrandTask;
+import io.platform.store.biz.service.StoreAgentBrandLvService;
 import io.platform.store.biz.service.StoreBasicInfoService;
 import io.platform.store.dto.StoreBasicInfoDto;
 import io.platform.store.service.client.api.StoreBasicInfoServiceClient;
@@ -20,9 +27,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-
+import java.util.*;
 
 
 @Component
@@ -33,6 +38,8 @@ public class StoreBasicInfoServiceClientImpl extends BaseServiceClient<StoreBasi
 
     @Resource
     private StoreBasicInfoService storeBasicInfoService;
+    @Resource
+    private StoreAgentBrandLvService storeAgentBrandLvService;
 
     @Override
     public StoreBasicInfoDto queryObject(Long id) {
@@ -143,5 +150,33 @@ public class StoreBasicInfoServiceClientImpl extends BaseServiceClient<StoreBasi
         return pageDto;
     }
 
+    /**
+     * 查看门店品牌任务量
+     * @param storId
+     * @return
+     */
+    @Override
+    public List<StoreTaskStatistics> storeBrandTask(Long storId) {
+        Map<String,Object> map = new HashMap<>();
+        map.put("STORE_ID",storId);
+        List<StoreAgentBrandLv> storeAgentBrandLvs = storeAgentBrandLvService.selectByMap(map);
+        List<StoreTaskStatistics> list = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(storeAgentBrandLvs)){
+            for (StoreAgentBrandLv storeAgentBrandLv : storeAgentBrandLvs) {
+                Date date = new Date();
+                DateTime startTime = DateUtil.beginOfQuarter(date);
+                DateTime endTime = DateUtil.endOfQuarter(date);
+                StoreBrandTask storeBrandTask = storeBasicInfoService.storeBrandTask(storeAgentBrandLv.getStoreId(),
+                        storeAgentBrandLv.getBrand(),
+                        startTime, endTime);
+                StoreTaskStatistics storeTaskStatistics = new StoreTaskStatistics();
+                storeTaskStatistics.setBrand(storeAgentBrandLv.getBrand());
+                storeTaskStatistics.setObject(storeBrandTask);
+                list.add(storeTaskStatistics);
+            }
+        }
+        return list;
+    }
+
 
 }

+ 59 - 14
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/java/io/platform/store/service/client/impl/StoreWriteOffCouponServiceClientImpl.java

@@ -3,12 +3,17 @@ package io.platform.store.service.client.impl;
 
 import com.alibaba.dubbo.config.annotation.Service;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 
 import io.platform.base.common.BaseServiceClient;
 import io.platform.base.common.utils.ExecuteResult;
 
+import io.platform.store.biz.entity.StoreAgentBrandLv;
+import io.platform.store.biz.entity.StoreBasicInfo;
 import io.platform.store.biz.entity.StoreWriteOffCoupon;
+import io.platform.store.biz.service.StoreAgentBrandLvService;
+import io.platform.store.biz.service.StoreBasicInfoService;
 import io.platform.store.biz.service.StoreWriteOffCouponService;
 import io.platform.store.dto.StoreWriteOffCouponDto;
 import io.platform.store.service.client.api.StoreWriteOffCouponServiceClient;
@@ -20,6 +25,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -33,6 +39,10 @@ public class StoreWriteOffCouponServiceClientImpl extends BaseServiceClient<Stor
 
     @Resource
     private StoreWriteOffCouponService storeWriteOffCouponService;
+    @Resource
+    private StoreBasicInfoService storeBasicInfoService;
+    @Resource
+    private StoreAgentBrandLvService storeAgentBrandLvService;
 
     @Override
     public StoreWriteOffCouponDto queryObject(Long id) {
@@ -56,20 +66,53 @@ public class StoreWriteOffCouponServiceClientImpl extends BaseServiceClient<Stor
     }
 
     @Override
-    public ExecuteResult<String> save(StoreWriteOffCouponDto storeWriteOffCouponDto) {
-        ExecuteResult<String> result = new ExecuteResult<String>();
-        try{
-            StoreWriteOffCoupon storeWriteOffCoupon = new StoreWriteOffCoupon();
-            revert(storeWriteOffCouponDto,storeWriteOffCoupon);
-            boolean flag = storeWriteOffCouponService.save(storeWriteOffCoupon);
-            if(!flag){
-                result.addErrorMessage("保存失败。");
+    public ExecuteResult<StoreWriteOffCouponDto> save(List<StoreWriteOffCouponDto> storeWriteOffCouponDtoList) {
+        ExecuteResult<StoreWriteOffCouponDto> result = new ExecuteResult<>();
+        if (CollectionUtils.isNotEmpty(storeWriteOffCouponDtoList)){
+            for (StoreWriteOffCouponDto storeWriteOffCouponDto : storeWriteOffCouponDtoList) {
+                try{
+                    //查门店信息
+                    StoreBasicInfo storeBasicInfo = storeBasicInfoService.getById(storeWriteOffCouponDto.getStoreId());
+                    if (null == storeBasicInfo){
+                        result.setErrorMessages("门店不存在");
+                        return result;
+                    }
+                    String amount = String.valueOf(storeWriteOffCouponDto.getAmount());
+                    boolean flag = amount.matches("[0-9]+");
+                    if (!flag) {
+                        result.addErrorMessage("返利金额只能输入数字,不能输入特殊字符");
+                        return result;
+                    }
+                    if (storeWriteOffCouponDto.getAmount().longValue() == 0) {
+                        result.addErrorMessage("返利金额不能为0");
+                        return result;
+                    }
+                    if (storeWriteOffCouponDto.getAmount().longValue() < 0) {
+                        result.addErrorMessage("返利金额不能小于零");
+                        return result;
+                    }
+                    //查门店品牌可用金额
+                    QueryWrapper<StoreAgentBrandLv> queryWrapper = new QueryWrapper<>();
+                    queryWrapper.eq("STORE_ID",storeBasicInfo.getMainId());
+                    queryWrapper.eq("BRAND_CODE",storeWriteOffCouponDto.getBrandCode());
+                    queryWrapper.eq("AGENT_ID",storeWriteOffCouponDto.getKunnr());
+                    StoreAgentBrandLv agentBrandLvServiceOne = storeAgentBrandLvService.getOne(queryWrapper);
+                    if (storeWriteOffCouponDto.getAmount().longValue()<agentBrandLvServiceOne.getUsableMoney().longValue()){
+                        result.addErrorMessage("核销金额超过可用金额");
+                        return result;
+                    }
+                    StoreWriteOffCoupon storeWriteOffCoupon = new StoreWriteOffCoupon();
+                    revert(storeWriteOffCouponDto,storeWriteOffCoupon);
+                    storeWriteOffCoupon = storeWriteOffCouponService.storeCancel(storeWriteOffCoupon,agentBrandLvServiceOne);
+                    convert(storeWriteOffCoupon,storeWriteOffCouponDto);
+                    result.setResult(storeWriteOffCouponDto);
+                }
+                catch (Exception e) {
+                    logger.error(" 保存错误:" + e.toString(), e);
+                    result.addErrorMessage("保存错误:" + e.toString());
+                }
             }
         }
-        catch (Exception e) {
-            logger.error(" 保存错误:" + e.toString(), e);
-            result.addErrorMessage("保存错误:" + e.toString());
-        }
         return result;
     }
 
@@ -127,9 +170,11 @@ public class StoreWriteOffCouponServiceClientImpl extends BaseServiceClient<Stor
     public Page<StoreWriteOffCouponDto> getPage(Page<StoreWriteOffCouponDto> pageDto,StoreWriteOffCouponDto storeWriteOffCouponDto) {
         Page<StoreWriteOffCoupon> page = new Page<>(pageDto.getCurrent(),pageDto.getSize());
 
-        page.setAsc(pageDto.ascs());
+        /*page.setAsc(pageDto.ascs());
         page.setDesc(pageDto.descs());
-        page.condition().putAll(pageDto.condition());
+        page.condition().putAll(pageDto.condition());*/
+        page.setAsc("STATUS");
+        page.setDesc("MAIN_ID");
 
         StoreWriteOffCoupon storeWriteOffCoupon = new StoreWriteOffCoupon();
         revert(storeWriteOffCouponDto,storeWriteOffCoupon);

+ 14 - 2
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/mybatis/store/StoreAgentBrandLvMapper.xml

@@ -17,7 +17,8 @@
     </select>
 
 
-    <select id="getBrandByStoreIdAndBrand" parameterType="object" resultType="io.platform.store.biz.entity.StoreAgentBrandLv">
+    <select id="getBrandByStoreIdAndBrand" parameterType="object"
+            resultType="io.platform.store.biz.entity.StoreAgentBrandLv">
         SELECT
             *
         FROM
@@ -46,8 +47,19 @@
         WHERE
             STORE_ID  = #{storeId}
             AND B2B_STATUS = '1'
+            GROUP BY AGENT_ID
     </select>
-
+    <!--根据门店ID获取门店的总的可用金额,总的冻结金额,总的待核销金额-->
+    <select id="selectStoreMoney" resultType="io.platform.store.biz.entity.StoreBasicInfo">
+    SELECT
+	NVL(SUM( BLOCK_MONEY ), 0) BLOCK_MONEY,
+	NVL(SUM( USABLE_MONEY ), 0) USABLE_MONEY,
+	NVL(SUM( ALL_BLOCK_MONEY ), 0) ALL_BLOCK_MONEY
+FROM
+	APP_STORE_AGENT_BRAND_LV
+WHERE
+	STORE_ID = #{storeId}
+</select>
 
 
 </mapper>

+ 37 - 2
sailun-allsteel-bus-provider/sailun-allsteel-bus-service/src/main/resources/mybatis/store/StoreBasicInfoMapper.xml

@@ -15,7 +15,6 @@
     </select>
 
 
-
     <!-- 门店添加积分 -->
     <update id="updateStoreIntegral" parameterType="object">
         UPDATE APP_STORE_BASIC_INFO
@@ -25,5 +24,41 @@
     </update>
 
 
-
+    <select id="storeBrandTask" resultType="io.platform.store.biz.entity.StoreBrandTask">
+    SELECT
+    asabl.STORE_ID storeId,
+    asabl.STORE_NAME storeName,
+    asabl.AGENT_ID agentId,
+    asabl.AGENT_NAME agentName,
+    asabl.BRAND brand,
+    NVL(asabl.LV_COUNT, 0) lvcount,
+    NVL(asabl.LV_COUNT*3, 0) quarterCount,
+    NVL(asr.MONTH_SCAN, 0) monthScan,
+    NVL(ast.QUARTER_SCAN, 0) quarterScan,
+    nvl(case when nvl(asabl.LV_COUNT,0)-nvl(asr.MONTH_SCAN,0)&gt;=0 then nvl(asabl.LV_COUNT,0)-nvl(asr.MONTH_SCAN,0)
+    when nvl(asabl.LV_COUNT,0)-nvl(asr.MONTH_SCAN,0)&lt;0 then 0 end,0) monthLeftNum,
+    nvl(case when nvl(asabl.LV_COUNT*3,0)-nvl(ast.QUARTER_SCAN,0)&gt;=0 then nvl(asabl.LV_COUNT*3,0)-nvl(ast.QUARTER_SCAN,0)
+    when nvl(asabl.LV_COUNT*3,0)-nvl(ast.QUARTER_SCAN,0)&lt;0 then 0 end,0) quarterLeftNum
+    FROM
+    APP_STORE_AGENT_BRAND_LV asabl
+    LEFT JOIN
+    (
+    SELECT STORE_ID,NVL(COUNT(1), 0) MONTH_SCAN FROM APP_SCAN_RECORD WHERE BRAND = #{brand} AND SCAN_TYPE = 1 AND FLAG_REGULAR = 0  AND trunc(CREATE_TIME)
+    BETWEEN ( trunc( SYSDATE,'mm' ) )
+    AND ( last_day( SYSDATE ) )
+    GROUP BY STORE_ID
+    )asr
+    ON asabl.MAIN_ID = asr.STORE_ID
+    LEFT JOIN
+    (
+    SELECT STORE_ID,NVL(COUNT(1), 0) QUARTER_SCAN FROM APP_SCAN_RECORD WHERE BRAND = #{brand} AND SCAN_TYPE = 1 AND FLAG_REGULAR = 0  AND trunc(CREATE_TIME)
+    BETWEEN #{startTime}
+    AND #{endTime}
+    GROUP BY STORE_ID
+    )ast
+    ON asabl.MAIN_ID = ast.STORE_ID
+    where
+    asabl.STORE_ID = #{storeId}
+    AND asabl.BRAND = #{brand}
+</select>
 </mapper>

+ 22 - 0
sailun-allsteel-common/src/main/java/io/platform/base/dto/SettlementCenteDto.java

@@ -0,0 +1,22 @@
+package io.platform.base.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 结算中心查询返回数据实体
+ */
+@Data
+public class SettlementCenteDto implements Serializable {
+    private static final long serialVersionUID = 5454155825314635342L;
+    /**
+     * 经销商名称
+     */
+    private String agentName;
+    /**
+     * 门店经营品牌及品牌金额信息
+     */
+    private List<Object> list;
+}

+ 21 - 0
sailun-allsteel-common/src/main/java/io/platform/base/dto/StoreTaskStatistics.java

@@ -0,0 +1,21 @@
+package io.platform.base.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 门店查询任务量返回数据实体
+ */
+@Data
+public class StoreTaskStatistics implements Serializable {
+    private static final long serialVersionUID = 5454155825314635342L;
+    /**
+     * 门店品牌
+     */
+    private String brand;
+    /**
+     * 门店品牌任务信息
+     */
+    private Object object;
+}