Commit 0a2b2609 by 张新旗

代码永远在路上

parent ef275933
......@@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
/**
......@@ -12,6 +13,7 @@ import org.springframework.web.client.RestTemplate;
* @author zxq
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@EnableScheduling //扫描定时器
public class RuoYiApplication
{
public static void main(String[] args)
......
package com.soss.web.controller.coffee;
import com.alibaba.fastjson.JSONObject;
import com.soss.common.core.controller.BaseController;
import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.domain.model.LoginUser;
......@@ -7,14 +8,17 @@ import com.soss.common.core.page.TableDataInfo;
import com.soss.common.exception.ServiceException;
import com.soss.framework.web.service.TokenService;
import com.soss.system.domain.Order;
import com.soss.system.domain.OrderDetail;
import com.soss.system.service.impl.AppServiceImpl;
import com.soss.system.service.impl.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/app")
......@@ -39,6 +43,25 @@ public class AppController extends BaseController {
List<Order> myOrder = orderService.getMyOrder(openId);
return getDataTable(myOrder);
}
@RequestMapping("/getHomeOrder")
public AjaxResult getHomeOrder(HttpServletRequest request){
LoginUser loginUser = tokenService.getLoginUser(request);
if(loginUser ==null){
return AjaxResult.success();
}
String openId = loginUser.getOpenId();
Map<String,String> info = orderService.getMyFristOrder(openId);
return AjaxResult.success("操作成功",info);
}
@RequestMapping("/getWaitTine")
public AjaxResult getWaitTime(@RequestBody Order order){
String info = orderService.getWaitTime(order);
return AjaxResult.success("操作成功",info);
}
@RequestMapping("/refundOrder")
public AjaxResult refundOrder(String orderId){
return AjaxResult.success(orderService.refundOrder(orderId));
......
......@@ -37,7 +37,7 @@ public class ApplicationController {
@RequestMapping("/saveData")
public AjaxResult saveApplicationData(@RequestParam("machineCode")String machineCode, @RequestBody String body){
String id = UUID.randomUUID().toString();
String key = machineCode+"_"+id;
String key = machineCode;//+"_"+id;
stringRedisTemplate.opsForValue().set(key, body);
stringRedisTemplate.expire(id,1, TimeUnit.HOURS);
return AjaxResult.success("处理成功",key);
......
......@@ -57,6 +57,9 @@ public class OrderController extends BaseController
}
/**
* 获取订单详细信息
*/
......@@ -88,14 +91,25 @@ public class OrderController extends BaseController
return ajaxResult;
}
int amount = order.getAmount().movePointRight(2).intValue();
Map payInfo = weixinService.pay(request, "hooloo", order.getOrderNo(), order.getUserId(), 1);
Map payInfo = weixinService.pay(request, "hooloo", order.getOrderNo(), order.getUserId(), amount);
if(payInfo !=null){
return AjaxResult.success(payInfo);
}else{
throw new ServiceException("微信支付发生异常");
}
}
@RequestMapping("/payOrder")
public AjaxResult cancel(HttpServletRequest request, String orderId)
{
Order order = orderService.selectOrderById(orderId);
int amount = order.getAmount().movePointRight(2).intValue();
Map payInfo = weixinService.pay(request, "hooloo", order.getOrderNo(), order.getUserId(), amount);
if(payInfo !=null){
return AjaxResult.success(payInfo);
}else{
throw new ServiceException("微信支付发生异常");
}
}
/**
......
......@@ -2,7 +2,11 @@ package com.soss.web.controller.coffee;
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.vo.OrderQuery;
import org.checkerframework.checker.units.qual.A;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -19,6 +23,8 @@ import com.soss.system.domain.OrderRefund;
import com.soss.system.service.IOrderRefundService;
import com.soss.common.core.page.TableDataInfo;
import javax.servlet.http.HttpServletRequest;
/**
* 订单退款Controller
*
......@@ -33,16 +39,18 @@ public class OrderRefundController extends BaseController
private IOrderRefundService orderRefundService;
@Autowired
private WeixinServiceImpl weixinService;
@Autowired
private TokenService tokenService;
/**
* 查询订单退款列表
*/
@PreAuthorize("@ss.hasPermi('system:refund:list')")
@GetMapping("/list")
public TableDataInfo list(OrderRefund orderRefund)
public TableDataInfo list(OrderQuery orderQuery)
{
startPage();
List<OrderRefund> list = orderRefundService.selectOrderRefundList(orderRefund);
List<OrderRefund> list = orderRefundService.selectOrderRefundList(orderQuery);
return getDataTable(list);
}
......@@ -61,16 +69,19 @@ public class OrderRefundController extends BaseController
*/
@Log(title = "订单退款", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody OrderRefund orderRefund)
public AjaxResult add(HttpServletRequest request, @RequestBody OrderRefund orderRefund)
{
LoginUser loginUser = tokenService.getLoginUser(request);
orderRefund.setCreateUserName(loginUser.getUsername());
AjaxResult ajaxResult = orderRefundService.insertOrderRefund(orderRefund);
Object obejct = ajaxResult.get(AjaxResult.DATA_TAG);
if(obejct!=null && obejct instanceof OrderRefund){
OrderRefund orderRefund1 = (OrderRefund) obejct;
if("0".equals(orderRefund1.getState())){
int totalFee = orderRefund1.getTotalFee().movePointRight(2).intValue();
int refundAmount = orderRefund1.getRefundAmount().movePointRight(2).intValue();
weixinService.refund(orderRefund1.getOrderNo(),orderRefund1.getRefundNo(),1,1);
weixinService.refund(orderRefund1.getOrderNo(),orderRefund1.getRefundNo(),totalFee,refundAmount);
orderRefund1.setState("1");
orderRefundService.updateOrderRefund(orderRefund1);
}
......
......@@ -7,7 +7,9 @@ import com.soss.framework.web.service.WeixinServiceImpl;
import com.soss.system.domain.Order;
import com.soss.system.mapper.OrderMapper;
import com.soss.system.service.impl.AppServiceImpl;
import com.soss.system.service.impl.OrderServiceImpl;
import com.soss.system.service.impl.OrderTakingServiceImpl;
import com.soss.system.weixin.util.SendMessageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -29,6 +31,8 @@ public class WeixinController {
private OrderTakingServiceImpl orderTakingService;
@Autowired
private OrderMapper orderMapper;
@Autowired
private OrderServiceImpl orderService;
//这个就是那个使用传code进来的接口
@PostMapping("/login")
......@@ -42,6 +46,7 @@ public class WeixinController {
Map<String,String> map = weixinService.login(code,encryptedData,iv,source);
ajax.put(Constants.TOKEN, map.get("token"));
ajax.put("phoneNumber", map.get("phoneNumber"));
ajax.put("customerName",map.get("customerName"));
return ajax;
}
@PostMapping("/refreshToken")
......@@ -67,10 +72,12 @@ public class WeixinController {
return weixinService.wxNotify(request);
}
@Autowired
private SendMessageUtils sendMessageUtils;
@RequestMapping("/test")
public Map<String, String> test(HttpServletRequest request) throws Exception{
Order order = orderMapper.selectOrderById("8");
int amount = order.getAmount().movePointRight(2).intValue();
Order order = orderService.selectOrderById("59");
sendMessageUtils.sendWxMsg(order);
return null;
}
......
......@@ -70,12 +70,10 @@ public class SysUserController extends BaseController
AjaxResult ajax = AjaxResult.success();
List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll());
if (StringUtils.isNotNull(userId))
{
SysUser sysUser = userService.selectUserById(userId);
ajax.put(AjaxResult.DATA_TAG, sysUser);
ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
}
return ajax;
......
......@@ -88,6 +88,8 @@ weixin:
query-url: https://api.mch.weixin.qq.com/pay/orderquery
cert-path: classpath:apiclient_cert.p12
refund-url: https://hooloo-api.gdatac.com/weixin/refundNotify
templateId: Fu_CPIXa0cnJ4EDdVKqFQ4T3qTxBqv8vXMU7-sQgerg
pagePath: /cs
#mqtt:
# url: tcp://iot-06z00dhgql5j8bw.mqtt.iothub.aliyuncs.com:1883
# clientId: h5kgirX6kNQ.XQ_000001A|securemode=2,signmethod=hmacsha256,timestamp=1651746531320|
......@@ -109,3 +111,4 @@ machine:
url: http://47.94.241.71:10003
json:
path: D:\workspecs\soss\soss\soss-admin\src\main\resources/province.json
timeout: 10
\ No newline at end of file
......@@ -101,7 +101,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求
.authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage","/weixin/**","/application/**","/v1/**","/tool/**").anonymous()
.antMatchers("/login", "/register", "/captchaImage","/weixin/**","/application/**","/v1/**","/tool/**").permitAll()
.antMatchers(
HttpMethod.GET,
"/",
......
......@@ -23,6 +23,7 @@ import com.soss.common.utils.QRCodeUtil;
import com.soss.common.utils.StringUtils;
import com.soss.common.utils.ip.IpUtils;
import com.soss.common.utils.sign.Base64;
import com.soss.system.constants.OrderStatusConstant;
import com.soss.system.domain.*;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.mapper.CustomerMapper;
......@@ -30,6 +31,7 @@ import com.soss.system.mapper.CustomerMapper;
import com.soss.system.mapper.OrderMapper;
import com.soss.system.mapper.OrderRefundMapper;
import com.soss.system.mapper.ShopMapper;
import com.soss.system.service.IWechatMessageService;
import com.soss.system.service.impl.MachineApiServiceImpl;
import com.soss.system.service.impl.OrderOperationLogServiceImpl;
import com.soss.system.weixin.entity.OrderInfo;
......@@ -37,6 +39,7 @@ import com.soss.system.weixin.entity.OrderInfo;
import com.soss.system.weixin.entity.QueryReturnInfo;
import com.soss.system.weixin.util.RandomStringGenerator;
import com.soss.system.weixin.util.SendMessageUtils;
import com.soss.system.weixin.util.Signature;
import com.thoughtworks.xstream.XStream;
......@@ -122,6 +125,11 @@ public class WeixinServiceImpl {
private String areaData;
@Value("${json.path}")
private String jsonPath;
@Autowired
private IWechatMessageService wechatMessageService;
@Autowired
private SendMessageUtils sendMessageUtils;
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";
......@@ -162,7 +170,7 @@ public class WeixinServiceImpl {
customer = new Customer();
customer.setId(cutomerId);
customer.setHeadSculpturePath(encDataInf.getString("avatarUrl"));
customer.setUserName("小呼噜"+customer.getPhone().substring(customer.getPhone().length()-4));
customer.setUserName("小呼噜"+encDataInf.getString("phoneNumber").substring(encDataInf.getString("phoneNumber").length()-4));
customer.setPhone(encDataInf.getString("phoneNumber"));
customer.setCreateTime(new Date());
if(StringUtils.isNotEmpty(source)){
......@@ -175,6 +183,7 @@ public class WeixinServiceImpl {
Map map = new HashMap();
map.put("token",token);
map.put("phoneNumber",encDataInf.getString("phoneNumber"));
map.put("customerName",customer.getUserName());
return map;
}catch (Exception e){
log.error("微信登录发生异常",e);
......@@ -449,14 +458,14 @@ public class WeixinServiceImpl {
stringRedisTemplate.opsForValue().set(uid, String.valueOf(order.getId()));
stringRedisTemplate.expire(uid,1, TimeUnit.DAYS);
jsonObject.put("secret",uid);
order.setPickCode(jsonObject.toJSONString());
orderMapper.updateOrder(order);
orderOperationLogService.insertOrderOperationLog("已付款",order.getId(),"付款成功",order.getUserName(),"付款");
orderOperationLogService.insertOrderOperationLog(order);
machineApiService.updateOrder(order);
//极光推送
jiGuangPushService.pushOrderState(order);
wechatMessageService.insertWechatMessage(order.getUserId(),"下单成功,您已经下单成功了~");
sendMessageUtils.sendWxMsg(order);
}
} finally {
//要主动释放锁
......@@ -524,15 +533,17 @@ public class WeixinServiceImpl {
orderRefund1.setState("2");
orderRefundMapper.updateOrderRefund(orderRefund1);
OrderOperationLog orderOperationLog = new OrderOperationLog();
orderOperationLog.setOrderId(String.valueOf(orderRefund1.getOrderId()));
order.setState("11");
orderOperationLog.setOrderId(orderRefund1.getOrderId());
order.setState(OrderStatusConstant.refund);
if(orderRefund1.getRefundAmount().compareTo(order.getAmount())<0){
order.setState("12");
order.setState(OrderStatusConstant.PartialRefund);
}
orderRefund1.setOrder(order);
orderMapper.updateOrder(order);
orderOperationLogService.insertOrderOperationLog("已退款", Long.valueOf(orderRefund.getOrderId()),"用户退款成功,已到账","系统","退款");
machineApiService.updateOrder(order);
jiGuangPushService.pushOrderState(order);
orderOperationLogService.insertOrderOperationLog(orderRefund1);
return WxPayNotifyResponse.success("退款成功!");
}
......@@ -667,7 +678,7 @@ public class WeixinServiceImpl {
List<Customer> customers = customerMapper.selectCustomerList(customer);
if(customers!=null &&!customers.isEmpty()){
Customer customer1 = customers.get(0);
return tokenService.createToken(transLoginUser(customer));
return tokenService.createToken(transLoginUser(customer1));
}
throw new ServiceException("该用户没有注册,请先注册");
......
......@@ -86,6 +86,12 @@
<artifactId>weixin-java-pay</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
<version>4.1.0</version>
</dependency>
......
package com.soss.system.config;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@AllArgsConstructor
public class WxConfig {
@Value("${weixin.appid}")
private String appid;
@Value("${weixin.secret}")
private String secret;
public WxConfig(){
}
/**
* 小程序service配置
*/
@Bean
public WxMaService wxMaService() {
WxMaDefaultConfigImpl wxMaConfig = new WxMaDefaultConfigImpl();
wxMaConfig.setAppid(appid);
wxMaConfig.setSecret(secret);
WxMaService wxMaService = new WxMaServiceImpl();
wxMaService.setWxMaConfig(wxMaConfig);
return wxMaService;
}
}
package com.soss.system.constants;
public class OrderStatusConstant {
/**
* 0 创建未校验
* 1 未支付 给机器
* 2 已支付 给机器,安卓
* 3 支付制作中 机器给我们 我们给安卓
* 4 制作完成未取 机器给我们,我们给安卓
* 5 取餐中 机器给我们
* 6 正常完成 机器给我们 我们给安卓
* 7 待取超时 我们定时器生成,我们给机器
* 8 未支付取消 给机器,安卓
* 9 支付后制作前取消 给机器,安卓
* 10 制作中取消 给机器,安卓
* 11 制作完成取消 给机器,安卓
* 12 退款中
* 13 退款失败 给机器,安卓
* 14 部分退款 给机器,安卓
* 15 已退款 给机器,安卓
* 50 其他人工干预状态
*/
public final static String Unpaid="1";
public final static String Paid="2";
public final static String production="3";
public final static String productionCompleted="4";
public final static String Taking="5";
public final static String completed="6";
public final static String timeout="7";
public final static String UnpaidCancel="8";
public final static String PaidCancel="9";
public final static String productionCancel="10";
public final static String productionCompletedCancel="11";
public final static String refunding="12";
public final static String refundFailed="13";
public final static String PartialRefund="14";
public final static String refund="15";
public final static String artificial="50";
}
......@@ -42,6 +42,16 @@ public class OrderRefund extends BaseEntity
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdAt;
private String createUserName;
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
......
......@@ -22,7 +22,7 @@ public class WechatMessage extends BaseEntity
/** 用户ID */
@Excel(name = "用户ID")
private Long userId;
private String userId;
/** 推送ID */
@Excel(name = "推送ID")
......@@ -71,12 +71,12 @@ public class WechatMessage extends BaseEntity
{
return id;
}
public void setUserId(Long userId)
public void setUserId(String userId)
{
this.userId = userId;
}
public Long getUserId()
public String getUserId()
{
return userId;
}
......
......@@ -10,6 +10,79 @@ public class OrderQuery extends BaseEntity {
private String orderNo;
//顺序号
private String orderNum;
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public String getOrderNum() {
return orderNum;
}
public void setOrderNum(String orderNum) {
this.orderNum = orderNum;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Long getShopId() {
return shopId;
}
public void setShopId(Long shopId) {
this.shopId = shopId;
}
public Date getCreateAtStart() {
return createAtStart;
}
public void setCreateAtStart(Date createAtStart) {
this.createAtStart = createAtStart;
}
public Date getCreateAtEnd() {
return createAtEnd;
}
public void setCreateAtEnd(Date createAtEnd) {
this.createAtEnd = createAtEnd;
}
public Date getPayAtStart() {
return payAtStart;
}
public void setPayAtStart(Date payAtStart) {
this.payAtStart = payAtStart;
}
public Date getPayAtEnd() {
return payAtEnd;
}
public void setPayAtEnd(Date payAtEnd) {
this.payAtEnd = payAtEnd;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
//用户昵称
private String userName;
......
......@@ -71,4 +71,8 @@ public interface OrderMapper
List<Order> selectOrderByQuery(OrderQuery order);
List<Order> selectOrder(@Param("status") List<String> status,@Param("machineId") String machineCode);
Order selectHomeByUserId(@Param("userId") String openId,@Param("status") List<String> status);
void updateTimeOut(@Param("status") String productionCompleted,@Param("timeout") String timeout);
}
......@@ -2,6 +2,7 @@ package com.soss.system.mapper;
import java.util.List;
import com.soss.system.domain.OrderRefund;
import com.soss.system.domain.vo.OrderQuery;
/**
* 订单退款Mapper接口
......@@ -58,4 +59,6 @@ public interface OrderRefundMapper
* @return 结果
*/
public int deleteOrderRefundByIds(String[] ids);
List<OrderRefund> selectList(OrderQuery orderQuery);
}
package com.soss.system.schedule;
import com.soss.system.constants.OrderStatusConstant;
import com.soss.system.domain.Order;
import com.soss.system.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class OrderSchedule {
@Autowired
private OrderMapper orderMapper;
@Value("${timeout}")
private String timeout;
@Scheduled(fixedDelay = 60*1000)
private void process() {
orderMapper.updateTimeOut(OrderStatusConstant.productionCompleted,timeout);
}
}
package com.soss.system.service;
import java.util.List;
import com.soss.system.domain.Order;
import com.soss.system.domain.OrderOperationLog;
/**
......@@ -33,7 +35,7 @@ public interface IOrderOperationLogService
* @param 【请填写功能名称】
* @return 结果
*/
int insertOrderOperationLog(String status,Long orderId,String content,String operationUser,String operation);
int insertOrderOperationLog(Order order);
/**
* 修改【请填写功能名称】
......
......@@ -4,6 +4,7 @@ import java.util.List;
import com.soss.common.core.domain.AjaxResult;
import com.soss.system.domain.OrderRefund;
import com.soss.system.domain.vo.OrderQuery;
/**
* 订单退款Service接口
......@@ -62,4 +63,6 @@ public interface IOrderRefundService
public int deleteOrderRefundById(String id);
OrderRefund getOrderRefund(String id);
List<OrderRefund> selectOrderRefundList(OrderQuery orderQuery);
}
......@@ -36,6 +36,14 @@ public interface IWechatMessageService
public int insertWechatMessage(WechatMessage wechatMessage);
/**
* 新增小程序信息发送
*
* @param wechatMessage 小程序信息发送
* @return 结果
*/
public int insertWechatMessage(String openId, String message);
/**
* 修改小程序信息发送
*
* @param wechatMessage 小程序信息发送
......
......@@ -3,12 +3,15 @@ package com.soss.system.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.soss.common.exception.ServiceException;
import com.soss.common.utils.DateUtils;
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;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -49,6 +52,12 @@ public class MachineApiServiceImpl {
private JiGuangPushServiceImpl jiGuangPushService;
@Autowired
private GoodsCategoryMapper goodsCategoryMapper;
@Autowired
private WechatMessageServiceImpl wechatMessageService;
@Autowired
private SendMessageUtils sendMessageUtils;
@Autowired
private OrderOperationLogServiceImpl operationLogService;
public String shopGoodsUpdate(JSONObject jsonObject) {
String shopID = jsonObject.getString("shopId");
......@@ -85,11 +94,19 @@ public class MachineApiServiceImpl {
order.setId(orderID);
order.setState(status);
order.setUpdatedAt(new Date());
if("6".equals(status)){
if(OrderStatusConstant.completed.equals(status)){
order.setFinishTime(new Date());
}
int i = orderMapper.updateOrder(order);
jiGuangPushService.pushOrderState(order);
if(OrderStatusConstant.production.equals(status)){
wechatMessageService.insertWechatMessage(order.getUserId(),"制作提醒,您的订单已经开始制作,马上就能享受美味了!");
}
if(OrderStatusConstant.completed.equals(status)){
wechatMessageService.insertWechatMessage(order.getUserId(),"制作完成,您的订单已经制作完成,现在可以去取餐啦!");
sendMessageUtils.sendWxMsg(order);
}
return i+"";
}
......@@ -218,14 +235,20 @@ public class MachineApiServiceImpl {
}
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());
if("2".equals(order.getState())){
data.put("payTime",DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",order.getPayTime()));
}
param.put("data",data.toJSONString());
param.put("orderId",order.getId());
sendRequest(param.toJSONString(),"/v1/order/update");
ResultVo resultVo = sendRequest(param.toJSONString(), "/v1/order/update");
jiGuangPushService.pushOrderState(order);
operationLogService.insertOrderOperationLog(order,resultVo);
}
public Object checkOrder(JSONObject jsonObject) {
......
......@@ -4,6 +4,10 @@ import java.util.Date;
import java.util.List;
import com.soss.common.utils.StringUtils;
import com.soss.system.constants.OrderStatusConstant;
import com.soss.system.domain.Order;
import com.soss.system.domain.OrderRefund;
import com.soss.system.domain.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.soss.system.mapper.OrderOperationLogMapper;
......@@ -53,20 +57,56 @@ public class OrderOperationLogServiceImpl implements IOrderOperationLogService
* @return 结果
*/
@Override
public int insertOrderOperationLog(String status,Long orderId,String content,String operationUser,String operation)
public int insertOrderOperationLog(Order order)
{
OrderOperationLog operationLog = new OrderOperationLog();
operationLog.setStatus(status);
operationLog.setOrderId(String.valueOf(orderId));
operationLog.setContent(content);
operationLog.setOrderId(String.valueOf(order.getId()));
operationLog.setCreateAt(new Date());
operationLog.setOperationUser(operationUser);
operationLog.setOperation(operation);
if(StringUtils.isEmpty(operationUser)){
operationLog.setOperationUser("接口");
}
if(StringUtils.isEmpty(operation)){
operationLog.setOperation("同步信息");
String state = order.getState();
switch (state){
case OrderStatusConstant.Unpaid:
operationLog.setStatus("待付款");
operationLog.setOperation("创建订单");
operationLog.setOperationUser(order.getUserName());
operationLog.setContent("创建了订单");
break;
case OrderStatusConstant.UnpaidCancel:
operationLog.setStatus("已取消");
operationLog.setOperation("取消订单");
operationLog.setOperationUser(order.getUserName());
operationLog.setContent("用户取消订单");
break;
case OrderStatusConstant.Paid:
operationLog.setStatus("已付款");
operationLog.setOperation("付款");
operationLog.setOperationUser(order.getUserName());
operationLog.setContent("付款成功");
break;
case OrderStatusConstant.production:
operationLog.setStatus("制作中");
operationLog.setOperation("同步信息");
operationLog.setOperationUser("接口");
operationLog.setContent("机器推送制作中");
break;
case OrderStatusConstant.productionCompleted:
operationLog.setStatus("制作完成");
operationLog.setOperation("同步信息");
operationLog.setOperationUser("接口");
operationLog.setContent("机器推送制作完成");
break;
case OrderStatusConstant.Taking:
operationLog.setStatus("取餐中");
operationLog.setOperation("同步信息");
operationLog.setOperationUser("接口");
operationLog.setContent("机器推送取餐中");
break;
case OrderStatusConstant.completed:
operationLog.setStatus("已完成");
operationLog.setOperation("同步信息");
operationLog.setOperationUser("接口");
operationLog.setContent("机器推送已完成");
break;
}
return orderOperationLogMapper.insertOrderOperationLog(operationLog);
}
......@@ -106,4 +146,48 @@ public class OrderOperationLogServiceImpl implements IOrderOperationLogService
{
return orderOperationLogMapper.deleteOrderOperationLogById(id);
}
public void insertOrderOperationLog(OrderRefund orderRefund) {
Order order = orderRefund.getOrder();
OrderOperationLog operationLog = new OrderOperationLog();
operationLog.setOrderId(String.valueOf(order.getId()));
operationLog.setCreateAt(new Date());
if(StringUtils.isEmpty(orderRefund.getDesc())){
operationLog.setStatus("已退款");
operationLog.setOperation("退款");
operationLog.setOperationUser("系统");
operationLog.setContent("用户完成退款");
}else{
operationLog.setStatus("已完成");
operationLog.setOperation("售后");
operationLog.setOperationUser(orderRefund.getCreateUserName());
operationLog.setContent(orderRefund.getDesc());
}
}
public void insertOrderOperationLog(Order order, ResultVo resultVo) {
OrderOperationLog operationLog = new OrderOperationLog();
operationLog.setOrderId(String.valueOf(order.getId()));
operationLog.setCreateAt(new Date());
String state = order.getState();
operationLog.setOperation("同步消息");
operationLog.setOperationUser("接口");
String result = "成功";
if(!"0".equals(resultVo.getCode())){
result = "失败";
}
switch (state){
case OrderStatusConstant.UnpaidCancel:
operationLog.setStatus("已取消");
operationLog.setContent("取消订单同步"+result);
break;
case OrderStatusConstant.Paid:
operationLog.setStatus("已付款");
operationLog.setContent("付款状态信息"+result);
break;
}
orderOperationLogMapper.insertOrderOperationLog(operationLog);
}
}
package com.soss.system.service.impl;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
......@@ -8,9 +9,12 @@ import com.soss.common.core.domain.AjaxResult;
import com.soss.common.exception.ServiceException;
import com.soss.common.utils.GenerateCode;
import com.soss.common.utils.StringUtils;
import com.soss.system.constants.OrderStatusConstant;
import com.soss.system.domain.Order;
import com.soss.system.domain.OrderDetail;
import com.soss.system.domain.OrderSnapshot;
import com.soss.system.domain.vo.OrderQuery;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.mapper.OrderMapper;
import com.soss.system.mapper.OrderSnapshotMapper;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -36,6 +40,12 @@ public class OrderRefundServiceImpl implements IOrderRefundService
private OrderMapper orderMapper;
@Autowired
private OrderSnapshotMapper orderSnapshotMapper;
@Autowired
private MachineApiServiceImpl machineApiService;
@Autowired
private JiGuangPushServiceImpl jiGuangPushService;
@Autowired
private OrderOperationLogServiceImpl orderOperationLogService;
/**
* 查询订单退款
......@@ -91,11 +101,11 @@ public class OrderRefundServiceImpl implements IOrderRefundService
}
// 制作中、制作完成、聚餐中、已完成
String state = order.getState();
if("2".equals(state)){
List<String> status = Arrays.asList(OrderStatusConstant.production,OrderStatusConstant.productionCompleted,OrderStatusConstant.completed);
if(OrderStatusConstant.Paid.equals(state)){
cancel(order);
// 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成
}else if("3".equals(state)||"4".equals(state)||"5".equals(state)||"6".equals(state)||"13".equals(state)){
}else if(status.contains(state)){
String desc = orderRefund.getDesc();
if(StringUtils.isEmpty(desc)){
return AjaxResult.error("请联系客服进行退款");
......@@ -112,9 +122,27 @@ public class OrderRefundServiceImpl implements IOrderRefundService
orderRefund.setTotalFee(order.getAmount());
orderRefund.setOrderNo(order.getOrderNo());
int i = orderRefundMapper.insertOrderRefund(orderRefund);
order.setState(OrderStatusConstant.refunding);
orderMapper.updateOrder(order);
orderRefund.setOrder(order);
return AjaxResult.success(orderRefund);
}
public void cancel(Order order) {
if(OrderStatusConstant.Unpaid.equals(order.getState())){
order.setState(OrderStatusConstant.UnpaidCancel);
order.setUpdatedAt(new Date());
orderMapper.updateOrder(order);
machineApiService.updateOrder(order);
}else if(OrderStatusConstant.Paid.equals(order.getState())){
order.setState(OrderStatusConstant.PaidCancel);
order.setUpdatedAt(new Date());
orderMapper.updateOrder(order);
machineApiService.updateOrder(order);
jiGuangPushService.pushOrderState(order);
}else{
throw new ServiceException("该订单不允许退款");
}
}
/**
* 修改订单退款
*
......@@ -163,4 +191,17 @@ public class OrderRefundServiceImpl implements IOrderRefundService
orderRefund.setTotalFee(order.getAmount());
return orderRefund;
}
@Override
public List<OrderRefund> selectOrderRefundList(OrderQuery orderQuery) {
List<OrderRefund> orderRefunds = orderRefundMapper.selectList(orderQuery);
for (OrderRefund refund : orderRefunds) {
Order order = orderService.selectOrderById(refund.getOrderId());
OrderSnapshot orderSnapshot = orderSnapshotMapper.selectOrderSnapshotByOrderId(order.getId());
List<OrderDetail> orderDetails = JSONObject.parseArray(orderSnapshot.getSnapshot(), OrderDetail.class);
order.setOrderDetails(orderDetails);
refund.setOrder(order);
}
return orderRefunds;
}
}
......@@ -5,6 +5,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.soss.common.constant.HttpStatus;
import com.soss.common.core.domain.AjaxResult;
......@@ -12,15 +13,19 @@ 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.spring.SpringUtils;
import com.soss.system.constants.OrderStatusConstant;
import com.soss.system.domain.*;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.service.IOrderService;
import com.soss.system.domain.vo.OrderQuery;
import com.soss.system.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.support.atomic.RedisAtomicInteger;
import org.springframework.security.core.token.TokenService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
/**
* 订单Service业务层处理
......@@ -49,6 +54,8 @@ public class OrderServiceImpl implements IOrderService
private OrderOperationLogServiceImpl orderOperationLogService;
@Autowired
private OrderSnapshotServiceImpl orderSnapshotService;
@Autowired
private JiGuangPushServiceImpl jiGuangPushService;
......@@ -102,7 +109,7 @@ public class OrderServiceImpl implements IOrderService
if(HttpStatus.SUCCESS != (int)result.get(result.CODE_TAG)){
return result;
}
order.setState("1");
order.setState(OrderStatusConstant.Unpaid);
order.setUserId(loginUser.getOpenId());
order.setUserName(loginUser.getUsername());
order.setCreatedAt(new Date());
......@@ -138,7 +145,7 @@ public class OrderServiceImpl implements IOrderService
}
//发送数据给机器
machineApiService.createOrder(order);
orderOperationLogService.insertOrderOperationLog("待付款",order.getId(),"创建了订单",order.getUserName(),"创建订单");
orderOperationLogService.insertOrderOperationLog(order);
orderSnapshotService.saveOrderSnapshot(order);
return AjaxResult.success(order.getOrderNo());
......@@ -207,16 +214,12 @@ public class OrderServiceImpl implements IOrderService
@Override
public List<Order> getMyOrder(String openId) {
List<Order> orders = orderMapper.selectByUserId("oA0gy4xT7vFZ5SGI__x_ss7vNi8g");
List<Order> orders = orderMapper.selectByUserId(openId);
for (Order order : orders) {
order.setShop(shopMapper.selectShopById(order.getShopId()));
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderId(order.getId());
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
for (OrderDetail detail : orderDetails) {
detail.setGoods(goodsMapper.selectGoodsById(detail.getGoodsId()));
}
order.setOrderDetails(orderDetails);
OrderSnapshot orderSnapshot = orderSnapshotService.selectOrderSnapshotByOrderId(order.getId());
order.setOrderDetails(JSONArray.parseArray(orderSnapshot.getSnapshot(),OrderDetail.class));
}
return orders;
}
......@@ -225,11 +228,19 @@ public class OrderServiceImpl implements IOrderService
@Transactional
public int cancel(String orderId) {
Order order = orderMapper.selectOrderById(orderId);
if("1".equals(order.getState())){
order.setState("7");
if(OrderStatusConstant.Unpaid.equals(order.getState())){
order.setState("8");
order.setUpdatedAt(new Date());
orderMapper.updateOrder(order);
orderOperationLogService.insertOrderOperationLog(order);
machineApiService.updateOrder(order);
}else if(OrderStatusConstant.Paid.equals(order.getState())){
order.setState("9");
order.setUpdatedAt(new Date());
orderMapper.updateOrder(order);
orderOperationLogService.insertOrderOperationLog(order);
machineApiService.updateOrder(order);
jiGuangPushService.pushOrderState(order);
}else{
throw new ServiceException("该订单不允许取消");
}
......@@ -237,6 +248,8 @@ public class OrderServiceImpl implements IOrderService
return 0;
}
/**
* 获取机器顺序号
* @param shopId
......@@ -281,8 +294,9 @@ public class OrderServiceImpl implements IOrderService
}
public List<JSONObject> getOrderInfo(String machineCode) {
Machine machine = machineMapper.selectMachineByCode(machineCode);
List<String> status = Arrays.asList("3","4","5");
List<Order> orders = orderMapper.selectOrder(status, machineCode);
List<Order> orders = orderMapper.selectOrder(status, machine.getId());
Map<String, List<Order>> collect = orders.stream().collect(Collectors.groupingBy(Order::getState));
List<JSONObject> objects = new ArrayList<>();
for(String key:collect.keySet()){
......@@ -316,4 +330,49 @@ public class OrderServiceImpl implements IOrderService
}
return null;
}
public Map<String,String> getMyFristOrder(String openId) {
List<String> status = Arrays.asList("2","3","4");
Order order = orderMapper.selectHomeByUserId(openId,status);
if(order ==null){
return null;
}
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderId(order.getId());
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
order.setOrderDetails(orderDetails);
String waitTime = getWaitTime(order);
Map<String,String> map =new HashMap<>();
map.put("waitTime",waitTime);
map.put("pickCode",order.getPickCode());
map.put("orderNum",order.getOrderNum());
return map;
}
public String getWaitTime(Order order) {
String machineId = order.getMachineId();
List<String> status = Arrays.asList("2","3");
List<Order> orders = orderMapper.selectOrder(status, machineId);
List<OrderDetail> list = new ArrayList<>();
list.addAll(order.getOrderDetails());
for (Order order1 : orders) {
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderId(order1.getId());
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
if(CollectionUtils.isEmpty(orderDetails)){
}else{
list.addAll(orderDetails);
}
}
Long takeTimeCount =0L;
for (OrderDetail orderDetail : list) {
Long takeTime = goodsMapper.selectGoodsById(orderDetail.getGoodsId()).getTakeTime();
takeTimeCount+=takeTime;
}
return String.valueOf((int)(takeTimeCount/60));
}
}
......@@ -152,7 +152,7 @@ public class ShopRecommendServiceImpl implements IShopRecommendService
String turn = frist.getTurn();
shopRecommend.setGoodsId(lastGoodsId);
ShopRecommend last = shopRecommendMapper.selectShopRecommendList(shopRecommend).get(0);
frist.setType(last.getTurn());
frist.setTurn(last.getTurn());
last.setTurn(turn);
shopRecommendMapper.updateShopRecommend(frist);
shopRecommendMapper.updateShopRecommend(last);
......
......@@ -12,6 +12,7 @@ import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2022-04-28
*/
@Service
@Slf4j
public class ShopServiceImpl implements IShopService
{
@Autowired
......@@ -231,7 +233,7 @@ public class ShopServiceImpl implements IShopService
Goods goods = goodsMapper.selectGoodsById(String.valueOf(goodsId));
List<ShopGoods> shopGoodsList = shopGoodsMapper.selectShopGoodsList(shopGoods);
shopGoodsList = shopGoodsList.stream().filter(e->{
String category = goodsMapper.selectGoodsById(String.valueOf(goodsId)).getCategory();
String category = goodsMapper.selectGoodsById(String.valueOf(e.getGoodsId())).getCategory();
if(category.equals(goods.getCategory())){
return true;
}else{
......@@ -239,6 +241,7 @@ public class ShopServiceImpl implements IShopService
}
}).collect(Collectors.toList());
int size = shopGoodsList.size();
Long lastGoodsId = null;
for(int i =0;i<size;i++){
......
......@@ -46,14 +46,11 @@ public class SysUserServiceImpl implements ISysUserService
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private SysPostMapper postMapper;
@Autowired
private SysUserRoleMapper userRoleMapper;
@Autowired
private SysUserPostMapper userPostMapper;
@Autowired
private ISysConfigService configService;
......@@ -150,12 +147,7 @@ public class SysUserServiceImpl implements ISysUserService
@Override
public String selectUserPostGroup(String userName)
{
List<SysPost> list = postMapper.selectPostsByUserName(userName);
if (CollectionUtils.isEmpty(list))
{
return StringUtils.EMPTY;
}
return list.stream().map(SysPost::getPostName).collect(Collectors.joining(","));
return null;
}
/**
......@@ -417,7 +409,7 @@ public class SysUserServiceImpl implements ISysUserService
}
if (list.size() > 0)
{
userPostMapper.batchUserPost(list);
//userPostMapper.batchUserPost(list);
}
}
}
......@@ -461,7 +453,7 @@ public class SysUserServiceImpl implements ISysUserService
// 删除用户与角色关联
userRoleMapper.deleteUserRoleByUserId(userId);
// 删除用户与岗位表
userPostMapper.deleteUserPostByUserId(userId);
//userPostMapper.deleteUserPostByUserId(userId);
return userMapper.deleteUserById(userId);
}
......
package com.soss.system.service.impl;
import java.util.Date;
import java.util.List;
import com.soss.system.service.IWechatMessageService;
......@@ -56,6 +57,19 @@ public class WechatMessageServiceImpl implements IWechatMessageService
return wechatMessageMapper.insertWechatMessage(wechatMessage);
}
@Override
public int insertWechatMessage(String openId, String message) {
WechatMessage wechatMessage = new WechatMessage();
wechatMessage.setMessage(message);
wechatMessage.setCreatedAt(new Date());
wechatMessage.setState("0");
wechatMessage.setIsRead("1");
wechatMessage.setType("1");
wechatMessage.setUserId(openId);
wechatMessage.setUpdatedAt(new Date());
return wechatMessageMapper.insertWechatMessage(wechatMessage);
}
/**
* 修改小程序信息发送
*
......
package com.soss.system.weixin.util;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import com.soss.system.domain.Order;
import com.soss.system.domain.Shop;
import com.soss.system.mapper.ShopMapper;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
@Slf4j
public class SendMessageUtils {
@Autowired
private WxMaService wxMaService;
@Value("${weixin.templateId}")
private String templateId;
@Value("${weixin.pagePath}")
private String pagePath;
@Autowired
private ShopMapper shopMapper;
/**
* 设置会议订阅消息
*
* @param
* @return 订阅会议消息
*/
private List<WxMaSubscribeMessage.MsgData> setMeetingMsg (Order order) {
Shop shop = shopMapper.selectShopById(order.getShopId());
List<WxMaSubscribeMessage.MsgData> dataList = new ArrayList<>();
//这里要完全按照订阅消息模板详情去设置,thing1 ,thing2...不能变
WxMaSubscribeMessage.MsgData data1 = new WxMaSubscribeMessage.MsgData();
data1.setName("character_string1");
data1.setValue(order.getOrderNo());
dataList.add(data1);
WxMaSubscribeMessage.MsgData data2 = new WxMaSubscribeMessage.MsgData();
data2.setName("thing2");
data2.setValue(shop.getName());
dataList.add(data2);
WxMaSubscribeMessage.MsgData data3 = new WxMaSubscribeMessage.MsgData();
data3.setName("character_string4");
data3.setValue(order.getOrderNum());
dataList.add(data3);
WxMaSubscribeMessage.MsgData data4 = new WxMaSubscribeMessage.MsgData();
data4.setName("thing7");
data4.setValue(shop.getAddress());
dataList.add(data4);
return dataList;
}
/**
* 根据模板id发送消息
*
*/
public void sendWxMsg(Order order) {
try {
WxMaSubscribeMessage.WxMaSubscribeMessageBuilder builder = WxMaSubscribeMessage.builder();
//发送人openid
builder.toUser(order.getUserId());
//发送的模板id
builder.templateId(templateId);
//消息主体
builder.data(setMeetingMsg(order));
//点击订阅消息的跳转链接(默认是正式发布的小程序页面,当然也可以通过参数进行控制)
builder.page(pagePath);
WxMaSubscribeMessage msg = builder.build();
wxMaService.getMsgService().sendSubscribeMsg(msg);
} catch (WxErrorException e) {
log.error("会议通知发送失败,用户openId:{}, 错误码:{},错误信息:{}",
order.getUserId(), e.getError().getErrorCode(), e.getError().getErrorMsg());
//发送失败就发送短信
}
}
}
......@@ -195,6 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<![CDATA[ and pay_time <= to_date(#{payAtEnd,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]>
</if>
</where>
order by created_at desc
</select>
<select id="selectOrder" resultMap="OrderResult">
<include refid="selectOrderVo"/>
......@@ -207,4 +208,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and machine_id = #{machineId}
</where>
</select>
<select id="selectHomeByUserId" resultMap="OrderResult">
<include refid="selectOrderVo"/>
<where>
state in
<foreach item="item" index="index" collection="status"
open="(" separator="," close=")">
#{item}
</foreach>
and user_id = #{userId}
</where>
order by create_at desc limit 1
</select>
<update id="updateTimeOut">
update `order` set state='5' where state =#{status} and updated_at &lt; DATE_SUB(NOW() ,interval #{timeout} SECOND)
</update>
</mapper>
\ No newline at end of file
......@@ -14,10 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="orderNo" column="order_no"/>
<result property="createUserName" column="create_user_name"></result>
</resultMap>
<sql id="selectOrderRefundVo">
select id, order_id, refund_amount, state, `desc`, created_at, updated_at,refund_no,order_no from order_refund
select id, order_id, refund_amount, state, `desc`, created_at, updated_at,refund_no,order_no,create_user_name from order_refund
</sql>
<select id="selectOrderRefundList" parameterType="OrderRefund" resultMap="OrderRefundResult">
......@@ -50,8 +51,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updatedAt != null">updated_at,</if>
<if test="refundNo != null">refund_no,</if>
<if test="orderNo != null">order_no,</if>
<if test="createUserName != null">create_user_name,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null and orderId != ''">#{orderId},</if>
<if test="refundAmount != null">#{refundAmount},</if>
......@@ -61,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updatedAt != null">#{updatedAt},</if>
<if test="refundNo != null">#{refundNo},</if>
<if test="orderNo != null">#{orderNo},</if>
<if test="createUserName != null">#{create_user_name},</if>
</trim>
</insert>
......@@ -88,4 +92,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</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}
</if>
<if test="orderNum!=null ">
and order_num =#{orderNum}
</if>
<if test="userName!=null">
and user_name like concat('%', #{userName}, '%')
</if>
<if test="shopId!=null ">
and shop_id =#{shopId}
</if>
<if test="state!=null ">
and shop_id =#{shopId}
</if>
<if test="createAtStart!=null ">
<![CDATA[ and create_at >= to_date(#{createAtStart,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]>
</if>
<if test="createAtEnd!=null ">
<![CDATA[ and create_at <= to_date(#{createAtEnd,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]>
</if>
<if test="payAtStart!=null ">
<![CDATA[ and pay_time >= to_date(#{payAtStart,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]>
</if>
<if test="payAtEnd!=null ">
<![CDATA[ and pay_time <= to_date(#{payAtEnd,jdbcType=DATE},'yyyy-MM-dd hh24:mi:ss')]]>
</if>
</where>
order by or2.created_at desc
</select>
</mapper>
\ No newline at end of file
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