瀏覽代碼

二手小程序

zhijiezhao 1 周之前
父節點
當前提交
5a306da03e

+ 25 - 0
src/main/java/com/caimei365/manager/controller/caimei/AreaApi.java

@@ -0,0 +1,25 @@
+package com.caimei365.manager.controller.caimei;
+
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.AddressSelectVo;
+import com.caimei365.manager.service.caimei.AddressService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/area")
+public class AreaApi {
+
+    @Resource
+    private AddressService addressService;
+
+    @GetMapping("/select")
+    public ResponseJson<List<AddressSelectVo>> getSelectAddress() {
+        return addressService.getSelectAddress();
+    }
+
+}

+ 58 - 0
src/main/java/com/caimei365/manager/controller/caimei/user/ShopApi.java

@@ -0,0 +1,58 @@
+package com.caimei365.manager.controller.caimei.user;
+
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmShop;
+import com.caimei365.manager.service.caimei.user.ShopService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ * 供应商管理接口
+ */
+@RestController
+@RequestMapping("/shop")
+public class ShopApi {
+
+
+    @Resource
+    private ShopService shopService;
+
+    /**
+     * 编辑二手小程序区域经理(供应商)
+     *
+     * @param shop
+     * @return
+     */
+    @PostMapping("/add/shop")
+    public ResponseJson addShop(@RequestBody CmShop shop) {
+        return shopService.addShop(shop);
+    }
+
+    @PostMapping("/updateStatus")
+    public ResponseJson updateStatus(@RequestBody CmShop shop) {
+        if (null == shop.getShopId()) {
+            return ResponseJson.error("ID不能为空!");
+        }
+        return shopService.updateStatus(shop);
+    }
+
+    @GetMapping("/form")
+    public ResponseJson shopForm(Integer shopId) {
+        return shopService.shopForm(shopId);
+    }
+
+    @GetMapping("/update/password")
+    public ResponseJson updatePassword(String password, Integer userId) {
+        return shopService.updatePassword(password, userId);
+    }
+
+    @GetMapping("/list")
+    public ResponseJson<PaginationVo<CmShop>> shopList(String shopName, String mobile,
+                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                       @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+        return shopService.shopList(shopName, mobile, pageNum, pageSize);
+    }
+
+}

+ 18 - 0
src/main/java/com/caimei365/manager/dao/AddressMapper.java

@@ -0,0 +1,18 @@
+package com.caimei365.manager.dao;
+
+import com.caimei365.manager.entity.caimei.AddressSelectVo;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface AddressMapper {
+    List<AddressSelectVo> getAllProvinceList();
+
+    List<AddressSelectVo> getCityListByProvinceId(Integer parentId);
+
+    List<AddressSelectVo> getTownListByCityId(Integer parentId);
+
+    List<AddressSelectVo> selectAllAddresses();
+
+}

+ 22 - 0
src/main/java/com/caimei365/manager/dao/user/ShopMapper.java

@@ -0,0 +1,22 @@
+package com.caimei365.manager.dao.user;
+
+import com.caimei365.manager.entity.caimei.CmShop;
+import com.caimei365.manager.entity.caimei.cmUser.User;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+
+@Mapper
+public interface ShopMapper {
+
+    List<CmShop> findShopList(String shopName, String mobile);
+
+    void insertShop(CmShop cmShop);
+
+    void updateUserShopId(User user);
+
+    void updateShop(CmShop shop);
+
+    CmShop getShopForm(Integer shopId);
+}

+ 28 - 0
src/main/java/com/caimei365/manager/entity/caimei/AddressSelectVo.java

@@ -0,0 +1,28 @@
+package com.caimei365.manager.entity.caimei;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+@Data
+public class AddressSelectVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * ID
+     */
+    private Integer id;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 父级ID
+     */
+    private Integer parentId;
+    /**
+     * 子级列表
+     */
+    private List<AddressSelectVo> children;
+}

+ 28 - 36
src/main/java/com/caimei365/manager/entity/caimei/CmShop.java

@@ -1,18 +1,30 @@
 package com.caimei365.manager.entity.caimei;
 
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 
-/**
- * Description
- *
- * @author : Aslee
- * @date : 2021/3/9
- */
-/*@EqualsAndHashCode(callSuper = true)*/
+@Accessors(chain = true)
 @Data
 public class CmShop implements Serializable {
+
+    private String password;
+
+    private boolean flag;
+
+    /**
+     *  供应商类别 0未审核的二手供应商,普通1,新品供应商2,二手供应商3
+     */
+    private Integer shopType;
+    /**
+     * 简介
+     */
+    private String info;
+    /**
+     * 公司LOGO
+     */
+    private String logo;
     /**
      * 用户ID
      */
@@ -33,6 +45,10 @@ public class CmShop implements Serializable {
      * 联系人
      */
     private String linkMan;
+    /**
+     * 主打产品说明
+     */
+    private String productDesc;
     /**
      * 手机号
      */
@@ -61,6 +77,10 @@ public class CmShop implements Serializable {
      * 所在县区Id
      */
     private Integer townId;
+    /**
+     * 省/市/区 拼接字符串 前端展示
+     */
+    private String cityShopForm;
     /**
      * 地址
      */
@@ -72,7 +92,7 @@ public class CmShop implements Serializable {
     /**
      * 营业执照(businessLicenseImage)
      */
-    private String businessLicense;
+    private String businessLicenseImage;
     /**
      * 医疗=1和非医疗=2
      */
@@ -85,26 +105,6 @@ public class CmShop implements Serializable {
      * 主打项目(mainpro)
      */
     private String mainProduct;
-    /**
-     * 主打系列商品说明
-     */
-    private String mainProductDesc;
-    /**
-     * 公司介绍
-     */
-    private String shopDesc;
-    /**
-     * 官网地址
-     */
-    private String website;
-    /**
-     * 微信公众号
-     */
-    private String wxOfficialAccount;
-    /**
-     * 微信小程序
-     */
-    private String wxApplets;
     /**
      * 添加时间
      */
@@ -113,16 +113,8 @@ public class CmShop implements Serializable {
      * 供应商状态: 90:已上线,91:已下线,92:审核不通过,3:待审核
      */
     private Integer status;
-    /**
-     * 是否可用,1可用
-     */
-    private String validFlag;
     /**
      * 如选择为医疗>>三类器械  则必须要上传资质
      */
     private String medicalPracticeLicenseImg1;
-    /**
-     * 是否支持选择
-     */
-    private Boolean flag;
 }

+ 3 - 10
src/main/java/com/caimei365/manager/entity/caimei/cmUser/User.java

@@ -1,18 +1,11 @@
 package com.caimei365.manager.entity.caimei.cmUser;
 
-import java.math.BigDecimal;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
-import java.io.Serializable;
-
 import lombok.Data;
 import lombok.experimental.Accessors;
 import org.apache.ibatis.type.Alias;
-import com.fasterxml.jackson.annotation.JsonFormat;
 
-import java.util.Date;
+import java.io.Serializable;
+import java.math.BigDecimal;
 
 /**
  * 用户信息对象 user
@@ -77,7 +70,7 @@ public class User implements Serializable {
     private String realName;
 
     /**
-     * 注册来源: 0网站 1小程序
+     * 注册来源: 0网站 1小程序 3后台
      */
     private String source;
 

+ 11 - 0
src/main/java/com/caimei365/manager/service/caimei/AddressService.java

@@ -0,0 +1,11 @@
+package com.caimei365.manager.service.caimei;
+
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.AddressSelectVo;
+
+import java.util.List;
+
+public interface AddressService {
+
+    ResponseJson<List<AddressSelectVo>> getSelectAddress();
+}

+ 27 - 0
src/main/java/com/caimei365/manager/service/caimei/impl/AddressServiceImpl.java

@@ -0,0 +1,27 @@
+package com.caimei365.manager.service.caimei.impl;
+
+import com.caimei365.manager.dao.AddressMapper;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.AddressSelectVo;
+import com.caimei365.manager.service.caimei.AddressService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+@Slf4j
+public class AddressServiceImpl implements AddressService {
+
+    @Resource
+    private AddressMapper addressMapper;
+
+
+    @Override
+    public ResponseJson<List<AddressSelectVo>> getSelectAddress() {
+        // 获取所有省份列表
+        List<AddressSelectVo> provinceList = addressMapper.selectAllAddresses();
+        return ResponseJson.success(provinceList);
+    }
+}

+ 18 - 0
src/main/java/com/caimei365/manager/service/caimei/user/ShopService.java

@@ -0,0 +1,18 @@
+package com.caimei365.manager.service.caimei.user;
+
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmShop;
+
+public interface ShopService {
+
+    ResponseJson addShop(CmShop shop);
+
+    ResponseJson<PaginationVo<CmShop>> shopList(String shopName, String mobile, int pageNum, int pageSize);
+
+    ResponseJson shopForm(Integer shopId);
+
+    ResponseJson updatePassword(String password, Integer userId);
+
+    ResponseJson updateStatus(CmShop shop);
+}

+ 81 - 0
src/main/java/com/caimei365/manager/service/caimei/user/impl/ShopServiceImpl.java

@@ -0,0 +1,81 @@
+package com.caimei365.manager.service.caimei.user.impl;
+
+import com.caimei365.manager.dao.user.ShopMapper;
+import com.caimei365.manager.dao.user.UserMapper;
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.caimei.CmShop;
+import com.caimei365.manager.entity.caimei.cmUser.User;
+import com.caimei365.manager.service.caimei.user.ShopService;
+import com.caimei365.manager.utils.Md5Util;
+import com.github.pagehelper.PageHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+@Slf4j
+public class ShopServiceImpl implements ShopService {
+
+    @Resource
+    private ShopMapper shopMapper;
+    @Resource
+    private UserMapper userMapper;
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public ResponseJson addShop(CmShop shop) {
+        if (null == shop.getShopId()) {
+            //新增
+            User user = new User();
+            user.setUserOrganizeID(5).setUserIdentity(3).setUserName(shop.getShortName()).setRealName(shop.getLinkMan()).setName(shop.getName())
+                    .setManufacturerStatus(90).setSource("3").setRegisterUserTypeID("1").setPassword(Md5Util.md5(shop.getPassword())).setBindMobile(shop.getContractMobile());
+            userMapper.addUser(user);
+            shop.setShopType(2).setStatus(90).setUserId(Integer.valueOf(user.getUserID()));
+            shopMapper.insertShop(shop);
+            user.setShopID(shop.getShopId());
+            shopMapper.updateUserShopId(user);
+        } else {
+            User user = new User();
+            user.setUserID(shop.getUserId().toString()).setUserOrganizeID(5).setUserIdentity(3).setUserName(shop.getShortName()).setBindMobile(shop.getContractMobile())
+                    .setRealName(shop.getLinkMan()).setName(shop.getName()).setManufacturerStatus(shop.getStatus()).setSource("3").setRegisterUserTypeID("1");
+            userMapper.updateUser(user);
+            shopMapper.updateShop(shop);
+        }
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson<PaginationVo<CmShop>> shopList(String shopName, String mobile, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<CmShop> shops = shopMapper.findShopList(shopName, mobile);
+        PaginationVo<CmShop> pageList = new PaginationVo<>(shops);
+        return ResponseJson.success(pageList);
+    }
+
+
+    @Override
+    public ResponseJson shopForm(Integer shopId) {
+        return ResponseJson.success(shopMapper.getShopForm(shopId));
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public ResponseJson updatePassword(String password, Integer userId) {
+        userMapper.updateUser(new User().setUserID(userId.toString()).setPassword(Md5Util.md5(password)));
+        return ResponseJson.success();
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public ResponseJson updateStatus(CmShop shop) {
+        shopMapper.updateShop(shop);
+        userMapper.updateUser(new User().setUserID(shop.getUserId().toString()).setManufacturerStatus(shop.getStatus()));
+        return ResponseJson.success();
+    }
+
+
+}

+ 55 - 0
src/main/resources/mapper/AddressMapper.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.caimei365.manager.dao.AddressMapper">
+
+    <select id="getAllProvinceList" resultType="com.caimei365.manager.entity.caimei.AddressSelectVo">
+        SELECT provinceID AS id, name
+        FROM province
+        WHERE validFlag = '1'
+    </select>
+
+    <select id="getCityListByProvinceId" resultType="com.caimei365.manager.entity.caimei.AddressSelectVo">
+        SELECT provinceID AS parentId, cityID AS id, name
+        FROM city
+        WHERE provinceID = #{provinceId}
+          AND validFlag = '1'
+    </select>
+
+    <select id="getTownListByCityId" resultType="com.caimei365.manager.entity.caimei.AddressSelectVo">
+        SELECT cityID AS parentId, townID AS id, name
+        FROM town
+        WHERE cityID = #{cityId}
+          AND validFlag = '1'
+    </select>
+
+    <resultMap id="ProvinceResultMap" type="com.caimei365.manager.entity.caimei.AddressSelectVo">
+        <id property="id" column="provinceID"/>
+        <result property="name" column="name"/>
+        <collection property="children" ofType="com.caimei365.manager.entity.caimei.AddressSelectVo" resultMap="CityResultMap"/>
+    </resultMap>
+
+    <resultMap id="CityResultMap" type="com.caimei365.manager.entity.caimei.AddressSelectVo">
+        <id property="id" column="cityID"/>
+        <result property="name" column="name"/>
+        <result property="parentId" column="provinceID"/>
+        <collection property="children" ofType="com.caimei365.manager.entity.caimei.AddressSelectVo" resultMap="TownResultMap"/>
+    </resultMap>
+
+    <resultMap id="TownResultMap" type="com.caimei365.manager.entity.caimei.AddressSelectVo">
+        <id property="id" column="townID"/>
+        <result property="parentId" column="cityID"/>
+        <result property="name" column="name"/>
+    </resultMap>
+
+    <select id="selectAllAddresses" resultMap="ProvinceResultMap">
+        SELECT p.provinceId,
+               p.name AS provinceName,
+               c.cityId,
+               c.name AS cityName,
+               t.townId,
+               t.name AS townName
+        FROM province p
+        LEFT JOIN city c ON p.provinceId = c.provinceId
+        LEFT JOIN town t ON c.cityId = t.cityId
+    </select>
+</mapper>

+ 186 - 0
src/main/resources/mapper/user/ShopMapper.xml

@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.caimei365.manager.dao.user.ShopMapper">
+
+    <insert id="insertShop"  parameterType="com.caimei365.manager.entity.caimei.CmShop" useGeneratedKeys="true" keyProperty="shopId">
+        INSERT INTO shop(userId,
+                         name,
+                         sname,
+                         logo,
+                         businessLicenseImage,
+                         provinceID,
+                         cityID,
+                         townID,
+                         address,
+                         linkMan,
+                         contractMobile,
+                         info,
+                         productDesc,
+                         addTime,
+                         status,
+                         firstShopType,
+                         secondShopType,
+                         medicalPracticeLicenseImg1,
+                         mainpro,
+                         socialCreditCode,
+                         shopType)
+        VALUES (#{userId},
+                #{name},
+                #{shortName},
+                #{logo},
+                #{businessLicenseImage},
+                #{provinceId},
+                #{cityId},
+                #{townId},
+                #{address},
+                #{linkMan},
+                #{contractMobile},
+                #{info},
+                #{productDesc},
+                now(),
+                #{status},
+                #{firstShopType},
+                #{secondShopType},
+                #{medicalPracticeLicenseImg1},
+                #{mainProduct},
+                #{socialCreditCode},
+                #{shopType})
+    </insert>
+
+    <update id="updateUserShopId">
+        update user set shopID = #{shopID}
+    </update>
+
+    <update id="updateShop">
+        UPDATE shop
+        <set>
+            <if test="name != null and name != ''">
+                name = #{name},
+            </if>
+            <if test="shortName != null and shortName != ''">
+                sname = #{shortName},
+            </if>
+            <if test="logo != null and logo != ''">
+                logo = #{logo},
+            </if>
+            <if test="businessLicenseImage != null and businessLicenseImage != ''">
+                businessLicenseImage = #{businessLicenseImage},
+            </if>
+            <if test="address != null and address != ''">
+                address = #{address},
+            </if>
+            <if test="linkMan != null and linkMan != ''">
+                linkMan = #{linkMan},
+            </if>
+            <if test="contractMobile != null and contractMobile != ''">
+                contractMobile = #{contractMobile},
+            </if>
+            <if test="info != null and info != ''">
+                info = #{info},
+            </if>
+            <if test="productDesc != null and productDesc != ''">
+                productDesc = #{productDesc},
+            </if>
+            <if test="status != null and status != ''">
+                status = #{status},
+            </if>
+            <if test="provinceId != null and provinceId != ''">
+                provinceID = #{provinceId},
+            </if>
+            <if test="cityId != null and cityId != ''">
+                cityID = #{cityId},
+            </if>
+            <if test="townId != null and townId != ''">
+                townID = #{townId},
+            </if>
+            <if test="firstShopType != null and firstShopType != ''">
+                firstShopType=#{firstShopType},
+            </if>
+            <if test="secondShopType != null and secondShopType != ''">
+                secondShopType=#{secondShopType},
+            </if>
+            <if test="medicalPracticeLicenseImg1 != null and medicalPracticeLicenseImg1 != ''">
+                medicalPracticeLicenseImg1=#{medicalPracticeLicenseImg1},
+            </if>
+            <if test="mainProduct != null and mainProduct != ''">
+                mainpro = #{mainProduct},
+            </if>
+            <if test="socialCreditCode != null">
+                socialCreditCode = #{socialCreditCode}
+            </if>
+        </set>
+        WHERE shopID = #{shopId}
+    </update>
+
+
+    <select id="findShopList" resultType="com.caimei365.manager.entity.caimei.CmShop">
+        SELECT
+        a.shopID AS "shopId",
+        a.userID AS "userId",
+        a.name AS "name",
+        a.sname AS "shortName",
+        a.logo AS "logo",
+        a.businessLicenseImage AS "businessLicenseImage",
+        a.townID AS "townId",
+        d.provinceID AS "provinceId",
+        c.cityID AS "cityId",
+        a.address AS "address",
+        a.linkMan AS "linkMan",
+        a.contractMobile AS "contractMobile",
+        a.info AS "info",
+        a.addTime AS "addTime",
+        a.status AS "status",
+        a.firstShopType AS "firstShopType",
+        a.secondShopType AS "secondShopType",
+        a.socialCreditCode AS "socialCreditCode",
+        a.shopType AS "shopType"
+        FROM shop a
+        LEFT JOIN user u ON u.userID = a.userID
+        LEFT JOIN town b ON b.townID=a.townID
+        LEFT JOIN city c ON c.cityID=b.cityID
+        LEFT JOIN province d ON d.provinceID=c.provinceID
+        <where>
+            u.userOrganizeID = 5
+            <if test="shopName != null and shopName != ''">
+                AND a.name LIKE concat('%',#{shopName},'%')
+            </if>
+            <if test="mobile != null and mobile != ''">
+                AND a.contractMobile = #{mobile}
+            </if>
+        </where>
+        ORDER BY case when a.status = 91 then 0 else 1 end desc, a.shopID DESC
+    </select>
+
+    <select id="getShopForm" resultType="com.caimei365.manager.entity.caimei.CmShop">
+        SELECT
+            a.shopID AS "shopId",
+            a.userID AS "userId",
+            a.name AS "name",
+            a.sname AS "shortName",
+            a.logo AS "logo",
+            a.businessLicenseImage AS "businessLicenseImage",
+            a.townID AS "townId",
+            d.provinceID AS "provinceId",
+            c.cityID AS "cityId",
+            a.address AS "address",
+            a.linkMan AS "linkMan",
+            a.contractMobile AS "contractMobile",
+            a.info AS "info",
+            a.addTime AS "addTime",
+            a.status AS "status",
+            a.firstShopType AS "firstShopType",
+            a.secondShopType AS "secondShopType",
+            a.socialCreditCode AS "socialCreditCode",
+            a.shopType AS "shopType",
+            u.password as "password",
+            a.medicalPracticeLicenseImg1,
+            concat(d.name,'/',c.name,'/',b.name) as cityShopForm
+        FROM shop a
+        LEFT JOIN user u ON u.userID = a.userID
+        LEFT JOIN town b ON b.townID=a.townID
+        LEFT JOIN city c ON c.cityID=b.cityID
+        LEFT JOIN province d ON d.provinceID=c.provinceID
+        where a.shopId = #{shopId}
+    </select>
+
+</mapper>