package com.sinata.shop.modular.mall.controller;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.sinata.common.enums.EnumIsDelete;
|
import com.sinata.common.enums.EnumMerchantState;
|
import com.sinata.core.base.controller.BaseController;
|
import com.sinata.shop.core.common.annotion.BussinessLog;
|
import com.sinata.shop.core.common.annotion.Permission;
|
import com.sinata.shop.core.common.constant.factory.PageFactory;
|
import com.sinata.shop.core.log.LogObjectHolder;
|
import com.sinata.shop.core.shiro.ShiroKit;
|
import com.sinata.shop.modular.mall.model.AreaCity;
|
import com.sinata.shop.modular.mall.model.MemMerchant;
|
import com.sinata.shop.modular.mall.model.StoreService;
|
import com.sinata.shop.modular.mall.service.*;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.util.StringUtils;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 门店信息控制器
|
*
|
* @author goku
|
*/
|
@Controller
|
@RequestMapping("/memMerchant")
|
public class MemMerchantController extends BaseController {
|
|
private String PREFIX = "/mall/memMerchant/";
|
|
@Autowired
|
private IMemMerchantService memMerchantService;
|
|
@Resource
|
private IMallGoodsSkuService mallGoodsSkuService;
|
@Resource
|
private IStoreServiceService storeServiceService;
|
@Resource
|
private IAreaCityService areaCityService;
|
|
/**
|
* 获取门店信息
|
*/
|
@RequestMapping("")
|
public String getMerchant(Model model) {
|
Integer userId = ShiroKit.getUserId();
|
Wrapper wrapper = new EntityWrapper<StoreService>().orderBy("id", false);
|
wrapper.eq("status",1);
|
wrapper.eq("is_delete", EnumIsDelete.EXISTED.index);
|
model.addAttribute("serviceList",storeServiceService.selectList(wrapper));
|
MemMerchant memMerchant = memMerchantService.selectById(userId);
|
model.addAttribute("item",memMerchant);
|
Wrapper wrapper2 = new EntityWrapper<AreaCity>().orderBy("id", false);
|
wrapper2.eq("is_open",1);
|
wrapper2.eq("is_delete", EnumIsDelete.EXISTED.index);
|
model.addAttribute("cityAreaList",areaCityService.selectList(wrapper2));
|
model.addAttribute("merchantGoodsList",mallGoodsSkuService.queryMerchantGoodsList(memMerchant.getId()));
|
LogObjectHolder.me().set(memMerchant);
|
return PREFIX + "memMerchant.html";
|
}
|
|
|
@ResponseBody
|
@BussinessLog("升级门店")
|
@RequestMapping(value = "/upgradeMerchant")
|
public Object upgradeMerchant(Integer gradeId) {
|
Integer merchantId = ShiroKit.getUserId();
|
this.memMerchantService.upgradeMerchant(merchantId, gradeId);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 跳转到添加门店信息
|
*/
|
@RequestMapping("/memMerchant_add")
|
public String memMerchantAdd() {
|
return PREFIX + "memMerchant_add.html";
|
}
|
|
/**
|
* 跳转到修改门店信息
|
*/
|
@RequestMapping("/memMerchant_update/{memMerchantId}")
|
public String memMerchantUpdate(@PathVariable Integer memMerchantId, Model model) {
|
MemMerchant memMerchant = memMerchantService.selectById(memMerchantId);
|
model.addAttribute("item", memMerchant);
|
LogObjectHolder.me().set(memMerchant);
|
return PREFIX + "memMerchant_edit.html";
|
}
|
|
/**
|
* 获取门店信息列表
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/list")
|
public Object list(String beginTime, String endTime, String condition) {
|
Page<Map<String, Object>> page = new PageFactory().defaultPage();
|
Wrapper wrapper = new EntityWrapper<MemMerchant>().orderBy("id", false);
|
|
// 时间搜索
|
if (!StringUtils.isEmpty(beginTime)) {
|
wrapper.ge("create_time", beginTime + " 00:00:00");
|
}
|
if (!StringUtils.isEmpty(endTime)) {
|
wrapper.le("create_time", endTime + " 23:59:59");
|
}
|
|
// 查询数据列表
|
List<Map<String, Object>> list = memMerchantService.selectMapsPage(page, wrapper).getRecords();
|
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
/**
|
* 新增门店信息
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "新增门店信息")
|
@RequestMapping(value = "/add")
|
public Object add(MemMerchant memMerchant) {
|
memMerchantService.insert(memMerchant);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除/批量删除
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "删除/批量删除门店信息")
|
@RequestMapping(value = "/delete")
|
public Object delete(@RequestParam String ids) {
|
// 逻辑删除
|
memMerchantService.updateForSet("is_delete = 1", new EntityWrapper<MemMerchant>().in("id", ids.split(",")));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改门店信息
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "修改门店信息")
|
@RequestMapping(value = "/update")
|
public Object update(MemMerchant memMerchant) {
|
memMerchantService.updateById(memMerchant);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改门店信息状态
|
*/
|
@ResponseBody
|
@BussinessLog(value = "修改门店信息状态")
|
@RequestMapping(value = "/updateState")
|
public Object updateState(Integer memMerchantId, Integer state) {
|
memMerchantService.updateForSet("state = " + state, new EntityWrapper<MemMerchant>().eq("id", memMerchantId));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改门店信息状态
|
*/
|
@ResponseBody
|
@BussinessLog(value = "修改门店头部头像")
|
@RequestMapping(value = "/updateMerchantHeadPicture")
|
public Object updateMerchantAvatar(@RequestParam String headPicture) {
|
Integer merchantId = ShiroKit.getUserId();
|
memMerchantService.updateForSet("head_picture = '" + headPicture + "'", new EntityWrapper<MemMerchant>().eq("id", merchantId));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改门店信息状态
|
*/
|
@ResponseBody
|
@BussinessLog(value = "修改门店logo")
|
@RequestMapping(value = "/updateMerchantLogo")
|
public Object updateMerchantLogo(@RequestParam String logo) {
|
Integer merchantId = ShiroKit.getUserId();
|
memMerchantService.updateForSet("logo = '" + logo + "'", new EntityWrapper<MemMerchant>().eq("id", merchantId));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 跳转门店信息详情
|
*/
|
@RequestMapping(value = "/detail/{memMerchantId}")
|
public Object detail(@PathVariable("memMerchantId") Integer memMerchantId, Model model) {
|
MemMerchant memMerchant = memMerchantService.selectById(memMerchantId);
|
model.addAttribute("item", memMerchant);
|
return PREFIX + "memMerchant_detail.html";
|
}
|
|
/**
|
* @Title: changeMerchantUpload
|
* @Description: 判断当前门店是否能够上传商品
|
* @author guohongjin
|
* @date 2023-03-06
|
*/
|
@RequestMapping("changeMerchantUpload")
|
@ResponseBody
|
public Object changeMerchantUpload(){
|
Integer merchantId = ShiroKit.getUserId();
|
MemMerchant memMerchant = this.memMerchantService.selectById(merchantId);
|
if (memMerchant != null){
|
if (memMerchant.getState().intValue() == EnumMerchantState.CMS_LOGOFF.index || memMerchant.getState().intValue() == EnumMerchantState.LOCKED.index){
|
return true;
|
}
|
}
|
return false;
|
}
|
}
|