| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- package com.tzy.app.controller;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.tzy.app.domain.AppActManage;
- import com.tzy.app.dto.GroupDecrAmountDTO;
- import com.tzy.common.constant.Constants;
- import com.tzy.common.dto.InDto;
- import com.tzy.common.dto.OutDTO;
- import com.tzy.common.dto.UserInfo;
- import com.tzy.common.utils.StringUtils;
- import com.tzy.common.utils.UserType;
- import com.tzy.shipping.goods.dto.SkuDTO2;
- import com.tzy.shipping.goods.service.ISkuService;
- import com.tzy.sportcard.group.dto.GroupDecrAmountParam;
- import com.tzy.app.service.GroupDecrAmountService;
- import com.tzy.base.service.SysBaseService;
- import com.tzy.common.annotation.ApiLog;
- import com.tzy.common.core.controller.BaseController;
- import com.tzy.common.core.domain.AjaxResult;
- import com.tzy.common.core.domain.entity.SysUser;
- import com.tzy.common.enums.BusinessType;
- import com.tzy.common.utils.ShiroUtils;
- import io.swagger.annotations.ApiOperation;
- import org.apache.logging.log4j.util.Strings;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import java.util.List;
- import java.util.Objects;
- /**
- * 2024-618砍一刀活动
- * 2025-618砍一刀活动
- */
- @RestController
- @RequestMapping("/decr/amount")
- public class GroupDecrAmountController extends BaseController {
- @Resource
- private GroupDecrAmountService groupDecrAmountService;
- @Resource
- private SysBaseService sysBaseService;
- @Autowired
- private ISkuService skuService;
- @ApiLog(title = "新增砍一刀活动", businessType = BusinessType.INSERT)
- @ApiOperation("新增砍一刀活动")
- @PostMapping("/save")
- public AjaxResult save(@RequestBody AppActManage appActManage){
- return toAjax(groupDecrAmountService.save(appActManage));
- }
- @ApiLog(title = "编辑砍一刀活动", businessType = BusinessType.UPDATE)
- @ApiOperation("编辑砍一刀活动")
- @PostMapping("/edit")
- public AjaxResult edit(@RequestBody AppActManage appActManage){
- return toAjax(groupDecrAmountService.edit(appActManage));
- }
- @ApiLog(title = "上下架砍一刀活动", businessType = BusinessType.UPDATE)
- @ApiOperation("上下架砍一刀活动")
- @PostMapping("/publish")
- public AjaxResult publish(@RequestBody AppActManage appActManage){
- return toAjax(groupDecrAmountService.publish(appActManage));
- }
- @ApiLog(title = "砍一刀活动列表", businessType = BusinessType.SEARCH)
- @ApiOperation("砍一刀活动列表")
- @PostMapping("/page")
- public AjaxResult page(@RequestBody AppActManage appActManage){
- PageInfo<GroupDecrAmountDTO> page = groupDecrAmountService.page(appActManage);
- return AjaxResult.success(page);
- }
- @ApiLog(title = "价格详情", businessType = BusinessType.SEARCH)
- @ApiOperation("价格详情")
- @PostMapping("/detail")
- public AjaxResult getPriceInfo(@RequestBody GroupDecrAmountParam param){
- if(param == null || param.getId() == null){
- return AjaxResult.error("参数为空");
- }
- return AjaxResult.success(groupDecrAmountService.getPriceInfo(param.getId()));
- }
- @ApiLog(title = "同步价格", businessType = BusinessType.UPDATE)
- @ApiOperation("同步价格")
- @PostMapping("/sync")
- public AjaxResult syncPrice(@RequestBody GroupDecrAmountParam param){
- if(param == null || param.getId() == null){
- return AjaxResult.error("参数为空");
- }
- return toAjax(groupDecrAmountService.syncPrice(param.getId()));
- }
- @ApiLog(title = "商家下的拼团", businessType = BusinessType.SEARCH)
- @ApiOperation("商家下的拼团")
- @PostMapping("/groups")
- public AjaxResult selectByMerchantId(@RequestBody GroupDecrAmountParam param) {
- // 取得当前登陆用户的信息
- SysUser user = ShiroUtils.getSysUser();
- if (user == null) {
- return AjaxResult.error("请先登录");
- }
- if (param == null || Strings.isEmpty(param.getGroupInfoCode())) {
- return AjaxResult.error("参数为空");
- }
- // 取得当前登陆用户的信息
- if (user.getMerchantInfo() != null) {
- param.setMerchantId(user.getMerchantInfo().getId());
- }
- return AjaxResult.success(groupDecrAmountService.selectByMerchantId(param));
- }
- @ApiLog(title = "修改绑定拼团商家", businessType = BusinessType.UPDATE)
- @ApiOperation("修改绑定拼团商家")
- @PostMapping("/bind/merchant")
- public AjaxResult bindMerchant(@RequestBody GroupDecrAmountParam param) {
- if (param == null || param.getId() == null) {
- return AjaxResult.error("参数为空");
- }
- return toAjax(groupDecrAmountService.bindMerchant(param));
- }
- //region 2025-618砍一刀活动
- @ApiLog(title = "618活动商品查询", businessType = BusinessType.SEARCH)
- @ResponseBody
- @PostMapping("/goods/act")
- @ApiOperation("618活动商品查询")
- public OutDTO getActGoods(@RequestBody InDto inDto) {
- SkuDTO2 sku = new SkuDTO2();
- String actType = inDto.getString("actType");
- Long merchantId = Long.valueOf(inDto.getString("merchantId"));
- actType = StringUtils.isEmpty(actType) ? "act_goods_sale" : actType;
- sku.setActType(actType);
- sku.setMerchantId(merchantId);
- PageHelper.startPage(inDto.getPageNo(), inDto.getPageSize());
- List<SkuDTO2> list = skuService.selectSkuList2(sku);
- return OutDTO.ok().put("goods",list);
- }
- @ApiLog(title = "砍一刀活动绑定拼团", businessType = BusinessType.UPDATE)
- @ApiOperation("砍一刀活动绑定拼团")
- @PostMapping("/bind")
- public AjaxResult bindGroup(@RequestBody GroupDecrAmountParam param){
- if(param != null && param.getBindType() == null){
- if(param.getId() == null){
- return AjaxResult.error("参数为空");
- }
- return toAjax(groupDecrAmountService.bindGroup(param.getId(), param.getGroupInfoId()));
- } else if (param != null && param.getBindType() != null) {
- switch (param.getBindType()) {
- case Constants.BIND_TYPE_GROUP:
- if (param.getId() == null || param.getBindId() == null) {
- return AjaxResult.error("参数为空");
- }
- return toAjax(groupDecrAmountService.bindActGroup(param.getId(), param.getBindId()));
- case Constants.BIND_TYPE_GOODS:
- if (param.getId() == null || param.getBindId() == null) {
- return AjaxResult.error("参数为空");
- }
- return toAjax(groupDecrAmountService.bindGoods(param.getId(), param.getBindId()));
- case Constants.BIND_TYPE_BIDS:
- if (param.getId() == null || param.getBindId() == null) {
- return AjaxResult.error("参数为空");
- }
- return toAjax(groupDecrAmountService.bindBid(param.getId(), param.getBindId()));
- }
- }
- else{
- return AjaxResult.error("参数为空");
- }
- return AjaxResult.error("参数为空");
- }
- //endregion
- }
|