Commit 0c232214 by 张新旗

代码修改

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