| @@ -0,0 +1,34 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.AiOrder; | |||||
| import com.iformall.service.AiOrderService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("aiOrder") | |||||
| @Api(description = "核销和用户卡券查询接口") | |||||
| public class AiOrderController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private AiOrderService aiOrderService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(@ModelAttribute AiOrder aiOrder, Integer pageNum, Integer pageSize) { | |||||
| aiOrder.updateTenantInfo(getTenantInfo()); | |||||
| return new ResultData(aiOrderService.listAsPage(aiOrder, pageNum, pageSize)); | |||||
| } | |||||
| } | |||||
| @@ -442,6 +442,13 @@ public class BaseMyBatisConfiguration { | |||||
| wxEnergyReadingCalcuteResultSharding.setRule(EnumShardingRule.HASH.getCode()); | wxEnergyReadingCalcuteResultSharding.setRule(EnumShardingRule.HASH.getCode()); | ||||
| shardingList.add(wxEnergyReadingCalcuteResultSharding); | shardingList.add(wxEnergyReadingCalcuteResultSharding); | ||||
| ShardingSphere aiOrderSharding = new ShardingSphere(); | |||||
| aiOrderSharding.setColumn("tenant_id"); | |||||
| aiOrderSharding.setTableName("ai_order"); | |||||
| aiOrderSharding.setCount(100); | |||||
| aiOrderSharding.setRule(EnumShardingRule.HASH.getCode()); | |||||
| shardingList.add(aiOrderSharding); | |||||
| //初始化 | //初始化 | ||||
| shardingSpherePlugin.setShardingSpheres(shardingList); | shardingSpherePlugin.setShardingSpheres(shardingList); | ||||
| Properties properties = new Properties(); | Properties properties = new Properties(); | ||||
| @@ -0,0 +1,89 @@ | |||||
| package com.iformall.domain.po; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.fasterxml.jackson.annotation.JsonFormat; | |||||
| import com.iformall.common.SortColumn; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.math.BigDecimal; | |||||
| import java.text.DecimalFormat; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| /** | |||||
| * "1.创建订单时同步创建。 | |||||
| 2.每天凌晨查询昨天创建的订单,同步wx_coupon_order | |||||
| 3.coupon_order_status==0(待使用)的订单每隔2个小时同步" | |||||
| */ | |||||
| @TableName(value = "ai_order") | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class AiOrder extends TenantEntity { | |||||
| protected Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "订单ID(WxOrder)", name = "orderId") | |||||
| private Long orderId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "券码ID", name = "couponOrderId") | |||||
| private Long couponOrderId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "卡券ID", name = "couponId") | |||||
| private Long couponId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "EnumCouponType", name = "couponType") | |||||
| private Integer couponType; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "couponTitle", name = "couponTitle") | |||||
| private String couponTitle; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "券实际购买价格", name = "couponSalePrice") | |||||
| private Integer couponSalePrice; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "面值", name = "couponPrice") | |||||
| private Integer couponPrice; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "补贴", name = "couponSubsidy") | |||||
| private Integer couponSubsidy; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商户用户ID", name = "bUserId") | |||||
| private Long bUserId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商户用户电话", name = "bUserPhone") | |||||
| private String bUserPhone; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商户ID", name = "bMerchantId") | |||||
| private Long bMerchantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "商户ID", name = "bMerchantName") | |||||
| private String bMerchantName; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "品牌ID", name = "brandId") | |||||
| private Long brandId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "品牌名称", name = "brandName") | |||||
| private String brandName; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "业态", name = "bussiness") | |||||
| private Long bussiness; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "品牌名称", name = "bussinessName") | |||||
| private String bussinessName; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "店铺号", name = "shopNumber") | |||||
| private String shopNumber; | |||||
| @io.swagger.annotations.ApiModelProperty(value="赠券商户编号",name="sendMerchantId") | |||||
| private Long sendMerchantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "赠券商户名称", name = "sendMerchantName") | |||||
| private String sendMerchantName; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "订单创建时间(wxOrder)", name = "createDate") | |||||
| private Date createDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "订单更新时间", name = "updateDate") | |||||
| private Date updateDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "核销时间", name = "verifyTime") | |||||
| private Date verifyTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "过期时间", name = "expiredTime") | |||||
| private Date expiredTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "持有者ID", name = "ownerId") | |||||
| private Long ownerId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "持有者电话", name = "ownerPhone") | |||||
| private String ownerPhone; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "持有者昵称", name = "ownerNickName") | |||||
| private String ownerNickName; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "EnumCouponOrderStatus", name = "couponOrderStatus") | |||||
| private Integer couponOrderStatus; | |||||
| @TableField(exist = false) | |||||
| private List<Integer> couponOrderStatusList; | |||||
| } | |||||
| @@ -0,0 +1,13 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.AiOrder; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | |||||
| public interface AiOrderMapper extends CommonMapper<AiOrder, Long> { | |||||
| AiOrder selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| List<AiOrder> findList(AiOrder wxCouponOrder); | |||||
| } | |||||
| @@ -0,0 +1,35 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.AiOrder; | |||||
| import java.util.List; | |||||
| public interface AiOrderService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<AiOrder> listAsPage(AiOrder record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| AiOrder getById(Long id,String tenantId); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(AiOrder record); | |||||
| } | |||||
| @@ -0,0 +1,44 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.AiOrder; | |||||
| import com.iformall.mapper.AiOrderMapper; | |||||
| import com.iformall.service.AiOrderService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| @Service | |||||
| public class AiOrderServiceImpl implements AiOrderService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| AiOrderMapper aiOrderMapper; | |||||
| @Override | |||||
| public PageInfo<AiOrder> listAsPage(AiOrder record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> aiOrderMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public AiOrder getById(Long id,String tenantId) { | |||||
| return aiOrderMapper.selectById(id,tenantId); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(AiOrder record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| aiOrderMapper.insert(record); | |||||
| } else { | |||||
| aiOrderMapper.updateById(record); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,110 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.AiOrderMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.AiOrder"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
| <result column="order_id" jdbcType="BIGINT" property="orderId" /> | |||||
| <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" /> | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||||
| <result column="coupon_type" jdbcType="INTEGER" property="couponType" /> | |||||
| <result column="coupon_title" jdbcType="VARCHAR" property="couponTitle" /> | |||||
| <result column="coupon_sale_price" jdbcType="INTEGER" property="couponSalePrice" /> | |||||
| <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" /> | |||||
| <result column="coupon_subsidy" jdbcType="INTEGER" property="couponSubsidy" /> | |||||
| <result column="b_user_id" jdbcType="BIGINT" property="bUserId" /> | |||||
| <result column="b_user_phone" jdbcType="VARCHAR" property="bUserPhone" /> | |||||
| <result column="b_merchant_id" jdbcType="BIGINT" property="bMerchantId" /> | |||||
| <result column="b_merchant_name" jdbcType="VARCHAR" property="bMerchantName" /> | |||||
| <result column="brand_id" jdbcType="BIGINT" property="brandId" /> | |||||
| <result column="brand_name" jdbcType="VARCHAR" property="brandName" /> | |||||
| <result column="bussiness" jdbcType="BIGINT" property="bussiness" /> | |||||
| <result column="bussiness_name" jdbcType="VARCHAR" property="bussinessName" /> | |||||
| <result column="shop_number" jdbcType="VARCHAR" property="shopNumber" /> | |||||
| <result column="send_merchant_id" jdbcType="INTEGER" property="sendMerchantId" /> | |||||
| <result column="send_merchant_name" jdbcType="VARCHAR" property="sendMerchantName" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| <result column="verify_time" jdbcType="TIMESTAMP" property="verifyTime" /> | |||||
| <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" /> | |||||
| <result column="owner_id" jdbcType="BIGINT" property="ownerId" /> | |||||
| <result column="owner_phone" jdbcType="VARCHAR" property="ownerPhone" /> | |||||
| <result column="owner_nick_name" jdbcType="VARCHAR" property="ownerNickName" /> | |||||
| <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`order_id`,`coupon_order_id`,`coupon_id`,`coupon_type`,`coupon_title`,`coupon_sale_price`, | |||||
| `coupon_price`,`coupon_subsidy`,`b_user_id`,`b_user_phone`,`b_merchant_id`,`b_merchant_name`,`brand_id`,`brand_name`,`bussiness`, | |||||
| `bussiness_name`,`shop_number`,`send_merchant_id`,`send_merchant_name`,`create_date`,`update_date`,`verify_time`,`expired_time`, | |||||
| `owner_id`,`owner_phone`,`owner_nick_name`,`coupon_order_status` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where `tenant_id` = #{tenantId} | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != couponType "> | |||||
| and `coupon_type` = #{couponType} | |||||
| </if> | |||||
| <if test=" null != ownerId "> | |||||
| and `owner_id` = #{ownerId} | |||||
| </if> | |||||
| <if test=" null != bUserId "> | |||||
| and `b_user_id` = #{bUserId} | |||||
| </if> | |||||
| <if test=" null != bMerchantId "> | |||||
| and `b_merchant_id` = #{bMerchantId} | |||||
| </if> | |||||
| <if test=" null != orderId "> | |||||
| and `order_id` = #{orderId} | |||||
| </if> | |||||
| <if test=" null != couponOrderStatus "> | |||||
| and `coupon_order_status` = #{couponOrderStatus} | |||||
| </if> | |||||
| <if test=" null != sendMerchantId "> | |||||
| and `send_merchant_id` = #{sendMerchantId} | |||||
| </if> | |||||
| <if test=" null != couponOrderStatusList "> | |||||
| and coupon_order_status in | |||||
| <foreach collection="couponOrderStatusList" index="index" item="cosidItem" open="(" separator="," close=")"> | |||||
| #{cosidItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from ai_order where id = #{id} and tenant_id=#{tenantId} | |||||
| </select> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.AiOrder" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from ai_order | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||