订单接口

This commit is contained in:
Administrator 2020-09-17 19:36:37 +08:00
parent 820199267f
commit d7f5bedbb0
22 changed files with 704 additions and 21 deletions

View File

@ -38,6 +38,7 @@ public class AjaxMemberController extends AuthController {
resultMap.put("douBalance", member.getDouBalance()); resultMap.put("douBalance", member.getDouBalance());
resultMap.put("douPerson", member.getDouPerson()); resultMap.put("douPerson", member.getDouPerson());
resultMap.put("douTeam", member.getDouTeam()); resultMap.put("douTeam", member.getDouTeam());
resultMap.put("douSpecial", member.getDouSpecial());
resultMap.put("douField", member.getDouField()); resultMap.put("douField", member.getDouField());
return AjaxResult.success(resultMap); return AjaxResult.success(resultMap);
} }

View File

@ -1,9 +1,6 @@
package com.ruoyi.business.ajax; package com.ruoyi.business.ajax;
import com.ruoyi.business.domain.BizMember; import com.ruoyi.business.domain.*;
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.business.service.*;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -62,7 +59,7 @@ public class AjaxOrderController extends AuthController {
Long userID = getUserID(); Long userID = getUserID();
Map<String, Object> resultMap = new HashMap<String, Object>(); Map<String, Object> resultMap = new HashMap<String, Object>();
//取出福豆余额 //取出福豆余额
resultMap.put("douBalance", bizMemberService.selectBizMemberDou(userID, BizMember.DOU_BALANCE)); resultMap.put("douBalance", bizMemberService.selectBizMemberDou(userID, BizAccount.DOU_BALANCE));
//取出默认地址 //取出默认地址
BizMemberAddress defaultAddress = bizMemberAddressService.selectDefaultAddressByMemberId(userID); BizMemberAddress defaultAddress = bizMemberAddressService.selectDefaultAddressByMemberId(userID);
resultMap.put("defaultAddress", defaultAddress); resultMap.put("defaultAddress", defaultAddress);
@ -84,7 +81,25 @@ public class AjaxOrderController extends AuthController {
{ {
Long userID = getUserID(); Long userID = getUserID();
return bizOrderService.orderAdd(userID, productID, productNum, addressID, remark);
}
return AjaxResult.success(); //取消订单
@PostMapping("/orderCancel")
public AjaxResult orderCancel(Long orderID)
{
Long userID = getUserID();
//TODO 取消订单延后(专项划拨处理??)
return bizOrderService.orderConfirm(userID, orderID);
}
//订单收货
@PostMapping("/orderConfirm")
public AjaxResult orderConfirm(Long orderID)
{
Long userID = getUserID();
return bizOrderService.orderConfirm(userID, orderID);
} }
} }

View File

@ -100,7 +100,7 @@ public class BizProductController extends BaseController
Date now = new Date(); Date now = new Date();
bizProduct.setCreateBy(ShiroUtils.getLoginName()); bizProduct.setCreateBy(ShiroUtils.getLoginName());
bizProduct.setCreateTime(now); bizProduct.setCreateTime(now);
bizProduct.setProductCode("BPD" + DateUtils.dateTimeNow("YYYYMMDDHHMMSSSSS")); bizProduct.setProductCode("BPD" + DateUtils.getMilliTime());
//如果上架设置上架时间 //如果上架设置上架时间
if (bizProduct.getOnlineStatus() == 1) { if (bizProduct.getOnlineStatus() == 1) {
bizProduct.setOnlineTime(now); bizProduct.setOnlineTime(now);

View File

@ -92,7 +92,7 @@ public class BizProductTypeController extends BaseController
{ {
bizProductType.setCreateBy(ShiroUtils.getLoginName()); bizProductType.setCreateBy(ShiroUtils.getLoginName());
bizProductType.setCreateTime(new Date()); bizProductType.setCreateTime(new Date());
bizProductType.setProductTypeCode("BPT" + DateUtils.dateTimeNow("YYYYMMDDHHMMSSSSS")); bizProductType.setProductTypeCode("BPT" + DateUtils.getMilliTime());
return toAjax(bizProductTypeService.insertBizProductType(bizProductType)); return toAjax(bizProductTypeService.insertBizProductType(bizProductType));
} }

View File

@ -16,6 +16,13 @@ public class BizAccount 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_SPECIAL = 3;
public static final int DOU_FIELD = 4;
/** 会员账户ID */ /** 会员账户ID */
private Long id; private Long id;
@ -58,12 +65,12 @@ public class BizAccount extends BaseEntity
{ {
return accountType; return accountType;
} }
public void setAmount(BigDecimal amount) public void setAmount(BigDecimal amount)
{ {
this.amount = amount; this.amount = amount;
} }
public BigDecimal getAmount() public BigDecimal getAmount()
{ {
return amount; return amount;
} }

View File

@ -0,0 +1,185 @@
package com.ruoyi.business.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
/**
* 会员账户明细对象 biz_account_detail
*
* @author ruoyi
* @date 2020-09-17
*/
public class BizAccountDetail extends BaseEntity
{
private static final long serialVersionUID = 1L;
//福豆改变类型
public static final int DOU_CHANGE_TYPE_ADD = 1;
public static final int DOU_CHANGE_TYPE_REDUSE = -1;
//福豆使用类型
public static final int DOU_DETAIL_TYPE_CHARGE = 1;
public static final int DOU_DETAIL_TYPE_DRAW = 2;
public static final int DOU_DETAIL_TYPE_EXCHANGE = 3;
public static final int DOU_DETAIL_TYPE_RESET = 4;
public static final int DOU_DETAIL_TYPE_ORDER = 5;
//福豆使用备注
public static final String DOU_DESC_RECOMM = "直推奖励";
public static final String DOU_DESC_SECOND = "二级推荐奖励";
public static final String DOU_DESC_TEAM = "团队奖励";
public static final String DOU_DESC_SPECIAL1 = "专项账户充值";
public static final String DOU_DESC_SPECIAL2 = "专项划拨";
public static final String DOU_DESC_ORDER = "订单消费";
/** 会员账户明细ID */
private Long id;
/** 会员ID */
@Excel(name = "会员ID")
private Long memberId;
/** 会员账户ID */
@Excel(name = "会员账户ID")
private Long accountId;
/** 账户类型0-福豆余额1-个人福豆2-团队福豆3-专项福豆4-福豆田 */
@Excel(name = "账户类型0-福豆余额1-个人福豆2-团队福豆3-专项福豆4-福豆田")
private Integer accountType;
/** 业务订单编号: 三方支付/兑现申请/团队明细 */
@Excel(name = "业务订单编号: 三方支付/兑现申请/团队明细")
private String businessNo;
/** 变更类型1:收入(加)-1:支出(减) */
@Excel(name = "变更类型1:收入(加)-1:支出(减)")
private Integer changeType;
/** 变动详情.1充值2:提现3:转账4:冲正5:支付 */
@Excel(name = "变动详情.1充值2:提现3:转账4:冲正5:支付")
private Integer typeDetail;
/** 账户变更前金额 */
@Excel(name = "账户变更前金额")
private Long beforeAmount;
/** 账户变更后金额 */
@Excel(name = "账户变更后金额")
private Long afterAmount;
/** 交易备注:充值【一级推荐奖励】,充值【二级推荐奖励】,充值【团队奖励】,充值【专项划拨】,转账【专项划拨】 */
@Excel(name = "交易备注:充值【一级推荐奖励】,充值【二级推荐奖励】,充值【团队奖励】,充值【专项划拨】,转账【专项划拨】")
private String changeDesc;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setMemberId(Long memberId)
{
this.memberId = memberId;
}
public Long getMemberId()
{
return memberId;
}
public void setAccountId(Long accountId)
{
this.accountId = accountId;
}
public Long getAccountId()
{
return accountId;
}
public void setAccountType(Integer accountType)
{
this.accountType = accountType;
}
public Integer getAccountType()
{
return accountType;
}
public void setBusinessNo(String businessNo)
{
this.businessNo = businessNo;
}
public String getBusinessNo()
{
return businessNo;
}
public void setChangeType(Integer changeType)
{
this.changeType = changeType;
}
public Integer getChangeType()
{
return changeType;
}
public void setTypeDetail(Integer typeDetail)
{
this.typeDetail = typeDetail;
}
public Integer getTypeDetail()
{
return typeDetail;
}
public void setBeforeAmount(Long beforeAmount)
{
this.beforeAmount = beforeAmount;
}
public Long getBeforeAmount()
{
return beforeAmount;
}
public void setAfterAmount(Long afterAmount)
{
this.afterAmount = afterAmount;
}
public Long getAfterAmount()
{
return afterAmount;
}
public void setChangeDesc(String changeDesc)
{
this.changeDesc = changeDesc;
}
public String getChangeDesc()
{
return changeDesc;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("memberId", getMemberId())
.append("accountId", getAccountId())
.append("accountType", getAccountType())
.append("businessNo", getBusinessNo())
.append("changeType", getChangeType())
.append("typeDetail", getTypeDetail())
.append("beforeAmount", getBeforeAmount())
.append("afterAmount", getAfterAmount())
.append("changeDesc", getChangeDesc())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -15,12 +15,6 @@ 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;
@ -69,6 +63,9 @@ public class BizMember extends BaseEntity
@Excel(name = "团队福豆") @Excel(name = "团队福豆")
private Long douTeam; private Long douTeam;
@Excel(name = "专项福豆")
private Long douSpecial;
@Excel(name = "福豆田") @Excel(name = "福豆田")
private Long douField; private Long douField;
@ -196,6 +193,14 @@ public class BizMember extends BaseEntity
this.douTeam = douTeam; this.douTeam = douTeam;
} }
public Long getDouSpecial() {
return douSpecial;
}
public void setDouSpecial(Long douSpecial) {
this.douSpecial = douSpecial;
}
public Long getDouField() { public Long getDouField() {
return douField; return douField;
} }

View File

@ -0,0 +1,126 @@
package com.ruoyi.business.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
/**
* 订单明细对象 biz_order_detail
*
* @author ruoyi
* @date 2020-09-17
*/
public class BizOrderDetail extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 订单明细ID */
private Long id;
/** 订单ID */
@Excel(name = "订单ID")
private Long orderId;
/** 订单编码 */
@Excel(name = "订单编码")
private String orderSn;
/** 产品ID */
@Excel(name = "产品ID")
private Long productId;
/** 产品编码 */
@Excel(name = "产品编码")
private String productCode;
/** 商品数量 */
@Excel(name = "商品数量")
private Integer productCount;
/** 商品金额 */
@Excel(name = "商品金额")
private BigDecimal productAmount;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setOrderId(Long orderId)
{
this.orderId = orderId;
}
public Long getOrderId()
{
return orderId;
}
public void setOrderSn(String orderSn)
{
this.orderSn = orderSn;
}
public String getOrderSn()
{
return orderSn;
}
public void setProductId(Long productId)
{
this.productId = productId;
}
public Long getProductId()
{
return productId;
}
public void setProductCode(String productCode)
{
this.productCode = productCode;
}
public String getProductCode()
{
return productCode;
}
public void setProductCount(Integer productCount)
{
this.productCount = productCount;
}
public Integer getProductCount()
{
return productCount;
}
public void setProductAmount(BigDecimal productAmount)
{
this.productAmount = productAmount;
}
public BigDecimal getProductAmount()
{
return productAmount;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("orderId", getOrderId())
.append("orderSn", getOrderSn())
.append("productId", getProductId())
.append("productCode", getProductCode())
.append("productCount", getProductCount())
.append("productAmount", getProductAmount())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.business.mapper; package com.ruoyi.business.mapper;
import com.ruoyi.business.domain.BizAccount; import com.ruoyi.business.domain.BizAccount;
import com.ruoyi.business.domain.BizAccountDetail;
import java.util.List; import java.util.List;
@ -59,4 +60,20 @@ public interface BizAccountMapper
* @return 结果 * @return 结果
*/ */
public int deleteBizAccountByIds(String[] ids); public int deleteBizAccountByIds(String[] ids);
/**
* 查询会员账户明细列表
*
* @param bizAccountDetail 会员账户明细
* @return 会员账户明细集合
*/
public List<BizAccountDetail> selectBizAccountDetailList(BizAccountDetail bizAccountDetail);
/**
* 新增会员账户明细
*
* @param bizAccountDetail 会员账户明细
* @return 结果
*/
public int insertBizAccountDetail(BizAccountDetail bizAccountDetail);
} }

View File

@ -2,6 +2,7 @@ package com.ruoyi.business.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.business.domain.BizOrder; import com.ruoyi.business.domain.BizOrder;
import com.ruoyi.business.domain.BizOrderDetail;
/** /**
* 订单Mapper接口 * 订单Mapper接口
@ -58,4 +59,12 @@ public interface BizOrderMapper
* @return 结果 * @return 结果
*/ */
public int deleteBizOrderByIds(String[] ids); public int deleteBizOrderByIds(String[] ids);
/**
* 新增订单明细
*
* @param bizOrderDetail 订单明细
* @return 结果
*/
public int insertBizOrderDetail(BizOrderDetail bizOrderDetail);
} }

View File

@ -59,4 +59,12 @@ public interface IBizAccountService
* @return 结果 * @return 结果
*/ */
public int deleteBizAccountById(Long id); public int deleteBizAccountById(Long id);
/**
* 会员福豆变动明细
*
* @param memberID accountType detailType money businessInfo desc
* @return boolean
*/
public boolean accountChange(Long memberID, int accountType, int detailType, Long money, String businessInfo, String desc);
} }

View File

@ -76,4 +76,5 @@ public interface IBizMemberService
* @return 结果 * @return 结果
*/ */
public int deleteBizMemberById(Long id); public int deleteBizMemberById(Long id);
} }

View File

@ -2,6 +2,7 @@ package com.ruoyi.business.service;
import java.util.List; import java.util.List;
import com.ruoyi.business.domain.BizOrder; import com.ruoyi.business.domain.BizOrder;
import com.ruoyi.common.core.domain.AjaxResult;
/** /**
* 订单Service接口 * 订单Service接口
@ -66,4 +67,20 @@ public interface IBizOrderService
* @return 结果 * @return 结果
*/ */
public int deleteBizOrderById(Long id); public int deleteBizOrderById(Long id);
/**
* 添加订单
*
* @param
* @return AjaxResult
*/
public AjaxResult orderAdd(Long memberID, Long productID, int productNum, Long addressID, String remark);
/**
* 订单收货
*
* @param
* @return AjaxResult
*/
public AjaxResult orderConfirm(Long userID, Long orderID);
} }

View File

@ -1,8 +1,11 @@
package com.ruoyi.business.service.impl; package com.ruoyi.business.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import com.ruoyi.business.domain.BizAccount; import com.ruoyi.business.domain.BizAccount;
import com.ruoyi.business.domain.BizAccountDetail;
import com.ruoyi.business.mapper.BizAccountMapper; import com.ruoyi.business.mapper.BizAccountMapper;
import com.ruoyi.business.service.IBizAccountService; import com.ruoyi.business.service.IBizAccountService;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
@ -95,4 +98,49 @@ public class BizAccountServiceImpl implements IBizAccountService
{ {
return bizAccountMapper.deleteBizAccountById(id); return bizAccountMapper.deleteBizAccountById(id);
} }
/**
* 会员福豆变动明细
*
* @param memberID accountType detailType money businessInfo desc
* @return boolean
*/
@Override
public boolean accountChange(Long memberID, int accountType, int detailType, Long money, String businessInfo, String desc)
{
//取出用户账户
BizAccount bizAccount = new BizAccount();
bizAccount.setMemberId(memberID);
bizAccount.setAccountType(accountType);
List<BizAccount> accountList = bizAccountMapper.selectBizAccountList(bizAccount);
if (accountList.size() == 0) {
return false;
}
bizAccount = accountList.get(0);
//减去的话判断金额
int changeType = money >= 0 ? BizAccountDetail.DOU_CHANGE_TYPE_ADD : BizAccountDetail.DOU_CHANGE_TYPE_REDUSE;
Long beforeMoney = bizAccount.getAmount().longValue();
if (changeType == BizAccountDetail.DOU_CHANGE_TYPE_REDUSE && beforeMoney < -money) {
return false;
}
//增加余额
Long afterMoney = beforeMoney + money;
bizAccount.setAmount(new BigDecimal(afterMoney));
bizAccountMapper.updateBizAccount(bizAccount);
//详细记录
BizAccountDetail detail = new BizAccountDetail();
detail.setMemberId(memberID);
detail.setAccountId(bizAccount.getId());
detail.setAccountType(accountType);
detail.setBusinessNo(businessInfo);
detail.setChangeType(changeType);
detail.setTypeDetail(detailType);
detail.setBeforeAmount(beforeMoney);
detail.setAfterAmount(afterMoney);
detail.setChangeDesc(desc);
detail.setUpdateTime(new Date());
bizAccountMapper.insertBizAccountDetail(detail);
return true;
}
} }

View File

@ -39,6 +39,7 @@ public class BizMemberAddressServiceImpl implements IBizMemberAddressService
* @param memberID 会员ID * @param memberID 会员ID
* @return 会员收货地址 * @return 会员收货地址
*/ */
@Override
public BizMemberAddress selectDefaultAddressByMemberId(Long memberID) public BizMemberAddress selectDefaultAddressByMemberId(Long memberID)
{ {
return bizMemberAddressMapper.selectDefaultAddressByMemberId(memberID); return bizMemberAddressMapper.selectDefaultAddressByMemberId(memberID);
@ -50,6 +51,7 @@ public class BizMemberAddressServiceImpl implements IBizMemberAddressService
* @param memberID 会员ID * @param memberID 会员ID
* @return int * @return int
*/ */
@Override
public int cancelDefaultAddress(Long memberID) public int cancelDefaultAddress(Long memberID)
{ {
return bizMemberAddressMapper.cancelDefaultAddress(memberID); return bizMemberAddressMapper.cancelDefaultAddress(memberID);

View File

@ -1,9 +1,14 @@
package com.ruoyi.business.service.impl; package com.ruoyi.business.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.ruoyi.business.domain.BizAccount;
import com.ruoyi.business.domain.BizAccountDetail;
import com.ruoyi.business.mapper.BizAccountMapper;
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;
@ -24,6 +29,9 @@ public class BizMemberServiceImpl implements IBizMemberService
@Autowired @Autowired
private BizMemberMapper bizMemberMapper; private BizMemberMapper bizMemberMapper;
@Autowired
private BizAccountMapper bizAccountMapper;
/** /**
* 查询会员 * 查询会员
* *
@ -66,6 +74,7 @@ public class BizMemberServiceImpl implements IBizMemberService
* @param memberID type * @param memberID type
* @return 结果 * @return 结果
*/ */
@Override
public Long selectBizMemberDou(Long memberID, int type) public Long selectBizMemberDou(Long memberID, int type)
{ {
Map map = new HashMap<>(); Map map = new HashMap<>();
@ -123,4 +132,5 @@ public class BizMemberServiceImpl implements IBizMemberService
{ {
return bizMemberMapper.deleteBizMemberById(id); return bizMemberMapper.deleteBizMemberById(id);
} }
} }

View File

@ -1,15 +1,23 @@
package com.ruoyi.business.service.impl; package com.ruoyi.business.service.impl;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.ruoyi.business.domain.*;
import com.ruoyi.business.mapper.BizMemberAddressMapper;
import com.ruoyi.business.mapper.BizMemberMapper;
import com.ruoyi.business.mapper.BizProductMapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.util.ShiroUtils; import com.ruoyi.framework.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.BizOrderMapper; import com.ruoyi.business.mapper.BizOrderMapper;
import com.ruoyi.business.domain.BizOrder;
import com.ruoyi.business.service.IBizOrderService; import com.ruoyi.business.service.IBizOrderService;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 订单Service业务层处理 * 订单Service业务层处理
@ -23,6 +31,18 @@ public class BizOrderServiceImpl implements IBizOrderService
@Autowired @Autowired
private BizOrderMapper bizOrderMapper; private BizOrderMapper bizOrderMapper;
@Autowired
private BizProductMapper bizProductMapper;
@Autowired
private BizMemberMapper bizMemberMapper;
@Autowired
private BizMemberAddressMapper bizMemberAddressMapper;
@Autowired
private BizAccountServiceImpl bizAccountService;
/** /**
* 查询订单 * 查询订单
* *
@ -79,6 +99,7 @@ public class BizOrderServiceImpl implements IBizOrderService
* @param orderID 订单ID * @param orderID 订单ID
* @return 结果 * @return 结果
*/ */
@Override
public int deliverBizOrder(Long orderID) public int deliverBizOrder(Long orderID)
{ {
BizOrder bizOrder = bizOrderMapper.selectBizOrderById(orderID); BizOrder bizOrder = bizOrderMapper.selectBizOrderById(orderID);
@ -118,4 +139,100 @@ public class BizOrderServiceImpl implements IBizOrderService
{ {
return bizOrderMapper.deleteBizOrderById(id); return bizOrderMapper.deleteBizOrderById(id);
} }
/**
* 添加订单
*
* @param
* @return AjaxResult
*/
@Override
@Transactional
public AjaxResult orderAdd(Long memberID, Long productID, int productNum, Long addressID, String remark)
{
if (productNum <= 0 || productNum > 99) { //检测数量
return AjaxResult.error("商品数目异常");
}
if (StringUtils.isEmpty(remark) || remark.length() > 30) { //检测备注
return AjaxResult.error("备注信息异常");
}
//取出商品
BizProduct product = bizProductMapper.selectBizProductById(productID);
if (product == null || product.getOnlineStatus() == 0) { //检测上架
return AjaxResult.error("该商品不存在");
}
//订单总价
Long amount = product.getAmount();
Long orderTotal = amount * productNum;
//判断余额
BizMember member = bizMemberMapper.selectBizMemberById(memberID);
Long douBalance = member.getDouBalance();
if (douBalance < orderTotal) {
return AjaxResult.error("福豆余额不足");
}
Long cashbackAmount = product.getCashbackAmount() * productNum;
//TODO cashbackAmount 专项划拨金额等级判断
//判断地址
BizMemberAddress address = bizMemberAddressMapper.selectBizMemberAddressById(addressID);
if (address == null || !address.getMemberID().equals(memberID)) {
return AjaxResult.error("收货地址不正确");
}
//创建订单
BizOrder order = new BizOrder();
order.setOrderSn("ORD" + DateUtils.getMilliTime());
order.setMemberId(memberID);
order.setMobile(address.getMobile());
order.setMemberName(member.getMemberName());
order.setOrderAmount(new BigDecimal(orderTotal));
order.setOrderStatus(BizOrder.STATUS_PAYED); //已支付
order.setRemark(remark);
order.setAddressDetail(address.getAddress());
order.setAddressId(addressID);
insertBizOrder(order);
//订单详情
BizOrderDetail orderDetail = new BizOrderDetail();
orderDetail.setOrderId(order.getId());
orderDetail.setOrderSn(order.getOrderSn());
orderDetail.setProductId(productID);
orderDetail.setProductCode(product.getProductName());
orderDetail.setProductCount(productNum);
orderDetail.setProductAmount(new BigDecimal(amount));
bizOrderMapper.insertBizOrderDetail(orderDetail);
//减去福豆余额账户
boolean result = bizAccountService.accountChange(memberID, BizAccount.DOU_BALANCE, BizAccountDetail.DOU_DETAIL_TYPE_ORDER, -orderTotal, String.valueOf(order.getId()), BizAccountDetail.DOU_DESC_ORDER);
if (!result) {
return AjaxResult.error("扣款失败,请联系管理员");
}
//增加专项账户
if(cashbackAmount > 0) {
result = bizAccountService.accountChange(memberID, BizAccount.DOU_SPECIAL, BizAccountDetail.DOU_DETAIL_TYPE_CHARGE, cashbackAmount, String.valueOf(order.getId()), BizAccountDetail.DOU_DESC_SPECIAL1);
if (!result) {
return AjaxResult.error("扣款失败,请联系管理员");
}
}
return AjaxResult.success();
}
/**
* 订单收货
*
* @param
* @return AjaxResult
*/
@Override
@Transactional
public AjaxResult orderConfirm(Long userID, Long orderID)
{
BizOrder order = selectBizOrderById(orderID);
//验证
if (order == null || order.getMemberId() != userID || order.getOrderStatus() != BizOrder.STATUS_DELIVERY) {
return AjaxResult.error("订单操作失败");
}
order.setOrderStatus(BizOrder.STATUS_COMPLETED);
order.setUpdateBy(String.valueOf(userID));
updateBizOrder(order);
return AjaxResult.success();
}
} }

View File

@ -15,6 +15,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<resultMap type="BizAccountDetail" id="BizAccountDetailResult">
<result property="id" column="id" />
<result property="memberId" column="member_id" />
<result property="accountId" column="account_id" />
<result property="accountType" column="account_type" />
<result property="businessNo" column="business_no" />
<result property="changeType" column="change_type" />
<result property="typeDetail" column="type_detail" />
<result property="beforeAmount" column="before_amount" />
<result property="afterAmount" column="after_amount" />
<result property="changeDesc" column="change_desc" />
<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="selectBizAccountVo"> <sql id="selectBizAccountVo">
select id, member_id, account_type, amount, create_by, create_time, update_by, update_time from biz_account select id, member_id, account_type, amount, create_by, create_time, update_by, update_time from biz_account
</sql> </sql>
@ -24,7 +41,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="memberId != null "> and member_id = #{memberId}</if> <if test="memberId != null "> and member_id = #{memberId}</if>
<if test="accountType != null "> and account_type = #{accountType}</if> <if test="accountType != null "> and account_type = #{accountType}</if>
<if test="amount != null "> and amount = #{amount}</if>
</where> </where>
</select> </select>
@ -80,4 +96,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </delete>
<select id="selectBizAccountDetailList" parameterType="BizAccountDetail" resultMap="BizAccountDetailResult">
select id, member_id, account_id, account_type, business_no, change_type, type_detail, before_amount, after_amount, change_desc, create_by, create_time, update_by, update_time from biz_account_detail
<where>
<if test="memberId != null "> and member_id = #{memberId}</if>
<if test="accountId != null "> and account_id = #{accountId}</if>
<if test="accountType != null "> and account_type = #{accountType}</if>
<if test="typeDetail != null "> and type_detail = #{typeDetail}</if>
</where>
order by id desc
</select>
<insert id="insertBizAccountDetail" parameterType="BizAccountDetail" useGeneratedKeys="true" keyProperty="id">
insert into biz_account_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="memberId != null">member_id,</if>
<if test="accountId != null">account_id,</if>
<if test="accountType != null">account_type,</if>
<if test="businessNo != null and businessNo != ''">business_no,</if>
<if test="changeType != null">change_type,</if>
<if test="typeDetail != null">type_detail,</if>
<if test="beforeAmount != null">before_amount,</if>
<if test="afterAmount != null">after_amount,</if>
<if test="changeDesc != null">change_desc,</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="memberId != null">#{memberId},</if>
<if test="accountId != null">#{accountId},</if>
<if test="accountType != null">#{accountType},</if>
<if test="businessNo != null and businessNo != ''">#{businessNo},</if>
<if test="changeType != null">#{changeType},</if>
<if test="typeDetail != null">#{typeDetail},</if>
<if test="beforeAmount != null">#{beforeAmount},</if>
<if test="afterAmount != null">#{afterAmount},</if>
<if test="changeDesc != null">#{changeDesc},</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>
</mapper> </mapper>

View File

@ -26,7 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(select amount from biz_account where member_id = a.id and account_type = 0) douBalance, (select amount from biz_account where member_id = a.id and account_type = 0) douBalance,
(select amount from biz_account where member_id = a.id and account_type = 1) douPerson, (select amount from biz_account where member_id = a.id and account_type = 1) douPerson,
(select amount from biz_account where member_id = a.id and account_type = 2) douTeam, (select amount from biz_account where member_id = a.id and account_type = 2) douTeam,
(select amount from biz_account where member_id = a.id and account_type = 3) douField (select amount from biz_account where member_id = a.id and account_type = 3) douSpecial,
(select amount from biz_account where member_id = a.id and account_type = 4) douField
from biz_member a from biz_member a
</sql> </sql>

View File

@ -21,13 +21,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<resultMap type="BizOrderDetail" id="BizOrderDetailResult">
<result property="id" column="id" />
<result property="orderId" column="order_id" />
<result property="orderSn" column="order_sn" />
<result property="productId" column="product_id" />
<result property="productCode" column="product_code" />
<result property="productCount" column="product_count" />
<result property="productAmount" column="product_amount" />
<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="selectBizOrderVo"> <sql id="selectBizOrderVo">
select a.id, order_sn, a.member_id, a.mobile, a.member_name, order_amount, order_status, remark, address_detail, address_id, a.create_by, a.create_time, a.update_by, a.update_time, select a.id, order_sn, a.member_id, a.mobile, a.member_name, order_amount, order_status, remark, address_detail, address_id, a.create_by, a.create_time, a.update_by, a.update_time,
b.mobile addressMobile, b.member_name addressName, b.province_name addressProvince, b.city_name addressCity, b.area_name addressArea, b.mobile addressMobile, b.member_name addressName, b.province_name addressProvince, b.city_name addressCity, b.area_name addressArea,
c.productName, c.productCount, c.productAmount c.productName, c.productCount, c.productAmount
from biz_order a from biz_order a
left join biz_member_address b on a.member_id = b.member_id left join biz_member_address b on a.member_id = b.member_id
left join (select max(id), order_id, product_code productName, product_count productCount, product_amount productAmount from biz_order_detail group by product_id) c left join (select max(id), order_id, product_code productName, product_count productCount, product_amount productAmount from biz_order_detail group by order_id) c
on a.id = c.order_id on a.id = c.order_id
</sql> </sql>
@ -111,4 +125,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </delete>
<insert id="insertBizOrderDetail" parameterType="BizOrderDetail" useGeneratedKeys="true" keyProperty="id">
insert into biz_order_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">order_id,</if>
<if test="orderSn != null and orderSn != ''">order_sn,</if>
<if test="productId != null">product_id,</if>
<if test="productCode != null and productCode != ''">product_code,</if>
<if test="productCount != null">product_count,</if>
<if test="productAmount != null">product_amount,</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="orderId != null">#{orderId},</if>
<if test="orderSn != null and orderSn != ''">#{orderSn},</if>
<if test="productId != null">#{productId},</if>
<if test="productCode != null and productCode != ''">#{productCode},</if>
<if test="productCount != null">#{productCount},</if>
<if test="productAmount != null">#{productAmount},</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>
</mapper> </mapper>

View File

@ -104,6 +104,11 @@
align: 'center', align: 'center',
title: '福豆田' title: '福豆田'
}, },
{
field: 'douSpecial',
align: 'center',
title: '专项福豆'
},
{ {
field: 'memberType', field: 'memberType',
title: '会员类型', title: '会员类型',

View File

@ -22,7 +22,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
public static String YYYY_MM_DD_HH_MM_SS_SSS = "yyyyMMddHHmmssSSS";
private static String[] parsePatterns = { private static String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
@ -53,6 +55,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
return dateTimeNow(YYYY_MM_DD_HH_MM_SS); return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
} }
public static final String getMilliTime()
{
return dateTimeNow(YYYY_MM_DD_HH_MM_SS_SSS);
}
public static final String dateTimeNow() public static final String dateTimeNow()
{ {
return dateTimeNow(YYYYMMDDHHMMSS); return dateTimeNow(YYYYMMDDHHMMSS);