Commit 2608aa50 by 张新旗

代码提交

parent d3d00a1c
...@@ -3,6 +3,7 @@ package com.soss.web.controller.coffee; ...@@ -3,6 +3,7 @@ package com.soss.web.controller.coffee;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.common.core.domain.AjaxResult; import com.soss.common.core.domain.AjaxResult;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils;
import com.soss.common.utils.uuid.UUID; import com.soss.common.utils.uuid.UUID;
import com.soss.system.domain.Machine; import com.soss.system.domain.Machine;
import com.soss.system.domain.Shop; import com.soss.system.domain.Shop;
...@@ -37,15 +38,18 @@ public class ApplicationController { ...@@ -37,15 +38,18 @@ public class ApplicationController {
String id = UUID.randomUUID().toString(); String id = UUID.randomUUID().toString();
String key = machineCode;//+"_"+id; String key = machineCode;//+"_"+id;
stringRedisTemplate.opsForValue().set(key, body); stringRedisTemplate.opsForValue().set(key, body);
stringRedisTemplate.expire(id,1, TimeUnit.HOURS); stringRedisTemplate.expire(key,60, TimeUnit.SECONDS);
return AjaxResult.success("处理成功",key); return AjaxResult.success("处理成功",key);
} }
@RequestMapping("/getData") @RequestMapping("/getData")
public AjaxResult getApplicationData(String body){ public AjaxResult getApplicationData(@RequestBody String body){
JSONObject jj = JSONObject.parseObject(body); JSONObject jj = JSONObject.parseObject(body);
String key = jj.getString("key"); String key = jj.getString("key");
JSONObject location = jj.getJSONObject("location"); JSONObject location = jj.getJSONObject("location");
String s = stringRedisTemplate.opsForValue().get(key); String s = stringRedisTemplate.opsForValue().get(key);
if(StringUtils.isEmpty(s)){
throw new ServiceException("该二维码已经过期");
}
JSONObject info = JSONObject.parseObject(s); JSONObject info = JSONObject.parseObject(s);
String machineCode = info.getString("machineCode"); String machineCode = info.getString("machineCode");
Machine machine = machineService.selectMachineByCode(machineCode); Machine machine = machineService.selectMachineByCode(machineCode);
...@@ -84,7 +88,7 @@ public class ApplicationController { ...@@ -84,7 +88,7 @@ public class ApplicationController {
return AjaxResult.success(orderService.getOrderInfo(machineCode)); return AjaxResult.success(orderService.getOrderInfo(machineCode));
} }
@RequestMapping("/checkSku") @RequestMapping("/checkSku")
private AjaxResult checkSku(@RequestParam(required = false) String shopId,String skuId,@RequestParam(required = false) String machineCode){ public AjaxResult checkSku(@RequestParam(required = false) String shopId,String skuId,@RequestParam(required = false) String machineCode){
return shopService.checkSku(shopId,skuId,machineCode); return shopService.checkSku(shopId,skuId,machineCode);
} }
} }
...@@ -14,6 +14,7 @@ import com.soss.system.domain.Order; ...@@ -14,6 +14,7 @@ import com.soss.system.domain.Order;
import com.soss.system.domain.vo.customer.CustomerQueryVo; import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo; import com.soss.system.domain.vo.customer.CustomerResultVo;
import com.soss.system.service.ICustomerService; import com.soss.system.service.ICustomerService;
import com.soss.system.service.impl.CustomerServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -39,10 +40,11 @@ public class CustomerController extends BaseController ...@@ -39,10 +40,11 @@ public class CustomerController extends BaseController
@GetMapping("/allow") @GetMapping("/allow")
private AjaxResult allow(HttpServletRequest request,String allow){ public AjaxResult allow(HttpServletRequest request,String allow){
TokenService bean = SpringUtils.getBean(TokenService.class); TokenService bean = SpringUtils.getBean(TokenService.class);
LoginUser loginUser = bean.getLoginUser(request); LoginUser loginUser = bean.getLoginUser(request);
return AjaxResult.success(customerService.allow(loginUser.getOpenId(),allow));
return AjaxResult.success(SpringUtils.getBean(CustomerServiceImpl.class).allow(loginUser.getOpenId(),allow));
} }
/** /**
......
...@@ -3,6 +3,7 @@ package com.soss.web.controller.coffee; ...@@ -3,6 +3,7 @@ package com.soss.web.controller.coffee;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.common.constant.Constants; import com.soss.common.constant.Constants;
import com.soss.common.core.domain.AjaxResult; import com.soss.common.core.domain.AjaxResult;
import com.soss.common.utils.spring.SpringUtils;
import com.soss.framework.web.service.WeixinServiceImpl; import com.soss.framework.web.service.WeixinServiceImpl;
import com.soss.system.domain.Order; import com.soss.system.domain.Order;
import com.soss.system.mapper.OrderMapper; import com.soss.system.mapper.OrderMapper;
...@@ -72,18 +73,11 @@ public class WeixinController { ...@@ -72,18 +73,11 @@ public class WeixinController {
return weixinService.wxNotify(request); return weixinService.wxNotify(request);
} }
@Autowired
private SendMessageUtils sendMessageUtils;
@RequestMapping("/test")
public Map<String, String> test(HttpServletRequest request) throws Exception{
Order order = orderService.selectOrderById("98");
sendMessageUtils.sendWxMsg(order);
return null;
}
@RequestMapping("/getShop") @RequestMapping("/getShop")
public AjaxResult getShop(){ public AjaxResult getShop(@RequestParam(required = false)String lng,@RequestParam(required = false)String lat){
return AjaxResult.success(appService.getShop()); return AjaxResult.success(appService.getShop(lng,lat));
} }
@RequestMapping("/getArea") @RequestMapping("/getArea")
public AjaxResult getArea(@RequestParam(required = false) String lng,@RequestParam(required = false)String lat){ public AjaxResult getArea(@RequestParam(required = false) String lng,@RequestParam(required = false)String lat){
......
...@@ -50,8 +50,8 @@ spring: ...@@ -50,8 +50,8 @@ spring:
token: token:
header: Authorization header: Authorization
secret: abcdefghijklmnopqrstuvwxyz secret: hoolooghijklmnopqrstuvwxyz
expireTime: 30 expireTime: 720
mybatis: mybatis:
typeAliasesPackage: com.soss.**.domain typeAliasesPackage: com.soss.**.domain
...@@ -105,8 +105,8 @@ sms: ...@@ -105,8 +105,8 @@ sms:
accessKeySecret: accessKeySecret:
signName: signName:
push: push:
appkey: 682a53c0cd0201792d45c469 appkey: 59c9290134b359212290c075
secret: b58cb126f80ec9bf7577a213 secret: 026756e7d5688089898db088
machine: machine:
url: http://47.94.241.71:10003 url: http://47.94.241.71:10003
json: json:
......
...@@ -101,7 +101,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -101,7 +101,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage","/weixin/**","/application/**","/v1/**","/tool/**").permitAll() .antMatchers("/login", "/register", "/captchaImage","/weixin/**","/application/**","/v1/**","/tool/**","/app/getWaitTine").permitAll()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,
"/", "/",
......
...@@ -20,6 +20,8 @@ import java.net.URLDecoder; ...@@ -20,6 +20,8 @@ import java.net.URLDecoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Aspect
@Configuration
@Slf4j @Slf4j
public class LoggerAspect { public class LoggerAspect {
// 定义切点Pointcut // 定义切点Pointcut
......
...@@ -8,26 +8,26 @@ import org.springframework.stereotype.Service; ...@@ -8,26 +8,26 @@ import org.springframework.stereotype.Service;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class AppServiceImpl { public class AppServiceImpl {
@Autowired @Autowired
private ShopMapper shopMapper; private ShopMapper shopMapper;
public Shop getShop() { public Shop getShop(String lng, String lat) {
Shop shop = new Shop(); Shop shop = new Shop();
shop.setState("1"); shop.setState("1");
shop.setIsDefault(1L); shop.setIsDefault(1L);
List<Shop> shops = shopMapper.selectShopList(shop); List<Shop> shops = shopMapper.selectShopList(shop);
if(shops !=null &&!shops.isEmpty()){ if(shops !=null &&!shops.isEmpty()){
Shop shop1 = shops.get(0); Shop shop1 = shops.get(0);
if(StringUtils.isNotEmpty(lng)&&StringUtils.isNotEmpty(lat)){
shop.setDistance(AppServiceImpl.GetDistance(Double.parseDouble(lng),Double.parseDouble(lat),Double.parseDouble(shop.getLng()),Double.parseDouble(shop.getLat())));
}
return shop1; return shop1;
}else{ }else{
return new Shop(); return new Shop();
} }
//return shops.stream().sorted((x, y) -> x.getDistance().compareTo(y.getDistance())).collect(Collectors.toList());
} }
...@@ -63,7 +63,7 @@ public class AppServiceImpl { ...@@ -63,7 +63,7 @@ public class AppServiceImpl {
}else{ }else{
Double aDouble =s; Double aDouble =s;
return aDouble.intValue()+"公里"; return aDouble.intValue()+"";
} }
} }
......
...@@ -132,7 +132,7 @@ public class CustomerServiceImpl implements ICustomerService ...@@ -132,7 +132,7 @@ public class CustomerServiceImpl implements ICustomerService
public Integer allow(String openId, String allow) { public Integer allow(String openId, String allow) {
Customer customer = new Customer(); Customer customer = new Customer();
customer.setId(openId); customer.setId(openId);
customer.setAllow(allow); customer.setAllow("1");
return customerMapper.updateCustomer(customer); return customerMapper.updateCustomer(customer);
} }
} }
...@@ -8,7 +8,6 @@ import com.soss.common.utils.StringUtils; ...@@ -8,7 +8,6 @@ import com.soss.common.utils.StringUtils;
import com.soss.system.constants.OrderStatusConstant; import com.soss.system.constants.OrderStatusConstant;
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.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.mapper.*; import com.soss.system.mapper.*;
import com.soss.system.weixin.util.SendMessageUtils; import com.soss.system.weixin.util.SendMessageUtils;
...@@ -23,9 +22,7 @@ import org.springframework.http.ResponseEntity; ...@@ -23,9 +22,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
@Service @Service
@Slf4j @Slf4j
...@@ -70,19 +67,68 @@ public class MachineApiServiceImpl { ...@@ -70,19 +67,68 @@ public class MachineApiServiceImpl {
} }
ShopGoodsSku shopGoodsSku = new ShopGoodsSku(); ShopGoodsSku shopGoodsSku = new ShopGoodsSku();
shopGoodsSku.setShopId(Long.parseLong(shopID)); shopGoodsSku.setShopId(Long.parseLong(shopID));
Map<Long,List<Long>> map = new HashMap<>();
for (String skuId : skuIds) { for (String skuId : skuIds) {
shopGoodsSku.setSkuId(Long.parseLong(skuId)); shopGoodsSku.setSkuId(Long.parseLong(skuId));
List<ShopGoodsSku> shopGoodsSkus = shopGoodsSkuMapper.selectShopGoodsSkuList(shopGoodsSku); List<ShopGoodsSku> shopGoodsSkus = shopGoodsSkuMapper.selectShopGoodsSkuList(shopGoodsSku);
if(shopGoodsSkus.isEmpty()){ if(shopGoodsSkus.isEmpty()){
throw new ServiceException(skuId+"不存在"); throw new ServiceException(skuId+"不存在");
} }
for (ShopGoodsSku goodsSkus : shopGoodsSkus) {
Long goodsId = goodsSkus.getGoodsId();
List<Long> strings = map.get(goodsId);
if(strings ==null){
strings = new ArrayList<>();
}
strings.add(goodsSkus.getSkuId());
map.put(goodsId,strings);
}
} }
int i = shopGoodsSkuMapper.updateSkuStatus(skuIds, robotID, shopID, status); int i = shopGoodsSkuMapper.updateSkuStatus(skuIds, robotID, shopID, status);
//推送给极光
Machine machine = machineMapper.selectMachineById(robotID);
String code = machine.getCode();
this.push(code,status,map);
return ""+i; return ""+i;
} }
/**
* {
* "action": "SKU_STATE_CHANGED",
* "timestamp": 1390010203013,
* "data": {
* "machineCode": "SN010293123",
* "goodsId": 100,
* "skuIds": [
* 200,
* 300
* ],
* "state": 2
* }
* }
* @param code
* @param status
* @param map
*/
private void push( String code, String status, Map<Long, List<Long>> map){
for (Long aLong : map.keySet()) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("action","SKU_STATE_CHANGED");
jsonObject.put("timestamp",System.currentTimeMillis());
JSONObject data = new JSONObject();
jsonObject.put("data",data);
data.put("machineCode",code);
data.put("goodsId",aLong);
data.put("skuIds",map.get(aLong));
data.put("state",status);
jiGuangPushService.push(code,jsonObject);
}
}
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");
......
...@@ -158,14 +158,14 @@ public class OrderServiceImpl implements IOrderService ...@@ -158,14 +158,14 @@ public class OrderServiceImpl implements IOrderService
List<OrderDetail> orderDetails = order.getOrderDetails(); List<OrderDetail> orderDetails = order.getOrderDetails();
if(orderDetails !=null && !orderDetails.isEmpty()){ if(orderDetails !=null && !orderDetails.isEmpty()){
BigDecimal bigDecimal = new BigDecimal(0); // BigDecimal bigDecimal = new BigDecimal(0);
for (OrderDetail orderDetail : orderDetails) { // for (OrderDetail orderDetail : orderDetails) {
bigDecimal = bigDecimal.add(orderDetail.getRealAmount().multiply( new BigDecimal(orderDetail.getNum()))); // bigDecimal = bigDecimal.add(orderDetail.getRealAmount().multiply( new BigDecimal(orderDetail.getNum())));
} // }
if(order.getAmount().compareTo(bigDecimal)!=0){ // if(order.getAmount().compareTo(bigDecimal)!=0){
throw new ServiceException("价格计算出现了问题,请重新计算"+ bigDecimal.stripTrailingZeros().toString() ); // throw new ServiceException("价格计算出现了问题,请重新计算"+ bigDecimal.stripTrailingZeros().toString() );
} // }
order.setAmount(bigDecimal); // order.setAmount(bigDecimal);
int i = orderMapper.insertOrder(order); int i = orderMapper.insertOrder(order);
for (OrderDetail orderDetail : orderDetails) { for (OrderDetail orderDetail : orderDetails) {
orderDetail.setOrderId(order.getId()); orderDetail.setOrderId(order.getId());
......
...@@ -14,6 +14,7 @@ import com.soss.system.service.IShopService; ...@@ -14,6 +14,7 @@ import com.soss.system.service.IShopService;
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;
import org.springframework.cglib.core.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -76,8 +77,8 @@ public class ShopServiceImpl implements IShopService ...@@ -76,8 +77,8 @@ public class ShopServiceImpl implements IShopService
Machine machine = new Machine(); Machine machine = new Machine();
machine.setShopId(shop1.getId()); machine.setShopId(shop1.getId());
shop1.setMachineCount(machineMapper.selectMachineList(machine).size()); shop1.setMachineCount(machineMapper.selectMachineList(machine).size());
shop1.setSalesAmount(orderMapper.selectSalesAmount(shop.getId())); shop1.setSalesAmount(orderMapper.selectSalesAmount(shop1.getId()));
shop1.setSalesVolume(orderMapper.selectSalesVolume(shop.getId(),null)); shop1.setSalesVolume(orderMapper.selectSalesVolume(shop1.getId(),null));
} }
return shops; return shops;
...@@ -201,6 +202,22 @@ public class ShopServiceImpl implements IShopService ...@@ -201,6 +202,22 @@ public class ShopServiceImpl implements IShopService
List<Goods> goodsList = shopGoodsMapper.selectShopCategoryGoodsByCategoryId(shopId,category.getId()); List<Goods> goodsList = shopGoodsMapper.selectShopCategoryGoodsByCategoryId(shopId,category.getId());
for (Goods goods : goodsList) { for (Goods goods : goodsList) {
ShopGoodsSku shopGoodsSku = new ShopGoodsSku();
shopGoodsSku.setShopId(shopId);
shopGoodsSku.setGoodsId(goods.getId());
List<ShopGoodsSku> shopGoodsSkus = shopGoodsSkuMapper.selectShopGoodsSkuList(shopGoodsSku);
if(!shopGoodsSkus.isEmpty()){
boolean boo= true;
for (ShopGoodsSku goodsSkus : shopGoodsSkus) {
if("2".equals(goodsSkus.getState())){
boo = false;
}
}
if(!boo){
goods.setState("2");
}
}
ShopRecommend shopRecommend = new ShopRecommend(); ShopRecommend shopRecommend = new ShopRecommend();
shopRecommend.setShopId(String.valueOf(shopId)); shopRecommend.setShopId(String.valueOf(shopId));
shopRecommend.setGoodsId(String.valueOf(goods.getId())); shopRecommend.setGoodsId(String.valueOf(goods.getId()));
......
...@@ -130,29 +130,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -130,29 +130,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<select id="selectSalesVolume" resultType="integer"> <select id="selectSalesVolume" resultType="integer">
select count(*) from ( select count(*) from (select
select
DISTINCT o.id DISTINCT o.id
from from
`order` o, `order` o
order_refund or2, join order_detail od on
order_detail od o.id = od.order_id
where
o.id = or2.order_id
and or2.state != '2'
and od.order_id = o.id
<if test="goodsId !=null"> <if test="goodsId !=null">
and od.goods_id =#{goodsId} and od.goods_id =#{goodsId}
</if> </if>
<if test="shopId !=null"> <if test="shopId !=null">
and o.shop_id=#{shopId} and o.shop_id=#{shopId}
</if> </if>
) a and o.state not in ('1', '8', '9', '10', '11')) a
</select> </select>
<select id="selectSalesAmount" resultType="java.math.BigDecimal"> <select id="selectSalesAmount" resultType="java.math.BigDecimal">
select SUM(o.amount) from `order` o select SUM(o.amount) from `order` o
where shop_id =#{shopId} where shop_id =#{shopId}
and state not in () and state not in ('1','8','9','10','11')
</select> </select>
<select id="selectByUserId" resultMap="OrderResult"> <select id="selectByUserId" resultMap="OrderResult">
<include refid="selectOrderVo"/> <include refid="selectOrderVo"/>
......
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