前端接口
This commit is contained in:
parent
97a10e5cad
commit
820199267f
|
|
@ -0,0 +1,91 @@
|
||||||
|
package com.ruoyi.business.ajax;
|
||||||
|
|
||||||
|
import com.ruoyi.business.domain.BizMember;
|
||||||
|
import com.ruoyi.business.domain.BizMemberAddress;
|
||||||
|
import com.ruoyi.business.domain.BizProduct;
|
||||||
|
import com.ruoyi.business.service.IBizMemberAddressService;
|
||||||
|
import com.ruoyi.business.service.IBizMemberService;
|
||||||
|
import com.ruoyi.business.service.IBizProductService;
|
||||||
|
import com.ruoyi.business.service.IBizProductTypeService;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ajax/member")
|
||||||
|
public class AjaxMemberController extends AuthController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBizMemberService bizMemberService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBizMemberAddressService bizMemberAddressService;
|
||||||
|
|
||||||
|
//个人中心
|
||||||
|
@PostMapping("/center")
|
||||||
|
public AjaxResult center()
|
||||||
|
{
|
||||||
|
Long userID = getUserID();
|
||||||
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
|
BizMember member = bizMemberService.selectBizMemberById(userID);
|
||||||
|
resultMap.put("name", member.getMemberName());
|
||||||
|
resultMap.put("mobile", member.getMobile());
|
||||||
|
resultMap.put("douBalance", member.getDouBalance());
|
||||||
|
resultMap.put("douPerson", member.getDouPerson());
|
||||||
|
resultMap.put("douTeam", member.getDouTeam());
|
||||||
|
resultMap.put("douField", member.getDouField());
|
||||||
|
return AjaxResult.success(resultMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
//读取我的地址列表
|
||||||
|
@PostMapping("/addressList")
|
||||||
|
public AjaxResult addressList()
|
||||||
|
{
|
||||||
|
Long userID = getUserID();
|
||||||
|
return AjaxResult.success(bizMemberAddressService.selectBizMemberAddressList(userID));
|
||||||
|
}
|
||||||
|
|
||||||
|
//我的地址详细
|
||||||
|
@PostMapping("/addressDetail")
|
||||||
|
public AjaxResult addressDetail(Long addressID)
|
||||||
|
{
|
||||||
|
Long userID = getUserID();
|
||||||
|
BizMemberAddress address = bizMemberAddressService.selectBizMemberAddressById(addressID);
|
||||||
|
if (address == null || address.getMemberID() != userID) {
|
||||||
|
return AjaxResult.error("操作有误请重试");
|
||||||
|
}
|
||||||
|
return AjaxResult.success(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
//编辑我的地址
|
||||||
|
@PostMapping("/addressEdit")
|
||||||
|
public AjaxResult addressDetail(BizMemberAddress bizMemberAddress)
|
||||||
|
{
|
||||||
|
Long userID = getUserID();
|
||||||
|
BizMemberAddress address = bizMemberAddressService.selectBizMemberAddressById(bizMemberAddress.getId());
|
||||||
|
if (address == null || address.getMemberID() != userID) {
|
||||||
|
return AjaxResult.error("操作有误请重试");
|
||||||
|
}
|
||||||
|
return AjaxResult.success(bizMemberAddressService.updateBizMemberAddress(bizMemberAddress));
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除我的地址
|
||||||
|
@PostMapping("/addressDelete")
|
||||||
|
public AjaxResult addressDelete(Long addressID)
|
||||||
|
{
|
||||||
|
Long userID = getUserID();
|
||||||
|
BizMemberAddress address = bizMemberAddressService.selectBizMemberAddressById(addressID);
|
||||||
|
if (address == null || address.getMemberID() != userID) {
|
||||||
|
return AjaxResult.error("操作有误请重试");
|
||||||
|
}
|
||||||
|
if (bizMemberAddressService.selectBizMemberAddressList(userID).size() <= 1) {
|
||||||
|
return AjaxResult.error("不能删除默认收货地址");
|
||||||
|
}
|
||||||
|
return AjaxResult.success(bizMemberAddressService.deleteBizMemberAddressById(addressID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
package com.ruoyi.business.ajax;
|
||||||
|
|
||||||
|
import com.ruoyi.business.domain.BizMember;
|
||||||
|
import com.ruoyi.business.domain.BizMemberAddress;
|
||||||
|
import com.ruoyi.business.domain.BizOrder;
|
||||||
|
import com.ruoyi.business.domain.BizProduct;
|
||||||
|
import com.ruoyi.business.service.*;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ajax/order")
|
||||||
|
public class AjaxOrderController extends AuthController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBizOrderService bizOrderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBizProductService bizProductService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBizMemberService bizMemberService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBizMemberAddressService bizMemberAddressService;
|
||||||
|
|
||||||
|
|
||||||
|
//我的订单(status-1取全部订单)
|
||||||
|
@PostMapping("/orderList")
|
||||||
|
public AjaxResult orderList(Integer status)
|
||||||
|
{
|
||||||
|
Long userID = getUserID();
|
||||||
|
BizOrder order = new BizOrder();
|
||||||
|
order.setMemberId(userID);
|
||||||
|
order.setOrderStatus(status);
|
||||||
|
return AjaxResult.success(bizOrderService.selectBizOrderList(order));
|
||||||
|
}
|
||||||
|
|
||||||
|
//我的订单详情
|
||||||
|
@PostMapping("/orderDetail")
|
||||||
|
public AjaxResult orderDetail(Long orderID)
|
||||||
|
{
|
||||||
|
Long userID = getUserID();
|
||||||
|
BizOrder order = bizOrderService.selectBizOrderById(orderID);
|
||||||
|
if (order == null || userID != order.getMemberId()) {
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
return AjaxResult.success(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
//订单结账
|
||||||
|
@PostMapping("/orderConclude")
|
||||||
|
public AjaxResult orderConclude(Long productID, Integer productNum)
|
||||||
|
{
|
||||||
|
Long userID = getUserID();
|
||||||
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
|
//取出福豆余额
|
||||||
|
resultMap.put("douBalance", bizMemberService.selectBizMemberDou(userID, BizMember.DOU_BALANCE));
|
||||||
|
//取出默认地址
|
||||||
|
BizMemberAddress defaultAddress = bizMemberAddressService.selectDefaultAddressByMemberId(userID);
|
||||||
|
resultMap.put("defaultAddress", defaultAddress);
|
||||||
|
//取出商品
|
||||||
|
BizProduct product = bizProductService.selectBizProductById(productID);
|
||||||
|
if (product == null || product.getOnlineStatus() == 0) { //检测上架
|
||||||
|
return AjaxResult.error("该商品不存在");
|
||||||
|
}
|
||||||
|
resultMap.put("productName", product.getProductName());
|
||||||
|
resultMap.put("productNum", productNum);
|
||||||
|
resultMap.put("productPrice", product.getAmount());
|
||||||
|
resultMap.put("orderPrice", product.getAmount() * productNum);
|
||||||
|
return AjaxResult.success(resultMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
//下订单
|
||||||
|
@PostMapping("/orderAdd")
|
||||||
|
public AjaxResult orderAdd(Long productID, Integer productNum, Long addressID, String remark)
|
||||||
|
{
|
||||||
|
Long userID = getUserID();
|
||||||
|
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
package com.ruoyi.business.ajax;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.ExcelReader;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.ruoyi.business.domain.BizProduct;
|
||||||
|
import com.ruoyi.business.domain.BizProductType;
|
||||||
|
import com.ruoyi.business.mapper.BizAccountMapper;
|
||||||
|
import com.ruoyi.business.mapper.BizMemberMapper;
|
||||||
|
import com.ruoyi.business.service.IBizProductService;
|
||||||
|
import com.ruoyi.business.service.IBizProductTypeService;
|
||||||
|
import com.ruoyi.business.sync.UserData;
|
||||||
|
import com.ruoyi.business.sync.UserDataListener;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ajax/product")
|
||||||
|
public class AjaxProductController extends AuthController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBizProductService bizProductService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBizProductTypeService bizProductTypeService;
|
||||||
|
|
||||||
|
//分类和推荐商品
|
||||||
|
@PostMapping("/center")
|
||||||
|
public AjaxResult center()
|
||||||
|
{
|
||||||
|
PageHelper.startPage(1, 10);
|
||||||
|
//首页分类
|
||||||
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
|
BizProductType productType = new BizProductType();
|
||||||
|
productType.setIsEnable(1);
|
||||||
|
resultMap.put("typeList", bizProductTypeService.selectBizProductTypeList(productType));
|
||||||
|
|
||||||
|
//首页商品
|
||||||
|
BizProduct product = new BizProduct();
|
||||||
|
product.setOnlineStatus(1);
|
||||||
|
resultMap.put("productList", getSimpleProductList(bizProductService.selectBizProductList(product)));
|
||||||
|
return AjaxResult.success(resultMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
//产品列表
|
||||||
|
@PostMapping("/list")
|
||||||
|
public AjaxResult list(Long typeID)
|
||||||
|
{
|
||||||
|
PageHelper.startPage(1, 20);
|
||||||
|
|
||||||
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
|
BizProductType productType = new BizProductType();
|
||||||
|
productType.setIsEnable(1);
|
||||||
|
resultMap.put("typeList", bizProductTypeService.selectBizProductTypeList(productType));
|
||||||
|
|
||||||
|
BizProduct product = new BizProduct();
|
||||||
|
product.setOnlineStatus(1);
|
||||||
|
product.setProductTypeId(typeID);
|
||||||
|
resultMap.put("productList", getSimpleProductList(bizProductService.selectBizProductList(product)));
|
||||||
|
resultMap.put("typeID", typeID);
|
||||||
|
return AjaxResult.success(resultMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
//读取产品
|
||||||
|
@PostMapping("/load")
|
||||||
|
public AjaxResult load(Long productId)
|
||||||
|
{
|
||||||
|
BizProduct bizProduct = bizProductService.selectBizProductById(productId);
|
||||||
|
return AjaxResult.success(bizProduct);
|
||||||
|
}
|
||||||
|
|
||||||
|
//简易商品列表
|
||||||
|
private List<Map> getSimpleProductList(List<BizProduct> productList)
|
||||||
|
{
|
||||||
|
List<Map> resultList = new ArrayList<Map>();
|
||||||
|
for (BizProduct bizProduct : productList) {
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("name", bizProduct.getProductName());
|
||||||
|
map.put("mainImage", bizProduct.getMainImage());
|
||||||
|
map.put("price", bizProduct.getAmount());
|
||||||
|
resultList.add(map);
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.ruoyi.business.ajax;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
|
||||||
|
public class AuthController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
//获取前端登录用户ID
|
||||||
|
public Long getUserID()
|
||||||
|
{
|
||||||
|
return 1L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,6 +15,12 @@ public class BizMember extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//用户豆账户(0-福豆余额,1-个人福豆,2-团队福豆, 3-福豆田)
|
||||||
|
public static final int DOU_BALANCE = 0;
|
||||||
|
public static final int DOU_PERSON = 1;
|
||||||
|
public static final int DOU_TEAM = 2;
|
||||||
|
public static final int DOU_FIELD = 3;
|
||||||
|
|
||||||
/** 会员ID */
|
/** 会员ID */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.ruoyi.business.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.business.domain.BizMemberAddress;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员收货地址Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2020-09-17
|
||||||
|
*/
|
||||||
|
public interface BizMemberAddressMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询会员收货地址
|
||||||
|
*
|
||||||
|
* @param id 会员收货地址ID
|
||||||
|
* @return 会员收货地址
|
||||||
|
*/
|
||||||
|
public BizMemberAddress selectBizMemberAddressById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员默认收货地址
|
||||||
|
*
|
||||||
|
* @param memberID 会员ID
|
||||||
|
* @return 会员收货地址
|
||||||
|
*/
|
||||||
|
public BizMemberAddress selectDefaultAddressByMemberId(Long memberID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消默认收货地址
|
||||||
|
*
|
||||||
|
* @param memberID 会员ID
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public int cancelDefaultAddress(Long memberID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员收货地址列表
|
||||||
|
*
|
||||||
|
* @param memberID 会员ID
|
||||||
|
* @return 会员收货地址集合
|
||||||
|
*/
|
||||||
|
public List<BizMemberAddress> selectBizMemberAddressList(Long memberID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增会员收货地址
|
||||||
|
*
|
||||||
|
* @param bizMemberAddress 会员收货地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertBizMemberAddress(BizMemberAddress bizMemberAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改会员收货地址
|
||||||
|
*
|
||||||
|
* @param bizMemberAddress 会员收货地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateBizMemberAddress(BizMemberAddress bizMemberAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除会员收货地址
|
||||||
|
*
|
||||||
|
* @param id 会员收货地址ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteBizMemberAddressById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除会员收货地址
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteBizMemberAddressByIds(String[] ids);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.business.mapper;
|
package com.ruoyi.business.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ruoyi.business.domain.BizMember;
|
import com.ruoyi.business.domain.BizMember;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -35,6 +37,14 @@ public interface BizMemberMapper
|
||||||
*/
|
*/
|
||||||
public List<BizMember> selectBizMemberList(BizMember bizMember);
|
public List<BizMember> selectBizMemberList(BizMember bizMember);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员福豆余额
|
||||||
|
*
|
||||||
|
* @param map
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public Long selectBizMemberDou(Map map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增会员
|
* 新增会员
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.ruoyi.business.service;
|
||||||
|
|
||||||
|
import com.ruoyi.business.domain.BizMemberAddress;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员收货地址Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2020-09-17
|
||||||
|
*/
|
||||||
|
public interface IBizMemberAddressService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询会员收货地址
|
||||||
|
*
|
||||||
|
* @param id 会员收货地址ID
|
||||||
|
* @return 会员收货地址
|
||||||
|
*/
|
||||||
|
public BizMemberAddress selectBizMemberAddressById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员默认收货地址
|
||||||
|
*
|
||||||
|
* @param memberID 会员ID
|
||||||
|
* @return 会员收货地址
|
||||||
|
*/
|
||||||
|
public BizMemberAddress selectDefaultAddressByMemberId(Long memberID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消默认收货地址
|
||||||
|
*
|
||||||
|
* @param memberID 会员ID
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public int cancelDefaultAddress(Long memberID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员收货地址列表
|
||||||
|
*
|
||||||
|
* @param memberID 会员ID
|
||||||
|
* @return 会员收货地址集合
|
||||||
|
*/
|
||||||
|
public List<BizMemberAddress> selectBizMemberAddressList(Long memberID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增会员收货地址
|
||||||
|
*
|
||||||
|
* @param bizMemberAddress 会员收货地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertBizMemberAddress(BizMemberAddress bizMemberAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改会员收货地址
|
||||||
|
*
|
||||||
|
* @param bizMemberAddress 会员收货地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateBizMemberAddress(BizMemberAddress bizMemberAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除会员收货地址
|
||||||
|
*
|
||||||
|
* @param id 会员收货地址ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteBizMemberAddressById(Long id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.business.service;
|
package com.ruoyi.business.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ruoyi.business.domain.BizMember;
|
import com.ruoyi.business.domain.BizMember;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -35,6 +37,14 @@ public interface IBizMemberService
|
||||||
*/
|
*/
|
||||||
public List<BizMember> selectBizMemberList(BizMember bizMember);
|
public List<BizMember> selectBizMemberList(BizMember bizMember);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员福豆余额
|
||||||
|
*
|
||||||
|
* @param memberID type
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public Long selectBizMemberDou(Long memberID, int type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增会员
|
* 新增会员
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
package com.ruoyi.business.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.business.domain.BizMemberAddress;
|
||||||
|
import com.ruoyi.business.mapper.BizMemberAddressMapper;
|
||||||
|
import com.ruoyi.business.service.IBizMemberAddressService;
|
||||||
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
/**
|
||||||
|
* 会员收货地址Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2020-09-17
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BizMemberAddressServiceImpl implements IBizMemberAddressService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private BizMemberAddressMapper bizMemberAddressMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员收货地址
|
||||||
|
*
|
||||||
|
* @param id 会员收货地址ID
|
||||||
|
* @return 会员收货地址
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BizMemberAddress selectBizMemberAddressById(Long id)
|
||||||
|
{
|
||||||
|
return bizMemberAddressMapper.selectBizMemberAddressById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员默认收货地址
|
||||||
|
*
|
||||||
|
* @param memberID 会员ID
|
||||||
|
* @return 会员收货地址
|
||||||
|
*/
|
||||||
|
public BizMemberAddress selectDefaultAddressByMemberId(Long memberID)
|
||||||
|
{
|
||||||
|
return bizMemberAddressMapper.selectDefaultAddressByMemberId(memberID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消默认收货地址
|
||||||
|
*
|
||||||
|
* @param memberID 会员ID
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public int cancelDefaultAddress(Long memberID)
|
||||||
|
{
|
||||||
|
return bizMemberAddressMapper.cancelDefaultAddress(memberID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询会员收货地址列表
|
||||||
|
*
|
||||||
|
* @param memberID 会员ID
|
||||||
|
* @return 会员收货地址
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BizMemberAddress> selectBizMemberAddressList(Long memberID)
|
||||||
|
{
|
||||||
|
return bizMemberAddressMapper.selectBizMemberAddressList(memberID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增会员收货地址
|
||||||
|
*
|
||||||
|
* @param bizMemberAddress 会员收货地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertBizMemberAddress(BizMemberAddress bizMemberAddress)
|
||||||
|
{
|
||||||
|
bizMemberAddress.setCreateTime(DateUtils.getNowDate());
|
||||||
|
if (bizMemberAddress.getIsDelete() == 1) { //默认收货地址
|
||||||
|
bizMemberAddressMapper.cancelDefaultAddress(bizMemberAddress.getMemberID());
|
||||||
|
}
|
||||||
|
return bizMemberAddressMapper.insertBizMemberAddress(bizMemberAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改会员收货地址
|
||||||
|
*
|
||||||
|
* @param bizMemberAddress 会员收货地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateBizMemberAddress(BizMemberAddress bizMemberAddress)
|
||||||
|
{
|
||||||
|
bizMemberAddress.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
if (bizMemberAddress.getIsDelete() == 1) { //默认收货地址
|
||||||
|
bizMemberAddressMapper.cancelDefaultAddress(bizMemberAddress.getMemberID());
|
||||||
|
}
|
||||||
|
return bizMemberAddressMapper.updateBizMemberAddress(bizMemberAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除会员收货地址信息
|
||||||
|
*
|
||||||
|
* @param id 会员收货地址ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteBizMemberAddressById(Long id)
|
||||||
|
{
|
||||||
|
return bizMemberAddressMapper.deleteBizMemberAddressById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package com.ruoyi.business.service.impl;
|
package com.ruoyi.business.service.impl;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -57,6 +60,20 @@ public class BizMemberServiceImpl implements IBizMemberService
|
||||||
return bizMemberMapper.selectBizMemberList(bizMember);
|
return bizMemberMapper.selectBizMemberList(bizMember);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员福豆余额
|
||||||
|
*
|
||||||
|
* @param memberID type
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public Long selectBizMemberDou(Long memberID, int type)
|
||||||
|
{
|
||||||
|
Map map = new HashMap<>();
|
||||||
|
map.put("memberID", memberID);
|
||||||
|
map.put("type", type);
|
||||||
|
return bizMemberMapper.selectBizMemberDou(map);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增会员
|
* 新增会员
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.business.mapper.BizMemberAddressMapper">
|
||||||
|
|
||||||
|
<resultMap type="BizMemberAddress" id="BizMemberAddressResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="mobile" column="mobile" />
|
||||||
|
<result property="memberID" column="member_id" />
|
||||||
|
<result property="memberName" column="member_name" />
|
||||||
|
<result property="address" column="address" />
|
||||||
|
<result property="provinceCode" column="province_code" />
|
||||||
|
<result property="provinceName" column="province_name" />
|
||||||
|
<result property="cityCode" column="city_code" />
|
||||||
|
<result property="cityName" column="city_name" />
|
||||||
|
<result property="areaCode" column="area_code" />
|
||||||
|
<result property="areaName" column="area_name" />
|
||||||
|
<result property="isDelete" column="is_delete" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectBizMemberAddressVo">
|
||||||
|
select id, mobile, member_id, member_name, address, province_code, province_name, city_code, city_name, area_code, area_name, is_delete, create_by, create_time, update_by, update_time from biz_member_address
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectBizMemberAddressList" parameterType="Long" resultMap="BizMemberAddressResult">
|
||||||
|
<include refid="selectBizMemberAddressVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="memberID != null"> and member_id = #{memberID}</if>
|
||||||
|
</where>
|
||||||
|
order by id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectBizMemberAddressById" parameterType="Long" resultMap="BizMemberAddressResult">
|
||||||
|
<include refid="selectBizMemberAddressVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDefaultAddressByMemberId" parameterType="Long" resultMap="BizMemberAddressResult">
|
||||||
|
<include refid="selectBizMemberAddressVo"/>
|
||||||
|
where member_id = #{memberID}
|
||||||
|
order by is_delete desc, id limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="cancelDefaultAddress" parameterType="Long">
|
||||||
|
update biz_member_address
|
||||||
|
set is_delete = 0 where member_id = #{memberID}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<insert id="insertBizMemberAddress" parameterType="BizMemberAddress" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into biz_member_address
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="mobile != null and mobile != ''">mobile,</if>
|
||||||
|
<if test="memberID != null">member_id,</if>
|
||||||
|
<if test="memberName != null and memberName != ''">member_name,</if>
|
||||||
|
<if test="address != null and address != ''">address,</if>
|
||||||
|
<if test="provinceCode != null and provinceCode != ''">province_code,</if>
|
||||||
|
<if test="provinceName != null and provinceName != ''">province_name,</if>
|
||||||
|
<if test="cityCode != null and cityCode != ''">city_code,</if>
|
||||||
|
<if test="cityName != null and cityName != ''">city_name,</if>
|
||||||
|
<if test="areaCode != null and areaCode != ''">area_code,</if>
|
||||||
|
<if test="areaName != null and areaName != ''">area_name,</if>
|
||||||
|
<if test="isDelete != null">is_delete,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="mobile != null and mobile != ''">#{mobile},</if>
|
||||||
|
<if test="memberID != null">#{memberID},</if>
|
||||||
|
<if test="memberName != null and memberName != ''">#{memberName},</if>
|
||||||
|
<if test="address != null and address != ''">#{address},</if>
|
||||||
|
<if test="provinceCode != null and provinceCode != ''">#{provinceCode},</if>
|
||||||
|
<if test="provinceName != null and provinceName != ''">#{provinceName},</if>
|
||||||
|
<if test="cityCode != null and cityCode != ''">#{cityCode},</if>
|
||||||
|
<if test="cityName != null and cityName != ''">#{cityName},</if>
|
||||||
|
<if test="areaCode != null and areaCode != ''">#{areaCode},</if>
|
||||||
|
<if test="areaName != null and areaName != ''">#{areaName},</if>
|
||||||
|
<if test="isDelete != null">#{isDelete},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateBizMemberAddress" parameterType="BizMemberAddress">
|
||||||
|
update biz_member_address
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
|
||||||
|
<if test="memberName != null and memberName != ''">member_name = #{memberName},</if>
|
||||||
|
<if test="address != null and address != ''">address = #{address},</if>
|
||||||
|
<if test="provinceCode != null and provinceCode != ''">province_code = #{provinceCode},</if>
|
||||||
|
<if test="provinceName != null and provinceName != ''">province_name = #{provinceName},</if>
|
||||||
|
<if test="cityCode != null and cityCode != ''">city_code = #{cityCode},</if>
|
||||||
|
<if test="cityName != null and cityName != ''">city_name = #{cityName},</if>
|
||||||
|
<if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
|
||||||
|
<if test="areaName != null and areaName != ''">area_name = #{areaName},</if>
|
||||||
|
<if test="isDelete != null">is_delete = #{isDelete},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteBizMemberAddressById" parameterType="Long">
|
||||||
|
delete from biz_member_address where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteBizMemberAddressByIds" parameterType="String">
|
||||||
|
delete from biz_member_address where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -44,6 +44,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where a.id = #{id}
|
where a.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectBizMemberDou" parameterType="java.util.Map" resultType="Long">
|
||||||
|
select amount from biz_account where member_id = #{memberID} and account_type = #{type}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectBizMemberSimple" parameterType="Long" resultMap="BizMemberResult">
|
<select id="selectBizMemberSimple" parameterType="Long" resultMap="BizMemberResult">
|
||||||
select a.id, mobile, member_name, recommend_id, recommend_mobile, recommend_name, member_type, is_delete, is_enable, create_by, create_time, update_by, update_time,
|
select a.id, mobile, member_name, recommend_id, recommend_mobile, recommend_name, member_type, is_delete, is_enable, create_by, create_time, update_by, update_time,
|
||||||
where a.id = #{id}
|
where a.id = #{id}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<select id="selectBizOrderList" parameterType="BizOrder" resultMap="BizOrderResult">
|
<select id="selectBizOrderList" parameterType="BizOrder" resultMap="BizOrderResult">
|
||||||
<include refid="selectBizOrderVo"/>
|
<include refid="selectBizOrderVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="memberName != null and memberName != ''"> and (a.member_name like concat('%', #{memberName}, '%') or a.mobile like concat('%', #{memberName}, '%'))</if>
|
<if test="memberName != null and memberName != ''"> and (a.member_name like concat('%', #{memberName}, '%') or a.mobile like concat('%', #{memberName}, '%'))</if>
|
||||||
|
<if test="memberId != null"> and a.member_id = #{memberId}</if>
|
||||||
|
<if test="orderStatus != null and orderStatus != -1"> and a.order_status = #{orderStatus}</if>
|
||||||
</where>
|
</where>
|
||||||
order by a.id desc
|
order by a.id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue