Commit f6d7ceb5 by 张新旗

小程序,订单代码提交

parent ff5a1f6a
......@@ -32,5 +32,10 @@ public class AppController {
String openId = loginUser.getOpenId();
return AjaxResult.success(orderService.getMyOrder(openId));
}
@RequestMapping("/refundOrder")
public AjaxResult refundOrder(String orderId){
return AjaxResult.success(orderService.refundOrder(orderId));
}
}
......@@ -8,9 +8,9 @@ import com.ruoyi.system.jiguang.impl.JiGuangPushServiceImpl;
import com.ruoyi.system.service.impl.MachineServiceImpl;
import com.ruoyi.system.service.impl.OrderServiceImpl;
import com.ruoyi.system.service.impl.OrderTakingServiceImpl;
import com.ruoyi.system.service.impl.ShopServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -32,6 +32,8 @@ public class ApplicationController {
@Autowired
private OrderTakingServiceImpl orderTakingService;
@Autowired
private ShopServiceImpl shopService;
@Autowired
private OrderServiceImpl orderService;
@RequestMapping("/saveData")
public AjaxResult saveApplicationData(@RequestParam("machineCode")String machineCode, @RequestBody String body){
......@@ -70,4 +72,8 @@ public class ApplicationController {
public AjaxResult getOrderInfo(String machineCode){
return AjaxResult.success(orderService.getOrderInfo(machineCode));
}
@RequestMapping("/checkSku")
private AjaxResult checkSku(@RequestParam(required = false) String shopId,String skuId,@RequestParam(required = false) String machineCode){
return shopService.checkSku(shopId,skuId,machineCode);
}
}
package com.ruoyi.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -11,7 +11,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GoodsCategory;
import com.ruoyi.system.service.IGoodsCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
package com.ruoyi.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -11,7 +11,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Goods;
import com.ruoyi.system.service.IGoodsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
package com.ruoyi.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -18,7 +16,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Machine;
import com.ruoyi.system.service.IMachineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
package com.ruoyi.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -11,7 +11,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Material;
import com.ruoyi.system.service.IMaterialService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
......@@ -3,21 +3,18 @@ package com.ruoyi.web.controller.coffee;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.framework.web.service.WeixinServiceImpl;
import com.ruoyi.system.domain.OrderRefund;
import com.ruoyi.system.domain.vo.OrderQuery;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -28,7 +25,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.service.IOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
package com.ruoyi.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -18,7 +18,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OrderRefund;
import com.ruoyi.system.service.IOrderRefundService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
package com.ruoyi.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -18,7 +18,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Shop;
import com.ruoyi.system.service.IShopService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
package com.ruoyi.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.system.domain.Goods;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -14,7 +12,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ShopRecommend;
import com.ruoyi.system.service.IShopRecommendService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
package com.ruoyi.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -18,7 +18,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Spec;
import com.ruoyi.system.service.ISpecService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
package com.ruoyi.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -18,7 +18,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WechatUser;
import com.ruoyi.system.service.IWechatUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
......
......@@ -4,14 +4,14 @@ import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.QRCodeUtil;
import com.ruoyi.framework.web.service.WeixinServiceImpl;
import com.ruoyi.system.mapper.GoodsSkuMapper;
import com.ruoyi.system.service.impl.AppServiceImpl;
import com.ruoyi.system.service.impl.GoodsServiceImpl;
import com.ruoyi.system.service.impl.OrderTakingServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -25,6 +25,8 @@ public class WeixinController {
private AppServiceImpl appService;
@Autowired
private OrderTakingServiceImpl orderTakingService;
@Autowired
private GoodsServiceImpl goodsService;
//这个就是那个使用传code进来的接口
@PostMapping("/login")
......@@ -51,7 +53,7 @@ public class WeixinController {
}
@RequestMapping("/test")
public String test(){
return weixinService.test();
return goodsService.test();
}
@RequestMapping("/getShop")
......
......@@ -10,7 +10,6 @@ import com.ruoyi.common.config.RuoYiConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.google.code.kaptcha.Producer;
import com.ruoyi.common.constant.Constants;
......
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
......@@ -25,7 +23,6 @@ import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.SysUserRole;
......
......@@ -2,7 +2,6 @@ package com.ruoyi.web.controller.system;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.web.request.UserInfoQuery;
import org.apache.commons.lang3.ArrayUtils;
......@@ -17,7 +16,6 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
......@@ -28,7 +26,6 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
......
......@@ -158,4 +158,4 @@ push:
appkey: 123
secret: 123
machine:
url: http://xxxx:xxx/
url: http://47.94.247.71:10003
package com.ruoyi.system.domain.vo;
public class ResultVo {
private String code;
private String message;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
private String data;
}
package com.ruoyi.system.domain.vo.orderTaking;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
public class GoodsVo {
......@@ -49,13 +51,7 @@ public class GoodsVo {
this.discount = discount;
}
public String getPics() {
return pics;
}
public void setPics(String pics) {
this.pics = pics;
}
public String getDesc() {
return desc;
......@@ -73,14 +69,22 @@ public class GoodsVo {
this.remarks = remarks;
}
public String getTags() {
public List<String> getTags() {
return tags;
}
public void setTags(String tags) {
public void setTags(List<String> tags) {
this.tags = tags;
}
public JSONObject getPics() {
return pics;
}
public void setPics(JSONObject pics) {
this.pics = pics;
}
public String getSpecs() {
return specs;
......@@ -91,10 +95,10 @@ public class GoodsVo {
}
private String discount;
private String pics;
private JSONObject pics;
private String desc;
private String remarks;
private String tags;
private List<String> tags;
private String specs;
}
......@@ -22,7 +22,7 @@ public class AppServiceImpl {
Shop shop = new Shop();
shop.setState("1");
shop.setIsDefault(0L);
shop.setIsDefault(1);
shop.setIsDefault(1L);
List<Shop> shops = shopMapper.selectShopList(shop);
return shops;
......
......@@ -5,12 +5,12 @@ import java.util.List;
import com.ruoyi.common.utils.GenerateCode;
import com.ruoyi.system.domain.Goods;
import com.ruoyi.system.service.IGoodsCategoryService;
import com.ruoyi.system.mapper.GoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.GoodsCategoryMapper;
import com.ruoyi.system.domain.GoodsCategory;
import com.ruoyi.system.service.IGoodsCategoryService;
/**
* 商品分类Service业务层处理
......@@ -19,7 +19,7 @@ import com.ruoyi.system.service.IGoodsCategoryService;
* @date 2022-04-28
*/
@Service
public class GoodsCategoryServiceImpl implements IGoodsCategoryService
public class GoodsCategoryServiceImpl implements IGoodsCategoryService
{
@Autowired
private GoodsCategoryMapper goodsCategoryMapper;
......
......@@ -6,15 +6,15 @@ import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.GenerateCode;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.IGoodsService;
import com.ruoyi.system.mapper.*;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.service.IGoodsService;
import org.springframework.transaction.annotation.Transactional;
/**
......@@ -24,7 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2022-04-28
*/
@Service
public class GoodsServiceImpl implements IGoodsService
public class GoodsServiceImpl implements IGoodsService
{
@Autowired
private GoodsMapper goodsMapper;
......@@ -91,6 +91,7 @@ public class GoodsServiceImpl implements IGoodsService
goods.setCreatedAt(new Date());
goods.setUpdatedAt(new Date());
goods.setIsDeleted(0L);
goods.setState("2");
goodsMapper.insertGoods(goods);
insertgoodsExt(goods);
return 1;
......@@ -122,7 +123,7 @@ public class GoodsServiceImpl implements IGoodsService
}
}
}
createSku(ruleNodeList,goodsId,goods.getPrice());
createSku(ruleNodeList,goodsId,goods.getDiscount());
}
List<GoodsTag> goodsTagList = goods.getGoodsTagList();
if(goodsTagList!=null &&!goodsTagList.isEmpty()){
......@@ -141,7 +142,7 @@ public class GoodsServiceImpl implements IGoodsService
BigDecimal bigDecimal = new BigDecimal(price.toString());
RuleNode<SpecRule> parentRuleNode = ruleNode.getParentRuleNode();
specRuleList.add(ruleNode.getRuleNode());
bigDecimal.add(ruleNode.getRuleNode().getAmount());
bigDecimal = bigDecimal.add(ruleNode.getRuleNode().getAmount());
if(parentRuleNode!=null){
findPartentRuleNode(parentRuleNode,specRuleList,bigDecimal);
}
......@@ -158,7 +159,7 @@ public class GoodsServiceImpl implements IGoodsService
private void findPartentRuleNode(RuleNode<SpecRule> ruleRuleNode, List<SpecRule> specRuleList, BigDecimal bigDecimal) {
specRuleList.add(ruleRuleNode.getRuleNode());
bigDecimal.add(ruleRuleNode.getRuleNode().getAmount());
bigDecimal = bigDecimal.add(ruleRuleNode.getRuleNode().getAmount());
RuleNode<SpecRule> parentRuleNode = ruleRuleNode.getParentRuleNode();
if(parentRuleNode!=null){
findPartentRuleNode(parentRuleNode,specRuleList, bigDecimal);
......@@ -171,7 +172,6 @@ public class GoodsServiceImpl implements IGoodsService
if(childNode == null ||childNode.isEmpty()){
List<RuleNode> ruleNodes = new ArrayList<>();
ruleNode.setChildNode(ruleNodes);
ruleNodeList.clear();
for (SpecRule specRule : specRules) {
RuleNode<SpecRule> ruleNode1 = new RuleNode<>();
ruleNode1.setRuleNode(specRule);
......@@ -308,6 +308,13 @@ public class GoodsServiceImpl implements IGoodsService
}
public String test() {
Goods goods = goodsMapper.selectGoodsById("21");
insertgoodsExt(goods);
return null;
}
class RuleNode<T>{
......
......@@ -3,12 +3,11 @@ package com.ruoyi.system.service.impl;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.service.IMachineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MachineMapper;
import com.ruoyi.system.domain.Machine;
import com.ruoyi.system.service.IMachineService;
/**
* 机器Service业务层处理
......@@ -17,7 +16,7 @@ import com.ruoyi.system.service.IMachineService;
* @date 2022-04-28
*/
@Service
public class MachineServiceImpl implements IMachineService
public class MachineServiceImpl implements IMachineService
{
@Autowired
private MachineMapper machineMapper;
......
......@@ -6,14 +6,13 @@ import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.GenerateCode;
import com.ruoyi.system.domain.SpecRuleMaterial;
import com.ruoyi.system.service.IMaterialService;
import com.ruoyi.system.mapper.SpecMapper;
import com.ruoyi.system.mapper.SpecRuleMaterialMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MaterialMapper;
import com.ruoyi.system.domain.Material;
import com.ruoyi.system.service.IMaterialService;
import org.springframework.transaction.annotation.Transactional;
/**
* 原料Service业务层处理
......@@ -22,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2022-04-28
*/
@Service
public class MaterialServiceImpl implements IMaterialService
public class MaterialServiceImpl implements IMaterialService
{
@Autowired
private MaterialMapper materialMapper;
......
......@@ -11,19 +11,17 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.Machine;
import com.ruoyi.system.domain.OrderDetail;
import com.ruoyi.system.domain.ShopGoodsSku;
import com.ruoyi.system.service.IOrderService;
import com.ruoyi.system.domain.vo.OrderQuery;
import com.ruoyi.system.mapper.GoodsMapper;
import com.ruoyi.system.mapper.OrderDetailMapper;
import com.ruoyi.system.mapper.ShopGoodsSkuMapper;
import com.ruoyi.system.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.support.atomic.RedisAtomicInteger;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.OrderMapper;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.service.IOrderService;
import org.springframework.transaction.annotation.Transactional;
/**
......@@ -33,7 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2022-04-28
*/
@Service
public class OrderServiceImpl implements IOrderService
public class OrderServiceImpl implements IOrderService
{
@Autowired
private OrderMapper orderMapper;
......@@ -43,6 +41,10 @@ public class OrderServiceImpl implements IOrderService
private OrderDetailMapper orderDetailMapper;
@Autowired
private GoodsMapper goodsMapper;
@Autowired
private MachineMapper machineMapper;
@Autowired
private RobotServiceImpl robotService;
......@@ -94,20 +96,41 @@ public class OrderServiceImpl implements IOrderService
return result;
}
order.setState("1");
order.setUserId(loginUser.getOpenId());
order.setUserName(loginUser.getUsername());
order.setCreatedAt(new Date());
order.setOrderNum(getOrderNum(order.getShopId()));
order.setOrderNo(getOrderNo(order.getSource()));
String machineId = null;
if(StringUtils.isEmpty(order.getMachineId())){
Machine machine =new Machine();
machine.setShopId(Long.parseLong(order.getShopId()));
List<Machine> machines = machineMapper.selectMachineList(machine);
if(machines!=null &&!machines.isEmpty()){
Machine machine1 = machines.get(0);
if(!"1".equals(machine1)){
return AjaxResult.error("机器暂时不可用");
}
machineId = machine1.getCode();
order.setMachineId(machine1.getCode());
}else{
return AjaxResult.error("该店铺暂无绑定机器");
}
}
int i = orderMapper.insertOrder(order);
List<OrderDetail> orderDetails = order.getOrderDetails();
if(orderDetails !=null && !orderDetails.isEmpty()){
for (OrderDetail orderDetail : orderDetails) {
orderDetail.setOrderId(order.getId());
orderDetail.setCreatedAt(new Date());
orderDetail.setMachineId(machineId);
orderDetail.setUpdatedAt(new Date());
}
}
return AjaxResult.success();
//调用微信支付
//发送数据给机器
robotService.createOrder(order);
return AjaxResult.success(order.getOrderNo());
}
/**
......@@ -197,7 +220,7 @@ public class OrderServiceImpl implements IOrderService
String format = simpleDateFormat.format(new Date());
String redisKey = "shopId"+format+shopId;
RedisAtomicInteger redisAtomicInteger = new RedisAtomicInteger(redisKey,SpringUtils.getBean(StringRedisTemplate.class).getConnectionFactory());
redisAtomicInteger.set(40);
redisAtomicInteger.set(30);
redisAtomicInteger.expire(1, TimeUnit.DAYS);
int andIncrement = redisAtomicInteger.getAndIncrement();
return key+andIncrement;
......@@ -249,4 +272,17 @@ public class OrderServiceImpl implements IOrderService
return objects;
}
public String refundOrder(String orderId) {
Order order = orderMapper.selectOrderById(orderId);
List<String> status = Arrays.asList("2","3");
if(status.contains(order.getState())){
//todo 创建退款单,进行退款
}else{
//todo 创建退款单
}
return null;
}
}
......@@ -3,8 +3,6 @@ package com.ruoyi.system.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.vo.orderTaking.*;
import com.ruoyi.system.mapper.*;
......@@ -13,7 +11,6 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
......@@ -81,7 +78,7 @@ public class OrderTakingServiceImpl {
goodsVo.setSpecs(buildGoodsSpec(goodsVo.getSpecs()));
goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId()));
List<GoodsTag> goodsTags = goodsTagMapper.selectGoodsTagList(goodsTag);
String tags = JSONArray.toJSONString(goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList()));
List<String> tags = goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList());
goodsVo.setTags(tags);
//获取产品信息
List<SkuVo> skuVos = shopGoodsSkuMapper.selectSkuByGoodAndShop(shopId, goodsVo.getGoodsId());
......@@ -105,7 +102,7 @@ public class OrderTakingServiceImpl {
goodsVo.setDesc(good.getDesc());
goodsVo.setDiscount(good.getDiscount().stripTrailingZeros().toPlainString());
goodsVo.setPrice(good.getPrice().stripTrailingZeros().toPlainString());
goodsVo.setPics(good.getPics());
goodsVo.setPics(JSONObject.parseObject(good.getPics()));
goodsVo.setRemarks(good.getRemarks());
goodsVo.setSpecs(good.getSpec());
goodsVo.setSpecs(buildGoodsSpec(goodsVo.getSpecs()));
......@@ -113,7 +110,7 @@ public class OrderTakingServiceImpl {
goodsTag.setState("1");
goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId()));
List<GoodsTag> goodsTags = goodsTagMapper.selectGoodsTagList(goodsTag);
String tags = JSONArray.toJSONString(goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList()));
List<String> tags = goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList());
goodsVo.setTags(tags);
//获取产品信息
List<SkuVo> skuVos = shopGoodsSkuMapper.selectSkuByGoodAndShop(shopId, goodsVo.getGoodsId());
......@@ -142,7 +139,7 @@ public class OrderTakingServiceImpl {
goodsTag.setState("1");
goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId()));
List<GoodsTag> goodsTags = goodsTagMapper.selectGoodsTagList(goodsTag);
String tags = JSONArray.toJSONString(goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList()));
List<String> tags = goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList());
goodsVo.setTags(tags);
//获取产品信息
List<SkuVo> skuVos = shopGoodsSkuMapper.selectSkuByGoodAndShop(shopId, goodsVo.getGoodsId());
......
package com.ruoyi.system.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.domain.Order;
import com.ruoyi.system.domain.OrderDetail;
import com.ruoyi.system.domain.vo.ResultVo;
import com.ruoyi.system.mapper.OrderDetailMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;
@Service
@Slf4j
public class RobotServiceImpl {
@Value("machine.url")
private String url;
@Autowired
private RestTemplate restTemplate;
@Autowired
private OrderDetailMapper orderDetailMapper;
public void createOrder(Order order){
try{
String interfaceName = "/v1/order";
String postUrl = url+interfaceName;
String orderInfo = JSONObject.toJSONString(order);
log.info("请求创建订单接口:【{}】",orderInfo);
ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(postUrl, orderInfo, String.class);
log.info("请求创建订单接口返回结果为:【{}】",stringResponseEntity.getBody());
ResultVo resultVo = JSONObject.parseObject(stringResponseEntity.getBody(), ResultVo.class);
String code = resultVo.getCode();
if("2001".equals(code)){
throw new ServiceException("库存不足");
}else if("3001".equals(code)){
throw new ServiceException("机器繁忙");
}
}catch (Exception e){
log.error("请求发生异常:",e);
throw new ServiceException("服务器繁忙,请重试");
}
}
}
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.system.service.IShopGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ShopGoodsMapper;
import com.ruoyi.system.domain.ShopGoods;
import com.ruoyi.system.service.IShopGoodsService;
/**
* 店铺和商品关联Service业务层处理
......@@ -14,7 +15,7 @@ import com.ruoyi.system.service.IShopGoodsService;
* @date 2022-04-28
*/
@Service
public class ShopGoodsServiceImpl implements IShopGoodsService
public class ShopGoodsServiceImpl implements IShopGoodsService
{
@Autowired
private ShopGoodsMapper shopGoodsMapper;
......
......@@ -4,7 +4,6 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.domain.Goods;
import com.ruoyi.system.domain.Machine;
import com.ruoyi.system.mapper.MachineMapper;
......
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.IShopService;
import com.ruoyi.system.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.service.IShopService;
import org.springframework.transaction.annotation.Transactional;
/**
......@@ -25,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2022-04-28
*/
@Service
public class ShopServiceImpl implements IShopService
public class ShopServiceImpl implements IShopService
{
@Autowired
private ShopMapper shopMapper;
......@@ -233,6 +229,28 @@ public class ShopServiceImpl implements IShopService
}
public AjaxResult checkSku(String shopId, String skuId, String machineCode) {
ShopGoodsSku shopGoodsSku = new ShopGoodsSku();
shopGoodsSku.setSkuId(Long.parseLong(skuId));
if(StringUtils.isNotEmpty(shopId)){
shopGoodsSku.setShopId(Long.parseLong(shopId));
}
if(StringUtils.isNotEmpty(machineCode)){
shopGoodsSku.setMachineId(machineCode);
}
shopGoodsSku.setIsDeleted("0");
List<ShopGoodsSku> shopGoodsSkus = shopGoodsSkuMapper.selectShopGoodsSkuList(shopGoodsSku);
if(shopGoodsSkus ==null ||shopGoodsSkus.isEmpty()){
return AjaxResult.error("该产品已经不存在");
}else{
ShopGoodsSku shopGoodsSku1 = shopGoodsSkus.get(0);
if(!"1".equals(shopGoodsSku1.getState())){
return AjaxResult.error("该产品已经告罄");
}
}
return AjaxResult.success();
}
}
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.system.service.ISpecRuleMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SpecRuleMaterialMapper;
import com.ruoyi.system.domain.SpecRuleMaterial;
import com.ruoyi.system.service.ISpecRuleMaterialService;
/**
* 选项原料关联Service业务层处理
......@@ -14,7 +15,7 @@ import com.ruoyi.system.service.ISpecRuleMaterialService;
* @date 2022-04-28
*/
@Service
public class SpecRuleMaterialServiceImpl implements ISpecRuleMaterialService
public class SpecRuleMaterialServiceImpl implements ISpecRuleMaterialService
{
@Autowired
private SpecRuleMaterialMapper specRuleMaterialMapper;
......
......@@ -6,13 +6,13 @@ import java.util.List;
import com.ruoyi.common.utils.GenerateCode;
import com.ruoyi.system.domain.SpecRule;
import com.ruoyi.system.domain.SpecRuleMaterial;
import com.ruoyi.system.service.ISpecService;
import com.ruoyi.system.mapper.SpecRuleMapper;
import com.ruoyi.system.mapper.SpecRuleMaterialMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SpecMapper;
import com.ruoyi.system.domain.Spec;
import com.ruoyi.system.service.ISpecService;
import org.springframework.transaction.annotation.Transactional;
/**
......@@ -22,7 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2022-04-28
*/
@Service
public class SpecServiceImpl implements ISpecService
public class SpecServiceImpl implements ISpecService
{
@Autowired
private SpecMapper specMapper;
......
......@@ -9,8 +9,8 @@ import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.mapper.SysConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
......
......@@ -5,6 +5,8 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import com.ruoyi.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -16,7 +18,6 @@ import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.ruoyi.system.mapper.SysDictTypeMapper;
import com.ruoyi.system.service.ISysDictTypeService;
/**
* 字典 业务层处理
......
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.system.service.ISysNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.mapper.SysNoticeMapper;
import com.ruoyi.system.service.ISysNoticeService;
/**
* 公告 服务层实现
......
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.system.service.ISysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
......@@ -9,7 +11,6 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.service.ISysPostService;
/**
* 岗位信息 服务层处理
......
......@@ -5,6 +5,8 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.ruoyi.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -23,7 +25,6 @@ import com.ruoyi.system.mapper.SysRoleDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysRoleMenuMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.service.ISysRoleService;
/**
* 角色 业务层处理
......
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.system.service.IWechatMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.WechatMessageMapper;
import com.ruoyi.system.domain.WechatMessage;
import com.ruoyi.system.service.IWechatMessageService;
/**
* 小程序信息发送Service业务层处理
......@@ -14,7 +15,7 @@ import com.ruoyi.system.service.IWechatMessageService;
* @date 2022-04-28
*/
@Service
public class WechatMessageServiceImpl implements IWechatMessageService
public class WechatMessageServiceImpl implements IWechatMessageService
{
@Autowired
private WechatMessageMapper wechatMessageMapper;
......
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.system.service.IWechatUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.WechatUserMapper;
import com.ruoyi.system.domain.WechatUser;
import com.ruoyi.system.service.IWechatUserService;
/**
* 微信用户小程序信息(用于发送消息)Service业务层处理
......@@ -14,7 +15,7 @@ import com.ruoyi.system.service.IWechatUserService;
* @date 2022-04-28
*/
@Service
public class WechatUserServiceImpl implements IWechatUserService
public class WechatUserServiceImpl implements IWechatUserService
{
@Autowired
private WechatUserMapper wechatUserMapper;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment