Commit 74d1c0f1 by 张新旗

代码永远在路上

parent 0a9997d3
......@@ -3,10 +3,13 @@ package com.soss.web.controller.coffee;
import com.soss.common.annotation.Log;
import com.soss.common.core.controller.BaseController;
import com.soss.common.core.domain.AjaxResult;
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.framework.web.service.TokenService;
import com.soss.system.domain.Customer;
import com.soss.system.domain.Order;
import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo;
import com.soss.system.service.ICustomerService;
......@@ -14,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
......@@ -29,6 +33,8 @@ public class CustomerController extends BaseController
{
@Autowired
private ICustomerService customerService;
@Autowired
private TokenService tokenService;
/**
* 查询用户信息列表
......@@ -48,42 +54,18 @@ public class CustomerController extends BaseController
* 获取用户信息详细信息
*/
@PreAuthorize("@ss.hasPermi('system:customer:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
@GetMapping
public TableDataInfo getInfo(@RequestParam("id") String id,@RequestParam String status)
{
return AjaxResult.success(customerService.selectCustomerById(id));
startPage();
List<Order> orders = customerService.selectCustomerById(id,status);
return getDataTable(orders);
}
/**
* 新增用户信息
*/
@PreAuthorize("@ss.hasPermi('system:customer:add')")
@Log(title = "用户信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Customer customer)
{
return toAjax(customerService.insertCustomer(customer));
@GetMapping("/allow")
private AjaxResult allow(HttpServletRequest request,String allow){
LoginUser loginUser = tokenService.getLoginUser(request);
return AjaxResult.success(customerService.allow(loginUser.getOpenId(),allow));
}
/**
* 修改用户信息
*/
@PreAuthorize("@ss.hasPermi('system:customer:edit')")
@Log(title = "用户信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Customer customer)
{
return toAjax(customerService.updateCustomer(customer));
}
/**
* 删除用户信息
*/
@PreAuthorize("@ss.hasPermi('system:customer:remove')")
@Log(title = "用户信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(customerService.deleteCustomerByIds(ids));
}
}
......@@ -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.OrderServiceImpl;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -38,7 +39,7 @@ import com.soss.common.core.page.TableDataInfo;
public class OrderController extends BaseController
{
@Autowired
private IOrderService orderService;
private OrderServiceImpl orderService;
@Autowired
private TokenService tokenService;
@Autowired
......@@ -102,6 +103,8 @@ public class OrderController extends BaseController
public AjaxResult cancel(HttpServletRequest request, String orderId)
{
Order order = orderService.selectOrderById(orderId);
order.setOrderNo(orderService.getOrderNo(order.getSource()));
orderService.updateOrder(order);
int amount = order.getAmount().movePointRight(2).intValue();
Map payInfo = weixinService.pay(request, "hooloo", order.getOrderNo(), order.getUserId(), amount);
if(payInfo !=null){
......
package com.soss.web.controller.coffee;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.soss.common.core.domain.BaseEntity;
import com.soss.common.core.domain.model.LoginUser;
import com.soss.framework.web.service.TokenService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -33,15 +38,20 @@ public class WechatMessageController extends BaseController
{
@Autowired
private IWechatMessageService wechatMessageService;
@Autowired
private TokenService tokenService;
/**
* 查询小程序信息发送列表
*/
@PreAuthorize("@ss.hasPermi('system:message:list')")
@GetMapping("/list")
public TableDataInfo list(WechatMessage wechatMessage)
public TableDataInfo list(HttpServletRequest request, BaseEntity baseEntity)
{
WechatMessage wechatMessage = new WechatMessage();
LoginUser loginUser = tokenService.getLoginUser(request);
wechatMessage.setUserId(loginUser.getOpenId());
startPage();
List<WechatMessage> list = wechatMessageService.selectWechatMessageList(wechatMessage);
return getDataTable(list);
}
......
......@@ -5,6 +5,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.soss.common.annotation.Excel;
import com.soss.common.core.domain.BaseEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 用户信息对象 customer
*
......@@ -34,6 +37,45 @@ public class Customer extends BaseEntity
@Excel(name = "用户来源")
private String soucre;
public String getAllow() {
return allow;
}
public void setAllow(String allow) {
this.allow = allow;
}
private List<Order> cancelOrder;
private String allow;
public List<Order> getCancelOrder() {
return cancelOrder;
}
public void setCancelOrder(List<Order> cancelOrder) {
this.cancelOrder = cancelOrder;
}
public List<Order> getRefundOrder() {
return refundOrder;
}
public void setRefundOrder(List<Order> refundOrder) {
this.refundOrder = refundOrder;
}
public List<Order> getNormalOrder() {
return normalOrder;
}
public void setNormalOrder(List<Order> normalOrder) {
this.normalOrder = normalOrder;
}
private List<Order> refundOrder ;
private List<Order> normalOrder;
public void setId(String id)
{
this.id = id;
......
package com.soss.system.domain.vo.customer;
import com.soss.common.core.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;
......@@ -7,7 +8,7 @@ import javax.xml.crypto.Data;
import java.io.Serializable;
@Getter
@Setter
public class CustomerQueryVo implements Serializable {
public class CustomerQueryVo extends BaseEntity {
private String userInfo;
......
package com.soss.system.domain.vo.customer;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
......@@ -10,6 +11,8 @@ import java.util.Date;
@Getter
@Setter
public class CustomerResultVo implements Serializable {
private String id;
private String userName;
private String phoneNumber;
......@@ -25,9 +28,9 @@ public class CustomerResultVo implements Serializable {
private String refundCount;
private BigDecimal refundAmount;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date lastOrderDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
private String source;
......
......@@ -75,4 +75,6 @@ public interface OrderMapper
Order selectHomeByUserId(@Param("userId") String openId,@Param("status") List<String> status);
void updateTimeOut(@Param("status") String productionCompleted,@Param("timeout") String timeout);
List<Order> selectOrderByUserId(@Param("userId") String openId,@Param("status") List<String> status);
}
......@@ -2,6 +2,7 @@ package com.soss.system.service;
import java.util.List;
import com.soss.system.domain.Customer;
import com.soss.system.domain.Order;
import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo;
......@@ -17,9 +18,10 @@ public interface ICustomerService
* 查询用户信息
*
* @param id 用户信息主键
* @param status
* @return 用户信息
*/
public Customer selectCustomerById(String id);
public List<Order> selectCustomerById(String id, String status);
/**
* 查询用户信息列表
......@@ -60,4 +62,6 @@ public interface ICustomerService
* @return 结果
*/
public int deleteCustomerById(Long id);
Integer allow(String openId, String allow);
}
package com.soss.system.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.soss.common.utils.DateUtils;
import com.soss.system.constants.OrderStatusConstant;
import com.soss.system.domain.Order;
import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo;
import com.soss.system.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.soss.system.mapper.CustomerMapper;
......@@ -21,17 +27,36 @@ public class CustomerServiceImpl implements ICustomerService
{
@Autowired
private CustomerMapper customerMapper;
@Autowired
private OrderMapper orderMapper;
/**
* 查询用户信息
*
* @param id 用户信息主键
* @param status
* @return 用户信息
*/
@Override
public Customer selectCustomerById(String id)
public List<Order> selectCustomerById(String id, String status)
{
return customerMapper.selectCustomerById(id);
Order order = new Order();
order.setUserId(id);
List<String> normalStatus = Arrays.asList(OrderStatusConstant.PaidCancel,OrderStatusConstant.Unpaid,OrderStatusConstant.Paid,OrderStatusConstant.production,OrderStatusConstant.productionCompleted,OrderStatusConstant.Taking,OrderStatusConstant.completed);
List<String> cancelStatus = Arrays.asList(OrderStatusConstant.PaidCancel,OrderStatusConstant.UnpaidCancel,OrderStatusConstant.productionCancel,OrderStatusConstant.productionCompletedCancel);
List<String> refundStatus = Arrays.asList(OrderStatusConstant.refunding,OrderStatusConstant.refundFailed,OrderStatusConstant.PartialRefund,OrderStatusConstant.refund);
List<Order> orders = null;
if("1".equals(status)){
orders = orderMapper.selectOrderByUserId(id,normalStatus);
}else if("2".equals(status)){
orders = orderMapper.selectOrderByUserId(id,cancelStatus);
}else{
orders = orderMapper.selectOrderByUserId(id,refundStatus);
}
return orders;
}
/**
......@@ -96,4 +121,12 @@ public class CustomerServiceImpl implements ICustomerService
{
return customerMapper.deleteCustomerById(id);
}
@Override
public Integer allow(String openId, String allow) {
Customer customer = new Customer();
customer.setId(openId);
customer.setAllow(allow);
return customerMapper.updateCustomer(customer);
}
}
......@@ -270,7 +270,7 @@ public class OrderServiceImpl implements IOrderService
return key+String.format("%03d",andIncrement);
}
//获取订单号
private String getOrderNo(Integer source){
public String getOrderNo(Integer source){
String channel = "M";
if(source !=null){
if(source == 1){
......
......@@ -548,7 +548,11 @@ public class SysUserServiceImpl implements ISysUserService
@Override
public List<SysUser> selectUserList(String userInfo, String status) {
List<SysUser> u = userMapper.selectUserByUserInfo(userInfo,status);
return u;
List<SysUser> users = userMapper.selectUserByUserInfo(userInfo,status);
for (SysUser user : users) {
List<SysRole> sysRoles = roleMapper.selectRolesByUserName(user.getUserName());
user.setRoles(sysRoles);
}
return users;
}
}
......@@ -79,6 +79,7 @@ public class WechatMessageServiceImpl implements IWechatMessageService
@Override
public int updateWechatMessage(WechatMessage wechatMessage)
{
wechatMessage.setUpdatedAt(new Date());
return wechatMessageMapper.updateWechatMessage(wechatMessage);
}
......
......@@ -59,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="phone != null">phone = #{phone},</if>
<if test="headSculpturePath != null">head_sculpture_path = #{headSculpturePath},</if>
<if test="soucre != null">soucre = #{soucre},</if>
<if test="allow != null">allow = #{soucre},</if>
</trim>
where id = #{id}
</update>
......@@ -75,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectCustomerByQuery" resultType="com.soss.system.domain.vo.customer.CustomerResultVo">
select * from (select
c.id ,
c.user_name as userName,
c.phone as phoneNumber,
(select count(*) from `order` o where o.user_id = c.id) as orderCount,
......@@ -85,22 +87,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(select sum(o.amount) from `order` o where o.user_id = c.id and o.state in ('12','14','15')) as refundAmount,
(select o.created_at from `order` o where o.user_id = c.id order by o.created_at desc limit 1) as lastOrderDate,
c.create_time as createDate,
c.soucre
c.soucre as source
from
customer c ) a
<where>
<if test="userInfo != null and userInfo != ''">
and ((a.user_name like concat('%', #{userInfo}, '%')) or (a.phone like concat('%', #{userInfo}, '%') ))
and ((a.userName like concat('%', #{userInfo}, '%')) or (a.phoneNumber like concat('%', #{userInfo}, '%') ))
</if>
<if test="buyRecords != null and buyRecords != ''">
and
<if test="buyRecords == '1'">
<if test='buyRecords == "1"'>
a.orderCount >0
</if>
<if test="buyRecords == '2'">
<if test='buyRecords == "2"'>
a.orderCount =0
</if>
<if test="buyRecords == '3'">
<if test='buyRecords == "3"'>
a.orderCount >1
</if>
</if>
......
......@@ -223,4 +223,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateTimeOut">
update `order` set state='5' where state =#{status} and updated_at &lt; DATE_SUB(NOW() ,interval #{timeout} SECOND)
</update>
<select id="selectOrderByUserId" 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
</select>
</mapper>
\ No newline at end of file
......@@ -22,12 +22,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectRoleVo">
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
r.status, r.del_flag, r.create_time, r.remark
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id
left join sys_dept d on u.dept_id = d.dept_id
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
r.status, r.del_flag, r.create_time, r.remark
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id
</sql>
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
......
......@@ -146,7 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_role r on r.role_id = ur.role_id
where u.del_flag='0'
<if test="userInfo != null and userInfo != ''">
and ((u.user_name like concat('%', #{userInfo}, '%')) or (u.phonenumber like concat('%', #{userInfo}, '%') ))
and ((u.nick_name like concat('%', #{userInfo}, '%')) or (u.phonenumber like concat('%', #{userInfo}, '%') ))
</if>
<if test="status != null and status != ''">
AND u.status =#{status}
......
......@@ -82,7 +82,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null and type != ''">type = #{type},</if>
<if test="isRead != null and isRead != ''">is_read = #{isRead},</if>
<if test="isDeleted != null and isDeleted != ''">is_deleted = #{isDeleted},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
</trim>
where id = #{id}
......
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