| @@ -7,8 +7,12 @@ import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.dto.OrderSaveDto; | 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.po.base.BaseEntity; | ||||
| import com.iformall.domain.vo.WxMerchantSubsidyVo; | |||||
| import com.iformall.domain.vo.WxOrderQueryVo; | import com.iformall.domain.vo.WxOrderQueryVo; | ||||
| import com.iformall.enums.EnumCouponChannelStatus; | import com.iformall.enums.EnumCouponChannelStatus; | ||||
| import com.iformall.enums.EnumCouponChannelType; | import com.iformall.enums.EnumCouponChannelType; | ||||
| @@ -22,12 +26,17 @@ import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | 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.Date; | ||||
| import java.util.List; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| @RestController | @RestController | ||||
| @@ -58,7 +67,9 @@ public class WxOrderController extends BaseController { | |||||
| @SystemControllerLog(description = "订单管理-列表") | @SystemControllerLog(description = "订单管理-列表") | ||||
| public ResultData list(@ModelAttribute WxOrder wxOrder, Integer pageNum, Integer pageSize) { | public ResultData list(@ModelAttribute WxOrder wxOrder, Integer pageNum, Integer pageSize) { | ||||
| logger.debug("[" + getIpAddr() + "] WxOrderController::list"); | logger.debug("[" + getIpAddr() + "] WxOrderController::list"); | ||||
| if (null == wxOrder) wxOrder = new WxOrder(); | |||||
| if (null == wxOrder) { | |||||
| wxOrder = new WxOrder(); | |||||
| } | |||||
| wxOrder.setTenantId(getTenantId()); | wxOrder.setTenantId(getTenantId()); | ||||
| wxOrder.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); | wxOrder.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); | ||||
| final PageInfo<WxOrder> page = wxOrderService.listAsPage(wxOrder, pageNum, pageSize); | final PageInfo<WxOrder> page = wxOrderService.listAsPage(wxOrder, pageNum, pageSize); | ||||
| @@ -143,7 +154,9 @@ public class WxOrderController extends BaseController { | |||||
| } | } | ||||
| WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(orderSaveDto.getCouponChannelId()); | WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(orderSaveDto.getCouponChannelId()); | ||||
| ResultData resultData = couponChannelCheck(orderSaveDto, wxCouponChannel); | ResultData resultData = couponChannelCheck(orderSaveDto, wxCouponChannel); | ||||
| if (resultData != null) return resultData; | |||||
| if (resultData != null) { | |||||
| return resultData; | |||||
| } | |||||
| Long couponId = orderSaveDto.getCouponId() == null ? wxCouponChannel.getCouponId() : orderSaveDto.getCouponId(); | Long couponId = orderSaveDto.getCouponId() == null ? wxCouponChannel.getCouponId() : orderSaveDto.getCouponId(); | ||||
| if (couponId == null) { | if (couponId == null) { | ||||
| @@ -161,8 +174,9 @@ public class WxOrderController extends BaseController { | |||||
| if (coupon == null) { | if (coupon == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| if (!wxOrderService.checkCouponIsFree(coupon)) | |||||
| if (!wxOrderService.checkCouponIsFree(coupon)) { | |||||
| return new ResultData(ErrorCode.COUPON_IS_NOT_FREE); | return new ResultData(ErrorCode.COUPON_IS_NOT_FREE); | ||||
| } | |||||
| // 免费券 | // 免费券 | ||||
| order = wxOrderService.saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId(), null); | order = wxOrderService.saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId(), null); | ||||
| return new ResultData(order); | return new ResultData(order); | ||||
| @@ -200,4 +214,42 @@ public class WxOrderController extends BaseController { | |||||
| return null; | 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<String, Object> 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); | |||||
| } | |||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| @@ -7,7 +8,6 @@ import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -23,12 +23,15 @@ public class WxOrder extends BaseEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String merchantName; | private String merchantName; | ||||
| @Excel(name = "会员", width = 20, orderNum = "2") | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String cUserName; | private String cUserName; | ||||
| @Excel(name = "会员手机号", width = 20, orderNum = "3") | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String phone; | private String phone; | ||||
| @Excel(name = "订单编号", width = 20, orderNum = "1") | |||||
| @io.swagger.annotations.ApiModelProperty(value="订单码;正反向交易保持一致。",name="orderNumber") | @io.swagger.annotations.ApiModelProperty(value="订单码;正反向交易保持一致。",name="orderNumber") | ||||
| private Long orderNumber; | private Long orderNumber; | ||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | ||||
| @@ -43,12 +46,18 @@ public class WxOrder extends BaseEntity { | |||||
| private Integer type; | private Integer type; | ||||
| @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款",name="paymentType") | @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款",name="paymentType") | ||||
| private Integer paymentType; | private Integer paymentType; | ||||
| @Excel(name = "订单金额(元)", width = 20, orderNum = "6") | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付金额(分):允许有负数,退款时为负值。",name="payment") | @io.swagger.annotations.ApiModelProperty(value="支付金额(分):允许有负数,退款时为负值。",name="payment") | ||||
| private Integer payment; | private Integer payment; | ||||
| @io.swagger.annotations.ApiModelProperty(value="支付时间",name="paymentTime") | @io.swagger.annotations.ApiModelProperty(value="支付时间",name="paymentTime") | ||||
| private Date 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") | @io.swagger.annotations.ApiModelProperty(value="订单状态:-1全部;正向交易:0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款)反向交易:3-已退款; 4-退款失败,5-退款失败; 砍价:6-砍价中,7-砍价完成,8-砍价失败",name="orderStatus") | ||||
| private Integer orderStatus; | private Integer orderStatus; | ||||
| @Excel(name = "订单日期", width = 20, orderNum = "7", format = "yyyy-MM-dd") | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间/砍价开始时间",name="createDate") | @io.swagger.annotations.ApiModelProperty(value="创建时间/砍价开始时间",name="createDate") | ||||
| private Date createDate; | private Date createDate; | ||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | ||||
| @@ -82,4 +91,15 @@ public class WxOrder extends BaseEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| protected String statusStr; | 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; | |||||
| } | } | ||||
| @@ -87,4 +87,7 @@ public class WxOrderCouponVo { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "是否可转赠", name = "supportTransfer") | @io.swagger.annotations.ApiModelProperty(value = "是否可转赠", name = "supportTransfer") | ||||
| private Integer supportTransfer; | private Integer supportTransfer; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "补贴额", name = "subsidyNum") | |||||
| private Integer subsidyNum; | |||||
| } | } | ||||
| @@ -36,4 +36,13 @@ public class WxOrderQueryVo extends BaseEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Date createDate; | 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; | |||||
| } | } | ||||
| @@ -10,6 +10,8 @@ import com.iformall.domain.vo.WxOrderCouponVo; | |||||
| import com.iformall.domain.vo.WxOrderQueryVo; | import com.iformall.domain.vo.WxOrderQueryVo; | ||||
| import com.iformall.enums.EnumOrderStatus; | import com.iformall.enums.EnumOrderStatus; | ||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -189,4 +191,8 @@ public interface WxOrderService { | |||||
| */ | */ | ||||
| void actionAfterCouponOrderSuccess(WxOrder updateOrder, WxCoupon coupon, WxCUser user); | void actionAfterCouponOrderSuccess(WxOrder updateOrder, WxCoupon coupon, WxCUser user); | ||||
| Map<String, Object> summary(WxOrderQueryVo wxOrderQueryVo); | |||||
| void exportData(WxOrderQueryVo wxOrderQueryVo, HttpServletRequest request, HttpServletResponse response); | |||||
| } | } | ||||
| @@ -199,6 +199,7 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { | |||||
| wxBillDaily.setUpdatetime(date); | wxBillDaily.setUpdatetime(date); | ||||
| wxBillDaily.setPayWay(record.getPayWay()); | wxBillDaily.setPayWay(record.getPayWay()); | ||||
| wxBillDaily.setPriceDetail(record.getPriceDetail()); | wxBillDaily.setPriceDetail(record.getPriceDetail()); | ||||
| wxBillDaily.setServiceChargePay(record.getServiceChargePay()); | |||||
| try { | try { | ||||
| wxBillDailyMapper.updateById(wxBillDaily); | wxBillDailyMapper.updateById(wxBillDaily); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -211,7 +212,11 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { | |||||
| String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | ||||
| String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | ||||
| wxBillAction.setDetails(message + price + "元"); | 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.setUserId(user.getId()); | ||||
| wxBillAction.setUserName(user.getName()); | wxBillAction.setUserName(user.getName()); | ||||
| wxBillAction.setPhone(user.getPhone()); | wxBillAction.setPhone(user.getPhone()); | ||||
| @@ -164,6 +164,7 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { | |||||
| wxBillDeposit.setPayDate(date); | wxBillDeposit.setPayDate(date); | ||||
| wxBillDeposit.setUpdatetime(date); | wxBillDeposit.setUpdatetime(date); | ||||
| wxBillDeposit.setPayWay(record.getPayWay()); | wxBillDeposit.setPayWay(record.getPayWay()); | ||||
| wxBillDeposit.setServiceChargePay(record.getServiceChargePay()); | |||||
| try { | try { | ||||
| wxBillDepositMapper.updateById(wxBillDeposit); | wxBillDepositMapper.updateById(wxBillDeposit); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -176,7 +177,11 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { | |||||
| String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | ||||
| String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | ||||
| wxBillAction.setDetails(message + price + "元"); | 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.setUserId(user.getId()); | ||||
| wxBillAction.setUserName(user.getName()); | wxBillAction.setUserName(user.getName()); | ||||
| wxBillAction.setPhone(user.getPhone()); | wxBillAction.setPhone(user.getPhone()); | ||||
| @@ -195,6 +195,7 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService | |||||
| wxBillOtherDeposit.setUpdatetime(date); | wxBillOtherDeposit.setUpdatetime(date); | ||||
| wxBillOtherDeposit.setPayWay(record.getPayWay()); | wxBillOtherDeposit.setPayWay(record.getPayWay()); | ||||
| wxBillOtherDeposit.setComments(record.getComments()); | wxBillOtherDeposit.setComments(record.getComments()); | ||||
| wxBillOtherDeposit.setServiceChargePay(record.getServiceChargePay()); | |||||
| try { | try { | ||||
| wxBillOtherDepositMapper.updateById(wxBillOtherDeposit); | wxBillOtherDepositMapper.updateById(wxBillOtherDeposit); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -207,7 +208,11 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService | |||||
| String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | ||||
| String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | ||||
| wxBillAction.setDetails(message + price + "元"); | 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.setUserId(user.getId()); | ||||
| wxBillAction.setUserName(user.getName()); | wxBillAction.setUserName(user.getName()); | ||||
| wxBillAction.setPhone(user.getPhone()); | wxBillAction.setPhone(user.getPhone()); | ||||
| @@ -196,6 +196,7 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { | |||||
| wxBillOther.setPayWay(record.getPayWay()); | wxBillOther.setPayWay(record.getPayWay()); | ||||
| wxBillOther.setComments(record.getComments()); | wxBillOther.setComments(record.getComments()); | ||||
| wxBillOther.setName(record.getName()); | wxBillOther.setName(record.getName()); | ||||
| wxBillOther.setServiceChargePay(record.getServiceChargePay()); | |||||
| try { | try { | ||||
| wxBillOtherMapper.updateById(wxBillOther); | wxBillOtherMapper.updateById(wxBillOther); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -208,7 +209,11 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { | |||||
| String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | ||||
| String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | ||||
| wxBillAction.setDetails(message + price + "元"); | 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.setUserId(user.getId()); | ||||
| wxBillAction.setUserName(user.getName()); | wxBillAction.setUserName(user.getName()); | ||||
| wxBillAction.setPhone(user.getPhone()); | wxBillAction.setPhone(user.getPhone()); | ||||
| @@ -163,6 +163,7 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe | |||||
| wxBillDeposit.setPayDate(date); | wxBillDeposit.setPayDate(date); | ||||
| wxBillDeposit.setUpdatetime(date); | wxBillDeposit.setUpdatetime(date); | ||||
| wxBillDeposit.setPayWay(record.getPayWay()); | wxBillDeposit.setPayWay(record.getPayWay()); | ||||
| wxBillDeposit.setServiceChargePay(record.getServiceChargePay()); | |||||
| try { | try { | ||||
| wxBillPropertyDepositMapper.updateById(wxBillDeposit); | wxBillPropertyDepositMapper.updateById(wxBillDeposit); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -175,7 +176,11 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe | |||||
| String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | ||||
| String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | ||||
| wxBillAction.setDetails(message + price + "元"); | 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.setUserId(user.getId()); | ||||
| wxBillAction.setUserName(user.getName()); | wxBillAction.setUserName(user.getName()); | ||||
| wxBillAction.setPhone(user.getPhone()); | wxBillAction.setPhone(user.getPhone()); | ||||
| @@ -179,6 +179,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { | |||||
| property.setPayDate(record.getPayDate()); | property.setPayDate(record.getPayDate()); | ||||
| property.setUpdatetime(date); | property.setUpdatetime(date); | ||||
| property.setPayWay(record.getPayWay()); | property.setPayWay(record.getPayWay()); | ||||
| property.setServiceChargePay(record.getServiceChargePay()); | |||||
| try { | try { | ||||
| wxBillPropertyMapper.updateById(property); | wxBillPropertyMapper.updateById(property); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -191,7 +192,12 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { | |||||
| String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | ||||
| String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | ||||
| wxBillAction.setDetails(message + price + "元"); | 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.setUserId(user.getId()); | ||||
| wxBillAction.setUserName(user.getName()); | wxBillAction.setUserName(user.getName()); | ||||
| wxBillAction.setPhone(user.getPhone()); | wxBillAction.setPhone(user.getPhone()); | ||||
| @@ -358,19 +364,6 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { | |||||
| billAction.setUpdatetime(new Date()); | billAction.setUpdatetime(new Date()); | ||||
| wxBillActionMapper.insert(billAction); | 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); | wxBillPropertyMapper.updateById(record); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -182,6 +182,7 @@ public class WxBillRentServiceImpl implements WxBillRentService { | |||||
| wxBillRent.setPayDate(record.getPayDate()); | wxBillRent.setPayDate(record.getPayDate()); | ||||
| wxBillRent.setUpdatetime(date); | wxBillRent.setUpdatetime(date); | ||||
| wxBillRent.setPayWay(record.getPayWay()); | wxBillRent.setPayWay(record.getPayWay()); | ||||
| wxBillRent.setServiceChargePay(record.getServiceChargePay()); | |||||
| try { | try { | ||||
| wxBillRentMapper.updateById(wxBillRent); | wxBillRentMapper.updateById(wxBillRent); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -194,7 +195,12 @@ public class WxBillRentServiceImpl implements WxBillRentService { | |||||
| String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | ||||
| String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | ||||
| wxBillAction.setDetails(message + price + "元"); | 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.setUserId(user.getId()); | ||||
| wxBillAction.setUserName(user.getName()); | wxBillAction.setUserName(user.getName()); | ||||
| wxBillAction.setPhone(user.getPhone()); | wxBillAction.setPhone(user.getPhone()); | ||||
| @@ -471,20 +477,6 @@ public class WxBillRentServiceImpl implements WxBillRentService { | |||||
| billAction.setUpdatetime(new Date()); | billAction.setUpdatetime(new Date()); | ||||
| wxBillActionMapper.insert(billAction); | 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); | wxBillRentMapper.updateById(record); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -18,7 +18,6 @@ import com.iformall.mapper.*; | |||||
| import com.iformall.mq.MqBaseProducer; | import com.iformall.mq.MqBaseProducer; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.EventUtil; | |||||
| import com.iformall.utils.JsonUtil; | import com.iformall.utils.JsonUtil; | ||||
| import org.apache.commons.collections.CollectionUtils; | import org.apache.commons.collections.CollectionUtils; | ||||
| import org.apache.commons.collections.map.HashedMap; | import org.apache.commons.collections.map.HashedMap; | ||||
| @@ -147,7 +146,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| //如果审批完成,而且是补录直接改为已签约状态(普通需要绑定商户才是已签约) | //如果审批完成,而且是补录直接改为已签约状态(普通需要绑定商户才是已签约) | ||||
| WxRentContract record = wxRentContractMapper.selectById(businessId); | 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); | wxRentContractService.updateRentContractStatus(businessId); | ||||
| } | } | ||||
| }else if(EnumFlowContractType.PROPERTY.getCode().equals(contractType) || EnumFlowContractType.PROPERTY_POINT.getCode().equals(contractType)){ | }else if(EnumFlowContractType.PROPERTY.getCode().equals(contractType) || EnumFlowContractType.PROPERTY_POINT.getCode().equals(contractType)){ | ||||
| @@ -25,10 +25,13 @@ import org.springframework.stereotype.Service; | |||||
| import org.springframework.transaction.annotation.Propagation; | import org.springframework.transaction.annotation.Propagation; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.text.ParseException; | import java.text.ParseException; | ||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.stream.Collectors; | |||||
| @Service | @Service | ||||
| public class WxOrderServiceImpl implements WxOrderService { | public class WxOrderServiceImpl implements WxOrderService { | ||||
| @@ -122,6 +125,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponPasswordMapper couponPasswordMapper; | private WxCouponPasswordMapper couponPasswordMapper; | ||||
| @Autowired | |||||
| ExcelService excelService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); | ||||
| @@ -216,6 +222,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| /** | /** | ||||
| * 用户购买的订单数量 | * 用户购买的订单数量 | ||||
| * | |||||
| * @param user | * @param user | ||||
| * @param counpon | * @param counpon | ||||
| * @return | * @return | ||||
| @@ -244,6 +251,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| /** | /** | ||||
| * 用户购买的订单数量 | * 用户购买的订单数量 | ||||
| * | |||||
| * @param user | * @param user | ||||
| * @param counpon | * @param counpon | ||||
| * @return | * @return | ||||
| @@ -263,7 +271,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); | statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); | ||||
| orderQ.setStatusS(statusS); | orderQ.setStatusS(statusS); | ||||
| List<WxOrder> orders = wxOrderMapper.findList(orderQ); | List<WxOrder> orders = wxOrderMapper.findList(orderQ); | ||||
| if(orders.size() >= 1) { | |||||
| if (orders.size() >= 1) { | |||||
| return orders.get(0); | return orders.get(0); | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -275,6 +283,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| /** | /** | ||||
| * 用户正在参加的新手活动 | * 用户正在参加的新手活动 | ||||
| * | |||||
| * @param user | * @param user | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| @@ -305,6 +314,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| /** | /** | ||||
| * 用户购买的券包数量- 待使用的券 | * 用户购买的券包数量- 待使用的券 | ||||
| * | |||||
| * @param user | * @param user | ||||
| * @param counpon | * @param counpon | ||||
| * @return | * @return | ||||
| @@ -329,6 +339,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| /** | /** | ||||
| * 商户注券减库存 | * 商户注券减库存 | ||||
| * | |||||
| * @param user | * @param user | ||||
| * @param coupon | * @param coupon | ||||
| * @param couponIdStr | * @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()); | 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); | int merchantRemain = jo.getIntValue(WxCouponSend.KEY_MERCHANT_REMAIN); | ||||
| // 检查 优惠券 库存 | // 检查 优惠券 库存 | ||||
| @@ -390,7 +401,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| try { | try { | ||||
| // 减库存 | // 减库存 | ||||
| wxCouponSendService.reduceMerchantSend(wxCouponSendVo.getId(), merchantRemain,merchantSend,1); | |||||
| wxCouponSendService.reduceMerchantSend(wxCouponSendVo.getId(), merchantRemain, merchantSend, 1); | |||||
| } catch (RuntimeException e) { | } catch (RuntimeException e) { | ||||
| logger.error("此券减库存失败, couponId: {}, error: {}", couponIdStr, e.getMessage()); | logger.error("此券减库存失败, couponId: {}, error: {}", couponIdStr, e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), coupon.getTitle() + ErrorCode.ORDER_IS_LIMITED.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 user | ||||
| * @param coupon | * @param coupon | ||||
| * @param couponIdStr | * @param couponIdStr | ||||
| @@ -411,7 +423,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| long time = System.currentTimeMillis() + RedisLock.TIMEOUT; | long time = System.currentTimeMillis() + RedisLock.TIMEOUT; | ||||
| String timeStr = String.valueOf(time); | String timeStr = String.valueOf(time); | ||||
| // 库存加锁 | // 库存加锁 | ||||
| if (!redisLock.lock(couponIdStr, timeStr)) { | |||||
| if (!redisLock.lock(couponIdStr, timeStr)) { | |||||
| logger.error("此券被锁定, couponId: " + couponIdStr); | logger.error("此券被锁定, couponId: " + couponIdStr); | ||||
| throw new MallinkException(ErrorCode.TOO_MANY_REQUEST); | throw new MallinkException(ErrorCode.TOO_MANY_REQUEST); | ||||
| } | } | ||||
| @@ -525,6 +537,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| /** | /** | ||||
| * 检查券商户是否可用 | * 检查券商户是否可用 | ||||
| * | |||||
| * @param couponId | * @param couponId | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| @@ -733,9 +746,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| Integer shareAmount = payOrder.getPayAmount() - fee; | Integer shareAmount = payOrder.getPayAmount() - fee; | ||||
| cardInfo.setShareFeeAmount(shareAmount); | cardInfo.setShareFeeAmount(shareAmount); | ||||
| cardInfo.setRemainingShareFeeAmount(shareAmount); | cardInfo.setRemainingShareFeeAmount(shareAmount); | ||||
| if(payAccount.getRealRate() != null) { | |||||
| if (payAccount.getRealRate() != null) { | |||||
| int iRealChargeFee = PayUtils.getPayRate(payOrder.getPayAmount(), payAccount.getRealRate(), true); | int iRealChargeFee = PayUtils.getPayRate(payOrder.getPayAmount(), payAccount.getRealRate(), true); | ||||
| if(fee > iRealChargeFee) { | |||||
| if (fee > iRealChargeFee) { | |||||
| cardInfo.setRateAmount(fee - iRealChargeFee); | cardInfo.setRateAmount(fee - iRealChargeFee); | ||||
| } | } | ||||
| } | } | ||||
| @@ -774,7 +787,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class}) | @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 用户状态 | // check 用户状态 | ||||
| WxCUser user = null; | WxCUser user = null; | ||||
| try { | try { | ||||
| @@ -805,7 +818,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| if (Objects.nonNull(wxCouponSendVo) && Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSendVo.getSendType())) { | if (Objects.nonNull(wxCouponSendVo) && Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSendVo.getSendType())) { | ||||
| // 商户注券减库存操作 | // 商户注券减库存操作 | ||||
| stockMerchantReduce(user,coupon,couponIdStr,wxCouponSendVo); | |||||
| stockMerchantReduce(user, coupon, couponIdStr, wxCouponSendVo); | |||||
| } else { | } else { | ||||
| // 减库存操作 | // 减库存操作 | ||||
| stockReduce(user, coupon, couponIdStr); | stockReduce(user, coupon, couponIdStr); | ||||
| @@ -951,6 +964,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| /** | /** | ||||
| * 下订单后操作 | * 下订单后操作 | ||||
| * | |||||
| * @param updateOrder | * @param updateOrder | ||||
| * @param coupon | * @param coupon | ||||
| * @param user | * @param user | ||||
| @@ -968,6 +982,23 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| } | } | ||||
| @Override | |||||
| public Map<String, Object> summary(WxOrderQueryVo wxOrderQueryVo) { | |||||
| List<WxOrder> listOrder = wxOrderMapper.findListOrder(wxOrderQueryVo); | |||||
| Long payment = listOrder.stream().collect(Collectors.summingLong(WxOrder::getPayment)); | |||||
| Long pay = listOrder.stream().collect(Collectors.summingLong(WxOrder::getPay)); | |||||
| Map<String, Object> data = new HashMap<>(); | |||||
| data.put("payment", payment); | |||||
| data.put("pay", pay); | |||||
| return data; | |||||
| } | |||||
| @Override | |||||
| public void exportData(WxOrderQueryVo wxOrderQueryVo, HttpServletRequest request, HttpServletResponse response) { | |||||
| List<WxOrder> 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)) { | if (checkCouponIsFree(coupon)) { | ||||
| // 免费券 | // 免费券 | ||||
| order = saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId(), null); | order = saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId(), null); | ||||
| if(order != null) { | |||||
| if (order != null) { | |||||
| // 6. 下订单完成,发送内部消息 | // 6. 下订单完成,发送内部消息 | ||||
| // 下订单完成,发送内部消息 | // 下订单完成,发送内部消息 | ||||
| try { | try { | ||||
| @@ -1479,6 +1510,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| /** | /** | ||||
| * 保存订单-免费 | * 保存订单-免费 | ||||
| * | |||||
| * @param record | * @param record | ||||
| * @param user | * @param user | ||||
| * @param coupon | * @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) { | public WxOrder saveNoFreeOrderForCoupon(WxCUser user, WxCoupon coupon, Long couponChannelId, boolean isPress, Long orderGroupId, String formId) { | ||||
| // 1. check user info and coupon info | // 1. check user info and coupon info | ||||
| userCouponMerchantCheck(user, coupon); | userCouponMerchantCheck(user, coupon); | ||||
| if (coupon.checkIsCreditCoupon()) { | |||||
| //若用户剩余积分比积分售价低则不能支付 | |||||
| if (user.getCredit() == null || user.getCredit() < coupon.getCreditPrice()) { | |||||
| throw new MallinkException(ErrorCode.CREDIT_NOT_ENOUGH); | |||||
| } | |||||
| } | |||||
| // 2. 拼团检查 | // 2. 拼团检查 | ||||
| if (isOrderGroup(orderGroupId)) { | if (isOrderGroup(orderGroupId)) { | ||||
| checkOrderGroup(user, orderGroupId); | checkOrderGroup(user, orderGroupId); | ||||
| @@ -1571,6 +1610,15 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| // 3. 减库存操作 | // 3. 减库存操作 | ||||
| stockReduce(user, coupon, couponIdStr); | stockReduce(user, coupon, couponIdStr); | ||||
| // 3. 当积分券或者积分停车券时 则进行积分支付 | |||||
| Integer orderType; | |||||
| if (coupon.checkIsCreditCoupon()) { | |||||
| creditPay(user, coupon); | |||||
| orderType = EnumOrderType.CREDIT.getCode(); | |||||
| } else { | |||||
| orderType = EnumOrderType.COUPON.getCode(); | |||||
| } | |||||
| // 4. 保存订单 | // 4. 保存订单 | ||||
| Long orderNumber; | Long orderNumber; | ||||
| // 4.1 券价格 | // 4.1 券价格 | ||||
| @@ -1591,6 +1639,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| // 4.2 保存订单 | // 4.2 保存订单 | ||||
| WxOrder record = new WxOrder(); | WxOrder record = new WxOrder(); | ||||
| record.setType(orderType); | |||||
| record.setCouponChannelId(couponChannelId); | record.setCouponChannelId(couponChannelId); | ||||
| record.setOrderGroupId(orderGroupId); | record.setOrderGroupId(orderGroupId); | ||||
| record.setFormId(formId); | record.setFormId(formId); | ||||
| @@ -1607,7 +1656,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| // 5. 第一次砍价 | // 5. 第一次砍价 | ||||
| try { | try { | ||||
| firstPress(record, user, coupon, orderNumber); | firstPress(record, user, coupon, orderNumber); | ||||
| }catch (Exception e) { | |||||
| } catch (Exception e) { | |||||
| logger.error("第一次砍价失败:" + e.getMessage()); | logger.error("第一次砍价失败:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); | throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); | ||||
| } | } | ||||
| @@ -1617,6 +1666,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| /** | /** | ||||
| * 初始砍价 | * 初始砍价 | ||||
| * | |||||
| * @param record | * @param record | ||||
| * @param user | * @param user | ||||
| * @param coupon | * @param coupon | ||||
| @@ -1665,7 +1715,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| record.setTenantId(user.getTenantId()); | record.setTenantId(user.getTenantId()); | ||||
| record.setOrderNumber(orderNumber); | record.setOrderNumber(orderNumber); | ||||
| record.setProductId(coupon.getId()); | record.setProductId(coupon.getId()); | ||||
| record.setType(EnumOrderType.COUPON.getCode()); | |||||
| //record.setType(EnumOrderType.COUPON.getCode()); | |||||
| record.setCUserId(user.getId()); | record.setCUserId(user.getId()); | ||||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | ||||
| record.setDetail(bodyStr); | record.setDetail(bodyStr); | ||||
| @@ -222,7 +222,7 @@ | |||||
| <sql id="allCUserOrderDetailColumns"> | <sql id="allCUserOrderDetailColumns"> | ||||
| 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, | 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, | 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 | |||||
| </sql> | </sql> | ||||
| <update id="updateStatusByPressCouponId" parameterType="com.iformall.domain.po.WxOrder"> | <update id="updateStatusByPressCouponId" parameterType="com.iformall.domain.po.WxOrder"> | ||||
| @@ -278,7 +278,8 @@ | |||||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | <result column="remark" jdbcType="VARCHAR" property="remark"/> | ||||
| <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/> | <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/> | ||||
| <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/> | <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/> | ||||
| <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"></result> | |||||
| <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/> | <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/> | ||||
| <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/> | <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/> | ||||
| <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" /> | <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" /> | ||||
| @@ -538,43 +539,50 @@ | |||||
| <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | ||||
| <result column="c_user_name" jdbcType="VARCHAR" property="cUserName"/> | <result column="c_user_name" jdbcType="VARCHAR" property="cUserName"/> | ||||
| <result column="phone" jdbcType="VARCHAR" property="phone"/> | <result column="phone" jdbcType="VARCHAR" property="phone"/> | ||||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||||
| <result column="attribute" jdbcType="INTEGER" property="attribute"/> | |||||
| <result column="pay" jdbcType="INTEGER" property="pay"/> | |||||
| </resultMap> | </resultMap> | ||||
| <select id="findListOrder" resultMap="orderMap" parameterType="com.iformall.domain.vo.WxOrderQueryVo"> | <select id="findListOrder" resultMap="orderMap" parameterType="com.iformall.domain.vo.WxOrderQueryVo"> | ||||
| select o.* from ( | |||||
| select o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.type,o.payment_type,o.payment,o.payment_time, | |||||
| o.order_status,o.create_date,o.update_date,o.detail,'[多商户交易]' merchant_name,cubi.`name` c_user_name,cubi.phone | |||||
| from | |||||
| ( | |||||
| select o.* from wx_order o where o.type=0 and o.order_status in (0,2,3,1,4) and o.id in( | |||||
| select o.id from wx_order o left join wx_coupon_merchant cm | |||||
| on o.product_id=cm.product_id group by o.id having count(o.id)>1)) o | |||||
| left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id where o.tenant_id =#{tenantId} | |||||
| select o.*,case o.order_status when 0 then 0 when 2 then 0 else o.payment end pay from ( | |||||
| select o.id,o.order_number,o.tenant_id,o.product_id,o.payment,o.order_status, | |||||
| c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,1 attribute from wx_order o | |||||
| left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id | |||||
| left join wx_coupon c on o.product_id=c.id | |||||
| where o.tenant_id=#{tenantId} and c.type=100 | |||||
| union all | union all | ||||
| select o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.type,o.payment_type,o.payment,o.payment_time, | |||||
| o.order_status,o.create_date,o.update_date,o.detail,m.`name` merchant_name,cubi.`name` c_user_name,cubi.phone | |||||
| from( | |||||
| select o.*,cm.merchant_id from ( | |||||
| select o.* from wx_order o where o.type=0 and o.order_status in (0,2,3,1,4) and o.id not in( | |||||
| select o.id from wx_order o left join wx_coupon_merchant cm | |||||
| on o.product_id=cm.product_id group by o.id having count(o.id)>1) | |||||
| ) o | |||||
| left join wx_coupon_merchant cm on o.product_id=cm.product_id where o.tenant_id =#{tenantId} | |||||
| select o.id,o.order_number,o.tenant_id,o.product_id,o.payment,o.order_status, | |||||
| c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,2 attribute from wx_order o | |||||
| left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id | |||||
| left join wx_coupon c on o.product_id=c.id | |||||
| where o.tenant_id=#{tenantId} and c.type!=100 and o.payment=c.price | |||||
| union all | union all | ||||
| select o.*,mbu.merchant_id from wx_order o | |||||
| left join wx_merchant_b_user mbu on o.product_id=mbu.id | |||||
| where o.type in (1,2) and o.order_status in (0,2,3,1,4) ) o | |||||
| left join wx_merchant m on o.merchant_id=m.id | |||||
| left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id where o.tenant_id =#{tenantId} | |||||
| select o.id,o.order_number,o.tenant_id,o.product_id,o.payment, | |||||
| case o.order_status when 6 then 0 when 7 then 1 | |||||
| when 8 then 2 when 9 then 2 else o.order_status end order_status, | |||||
| c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,3 attribute from wx_order o | |||||
| left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id | |||||
| left join wx_coupon c on o.product_id=c.id | |||||
| where o.tenant_id=#{tenantId} and c.type=8 and o.payment!=c.price | |||||
| union all | |||||
| select o.id,o.order_number,o.tenant_id,o.product_id,o.payment, | |||||
| case o.order_status when 10 then 1 when 11 then 1 | |||||
| when 12 then 4 when 13 then 4 when 14 then 4 when 15 then 0 when 16 then 2 | |||||
| else o.order_status end order_status, | |||||
| c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,4 attribute from wx_order o | |||||
| left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id | |||||
| left join wx_coupon c on o.product_id=c.id | |||||
| where o.tenant_id=#{tenantId} and c.type=9 and o.payment!=c.price | |||||
| ) o | ) o | ||||
| <where> | <where> | ||||
| <if test="tenantId!=null"> | <if test="tenantId!=null"> | ||||
| and o.tenant_id =#{tenantId} | and o.tenant_id =#{tenantId} | ||||
| </if> | </if> | ||||
| <if test="merchantName!=null and merchantName!=''"> | |||||
| and o.`merchant_name` like concat('%',#{merchantName},'%') | |||||
| <if test="title!=null and title!=''"> | |||||
| and o.`title` like concat('%',#{title},'%') | |||||
| </if> | </if> | ||||
| <if test="payment!=null and (payment== '' or payment == 0)"> | <if test="payment!=null and (payment== '' or payment == 0)"> | ||||
| and o.`payment` = 0 | and o.`payment` = 0 | ||||
| @@ -589,6 +597,12 @@ | |||||
| <if test="orderStatus!=null"> | <if test="orderStatus!=null"> | ||||
| and o.order_status = #{orderStatus} | and o.order_status = #{orderStatus} | ||||
| </if> | </if> | ||||
| <if test="attribute!=null"> | |||||
| and o.attribute = #{attribute} | |||||
| </if> | |||||
| <if test="orderNumber!=null"> | |||||
| and o.order_number like concat('%',#{orderNumber},'%') | |||||
| </if> | |||||
| </where> | </where> | ||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||