Commit 2608aa50 by 张新旗

代码提交

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