Commit 3a6a9b53 by 张新旗

前进前进,继续上代码

parent 11922e0a
......@@ -77,6 +77,11 @@ public class AppController extends BaseController {
String info = orderService.getWaitTime(order);
return AjaxResult.success("操作成功",info);
}
@RequestMapping("/getWaitTineByOrderId")
public AjaxResult getWaitTineByOrderId( Long orderId){
String info = orderService.getWaitTimeByOrderId(orderId);
return AjaxResult.success("操作成功",info);
}
......
......@@ -83,4 +83,6 @@ public interface OrderMapper
void updateCancel(@Param("status") String unpaid, @Param("timeout") int i);
List<Order> selectOrderByTime(@Param("status")String unpaid, @Param("timeout")int i);
List<Order> selectBeforeOrder(@Param("status")List<String> status, @Param("orderId")Long orderId);
}
......@@ -5,6 +5,7 @@ import com.soss.system.domain.Order;
import com.soss.system.domain.OrderOperationLog;
import com.soss.system.mapper.OrderMapper;
import com.soss.system.mapper.OrderOperationLogMapper;
import com.soss.system.service.impl.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -18,15 +19,25 @@ public class OrderSchedule {
@Autowired
private OrderMapper orderMapper;
@Value("${timeout}")
private String timeout;
private Integer timeout;
@Autowired
private OrderOperationLogMapper operationLogMapper;
@Autowired
private OrderServiceImpl orderService;
@Scheduled(fixedDelay = 60*1000)
private void process() {
orderMapper.updateTimeOut(OrderStatusConstant.productionCompleted,timeout);
//orderMapper.updateTimeOut(OrderStatusConstant.productionCompleted,timeout);
List<Order> orders1 = orderMapper.selectOrderByTime(OrderStatusConstant.productionCompleted, timeout);
if(orders1!=null &&orders1.size()>0){
for (Order order : orders1) {
order.setState(OrderStatusConstant.timeout);
order.setUpdatedAt(new Date());
orderService.updateOrder(order);
}
}
//orderMapper.updateCancel(OrderStatusConstant.Unpaid,15);
List<Order> orders = orderMapper.selectOrderByTime(OrderStatusConstant.Unpaid, 15);
List<Order> orders = orderMapper.selectOrderByTime(OrderStatusConstant.Unpaid, 15*60);
if(orders!=null &&orders.size()>0){
for (Order order : orders) {
order.setState(OrderStatusConstant.UnpaidCancel);
......
......@@ -5,10 +5,12 @@ import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.soss.common.exception.ServiceException;
import com.soss.common.utils.GenerateCode;
import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.service.IGoodsService;
import com.soss.system.mapper.*;
import lombok.extern.slf4j.Slf4j;
......@@ -45,6 +47,10 @@ public class GoodsServiceImpl implements IGoodsService
private GoodsCategoryMapper goodsCategoryMapper;
@Autowired
private ShopRecommendMapper shopRecommendMapper;
@Autowired
private MachineMapper machineMapper;
@Autowired
private JiGuangPushServiceImpl jiGuangPushService;
/**
......@@ -312,10 +318,24 @@ public class GoodsServiceImpl implements IGoodsService
shopGoodsSkuMapper.deleteShopGoodsSkuByGoodsId(shopGoods1.getGoodsId());
List<String> goodsIds = Arrays.asList(String.valueOf(shopGoods1.getGoodsId()));
shopRecommendMapper.deleteByShopIdGoods(shopGoods1.getShopId(),goodsIds);
updateApplication(shopGoods1.getShopId());
}
return i+"";
}
public void updateApplication(long shopId){
Machine machine = new Machine();
machine.setShopId(shopId);
List<Machine> machines = machineMapper.selectMachineList(machine);
if(!machines.isEmpty()){
JSONObject jsonObject = new JSONObject();
jsonObject.put("action","GOODS_CHANGED");
jsonObject.put("timestamp",System.currentTimeMillis());
jiGuangPushService.push(machines.get(0).getCode(),jsonObject);
}
}
@Override
public String deleteGoodsById(Long id, boolean boo) {
......
......@@ -212,6 +212,9 @@ public class OrderServiceImpl implements IOrderService
case OrderStatusConstant.completed:
completedState(order);
break;
case OrderStatusConstant.timeout:
timeoutState(order);
break;
case OrderStatusConstant.UnpaidCancel:
case OrderStatusConstant.PaidCancel:
unpaidCancelState(order);
......@@ -229,6 +232,10 @@ public class OrderServiceImpl implements IOrderService
return orderMapper.updateOrder(order);
}
private void timeoutState(Order order) {
jiGuangPushService.pushOrderState(order);
}
/**
* 部分退款
* @param order
......@@ -517,7 +524,7 @@ public class OrderServiceImpl implements IOrderService
orderDetail.setOrderId(order.getId());
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
order.setOrderDetails(orderDetails);
String waitTime = getWaitTime(order);
String waitTime = getWaitTimeByOrderId(order.getId());
Map<String,String> map =new HashMap<>();
map.put("waitTime",waitTime);
map.put("pickCode",order.getPickCode());
......@@ -554,6 +561,32 @@ public class OrderServiceImpl implements IOrderService
}
public String getWaitTimeByOrderId(Long orderId) {
List<String> status = Arrays.asList(OrderStatusConstant.Paid,OrderStatusConstant.production);
List<Order> orders = orderMapper.selectBeforeOrder(status, orderId);
List<OrderDetail> list = new ArrayList<>();
for (Order order1 : orders) {
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderId(order1.getId());
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
if(CollectionUtils.isEmpty(orderDetails)){
}else{
list.addAll(orderDetails);
}
}
Long takeTimeCount =0L;
for (OrderDetail orderDetail : list) {
Long takeTime = goodsMapper.selectGoodsById(orderDetail.getGoodsId()).getTakeTime();
takeTime = Integer.parseInt(orderDetail.getNum())*takeTime;
takeTimeCount+=takeTime;
}
return String.valueOf((int)(takeTimeCount/60));
}
public List<GoodsVo> getNextOrder(String orderId,String shopId) {
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderId(Long.parseLong(orderId));
......
......@@ -174,6 +174,7 @@ public class ShopRecommendServiceImpl implements IShopRecommendService
last.setTurn(turn);
shopRecommendMapper.updateShopRecommend(frist);
shopRecommendMapper.updateShopRecommend(last);
updateApplication(Long.parseLong(shopRecommend.getShopId()));
return null;
}
......
......@@ -308,6 +308,13 @@ public class ShopServiceImpl implements IShopService
lastShopGoods.setTurn(turn);
shopGoodsMapper.updateShopGoods(fristShopGoods);
shopGoodsMapper.updateShopGoods(lastShopGoods);
Machine machine = new Machine();
machine.setShopId(shopId);
List<Machine> machines = machineMapper.selectMachineList(machine);
if(!machines.isEmpty()){
Machine machine1 =machines .get(0);
updateApplication(machine1.getCode());
}
return null;
}
......
......@@ -244,6 +244,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectOrderVo"/>
where state =#{status} and updated_at &lt; DATE_SUB(NOW() ,interval #{timeout} SECOND)
</select>
<select id="selectBeforeOrder" resultType="com.soss.system.domain.Order">
select id, order_no, order_num, user_id, user_name, user_phone, pay_time, finish_time, amount, goods_num, pick_code, shop_id, machine_id, source, state, created_at, updated_at
from `order` o where o.id &lt;#{orderId} and o.shop_id =(select DISTINCT a.shop_id from `order` a where a.id=#{orderId})
and state in
<foreach item="item" index="index" collection="status"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
<update id="updateCancel">
update `order` set state='8' where state =#{status} and updated_at &lt; DATE_SUB(NOW() ,interval #{timeout} SECOND)
</update>
......
......@@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createdAt != null "> and s.created_at = #{createdAt}</if>
<if test="updatedAt != null "> and s.updated_at = #{updatedAt}</if>
<if test="isDefault != null "> and s.is_default = #{isDefault}</if>
<if test="machineCode!=null"> and m.code =#{machineCode}</if>
<if test="machineCode!=null and machineCode != ''"> and m.code =#{machineCode}</if>
</where>
</select>
......
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