Commit 0c232214 by 张新旗

代码修改

parent f97c35be
package com.ruoyi.web.controller.coffee; package com.ruoyi.web.controller.coffee;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.uuid.UUID; import com.ruoyi.common.utils.uuid.UUID;
...@@ -48,21 +49,21 @@ public class ApplicationController { ...@@ -48,21 +49,21 @@ public class ApplicationController {
@RequestMapping("/getData") @RequestMapping("/getData")
public AjaxResult getApplicationData(String key){ public AjaxResult getApplicationData(String key){
String s = stringRedisTemplate.opsForValue().get(key); String s = stringRedisTemplate.opsForValue().get(key);
stringRedisTemplate.delete(key);
String[] keys = key.split("_"); String[] keys = key.split("_");
//推送数据给安卓 //推送数据给安卓
PushBean pushBean = new PushBean(); JSONObject jsonObject = new JSONObject();
Map<String,String> map = new HashMap(); jsonObject.put("action","QRCODE_VISITED");
map.put("type","1"); jsonObject.put("timestamp",String.valueOf(System.currentTimeMillis()));
map.put("code","200"); JSONObject data = new JSONObject();
jiGuangPushService.push(keys[0],map); data.put("seqNo",key);
jsonObject.put("data",data);
jiGuangPushService.push(keys[0],jsonObject);
stringRedisTemplate.delete(key);
return AjaxResult.success("处理成功",s); return AjaxResult.success("处理成功",s);
} }
@RequestMapping("/jgRegister") @RequestMapping("/jgRegister")
public AjaxResult jgRegister(@RequestParam String machineCode,@RequestParam String registerId){ public AjaxResult jgRegister(@RequestParam String machineCode,@RequestParam String registerId){
Machine machine = machineService.selectMachineByCode(machineCode);
Machine machine = machineService.selectMachineById(machineCode);
if(machine==null ){ if(machine==null ){
throw new ServiceException("该机器未绑定店铺,请先绑定店铺"); throw new ServiceException("该机器未绑定店铺,请先绑定店铺");
} }
......
...@@ -18,13 +18,22 @@ public class MachineApiController { ...@@ -18,13 +18,22 @@ public class MachineApiController {
public ResultVo shopGoodsUpdate(@RequestBody String body){ public ResultVo shopGoodsUpdate(@RequestBody String body){
log.info("/down/material/update 请求内容为 【{}】",body); log.info("/down/material/update 请求内容为 【{}】",body);
JSONObject jsonObject = JSONObject.parseObject(body); JSONObject jsonObject = JSONObject.parseObject(body);
return ResultVo.success(machineApiService.shopGoodsUpdate(jsonObject)); try{
return ResultVo.success(machineApiService.shopGoodsUpdate(jsonObject));
}catch (Exception e){
return ResultVo.error(e.getMessage());
}
} }
@PostMapping("/down/order/update") @PostMapping("/down/order/update")
public ResultVo updateOrder(@RequestBody String body){ public ResultVo updateOrder(@RequestBody String body){
log.info("/down/order/update 请求内容为 【{}】",body); log.info("/down/order/update 请求内容为 【{}】",body);
JSONObject jsonObject = JSONObject.parseObject(body); JSONObject jsonObject = JSONObject.parseObject(body);
return ResultVo.success(machineApiService.updateOrder(jsonObject)); try{
return ResultVo.success(machineApiService.updateOrder(jsonObject));
}catch (Exception e){
return ResultVo.error(e.getMessage());
}
} }
@PostMapping("/down/robot/status") @PostMapping("/down/robot/status")
public ResultVo robotUpdate(@RequestBody String body){ public ResultVo robotUpdate(@RequestBody String body){
......
...@@ -34,7 +34,7 @@ public class MachineController extends BaseController ...@@ -34,7 +34,7 @@ public class MachineController extends BaseController
/** /**
* 查询机器列表 * 查询机器列表
*/ */
@PreAuthorize("@ss.hasPermi('system:machine:list')") // @PreAuthorize("@ss.hasPermi('system:machine:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(Machine machine) public TableDataInfo list(Machine machine)
{ {
......
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.domain.Goods;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -141,6 +142,13 @@ public class ShopController extends BaseController ...@@ -141,6 +142,13 @@ public class ShopController extends BaseController
return AjaxResult.success(shopService.getShopCity()); return AjaxResult.success(shopService.getShopCity());
} }
@GetMapping("/goodslist")
public TableDataInfo list(String goodsName,String category,Long shopId)
{
startPage();
List<Goods> list = shopService.selectGoodsList(goodsName,category,shopId);
return getDataTable(list);
}
} }
...@@ -60,7 +60,7 @@ public class SpecController extends BaseController ...@@ -60,7 +60,7 @@ public class SpecController extends BaseController
/** /**
* 新增规格 * 新增规格
*/ */
@PreAuthorize("@ss.hasPermi('system:spec:add')") //@PreAuthorize("@ss.hasPermi('system:spec:add')")
@Log(title = "规格", businessType = BusinessType.INSERT) @Log(title = "规格", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Spec spec) public AjaxResult add(@RequestBody Spec spec)
......
...@@ -156,7 +156,7 @@ sms: ...@@ -156,7 +156,7 @@ sms:
accessKeySecret: accessKeySecret:
signName: signName:
push: push:
appkey: 123 appkey: 682a53c0cd0201792d45c469
secret: 123 secret: b58cb126f80ec9bf7577a213
machine: machine:
url: http://47.94.241.71:10003 url: http://47.94.241.71:10003
...@@ -19,6 +19,7 @@ public class JiGuangConfig { ...@@ -19,6 +19,7 @@ public class JiGuangConfig {
private String secret; private String secret;
// 获取推送客户端 // 获取推送客户端
@Bean
public JPushClient getJPushClient() { public JPushClient getJPushClient() {
JPushClient jPushClient = new JPushClient(secret, appkey); JPushClient jPushClient = new JPushClient(secret, appkey);
return jPushClient; return jPushClient;
......
...@@ -43,7 +43,7 @@ public class GlobalExceptionHandlerFilter implements Filter { ...@@ -43,7 +43,7 @@ public class GlobalExceptionHandlerFilter implements Filter {
ajaxResult = AjaxResult.error("该数据已经存在"); ajaxResult = AjaxResult.error("该数据已经存在");
}else if(throwable instanceof ServiceException){ }else if(throwable instanceof ServiceException){
ajaxResult = AjaxResult.error(e.getMessage()); ajaxResult = AjaxResult.error(e.getMessage());
}else{ }else if(throwable instanceof ServiceException){
throw e; throw e;
} }
servletResponse.getWriter().write(JSONObject.toJSONString(ajaxResult)); servletResponse.getWriter().write(JSONObject.toJSONString(ajaxResult));
......
...@@ -26,8 +26,11 @@ import com.ruoyi.system.domain.Customer; ...@@ -26,8 +26,11 @@ import com.ruoyi.system.domain.Customer;
import com.ruoyi.system.domain.Order; import com.ruoyi.system.domain.Order;
import com.ruoyi.system.domain.OrderOperationLog; import com.ruoyi.system.domain.OrderOperationLog;
import com.ruoyi.system.domain.OrderRefund; import com.ruoyi.system.domain.OrderRefund;
import com.ruoyi.system.jiguang.JiGuangPushService;
import com.ruoyi.system.jiguang.impl.JiGuangPushServiceImpl;
import com.ruoyi.system.mapper.CustomerMapper; import com.ruoyi.system.mapper.CustomerMapper;
import com.ruoyi.system.mapper.MachineMapper;
import com.ruoyi.system.mapper.OrderMapper; import com.ruoyi.system.mapper.OrderMapper;
import com.ruoyi.system.mapper.OrderRefundMapper; import com.ruoyi.system.mapper.OrderRefundMapper;
import com.ruoyi.system.service.impl.MachineApiServiceImpl; import com.ruoyi.system.service.impl.MachineApiServiceImpl;
...@@ -90,6 +93,9 @@ public class WeixinServiceImpl { ...@@ -90,6 +93,9 @@ public class WeixinServiceImpl {
private MachineApiServiceImpl machineApiService; private MachineApiServiceImpl machineApiService;
@Autowired @Autowired
private OrderRefundMapper orderRefundMapper; private OrderRefundMapper orderRefundMapper;
@Autowired
private JiGuangPushServiceImpl jiGuangPushService;
private final ReentrantLock lock = new ReentrantLock(); private final ReentrantLock lock = new ReentrantLock();
...@@ -389,7 +395,15 @@ public class WeixinServiceImpl { ...@@ -389,7 +395,15 @@ public class WeixinServiceImpl {
String orderNo = notifyMap.get("out_trade_no"); String orderNo = notifyMap.get("out_trade_no");
Order order = new Order(); Order order = new Order();
order.setOrderNo(orderNo); order.setOrderNo(orderNo);
Order order1 = orderMapper.selectOrderList(order).get(0); List<Order> orders = orderMapper.selectOrderList(order);
if(orders.isEmpty()){
returnMap.put("return_code", "FAIL");
returnMap.put("return_msg", "没有该订单");
String returnXml = WXPayUtil.mapToXml(returnMap);
return returnXml;
}
order = orders.get(0);
//并校验返回的订单金额是否与商户侧的订单金额一致 //并校验返回的订单金额是否与商户侧的订单金额一致
// if (order1 != null && order1.get() != Long.parseLong(notifyMap.get("total_fee"))) { // if (order1 != null && order1.get() != Long.parseLong(notifyMap.get("total_fee"))) {
// log.error("金额校验失败"); // log.error("金额校验失败");
...@@ -405,27 +419,26 @@ public class WeixinServiceImpl { ...@@ -405,27 +419,26 @@ public class WeixinServiceImpl {
try { try {
//处理重复的通知 //处理重复的通知
//接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。 //接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。
String orderStatus =order1.getState(); String orderStatus =order.getState();
if("1".equals(orderStatus)){ if("1".equals(orderStatus)){
//更新订单状态 //更新订单状态
order1.setPayTime(new Date()); order.setPayTime(new Date());
order1.setState("2"); order.setState("2");
JSONObject jsonObject =new JSONObject(); JSONObject jsonObject =new JSONObject();
jsonObject.put("orderId",order.getId()); jsonObject.put("orderId",order.getId());
jsonObject.put("userId",order.getUserId()); jsonObject.put("userId",order.getUserId());
order1.setPickCode(QRCodeUtil.getBase64QRCode(jsonObject.toJSONString())); order.setPickCode(QRCodeUtil.getBase64QRCode(jsonObject.toJSONString()));
orderMapper.updateOrder(order1); orderMapper.updateOrder(order);
OrderOperationLog orderOperationLog = new OrderOperationLog();
orderOperationLog.setOrderId(String.valueOf(order.getId())); orderOperationLogService.insertOrderOperationLog("已付款",order.getId(),"付款成功",order.getUserName(),"付款");
orderOperationLog.setOperation("付款"); machineApiService.updateOrder(order);
orderOperationLog.setOperationUser(order.getUserName()); //极光推送
orderOperationLog.setCreateAt(new Date()); String machineId = order.getMachineId();
orderOperationLog.setContent("付款成功"); Map map = new HashMap();
orderOperationLog.setStatus("付款"); map.put("type","2");
orderOperationLogService.insertOrderOperationLog(orderOperationLog); map.put("orderId",order.getId());
machineApiService.updateOrder(order1); map.put("state",order.getState());
jiGuangPushService.pushMachine(machineId,map);
} }
} finally { } finally {
//要主动释放锁 //要主动释放锁
...@@ -493,12 +506,8 @@ public class WeixinServiceImpl { ...@@ -493,12 +506,8 @@ public class WeixinServiceImpl {
orderRefundMapper.updateOrderRefund(orderRefund1); orderRefundMapper.updateOrderRefund(orderRefund1);
OrderOperationLog orderOperationLog = new OrderOperationLog(); OrderOperationLog orderOperationLog = new OrderOperationLog();
orderOperationLog.setOrderId(String.valueOf(orderRefund1.getOrderId())); orderOperationLog.setOrderId(String.valueOf(orderRefund1.getOrderId()));
orderOperationLog.setOperation("退款");
orderOperationLog.setOperationUser("自动退款"); orderOperationLogService.insertOrderOperationLog("已退款", Long.valueOf(orderRefund.getOrderId()),"用户退款成功,已到账","系统","退款");
orderOperationLog.setCreateAt(new Date());
orderOperationLog.setContent("退款成功");
orderOperationLog.setStatus("退款");
orderOperationLogService.insertOrderOperationLog(orderOperationLog);
return WxPayNotifyResponse.success("退款成功!"); return WxPayNotifyResponse.success("退款成功!");
} }
......
package com.ruoyi.system.domain.vo; package com.ruoyi.system.domain.vo;
import com.alibaba.fastjson.JSONObject;
import java.util.Map; import java.util.Map;
public class PushBean { public class PushBean {
...@@ -11,6 +13,16 @@ public class PushBean { ...@@ -11,6 +13,16 @@ public class PushBean {
//android专用// 可选, 通知标题,如果指定了,则通知里原来展示 App名称的地方,将展示成这个字段。 //android专用// 可选, 通知标题,如果指定了,则通知里原来展示 App名称的地方,将展示成这个字段。
private String title; private String title;
public JSONObject getMessageCount() {
return messageCount;
}
public void setMessageCount(JSONObject messageCount) {
this.messageCount = messageCount;
}
private JSONObject messageCount;
public String getAlert() { public String getAlert() {
return alert; return alert;
......
package com.ruoyi.system.jiguang.impl; package com.ruoyi.system.jiguang.impl;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.Machine;
import com.ruoyi.system.domain.vo.PushBean; import com.ruoyi.system.domain.vo.PushBean;
import com.ruoyi.system.jiguang.JiGuangPushService; import com.ruoyi.system.jiguang.JiGuangPushService;
import com.ruoyi.system.jiguang.MyJiGuangPushService; import com.ruoyi.system.jiguang.MyJiGuangPushService;
...@@ -92,13 +94,22 @@ public class JiGuangPushServiceImpl implements JiGuangPushService { ...@@ -92,13 +94,22 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
return regList.toArray(new String[0]); return regList.toArray(new String[0]);
} }
public void push(String key, Map<String, String> map) { public void push(String key, JSONObject jsonObject) {
String s = machineMapper.selectRegister(key); String s = machineMapper.selectRegister(key);
if(StringUtils.isNotEmpty(s)){ if(StringUtils.isNotEmpty(s)){
PushBean pushBean = new PushBean(); PushBean pushBean = new PushBean();
pushBean.setExtras(map); pushBean.setMessageCount(jsonObject);
pushAndroid(pushBean,key); pushAndroid(pushBean,s);
} }
}
public void pushMachine(String machineId, Map<String, String> map) {
Machine machine = machineMapper.selectMachineById(machineId);
if(StringUtils.isNotEmpty(machine.getRegister())){
PushBean pushBean = new PushBean();
pushBean.setExtras(map);
pushBean.setAlert("新消息");
pushAndroid(pushBean,machine.getRegister());
}
} }
} }
...@@ -4,16 +4,22 @@ import cn.jpush.api.JPushClient; ...@@ -4,16 +4,22 @@ import cn.jpush.api.JPushClient;
import cn.jpush.api.common.resp.APIConnectionException; import cn.jpush.api.common.resp.APIConnectionException;
import cn.jpush.api.common.resp.APIRequestException; import cn.jpush.api.common.resp.APIRequestException;
import cn.jpush.api.push.PushResult; import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.Platform; import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload; import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience; import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.Notification; import cn.jpush.api.push.model.notification.Notification;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.domain.Machine;
import com.ruoyi.system.domain.vo.PushBean; import com.ruoyi.system.domain.vo.PushBean;
import com.ruoyi.system.jiguang.MyJiGuangPushService; import com.ruoyi.system.jiguang.MyJiGuangPushService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/** /**
* 极光推送 * 极光推送
* 封装第三方api相关 * 封装第三方api相关
...@@ -21,7 +27,7 @@ import org.springframework.stereotype.Service; ...@@ -21,7 +27,7 @@ import org.springframework.stereotype.Service;
@Service @Service
@Slf4j @Slf4j
public class MyJiGuangPushServiceImpl implements MyJiGuangPushService { public class MyJiGuangPushServiceImpl implements MyJiGuangPushService {
//@Autowired @Autowired
private JPushClient jPushClient; private JPushClient jPushClient;
/** /**
* 广播 (所有平台,所有设备, 不支持附加信息) * 广播 (所有平台,所有设备, 不支持附加信息)
...@@ -84,10 +90,13 @@ public class MyJiGuangPushServiceImpl implements MyJiGuangPushService { ...@@ -84,10 +90,13 @@ public class MyJiGuangPushServiceImpl implements MyJiGuangPushService {
*/ */
@Override @Override
public boolean pushAndroid(PushBean pushBean, String ... registids){ public boolean pushAndroid(PushBean pushBean, String ... registids){
Message build = new Message.Builder().setMsgContent(pushBean.getMessageCount().toJSONString()).build();
return sendPush(PushPayload.newBuilder() return sendPush(PushPayload.newBuilder()
.setPlatform(Platform.android()) .setPlatform(Platform.android())
.setAudience(Audience.registrationId(registids)) .setAudience(Audience.registrationId(registids))
.setNotification(Notification.android(pushBean.getAlert(), pushBean.getTitle(), pushBean.getExtras())) .setMessage(build)
//.setNotification(Notification.android(pushBean.getAlert(), pushBean.getTitle(), pushBean.getExtras()))
.build()); .build());
} }
/** /**
......
...@@ -19,6 +19,8 @@ public interface MachineMapper ...@@ -19,6 +19,8 @@ public interface MachineMapper
*/ */
public Machine selectMachineById(String id); public Machine selectMachineById(String id);
public Machine selectMachineByCode(String code);
/** /**
* 查询机器列表 * 查询机器列表
* *
......
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.system.domain.Goods; import com.ruoyi.system.domain.Goods;
import com.ruoyi.system.domain.ShopGoods; import com.ruoyi.system.domain.ShopGoods;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
/** /**
...@@ -69,4 +67,7 @@ public interface ShopGoodsMapper ...@@ -69,4 +67,7 @@ public interface ShopGoodsMapper
List<Goods> selectShopCategoryGoodsByCategoryId(@Param("shopId") long shopId, @Param("categoryId") String categoryId); List<Goods> selectShopCategoryGoodsByCategoryId(@Param("shopId") long shopId, @Param("categoryId") String categoryId);
void updateStatus(@Param("shopID")String shopID, @Param("goodsId") Long goodsId,@Param("machineId") String robotID,@Param("status") String s); void updateStatus(@Param("shopID")String shopID, @Param("goodsId") Long goodsId,@Param("machineId") String robotID,@Param("status") String s);
List<Goods> selectShopNoAddGoods(@Param("goodsName") String goodsName, @Param("category") String category, @Param("shopId") Long shopId);
} }
...@@ -30,10 +30,10 @@ public interface IOrderOperationLogService ...@@ -30,10 +30,10 @@ public interface IOrderOperationLogService
/** /**
* 新增【请填写功能名称】 * 新增【请填写功能名称】
* *
* @param orderOperationLog 【请填写功能名称】 * @param 【请填写功能名称】
* @return 结果 * @return 结果
*/ */
public int insertOrderOperationLog(OrderOperationLog orderOperationLog); int insertOrderOperationLog(String status,Long orderId,String content,String operationUser,String operation);
/** /**
* 修改【请填写功能名称】 * 修改【请填写功能名称】
......
...@@ -3,6 +3,7 @@ package com.ruoyi.system.service; ...@@ -3,6 +3,7 @@ package com.ruoyi.system.service;
import java.util.List; import java.util.List;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.domain.Goods;
import com.ruoyi.system.domain.GoodsCategory; import com.ruoyi.system.domain.GoodsCategory;
import com.ruoyi.system.domain.GoodsSku; import com.ruoyi.system.domain.GoodsSku;
import com.ruoyi.system.domain.Shop; import com.ruoyi.system.domain.Shop;
...@@ -75,4 +76,7 @@ public interface IShopService ...@@ -75,4 +76,7 @@ public interface IShopService
String offGoods(JSONObject body); String offGoods(JSONObject body);
List<Goods> selectGoodsList(String goodsName, String category, Long shopId);
} }
...@@ -73,7 +73,9 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -73,7 +73,9 @@ public class GoodsServiceImpl implements IGoodsService
for (Goods goods1 : goodsList) { for (Goods goods1 : goodsList) {
GoodsCategory goodsCategory = goodsCategoryMapper.selectGoodsCategoryById(goods1.getCategory()); GoodsCategory goodsCategory = goodsCategoryMapper.selectGoodsCategoryById(goods1.getCategory());
goods1.setCategoryName(goodsCategory.getName()); if(goodsCategory !=null){
goods1.setCategoryName(goodsCategory.getName());
}
int count = orderMapper.selectSalesVolume(null,goods1.getId()); int count = orderMapper.selectSalesVolume(null,goods1.getId());
goods1.setSalesVolume(count); goods1.setSalesVolume(count);
} }
...@@ -255,7 +257,7 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -255,7 +257,7 @@ public class GoodsServiceImpl implements IGoodsService
shop.setIsDefault(0L); shop.setIsDefault(0L);
List<Shop> shops = shopService.selectShopList(shop); List<Shop> shops = shopService.selectShopList(shop);
for (Shop shop1 : shops) { for (Shop shop1 : shops) {
if("3".equals(shop1.getState())){ if(!"3".equals(shop1.getState())){
try{ try{
shopService.addGoods(shop1.getId(),goodsId); shopService.addGoods(shop1.getId(),goodsId);
}catch (ServiceException serviceException){ }catch (ServiceException serviceException){
......
...@@ -43,14 +43,32 @@ public class MachineApiServiceImpl { ...@@ -43,14 +43,32 @@ public class MachineApiServiceImpl {
List<String> skuIds = JSONObject.parseArray(skuIDs, String.class); List<String> skuIds = JSONObject.parseArray(skuIDs, String.class);
String robotID = jsonObject.getString("robotId"); String robotID = jsonObject.getString("robotId");
String status = jsonObject.getString("status"); String status = jsonObject.getString("status");
if(StringUtils.isEmpty(skuIDs)){
throw new ServiceException("sku不能为空");
}
ShopGoodsSku shopGoodsSku = new ShopGoodsSku();
shopGoodsSku.setShopId(Long.parseLong(shopID));
for (String skuId : skuIds) {
shopGoodsSku.setSkuId(Long.parseLong(skuId));
List<ShopGoodsSku> shopGoodsSkus = shopGoodsSkuMapper.selectShopGoodsSkuList(shopGoodsSku);
if(shopGoodsSkus.isEmpty()){
throw new ServiceException(skuId+"不存在");
}
}
int i = shopGoodsSkuMapper.updateSkuStatus(skuIds, robotID, shopID, status); int i = shopGoodsSkuMapper.updateSkuStatus(skuIds, robotID, shopID, status);
return ""+i; return ""+i;
} }
public String updateOrder(JSONObject jsonObject) { public String updateOrder(JSONObject jsonObject) {
long orderID = jsonObject.getLong("orderId"); Long orderID = jsonObject.getLong("orderId");
String status = jsonObject.getString("status"); String status = jsonObject.getString("status");
Order order1 = orderMapper.selectOrderById(String.valueOf(orderID));
if(order1==null){
throw new ServiceException("该订单不存在");
}
Order order = new Order(); Order order = new Order();
order.setId(orderID); order.setId(orderID);
order.setState(status); order.setState(status);
......
...@@ -96,31 +96,36 @@ public class MachineServiceImpl implements IMachineService ...@@ -96,31 +96,36 @@ public class MachineServiceImpl implements IMachineService
@Override @Override
public String bindMachine(String code, Long shopId) { public String bindMachine(String code, Long shopId) {
Machine machine1 = machineMapper.selectMachineById(code);
if(machine1!=null){
throw new ServiceException("该机器已经被绑定,请先解绑再绑定");
}
Machine machine = new Machine(); Machine machine = new Machine();
machine.setShopId(shopId); machine.setShopId(shopId);
List<Machine> machines = machineMapper.selectMachineList(machine); List<Machine> machines = machineMapper.selectMachineList(machine);
if(!machines.isEmpty()){ if(!machines.isEmpty()){
throw new ServiceException("目前只允许一个店铺绑定一台机器"); throw new ServiceException("目前只允许一个店铺绑定一台机器");
} }
Machine machine1 = machineMapper.selectMachineByCode(code);
machine.setId(code); if(machine1 ==null){
machine.setCode(code); machine.setCode(code);
machine.setBindTime(new Date());
machine.setBindTime(new Date()); machine.setCreatedAt(new Date());
machine.setCreatedAt(new Date()); machine.setUpdatedAt(new Date());
machine.setUpdatedAt(new Date()); machine.setState("1");
machine.setState("1"); return machineMapper.insertMachine(machine)+"";
machineMapper.insertMachine(machine); }
return null; if(machine1.getShopId()!=null){
throw new ServiceException("该机器已经被绑定,请先解绑再绑定");
}
machine1.setCode(code);
machine1.setShopId(shopId);
machineMapper.updateMachine(machine1);
return "1";
} }
@Override @Override
public int unbound(String id) { public int unbound(String id) {
return machineMapper.deleteMachineById(id); return machineMapper.deleteMachineById(id);
} }
public Machine selectMachineByCode(String machineCode) {
return machineMapper.selectMachineByCode(machineCode);
}
} }
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import java.util.Date;
import java.util.List; import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.OrderOperationLogMapper; import com.ruoyi.system.mapper.OrderOperationLogMapper;
...@@ -50,9 +53,20 @@ public class OrderOperationLogServiceImpl implements IOrderOperationLogService ...@@ -50,9 +53,20 @@ public class OrderOperationLogServiceImpl implements IOrderOperationLogService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertOrderOperationLog(OrderOperationLog orderOperationLog) public int insertOrderOperationLog(String status,Long orderId,String content,String operationUser,String operation)
{ {
return orderOperationLogMapper.insertOrderOperationLog(orderOperationLog); OrderOperationLog operationLog = new OrderOperationLog();
operationLog.setStatus(status);
operationLog.setOrderId(String.valueOf(orderId));
operationLog.setContent(content);
operationLog.setCreateAt(new Date());
if(StringUtils.isEmpty(operationUser)){
operationLog.setOperationUser("接口");
}
if(StringUtils.isEmpty(operation)){
operationLog.setOperation("同步信息");
}
return orderOperationLogMapper.insertOrderOperationLog(operationLog);
} }
/** /**
......
...@@ -112,8 +112,8 @@ public class OrderServiceImpl implements IOrderService ...@@ -112,8 +112,8 @@ public class OrderServiceImpl implements IOrderService
if(!"1".equals(machine1.getState())){ if(!"1".equals(machine1.getState())){
return AjaxResult.error("机器暂时不可用"); return AjaxResult.error("机器暂时不可用");
} }
machineId = machine1.getCode(); machineId = machine1.getId();
order.setMachineId(machine1.getCode()); order.setMachineId(machineId);
}else{ }else{
return AjaxResult.error("该店铺暂无绑定机器"); return AjaxResult.error("该店铺暂无绑定机器");
} }
...@@ -124,20 +124,14 @@ public class OrderServiceImpl implements IOrderService ...@@ -124,20 +124,14 @@ public class OrderServiceImpl implements IOrderService
for (OrderDetail orderDetail : orderDetails) { for (OrderDetail orderDetail : orderDetails) {
orderDetail.setOrderId(order.getId()); orderDetail.setOrderId(order.getId());
orderDetail.setCreatedAt(new Date()); orderDetail.setCreatedAt(new Date());
orderDetail.setMachineId(machineId);
orderDetail.setUpdatedAt(new Date()); orderDetail.setUpdatedAt(new Date());
orderDetail.setMachineId(machineId);
} }
} }
//发送数据给机器 //发送数据给机器
machineApiService.createOrder(order); machineApiService.createOrder(order);
OrderOperationLog orderOperationLog = new OrderOperationLog(); orderOperationLogService.insertOrderOperationLog("待付款",order.getId(),"创建了订单",order.getUserName(),"创建订单");
orderOperationLog.setOrderId(String.valueOf(order.getId()));
orderOperationLog.setOperation("创建订单");
orderOperationLog.setOperationUser(order.getUserName());
orderOperationLog.setCreateAt(new Date());
orderOperationLog.setContent("创建了订单");
orderOperationLog.setStatus("待付款");
orderOperationLogService.insertOrderOperationLog(orderOperationLog);
return AjaxResult.success(order.getOrderNo()); return AjaxResult.success(order.getOrderNo());
} }
......
...@@ -8,6 +8,7 @@ import com.ruoyi.system.domain.vo.orderTaking.*; ...@@ -8,6 +8,7 @@ import com.ruoyi.system.domain.vo.orderTaking.*;
import com.ruoyi.system.mapper.*; import com.ruoyi.system.mapper.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -41,14 +42,11 @@ public class OrderTakingServiceImpl { ...@@ -41,14 +42,11 @@ public class OrderTakingServiceImpl {
*/ */
public OrderTakingVo getMachineInfo(String machineCode) { public OrderTakingVo getMachineInfo(String machineCode) {
Machine machine = new Machine(); Machine machine = machineMapper.selectMachineByCode(machineCode);
machine.setCode(machineCode); if(machine==null || machine.getShopId() ==null){
List<Machine> machines = machineMapper.selectMachineList(machine);
if(machines==null && !machines.isEmpty()){
throw new ServiceException("该机器没有绑定店铺"); throw new ServiceException("该机器没有绑定店铺");
} }
Long shopId = machines.get(0).getShopId(); return this.getOrderTakingInfo(machine.getShopId());
return this.getOrderTakingInfo(shopId);
} }
...@@ -59,11 +57,11 @@ public class OrderTakingServiceImpl { ...@@ -59,11 +57,11 @@ public class OrderTakingServiceImpl {
} }
public OrderTakingVo getOrderTakingInfo(Long shopId){ public OrderTakingVo getOrderTakingInfo(Long shopId){
OrderTakingVo orderTakingVo = new OrderTakingVo(); OrderTakingVo orderTakingVo = new OrderTakingVo();
Shop shop = shopMapper.selectShopById(String.valueOf(shopId)); Shop shop = shopMapper.selectShopById(String.valueOf(shopId));
if(shop ==null){
return orderTakingVo;
}
orderTakingVo.setShopState(shop.getState()); orderTakingVo.setShopState(shop.getState());
ImagesVo imagesVo = new ImagesVo(); ImagesVo imagesVo = new ImagesVo();
orderTakingVo.setImages(imagesVo); orderTakingVo.setImages(imagesVo);
...@@ -79,48 +77,15 @@ public class OrderTakingServiceImpl { ...@@ -79,48 +77,15 @@ public class OrderTakingServiceImpl {
//查询出该店铺今日特惠的商品 //查询出该店铺今日特惠的商品
List<GoodsVo> goodsVos = shopRecommendMapper.selectShopGoodsByTyepe("2",shopId); List<GoodsVo> goodsVos = shopRecommendMapper.selectShopGoodsByTyepe("2",shopId);
preferentialCategoryVo.setGoods(goodsVos); preferentialCategoryVo.setGoods(goodsVos);
for (GoodsVo goodsVo : goodsVos) { if(!CollectionUtils.isEmpty(goodsVos)){
GoodsTag goodsTag = new GoodsTag(); for (GoodsVo goodsVo : goodsVos) {
goodsTag.setState("1");
goodsVo.setSpecs(buildGoodsSpec(goodsVo.getSpecString()));
goodsVo.setSpecString(null);
goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId()));
goodsVo.setPics(JSONObject.parseObject(goodsVo.getPictures()));
goodsVo.setPictures(null);
List<GoodsTag> goodsTags = goodsTagMapper.selectGoodsTagList(goodsTag);
List<String> tags = goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList());
goodsVo.setTags(tags);
//获取产品信息
List<SkuVo> skuVos = shopGoodsSkuMapper.selectSkuByGoodAndShop(shopId, goodsVo.getGoodsId());
buildSkuRules(skuVos);
goodsVo.setSkus(skuVos);
}
//普通分类的产品
List<GoodsCategory> shopCategories = goodsCategoryMapper.selectByShopId(shopId);
for (GoodsCategory category : shopCategories) {
CategoryVo categoryVo = new CategoryVo();
categoryVo.setId(Long.parseLong(category.getId()));
categoryVo.setName(category.getName());
List<Goods> goodsList = shopGoodsMapper.selectShopCategoryGoodsByCategoryId(shopId, category.getId());
List<GoodsVo> goodsVoList = new ArrayList<>();
categoryVo.setGoods(goodsVoList);
for (Goods good : goodsList) {
GoodsVo goodsVo =new GoodsVo();
goodsVo.setGoodsId(String.valueOf(good.getId()));
goodsVo.setName(good.getName());
goodsVo.setDesc(good.getDesc());
goodsVo.setDiscount(good.getDiscount().stripTrailingZeros().toPlainString());
goodsVo.setPrice(good.getPrice().stripTrailingZeros().toPlainString());
goodsVo.setPics(JSONObject.parseObject(good.getPics()));
goodsVo.setRemarks(good.getRemarks());
goodsVo.setSpecs(buildGoodsSpec(good.getSpec()));
goodsVo.setSpecString(null);
GoodsTag goodsTag = new GoodsTag(); GoodsTag goodsTag = new GoodsTag();
goodsTag.setState("1"); goodsTag.setState("1");
goodsVo.setSpecs(buildGoodsSpec(goodsVo.getSpecString()));
goodsVo.setSpecString(null);
goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId())); goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId()));
goodsVo.setPics(JSONObject.parseObject(goodsVo.getPictures()));
goodsVo.setPictures(null);
List<GoodsTag> goodsTags = goodsTagMapper.selectGoodsTagList(goodsTag); List<GoodsTag> goodsTags = goodsTagMapper.selectGoodsTagList(goodsTag);
List<String> tags = goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList()); List<String> tags = goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList());
goodsVo.setTags(tags); goodsVo.setTags(tags);
...@@ -128,12 +93,53 @@ public class OrderTakingServiceImpl { ...@@ -128,12 +93,53 @@ public class OrderTakingServiceImpl {
List<SkuVo> skuVos = shopGoodsSkuMapper.selectSkuByGoodAndShop(shopId, goodsVo.getGoodsId()); List<SkuVo> skuVos = shopGoodsSkuMapper.selectSkuByGoodAndShop(shopId, goodsVo.getGoodsId());
buildSkuRules(skuVos); buildSkuRules(skuVos);
goodsVo.setSkus(skuVos); goodsVo.setSkus(skuVos);
goodsVoList.add(goodsVo);
} }
categoryVos.add(categoryVo);
} }
//普通分类的产品
List<GoodsCategory> shopCategories = goodsCategoryMapper.selectByShopId(shopId);
if(!CollectionUtils.isEmpty(shopCategories)){
for (GoodsCategory category : shopCategories) {
CategoryVo categoryVo = new CategoryVo();
categoryVo.setId(Long.parseLong(category.getId()));
categoryVo.setName(category.getName());
List<Goods> goodsList = shopGoodsMapper.selectShopCategoryGoodsByCategoryId(shopId, category.getId());
List<GoodsVo> goodsVoList = new ArrayList<>();
categoryVo.setGoods(goodsVoList);
if(!CollectionUtils.isEmpty(goodsList)){
for (Goods good : goodsList) {
GoodsVo goodsVo =new GoodsVo();
goodsVo.setGoodsId(String.valueOf(good.getId()));
goodsVo.setName(good.getName());
goodsVo.setDesc(good.getDesc());
goodsVo.setDiscount(good.getDiscount().stripTrailingZeros().toPlainString());
goodsVo.setPrice(good.getPrice().stripTrailingZeros().toPlainString());
goodsVo.setPics(JSONObject.parseObject(good.getPics()));
goodsVo.setRemarks(good.getRemarks());
goodsVo.setSpecs(buildGoodsSpec(good.getSpec()));
goodsVo.setSpecString(null);
GoodsTag goodsTag = new GoodsTag();
goodsTag.setState("1");
goodsTag.setGoodsId(Long.parseLong(goodsVo.getGoodsId()));
List<GoodsTag> goodsTags = goodsTagMapper.selectGoodsTagList(goodsTag);
List<String> tags = goodsTags.stream().map(GoodsTag::getTag).collect(Collectors.toList());
goodsVo.setTags(tags);
//获取产品信息
List<SkuVo> skuVos = shopGoodsSkuMapper.selectSkuByGoodAndShop(shopId, goodsVo.getGoodsId());
buildSkuRules(skuVos);
goodsVo.setSkus(skuVos);
goodsVoList.add(goodsVo);
}
}
categoryVos.add(categoryVo);
}
}
List<RecommendVo> recommendVos = new ArrayList<>(); List<RecommendVo> recommendVos = new ArrayList<>();
List<GoodsVo> recommendGoods = shopRecommendMapper.selectShopGoodsByTyepe("1", shopId); List<GoodsVo> recommendGoods = shopRecommendMapper.selectShopGoodsByTyepe("1", shopId);
for (GoodsVo goodsVo : recommendGoods) { for (GoodsVo goodsVo : recommendGoods) {
RecommendVo recommendVo = new RecommendVo(); RecommendVo recommendVo = new RecommendVo();
recommendVos.add(recommendVo); recommendVos.add(recommendVo);
...@@ -168,6 +174,9 @@ public class OrderTakingServiceImpl { ...@@ -168,6 +174,9 @@ public class OrderTakingServiceImpl {
} }
private void buildSkuRules(List<SkuVo> skuVos) { private void buildSkuRules(List<SkuVo> skuVos) {
if(CollectionUtils.isEmpty(skuVos)){
return;
}
for (SkuVo skuVo : skuVos) { for (SkuVo skuVo : skuVos) {
String rules = skuVo.getRulesString(); String rules = skuVo.getRulesString();
List<SpecRule> specRuleList = JSONObject.parseArray(rules, SpecRule.class); List<SpecRule> specRuleList = JSONObject.parseArray(rules, SpecRule.class);
......
...@@ -181,7 +181,6 @@ public class ShopServiceImpl implements IShopService ...@@ -181,7 +181,6 @@ public class ShopServiceImpl implements IShopService
shopGoodsSku.setIsDeleted("0"); shopGoodsSku.setIsDeleted("0");
shopGoodsSku.setCreatedAt(new Date()); shopGoodsSku.setCreatedAt(new Date());
shopGoodsSku.setUpdatedAt(new Date()); shopGoodsSku.setUpdatedAt(new Date());
shopGoodsSku.setMachineId(machine1.getId());
shopGoodsSkuMapper.insertShopGoodsSku(shopGoodsSku); shopGoodsSkuMapper.insertShopGoodsSku(shopGoodsSku);
} }
} }
...@@ -257,6 +256,21 @@ public class ShopServiceImpl implements IShopService ...@@ -257,6 +256,21 @@ public class ShopServiceImpl implements IShopService
return null; return null;
} }
@Override
public List<Goods> selectGoodsList(String goodsName, String category, Long shopId) {
List<Goods> goodsList = shopGoodsMapper.selectShopNoAddGoods(goodsName, category, shopId);
for (Goods goods1 : goodsList) {
GoodsCategory goodsCategory = goodsCategoryMapper.selectGoodsCategoryById(goods1.getCategory());
if(goodsCategory !=null){
goods1.setCategoryName(goodsCategory.getName());
}
int count = orderMapper.selectSalesVolume(null,goods1.getId());
goods1.setSalesVolume(count);
}
return goodsList;
}
public AjaxResult checkSku(String shopId, String skuId, String machineCode) { public AjaxResult checkSku(String shopId, String skuId, String machineCode) {
ShopGoodsSku shopGoodsSku = new ShopGoodsSku(); ShopGoodsSku shopGoodsSku = new ShopGoodsSku();
......
...@@ -20,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -20,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createdAt" column="created_at" /> <result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" /> <result property="updatedAt" column="updated_at" />
<result property="code" column="code" /> <result property="code" column="code" />
<result property="shelfAt" column="shelf_at"/>
</resultMap> </resultMap>
<sql id="selectGoodsVo"> <sql id="selectGoodsVo">
select id, name, category, price, discount, take_time, spec, pics, `desc`, remarks, state, is_deleted, created_at, updated_at, code from goods select id, name, category, price, discount, take_time, spec, pics, `desc`, remarks, state, is_deleted, created_at, updated_at, code,shelf_at from goods
</sql> </sql>
<select id="selectGoodsList" parameterType="Goods" resultMap="GoodsResult"> <select id="selectGoodsList" parameterType="Goods" resultMap="GoodsResult">
...@@ -43,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -43,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null "> and created_at = #{createdAt}</if> <if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if> <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
<if test="code != null and code != ''"> and code = #{code}</if> <if test="code != null and code != ''"> and code = #{code}</if>
<if test="shelfAt != null shelfAt code != ''"> and shelf_at = #{shelfAt}</if>
</where> </where>
</select> </select>
...@@ -68,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -68,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null">created_at,</if> <if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if> <if test="updatedAt != null">updated_at,</if>
<if test="code != null">code,</if> <if test="code != null">code,</if>
<if test="shelfAt != null">shelf_at,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if> <if test="name != null and name != ''">#{name},</if>
...@@ -84,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -84,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null">#{createdAt},</if> <if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if> <if test="updatedAt != null">#{updatedAt},</if>
<if test="code != null">#{code},</if> <if test="code != null">#{code},</if>
<if test="shelfAt != null">#{shelfAt},</if>
</trim> </trim>
</insert> </insert>
...@@ -104,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -104,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null">created_at = #{createdAt},</if> <if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if> <if test="updatedAt != null">updated_at = #{updatedAt},</if>
<if test="code != null">code = #{code},</if> <if test="code != null">code = #{code},</if>
<if test="shelfAt != null">shelf_at = #{shelfAt},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
......
...@@ -36,11 +36,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -36,11 +36,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMachineVo"/> <include refid="selectMachineVo"/>
where id = #{id} where id = #{id}
</select> </select>
<select id="selectMachineByCode" parameterType="String" resultMap="MachineResult">
<include refid="selectMachineVo"/>
where code = #{code}
</select>
<insert id="insertMachine" parameterType="Machine" useGeneratedKeys="true" keyProperty="id"> <insert id="insertMachine" parameterType="Machine" useGeneratedKeys="true" keyProperty="id">
insert into machine insert into machine
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if>
<if test="shopId != null and shopId != ''">shop_id,</if> <if test="shopId != null and shopId != ''">shop_id,</if>
<if test="code != null and code != ''">code,</if> <if test="code != null and code != ''">code,</if>
<if test="type != null and type != ''">type,</if> <if test="type != null and type != ''">type,</if>
...@@ -50,7 +53,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -50,7 +53,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updatedAt != null">updated_at,</if> <if test="updatedAt != null">updated_at,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="shopId != null and shopId != ''">#{shopId},</if> <if test="shopId != null and shopId != ''">#{shopId},</if>
<if test="code != null and code != ''">#{code},</if> <if test="code != null and code != ''">#{code},</if>
<if test="type != null and type != ''">#{type},</if> <if test="type != null and type != ''">#{type},</if>
...@@ -77,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -77,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<delete id="deleteMachineById" parameterType="String"> <delete id="deleteMachineById" parameterType="String">
delete from machine where id = #{id} update machine set shop_id = null where id = #{id}
</delete> </delete>
<delete id="deleteMachineByIds" parameterType="String"> <delete id="deleteMachineByIds" parameterType="String">
...@@ -87,9 +89,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -87,9 +89,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </delete>
<update id="unbound"> <update id="unbound">
update machine set shopId =null where id =#{id} update machine set shopId =null where code =#{id}
</update> </update>
<select id="selectRegister" resultType="string"> <select id="selectRegister" resultType="string">
select register from machine where id =#{id} select register from machine where code =#{id}
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -96,5 +96,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -96,5 +96,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and shop_id =#{shopId} and category =#{categoryId} and shop_id =#{shopId} and category =#{categoryId}
order by sg.turn order by sg.turn
</select> </select>
<select id="selectShopNoAddGoods" resultType="com.ruoyi.system.domain.Goods">
select id, name, category, price, discount, take_time, spec, pics, `desc`, remarks, state, is_deleted, created_at, updated_at, code,shelf_at from goods
where
id not in (
SELECT
sg.goods_id
from
shop_goods sg
where
sg.shop_id = #{shopId})
and state ='3'
<if test="goodsName!=null and goodsName!=''">
and name like concat('%', #{goodsName}, '%')
</if>
<if test="category!=null and category!=''">
and category like concat('%', #{category}, '%')
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -116,7 +116,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -116,7 +116,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update shop_goods_sku set state =#{status} update shop_goods_sku set state =#{status}
<where> <where>
and shop_id=#{shopId} and shop_id=#{shopId}
and machine_id=#{machineCode}
<if test="skuIds!=null"> <if test="skuIds!=null">
and sku_id in and sku_id in
<foreach collection="skuIds" index="index" item="item" open="(" separator="," close=")"> <foreach collection="skuIds" index="index" item="item" open="(" separator="," close=")">
...@@ -126,7 +125,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -126,7 +125,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</update> </update>
<delete id="deleteByGoodsIds"> <delete id="deleteByGoodsIds">
delete shop_goods_sku where shop_id=#{shopId} delete from shop_goods_sku where shop_id=#{shopId}
and goods_id in and goods_id in
<foreach collection="goodsIds" index="index" item="item" open="(" separator="," close=")"> <foreach collection="goodsIds" index="index" item="item" open="(" separator="," close=")">
......
...@@ -24,12 +24,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -24,12 +24,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSpecRuleList" parameterType="SpecRule" resultMap="SpecRuleResult"> <select id="selectSpecRuleList" parameterType="SpecRule" resultMap="SpecRuleResult">
<include refid="selectSpecRuleVo"/> <include refid="selectSpecRuleVo"/>
<where> <where>
and is_deleted = 0
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="specId != null and specId != ''"> and spec_id = #{specId}</if> <if test="specId != null and specId != ''"> and spec_id = #{specId}</if>
<if test="amount != null "> and amount = #{amount}</if> <if test="amount != null "> and amount = #{amount}</if>
<if test="turn != null and turn != ''"> and turn = #{turn}</if> <if test="turn != null and turn != ''"> and turn = #{turn}</if>
<if test="isRecommend != null and isRecommend != ''"> and is_recommend = #{isRecommend}</if> <if test="isRecommend != null and isRecommend != ''"> and is_recommend = #{isRecommend}</if>
<if test="isDefault != null "> and is_default = #{isDefault}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if> <if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if> <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
</where> </where>
......
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