| @@ -1,117 +0,0 @@ | |||
| package com.simple.controller; | |||
| import com.simple.common.ErrorCode; | |||
| import com.simple.domain.po.WxMerchantBUser; | |||
| import com.simple.domain.vo.OrderVo; | |||
| import com.simple.enums.EnumOrderStatus; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.models.auth.In; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.util.Assert; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxOrder; | |||
| import com.simple.service.WxOrderService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("/order") | |||
| @Api(description="订单相关接口") | |||
| public class WxOrderController extends BaseController { | |||
| private Logger logger = Logger.getLogger(WxOrderController.class); | |||
| @Autowired | |||
| private WxOrderService wxOrderService; | |||
| @GetMapping("list") | |||
| @ApiOperation(value = "券查询接口", notes="") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "orderStatus", value = "订单状态:-1全部;0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款);3-未退款/待退款;4-已退款;5-退款失败", required = false, dataType = "Integer"), | |||
| @ApiImplicitParam(name = "couponStatus", value = "券状态:-1全部;3:已领取/已购买/未核销/未使用,4:已核销/已使用,5:已过期,6:已退券", required = false, dataType = "Integer") | |||
| }) | |||
| public ResultData list(Integer orderStatus, Integer couponStatus, Integer pageNum, Integer pageSize) { | |||
| WxMerchantBUser user = getUser(); | |||
| OrderVo orderVo = new OrderVo(); | |||
| orderVo.setbUserId(user.getId()); | |||
| if (orderStatus != -1) | |||
| orderVo.setOrderStatus(orderStatus); | |||
| if (couponStatus != -1) | |||
| orderVo.setCouponStatus(couponStatus); | |||
| final PageInfo<Map<String,Object>> page = wxOrderService.bQueryListMap(orderVo, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation(value = "订单详情", notes = "{\"couponOrderId\":\"String\",\"orderId\":\"String\",\"couponId\":\"String\"}") | |||
| @GetMapping("detail") | |||
| public ResultData orderDetail(@RequestBody Map<String, String> paramMap) { | |||
| //Assert.notNull(wxOrders.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| String couponOrderIdStr = paramMap.get("couponOrderId"); | |||
| String orderIdStr = paramMap.get("orderId"); | |||
| String couponIdStr = paramMap.get("couponId"); | |||
| if (StringUtils.isBlank(couponOrderIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponOrderId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(orderIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(couponIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponId不能为空"); | |||
| } | |||
| Long couponOrderId = 0L, orderId = 0L, couponId = 0L; | |||
| try { | |||
| couponOrderId = Long.valueOf(couponOrderIdStr); | |||
| orderId = Long.valueOf(orderIdStr); | |||
| couponId = Long.valueOf(couponIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("couponOrderId " + couponOrderIdStr + ", e:" + e.getMessage()); | |||
| } | |||
| WxMerchantBUser user = getUser(); | |||
| OrderVo orderVo = new OrderVo(); | |||
| orderVo.setbUserId(user.getId()); | |||
| orderVo.setOrderId(orderId); | |||
| orderVo.setCouponId(couponId); | |||
| Map<String,Object> map = wxOrderService.queryObject(orderVo); | |||
| return new ResultData(map); | |||
| } | |||
| @ApiOperation(value = "手工退款", notes = "{\"orderId\":\"string\"}") | |||
| @PostMapping("refund") | |||
| public ResultData expiringOrder(@RequestBody Map<String, String> paramMap) { | |||
| //Assert.notNull(wxOrders.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| String orderIdStr = paramMap.get("orderId"); | |||
| if (StringUtils.isBlank(orderIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | |||
| } | |||
| Long orderId = 0L; | |||
| try { | |||
| orderId = Long.valueOf(orderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("orderId " + orderIdStr + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "订单ID转换异常"); | |||
| } | |||
| try { | |||
| WxOrder order = wxOrderService.getById(orderId); | |||
| if (order != null) { | |||
| wxOrderService.updateOrderStatus(order, EnumOrderStatus.ORDER_STATUS_PENDING_REFUND); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("orderId " + orderIdStr + ", e:" + e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -1,96 +0,0 @@ | |||
| package com.simple.domain.vo; | |||
| import java.io.Serializable; | |||
| public class OrderVo implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| /*商户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") | |||
| private Long merchantId; | |||
| /*订单ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="订单ID",name="orderId") | |||
| private Long orderId; | |||
| /*卡券ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="卡券ID",name="couponId") | |||
| private Long couponId; | |||
| /*c端用户id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="c端用户id",name="cUserId") | |||
| private Long cUserId; | |||
| /*b端用户id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="b端用户id",name="bUserId") | |||
| private Long bUserId; | |||
| /*订单状态**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="订单状态",name="orderStatus") | |||
| private Integer orderStatus; | |||
| /*券状态**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="券状态",name="status") | |||
| private Integer couponStatus; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String tenantId) { | |||
| this.tenantId = tenantId; | |||
| } | |||
| public Long getMerchantId() { | |||
| return merchantId; | |||
| } | |||
| public void setMerchantId(Long merchantId) { | |||
| this.merchantId = merchantId; | |||
| } | |||
| public Long getOrderId() { | |||
| return orderId; | |||
| } | |||
| public void setOrderId(Long orderId) { | |||
| this.orderId = orderId; | |||
| } | |||
| public Long getCouponId() { | |||
| return couponId; | |||
| } | |||
| public void setCouponId(Long couponId) { | |||
| this.couponId = couponId; | |||
| } | |||
| public Long getcUserId() { | |||
| return cUserId; | |||
| } | |||
| public void setcUserId(Long cUserId) { | |||
| this.cUserId = cUserId; | |||
| } | |||
| public Long getbUserId() { | |||
| return bUserId; | |||
| } | |||
| public void setbUserId(Long bUserId) { | |||
| this.bUserId = bUserId; | |||
| } | |||
| public Integer getOrderStatus() { | |||
| return orderStatus; | |||
| } | |||
| public void setOrderStatus(Integer orderStatus) { | |||
| this.orderStatus = orderStatus; | |||
| } | |||
| public Integer getCouponStatus() { | |||
| return couponStatus; | |||
| } | |||
| public void setCouponStatus(Integer couponStatus) { | |||
| this.couponStatus = couponStatus; | |||
| } | |||
| } | |||
| @@ -3,7 +3,6 @@ package com.simple.mapper; | |||
| import java.util.*; | |||
| import com.simple.common.CommonMapper; | |||
| import com.simple.domain.po.WxCouponOrder; | |||
| import com.simple.domain.vo.OrderVo; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.simple.domain.po.WxOrder; | |||
| @@ -11,9 +10,5 @@ public interface WxOrderMapper extends CommonMapper<WxOrder, Long> { | |||
| List<WxOrder> findList(WxOrder wxOrder); | |||
| List<Map<String,Object>> queryListMap(OrderVo orderVo); | |||
| Map<String,Object> queryObject(OrderVo orderVo); | |||
| List<WxOrder> findListOfUnpaidOrderByDate(Map dateMap); | |||
| } | |||
| @@ -4,7 +4,6 @@ import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxCUser; | |||
| import com.simple.domain.po.WxOrder; | |||
| import com.simple.domain.vo.OrderVo; | |||
| import com.simple.enums.EnumOrderStatus; | |||
| public interface WxOrderService { | |||
| @@ -19,22 +18,6 @@ public interface WxOrderService { | |||
| */ | |||
| PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param orderVo | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<Map<String,Object>> bQueryListMap(OrderVo orderVo, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 查询券详情 | |||
| * @param orderVo | |||
| * @return | |||
| */ | |||
| Map<String,Object> queryObject(OrderVo orderVo); | |||
| /** | |||
| * 提交订单 | |||
| @@ -8,7 +8,6 @@ import com.simple.domain.po.WxCUser; | |||
| import com.simple.domain.po.WxCoupon; | |||
| import com.simple.domain.po.WxCouponOrder; | |||
| import com.simple.domain.po.WxOrder; | |||
| import com.simple.domain.vo.OrderVo; | |||
| import com.simple.enums.*; | |||
| import com.simple.exception.MallinkException; | |||
| import com.simple.mapper.*; | |||
| @@ -61,15 +60,6 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public PageInfo<Map<String, Object>> bQueryListMap(OrderVo orderVo, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.queryListMap(orderVo)); | |||
| } | |||
| @Override | |||
| public Map<String, Object> queryObject(OrderVo orderVo) { | |||
| return wxOrderMapper.queryObject(orderVo); | |||
| } | |||
| private int getUserCouponOrderCount(WxCUser user, WxCoupon counpon) { | |||
| // 用户购买的券包数量 | |||
| @@ -109,86 +109,6 @@ | |||
| </select> | |||
| <select id="queryListMap" parameterType="com.simple.domain.vo.OrderVo" resultType="hashmap"> | |||
| select o.id orderId, c.title, v.verification_date, | |||
| o.c_user_id, uc.phone, uc.nick_name, c.price, c.sale_price, | |||
| o.`order_status`, co.`coupon_status` | |||
| from wx_order o | |||
| left join wx_coupon_order co on co.order_id = o.id | |||
| left join wx_coupon c on c.id = co.coupon_id | |||
| left join wx_coupon_verify v on v.coupon_id= co.coupon_id | |||
| left join wx_c_user uc on uc.id = o.c_user_id | |||
| left join wx_merchant_b_user ub on ub.id = o.b_user_id | |||
| <where> | |||
| <if test="tenantId != null and tenantId !=''"> | |||
| and c.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test="merchantId != null and merchantId !=''"> | |||
| and c.`merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test="orderId != null and orderId!=''"> | |||
| and o.`id` = #{orderId} | |||
| </if> | |||
| <if test="couponId != null and couponId!=''"> | |||
| and co.`coupon_id` = #{couponId} | |||
| </if> | |||
| <if test="cUserId != null and cUserId !=''"> | |||
| and o.`c_user_id` = #{cUserId} | |||
| </if> | |||
| <if test="bUserId != null and bUserId !=''"> | |||
| and o.`b_user_id` = #{bUserId} | |||
| </if> | |||
| <if test="orderStatus != null and orderStatus != ''" > | |||
| and o.`order_status` = #{status} | |||
| </if> | |||
| <if test="couponStatus != null and couponStatus != ''"> | |||
| and co.`coupon_status` = #{couponStatus} | |||
| </if> | |||
| </where> | |||
| <choose> | |||
| <otherwise> | |||
| order by o.`id` desc | |||
| </otherwise> | |||
| </choose> | |||
| </select> | |||
| <select id="queryObject" parameterType="com.simple.domain.vo.OrderVo" resultType="hashmap"> | |||
| select o.id, o.coupon_id, c.title, c.sub_title, v.verification_date, | |||
| o.c_user_id, o.create_date, u.phone, u.nick_name, c.price, c.sale_price, | |||
| o.status, o.coupon_status, c.remark | |||
| from wx_order o | |||
| left join wx_coupon c on c.id = o.coupon_id | |||
| left join wx_coupon_verify v on v.coupon_id= o.coupon_id | |||
| left join wx_c_user u on u.id = o.c_user_id | |||
| <where> | |||
| <if test="tenantId != null and tenantId !=''"> | |||
| and c.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test="merchantId != null and merchantId !=''"> | |||
| and c.`merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test="orderId != null and orderId!=''"> | |||
| and o.`id` = #{orderId} | |||
| </if> | |||
| <if test="couponId != null and couponId!=''"> | |||
| and o.`coupon_id` = #{couponId} | |||
| </if> | |||
| <if test="cUserId != null and cUserId !=''"> | |||
| and o.`c_user_id` = #{cUserId} | |||
| </if> | |||
| <if test="status != null and status != ''" > | |||
| and o.`status` = #{status} | |||
| </if> | |||
| <if test="couponStatus != null and couponStatus.trim() != ''"> | |||
| and o.`coupon_status` = #{couponStatus} | |||
| </if> | |||
| </where> | |||
| <choose> | |||
| <otherwise> | |||
| order by id desc | |||
| </otherwise> | |||
| </choose> | |||
| </select> | |||
| <select id="findListOfUnpaidOrderByDate" parameterType="map" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_order | |||