Commit 49970133 by 郑云飞

1

parent 0db8b648
......@@ -30,20 +30,20 @@ public class OrderMainAppController {
@ResponseBody
public Result findPageList(@RequestBody OrderMain item) {
if(item.getCustomerid() == null || item.getCustomerid().equals("")) return Result.success();
if (item.getCustomerid() == null || item.getCustomerid().equals("")) return Result.success();
//这里对返回对象用Map处理,map.pageinfo=>分页信息;map.items=>结果数据集;
Map<String,Object> rmap = new HashMap<String,Object>();
Map<String, Object> rmap = new HashMap<String, Object>();
//传入当前页数,适配PC端Layui分页
if(item.getCurpage() != null || item.getPagesize() != null) {
if (item.getCurpage() != null || item.getPagesize() != null) {
PageInfo pinfo = new PageInfo();
if(item.getCurpage() != null) {
if (item.getCurpage() != null) {
pinfo.setCurPage(item.getCurpage());
}
if(item.getPagesize() != null) {
if (item.getPagesize() != null) {
pinfo.setPageSize(item.getPagesize());
}
item.setPageinfo(pinfo);
......@@ -51,10 +51,10 @@ public class OrderMainAppController {
// 1.查询前 需要对分页对象 做处理,主要是 分页 开始记录数 limit arg0开始记录,arg1每页几条记录
PageInfo pinfo = item.getPageinfo();
if(pinfo == null) {
if (pinfo == null) {
pinfo = new PageInfo();
item.setPageinfo(pinfo);
}else{
} else {
// 分页开始记录数
int curRecord = (pinfo.getCurPage() - 1) * pinfo.getPageSize();
pinfo.setCurRecord(curRecord);
......@@ -62,15 +62,15 @@ public class OrderMainAppController {
}
item.setAppflag(1);
// 2.1 执行主表 查询
List<OrderMain> items=this.orderService.selectByParamPageList(item);
List<OrderMain> items = this.orderService.selectByParamPageList(item);
// 3.将查询结果的 分页数据封装后返回
int totalRs = pinfo.getTotalRecords(); //总记录数
int totalPs = 0; //总页数
if(totalRs % pinfo.getPageSize() == 0){ //总页数计算
totalPs = totalRs / pinfo.getPageSize() ;
}else{
totalPs = 1 + totalRs / pinfo.getPageSize() ;
if (totalRs % pinfo.getPageSize() == 0) { //总页数计算
totalPs = totalRs / pinfo.getPageSize();
} else {
totalPs = 1 + totalRs / pinfo.getPageSize();
}
pinfo.setTotalPages(totalPs);
......@@ -81,8 +81,6 @@ public class OrderMainAppController {
}
/**
* FRICE TODO 根据 ”多参数“ 查找对象集合
*/
......@@ -96,7 +94,6 @@ public class OrderMainAppController {
}
/**
* 更新订单
*/
......@@ -111,8 +108,6 @@ public class OrderMainAppController {
}
/**
* 创建订单
*/
......@@ -128,7 +123,6 @@ public class OrderMainAppController {
}
/**
* 创建积分订单
*/
......@@ -156,10 +150,8 @@ public class OrderMainAppController {
}
/**
* 根据”对象id“ 删除对象
*
*/
@RequestMapping(value = "/{id}/deleteById", method = RequestMethod.POST)
@ResponseBody
......@@ -170,15 +162,14 @@ public class OrderMainAppController {
}
/**
* 根据参数,查询订单数量
*/
@RequestMapping(value = "/findOrderNum",method = RequestMethod.POST)
@RequestMapping(value = "/findOrderNum", method = RequestMethod.POST)
@ResponseBody
public Result findOrderNum(@RequestBody JSONObject json){
public Result findOrderNum(@RequestBody JSONObject json) {
OrderMain user = JSONObject.toJavaObject(json,OrderMain.class);
OrderMain user = JSONObject.toJavaObject(json, OrderMain.class);
int orderNum = this.orderService.findOrderNum(user);
......@@ -187,31 +178,28 @@ public class OrderMainAppController {
}
/**
* 取消订单
*/
@RequestMapping(value = "/cancelOrder",method = RequestMethod.POST)
@RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
@ResponseBody
public Result cancelOrder(@RequestBody JSONObject json){
public Result cancelOrder(@RequestBody JSONObject json) {
//1. 将前台传过来的json对象转换成具有业务属性的 Java 对象
OrderMain user = JSONObject.toJavaObject(json,OrderMain.class);
OrderMain user = JSONObject.toJavaObject(json, OrderMain.class);
return this.orderService.cancelOrder(user);
}
/**
* 订单已完成
*/
@RequestMapping(value = "/updateOkStatus",method = RequestMethod.POST)
@RequestMapping(value = "/updateOkStatus", method = RequestMethod.POST)
@ResponseBody
public Result updateOkStatus(@RequestBody JSONObject json){
public Result updateOkStatus(@RequestBody JSONObject json) {
//1. 将前台传过来的json对象转换成具有业务属性的 Java 对象
OrderMain user = JSONObject.toJavaObject(json,OrderMain.class);
OrderMain user = JSONObject.toJavaObject(json, OrderMain.class);
return this.orderService.updateOkStatus(user);
......@@ -222,9 +210,9 @@ public class OrderMainAppController {
* @积分兑换 商品
*/
@RequestMapping(value = "/integralPay", method = RequestMethod.POST)
public Result integralPay(Integer userId, Integer orderId){
public Result integralPay(Integer userId, Integer orderId) {
return this.orderService.integralPay(userId,orderId);
return this.orderService.integralPay(userId, orderId);
}
......@@ -240,6 +228,12 @@ public class OrderMainAppController {
}
}
/**
* 获取用户最后一次填写的地址信息
*/
@RequestMapping(value = "/getLastOrderAddres", method = RequestMethod.GET)
public Result getLastOrderAddres(Integer userId) {
return orderService.getLastOrderAddres(userId);
}
}
package com.yunniu.farming.webadmin.controller;
import cn.hutool.core.lang.WeightRandom;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yunniu.farming.util.DateTools;
import com.yunniu.farming.webadmin.dao.CustomerDao;
import com.yunniu.farming.webadmin.dao.GroupBuyDao;
......@@ -94,7 +92,16 @@ public class TaskJob {
*/
@Scheduled(cron = "0 * * * * ? ")
public void activityFailure() {
groupBuyDao.activityFailure();
groupBuyDao.activityFailure(new Date());
}
/**
* 定时失效团购活动
*/
@Scheduled(cron = "0 * * * * ? ")
public void activityValidation() {
groupBuyDao.activityValidation(new Date());
}
......
......@@ -3,7 +3,9 @@ package com.yunniu.farming.webadmin.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunniu.farming.webadmin.model.GroupBuy;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
......@@ -18,7 +20,7 @@ public interface GroupBuyDao extends BaseMapper<GroupBuy> {
int updateEndTime(GroupBuy item);
int activityFailure();
int activityFailure(@Param("now") Date now);
int updateStatus(Long id);
......@@ -26,4 +28,5 @@ public interface GroupBuyDao extends BaseMapper<GroupBuy> {
List<String> findavatarList();
int activityValidation(@Param("now") Date now);
}
......@@ -20,4 +20,6 @@ public interface OrderMainDao extends BaseMapper<OrderMain> {
List<OrderMain> getPageListByGroupOrderId(OrderMain item);
List<OrderMain> selectByGroupOrderId(Long id);
OrderMain getLastOrderAddres(Integer userId);
}
......@@ -6,13 +6,8 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yunniu.farming.result.Result;
import com.yunniu.farming.util.COSUtil;
import com.yunniu.farming.util.FileUtil;
import com.yunniu.farming.util.ImageUtil;
import com.yunniu.farming.util.UUIDUtils;
import com.yunniu.farming.webadmin.dao.*;
import com.yunniu.farming.webadmin.model.*;
import com.yunniu.farming.webadmin.service.GroupBuyProductService;
import com.yunniu.farming.webadmin.service.GroupBuyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -20,10 +15,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zyf
......@@ -68,7 +60,7 @@ public class GroupBuyServiceimpl implements GroupBuyService {
if (ObjectUtils.isEmpty(item.getId())) {
// 设置小区id集合的值
item.setAreaIds(JSON.toJSONString(item.getAreaIdList()));
item.setGroupStatus(3);
item.setGroupStatus(2);
// 保存活动基础信息
this.mapper.insert(item);
......
......@@ -5,7 +5,10 @@ import com.yunniu.farming.util.DateTools;
import com.yunniu.farming.util.DateUtils;
import com.yunniu.farming.util.StringHelper;
import com.yunniu.farming.util.WxPayAppUtils;
import com.yunniu.farming.webadmin.dao.*;
import com.yunniu.farming.webadmin.dao.CustomerDao;
import com.yunniu.farming.webadmin.dao.IntegralrecDao;
import com.yunniu.farming.webadmin.dao.OrderMainDao;
import com.yunniu.farming.webadmin.dao.OrderSubDao;
import com.yunniu.farming.webadmin.model.GroupOrder;
import com.yunniu.farming.webadmin.model.Integralrec;
import com.yunniu.farming.webadmin.model.OrderMain;
......@@ -13,14 +16,16 @@ import com.yunniu.farming.webadmin.model.OrderSub;
import com.yunniu.farming.webadmin.service.GroupOrderService;
import com.yunniu.farming.wx.WxConfigUtil;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.text.DecimalFormat;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
......@@ -345,13 +350,13 @@ public class OrderMainServiceImpl {
if(co == null) return;
// 支付回调标志,防止 多次回调
if(StringUtils.isEmpty(co.getSdef1())){
if (StringUtils.isEmpty(co.getSdef4())) {
//支会回调标志
co.setIstatus(OrderMain.STATUS_WAITING);//待收货
co.setIpaystatus(OrderMain.PAY_STATUS_OK);//支付成功
co.setTpaytime(new Date());//支付时间
co.setSdef1("1");
co.setSdef4("1");
this.update(co);
......@@ -457,4 +462,15 @@ public class OrderMainServiceImpl {
return Result.success("支付成功");
}
/**
* 获取用户最后一次填写的地址信息
*
* @param userId 用户id
* @return
*/
public Result getLastOrderAddres(Integer userId) {
return Result.success(this.orderMainDao.getLastOrderAddres(userId));
}
}
......@@ -31,7 +31,8 @@
</update>
<update id="activityFailure">
update group_buy set group_status = 4 where end_time &lt;= now();
update group_buy set group_status = 4 where end_time &lt;= DATE_FORMAT(#{now},'%Y-%m-%d %H:%i:%s') and
group_status =3;
</update>
<update id="updateStatus">
......@@ -39,10 +40,20 @@
</update>
<select id="findJoinNumber" resultType="java.lang.Integer">
select count(1) from order_main where group_order_id is not null
select count(1)
from order_main
where group_order_id is not null
</select>
<select id="findavatarList" resultType="java.lang.String">
select c.swximgurl from order_main om left join customer c on om.customerid = c.id where group_order_id is not null limit 3
select c.swximgurl
from order_main om
left join customer c on om.customerid = c.id
where group_order_id is not null limit 3
</select>
<update id="activityValidation">
update group_buy set group_status = 3 where start_time &lt;= DATE_FORMAT(#{now},'%Y-%m-%d %H:%i:%s') and
group_status =2;
</update>
</mapper>
\ No newline at end of file
......@@ -323,4 +323,17 @@
from order_main
where group_order_id = #{id,jdbcType=BIGINT} and ipaystatus = 1
</select>
<select id="getLastOrderAddres" resultMap="BaseResultMap">
select sdef1,
sdef2,
sdef3
from order_main
where customerid = #{userId}
and group_order_id is not null
and sdef1 is not null
and sdef2 is not null
and sdef3 is not null
order by tordertime desc limit 1
</select>
</mapper>
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