diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxOrderController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxOrderController.java index ecc694d56..07d539771 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxOrderController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxOrderController.java @@ -7,8 +7,12 @@ import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; import com.iformall.domain.dto.OrderSaveDto; -import com.iformall.domain.po.*; +import com.iformall.domain.po.WxCUser; +import com.iformall.domain.po.WxCoupon; +import com.iformall.domain.po.WxCouponChannel; +import com.iformall.domain.po.WxOrder; import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.vo.WxMerchantSubsidyVo; import com.iformall.domain.vo.WxOrderQueryVo; import com.iformall.enums.EnumCouponChannelStatus; import com.iformall.enums.EnumCouponChannelType; @@ -22,12 +26,17 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.Map; @RestController @@ -58,7 +67,9 @@ public class WxOrderController extends BaseController { @SystemControllerLog(description = "订单管理-列表") public ResultData list(@ModelAttribute WxOrder wxOrder, Integer pageNum, Integer pageSize) { logger.debug("[" + getIpAddr() + "] WxOrderController::list"); - if (null == wxOrder) wxOrder = new WxOrder(); + if (null == wxOrder) { + wxOrder = new WxOrder(); + } wxOrder.setTenantId(getTenantId()); wxOrder.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); final PageInfo page = wxOrderService.listAsPage(wxOrder, pageNum, pageSize); @@ -143,7 +154,9 @@ public class WxOrderController extends BaseController { } WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(orderSaveDto.getCouponChannelId()); ResultData resultData = couponChannelCheck(orderSaveDto, wxCouponChannel); - if (resultData != null) return resultData; + if (resultData != null) { + return resultData; + } Long couponId = orderSaveDto.getCouponId() == null ? wxCouponChannel.getCouponId() : orderSaveDto.getCouponId(); if (couponId == null) { @@ -161,8 +174,9 @@ public class WxOrderController extends BaseController { if (coupon == null) { return new ResultData(ErrorCode.COUPON_IS_EMPTY); } - if (!wxOrderService.checkCouponIsFree(coupon)) + if (!wxOrderService.checkCouponIsFree(coupon)) { return new ResultData(ErrorCode.COUPON_IS_NOT_FREE); + } // 免费券 order = wxOrderService.saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId(), null); return new ResultData(order); @@ -200,4 +214,42 @@ public class WxOrderController extends BaseController { return null; } + @ApiOperation("查看明细") + @GetMapping("/detail") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + @SystemControllerLog(description = "订单管理-id查询") + public ResultData detail(Long id) { + logger.debug("[" + getIpAddr() + "] WxOrderController::detail"); + WxOrder order = new WxOrder(); + order.setId(id); + order.setTenantId(getTenantId()); + return new ResultData(Result.SUCCESS, "查询成功", wxOrderService.detailCUserVo(order)); + } + + @ApiOperation("交易列表") + @GetMapping("summary") + @SystemControllerLog(description = "订单管理-总计") + public ResultData summary(@ModelAttribute WxOrderQueryVo wxOrderQueryVo) { + logger.debug("[" + getIpAddr() + "] WxOrderController::summary"); + if (null == wxOrderQueryVo) { + wxOrderQueryVo = new WxOrderQueryVo(); + } + wxOrderQueryVo.setTenantId(getTenantId()); + Map data = wxOrderService.summary(wxOrderQueryVo); + return new ResultData(data); + } + + @ApiOperation("导出") + @GetMapping("/exportData") + @SystemControllerLog(description = "导出") + public void exportData(@ModelAttribute WxOrderQueryVo wxOrderQueryVo, HttpServletRequest request, HttpServletResponse response) { + logger.info("[" + getIpAddr() + "] WxOrderController/exportData"); + if (null == wxOrderQueryVo) { + wxOrderQueryVo = new WxOrderQueryVo(); + } + wxOrderQueryVo.setTenantId(getTenantId()); + wxOrderService.exportData(wxOrderQueryVo, request, response); + } + + } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java index 96ff99808..02f9a9b19 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java @@ -1,5 +1,6 @@ package com.iformall.domain.po; +import cn.afterturn.easypoi.excel.annotation.Excel; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.iformall.domain.po.base.BaseEntity; @@ -7,7 +8,6 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; - import java.util.Date; import java.util.List; @@ -23,12 +23,15 @@ public class WxOrder extends BaseEntity { @TableField(exist = false) private String merchantName; + @Excel(name = "会员", width = 20, orderNum = "2") @TableField(exist = false) private String cUserName; + @Excel(name = "会员手机号", width = 20, orderNum = "3") @TableField(exist = false) private String phone; + @Excel(name = "订单编号", width = 20, orderNum = "1") @io.swagger.annotations.ApiModelProperty(value="订单码;正反向交易保持一致。",name="orderNumber") private Long orderNumber; @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") @@ -43,12 +46,18 @@ public class WxOrder extends BaseEntity { private Integer type; @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款",name="paymentType") private Integer paymentType; + + @Excel(name = "订单金额(元)", width = 20, orderNum = "6") @io.swagger.annotations.ApiModelProperty(value="支付金额(分):允许有负数,退款时为负值。",name="payment") private Integer payment; @io.swagger.annotations.ApiModelProperty(value="支付时间",name="paymentTime") private Date paymentTime; + + @Excel(name = "订单状态", width = 20, orderNum = "9", replace = {"待付款_0", "已支付_1", "已取消_2", "待退款_3", "已退款_4", "退款失败_5"}) @io.swagger.annotations.ApiModelProperty(value="订单状态:-1全部;正向交易:0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款)反向交易:3-已退款; 4-退款失败,5-退款失败; 砍价:6-砍价中,7-砍价完成,8-砍价失败",name="orderStatus") private Integer orderStatus; + + @Excel(name = "订单日期", width = 20, orderNum = "7", format = "yyyy-MM-dd") @io.swagger.annotations.ApiModelProperty(value="创建时间/砍价开始时间",name="createDate") private Date createDate; @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") @@ -82,4 +91,15 @@ public class WxOrder extends BaseEntity { @TableField(exist = false) protected String statusStr; + @Excel(name = "商品名称", width = 20, orderNum = "5") + @TableField(exist = false) + private String title; + + @Excel(name = "商品属性", width = 20, orderNum = "4", replace = {"消费卡_1", "优惠券_2", "砍价_3", "拼团_4"}) + @TableField(exist = false) + private Integer attribute; + + @Excel(name = "支付金额(元)", width = 20, orderNum = "8") + @TableField(exist = false) + private Integer pay; } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderCouponVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderCouponVo.java index d66aba5c9..021547b00 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderCouponVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderCouponVo.java @@ -87,4 +87,7 @@ public class WxOrderCouponVo { @io.swagger.annotations.ApiModelProperty(value = "是否可转赠", name = "supportTransfer") private Integer supportTransfer; + @io.swagger.annotations.ApiModelProperty(value = "补贴额", name = "subsidyNum") + private Integer subsidyNum; + } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderQueryVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderQueryVo.java index 85ed59400..b55bb582b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderQueryVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderQueryVo.java @@ -36,4 +36,13 @@ public class WxOrderQueryVo extends BaseEntity { @TableField(exist = false) private Date createDate; + @io.swagger.annotations.ApiModelProperty(value = "产品名称", name = "title") + private String title; + + @io.swagger.annotations.ApiModelProperty(value = "商品属性", name = "attribute") + private Integer attribute; + + @io.swagger.annotations.ApiModelProperty(value = "订单号", name = "orderNumber") + private String orderNumber; + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxOrderService.java index 0c8b197bf..a1b1153cc 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxOrderService.java @@ -10,6 +10,8 @@ import com.iformall.domain.vo.WxOrderCouponVo; import com.iformall.domain.vo.WxOrderQueryVo; import com.iformall.enums.EnumOrderStatus; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -189,4 +191,8 @@ public interface WxOrderService { */ void actionAfterCouponOrderSuccess(WxOrder updateOrder, WxCoupon coupon, WxCUser user); + Map summary(WxOrderQueryVo wxOrderQueryVo); + + void exportData(WxOrderQueryVo wxOrderQueryVo, HttpServletRequest request, HttpServletResponse response); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java index 13dfe4f80..81e011b0a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java @@ -199,6 +199,7 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { wxBillDaily.setUpdatetime(date); wxBillDaily.setPayWay(record.getPayWay()); wxBillDaily.setPriceDetail(record.getPriceDetail()); + wxBillDaily.setServiceChargePay(record.getServiceChargePay()); try { wxBillDailyMapper.updateById(wxBillDaily); } catch (Exception e) { @@ -211,7 +212,11 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); wxBillAction.setDetails(message + price + "元"); - wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + if(record.getServiceChargePay() != null){ + wxBillAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); + }else{ + wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + } wxBillAction.setUserId(user.getId()); wxBillAction.setUserName(user.getName()); wxBillAction.setPhone(user.getPhone()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java index 98a37c45c..4828a712b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java @@ -164,6 +164,7 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { wxBillDeposit.setPayDate(date); wxBillDeposit.setUpdatetime(date); wxBillDeposit.setPayWay(record.getPayWay()); + wxBillDeposit.setServiceChargePay(record.getServiceChargePay()); try { wxBillDepositMapper.updateById(wxBillDeposit); } catch (Exception e) { @@ -176,7 +177,11 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); wxBillAction.setDetails(message + price + "元"); - wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + if(record.getServiceChargePay() != null){ + wxBillAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); + }else{ + wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + } wxBillAction.setUserId(user.getId()); wxBillAction.setUserName(user.getName()); wxBillAction.setPhone(user.getPhone()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherDepositServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherDepositServiceImpl.java index 92d24695d..bcd82a94b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherDepositServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherDepositServiceImpl.java @@ -195,6 +195,7 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService wxBillOtherDeposit.setUpdatetime(date); wxBillOtherDeposit.setPayWay(record.getPayWay()); wxBillOtherDeposit.setComments(record.getComments()); + wxBillOtherDeposit.setServiceChargePay(record.getServiceChargePay()); try { wxBillOtherDepositMapper.updateById(wxBillOtherDeposit); } catch (Exception e) { @@ -207,7 +208,11 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); wxBillAction.setDetails(message + price + "元"); - wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + if(record.getServiceChargePay() != null){ + wxBillAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); + }else{ + wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + } wxBillAction.setUserId(user.getId()); wxBillAction.setUserName(user.getName()); wxBillAction.setPhone(user.getPhone()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java index 9064cf270..97d6abcb4 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java @@ -196,6 +196,7 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { wxBillOther.setPayWay(record.getPayWay()); wxBillOther.setComments(record.getComments()); wxBillOther.setName(record.getName()); + wxBillOther.setServiceChargePay(record.getServiceChargePay()); try { wxBillOtherMapper.updateById(wxBillOther); } catch (Exception e) { @@ -208,7 +209,11 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); wxBillAction.setDetails(message + price + "元"); - wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + if(record.getServiceChargePay() != null){ + wxBillAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); + }else{ + wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + } wxBillAction.setUserId(user.getId()); wxBillAction.setUserName(user.getName()); wxBillAction.setPhone(user.getPhone()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java index 578423b0d..ee4866fb2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java @@ -163,6 +163,7 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe wxBillDeposit.setPayDate(date); wxBillDeposit.setUpdatetime(date); wxBillDeposit.setPayWay(record.getPayWay()); + wxBillDeposit.setServiceChargePay(record.getServiceChargePay()); try { wxBillPropertyDepositMapper.updateById(wxBillDeposit); } catch (Exception e) { @@ -175,7 +176,11 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); wxBillAction.setDetails(message + price + "元"); - wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + if(record.getServiceChargePay() != null){ + wxBillAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); + }else{ + wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + } wxBillAction.setUserId(user.getId()); wxBillAction.setUserName(user.getName()); wxBillAction.setPhone(user.getPhone()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java index acdf21e82..12b5c1eaa 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java @@ -179,6 +179,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { property.setPayDate(record.getPayDate()); property.setUpdatetime(date); property.setPayWay(record.getPayWay()); + property.setServiceChargePay(record.getServiceChargePay()); try { wxBillPropertyMapper.updateById(property); } catch (Exception e) { @@ -191,7 +192,12 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); wxBillAction.setDetails(message + price + "元"); - wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + if(record.getServiceChargePay() != null){ + wxBillAction.setDetails(record.getServiceChargePayBefore()+"元变更为" +record.getServiceChargePayUpdate()+"元"); + wxBillAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); + }else{ + wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + } wxBillAction.setUserId(user.getId()); wxBillAction.setUserName(user.getName()); wxBillAction.setPhone(user.getPhone()); @@ -358,19 +364,6 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { billAction.setUpdatetime(new Date()); wxBillActionMapper.insert(billAction); } - if(record.getServiceChargePayUpdate() != null) { - record.setServiceChargePay(Integer.parseInt(record.getServiceChargePayUpdate()) * 100); - - billAction = new WxBillAction(); - billAction.setId(idWorker.nextId()); - billAction.setCreatetime(new Date()); - billAction.setUserName("系统端"); - billAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); - billAction.setBillId(record.getId()); - billAction.setDetails(record.getServiceChargePayBefore()+"元变更为" +record.getServiceChargePayUpdate()+"元"); - billAction.setUpdatetime(new Date()); - wxBillActionMapper.insert(billAction); - } wxBillPropertyMapper.updateById(record); return new ResultData(); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java index e72e87900..5efba1555 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java @@ -182,6 +182,7 @@ public class WxBillRentServiceImpl implements WxBillRentService { wxBillRent.setPayDate(record.getPayDate()); wxBillRent.setUpdatetime(date); wxBillRent.setPayWay(record.getPayWay()); + wxBillRent.setServiceChargePay(record.getServiceChargePay()); try { wxBillRentMapper.updateById(wxBillRent); } catch (Exception e) { @@ -194,7 +195,12 @@ public class WxBillRentServiceImpl implements WxBillRentService { String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); wxBillAction.setDetails(message + price + "元"); - wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + if(record.getServiceChargePay() != null){ + wxBillAction.setDetails(record.getServiceChargePayBefore()+"元变更为" +record.getServiceChargePayUpdate()+"元"); + wxBillAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); + }else{ + wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); + } wxBillAction.setUserId(user.getId()); wxBillAction.setUserName(user.getName()); wxBillAction.setPhone(user.getPhone()); @@ -471,20 +477,6 @@ public class WxBillRentServiceImpl implements WxBillRentService { billAction.setUpdatetime(new Date()); wxBillActionMapper.insert(billAction); } - if(record.getServiceChargePayUpdate() != null) { - record.setServiceChargePay(Integer.parseInt(record.getServiceChargePayUpdate()) * 100); - - billAction = new WxBillAction(); - billAction.setId(idWorker.nextId()); - billAction.setCreatetime(new Date()); - billAction.setUserName("系统端"); - billAction.setAction(EnumBillAction.UPDATE_SERVICE_MONEY.getCode()); - billAction.setBillId(record.getId()); - billAction.setDetails(record.getServiceChargePayBefore()+"元变更为" +record.getServiceChargePayUpdate()+"元"); - billAction.setUpdatetime(new Date()); - wxBillActionMapper.insert(billAction); - } - wxBillRentMapper.updateById(record); return new ResultData(); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java index b8bbf0041..d0114473c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -18,7 +18,6 @@ import com.iformall.mapper.*; import com.iformall.mq.MqBaseProducer; import com.iformall.service.*; import com.iformall.utils.Constant; -import com.iformall.utils.EventUtil; import com.iformall.utils.JsonUtil; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.map.HashedMap; @@ -147,7 +146,7 @@ public class WxFlowServiceImpl implements WxFlowService { //如果审批完成,而且是补录直接改为已签约状态(普通需要绑定商户才是已签约) WxRentContract record = wxRentContractMapper.selectById(businessId); - if(record.getMerchantId()!=null && EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { + if(record != null && record.getMerchantId()!=null && EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { wxRentContractService.updateRentContractStatus(businessId); } }else if(EnumFlowContractType.PROPERTY.getCode().equals(contractType) || EnumFlowContractType.PROPERTY_POINT.getCode().equals(contractType)){ diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index 8c6e585fc..9561a32b7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -25,10 +25,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; @Service public class WxOrderServiceImpl implements WxOrderService { @@ -122,6 +125,9 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired private WxCouponPasswordMapper couponPasswordMapper; + @Autowired + ExcelService excelService; + @Override public PageInfo listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); @@ -216,6 +222,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 用户购买的订单数量 + * * @param user * @param counpon * @return @@ -244,6 +251,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 用户购买的订单数量 + * * @param user * @param counpon * @return @@ -263,7 +271,7 @@ public class WxOrderServiceImpl implements WxOrderService { statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); orderQ.setStatusS(statusS); List orders = wxOrderMapper.findList(orderQ); - if(orders.size() >= 1) { + if (orders.size() >= 1) { return orders.get(0); } } catch (Exception e) { @@ -275,6 +283,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 用户正在参加的新手活动 + * * @param user * @return */ @@ -305,6 +314,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 用户购买的券包数量- 待使用的券 + * * @param user * @param counpon * @return @@ -329,6 +339,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 商户注券减库存 + * * @param user * @param coupon * @param couponIdStr @@ -343,8 +354,8 @@ public class WxOrderServiceImpl implements WxOrderService { throw new MallinkException(ErrorCode.TOO_MANY_REQUEST.getCode(), coupon.getTitle() + ErrorCode.TOO_MANY_REQUEST.getMessage()); } - JSONObject jo = JSONObject.parseObject(wxCouponSendVo.getConditions()) ; - int merchantSend = jo.getIntValue(WxCouponSend.KEY_MERCHANT_SEND) ; + JSONObject jo = JSONObject.parseObject(wxCouponSendVo.getConditions()); + int merchantSend = jo.getIntValue(WxCouponSend.KEY_MERCHANT_SEND); int merchantRemain = jo.getIntValue(WxCouponSend.KEY_MERCHANT_REMAIN); // 检查 优惠券 库存 @@ -390,7 +401,7 @@ public class WxOrderServiceImpl implements WxOrderService { try { // 减库存 - wxCouponSendService.reduceMerchantSend(wxCouponSendVo.getId(), merchantRemain,merchantSend,1); + wxCouponSendService.reduceMerchantSend(wxCouponSendVo.getId(), merchantRemain, merchantSend, 1); } catch (RuntimeException e) { logger.error("此券减库存失败, couponId: {}, error: {}", couponIdStr, e.getMessage()); throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), coupon.getTitle() + ErrorCode.ORDER_IS_LIMITED.getMessage()); @@ -403,6 +414,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 减库存 + * * @param user * @param coupon * @param couponIdStr @@ -411,7 +423,7 @@ public class WxOrderServiceImpl implements WxOrderService { long time = System.currentTimeMillis() + RedisLock.TIMEOUT; String timeStr = String.valueOf(time); // 库存加锁 - if (!redisLock.lock(couponIdStr, timeStr)) { + if (!redisLock.lock(couponIdStr, timeStr)) { logger.error("此券被锁定, couponId: " + couponIdStr); throw new MallinkException(ErrorCode.TOO_MANY_REQUEST); } @@ -525,6 +537,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 检查券商户是否可用 + * * @param couponId * @return */ @@ -733,9 +746,9 @@ public class WxOrderServiceImpl implements WxOrderService { Integer shareAmount = payOrder.getPayAmount() - fee; cardInfo.setShareFeeAmount(shareAmount); cardInfo.setRemainingShareFeeAmount(shareAmount); - if(payAccount.getRealRate() != null) { + if (payAccount.getRealRate() != null) { int iRealChargeFee = PayUtils.getPayRate(payOrder.getPayAmount(), payAccount.getRealRate(), true); - if(fee > iRealChargeFee) { + if (fee > iRealChargeFee) { cardInfo.setRateAmount(fee - iRealChargeFee); } } @@ -774,7 +787,7 @@ public class WxOrderServiceImpl implements WxOrderService { @Override @Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class}) - public WxCouponOrder sendFreeCouponToUser(Long userId, Long couponId,WxCouponSendVo wxCouponSendVo) { + public WxCouponOrder sendFreeCouponToUser(Long userId, Long couponId, WxCouponSendVo wxCouponSendVo) { // check 用户状态 WxCUser user = null; try { @@ -805,7 +818,7 @@ public class WxOrderServiceImpl implements WxOrderService { if (Objects.nonNull(wxCouponSendVo) && Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSendVo.getSendType())) { // 商户注券减库存操作 - stockMerchantReduce(user,coupon,couponIdStr,wxCouponSendVo); + stockMerchantReduce(user, coupon, couponIdStr, wxCouponSendVo); } else { // 减库存操作 stockReduce(user, coupon, couponIdStr); @@ -951,6 +964,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 下订单后操作 + * * @param updateOrder * @param coupon * @param user @@ -968,6 +982,23 @@ public class WxOrderServiceImpl implements WxOrderService { } + @Override + public Map summary(WxOrderQueryVo wxOrderQueryVo) { + List listOrder = wxOrderMapper.findListOrder(wxOrderQueryVo); + Long payment = listOrder.stream().collect(Collectors.summingLong(WxOrder::getPayment)); + Long pay = listOrder.stream().collect(Collectors.summingLong(WxOrder::getPay)); + Map data = new HashMap<>(); + data.put("payment", payment); + data.put("pay", pay); + return data; + } + + @Override + public void exportData(WxOrderQueryVo wxOrderQueryVo, HttpServletRequest request, HttpServletResponse response) { + List list = wxOrderMapper.findListOrder(wxOrderQueryVo); + excelService.exportExcel(list, null, "线上交易", WxOrder.class, "线上交易.xlsx", response, false); + } + /** * 积分设置来源商户 */ @@ -1396,7 +1427,7 @@ public class WxOrderServiceImpl implements WxOrderService { if (checkCouponIsFree(coupon)) { // 免费券 order = saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId(), null); - if(order != null) { + if (order != null) { // 6. 下订单完成,发送内部消息 // 下订单完成,发送内部消息 try { @@ -1479,6 +1510,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 保存订单-免费 + * * @param record * @param user * @param coupon @@ -1563,6 +1595,13 @@ public class WxOrderServiceImpl implements WxOrderService { public WxOrder saveNoFreeOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, boolean isPress, Long orderGroupId, String formId) { // 1. check user info and coupon info userCouponMerchantCheck(user, coupon); + if (coupon.checkIsCreditCoupon()) { + //若用户剩余积分比积分售价低则不能支付 + if (user.getCredit() == null || user.getCredit() < coupon.getCreditPrice()) { + throw new MallinkException(ErrorCode.CREDIT_NOT_ENOUGH); + } + } + // 2. 拼团检查 if (isOrderGroup(orderGroupId)) { checkOrderGroup(user, orderGroupId); @@ -1571,6 +1610,15 @@ public class WxOrderServiceImpl implements WxOrderService { // 3. 减库存操作 stockReduce(user, coupon, couponIdStr); + // 3. 当积分券或者积分停车券时 则进行积分支付 + Integer orderType; + if (coupon.checkIsCreditCoupon()) { + creditPay(user, coupon); + orderType = EnumOrderType.CREDIT.getCode(); + } else { + orderType = EnumOrderType.COUPON.getCode(); + } + // 4. 保存订单 Long orderNumber; // 4.1 券价格 @@ -1591,6 +1639,7 @@ public class WxOrderServiceImpl implements WxOrderService { // 4.2 保存订单 WxOrder record = new WxOrder(); + record.setType(orderType); record.setCouponChannelId(couponChannelId); record.setOrderGroupId(orderGroupId); record.setFormId(formId); @@ -1607,7 +1656,7 @@ public class WxOrderServiceImpl implements WxOrderService { // 5. 第一次砍价 try { firstPress(record, user, coupon, orderNumber); - }catch (Exception e) { + } catch (Exception e) { logger.error("第一次砍价失败:" + e.getMessage()); throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); } @@ -1617,6 +1666,7 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 初始砍价 + * * @param record * @param user * @param coupon @@ -1665,7 +1715,7 @@ public class WxOrderServiceImpl implements WxOrderService { record.setTenantId(user.getTenantId()); record.setOrderNumber(orderNumber); record.setProductId(coupon.getId()); - record.setType(EnumOrderType.COUPON.getCode()); + //record.setType(EnumOrderType.COUPON.getCode()); record.setCUserId(user.getId()); record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); record.setDetail(bodyStr); diff --git a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml index 754ff2690..7920504df 100644 --- a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml @@ -222,7 +222,7 @@ o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date, c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date, - co.id as coupon_order_id,co.coupon_order_status,c.support_transfer + co.id as coupon_order_id,co.coupon_order_status,c.support_transfer,c.subsidy_num @@ -278,7 +278,8 @@ - + + @@ -538,43 +539,50 @@ + + +