团购卷卷码表
原订单列表逻辑 店铺营业时间 团购卷订单 团购卷卷码表 资源管理 字典管理 通用门店 个人中心 支付
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbGroupOrderCoupon;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbGroupOrderCouponMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 团购卷 卷码表(TbGroupOrderCoupon)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-05-06 14:39:59
|
||||
*/
|
||||
@Service
|
||||
public class GroupOrderCouponService {
|
||||
@Resource
|
||||
private TbGroupOrderCouponMapper tbGroupOrderCouponMapper;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
public TbGroupOrderCoupon queryById(Integer id) {
|
||||
return this.tbGroupOrderCouponMapper.queryById(id);
|
||||
}
|
||||
|
||||
public List<TbGroupOrderCoupon> queryByOrderId(Integer orderId) {
|
||||
return tbGroupOrderCouponMapper.queryByOrderId(orderId);
|
||||
}
|
||||
|
||||
public List<TbGroupOrderCoupon> queryNoRefundByOrderId(Integer orderId) {
|
||||
return tbGroupOrderCouponMapper.queryNoRefundByOrderId(orderId);
|
||||
}
|
||||
|
||||
public TbGroupOrderCoupon insert(TbGroupOrderCoupon tbGroupOrderCoupon) {
|
||||
this.tbGroupOrderCouponMapper.insert(tbGroupOrderCoupon);
|
||||
return tbGroupOrderCoupon;
|
||||
}
|
||||
|
||||
public TbGroupOrderCoupon update(TbGroupOrderCoupon tbGroupOrderCoupon) {
|
||||
this.tbGroupOrderCouponMapper.update(tbGroupOrderCoupon);
|
||||
return this.queryById(tbGroupOrderCoupon.getId());
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbPurchaseNoticeMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbGroupOrderInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.CreateGroupOrderDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.GroupOrderDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.GroupOrderDetailsVo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.GroupOrderListVo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.ProductVo;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.LocationUtils;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -22,18 +22,23 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class GroupOrderInfoService{
|
||||
public class GroupOrderInfoService {
|
||||
@Autowired
|
||||
private TbShopInfoMapper shopInfoMapper;
|
||||
@Autowired
|
||||
private TbProductMapper tbProductMapper;
|
||||
@Resource
|
||||
private TbGroupOrderInfoMapper tbGroupOrderInfoMapper;
|
||||
@Autowired
|
||||
private GroupOrderCouponService groupOrderCouponService;
|
||||
@Autowired
|
||||
private TbMerchantAccountMapper merchantAccountMapper;
|
||||
@Resource
|
||||
private TbPurchaseNoticeMapper noticeMapper;
|
||||
|
||||
@@ -43,23 +48,33 @@ public class GroupOrderInfoService{
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
|
||||
public Result queryById(Integer id,String lng,String lat) {
|
||||
|
||||
public Result queryById(Integer id, String lng, String lat) {
|
||||
TbGroupOrderInfo groupOrder = tbGroupOrderInfoMapper.queryById(id);
|
||||
GroupOrderDetailsVo result=new GroupOrderDetailsVo();
|
||||
GroupOrderDetailsVo result = new GroupOrderDetailsVo();
|
||||
result.setId(id);
|
||||
result.setProId(groupOrder.getProId());
|
||||
result.setProName(groupOrder.getProName());
|
||||
result.setProImg(groupOrder.getProImg());
|
||||
TbPurchaseNotice tbPurchaseNotice = noticeMapper.queryByCouponId(groupOrder.getProId());
|
||||
result.setAvaTime(tbPurchaseNotice.getAvailableTime()+" | 到店吃");
|
||||
// result.setProDetail();
|
||||
if(tbPurchaseNotice!=null){
|
||||
result.setAvaTime(tbPurchaseNotice.getAvailableTime()+" | 到店吃");
|
||||
result.setNotice(tbPurchaseNotice);
|
||||
}
|
||||
// result.setProDetail(); //随时退·过期自动退·到店
|
||||
result.setOrderAmount(groupOrder.getOrderAmount());
|
||||
|
||||
result.setExpDate(groupOrder.getNumber()+"张可用 | "+ DateUtils.getTimeM(groupOrder.getExpDate()));
|
||||
if(!groupOrder.getStatus().equals("unpaid")){
|
||||
if(!groupOrder.getStatus().equals("closed")){
|
||||
result.setExpDate(groupOrder.getNumber()-
|
||||
groupOrder.getRefundNumber() + "张可用 | " +
|
||||
DateUtils.getTimeM(
|
||||
groupOrder.getExpDate())+" 到期");
|
||||
}
|
||||
}
|
||||
result.setRefundAble(groupOrder.getRefundAble());
|
||||
List<String> coupons = Arrays.asList(groupOrder.getCouponNo().split(","));
|
||||
List<String> couponUrls = Arrays.asList(groupOrder.getCouponUrl().split(","));
|
||||
result.setCouponNo(coupons);
|
||||
result.setCouponUrl(couponUrls);
|
||||
List<TbGroupOrderCoupon> tbGroupOrderCoupons = groupOrderCouponService.queryByOrderId(id);
|
||||
result.setCoupons(tbGroupOrderCoupons);
|
||||
|
||||
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(groupOrder.getShopId());
|
||||
result.setShopName(shopInfo.getShopName());
|
||||
@@ -73,67 +88,90 @@ public class GroupOrderInfoService{
|
||||
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(groupOrder.getProId());
|
||||
result.setTagVos(JSONUtil.parseListTNewList(product.getGroupSnap(), ProductVo.class));
|
||||
|
||||
result.setNotice(tbPurchaseNotice);
|
||||
|
||||
result.setOrderNo(groupOrder.getOrderNo());
|
||||
result.setPhone(groupOrder.getPhone());
|
||||
result.setPayTime(DateUtils.getTime(groupOrder.getPayTime()));
|
||||
if (groupOrder.getPayTime() != null) {
|
||||
result.setPayTime(DateUtils.getTime(groupOrder.getPayTime()));
|
||||
}
|
||||
result.setNumber(groupOrder.getNumber());
|
||||
result.setPayAmount(groupOrder.getPayAmount());
|
||||
return Result.success(CodeEnum.SUCCESS,result);
|
||||
result.setSaveAmount(groupOrder.getSaveAmount());
|
||||
result.setStatus(groupOrder.getStatus());
|
||||
return Result.success(CodeEnum.SUCCESS, result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @return 查询结果
|
||||
*/
|
||||
public Result queryByPage(GroupOrderDto param) {
|
||||
PageHelper.startPage(param.getPage(), param.getSize());
|
||||
List<GroupOrderListVo> tbGroupOrderInfos = tbGroupOrderInfoMapper.queryAll(param);
|
||||
return Result.success(CodeEnum.SUCCESS,new PageInfo(tbGroupOrderInfos));
|
||||
return new Result(CodeEnum.SUCCESS,new PageInfo<>(tbGroupOrderInfoMapper.queryAll(param)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbGroupOrderInfo 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
|
||||
public Result insert(TbGroupOrderInfo tbGroupOrderInfo) {
|
||||
public Result insert(CreateGroupOrderDto param) {
|
||||
TbMerchantAccount tbMerchantAccount = merchantAccountMapper.selectByShopId(param.getShopId().toString());
|
||||
if (tbMerchantAccount == null) {
|
||||
throw new MsgException("生成订单错误");
|
||||
}
|
||||
|
||||
TbGroupOrderInfo tbGroupOrderInfo = new TbGroupOrderInfo();
|
||||
tbGroupOrderInfo.setOrderNo(generateOrderNumber());
|
||||
tbGroupOrderInfo.setMerchantId(tbMerchantAccount.getId());
|
||||
tbGroupOrderInfo.setShopId(param.getShopId());
|
||||
tbGroupOrderInfo.setProId(param.getProId());
|
||||
tbGroupOrderInfo.setUserId(param.getUserId());
|
||||
tbGroupOrderInfo.setPhone(param.getPhone());
|
||||
TbProduct tbProduct = tbProductMapper.selectById(param.getProId());
|
||||
tbGroupOrderInfo.setProImg(tbProduct.getCoverImg());
|
||||
tbGroupOrderInfo.setProName(tbProduct.getName());
|
||||
tbGroupOrderInfo.setNumber(param.getNum());
|
||||
tbGroupOrderInfo.setRefundNumber(0);
|
||||
tbGroupOrderInfo.setOrderAmount(param.getOrderAmount());
|
||||
tbGroupOrderInfo.setRefundAmount(BigDecimal.ZERO);
|
||||
tbGroupOrderInfo.setSaveAmount(param.getOrderAmount().subtract(param.getPayAmount()));
|
||||
tbGroupOrderInfo.setPayAmount(param.getPayAmount());
|
||||
tbGroupOrderInfo.setStatus("unpaid");
|
||||
tbGroupOrderInfo.setRemark(param.getRemark());
|
||||
tbGroupOrderInfo.setCreateTime(new Date());
|
||||
tbGroupOrderInfo.setTradeDay(new Date());
|
||||
tbGroupOrderInfo.setRefundAble(1);
|
||||
int insert = tbGroupOrderInfoMapper.insert(tbGroupOrderInfo);
|
||||
if(insert>0){
|
||||
return new Result(CodeEnum.SUCCESS);
|
||||
}else {
|
||||
if (insert > 0) {
|
||||
return new Result(CodeEnum.SUCCESS,tbGroupOrderInfo);
|
||||
} else {
|
||||
return new Result(CodeEnum.FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
public String generateOrderNumber() {
|
||||
String date = DateUtils.getSdfTimes();
|
||||
Random random = new Random();
|
||||
int randomNum = random.nextInt(900) + 100;
|
||||
return "GP" + date + randomNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbGroupOrderInfo 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
|
||||
|
||||
public Result update(TbGroupOrderInfo tbGroupOrderInfo) {
|
||||
int update = tbGroupOrderInfoMapper.update(tbGroupOrderInfo);
|
||||
if(update>0){
|
||||
if (update > 0) {
|
||||
return new Result(CodeEnum.SUCCESS);
|
||||
}else {
|
||||
} else {
|
||||
return new Result(CodeEnum.FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
|
||||
public boolean deleteById(Integer id) {
|
||||
return this.tbGroupOrderInfoMapper.deleteById(id) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.dao.SysDictDetailMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.SysDictMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbCouponCategoryMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.SysDict;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCouponCategory;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ComShopDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.HomeBaseDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.*;
|
||||
@@ -26,7 +27,6 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -41,7 +41,8 @@ public class HomeDistrictService {
|
||||
@Resource
|
||||
private TbCouponCategoryMapper couponCategoryMapper;
|
||||
@Resource
|
||||
private SysDictDetailMapper sysDictDetailMapper;
|
||||
// private SysDictDetailMapper sysDictDetailMapper;
|
||||
private SysDictMapper sysDictMapper;
|
||||
|
||||
public Result topCommon(HomeDto param, String environment){
|
||||
CommonVo result = new CommonVo();
|
||||
@@ -55,22 +56,17 @@ public class HomeDistrictService {
|
||||
}else {//商品分类页
|
||||
TbCouponCategory tbCouponCategory = couponCategoryMapper.queryById(Integer.valueOf(param.getType()));
|
||||
result.setTitle(tbCouponCategory.getName());
|
||||
List<TbPlatformDict> carouselList = platformDictMapper.queryAllByType(param.getType(), environment);
|
||||
List<TbPlatformDict> carouselList = platformDictMapper.queryGroupByValue(param.getType(), environment);
|
||||
if (!CollectionUtils.isEmpty(carouselList)) {
|
||||
result.setCarousel(JSONUtil.parseListTNewList(carouselList, HomeCarouselVo.class));
|
||||
}
|
||||
List<SysDict> sysDicts = sysDictDetailMapper.selectByType(null);
|
||||
List<DicDetailVO> dicDetailVO = new ArrayList<>();
|
||||
for (SysDict sysDictsList : sysDicts) {
|
||||
DicDetailVO dicDetailVOList = new DicDetailVO();
|
||||
dicDetailVOList.setDictName(sysDictsList.getDictName());
|
||||
dicDetailVOList.setName(sysDictsList.getName());
|
||||
dicDetailVOList.setDescription(sysDictsList.getDescription());
|
||||
dicDetailVOList.setDetail(sysDictDetailMapper.selectByDictId(sysDictsList.getDictId()));
|
||||
dicDetailVOList.setIsChild((sysDictsList.getIsChild() == null || sysDictsList.getIsChild() == 0) ? false : true);
|
||||
dicDetailVO.add(dicDetailVOList);
|
||||
List<SysDict> sysDicts = sysDictMapper.selectByType(null);
|
||||
for (SysDict sysDict : sysDicts) {
|
||||
if (sysDict.getIsChild()==1) {
|
||||
sysDict.setDetail(sysDictMapper.selectByDictId(sysDict.getDictId()));
|
||||
}
|
||||
}
|
||||
result.setMenu(dicDetailVO);
|
||||
result.setMenu(sysDicts);
|
||||
}
|
||||
} else {
|
||||
if (param.getOrderBy() != null) {
|
||||
@@ -80,23 +76,19 @@ public class HomeDistrictService {
|
||||
result.setCarousel(JSONUtil.parseListTNewList(carouselList, HomeCarouselVo.class));
|
||||
}
|
||||
result.setTitle("今日上新");
|
||||
} else if (param.getOrderBy() == 2) {
|
||||
} else if (param.getOrderBy() == 4) {
|
||||
List<TbPlatformDict> carouselList = platformDictMapper.queryAllByType("hotCoupon", environment);
|
||||
if (!CollectionUtils.isEmpty(carouselList)) {
|
||||
result.setCarousel(JSONUtil.parseListTNewList(carouselList, HomeCarouselVo.class));
|
||||
}
|
||||
result.setTitle("热榜推荐");
|
||||
List<SysDict> sysDicts = sysDictDetailMapper.selectHot();
|
||||
List<DicDetailVO> dicDetailVO = new ArrayList<>();
|
||||
for (SysDict sysDictsList : sysDicts) {
|
||||
DicDetailVO dicDetailVOList = new DicDetailVO();
|
||||
dicDetailVOList.setDictName(sysDictsList.getDictName());
|
||||
dicDetailVOList.setName(sysDictsList.getName());
|
||||
dicDetailVOList.setDescription(sysDictsList.getDescription());
|
||||
dicDetailVOList.setIsChild((sysDictsList.getIsChild() == null || sysDictsList.getIsChild() == 0) ? false : true);
|
||||
dicDetailVO.add(dicDetailVOList);
|
||||
List<SysDict> sysDicts = sysDictMapper.selectHot();
|
||||
for (SysDict sysDict : sysDicts) {
|
||||
if (sysDict.getIsChild()==1) {
|
||||
sysDict.setDetail(sysDictMapper.selectByDictId(sysDict.getDictId()));
|
||||
}
|
||||
}
|
||||
result.setMenu(dicDetailVO);
|
||||
result.setMenu(sysDicts);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,7 +106,7 @@ public class HomeDistrictService {
|
||||
topAndBottomMap.get("rightTopPoint")[0],//34.39724773780949
|
||||
topAndBottomMap.get("leftBottomPoint")[1],
|
||||
topAndBottomMap.get("leftBottomPoint")[0],
|
||||
param.getAddress(), param.getLng(), param.getLat());//西安市
|
||||
param.getAddress(), param.getLng(), param.getLat(),null);//西安市
|
||||
for (SubShopVo subShopVo : subShopVos) {//距离计算
|
||||
if (StringUtils.isNotBlank(subShopVo.getLat()) && StringUtils.isNotBlank(subShopVo.getLng())) {
|
||||
BigDecimal distance = LocationUtils.getDistanceFrom2LngLat(
|
||||
@@ -123,17 +115,38 @@ public class HomeDistrictService {
|
||||
subShopVo.setDistances(distance.toString());
|
||||
}
|
||||
}
|
||||
PageInfo pageInfo = new PageInfo();
|
||||
pageInfo.setList(subShopVos);
|
||||
return Result.success(CodeEnum.SUCCESS, pageInfo);
|
||||
return Result.success(CodeEnum.SUCCESS, new PageInfo(subShopVos));
|
||||
|
||||
}
|
||||
|
||||
public Result queryComShopList(ComShopDto param) {
|
||||
Map<String, double[]> topAndBottomMap = LocationUtils.returnLLSquarePoint(
|
||||
Double.parseDouble(param.getLng()),
|
||||
Double.parseDouble(param.getLat()),
|
||||
param.getDistanceInKm());
|
||||
List<SubShopVo> subShopVos = shopInfoMapper.selShopInfoByGps(
|
||||
topAndBottomMap.get("rightTopPoint")[1],//109.06198684730003
|
||||
topAndBottomMap.get("rightTopPoint")[0],//34.39724773780949
|
||||
topAndBottomMap.get("leftBottomPoint")[1],
|
||||
topAndBottomMap.get("leftBottomPoint")[0],
|
||||
param.getAddress(), param.getLng(), param.getLat(),param.getShopName());//西安市
|
||||
for (SubShopVo subShopVo : subShopVos) {//距离计算
|
||||
subShopVo.setBusinessTime(subShopVo.getBusinessStartDay()+"至"+subShopVo.getBusinessEndDay()+" "+subShopVo.getBusinessTime());
|
||||
if (StringUtils.isNotBlank(subShopVo.getLat()) && StringUtils.isNotBlank(subShopVo.getLng())) {
|
||||
BigDecimal distance = LocationUtils.getDistanceFrom2LngLat(
|
||||
Double.parseDouble(param.getLng()), Double.parseDouble(param.getLat()),
|
||||
Double.parseDouble(subShopVo.getLng()), Double.parseDouble(subShopVo.getLat()));
|
||||
subShopVo.setDistances(distance.toString());
|
||||
}
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS, subShopVos);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用商品页
|
||||
*/
|
||||
public Result proList(HomeDto param) throws ExecutionException, InterruptedException {
|
||||
PageInfo products = productService.products(param);
|
||||
return Result.success(CodeEnum.SUCCESS, products);
|
||||
public Result proList(HomeDto param) {
|
||||
return Result.success(CodeEnum.SUCCESS, productService.products(param));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.dao.SysDictDetailMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.SysDictMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.Enum.LogoEnum;
|
||||
@@ -11,6 +11,7 @@ import com.chaozhanggui.system.cashierservice.entity.vo.*;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.BigDecimalUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.RandomUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.StringUtil;
|
||||
@@ -37,7 +38,7 @@ public class HomePageService {
|
||||
@Resource
|
||||
private TbPlatformDictMapper platformDictMapper;
|
||||
@Resource
|
||||
private SysDictDetailMapper sysDictDetailMapper;
|
||||
private SysDictMapper sysDictMapper;
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
@Autowired
|
||||
@@ -53,18 +54,13 @@ public class HomePageService {
|
||||
homeUpVO.setDistrict(JSONUtil.parseListTNewList(districtList, HomeDistrictVo.class));
|
||||
|
||||
//菜单
|
||||
List<SysDict> sysDicts = sysDictDetailMapper.selectByType("home");
|
||||
List<DicDetailVO> dicDetailVO = new ArrayList<>();
|
||||
for (SysDict sysDictsList : sysDicts) {
|
||||
DicDetailVO dicDetailVOList = new DicDetailVO();
|
||||
dicDetailVOList.setDictName(sysDictsList.getDictName());
|
||||
dicDetailVOList.setName(sysDictsList.getName());
|
||||
dicDetailVOList.setDescription(sysDictsList.getDescription());
|
||||
dicDetailVOList.setDetail(sysDictDetailMapper.selectByDictId(sysDictsList.getDictId()));
|
||||
dicDetailVOList.setIsChild((sysDictsList.getIsChild() == null || sysDictsList.getIsChild() == 0) ? false : true);
|
||||
dicDetailVO.add(dicDetailVOList);
|
||||
List<SysDict> sysDicts = sysDictMapper.selectByType("home");
|
||||
for (SysDict sysDict : sysDicts) {
|
||||
if (sysDict.getIsChild()==1) {
|
||||
sysDict.setDetail(sysDictMapper.selectByDictId(sysDict.getDictId()));
|
||||
}
|
||||
}
|
||||
homeUpVO.setMenu(dicDetailVO);
|
||||
homeUpVO.setMenu(sysDicts);
|
||||
/**
|
||||
* 销量榜
|
||||
*/
|
||||
@@ -72,8 +68,7 @@ public class HomePageService {
|
||||
for (HomeVO o : homeVOs) {
|
||||
BigDecimal originPrice = o.getOriginPrice();
|
||||
if (originPrice.compareTo(BigDecimal.ZERO) != 0) {
|
||||
BigDecimal multiply = o.getSalePrice().divide(o.getOriginPrice(), 2, RoundingMode.DOWN).multiply(BigDecimal.TEN);
|
||||
o.setDiscount(multiply);
|
||||
o.setDiscount(BigDecimalUtils.getDiscount(o.getOriginPrice(),o.getSalePrice()));
|
||||
} else {
|
||||
o.setDiscount(null);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.CashierCarVo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.OrderVo;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||
@@ -14,25 +11,19 @@ import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.socket.AppWebSocketServer;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.N;
|
||||
import com.chaozhanggui.system.cashierservice.util.RedisUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.SnowFlakeUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.awt.print.Pageable;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -209,18 +200,12 @@ public class OrderService {
|
||||
|
||||
|
||||
public Result orderList(Integer userId, Integer page, Integer size, String status) {
|
||||
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(userId);
|
||||
if (tbUserInfo == null) {
|
||||
return Result.fail("生成订单失败");
|
||||
}
|
||||
//获取页码号
|
||||
int beginNo;
|
||||
if (page <= 0) {
|
||||
beginNo = 0;
|
||||
} else {
|
||||
beginNo = (page - 1) * size;
|
||||
}
|
||||
List<TbOrderInfo> tbOrderInfos = orderInfoMapper.selectByUserId(userId, beginNo, size, status);
|
||||
// TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(userId);
|
||||
// if (tbUserInfo == null) {
|
||||
// return Result.fail("获取订单失败");
|
||||
// }
|
||||
PageHelper.startPage(page, size);
|
||||
List<TbOrderInfo> tbOrderInfos = orderInfoMapper.selectByUserId(userId, status);
|
||||
|
||||
for (TbOrderInfo orderInfo : tbOrderInfos) {
|
||||
List<TbOrderDetail> list = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.model.PayReq;
|
||||
import com.chaozhanggui.system.cashierservice.model.ReturnOrderReq;
|
||||
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
@@ -28,16 +32,14 @@ import org.springframework.web.client.RestTemplate;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PayService {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
TbOrderInfoMapper tbOrderInfoMapper;
|
||||
|
||||
@@ -53,7 +55,11 @@ public class PayService {
|
||||
|
||||
@Autowired
|
||||
TbOrderDetailMapper tbOrderDetailMapper;
|
||||
@Autowired
|
||||
private TbMerchantAccountMapper merchantAccountMapper;
|
||||
|
||||
@Autowired
|
||||
private GroupOrderCouponService groupOrderCouponService;
|
||||
|
||||
|
||||
@Autowired
|
||||
@@ -66,12 +72,13 @@ public class PayService {
|
||||
@Value("${ysk.callBackurl}")
|
||||
private String callBackurl;
|
||||
|
||||
@Value("${ysk.callBackGroupurl}")
|
||||
private String callBackGroupurl;
|
||||
|
||||
@Value("${ysk.callBackIn}")
|
||||
private String callBackIn;
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private TbCashierCartMapper tbCashierCartMapper;
|
||||
|
||||
@@ -94,37 +101,47 @@ public class PayService {
|
||||
|
||||
@Autowired
|
||||
TbShopUserFlowMapper tbShopUserFlowMapper;
|
||||
|
||||
@Resource
|
||||
private TbGroupOrderInfoMapper tbGroupOrderInfoMapper;
|
||||
@Autowired
|
||||
private TbProductMapper tbProductMapper;
|
||||
@Resource
|
||||
private GroupOrderCouponService orderCouponService;
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result payOrder(String openId,String orderId,String ip) throws Exception {
|
||||
TbOrderInfo orderInfo= tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||
public Result payOrder(String openId, String orderId,String payType, String ip) throws Exception {
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||
|
||||
if(!"unpaid".equals(orderInfo.getStatus())&&!"paying".equals(orderInfo.getStatus())){
|
||||
if (!"unpaid".equals(orderInfo.getStatus()) && !"paying".equals(orderInfo.getStatus())) {
|
||||
return Result.fail("订单状态异常,不允许支付");
|
||||
}
|
||||
|
||||
if(ObjectUtil.isNull(orderInfo.getMerchantId())||ObjectUtil.isEmpty(orderInfo.getMerchantId())){
|
||||
if (ObjectUtil.isNull(orderInfo.getMerchantId()) || ObjectUtil.isEmpty(orderInfo.getMerchantId())) {
|
||||
return Result.fail("没有对应的商户");
|
||||
}
|
||||
|
||||
|
||||
TbMerchantThirdApply thirdApply= tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
||||
|
||||
if(ObjectUtil.isEmpty(thirdApply)||ObjectUtil.isNull(thirdApply)){
|
||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||
return Result.fail("支付通道不存在");
|
||||
}
|
||||
|
||||
TbOrderPayment payment=tbOrderPaymentMapper.selectByOrderId(orderId);
|
||||
if(ObjectUtil.isEmpty(payment)||payment==null){
|
||||
payment=new TbOrderPayment();
|
||||
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
|
||||
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
||||
payment = new TbOrderPayment();
|
||||
payment.setPayTypeId("ysk");
|
||||
payment.setAmount(orderInfo.getOrderAmount());
|
||||
payment.setPaidAmount(orderInfo.getPayAmount());
|
||||
payment.setHasRefundAmount(BigDecimal.ZERO);
|
||||
payment.setPayName("微信支付");
|
||||
payment.setPayType("wechatPay");
|
||||
if (payType.equals("wechatPay")) {
|
||||
payment.setPayName("微信支付");
|
||||
payment.setPayType("wechatPay");
|
||||
} else if (payType.equals("aliPay")) {
|
||||
payment.setPayName("支付宝支付");
|
||||
payment.setPayType("aliPay");
|
||||
}
|
||||
payment.setReceived(payment.getAmount());
|
||||
payment.setChangeFee(BigDecimal.ZERO);
|
||||
payment.setMemberId(orderInfo.getMemberId());
|
||||
@@ -132,32 +149,41 @@ public class PayService {
|
||||
payment.setOrderId(orderInfo.getId().toString());
|
||||
payment.setCreatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.insert(payment);
|
||||
}else {
|
||||
} else {
|
||||
if (payType.equals("wechatPay")) {
|
||||
payment.setPayName("微信支付");
|
||||
payment.setPayType("wechatPay");
|
||||
} else if (payType.equals("aliPay")) {
|
||||
payment.setPayName("支付宝支付");
|
||||
payment.setPayType("aliPay");
|
||||
}
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKey(payment);
|
||||
}
|
||||
|
||||
PayReq req=new PayReq();
|
||||
|
||||
PayReq req = new PayReq();
|
||||
req.setAppId(thirdApply.getAppId());
|
||||
req.setTimestamp(System.currentTimeMillis());
|
||||
req.setIp(ip);
|
||||
req.setMercOrderNo(orderInfo.getOrderNo());
|
||||
req.setNotifyUrl(callBackurl);
|
||||
req.setPayAmt(payment.getAmount().setScale(2,BigDecimal.ROUND_DOWN).toPlainString());
|
||||
req.setPayType("03");
|
||||
req.setPayWay("WXZF");
|
||||
req.setPayAmt(payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
|
||||
if (payType.equals("wechatPay")) {
|
||||
req.setPayType("03");
|
||||
req.setPayWay("WXZF");//WXZF ZFBZF UNIONPAY
|
||||
} else if (payType.equals("aliPay")) {
|
||||
req.setPayWay("ZFBZF");
|
||||
}
|
||||
req.setSubject("扫码点餐");
|
||||
req.setUserId(openId);
|
||||
|
||||
Map<String, Object> map = BeanUtil.transBeanMap(req);
|
||||
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
|
||||
Map<String,Object> map= BeanUtil.transBeanMap(req);
|
||||
req.setSign(MD5Util.encrypt(map,thirdApply.getAppToken(),true));
|
||||
|
||||
ResponseEntity<String> response= restTemplate.postForEntity(url.concat("trans/pay"),req,String.class);
|
||||
if(response.getStatusCodeValue()==200&&ObjectUtil.isNotEmpty(response.getBody())){
|
||||
JSONObject object=JSONObject.parseObject(response.getBody());
|
||||
if(object.get("code").equals("0")){
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url.concat("trans/pay"), req, String.class);
|
||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
if (object.get("code").equals("0")) {
|
||||
payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
@@ -166,7 +192,7 @@ public class PayService {
|
||||
|
||||
|
||||
tbOrderInfoMapper.updateByPrimaryKey(orderInfo);
|
||||
String key= RedisCst.TABLE_CART.concat(orderInfo.getTableId()).concat("-").concat(orderInfo.getShopId());
|
||||
String key = RedisCst.TABLE_CART.concat(orderInfo.getTableId()).concat("-").concat(orderInfo.getShopId());
|
||||
//清除缓存购物车数据
|
||||
redisUtil.deleteByKey(key);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
@@ -175,10 +201,10 @@ public class PayService {
|
||||
jsonObject1.put("type", "");
|
||||
jsonObject1.put("data", new JSONArray());
|
||||
jsonObject1.put("amount", 0);
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1,key, false);
|
||||
tbCashierCartMapper.updateStatusByOrderId(orderId.toString(),"final");
|
||||
return Result.success(CodeEnum.SUCCESS,object.getJSONObject("data"));
|
||||
}else {
|
||||
AppWebSocketServer.AppSendInfo(jsonObject1, key, false);
|
||||
tbCashierCartMapper.updateStatusByOrderId(orderId.toString(), "final");
|
||||
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
||||
} else {
|
||||
return Result.fail(object.getString("msg"));
|
||||
}
|
||||
}
|
||||
@@ -186,11 +212,159 @@ public class PayService {
|
||||
return Result.fail("失败");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result groupOrderPay(String orderId, String payType, String userId, String ip) {
|
||||
TbGroupOrderInfo orderInfo = tbGroupOrderInfoMapper.queryById(Integer.valueOf(orderId));
|
||||
|
||||
if (!"unpaid".equals(orderInfo.getStatus()) && !"paying".equals(orderInfo.getStatus())) {
|
||||
return Result.fail("订单状态异常,不允许支付");
|
||||
}
|
||||
|
||||
TbMerchantAccount tbMerchantAccount = merchantAccountMapper.selectByShopId(orderInfo.getShopId().toString());
|
||||
if (tbMerchantAccount == null) {
|
||||
throw new MsgException("生成订单错误");
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNull(tbMerchantAccount.getMerchantId()) || ObjectUtil.isEmpty(tbMerchantAccount.getMerchantId())) {
|
||||
return Result.fail("没有对应的商户");
|
||||
}
|
||||
|
||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(tbMerchantAccount.getMerchantId()));
|
||||
|
||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||
return Result.fail("支付通道不存在");
|
||||
}
|
||||
|
||||
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
|
||||
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
||||
payment = new TbOrderPayment();
|
||||
payment.setPayTypeId("ysk");
|
||||
payment.setAmount(orderInfo.getOrderAmount());
|
||||
payment.setPaidAmount(orderInfo.getPayAmount());
|
||||
payment.setHasRefundAmount(BigDecimal.ZERO);
|
||||
if (payType.equals("wechatPay")) {
|
||||
payment.setPayName("微信支付");
|
||||
payment.setPayType("wechatPay");
|
||||
} else if (payType.equals("aliPay")) {
|
||||
payment.setPayName("支付宝支付");
|
||||
payment.setPayType("aliPay");
|
||||
}
|
||||
payment.setReceived(payment.getAmount());
|
||||
payment.setChangeFee(BigDecimal.ZERO);
|
||||
// payment.setMemberId(orderInfo.getMemberId());//会员Id
|
||||
payment.setShopId(orderInfo.getShopId().toString());
|
||||
payment.setOrderId(orderInfo.getId().toString());
|
||||
payment.setCreatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.insert(payment);
|
||||
} else {
|
||||
if (payType.equals("wechatPay")) {
|
||||
payment.setPayName("微信支付");
|
||||
payment.setPayType("wechatPay");
|
||||
} else if (payType.equals("aliPay")) {
|
||||
payment.setPayName("支付宝支付");
|
||||
payment.setPayType("aliPay");
|
||||
}
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKey(payment);
|
||||
}
|
||||
|
||||
PayReq req = new PayReq();
|
||||
|
||||
req.setAppId(thirdApply.getAppId());
|
||||
req.setTimestamp(System.currentTimeMillis());
|
||||
req.setIp(ip);
|
||||
req.setMercOrderNo(orderInfo.getOrderNo());
|
||||
req.setNotifyUrl(callBackGroupurl);
|
||||
req.setPayAmt(payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
|
||||
if (payType.equals("wechatPay")) {
|
||||
req.setPayType("03");
|
||||
req.setPayWay("WXZF");//WXZF ZFBZF UNIONPAY
|
||||
} else if (payType.equals("aliPay")) {
|
||||
req.setPayWay("ZFBZF");
|
||||
}
|
||||
req.setSubject("零点八零:团购卷");
|
||||
req.setUserId(userId);
|
||||
|
||||
|
||||
Map<String, Object> map = BeanUtil.transBeanMap(req);
|
||||
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url.concat("trans/pay"), req, String.class);
|
||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
if (object.get("code").equals("0")) {
|
||||
payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
orderInfo.setPayType(payType);
|
||||
orderInfo.setStatus("paying");
|
||||
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
tbGroupOrderInfoMapper.update(orderInfo);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "success");
|
||||
jsonObject1.put("msg", "成功");
|
||||
jsonObject1.put("type", "");
|
||||
jsonObject1.put("data", new JSONArray());
|
||||
jsonObject1.put("amount", 0);
|
||||
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
||||
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
||||
} else {
|
||||
return Result.fail(object.getString("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
return Result.fail("失败");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result accountPay(String orderId, String userId, String shopId,String pwd) {
|
||||
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(userId)||ObjectUtil.isEmpty(shopId)||ObjectUtil.isEmpty(pwd)) {
|
||||
public Result returnOrder(ReturnGroupOrderDto param) {
|
||||
TbGroupOrderInfo groupOrderInfo = tbGroupOrderInfoMapper.queryById(param.getOrderId());
|
||||
List<TbGroupOrderCoupon> tbGroupOrderCoupons = orderCouponService.queryNoRefundByOrderId(param.getOrderId());
|
||||
if (param.getNum() > tbGroupOrderCoupons.size()) {
|
||||
return Result.fail("可退数量不足");
|
||||
}
|
||||
for (int i = 0; i < param.getNum(); i++) {
|
||||
TbGroupOrderCoupon coupon = tbGroupOrderCoupons.get(i);
|
||||
coupon.setIsRefund(1);
|
||||
coupon.setRefundAmount(param.getRefundAmount());
|
||||
coupon.setRefundDesc(param.getRefundDesc());
|
||||
coupon.setRefundReason(param.getRefundReason());
|
||||
orderCouponService.update(coupon);
|
||||
}
|
||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(groupOrderInfo.getMerchantId());
|
||||
MsgException.checkNull(thirdApply, "支付参数配置错误");
|
||||
ReturnOrderReq req = new ReturnOrderReq();
|
||||
req.setAppId(thirdApply.getAppId());
|
||||
req.setTimestamp(System.currentTimeMillis());
|
||||
req.setOrderNumber(groupOrderInfo.getPayOrderNo());
|
||||
req.setAmount(param.getRefundAmount().toString());
|
||||
req.setMercRefundNo(groupOrderInfo.getOrderNo());
|
||||
req.setRefundReason("团购卷:退货");
|
||||
req.setPayPassword(thirdApply.getPayPassword());
|
||||
Map<String, Object> map = BeanUtil.transBean2Map(req);
|
||||
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
log.info("groupOrderReturn req:{}", JSONUtil.toJsonStr(req));
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url.concat("merchantOrder/returnOrder"), req, String.class);
|
||||
log.info("groupOrderReturn:{}", response.getBody());
|
||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
if (!object.get("code").equals("0")) {
|
||||
MsgException.check(true, "退款渠道调用失败");
|
||||
}
|
||||
}
|
||||
groupOrderInfo.setRefundNumber(groupOrderInfo.getRefundNumber() + param.getNum());
|
||||
groupOrderInfo.setRefundAmount(groupOrderInfo.getRefundAmount().add(param.getRefundAmount()));
|
||||
if (groupOrderInfo.getNumber() == groupOrderInfo.getRefundNumber()) {
|
||||
groupOrderInfo.setRefundAble(0);
|
||||
groupOrderInfo.setStatus("refund");
|
||||
}
|
||||
tbGroupOrderInfoMapper.update(groupOrderInfo);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result accountPay(String orderId, String userId, String shopId, String pwd) {
|
||||
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(pwd)) {
|
||||
return Result.fail("参数错误");
|
||||
}
|
||||
|
||||
@@ -210,18 +384,18 @@ public class PayService {
|
||||
return Result.fail("当前店铺未开通储值卡支付");
|
||||
}
|
||||
|
||||
TbShopUser user = tbShopUserMapper.selectByUserIdAndShopId(userId,shopId);
|
||||
TbShopUser user = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
||||
|
||||
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
||||
return Result.fail("此用户非会员用户");
|
||||
}
|
||||
|
||||
|
||||
if("1".equals(user.getIsPwd())){
|
||||
if ("1".equals(user.getIsPwd())) {
|
||||
return Result.fail("会员支付密码为初始化密码");
|
||||
}
|
||||
|
||||
if(!MD5Util.encrypt(pwd).equals(user.getPwd())){
|
||||
if (!MD5Util.encrypt(pwd).equals(user.getPwd())) {
|
||||
return Result.fail("会员支付密码错误");
|
||||
}
|
||||
|
||||
@@ -254,12 +428,12 @@ public class PayService {
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
|
||||
int cartCount= tbCashierCartMapper.updateStatusByOrderId(orderId.toString(),"final");
|
||||
int cartCount = tbCashierCartMapper.updateStatusByOrderId(orderId.toString(), "final");
|
||||
|
||||
log.info("更新购物车:{}",cartCount);
|
||||
log.info("更新购物车:{}", cartCount);
|
||||
|
||||
//更新子单状态
|
||||
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId),"closed");
|
||||
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
|
||||
|
||||
//修改主单状态
|
||||
orderInfo.setStatus("closed");
|
||||
@@ -269,10 +443,10 @@ public class PayService {
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("token",0);
|
||||
jsonObject.put("type","wxcreate");
|
||||
jsonObject.put("orderId",orderInfo.getId().toString());
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", 0);
|
||||
jsonObject.put("type", "wxcreate");
|
||||
jsonObject.put("orderId", orderInfo.getId().toString());
|
||||
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
@@ -284,48 +458,48 @@ public class PayService {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result modifyOrderStatus(Integer orderId) throws IOException {
|
||||
TbOrderInfo orderInfo= tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||
if(ObjectUtil.isEmpty(orderInfo)){
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||
return Result.fail("订单信息不存在");
|
||||
}
|
||||
|
||||
if("paying".equals(orderInfo.getStatus())){
|
||||
TbOrderPayment payment= tbOrderPaymentMapper.selectByOrderId(orderInfo.getId().toString());
|
||||
if(ObjectUtil.isNotEmpty(payment)&&ObjectUtil.isNotEmpty(payment.getTradeNumber())){
|
||||
if ("paying".equals(orderInfo.getStatus())) {
|
||||
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderInfo.getId().toString());
|
||||
if (ObjectUtil.isNotEmpty(payment) && ObjectUtil.isNotEmpty(payment.getTradeNumber())) {
|
||||
|
||||
TbMerchantThirdApply thirdApply= tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
||||
|
||||
if(ObjectUtil.isEmpty(thirdApply)||ObjectUtil.isNull(thirdApply)){
|
||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||
return Result.fail("支付通道不存在");
|
||||
}
|
||||
TradeQueryReq req=new TradeQueryReq();
|
||||
TradeQueryReq req = new TradeQueryReq();
|
||||
req.setAppId(thirdApply.getAppId());
|
||||
req.setTimestamp(System.currentTimeMillis());
|
||||
req.setOrderNumber(payment.getTradeNumber());
|
||||
Map<String,Object> map= BeanUtil.transBeanMap(req);
|
||||
Map<String, Object> map = BeanUtil.transBeanMap(req);
|
||||
|
||||
req.setSign(MD5Util.encrypt(map,thirdApply.getAppToken(),true));
|
||||
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
|
||||
ResponseEntity<String> response= restTemplate.postForEntity(url.concat("merchantOrder/tradeQuery"),req,String.class);
|
||||
if(response.getStatusCodeValue()==200&&ObjectUtil.isNotEmpty(response.getBody())){
|
||||
JSONObject object=JSONObject.parseObject(response.getBody());
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url.concat("merchantOrder/tradeQuery"), req, String.class);
|
||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
|
||||
if(object.get("code").equals("0")){
|
||||
JSONObject data=object.getJSONObject("data");
|
||||
String status=data.getString("status");
|
||||
String cartStatus="";
|
||||
switch (status){
|
||||
if (object.get("code").equals("0")) {
|
||||
JSONObject data = object.getJSONObject("data");
|
||||
String status = data.getString("status");
|
||||
String cartStatus = "";
|
||||
switch (status) {
|
||||
case "0": //交易失败
|
||||
break;
|
||||
case "1": //交易成功
|
||||
|
||||
//修改数据库中购物车数据
|
||||
int cartCount= tbCashierCartMapper.updateStatusByOrderId(orderId.toString(),"final");
|
||||
int cartCount = tbCashierCartMapper.updateStatusByOrderId(orderId.toString(), "final");
|
||||
|
||||
log.info("更新购物车:{}",cartCount);
|
||||
log.info("更新购物车:{}", cartCount);
|
||||
|
||||
//更新子单状态
|
||||
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId),"closed");
|
||||
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
|
||||
|
||||
//修改主单状态
|
||||
orderInfo.setStatus("closed");
|
||||
@@ -335,76 +509,72 @@ public class PayService {
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("token",0);
|
||||
jsonObject.put("type","wxcreate");
|
||||
jsonObject.put("orderId",orderInfo.getId().toString());
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", 0);
|
||||
jsonObject.put("type", "wxcreate");
|
||||
jsonObject.put("orderId", orderInfo.getId().toString());
|
||||
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
|
||||
|
||||
log.info("发送打印数据");
|
||||
producer.printMechine(orderInfo.getId() + "");
|
||||
log.info("发送赠送购物券");
|
||||
JSONObject coupons = new JSONObject();
|
||||
coupons.put("type","buy");
|
||||
coupons.put("orderId",orderId);
|
||||
coupons.put("type", "buy");
|
||||
coupons.put("orderId", orderId);
|
||||
producer.printCoupons(coupons.toJSONString());
|
||||
return Result.success(CodeEnum.SUCCESS,orderId);
|
||||
return Result.success(CodeEnum.SUCCESS, orderId);
|
||||
case "2": //退款成功
|
||||
cartStatus="refund";
|
||||
cartStatus = "refund";
|
||||
orderInfo.setStatus("refund");
|
||||
break;
|
||||
case "3": //退款失败
|
||||
break;
|
||||
case "4": //退款中
|
||||
cartStatus="refunding";
|
||||
cartStatus = "refunding";
|
||||
orderInfo.setStatus("refunding");
|
||||
break;
|
||||
}
|
||||
|
||||
tbCashierCartMapper.updateStatusByOrderId(orderId.toString(),cartStatus);
|
||||
tbCashierCartMapper.updateStatusByOrderId(orderId.toString(), cartStatus);
|
||||
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS,orderId);
|
||||
return Result.success(CodeEnum.SUCCESS, orderId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result memberIn(String openId,String userId,String amount,String shopId,String ip){
|
||||
if(ObjectUtil.isEmpty(openId)||ObjectUtil.isEmpty(userId)){
|
||||
public Result memberIn(String openId, String userId, String amount, String shopId, String ip) {
|
||||
if (ObjectUtil.isEmpty(openId) || ObjectUtil.isEmpty(userId)) {
|
||||
return Result.fail("用户信息允许为空");
|
||||
}
|
||||
|
||||
|
||||
TbShopUser tbShopUser= tbShopUserMapper.selectByUserIdAndShopId(userId,shopId);
|
||||
if(ObjectUtil.isEmpty(tbShopUser)){
|
||||
TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
||||
if (ObjectUtil.isEmpty(tbShopUser)) {
|
||||
return Result.fail("对应的用户信息不存在");
|
||||
}
|
||||
|
||||
|
||||
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
||||
if(ObjectUtil.isEmpty(shopInfo)){
|
||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
||||
if (ObjectUtil.isEmpty(shopInfo)) {
|
||||
return Result.fail("对应的店铺信息不存在");
|
||||
}
|
||||
|
||||
|
||||
|
||||
TbMerchantThirdApply thirdApply= tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId()));
|
||||
if(ObjectUtil.isEmpty(thirdApply)||ObjectUtil.isNull(thirdApply)){
|
||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId()));
|
||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||
return Result.fail("支付通道不存在");
|
||||
}
|
||||
|
||||
BigDecimal payAmount= new BigDecimal(amount).setScale(2,BigDecimal.ROUND_DOWN);
|
||||
BigDecimal payAmount = new BigDecimal(amount).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
|
||||
TbMemberIn memberIn=new TbMemberIn();
|
||||
TbMemberIn memberIn = new TbMemberIn();
|
||||
memberIn.setAmount(payAmount);
|
||||
memberIn.setUserId(Integer.valueOf(tbShopUser.getUserId()));
|
||||
memberIn.setCode(tbShopUser.getDynamicCode());
|
||||
@@ -415,8 +585,7 @@ public class PayService {
|
||||
tbMemberInMapper.insert(memberIn);
|
||||
|
||||
|
||||
|
||||
PayReq req=new PayReq();
|
||||
PayReq req = new PayReq();
|
||||
|
||||
req.setAppId(thirdApply.getAppId());
|
||||
req.setTimestamp(System.currentTimeMillis());
|
||||
@@ -430,26 +599,49 @@ public class PayService {
|
||||
req.setUserId(openId);
|
||||
|
||||
|
||||
Map<String,Object> map= BeanUtil.transBeanMap(req);
|
||||
req.setSign(MD5Util.encrypt(map,thirdApply.getAppToken(),true));
|
||||
Map<String, Object> map = BeanUtil.transBeanMap(req);
|
||||
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
|
||||
ResponseEntity<String> response= restTemplate.postForEntity(url.concat("trans/pay"),req,String.class);
|
||||
if(response.getStatusCodeValue()==200&&ObjectUtil.isNotEmpty(response.getBody())){
|
||||
JSONObject object=JSONObject.parseObject(response.getBody());
|
||||
if(object.get("code").equals("0")){
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url.concat("trans/pay"), req, String.class);
|
||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
if (object.get("code").equals("0")) {
|
||||
memberIn.setOrderNo(object.getJSONObject("data").get("orderNumber").toString());
|
||||
memberIn.setUpdateTime(new Date());
|
||||
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS,object.getJSONObject("data"));
|
||||
}else {
|
||||
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
||||
} else {
|
||||
return Result.fail(object.getString("msg"));
|
||||
}
|
||||
}
|
||||
return Result.fail("失败");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String callBackGroupPay(String payOrderNO) {
|
||||
TbGroupOrderInfo orderInfo = tbGroupOrderInfoMapper.selectByPayOrderNo(payOrderNO);
|
||||
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||
return "订单信息不存在";
|
||||
}
|
||||
|
||||
if ("paying".equals(orderInfo.getStatus())) {
|
||||
for (int i = 0; i < orderInfo.getNumber(); i++) {
|
||||
TbGroupOrderCoupon groupOrderCoupon = new TbGroupOrderCoupon();
|
||||
groupOrderCoupon.setOrderId(orderInfo.getId());
|
||||
groupOrderCoupon.setCouponNo(genCouponNumber());
|
||||
groupOrderCoupon.setIsRefund(0);
|
||||
groupOrderCouponService.insert(groupOrderCoupon);
|
||||
}
|
||||
orderInfo.setExpDate(getNextMonDate());
|
||||
//修改主单状态
|
||||
orderInfo.setStatus("unused");
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
tbGroupOrderInfoMapper.update(orderInfo);
|
||||
return "SUCCESS";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String callBackPay(String payOrderNO) {
|
||||
@@ -474,10 +666,10 @@ public class PayService {
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("token",0);
|
||||
jsonObject.put("type","wxcreate");
|
||||
jsonObject.put("orderId",orderInfo.getId().toString());
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", 0);
|
||||
jsonObject.put("type", "wxcreate");
|
||||
jsonObject.put("orderId", orderInfo.getId().toString());
|
||||
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
@@ -492,10 +684,10 @@ public class PayService {
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String minsuccess(String payOrderNO,String tradeNo){
|
||||
public String minsuccess(String payOrderNO, String tradeNo) {
|
||||
|
||||
TbMemberIn memberIn= tbMemberInMapper.selectByOrderNo(payOrderNO);
|
||||
if(ObjectUtil.isEmpty(memberIn)){
|
||||
TbMemberIn memberIn = tbMemberInMapper.selectByOrderNo(payOrderNO);
|
||||
if (ObjectUtil.isEmpty(memberIn)) {
|
||||
return "充值记录不存在";
|
||||
}
|
||||
|
||||
@@ -504,8 +696,8 @@ public class PayService {
|
||||
memberIn.setUpdateTime(new Date());
|
||||
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
|
||||
|
||||
TbShopUser tbShopUser= tbShopUserMapper.selectByUserIdAndShopId(memberIn.getUserId().toString(),memberIn.getShopId().toString());
|
||||
if(ObjectUtil.isEmpty(tbShopUser)){
|
||||
TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(memberIn.getUserId().toString(), memberIn.getShopId().toString());
|
||||
if (ObjectUtil.isEmpty(tbShopUser)) {
|
||||
return "用户信息不存在";
|
||||
}
|
||||
|
||||
@@ -515,7 +707,7 @@ public class PayService {
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
|
||||
TbShopUserFlow flow=new TbShopUserFlow();
|
||||
TbShopUserFlow flow = new TbShopUserFlow();
|
||||
flow.setShopUserId(Integer.valueOf(tbShopUser.getId()));
|
||||
flow.setBizCode("scanMemberIn");
|
||||
flow.setBizName("会员扫码充值");
|
||||
@@ -531,20 +723,48 @@ public class PayService {
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* 生成长度为12的随机串
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String genCouponNumber() {
|
||||
Random random = new Random();
|
||||
long min = 10000000000L;
|
||||
long max = 19999999999L;
|
||||
// 生成介于min和max之间的随机整数
|
||||
long randomNumber = min + ((long) (random.nextDouble() * (max - min)));
|
||||
// 将随机整数转换为字符串,并在前面补0,直到长度为12位
|
||||
return String.format("%012d", randomNumber);
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
/**
|
||||
* 获取一个月后的时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Date getNextMonDate() {
|
||||
// 获取当前日期和时间
|
||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
// 计算一个月后的日期和时间
|
||||
LocalDateTime nextMonthDateTime = currentDateTime.plusMonths(1);
|
||||
return java.sql.Timestamp.valueOf(nextMonthDateTime);
|
||||
}
|
||||
|
||||
RestTemplate restTemplate1= new RestTemplate();
|
||||
JSONObject param=new JSONObject();
|
||||
|
||||
String priv="MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIqNqTqhN8zE7eFZnwKcyBTENce2wdAtl/gaDHNuNVgg33dS27Jx0fKl9QSHXyzyxbAdG8F94niYbRBstrMymFRjuO72jH+rIH62Ym1k7l8JSLVK2dKHXt8lHDaQGUP10q0EEocnDQ9cL93oBNG1ttsV6vOAu1TPvRK9TGihRAe1AgMBAAECgYBmI8KCl0DkcrSOsRvYuC2DqZWf8el1B3eFjeZp3e/zVOCIPYv6Q5ArWg6DVSxjnWEA0KSagqvGjU+xkQMqnXzPcPMhsIS+1wyR/pP+pwiatO2ioHaQpEqHg9eXhxrgA477/xuKVw9zl5GNqaIgd++2NDXnqLh0Y6OR73f0OB5eDQJBAPihEm+UWLOam/Q/k2+k4Lm2dvxJTBur1fslBiJpgMhgcz/PlwRwpL7aPD0AuPv0NqLouuoTiKpq9icnUv12tgsCQQCOqTANw0IErCHUNdinjXewmG3ui1j9XgM41rSn5ZeTrPL4GhZc2zbS/pZT4PBKUL6NLGkfPHmw4rOmNL/Xc5E/AkBqAwQBX5eSvVHSC2mqKPtJNGv3lqlFAzfyJg8/jQzEY5vAkZsq4Xzdg+A7gptdkvvY6rMIK9wSDhl3CGVyfbORAkA1N+g1OiHmnFACWhP4bU25EyPvWQxZeDi7e1zpRTzGWj5JT3IIMb7B9zcdE0yQbI6pG2gbvvOmiOt7lTH7raEBAkBas2gugvR3f0aGqQcqMpyM627pyRppQ2h58/7KBylP3oR2BReqMUcXeiJ8TuBXzbRXpeVQ0DWOva5CWZJmBMdz";
|
||||
public static void main(String[] args) {
|
||||
|
||||
PayReq req=new PayReq();
|
||||
RestTemplate restTemplate1 = new RestTemplate();
|
||||
JSONObject param = new JSONObject();
|
||||
|
||||
String priv = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIqNqTqhN8zE7eFZnwKcyBTENce2wdAtl/gaDHNuNVgg33dS27Jx0fKl9QSHXyzyxbAdG8F94niYbRBstrMymFRjuO72jH+rIH62Ym1k7l8JSLVK2dKHXt8lHDaQGUP10q0EEocnDQ9cL93oBNG1ttsV6vOAu1TPvRK9TGihRAe1AgMBAAECgYBmI8KCl0DkcrSOsRvYuC2DqZWf8el1B3eFjeZp3e/zVOCIPYv6Q5ArWg6DVSxjnWEA0KSagqvGjU+xkQMqnXzPcPMhsIS+1wyR/pP+pwiatO2ioHaQpEqHg9eXhxrgA477/xuKVw9zl5GNqaIgd++2NDXnqLh0Y6OR73f0OB5eDQJBAPihEm+UWLOam/Q/k2+k4Lm2dvxJTBur1fslBiJpgMhgcz/PlwRwpL7aPD0AuPv0NqLouuoTiKpq9icnUv12tgsCQQCOqTANw0IErCHUNdinjXewmG3ui1j9XgM41rSn5ZeTrPL4GhZc2zbS/pZT4PBKUL6NLGkfPHmw4rOmNL/Xc5E/AkBqAwQBX5eSvVHSC2mqKPtJNGv3lqlFAzfyJg8/jQzEY5vAkZsq4Xzdg+A7gptdkvvY6rMIK9wSDhl3CGVyfbORAkA1N+g1OiHmnFACWhP4bU25EyPvWQxZeDi7e1zpRTzGWj5JT3IIMb7B9zcdE0yQbI6pG2gbvvOmiOt7lTH7raEBAkBas2gugvR3f0aGqQcqMpyM627pyRppQ2h58/7KBylP3oR2BReqMUcXeiJ8TuBXzbRXpeVQ0DWOva5CWZJmBMdz";
|
||||
|
||||
PayReq req = new PayReq();
|
||||
|
||||
req.setAppId("M8002023120892f1e4");
|
||||
req.setTimestamp(System.currentTimeMillis());
|
||||
req.setIp("127.0.0.1");
|
||||
req.setMercOrderNo(System.currentTimeMillis()+"");
|
||||
req.setMercOrderNo(System.currentTimeMillis() + "");
|
||||
req.setNotifyUrl("https");
|
||||
req.setPayAmt("0.01");
|
||||
req.setPayType("03");
|
||||
@@ -552,13 +772,12 @@ public class PayService {
|
||||
req.setSubject("ddd");
|
||||
req.setUserId("or1l864NBOoJZhC5x_yeziZ26j6c");
|
||||
|
||||
Map<String,Object> map= BeanUtil.transBeanMap(req);
|
||||
Map<String, Object> map = BeanUtil.transBeanMap(req);
|
||||
|
||||
req.setSign(MD5Util.encrypt(map,priv,true));
|
||||
req.setSign(MD5Util.encrypt(map, priv, true));
|
||||
|
||||
|
||||
ResponseEntity<String> response= restTemplate1.postForEntity("https://gatewaytestapi.sxczgkj.cn/gate-service/trans/pay",req,String.class);
|
||||
|
||||
ResponseEntity<String> response = restTemplate1.postForEntity("https://gatewaytestapi.sxczgkj.cn/gate-service/trans/pay", req, String.class);
|
||||
|
||||
|
||||
// TradeQueryReq req=new TradeQueryReq();
|
||||
@@ -572,11 +791,8 @@ public class PayService {
|
||||
// ResponseEntity<String> response= restTemplate1.postForEntity("https://gateway.api.sxczgkj.cn/gate-service/merchantOrder/tradeQuery",req,String.class);
|
||||
//
|
||||
//
|
||||
System.out.println(">>>>>>>>>>>>>>>"+response.getBody());
|
||||
System.out.println(">>>>>>>>>>>>>>>" + response.getBody());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,16 +10,14 @@ import com.chaozhanggui.system.cashierservice.entity.vo.*;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.socket.AppWebSocketServer;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.LocationUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.Threads;
|
||||
import com.chaozhanggui.system.cashierservice.util.*;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
@@ -64,6 +62,13 @@ public class ProductService {
|
||||
@Autowired
|
||||
TbProductSkuMapper tbProductSkuMapper;
|
||||
|
||||
public Result queryShopIdByTableCode(String code) {
|
||||
String shopId = tbShopTableMapper.queryShopIdByTableCode(code);
|
||||
if (StringUtils.isBlank(shopId)) {
|
||||
return Result.fail("台桌信息不存在");
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS, shopId);
|
||||
}
|
||||
|
||||
public Result queryProduct(String code, String productGroupId) {
|
||||
|
||||
@@ -142,17 +147,40 @@ public class ProductService {
|
||||
* 销量榜
|
||||
* 咖啡饮品
|
||||
*/
|
||||
public PageInfo products(HomeDto homeDto) throws ExecutionException, InterruptedException {
|
||||
public PageInfo products(HomeDto homeDto) {
|
||||
if (homeDto.getOrderBy() == 5) {
|
||||
homeDto.setPage(1);
|
||||
homeDto.setSize(4);
|
||||
}
|
||||
PageHelper.startPage(homeDto.getPage(), homeDto.getSize());
|
||||
//经纬度(附近一km)
|
||||
Map<String, double[]> topAndBottomMap = LocationUtils.returnLLSquarePoint(
|
||||
Double.parseDouble(homeDto.getLng()), Double.parseDouble(homeDto.getLat()), homeDto.getDistanceInKm());
|
||||
|
||||
List<ShopGroupInfoVo> shopGroupInfoVos = tbProductMapper.selGroups(
|
||||
homeDto.getType(),
|
||||
topAndBottomMap.get("rightTopPoint")[1], topAndBottomMap.get("rightTopPoint")[0],
|
||||
topAndBottomMap.get("leftBottomPoint")[1], topAndBottomMap.get("leftBottomPoint")[0],
|
||||
homeDto.getAddress(), homeDto.getOrderBy().toString(), homeDto.getLng(), homeDto.getLat());
|
||||
Long stTime = null;
|
||||
Long enTime = null;
|
||||
List<ShopGroupInfoVo> shopGroupInfoVos = new ArrayList<>();
|
||||
if (homeDto.getOrderBy() == 4) {
|
||||
if (homeDto.getDateType() == 0) {
|
||||
stTime = DateUtils.getDayStartLong();
|
||||
enTime = DateUtils.getDayEndLong();
|
||||
} else if (homeDto.getDateType() == 1) {
|
||||
enTime = System.currentTimeMillis();
|
||||
stTime = enTime - 3600000L * 2;
|
||||
}
|
||||
shopGroupInfoVos = tbProductMapper.selHotGroups(
|
||||
homeDto.getType(),
|
||||
DateUtils.getStrTime(new Date(stTime)), DateUtils.getStrTime(new Date(enTime)),
|
||||
homeDto.getAddress(), homeDto.getOrderBy().toString(), homeDto.getLng(), homeDto.getLat());
|
||||
} else {
|
||||
shopGroupInfoVos = tbProductMapper.selGroups(
|
||||
homeDto.getType(),
|
||||
topAndBottomMap.get("rightTopPoint")[1], topAndBottomMap.get("rightTopPoint")[0],
|
||||
topAndBottomMap.get("leftBottomPoint")[1], topAndBottomMap.get("leftBottomPoint")[0],
|
||||
homeDto.getAddress(), homeDto.getOrderBy().toString(), homeDto.getLng(), homeDto.getLat());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(shopGroupInfoVos)) {
|
||||
return new PageInfo();
|
||||
}
|
||||
List<Integer> productIds = shopGroupInfoVos.stream().map(ShopGroupInfoVo::getProId).collect(Collectors.toList());
|
||||
List<String> stringList = productIds.stream()
|
||||
.map(Object::toString) // 将 Integer 对象映射为 String 对象
|
||||
@@ -196,7 +224,7 @@ public class ProductService {
|
||||
homeVO.setDiscount(BigDecimal.ZERO);
|
||||
} else {
|
||||
homeVO.setOriginPrice(tbProductSku.getOriginPrice());
|
||||
homeVO.setDiscount(tbProductSku.getOriginPrice().divide(tbProductSku.getSalePrice(), 2, RoundingMode.DOWN).multiply(BigDecimal.TEN));
|
||||
homeVO.setDiscount(BigDecimalUtils.getDiscount(tbProductSku.getOriginPrice(), tbProductSku.getSalePrice()));
|
||||
}
|
||||
//销量
|
||||
homeVO.setRealSalesNumber(new BigDecimal(o.getNumber()));
|
||||
@@ -225,15 +253,13 @@ public class ProductService {
|
||||
* @throws Exception
|
||||
*/
|
||||
public Result productInfo(Integer productId, String lat, String lng, String environment) throws Exception {
|
||||
CompletableFuture<TbProduct> product = CompletableFuture.supplyAsync(() ->
|
||||
tbProductMapper.selectById(productId));
|
||||
CompletableFuture<TbProductWithBLOBs> product = CompletableFuture.supplyAsync(() ->
|
||||
tbProductMapper.selectByPrimaryKey(productId));
|
||||
CompletableFuture<List<TbProductSku>> productSku = CompletableFuture.supplyAsync(() ->
|
||||
tbProductSkuMapper.selectSku(productId.toString()));
|
||||
CompletableFuture<List<TagProductVO>> dictPro = CompletableFuture.supplyAsync(() ->
|
||||
tagProductDeptsMapper.queryTagByProductId(productId.toString()));
|
||||
Threads.call(product, productSku, dictPro);
|
||||
Threads.call(product, productSku);
|
||||
|
||||
TbProduct tbProduct = product.get();
|
||||
TbProductWithBLOBs tbProduct = product.get();
|
||||
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbProduct.getShopId()));
|
||||
TbPurchaseNotice tbPurchaseNotice = purchaseNoticeMapper.queryByCouponId(tbProduct.getId());
|
||||
|
||||
@@ -254,7 +280,7 @@ public class ProductService {
|
||||
productInfo.setDiscount(BigDecimal.ZERO);
|
||||
} else {
|
||||
productInfo.setOriginPrice(tbProductSku.getSalePrice());
|
||||
productInfo.setDiscount(tbProductSku.getOriginPrice().divide(tbProductSku.getSalePrice(), 2, RoundingMode.DOWN).multiply(BigDecimal.TEN));
|
||||
productInfo.setDiscount(BigDecimalUtils.getDiscount(tbProductSku.getOriginPrice(), tbProductSku.getSalePrice()));
|
||||
}
|
||||
//现价
|
||||
productInfo.setSalePrice(new BigDecimal(tbProductSku.getSalePrice().toString()));
|
||||
@@ -264,34 +290,33 @@ public class ProductService {
|
||||
//名称
|
||||
productInfo.setProductName(tbProduct.getName());
|
||||
//店铺
|
||||
productInfo.setShopName(tbShopInfo.getShopName() + (StringUtils.isNotBlank(tbShopInfo.getChainName()) ? "(" + tbShopInfo.getChainName() + ")" : ""));
|
||||
productInfo.setShopName(tbShopInfo.getShopName());
|
||||
if (StringUtils.isNotBlank(tbShopInfo.getChainName())) {
|
||||
productInfo.setChainName(tbShopInfo.getChainName());
|
||||
Integer i = tbShopInfoMapper.selNumByChain(tbShopInfo.getChainName());
|
||||
productInfo.setShopNum(i);
|
||||
}
|
||||
productInfo.setPhone(tbShopInfo.getPhone());
|
||||
productInfo.setBusinessTime(tbShopInfo.getBusinessTime());
|
||||
productInfo.setBusinessTime(tbShopInfo.getBusinessStartDay() + "至" + tbShopInfo.getBusinessEndDay() + " " + tbShopInfo.getBusinessTime());
|
||||
BigDecimal distance = LocationUtils.getDistanceFrom2LngLat(
|
||||
Double.parseDouble(lng), Double.parseDouble(lat),
|
||||
Double.parseDouble(tbShopInfo.getLng()), Double.parseDouble(tbShopInfo.getLat()));
|
||||
productInfo.setDistances(distance.toString());//距离
|
||||
productInfo.setAddress(tbShopInfo.getAddress());
|
||||
|
||||
//商品 暂时只做单商品
|
||||
ProductVo productVo = new ProductVo();
|
||||
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(tbProduct.getUnitId()));
|
||||
TbShopCategory tbShopCategory = categoryMapper.selectByPrimaryKey(Integer.valueOf(tbProduct.getCategoryId()));
|
||||
productVo.setTitle(tbShopCategory.getName());
|
||||
productVo.setNumber(1);
|
||||
ProductVo.Food food = new ProductVo.Food();
|
||||
food.setName(tbProduct.getName());
|
||||
food.setUnitName(tbShopUnit.getName());
|
||||
food.setLowPrice(tbProduct.getLowPrice());
|
||||
|
||||
for (TagProductVO tagProductVO : dictPro.get()) {
|
||||
food.getProTag().add(tagProductVO);
|
||||
List<ProductVo> productVos = JSONUtil.parseListTNewList(tbProduct.getGroupSnap(), ProductVo.class);
|
||||
for (ProductVo productVo : productVos) {
|
||||
for (ProductVo.Food good : productVo.getGoods()) {
|
||||
List<TagProductVO> dictPro = tagProductDeptsMapper.queryTagByProductId(good.getId().toString());
|
||||
good.setProTag(dictPro);
|
||||
}
|
||||
}
|
||||
productVo.getGoods().add(food);
|
||||
productInfo.getProductList().add(productVo);
|
||||
productInfo.setPurchaseNotice(tbPurchaseNotice);
|
||||
|
||||
productInfo.setProductList(productVos);
|
||||
|
||||
List<TbPlatformDict> tbPlatformDicts = platformDictMapper.queryAllByType("prodetail", environment);
|
||||
if (tbPurchaseNotice != null) {
|
||||
productInfo.setPurchaseNotice(tbPurchaseNotice);
|
||||
if (tbPurchaseNotice.getBookingType().startsWith("无需预约")) {
|
||||
List<TbPlatformDict> book = platformDictMapper.queryAllByType("prodetail-book", environment);
|
||||
tbPlatformDicts.addAll(book);
|
||||
@@ -311,15 +336,19 @@ public class ProductService {
|
||||
tbProductSkuMapper.selectSku(productId.toString()));
|
||||
CompletableFuture<TbPurchaseNotice> notice = CompletableFuture.supplyAsync(() ->
|
||||
purchaseNoticeMapper.queryByCouponId(productId));
|
||||
Threads.call(product, productSku,notice);
|
||||
Threads.call(product, productSku, notice);
|
||||
|
||||
TbProduct tbProduct = product.get();
|
||||
OrderConfirmVo confirmVo=new OrderConfirmVo();
|
||||
OrderConfirmVo confirmVo = new OrderConfirmVo();
|
||||
confirmVo.setProId(tbProduct.getId().toString());
|
||||
confirmVo.setShopId(tbProduct.getShopId());
|
||||
confirmVo.setProImg(tbProduct.getCoverImg());
|
||||
confirmVo.setProName(tbProduct.getName());
|
||||
|
||||
TbPurchaseNotice tbPurchaseNotice = notice.get();
|
||||
confirmVo.setAvaTime(tbPurchaseNotice.getAvailableTime());
|
||||
if (tbPurchaseNotice != null) {
|
||||
confirmVo.setAvaTime(tbPurchaseNotice.getAvailableTime());
|
||||
}
|
||||
|
||||
//价格组装
|
||||
for (TbProductSku tbProductSku : productSku.get()) {
|
||||
@@ -329,13 +358,15 @@ public class ProductService {
|
||||
confirmVo.setSave(tbProductSku.getSalePrice());
|
||||
} else {
|
||||
confirmVo.setOriginPrice(tbProductSku.getOriginPrice());
|
||||
confirmVo.setSave(tbProductSku.getSalePrice());
|
||||
confirmVo.setSave(tbProductSku.getOriginPrice().subtract(tbProductSku.getSalePrice()));
|
||||
}
|
||||
//现价=售价
|
||||
confirmVo.setSalePrice(tbProductSku.getSalePrice().subtract(tbProductSku.getOriginPrice()));
|
||||
confirmVo.setSalePrice(tbProductSku.getSalePrice());
|
||||
}
|
||||
List<TbPlatformDict> tbPlatformDicts = platformDictMapper.queryAllByType("order_confirm_no_counpon", environment);
|
||||
if (!CollectionUtils.isEmpty(tbPlatformDicts)) {
|
||||
confirmVo.setCouponDetail(JSONUtil.parseListTNewList(tbPlatformDicts, TagVo.class).get(0));
|
||||
}
|
||||
List<TbPlatformDict> tbPlatformDicts = platformDictMapper.queryAllByType("order_confirm_no_counpon",environment);
|
||||
confirmVo.setCouponDetail(JSONUtil.parseListTNewList(tbPlatformDicts, TagVo.class).get(0));
|
||||
return Result.success(CodeEnum.SUCCESS, confirmVo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user