From 2da268ea776a346f04a9a19de15f51e87b3f6770 Mon Sep 17 00:00:00 2001
From: lidongdong <1459917685@qq.com>
Date: 星期三, 22 十一月 2023 15:44:58 +0800
Subject: [PATCH] 修改路北社区定时任务
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/VolunteerCreditsExchangeServiceImpl.java | 226 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 182 insertions(+), 44 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/VolunteerCreditsExchangeServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/VolunteerCreditsExchangeServiceImpl.java
index 2bd3c70..56ee325 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/VolunteerCreditsExchangeServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/VolunteerCreditsExchangeServiceImpl.java
@@ -6,19 +6,19 @@
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.VolunteerCreditsExchangeVO;
import com.panzhihua.common.model.vos.community.VolunteerIntegralMerchantVO;
-import com.panzhihua.common.model.vos.community.VolunteerTypeVO;
+import com.panzhihua.common.model.vos.community.VolunteerIntegralRecordVO;
+import com.panzhihua.common.model.vos.community.VolunteerMerchantVO;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.utlis.Snowflake;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.dao.VolunteerCreditsExchangeDao;
-import com.panzhihua.service_community.dao.VolunteerTypeDao;
-import com.panzhihua.service_community.entity.VolunteerActivity;
import com.panzhihua.service_community.entity.VolunteerCreditsExchange;
import com.panzhihua.service_community.entity.VolunteerIntegralMerchant;
-import com.panzhihua.service_community.entity.VolunteerType;
+import com.panzhihua.service_community.entity.VolunteerMerchant;
import com.panzhihua.service_community.service.VolunteerCreditsExchangeService;
import com.panzhihua.service_community.service.VolunteerIntegralMerchantService;
-import com.panzhihua.service_community.service.VolunteerTypeService;
+import com.panzhihua.service_community.service.VolunteerIntegralRecordService;
+import com.panzhihua.service_community.service.VolunteerMerchantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -36,14 +36,21 @@
@Resource
private UserService userService;
+ @Resource
+ private VolunteerIntegralRecordService virService;
+
+ @Resource
+ private VolunteerMerchantService vmService;
+
+
@Override
public R getList(int pageNum, int pageSize, String goodsId, String orderNumber,
String goodsName, String condition, String userName,String communityId,
- String userId,String orderType) {
+ String userId,String orderType,String merchantId) {
Page page=new Page<VolunteerCreditsExchange>(pageNum,pageSize);
return R.ok(baseMapper.getList(page,goodsId,orderNumber,goodsName,condition,
- userName,communityId,userId,orderType));
+ userName,communityId,userId,orderType,merchantId));
}
@Override
@@ -65,33 +72,13 @@
}
VolunteerIntegralMerchant goods=goodsService.queryById(item.getGoodsId());
+
+ LoginUserInfoVO loginUserInfoVOR=userService.getUserInfoByUserId(item.getUserId()).getData();
+
if(goods==null)
{
return R.fail("商品不存在");
}
-
- if(StringUtils.isEmpty(goods.getGoodNum()))
- {
- return R.fail("商品库存不足");
- }
- else
- {
- int goodNum=Integer.valueOf(goods.getGoodNum());
- if(goodNum<=0)
- {
- return R.fail("商品库存不足");
- }
-
- goodNum--;
-
- VolunteerIntegralMerchantVO vo=new VolunteerIntegralMerchantVO();
- vo.setId(goods.getId());
- vo.setGoodNum(goodNum+"");
- goodsService.updateById(vo);
- }
-
-
- LoginUserInfoVO loginUserInfoVOR=userService.getUserInfoByUserId(item.getUserId()).getData();
int integral=0;
if(!StringUtils.isEmpty(loginUserInfoVOR.getLoveIntegral()))
@@ -111,9 +98,41 @@
return R.fail("兑换用户id不能为空");
}
+// if(StringUtils.isEmpty(goods.getGoodNum()))
+// {
+// return R.fail("商品库存不足");
+// }
+// else
+// {
+// int goodNum=Integer.valueOf(goods.getGoodNum());
+// if(goodNum<=0)
+// {
+// return R.fail("商品库存不足");
+// }
+//
+// goodNum--;
+//
+// VolunteerIntegralMerchantVO vo=new VolunteerIntegralMerchantVO();
+// vo.setId(goods.getId());
+// vo.setGoodNum(goodNum+"");
+// goodsService.updateById(vo);
+// }
+
int num1=integral-Integer.valueOf(goods.getIntegral());
loginUserInfoVOR.setLoveIntegral(num1+"");
userService.putUser(loginUserInfoVOR);
+
+ item.setPalyIntegral(goods.getIntegral());
+
+
+ //增加积分明细记录
+ VolunteerIntegralRecordVO virvo=new VolunteerIntegralRecordVO();
+ virvo.setUserId(loginUserInfoVOR.getUserId()+"");
+ virvo.setIType("2");
+ virvo.setIntegral(item.getPalyIntegral());
+ virvo.setCommunityId(item.getCommunityId());
+ virService.insertVolunteer(virvo);
+
//设置订单号
item.setOrderNumber(Snowflake.getId()+"");
@@ -126,6 +145,84 @@
}
@Override
+ public R insertMerchantData(VolunteerCreditsExchangeVO item)
+ {
+ if (item==null)
+ {
+ return R.fail("参数不能为空");
+ }
+
+ if(StringUtils.isEmpty(item.getMerchantId()))
+ {
+ return R.fail("商家id不能为空");
+ }
+
+ LoginUserInfoVO loginUserInfoVOR=userService.getUserInfoByUserId(item.getUserId()).getData();
+
+ if(StringUtils.isEmpty(item.getPalyIntegral()))
+ {
+ return R.fail("支付积分不能为空");
+ }
+
+ int integral=0;
+ if(!StringUtils.isEmpty(loginUserInfoVOR.getLoveIntegral()))
+ {
+ integral=Integer.valueOf(loginUserInfoVOR.getLoveIntegral());
+ }
+
+ if(integral<Integer.valueOf(item.getPalyIntegral()))
+ {
+ return R.fail("剩余积分不足!无法支付");
+ }
+
+ if(StringUtils.isEmpty(item.getUserId()))
+ {
+ return R.fail("兑换用户id不能为空");
+ }
+
+ //增加积分明细记录
+ VolunteerIntegralRecordVO virvo=new VolunteerIntegralRecordVO();
+ virvo.setUserId(loginUserInfoVOR.getUserId()+"");
+ virvo.setIType("3");
+ virvo.setIntegral(item.getPalyIntegral());
+ virvo.setCommunityId(item.getCommunityId());
+ virService.insertVolunteer(virvo);
+
+ //修改个人积分
+ int num1=integral-Integer.valueOf(item.getPalyIntegral());
+ loginUserInfoVOR.setLoveIntegral(num1+"");
+ userService.putUser(loginUserInfoVOR);
+
+
+ //修改商家积分
+ R<VolunteerMerchant> vm= vmService.getById(item.getMerchantId());
+
+ int vmNum=0;
+ if(!StringUtils.isEmpty(vm.getData().getMerchantIntegral()))
+ {
+ vmNum=Integer.valueOf(vm.getData().getMerchantIntegral());
+ }
+
+ vmNum+=Integer.valueOf(item.getPalyIntegral());
+
+ VolunteerMerchantVO vmvo=new VolunteerMerchantVO();
+ vmvo.setId(item.getMerchantId());
+ vmvo.setMerchantIntegral(vmNum+"");
+ vmService.updateVolunteerMerchant(vmvo);
+
+ item.setCondition("3");
+ //设置订单号
+ String orderNum=Snowflake.getId()+"";
+ item.setOrderNumber(orderNum);
+ int num= baseMapper.insertData(item);
+ if(num>0)
+ {
+ return R.ok(orderNum);
+ }
+ return R.fail("操作失败");
+ }
+
+ @Override
public R update(VolunteerCreditsExchangeVO item)
{
if (item==null)
@@ -133,20 +230,6 @@
return R.fail("参数不能为空");
}
- if(StringUtils.isEmpty(item.getGoodsId()))
- {
- return R.fail("商品id不能为空");
- }
-
- if(StringUtils.isEmpty(item.getNeedScore()))
- {
- return R.fail("所需积分不能为空");
- }
-
- if(StringUtils.isEmpty(item.getUserId()))
- {
- return R.fail("兑换用户id不能为空");
- }
int num= baseMapper.update(item);
if(num>0)
{
@@ -186,4 +269,59 @@
}
return R.fail("操作失败");
}
+
+ /**
+ * 社区订单取消
+ * @param id 订单iD
+ * @return
+ */
+ @Override
+ public R communityCancellation(String id)
+ {
+ if(StringUtils.isEmpty(id))
+ {
+ return R.fail("订单id不能为空");
+ }
+ //查询订单
+ VolunteerCreditsExchange vce=baseMapper.getData(id);
+ if(StringUtils.equals("0",vce.getCondition()))
+ {
+ //修改订单状态为取消
+ VolunteerCreditsExchangeVO volunteerCreditsExchangeVO=new VolunteerCreditsExchangeVO();
+ volunteerCreditsExchangeVO.setId(id);
+ volunteerCreditsExchangeVO.setCondition("2");
+ baseMapper.update(volunteerCreditsExchangeVO);
+
+ //查询用户详情
+ LoginUserInfoVO loginUserInfoVOR=userService.getUserInfoByUserId(vce.getUserId()).getData();
+ int integral=0;
+ if(!StringUtils.isEmpty(loginUserInfoVOR.getLoveIntegral()))
+ {
+ integral=Integer.valueOf(loginUserInfoVOR.getLoveIntegral());
+ }
+ integral=integral+Integer.valueOf(vce.getPalyIntegral());
+ loginUserInfoVOR.setLoveIntegral(integral+"");
+ userService.putUser(loginUserInfoVOR);
+
+ //更新商品库存
+ VolunteerIntegralMerchant goods=goodsService.queryById(vce.getGoodsId());
+ VolunteerIntegralMerchantVO vimvo=new VolunteerIntegralMerchantVO();
+ int goodNum=Integer.valueOf(goods.getGoodNum());
+ goodNum++;
+ vimvo.setId(goods.getId());
+ vimvo.setGoodNum(goodNum+"");
+ goodsService.updateById(vimvo);
+
+ //增加积分明细记录
+ VolunteerIntegralRecordVO virvo=new VolunteerIntegralRecordVO();
+ virvo.setUserId(loginUserInfoVOR.getUserId()+"");
+ virvo.setIType("4");
+ virvo.setIntegral(vce.getPalyIntegral());
+ virvo.setCommunityId(vce.getCommunityId());
+ virService.insertVolunteer(virvo);
+ }
+ return R.fail("订单不是未核销订单");
+ }
+
+
}
--
Gitblit v1.7.1