Commit 875859f8 by 张新旗

代码永远在路上

parent 4afda118
...@@ -108,6 +108,13 @@ public class OrderController extends BaseController ...@@ -108,6 +108,13 @@ public class OrderController extends BaseController
{ {
return toAjax(orderService.updateOrder(order)); 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; ...@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map; import java.util.Map;
@RestController @RestController
...@@ -65,6 +66,12 @@ public class WeixinController { ...@@ -65,6 +66,12 @@ public class WeixinController {
public AjaxResult getShop(@RequestParam(required = false) String lng,@RequestParam(required = false)String lat){ public AjaxResult getShop(@RequestParam(required = false) String lng,@RequestParam(required = false)String lat){
return AjaxResult.success(appService.getShop(lng,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") @GetMapping(value = "/infoByShop")
......
...@@ -107,3 +107,5 @@ push: ...@@ -107,3 +107,5 @@ push:
secret: b58cb126f80ec9bf7577a213 secret: b58cb126f80ec9bf7577a213
machine: machine:
url: http://47.94.241.71:10003 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.
package com.soss.framework.web.service; package com.soss.framework.web.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse; import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest; import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
...@@ -21,15 +23,13 @@ import com.soss.common.utils.QRCodeUtil; ...@@ -21,15 +23,13 @@ import com.soss.common.utils.QRCodeUtil;
import com.soss.common.utils.StringUtils; import com.soss.common.utils.StringUtils;
import com.soss.common.utils.ip.IpUtils; import com.soss.common.utils.ip.IpUtils;
import com.soss.common.utils.sign.Base64; import com.soss.common.utils.sign.Base64;
import com.soss.system.domain.Customer; import com.soss.system.domain.*;
import com.soss.system.domain.Order;
import com.soss.system.domain.OrderOperationLog;
import com.soss.system.domain.OrderRefund;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.mapper.CustomerMapper; import com.soss.system.mapper.CustomerMapper;
import com.soss.system.mapper.OrderMapper; import com.soss.system.mapper.OrderMapper;
import com.soss.system.mapper.OrderRefundMapper; import com.soss.system.mapper.OrderRefundMapper;
import com.soss.system.mapper.ShopMapper;
import com.soss.system.service.impl.MachineApiServiceImpl; import com.soss.system.service.impl.MachineApiServiceImpl;
import com.soss.system.service.impl.OrderOperationLogServiceImpl; import com.soss.system.service.impl.OrderOperationLogServiceImpl;
import com.soss.system.weixin.entity.OrderInfo; import com.soss.system.weixin.entity.OrderInfo;
...@@ -44,10 +44,16 @@ import org.slf4j.Logger; ...@@ -44,10 +44,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.web.JsonPath;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
...@@ -55,6 +61,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -55,6 +61,7 @@ import javax.servlet.http.HttpServletRequest;
import java.io.*; import java.io.*;
import java.net.InetAddress; import java.net.InetAddress;
import java.security.spec.AlgorithmParameterSpec; import java.security.spec.AlgorithmParameterSpec;
import java.text.DecimalFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
...@@ -83,6 +90,8 @@ public class WeixinServiceImpl { ...@@ -83,6 +90,8 @@ public class WeixinServiceImpl {
private OrderRefundMapper orderRefundMapper; private OrderRefundMapper orderRefundMapper;
@Autowired @Autowired
private JiGuangPushServiceImpl jiGuangPushService; private JiGuangPushServiceImpl jiGuangPushService;
@Autowired
private ShopMapper shopMapper;
private final ReentrantLock lock = new ReentrantLock(); private final ReentrantLock lock = new ReentrantLock();
...@@ -110,6 +119,9 @@ public class WeixinServiceImpl { ...@@ -110,6 +119,9 @@ public class WeixinServiceImpl {
private String certPath; private String certPath;
@Value("${weixin.refund-url}") @Value("${weixin.refund-url}")
private String refundUrl; private String refundUrl;
private String areaData;
@Value("${json.path}")
private String jsonPath;
public String getSessionKeyOrOpenId(String code) { public String getSessionKeyOrOpenId(String code) {
String url = "https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code"; String url = "https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code";
...@@ -117,6 +129,23 @@ public class WeixinServiceImpl { ...@@ -117,6 +129,23 @@ public class WeixinServiceImpl {
String res = restTemplate.getForObject(replaceUrl,String.class); String res = restTemplate.getForObject(replaceUrl,String.class);
return res; return res;
} }
@PostConstruct
public void getData(){
try{
File file = new File(jsonPath);
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
StringBuilder builder = new StringBuilder();
String line = null;
while ((line=bufferedReader.readLine())!=null){
builder.append(line);
}
areaData = builder.toString();
}catch (Exception e){
log.error("",e);
}
}
public String login(String code, String encryptedData, String iv, String source) { public String login(String code, String encryptedData, String iv, String source) {
try{ try{
...@@ -133,6 +162,7 @@ public class WeixinServiceImpl { ...@@ -133,6 +162,7 @@ public class WeixinServiceImpl {
customer.setHeadSculpturePath(encDataInf.getString("avatarUrl")); customer.setHeadSculpturePath(encDataInf.getString("avatarUrl"));
customer.setUserName(encDataInf.getString("nickName")); customer.setUserName(encDataInf.getString("nickName"));
customer.setPhone(encDataInf.getString("phoneNumber")); customer.setPhone(encDataInf.getString("phoneNumber"));
customer.setUserName("小呼噜"+customer.getPhone().substring(customer.getPhone().length()-4));
customer.setCreateTime(new Date()); customer.setCreateTime(new Date());
if(StringUtils.isNotEmpty(source)){ if(StringUtils.isNotEmpty(source)){
customer.setSoucre(source); customer.setSoucre(source);
...@@ -426,12 +456,10 @@ public class WeixinServiceImpl { ...@@ -426,12 +456,10 @@ public class WeixinServiceImpl {
orderOperationLogService.insertOrderOperationLog("已付款",order.getId(),"付款成功",order.getUserName(),"付款"); orderOperationLogService.insertOrderOperationLog("已付款",order.getId(),"付款成功",order.getUserName(),"付款");
machineApiService.updateOrder(order); machineApiService.updateOrder(order);
//极光推送 //极光推送
String machineId = order.getMachineId();
Map map = new HashMap();
map.put("type","2");
map.put("orderId",order.getId()); jiGuangPushService.pushOrderState(order);
map.put("state",order.getState());
jiGuangPushService.pushMachine(machineId,map);
} }
} finally { } finally {
//要主动释放锁 //要主动释放锁
...@@ -494,14 +522,20 @@ public class WeixinServiceImpl { ...@@ -494,14 +522,20 @@ public class WeixinServiceImpl {
return WxPayNotifyResponse.fail("退款失败"); return WxPayNotifyResponse.fail("退款失败");
} }
OrderRefund orderRefund1 = orderRefunds.get(0); OrderRefund orderRefund1 = orderRefunds.get(0);
Order order = orderMapper.selectOrderById(orderRefund1.getOrderId());
if("1".equals(orderRefund1.getState())){ if("1".equals(orderRefund1.getState())){
orderRefund1.setState("2"); orderRefund1.setState("2");
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()));
order.setState("11");
if(orderRefund1.getRefundAmount().compareTo(order.getAmount())<0){
order.setState("12");
}
orderMapper.updateOrder(order);
orderOperationLogService.insertOrderOperationLog("已退款", Long.valueOf(orderRefund.getOrderId()),"用户退款成功,已到账","系统","退款"); orderOperationLogService.insertOrderOperationLog("已退款", Long.valueOf(orderRefund.getOrderId()),"用户退款成功,已到账","系统","退款");
machineApiService.updateOrder(order);
jiGuangPushService.pushOrderState(order);
return WxPayNotifyResponse.success("退款成功!"); return WxPayNotifyResponse.success("退款成功!");
} }
...@@ -519,4 +553,114 @@ public class WeixinServiceImpl { ...@@ -519,4 +553,114 @@ public class WeixinServiceImpl {
} }
return WxPayNotifyResponse.fail("回调有误!"); return WxPayNotifyResponse.fail("回调有误!");
} }
public List<JSONObject> getArea(String lng,String lat) {
String provinceString ="[value ='%s'][0].name";
String cityString ="[value='%s'][0].children[value='%s'][0].name";
String zoneString = "[value='%s'][0].children[value='%s'][0].children[value='%s'][0].name";
Shop shop = new Shop();
shop.setState("1");
List<Shop> shops = shopMapper.selectShopList(shop);
List<JSONObject> proviceList = new ArrayList<>();
List<String> proString = new ArrayList<>();
for (Shop shop1 : shops) {
double v = GetDistance(Double.parseDouble(lng), Double.parseDouble(lat), Double.parseDouble(shop1.getLng()), Double.parseDouble(shop1.getLat()));
DecimalFormat df = new DecimalFormat("0.00");
shop1.setDistance(df.format(v));
String province = shop1.getProvince();
if(proString.contains(province)){
for (JSONObject provinceObject : proviceList) {
if(province.equals(provinceObject.getString("value"))){
JSONArray cityChild = provinceObject.getJSONArray("children");
boolean cityboo =true;
for(int i=0;i<cityChild.size();i++){
JSONObject city = cityChild.getJSONObject(i);
if(shop1.getCity().equals(city.getString("value"))){
cityboo =false;
JSONArray zooeObject = city.getJSONArray("children");
boolean zoneBoo = true;
for(int j=0;j<zooeObject.size();j++){
JSONObject zooe = zooeObject.getJSONObject(j);
if(shop1.getZone().equals(zooe.getString("value"))){
zoneBoo = false;
zooe.getJSONArray("shops").add(shop1);
}
}
if(zoneBoo){
JSONObject zone =new JSONObject();
zone.put("value",shop1.getZone());
zone.put("name",JSONPath.read(areaData,String.format(zoneString,province,shop1.getCity(),shop1.getZone())));
zooeObject.add(zone);
List<Shop> shopList = new ArrayList<>();
shopList.add(shop1);
zone.put("shops",shopList);
}
}
}
if(cityboo){
JSONObject city = new JSONObject();
city.put("value",shop1.getCity());
city.put("name",JSONPath.read(areaData,String.format(cityString,province,shop1.getCity())));
cityChild.add(city);
}
}
}
}else{
proString.add(province);
JSONObject provice = new JSONObject();
provice.put("value",province);
String format = String.format(provinceString, province);
provice.put("name",JSONPath.read(areaData,format));
proviceList.add(provice);
JSONObject city = new JSONObject();
city.put("value",shop1.getCity());
city.put("name",JSONPath.read(areaData,String.format(cityString,province,shop1.getCity())));
List<JSONObject> citys =new ArrayList<>();
citys.add(city);
provice.put("children",citys);
JSONObject zone =new JSONObject();
zone.put("value",shop1.getZone());
zone.put("name",JSONPath.read(areaData,String.format(zoneString,province,shop1.getCity(),shop1.getZone())));
List<Shop> shopList = new ArrayList<>();
shopList.add(shop1);
zone.put("shops",shopList);
List<JSONObject> zones = new ArrayList<>();
zones.add(zone);
city.put("children",zones);
}
}
return proviceList;
}
private static final double EARTH_RADIUS = 6378137;
/**
* 根据两点间经纬度坐标(double值),计算两点间距离,单位为米
* @param lng1
* @param lat1
* @param lng2
* @param lat2
* @return
*/
public static double GetDistance(double lng1, double lat1, double lng2, double lat2)
{
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lng1) - rad(lng2);
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s * EARTH_RADIUS;
s = Math.round(s * 10000) / 10000;
return s;
}
private static double rad(double d)
{
return d * Math.PI / 180.0;
}
} }
...@@ -44,10 +44,20 @@ public class ShopRecommend extends BaseEntity ...@@ -44,10 +44,20 @@ public class ShopRecommend extends BaseEntity
@Excel(name = "推荐排序") @Excel(name = "推荐排序")
private String turn; private String turn;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/** 描述 */ /** 描述 */
@Excel(name = "描述") @Excel(name = "描述")
private String desc; private String desc;
private String name;
/** 类型 1 点单屏推荐 2 今日特惠 */ /** 类型 1 点单屏推荐 2 今日特惠 */
@Excel(name = "类型 1 点单屏推荐 2 今日特惠") @Excel(name = "类型 1 点单屏推荐 2 今日特惠")
private String type; private String type;
......
...@@ -7,6 +7,16 @@ public class RecommendVo implements Serializable { ...@@ -7,6 +7,16 @@ public class RecommendVo implements Serializable {
private String goodsName; private String goodsName;
private String pic; private String pic;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
private String title;
public String getGoodsName() { public String getGoodsName() {
return goodsName; return goodsName;
} }
......
...@@ -3,6 +3,7 @@ package com.soss.system.jiguang.impl; ...@@ -3,6 +3,7 @@ package com.soss.system.jiguang.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.common.utils.StringUtils; import com.soss.common.utils.StringUtils;
import com.soss.system.domain.Machine; import com.soss.system.domain.Machine;
import com.soss.system.domain.Order;
import com.soss.system.domain.vo.PushBean; import com.soss.system.domain.vo.PushBean;
import com.soss.system.jiguang.JiGuangPushService; import com.soss.system.jiguang.JiGuangPushService;
import com.soss.system.jiguang.MyJiGuangPushService; import com.soss.system.jiguang.MyJiGuangPushService;
...@@ -111,4 +112,21 @@ public class JiGuangPushServiceImpl implements JiGuangPushService { ...@@ -111,4 +112,21 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
pushAndroid(pushBean,machine.getRegister()); 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 ...@@ -67,5 +67,5 @@ public interface ShopRecommendMapper
List<Goods> selectShopRecommendGoods(@Param("shopId") String shopId,@Param("type") String type); 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 ...@@ -68,4 +68,6 @@ public interface IOrderService
AjaxResult check(Order order); AjaxResult check(Order order);
List<Order> getMyOrder(String openId); List<Order> getMyOrder(String openId);
int cancel(String orderId);
} }
...@@ -15,7 +15,7 @@ public class AppServiceImpl { ...@@ -15,7 +15,7 @@ public class AppServiceImpl {
@Autowired @Autowired
private ShopMapper shopMapper; private ShopMapper shopMapper;
public List<Shop> getShop(String lng,String lat) { 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 shop = new Shop();
shop.setState("1"); shop.setState("1");
shop.setIsDefault(0L); shop.setIsDefault(0L);
......
...@@ -14,6 +14,7 @@ import com.soss.common.utils.StringUtils; ...@@ -14,6 +14,7 @@ import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*; import com.soss.system.domain.*;
import com.soss.system.service.IGoodsService; import com.soss.system.service.IGoodsService;
import com.soss.system.mapper.*; import com.soss.system.mapper.*;
import org.apache.poi.ss.formula.functions.T;
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.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -43,6 +44,9 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -43,6 +44,9 @@ public class GoodsServiceImpl implements IGoodsService
private OrderMapper orderMapper; private OrderMapper orderMapper;
@Autowired @Autowired
private GoodsCategoryMapper goodsCategoryMapper; private GoodsCategoryMapper goodsCategoryMapper;
ThreadLocal<BigDecimal> discountThread = new ThreadLocal();
ThreadLocal<BigDecimal> priceThread = new ThreadLocal();
/** /**
* 查询商品 * 查询商品
...@@ -152,13 +156,18 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -152,13 +156,18 @@ public class GoodsServiceImpl implements IGoodsService
private void createSku(List<RuleNode> ruleNodeList, long goodsId, BigDecimal discount,BigDecimal price) { private void createSku(List<RuleNode> ruleNodeList, long goodsId, BigDecimal discount,BigDecimal price) {
for (RuleNode<SpecRule> ruleNode : ruleNodeList) { for (RuleNode<SpecRule> ruleNode : ruleNodeList) {
List<SpecRule> specRuleList = new ArrayList<>(); List<SpecRule> specRuleList = new ArrayList<>();
BigDecimal bigDecimal = new BigDecimal(price.toString());
BigDecimal disCount = new BigDecimal(discount.toString());
RuleNode<SpecRule> parentRuleNode = ruleNode.getParentRuleNode(); RuleNode<SpecRule> parentRuleNode = ruleNode.getParentRuleNode();
specRuleList.add(ruleNode.getRuleNode()); 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){ if(parentRuleNode!=null){
findPartentRuleNode(parentRuleNode,specRuleList,bigDecimal,disCount); findPartentRuleNode(parentRuleNode,specRuleList);
} }
Collections.reverse(specRuleList); Collections.reverse(specRuleList);
GoodsSku goodsSku = new GoodsSku(); GoodsSku goodsSku = new GoodsSku();
...@@ -166,20 +175,20 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -166,20 +175,20 @@ public class GoodsServiceImpl implements IGoodsService
goodsSku.setCreatedAt(new Date()); goodsSku.setCreatedAt(new Date());
goodsSku.setIsDeleted("0"); goodsSku.setIsDeleted("0");
goodsSku.setUpdatedAt(new Date()); goodsSku.setUpdatedAt(new Date());
goodsSku.setPrice(bigDecimal); goodsSku.setPrice(priceThread.get());
goodsSku.setDiscount(discount); goodsSku.setDiscount(discountThread.get());
goodsSku.setRuleList(JSONArray.toJSONString(specRuleList)); goodsSku.setRuleList(JSONArray.toJSONString(specRuleList));
goodsSkuMapper.insertGoodsSku(goodsSku); 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()); specRuleList.add(ruleRuleNode.getRuleNode());
bigDecimal = bigDecimal.add(ruleRuleNode.getRuleNode().getAmount()); priceThread.set(priceThread.get().add(ruleRuleNode.getRuleNode().getAmount()));
disCount = disCount.add(ruleRuleNode.getRuleNode().getAmount()); discountThread.set(discountThread.get().add(ruleRuleNode.getRuleNode().getAmount()));
RuleNode<SpecRule> parentRuleNode = ruleRuleNode.getParentRuleNode(); RuleNode<SpecRule> parentRuleNode = ruleRuleNode.getParentRuleNode();
if(parentRuleNode!=null){ if(parentRuleNode!=null){
findPartentRuleNode(parentRuleNode,specRuleList, bigDecimal, disCount); findPartentRuleNode(parentRuleNode,specRuleList);
} }
} }
......
...@@ -6,6 +6,8 @@ import com.soss.common.exception.ServiceException; ...@@ -6,6 +6,8 @@ import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils; import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*; import com.soss.system.domain.*;
import com.soss.system.domain.vo.ResultVo; 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 com.soss.system.mapper.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -43,6 +45,8 @@ public class MachineApiServiceImpl { ...@@ -43,6 +45,8 @@ public class MachineApiServiceImpl {
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
@Autowired @Autowired
private GoodsMapper goodsMapper; private GoodsMapper goodsMapper;
@Autowired
private JiGuangPushServiceImpl jiGuangPushService;
public String shopGoodsUpdate(JSONObject jsonObject) { public String shopGoodsUpdate(JSONObject jsonObject) {
String shopID = jsonObject.getString("shopId"); String shopID = jsonObject.getString("shopId");
...@@ -79,7 +83,9 @@ public class MachineApiServiceImpl { ...@@ -79,7 +83,9 @@ public class MachineApiServiceImpl {
Order order = new Order(); Order order = new Order();
order.setId(orderID); order.setId(orderID);
order.setState(status); order.setState(status);
order.setUpdatedAt(new Date());
int i = orderMapper.updateOrder(order); int i = orderMapper.updateOrder(order);
jiGuangPushService.pushOrderState(order);
return i+""; return i+"";
} }
...@@ -207,7 +213,14 @@ public class MachineApiServiceImpl { ...@@ -207,7 +213,14 @@ public class MachineApiServiceImpl {
} }
public void updateOrder(Order order) { 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) { public Object checkOrder(JSONObject jsonObject) {
......
...@@ -86,10 +86,10 @@ public class OrderRefundServiceImpl implements IOrderRefundService ...@@ -86,10 +86,10 @@ public class OrderRefundServiceImpl implements IOrderRefundService
// 制作中、制作完成、聚餐中、已完成 // 制作中、制作完成、聚餐中、已完成
String state = order.getState(); String state = order.getState();
if("2".equals(state)||"3".equals(state)){ if("2".equals(state)){
// 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成 // 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(); String desc = orderRefund.getDesc();
if(StringUtils.isEmpty(desc)){ if(StringUtils.isEmpty(desc)){
return AjaxResult.error("请联系客服进行退款"); return AjaxResult.error("请联系客服进行退款");
......
...@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
import com.soss.common.constant.HttpStatus; import com.soss.common.constant.HttpStatus;
import com.soss.common.core.domain.AjaxResult; import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.domain.model.LoginUser; 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.StringUtils;
import com.soss.common.utils.spring.SpringUtils; import com.soss.common.utils.spring.SpringUtils;
import com.soss.system.domain.*; import com.soss.system.domain.*;
...@@ -138,7 +139,7 @@ public class OrderServiceImpl implements IOrderService ...@@ -138,7 +139,7 @@ public class OrderServiceImpl implements IOrderService
} }
} }
//发送数据给机器 //发送数据给机器
// machineApiService.createOrder(order); machineApiService.createOrder(order);
orderOperationLogService.insertOrderOperationLog("待付款",order.getId(),"创建了订单",order.getUserName(),"创建订单"); orderOperationLogService.insertOrderOperationLog("待付款",order.getId(),"创建了订单",order.getUserName(),"创建订单");
orderSnapshotService.saveOrderSnapshot(order); orderSnapshotService.saveOrderSnapshot(order);
return AjaxResult.success(order.getOrderNo()); return AjaxResult.success(order.getOrderNo());
...@@ -208,7 +209,7 @@ public class OrderServiceImpl implements IOrderService ...@@ -208,7 +209,7 @@ public class OrderServiceImpl implements IOrderService
@Override @Override
public List<Order> getMyOrder(String openId) { public List<Order> getMyOrder(String openId) {
List<Order> orders = orderMapper.selectByUserId(openId); List<Order> orders = orderMapper.selectByUserId("oA0gy4xT7vFZ5SGI__x_ss7vNi8g");
for (Order order : orders) { for (Order order : orders) {
order.setShop(shopMapper.selectShopById(order.getShopId())); order.setShop(shopMapper.selectShopById(order.getShopId()));
OrderDetail orderDetail = new OrderDetail(); OrderDetail orderDetail = new OrderDetail();
...@@ -222,6 +223,20 @@ public class OrderServiceImpl implements IOrderService ...@@ -222,6 +223,20 @@ public class OrderServiceImpl implements IOrderService
return orders; 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 * @param shopId
......
...@@ -108,6 +108,7 @@ public class OrderTakingServiceImpl { ...@@ -108,6 +108,7 @@ public class OrderTakingServiceImpl {
shopRecommend.setGoodsId(goodsVo.getGoodsId()); shopRecommend.setGoodsId(goodsVo.getGoodsId());
shopRecommend.setType("1"); shopRecommend.setType("1");
ShopRecommend shopRecommend1 = shopRecommendMapper.selectShopRecommendList(shopRecommend).get(0); ShopRecommend shopRecommend1 = shopRecommendMapper.selectShopRecommendList(shopRecommend).get(0);
recommendVo.setTitle(shopRecommend1.getName());
recommendVo.setDesc(shopRecommend1.getDesc()); recommendVo.setDesc(shopRecommend1.getDesc());
recommendVo.setGoodsName(shopRecommend1.getGoodsName()); recommendVo.setGoodsName(shopRecommend1.getGoodsName());
recommendVo.setPic(shopRecommend1.getPic()); recommendVo.setPic(shopRecommend1.getPic());
...@@ -152,9 +153,9 @@ public class OrderTakingServiceImpl { ...@@ -152,9 +153,9 @@ public class OrderTakingServiceImpl {
goodsVo.setSpecs(buildGoodsSpec(good.getSpec())); goodsVo.setSpecs(buildGoodsSpec(good.getSpec()));
goodsVo.setSpecString(null); goodsVo.setSpecString(null);
if(recommendGoodsId.contains(String.valueOf(good.getId()))){ if(recommendGoodsId.contains(String.valueOf(good.getId()))){
goodsVo.setIsRecommend("0");
}else{
goodsVo.setIsRecommend("1"); goodsVo.setIsRecommend("1");
}else{
goodsVo.setIsRecommend("0");
} }
GoodsTag goodsTag = new GoodsTag(); GoodsTag goodsTag = new GoodsTag();
goodsTag.setState("1"); goodsTag.setState("1");
......
...@@ -150,7 +150,7 @@ public class SpecServiceImpl implements ISpecService ...@@ -150,7 +150,7 @@ public class SpecServiceImpl implements ISpecService
spec.setUpdatedAt(new Date()); spec.setUpdatedAt(new Date());
int i = specMapper.updateSpec(spec); int i = specMapper.updateSpec(spec);
List<SpecRule> specRules = spec.getSpecRules(); List<SpecRule> specRules = spec.getSpecRules();
if(specRules ==null || specRules.size()>0){ if(specRules ==null || specRules.isEmpty()){
return i; return i;
} }
specRuleMapper.deleteSpecRuleBySpecId(spec.getId()); specRuleMapper.deleteSpecRuleBySpecId(spec.getId());
......
...@@ -18,10 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -18,10 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="recDate" column="rec_date" /> <result property="recDate" column="rec_date" />
<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="name" column="name" />
</resultMap> </resultMap>
<sql id="selectShopRecommendVo"> <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> </sql>
<select id="selectShopRecommendList" parameterType="ShopRecommend" resultMap="ShopRecommendResult"> <select id="selectShopRecommendList" parameterType="ShopRecommend" resultMap="ShopRecommendResult">
...@@ -39,6 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -39,6 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="recDate != null "> and rec_date = #{recDate}</if> <if test="recDate != null "> and rec_date = #{recDate}</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>
<if test="name != null "> and name = #{updatedAt}</if>
</where> </where>
</select> </select>
...@@ -62,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -62,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="recDate != null">rec_date,</if> <if test="recDate != null">rec_date,</if>
<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="name != null">name,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="shopId != null and shopId != ''">#{shopId},</if> <if test="shopId != null and shopId != ''">#{shopId},</if>
...@@ -76,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -76,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="recDate != null">#{recDate},</if> <if test="recDate != null">#{recDate},</if>
<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="name != null">#{name},</if>
</trim> </trim>
</insert> </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