|
@@ -4,25 +4,27 @@ import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.pj.api.client.admin.AdminInterface;
|
|
|
-import com.pj.api.dto.AppUserDto;
|
|
|
import com.pj.current.dto.APPLoginUserInfo;
|
|
|
-import com.pj.current.dto.PCLoginUserInfo;
|
|
|
import com.pj.current.satoken.StpAPPUserUtil;
|
|
|
-import com.pj.current.satoken.StpUserUtil;
|
|
|
-import com.pj.enummj.AuditStatus;
|
|
|
-import com.pj.enummj.DeleteStatus;
|
|
|
-import com.pj.enummj.GoodsStatus;
|
|
|
-import com.pj.tb_enterprise.TbEnterprise;
|
|
|
+import com.pj.enummj.*;
|
|
|
import com.pj.tb_goods.TbGoods;
|
|
|
import com.pj.tb_goods.TbGoodsMapper;
|
|
|
import com.pj.tb_goods_transit.param.JudgeTransitParam;
|
|
|
+import com.pj.tb_goods_transit.param.PurchaseLevelOneGoodsTransitParam;
|
|
|
import com.pj.tb_goods_transit.param.TransactionGoodsParam;
|
|
|
+import com.pj.tb_group.TbGroup;
|
|
|
+import com.pj.tb_group.TbGroupMapper;
|
|
|
+import com.pj.tb_order.TbOrder;
|
|
|
+import com.pj.tb_order.TbOrderMapper;
|
|
|
+import com.pj.tb_people.TbPeople;
|
|
|
+import com.pj.tb_people.TbPeopleMapper;
|
|
|
import com.pj.tb_trade_area.TbTradeArea;
|
|
|
import com.pj.tb_trade_area.TbTradeAreaMapper;
|
|
|
import com.pj.utils.so.SoMap;
|
|
@@ -30,13 +32,13 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.springframework.amqp.core.AmqpTemplate;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import com.pj.utils.sg.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.swing.filechooser.FileSystemView;
|
|
@@ -59,10 +61,16 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
@Autowired
|
|
|
private TbGoodsMapper tbGoodsMapper;
|
|
|
@Autowired
|
|
|
- private AdminInterface adminInterface;
|
|
|
+ private TbGroupMapper tbGroupMapper;
|
|
|
/** 互市区mapper */
|
|
|
@Autowired
|
|
|
private TbTradeAreaMapper tbTradeAreaMapper;
|
|
|
+ /** 订单保存 */
|
|
|
+ @Autowired
|
|
|
+ private TbOrderMapper tbOrderMapper;
|
|
|
+ /** 边民 */
|
|
|
+ @Autowired
|
|
|
+ private TbPeopleMapper tbPeopleMapper;
|
|
|
|
|
|
/** 增 */
|
|
|
void add(TbGoodsTransit t){
|
|
@@ -109,6 +117,8 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
//获取审核id
|
|
|
List<String> ids = judgeTransitParam.getIds();
|
|
|
if(ids.size() == 0)return "没有需要审核的数据。";
|
|
|
+ //检查登录
|
|
|
+ StpUtil.checkLogin();
|
|
|
//获取审核状态
|
|
|
Integer judgeStatus = judgeTransitParam.getJudgeStatus();
|
|
|
//添加审核计数器
|
|
@@ -135,18 +145,18 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
|
|
|
/** app端 - 添加需要交易的商品 */
|
|
|
public boolean transactionGoods(TransactionGoodsParam transactionGoodsParam){
|
|
|
+ //检查登录
|
|
|
+// StpUtil.checkLogin();
|
|
|
//判断商品的净重毛重
|
|
|
Double netWeight = transactionGoodsParam.getNetWeight();
|
|
|
Double grossWeight = transactionGoodsParam.getGrossWeight();
|
|
|
if(netWeight > grossWeight){
|
|
|
throw new RuntimeException("净重超过了毛重,请检查输入。");
|
|
|
}
|
|
|
- //获取当前登录人 todo:生产阶段需打开该注释
|
|
|
-// StpUserUtil.checkLogin();
|
|
|
-// long loginIdAsLong = StpUserUtil.getLoginIdAsLong();
|
|
|
- Long loginIdAsLong = 4L;//测试阶段,写死appUser的id
|
|
|
- AppUserDto appUserById = adminInterface.getAppUserById(loginIdAsLong);
|
|
|
- if(appUserById == null)throw new RuntimeException("账户登录信息已失效!请重新登录");
|
|
|
+ //获取当前登录人
|
|
|
+ APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
+ if(appLoginInfo == null || appLoginInfo.getLoginId() == null)
|
|
|
+ throw new RuntimeException("账户登录信息已失效!请重新登录");
|
|
|
//取出申报商品ID
|
|
|
Long id = transactionGoodsParam.getId();
|
|
|
//查询监管产品
|
|
@@ -165,13 +175,17 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
tbGoodsTransit.setPlaceOrigin(tbGoods.getSource());
|
|
|
tbGoodsTransit.setGoodsUnits(tbGoods.getUnit());
|
|
|
tbGoodsTransit.setGoodsType(tbGoods.getTypeNames());
|
|
|
+ tbGoodsTransit.setShopId(transactionGoodsParam.getShopId());
|
|
|
+ tbGoodsTransit.setShopName(transactionGoodsParam.getShopName());
|
|
|
+ //保存海关商品表的主键到商品审核表上 todo:原计划是保存[海关申报单号],临时修改成保存海关商品表的主键
|
|
|
+ tbGoodsTransit.setDeclareOdd(tbGoods.getId().toString());
|
|
|
//设置默认信息
|
|
|
tbGoodsTransit.setAuditStatus(1);//默认已过审
|
|
|
tbGoodsTransit.setGoodsStatus(1);//默认已上架
|
|
|
//设置基本信息
|
|
|
tbGoodsTransit.setCreateTime(new Date());
|
|
|
- tbGoodsTransit.setCreateBy(loginIdAsLong + "");
|
|
|
- tbGoodsTransit.setCreateName(appUserById.getName());
|
|
|
+ tbGoodsTransit.setCreateBy(appLoginInfo.getLoginId() + "");
|
|
|
+ tbGoodsTransit.setCreateName(appLoginInfo.getLoginName());
|
|
|
tbGoodsTransit.setDeleteStatus(1);
|
|
|
//执行保存
|
|
|
int insert = tbGoodsTransitMapper.insert(tbGoodsTransit);
|
|
@@ -183,10 +197,16 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
boolean UpOrDownGoods(Long goodsTransitId , Integer goodsStatus){
|
|
|
//获取当前登陆人
|
|
|
APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
- if(appLoginInfo == null)throw new RuntimeException("当前登陆人不存在!");
|
|
|
+ if(appLoginInfo == null || appLoginInfo.getLoginId() == null)
|
|
|
+ throw new RuntimeException("当前登陆人不存在!");
|
|
|
+ //查询当前需要执行上架/下架的商品
|
|
|
TbGoodsTransit tbGoodsTransit = tbGoodsTransitMapper.selectById(goodsTransitId);
|
|
|
- if(tbGoodsTransit == null)throw new RuntimeException("该商品状态异常或不存在!");
|
|
|
- tbGoodsTransit.setGoodsStatus(goodsStatus == null? 0 : goodsStatus);
|
|
|
+ if(tbGoodsTransit == null || tbGoodsTransit.getId() == null)
|
|
|
+ throw new RuntimeException("该商品状态异常或不存在!");
|
|
|
+ //设置商品状态
|
|
|
+ tbGoodsTransit.setGoodsStatus
|
|
|
+ (goodsStatus == null || goodsStatus.toString().equals("")?
|
|
|
+ tbGoodsTransit.getGoodsStatus() : goodsStatus);
|
|
|
//设置基本属性
|
|
|
tbGoodsTransit.setUpdateTime(new Date());
|
|
|
tbGoodsTransit.setUpdateBy(appLoginInfo.getLoginId() + "");
|
|
@@ -198,6 +218,65 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 采购一级市场的商品,
|
|
|
+ * 包括加入购物车、购买、支付(暂时不做),
|
|
|
+ * 下单后会向组内边民发送短信,
|
|
|
+ * 通知其登录APP进行交易确认。
|
|
|
+ */
|
|
|
+ public boolean purchaseLevelOntGoodsTransit(PurchaseLevelOneGoodsTransitParam purchaseLevelOntGoodsTransitParam){
|
|
|
+ //检查登录
|
|
|
+// StpUtil.checkLogin();
|
|
|
+ //获取当前登陆人
|
|
|
+ APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
+ if(appLoginInfo == null || appLoginInfo.getLoginId() == null)
|
|
|
+ throw new RuntimeException("当前登陆用户信息已失效!");
|
|
|
+ //判断当前登陆人是否为互市组组长
|
|
|
+ List<TbGroup> list = tbGroupMapper.selectList
|
|
|
+ (new LambdaQueryWrapper<TbGroup>().eq(TbGroup::getLeaderId, appLoginInfo.getLoginId())
|
|
|
+ .eq(TbGroup::getIsLock, IsLock.IS_LOCK_ON.getCode())
|
|
|
+ .eq(TbGroup::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode()));
|
|
|
+ if(list.size() != 1)throw new RuntimeException("您当前不属于互市组组长~");
|
|
|
+ //获取商品ID
|
|
|
+ String goodsTransitId = purchaseLevelOntGoodsTransitParam.getGoodsTransitId();
|
|
|
+ //查询商品
|
|
|
+ TbGoodsTransit tbGoodsTransit = tbGoodsTransitMapper.selectById(goodsTransitId);
|
|
|
+ if(tbGoodsTransit == null || tbGoodsTransit.getId() == null)
|
|
|
+ throw new RuntimeException("当前商品信息已失效!");
|
|
|
+ //检查是否属于海关允许销售商品
|
|
|
+ String declareOdd = tbGoodsTransit.getDeclareOdd();
|
|
|
+ TbGoods tbGoods = tbGoodsMapper.selectById(declareOdd);
|
|
|
+ if(tbGoods == null)throw new RuntimeException("当前商品已海关不允许销售!");
|
|
|
+ //执行采购,创建一级市场订单表
|
|
|
+ TbOrder tbOrder = methodGoodsTransitService.setTbOrderProperties(tbGoodsTransit, appLoginInfo);
|
|
|
+
|
|
|
+ //查询是否已存在该订单
|
|
|
+ List<TbOrder> tbOrderList = tbOrderMapper.selectList(new LambdaQueryWrapper<TbOrder>().eq(TbOrder::getGoodsId, tbGoodsTransit.getId()));
|
|
|
+ if(tbOrderList.size() != 0)throw new RuntimeException("当前商品已存在订单,暂时无法继续下单!");
|
|
|
+
|
|
|
+ //执行保存
|
|
|
+ int insert = tbOrderMapper.insert(tbOrder);
|
|
|
+ if(insert == 1){
|
|
|
+ // todo: 执行订单完成后的逻辑
|
|
|
+ // todo: 发送短信给边民组通知其确认
|
|
|
+ //获取互市组ID
|
|
|
+ Long groupId = list.get(0).getId();
|
|
|
+ if(groupId == null)throw new RuntimeException("订单异常,原因是没有关联的边民!");
|
|
|
+ //通过互市组ID查询所属边民的ID集合
|
|
|
+ List<TbPeople> tbPeopleList = tbPeopleMapper.selectList
|
|
|
+ (new LambdaQueryWrapper<TbPeople>()
|
|
|
+ .eq(TbPeople::getGroupId, groupId)
|
|
|
+ .eq(TbPeople::getIsLock, IsLock.IS_LOCK_ON.getCode())
|
|
|
+ .eq(TbPeople::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode()));
|
|
|
+
|
|
|
+ if(tbPeopleList.size() == 0)throw new RuntimeException("订单异常,原因是没有关联的边民!!!");
|
|
|
+ methodGoodsTransitService.sendSms(tbPeopleList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 导入
|
|
|
* @param file excel文件
|
|
|
* @return
|