Commit d3d00a1c by 张新旗

代码什么时候是个头

parent 9d685b0e
......@@ -63,10 +63,13 @@ public class AppController extends BaseController {
order.setShopId(jsonObject.getString("shopId"));
JSONArray goods = jsonObject.getJSONArray("goods");
List<OrderDetail> orderDetails = new ArrayList<>();
order.setOrderDetails(orderDetails);
for(int i =0;i<goods.size();i++){
OrderDetail orderDetail = new OrderDetail();
orderDetail.setGoodsId(goods.getJSONObject(i).getString("goodsId"));
orderDetail.setNum(goods.getJSONObject(i).getString("num"));
orderDetails.add(orderDetail);
}
String info = orderService.getWaitTime(order);
return AjaxResult.success("操作成功",info);
......@@ -77,7 +80,10 @@ public class AppController extends BaseController {
@RequestMapping("/refundOrder")
public AjaxResult refundOrder(String orderId){
return AjaxResult.success(orderService.refundOrder(orderId));
}
@RequestMapping("/getNextOrder")
public AjaxResult getNextOrder(String orderId,String shopId){
return AjaxResult.success(orderService.getNextOrder(orderId,shopId));
}
}
......@@ -21,17 +21,17 @@ import java.util.concurrent.TimeUnit;
@RequestMapping("/application")
public class ApplicationController {
@Autowired
private StringRedisTemplate stringRedisTemplate;
StringRedisTemplate stringRedisTemplate;
@Autowired
private MachineServiceImpl machineService;
MachineServiceImpl machineService;
@Autowired
JiGuangPushServiceImpl jiGuangPushService;
@Autowired
private OrderTakingServiceImpl orderTakingService;
OrderTakingServiceImpl orderTakingService;
@Autowired
private ShopServiceImpl shopService;
ShopServiceImpl shopService;
@Autowired
private OrderServiceImpl orderService;
OrderServiceImpl orderService;
@RequestMapping("/saveData")
public AjaxResult saveApplicationData(@RequestParam("machineCode")String machineCode, @RequestBody String body){
String id = UUID.randomUUID().toString();
......
......@@ -7,6 +7,7 @@ import com.soss.common.core.domain.model.LoginUser;
import com.soss.common.core.page.TableDataInfo;
import com.soss.common.enums.BusinessType;
import com.soss.common.utils.poi.ExcelUtil;
import com.soss.common.utils.spring.SpringUtils;
import com.soss.framework.web.service.TokenService;
import com.soss.system.domain.Customer;
import com.soss.system.domain.Order;
......@@ -36,6 +37,14 @@ public class CustomerController extends BaseController
@Autowired
private TokenService tokenService;
@GetMapping("/allow")
private 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));
}
/**
* 查询用户信息列表
*/
......@@ -61,11 +70,7 @@ public class CustomerController extends BaseController
List<Order> orders = customerService.selectCustomerById(id,status);
return getDataTable(orders);
}
@GetMapping("/allow")
private AjaxResult allow(HttpServletRequest request,String allow){
LoginUser loginUser = tokenService.getLoginUser(request);
return AjaxResult.success(customerService.allow(loginUser.getOpenId(),allow));
}
}
......@@ -10,6 +10,7 @@ import com.soss.common.exception.ServiceException;
import com.soss.framework.web.service.TokenService;
import com.soss.framework.web.service.WeixinServiceImpl;
import com.soss.system.domain.vo.OrderQuery;
import com.soss.system.service.impl.CustomerServiceImpl;
import com.soss.system.service.impl.OrderServiceImpl;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -131,7 +132,4 @@ public class OrderController extends BaseController
return toAjax(orderService.cancel(orderId));
}
}
......@@ -5,7 +5,9 @@ import java.util.List;
import com.soss.common.core.domain.model.LoginUser;
import com.soss.framework.web.service.TokenService;
import com.soss.framework.web.service.WeixinServiceImpl;
import com.soss.system.domain.Order;
import com.soss.system.domain.vo.OrderQuery;
import com.soss.system.service.impl.OrderServiceImpl;
import org.checkerframework.checker.units.qual.A;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -41,6 +43,8 @@ public class OrderRefundController extends BaseController
private WeixinServiceImpl weixinService;
@Autowired
private TokenService tokenService;
@Autowired
private OrderServiceImpl orderService;
/**
* 查询订单退款列表
......@@ -91,12 +95,11 @@ public class OrderRefundController extends BaseController
return ajaxResult;
}
@PostMapping("/refund")
public AjaxResult refund(@RequestBody OrderRefund orderRefund){
int totalFee = orderRefund.getTotalFee().movePointRight(2).intValue();
int refundAmount = orderRefund.getRefundAmount().movePointRight(2).intValue();
orderRefund.setState("1");
weixinService.refund(orderRefund.getRefundNo(),orderRefund.getOrderNo(),1,1);
return AjaxResult.success( orderRefundService.updateOrderRefund(orderRefund));
public void refund(){
Order order = orderService.selectOrderById("98");
int totalFee = order.getAmount().movePointRight(2).intValue();
weixinService.refund(order.getOrderNo(),order.getOrderNo()+"1",totalFee,totalFee);
}
......
......@@ -127,10 +127,6 @@ public class SysRoleController extends BaseController
}
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
}
@GetMapping("/status")
public AjaxResult status(SysRole role){
return AjaxResult.success(roleService.updateRole(role));
}
/**
* 修改保存数据权限
*/
......
package com.soss.system.aspect;
import com.alibaba.fastjson.JSON;
import com.soss.common.utils.StringUtils;
import com.soss.common.utils.uuid.IdUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Field;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
@Slf4j
public class LoggerAspect {
// 定义切点Pointcut
@Pointcut("execution(* com.soss.web.controller..*.*(..))")
public void executeService() {
}
@Around("executeService()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
HttpServletRequest request = sra.getRequest();
String url = request.getRequestURL().toString();
String method = request.getMethod();
String queryString = request.getQueryString();
Object[] args = pjp.getArgs();
String params = "";
//获取请求参数集合并进行遍历拼接
if (args.length > 0) {
if ("POST".equals(method)||"PUT".equals(method)) {
for (Object arg : args) {
if(arg instanceof HttpServletRequest || arg instanceof HttpServletResponse){
continue;
}
if(url.indexOf("/weixin")== -1){
Map map = getKeyAndValue(arg);
params = JSON.toJSONString(map);
}
}
} else if ("GET".equals(method)||"DELETE".equals(method)) {
if(StringUtils.isNotEmpty(queryString)){
params = URLDecoder.decode(queryString, "UTF-8");
}
}
}
String s = IdUtils.randomUUID();
log.info("请求开始 标识id:【{}】===地址【{}】,【{}】,【{}】:" ,s,url,method,params);
// result的值就是被拦截方法的返回值
Object result = pjp.proceed();
log.info("请求结束 标识id:【{}】 ===返回值:【{}】" ,s,JSON.toJSON(result));
return result;
}
public static Map<String, Object> getKeyAndValue(Object obj) {
Map<String, Object> map = new HashMap<>();
// 得到类对象
Class userCla = obj.getClass();
/* 得到类中的所有属性集合 */
Field[] fs = userCla.getDeclaredFields();
for (Field f : fs) {
f.setAccessible(true); // 设置些属性是可以访问的
Object val;
try {
val = f.get(obj);
// 得到此属性的值
map.put(f.getName(), val);// 设置键值
} catch (IllegalArgumentException | IllegalAccessException e) {
log.error("打印请求发生异常:",e);
}
}
return map;
}
}
......@@ -68,7 +68,9 @@ public class GoodsCategoryServiceImpl implements IGoodsCategoryService
goodsCategory.setCreatedAt(new Date());
goodsCategory.setUpdatedAt(new Date());
goodsCategory.setIsDeleted("0");
return goodsCategoryMapper.insertGoodsCategory(goodsCategory);
goodsCategoryMapper.insertGoodsCategory(goodsCategory);
goodsCategory.setTurn(goodsCategory.getId());
return goodsCategoryMapper.updateGoodsCategory(goodsCategory);
}
/**
......
......@@ -175,6 +175,7 @@ public class OrderOperationLogServiceImpl implements IOrderOperationLogService
operationLog.setOperationUser(orderRefund.getCreateUserName());
operationLog.setContent(orderRefund.getDesc());
}
orderOperationLogMapper.insertOrderOperationLog(operationLog);
}
......
......@@ -16,6 +16,10 @@ import com.soss.common.utils.StringUtils;
import com.soss.common.utils.spring.SpringUtils;
import com.soss.system.constants.OrderStatusConstant;
import com.soss.system.domain.*;
import com.soss.system.domain.vo.orderTaking.CategoryVo;
import com.soss.system.domain.vo.orderTaking.GoodsVo;
import com.soss.system.domain.vo.orderTaking.OrderTakingVo;
import com.soss.system.domain.vo.orderTaking.SkuVo;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.service.IOrderService;
import com.soss.system.domain.vo.OrderQuery;
......@@ -63,6 +67,8 @@ public class OrderServiceImpl implements IOrderService
private WechatMessageServiceImpl wechatMessageService;
@Autowired
private SendMessageUtils sendMessageUtils;
@Autowired
private OrderTakingServiceImpl orderTakingService;
......@@ -510,7 +516,7 @@ public class OrderServiceImpl implements IOrderService
public String getWaitTime(Order order) {
String shopId = order.getShopId();
List<String> status = Arrays.asList("2","3");
List<String> status = Arrays.asList(OrderStatusConstant.Paid,OrderStatusConstant.production);
List<Order> orders = orderMapper.selectOrderByShopId(status, shopId);
List<OrderDetail> list = new ArrayList<>();
list.addAll(order.getOrderDetails());
......@@ -527,10 +533,52 @@ public class OrderServiceImpl implements IOrderService
Long takeTimeCount =0L;
for (OrderDetail orderDetail : list) {
Long takeTime = goodsMapper.selectGoodsById(orderDetail.getGoodsId()).getTakeTime();
takeTime = Integer.parseInt(orderDetail.getNum())*takeTime;
takeTimeCount+=takeTime;
}
return String.valueOf((int)(takeTimeCount/60));
}
public List<GoodsVo> getNextOrder(String orderId,String shopId) {
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderId(Long.parseLong(orderId));
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
List<String> skuIds = orderDetails.stream().map(OrderDetail::getSkuId).collect(Collectors.toList());
OrderTakingVo infoByShop = orderTakingService.getInfoByShop(shopId);
List<CategoryVo> categorys = infoByShop.getCategorys();
List<GoodsVo> ccs = new ArrayList<>();
if(categorys !=null && !categorys.isEmpty()){
for (CategoryVo category : categorys) {
if(category.getId()==0 ){
continue;
}
List<GoodsVo> goods = category.getGoods();
if(goods==null ||goods.isEmpty()){
continue;
}
for (GoodsVo good : goods) {
List<SkuVo> skuVoList = new ArrayList<>();
if(good.getSkus()==null ||good.getSkus().isEmpty()){
continue;
}
for (SkuVo skus : good.getSkus()) {
if(skuIds.contains(skus.getSkuId())){
skuVoList.add(skus);
}
}
if(!skuVoList.isEmpty()){
ccs.add(good);
good.setSkus(skuVoList);
}
}
}
}
return ccs;
}
}
......@@ -88,7 +88,7 @@ public class WechatMessageServiceImpl implements IWechatMessageService
WechatMessage update = new WechatMessage();
update.setId( wechatMessage.getId());
update.setUpdatedAt(new Date());
update.setState("2");
update.setIsRead("2");
return wechatMessageMapper.updateWechatMessage(update);
}
......
......@@ -150,10 +150,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) a
</select>
<select id="selectSalesAmount" resultType="java.math.BigDecimal">
select SUM(o.amount) from `order` o,order_refund or2
where o.id = or2.order_id
and or2.state !='2'
and shop_id =#{shopId}
select SUM(o.amount) from `order` o
where shop_id =#{shopId}
and state not in ()
</select>
<select id="selectByUserId" resultMap="OrderResult">
<include refid="selectOrderVo"/>
......@@ -177,7 +176,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and shop_id =#{shopId}
</if>
<if test="state!=null ">
and shop_id =#{shopId}
and state =#{state}
</if>
<if test="createAtStart!=null ">
......@@ -188,7 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<if test="payAtStart!=null ">
<![CDATA[ and pay_time >= #{payAtStarts}]]>
<![CDATA[ and pay_time >= #{payAtStart}]]>
</if>
<if test="payAtEnd!=null ">
......
......@@ -92,38 +92,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectList" resultMap="OrderRefundResult">
select or2.* from `order` o ,order_refund or2 where o.id =or2.order_id
<where>
<if test="orderNo!=null ">
and order_no =#{orderNo}
and o.order_no =#{orderNo}
</if>
<if test="orderNum!=null ">
and order_num =#{orderNum}
and o.order_num =#{orderNum}
</if>
<if test="userName!=null">
and user_name like concat('%', #{userName}, '%')
and o.user_name like concat('%', #{userName}, '%')
</if>
<if test="shopId!=null ">
and shop_id =#{shopId}
and o.shop_id =#{shopId}
</if>
<if test="state!=null ">
and shop_id =#{shopId}
and o.state =#{state}
</if>
<if test="createAtStart!=null ">
<![CDATA[ and create_at >= to_date(#{createAtStart,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]>
<![CDATA[ and o.created_at >= #{createAtStart}]]>
</if>
<if test="createAtEnd!=null ">
<![CDATA[ and create_at <= to_date(#{createAtEnd,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]>
<![CDATA[ and o.created_at <= #{createAtEnd}]]>
</if>
<if test="payAtStart!=null ">
<![CDATA[ and pay_time >= to_date(#{payAtStart,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]>
<![CDATA[ and o.pay_time >= #{payAtStart}]]>
</if>
<if test="payAtEnd!=null ">
<![CDATA[ and pay_time <= to_date(#{payAtEnd,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]>
<![CDATA[ and o.pay_time <= #{payAtEnd}]]>
</if>
</where>
order by or2.created_at desc
</select>
</mapper>
\ No newline at end of file
......@@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by r.role_sort
order by r.create_time desc
</select>
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
......@@ -138,11 +138,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteRoleById" parameterType="Long">
update sys_role set del_flag = '2' where role_id = #{roleId}
delete from sys_role where role_id = #{roleId}
</delete>
<delete id="deleteRoleByIds" parameterType="Long">
update sys_role set del_flag = '2' where role_id in
delete from sys_role where role_id in
<foreach collection="array" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>
......
......@@ -139,9 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select user_id, email from sys_user where email = #{email} limit 1
</select>
<select id="selectUserByUserInfo" resultType="com.soss.common.core.domain.entity.SysUser">
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u
select DISTINCT u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark from sys_user u
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
where u.del_flag='0'
......@@ -219,11 +217,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteUserById" parameterType="Long">
update sys_user set del_flag = '2' where user_id = #{userId}
delete from sys_user where user_id = #{userId}
</delete>
<delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in
delete from sys_user where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
......
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