AppPinkController.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. package com.txz.mall.controller.appcontroller;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import com.github.pagehelper.PageHelper;
  4. import com.github.pagehelper.PageInfo;
  5. import com.txz.mall.business.PinkServiceBusiness;
  6. import com.txz.mall.core.Result;
  7. import com.txz.mall.core.ResultCode;
  8. import com.txz.mall.model.StoreOrder;
  9. import com.txz.mall.model.StorePink;
  10. import com.txz.mall.service.StorePinkService;
  11. import com.txz.mall.web.param.StorePinkParam;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16. import org.springframework.web.bind.annotation.*;
  17. import tk.mybatis.mapper.entity.Condition;
  18. import tk.mybatis.mapper.entity.Example;
  19. import vo.StorePinkDetailVO;
  20. import vo.StorePinkOngoingVO;
  21. import javax.annotation.Resource;
  22. import java.util.Date;
  23. import java.util.List;
  24. /**
  25. * Created by CodeGenerator on 2025/07/15.
  26. */
  27. @Api(tags = "app拼团管理")
  28. @RestController
  29. @RequestMapping("/app/pink")
  30. public class AppPinkController {
  31. private static Logger log = LoggerFactory.getLogger(AppPinkController.class);
  32. @Resource
  33. private StorePinkService storePinkService;
  34. @Resource
  35. private PinkServiceBusiness pinkServiceBusiness;
  36. @PostMapping("/add")
  37. @ApiOperation(value = "拼团新增")
  38. public Result add(@RequestBody StorePink storePink) {
  39. if (storePink == null) {
  40. return Result.fail(ResultCode.OBJECT_IS_NULL);
  41. }
  42. try {
  43. storePink.setCreateTime(new Date());
  44. // storePink.setCreateUserId(userId);
  45. storePinkService.save(storePink);
  46. } catch (Exception e) {
  47. log.error("新增对象操作异常e:{}", e);
  48. return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
  49. }
  50. return Result.success();
  51. }
  52. @DeleteMapping("/delete")
  53. @ApiOperation(value = "拼团删除")
  54. public Result delete(@RequestParam Long id) {
  55. if (id == null) {
  56. return Result.fail(ResultCode.ID_IS_NULL);
  57. }
  58. try {
  59. StorePink storePink = new StorePink();
  60. storePink.setId(id);
  61. storePink.setIsDelete(1);
  62. storePinkService.update(storePink);
  63. } catch (Exception e) {
  64. log.error("删除对象操作异常e:{}", e);
  65. return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
  66. }
  67. return Result.success();
  68. }
  69. @PutMapping("/update")
  70. @ApiOperation(value = "拼团更新")
  71. public Result update(@RequestBody StorePink storePink) {
  72. if (storePink == null) {
  73. return Result.fail(ResultCode.OBJECT_IS_NULL);
  74. }
  75. if (storePink.getId() == null) {
  76. return Result.fail(ResultCode.ID_IS_NULL);
  77. }
  78. try {
  79. storePink.setUpdateTime(new Date());
  80. // storePink.setUpdateUserId(userId);
  81. storePinkService.update(storePink);
  82. } catch (Exception e) {
  83. log.error("更新对象操作异常e:{}", e);
  84. return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
  85. }
  86. return Result.success();
  87. }
  88. @GetMapping("/detail")
  89. @ApiOperation(value = "拼团获取详情")
  90. public Result<StorePink> detail(@RequestParam Long id) {
  91. if (id == null) {
  92. return Result.fail(ResultCode.ID_IS_NULL);
  93. }
  94. StorePink storePink = null;
  95. try {
  96. storePink = storePinkService.findById(id);
  97. } catch (Exception e) {
  98. log.error("查询对象操作异常e:{}", e);
  99. return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
  100. }
  101. return Result.success(storePink);
  102. }
  103. @PostMapping("/list")
  104. @ApiOperation(value = "拼团获取列表")
  105. public Result<List<StorePink>> list(@RequestBody StorePinkParam storePink) {
  106. PageHelper.startPage(storePink.getPage(), storePink.getSize());
  107. Condition condition = new Condition(StorePink.class);
  108. Example.Criteria criteria = condition.createCriteria();
  109. criteria.andEqualTo("isDelete", 0);
  110. criteria.andEqualTo("orderId", storePink.getOrderId());
  111. criteria.andEqualTo("id", storePink.getId());
  112. condition.setOrderByClause("create_time DESC");
  113. if (storePink.getPid() != null) {
  114. criteria.andEqualTo("pid", storePink.getPid());
  115. }
  116. PageInfo pageInfo = null;
  117. try {
  118. List<StorePink> list = storePinkService.findByCondition(condition);
  119. pageInfo = new PageInfo(list);
  120. } catch (Exception e) {
  121. log.error("查询对象操作异常e:{}", e);
  122. return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
  123. }
  124. return Result.success(pageInfo);
  125. }
  126. @ApiOperation(value = "已存在的拼团列表")
  127. @PostMapping(value = "/ongoing/list")
  128. public Result<List<StorePinkOngoingVO>> ongoingList(@RequestBody StorePinkParam storePinkParam) {
  129. PageHelper.startPage(storePinkParam.getPage(), storePinkParam.getSize());
  130. StorePink storePink = BeanUtil.toBean(storePinkParam, StorePink.class);
  131. List<StorePinkOngoingVO> list = storePinkService.ongoingList(storePink);
  132. PageInfo pageInfo = new PageInfo(list);
  133. return Result.success(pageInfo);
  134. }
  135. /**
  136. * 拼团订单列表
  137. */
  138. @ApiOperation(value = "拼团订单列表")
  139. @GetMapping(value = "/orderPink")
  140. public Result<List<StorePinkDetailVO>> getPinkList(@RequestParam("id") Long id) {
  141. return Result.success(pinkServiceBusiness.getAdminList(id,"app"));
  142. }
  143. /**
  144. * 拼团成功
  145. */
  146. @ApiOperation(value = "拼团成功")
  147. @PostMapping(value = "/pinkSuccess")
  148. public Result pinkSuccess(@RequestParam("id") Long id) {
  149. StoreOrder storeOrder = new StoreOrder();
  150. storePinkService.pinkSuccess(id,storeOrder);
  151. return Result.success();
  152. }
  153. /**
  154. * 拼团失败
  155. */
  156. // @ApiOperation(value = "拼团失败")
  157. // @PostMapping(value = "/pinkFail")
  158. // public Result pinkFail() {
  159. // pinkServiceBusiness.pinkFail();
  160. // return Result.success();
  161. // }
  162. //
  163. // /**
  164. // * 天选
  165. // */
  166. // @ApiOperation(value = "天选")
  167. // @PostMapping(value = "/theSelection")
  168. // public Result theSelection(@RequestParam("id") String orderId) {
  169. // storePinkService.theSelection(orderId);
  170. // return Result.success();
  171. // }
  172. }