瀏覽代碼

新增客户信息,以及修改枚举全国的值

杨六六 4 年之前
父節點
當前提交
4e3ff08774

+ 3 - 1
common/fire-dto/src/main/java/com/fire/dto/CustomerInfo.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Builder;
 import lombok.Data;
 import java.math.BigDecimal;
 
@@ -12,6 +13,7 @@ import java.math.BigDecimal;
 @ApiModel(value = "客户表实体")
 @Data
 @TableName("customer_info")
+@Builder
 public class CustomerInfo {
 
     @ApiModelProperty(value = "客户ID")
@@ -39,7 +41,7 @@ public class CustomerInfo {
     @ApiModelProperty(value = "联系人地址")
     private String address;
 
-    @ApiModelProperty(value = "状态,0:待提交 1:商用2:暂停")
+    @ApiModelProperty(value = "状态, 1:有效2:无效 3:暂停")
     private Integer status;
 
     @ApiModelProperty(value = "帐号余额")

+ 1 - 1
common/fire-dto/src/main/java/com/fire/dto/enums/Province.java

@@ -1,7 +1,7 @@
 package com.fire.dto.enums;
 
 public enum Province {
-    QG_ALL("100", "全国"),
+    QG_ALL("00", "全国"),
     GD_YUE("44", "广东省"),
     HN_YU("41", "河南省"),
     NM_MENG("15", "内蒙古自治区"),

+ 10 - 4
modules/admin/src/main/java/com/fire/admin/rest/CustomerController.java

@@ -3,13 +3,12 @@ package com.fire.admin.rest;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fire.admin.dto.CustomerDto;
 import com.fire.admin.service.CustomerService;
+import com.fire.dto.response.BaseResponse;
 import com.fire.dto.response.BaseRestResponse;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 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.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * @author: liuliu
@@ -32,7 +31,14 @@ public class CustomerController {
     @ApiOperation(value = "客户分页信息")
     @GetMapping("/info")
     public BaseRestResponse getCustomerPageInfo(Page page, CustomerDto customerDto) {
-        return new BaseRestResponse<>(customerService.getcustomerInfoPage(page, customerDto));
+        return new BaseRestResponse<>(customerService.getCustomerInfoPage(page, customerDto));
+    }
+
+    @ApiOperation(value = "客户新增")
+    @PostMapping("/add")
+    public BaseResponse makeAddCustomerInfo(@RequestBody CustomerDto customerDto){
+        customerService.insertCustomer(customerDto);
+        return new BaseResponse();
     }
 
 }

+ 11 - 1
modules/admin/src/main/java/com/fire/admin/service/CustomerService.java

@@ -22,6 +22,16 @@ public interface CustomerService extends IService<CustomerInfo> {
     * @Author: liuliu
     * @Date: 2021/5/20 16:23
     */
-    IPage<CustomerInfoVo> getcustomerInfoPage(Page page, CustomerDto customerDto);
+    IPage<CustomerInfoVo> getCustomerInfoPage(Page page, CustomerDto customerDto);
+    
+    /**
+    * @Description:  TODO 新增客户信息
+    * @Param: [customerDto]
+    * @return: void
+    * @Author: liuliu
+    * @Date: 2021/5/21 15:19
+    */
+    void  insertCustomer(CustomerDto customerDto);
+    
 
 }

+ 46 - 1
modules/admin/src/main/java/com/fire/admin/service/impl/CustomerServiceImpl.java

@@ -6,10 +6,18 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fire.admin.dto.CustomerDto;
 import com.fire.admin.mapper.CustomerMapper;
 import com.fire.admin.service.CustomerService;
+import com.fire.admin.util.SecurityUtil;
 import com.fire.admin.vo.CustomerInfoVo;
 import com.fire.dto.CustomerInfo;
+import com.fire.utils.date.DateUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+import redis.clients.jedis.JedisCluster;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+
+import static com.fire.dto.enums.RedisKey.CUSTOMER_AMOUNT;
 
 /**
  * @author: liuliu
@@ -21,6 +29,9 @@ import org.springframework.stereotype.Service;
 @Service
 public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInfo> implements CustomerService {
 
+    @Resource
+    private JedisCluster jedisCluster;
+
     /**
      * @Description: TODO 分页获取客户信息
      * @Param: 查询条件,根据客户名称模糊查询
@@ -29,7 +40,41 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
      * @Date: 2021/5/20 16:25
      */
     @Override
-    public IPage<CustomerInfoVo> getcustomerInfoPage(Page page, CustomerDto customerDto) {
+    public IPage<CustomerInfoVo> getCustomerInfoPage(Page page, CustomerDto customerDto) {
         return baseMapper.queryCustomerInfoPage(page, customerDto);
     }
+
+
+    /**
+     * @Description: TODO 新增客户信息
+     * @Param: [customerDto]
+     * @return: void
+     * @Author: liuliu
+     * @Date: 2021/5/21 15:14
+     */
+    @Override
+    public void insertCustomer(CustomerDto customerDto) {
+        CustomerInfo customerInfo = CustomerInfo.builder().partnerId(customerDto.getPartnerId())
+                .customerName(customerDto.getCustomerName())
+                .shorterName(customerDto.getShorterName())
+                .linkmanName(customerDto.getLinkmanName())
+                .linkmanMobile(customerDto.getLinkmanMobile())
+                .linkmanEmail(customerDto.getLinkmanEmail())
+                .address(customerDto.getAddress())
+                .status(1)
+                .isFirstLogin(0)
+                .isDeleted(0)
+                // .creator(SecurityUtil.getUser().getUsername())
+                .creator("唐僧")
+                .createTime(DateUtils.strformatDatetime(LocalDateTime.now()))
+                .partnerCommission(customerDto.getPartnerCommission())
+                .userId(customerDto.getUserId())
+                .priceCheck(customerDto.getPriceCheck()).build();
+        baseMapper.insert(customerInfo);
+
+        log.info("新增客户对象为:【{}】", customerInfo.toString());
+
+        jedisCluster.hset(CUSTOMER_AMOUNT.key(), CUSTOMER_AMOUNT.key().concat(customerInfo.getCustomerId().toString()), "0");
+
+    }
 }