123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- package com.txz.mall.controller.appcontroller;
- import cn.hutool.core.bean.BeanUtil;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.txz.mall.business.PinkServiceBusiness;
- import com.txz.mall.core.Result;
- import com.txz.mall.core.ResultCode;
- import com.txz.mall.model.StoreOrder;
- import com.txz.mall.model.StorePink;
- import com.txz.mall.service.StorePinkService;
- import com.txz.mall.web.param.StorePinkParam;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.web.bind.annotation.*;
- import tk.mybatis.mapper.entity.Condition;
- import tk.mybatis.mapper.entity.Example;
- import vo.StorePinkDetailVO;
- import vo.StorePinkOngoingVO;
- import javax.annotation.Resource;
- import java.util.Date;
- import java.util.List;
- /**
- * Created by CodeGenerator on 2025/07/15.
- */
- @Api(tags = "app拼团管理")
- @RestController
- @RequestMapping("/app/pink")
- public class AppPinkController {
- private static Logger log = LoggerFactory.getLogger(AppPinkController.class);
- @Resource
- private StorePinkService storePinkService;
- @Resource
- private PinkServiceBusiness pinkServiceBusiness;
- @PostMapping("/add")
- @ApiOperation(value = "拼团新增")
- public Result add(@RequestBody StorePink storePink) {
- if (storePink == null) {
- return Result.fail(ResultCode.OBJECT_IS_NULL);
- }
- try {
- storePink.setCreateTime(new Date());
- // storePink.setCreateUserId(userId);
- storePinkService.save(storePink);
- } catch (Exception e) {
- log.error("新增对象操作异常e:{}", e);
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return Result.success();
- }
- @DeleteMapping("/delete")
- @ApiOperation(value = "拼团删除")
- public Result delete(@RequestParam Long id) {
- if (id == null) {
- return Result.fail(ResultCode.ID_IS_NULL);
- }
- try {
- StorePink storePink = new StorePink();
- storePink.setId(id);
- storePink.setIsDelete(1);
- storePinkService.update(storePink);
- } catch (Exception e) {
- log.error("删除对象操作异常e:{}", e);
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return Result.success();
- }
- @PutMapping("/update")
- @ApiOperation(value = "拼团更新")
- public Result update(@RequestBody StorePink storePink) {
- if (storePink == null) {
- return Result.fail(ResultCode.OBJECT_IS_NULL);
- }
- if (storePink.getId() == null) {
- return Result.fail(ResultCode.ID_IS_NULL);
- }
- try {
- storePink.setUpdateTime(new Date());
- // storePink.setUpdateUserId(userId);
- storePinkService.update(storePink);
- } catch (Exception e) {
- log.error("更新对象操作异常e:{}", e);
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return Result.success();
- }
- @GetMapping("/detail")
- @ApiOperation(value = "拼团获取详情")
- public Result<StorePink> detail(@RequestParam Long id) {
- if (id == null) {
- return Result.fail(ResultCode.ID_IS_NULL);
- }
- StorePink storePink = null;
- try {
- storePink = storePinkService.findById(id);
- } catch (Exception e) {
- log.error("查询对象操作异常e:{}", e);
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return Result.success(storePink);
- }
- @PostMapping("/list")
- @ApiOperation(value = "拼团获取列表")
- public Result<List<StorePink>> list(@RequestBody StorePinkParam storePink) {
- PageHelper.startPage(storePink.getPage(), storePink.getSize());
- Condition condition = new Condition(StorePink.class);
- Example.Criteria criteria = condition.createCriteria();
- criteria.andEqualTo("isDelete", 0);
- criteria.andEqualTo("orderId", storePink.getOrderId());
- criteria.andEqualTo("id", storePink.getId());
- condition.setOrderByClause("create_time DESC");
- if (storePink.getPid() != null) {
- criteria.andEqualTo("pid", storePink.getPid());
- }
- PageInfo pageInfo = null;
- try {
- List<StorePink> list = storePinkService.findByCondition(condition);
- pageInfo = new PageInfo(list);
- } catch (Exception e) {
- log.error("查询对象操作异常e:{}", e);
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return Result.success(pageInfo);
- }
- @ApiOperation(value = "已存在的拼团列表")
- @PostMapping(value = "/ongoing/list")
- public Result<List<StorePinkOngoingVO>> ongoingList(@RequestBody StorePinkParam storePinkParam) {
- PageHelper.startPage(storePinkParam.getPage(), storePinkParam.getSize());
- StorePink storePink = BeanUtil.toBean(storePinkParam, StorePink.class);
- List<StorePinkOngoingVO> list = storePinkService.ongoingList(storePink);
- PageInfo pageInfo = new PageInfo(list);
- return Result.success(pageInfo);
- }
- /**
- * 拼团订单列表
- */
- @ApiOperation(value = "拼团订单列表")
- @GetMapping(value = "/orderPink")
- public Result<List<StorePinkDetailVO>> getPinkList(@RequestParam("id") Long id) {
- return Result.success(pinkServiceBusiness.getAdminList(id,"app"));
- }
- /**
- * 拼团成功
- */
- @ApiOperation(value = "拼团成功")
- @PostMapping(value = "/pinkSuccess")
- public Result pinkSuccess(@RequestParam("id") Long id) {
- StoreOrder storeOrder = new StoreOrder();
- storePinkService.pinkSuccess(id,storeOrder);
- return Result.success();
- }
- /**
- * 拼团失败
- */
- // @ApiOperation(value = "拼团失败")
- // @PostMapping(value = "/pinkFail")
- // public Result pinkFail() {
- // pinkServiceBusiness.pinkFail();
- // return Result.success();
- // }
- //
- // /**
- // * 天选
- // */
- // @ApiOperation(value = "天选")
- // @PostMapping(value = "/theSelection")
- // public Result theSelection(@RequestParam("id") String orderId) {
- // storePinkService.theSelection(orderId);
- // return Result.success();
- // }
- }
|