123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- package com.qxgmat.service.inline;
- import com.github.pagehelper.Page;
- import com.nuliji.tools.AbstractService;
- import com.nuliji.tools.Tools;
- import com.nuliji.tools.Transform;
- import com.nuliji.tools.exception.ParameterException;
- import com.nuliji.tools.exception.SystemException;
- import com.nuliji.tools.mybatis.Example;
- import com.qxgmat.data.constants.enums.ServiceKey;
- import com.qxgmat.data.constants.enums.module.CourseModule;
- import com.qxgmat.data.constants.enums.module.ProductType;
- import com.qxgmat.data.constants.enums.status.DirectionStatus;
- import com.qxgmat.data.dao.UserOrderCheckoutMapper;
- import com.qxgmat.data.dao.UserOrderRecordMapper;
- import com.qxgmat.data.dao.entity.UserOrder;
- import com.qxgmat.data.dao.entity.UserOrderCheckout;
- import com.qxgmat.data.dao.entity.UserOrderRecord;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.Collection;
- import java.util.Date;
- import java.util.List;
- @Service
- public class UserOrderCheckoutService extends AbstractService {
- private static final Logger logger = LoggerFactory.getLogger(UserOrderCheckoutService.class);
- @Resource
- private UserOrderCheckoutMapper userOrderCheckoutMapper;
- public List<UserOrderCheckout> allByUser(Integer userId, Integer orderId){
- Example example = new Example(UserOrderCheckout.class);
- example.and(
- example.createCriteria()
- .andEqualTo("userId", userId)
- .andEqualTo("orderId", orderId)
- );
- return select(userOrderCheckoutMapper, example);
- }
- /**
- * 列出对应类型的购物信息
- * @param userId
- * @param productType
- * @param productIds
- * @return
- */
- public List<UserOrderCheckout> listWithProduct(Integer userId, ProductType productType, Collection productIds){
- Example example = new Example(UserOrderCheckout.class);
- example.and(
- example.createCriteria()
- .andEqualTo("orderId", 0)
- .andEqualTo("userId", userId)
- .andEqualTo("productType", productType.key)
- .andIn("productId", productIds)
- );
- return select(userOrderCheckoutMapper, example);
- }
- public UserOrderCheckout getWithProduct(Integer userId, ProductType productType, Integer productId){
- Example example = new Example(UserOrderCheckout.class);
- example.and(
- example.createCriteria()
- .andEqualTo("orderId", 0)
- .andEqualTo("userId", userId)
- .andEqualTo("productType", productType.key)
- .andEqualTo("productId", productId)
- );
- return one(userOrderCheckoutMapper, example);
- }
- public boolean changeByUser(Integer userId, Integer orderId, UserOrderCheckout checkout){
- Example example = new Example(UserOrderCheckout.class);
- example.and(
- example.createCriteria()
- .andEqualTo("userId", userId)
- .andEqualTo("orderId", orderId)
- );
- return update(userOrderCheckoutMapper, example, checkout) > 0;
- }
- public boolean deleteByUser(Integer userId, Integer orderId){
- Example example = new Example(UserOrderCheckout.class);
- example.and(
- example.createCriteria()
- .andEqualTo("userId", userId)
- .andEqualTo("orderId", orderId)
- );
- return delete(userOrderCheckoutMapper, example) > 0;
- }
- public UserOrderCheckout add(UserOrderCheckout record){
- int result = insert(userOrderCheckoutMapper, record);
- record = one(userOrderCheckoutMapper, record.getId());
- if(record == null){
- throw new SystemException("服务记录添加失败");
- }
- return record;
- }
- public UserOrderCheckout edit(UserOrderCheckout service){
- UserOrderCheckout in = one(userOrderCheckoutMapper, service.getId());
- if(in == null){
- throw new ParameterException("服务记录不存在");
- }
- int result = update(userOrderCheckoutMapper, service);
- return service;
- }
- public boolean delete(Number id){
- UserOrderCheckout in = one(userOrderCheckoutMapper, id);
- if(in == null){
- throw new ParameterException("服务记录不存在");
- }
- int result = delete(userOrderCheckoutMapper, id);
- return result > 0;
- }
- public UserOrderCheckout get(Number id){
- UserOrderCheckout in = one(userOrderCheckoutMapper, id);
- if(in == null){
- throw new ParameterException("服务记录不存在");
- }
- return in;
- }
- public Page<UserOrderCheckout> select(int page, int pageSize){
- return select(userOrderCheckoutMapper, page, pageSize);
- }
- public Page<UserOrderCheckout> select(Integer[] ids){
- return page(()->select(userOrderCheckoutMapper, ids), 1, ids.length);
- }
- public List<UserOrderCheckout> select(Collection ids){
- return select(userOrderCheckoutMapper, ids);
- }
- }
|