Commit 875859f8 by 张新旗

代码永远在路上

parent 4afda118
......@@ -108,6 +108,13 @@ public class OrderController extends BaseController
{
return toAjax(orderService.updateOrder(order));
}
@RequestMapping("/cancel")
public AjaxResult cancel(String orderId)
{
return toAjax(orderService.cancel(orderId));
}
}
......@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@RestController
......@@ -65,6 +66,12 @@ public class WeixinController {
public AjaxResult getShop(@RequestParam(required = false) String lng,@RequestParam(required = false)String lat){
return AjaxResult.success(appService.getShop(lng,lat));
}
@RequestMapping("/getArea")
public AjaxResult getArea(@RequestParam(required = false) String lng,@RequestParam(required = false)String lat){
List<JSONObject> area = weixinService.getArea(lng,lat);
return AjaxResult.success(area);
}
@GetMapping(value = "/infoByShop")
......
......@@ -107,3 +107,5 @@ push:
secret: b58cb126f80ec9bf7577a213
machine:
url: http://47.94.241.71:10003
json:
path: D:\workspecs\soss\soss\soss-admin\src\main\resources/province.json
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -44,10 +44,20 @@ public class ShopRecommend extends BaseEntity
@Excel(name = "推荐排序")
private String turn;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/** 描述 */
@Excel(name = "描述")
private String desc;
private String name;
/** 类型 1 点单屏推荐 2 今日特惠 */
@Excel(name = "类型 1 点单屏推荐 2 今日特惠")
private String type;
......
......@@ -7,6 +7,16 @@ public class RecommendVo implements Serializable {
private String goodsName;
private String pic;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
private String title;
public String getGoodsName() {
return goodsName;
}
......
......@@ -3,6 +3,7 @@ package com.soss.system.jiguang.impl;
import com.alibaba.fastjson.JSONObject;
import com.soss.common.utils.StringUtils;
import com.soss.system.domain.Machine;
import com.soss.system.domain.Order;
import com.soss.system.domain.vo.PushBean;
import com.soss.system.jiguang.JiGuangPushService;
import com.soss.system.jiguang.MyJiGuangPushService;
......@@ -111,4 +112,21 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
pushAndroid(pushBean,machine.getRegister());
}
}
public void pushOrderState(Order order) {
Machine machine = machineMapper.selectMachineById(order.getMachineId());
if(StringUtils.isNotEmpty(machine.getRegister())){
JSONObject jsonObject = new JSONObject();
jsonObject.put("action","ORDER_STATE_CHANGED");
jsonObject.put("timestamp",System.currentTimeMillis());
JSONObject data = new JSONObject();
data.put("orderId",order.getId());
data.put("orderNo",order.getOrderNo());
data.put("state",order.getState());
PushBean pushBean = new PushBean();
pushBean.setMessageCount(jsonObject);
pushAndroid(pushBean,machine.getRegister());
}
}
}
......@@ -67,5 +67,5 @@ public interface ShopRecommendMapper
List<Goods> selectShopRecommendGoods(@Param("shopId") String shopId,@Param("type") String type);
void deleteByShopIdGoods(Long shopId, List<String> goodsIds);
void deleteByShopIdGoods(@Param("shopId") Long shopId,@Param("goodsIds") List<String> goodsIds);
}
......@@ -68,4 +68,6 @@ public interface IOrderService
AjaxResult check(Order order);
List<Order> getMyOrder(String openId);
int cancel(String orderId);
}
......@@ -15,7 +15,7 @@ public class AppServiceImpl {
@Autowired
private ShopMapper shopMapper;
public List<Shop> getShop(String lng,String lat) {
if(StringUtils.isNotEmpty(lng)||StringUtils.isNotEmpty(lat)){
if(StringUtils.isEmpty(lng)||StringUtils.isEmpty(lat)){
Shop shop = new Shop();
shop.setState("1");
shop.setIsDefault(0L);
......
......@@ -14,6 +14,7 @@ import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*;
import com.soss.system.service.IGoodsService;
import com.soss.system.mapper.*;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -43,6 +44,9 @@ public class GoodsServiceImpl implements IGoodsService
private OrderMapper orderMapper;
@Autowired
private GoodsCategoryMapper goodsCategoryMapper;
ThreadLocal<BigDecimal> discountThread = new ThreadLocal();
ThreadLocal<BigDecimal> priceThread = new ThreadLocal();
/**
* 查询商品
......@@ -152,13 +156,18 @@ public class GoodsServiceImpl implements IGoodsService
private void createSku(List<RuleNode> ruleNodeList, long goodsId, BigDecimal discount,BigDecimal price) {
for (RuleNode<SpecRule> ruleNode : ruleNodeList) {
List<SpecRule> specRuleList = new ArrayList<>();
BigDecimal bigDecimal = new BigDecimal(price.toString());
BigDecimal disCount = new BigDecimal(discount.toString());
RuleNode<SpecRule> parentRuleNode = ruleNode.getParentRuleNode();
specRuleList.add(ruleNode.getRuleNode());
bigDecimal = bigDecimal.add(ruleNode.getRuleNode().getAmount());
priceThread.set(price);
discountThread.set(discount);
priceThread.set(priceThread.get().add(ruleNode.getRuleNode().getAmount()));
discountThread.set(discountThread.get().add(ruleNode.getRuleNode().getAmount()));
System.err.println(priceThread.get());
System.err.println(discountThread.get());
if(parentRuleNode!=null){
findPartentRuleNode(parentRuleNode,specRuleList,bigDecimal,disCount);
findPartentRuleNode(parentRuleNode,specRuleList);
}
Collections.reverse(specRuleList);
GoodsSku goodsSku = new GoodsSku();
......@@ -166,20 +175,20 @@ public class GoodsServiceImpl implements IGoodsService
goodsSku.setCreatedAt(new Date());
goodsSku.setIsDeleted("0");
goodsSku.setUpdatedAt(new Date());
goodsSku.setPrice(bigDecimal);
goodsSku.setDiscount(discount);
goodsSku.setPrice(priceThread.get());
goodsSku.setDiscount(discountThread.get());
goodsSku.setRuleList(JSONArray.toJSONString(specRuleList));
goodsSkuMapper.insertGoodsSku(goodsSku);
}
}
private void findPartentRuleNode(RuleNode<SpecRule> ruleRuleNode, List<SpecRule> specRuleList, BigDecimal bigDecimal, BigDecimal disCount) {
private void findPartentRuleNode(RuleNode<SpecRule> ruleRuleNode, List<SpecRule> specRuleList) {
specRuleList.add(ruleRuleNode.getRuleNode());
bigDecimal = bigDecimal.add(ruleRuleNode.getRuleNode().getAmount());
disCount = disCount.add(ruleRuleNode.getRuleNode().getAmount());
priceThread.set(priceThread.get().add(ruleRuleNode.getRuleNode().getAmount()));
discountThread.set(discountThread.get().add(ruleRuleNode.getRuleNode().getAmount()));
RuleNode<SpecRule> parentRuleNode = ruleRuleNode.getParentRuleNode();
if(parentRuleNode!=null){
findPartentRuleNode(parentRuleNode,specRuleList, bigDecimal, disCount);
findPartentRuleNode(parentRuleNode,specRuleList);
}
}
......
......@@ -6,6 +6,8 @@ import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*;
import com.soss.system.domain.vo.ResultVo;
import com.soss.system.jiguang.JiGuangPushService;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.mapper.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -43,6 +45,8 @@ public class MachineApiServiceImpl {
private StringRedisTemplate stringRedisTemplate;
@Autowired
private GoodsMapper goodsMapper;
@Autowired
private JiGuangPushServiceImpl jiGuangPushService;
public String shopGoodsUpdate(JSONObject jsonObject) {
String shopID = jsonObject.getString("shopId");
......@@ -79,7 +83,9 @@ public class MachineApiServiceImpl {
Order order = new Order();
order.setId(orderID);
order.setState(status);
order.setUpdatedAt(new Date());
int i = orderMapper.updateOrder(order);
jiGuangPushService.pushOrderState(order);
return i+"";
}
......@@ -207,7 +213,14 @@ public class MachineApiServiceImpl {
}
public void updateOrder(Order order) {
JSONObject param = new JSONObject();
JSONObject data = new JSONObject();
data.put("state",Integer.parseInt(order.getState()));
data.put("payTime",order.getPayTime());
data.put("finishTime",order.getFinishTime());
param.put("data",data.toJSONString());
param.put("orderId",order.getId());
sendRequest(param.toJSONString(),"/v1/order/update");
}
public Object checkOrder(JSONObject jsonObject) {
......
......@@ -86,10 +86,10 @@ public class OrderRefundServiceImpl implements IOrderRefundService
// 制作中、制作完成、聚餐中、已完成
String state = order.getState();
if("2".equals(state)||"3".equals(state)){
if("2".equals(state)){
// 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成
}else if("4".equals(state)||"5".equals(state)||"6".equals(state)||"7".equals(state)){
}else if("3".equals(state)||"4".equals(state)||"5".equals(state)||"6".equals(state)||"13".equals(state)){
String desc = orderRefund.getDesc();
if(StringUtils.isEmpty(desc)){
return AjaxResult.error("请联系客服进行退款");
......
......@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
import com.soss.common.constant.HttpStatus;
import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.domain.model.LoginUser;
import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils;
import com.soss.common.utils.spring.SpringUtils;
import com.soss.system.domain.*;
......@@ -138,7 +139,7 @@ public class OrderServiceImpl implements IOrderService
}
}
//发送数据给机器
// machineApiService.createOrder(order);
machineApiService.createOrder(order);
orderOperationLogService.insertOrderOperationLog("待付款",order.getId(),"创建了订单",order.getUserName(),"创建订单");
orderSnapshotService.saveOrderSnapshot(order);
return AjaxResult.success(order.getOrderNo());
......@@ -208,7 +209,7 @@ public class OrderServiceImpl implements IOrderService
@Override
public List<Order> getMyOrder(String openId) {
List<Order> orders = orderMapper.selectByUserId(openId);
List<Order> orders = orderMapper.selectByUserId("oA0gy4xT7vFZ5SGI__x_ss7vNi8g");
for (Order order : orders) {
order.setShop(shopMapper.selectShopById(order.getShopId()));
OrderDetail orderDetail = new OrderDetail();
......@@ -222,6 +223,20 @@ public class OrderServiceImpl implements IOrderService
return orders;
}
@Override
public int cancel(String orderId) {
Order order = orderMapper.selectOrderById(orderId);
if("1".equals(order.getState())){
order.setState("7");
order.setUpdatedAt(new Date());
orderMapper.updateOrder(order);
}else{
throw new ServiceException("该订单不允许取消");
}
return 0;
}
/**
* 获取机器顺序号
* @param shopId
......
......@@ -108,6 +108,7 @@ public class OrderTakingServiceImpl {
shopRecommend.setGoodsId(goodsVo.getGoodsId());
shopRecommend.setType("1");
ShopRecommend shopRecommend1 = shopRecommendMapper.selectShopRecommendList(shopRecommend).get(0);
recommendVo.setTitle(shopRecommend1.getName());
recommendVo.setDesc(shopRecommend1.getDesc());
recommendVo.setGoodsName(shopRecommend1.getGoodsName());
recommendVo.setPic(shopRecommend1.getPic());
......@@ -152,9 +153,9 @@ public class OrderTakingServiceImpl {
goodsVo.setSpecs(buildGoodsSpec(good.getSpec()));
goodsVo.setSpecString(null);
if(recommendGoodsId.contains(String.valueOf(good.getId()))){
goodsVo.setIsRecommend("0");
}else{
goodsVo.setIsRecommend("1");
}else{
goodsVo.setIsRecommend("0");
}
GoodsTag goodsTag = new GoodsTag();
goodsTag.setState("1");
......
......@@ -150,7 +150,7 @@ public class SpecServiceImpl implements ISpecService
spec.setUpdatedAt(new Date());
int i = specMapper.updateSpec(spec);
List<SpecRule> specRules = spec.getSpecRules();
if(specRules ==null || specRules.size()>0){
if(specRules ==null || specRules.isEmpty()){
return i;
}
specRuleMapper.deleteSpecRuleBySpecId(spec.getId());
......
......@@ -18,10 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="recDate" column="rec_date" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="name" column="name" />
</resultMap>
<sql id="selectShopRecommendVo">
select id, shop_id, machine_id, goods_id, goods_name, pic, turn, `desc`, type, state, rec_date, created_at, updated_at from shop_recommend
select id, shop_id, machine_id, goods_id, goods_name, pic, turn, `desc`, type, state, rec_date, created_at, updated_at,name from shop_recommend
</sql>
<select id="selectShopRecommendList" parameterType="ShopRecommend" resultMap="ShopRecommendResult">
......@@ -39,6 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="recDate != null "> and rec_date = #{recDate}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
<if test="name != null "> and name = #{updatedAt}</if>
</where>
</select>
......@@ -62,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="recDate != null">rec_date,</if>
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
<if test="name != null">name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="shopId != null and shopId != ''">#{shopId},</if>
......@@ -76,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="recDate != null">#{recDate},</if>
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
<if test="name != null">#{name},</if>
</trim>
</insert>
......
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