Commit 3f6f5969 by 张新旗

什么时候是个头,是个头

parent c6311946
package com.soss.web.controller.coffee; package com.soss.web.controller.coffee;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.common.core.controller.BaseController; import com.soss.common.core.controller.BaseController;
import com.soss.common.core.domain.AjaxResult; import com.soss.common.core.domain.AjaxResult;
...@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -55,7 +57,17 @@ public class AppController extends BaseController { ...@@ -55,7 +57,17 @@ public class AppController extends BaseController {
return AjaxResult.success("操作成功",info); return AjaxResult.success("操作成功",info);
} }
@RequestMapping("/getWaitTine") @RequestMapping("/getWaitTine")
public AjaxResult getWaitTime(@RequestBody Order order){ public AjaxResult getWaitTime(@RequestBody String body){
JSONObject jsonObject = JSONObject.parseObject(body);
Order order = new Order();
order.setShopId(jsonObject.getString("shopId"));
JSONArray goods = jsonObject.getJSONArray("goods");
List<OrderDetail> orderDetails = new ArrayList<>();
for(int i =0;i<goods.size();i++){
OrderDetail orderDetail = new OrderDetail();
orderDetail.setGoodsId(goods.getJSONObject(i).getString("goodsId"));
orderDetails.add(orderDetail);
}
String info = orderService.getWaitTime(order); String info = orderService.getWaitTime(order);
return AjaxResult.success("操作成功",info); return AjaxResult.success("操作成功",info);
} }
......
...@@ -5,11 +5,9 @@ import com.soss.common.core.domain.AjaxResult; ...@@ -5,11 +5,9 @@ import com.soss.common.core.domain.AjaxResult;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
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.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.service.impl.MachineServiceImpl; import com.soss.system.service.impl.*;
import com.soss.system.service.impl.OrderServiceImpl;
import com.soss.system.service.impl.OrderTakingServiceImpl;
import com.soss.system.service.impl.ShopServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -43,8 +41,17 @@ public class ApplicationController { ...@@ -43,8 +41,17 @@ public class ApplicationController {
return AjaxResult.success("处理成功",key); return AjaxResult.success("处理成功",key);
} }
@RequestMapping("/getData") @RequestMapping("/getData")
public AjaxResult getApplicationData(String key){ public AjaxResult getApplicationData(String body){
JSONObject jj = JSONObject.parseObject(body);
String key = jj.getString("key");
JSONObject location = jj.getJSONObject("location");
String s = stringRedisTemplate.opsForValue().get(key); String s = stringRedisTemplate.opsForValue().get(key);
JSONObject info = JSONObject.parseObject(s);
String machineCode = info.getString("machineCode");
Machine machine = machineService.selectMachineByCode(machineCode);
Shop shop = shopService.selectShopById(String.valueOf(machine.getShopId()));
shop.setDistance(AppServiceImpl.GetDistance(Double.parseDouble(shop.getLng()),Double.parseDouble(shop.getLat()),Double.parseDouble(location.getString("lng")),Double.parseDouble(location.getString("lat"))));
info.put("shop",shop);
String[] keys = key.split("_"); String[] keys = key.split("_");
//推送数据给安卓 //推送数据给安卓
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -55,7 +62,7 @@ public class ApplicationController { ...@@ -55,7 +62,7 @@ public class ApplicationController {
jsonObject.put("data",data); jsonObject.put("data",data);
jiGuangPushService.push(keys[0],jsonObject); jiGuangPushService.push(keys[0],jsonObject);
// stringRedisTemplate.delete(key); // stringRedisTemplate.delete(key);
return AjaxResult.success("处理成功",s); return AjaxResult.success("处理成功",info.toJSONString());
} }
@RequestMapping("/jgRegister") @RequestMapping("/jgRegister")
public AjaxResult jgRegister(@RequestParam String machineCode,@RequestParam String registerId){ public AjaxResult jgRegister(@RequestParam String machineCode,@RequestParam String registerId){
......
...@@ -93,7 +93,6 @@ public class WechatMessageController extends BaseController ...@@ -93,7 +93,6 @@ public class WechatMessageController extends BaseController
/** /**
* 修改小程序信息发送 * 修改小程序信息发送
*/ */
@PreAuthorize("@ss.hasPermi('system:message:edit')")
@Log(title = "小程序信息发送", businessType = BusinessType.UPDATE) @Log(title = "小程序信息发送", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody WechatMessage wechatMessage) public AjaxResult edit(@RequestBody WechatMessage wechatMessage)
......
...@@ -82,8 +82,8 @@ public class WeixinController { ...@@ -82,8 +82,8 @@ public class WeixinController {
} }
@RequestMapping("/getShop") @RequestMapping("/getShop")
public AjaxResult getShop(@RequestParam(required = false) String lng,@RequestParam(required = false)String lat){ public AjaxResult getShop(){
return AjaxResult.success(appService.getShop(lng,lat)); return AjaxResult.success(appService.getShop());
} }
@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){
......
...@@ -127,7 +127,10 @@ public class SysRoleController extends BaseController ...@@ -127,7 +127,10 @@ public class SysRoleController extends BaseController
} }
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员"); return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
} }
@GetMapping("/status")
public AjaxResult status(SysRole role){
return AjaxResult.success(roleService.updateRole(role));
}
/** /**
* 修改保存数据权限 * 修改保存数据权限
*/ */
......
...@@ -32,6 +32,7 @@ import com.soss.system.mapper.OrderMapper; ...@@ -32,6 +32,7 @@ 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.mapper.ShopMapper;
import com.soss.system.service.IWechatMessageService; import com.soss.system.service.IWechatMessageService;
import com.soss.system.service.impl.AppServiceImpl;
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;
...@@ -573,9 +574,8 @@ public class WeixinServiceImpl { ...@@ -573,9 +574,8 @@ public class WeixinServiceImpl {
List<JSONObject> proviceList = new ArrayList<>(); List<JSONObject> proviceList = new ArrayList<>();
List<String> proString = new ArrayList<>(); List<String> proString = new ArrayList<>();
for (Shop shop1 : shops) { for (Shop shop1 : shops) {
double v = GetDistance(Double.parseDouble(lng), Double.parseDouble(lat), Double.parseDouble(shop1.getLng()), Double.parseDouble(shop1.getLat())); String aa = AppServiceImpl.GetDistance(Double.parseDouble(lng), Double.parseDouble(lat), Double.parseDouble(shop1.getLng()), Double.parseDouble(shop1.getLat()));
DecimalFormat df = new DecimalFormat("0.00"); shop1.setDistance(aa);
shop1.setDistance(df.format(v));
String province = shop1.getProvince(); String province = shop1.getProvince();
if(proString.contains(province)){ if(proString.contains(province)){
for (JSONObject provinceObject : proviceList) { for (JSONObject provinceObject : proviceList) {
...@@ -650,32 +650,7 @@ public class WeixinServiceImpl { ...@@ -650,32 +650,7 @@ public class WeixinServiceImpl {
return proviceList; 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;
}
public String refresh(String phoneNumber) { public String refresh(String phoneNumber) {
Customer customer = new Customer(); Customer customer = new Customer();
...@@ -683,6 +658,7 @@ public class WeixinServiceImpl { ...@@ -683,6 +658,7 @@ public class WeixinServiceImpl {
List<Customer> customers = customerMapper.selectCustomerList(customer); List<Customer> customers = customerMapper.selectCustomerList(customer);
if(customers!=null &&!customers.isEmpty()){ if(customers!=null &&!customers.isEmpty()){
Customer customer1 = customers.get(0); Customer customer1 = customers.get(0);
log.info("当前登录的用户为:【{}】",customer1.getUserName());
return tokenService.createToken(transLoginUser(customer1)); return tokenService.createToken(transLoginUser(customer1));
} }
......
...@@ -55,6 +55,38 @@ public class OrderQuery extends BaseEntity { ...@@ -55,6 +55,38 @@ public class OrderQuery extends BaseEntity {
//用户昵称 //用户昵称
private String userName; private String userName;
public String getCreateAtStart() {
return createAtStart;
}
public void setCreateAtStart(String createAtStart) {
this.createAtStart = createAtStart;
}
public String getCreateAtEnd() {
return createAtEnd;
}
public void setCreateAtEnd(String createAtEnd) {
this.createAtEnd = createAtEnd;
}
public String getPayAtStart() {
return payAtStart;
}
public void setPayAtStart(String payAtStart) {
this.payAtStart = payAtStart;
}
public String getPayAtEnd() {
return payAtEnd;
}
public void setPayAtEnd(String payAtEnd) {
this.payAtEnd = payAtEnd;
}
private Long shopId; private Long shopId;
private String createAtStart; private String createAtStart;
......
...@@ -72,6 +72,8 @@ public interface OrderMapper ...@@ -72,6 +72,8 @@ public interface OrderMapper
List<Order> selectOrder(@Param("status") List<String> status,@Param("machineId") String machineCode); List<Order> selectOrder(@Param("status") List<String> status,@Param("machineId") String machineCode);
List<Order> selectOrderByShopId(@Param("status") List<String> status,@Param("shopId") String shopId);
Order selectHomeByUserId(@Param("userId") String openId,@Param("status") List<String> status); Order selectHomeByUserId(@Param("userId") String openId,@Param("status") List<String> status);
void updateTimeOut(@Param("status") String productionCompleted,@Param("timeout") String timeout); void updateTimeOut(@Param("status") String productionCompleted,@Param("timeout") String timeout);
......
...@@ -58,4 +58,6 @@ public interface ShopMapper ...@@ -58,4 +58,6 @@ public interface ShopMapper
* @return 结果 * @return 结果
*/ */
public int deleteShopByIds(String[] ids); public int deleteShopByIds(String[] ids);
void updateNoDefault();
} }
...@@ -14,7 +14,7 @@ import java.util.stream.Collectors; ...@@ -14,7 +14,7 @@ import java.util.stream.Collectors;
public class AppServiceImpl { public class AppServiceImpl {
@Autowired @Autowired
private ShopMapper shopMapper; private ShopMapper shopMapper;
public Shop getShop(String lng,String lat) { public Shop getShop() {
Shop shop = new Shop(); Shop shop = new Shop();
shop.setState("1"); shop.setState("1");
...@@ -22,9 +22,6 @@ public class AppServiceImpl { ...@@ -22,9 +22,6 @@ public class AppServiceImpl {
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);
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));
return shop1; return shop1;
}else{ }else{
return new Shop(); return new Shop();
...@@ -43,7 +40,7 @@ public class AppServiceImpl { ...@@ -43,7 +40,7 @@ public class AppServiceImpl {
* @param lat2 * @param lat2
* @return * @return
*/ */
public static double GetDistance(double lng1, double lat1, double lng2, double lat2) public static String GetDistance(double lng1, double lat1, double lng2, double lat2)
{ {
double radLat1 = rad(lat1); double radLat1 = rad(lat1);
double radLat2 = rad(lat2); double radLat2 = rad(lat2);
...@@ -53,7 +50,21 @@ public class AppServiceImpl { ...@@ -53,7 +50,21 @@ public class AppServiceImpl {
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2))); Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s * EARTH_RADIUS; s = s * EARTH_RADIUS;
s = Math.round(s * 10000) / 10000; s = Math.round(s * 10000) / 10000;
return s; String distance = null;
if(s>1000&&s<10000){
DecimalFormat df = new DecimalFormat("######0.0");
distance = df.format(s/1000);
return distance+"公里";
}else if (s>=10000){
Double aDouble = s/10000;
return aDouble.intValue()+"公里";
}else{
Double aDouble =s;
return aDouble.intValue()+"公里";
}
} }
private static double rad(double d) private static double rad(double d)
......
...@@ -352,9 +352,9 @@ public class OrderServiceImpl implements IOrderService ...@@ -352,9 +352,9 @@ public class OrderServiceImpl implements IOrderService
} }
public String getWaitTime(Order order) { public String getWaitTime(Order order) {
String machineId = order.getMachineId(); String shopId = order.getShopId();
List<String> status = Arrays.asList("2","3"); List<String> status = Arrays.asList("2","3");
List<Order> orders = orderMapper.selectOrder(status, machineId); List<Order> orders = orderMapper.selectOrderByShopId(status, shopId);
List<OrderDetail> list = new ArrayList<>(); List<OrderDetail> list = new ArrayList<>();
list.addAll(order.getOrderDetails()); list.addAll(order.getOrderDetails());
for (Order order1 : orders) { for (Order order1 : orders) {
......
...@@ -109,6 +109,9 @@ public class ShopServiceImpl implements IShopService ...@@ -109,6 +109,9 @@ public class ShopServiceImpl implements IShopService
public int updateShop(Shop shop) public int updateShop(Shop shop)
{ {
shop.setUpdatedAt(new Date()); shop.setUpdatedAt(new Date());
if(1 == shop.getIsDefault()){
shopMapper.updateNoDefault();
}
return shopMapper.updateShop(shop); return shopMapper.updateShop(shop);
} }
......
...@@ -85,8 +85,11 @@ public class WechatMessageServiceImpl implements IWechatMessageService ...@@ -85,8 +85,11 @@ public class WechatMessageServiceImpl implements IWechatMessageService
@Override @Override
public int updateWechatMessage(WechatMessage wechatMessage) public int updateWechatMessage(WechatMessage wechatMessage)
{ {
wechatMessage.setUpdatedAt(new Date()); WechatMessage update = new WechatMessage();
return wechatMessageMapper.updateWechatMessage(wechatMessage); update.setId( wechatMessage.getId());
update.setUpdatedAt(new Date());
update.setState("2");
return wechatMessageMapper.updateWechatMessage(update);
} }
/** /**
......
...@@ -181,18 +181,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -181,18 +181,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
<if test="createAtStart!=null "> <if test="createAtStart!=null ">
<![CDATA[ and create_at >= to_date(#{createAtStart,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]> <![CDATA[ and created_at >= #{createAtStart}]]>
</if> </if>
<if test="createAtEnd!=null "> <if test="createAtEnd!=null ">
<![CDATA[ and create_at <= to_date(#{createAtEnd,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]> <![CDATA[ and created_at <= #{createAtEnd}]]>
</if> </if>
<if test="payAtStart!=null "> <if test="payAtStart!=null ">
<![CDATA[ and pay_time >= to_date(#{payAtStart,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]> <![CDATA[ and pay_time >= #{payAtStarts}]]>
</if> </if>
<if test="payAtEnd!=null "> <if test="payAtEnd!=null ">
<![CDATA[ and pay_time <= to_date(#{payAtEnd,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]> <![CDATA[ and pay_time <= #{payAtEnd}]]>
</if> </if>
</where> </where>
order by created_at desc order by created_at desc
...@@ -235,4 +235,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -235,4 +235,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
order by created_at desc order by created_at desc
</select> </select>
<select id="selectOrderByShopId" resultMap="OrderResult">
<include refid="selectOrderVo"/>
<where>
state in
<foreach item="item" index="index" collection="status"
open="(" separator="," close=")">
#{item}
</foreach>
and shop_id = #{shopId}
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -123,4 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -123,4 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<update id="updateNoDefault">
update shop set is_default = 0
</update>
</mapper> </mapper>
\ No newline at end of file
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
left join sys_user_role ur on rm.role_id = ur.role_id left join sys_user_role ur on rm.role_id = ur.role_id
left join sys_role ro on ur.role_id = ro.role_id left join sys_role ro on ur.role_id = ro.role_id
left join sys_user u on ur.user_id = u.user_id left join sys_user u on ur.user_id = u.user_id
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0 where u.user_id = #{userId} and m.menu_type in ('M', 'C','F') and m.status = 0 AND ro.status = 0
order by m.parent_id, m.order_num order by m.parent_id, m.order_num
</select> </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