1
0

GoodsGroupOpenServiceImpl.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package com.kmall.admin.service.impl;
  2. import com.google.common.collect.Maps;
  3. import com.kmall.admin.dao.GoodsGroupOpenDao;
  4. import com.kmall.admin.dao.GoodsGroupOpenDetailDao;
  5. import com.kmall.admin.dao.OrderDao;
  6. import com.kmall.admin.entity.GoodsGroupOpenDetailEntity;
  7. import com.kmall.admin.entity.GoodsGroupOpenEntity;
  8. import com.kmall.admin.entity.OrderEntity;
  9. import com.kmall.admin.service.GoodsGroupOpenService;
  10. import com.kmall.manager.manager.wechat.WechatUtil;
  11. import com.kmall.common.utils.wechat.WechatRefundApiResult;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import org.springframework.transaction.annotation.Transactional;
  15. import java.util.List;
  16. import java.util.Map;
  17. /**
  18. * Service实现类
  19. *
  20. * @author Scott
  21. * @email
  22. * @date 2017-10-23 22:06:59
  23. */
  24. @Service("goodsGroupOpenService")
  25. public class GoodsGroupOpenServiceImpl implements GoodsGroupOpenService {
  26. @Autowired
  27. private GoodsGroupOpenDao goodsGroupOpenDao;
  28. @Autowired
  29. private GoodsGroupOpenDetailDao goodsGroupOpenDetailDao;
  30. @Autowired
  31. private OrderDao orderDao;
  32. @Override
  33. public GoodsGroupOpenEntity queryObject(Long id) {
  34. return goodsGroupOpenDao.queryObject(id);
  35. }
  36. @Override
  37. public List<GoodsGroupOpenEntity> queryList(Map<String, Object> map) {
  38. return goodsGroupOpenDao.queryList(map);
  39. }
  40. @Override
  41. public int queryTotal(Map<String, Object> map) {
  42. return goodsGroupOpenDao.queryTotal(map);
  43. }
  44. @Override
  45. public int save(GoodsGroupOpenEntity goodsGroupOpen) {
  46. return goodsGroupOpenDao.save(goodsGroupOpen);
  47. }
  48. @Override
  49. public int update(GoodsGroupOpenEntity goodsGroupOpen) {
  50. return goodsGroupOpenDao.update(goodsGroupOpen);
  51. }
  52. @Override
  53. public int delete(Long id) {
  54. return goodsGroupOpenDao.delete(id);
  55. }
  56. @Override
  57. @Transactional
  58. public int deleteBatch(Long[] ids) {
  59. return goodsGroupOpenDao.deleteBatch(ids);
  60. }
  61. @Override
  62. @Transactional
  63. public int cancelGroup(Integer id) {
  64. int result = 0;
  65. if (null == id) {
  66. return result;
  67. }
  68. GoodsGroupOpenEntity groupOpenEntity = goodsGroupOpenDao.queryObject(id);
  69. if (null == groupOpenEntity) {
  70. return result;
  71. }
  72. groupOpenEntity.setAttendStatus(3);
  73. goodsGroupOpenDao.update(groupOpenEntity);
  74. // 更新团购明细
  75. Map detailMap = Maps.newHashMap();
  76. detailMap.put("openId", id);
  77. List<GoodsGroupOpenDetailEntity> openDetailEntityList = goodsGroupOpenDetailDao.queryList(detailMap);
  78. /* if (null != openDetailEntityList && openDetailEntityList.size() > 0) {
  79. for (GoodsGroupOpenDetailEntity detailEntity : openDetailEntityList) {
  80. // 参团状态 0待付款 1拼团中 2拼团成功 3拼团失败
  81. if (detailEntity.getAttendStatus() == 0) {
  82. detailEntity.setAttendStatus(3);
  83. goodsGroupOpenDetailDao.update(detailEntity);
  84. OrderEntity orderEntity = orderDao.queryObjectByActivityId(detailEntity.getId(), 2);
  85. if (null == orderEntity) {
  86. continue;
  87. }
  88. orderEntity.setPostscript(orderEntity.getPostscript() + "手动取消团购");
  89. orderEntity.setOrderStatus(101);
  90. orderDao.update(orderEntity);
  91. } else if (detailEntity.getAttendStatus() == 1) {
  92. detailEntity.setAttendStatus(3);
  93. goodsGroupOpenDetailDao.update(detailEntity);
  94. OrderEntity orderEntity = orderDao.queryObjectByActivityId(detailEntity.getId(), 2);
  95. if (null == orderEntity) {
  96. continue;
  97. }
  98. orderEntity.setPostscript(orderEntity.getPostscript() + "手动取消团购");
  99. orderEntity.setOrderStatus(401);
  100. orderDao.update(orderEntity);
  101. // todo 上线修改
  102. // WechatRefundApiResult refundApiResult = WechatUtil.wxRefund(orderEntity.getOrderSn().toString(),
  103. // orderEntity.getActualPrice().doubleValue(), orderEntity.getActualPrice().doubleValue());
  104. WechatRefundApiResult refundApiResult = WechatUtil.wxRefund(orderEntity.getOrderSn().toString(),
  105. 0.01, 0.01);
  106. } else if (detailEntity.getAttendStatus() == 2) {
  107. detailEntity.setAttendStatus(3);
  108. goodsGroupOpenDetailDao.update(detailEntity);
  109. OrderEntity orderEntity = orderDao.queryObjectByActivityId(detailEntity.getId(), 2);
  110. if (null == orderEntity) {
  111. continue;
  112. }
  113. orderEntity.setPostscript(orderEntity.getPostscript() + "手动取消团购");
  114. orderEntity.setOrderStatus(401);
  115. orderDao.update(orderEntity);
  116. // todo 上线修改
  117. // WechatRefundApiResult refundApiResult = WechatUtil.wxRefund(orderEntity.getOrderSn().toString(),
  118. // orderEntity.getActualPrice().doubleValue(), orderEntity.getActualPrice().doubleValue());
  119. WechatRefundApiResult refundApiResult = WechatUtil.wxRefund(orderEntity.getOrderSn().toString(),
  120. 0.01, 0.01);
  121. }
  122. }
  123. }*/
  124. result = 1;
  125. return result;
  126. }
  127. }